Reliable method in DECORATE for providing an offhand attack?

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
User avatar
SpeedStriker243
Posts: 37
Joined: Wed Feb 03, 2021 3:50 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Location: United Kingdom
Contact:

Reliable method in DECORATE for providing an offhand attack?

Post by SpeedStriker243 »

Is there a way of providing an offhand attack in DECORATE that can be defined once and called to from any weapon?

Right now, all I have for a pseudo-offhand attacking ability is this:

Code: Select all

  Reload:
    TNT1 A 0 A_CheckFloor("KickEX")
    // code for ground attack
    Goto Ready
  KickEX:
    // code for aerial attack
    Goto Ready
and I'm having to copy and paste this across all weapon definitions, and when I want to update something, I have to do it in one weapon definition and then copy and paste to the others. The knockback of the attack is also inconsistent since each definition is just inheriting from the weapon that the Reload state is present in.

I could probably see if I could do it in ZScript, but then I'd have to rewrite everything which will take a while, so I'm not sure I want to do that yet...
User avatar
Apeirogon
Posts: 1606
Joined: Mon Jun 12, 2017 12:57 am

Re: Reliable method in DECORATE for providing an offhand att

Post by Apeirogon »

You could try custom inventory items (it able to draw sprites on screen in same way as weapon) and bind give "custom item name" to some key. But it would be kinda hacky, like most advanced stuff in created using Decorate.
I could probably see if I could do it in ZScript, but then I'd have to rewrite everything which will take a while, so I'm not sure I want to do that yet...
Not rewrite, just add ; at the end of the each line and put actor default variables in default{} block.
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Reliable method in DECORATE for providing an offhand att

Post by Jarewill »

Like Apeirogon said, using CustomInventory items are your best bet.
Here's an example "quick kick" item:
Spoiler:
It uses ZScript, but you can include both ZScript and DECORATE, so no need to rewrite everything.
User avatar
SpeedStriker243
Posts: 37
Joined: Wed Feb 03, 2021 3:50 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Location: United Kingdom
Contact:

Re: Reliable method in DECORATE for providing an offhand att

Post by SpeedStriker243 »

Huh, alright. I'll try and see what I can do.
User avatar
SpeedStriker243
Posts: 37
Joined: Wed Feb 03, 2021 3:50 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Location: United Kingdom
Contact:

Re: Reliable method in DECORATE for providing an offhand att

Post by SpeedStriker243 »

That worked really well, thanks so much!
User avatar
SpeedStriker243
Posts: 37
Joined: Wed Feb 03, 2021 3:50 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Location: United Kingdom
Contact:

Re: Reliable method in DECORATE for providing an offhand att

Post by SpeedStriker243 »

Another question though: how do I edit the properties of the attack? Does it inherit from the DECORATE weapon it's called from?
Jarewill
 
 
Posts: 1853
Joined: Sun Jul 21, 2019 8:54 am

Re: Reliable method in DECORATE for providing an offhand att

Post by Jarewill »

SpeedStriker243 wrote:Another question though: how do I edit the properties of the attack? Does it inherit from the DECORATE weapon it's called from?
For modifying damage: Just change variables in the A_CustomPunch function in QuickMelee state.
For modifying properties like kickback: You will have to make a new BulletPuff for that with the ProjectileKickBack property:

Code: Select all

Class NewBulletPuff : BulletPuff
{
    Default
    {
        ProjectileKickBack 500;
    }
}
Then use that BulletPuff in A_CustomPunch or whatever function was used.
ZScript is loaded before DECORATE, so I am not sure if DECORATE BulletPuff will work, just in case I posted an example in ZScript.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Reliable method in DECORATE for providing an offhand att

Post by Player701 »

Jarewill wrote:ZScript is loaded before DECORATE, so I am not sure if DECORATE BulletPuff will work, just in case I posted an example in ZScript.
It is not possible for a ZScript-based actor to inherit from a DECORATE-based one, but you can use class names from both everywhere - they seem to be resolved at a later stage of the compilation. No guarantees that it's not going to change, though...
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
Posts: 49231
Joined: Sat Jul 19, 2003 10:19 am
Location: Germany

Re: Reliable method in DECORATE for providing an offhand att

Post by Graf Zahl »

Class names as parameters are indeed resolved later. This is by design and won't change.
User avatar
Player701
 
 
Posts: 1710
Joined: Wed May 13, 2009 3:15 am
Graphics Processor: nVidia with Vulkan support
Contact:

Re: Reliable method in DECORATE for providing an offhand att

Post by Player701 »

Oh, good to know that. Thanks, Graf.
User avatar
SpeedStriker243
Posts: 37
Joined: Wed Feb 03, 2021 3:50 pm
Preferred Pronouns: He/Him
Graphics Processor: nVidia (Modern GZDoom)
Location: United Kingdom
Contact:

Re: Reliable method in DECORATE for providing an offhand att

Post by SpeedStriker243 »

Eh, that's not a problem for me. Thanks so much!
Post Reply

Return to “Scripting”