Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //
- // tracker.sqf --by Diffusion9 2015-10
- // tracks [player] gridPOS every [x] seconds.
- // Currently called by: [] execVM "scripts\tracker.sqf"
- // This entire script is currently way more verbose than it needs to be (not including the RPT calls)
- // VisitedGrids and VisitedStatus need to be merged into one.
- //
- _gridPOS = mapGridPosition player; //--output: 108106 // Get current Map Grid from target.
- if (_gridPOS in VisitedGrids) then { // Check _gridPOS against [Array].
- //
- //EXISTING GRID -- CHECK STATUS
- //The Map Grid already exists in the VisitedGrids array:
- //This section is mostly for debug, except for _ageCheck, which is placeholder.
- diag_log format ["%1","================================="];
- diag_log format ["%1", "=====GATHERING GRID DATA ======="];
- diag_log format ["%1 %2", "_gridPOS:",_gridPOS]; //--output: 108106 (players current map grid).
- _res = [VisitedStatus,_gridPOS] call KK_fnc_findAll; //Find _gridPOS' index inside the VisitedStatus array.
- diag_log format ["%1 %2", "_res:",_res]; //We need the index in the array so KK_fnc_findAllGetPath can do work.
- _gridCords = [VisitedStatus,(_res select 0)] call KK_fnc_findAllGetPath; //using function to grab the actual output of the index.
- diag_log format ["%1 %2", "_gridCords:",_gridCords]; //--output: 108106
- _gridStatPosition = (_res select 0); //Array index, removed from nested Array. A bit redundant but whatever.
- diag_log format ["%1 %2", "_gridStatPosition(0):",_gridStatPosition]; //--output: [0,0].
- _gridStatPosition set [1, 1]; //<array> set [index, value] -- increments to the next index (status index).
- diag_log format ["%1 %2", "_gridStatPosition(1,1):",_gridStatPosition];
- _gridStatus = [VisitedStatus,(_gridStatPosition)] call KK_fnc_findAllGetPath; //Gets the value of the Grid's status.
- diag_log format ["%1 %2", "_gridStatus:",_gridStatus]; //--output: 1
- _gridTimePosition = (_res select 0); //Getting the inner-array index for the grid. Redundant again.
- diag_log format ["%1 %2", "_gridTimePosition (sel 0):",_gridTimePosition];
- _gridTimePosition set [1, 2]; //<array> set [index, value]. -- incrementing the value of the index again.
- diag_log format ["%1 %2", "_gridTimePosition(1,2):",_gridTimePosition];
- _gridTime = [VisitedStatus,(_gridTimePosition)] call KK_fnc_findAllGetPath; //Gets the value of the Grid's Time of Entry.
- diag_log format ["%1 %2", "_gridTime:",_gridTime];
- _ageCheck = (time - _gridTime); // Determine the age of the grid. Bogus calculation currently.
- diag_log format ["%1 %2", "_ageCheck:",_ageCheck];
- diag_log format ["%1", "=========GRID DATA END========="];
- diag_log format ["%1","================================"];
- //
- // GRID RESET
- //If the grid [Fulfills Condition] it should be flipped back to Unsecure to keep the party going.
- //Current ageCheck is bogus, used for test.
- IF (_ageCheck <= 0) then {
- diag_log format ["%1","================================"];
- diag_log format ["%1","===========GRID RESET==========="];
- diag_log format ["%1 %2", "Current Grid:",_gridPOS]; //--output: 108106
- diag_log format ["%1 %2", "VisitedGrids (Incoming):",VisitedGrids]; //--output: [{108106},{MAP},{GRID}]
- diag_log format ["%1 %2", "VisitedStatus (Incoming):",VisitedStatus]; //--output: [[Multi],[Dimensional],[Array]]
- _res0 = ([VisitedStatus,_gridPOS] call KK_fnc_findAll) select 0 select 0; // Array index in VisitedStatus.
- _res1 = ([VisitedGrids,_gridPOS] call KK_fnc_findAll) select 0 select 0; //Array index in VisitedGrids.
- diag_log format ["%1 %2", "VisitedStatus _res0:",_res0]; //--output: [0,0] without nest.
- diag_log format ["%1 %2", "VisitedGrids _res1:",_res1]; //--output: [0] without nest.
- VisitedStatus deleteAt _res0; //Removes index from the array.
- VisitedGrids deleteAt _res1; //Removes index from the array.
- diag_log format ["%1 %2", "Updated VisitedStatus:",VisitedStatus];
- diag_log format ["%1 %2", "Updated VisitedGrids:",VisitedGrids];
- diag_log format ["%1","==========GRID RESET END========"];
- diag_log format ["%1","================================"];
- };
- //
- // MAP GRID IS CONTESTED(1)
- IF (_gridStatus == 1) then {
- diag_log format ["%1","==================================="];
- diag_log format ["%1","====CONTESTED GRID STATUS START===="];
- diag_log format ["%1 %2", "Current Grid:",_gridPOS];
- diag_log format ["%1 %2", "Grid Status:", _gridStatus];
- diag_log format ["%1 %2", "Grid Time:", _gridTime];
- diag_log format ["%1 %2", "VisitedStatus:", VisitedStatus];
- diag_log format ["%1 %2", "VisitedGrids:", VisitedGrids];
- diag_log format ["%1","====CONTESTED STATUS GRID END======"];
- diag_log format ["%1","==================================="];
- };
- } else {
- //
- //NEW GRID
- //This is a new grid that the player has not yet entered, and must be configured.
- //Creates an array of 'settings' for this grid, and stores it to two arrays of 'visited' grids.
- VisitedGrids pushBack _gridPOS; //Add to VisitedGrids - raw list grid list of all encountered map grids.
- _gridLoc = _gridPOS; //Set _gridLoc to the Map Grid (--ex: 108107).
- _gridStatus = 1; //Set the Grid Status to CONTESTED (1) - since it is a first-time encounter.
- _gridTime = time; //Store the time the grid was encountered (for use later).
- _updateGridStatus = [_gridLoc,_gridStatus,_gridTime]; //Combine all three into an array for stowage.
- VisitedStatus pushback _updateGridStatus; //Add to the VisitedStatus array. Verbose but easy for me to understand right now.
- if (21 > random 100) then { //21% chance to trigger.
- hint "DEBUG: Spawn Chance"; //debug hint.
- [] execVM "scripts\DynamicAISpawn.sqf"; //Spawn Enemy AI
- };
- //RPT DUMPS for debug.
- diag_log format ["%1","================================"];
- diag_log format ["%1","=====NEW GRID CONFIGURATION====="];
- diag_log format ["%1 %2", "This is a new Grid", _gridLoc];
- diag_log format ["%1 %2 %3 %4", "Grid", _gridLoc , "Set Status to:", _gridStatus];
- diag_log format ["%1 %2 %3 %4", "Grid", _gridLoc , "Time:", _gridTime];
- diag_log format ["%1 %2","Outgoing to VisitedStatus:",_updateGridStatus];
- diag_log format ["%1","=========GRID CONFIG END========"];
- diag_log format ["%1","================================"];
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement