BUMPSPECIAL + action 73 + ISMONSTER makes actor disappear?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
CaptainToenail
Posts: 3975
Joined: Fri Jul 06, 2007 9:16 am

BUMPSPECIAL + action 73 + ISMONSTER makes actor disappear?

Post by CaptainToenail »

Can someone explain to me why this actor will disappear after the player touches it three times when the ISMONSTER flag is present? Is there something I can do to prevent this?

The ISMONSTER flag is there so that the actors don't spawn when there's no room via A_SpawnItemEx.

Code: Select all

ACTOR Cactus1 10500
{
  Var float user_scale;
  Activation THINGSPEC_Switch

  Radius 8
  Height 64
  +SOLID
  +BUMPSPECIAL
  +ISMONSTER

  States
  {
  Spawn:
   CACN A 0 NoDelay A_ChangeFlag("SPRITEFLIP", random(0,1)) 
	CACN A 0 Thing_SetSpecial(0, 73, 1, 0, 0)
	CACN A 0 A_SetUserVarFloat("user_scale", FRandom(0.5,1.0)) 
	CACN A 0 A_SetScale (user_scale, user_scale)
	CACN A -1 
    Stop
  }
}
Thanks,
CT
Blue Shadow
Posts: 5046
Joined: Sun Nov 14, 2010 12:59 am

Re: BUMPSPECIAL + action 73 + ISMONSTER makes actor disappea

Post by Blue Shadow »

If the main idea is to get the special to execute without the actor changing its states (active/inactive), then you don't need the Activation THINGSPEC_Switch line. So you should remove it.

To explain why the actor, while flagged as a monster, disappears after being bumped into repeatedly:
  • When the actor is bumped into the first time, it is activated. Since the actor wasn't considered deactivated at the time of activation, no changes occur to it.
  • The second bump deactivates the actor. If the actor had the Inactive state, it would've entered that state. Since it lacks that state, the game instead freezes it by setting the current duration of the state it is in to -1 ("infinite" duration).
  • The third bump activates the actor. At the time of activation, the actor was deactivated, unlike the first bump. So the game unfreezes the actor by setting the current duration of the state it is in to 1 (1 tic). If it had the Active state, the actor would've entered that state instead of being unfrozen.
When the current duration of the state hits zero, the actor leaves the current state and attempts to enter the next. However, there isn't a state after CACN A -1, so the actor is removed from the game.
CaptainToenail
Posts: 3975
Joined: Fri Jul 06, 2007 9:16 am

Re: BUMPSPECIAL + action 73 + ISMONSTER makes actor disappea

Post by CaptainToenail »

Interesting. Thanks for taking a look at this Blue Shadow.
Post Reply

Return to “Scripting”