#problem with this

1 messages · Page 1 of 1 (latest)

desert vigil
#
options:
    heal-chance: 24
    heal-amount: 8
    dash-forward-force: 1.6
    dash-upward-force: 0.7
    dash-cooldown: 20 seconds

function isFrostedArmor(i: item) :: boolean:
    if {_i} is air:
        return false
    if name of {_i} is "&x&6&C&C&3&F&F&lꜰ&x&7&2&C&7&F&F&lʀ&x&7&7&C&B&F&E&lᴏ&x&7&D&C&F&F&E&lꜱ&x&8&2&D&3&F&D&lᴛ&x&8&8&D&7&F&D&lᴇ&x&8&E&D&B&F&C&lᴅ &x&9&3&D&F&F&C&lᴀ&x&9&9&E&3&F&B&lʀ&x&9&E&E&7&F&B&lᴍ&x&A&4&E&B&F&A&lᴏ&x&A&A&E&F&F&A&lʀ":
        return true
    return false

function hasFullFrostedArmor(p: player) :: boolean:
    set {_helmet} to helmet of {_p}
    set {_chest} to chestplate of {_p}
    set {_legs} to leggings of {_p}
    set {_boots} to boots of {_p}
    if isFrostedArmor({_helmet}) is true:
        if isFrostedArmor({_chest}) is true:
            if isFrostedArmor({_legs}) is true:
                if isFrostedArmor({_boots}) is true:
                    return true
    return false

on damage of living entity:
    victim is a player

    set {_player} to victim
    if hasFullFrostedArmor({_player}) is false:
        stop

    if health of {_player} > 6: # Only trigger if ≤3 hearts
        stop

    chance of {@heal-chance}%:
        set {_newhp} to health of {_player} + {@heal-amount}
        if {_newhp} > max health of {_player}:
            set {_newhp} to max health of {_player}
        set health of {_player} to {_newhp}
        play sound "block.glass.break" with volume 0.8 and pitch 1.4 at {_player}
        send action bar "&b❄ Your chest crystallizes with frozen hearts ❄" to {_player}

on sneak toggle:
    player is sneaking
    if hasFullFrostedArmor(player) is false:
        stop

    if {frostdash.last::%uuid of player%} is set:
        if difference between now and {frostdash.last::%uuid of player%} <= 0.4 seconds:

            if {frostdash.cooldown::%uuid of player%} is set:
                set {_timepassed} to difference between now and {frostdash.cooldown::%uuid of player%}
                if {_timepassed} < {@dash-cooldown}:
                    set {_remaining} to {@dash-cooldown} - {_timepassed}
                    send action bar "&c❄ Frost Dash ready in &f%rounded {_remaining}%s &c❄" to player
                    stop

            push player forwards with force {@dash-forward-force}
            push player upwards with force {@dash-upward-force}
            play sound "entity.player.attack.sweep" with volume 1 and pitch 1.2 at player
            send action bar "&b❄ Frost Dash ❄" to player
            set {frostdash.cooldown::%uuid of player%} to now

    set {frostdash.last::%uuid of player%} to now
#

For some reason the cooldown isn't working

granite nebula
#

Not sure, this has solved problems like this within the past but change the player is sneaking line to a if player is sneaking

#

ofc with a colon at the end

languid goblet
#

I was wondering why this code is wonky is a few areas.. then i realised its ai lol

#

Local vars are not useful here, if all could be used instead of 4 nested ifs

Also also nested ifs in the sneak toggle event as well

#

Use on damage of player:, and the local var is not needed here either

#

Would feel better if the % was in the option as well, as just defining yhe option as 24 doesnt tell us 24 out of what. Could be 24 percent, times out of 50 or a thousand. (Or it could be interpreted as frequency, 1 activation every 24 times)

I love how the code checks to make sure it doesnt give the player extra health and then immediately does just that on the next line
-# oops i assumed the line in the if was set {_player}’s health to max health of {_player}, but i now realise its adjusting the var

(use the min() function here—or just ignore this as im sure theres a built in cap anyways)

#

Why have 2 variables if you set them to the exact same thing? Just need one and then compare the time since with the cooldown option. Speaking of the options, why is there a 0.4 in there as well? You are checking THAT cooldown AS WELL AS the 20 second one

#

Also this is just wrong—skript uses 1 = 1 full heart, not 1 = 1 half heart

languid goblet
loud vine