1
OSP ресурсы: модели, текстуры, скрипты / Re: Делимся скриптами для МС
« : 30 Октября, 2016, 18:59 »Скрипт в mission templates для восполнения ХП лошади когда она приближается к стогам сена, расположенным на карте.(0.5, 0.5, 0, [],
[
(multiplayer_is_server),
(try_begin),
(store_current_scene, ":cur_scene"),
(eq, ":cur_scene", "scn_multi_scene_17"),
(scene_prop_get_num_instances, ":count_of_straw_b", "spr_straw_b"),
(try_for_range, ":cur_straw_b", 0, ":count_of_straw_b"),
(scene_prop_get_instance, ":straw_instance", "spr_straw_b", ":cur_straw_b"),
(prop_instance_get_starting_position, pos1,":straw_instance"),
(try_for_agents, ":cur_agent"),
(agent_is_human, ":cur_agent"),
(agent_is_alive, ":cur_agent"),
(agent_get_horse, ":horse", ":cur_agent"),
(neq, ":horse", -1),
(agent_get_position, pos2, ":horse"),
(get_sq_distance_between_positions, ":dist", pos1, pos2),
(try_begin),
(le, ":dist", 2500),
(store_agent_hit_points, ":hp", ":horse"),
(assign, ":hp_new", ":hp"),
(lt, ":hp_new", 100),
(agent_set_hit_points, ":horse", 100, 0),
(try_end),
(try_end),
(try_end),
(try_end),
]),
Посмотрел твой скрипт, вот менее корявая версия (WB 1.165+):
MSHH_MAX_HP_PER_TICK = 7
MSHH_MAX_HEAL_DIST = 3
MSHH_UTILITY_PROP_ID = "spr_straw_b"
MSHH_UTILITY_PROP_VAR = 1
MSHH_FREQUENCY = 3
multiplayer_server_heal_horses = (
MSHH_FREQUENCY, 0, 0, [(multiplayer_is_server),(store_current_scene,":cur_scene"),(eq,":cur_scene","scn_multi_scene_17")],
[
(try_for_agents,":horse_agent"),
(agent_is_active,":horse_agent"),
(agent_is_alive,":horse_agent"),
(neg|agent_is_human,":horse_agent"),
(store_agent_hit_points,":horse_hp",":horse_agent",0),
(lt,":horse_hp",100),
(agent_get_position,pos1,":horse_agent"),
(assign,":continue",1),
(try_for_prop_instances,":instance_id",MSHH_UTILITY_PROP_ID),
(eq,":continue",1),
(prop_instance_is_valid,":instance_id"),
(prop_instance_get_variation_id,":var_id",":instance_id"),
(eq,":var_id",MSHH_UTILITY_PROP_VAR),
(prop_instance_get_position,pos2,":instance_id"),
(get_distance_between_positions_in_meters,":dist",pos1,pos2),
(le,":dist",MSHH_MAX_HEAL_DIST),
(assign,":continue",0),
(store_random_in_range,":hp_bonus",0,MSHH_MAX_HP_PER_TICK + 1),
(gt,":hp_bonus",0),
(store_add,":new_hp",":horse_hp",":hp_bonus"),
(agent_set_hit_points,":horse_agent",":new_hp",0),
(try_end),
(try_end),
])
MSHH_MAX_HEAL_DIST = 3
MSHH_UTILITY_PROP_ID = "spr_straw_b"
MSHH_UTILITY_PROP_VAR = 1
MSHH_FREQUENCY = 3
multiplayer_server_heal_horses = (
MSHH_FREQUENCY, 0, 0, [(multiplayer_is_server),(store_current_scene,":cur_scene"),(eq,":cur_scene","scn_multi_scene_17")],
[
(try_for_agents,":horse_agent"),
(agent_is_active,":horse_agent"),
(agent_is_alive,":horse_agent"),
(neg|agent_is_human,":horse_agent"),
(store_agent_hit_points,":horse_hp",":horse_agent",0),
(lt,":horse_hp",100),
(agent_get_position,pos1,":horse_agent"),
(assign,":continue",1),
(try_for_prop_instances,":instance_id",MSHH_UTILITY_PROP_ID),
(eq,":continue",1),
(prop_instance_is_valid,":instance_id"),
(prop_instance_get_variation_id,":var_id",":instance_id"),
(eq,":var_id",MSHH_UTILITY_PROP_VAR),
(prop_instance_get_position,pos2,":instance_id"),
(get_distance_between_positions_in_meters,":dist",pos1,pos2),
(le,":dist",MSHH_MAX_HEAL_DIST),
(assign,":continue",0),
(store_random_in_range,":hp_bonus",0,MSHH_MAX_HP_PER_TICK + 1),
(gt,":hp_bonus",0),
(store_add,":new_hp",":horse_hp",":hp_bonus"),
(agent_set_hit_points,":horse_agent",":new_hp",0),
(try_end),
(try_end),
])