Help with a custom ability

Draco

Member
Alright, I had made a post for the mod I'm currently working on before but now I've run into another thing that I haven't been able to solve.
I'm trying to give Amy a hammer attack similar to her normal CA2_MELEE with a hammer jump but in the Custom 3 button instead of spin (due to my mod having all characters use the spindash as ther charability 2) and also in the same button give her an adaptation of her Frontiers Card Stomp and High Card Jump. I've been able to recreate the hammer attack with no problem (although it's a little janky and I could use some tips) but the thing that's a bigger headache is the Card Stomp and Jump. It kind of works but is really buggy and while testing the ability it just stops working out of nowhere and I can't seem to pinpoint why. If anyone could help out it would be a great help, I'm not that good at coding and just learning how to do things with the srb2 lua so forgive me if the code is redundant and confusing, it could be simplified a lot, I just don't know how yet.

local hammerkey = BT_CUSTOM3

local function hammerAttack(player)
if player.mo.skin ~= "amy" then return end

if not (player.hammer) then player.hammer = false end
if not (player.swingcount) then player.swingcount = 0 end
if not (player.attacktime) then player.attacktime = 0 end
if not (player.swingtime) then player.swingtime = 0 end

if (player.cmd.buttons & hammerkey)
player.swingcount = $ + 1
else
player.swingcount = 0
end

if player.swingcount == 1
player.hammer = true
end

if (player.hammer) == true
and player.attacktime < 1
player.attacktime = 1
end

if player.mo.skin == "amy" then
if not (player.cardstomp) then player.cardstomp = false end
if not (player.cardjump) then player.cardjump = false end
if not (player.cardtime) then player.cardtime = 0 end
if not (player.jumptime) then player.jumptime = 0 end
if not (player.stomped) then player.stomped = false end

if player.cardtime >= 1*TICRATE
player.cardtime = 0
end

if not P_IsObjectOnGround(player.mo)
and player.swingcount == 1
and player.jumptime == 0 then
player.cardstomp = true
end

if not P_PlayerInPain(player)
and player.powers[pw_carry] < 1
and not player.exiting
and not P_IsObjectInGoop(player.mo)
and player.playerstate == PST_LIVE
and not (player.pflags & PF_SLIDING)
and player.mo.state != S_PLAY_GASP
if (player.cardstomp == true)
if not P_IsObjectOnGround(player.mo)
and player.swingcount == 1
and (player.stomped == false)
P_SetObjectMomZ(player.mo,-40*FRACUNIT,false)
player.powers[pw_strong] = STR_MELEE
player.mo.state = S_PLAY_MELEE_LANDING
player.stomped = true
print("hyaa")
end
if player.mo.eflags & MFE_JUSTHITFLOOR
or P_IsObjectOnGround(player.mo)
and (player.stomped == true)
player.cardtime = $ + 1
print("ready?")
end

if player.cardtime <= 1*TICRATE
and player.cardtime > 0
and player.mo.eflags & MFE_JUSTHITFLOOR or P_IsObjectOnGround(player.mo)
and (player.stomped == true)
if player.cmd.buttons & BT_JUMP
P_SetObjectMomZ(player.mo,(15*player.jumpfactor),false)
player.pflags = $1|PF_JUMPED
player.mo.state = S_PLAY_JUMP
player.cardtime = 0
player.cardjump = true
player.stomped = false
player.cardstomp = false
print("jump")
end
elseif player.cardtime == 0
and player.mo.eflags & MFE_JUSTHITFLOOR or P_IsObjectOnGround(player.mo)
player.cardjump = false
player.stomped = false
end
end

if (player.cardjump == true)
player.jumptime = $ + 1
else
player.jumptime = 0
end

if player.jumptime >= 1*TICRATE
player.jumptime = 0
player.cardjump = false
end
end
end

if player.attacktime > 0
and player.attacktime <= 1*TICRATE/2
and P_IsObjectOnGround(player.mo)
and not (player.pflags & PF_SPINNING)
and not (player.pflags & PF_FULLSTASIS) then
player.mo.state = S_PLAY_MELEE
player.powers[pw_strong] = STR_TWINSPIN
if player.speed < (player.normalspeed - player.normalspeed/10)
or not P_IsObjectOnGround(player.mo)
and not player.cardjump == true
and not player.stomped == true
player.pflags = $1|PF_FULLSTASIS
end
if P_IsObjectOnGround(player.mo)
and player.speed >= (player.normalspeed - player.normalspeed/10)
P_SetObjectMomZ(player.mo, (13*player.jumpfactor), false)
end
player.attacktime = $ + 1
end

if player.attacktime > 0 then
player.swingtime = $ + 1
end

if player.swingtime >= 1*TICRATE/2
player.hammer = false
player.attacktime = 0
player.swingtime = 0
player.pflags = $1 & ~PF_FULLSTASIS
end
end

addHook("PlayerThink", hammerAttack)
 

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top