scoreboard players set @s spell_cost_current 750
scoreboard players operation @s spell_cost_current /= @s mana_efficiency
execute if score @s magus_mana_bar < @s spell_cost_current run function kiwi2:upgrades/classes/magus/spells/not_enough_mana_warning

execute unless score @s magus_mana_bar < @s spell_cost_current at @e[type=armor_stand,tag=player_magus_implode_shadow,limit=1,sort=nearest] run summon armor_stand ~ ~ ~ {Tags:["player_magus_implode_marker","player_magus_implode_marker_init"],Marker:1b,Invisible:1b,Invulnerable:1b,NoGravity:1b}
execute unless score @s magus_mana_bar < @s spell_cost_current as @e[type=armor_stand,tag=player_magus_implode_marker_init,limit=1,sort=nearest] run scoreboard players add @s magus_implode_timer 60
execute unless score @s magus_mana_bar < @s spell_cost_current as @e[type=armor_stand,tag=player_magus_implode_marker_init,limit=1,sort=nearest] run tag @s remove player_magus_implode_marker_init
execute unless score @s magus_mana_bar < @s spell_cost_current run schedule function kiwi2:upgrades/classes/magus/spells/tier_4/implode/implode_fx 1t

execute unless score @s magus_mana_bar < @s spell_cost_current run playsound minecraft:block.trial_spawner.spawn_item master @a[distance=..12] ~ ~ ~ 1 1
execute unless score @s magus_mana_bar < @s spell_cost_current run scoreboard players operation @s magus_mana_bar -= @s spell_cost_current