Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* AI Unit Create Script for special Crewmen or Pilots, fit for usage on ships.
- Use this script especially for important AI's like Pilots or Crewmen which offer services.
- Developed by Steam-User immerfestedruv.
- In the Unit Init Field insert:
- this addEventHandler ["killed", {0 = [_this,5,"blackfish_1","Driver",helipad_2,15] execVM "unit_spawn.sqf"}];
- You need to add some more Init Lines below, to handle the vehicle it should get in.*/
- _unit = (_this select 0) select 0; // First Argument, get Unit's details
- _delay = _this select 1; // Second Argument,get the init set respawn time
- _vehCall = _this select 2; // Third Argument, the Variable-Name of the unit's vehicle(Call-Sign)
- _vehSeat = _this select 3; // Forth Argument, on which Seat shall the unit sit
- _parkPlace = _this select 4; // Fifth Argument, the place where the vehicle parks
- _parkRad = _this select 5; // Sixth Argument, possible park Radius from the center of the vehicle park
- hint format ["unit/delay/vehCall/vehSeat/parkPlace/parkRad %1 / %2 / %3 / %4 / %5 / %6",_unit,_delay,_vehCall,_vehSeat,_parkPlace,_parkRad];
- _dirUnit = getDir _unit; // get original facing
- _posUnit = getPosATL _unit; // get original position
- _unitType = typeOf _unit; // get the unit type
- _unitgroup = group _unit; // get group of the original unit
- _unitName = vehicleVarName _unit; // get the Variable-Name of the unit
- _unitRank = rank _unit; // get the units orignal rank
- _unitSkill = skill _unit; // get the original skill of the unit
- if(isServer) then{
- sleep _delay*4; // sleep a bit
- if(!alive _unit) then { //true if unit is not alive
- deleteVehicle _unit; // clear up old units
- sleep _delay; // respawn time between deletion and respawn
- // create a new unit of same type at starting position
- _unitType createUnit [
- _posUnit,
- _unitgroup,
- // Following sentences are added to the init line of the _unit
- "_unit = this; //_unit is still an object but in nect line it will be an array
- _unit setVariable [ 'unitDef',[_delay,_vehCall,_vehSeat,_parkPlace,_parkRad];
- /* We have to extract the Definitions from our Array, but the array is in the addEventHandler known as
- _this and not as _unit, so we have to define _unit again. */
- _unit addEventHandler ['killed', {
- _unit = _this select 0;
- [_this, (_unit getVariable 'unitDef') select 0, //delay
- (_unit getVariable 'unitDef') select 1, //vehCall
- (_unit getVariable 'unitDef') select 2, //_vehSeat
- (_unit getVariable 'unitDef') select 3, //_parkPlace
- (_unit getVariable 'unitDef') select 4, //_parkRad
- ] execVM 'unit_spawn.sqf'}];
- [this,_delay,_vehCall,_vehSeat,_parkPlace,_parkRad] execVM 'unit_getin.sqf';",
- _unitSkill,
- _unitRank];
- _unit setPosATL _posUnit; // set correct position
- _unit setVehicleVarName _unitName;
- _unit setDir _dirUnit; // set correct facing of the unit
- };
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement