Alarmed state of agents and cascade alarming between neighbor bots

Users who are viewing this thread

Mat Berserker

Sergeant Knight at Arms
Hello. I have problem with allerted agents behavior. I'm curently working on some maps that feature scattered groups of enemy agents without aif_start_alarmed assigned to them.
On bigger map everything works just fine. Bots charge me and my army when we get into thier range of sight. So I can defeat first group and then proceed further down corridors until I meet next group.
mb88.jpg
But problem appear while playing on smaller map. When any of bots will see me it would alert neighbor bots that would alert their neighbors and so on. Because of alweys at least one agent sees me manualy changing of their state to not alarmed does nothing because it would instantly pop back in place. Because of that everyone will charge out from building and all fights will take place near front doors.
mb86.jpg
I tried to use agent_ai_set_aggressiveness but it seems to have nothing to do in matter of alerting agents.
Mine other approach is based on giving enemy team mordr_stand_ground. It prevents enemy from sallying out but it highly decrese enemy effectiveness in fight, especially when guards have only one handed weapons and players army can have ranged troops.

Is there any way of decreasing spreading ratio of alarmed state between nearby agents or at last making agents with mordr_stand_ground charge enemy on sight?
 
This is really explicit solution. As far as i know it would require making some dedicated trigger objects, placing them on map and assigning them to corresponding entry points. Not mentioning that it will need more sophisticated end of battle condition and  some basic AI scripting for attacker site bots(because they wouldn't know where to go).

Currently I'm working with some walkaround using stand your ground order and it seems quite promising. I ordered all but one enemy groups to stand their ground and one chosen group to charge. Then during game I iterate for all alarmed troops that are not in that group and check if they see they target, if so I move them to team that have charge orders. I also do same thing again but this time I check does they see player because it improve overall smoothness from players perspective. Sadly I don't know how agent_is_in_line_of_sight affect performance, but I haven't encounter any heavy lag yet.

Code snippet below.
Code:
	  (0, 0, ti_once, [],
       [
		(team_give_order, 1, grc_everyone, mordr_stand_ground),
		(team_give_order, 1, 5, mordr_charge), #division 5 is reserved for alarmed troops
        ]),
	  
	  (0.5, 0, 0, [],
       [
	   
		(try_for_agents,":agent"),
			(agent_is_alarmed, ":agent"),
			(agent_get_team, ":team", ":agent"),
			(eq, ":team",1),
			(agent_get_division, ":division", ":agent"),
			(neq, ":division", 5),
			(agent_ai_get_look_target, ":target", ":agent"),
			(neq,":target",-1),
			(agent_get_position, pos1, ":agent"),
			(position_move_z, pos1, 100),
			(agent_is_in_line_of_sight, ":target", pos1),
			(agent_set_division, ":agent", 5),
			(agent_force_rethink, ":agent"),
		(try_end),
		(get_player_agent_no, ":player"),
		(neq,":player",-1),
		(agent_is_alive,":player"),
		(try_for_agents,":agent"),
			(agent_is_alarmed, ":agent"),
			(agent_get_team, ":team", ":agent"),
			(eq, ":team",1),
			(agent_get_division, ":division", ":agent"),
			(neq, ":division", 5),
			(agent_get_position, pos1, ":agent"),
			(position_move_z, pos1, 100),
			(agent_is_in_line_of_sight, ":player", pos1),
			(agent_set_division, ":agent", 5),#move to division for alarmed troops and charge
			(agent_force_rethink, ":agent"),
		(try_end),
        ]),

It is not perfect and I still seek more elegant approach but it seems to work.
 
Back
Top Bottom