A couple of triggers that ain't working...

Users who are viewing this thread

My latest crazy idea, make some troop typed able to heal nearby troops if enemies are far enough away... but it's doing a whole lotta nothing.

healing_info = (
    ti_on_agent_spawn, 0, 0, [],
  [
      (store_trigger_param_1, ":agent"),
      (try_begin),
          (this_or_next|eq, ":agent", "trp_healingman"),
          (this_or_next|eq, ":agent", "trp_friar"),
          (eq, ":agent", "trp_vorokmonk"),
        (agent_set_slot, ":agent", slot_healing_rate, 1),
      (try_end),
  ])
 
healing = (
    3, 0, 0, [],
  [
    (assign, "$healing", 2),
    (try_for_agents, ":agent"),
    (get_player_agent_no,":player"),
    (neq,":agent",":player"),
    (agent_is_alive,":agent"),
    (agent_get_team,":team",":agent"),
    (try_for_agents,":eek:ther"),
    (agent_is_alive,":eek:ther"),
    (agent_is_human,":eek:ther"),
    (agent_get_team,":eek:therteam",":eek:ther"),
    (try_begin),
    (neq,":team",":eek:therteam"),
    (agent_get_position,pos2,":eek:ther"),
    (get_distance_between_positions,":dist",pos1,pos2),
    (lt,":dist",1000),
    (assign, "$healing", 1),
    (try_end),
    (eq, "$healing", 2),
    (agent_get_slot, ":rate", ":agent", slot_healing_rate),
    (gt,":rate",0),
    (try_for_agents, ":agent_2"),
    (agent_is_alive,":agent_2"),
    (agent_is_human,":agent_2"),
    (agent_get_position,pos3,":agent"),
    (agent_get_position,pos4,":agent_2"),
    (get_distance_between_positions,":dist2",pos3,pos4),
    (lt,":dist2",300),
    (agent_set_animation,":agent","anim_release_slashright_twohanded"),
    (store_agent_hit_points, ":hp", ":agent_2", 1),
    (val_add, ":hp", ":rate"),
    (agent_set_hit_points, ":agent_2", ":hp", 1),
    (try_end),
    (try_end),
    (try_end),
  ])

Any thoughts?

P.S. I HAVE created the slot, before anyone asks. And all those troop types DO exist.
 
I've had a ton of trouble having the agent operations check for team.  I have much better luck when I simply have the operations check if agent_is_ally.
 
Add debug code to check it Where the script stopped.
It is better to add debug code in front of there, eq, le, gt...

for example,
  (display_message, "@check1"),
  (neq,":team",":eek:therteam"),
  .....
  (display_message, "@check2"), 
  (lt,":dist",1000),

 
cool idea, maybe I'll add something like this to the jedi's in my mod.  :wink:  I'd agree with rucchi about adding debug code.  But I think your issue is that its assigning $healing=1 and so never healing an agent.  I think you have some logical issues here with the code?

1) You've never assigned a position to pos1 before you run this command
Code:
(get_distance_between_positions,":dist",pos1,pos2)

2) Shouldn't this be inside the top try_for_agents, because once its switched to 1 it wouldn't switch back for the next agent?
Code:
(assign, "$healing", 2),

3) For performance reasons I'd probably move this concept up higher in the code, because if they can't heal there is no reason to check distance, etc.
Code:
(agent_get_slot, ":rate", ":agent", slot_healing_rate),
(gt,":rate",0),
 
I'd do it not with agent_spawn, but with time, like this:
healing_info = (
  0.1, 0, 0, [], # 0.1 or the time interval you wish them to heal
  [(try_for_agents, ":agent"),
          (get_player_agent_no, ":player"),
          (neq, ":agent", ":player"),                                      # not the player
        #(this_or_next|eq, ":agent", "trp_healingman"),
        #(this_or_next|eq, ":agent", "trp_friar"),              # Perhaps a this_or_next for each?
        #(eq, ":agent", "trp_vorokmonk"),
          (agent_slot_eq, ":agent", slot_healer, 1),  # perhaps a slot check, assigned in script_game_start?
          <healing codes>   
      (try_end),
  ])
 
ok, but agent id is defined on spawning in every mission, I mean agent with agent id = 1 in different scene may be different, so it's safer to set and check the slot on troops.
Then your code could be like this :
Code:
healing_info = (
   0.1, 0, 0, [], # 0.1 or the time interval you wish them to heal
   [(try_for_agents, ":agent"),
          (get_player_agent_no, ":player"),
          (neq, ":agent", ":player"),                                      # not the player
          (agent_get_troop_id, ":troop_id", ":agent"), 
          (troop_slot_ge, ":troop_id", slot_healer, 1),   # perhaps a slot check, assigned in script_game_start?
          <healing codes>     
      (try_end),
   ])

on "game_start" script, we can set the slot_healer for some troop type like :
Code:
   (troop_set_slot, "trp_healingman", slot_healer, 1),
   (troop_set_slot,  "trp_friar", slot_healer, 1),
   (troop_set_slot, "trp_vorokmonk", slot_healer, 1),

For more variation, we can set slot_healer to number more than 1, and then on healing code, we can make the healing speed is faster for bigger value of slot_healer. So the 3 healer troop can have different healing speed.

 
I've been using this concept for some new features in my mod. I plan to eventually do a troop that heals people as well, but right now I've added two things:

1) A Power Droid that refills your ammo in battle when you are close.



module_mission_templates.py

Code:
common_agent_refill_ammo_trigger = (
	5, 0, 0,	# check every 5 seconds
		[],
		[
			#(display_message, "@running common_agent_refill_ammo_trigger"),	#debug
			(get_player_agent_no, ":player_agent"),
			(assign, ":player_agent_refilled", 0),
			(try_for_agents, ":agent"),
				(agent_is_alive, ":agent"),	#so we don't try dead agents
				(agent_is_human,":agent"),	#agent is a human
				(agent_get_troop_id, ":agent_troop", ":agent"),
				(eq, ":agent_troop", "trp_power_droid"),
				#(display_message, "@trp_power_droid found!"),	#debug
				(agent_get_position,pos1,":agent"),
				(agent_get_team  ,":agent_team", ":agent"),
				(try_for_agents, ":chosen"),
					(agent_is_alive, ":chosen"),	#so we don't try dead agents
					(agent_is_human,":chosen"),	#agent is a human	
					(agent_get_team  ,":chosen_team", ":chosen"),
					(eq, ":agent_team", ":chosen_team"),
					(agent_get_position, pos2, ":chosen"),
					(get_distance_between_positions,":dist",pos1,pos2),
					(lt,":dist",400),	#SW - how close they have to be to refill ammo
					(agent_refill_ammo, ":chosen"),
					(eq, ":chosen",":player_agent"),
					(assign, ":player_agent_refilled", 1),
				(try_end),
			(try_end),
			(try_begin),
				(eq, ":player_agent_refilled", 1),
				(display_message, "@A Power Droid refilled your ammo!"),
			(try_end),
		])

2) A Bacta Tank in a ship scene that heals the player when you walk into it.    :smile:

   

module_mission_templates.py

Code:
	  (5, 0, 0, [], [		#run every X seconds
			(get_player_agent_no, ":player_agent"),	
			(scene_prop_get_num_instances,":num_instances","spr_sw_bacta_tank_new_heal"),
			(gt, ":num_instances", 0),
			(try_for_range, ":cur_i", 0, ":num_instances"),
				(scene_prop_get_instance,":instance", "spr_sw_bacta_tank_new_heal", ":cur_i"),
				(prop_instance_get_position,pos1,":instance"),
				(agent_get_position, pos2, ":player_agent"),
				(get_distance_between_positions,":dist",pos1,pos2),
				(try_begin),
					(le, ":dist", 125),	#very close
					(display_message, "@You are being healed by the Bacta Tank..."),
					(store_agent_hit_points, ":player_agent_health", ":player_agent", 1),
					(val_add, ":player_agent_health", 5),
					(agent_set_hit_points, ":player_agent", ":player_agent_health", 1),					
				(else_try),
					(le, ":dist", 1300),	#in room
					(display_message, "@Walk into the Bacta Tank to heal yourself."),
				(try_end),
			(try_end),
		]),
 
Back
Top Bottom