How to check which state the weapon is using?

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.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Cacodemon345
Posts: 419
Joined: Fri Dec 22, 2017 1:53 am
Graphics Processor: ATI/AMD (Modern GZDoom)
Contact:

How to check which state the weapon is using?

Post by Cacodemon345 »

I have no idea how to check which state the weapon is using. I want to check what state the weapon is using but I can't.

Is it possible?
User avatar
m8f
 
 
Posts: 1445
Joined: Fri Dec 29, 2017 4:15 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Manjaro Linux
Location: Siberia (UTC+7)
Contact:

Re: How to check which state the weapon is using?

Post by m8f »

This is possible with ZScript.
First way (easy, but not all states) - through PlayerInfo.WeaponState:

Code: Select all

    bool isReady = (player.WeaponState & WF_WEAPONREADY)
      || (player.WeaponState & WF_WEAPONREADYALT);

Code: Select all

    bool isDeselectable = player.WeaponState & WF_WEAPONSWITCHOK;
Other states can be found here (or in gzdoom.pk3).

Second way: through Actor.InStateSequence method.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49071
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: How to check which state the weapon is using?

Post by Graf Zahl »

Second way: Does not work for weapons. It checks the actor's states, i.e. the player.
Post Reply

Return to “Scripting”