help

redhot69

amongus
i want my char to damage enemies with player.mo.state roll but i cant
addHook("PlayerThink", function(player)
if player.mo.skin == "movieknux"
and player.cmd.buttons == BT_CUSTOM1 then
player.mo.state = S_PLAY_ROLL
P_InstaThrust(player.mo,player.mo.angle,4*FRACUNIT)
end
end)
 
also how can i put a cooldown
Out of curiosity, what are you trying to do exactly? And in what situations do you want this cooldown to kick in?

I ask this because this, using the previous answer as basis, effectively works like a pseudo-cooldown:
Example (slightly altered code for my convenience):
local function DmgRoll(player) --Named it loosely from what I've assumed the code is trying to do.
    if player.mo.skin == "movieknux"
    and (player.cmd.buttons & BT_CUSTOM1)
    and not (player.pflags & PF_SPINNING) then --Having the check here makes it so you cannot do it again until the PF_SPINNING flags are removed from the player.
        player.mo.state = S_PLAY_ROLL
        player.pflags = $|PF_SPINNING
        P_InstaThrust(player.mo, player.mo.angle, 4*FRACUNIT)
    end
end
addHook("PlayerThink", DmgRoll)
Admittedly it is not pretty, it's more of a temporary solution than anything but it can be built on top of rather easily for further control logic so you can tweak it to your liking.

If what you want is an honest to god "x-amount-of-time cooldown", you'd have to go about it by creating variables to hold and control the minimum and maximum cooldown values, interval, etc. and then making the check, using those values, to allow the player to perform the desired action. It's more intricate to work with than the alternative but depending on what you want is potentially better also.
 
Out of curiosity, what are you trying to do exactly? And in what situations do you want this cooldown to kick in?

I ask this because this, using the previous answer as basis, effectively works like a pseudo-cooldown:
Example (slightly altered code for my convenience):
local function DmgRoll(player) --Named it loosely from what I've assumed the code is trying to do.
    if player.mo.skin == "movieknux"
    and (player.cmd.buttons & BT_CUSTOM1)
    and not (player.pflags & PF_SPINNING) then --Having the check here makes it so you cannot do it again until the PF_SPINNING flags are removed from the player.
        player.mo.state = S_PLAY_ROLL
        player.pflags = $|PF_SPINNING
        P_InstaThrust(player.mo, player.mo.angle, 4*FRACUNIT)
    end
end
addHook("PlayerThink", DmgRoll)
Admittedly it is not pretty, it's more of a temporary solution than anything but it can be built on top of rather easily for further control logic so you can tweak it to your liking.

If what you want is an honest to god "x-amount-of-time cooldown", you'd have to go about it by creating variables to hold and control the minimum and maximum cooldown values, interval, etc. and then making the check, using those values, to allow the player to perform the desired action. It's more intricate to work with than the alternative but depending on what you want is potentially better also.
a punch with cooldown
 

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

Back
Top