
execute as @s[tag=jce] at @s run execute as @e[r=30,tag=hitboxVictim] at @s run particle combat:bladejc ~~1.5~
execute as @s[tag=jce] at @s run execute as @e[r=30,tag=hitboxVictim] at @s run summon combat:weaponjc_fin
tag @s remove jce

scoreboard players add @s atkExchange 1
scoreboard players set @s[scores={atkExchange=3..}] atkExchange 1

#knockbackVictim->2
execute if entity @s[tag=applyKB] positioned ~~~ as @e[r=30,tag=hitboxVictim,tag=!iframes] run tag @s add KBframes

#victimHasParry->3
scoreboard players add @e[r=30,tag=hitboxVictim,scores={parry=1..8}] parry 6
scoreboard players add @e[r=30,tag=hitboxVictim,scores={parry=1..,has_skill=0}] emotionP 10

execute if entity @s positioned ~~~ as @e[tag=!clashParry,r=30,tag=hitboxVictim,scores={parry=1..}] run summon combat:parry

#clashParry->4
execute as @e[c=1,r=30,tag=hitboxVictim,scores={parry=1..,has_skill=1}] at @s run scoreboard players set @e[c=1,tag=attacker,scores={parry=..11}] parry 10

#victimHasBlock->5
execute if entity @s[tag=!guardBreak] positioned ~~~ as @e[r=30,tag=hitboxVictim,scores={block=1..,parry=0}] run summon combat:block

#punishVictimBlock->6
execute if entity @s[tag=guardBreak] positioned ~~~ as @e[r=30,tag=hitboxVictim,scores={block=1..,parry=0}] run summon combat:stagger

#gainEmP->7
execute as @e[r=30,tag=hitboxVictim,scores={block=0,parry=0}] at @s run scoreboard players add @e[c=1,tag=attacker] emotionP 3

#victimLoseEmP->8
execute as @s[tag=!empSafe] at @s run scoreboard players remove @e[tag=!iframes,r=30,tag=hitboxVictim,scores={block=0..,parry=0}] emotionP 5

#victimHasBlockLoseStamina->9
execute if entity @s[tag=!guardBreak] positioned ~~~ as @e[r=30,tag=hitboxVictim] run scoreboard players remove @s[scores={block=1..,parry=0}] stamina 15

#victimHasBlockLoseEmP->10
execute as @s[tag=!empSafe,tag=trait:unstoppable] at @s run scoreboard players remove @e[tag=!iframes,r=30,tag=hitboxVictim,scores={block=0..,parry=0}] emotionP 2

#victimHasBlockPunishStamina->11
execute if entity @s[tag=guardBreak,tag=!trait:unstoppable] positioned ~~~ as @e[r=30,tag=hitboxVictim] run scoreboard players set @s[scores={block=1..,parry=0}] stamina -100
execute if entity @s[tag=guardBreak,tag=trait:unstoppable] positioned ~~~ as @e[r=30,tag=hitboxVictim] run scoreboard players set @s[scores={block=1..,parry=0}] stamina -200

#ifVictimMeetFilterRefreshVictim->12
execute as @s[tag=!guardBreak] at @s run tag @e[r=30,scores={block=1..},tag=hitboxVictim] remove hitboxVictim
execute as @s at @s run tag @e[r=30,scores={parry=1..},tag=hitboxVictim] remove hitboxVictim

#grabSensor->13
execute as @e[r=30,tag=hitboxVictim,scores={parry=0}] at @s run scoreboard players set @e[c=1,tag=attacker,tag=grab:entityA] grab_sensor 1

tp @s[tag=grab:entityA,scores={kbHori=0,kbVerti=0}] @s

execute as @s[tag=guardBreak,tag=grab:entityA] at @s run tag @e[tag=!attacker,c=1,r=30,tag=hitboxVictim,scores={parry=0}] add grab:entityB
execute as @s[tag=!guardBreak,tag=grab:entityA] at @s run tag @e[tag=!attacker,c=1,r=30,tag=hitboxVictim,scores={block=0,parry=0}] add grab:entityB

execute as @s[tag=grab:entityA] at @s run execute as @e[tag=grab:entityB,c=1,tag=hitboxVictim] at @s if score @s grabID = @e[c=1,tag=grab:entityA] grabID run tp @e[c=1,tag=grab:entityB] ~~~

execute as @e[r=30,tag=hitboxVictim] at @s run scoreboard players set @e[c=1,tag=grab:entityB,tag=!grab:entityB] inGrab 1

event entity @s[tag=grab:entityA] rideable
scoreboard players random @s[tag=grab:entityA] grabID -10000 10000
scoreboard players operation @e[c=1,tag=hitboxVictim,tag=grab:entityB] grabID = @e[c=1,tag=attacker,tag=grab:entityA] grabID
tag @s remove grab:entityB
ride @s[tag=!grab:entityA] evict_riders
event entity @s[tag=!grab:entityA] ridedisable

#critChance->14
scoreboard players random @s bfRoll 1 20
scoreboard players operation @s bfRoll += @s bf_add
execute as @s[scores={bfRoll=16..}] at @s run scoreboard players add @s damageOutput 10

tag @s[scores={stun=0}] remove KBframes

tag @s remove grab:hit

#soulTrait->15
scoreboard players operation @s[tag=trait:megalomaniac,scores={stun=0}] damageOutput += @s[tag=trait:megalomaniac] mglstrksbck
scoreboard players operation @s[tag=trait:judgement,scores={stun=0}] damageOutput *= jtMulti slashRes

execute as @s[hasitem={item=weapon:rumiaex,location=slot.weapon.mainhand},scores={has_skill=1}] at @e[scores={rumiaCurse=1..}] run summon attack:rumiaspike
execute as @s[hasitem={item=weapon:rumiaex,location=slot.weapon.mainhand},scores={has_skill=0}] at @s run scoreboard players set @e[tag=!attacker,tag=hitboxVictim,r=30] rumiaCurse 200

scoreboard players operation @s damageOutput *= @s rankMultiplier
scoreboard players operation @s applyBleed *= @s rankMultiplier
scoreboard players operation @s applyBurn *= @s rankMultiplier
scoreboard players operation @s damageOutput /= @s statusFragile

scoreboard players set @s parry 0
execute as @s[type=player,scores={stun=0,atkExchange=1}] at @s run scriptevent apply:damage
execute as @s[type=player,scores={stun=0,atkExchange=2}] at @s run scriptevent apply:damage
execute as @s[type=!player,scores={stun=0,atkExchange=1}] at @s run scriptevent apply:damage
execute as @s[type=!player,scores={stun=0,atkExchange=2}] at @s run scriptevent apply:damage