Skip to content

Commit b17c8f2

Browse files
author
Cre8or
committed
Make factory vehicles spawn unowned
- Vehicles spawned by the factory now spawn unowned, and can be claimed by the first person to enter them - The save function now saves unowned vehicles that have a new variable ("OT_forceSaveUnowned") set to true - The load function now applies the "OT_forceSaveUnowned" variable to saved objects that don't have an owner
1 parent 11853eb commit b17c8f2

3 files changed

Lines changed: 17 additions & 9 deletions

File tree

addons/overthrow_main/functions/factions/GUER/fn_GUERLoop.sqf

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -332,11 +332,11 @@ if ((date select 4) != _lastmin) then {
332332
[-_costtoproduce] call OT_fnc_resistanceFunds;
333333
_timespent = _timespent + 1;
334334
}else{
335-
_need = "";
336-
if !(_dowood) then {_need = _need + format["%1 x wood ",_wood]};
337-
if !(_dosteel) then {_need = _need + format["%1 x steel ",_steel]};
338-
if !(_doplastic) then {_need = _need + format["%1 x plastic ",_plastic]};
339-
if !(_domoney) then {_need = _need + format["$%1 resistance funds",_costtoproduce]};
335+
_need = "";
336+
if !(_dowood) then {_need = _need + format["%1 x wood ",_wood]};
337+
if !(_dosteel) then {_need = _need + format["%1 x steel ",_steel]};
338+
if !(_doplastic) then {_need = _need + format["%1 x plastic ",_plastic]};
339+
if !(_domoney) then {_need = _need + format["$%1 resistance funds",_costtoproduce]};
340340
format["Factory has insufficient resources to produce item (need: %1)",_need] remoteExec["OT_fnc_notifyMinor",0,false];
341341
spawner setVariable ["GEURproduceerror",format["Factory has insufficient resources to produce item (need: %1)",_need],true];
342342
};
@@ -363,7 +363,8 @@ if ((date select 4) != _lastmin) then {
363363
_p = OT_factoryVehicleSpawn findEmptyPosition [5,100,_currentCls];
364364
if(count _p > 0) then {
365365
_veh = _currentCls createVehicle _p;
366-
[_veh,(server getVariable ["generals",[]]) select 0] call OT_fnc_setOwner;
366+
//[_veh,(server getVariable ["generals",[]]) select 0] call OT_fnc_setOwner;
367+
_veh setVariable ["OT_forceSaveUnowned", true, false]; // Save this vehicle even if it is unowned (we know somebody must have requested it at the factory, so they'll come back and claim it... eventually)
367368
clearWeaponCargoGlobal _veh;
368369
clearMagazineCargoGlobal _veh;
369370
clearBackpackCargoGlobal _veh;

addons/overthrow_main/functions/save/fn_loadGame.sqf

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,14 @@ sleep 0.3;
221221
clearItemCargoGlobal _veh;
222222
_veh setVariable ["name",_name,true];
223223

224-
[_veh,_owner] call OT_fnc_setOwner;
224+
// If this vehicle doesn't have an owner, set the forceSaveunowned flag to true so it gets saved again (until somebody owns it)
225+
if (_owner isEqualTo "") then {
226+
_veh setVariable ["OT_forceSaveUnowned", true, false];
227+
// Otherwise, set the owner (as per usual)
228+
} else {
229+
[_veh,_owner] call OT_fnc_setOwner;
230+
};
231+
225232
{
226233
[_x,_veh] call {
227234
params ["_it", "_veh"];

addons/overthrow_main/functions/save/fn_saveGame.sqf

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private _tocheck = ((allMissionObjects "Static") + vehicles) select {
105105
(alive _x)
106106
&& {(typeof _x != OT_flag_IND)}
107107
&& {!(typeOf _x isKindOf ["Man", _cfgVeh])}
108-
&& {(_x call OT_fnc_hasOwner)}
108+
&& {(_x call OT_fnc_hasOwner) or (_x getVariable ["OT_forceSaveUnowned", false])}
109109
&& {(_x getVariable["OT_garrison",false]) isEqualTo false}
110110
};
111111

@@ -144,7 +144,7 @@ private _vehicles = (_tocheck) apply {
144144
[getPosWorld _x,_simCheck, 1], // 1 stands for the new posWorld format
145145
[vectorDir _x,vectorUp _x],
146146
_s,
147-
_x call OT_fnc_getOwner,
147+
["", _x call OT_fnc_getOwner] select (_x call OT_fnc_hasOwner), // Save an empty string if the object doesn't have an owner (yet)
148148
_x getVariable ["name",""],
149149
_x getVariable ["OT_init",""]
150150
];

0 commit comments

Comments
 (0)