horses_spook = (
2, 0, 0, [],#Every six seconds
[
(try_for_agents, ":cur_agent"),
(try_begin),
(neg|agent_is_human,":cur_agent"),
(agent_is_alive,":cur_agent"),
(agent_get_item_id,":horse_type", ":cur_agent"),
(try_for_range,":camel",camels_begin,camels_end),
(eq,":horse_type",":camel"),#If this horse is a camel
(agent_get_position,pos2,":cur_agent"),
(try_for_agents,":enemy_horse"),
(assign,":canspook",1),
(neg|agent_is_human,":enemy_horse"),#See if its a horse
(agent_is_alive,":enemy_horse"),#Make sure he's not dead
(agent_get_item_id,":enemy_horse_type",":enemy_horse"),
(try_for_range,":camel",camels_begin,camels_end),
(eq,":enemy_horse_type",":camel"),#Can't scare other camels
(assign,":canspook",0),
(try_end),
(store_random_in_range,":chance",1,11),
(agent_get_rider,":enemy_rider",":enemy_horse"),
(agent_get_troop_id,":ridertroop",":enemy_rider"),
(store_skill_level,":riding",skl_riding,":ridertroop"),
(val_add,":chance",":riding"),
(try_begin),
(ge,":chance",10),
(assign,":canspook",0),
(end_try),
(try_begin),
(eq,":canspook",1),
(agent_get_position,pos1,":enemy_horse"),
(get_distance_between_positions,":dist",pos1,pos2),#In CM
(try_begin),
(le,":dist",3500),#Within 35m
(agent_set_animation,":enemy_horse","anim_horse_rear"),
(try_end),
(try_end),
(try_end),
(try_end),
(try_end),
(try_end)])