Rawhide 2 Posted July 7, 2008 Hi, I would like some AI units (air and ground) to not enter a specific zone. The zone could be a marker, trigger, gamelogic or whatever you find appropriate. Does anybody have the solution? So far I have only managed to put their behavior to "careless" when entering this zone. Best regards, -Rawhide EDIT: I might add that the AI's are patrolling nearby via waypoints. They leave these waypoints to engage what they see over there(the mentioned zone). I only want the AI's to engage when their opponents are entering their territory. Share this post Link to post Share on other sites
johnnyboy 3795 Posted July 7, 2008 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_man disableai "target" Try the above on all your patrolling units. disableai "target" prevents units from breaking formation to engage targets, so they should stay on their waypointed path. However, this does not prevent them from shooting at targets. Hope this helps. Also, you could use... <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_man setcaptive true; ...on all enemy units so the patrol ignores them. Then you can set them back to setcaptive false when they enter the zone where you want the patrolling units to respond. Share this post Link to post Share on other sites
whisper 0 Posted July 7, 2008 In a case of a patrol, you could force them to run to their first waypoint as soon as they enter the zone. Make a trigger activated by the side of the group you want to forbid to enter, or bind it to the group directly. In on Action field of your trigger : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x doWatch objNull; (group _x) setCurrentWaypoint [group _x, 1]} forEach thislist Of course, if the patrol is around the forbidden area, it could lead to issues where the group would have to go all the way through the area to reach the 1st waypoint of their patrol Share this post Link to post Share on other sites
Rawhide 2 Posted July 8, 2008 Thanks a lot guys! @JohnnyBoy: hmm, I like the simplicity of your solution: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_man disableai "target"But, when they are in their "own" zone, they should break out of formation and engage enemies. But they should not enter their enemies zone. In this case, it is SU35 Flankers, and they have of course a visibility far out of their own zone. When they spot enemies on the enemies' base they tend to attack this one. And they shoulden't. So far, I've set up a trigger that sets the behaviour to "careless" when they enter. But that's not realistic to have east jets that just flies over west base without engaging... I would rather have them to ignore their enemies zone completely. @Whisper: I think that might be the solution: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x doWatch objNull; (group _x) setCurrentWaypoint [group _x, 1]} forEach thislistIf this can force them to their first waypoint when entering the zone. I will try your solution when I have time later today or tomorrow, and report back the results. One more Q though: this part of the code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">setCurrentWaypoint [group _x, 1]-is the number 1 the number in the waypoint sequence? So if I wanted the AI's to be forced to waypoint 6 instead, this would be the whole code: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x doWatch objNull; (group _x) setCurrentWaypoint [group _x, 6]} forEach thislistCorrect? It is also a solution to make all the AI's in the base that should not be attacked, as captives. But I find that a rather bad and unnecessary way to solve it... Thanks again, -Rawhide Share this post Link to post Share on other sites
whisper 0 Posted July 8, 2008 Yes, the "1" is the waypoint number, 0 is the starting position of the unit as put in the editor (not really a waypoint per se), then it counts the waypoints. If the unit doesn't follow the order and keeps engaging the ennemy (even though by using doWatch objNull, I tried to force them to stop targetting units), you could maybe try to create a temporary waypoint with the move command : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x doWatch objNull; (group _x) move waypointPosition [group _x, 1]} foreach thislist Perhaps one of these attempts will do the trick. You could also force a doMove for evey single unit (not using the waypoint system for groups), but in this case, I fear the units would be stuck in their target position afterwards. You'd need to track their position, and once they have finished moving out of the forbidden zone, free them from the move command. Something like that : on onActivation field : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{[_x, waypointPos [group _x, 1]] execVM "leaveZone.sqf"} forEach thislist And leaveZone.sqf : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_u = _this select 0; _pos = _this select 1; // Ask the unit to move to desired position _u doMove _pos; // Wait until the unit has moved waitUntil {unitReady _u}; // Release the unit for it to follow again its waypoints _u doFollow _u; Share this post Link to post Share on other sites
Rawhide 2 Posted July 9, 2008 In a case of a patrol, you could force them to run to their first waypoint as soon as they enter the zone.Make a trigger activated by the side of the group you want to forbid to enter, or bind it to the group directly. In on Action field of your trigger : <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{_x doWatch objNull; (group _x) setCurrentWaypoint [group _x, 1]} forEach thislist This worked like a charm! Thanks a lot whisper -Rawhide Share this post Link to post Share on other sites
Rawhide 2 Posted July 11, 2008 If the AI (in this case a SU-34, named su1) gets a lock on a target in the zone (given that he is in a engage at will mode), he will ignore the given waypoint that sends him away from the zone and engage the targets. To prevent this from happening, I added the following codes to the trigger. This makes the AI Su-34 careless of the targets, and he will then go to the waypoint that is given. That is why I have the behaviour-change before the string that gives the plane a new waypoint. Note: if more than one SU-34, I would recommend one trigger for each aircraft. You could add several planes to the same trigger, but in that case when one of the SU-34's leaves the zone it will put the combatbehaviour to an aggressive one to the one plane that is still in the zone. The two triggers covers the area that the AI SU-34 should not enter. When entering the zone: Condition: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">su1 in thisList On act.: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">su1 setBehaviour "CARELESS"; su1 setCombatMode "BLUE"; {_x doWatch objNull; (group _x) setCurrentWaypoint [group _x, 4]} forEach thislist And then a second trigger that covers the same area. When leaving the zone: Condition: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">not (su1 in thisList) On act.: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">su1 setBehaviour "COMBAT"; su1 setCombatMode "RED" I guess the codes explains themselves. -Rawhide Share this post Link to post Share on other sites