first attempt at rewrite of the task system

This commit is contained in:
Eero af Heurlin 2016-07-24 23:17:24 +03:00
parent 0a519cdbcb
commit 1ad78d7446
12 changed files with 376 additions and 11 deletions

View File

@ -0,0 +1,81 @@
diag_log format["createDropoffLZ called, _this: %1", _this];
private _lzLocation = _this select 0;
private _bindToVehicle = _this select 1;
private _bindToSquad = _this select 2;
private _fromTaskId = _this select 3;
private _assignToPlayer = driver _bindToVehicle;
private _enemies = [];
private _lzhot = false;
//Make the LZ hot if the roll demands it
if ((random 1) < hotLZChance) then
{
_lzhot = true
};
private _lzAA = false;
if ((random 1) < AAChance) then
{
_lzhot = true;
_lzAA = true;
};
private _taskType = "move";
if (_lzhot) then
{
_taskType = "attack";
_enemies = _enemies + ([_lzLocation, _lzAA] call createEnemySquads);
};
lzCounter = lzCounter + 1;
publicVariable "lzCounter";
private _shortestDesc = format["LZ %1", lzCounter];
private _longdesc = format["%1 wants to fly to this location", _squad];
private _shortdesc = format["Drop off %1", _squad];
if (_lzAA and _lzhot) then
{
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports heavy enemy activity with AA assets at the location";
};
if (!_lzAA and _lzhot) then
{
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports enemy activity at the location";
};
private _assignTo = [_assignToPlayer, west];
// PONDER: make a parent task "ferry squad X" ??
private _taskid = format["dropoff_%1", lzCounter];
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],_lzLocation,"AUTOASSIGNED",1,true, _taskType, true] call BIS_fnc_taskCreate;
private _handleDropoff=false;
private _trg = createTrigger["EmptyDetector",getPos _lzLocation, true];
_trg setTriggerArea[lzSize,lzSize,0,false];
_trg setTriggerActivation["WEST","PRESENT",false];
_trg setTriggerTimeout [2.5, 2.5, 2.5, true];
_trg setTriggerStatements[ format["((%1 in thisList) && (isTouchingGround %1))", _bindToVehicle], "_handleDropoff = true;", ""];
// TODO: implement deadline so the task doesn't linger forever
scopeName "main";
while {true} do
{
scopeName "mainloop";
if ({alive _x} count units _squad == 0) then
{
// Everybody died before getting there :(
[_taskid, "FAILED" ,true] spawn BIS_fnc_taskSetState;
breakOut "mainloop";
}
if (_handleDropoff) then
{
private _veh = [list _trg] call playerVehicleInList;
private _handle = [_lzLocation, _veh, _squad, _taskid] execVM "ejectSquad.sqf";
waitUntil {isNull _handle};
breakOut "mainloop";
};
sleep 1;
};
deleteVehicle _trg;
// Make sure there are no lingering enemy or own units
[_enemies + [_squad]] call deleteSquads;

View File

@ -0,0 +1,29 @@
diag_log format["createEnemySquad called, _this: %1", _this];
_centrePos = _this select 0;
_includeAA = this select 1;
_centreX = _centrePos select 0;
_centrePos set [0, _centreX + 100 + (floor random 300)];
_position = _centrePos findEmptyPosition [0,100];
// TODO: check if we want to create multiple enemy squads
_groupEnemy = createGroup east;
"O_Soldier_F" createUnit [_position, _groupEnemy,"",0.6, "CORPORAL"];
"O_Soldier_F" createUnit [_position, _groupEnemy,"",0.1, "PRIVATE"];
"O_soldier_M_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_AR_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_M_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_AR_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_M_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_AR_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_M_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"O_soldier_AR_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
if (_includeAA) then
{
"O_soldier_AA_F" createUnit [_position, _groupEnemy,"",0.75, "CORPORAL"];
}
[_groupEnemy]

View File

@ -0,0 +1,87 @@
diag_log format["createPickupLZ called, _this: %1", _this];
private _lzLocation = _this select 0;
private _assignExtra = _this select 1;
private _squad = [_lzLocation] call createSquad;
private _enemies = [];
private _lzhot = false;
//Make the LZ hot if the roll demands it
if ((random 1) < hotLZChance) then
{
_lzhot = true
};
private _lzAA = false;
if ((random 1) < AAChance) then
{
_lzhot = true;
_lzAA = true;
};
if (_lzhot)
{
_enemies = _enemies + ([_lzLocation, _lzAA] call createEnemySquads);
};
lzCounter = lzCounter + 1;
publicVariable "lzCounter";
private _shortestDesc = format["LZ %1", lzCounter];
private _longdesc = format["%1 wants a pickup from this location", _squad];
private _shortdesc = format["Pick up %1", _squad];
if (_lzAA and _lzhot) then
{
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports heavy enemy activity with AA assets at the location";
};
if (!_lzAA and _lzhot) then
{
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports enemy activity at the location";
};
private _assignTo = [west];
if (!(_assignExtra isEqualTo false)) then
{
_assignTo = _assignTo + _assignExtra;
};
// PONDER: make a parent task "ferry squad X" ??
private _taskid = format["pickup_%1", lzCounter];
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],_lzLocation,"AUTOASSIGNED",1,true, "meet", true] call BIS_fnc_taskCreate;
private _handlePickup=false;
private _trg = createTrigger["EmptyDetector",getPos _lzLoc, true];
_trg setTriggerArea[lzSize,lzSize,0,false];
_trg setTriggerActivation["WEST","PRESENT",false];
_trg setTriggerTimeout [2.5, 2.5, 2.5, true];
_trg setTriggerStatements["([thisList] call playerVehicleInListBool)", "_handlePickup = true;", ""];
// TODO: implement deadline so the task doesn't linger forever
scopeName "main";
while {true} do
{
scopeName "mainloop";
if ({alive _x} count units _squad == 0) then
{
// Everybody died before we got there :(
[_taskid, "FAILED" ,true] spawn BIS_fnc_taskSetState;
breakOut "mainloop";
}
if (_handlePickup) then
{
private _newLZLocation = (lzList - [_lzLocation]) call BIS_fnc_SelectRandom;
private _veh = [list _trg] call playerVehicleInList;
private _handle = [_veh, _squad, _taskid] execVM "loadSquad.sqf";
waitUntil {isNull _handle};
private _handle = [_newLZLocation, _veh, _squad, _taskid] execVM "createDropoffLZ.sqf";
waitUntil {isNull _handle};
breakOut "mainloop";
};
sleep 1;
};
deleteVehicle _trg;
// Make sure there are no lingering enemy or own units
[_enemies + [_squad]] call deleteSquads;

View File

@ -0,0 +1,11 @@
diag_log format["createSquad called, _this: %1", _this];
_spawnPos = _this select 0;
_groupTaxi = createGroup west;
"B_Soldier_F" createUnit [_spawnPos, _groupTaxi,"",0.6, "CORPORAL"];
"B_soldier_AR_F" createUnit [_position, _groupEnemy,"",0.3, "PRIVATE"];
"B_Soldier_F" createUnit [_spawnPos, _groupTaxi,"",0.5, "PRIVATE"];
"B_Soldier_F" createUnit [_spawnPos, _groupTaxi,"",0.5, "PRIVATE"];
"B_Soldier_F" createUnit [_spawnPos, _groupTaxi,"",0.5, "PRIVATE"];
_groupTaxi

View File

@ -0,0 +1,7 @@
diag_log format["deleteSquads called, _this: %1", _this];
_squads = _this select 0;
{
_squad = _x;
{deleteVehicle _x} forEach units _squad;
} forEach _squads;

View File

@ -0,0 +1,28 @@
diag_log format["ejectSquad called, _this: %1", _this];
private _lz = _this select 0
private _vehicle = _this select 1;
private _squad = _this select 2;
private _fromTaskId = _this select 3;
deleteWaypoint [_squad,1];
{_x action["eject", vehicle _x]} forEach units _squad;
{unAssignVehicle _x} forEach units _squad;
{_x enableAI "TARGET"; _x enableAI "AUTOTARGET";} foreach units _squad;
private wp = _squad addwaypoint [_lz,5,1];
wp setwaypointType "MOVE";
scopeName "main";
while {true} do
{
scopeName "ejectloop";
if (((_x in _vehicle) && (alive _x)} count units _group) == 0) then
{
// No squad units left alive inside
[_fromTaskId, "SUCCEEDED" ,true] spawn BIS_fnc_taskSetState;
breakOut "ejectloop";
};
sleep 2;
};
diag_log format["ejectSquad done, _this: %1", _this];

View File

@ -1,11 +1,21 @@
lzLanded = compile preProcessfile "lzlanded.sqf";
null = execVM "briefing.sqf";
_maxplayers = 4;
// Config constant globals
_lzCount = 86;
//Handle parameters
// Compile helpers
createDropoffLZ = compile preProcessfile "createDropoffLZ.sqf";
createPickupLZ = compile preProcessfile "createPickupLZ.sqf";
createSquad = compile preProcessfile "createSquad.sqf";
createEnemySquads = compile preProcessfile "createEnemySquads.sqf";
deleteSquads = compile preProcessfile "deleteSquads.sqf";
playerVehicleInList = compile preProcessfile "playerVehicleInList.sqf";
playerVehicleInListBool = compile preProcessfile "playerVehicleInListBool.sqf";
execVM "briefing.sqf";
//Handle MP parameters
//Time of day
_time = paramsArray select 0;
@ -47,6 +57,14 @@ while {_x < _lzCount} do
publicVariable "lzList";
lzCounter = 0;
publicVariable "lzCounter";
missionInitComplete = true;
publicVariable "missionInitComplete";
if (isServer) then
{
execVM "taskSpawner.sqf";
}

View File

@ -0,0 +1,31 @@
diag_log format["loadSquad called, _this: %1", _this];
private _vehicle = _this select 0;
private _squad = _this select 1;
private _fromTaskId = _this select 2;
{_x assignAsCargo _vehicle} foreach units _squad;
{[_x] ordergetin true} foreach units _squad;
{_x disableAI "TARGET"; _x disableAI "AUTOTARGET";} foreach units _squad;
private wp = _squad addwaypoint [_vehicle,5,1];
wp setwaypointType "GETIN";
scopeName "main";
while {true} do
{
scopeName "loadingLoop";
if ({alive _x} count units _squad == 0) then
{
// Everybody died before boarding :(
[_fromTaskId, "FAILED" ,true] spawn BIS_fnc_taskSetState;
breakOut "loadingLoop";
}
if ({alive _x} count units _squad == {(_x in _vehicle) && (alive _x)} count units _squad) then
{
// Boarded
[_fromTaskId, "SUCCEEDED" ,true] spawn BIS_fnc_taskSetState;
breakOut "loadingLoop";
};
sleep 2;
};
diag_log format["loadSquad done, _this: %1", _this];

View File

@ -8,7 +8,7 @@ class EditorData
toggles=1;
class ItemIDProvider
{
nextID=132;
nextID=134;
};
class MarkerIDProvider
{
@ -35,13 +35,14 @@ addons[]=
"A3_Air_F_EPB_Heli_Light_03",
"A3_Modules_F_Multiplayer",
"A3_Characters_F",
"A3_Modules_F"
"A3_Modules_F",
"cba_main"
};
class AddonsMetaData
{
class List
{
items=7;
items=8;
class Item0
{
className="A3_Ui_F";
@ -91,6 +92,13 @@ class AddonsMetaData
author="Bohemia Interactive";
url="http://www.arma3.com";
};
class Item7
{
className="cba_main";
name="Community Base Addons - Main Component";
author="CBA Team";
url="https://www.github.com/CBATeam/CBA_A3";
};
};
};
randomSeed=14406749;
@ -400,7 +408,7 @@ class Mission
};
class Entities
{
items=114;
items=115;
class Item0
{
dataType="Marker";
@ -2373,6 +2381,17 @@ class Mission
};
id=116;
};
class Item114
{
dataType="Logic";
class PositionInfo
{
position[]={14259.498,17.979912,15956.166};
};
id=133;
type="CBA_main_require";
atlOffset=-8.7738037e-005;
};
};
class Connections
{

View File

@ -0,0 +1,17 @@
diag_log format["playerVehicleInList called, _this: %1", _this];
private _triggerList = _this select 0;
private _returnValue = false;
scopeName "main";
{
private _plr = _x;
private _veh = vehicle _plr;
if ( (_plr != _veh) && (isTouchingGround _veh) && (_veh in _triggerList) ) then
{
_returnValue = _veh;
breakTo "main";
}
} forEach BIS_fnc_listPlayers;
diag_log format["playerVehicleInList returning: %1", _returnValue];
_returnValue

View File

@ -0,0 +1,11 @@
diag_log format["playerVehicleInListBool called, _this: %1", _this];
private _triggerList = _this select 0;
private _returnValue = false;
if (!(([_triggerList] call playerVehicleInList) isEqualTo false)) then
{
_returnValue = true;
}
diag_log format["playerVehicleInListBool returning: %1", _returnValue];
_returnValue

View File

@ -0,0 +1,26 @@
diag_log format["taskSpawner called, _this: %1", _this];
scopeName "main";
while {true} do
{
scopeName "mainloop";
private _justPlayers = BIS_fnc_listPlayers - entities "HeadlessClient_F";
private _result = [(west BIS_fnc_tasksUnit), {[_this] call BIS_fnc_taskCompleted}] call CBA_fnc_reject;
diag_log format["taskSpawner: active tasks: %1 players: ", (count _result), (count _justPlayers)];
while (count _result != count _justPlayers) do
{
scopename "spawnloop";
private _newLZLocation = lzList call BIS_fnc_SelectRandom;
{
scopename "playerloop";
private _plr = _x
diag_log format["taskSpawner: checking if %1 is free to take a pickup", _plr];
if (count (_plr call BIS_fnc_tasksUnit) == 0) then
{
[_newLZLocation, [_plr]] execVM "createPickupLZ.sqf";
breakTo "spawnloop";
}
} forEach _justPlayers;
[_newLZLocation, false] execVM "createPickupLZ.sqf";
}
sleep 10;
};