Hai,
I'm trying to code a dynamically generated health bar above a agent. So for the basics are done, but I am kinda stuck at the moment.
Did anyone every tried to code the same thing? Tried to search it, but couldn't find anything
If not I hope you can help me out with the following code,
Currently only shows up for just 1 agent (needs to be all the agents withing the 50mtr distance of the player).
I also have less knowledge about setting the positions right for the health bar, kinda want them floating above a players head and make the bar smaller if the distance increases. (currently hovers somewhere near the feet of the agent and does not get smaller when the distance is larger)
Really hope you lot can help me out.
Thanks
I'm trying to code a dynamically generated health bar above a agent. So for the basics are done, but I am kinda stuck at the moment.
Did anyone every tried to code the same thing? Tried to search it, but couldn't find anything
If not I hope you can help me out with the following code,
Currently only shows up for just 1 agent (needs to be all the agents withing the 50mtr distance of the player).
I also have less knowledge about setting the positions right for the health bar, kinda want them floating above a players head and make the bar smaller if the distance increases. (currently hovers somewhere near the feet of the agent and does not get smaller when the distance is larger)
Code:
("update_health_bars", [
(set_fixed_point_multiplier, 1000),
(get_player_agent_no, ":my_agent_id"),
(agent_get_position, pos0, ":my_agent_id"),
#(try_for_players, ":player_id", 1),
(try_for_agents, ":agent_id"),
(neq, ":my_agent_id", ":agent_id"),
#(player_is_active, ":player_id"),
#(player_get_agent_id, ":agent_id", ":player_id"),
(agent_is_human, ":agent_id"),
(agent_is_alive, ":agent_id"),
(agent_get_position, pos1, ":agent_id"),
(position_move_z, pos1, 150),
(get_distance_between_positions_in_meters, ":dist", pos0, pos1),
(try_begin),
#in range of player
(lt, ":dist", 50),
(position_get_screen_projection, pos0, pos1),
(store_agent_hit_points, ":health", ":agent_id", 0),
(create_progress_overlay, reg0, 0, 100),
(overlay_set_val, reg0, ":health"),
(overlay_set_position, reg0, pos0),
(position_get_x, ":pos0_x", pos0),
(val_add, ":pos0_x", ":dist"),
(position_set_x, pos0, ":pos0_x"),
(overlay_set_size, reg0, pos0),
(try_end),
(try_end),
(try_begin),
(key_clicked, key_b),
(display_message, "@script stopped"),
(else_try),
(start_presentation, "prsnt_kaasovic_show_player_health"),
(try_end),
]),
Really hope you lot can help me out.
Thanks