⛧Labyrinthia⛧
Vampire scene rotgirl
So, I won't bother with the specific details but I made this silly script as a concept for something else I'm working on.
This should give you the Armageddon Shield (as long as you have no shields) if you pressed CUSTOM 1, at the cost of 5 rings. And then it should remove any shield you have if you pressed CUSTOM 1 again.
It works "fine", yes, but I'm running into 2 issues:
I'm guessing that the second one is because calling the shield doesn't also spawns the sprite for it, so I might have an idea or two to circumvent it but I don't know how to work with the first one. Is it possible to make a time window that pressing CUST1 won't activate the script? Or make it so that after the function is called once, it won't happen again until you release the key and press it again? Genuinely don't know what to do here.
Code:
local CANCHANGE = false
local CANREVERT = true
addHook("ThinkFrame", function()
for player in players.iterate do
if player.mo.skin == "sonic"
and player.mo.health >= 6
and player.powers[pw_shield] == SH_NONE
CANCHANGE = true
else
CANCHANGE = false
end
if player.mo.skin == "sonic"
and player.powers[pw_shield] != SH_NONE
CANREVERT = true
else
CANREVERT = false
end
if CANCHANGE == true
and (player.cmd.buttons & BT_CUSTOM1)
player.powers[pw_shield] = SH_BOMB
player.mo.health = player.mo.health - 5
player.health = $1 - 5
S_StartSound(nil, sfx_shield)
end
if CANREVERT == true
and (player.cmd.buttons & BT_CUSTOM1)
player.powers[pw_shield] = SH_NONE
S_StartSound(nil, sfx_shldls)
else
return
end
end
end)
This should give you the Armageddon Shield (as long as you have no shields) if you pressed CUSTOM 1, at the cost of 5 rings. And then it should remove any shield you have if you pressed CUSTOM 1 again.
It works "fine", yes, but I'm running into 2 issues:
- The game is calling the function way too much (every frame that CUSTOM1 is being held instead of only once per keypress, no matter how long it's held)
- The sprite for the shield simply doesn't appear even though it is there, as in, still protects me from a hit and explodes like it should.
I'm guessing that the second one is because calling the shield doesn't also spawns the sprite for it, so I might have an idea or two to circumvent it but I don't know how to work with the first one. Is it possible to make a time window that pressing CUST1 won't activate the script? Or make it so that after the function is called once, it won't happen again until you release the key and press it again? Genuinely don't know what to do here.