Scriptable weapon action?

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
Ty Halderman
... in rememberance ...
Posts: 282
Joined: Thu Jul 17, 2003 9:53 pm
Location: New Orleans LA
Contact:

Scriptable weapon action?

Post by Ty Halderman »

I'm pretty sure I know the answer to this, but is there any way to trigger a script when a weapon is fired? This is generic, such as let's say I put a weapon in slot 8, and I wanted to script what happened when it was fired vs. using DEH/BEX to specify "normal" code pointers.

Assuming I'm right and that isn't possible, I guess the best alternative would be to bind a key to the script as the "how to use this weapon key." But then I'd need to know which weapon the player was holding at the time, and I don't know of a way to query that--it's not a usual APROP sort of question, I don't think.

A cookie to whoever proves me wrong :wink:
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

You are right, it's not possible to execute a script in a code pointer (because that's what you want) But you can check which weapon the player is using with the CheckWeapon(weaponname) function.
User avatar
Enjay
 
 
Posts: 27186
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland
Contact:

Post by Enjay »

If it was a weapon that fired a projectile that Zdoom can use for Thingcount, you could have a thing count script running, then as soon as your projectile appeared, you could do stuff.
User avatar
Chris
Posts: 2979
Joined: Thu Jul 17, 2003 12:07 am
Graphics Processor: ATI/AMD with Vulkan/Metal Support

Post by Chris »

Hmm... sacrificing one monster or Doom object, say the Candle, and whenever it appeared in a level, a script that loops every tic would spawn a projectile for ever count that it's there. The candle would then self-destruct and be gone in the next tic.

Only question now, is how to spawn it at the player(giving the players unique TIDs should work there), and having it fire at the same angle the player facing, both pitch and yaw..
User avatar
Ty Halderman
... in rememberance ...
Posts: 282
Joined: Thu Jul 17, 2003 9:53 pm
Location: New Orleans LA
Contact:

Post by Ty Halderman »

Graf Zahl wrote:...you can check which weapon the player is using with the CheckWeapon(weaponname) function.
Actually CheckWeapon() (the syntax you gave is for SetWeapon) but I didn't know it existed in the first place. Perfect.
Enjay wrote:If it was a weapon that fired a projectile that Zdoom can use for Thingcount...
I can do that. And I can make that projectile invisible, so it's only programatically that it even exists while being looked for.
Chris wrote:Only question now, is how to spawn it at the player(giving the players unique TIDs should work there), and having it fire at the same angle the player facing, both pitch and yaw..
For what I've got, I don't really need it to act like a weapon, more of a control device. I can use ACS trickery to make the effect what I want it to be, now that I'm in charge :twisted: .
  • Cookies for all!
    Image
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49252
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Post by Graf Zahl »

Ty Halderman wrote:
Graf Zahl wrote:...you can check which weapon the player is using with the CheckWeapon(weaponname) function.
Actually CheckWeapon() (the syntax you gave is for SetWeapon) but I didn't know it existed in the first place. Perfect.

From looking at the source CheckWeapon requires a weapon name as parameter and returns either 1 or 0 depending if the selected weapon is the one specified by name.
User avatar
Ty Halderman
... in rememberance ...
Posts: 282
Joined: Thu Jul 17, 2003 9:53 pm
Location: New Orleans LA
Contact:

Post by Ty Halderman »

Graf Zahl wrote:From looking at the source CheckWeapon requires a weapon name as parameter and returns either 1 or 0 depending if the selected weapon is the one specified by name.
Oops, right you are. I didn't notice the STACK(1) = 0 == strcmp... construct, just that STACK(1) was being set to something. Thanks.
Locked

Return to “Editing (Archive)”