allow/setDamage and disableAI tweaks

This commit is contained in:
vbawol 2017-08-18 12:06:46 -05:00
parent f0fbbe2cbb
commit 94c5fee877
6 changed files with 145 additions and 161 deletions

View File

@ -178,16 +178,9 @@ if (!isNull _player) then {
_newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"]; _newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"];
if !(isNull _newPlyr) then { if !(isNull _newPlyr) then {
// disable damage server side
_newPlyr allowDamage false;
// add to cleanup
addToRemainsCollector[_newPlyr];
{
_newPlyr disableAI _x;
} forEach["FSM", "MOVE", "AUTOTARGET", "TARGET"];
_newPlyr setDir _dir; // disable AI on temp unit
_newPlyr setPosATL _location; _newPlyr disableAI "ALL";
if (!_alreadyDead) then { if (!_alreadyDead) then {
// Medical // Medical
@ -200,6 +193,12 @@ if (!isNull _player) then {
_playerData = _defaultData; _playerData = _defaultData;
}; };
// disable further damage server side
_newPlyr allowDamage false;
_newPlyr setDir _dir;
_newPlyr setPosATL _location;
// set player loadout // set player loadout
if (_schemaVersion >= 1.0) then { if (_schemaVersion >= 1.0) then {
_playerData params ["","","","","","_loadout"]; _playerData params ["","","","","","_loadout"];
@ -317,6 +316,10 @@ if (!isNull _player) then {
deleteVehicle _newPlyr; deleteVehicle _newPlyr;
diag_log "Epoch: DEBUG: _player object was null reject connection"; diag_log "Epoch: DEBUG: _player object was null reject connection";
} else { } else {
// add to cleanup
addToRemainsCollector[_newPlyr];
_reject = false; _reject = false;
if (_playerGroup != "") then { if (_playerGroup != "") then {

View File

@ -33,9 +33,7 @@ _location = getMarkerPos "respawn_west";
_location set[2, 0]; _location set[2, 0];
_player = (group _player) createUnit [_class, _location, [], 0, "CAN_COLLIDE"]; _player = (group _player) createUnit [_class, _location, [], 0, "CAN_COLLIDE"];
{ _player disableAI "ALL";
_player disableAI _x;
} forEach["FSM", "MOVE", "AUTOTARGET", "TARGET"];
_player setDir _dir; _player setDir _dir;
_player setPosATL _location; _player setPosATL _location;

View File

@ -110,19 +110,17 @@ if (!local _player) then {
}; };
_newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"]; _newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"];
// new Dynamicsimulation // new Dynamicsimulation
if(["CfgDynamicSimulation", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntryV2)then if(["CfgDynamicSimulation", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntryV2)then
{ {
_newPlyr enableDynamicSimulation true; _newPlyr enableDynamicSimulation true;
_newPlyr triggerDynamicSimulation true; _newPlyr triggerDynamicSimulation true;
}; };
addToRemainsCollector[_newPlyr]; addToRemainsCollector[_newPlyr];
{ _newPlyr disableAI "ALL";
_newPlyr disableAI _x;
}forEach["FSM", "MOVE", "AUTOTARGET", "TARGET"];
_newPlyr setVariable ["SETUP", true]; _newPlyr setVariable ["SETUP", true];
_newPlyr setVariable ["PUID", _playerUID]; _newPlyr setVariable ["PUID", _playerUID];
@ -247,7 +245,7 @@ if (!local _player) then {
// send to player // send to player
[_newPlyr, _token, loadAbs _newPlyr] remoteExec ['EPOCH_clientRevive',_player]; [_newPlyr, _token, loadAbs _newPlyr] remoteExec ['EPOCH_clientRevive',_player];
// send stat to reviver // send stat to reviver
[_reviver, "Revives", 1, true] call EPOCH_server_updatePlayerStats; [_reviver, "Revives", 1, true] call EPOCH_server_updatePlayerStats;
}; };

View File

@ -86,13 +86,6 @@ if (_allowSave) then{
// appearance now handled with getUnitLoadout, typeof is still need to determine players class. // appearance now handled with getUnitLoadout, typeof is still need to determine players class.
_appearance = ["", "", "", "", "", typeOf _player]; _appearance = ["", "", "", "", "", typeOf _player];
/* Old unused method
_appearance = [goggles _player, headgear _player, vest _player, backpack _player, uniform _player, typeOf _player];
_itemsplayer = [getItemCargo(uniformContainer _player), getItemCargo(vestContainer _player), getItemCargo(backpackContainer _player)];
_weaponsplayer = [getWeaponCargo(uniformContainer _player), getWeaponCargo(vestContainer _player), getWeaponCargo(backpackContainer _player)];
_weapons = [currentWeapon _player, weaponsItems _player, [primaryWeapon _player, secondaryWeapon _player, handgunWeapon _player]];
*/
// new save format // new save format
_loadout = getUnitLoadout _player; _loadout = getUnitLoadout _player;

View File

@ -1,19 +1,19 @@
/* /*
Author: Aaron Clark - EpochMod.com Author: Aaron Clark - EpochMod.com
Contributors: Contributors:
Description: Description:
Load Vehicles Load Vehicles
Licence: Licence:
Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike
Github: Github:
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_vehicle/EPOCH_load_vehicles.sqf
*/ */
//[[[cog import generate_private_arrays ]]] //[[[cog import generate_private_arrays ]]]
private ["_actualHitpoints","_allHitpoints","_allVehicles","_allowDamage","_arr","_arrNum","_availableColorsConfig","_baseClass","_cfgEpochVehicles","_check","_class","_color","_colors","_config","_count","_damage","_dataFormat","_dataFormatCount","_diag","_dmg","_found","_hitpoints","_immuneIfStartInBase","_jammerOwner","_jammerRange","_jammers","_location","_lockedOwner","_mags","_marker","_nearestJammer","_removemagazinesturret","_removeweapons","_response","_selections","_serverSettingsConfig","_textureSelectionIndex","_textures","_vehHiveKey","_vehLockHiveKey","_vehicle","_vehicleDamages","_vehicleSlotIndex","_worldspace"]; private ["_actualHitpoints","_allHitpoints","_allVehicles","_allowDamage","_arr","_arrNum","_availableColorsConfig","_cfgEpochVehicles","_check","_class","_colors","_config","_count","_dataFormat","_dataFormatCount","_diag","_dmg","_found","_immuneIfStartInBase","_jammerOwner","_jammerRange","_jammers","_location","_lockedOwner","_marker","_nearestJammer","_removemagazinesturret","_removeweapons","_response","_selections","_serverSettingsConfig","_textureSelectionIndex","_textures","_vehHiveKey","_vehLockHiveKey","_vehicle","_vehicleSlotIndex"];
//[[[end]]] //[[[end]]]
params [["_maxVehicleLimit",0]]; params [["_maxVehicleLimit",0]];
@ -22,7 +22,7 @@ _dataFormat = ["", [], 0, [], 0, [], [], 0, ""];
_dataFormatCount = count _dataFormat; _dataFormatCount = count _dataFormat;
EPOCH_VehicleSlots = []; EPOCH_VehicleSlots = [];
_allVehicles = []; _allVehicles = [];
_vehicleDamages = [];
_config = 'CfgEpochClient' call EPOCH_returnConfig; _config = 'CfgEpochClient' call EPOCH_returnConfig;
_jammerRange = getNumber(_config >> "buildingJammerRange"); _jammerRange = getNumber(_config >> "buildingJammerRange");
@ -62,11 +62,10 @@ for "_i" from 1 to _maxVehicleLimit do {
if !((_arr select _forEachIndex) isEqualType _x) then {_arr set[_forEachIndex, _x]}; if !((_arr select _forEachIndex) isEqualType _x) then {_arr set[_forEachIndex, _x]};
} forEach _dataFormat; } forEach _dataFormat;
_class = _arr select 0; _arr params ["_class","_worldspace","_damage","_hitpoints","_fuel","_inventory","_ammo","_color","_baseClass"];
_worldspace = _arr select 1;
_damage = _arr select 2;
if (_class != "" && _damage < 1) then { if (_class != "" && _damage < 1) then {
// remove location from worldspace and set to new var
_location = _worldspace deleteAt 0; _location = _worldspace deleteAt 0;
if !(_location isEqualTo []) then { if !(_location isEqualTo []) then {
@ -87,91 +86,10 @@ for "_i" from 1 to _maxVehicleLimit do {
// turn off BIS randomization // turn off BIS randomization
_vehicle setVariable ["BIS_enableRandomization", false]; _vehicle setVariable ["BIS_enableRandomization", false];
if !(isNull _vehicle) then { if !(isNull _vehicle) then {
// make vehicle immune from damage.
_vehicle allowDamage false;
// store spawned vehicles in array to make one call to remains handler
_allVehicles pushBack _vehicle;
// remove selected slot from array and set on vehicle
EPOCH_VehicleSlots deleteAt _vehicleSlotIndex;
_vehicle setVariable ["VEHICLE_SLOT", str(_i), true];
// set server side token and init vehicle event handlers.
_vehicle call EPOCH_server_setVToken;
_vehicle call EPOCH_server_vehicleInit;
// set final direction and postion of vehicle
_vehicle setVectorDirAndUp _worldspace;
_vehicle setposATL _location;
// push damage to temp array to apply damage after some delay
_vehicleDamages pushBack [_vehicle,_damage,(_arr select 3)];
// set fuel level
_vehicle setFuel (_arr select 4);
// apply persistent textures
_cfgEpochVehicles = 'CfgEpochVehicles' call EPOCH_returnConfig;
_availableColorsConfig = (_cfgEpochVehicles >> _class >> "availableColors");
if (isArray(_availableColorsConfig)) then {
_color = _arr select 7;
_colors = getArray(_availableColorsConfig);
_textureSelectionIndex = (_cfgEpochVehicles >> _class >> "textureSelectionIndex");
_selections = if (isArray(_textureSelectionIndex)) then { getArray(_textureSelectionIndex) } else { [0] };
_count = (count _colors) - 1;
{
_textures = _colors select 0;
if (_count >= _forEachIndex) then {
_textures = _colors select _forEachIndex;
};
_vehicle setObjectTextureGlobal [_x, _textures select _color];
} forEach _selections;
_vehicle setVariable ["VEHICLE_TEXTURE", _color];
};
_baseClass = _arr select 8;
if !(_baseClass isequalto "") then {
_vehicle setvariable ["VEHICLE_BASECLASS",_baseClass];
};
// disable thermal imaging equipment
_vehicle disableTIEquipment true;
// lock all vehicles
_vehicle lock true;
// load vehicle inventory
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
clearBackpackCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
if !(_removeweapons isequalto []) then {
{
_vehicle removeWeaponGlobal _x;
} foreach _removeweapons;
};
if !(_removemagazinesturret isequalto []) then {
{
_vehicle removeMagazinesTurret _x;
} foreach _removemagazinesturret;
};
// utilize He-Man's new Cargo functions
[_vehicle,_arr select 5] call EPOCH_server_CargoFill;
// remove and add back magazines
if !((_arr select 6) isequalto []) then {
if ((_arr select 6 select 0) isequaltype true) then {
{
_vehicle removeMagazinesTurret [_x select 0, _x select 1];
} foreach magazinesAllTurrets _vehicle;
{
if ((_x select 2) > 0) then {
_vehicle addMagazineTurret [_x select 0,_x select 1,_x select 2];
};
} foreach (_arr select 6 select 1);
}
else {
{_vehicle removeMagazineGlobal _x}count (magazines _vehicle);
{_vehicle addMagazine _x}count (_arr select 6);
};
};
// set damage and hitpoints // set damage and hitpoints
_vehicle setDamage _damage; _vehicle setDamage _damage;
_allHitpoints = getAllHitPointsDamage _vehicle; _allHitpoints = getAllHitPointsDamage _vehicle;
_hitpoints = _arr select 3;
if !(_allHitpoints isEqualTo []) then{ if !(_allHitpoints isEqualTo []) then{
_actualHitpoints = _allHitpoints select 0; _actualHitpoints = _allHitpoints select 0;
if ((count _actualHitpoints) == (count _hitpoints)) then{ if ((count _actualHitpoints) == (count _hitpoints)) then{
@ -185,32 +103,111 @@ for "_i" from 1 to _maxVehicleLimit do {
}; };
}; };
// allow damage // make vehicle immune from further damage.
_allowDamage = true; _vehicle allowDamage false;
if (_immuneIfStartInBase) then {
_jammers = nearestObjects[_vehicle, ["PlotPole_EPOCH"], _jammerRange];
if!(_jammers isEqualTo [])then {
// get jammer owner
_nearestJammer = _jammers select 0;
_jammerOwner = _nearestJammer getVariable["BUILD_OWNER", "-2"];
// get vehicle lock owner
_lockedOwner = "-1";
_vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), str(_i)];
(["VehicleLock", _vehLockHiveKey] call EPOCH_fnc_server_hiveGETRANGE) params [["_status", 0 ],["_payload", [] ]];
if (_status isEqualTo 1) then {
_lockedOwner = _payload param [0,"-1"];
};
// if match keep vehicle immune till first unlock
if (_jammerOwner isEqualTo _lockedOwner) then {
_vehicle setVariable ["EPOCH_disallowedDamage", true];
_allowDamage = false;
};
};
};
if (_allowDamage) then { // store spawned vehicles in array to make one call to remains handler
_vehicle allowDamage true; _allVehicles pushBack _vehicle;
}; // remove selected slot from array and set on vehicle
EPOCH_VehicleSlots deleteAt _vehicleSlotIndex;
_vehicle setVariable ["VEHICLE_SLOT", str(_i), true];
// set server side token and init vehicle event handlers.
_vehicle call EPOCH_server_setVToken;
_vehicle call EPOCH_server_vehicleInit;
// set final direction and postion of vehicle
_vehicle setVectorDirAndUp _worldspace;
_vehicle setposATL _location;
// set fuel level
_vehicle setFuel _fuel;
// apply persistent textures
_cfgEpochVehicles = 'CfgEpochVehicles' call EPOCH_returnConfig;
_availableColorsConfig = (_cfgEpochVehicles >> _class >> "availableColors");
if (isArray(_availableColorsConfig)) then {
_colors = getArray(_availableColorsConfig);
_textureSelectionIndex = (_cfgEpochVehicles >> _class >> "textureSelectionIndex");
_selections = if (isArray(_textureSelectionIndex)) then { getArray(_textureSelectionIndex) } else { [0] };
_count = (count _colors) - 1;
{
_textures = _colors select 0;
if (_count >= _forEachIndex) then {
_textures = _colors select _forEachIndex;
};
_vehicle setObjectTextureGlobal [_x, _textures select _color];
} forEach _selections;
_vehicle setVariable ["VEHICLE_TEXTURE", _color];
};
if !(_baseClass isequalto "") then {
_vehicle setvariable ["VEHICLE_BASECLASS",_baseClass];
};
// disable thermal imaging equipment
_vehicle disableTIEquipment true;
// lock all vehicles
_vehicle lock true;
// load vehicle inventory
clearWeaponCargoGlobal _vehicle;
clearMagazineCargoGlobal _vehicle;
clearBackpackCargoGlobal _vehicle;
clearItemCargoGlobal _vehicle;
if !(_removeweapons isequalto []) then {
{
_vehicle removeWeaponGlobal _x;
} foreach _removeweapons;
};
if !(_removemagazinesturret isequalto []) then {
{
_vehicle removeMagazinesTurret _x;
} foreach _removemagazinesturret;
};
// utilize He-Man's new Cargo functions
[_vehicle,_inventory] call EPOCH_server_CargoFill;
// remove and add back magazines
if !(_ammo isequalto []) then {
if ((_ammo select 0) isequaltype true) then {
{
_vehicle removeMagazinesTurret [_x select 0, _x select 1];
} foreach magazinesAllTurrets _vehicle;
{
if ((_x select 2) > 0) then {
_vehicle addMagazineTurret [_x select 0,_x select 1,_x select 2];
};
} foreach (_ammo select 1);
}
else {
{_vehicle removeMagazineGlobal _x}count (magazines _vehicle);
{_vehicle addMagazine _x}count _ammo;
};
};
// allow damage
_allowDamage = true;
if (_immuneIfStartInBase) then {
_jammers = nearestObjects[_vehicle, ["PlotPole_EPOCH"], _jammerRange];
if!(_jammers isEqualTo [])then {
// get jammer owner
_nearestJammer = _jammers select 0;
_jammerOwner = _nearestJammer getVariable["BUILD_OWNER", "-2"];
// get vehicle lock owner
_lockedOwner = "-1";
_vehLockHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), str(_i)];
(["VehicleLock", _vehLockHiveKey] call EPOCH_fnc_server_hiveGETRANGE) params [["_status", 0 ],["_payload", [] ]];
if (_status isEqualTo 1) then {
_lockedOwner = _payload param [0,"-1"];
};
// if match keep vehicle immune till first unlock
if (_jammerOwner isEqualTo _lockedOwner) then {
_vehicle setVariable ["EPOCH_disallowedDamage", true];
_allowDamage = false;
};
};
};
if (_allowDamage) then {
_vehicle allowDamage true;
};
// new Dynamicsimulation // new Dynamicsimulation
if(["CfgDynamicSimulation", "vehicleDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntryV2)then if(["CfgDynamicSimulation", "vehicleDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntryV2)then
@ -219,17 +216,6 @@ for "_i" from 1 to _maxVehicleLimit do {
_vehicle enableDynamicSimulation true; _vehicle enableDynamicSimulation true;
}; };
// turrets
/*
_mags = _vehicle magazinesTurret [0];
{
_object removeMagazinesTurret [_x, [0]];
} forEach _mags;
_mags = _vehicle magazinesTurret [-1];
{
_object removeMagazinesTurret [_x, [-1]];
} forEach _mags;
*/
if (EPOCH_DEBUG_VEH) then { if (EPOCH_DEBUG_VEH) then {
_marker = createMarker [str(_location) , _location]; _marker = createMarker [str(_location) , _location];
_marker setMarkerShape "ICON"; _marker setMarkerShape "ICON";

View File

@ -25,6 +25,17 @@ _vehObj = createVehicle[_vehClass, _position, [], 0, _can_collide];
_vehObj setVariable ["BIS_enableRandomization", false]; _vehObj setVariable ["BIS_enableRandomization", false];
if !(isNull _vehObj) then{ if !(isNull _vehObj) then{
_vehObj call EPOCH_server_setVToken; _vehObj call EPOCH_server_setVToken;
// add random damage to vehicle (avoid setting engine or fuel to 100% damage to prevent instant destruction)
if (_spawnDamaged) then {
{
_maxDamage = if (_x in ["HitEngine","HitFuel"]) then {0.9} else {1};
_vehObj setHitIndex [_forEachIndex,((random 1 max 0.1) min _maxDamage)];
} forEach ((getAllHitPointsDamage _vehObj) param [0,[]]);
};
// make vehicle immune from further damage.
_vehObj allowDamage false;
// Set Direction and position // Set Direction and position
if (_direction isEqualType []) then{ if (_direction isEqualType []) then{
_vehObj setVectorDirAndUp _direction; _vehObj setVectorDirAndUp _direction;
@ -59,14 +70,6 @@ if !(isNull _vehObj) then{
// randomize fuel TODO push min max to config // randomize fuel TODO push min max to config
_vehObj setFuel ((random 1 max 0.1) min 0.9); _vehObj setFuel ((random 1 max 0.1) min 0.9);
// add random damage to vehicles (avoid setting engine or fuel to 100% damage to prevent instant destruction)
if (_spawnDamaged) then {
{
_maxDamage = if (_x in ["HitEngine","HitFuel"]) then {0.9} else {1};
_vehObj setHitIndex [_forEachIndex,((random 1 max 0.1) min _maxDamage)];
} forEach ((getAllHitPointsDamage _vehObj) param [0,[]]);
};
// get colors from config // get colors from config
_cfgEpochVehicles = 'CfgEpochVehicles' call EPOCH_returnConfig; _cfgEpochVehicles = 'CfgEpochVehicles' call EPOCH_returnConfig;
_availableColorsConfig = (_cfgEpochVehicles >> _vehClass >> "availableColors"); _availableColorsConfig = (_cfgEpochVehicles >> _vehClass >> "availableColors");
@ -133,6 +136,9 @@ if !(isNull _vehObj) then{
// Add to A3 remains collector // Add to A3 remains collector
addToRemainsCollector[_vehObj]; addToRemainsCollector[_vehObj];
// make vehicle mortal again
_vehObj allowDamage true;
} else { } else {
diag_log format["DEBUG: Failed to create vehicle: %1", _this]; diag_log format["DEBUG: Failed to create vehicle: %1", _this];
}; };