Skip to content

Commit

Permalink
Merge pull request #11 from jokoho48/revert-10-reworkGroupSelection
Browse files Browse the repository at this point in the history
Revert "start working to move from Unit Based selection to Group Based"
  • Loading branch information
flaver12 committed Dec 22, 2015
2 parents 3a08e2d + 746bf63 commit 90daf9e
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 48 deletions.
13 changes: 7 additions & 6 deletions addon/jtog_rbu/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,12 @@ class CfgFunctions {

//Define our own category
class CfgFactionClasses {

//Set up for the category
class JTOG {
displayName="1st JTOG";
priority = 0.1;
side = 7;
side = 7;
};
};

Expand All @@ -66,9 +67,9 @@ class CfgVehicles {
};

class Extended_FiredBIS_EventHandlers {
class CAManBase {
class JTOG_RBU {
firedBIS = "_this call jtog_rbu_fnc_hanldeAI;"
};
};
class CAManBase {
class JTOG_RBU {
firedBIS = "_this call jtog_rbu_fnc_hanldeAI;"
};
};
};
3 changes: 1 addition & 2 deletions addon/jtog_rbu/functions/fn_checkSentAI.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@ params ["_unit", "_walkTime"];
params ["_args", "_idPFH"];
_args params ["_i", "_unit", _walkTime];
jtog_inLoop = 1;
publicVariable "jtog_inLoop";

private _alivecount = ({alive _x} count units _unit);

if!(_alivecount > 0) exitWith {
jtog_inLoop = 0;
publicVariable "jtog_inLoop";
[_idPFH] call CBA_fnc_removePerFrameHandler;
};

Expand Down
2 changes: 1 addition & 1 deletion addon/jtog_rbu/functions/fn_createWaypoint.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

params ["_unit", "_radius", "_position", ["_mode", "AWARE", [""]];

if(jtog_debug) then { systemChat format["JTOG-#RBU UNIT WILL GO TO %1", _position]};
if(jtog_debug == 1) then { systemChat format["JTOG-#RBU UNIT WILL GO TO %1", _position]};

//Saves the current location of the unit
jtog_rbu_last_group_pos = getPos _unit
Expand Down
26 changes: 10 additions & 16 deletions addon/jtog_rbu/functions/fn_hanldeAI.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ private ["_units", "_unit", "_i", "_hearing", "_unitBlacklist", "_nothingHear",
params ["_unit", "", "", "", "_ammo"];

if !(isPlayer _unit || (jtog_inLoop == 0)) exitWith {};
if !(isServer) exitWith {
_this remoteExec ["jtog_rbu_fnc_hanldeAI", 2, false];
};

_i = 0;
_units = [];
_hearing = jtog_hearing;
Expand Down Expand Up @@ -77,36 +75,32 @@ if(_nothingHear) then {_hearing = round (_hearing / 100) * 10;};
_finalDist = floor(_bestMarker);

//DEBUG
if (jtog_debug) then {
systemChat format["JTOG-#RBU: Player: %1", position player];
systemChat format["JTOG-#RBU: Unit: %1", position _unit];
};
if (jtog_debug == 1) then { systemChat format["JTOG-#RBU: Player: %1", position player] };
if (jtog_debug == 1) then { systemChat format["JTOG-#RBU: Unit: %1", position _unit] };

//Check for distance
if (_finalDist < _hearing) then {
//Loop through all units
//AS_TODO: Check for a better solution
{
//Check the loop
if !(count _units >= jtog_maxAI) then {
_leader = leader _x;
if !(_forEachIndex == jtog_maxAI) then {
//Check for AI
if (!isPlayer _leader && {(side _leader) != civilian} && {side _leader != playerside}) then {
if !(typeof _leader in _unitBlacklist) then {
if (!isPlayer _x && {(side _x) != civilian} && {side _x != playerside}) then {
if !(typeof _x in _unitBlacklist) then {
//Check distance
_result = (getMarkerPos _usedMarker) distance _leader;
_result = (getMarkerPos _usedMarker) distance _x;
if (_result < _hearing) then {
//push the unit in a array
_units pushBack units (group _leader);
_groups pushBack _leader;
_units pushBack _x;
};
};
};
};
nil
} forEach allGroups;
} forEach allUnits;

if !(_units isEqualTo []) then {
[_groups, _unit] call jtog_rbu_fnc_sendAI;
[_units, _unit] call jtog_rbu_fnc_sendAI;
};
};
6 changes: 3 additions & 3 deletions addon/jtog_rbu/functions/fn_initRBU.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ private _waypoints = _logic getVariable ['NumberOfWaypoints', 10];
private _debug = _logic getVariable ['Debug', 0];

//Set debug public
jtog_debug = _debug isEqualTo 1;
jtog_debug = _debug;
publicVariable "jtog_debug";

//If no marker name leave it!
if(isNil "_markerName") exitWith { systemChat "JTOG-#RBU ERROR! NO MARKER NAME SET! :(" };

//Say that we now starting all the good stuff
if(jtog_debug) then { systemChat "JTOG-#RBU starting init....." };
if(jtog_debug == 1) then { systemChat "JTOG-#RBU starting init....." };

//Set public variables
jtog_markerNames = _markerName;
Expand All @@ -54,4 +54,4 @@ publicVariable "jtog_walkTime";
publicVariable "jtog_numOfWay";

//Give feedback if its done!
if(jtog_debug) then { systemChat "JTOG-#RBU IS NOW READY TO GO STEIL!!" };
if(jtog_debug == 1) then { systemChat "JTOG-#RBU IS NOW READY TO GO STEIL!!" };
5 changes: 2 additions & 3 deletions addon/jtog_rbu/functions/fn_resetAI.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ _leader = leader _group;

_position = missionNamespace getVariable ["jtog_rbu_last_group_pos", [0,0,0]];

if(jtog_debug) then { systemChat format["JTOG-#RBU Destroy group with leader: %1", _leader]};
if(jtog_debug == 1) then { systemChat format["JTOG-#RBU Destroy group with leader: %1", _leader]};

//First let all leave the group
_units = units group _unit;

if(jtog_debug) then { systemChat format["JTOG-#RBU Create now new group, they go to: %1", _position]};
if(jtog_debug == 1) then { systemChat format["JTOG-#RBU Create now new group, they go to: %1", _position]};

//Now lets create a new fresh group
_leader = leader _unit;
Expand All @@ -28,4 +28,3 @@ if !(_units isEqualTo []) then {
//Now send it back
[_leader, 30, _position] call jtog_rbu_fnc_createWaypoint;
jtog_inLoop = 0;
publicVariable "jtog_inLoop";
32 changes: 15 additions & 17 deletions addon/jtog_rbu/functions/fn_sendAI.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,22 @@
* @desc Sends the ai to a check
*/

private ["_leader"];
private ["_i", "_leader"];

params ["_groups", "_unit"];
params ["_units", "_unit"];
_i = 0;

//We found only one unit so just seend it
//Just the first unit is the leader
_leader = _units select 0;
[_leader] joinSilent grpNull;
if !(_units isEqualTo []) then {
(_units - _leader) joinSilent grpNull;
};

{
//We found only one unit so just seend it
//Just the first unit is the leader
_leader = leader _x;
[_leader] joinSilent grpNull;
if !(_units isEqualTo []) then {
(_units - _leader) joinSilent grpNull;
};
//CBA-Event
["RBU_Send_AI", [_units, _leader, _unit, position _unit]] call CBA_fnc_globalEvent;

//CBA-Event
["RBU_Send_AI", [_units, _leader, _unit, position _unit]] call CBA_fnc_globalEvent;

//Create waypoints and watch if they are alive
[_leader, floor(random jtog_searchTerm), position _unit] call jtog_rbu_fnc_createWaypoint;
[_leader, jtog_walkTime] call jtog_rbu_fnc_checkSentAI;
} count _groups;
//Create waypoints and watch if they are alive
[_leader, floor(random jtog_searchTerm), position _unit] call jtog_rbu_fnc_createWaypoint;
[_leader, jtog_walkTime] call jtog_rbu_fnc_checkSentAI;

0 comments on commit 90daf9e

Please sign in to comment.