mirror of
https://github.com/rambo/arma3_missions.git
synced 2024-08-30 16:52:13 +00:00
better LZ logic, trying to assign tasks to players but it doesnot quite work
This commit is contained in:
parent
060d3c5388
commit
459a9c3848
helotraining_rewrite.Altis
@ -40,12 +40,13 @@ if (!_lzAA and _lzhot) then
|
||||
_longdesc = _longdesc + "<br/><strong>Be advised:</strong> Intel reports enemy activity at the location";
|
||||
};
|
||||
|
||||
_longdesc = _longdesc + format["<br/>Created for %1", _assignToPlayer];
|
||||
private _assignTo = [_assignToPlayer, west];
|
||||
|
||||
// PONDER: make a parent task "ferry squad X" ??
|
||||
private _taskid = format["dropoff_%1", lzCounter];
|
||||
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,"CREATED",(STARTPRIORITY-lzCounter),true, _taskType, true] call BIS_fnc_taskCreate;
|
||||
//_assignToPlayer setCurrentTask _taskid;
|
||||
_assignToPlayer setCurrentTask ([_taskid,_assignToPlayer] call BIS_fnc_taskReal);
|
||||
|
||||
private _trg = createTrigger["EmptyDetector",getPos _lzLocation, false];
|
||||
_trg setTriggerArea[lzSize,lzSize,0,false];
|
||||
|
@ -1,4 +1,4 @@
|
||||
diag_log format["createEnemySquad called, _this: %1", _this];
|
||||
//diag_log format["createEnemySquad called, _this: %1", _this];
|
||||
private _centrePos = _this select 0;
|
||||
private _includeAA = _this select 1;
|
||||
|
||||
@ -26,6 +26,6 @@ if (_includeAA) then
|
||||
"O_soldier_AA_F" createUnit [_enemyPosition, _groupEnemy,"",0.75, "CORPORAL"];
|
||||
};
|
||||
|
||||
diag_log format["createEnemySquad %1 positioned to %2", _groupEnemy, _enemyPosition];
|
||||
//diag_log format["createEnemySquad %1 positioned to %2", _groupEnemy, _enemyPosition];
|
||||
|
||||
[_groupEnemy]
|
@ -12,13 +12,12 @@ if ((random 1) < hotLZChance) then
|
||||
_lzhot = true
|
||||
};
|
||||
private _lzAA = false;
|
||||
private _taskType = "move";
|
||||
if ((random 1) < AAChance) then
|
||||
{
|
||||
_lzhot = true;
|
||||
_lzAA = true;
|
||||
};
|
||||
private _taskType = "move";
|
||||
private _taskType = "meet";
|
||||
if (_lzhot) then
|
||||
{
|
||||
_taskType = "defend";
|
||||
@ -48,20 +47,25 @@ if (!_lzAA and _lzhot) then
|
||||
[_squadCmdr, "Be advised, LZ is hot"] remoteExec ["sideChat", _side];
|
||||
};
|
||||
|
||||
private _taskState = "AUTOASSIGNED";
|
||||
private _assignTo = [west];
|
||||
if (!(_assignExtra isEqualTo false)) then
|
||||
{
|
||||
_longdesc = _longdesc + format["<br/>Created for %1", _assignExtra];
|
||||
_assignTo = _assignTo + _assignExtra;
|
||||
_taskState = "CREATED";
|
||||
};
|
||||
|
||||
|
||||
|
||||
// PONDER: make a parent task "ferry squad X" ??
|
||||
private _taskid = format["pickup_%1", lzCounter];
|
||||
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,"AUTOASSIGNED",(STARTPRIORITY-lzCounter),true, "meet", true] call BIS_fnc_taskCreate;
|
||||
[_assignTo,[_taskid],[_longdesc, _shortdesc, _shortestDesc],getPos _lzLocation,_taskState,(STARTPRIORITY-lzCounter),true, _taskType, true] call BIS_fnc_taskCreate;
|
||||
if (!(_assignExtra isEqualTo false)) then
|
||||
{
|
||||
// (_assignExtra select 0) setCurrentTask _taskid;
|
||||
{
|
||||
_x setCurrentTask ([_taskid,_x] call BIS_fnc_taskReal);
|
||||
} forEach _assignExtra;
|
||||
};
|
||||
|
||||
if (bSmoke) then
|
||||
@ -101,7 +105,7 @@ while {true} do
|
||||
{
|
||||
diag_log format["createPickupLZ: triggedred, loading up %1", _squad];
|
||||
// TODO: Filter the list so that locations near currently active tasks are not considered
|
||||
private _newLZLocation = (lzList - [_lzLocation]) call BIS_fnc_SelectRandom;
|
||||
private _newLZLocation = [[_lzLocation]] call selectLZ;
|
||||
|
||||
private _veh = [list _trg] call playerVehicleInList;
|
||||
private _handle = [_veh, _squad, _taskid] spawn loadSquad;
|
||||
|
@ -1,4 +1,4 @@
|
||||
diag_log format["createSquad called, _this: %1", _this];
|
||||
//diag_log format["createSquad called, _this: %1", _this];
|
||||
private _spawnPos = _this select 0;
|
||||
|
||||
private _groupTaxi = createGroup west;
|
||||
|
@ -1,4 +1,4 @@
|
||||
diag_log format["getSideActiveTasks called, _this: %1", _this];
|
||||
//diag_log format["getSideActiveTasks called, _this: %1", _this];
|
||||
private _side = _this select 0;
|
||||
private _returnValue = [];
|
||||
|
||||
@ -9,5 +9,5 @@ private _returnValue = [];
|
||||
};
|
||||
} forEach ([_side] call getSideTasks);
|
||||
|
||||
diag_log format["getSideActiveTasks returning: %1", _returnValue];
|
||||
//diag_log format["getSideActiveTasks returning: %1", _returnValue];
|
||||
_returnValue
|
@ -1,4 +1,4 @@
|
||||
diag_log format["getSideTasks called, _this: %1", _this];
|
||||
//diag_log format["getSideTasks called, _this: %1", _this];
|
||||
private _side = _this select 0;
|
||||
private _returnValue = [];
|
||||
{
|
||||
@ -12,5 +12,5 @@ private _returnValue = [];
|
||||
};
|
||||
} foreach allUnits;
|
||||
|
||||
diag_log format["getSideTasks returning: %1", _returnValue];
|
||||
//diag_log format["getSideTasks returning: %1", _returnValue];
|
||||
_returnValue
|
@ -1,6 +1,7 @@
|
||||
// Config constant globals
|
||||
LZCOUNT = 86;
|
||||
STARTPRIORITY = 1000;
|
||||
EXLUDESPAWNLZS = [(missionNamespace getVariable "lz33")]; // Exclude the airport location near spawn marker
|
||||
|
||||
// Precompile code
|
||||
execVM "precompile.sqf";
|
||||
@ -11,7 +12,7 @@ if (isServer) then
|
||||
//Handle MP parameters
|
||||
_handle = execVM "readparams.sqf";
|
||||
waitUntil {isNull _handle};
|
||||
execVM "taskSpawner.sqf";
|
||||
[EXLUDESPAWNLZS] spawn taskSpawner;
|
||||
};
|
||||
|
||||
// Flag init complete
|
||||
|
@ -1,4 +1,4 @@
|
||||
diag_log format["isLanded called, _this: %1", _this];
|
||||
//diag_log format["isLanded called, _this: %1", _this];
|
||||
private _vehicle = _this select 0;
|
||||
private _returnValue = false;
|
||||
|
||||
@ -14,7 +14,7 @@ private _isSlow = true;
|
||||
if (_isSlow && (_altitude < 1)) then
|
||||
{
|
||||
_returnValue = true;
|
||||
}
|
||||
};
|
||||
|
||||
diag_log format["isLanded returning: %1", _returnValue];
|
||||
//diag_log format["isLanded returning: %1", _returnValue];
|
||||
_returnValue
|
@ -1,4 +1,4 @@
|
||||
diag_log format["loadSquad called, _this: %1", _this];
|
||||
//diag_log format["loadSquad called, _this: %1", _this];
|
||||
private _vehicle = _this select 0;
|
||||
private _squad = _this select 1;
|
||||
private _fromTaskId = _this select 2;
|
||||
@ -20,7 +20,7 @@ scopeName "main";
|
||||
while {true} do
|
||||
{
|
||||
scopeName "loadingLoop";
|
||||
diag_log format["loadSquad: ticking %1", _this];
|
||||
//diag_log format["loadSquad: ticking %1", _this];
|
||||
if ({alive _x} count units _squad == 0) then
|
||||
{
|
||||
// Everybody died before boarding :(
|
||||
@ -38,4 +38,4 @@ while {true} do
|
||||
|
||||
[_squadCmdr, format["%1, everyone is onboard, you're clear to lift off", name _pilot]] remoteExec ["sideChat", _side];
|
||||
|
||||
diag_log format["loadSquad done, _this: %1", _this];
|
||||
//diag_log format["loadSquad done, _this: %1", _this];
|
||||
|
@ -16,7 +16,7 @@ class EditorData
|
||||
};
|
||||
class Camera
|
||||
{
|
||||
pos[]={14297.817,83.489143,15876.068};
|
||||
pos[]={14534.677,467.11179,15490.579};
|
||||
dir[]={-0.18160321,-0.59209311,0.78515315};
|
||||
up[]={-0.13343464,0.80584365,0.57689732};
|
||||
aside[]={0.97428519,1.8044375e-009,0.22534904};
|
||||
|
1
helotraining_rewrite.Altis/onPlayerRespawn.sqf
Normal file
1
helotraining_rewrite.Altis/onPlayerRespawn.sqf
Normal file
@ -0,0 +1 @@
|
||||
player addRating 9999;
|
@ -7,12 +7,12 @@ scopeName "main";
|
||||
{
|
||||
private _plr = _x;
|
||||
private _veh = vehicle _plr;
|
||||
if ( (_plr != _veh) && (isLanded _veh) && (_veh in _triggerList) ) then
|
||||
if ( (_plr != _veh) && ([_veh] call isLanded) && (_veh in _triggerList) ) then
|
||||
{
|
||||
_returnValue = _veh;
|
||||
breakTo "main";
|
||||
}
|
||||
} forEach _justPlayers;
|
||||
|
||||
diag_log format["playerVehicleInList returning: %1 (driver: %2)", _returnValue, driver _returnValue];
|
||||
//diag_log format["playerVehicleInList returning: %1", _returnValue];
|
||||
_returnValue
|
@ -1,4 +1,4 @@
|
||||
diag_log format["playerVehicleInListBool called, _this: %1", _this];
|
||||
//ag_log format["playerVehicleInListBool called, _this: %1", _this];
|
||||
private _triggerList = _this select 0;
|
||||
private _returnValue = false;
|
||||
|
||||
@ -7,5 +7,5 @@ if (!(([_triggerList] call playerVehicleInList) isEqualTo false)) then
|
||||
_returnValue = true;
|
||||
};
|
||||
|
||||
diag_log format["playerVehicleInListBool returning: %1", _returnValue];
|
||||
//ag_log format["playerVehicleInListBool returning: %1", _returnValue];
|
||||
_returnValue
|
@ -1,21 +1,21 @@
|
||||
// Compile helpers
|
||||
createDropoffLZ = compile preProcessfile "createDropoffLZ.sqf";
|
||||
createPickupLZ = compile preProcessfile "createPickupLZ.sqf";
|
||||
// compileFinal helpers
|
||||
createDropoffLZ = compileFinal preProcessfile "createDropoffLZ.sqf";
|
||||
createPickupLZ = compileFinal preProcessfile "createPickupLZ.sqf";
|
||||
|
||||
createSquad = compile preProcessfile "createSquad.sqf";
|
||||
createEnemySquads = compile preProcessfile "createEnemySquads.sqf";
|
||||
loadSquad = compile preProcessfile "loadSquad.sqf";
|
||||
ejectSquad = compile preProcessfile "ejectSquad.sqf";
|
||||
spawnSmokeBySquad = compile preProcessfile "spawnSmokeBySquad.sqf";
|
||||
createSquad = compileFinal preProcessfile "createSquad.sqf";
|
||||
createEnemySquads = compileFinal preProcessfile "createEnemySquads.sqf";
|
||||
loadSquad = compileFinal preProcessfile "loadSquad.sqf";
|
||||
ejectSquad = compileFinal preProcessfile "ejectSquad.sqf";
|
||||
spawnSmokeBySquad = compileFinal preProcessfile "spawnSmokeBySquad.sqf";
|
||||
|
||||
deleteSquads = compile preProcessfile "deleteSquads.sqf";
|
||||
playerVehicleInList = compile preProcessfile "playerVehicleInList.sqf";
|
||||
playerVehicleInListBool = compile preProcessfile "playerVehicleInListBool.sqf";
|
||||
getSideTasks = compile preProcessfile "getSideTasks.sqf";
|
||||
getSideActiveTasks = compile preProcessfile "getSideActiveTasks.sqf";
|
||||
isLanded = compile preProcessfile "isLanded.sqf";
|
||||
selectLZ = compile preProcessfile "selectLZ.sqf";
|
||||
deleteSquads = compileFinal preProcessfile "deleteSquads.sqf";
|
||||
playerVehicleInList = compileFinal preProcessfile "playerVehicleInList.sqf";
|
||||
playerVehicleInListBool = compileFinal preProcessfile "playerVehicleInListBool.sqf";
|
||||
getSideTasks = compileFinal preProcessfile "getSideTasks.sqf";
|
||||
getSideActiveTasks = compileFinal preProcessfile "getSideActiveTasks.sqf";
|
||||
isLanded = compileFinal preProcessfile "isLanded.sqf";
|
||||
selectLZ = compileFinal preProcessfile "selectLZ.sqf";
|
||||
|
||||
taskSpawner = compile preProcessfile "taskSpawner.sqf";
|
||||
xenoRepair = compile preProcessfile "xenoRepair.sqf";
|
||||
vehicleInit = compile preProcessfile "vehicleInit.sqf";
|
||||
taskSpawner = compileFinal preProcessfile "taskSpawner.sqf";
|
||||
xenoRepair = compileFinal preProcessfile "xenoRepair.sqf";
|
||||
vehicleInit = compileFinal preProcessfile "vehicleInit.sqf";
|
||||
|
@ -1,13 +1,38 @@
|
||||
diag_log format["selectLZ called, _this: %1", _this];
|
||||
//diag_log format["selectLZ called, _this: %1", _this];
|
||||
private _excludeList = _this select 0;
|
||||
private _returnValue = false;
|
||||
|
||||
private _candidates = lzList - _excludeList;
|
||||
private _tasks = [west] call getSideActiveTasks;
|
||||
private _candidates = lzList;
|
||||
if (!(_excludeList isEqualTo false)) then
|
||||
{
|
||||
_candidates = _candidates - _excludeList;
|
||||
};
|
||||
private _taskLocations = [];
|
||||
{
|
||||
_taskLocations = _taskLocations + [([_x] call BIS_fnc_taskDestination)];
|
||||
} forEach ([west] call getSideActiveTasks);
|
||||
|
||||
scopeName "main";
|
||||
while {true};
|
||||
while {true} do
|
||||
{
|
||||
scopeName "selectloop";
|
||||
private _usable = true;
|
||||
private _candidate = _candidates call BIS_fnc_SelectRandom;
|
||||
{
|
||||
scopeName "checkloop";
|
||||
private _dist = _candidate distance _x;
|
||||
if (_dist < (4*lzSize)) then
|
||||
{
|
||||
_usable = false;
|
||||
breakOut "checkloop";
|
||||
};
|
||||
} forEach _taskLocations;
|
||||
if (_usable) then
|
||||
{
|
||||
_returnValue = _candidate;
|
||||
breakOut "selectloop";
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
diag_log format["selectLZ returning: %1", _returnValue];
|
||||
//diag_log format["selectLZ returning: %1", _returnValue];
|
||||
_returnValue
|
@ -1,33 +1,48 @@
|
||||
diag_log "taskSpawner called";
|
||||
private _lzexclude = _this select 0;
|
||||
private _respawn = missionNamespace getVariable ("respawn_west");
|
||||
private _tryAssignPlr = true;
|
||||
|
||||
|
||||
scopeName "main";
|
||||
while {true} do
|
||||
{
|
||||
scopeName "mainloop";
|
||||
private _justPlayers = (call BIS_fnc_listPlayers) - entities "HeadlessClient_F";
|
||||
diag_log format["taskSpawner: active tasks: %1 players: %2", (count ([west] call getSideActiveTasks)), (count _justPlayers)];
|
||||
while {count ([west] call getSideActiveTasks) < count _justPlayers} do
|
||||
private _alivePlayers = [];
|
||||
{
|
||||
if (alive _x) then
|
||||
{
|
||||
_alivePlayers = _alivePlayers + [_x];
|
||||
};
|
||||
} forEach _justPlayers;
|
||||
while {count ([west] call getSideActiveTasks) < count _alivePlayers} do
|
||||
{
|
||||
scopename "spawnloop";
|
||||
diag_log format["taskSpawner: active tasks: %1 players: %2", (count ([west] call getSideActiveTasks)), (count _alivePlayers)];
|
||||
// TODO: Filter the list so that locations near currently active tasks are not considered
|
||||
private _newLZLocation = lzList call BIS_fnc_SelectRandom;
|
||||
private _newLZLocation = [_lzexclude] call selectLZ;
|
||||
private _plrAssigned = false;
|
||||
if (_tryAssignPlr) then
|
||||
{
|
||||
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]] spawn createPickupLZ;
|
||||
_plrAssigned = true;
|
||||
breakTo "spawnloop";
|
||||
};
|
||||
} forEach _justPlayers;
|
||||
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]] spawn createPickupLZ;
|
||||
_plrAssigned = true;
|
||||
breakTo "spawnloop";
|
||||
};
|
||||
} forEach _alivePlayers;
|
||||
};
|
||||
if (!_plrAssigned) then
|
||||
{
|
||||
[_newLZLocation, false] spawn createPickupLZ;
|
||||
};
|
||||
// rate limit
|
||||
sleep 1;
|
||||
sleep 10;
|
||||
};
|
||||
sleep 10;
|
||||
sleep 5;
|
||||
};
|
||||
|
@ -1,9 +1,5 @@
|
||||
diag_log format["vehicleIinit called, _this: %1", _this];
|
||||
//diag_log format["vehicleIinit called, _this: %1", _this];
|
||||
|
||||
_vehicle = _this select 0;
|
||||
_pilot = _this select 1;
|
||||
diag_log format["vehicleIinit called, _this: %1", _this];
|
||||
|
||||
[_vehicle, ["Repair", "xenoRepair.sqf"]] remoteExec ["addAction", 0, netId _vehicle];
|
||||
|
||||
_pilot addRating 9999;
|
||||
[_vehicle, ["Repair", { [_this select 0] spawn xenoRepair; }]] remoteExec ["addAction", 0, netId _vehicle];
|
||||
|
Loading…
Reference in New Issue
Block a user