Trigger Question [Solved]

Users who are viewing this thread

I have been having issues with this trigger I made. It is set to slay players when they are behind this object. It all works fine, however it is very demanding ping-wise, and whenever it fires (every 5 seconds) the players ping goes crazy. Would there be some way to clean this up and make it be less demanding?

Thanks.

(5, 0, 0, [
(multiplayer_is_server),

],

      [
(try_begin),
    (scene_prop_get_num_instances, ":num_instances_of_scene_prop", "spr_glow_b"),
    (try_for_range, ":cur_prop_instance", 0, ":num_instances_of_scene_prop"),
      (scene_prop_get_instance, ":prop_instance_id", "spr_glow_b", ":cur_prop_instance"),
(scene_prop_get_instance, ":effected_object_instance_id", "spr_glow_b", ":cur_prop_instance"),
        (prop_instance_get_position, pos5, ":effected_object_instance_id"),
        (prop_instance_get_variation_id_2,":var_2", ":effected_object_instance_id"),
(eq, ":var_2", 0),

(try_for_players, ":player_no", 1),
(get_player_agent_no, ":player_agent"),
(player_get_agent_id, ":player_agent", ":player_no"),
            (agent_is_alive,":player_agent"),
            (agent_is_active,":player_agent"),
        (agent_is_human,":player_agent"),
        (agent_get_position,pos6,":player_agent"),
          (get_sq_distance_between_positions_in_meters,":distance",pos5,pos6),
          (gt,":distance",1),
          (neg|position_is_behind_position,pos6,pos5),
(agent_deliver_damage_to_agent, ":player_agent", ":player_agent", 80,"itm_admin_kill_dummy"),
(try_end),
(try_end),]),
 
a loop inside a loop is a receipt for disaster

remember to use the Q&A thread for quick questions, and once you have a solution you should update your threads, so others can see what you did. Updating the title with a [solved!] or closing the thread would also save time as we dont need to open it  :razz:
 
pete99 said:
Would there be a way to make this work.without having a loop inside a loop?
Almost, yes...
You could loop through the props, save their unique positions (allows up to 127 of your props within a scene).
Then run an agent loop and check each agent-position against the previously stored prop-positions.
Code:
(5, 0, 0, [], [
	(multiplayer_is_server),

	(assign, ":num_pos", 1),#reserve pos 0 for agents
	(try_for_prop_instances, ":instance", "spr_glow_b", somt_object),#if the prop isnt placed via the scene editior, use somt_temporary_object
		(prop_instance_get_variation_id_2,":var_2", ":instance"),
		(eq, ":var_2", 0),
		(prop_instance_get_position, ":num_pos", ":instance"),#stores the current prop position
		(val_add, ":num_pos", 1),#sum up positions/props
	(try_end),

	(gt, ":num_pos", 1),#only continue if there are damaging props on the scene
	(try_for_agents, ":agent", 0, 0),
		(agent_is_alive,":agent"),
		(neg|agent_is_non_player, ":agent"),#only players
		(agent_get_position, pos0,":agent"),
		(assign, ":end", ":num_pos"),
		(try_for_range, ":pos", 1, ":end"),
			(neg|position_is_behind_position, pos0, ":pos"),#found a prop/position that matches the condition
			(agent_deliver_damage_to_agent, ":agent", ":agent", 80, itm_admin_kill_dummy),
			(assign, ":end", -1),#break loop, agent is already dead
		(try_end),
	(try_end),
]),
 
Back
Top Bottom