task cleanup on death works

This commit is contained in:
Eero af Heurlin 2016-07-24 15:38:12 +03:00
parent 2bfef953cc
commit ad0533ea2c
5 changed files with 11 additions and 15 deletions

View File

@ -1,4 +1,5 @@
//null = [(playersArray select _playerno), [positionA, positionB, positionC...], previousLocation] execVM "createObj.sqf";
diag_log format["createObj called, _this: %1", _this];
waitUntil {!(isNil "missionInitComplete")};
@ -9,20 +10,14 @@ _prevLZ = _this select 2;
_playerno = _this select 3;
_player = playersArray select _playerno;
if (!!(taskIdsArray select _playerno)) exitWith { diag_log format["createObj: Task %1 already exists for %2", (taskIdsArray select _playerno), _playerno] };
_lzLoc = (_lzLocs - [_prevLZ]) call BIS_fnc_SelectRandom;
diag_log format["createObj called, _target: %1, _playerno: %2, _player: %3", _target, _playerno, _player];
// TODO: handle the case of player crash/death, reset the task etc
//_tsk1 = (playersArray select _playerno) createSimpleTask ["NextLZ"];
//_tsk1 setSimpleTaskDescription [format["Fly to and land within %1m of the next LZ", lzSize], "Next LZ", "LZ"];
//_tsk1 setSimpleTaskDestination (getPos _lzLoc);
//(playersArray select _playerno) setCurrentTask _tsk1;
_taskid = format["p%1_lz%2", _playerno, _lzLoc];
[west,[_taskid],[format["Player %2: Fly to and land within %1m of the LZ", lzSize, _playerno], format["p%1 LZ", _playerno], "LZ"],(getPos _lzLoc),true,5,true, "move", true] call BIS_fnc_taskCreate;
[west,[_taskid],[format["Player %2: Fly to and land within %1m of the LZ", lzSize, _playerno], format["p%1 LZ", _playerno], "LZ"],(getPos _lzLoc),"CREATED",1,true, "move", true] call BIS_fnc_taskCreate;
taskIdsArray set [_playerno, _taskid];

View File

@ -62,7 +62,7 @@ for [{_iX = 0}, {_iX < _maxplayers}, {_iX = _iX + 1}] do
landingCompleteArray set [_iX, false];
squadLoadedArray set [_iX, false];
playersArray set [_iX, ""];
taskIdsArray set [_iX, ""];
taskIdsArray set [_iX, false];
};
publicVariable "squadMDArray";
publicVariable "enemyMDArray";

View File

@ -8,9 +8,9 @@ _killhandler = compile(format["{Null = [_this, %1] execVM 'playerkilled.sqf';}",
_spawnhandler = compile(format["{Null = [_this, %1] execVM 'playerspawn.sqf';}", _playerno]);
// To pass the _playerno we must compile the value into the expression instead of passing variable as pointer
_target addEventHandler ["Killed", call _killhandler];
//_target addEventHandler ["Killed", call _killhandler];
_target addMPEventHandler ["MPKilled", call _killhandler];
_target addEventHandler ["Respawn", call _spawnhandler];
//_target addEventHandler ["Respawn", call _spawnhandler];
_target addMPEventHandler ["MPRespawn", call _spawnhandler];
[[_target], _playerno] execVM "playerspawn.sqf";

View File

@ -34,7 +34,7 @@ if (_squadCount > 1) then
landingCompleteArray set [_playerno, true];
publicVariable "landingCompleteArray";
[_taskid] call BIS_fnc_deleteTask;
taskIdsArray set [_playerno, null];
taskIdsArray set [_playerno, false];
publicVariable "taskIdsArray";

View File

@ -5,7 +5,8 @@ _playerno = _this select 1;
_taskid = taskIdsArray select _playerno;
null = [_taskid, "FAILED", False] spawn BIS_fnc_taskSetState;
taskIdsArray set [_playerno, ""];
[_taskid] call BIS_fnc_deleteTask;
taskIdsArray set [_playerno, false];
publicVariable "taskIdsArray";
_squadArray = squadMDArray select _playerno;