Can anyone help me and tell me why this does not work? Even if you look at someone standing in front of you, he is not targeted. The script should find the next agent in front of you, it was written by someone here in this thread, it was some time ago. Don't know who it was And now I try to fix it, but i don't know what is the reason why it does not work.
Code:
IT_magic_system_2 = (0, 0, 60, #every frame (reset_mission_timer_b),
[
(key_clicked, key_j), #could use global var, game_key, or something - see list in header_triggers
(get_player_agent_no, ":agent"),
(agent_get_wielded_item, "$staff", ":agent", 0),
],
[
(try_begin),
(eq, "$staff", "itm_heal_staff_1"),
(get_player_agent_no, ":player_agent"),
(assign, ":target_agent", -1),
(assign, ":close_dist", 9999),
(agent_get_look_position, pos1, ":player_agent"),
(display_message,"@get_look_position",0x6495ed),
(try_for_agents, ":agent"),
#add in checks for agent being alive, human, ally, whatever you need
(agent_get_position, pos2, ":agent"),
(neg|position_is_behind_position, pos2, pos1),
(position_has_line_of_sight_to_position, pos2, pos1),
(get_distance_between_positions, ":distance", pos2, pos1),
(display_message,"@pos1 + 2",0x6495ed),
(lt, ":distance", ":close_dist"),
(assign, ":close_dist", ":distance"),
(assign, ":target_agent", ":agent"),
(agent_set_animation, ":player_agent", "anim_defend_shield_right"),
(display_message,"@assigned!",0x6495ed),
(try_end),
(gt, ":target_agent", -1),
(store_agent_hit_points,":life",":target_agent",1),
(val_add,":life",15),
(agent_set_hit_points,":target_agent",":life",1),
(multiplayer_send_2_int_to_server, multiplayer_event_anim_made_by_player, "anim_defend_shield_forward", ":player_agent"),
(display_message,"@Works!",0x6495ed),
(else_try),
(eq, "$staff", "itm_curse_staff_1"),
(display_message,"@Works!",0x6495ed),
(try_end),
])