horse_fall_off = (
ti_on_agent_hit, 0, 0, [],[
#### Knocked off horses script, base by Gaunt, edited by Davee, edited a bit more by ChiefNinja.
(store_trigger_param_1, ":victim_agent"),
#(store_trigger_param_2, ":attacker"),
(store_trigger_param_3, "

rig_damage"),
(display_message,"@Horse script called!"),
#(ge, "

rig_damage", 15), ### Minimum damage needed
(store_agent_hit_points,":hp",":victim_agent"),
(val_sub, ":hp", "

rig_damage"),
(ge, ":hp", 1), ### So it dosn't run when it's not needed (agent dies anyway)
(agent_is_human,":victim_agent"),
(store_skill_level, ":skl_level", skl_riding, ":victim_agent"),
(val_add, ":skl_level", 1),
(val_clamp, ":skl_level", 1, 11),
(store_div, ":damage_mul", "

rig_damage", ":skl_level"), ## Chance is now based partially on riding skill.
(store_random_in_range,":chance",0,1), ### Decrease this number (20) for higher chances of knocking riders off (and vice-versa).
(ge,":damage_mul", ":chance"), ### If damage_mul dealt is over or equal to the ":chance" number, knock-off occurs.
(agent_get_horse,":horse",":victim_agent"),
(neq,":horse",-1),
(agent_get_item_id,":horsetype", ":horse"),
(neq,":horsetype",-1),
(agent_get_position,pos1,":horse"),
#(agent_get_speed, pos2, ":horse"),
(store_agent_hit_points,":horsehp",":horse"),
(entry_point_get_position, pos3, 0),
(agent_set_position,":horse",pos3),
(remove_agent, ":horse"),
(set_spawn_position, pos1),
(spawn_horse,":horsetype",0),
(agent_start_running_away, reg0),
#(agent_set_horse_speed_factor, reg0, 100), #I don't think this works but it isn't necessary. <- Only changes max speed of the horse
(agent_set_hit_points,reg0,":horsehp"),
])