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.

Reliable method in DECORATE for providing an offhand attack?

Postby SpeedStriker243 » Wed Feb 03, 2021 4:16 pm

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 allExpand view
  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
SpeedStriker243
 
Joined: 03 Feb 2021
Location: United Kingdom
Discord: SkylightDreams243#1457
Github ID: SpeedStriker243
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Reliable method in DECORATE for providing an offhand att

Postby Apeirogon » Sat Feb 13, 2021 1:28 pm

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.
User avatar
Apeirogon
I have a strange sense of humour
 
Joined: 12 Jun 2017

Re: Reliable method in DECORATE for providing an offhand att

Postby Jarewill » Sat Feb 13, 2021 1:38 pm

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.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Reliable method in DECORATE for providing an offhand att

Postby SpeedStriker243 » Sat Feb 13, 2021 3:44 pm

Huh, alright. I'll try and see what I can do.
User avatar
SpeedStriker243
 
Joined: 03 Feb 2021
Location: United Kingdom
Discord: SkylightDreams243#1457
Github ID: SpeedStriker243
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Reliable method in DECORATE for providing an offhand att

Postby SpeedStriker243 » Sat Feb 13, 2021 4:06 pm

That worked really well, thanks so much!
User avatar
SpeedStriker243
 
Joined: 03 Feb 2021
Location: United Kingdom
Discord: SkylightDreams243#1457
Github ID: SpeedStriker243
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Reliable method in DECORATE for providing an offhand att

Postby SpeedStriker243 » Sun Feb 14, 2021 5:13 am

Another question though: how do I edit the properties of the attack? Does it inherit from the DECORATE weapon it's called from?
User avatar
SpeedStriker243
 
Joined: 03 Feb 2021
Location: United Kingdom
Discord: SkylightDreams243#1457
Github ID: SpeedStriker243
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Reliable method in DECORATE for providing an offhand att

Postby Jarewill » Sun Feb 14, 2021 8:55 am

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 allExpand view
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.
Jarewill
 
 
 
Joined: 21 Jul 2019

Re: Reliable method in DECORATE for providing an offhand att

Postby Player701 » Mon Feb 15, 2021 3:31 am

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
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support

Re: Reliable method in DECORATE for providing an offhand att

Postby Graf Zahl » Mon Feb 15, 2021 11:02 am

Class names as parameters are indeed resolved later. This is by design and won't change.
User avatar
Graf Zahl
Lead GZDoom+Raze Developer
Lead GZDoom+Raze Developer
 
Joined: 19 Jul 2003
Location: Germany

Re: Reliable method in DECORATE for providing an offhand att

Postby Player701 » Mon Feb 15, 2021 11:56 pm

Oh, good to know that. Thanks, Graf.
User avatar
Player701
 
 
 
Joined: 13 May 2009
Location: Russia
Discord: Player701#8214
Operating System: Windows 10/8.1/8/201x 64-bit
OS Test Version: No (Using Stable Public Version)
Graphics Processor: nVidia with Vulkan support


Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests