OnHorseDamage
A player hit a horse - change the damage, cancel it, or let it through.
The shape of OnActorDamage without the body part, and the same return rules: a number replaces the damage (0
cancels), false cancels, nothing keeps it. The blow went through the same model as a hit on a person’s body - the attacker’s
weapon, no armour on the horse, the same wherever it lands - and a horse takes a third of it: about 8 short-sword slashes kill
one. The server has already refused a blow on the horse the attacker rides, and one on another
player’s horse (its rider’s, else its owner’s) where they could not hit that player - pvp off, the same team, the same party.
At 0 health the horse dies (OnHorseDeath).
Syntax
Section titled “Syntax”function OnHorseDamage(id, attacker, damage, zone, weapon, dtype) -- ...end| Parameter | Type | |
|---|---|---|
id |
number | the horse |
attacker |
number | the player who struck |
damage |
number | what the horse is about to lose (of 100) |
zone |
number | the attack zone the attacker’s game recorded |
weapon |
string | the weapon’s table name; "" bare-handed |
dtype |
string | "stab", "slash", "smash" or "" |
Returns
Section titled “Returns”a number replaces the damage (0 cancels); false cancels the hit; nothing keeps it
Example
Section titled “Example”-- a horse in the town is spared; the others take halffunction OnHorseDamage(id, attacker, damage, zone, weapon, dtype) if GetEntityData(id, "stabled") then return false end return damage * 0.5endSee also
Section titled “See also”OnHorseDeath · GetHorseHealth · SetHorseInvulnerable · OnActorDamage · the Horses group of the index
