[ZScript] Projectile PostBeginPlay bug

Forum rules
Please don't bump threads here if you have a problem - it will often be forgotten about if you do. Instead, make a new thread here.

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: [ZScript] Projectile PostBeginPlay bug

Re: [ZScript] Projectile PostBeginPlay bug

by Graf Zahl » Mon Dec 19, 2016 5:57 am

Careful: PostBeginPlay is "called before the thinker ticks for the first time". Read this sentence very carefully to understand your mistake. This does not say "is called before the actor does anything else". In your case the missile is exploded right in the spawning function, and that happens BEFORE it can tick for the first time.

[ZScript] Projectile PostBeginPlay bug

by Cherepoc » Mon Dec 19, 2016 5:53 am

PostBeginPlay is expected to be executed before any of actor frame actions, right? But if you stand in front of a wall and fire a projectile, then the code in it's first death frame action is executed before PostBeginPlay.
Use the code below. Start the game, change you weapon to plasmagun, run to nearby wall as close as you can, fire the projectile. You will see "Death" message appear before "PostBeginPlay".

Code: Select all

class BuggedPlasmaBall : PlasmaBall replaces PlasmaBall
{
	States
	{
	Death:
		TNT1 A 0 BugDeath;
		goto Super::Death;
	}
	
	override void PostBeginPlay()
	{
		A_Log("PostBeginPlay");
	}
	
	void BugDeath()
	{
		A_Log("Death");
	}
}

Top