Home   Help Search Login Register  

Author Topic: Preventing AI ejection from tank  (Read 1189 times)

0 Members and 1 Guest are viewing this topic.

Rocko Bonaparte

  • Guest
Preventing AI ejection from tank
« on: 11 Nov 2004, 06:55:58 »
I'm trying to keep an AI unit in a tank until the tank's completely gone and/or the AI die.  I thought I'd be clever and use 'lock' to do this.  It seems to work in preventing ME from getting out of the tank, but the AI will still abandon ship on their own.  A more concrete case is as commander, I can order them to dismount and they will.

It's my understanding that removeAction cannot work in this case.  Hence, I don't know what to fathom trying.  The vehicle in question is part of an addon I am creating, but this seems like a scripting problem to me.  Any suggestions?

Offline Triggerhappy

  • Contributing Member
  • **
  • Llama, it's what's for dinner.
Re:Preventing AI ejection from tank
« Reply #1 on: 11 Nov 2004, 11:00:00 »
Code: [Select]
_tank = _this select 0
_driver = driver _tank
_gunner = gunner _tank
_commander = commander _tank
_cargo = crew _tank - [_commander,_gunner,_driver]

#loop
?!_driver in _tank:_driver moveindriver _tank
?!_gunner in _tank:_gunner moveingunner _tank
?!_commander in _tank:__commander moveincommander _tank
?!"_x in _tank" foreach _cargo:_x moveincargo _tank
~.5
?unlocked = true:goto "end"
?!alive _tank:goto "end"
goto "loop"

#end
exit

you would exec this script when you want it to be locked, using some kind of trigger, howerver you want it to be activated,
[nameoftank] exec "thisScript.sqs"

it checks for a condition called unlocked to end the script if you want them to be able to get out again,
you would use a trigger and however you want it to happen, in activation you put: unlocked = true
and that will cause the script to end

also, this line may not work:
?!"_x in _tank" foreach _cargo:_x moveincargo _tank
i've never used the foreach command like that before, but it should work, if not the script would have to be changed

Rocko Bonaparte

  • Guest
Re:Preventing AI ejection from tank
« Reply #2 on: 12 Nov 2004, 03:50:22 »
So pretty much that script just keeps shoving the people back in the tank?

I have this theory that the AI won't want to stay in the tank once shoved back in.  If I tell them to disembark, and they eject, then it would be fine because that's a one-time thing.  However, they're also ejecting from a heavily-damaged vehicle.  In that case, I am betting they'll just keep ejecting.

But I'll give it a shot -- it seems simple enough.

Rocko Bonaparte

  • Guest
Re:Preventing AI ejection from tank
« Reply #3 on: 15 Nov 2004, 03:23:56 »
I added it to my vehicle spawn script in such a way that it doesn't have to check periodically.  It leads to a rather long conditional event in the script, but it seems to work ok.  If I force a unit to dismount one of the tanks, they try, but never pop up.  The "disembark" status on top of their icon in the bottom bar persists until I give them other orders.  In some tests, I didn't see any crew running around the battlefield, so I guess it was successful.