Jump to content
Sign in to follow this  
IndeedPete

Preventing AI to Fall Off of Rooftops

Recommended Posts

Hi there,

I'm having a typical A3 AI issue. In a perfectly unitCaptured scene me and my squad are being dropped off on the Kavala hostpital's rooftop. Down in the streets is some serious combat going on so my team changes to combat mode immediately and starts engaging targets. So far so good, but they don't seem to realise that every rooftop ends at some point and just walk over the edges. Means, after 30 seconds of intense fighting I've lost my whole team, not by enemy fire but by their own stupidity.

Any creative ideas to bypass this stupid behaviour? (I know, I could issue a stop order once we're out of the chopper but I don't want other players to revert because they didn't react fast enough.) Already considered making them invincible until we made it off the roof but it's a clunky workaround in my opinion.

Thanks!

Share this post


Link to post
Share on other sites

AI walking in Kavala hospital helipad = pain in the ass.... Don't know why it hasn't building positions which maybe make some pathfinding AI easier...

Share this post


Link to post
Share on other sites

Place sandbags or small concrete barriers to prevent AI from falling off?

Share this post


Link to post
Share on other sites

Hm, as far as I can see they can walk through basically any obstacle. It really is a pain in the ass. Such a cool place for a drop-off and the AI screws up the scene again. :/

Share this post


Link to post
Share on other sites

I suggest to try the office building near that, the rroftop has lots of buildingpos. and maybe AI does not mess up....

Share this post


Link to post
Share on other sites

It took me like 20 approaches to get the unitCapture done because of my non-existent flying skills, I won't do that again.^^ I think I'll go with clunky, and have them invincible until they're all on the ground...

Share this post


Link to post
Share on other sites

you cant stop them

You can stop them moving with code, but as soon as you switch that code back to allowing ai to move they will lemming off the top

Liken them to wasteland players :yay:

If however this is just for a cutscene, then you have 2 options

Make sure the units in the ai group do not have "FORMATION" set in the editor

then either

disableAI "MOVE"

which will prevent them from moving at all

or if you want them to be able to turn around but not move from their positions you can run the following code

group lockwp true;

group enableAttack false;

Edited by Terox

Share this post


Link to post
Share on other sites

I need them to move because the actual objective is a few blocks away from the rooftop LZ. It's really just a droppoint for the player's squad. I thought they would have at least some basic path finding which leads them to the staircase so they can get down. I remember A2's mission "Razor Two" where you start on a building's rooftop in Chernogorsk and the AI manages to take the stairs once the briefing is done. Either the AI worsened since then or it's just related to this particular building. Can anyone confirm this behaviour? I've also noticed (and posted to 1.24 feedback thread) that the AI falls off of watchtowers (especially those huge ones) once they're under attack (they simply walk through the walls).

Share this post


Link to post
Share on other sites

If you mocap all the soldiers first shooting some rounds off the roof and then tactically sweeping down to the first floor this would be the most epic Arma scene of all time :-)

Share this post


Link to post
Share on other sites

There's no first floor. oO It's just the rooftop, a ladder leading to a porch roof and a stair case going three floors down. Not sure if unitCapture is actually working on infantry but I could always use my savings to hire BIS' motion capture services and get myself some custom animations. :D (Though I doubt I'd have enough.)

Share this post


Link to post
Share on other sites

Pete, this issue has been around since OPF. I strongly suggest you find an alternative drop-off point before you have no hair left... Don't count on a solution at thios point unless you set allowdamage to false till they hit the ground.

Share this post


Link to post
Share on other sites

Yeah, seems like one of BIS' classic running gags. They are on allowDamage false for now. In fact, they're also setCaptive true because in this particular situation I spawned WEST classnames into and EAST group and they start killing each other once they leave the chopper if I don't set them captive. So, I guess one immersion breaker more won't hurt at this point. xX But on the bright side, the helo insertion is just one of four possible means of insertion the player can pick from so it's not that bad after all.

But speaking of this - in my opinion - way too static side system: It also hasn't changed since OFP. Sad, because it's just so damn limiting in some situations and I don't see any necessity. Why not just have definable sides / factions and relations between them and make classnames available to any side? But that's antoher topic, there's still hope for Arma 4...^^

Share this post


Link to post
Share on other sites
Yeah, seems like one of BIS' classic running gags. They are on allowDamage false for now. In fact, they're also setCaptive true because in this particular situation I spawned WEST classnames into and EAST group and they start killing each other once they leave the chopper if I don't set them captive. So, I guess one immersion breaker more won't hurt at this point. xX But on the bright side, the helo insertion is just one of four possible means of insertion the player can pick from so it's not that bad after all.

But speaking of this - in my opinion - way too static side system: It also hasn't changed since OFP. Sad, because it's just so damn limiting in some situations and I don't see any necessity. Why not just have definable sides / factions and relations between them and make classnames available to any side? But that's antoher topic, there's still hope for Arma 4...^^

Or you could script the chopper being shot down, crash landing near the hospital as some kind of "that's what you get for landing too close to the AO" lesson.

For additional flavor add "I told you this was gonna happen" from one of the squadmates.

Share this post


Link to post
Share on other sites

mmm my suggestion would simply micromanage every aspect up tell the point they finally get on ground floor. AI can fire at targets in Aware mode, so you could work on simply forcing them out of the state, or even micromanaging there stances so it "appears" they are in combat mode. I know it all sounds clunky and unneeded but that is the Arma way sometimes.

Share this post


Link to post
Share on other sites

Thanks guys, but I one chopper crash per campaign is enough in my opinion and I've got that covered already.^^ Micromanaging? So I'd have to give exact move commands to make up some kind of pathfinding on my own. Sounds interesting, I'll look into it. However, it's not even said that the player has a team as he picks that (like the way of insertion) before the mission. In some cases, players will choose to go on their own.

Share this post


Link to post
Share on other sites

uhm, I've been giving a thought or two about this....

What about putting a trigger on the boundaries of the hospital?

If any teammate enters, execute a script which checks the getpos unit select 2 number, if it higher than, let's say, 10 meters, play an anim like he's rappeling, you may setdir the unit to the building position and attach it in the same way the rappel heli insertions work. Very CoD :)

Share this post


Link to post
Share on other sites

Well, that certainly sounds interesting but they tend to jump off the roof like suicides. It will likely look as glitchy as it is now.^^

Share this post


Link to post
Share on other sites

Yes, but the trigger will fire as soon as they are on the falling side, and it attaches the unit instantly to the building (complex calculation of the attachment position, but at least, it's the same building position used as reference allways, and is the same z starting coord), so they don't fall, make them play an anim, and smoothly change the z attach variable to the ground.

Let's say the getPos building is [4,8,0];

Let's say the trigger fires on a unit which is on [8,4,30];

First, make the soldier look at the buildingPos: _dir = [_unit, building] call BIS_fnc_dirTo;

Then, make the _unit setDir _dir (or _dir + 180, whatever) Will look tacky, cause will not look straight to the wall, but you may make some if (_dir > 0 and _dir < 20) then {_dir = 10} fine tuning the angle for better view, error and trial, but you are using an specific building, not difficult.

_x = (getPos building _select 0) - (getPos _unit select 0);//-4

_y = (getPos building _select 1) - (getPos _unit select 1);//4

_z = getPos _unit select 2;//30

_unit switchMove "whateveranim";

while {!isTouchingGround _unit} do

{

_unit attachTo [building, [_x,_y,_z]];

_z = _z - 0.3;

sleep 0.1;

};

detach _unit;

_unit switchMove "";

May worth a try....

Share this post


Link to post
Share on other sites

Thanks, but I think I'll keep the invincibility approach for now. :) Maybe I'll get back to that later when the rough version of the mission is done.

Share this post


Link to post
Share on other sites

what you can do is have 2 triggers, an inner and outer trigger

If the ai unit leaves the inner trigger and the height above terrain level > than say 1, then setdir the unit 180 degrees and setpos him 1 metre back from where it came.

That way, if you have a rectangle inner trigger say 1m from the edge of the building, the AI will never get to the edge.

It will look a little gamey, however I use a similar type of boundary enforcement in some missions for players, just using 1 trigger as a limit of advance

This is the code for the LOA border control system, you should be able to easily adapt this for your particular requirements

You will need to add a

if(unit (getposASL select 3) <2)exitwith{};

and also exit if the unit in the list is a player

// AUTHOR	:	Original Mike (MK4)
// MP MACHINE	:	ALL
// Called from	:	Trigger On activation field
// Called using	:	 nul = [0] spawn Txu_fBorderControl;
// Time Called	:	Trigger activatiion
// Description	:
//
// COMMENTS	:
//
// Create a trigger with the following settings:
// - Repeatedly
// - Activation by (side you wish to impose the LOA on)
// - Cond: (vehicle player in thisList)
// - On Act:  nul = [] spawn Txu_fBorderControl;
// - On Deact:
//
// To exclude a player or a vehicle from the LOA, put this in its init line:
// this setVariable ["Txu_NoLOA", false];
//


//


 private["_sy","_sc", "_distance", "_msg", "_vel", "_velX", "_velY", "_velZ", "_dir", "_pos", "_posX", "_posY", "_posZ", "_eh", "_key","_disabledKeys" ];
 _sy = "MISC";
 _sc = "fbordercontrol";
 if(Txu_Debug)  then {[_sy,_sc,"START",_this]call Txu_fDebug_ScriptInit};


_veh = vehicle player;
_distance = 4; // preferred bumping distance


if ( format["%1",_veh getVariable "Txu_NoLOA"] != "false" ) then
{
 // send the player a message (standard msg when none was given)
 _msg = if (count _this > 0) then { _this select 0 } else
   { format["%1, you were entering a RESTRICTED ZONE. Check your map.", toUpper(name player)] };
 titleText [_msg, "PLAIN"];

 // no need for multiple people to do this
 if ( player == driver _veh ) then
 {
   // get the velocity vector
   _vel = velocity _veh;
   _velX = _vel select 0;
   _velY = _vel select 1;
   _velZ = _vel select 2;

   // get the direction of movement (could be different from the direction of the unit)
   _dir = [[0,0,0], _vel] call Txu_Misc_fDirTo;

   // turn 180
   _dir = _dir + 180;
   _veh setDir _dir;

   // place unit a few meters forward
   _pos = getPosATL _veh;
   _posX = _pos select 0;
   _posY = _pos select 1;
   _posZ = _pos select 2;
   _veh setPosATL [(_posX + sin(_dir) * _distance), (_posY + cos(_dir) * _distance), _posZ];

   // reverse the velocity vector
   _veh setVelocity [-_velX, -_velY, -_velZ];

   // if it was a footmobile, freeze userinput for a second
   // - needed because the LOA will be checked every 0.5 sec
   // - workaround for buggy disableUserInput
   if ( player == _veh ) then
   {
     Tx_fDisableMovementKeys = {
       _key = _this select 1;
       _disabledKeys = (actionKeys "moveForward") +  (actionKeys "moveBack") + (actionKeys "MoveLeft") +  (actionKeys "MoveRight");

       if ( _key in _disabledKeys ) then { true } else { false };
     };
     _eh = (findDisplay 46) displayAddEventhandler ["keyDown", "_this call Tx_fDisableMovementKeys"];
     uisleep 1;
     (findDisplay 46) displayRemoveEventHandler ["keyDown", _eh];
   };
 };
};


// end



 if(Txu_Debug)  then {[_sy,_sc,"END"]call Txu_fDebug_ScriptInit};

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  

×