Taylor1984 14 Posted March 30, 2018 Hi! Picture that you have an ignorant AI running towards a dangerous fire that will hurt him. I want the AI to run away from the fire when he gets too close to it, however how can you be sure that when you give the AI a waypoint or move order that it wont be placed on the other side of the fire so that the unit runs straight into the fire instead of away from it? I guess you'd have to find the unit's direction and tell him to run his dir + 180 degrees, right? How would I go about doing that? Cheers, you're the best. Share this post Link to post Share on other sites
beno_83au 1369 Posted March 30, 2018 Try getPos with its alternate syntax to get you on your way. Share this post Link to post Share on other sites
Taylor1984 14 Posted March 30, 2018 Thanks, exactly, that's what I understand I need to do, I just don't understand exactly how. :) Share this post Link to post Share on other sites
rübe 127 Posted March 30, 2018 Even with doMove (or moveTo down on fsm level), making the AI run as long as known threats are around is a hard one. You'll probably have to experiment with disableAI (e.g. targeting) in an attempt to make them ignore enemies and concentrate on running, and even then... (maybe continously reseting/earsing knownTargets helps, since that's an option now?) I'm not sure if people ever managed to do this properly/in a satisfactory way. Share this post Link to post Share on other sites
froggyluv 2136 Posted March 30, 2018 Devs talked about working on this a while ago and would be a great asset to the game. Giving the AI the ability to tactically withdraw and/or straight up run would be awesome Share this post Link to post Share on other sites
Taylor1984 14 Posted March 30, 2018 Yeah but in this case there might not even be enemy anywhere near the unit. Maybe I have to clarify that the fire I wrote about above is an actual burning fire with flames and not gun fire. I just want to find a way for a unit to run the opposite direction from whence he came. Share this post Link to post Share on other sites
HazJ 1289 Posted March 30, 2018 Old command but worth a try: https://community.bistudio.com/wiki/allowFleeing Quote Sets the cowardice level (the lack of courage or bravery) of a group or unit. The more cowardice a Group or Object has, the sooner it will start fleeing. 0 means maximum courage, while 1 means always fleeing. Another way would be to use Fired EH or something like that, the EH is local though so keep that in mind. Are you creating this for SP or MP? As always, there will be a way. Share this post Link to post Share on other sites
Taylor1984 14 Posted March 30, 2018 Thanks. I'm making a MP mission. But wouldn't the unit only run away when confronted with enemy units? I just want a unit to be scared of burning flames. Share this post Link to post Share on other sites
HazJ 1289 Posted March 30, 2018 Yeah, enemy. So therefore just add Fired EH to those units. For burning flames, are they pre-defined positions or? You could create blacklist zones/areas with triggers/markers or whatever. You'd have to look on Wiki for some kind of check when they on move so it avoids that. Share this post Link to post Share on other sites
Taylor1984 14 Posted March 30, 2018 Yeah, the position of the flames is a house that is burning and I don't want anyone walking close to that house once its burning but the AI is of course stupid and wants to walk into the building. :) There is a module called zone restriction but I'm not really sure how it works and how to use it. Share this post Link to post Share on other sites
Harzach 2517 Posted March 31, 2018 Maybe some strategically placed Land_InvisibleBarrier_F objects? Share this post Link to post Share on other sites
pierremgi 4873 Posted March 31, 2018 you can place/script a trigger on your fire. Set repeatable, anybody present, some radius in cond: this && isNil "fireFly" on act: { if (isNil {_x getVariable "wpt"} && _x inArea thistrigger) then { _x setVariable ["wpt", group _x addWaypoint [thistrigger getPos [((triggerArea thistrigger) select 0)+3, (thistrigger getdir _x) +30],0,currentWaypoint group _x]] }} forEach thislist; firefly = true on deact: 0 = thistrigger spawn {sleep 1; firefly = nil; { if !(_x inArea _this) then { _x setVariable ["wpt", nil] }} forEach allUnits select {!isNil {_x getVariable "firefly"}}} Now your guy will turn around the trigger to reach any waypoint. If inside, they turn indefinitely. Share this post Link to post Share on other sites
Taylor1984 14 Posted March 31, 2018 Thanks! It works pierremgi. The only thing that is a problem is that when the unit has a waypoint assigned within the trigger area he tries to run back inside the trigger forever. Is there a way to add a removal of the original waypoint that doesn't seem to disappear. Once inside the trigger a new waypoint is created but it's the number before the original so I guess you'd have to remove the original? Share this post Link to post Share on other sites
pierremgi 4873 Posted April 1, 2018 Yep, you need to remove all waypoints inside the trigger. Just modify the on act field: { if (isNil {_x getVariable "wpt"} && _x inArea thistrigger) then { for "_i" from 0 to count waypoints group _x -1 do { if (waypointPosition [group _x,_i] inArea thistrigger) then { deleteWaypoint [group _x,_i]; _i = _i-1 } }; _x setVariable ["wpt", group _x addWaypoint [thistrigger getPos [((triggerArea thistrigger) select 0)+3, (thistrigger getdir _x) +30],0,currentWaypoint group _x]] } } forEach thislist; firefly = true 1 Share this post Link to post Share on other sites
Taylor1984 14 Posted April 1, 2018 OK, thanks. I'll try that. I'll make sure to credit you in my mission if it's OK? Share this post Link to post Share on other sites
pierremgi 4873 Posted April 1, 2018 No problem. You're welcome. Share this post Link to post Share on other sites