Home   Help Search Login Register  

Author Topic: No driver fix needed  (Read 1377 times)

0 Members and 1 Guest are viewing this topic.

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
No driver fix needed
« on: 19 Sep 2008, 13:32:07 »
Frequently when I go around the warfare map I will find uaz's and hmmv's that have had their driver killed, but with a perfectly healthy gunner and passenger in a barely damaged vehicle.  Instead of having them just sit there as an immobile defense, I want them to get moving.
 How can we 1)detect if the driver is dead but passenger/gunner is alive, 2)order the passenger to get in the driver seat and re-join his unit or 3)if there is no passenger, then order the gunner to get in the driver's seat and rejoin his unit or 4)order everyone out of the vehicle if the driver is dead and they rejoin their unit on foot?
 If I was in a vehicle as a passenger or gunner and my driver was shot out, I would, as a player, move to the drivers' seat and continue onward.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: No driver fix needed
« Reply #1 on: 21 Sep 2008, 01:56:24 »
I don't know how warfare is structured, but you would do this by adding a killed eventhandler to each driver. The killed eventhandler would call a script that would check if a gunner or passenger existed and then assign them to be driver.
urp!

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re: No driver fix needed
« Reply #2 on: 21 Sep 2008, 02:35:05 »
all the ai controlled vehicles are created on the fly from scripts
I have been able to determine if the driver is dead but detecting if there is a gunner or passenger is generating errors...here is the code I am trying, with some additions not needed in the final version:

Code: [Select]
; ****************************************************************
; Script file for Armed Assault
; Created by: {USI}_Studios/{USI}_Zombie
; ****************************************************************
_vehicle = _this;
_gu = crew _vehicle select 1;
;;_pa = crew _vehicle select 2;

;;trying to get vehicles moving with dead drivers
#starthere
?(driver _vehicle !isnull) and (crew _vehicle select 1) !isnull and (crew _vehicle select 2) !isnull then goto "allalive";
?(driver _vehicle isnull) and (crew _vehicle select 1) !isnull and (crew _vehicle select 2) !isnull then goto "passenger";
?(driver _vehicle isnull) and (crew _vehicle select 1) !isnull and (crew _vehicle select 2) isnull then goto "gunner";
#passenger
unassignvehicle _gu;
_gu assignAsDriver _vehicle;
_gu moveindriver _vehicle;
#allalive
player sidechat "all alive";
goto "starthere";
end


Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: No driver fix needed
« Reply #3 on: 21 Sep 2008, 12:49:53 »
You will get an error if there are less than 3 crew in the vehicle, since you won't be able to use select on the crew array.

The gunner is "gunner _vehicle", not "_crew select 1". If you don't have a driver, then the gunner won't be at index 1.

You are getting your syntax inverted. The correct syntax for isNull is:
Code: [Select]
isNull driver _vehicle;

Crew array can contain corpses. Thus, you should be using "alive _person", not "isNull _person".
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Zombie

  • Members
  • *
  • Beware the night, the zombie walks among you
    • USI
Re: No driver fix needed
« Reply #4 on: 21 Sep 2008, 13:52:20 »
  Ok, that's a start, I did notice a gunner _vehicle option, but what about a passenger (unit in cargo)?  That's why I was using crew

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: No driver fix needed
« Reply #5 on: 21 Sep 2008, 14:46:09 »
The passengers are (if you ignore dual-gunner vehicles like some boats and blackhawks):
Code: [Select]
_passengers = (crew _vehicle) - ([driver _vehicle] + [gunner _vehicle] + [commander _vehicle]);

You could also use assignedVehicleRole to work out which individuals were cargo within the crew (which does take into account the dual-gunner vehicles).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)