A_RemoveChildren does not work in PickUp states?

Mon Feb 21, 2022 12:43 pm

Hello people, i've had this problem now fomr some time, and i simply cannot understand it.

I have an actor which is a custom inventory orb that grants you a random weapon, and when it spawns, it summons this special flare effect:

Code:
TNT1 A 0 NoDelay A_SpawnItemEx("WeaponPickupFlare", 4, 0, 20, 0, 0, 0, 0, SXF_SETMASTER)


Now, during it's pickup state, this function is called, yet NOTHING happens:

Code:
TNT1 A 0 A_RemoveChildren(True, RMVF_EVERYTHING)


I've tried SO much different things, and yet nothing really works, this bugs me, because if i put the above function during it's spawn loop, it works?? another weird thing is the fact that other functions such as A_SpawnItemEx also work during it's pickup state, so what's going on here?

Re: A_RemoveChildren does not work in PickUp states?

Mon Feb 21, 2022 2:50 pm

It's a matter of the pointer.
In the Spawn state of CustomInventory, the item itself is the pointer for various calls, so those effects are it's children.
However in the Pickup state, the player picking up the item is the pointer, which doesn't have any children to kill.

The best way to make those effects disappear without going into ZScript, would be to remove it from the effect's states.
I don't know if A_JumpIfHealthLower would work, but it might be worth checking out with the AAPTR_MASTER pointer.
Alternatively you could call A_CheckProximity to see if the effect is near the weapon pickup and remove it if not.

Re: A_RemoveChildren does not work in PickUp states?

Mon Feb 21, 2022 3:18 pm

Oh, that's a good idea! but how do you use return states with A_CheckProximity? I can't seem to do it, yet i can use action functions. Here's my attempt after a few tries:

Code:
   DTPW AAAAAAA 2 BRIGHT Light("WPNFLARE")
   {
         if (A_CheckProximity("StopExisting", "ShufflePlayer", 30))
       {
        A_SetScale(scalex - 0.005, scaley - 0.005);
        A_SpawnItemEx("WhiteLine", frandom(-28, 28), frandom(-21, 21), frandom(0, 7), 0, 0, random(2, 3), 0, 0, 60);
         }
         else {
        return A_Jump(256, "StopExisting"); //Using a direct return does not work also
         }
      }
   Loop


Edit: oh, i've done this, it seems to work except the whole return thing.

Code:
   DTPW AAAAAAA 2 BRIGHT Light("WPNFLARE")
   {
         if (A_CheckProximity("StopExisting", "ShufflePlayer", 30))
       {
        A_Jump(256, "StopExisting");
        A_SpawnItemEx("BFGBall"); //This works, yet the one above it does not?
         }
         else {
        A_SetScale(scalex + 0.005, scaley + 0.005);
        A_SpawnItemEx("WhiteLine", frandom(-28, 28), frandom(-21, 21), frandom(0, 7), 0, 0, random(2, 3), 0, 0, 60);
         }
      } //After this action frame there is another one where the glow gets smaller, just as a note

Re: A_RemoveChildren does not work in PickUp states?

Mon Feb 21, 2022 3:45 pm

Maybe try this?
Code:
   {
         if (A_CheckProximity("StopExisting", "ShufflePlayer", 30))
       {
        A_SpawnItemEx("BFGBall");
        Return state("StopExisting");
         }
         else {
        A_SetScale(scalex + 0.005, scaley + 0.005);
        A_SpawnItemEx("WhiteLine", frandom(-28, 28), frandom(-21, 21), frandom(0, 7), 0, 0, random(2, 3), 0, 0, 60);
        Return state("");
         }
      } //After this action frame there is another one where the glow gets smaller, just as a note  

Code untested.

Re: A_RemoveChildren does not work in PickUp states?

Mon Feb 21, 2022 4:21 pm

Code:
 A_SpawnItemEx("BFGBall");
this was just a debugging action, didn't need to leave it there hahaha

I'm not sure what you did differently in regardings to the return state, but yes, it works perfectly.

It's kinda hacky and i regret again not making this entry as ZScript, but thank you as always Jarewill!! :D