Different Pickup-/Projectile-Sprites if global variable=1?

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
Locked
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Different Pickup-/Projectile-Sprites if global variable=1?

Post by Tormentor667 »

Is it possible to change a pickups sprite depending on a global variable's value?
And, is it possible to change a weapons projectile depending on the global variable's value?

*EDIT*
Trying to be more specific what I want to do: I have two hand grenades, one for the regular missions, one for the Astrostein mission:
Spoiler: Grenade
Spoiler: Astrostein Grenade
Instead of using them from the regular item box, you can insta-use them with a key binding defined in the MENUDEF
Spoiler: MENUDEF
This works perfect for tge regular Grenade but what can I do if I want the Astrostein grenade to be thrown with the same key? It's actually the same kind of powerup, only with a different look.
User avatar
kodi
 
 
Posts: 1361
Joined: Mon May 06, 2013 8:02 am

Re: Different Pickup-/Projectile-Sprites if global variable=

Post by kodi »

Should be as simple as a A_jumpif(CallAcs("MyScript"), "MyDesiredstate") in the grenades spawn state. Where MyDesiredState is an alternate spawn state in this case, and MySript does something like..

Code: Select all

if(GlobalValue==true){
SetResultValue(true)
}
else{
SetResultValue(false)
}
..right? Unless I'm missing something.
User avatar
edward850
Posts: 5902
Joined: Tue Jul 19, 2005 9:06 pm
Location: New Zealand
Contact:

Re: Different Pickup-/Projectile-Sprites if global variable=

Post by edward850 »

Why even waste the stack?

Code: Select all

SetResultValue(GlobalValue); 
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: Different Pickup-/Projectile-Sprites if global variable=

Post by Tormentor667 »

Sorry, I dont get it :-/
User avatar
wildweasel
Posts: 21706
Joined: Tue Jul 15, 2003 7:33 pm
Preferred Pronouns: He/Him
Operating System Version (Optional): A lot of them
Graphics Processor: Not Listed
Contact:

Re: Different Pickup-/Projectile-Sprites if global variable=

Post by wildweasel »

Tormentor667 wrote:Sorry, I dont get it :-/
In that case, all you'd need to do is have some script set the globalvalue to 1 or 0. Then your weapon needs only call a script that sets its own result value to the globalvalue's value. No need for the If statement at all.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Different Pickup-/Projectile-Sprites if global variable=

Post by Ed the Bat »

Tormentor667 wrote:Sorry, I dont get it :-/
Let me just get to GitHub and make it happen for you.
User avatar
Tormentor667
Posts: 13556
Joined: Wed Jul 16, 2003 3:52 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia (Modern GZDoom)
Location: Germany
Contact:

Re: Different Pickup-/Projectile-Sprites if global variable=

Post by Tormentor667 »

@wildweasel - I understand the part with the global value but I have no idea how to implement that call decorate-wise. But...

@Ed - ...I guess this has already been resolved, so thanks to all for the hints and thanks to Ed for implementing it, I will take a closer look to at least understand what's going on :)
Locked

Return to “Editing (Archive)”