Skip to content

Commit

Permalink
Update 'unstable' from master
Browse files Browse the repository at this point in the history
  • Loading branch information
Spoffy committed Jul 14, 2019
2 parents feb466e + 203d853 commit d8774c5
Show file tree
Hide file tree
Showing 9 changed files with 102 additions and 178 deletions.
162 changes: 1 addition & 161 deletions A3-Antistasi/Garage/garage2.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -69,164 +69,4 @@ if (isNil "garage_keyDownHandler") then {
private _extraMessage = "Arrow Up-Down to Switch Vehicles<br/>";

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.
["<t size='0.6'>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 ["<t size='0.7'>%1<br/><br/><t size='0.6'>Garage Keys.<t size='0.5'><br/>Arrow Up-Down to Navigate<br/>Arrow Left-Right to rotate<br/>SPACE to Select<br/>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);
}];
*/
[_initialType, "GARAGE", _extraMessage] call A3A_fnc_vehPlacementBegin;
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@
params ["_vehType"];

private _vehName = getText (configFile >> "CfgVehicles" >> _vehType >> "displayName");
[format ["<t size='0.7'>%1</t><br/><t size='0.5'>%2</t><br/><t size='0.5'>SPACE to place vehicle<br/>Arrow Left-Right to rotate<br/>ENTER to Exit</t>", _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 ["<t size='0.7'>%1</t><br/><t size='0.5'>%2</t><br/><t size='0.5'>SPACE to place vehicle<br/>Arrow Left-Right to rotate<br/>%3 for Precision (Less Safe) Placement<br/>ENTER to Exit</t>", _vehName, vehPlace_extraMessage, _turboKeyName],0,0,5,0,0,4] spawn bis_fnc_dynamicText;
29 changes: 19 additions & 10 deletions A3-Antistasi/Garage/vehPlacementBegin.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -142,17 +143,25 @@ 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;
//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 {
private _validPos = _pos findEmptyPosition [0, 0, typeOf vehPlace_previewVeh];
if (count _validPos > 0) then {
_placementPos = _pos;
};
} else {
//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]};
Expand Down
14 changes: 14 additions & 0 deletions A3-Antistasi/REINF/Building/buildCreateVehicleCallback.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,27 @@ 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
{
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
Expand Down
2 changes: 2 additions & 0 deletions A3-Antistasi/functions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";};
Expand Down Expand Up @@ -56,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";};
Expand Down
13 changes: 13 additions & 0 deletions A3-Antistasi/groupCleaner.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
shouldCleanGroups = true;

while {shouldCleanGroups} do {
{
if (side _x == civilian) then {
_x deleteGroupWhenEmpty true;
};
} forEach allGroups;

sleep 300;
};


3 changes: 3 additions & 0 deletions A3-Antistasi/initServer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 16 additions & 6 deletions A3-Antistasi/orgPlayers/nonMemberDistance.sqf
Original file line number Diff line number Diff line change
@@ -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)};
Expand All @@ -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
{
Expand Down
32 changes: 32 additions & 0 deletions A3-Antistasi/teleportVehicleToBase.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
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 setVectorUp (surfaceNormal _newPosition);

[_vehicle] spawn {
private _vehicle = param [0];
sleep 1;
_vehicle allowDamage true;
_vehicle enableSimulation true;
};

true;

0 comments on commit d8774c5

Please sign in to comment.