Grieferus Posted August 17, 2023 (edited) Let's get straight to the point: how do I make CVAR-dependant death state? To clarify: we have lamps. Normally, they just shine (Or don't shine), and you can't hit them. However, I want to make them destructible, when the appropriate CVAR is used. Edited August 18, 2023 by Grieferus 0 Quote Share this post Link to post
ramon.dexter Posted August 18, 2023 (edited) Okay, pretty simple. You can do it either in decorate or in zscript. Zscript: Death: TNT1 A 0 { if ( GetCvar("cvar_isshining") ) { return resolveState("Death_shine"); } else { return resolveState("Death_Normal"); } return resolveState(null); } Death_Shine: // stuff Death_Normal: // stuff Decorate: Death: TNT1 A 0 A_JumpIf(GetCvar("cvar_isshining"), "Death_shine") TNT1 A 0 A_JumpIf(!GetCvar("cvar_isshining"), "Death_Normal") //intentional fallthrough Death_Normal: // stuff Death_Shine: // stuff And a little clarification, if ( GetCvar("cvar_isshining") ) means GetCvar("cvar_isshining") equals true, while ( !GetCvar("cvar_isshining") ) means GetCvar("cvar_isshining") equals false. Edited August 18, 2023 by ramon.dexter 0 Quote Share this post Link to post
Grieferus Posted August 19, 2023 Death: TNT1 A 0 A_JumpIf(CallACS("environmenttoggle")==0, "Death_shine") TNT1 A 0 A_JumpIf(CallACS("environmenttoggle")==1, "Death_Normal") //don't really know what goto should be here Death_Normal: LAMP AB 2 A_PlaySound("glassbreak") TNT1 AAAA 0 A_SpawnItemEx("GlassPiece",random(-2,2),random(-2,2),random(47,49),random(4,8),0,random(5,10),random(0,360),0,80) LAMP B 1 LAMP B -1 Stop Death_Shine: Goto Spawn If I got this right. 0 Quote Share this post Link to post
ramon.dexter Posted August 19, 2023 You can directly read cvars in decorate with function GetCvar(), no need to call acs here. 0 Quote Share this post Link to post
Grieferus Posted August 19, 2023 Got it! Now that I'm thinking, I could do this with other decorations. The problem is... Well, they're randomized (Although, it's optional), so it seems that the only viable option is to make a separate actor for each randomized decoration (To prevent, for example, skulls appearing from a stick with only a head). 0 Quote Share this post Link to post
Xaser Posted August 19, 2023 Just a heads-up, you'll only want to use the DECORATE version if you're targeting Zandronum, ACE Engine, or some other non-gzdoom port. For GZDoom itself, go with ZScript so you don't lock yourself out of the power of the language for when you'll inevitably need it. 0 Quote Share this post Link to post
Grieferus Posted August 19, 2023 (edited) I'm using old version of GZDoom, which supports ZScript, but I don't know how different the syntax of its version of ZScript is from newer ones. Edited August 19, 2023 by Grieferus 0 Quote Share this post Link to post
Xaser Posted August 20, 2023 The basic syntax is the same in all versions, pretty much -- later versions add new features, functions, and whatnot, but the example posted uses some pretty basic stuff (GetCvar and ResolveState have been around for a long while). Give it a shot. 0 Quote Share this post Link to post
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.