Skip to content

Commit

Permalink
Merge pull request #292 from Ansible2/master
Browse files Browse the repository at this point in the history
0.7.32
  • Loading branch information
Ansible2 authored Dec 9, 2020
2 parents 6fe3380 + 4643539 commit 06a4e70
Show file tree
Hide file tree
Showing 17 changed files with 1,009 additions and 64 deletions.
13 changes: 8 additions & 5 deletions Functions/Init Functions/fn_createBuildObjectsArray.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,17 @@ params [
];

if (isNull _configToSearch) exitWith {
"_configToSearch isNull" call BIS_fnc_error;
"BLWK_fnc_createBuildObjectsArray: _configToSearch isNull" call BIS_fnc_error;
};

if !(isClass _configToSearch) exitWith {
["_configToSearch %1 is not a class",_configToSearch] call BIS_fnc_error;
["BLWK_fnc_createBuildObjectsArray: _configToSearch %1 is not a class",_configToSearch] call BIS_fnc_error;
};

private _configs = "true" configClasses _configToSearch;

if (_configs isEqualTo []) exitWith {
["No classes found in _configToSearch %1",_configToSearch] call BIS_fnc_error;
["BLWK_fnc_createBuildObjectsArray: No classes found in _configToSearch %1",_configToSearch] call BIS_fnc_error;
};

private _returnArray = [];
Expand All @@ -49,7 +49,8 @@ private [
"_attachmentY_temp",
"_attachmentZ_temp",
"_invincible_temp",
"_keepInventory_temp"
"_keepInventory_temp",
"_detectCollision_temp"
];
_configs apply {
_class_temp = configName _x;
Expand All @@ -64,6 +65,7 @@ _configs apply {
_attachmentZ_temp = [_x >> "attachmentZ"] call BIS_fnc_getCfgData;
_invincible_temp = [_x >> "invincible"] call BIS_fnc_getCfgDataBool;
_keepInventory_temp = [_x >> "keepInventory"] call BIS_fnc_getCfgDataBool;
_detectCollision_temp = [_x >> "detectCollsion"] call BIS_fnc_getCfgDataBool;


_returnArray pushBack [
Expand All @@ -73,7 +75,8 @@ _configs apply {
[_rotation_temp,[_attachmentX_temp,_attachmentY_temp,_attachmentZ_temp]],
_hasAI_temp,
_invincible_temp,
_keepInventory_temp
_keepInventory_temp,
_detectCollision_temp
];
};
};
Expand Down
1 change: 1 addition & 0 deletions Functions/Init Functions/fn_initServerAlias.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ null = [] spawn BLWK_fnc_createBattleAmbienceSound;

sleep (BLWK_timeBetweenRounds - 15);
null = remoteExec ["BLWK_fnc_startWaveCountDownFinal",BLWK_allClientsTargetID];

sleep 15;

null = [] spawn BLWK_fnc_startWave;
Expand Down
2 changes: 2 additions & 0 deletions Functions/Init Functions/fn_prepareGlobals.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ if (isServer OR {!hasInterface}) then {

// used for chaning medical items of OPTRE units (biofoam to FAKs)
BLWK_isOptreLoaded = ["OPTRE_core"] call KISKA_fnc_ispatchLoaded;

BLWK_doDetectCollision = [false,true] select ("BLWK_doDetectCollision" call BIS_fnc_getParamValue);
};
if (isServer) then {
// We don't need to constantly check if the server is dedicated, and we only want to run things like
Expand Down
6 changes: 4 additions & 2 deletions Functions/Init Functions/fn_prepareUnitClasses.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include "..\..\Headers\Faction Headers\Unit Tables\RHS_AFRF Unit Tables.hpp"
#include "..\..\Headers\Faction Headers\Unit Tables\RHS_USAF Unit Tables.hpp"
#include "..\..\Headers\Faction Headers\Unit Tables\Z&DUnitTables.hpp"
#include "..\..\Headers\Faction Headers\Unit Tables\RHS_GREF Unit Tables.hpp"
#include "..\..\Headers\Faction Headers\Unit Tables\Project OPFOR Unit Tables.hpp"
/* ----------------------------------------------------------------------------
Function: BLWK_fnc_prepareUnitClasses
Expand Down Expand Up @@ -67,7 +69,7 @@ private _fn_sortFactionClasses = {
private _allowedUnitClasses = [];
_unitClassesToCheck apply {
_tempUnitClass = _x;
// exclude the vehicle array and make sure unit actual exists
// exclude the vehicle array and make sure unit actually exists
if (_tempUnitClass isEqualType "" AND {call _fn_checkTempClass}) then {
_allowedUnitClasses pushBack _tempUnitClass;
};
Expand All @@ -78,7 +80,7 @@ private _fn_sortFactionClasses = {
// exit the mission
if (_unitClassesToCheck isEqualTo _defaultFactionClasses) then {
null = [] spawn {
null = ["A default faction appears to be empty, the mission will now end to reconfigure parameters"] remoteExec ["hint",0,true];
null = ["A default faction appears to be empty, the mission will now end to reconfigure parameters"] remoteExecCall ["BIS_fnc_error",0];
sleep 20;
call BIS_fnc_endMissionServer;
};
Expand Down
65 changes: 65 additions & 0 deletions Functions/Other/fn_aiCollisionLoop.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/* ----------------------------------------------------------------------------
Function: BLWK_fnc_aiCollisionLoop
Description:
Used to keep the AI from attempting to walk through a placed object.
Units on roads sometimes follow predetermined paths that can have them walk
through objects a user places down.
Parameters:
0: _unit : <OBJECT> - The unit to run the loop on
Returns:
NOTHING
Examples:
(begin example)
null = [myUnit] spawn BLWK_fnc_aiCollisionLoop;
(end)
Author(s):
Ansible2 // Cipher
---------------------------------------------------------------------------- */
if (!BLWK_doDetectCollision) exitWith {};

if (!canSuspend) exitWith {
"BLWK_fnc_aiCollisionLoop: should be run in scheduled environment" call BIS_fnc_error;
null = _this spawn BLWK_fnc_aiCollisionLoop;
};

params ["_unit"];

sleep 5;

private ["_objects","_position","_index","_moveToPosition"];
while {BLWK_doDetectCollision AND {alive _unit}} do {
sleep 0.1;

// don't run while a unit is in a vehicle
if (isNull (objectParent _unit)) then {
_position = getposASL _unit;
_objects = lineIntersectsObjs [_position,AGLToASL (_unit getRelPos [1,0]), objNull, _unit, false, 4];

if !(_objects isEqualTo []) then {

// check if any encountered object is a built one
_index = _objects findIf {_x getVariable ["BLWK_collisionObject",false]};
if (_index != -1) then {
_moveToPosition = (_unit getRelPos [20,180]);
// push the unit back from the object
_unit setPosATL (_unit getRelPos [2,180]);

waitUntil {
// tell the unit to move away
_unit move _moveToPosition;
sleep 0.25;
if (_unit distance2D _moveToPosition < 5 OR {!alive _unit}) exitWith {true};
false
};
};
};
};
};
7 changes: 3 additions & 4 deletions Functions/Other/fn_pathingLoop.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ params [
];

if (isNull _groupToCheck) exitWith {
"null _groupToCheck" call BIS_fnc_error;
"BLWK_fnc_pathingLoop: null _groupToCheck" call BIS_fnc_error;
};

// follower units won't likely get stuck as their primary goal is to join the formation at all cost
Expand All @@ -48,7 +48,7 @@ if (_groupToCheck isEqualType objNull) then {

private _groupLeader = leader _groupToCheck;
if (!alive _groupLeader) exitWith {
["_groupLeader %1 is dead!",_groupLeader] call BIS_fnc_error;
["BLWK_fnc_pathingLoop: _groupLeader %1 is dead!",_groupLeader] call BIS_fnc_error;
};


Expand Down Expand Up @@ -115,7 +115,6 @@ private _fn_handleStationaryLeader = {
};



#define LOOP_VAR_NAME "BLWK_runPathingLoop"
_groupToCheck setVariable [LOOP_VAR_NAME,true];

Expand All @@ -135,7 +134,7 @@ while {sleep _timeBetweenChecks; (_groupToCheck getVariable [LOOP_VAR_NAME,false
//_groupLeader setPos (selectRandom BLWK_infantrySpawnPositions);
_groupLeader setPos ([BLWK_mainCrate, 75, 125, 2, 0] call BIS_fnc_findSafePos);
sleep 1;
[_groupLeader,position BLWK_mainCrate] remoteExecCall ["doMove",_groupLeader];
[_groupLeader,position BLWK_mainCrate] remoteExecCall ["move",_groupLeader];
};
};
};
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ if (isNil "_group") then {

null = [_group] spawn BLWK_fnc_pathingLoop;

null = [_unit] spawn BLWK_fnc_aiCollisionLoop;

null = [_group] spawn BLWK_fnc_startStalkingPlayers;


Expand Down
23 changes: 14 additions & 9 deletions Functions/Waves/fn_endWave.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,16 +56,21 @@ private "_playerTemp";
_players apply {
_playerTemp = _x;

if (lifeState _playerTemp == "DEAD") exitWith {
[_playerTemp] remoteExec ["forceRespawn",_playerTemp];
};
if (lifeState _playerTemp == "INCAPACITATED") then {
if (BLWK_dontUseRevive) then {
if (BLWK_ACELoaded) then {
[_playerTemp] remoteExecCall ["ace_medical_treatment_fnc_fullHealLocal",_playerTemp];
if (!alive _playerTemp) then {
// add a single respawn ticket for each dead unit
private _respawns = [BLUFOR,1] call BIS_fnc_respawnTickets;
missionNamespace setVariable ["BLWK_numRespawnTickets",_respawns,true];
[0] remoteExecCall ["setPlayerRespawnTime",_playerTemp];
[_playerTemp] remoteExecCall ["forceRespawn",_playerTemp];
} else {
if (lifeState _playerTemp == "INCAPACITATED") then {
if (BLWK_dontUseRevive) then {
if (BLWK_ACELoaded) then {
[_playerTemp] remoteExecCall ["ace_medical_treatment_fnc_fullHealLocal",_playerTemp];
};
} else {
["BLWK_reviveOnStateVar", 1, _playerTemp] remoteExecCall ["BIS_fnc_reviveOnState",_playerTemp];
};
} else {
["BLWK_reviveOnStateVar", 1, _playerTemp] remoteExecCall ["BIS_fnc_reviveOnState",_playerTemp];
};
};
};
Expand Down
8 changes: 7 additions & 1 deletion Functions/build/fn_purchaseObject.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ params [
"", // don't need attachment info
"_hasAi",
["_indestructable",false],
["_keepInventory",false]
["_keepInventory",false],
["_doDetectCollision",false]
];

/*
Expand Down Expand Up @@ -83,6 +84,11 @@ null = [_purchasedObject,player,true] spawn BLWK_fnc_pickupObject;
sleep 1;
[_purchasedObject] call BLWK_fnc_addBuildableObjectActions; // give local player object actions

if (_doDetectCollision) then {
// only the AI needs to know about it
_purchasedObject setVariable ["BLWK_collisionObject",true,BLWK_theAIHandlerOwnerID];
};

/*
Due to network issues with setOwner
objects that are too quickly manipulated by other players after being set down
Expand Down
Loading

0 comments on commit 06a4e70

Please # to comment.