Move BeginPlay() to Thinkers

Moderator: GZDoom Developers

Post Reply
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Move BeginPlay() to Thinkers

Post by Major Cooke »

Since ChangeStatNum can only be applied in BeginPlay, I think it would be logical to move the BeginPlay() function from inside of Actor to Thinker.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Move BeginPlay() to Thinkers

Post by Graf Zahl »

This cannot be done and is not needed. The main problem with actors is that they are not constructed by your own code but by an internal actor factory (i.e Actor.Spawn.) BeginPlay is merely a callback in there that allows you to perform some customization which under normal circumstances would happen in the constructor.

Unless you do not build your own thinker creation factory the place to change the statnum is your thinker's constructor.

If you want to change the statnum of a system created thinker, think again. Not a good idea!
User avatar
Major Cooke
Posts: 8175
Joined: Sun Jan 28, 2007 3:55 pm
Preferred Pronouns: He/Him
Location: QZDoom Maintenance Team

Re: Move BeginPlay() to Thinkers

Post by Major Cooke »

Graf Zahl wrote:This cannot be done and is not needed. The main problem with actors is that they are not constructed by your own code but by an internal actor factory (i.e Actor.Spawn.) BeginPlay is merely a callback in there that allows you to perform some customization which under normal circumstances would happen in the constructor.

Unless you do not build your own thinker creation factory the place to change the statnum is your thinker's constructor.
Oh, so you mean this?

Code: Select all

MyThinker t = new("MyThinker");
t.ChangeStatNum(STAT_USER);
That seems to work. Very well, I suppose I can just have a global class statically do that for me.
Graf Zahl wrote:If you want to change the statnum of a system created thinker, think again. Not a good idea!
You mean like ACS/Map thinkers? I have no intention of doing such a thing. I just meant for hand-made thinkers created via ZScript with the "new" function. And setting things like SFX actors onto a different statnum so actors that do a lot of stat searching can have their workloads minimized. Helps hugely with the changes I made with (i.e.) AEons of Death so gibs can stop lagging upon creation, because it gets a count of how many gibs are currently around and doesn't spawn anymore if there are too many. As you know, AEoD can get clusterfucky with with so many special effects going on and actors that shouldn't be bothered searching for anything other than gibs, by gibs alone.

That's about as far as I go, just for the sake of optimizing gameplay and making it far more efficient.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49066
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Move BeginPlay() to Thinkers

Post by Graf Zahl »

Major Cooke wrote: That seems to work. Very well, I suppose I can just have a global class statically do that for me.
Well, what do you think how this works for actors? You'll never see them created with 'new'. Instead there's a static function to spawn them - and it's this function that calls BeginPlay. If you create a thinker with new and then initialize it, it's your own code that performs the setup so no facility in the engine can call BeginPlay.
Post Reply

Return to “Closed Feature Suggestions [GZDoom]”