Jump to content
Sign in to follow this  
luckylewis

Ignoring enemy fire

Recommended Posts

Hello there, please excuse my lack of scripting talent, if this is common knowledge among you lot.

For a mission I'm making, I want a bunch of groups to run while under fire from enemy static gun emplacements. I've set a waypoint with speed as 'FULL' and combatmode as 'Never fire' so that they don't stop and shoot while running. I've already added a trigger so that the units are always standing up while running.

However, whenever the groups come under fire from the enemy units, the squad leaders make a halt hand signal and most of the groups slow down doing that slow walk thing instead of running. It looks rather silly watching all the units walking about while they are under heavy fire so I was wondering if there is a script/trigger about that makes AI ignore enemy fire, so that they don't stop running, nor do they shoot, hold position, or walk. Just a continuous sprint/jog to their destination, think of it a bit like one of those soviet infantry charges during WW2.

I've tried using the 'SAFE' and 'CARELESS' commands too but that seems to make more walk and most of them still stop running after coming under enemy fire.

Any help is much appreciated,

Lewis.

Share this post


Link to post
Share on other sites

This is exactly the sort of thing I need help with as well. Any replies would be much appreciated.

Share this post


Link to post
Share on other sites

I think the thing you're looking for is the 'DisableAI' command. You can completely switch off parts of the AI behaviour with it, including if memory serves, it's ability to detect an enemy.

Unfortunately I can't remember the command syntax off the top of my head, but if you can find a guide or the wiki or something at least you've got an idea what to look for. :D

Share this post


Link to post
Share on other sites
Unfortunately I can't remember the command syntax off the top of my head, but if you can find a guide or the wiki or something at least you've got an idea what to look for. :D

There are the parameters for disableAI.

Maybe the VBS2 parameter ("PATHPLAN") works in ArmA 2 too.

"PATHPLAN" - disable the AI's path planning, thus forcing the unit to move along a straight path through the waypoints. (To disable path planning for vehicles, apply this command to the driver.)
=> http://community.bistudio.com/wiki/disableAI_(VBS2)

Can someone test it? :D

Share this post


Link to post
Share on other sites

Thanks guys, I'll try those. I have tried disableAI previously, I forgot to mention that, but I haven't used some of those parameters. I'll try some of the ones I haven't tried later.

I did manage to find a small work around by simply not using groups and individuals instead, they still stop when coming under fire though, but it solved some of the other issues I was having with the group leaders, still it's not very logical so I'll try those disableAIs soon.

Share this post


Link to post
Share on other sites

I think one simple thing you could do, even though I too am new to the editor, is set the behaviour of the fleeing soldiers to careless and on full speed..I have tried this in one of my missions and the soldiers just ran and ran and ran.

Edited by AFreeman

Share this post


Link to post
Share on other sites
To disable path planning for vehicles, apply this command to the driver.

How do I apply script/command for the driver? I'm kind of a noob when it comes to scripting.

Share this post


Link to post
Share on other sites

Hello FineLeatherJacket and Welcome to the Forums!

If you are talking about the PATHPLAN parameter of disableAI, I do not believe that will work with A2 or OA, only VBS2.

It is possible that this combination of commands will work...

disableAI "TARGET";

disableAI "AUTOTARGET";

setCombatMode "blue";

setBehaviour "careless";

... but maybe not. With the release of OA 1.60 we will have a new command called disableAI "FSM" that will probably do the trick. Here is a thread about it:

http://forums.bistudio.com/showthread.php?t=125337

If you are new to scripting, I strongly recommending reading the following:

http://community.bistudio.com/wiki/External_Scripting_Quickstart_(ArmA_2)

Share this post


Link to post
Share on other sites

Unfortunately what you're looking to do is essentially impossible because as soon any AI unit comes under fire it starts going through its danger.fsm routine, ignoring waypoint behavior completely. Setting the combat mode to "blue" will stop the AI from firing, but their behavior mode will be forced to "Combat" by the FSM regardless of what you set it to be.

The disableAI "FSM" command that Loyalguard mentioned appears to be designed just for these situations, but I've never tried it before, so I can't speak to its effectiveness.

Share this post


Link to post
Share on other sites

Ok. thanks:)

I tried to make a Normandy airborne landing. With the transport plane flying under AA fire and unload the paratroopers, but I will test your suggestions.

Share this post


Link to post
Share on other sites

The best way in my opinion to do this is through simulation, I've created a similar mission, it's incomplete so I don't feel comfortable hosting it on a filesharing service yet. But there's a simulated flak script, and I changed the desired munition to an RPG warhead, making it look similar to a flak 88. That can be found through searching. I created floating targets out of invisible helipads and has the aa guns engage them, the planes themselves are setCaptive'd, to do so you'll probably need the latest beta patch installed so you can use the doTarget and doFire commands.

The flak is essentially harmless and I doubt your planes will cross paths with any aa gun fire. But it's a work around, if you want you could just setDamage a plane if you wanted to make it look like there was any real danger. Otherwise the planes take evasive action which can lead to men ejecting over the english channel because one pilot had the balls to keep flying while the rest made a huge loop over the ocean before trying again.

Share this post


Link to post
Share on other sites
the best way in my opinion to do this is through simulation, i've created a similar mission, it's incomplete so i don't feel comfortable hosting it on a filesharing service yet.

I've now spend way too many hours trying to get my damn planes to stop evade the enemy. I doesn't even have any AA guns, just 2 MG and a AT gun.

But they still make those evade moves and fly around in circles.

Share this post


Link to post
Share on other sites

Did you use the command "setCaptive true"?

This way the AA guns aren't actually firing at your planes, and the planes won't react. Either way I turned their skill level down, set them to careless and never fire along with disabling the ability for pilots to target.

Share this post


Link to post
Share on other sites

Mate, you've managed to run into a probably not possible thing here. Many of us have faced the same problem, no working solutions are available yet. No setcaptive, no civilian pilot, no 0 skill, no disableAIs, not even disableAI "FSM".

See this topic for some more observations:

http://forums.bistudio.com/showthread.php?t=118135

Actually there is one brute force cheat: via a script/FSM you constantly check for planes direction, and if it is not exactly the same as it shuold be you reset its direction and bank. If you use an FSM it will happen at every frame, so it won't be noticable at all on the plane. You pay with CPU for this....

My older method from an FSM:

condition:

direction _plane != [ _plane, _targetPos ] call BIS_fnc_dirTo

state:

_plane setDir ([ _plane, _targetPos ] call BIS_fnc_dirTo);

_pitch = (_plane call BIS_fnc_getPitchBank) select 0;

[_plane,_pitch , 0] call BIS_fnc_setPitchBank;

Even better method: run the below code on _plane on every frame (by FSM or with 0.04 sleeps in an sqf), and you get a plane flying nicely in a straight direction, with fixed speed, by always resetting its velocity and banking. Brutal, but works in every situation.

_speed = 65; //in meters/sec

_cDir = [ _plane, _targetPos] call BIS_fnc_dirTo;

_plane setVelocity [sin _cDir *_speed, cos _cDir *_speed, velocity _plane select 2];

[_plane, (_plane call BIS_fnc_getPitchBank) select 0 , 0] call BIS_fnc_setPitchBank;

Edited by zapat

Share this post


Link to post
Share on other sites

Sorry, this was only an idea, but implementation is pretty simple and can be done many ways, depending on what exactly you want to do. Here is the most basic one:

1. make a "straight.sqf" file with the below code (you can change speed of course) in your mission's folder.

_plane = _this select 0;
_targetPos = _this select 1;

_speed = 65; //in meters/sec

while {_plane distance _targetPos > 100 + (getPosATL _plane select 2)  && alive _plane} do
{
   _cDir = [ _plane, _targetPos] call BIS_fnc_dirTo;
   _plane setdir _cDir;
   _plane setVelocity [sin _cDir *_speed, cos _cDir *_speed, velocity _plane select 2];
   [_plane, (_plane call BIS_fnc_getPitchBank) select 0 , 0] call BIS_fnc_setPitchBank; 
   sleep 0.04;
};

2. in the editor, create a flying plane, with the following init:

null = [this, getMarkerPos 'target'] execVM "straight.sqf";

3. in the editor create a marker, named "target": the plane will fly straight to "target" from the beginning until it gets around the marker, then it will continue to next waypoint.

Some additions:

You can run the script at any time if it is not okay from the beginning, but plane will instantly (without any transitions) turn to its direction.

This basically overrides any 2D movement attempts, by moving the object itself "manually", so it doesn't matter how the pilot wants to behave. 3D movement (up and down) is not overriden, so the plane can follow the terrain (This will be extremely limited with this method, because limitations begin at init, so it messes up the calculated path: I use a domove to marker first, and then run the script: this way the the up-and-down path is calculated and in sync with straight path. This requires a more complex method though).

If you want total 3D straight flight (which many peole want), just change those below lines. setting proper height will be your job though!

_plane setVelocity [sin _cDir *_speed, cos _cDir *_speed, 0];

[_plane, 0, 0] call BIS_fnc_setPitchBank;

Edited by zapat

Share this post


Link to post
Share on other sites

so, it's a little bit choppy when I use the 3d movement version of this, is your method of moving to a marker then executing the script better or is it pretty much the same?

Share this post


Link to post
Share on other sites

Hmmm, you are right: setdir makes it choppy for some reason. No problem, we need to make it before the loop.

So best is, if you place your plane in the editor, and make it face target marker more or less (setVelocity will take care of the rest);

If you spawn the plane, set its direction after spawning.

One more idea: if we put the whole stuff into a waituntil condition field, then the engine will take care of running it every frame.

To sum it up, your straight.sqf file will look like this (the rest is the same as in my first post)

_plane = _this select 0;
_targetPos = _this select 1;

_speed = 65; //in meters/sec

waitUntil 
{
   _cDir = [ _plane, _targetPos] call BIS_fnc_dirTo;
   _plane setVelocity [sin _cDir *_speed, cos _cDir *_speed, 0];
   [_plane, 0 , 0] call BIS_fnc_setPitchBank; 
  !alive _plane || _plane distance _targetPos < 100 + (getPosATL _plane select 2)  
};  

Note: the ";" is missing at the last line on purpose!!! That is the condition line of the waitUntil.

Edited by zapat

Share this post


Link to post
Share on other sites

I gave it another test, it's a little bit less choppy, but when the planes start trying to avoid fire that's when it gets worse. It's not the prettiest looking, but it gets the job done. Obviously when you make the player the pilot it's perfectly smooth. I decided to go with empty C-47's instead of piloted ones, once I figure out how to make the massive amount of AA guns on the ground consider them enemies I'll be in business for a much simpler and effective Normandy mission.

Share this post


Link to post
Share on other sites

I use it in an FSM, wich is scheduled differently than an sqf, so this could cause the difference. I spawned like 20 planes in chain, one after each other, with Tunguskas firing, and all of them flied nicely. This sqf version is not tested that throughoutly.

I am not around my comp now, but an empty plane would probably do the trick. And before the marker, we could spawn the pilot.

Or a full disableAI on the pilot with disable movement and target and autotarget, and FSM before the waitUntil would be easier to do. Then right after the waitUntil is done, these could be turned back on so the plane would have a working pilot again. This should avoid movement interference, which causes choppiness, if delayed.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×