#reset the maxhp scoreboard
scoreboard players set @s CadeyrnMaxHP 900

#takes the horse's damage taken since last check and adds it to Cadeyrn's scoreboard
execute as @s store result score @s CadeyrnCurrentHP run data get entity @s Health 1
scoreboard players operation @s CadeyrnMaxHP -= @s CadeyrnCurrentHP
scoreboard players operation @s CadeyrnDamTaken = @s CadeyrnMaxHP
scoreboard players operation @e[type=stray,tag=CadeyrnTP,limit=1] CadeyrnDamTaken += @s CadeyrnDamTaken

#heal the horse
data merge entity @s {Health:900f}