Jump to content
  • 0

Best way to spawn "reward" vehicles?


SlightlyDaft

Question

Hi everyone, we want to create a well defended AI base, where the reward is a vehicle/heli or two. Once players fight their way into the base they can take these "reward" vehicles and keep them, just as if they had found the random vehicle spawns. So once they have been collected, they should persist over server restarts,

 

Also, at server restart, no matter if the vehicles have been claimed or not, the vehicles should be available again...ideally based on a random spawn chance...

 

What is the best or correct way to do this, and where would we put the code, also some code examples would be really helpful.

 

Keep it simple please :)

 

Thanks,

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Thanks, I am using A3EAI at the moment, but will take a look at WAI. 

 

Using WAI, do the vehicles persist over server restarts if a player has snagged one?

 

there is a script to custom_publish a vehicle. however, I found that there is some sort of vehicle limit imposed by Epoch and if your EPOCH_VehicleSlotCount==0 there is no way to add a new database slot.So the workaround that I use is to look for a rubber boat or a kart nearby, remove it and use it's database slot to publish the vehicle that the player has won from AI on a mission

 

If someone has any idea on how to add a new vehicle slot to the database, please share

_instanceID = call EPOCH_fn_InstanceID;
diag_log format["WAI: _instanceID:%1",_instanceID];
diag_log format["WAI: EPOCH_VehicleSlotCount:%1",EPOCH_VehicleSlotCount];
diag_log format["WAI: EPOCH_VehicleSlots:%1",EPOCH_VehicleSlots];
// _allowedVehicleList = EPOCH_allowedVehiclesList;
// diag_log format["WAI: EPOCH_allowedVehiclesList:%1",_allowedVehicleList];
_vehObj = _this;
_randomVehicleIndex = -1;

if (EPOCH_VehicleSlotCount==0) then {
	
	if (!isNil "EPOCH_allowedVehiclesList") then {
		_countAllowedVeh=count EPOCH_allowedVehiclesList;
		_randomVehicleIndex=floor(random(_countAllowedVeh));
		_randomVehicle=EPOCH_allowedVehiclesList select _randomVehicleIndex;
		_vehClass=_randomVehicle select 0;
		_velimit=_randomVehicle select 1;
		_vehicleCount={typeOf _x==_vehClass}count vehicles;
		if(_vehicleCount >=_velimit)then{
			EPOCH_allowedVehiclesList deleteAt _randomVehicleIndex;
		} else {
			if(_vehicleCount==(_velimit-1))then{
				EPOCH_allowedVehiclesList deleteAt _randomVehicleIndex;
			};
		};
	} else {
		_vehlist = nearestObjects [position _vehObj, ["C_Rubberboat_EPOCH","C_Rubberboat_02_EPOCH","C_Rubberboat_03_EPOCH","C_Rubberboat_04_EPOCH""C_Boat_Civil_01_EPOCH","K01","K02","K03","K04","jetski_epoch"], 10000];
		diag_log format["WAI: count _vehlist:%1 | _randomVehicle:%2",count _vehlist,_vehlist select 0];
		_vehToDelete = _vehlist select 0;
		_randomVehicleIndex = _vehToDelete getVariable["VEHICLE_SLOT","ABORT"];
		deleteVehicle _vehToDelete;
	};

};
_slot = "";
if !(EPOCH_VehicleSlots isEqualTo[]) then {
	_slot = EPOCH_VehicleSlots select 0;
	EPOCH_VehicleSlots = EPOCH_VehicleSlots - [_slot];
	EPOCH_VehicleSlotCount = count EPOCH_VehicleSlots;
	publicVariable 'EPOCH_VehicleSlotCount';
} else {
	diag_log format["WAI: _slot = _randomVehicleIndex:%1",_randomVehicleIndex];
	_slot = _randomVehicleIndex;
};
	
if (str(_slot) != "") then {
	_vehObj setVariable["VEHICLE_SLOT",_slot,true];

	private["_aa","_ab","_ac","_ad","_ae","_af","_ag","_ah","_ai","_aj","_ak","_al","_am","_an","_ao","_ap","_aq","_ar"];
	if(!isNull _vehObj) then {
		_aa=_vehObj;
		// _ac=_vehObj getVariable["VEHICLE_SLOT","ABORT"];
		// if(_ac !="ABORT")then{
			_ad=format["%1:%2",(call EPOCH_fn_InstanceID),_slot];
			_aj=[];
			_ak=_aa call EPOCH_getHitpoints;
			{
				_aj pushBack(_aa getHitPointDamage _x);
			}forEach _ak;
			_wepsItemsCargo=weaponsItemsCargo _aa;
			if(isNil "_wepsItemsCargo")then{
				_wepsItemsCargo=[];
			};
			_magsAmmoCargo=magazinesAmmoCargo _aa;
			if(isNil "_magsAmmoCargo")then{
				_magsAmmoCargo=[];
			};
			_aq=[[],[]];
			{
				_ar=_aq find(_x select 0);
				if(_ar >=0)then{
				(_aq select 1)set[_ar,((_aq select 1)select _ar)+(_x select 1)];}
				else{(_aq select 0)pushBack(_x select 0);(_aq select 1)pushBack(_x select 1);};
			}forEach _magsAmmoCargo;
			_al=[_wepsItemsCargo,_aq,getBackpackCargo _aa,getItemCargo _aa];
			_ap=_aa getVariable["VEHICLE_TEXTURE",0];
			_am=[typeOf _aa,[getposATL _aa,vectordir _aa,vectorup _aa],damage _aa,_aj,fuel _aa,_al,magazinesAmmo _aa,_ap];
			["Vehicle",_ad,EPOCH_expiresVehicle,_am] call EPOCH_server_hiveSETEX;
		//};
	};

	_vehObj call EPOCH_server_vehicleInit;

};
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...