From 7362b33f3224c40cdaf61aecbe53851273c2c57f Mon Sep 17 00:00:00 2001 From: Spoffy Date: Fri, 12 Jul 2019 23:22:35 +0100 Subject: [PATCH 1/8] Adds Vehicle Placement option for precision placement --- .../displayVehiclePlacementMessage.sqf | 3 +- A3-Antistasi/Garage/vehPlacementBegin.sqf | 29 +++++++++++++------ 2 files changed, 22 insertions(+), 10 deletions(-) diff --git a/A3-Antistasi/Garage/private/displayVehiclePlacementMessage.sqf b/A3-Antistasi/Garage/private/displayVehiclePlacementMessage.sqf index 61e49557d0..f1ee8dec9f 100644 --- a/A3-Antistasi/Garage/private/displayVehiclePlacementMessage.sqf +++ b/A3-Antistasi/Garage/private/displayVehiclePlacementMessage.sqf @@ -6,4 +6,5 @@ params ["_vehType"]; private _vehName = getText (configFile >> "CfgVehicles" >> _vehType >> "displayName"); -[format ["%1
%2
SPACE to place vehicle
Arrow Left-Right to rotate
ENTER to Exit
", _vehName, vehPlace_extraMessage],0,0,5,0,0,4] spawn bis_fnc_dynamicText; +private _turboKeyName = if (count (actionKeysNames ["turbo", 1]) > 0) then {actionKeysNames ["turbo", 1];} else {"""No key bound""";}; +[format ["%1
%2
SPACE to place vehicle
Arrow Left-Right to rotate
%3 for Precision (Less Safe) Placement
ENTER to Exit
", _vehName, vehPlace_extraMessage, _turboKeyName],0,0,5,0,0,4] spawn bis_fnc_dynamicText; diff --git a/A3-Antistasi/Garage/vehPlacementBegin.sqf b/A3-Antistasi/Garage/vehPlacementBegin.sqf index edd5d42523..afc698d687 100644 --- a/A3-Antistasi/Garage/vehPlacementBegin.sqf +++ b/A3-Antistasi/Garage/vehPlacementBegin.sqf @@ -74,11 +74,12 @@ if(isNil "vehPlace_keyDownHandler") then { _handled; }]; }; - + vehPlace_updatedLookPosition = [0,0,0]; vehPlace_lastLookPosition = [0,0,0]; addMissionEventHandler ["EachFrame", { + scopeName "handler"; private _shouldExitHandler = false; if (vehPlace_actionToAttempt != VEHPLACE_NO_ACTION) then { @@ -144,15 +145,25 @@ addMissionEventHandler ["EachFrame", private _pos = ASLtoAGL ((_ins select 0) select 0); if (_pos distance vehPlace_lastLookPosition < 0.1) exitWith {}; vehPlace_lastLookPosition = _pos; - //Only update the position when we're looking a certain distance away from the position we were looking at when we last placed the preview. - //Helps avoid lots of rapid, potentially large changes in position. - if (_pos distance vehPlace_updatedLookPosition < 0.5) exitWith {}; - - //Gradually increase the search distance, to try to avoid large jumps in position. + private _placementPos = []; - for "_maxDist" from 0 to 10 step 5 do { - _placementPos = _pos findEmptyPosition [0, _maxDist, typeOf vehPlace_previewVeh]; - if (count _placementPos > 0) exitWith {}; + //Just use the current position, if we're in 'Precision' mode + if (inputAction "turbo" > 0) then { + diag_log "Precision!"; + private _validPos = _pos findEmptyPosition [0, 0, typeOf vehPlace_previewVeh]; + if (count _validPos > 0) then { + _placementPos = _pos; + }; + } else { + diag_log "Normal!"; + //Only update the position when we're looking a certain distance away from the position we were looking at when we last placed the preview. + //Helps avoid lots of rapid, potentially large changes in position. + //if (_pos distance vehPlace_updatedLookPosition < 0.5) then {breakOut "handler";}; + //Gradually increase the search distance, to try to avoid large jumps in position. + for "_maxDist" from 0 to 10 step 5 do { + _placementPos = _pos findEmptyPosition [0, _maxDist, typeOf vehPlace_previewVeh]; + if (count _placementPos > 0) exitWith {}; + }; }; // Make it vanish if we can't find an empty position if (count (_placementPos) == 0) exitWith {vehPlace_previewVeh setPosASL [0,0,0]}; From cc51cc40aa941009355a0e2a01ffce398558a9ef Mon Sep 17 00:00:00 2001 From: Spoffy Date: Fri, 12 Jul 2019 23:24:31 +0100 Subject: [PATCH 2/8] Increase Vehicle Placement refresh rate --- A3-Antistasi/Garage/vehPlacementBegin.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/A3-Antistasi/Garage/vehPlacementBegin.sqf b/A3-Antistasi/Garage/vehPlacementBegin.sqf index afc698d687..057221247a 100644 --- a/A3-Antistasi/Garage/vehPlacementBegin.sqf +++ b/A3-Antistasi/Garage/vehPlacementBegin.sqf @@ -143,7 +143,7 @@ addMissionEventHandler ["EachFrame", ]; if (count _ins == 0) exitWith {}; private _pos = ASLtoAGL ((_ins select 0) select 0); - if (_pos distance vehPlace_lastLookPosition < 0.1) exitWith {}; + if (_pos distance vehPlace_lastLookPosition < 0.01) exitWith {}; vehPlace_lastLookPosition = _pos; private _placementPos = []; From 52eaac0561b08a02bbc6474d019c312fe1787a56 Mon Sep 17 00:00:00 2001 From: Spoffy Date: Fri, 12 Jul 2019 23:28:06 +0100 Subject: [PATCH 3/8] Readd Vehicle Placement jitter fix Remove debug messages --- A3-Antistasi/Garage/vehPlacementBegin.sqf | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/A3-Antistasi/Garage/vehPlacementBegin.sqf b/A3-Antistasi/Garage/vehPlacementBegin.sqf index 057221247a..7dcdc1bc14 100644 --- a/A3-Antistasi/Garage/vehPlacementBegin.sqf +++ b/A3-Antistasi/Garage/vehPlacementBegin.sqf @@ -149,16 +149,14 @@ addMissionEventHandler ["EachFrame", private _placementPos = []; //Just use the current position, if we're in 'Precision' mode if (inputAction "turbo" > 0) then { - diag_log "Precision!"; private _validPos = _pos findEmptyPosition [0, 0, typeOf vehPlace_previewVeh]; if (count _validPos > 0) then { _placementPos = _pos; }; } else { - diag_log "Normal!"; //Only update the position when we're looking a certain distance away from the position we were looking at when we last placed the preview. //Helps avoid lots of rapid, potentially large changes in position. - //if (_pos distance vehPlace_updatedLookPosition < 0.5) then {breakOut "handler";}; + if (_pos distance vehPlace_updatedLookPosition < 0.5) then {breakOut "handler";}; //Gradually increase the search distance, to try to avoid large jumps in position. for "_maxDist" from 0 to 10 step 5 do { _placementPos = _pos findEmptyPosition [0, _maxDist, typeOf vehPlace_previewVeh]; From 1286c67e0262c649e97915b2906b0b6d0301f17d Mon Sep 17 00:00:00 2001 From: Spoffy Date: Fri, 12 Jul 2019 23:39:09 +0100 Subject: [PATCH 4/8] Removes old code from garage2.sqf --- A3-Antistasi/Garage/garage2.sqf | 162 +------------------------------- 1 file changed, 1 insertion(+), 161 deletions(-) diff --git a/A3-Antistasi/Garage/garage2.sqf b/A3-Antistasi/Garage/garage2.sqf index f9adaa6f49..a08480860f 100644 --- a/A3-Antistasi/Garage/garage2.sqf +++ b/A3-Antistasi/Garage/garage2.sqf @@ -69,164 +69,4 @@ if (isNil "garage_keyDownHandler") then { private _extraMessage = "Arrow Up-Down to Switch Vehicles
"; garageIsOpen = true; -[_initialType, "GARAGE", _extraMessage] call A3A_fnc_vehPlacementBegin; - -/* -garage_fnc_attemptBuy = { - //garage_lastPreviewPosition = nil; - _pos = getPosASL garage_previewVeh; - _dir = getDir garage_previewVeh; - _typeX = typeOf garage_previewVeh; - deleteVehicle garage_previewVeh; - - if !(player inArea garage_nearestMarker) exitWith - { - hint "You need to be close to one of your garrisons to be able to retrieve a vehicle from your garage"; - ["",0,0,5,0,0,4] spawn bis_fnc_dynamicText; - garage_previewVeh = objNull; - }; - if ([player,300] call A3A_fnc_enemyNearCheck) exitWith - { - hint "You cannot manage the Garage with enemies nearby"; - garage_previewVeh = objNull; - }; - - //Only show text after we've checked all of the failure conditions above. - ["Vehicle retrieved from Garage",0,0,3,0,0,4] spawn bis_fnc_dynamicText; - - waitUntil {isNull garage_previewVeh}; - - private _garageVeh = createVehicle [_typeX, [0,0,1000], [], 0, "NONE"]; - _garageVeh setDir _dir; - //Surely this overrides any collision checks createVehicle would have made? - _garageVeh setPosASL _pos; - [_garageVeh] call A3A_fnc_AIVEHinit; - - if (_garageVeh isKindOf "Car") then {_garageVeh setPlateNumber format ["%1",name player]}; - _newArr = []; - _found = false; - if (garage_mode == GARAGE_FACTION) then - { - { - if ((_x != (garage_vehiclesAvailable select garage_vehicleIndex)) or (_found)) then {_newArr pushBack _x} else {_found = true}; - } forEach vehInGarage; - vehInGarage = _newArr; - publicVariable "vehInGarage"; - } - else - { - { - if ((_x != (garage_vehiclesAvailable select garage_vehicleIndex)) or (_found)) then {_newArr pushBack _x} else {_found = true}; - } forEach personalGarage; - personalGarage = _newArr; - ["personalGarage",_newArr] call fn_SaveStat; - _garageVeh setVariable ["ownerX",getPlayerUID player,true]; - }; - - if (_garageVeh isKindOf "StaticWeapon") then {staticsToSave pushBack _garageVeh; publicVariable "staticsToSave"}; - - clearMagazineCargoGlobal _garageVeh; - clearWeaponCargoGlobal _garageVeh; - clearItemCargoGlobal _garageVeh; - clearBackpackCargoGlobal _garageVeh; - _garageVeh allowDamage true; - _garageVeh enableSimulationGlobal true; - isGarageOpen = false; -}; - -garage_fnc_exitGarage = { - params [["_message", ""]]; - if (count _message > 0) then { - hint _message; - }; - ["",0,0,5,0,0,4] spawn bis_fnc_dynamicText; - deleteVehicle garage_previewVeh; - garage_previewVeh = objNull; - isGarageOpen = false; -}; - -#define KEY_UP 200 -#define KEY_DOWN 208 - - - -garage_lastPreviewPosition = [0,0,0]; -addMissionEventHandler ["EachFrame", - { - private _shouldExitHandler = false; - if (garage_actionToAttempt != GARAGE_NO_ACTION) then - { - switch(garage_actionToAttempt) do - { - case GARAGE_PURCHASE: - { - [] spawn garage_fnc_attemptBuy; - _shouldExitHandler = true; - }; - case GARAGE_EXIT: - { - [] spawn garage_fnc_exitGarage; - _shouldExitHandler = true; - }; - case GARAGE_RELOAD_VEHICLE: - { - hideObject garage_previewVeh; - deleteVehicle garage_previewVeh; - private _typeX = garage_vehiclesAvailable select garage_vehicleIndex; - if (isNil "_typeX") exitWith {}; - if (typeName _typeX != typeName "") exitWith {}; - garage_previewVeh = _typeX createVehicleLocal [0,0,1000]; - garage_previewVeh allowDamage false; - garage_previewVeh enableSimulationGlobal false; - [format ["%1

Garage Keys.
Arrow Up-Down to Navigate
Arrow Left-Right to rotate
SPACE to Select
ENTER to Exit",getText (configFile >> "CfgVehicles" >> typeOf garage_previewVeh >> "displayName")],0,0,5,0,0,4] spawn bis_fnc_dynamicText; - }; - case GARAGE_ROTATE_LEFT: - { - garage_previewVeh setDir (getDir garage_previewVeh + 1); - }; - case GARAGE_ROTATE_RIGHT: - { - garage_previewVeh setDir (getDir garage_previewVeh - 1); - }; - }; - garage_actionToAttempt = GARAGE_NO_ACTION; - }; - - if (!(player inArea garage_nearestMarker)) then { - ["You need to be close to one of your garrisons to be able to retrieve a vehicle from your garage"] spawn garage_fnc_exitGarage; - _shouldExitHandler = true; - }; - - if (_shouldExitHandler) exitWith { - removeMissionEventHandler ["EachFrame", _thisEventHandler]; - }; - - if (isNull garage_previewVeh) exitWith {}; - // Get point on /terrain/ the player is looking at - _ins = lineIntersectsSurfaces [ - AGLToASL positionCameraToWorld [0,0,0], - AGLToASL positionCameraToWorld [0,0,1000], - player,garage_previewVeh,true,1,"NONE","NONE" - ]; - if (count _ins == 0) exitWith {}; - private _pos = ASLtoATL ((_ins select 0) select 0); - private _placementPos = _pos findEmptyPosition [0, 20, typeOf garage_previewVeh]; - // Do nothing else if we can't find an empty position - if (count (_placementPos) == 0) exitWith {garage_previewVeh setPosASL [0,0,0]}; - // If we're too close to the last position, don't do anything - if (_placementPos distance garage_lastPreviewPosition < 0.1) exitWith {}; - garage_lastPreviewPosition = _placementPos; - // If vehicle is a boat, make sure it spawns at sea level? - _shipX = false; - if (garage_previewVeh isKindOf "Ship") then {_placementPos set [2,0]; _shipX = true}; - // Do nothing if destination too far - if (_placementPos distance2d player > 100)exitWith {garage_previewVeh setPosASL [0,0,0]}; - // Ships only spawn on water, and cars can't spawn on water - _water = surfaceIsWater _placementPos; - if (_shipX and {!_water}) exitWith {garage_previewVeh setPosASL [0,0,0]}; - if (!_shipX and {_water}) exitWith {garage_previewVeh setPosASL [0,0,0]}; - // If all checks pass, set position of preview and orient it to the ground - garage_previewVeh setPosATL _placementPos; - garage_previewVeh setVectorUp (_chosenIntersection select 1); - }]; - */ \ No newline at end of file +[_initialType, "GARAGE", _extraMessage] call A3A_fnc_vehPlacementBegin; \ No newline at end of file From 29e53a2fe809d0d496c7e4f767b517d5f8cdba30 Mon Sep 17 00:00:00 2001 From: Spoffy Date: Fri, 12 Jul 2019 23:39:44 +0100 Subject: [PATCH 5/8] Adds location marker when constructing fortifications --- .../REINF/Building/buildCreateVehicleCallback.sqf | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/A3-Antistasi/REINF/Building/buildCreateVehicleCallback.sqf b/A3-Antistasi/REINF/Building/buildCreateVehicleCallback.sqf index 7aa078e4a2..8feee2e9ac 100644 --- a/A3-Antistasi/REINF/Building/buildCreateVehicleCallback.sqf +++ b/A3-Antistasi/REINF/Building/buildCreateVehicleCallback.sqf @@ -13,6 +13,16 @@ else hint "Walk to the selected position to start building"; }; +build_targetLocation = _positionX; +build_atBuildLocation = false; + +addMissionEventHandler ["Draw3D", { + if (build_atBuildLocation) exitWith { + removeMissionEventHandler ["Draw3D", _thisEventHandler]; + }; + drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa", [1,1,1,1], build_targetLocation, 1,1,0,"Build", 0, 0.05, "PuristaMedium"]; +}]; + waitUntil {sleep 1;(time > _timeOut) or (build_engineerSelected distance _positionX < 3)}; if (time > _timeOut) exitWith @@ -20,6 +30,10 @@ if (time > _timeOut) exitWith hint "You didn't move to the position, construction has timed out."; }; +build_atBuildLocation = true; +build_targetLocation = nil; + + if (build_cost > 0) then { if (!isMultiPlayer) then From 743c612e7d25765148943472f7c44a928df0dd15 Mon Sep 17 00:00:00 2001 From: Spoffy Date: Sun, 14 Jul 2019 14:01:27 +0100 Subject: [PATCH 6/8] Adds a loop to clear up civilian groups --- A3-Antistasi/functions.hpp | 1 + A3-Antistasi/groupCleaner.sqf | 13 +++++++++++++ A3-Antistasi/initServer.sqf | 3 +++ 3 files changed, 17 insertions(+) create mode 100644 A3-Antistasi/groupCleaner.sqf diff --git a/A3-Antistasi/functions.hpp b/A3-Antistasi/functions.hpp index d342b41663..913efaab16 100644 --- a/A3-Antistasi/functions.hpp +++ b/A3-Antistasi/functions.hpp @@ -26,6 +26,7 @@ class A3A class fn_location {file="fn_location.sqf";}; class fogCheck {file="fogCheck.sqf";}; class garbageCleaner {file="garbageCleaner.sqf";}; + class groupCleaner {file="groupCleaner.sqf";}; class garrisonInfo {file="garrisonInfo.sqf";}; class intelFound {file="intelFound.sqf";}; class isFrontline {file="isFrontline.sqf";}; diff --git a/A3-Antistasi/groupCleaner.sqf b/A3-Antistasi/groupCleaner.sqf new file mode 100644 index 0000000000..ff7f5c40ec --- /dev/null +++ b/A3-Antistasi/groupCleaner.sqf @@ -0,0 +1,13 @@ +shouldCleanGroups = true; + +while {shouldCleanGroups} do { + { + if (side _x == civilian) then { + _x deleteGroupWhenEmpty true; + }; + } forEach allGroups; + + sleep 300; +}; + + diff --git a/A3-Antistasi/initServer.sqf b/A3-Antistasi/initServer.sqf index a1a0a09148..8a2df53f74 100644 --- a/A3-Antistasi/initServer.sqf +++ b/A3-Antistasi/initServer.sqf @@ -180,6 +180,9 @@ resourcecheck = [] execVM "resourcecheck.sqf"; [] execVM "Scripts\fn_advancedTowingInit.sqf"; savingServer = false; +// Loop that removes unnecessary groups +[] spawn A3A_fnc_groupCleaner; + //Enable performance logging [] spawn { while {true} do From 4182ce0f6ffd105aa31e8e4fd34e5cf84f35bdc1 Mon Sep 17 00:00:00 2001 From: Spoffy Date: Sun, 14 Jul 2019 16:38:36 +0100 Subject: [PATCH 7/8] Teleports vehicles when member leash is triggered --- A3-Antistasi/functions.hpp | 1 + A3-Antistasi/orgPlayers/nonMemberDistance.sqf | 22 +++++++++---- A3-Antistasi/teleportVehicleToBase.sqf | 31 +++++++++++++++++++ 3 files changed, 48 insertions(+), 6 deletions(-) create mode 100644 A3-Antistasi/teleportVehicleToBase.sqf diff --git a/A3-Antistasi/functions.hpp b/A3-Antistasi/functions.hpp index 913efaab16..b8f9b7cc54 100644 --- a/A3-Antistasi/functions.hpp +++ b/A3-Antistasi/functions.hpp @@ -57,6 +57,7 @@ class A3A class sellVehicle {file="sellVehicle.sqf";}; class sizeMarker {file="sizeMarker.sqf";}; class statistics {file="statistics.sqf";}; + class teleportVehicleToBase {file="teleportVehicleToBase.sqf";}; class translateVariable {file="statSave\translateVariable.sqf";}; class keys {file="keys.sqf";}; class timingCA {file="timingCA.sqf";}; diff --git a/A3-Antistasi/orgPlayers/nonMemberDistance.sqf b/A3-Antistasi/orgPlayers/nonMemberDistance.sqf index cde345f641..24c4481156 100644 --- a/A3-Antistasi/orgPlayers/nonMemberDistance.sqf +++ b/A3-Antistasi/orgPlayers/nonMemberDistance.sqf @@ -1,4 +1,6 @@ -_countX = 61; +#define INITIAL_COUNT_TIME 61 + +_countX = INITIAL_COUNT_TIME; while {!([player] call A3A_fnc_isMember)} do { _playerMembers = playableUnits select {([_x] call A3A_fnc_isMember) and (side group _x == teamPlayer)}; @@ -13,23 +15,31 @@ while {!([player] call A3A_fnc_isMember)} do } else { - _countX = 61 + _countX = INITIAL_COUNT_TIME; }; } else { - _countX = 61; + _countX = INITIAL_COUNT_TIME; }; } else { - _countX = 61; + _countX = INITIAL_COUNT_TIME; }; - if (_countX != 61) then + if (_countX != INITIAL_COUNT_TIME) then { hint format ["You have to get closer to the HQ or the closest server member in %1 seconds. \n\n After this timeout you will be teleported to your HQ",_countX]; sleep 1; - if (_countX == 0) then {player setPos (getMarkerPos respawnTeamPlayer)}; + if (_countX == 0) then + { + private _possibleVehicle = vehicle player; + if (_possibleVehicle != player && (driver _possibleVehicle) == player) then + { + [_possibleVehicle] call A3A_fnc_teleportVehicleToBase; + }; + player setPos (getMarkerPos respawnTeamPlayer); + }; } else { diff --git a/A3-Antistasi/teleportVehicleToBase.sqf b/A3-Antistasi/teleportVehicleToBase.sqf new file mode 100644 index 0000000000..93c0c7cfe4 --- /dev/null +++ b/A3-Antistasi/teleportVehicleToBase.sqf @@ -0,0 +1,31 @@ +private _vehicle = param [0]; +if (isNil "_vehicle" or isNull _vehicle) exitWith {}; +private _boundingSphereDiameter = ((boundingBox _vehicle) select 2) + 1; + +private _possiblePosition = []; +private _newPosition = for "_i" from 1 to 20 do { + private _possiblePosition = [(getMarkerPos respawnTeamPlayer), 20, 60, _boundingSphereDiameter, 0, 0.3] call BIS_fnc_findSafePos; + private _checkedPosition = if (count _possiblePosition > 0) then { _possiblePosition findEmptyPosition [0,0, typeOf _vehicle]; } else {[]}; + if (count _checkedPosition > 0) exitWith {_checkedPosition}; +}; + +if (count _newPosition == 0) exitWith { + diag_log "[Antistasi] Couldn't find a safe position to teleport vehicle to base."; + false; +}; + +_vehicle setVelocity [0, 0, 0]; +_vehicle engineOn false; +_vehicle allowDamage false; +_vehicle enableSimulation false; + +_vehicle setPos _newPosition; + +[_vehicle] spawn { + private _vehicle = param [0]; + sleep 1; + _vehicle allowDamage true; + _vehicle enableSimulation true; +}; + +true; \ No newline at end of file From 203d8535d9fa40bedd0e54880c27cafe76c7db6f Mon Sep 17 00:00:00 2001 From: Spoffy Date: Sun, 14 Jul 2019 18:05:20 +0100 Subject: [PATCH 8/8] Orientates vehicle correctly when teleporting --- A3-Antistasi/teleportVehicleToBase.sqf | 1 + 1 file changed, 1 insertion(+) diff --git a/A3-Antistasi/teleportVehicleToBase.sqf b/A3-Antistasi/teleportVehicleToBase.sqf index 93c0c7cfe4..ef4b23b6bd 100644 --- a/A3-Antistasi/teleportVehicleToBase.sqf +++ b/A3-Antistasi/teleportVehicleToBase.sqf @@ -20,6 +20,7 @@ _vehicle allowDamage false; _vehicle enableSimulation false; _vehicle setPos _newPosition; +_vehicle setVectorUp (surfaceNormal _newPosition); [_vehicle] spawn { private _vehicle = param [0];