[DECORATE] Making a non-repeating, click-spam melee weapon?

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
Nash
 
 
Posts: 17498
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

[DECORATE] Making a non-repeating, click-spam melee weapon?

Post by Nash »

I already know how to make weapons that do not repeat its fire animation if you hold down +attack, but how do I make it so that you can repeatedly click for the weapon to rapidly swing the weapon?
User avatar
Nash
 
 
Posts: 17498
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by Nash »

Le bump, I have no idea how to do this!
User avatar
comet1337
Posts: 876
Joined: Fri Sep 25, 2015 3:48 am
Location: elsewhere

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by comet1337 »

Code: Select all

+noautofire

fire:
    // attack animation and stuff goes here
    tnt1 aaaa 1 a_weaponready(wrf_noswitch) // more "a" 's means larger window to mash left click
    // raise back from attack goes here
    goto ready
try that
User avatar
Nash
 
 
Posts: 17498
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by Nash »

That almost works, but the problem with that is during the window,

1) The frame becomes invisible (or if replaced with "####", the frame just gets frozen in place) for however long the duration of the swinging animation is
2) It doesn't let me specify which state to jump to... I want the click spam to alternate between a left-swing and right-swing

Code: Select all

// Baseball Bat

Actor Z_Weapon_BaseballBat : Z_DefaultWeapon
{
    Weapon.AmmoUse 0
    +WEAPON.MELEEWEAPON
    +WEAPON.NOAUTOFIRE
    States
    {
        // select animation
        Ready:
            TNT1 A 0 A_GiveInventory("Z_PlayerFlagIsAttacking", 1)
            BAT1 A 1 Offset(-60, 75)
            BAT1 A 1 Offset(-50, 70)
            BAT1 A 1 Offset(-40, 65)
            BAT1 A 1 Offset(-30, 60)
            BAT1 A 1 Offset(-20, 55)
            BAT1 A 1 Offset(-10, 40)
            BAT1 A 1 Offset(0, 35)
            // fall through
        // idle animation
        Idle:
            TNT1 A 0 A_TakeInventory("Z_PlayerFlagIsAttacking", 1)
            BAT1 A 1 A_WeaponReady
            Loop

        Select:
            TNT1 A 1 A_Raise
            Loop

        // deselect animation
        Deselect:
            TNT1 A 0 A_GiveInventory("Z_PlayerFlagIsAttacking", 1)
            BAT1 A 1 Offset(0, 30)
            BAT1 A 1 Offset(0, 60)
            BAT1 A 1 Offset(0, 90)
            BAT1 A 1 Offset(0, 120)
            BAT1 A 1 Offset(0, 150)
            BAT1 A 1 Offset(0, 180)

        DeselectLoop:
            TNT1 A 1 A_Lower
            Loop

        // attack animation
        Fire:
            TNT1 A 0 Offset(0, 0) A_GiveInventory("Z_PlayerFlagIsAttacking", 1)
            TNT1 A 0 Offset(0, 0) ACS_NamedExecuteAlways("Script_BatWeaponAnimationR", 0)
            BAT1 A 1 Offset(4, -3)
            BAT1 A 1 Offset(11, -7)
            BAT1 A 1 Offset(18, -8)
            BAT1 A 1 Offset(27, -11)
            BAT1 A 1 Offset(35, -11)
            BAT1 A 1 Offset(46, -12)
            BAT1 A 1 Offset(53, -13)
            BAT1 A 1 Offset(63, -17)
            BAT1 A 1 Offset(71, -16)
            BAT1 A 1 Offset(84, -16)
            BAT1 A 1 Offset(95, -15)
            BAT1 B 1 Offset(95, 0) A_PlayWeaponSound("weapons/fistswing")
            BAT1 B 1 Offset(105, 0)
            BAT1 B 1 Offset(118, 2)
            BAT1 B 1 Offset(130, 4)
            BAT1 B 1 Offset(117, 3)
            BAT1 B 1 Offset(75, 7)
            BAT1 B 1 Offset(-27, 25)
            TNT1 A 0 Offset(0, 0) A_CustomPunch(2 * random(1, 10), TRUE, 0, "Z_FistPuff", 80)
            BAT1 B 1 Offset(-136, 56)
            "####" "####" 1 A_Refire("Fire2")
            BAT1 B 1 Offset(-170, 64)
            BAT1 B 1 Offset(-215, 75)
            BAT1 B 1 Offset(-255, 85)
            BAT1 B 1 Offset(-277, 89)
            BAT1 A 1 Offset(-277, 89)
            BAT1 A 1 Offset(-219, 68)
            BAT1 A 1 Offset(-127, 44)
            BAT1 A 1 Offset(-58, 16)
            BAT1 A 1 Offset(-15, 0)
            Goto Idle
        Fire2:
            TNT1 A 0 Offset(0, 0) A_GiveInventory("Z_PlayerFlagIsAttacking", 1)
            TNT1 A 0 Offset(0, 0) ACS_NamedExecuteAlways("Script_BatWeaponAnimationL", 0)
            BAT1 A 1 Offset(-4, -3)
            BAT1 A 1 Offset(-11, -7)
            BAT1 A 1 Offset(-18, -8)
            BAT1 A 1 Offset(-27, -11)
            BAT1 A 1 Offset(-35, -11)
            BAT1 A 1 Offset(-46, -12)
            BAT1 A 1 Offset(-53, -13)
            BAT1 A 1 Offset(-63, -17)
            BAT1 A 1 Offset(-71, -16)
            BAT1 A 1 Offset(-84, -16)
            BAT1 A 1 Offset(-95, -15)
            BAT1 C 1 Offset(-95, 0) A_PlayWeaponSound("weapons/fistswing")
            BAT1 C 1 Offset(-105, 0)
            BAT1 C 1 Offset(-118, 2)
            BAT1 C 1 Offset(-130, 4)
            BAT1 C 1 Offset(-117, 3)
            BAT1 C 1 Offset(-75, 7)
            BAT1 C 1 Offset(27, 25)
            TNT1 A 0 Offset(0, 0) A_CustomPunch(2 * random(1, 10), TRUE, 0, "Z_FistPuff", 80)
            BAT1 C 1 Offset(136, 56)
            "####" "####" 0 A_Refire("Fire")
            BAT1 C 1 Offset(170, 64)
            BAT1 C 1 Offset(215, 75)
            BAT1 C 1 Offset(255, 85)
            BAT1 C 1 Offset(277, 89)
            BAT1 A 1 Offset(277, 89)
            BAT1 A 1 Offset(219, 68)
            BAT1 A 1 Offset(127, 44)
            BAT1 A 1 Offset(58, 16)
            BAT1 A 1 Offset(15, 0)
            Goto Idle
    }
}
User avatar
comet1337
Posts: 876
Joined: Fri Sep 25, 2015 3:48 am
Location: elsewhere

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by comet1337 »

well, this SHOULD be functional, but the animations are going to look like arse
you can re-swing at the same rate as when it used a_refire

Code: Select all

actor meleecycler : inventory {inventory.maxamount 2}

            // attack animation
            Fire:
                tnt1 a 0 a_jumpifinventory("meleecycler", 2, "fire2") // after first swing
                tnt1 a 0 a_jumpifinventory("meleecycler", 1, "fire1") // after second swing
            fire1:
                tnt1 a 0 a_giveinventory("meleecycler", 2)
                BAT1 A 1 Offset(4, -3)
                BAT1 A 1 Offset(11, -7)
                BAT1 A 1 Offset(18, -8)
                BAT1 A 1 Offset(27, -11)
                BAT1 A 1 Offset(35, -11)
                BAT1 A 1 Offset(46, -12)
                BAT1 A 1 Offset(53, -13)
                BAT1 A 1 Offset(63, -17)
                BAT1 A 1 Offset(71, -16)
                BAT1 A 1 Offset(84, -16)
                BAT1 A 1 Offset(95, -15)
                BAT1 B 1 Offset(95, 0) A_PlayWeaponSound("weapons/fistswing")
                BAT1 B 1 Offset(105, 0)
                BAT1 B 1 Offset(118, 2)
                BAT1 B 1 Offset(130, 4)
                BAT1 B 1 Offset(117, 3)
                BAT1 B 1 Offset(75, 7)
                BAT1 B 1 Offset(-27, 25)
                TNT1 A 0 Offset(0, 0) A_CustomPunch(2 * random(1, 10), TRUE, 0, "bulletpuff", 80)
                BAT1 B 1 Offset(-136, 56)
                BAT1 B 1 Offset(-170, 64)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 B 1 Offset(-215, 75)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 B 1 Offset(-255, 85)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 B 1 Offset(-277, 89)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(-277, 89)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(-219, 68)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(-127, 44)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(-58, 16)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(-15, 0)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                tnt1 a 0 a_takeinventory("meleecycler")
                Goto Idle
            Fire2:
                tnt1 a 0 a_jumpifinventory("meleecycler", 2, 3) // alternate between 1 and 2
                tnt1 a 0 a_giveinventory("meleecycler", 1)
                tnt1 a 0 a_jump(256, 2)
                tnt1 a 0 a_takeinventory("meleecycler", 1)
                BAT1 A 1 Offset(-4, -3)
                BAT1 A 1 Offset(-11, -7)
                BAT1 A 1 Offset(-18, -8)
                BAT1 A 1 Offset(-27, -11)
                BAT1 A 1 Offset(-35, -11)
                BAT1 A 1 Offset(-46, -12)
                BAT1 A 1 Offset(-53, -13)
                BAT1 A 1 Offset(-63, -17)
                BAT1 A 1 Offset(-71, -16)
                BAT1 A 1 Offset(-84, -16)
                BAT1 A 1 Offset(-95, -15)
                BAT1 C 1 Offset(-95, 0) A_PlayWeaponSound("weapons/fistswing")
                BAT1 C 1 Offset(-105, 0)
                BAT1 C 1 Offset(-118, 2)
                BAT1 C 1 Offset(-130, 4)
                BAT1 C 1 Offset(-117, 3)
                BAT1 C 1 Offset(-75, 7)
                BAT1 C 1 Offset(27, 25)
                TNT1 A 0 Offset(0, 0) A_CustomPunch(2 * random(1, 10), TRUE, 0, "bulletpuff", 80)
                BAT1 C 1 Offset(136, 56)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 C 1 Offset(170, 64)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 C 1 Offset(215, 75)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 C 1 Offset(255, 85)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 C 1 Offset(277, 89)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(277, 89)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(219, 68)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(127, 44)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(58, 16)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                BAT1 A 1 Offset(15, 0)
                tnt1 a 0 a_weaponready(wrf_noswitch)
                tnt1 a 0 a_takeinventory("meleecycler")
                Goto Idle
        }
    }
 
also a_weaponready and offsets don't get a long if they are on the same frame

Code: Select all

//offsets break:
BAT1 B 1 Offset(-170, 64) A_WeaponReady

//offsets don't break:
tnt1 a 0 A_WeaponReady
BAT1 B 1 Offset(-170, 64)

User avatar
Greyfalll
Posts: 15
Joined: Sat Aug 30, 2014 11:44 pm
Location: Pokke Village

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by Greyfalll »

using A_WeaponReady(WRF_NOSWITCH|WRF_NOBOB) on the same frame as Offset() should work though.
Gez
 
 
Posts: 17946
Joined: Fri Jul 06, 2007 3:22 pm

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by Gez »

You shouldn't use TNT1 A for 0 length states in weapons, it screws up when using sv_fastweapons.
Last edited by Gez on Sun Oct 18, 2015 3:44 am, edited 2 times in total.
User avatar
Nash
 
 
Posts: 17498
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by Nash »

Thanks for all the advice, although at this point sv_fastweapon support is pretty much completely broken because of how I am using states to define custom select/deselect animation... moreover, the weapon swing animation is already operating at 1 tic per frame so it won't make any difference. :S

Anyway, here's what I ended up with. Thanks again for all your help, guys. Man, DECORATE scripting can get ugly very fast...

Code: Select all

// Constants shared by all weapons

// Melee swing direction
const int SwingRight = 0;
const int SwingLeft = 1;

Actor Z_Weapon_SwingDirection : Inventory
{
    Inventory.MaxAmount 1
}

//===========================================================================
//
// BASEBALL BAT
//
//===========================================================================

// how many tics required for charge attack
const int BaseballBat_Charge_Max = 10;

Actor Z_Weapon_BaseballBat : Z_Weapon
{
    Weapon.AmmoUse 0
    +WEAPON.MELEEWEAPON
    +WEAPON.NOAUTOFIRE
    States
    {
        // select animation
        Ready:
            TNT1 A 0 A_GiveInventory("Z_PlayerFlag_IsAttacking", 1)
            BAT1 A 1 Offset(-60, 75)
            BAT1 A 1 Offset(-50, 70)
            BAT1 A 1 Offset(-40, 65)
            BAT1 A 1 Offset(-30, 60)
            BAT1 A 1 Offset(-20, 55)
            BAT1 A 1 Offset(-10, 40)
            BAT1 A 1 Offset(0, 35)
            // fall through
        // idle animation
        Idle:
            TNT1 A 0 A_TakeInventory("Z_PlayerFlag_IsAttacking", 1)
            BAT1 A 1 A_WeaponReady
            Loop

        Select:
            BAT1 A 1 A_Raise
            Loop

        // deselect animation
        Deselect:
            TNT1 A 0 A_GiveInventory("Z_PlayerFlag_IsAttacking", 1)
            BAT1 A 1 Offset(0, 30)
            BAT1 A 1 Offset(0, 60)
            BAT1 A 1 Offset(0, 90)
            BAT1 A 1 Offset(0, 120)
            BAT1 A 1 Offset(0, 150)
            BAT1 A 1 Offset(0, 180)

        DeselectLoop:
            BAT1 A 1 A_Lower
            Loop

        // attack
        Fire:
            BAT1 A 1 A_WeaponReady
            TNT1 A 0 A_Refire("ChargeAttack")
            TNT1 A 0 A_JumpIfInventory("Z_Weapon_SwingDirection", SwingLeft, "SwingLeft")
            Goto SwingRight

        // charge power attack counter
        ChargeAttack:
            TNT1 A 0 A_JumpIfInventory("Z_Weapon_Charge", BaseballBat_Charge_Max, "PowerAttack")
            TNT1 A 0 A_GiveInventory("Z_Weapon_Charge", 1)
            Goto Fire

        // swing right
        SwingRight:
            TNT1 A 0 Offset(0, 0) A_TakeInventory("Z_Weapon_Charge", BaseballBat_Charge_Max)
            TNT1 A 0 Offset(0, 0) A_GiveInventory("Z_PlayerFlag_IsAttacking", 1)
            TNT1 A 0 Offset(0, 0) ACS_NamedExecuteAlways("Script_WeaponAnimationSwingR", 0)
            BAT1 A 1 Offset(4, -3)
            BAT1 A 1 Offset(11, -7)
            BAT1 A 1 Offset(18, -8)
            BAT1 A 1 Offset(27, -11)
            BAT1 A 1 Offset(35, -11)
            BAT1 A 1 Offset(46, -12)
            BAT1 A 1 Offset(53, -13)
            BAT1 A 1 Offset(63, -17)
            BAT1 A 1 Offset(71, -16)
            BAT1 A 1 Offset(84, -16)
            BAT1 A 1 Offset(95, -15)
            BAT1 B 1 Offset(95, 0) A_PlayWeaponSound("weapons/fistswing")
            BAT1 B 1 Offset(105, 0)
            BAT1 B 1 Offset(118, 2)
            BAT1 B 1 Offset(130, 4)
            BAT1 B 1 Offset(117, 3)
            BAT1 B 1 Offset(75, 7)
            BAT1 B 1 Offset(-27, 25)
            TNT1 A 0 Offset(0, 0) A_CustomPunch(2 * random(1, 10), TRUE, 0, "Z_FistPuff", 80)
            TNT1 A 0 Offset(0, 0) A_GiveInventory("Z_Weapon_SwingDirection", 1)
            BAT1 B 1 Offset(-136, 56) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 B 1 Offset(-170, 64) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 B 1 Offset(-215, 75) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 B 1 Offset(-255, 85) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 B 1 Offset(-277, 89) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 A 1 Offset(-277, 89)
            BAT1 A 1 Offset(-219, 68)
            BAT1 A 1 Offset(-127, 44)
            BAT1 A 1 Offset(-58, 16)
            BAT1 A 1 Offset(-15, 0)
            TNT1 A 0 Offset(0, 0) A_TakeInventory("Z_Weapon_SwingDirection", 1)
            Goto Idle

        // swing left
        SwingLeft:
            TNT1 A 0 Offset(0, 0) A_TakeInventory("Z_Weapon_Charge", BaseballBat_Charge_Max)
            TNT1 A 0 Offset(0, 0) A_GiveInventory("Z_PlayerFlag_IsAttacking", 1)
            TNT1 A 0 Offset(0, 0) ACS_NamedExecuteAlways("Script_WeaponAnimationSwingL", 0)
            BAT1 A 1 Offset(-4, -3)
            BAT1 A 1 Offset(-11, -7)
            BAT1 A 1 Offset(-18, -8)
            BAT1 A 1 Offset(-27, -11)
            BAT1 A 1 Offset(-35, -11)
            BAT1 A 1 Offset(-46, -12)
            BAT1 A 1 Offset(-53, -13)
            BAT1 A 1 Offset(-63, -17)
            BAT1 A 1 Offset(-71, -16)
            BAT1 A 1 Offset(-84, -16)
            BAT1 A 1 Offset(-95, -15)
            BAT1 C 1 Offset(-95, 0) A_PlayWeaponSound("weapons/fistswing")
            BAT1 C 1 Offset(-105, 0)
            BAT1 C 1 Offset(-118, 2)
            BAT1 C 1 Offset(-130, 4)
            BAT1 C 1 Offset(-117, 3)
            BAT1 C 1 Offset(-75, 7)
            BAT1 C 1 Offset(27, 25)
            TNT1 A 0 Offset(0, 0) A_CustomPunch(2 * random(1, 10), TRUE, 0, "Z_FistPuff", 80)
            TNT1 A 0 Offset(0, 0) A_TakeInventory("Z_Weapon_SwingDirection", 1)
            BAT1 C 1 Offset(136, 56) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 C 1 Offset(170, 64) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 C 1 Offset(215, 75) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 C 1 Offset(255, 85) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 C 1 Offset(277, 89) A_WeaponReady(WRF_NOSWITCH | WRF_NOBOB)
            BAT1 A 1 Offset(277, 89)
            BAT1 A 1 Offset(219, 68)
            BAT1 A 1 Offset(127, 44)
            BAT1 A 1 Offset(58, 16)
            BAT1 A 1 Offset(15, 0)
            TNT1 A 0 Offset(0, 0) A_TakeInventory("Z_Weapon_SwingDirection", 1)
            Goto Idle

        PowerAttack:
            TNT1 A 0 Offset(0, 0) A_TakeInventory("Z_Weapon_Charge", BaseballBat_Charge_Max)
            TNT1 A 0 Offset(0, 0) A_GiveInventory("Z_PlayerFlag_IsAttacking", 1)
            TNT1 A 0 Offset(0, 0) ACS_NamedExecuteAlways("Script_WeaponAnimationPowerAttack1", 0)
            BAT1 B 100 A_Print("power attack activated!")
            goto Idle

        // push enemies away
        AltFire:
            TNT1 A 0 ACS_NamedExecuteAlways("Script_PushAttack")
            goto Idle
    }
}
 
User avatar
NeuralStunner
 
 
Posts: 12328
Joined: Tue Jul 21, 2009 12:04 pm
Preferred Pronouns: No Preference
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support
Location: capital N, capital S, no space
Contact:

Re: [DECORATE] Making a non-repeating, click-spam melee weap

Post by NeuralStunner »

Gez wrote:You shouldn't use TNT1 A for 0 length states in weapons, it screws up when using sv_fastweapons.
In my experience, my weapons tend to cause CTDs with sv_fastweapons. It doesn't seem to deal well with complex jumps and loops. I never worried a lot about it because hey, they're cheats (and pretty stupid ones at that).
Locked

Return to “Editing (Archive)”