[solved]keepDirection for next spaw after random spriteflip?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

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.

[solved]keepDirection for next spaw after random spriteflip?

Postby Lagi » Sun Nov 22, 2020 1:49 pm

i using spriteflip flag to flip corpse. some deaths type spawn additional pieces.
I would like to keep same direction of top flying torso, as the base [look at pic].


i know i can copy paste twice the set of XSplit (and name second XSplitMirror), but is there some cleaner way to code it?
Code: Select allExpand view

XSplit:      
TNT1 A 0 A_ChangeFlag("SPRITEFLIP", random(0,1))      
            GOLO G 6  A_Scream
            GOLO H 6 A_SpawnItemEx("TopTorso", -10, 10, 35, -3, 2, 4)
            GOLO IJ 6 
            GOLO K 6 A_NoBlocking
            GOLO LM 5
            GOLO N -1
            Stop

Code: Select allExpand view
ACTOR TopTorso   : golemarm
{
      Radius 14
      Height 14
      GRAVITY 0.3
      
   States
      {
      Spawn:
TNT1 A 0 A_ChangeFlag("SPRITEFLIP", random(0,1))   

      MUMB iiijkl 5
      MUMB mmnno 5 A_CheckFloor("Hit")
      Goto Spawn+9
      Hit:
      MUMB P -1
      stop
      }   
}
Last edited by Lagi on Mon Nov 23, 2020 6:15 am, edited 1 time in total.
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: How to keep direction for next spaw after random spritef

Postby Ac!d » Sun Nov 22, 2020 3:33 pm

Try to make a flag detector in the state XSplit, and another subclass of TopTorso with the flag +SPRITEFLIP on.

- If +SPRITEFLIP is TRUE, your flag detector will spawn the mirrored TopTorso.
- Else, if +SPRITEFLIP is FALSE, spawn the original TopTorso.

I don't know if it could work like this :
Code: Select allExpand view
TNT1 A 0
{
   If ( bSPRITEFLIP = False) { A_SpawnItemEx("TopTorso", -10, 10, 35, -3, 2, 4) ; }
   Else  { ... ; }
}
User avatar
Ac!d
Perfection is a way, not an end. - Korean Proverb
 
Joined: 02 Apr 2019
Location: France
Discord: Ac!d#2732

Re: How to keep direction for next spaw after random spritef

Postby Jarewill » Sun Nov 22, 2020 3:43 pm

I don't know about DECORATE, but with ZScript you could set a pointer to the TopTorso actor and change it's SPRITEFLIP flag according to the original actor:
In the original monster's code:
Code: Select allExpand view
GOLO H 6
{
    If(bSPRITEFLIP){A_SpawnItemEx("TopTorso", -10, 10, 35, -3, 2, 4, 0, SXF_SETTARGET);}
    Else{A_SpawnItemEx("TopTorso", -10, -10, 35, -3, -2, 4, 0, SXF_SETTARGET);} //So the velocity also gets changed

And in the TopTorso's spawn state:
Code: Select allExpand view
TNT1 A 0 {bSPRITEFLIP = target.bSPRITEFLIP;} 
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: How to keep direction for next spaw after random spritef

Postby Lagi » Sun Nov 22, 2020 4:38 pm

thanks guys,

Jarewill you right the velocity and spawnY also should be mirrored
User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence

Re: How to keep direction for next spaw after random spritef

Postby Lagi » Mon Nov 23, 2020 6:14 am

solved

Code: Select allExpand view
         XSplit:
            GOLO G 6  A_StartSound("mummy/death")
            TNT1 A 0 A_CheckFlag("SPRITEFLIP", "Mirror")
            
            TNT1 A 0 A_SpawnItemEx("TopTorso", -10, 10, 35, -3, 2, 4)
            TNT1 A 0 A_jump(256,2)
         Mirror:
            TNT1 A 0 A_SpawnItemEx("TopTorsoM", -10, -10, 35, -3, -2, 4)
            TNT1 A 0 A_SpawnItemEx("MummySoul2", 0, 0, 10, 0, 0, 1)
            GOLO HIJ 6 
            GOLO K 6 A_NoBlocking
            GOLO LM 5
            GOLO N -1
            Stop


Code: Select allExpand view
ACTOR TopTorso   : golemarm
   {
   Radius 14
   Height 14
   GRAVITY 0.3
   States
      {
         Spawn:
         GOLO OOOPQR 5
         GOLO SSTTU 5 A_CheckFloor("Hit")
         Goto Spawn+9
         
         Hit:
         GOLO V -1
         stop
   }   }

ACTOR TopTorsoM   : TopTorso { XScale -1.0 } //this one is bad for actors, they start drifting. instead +SPRITEFLIP


User avatar
Lagi
 
Joined: 23 Jun 2018
Location: Thou shalt alter thy beliefs with new evidence


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests