Skip to content
This repository has been archived by the owner on Jul 22, 2021. It is now read-only.

Commit

Permalink
rework pt3
Browse files Browse the repository at this point in the history
  • Loading branch information
McDiod committed Feb 3, 2017
1 parent cdb0ddf commit 62ae235
Show file tree
Hide file tree
Showing 25 changed files with 2,337 additions and 489 deletions.
2 changes: 2 additions & 0 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ missionname="TvT_KoeniglicherKampf"

islands=(
Altis
Beketov
Chernarus
fata
IslaDuala3
Expand All @@ -17,6 +18,7 @@ islands=(
Stratis
SugarLake
Takistan
Tanoa
utes
Zargabad
)
Expand Down
2 changes: 1 addition & 1 deletion cfgParams.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class Params
title = "Debug Mode";
values[] = {true, false};
texts[] = {"On", "Off"};
default = false;
default = true;
};

class randomteams
Expand Down
1 change: 1 addition & 0 deletions description.ext
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ loadScreen = "data\logo.paa";
enableDebugConsole = 1;
respawnDelay = 9999999;
allowFunctionsRecompile = 1;
disabledAI = 1;

//======================================================================
#include "cfgACE.hpp"
Expand Down
3 changes: 2 additions & 1 deletion functions/cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class koka {
class killMessage {};
class nearestCoast {};
class painEffect {};
class randomPos {};
class spawnCarepackage {};
class spawnLoot {};
};

class init {
Expand Down Expand Up @@ -43,6 +43,7 @@ class koka {
class setupPlayArea {};
class setWeather {};
class spawnBoats {};
class spawnLoot {};
class spawnVehicles {};
class startEquipment {};
class startRound {};
Expand Down
4 changes: 2 additions & 2 deletions functions/common/fn_endRound.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ if ((count PLAYINGGROUPS) == 1) then {
_message = format ["%1's group won!", (name _leader)];
[_message,0,0,4,0.3] remoteExec ["BIS_fnc_dynamicText",0,false];

[{["Won"] call BIS_fnc_endMissionServer}, [], 7] call CBA_fnc_waitAndExecute;
if (!DEBUG_MODE) then {[{["Won"] call BIS_fnc_endMissionServer}, [], 7] call CBA_fnc_waitAndExecute};

} else {
if ((count PLAYINGGROUPS) == 0) then {
_message = "No one left alive! Game ending in a draw.";
[_message,0,0,4,0.3] remoteExec ["BIS_fnc_dynamicText",0,false];

[{["Won"] call BIS_fnc_endMissionServer}, [], 7] call CBA_fnc_waitAndExecute;
if (!DEBUG_MODE) then {[{["Won"] call BIS_fnc_endMissionServer}, [], 7] call CBA_fnc_waitAndExecute};
}
else {
diag_log format ["Tried ending the round, but there are still %1 groups left.", (count PLAYINGGROUPS)];
Expand Down
49 changes: 49 additions & 0 deletions functions/common/fn_randomPos.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 0: center search pos
* 1: search radius (number/array)
* 2: search direction (number/array)
* 3: water
* 0: doesn't matter
* 1: don't find water pos
* 2: only find water pos
*/

params ["_center","_radius",["_angle",[0,360]],["_water",0]];

if (typeName _radius == "ARRAY") then {
_min = selectMin _radius;
_max = selectMax _radius;
_radius = (random (_max - _min)) + _min;
};

if (typeName _angle == "ARRAY") then {
_min = selectMin _angle;
_max = selectMax _angle;
_angle = (random (_max - _min)) + _min;
};

_searchPos = _center getPos [_radius,_angle];

_pos = switch (_water) do {
case (0): {
_searchPos
};
case (1): {
_pos = _searchPos;
for [{_i=0}, {_i<100}, {_i=_i+1}] do {
if !(surfaceIsWater _pos) exitWith {};
_pos = _searchPos getPos [_i*10,random 360];
};
_pos
};
case (2): {
_pos = _searchPos;
for [{_i=0}, {_i<100}, {_i=_i+1}] do {
if (surfaceIsWater _pos) exitWith {};
_pos = _searchPos getPos [_i*10,random 360];
};
_pos
};
};

_pos
20 changes: 18 additions & 2 deletions functions/init/fn_initSystems.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,28 @@
[{missionNamespace getVariable ["koka_init_setupPlayAreaDone", false]}, {[] call koka_fnc_lootInit}, []] call CBA_fnc_waitUntilAndExecute;
[{missionNamespace getVariable ["koka_init_setupPlayAreaDone", false]}, {[] call koka_fnc_randomTeams}, []] call CBA_fnc_waitUntilAndExecute;
[{missionNamespace getVariable ["koka_init_randomTeamsDone", false]}, {[] call koka_fnc_generateSWfreq}, []] call CBA_fnc_waitUntilAndExecute;
[{missionNamespace getVariable ["koka_init_generateSWfreqDone", false]}, {[] call koka_fnc_startRound}, []] call CBA_fnc_waitUntilAndExecute;
[{
missionNamespace getVariable ["koka_init_spawnBoatsDone", false] &&
missionNamespace getVariable ["koka_init_spawnVehiclesDone",false] &&
missionNamespace getVariable ["koka_init_generateSWfreqDone", false] &&
missionNamespace getVariable ["koka_init_lootInitDone", false]
}, {[] call koka_fnc_startRound}, []] call CBA_fnc_waitUntilAndExecute;

//game start
[{missionNamespace getVariable ["GAMESTARTED", false]}, {[] spawn koka_fnc_blueCircles}, []] call CBA_fnc_waitUntilAndExecute;
[{missionNamespace getVariable ["GAMESTARTED", false]}, {[] call koka_fnc_carePackages}, []] call CBA_fnc_waitUntilAndExecute;
[{missionNamespace getVariable ["GAMESTARTED", false]}, {[] call koka_fnc_winCondition}, []] call CBA_fnc_waitUntilAndExecute;
[{missionNamespace getVariable ["GAMESTARTED", false] && !isNil "NEWCIRCLEPOS" && !isNil "NEWCIRCLESIZE"}, {[] spawn koka_fnc_punishPlayer}, []] call CBA_fnc_waitUntilAndExecute;

[{
missionNamespace getVariable ["GAMESTARTED", false] &&
missionNamespace getVariable ["koka_init_generateSWfreqDone", false]
}, {[] call koka_fnc_setSWfreq; [] call koka_fnc_setSWfreq}, []] call CBA_fnc_waitUntilAndExecute;

[{
missionNamespace getVariable ["GAMESTARTED", false] &&
missionNamespace getVariable ["TELEPORTEDTOCHUTE",false] &&
!isNil "NEWCIRCLEPOS" &&
!isNil "NEWCIRCLESIZE"
}, {[] spawn koka_fnc_punishPlayer}, []] call CBA_fnc_waitUntilAndExecute;

}, []] call CBA_fnc_waitUntilAndExecute;
7 changes: 3 additions & 4 deletions functions/init/fn_lootInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

if (!isServer) exitWith {};

private ["_houseList", "_bPosCounter","_cleanUpCounter", "_lootSpawnCounter", "_lootSpawnTotalCounter", "_startTime", "_lootSpawned", "_searchAreaSize","_houseCounter","_halfNumberOfHouses"];
private ["_houseList", "_bPosCounter","_cleanUpCounter", "_lootSpawnCounter", "_lootSpawnTotalCounter", "_startTime", "_lootSpawned", "_searchAreaSize","_halfNumberOfHouses"];

//Load config and loot spawn function
call compile preprocessFileLineNumbers "loot\lootConfig.sqf";
Expand All @@ -30,7 +30,6 @@ if (DEBUG_MODE) then {HOUSELIST = _houseList; BUGGEDLOOTCOUNTER = 0};

//Main loop - spawn loot in each house
_lootSpawnTotalCounter = 0;
_houseCounter = 0;
_halfNumberOfHouses = (count _houseList) / 2;
{
_bPosCounter = 0;
Expand All @@ -44,7 +43,7 @@ _halfNumberOfHouses = (count _houseList) / 2;
while {((str _buildingPos) != "[0,0,0]")} do {

if (LOOT_PROBABILITY > random 100) then {
[_buildingPos] spawn koka_fnc_spawnLoot;
[_buildingPos,_forEachIndex == (count _houseList)-1] spawn koka_fnc_spawnLoot;
_lootSpawnCounter = _lootSpawnCounter +1;
_lootSpawned = true;
};
Expand All @@ -55,7 +54,7 @@ _halfNumberOfHouses = (count _houseList) / 2;
};

_lootSpawnTotalCounter = _lootSpawnTotalCounter + _lootSpawnCounter;
}foreach _houseList;
} foreach _houseList;

diag_log format ["Loot spawning completed in %1 seconds. Spawned loot in %2 positions.", (serverTime - _startTime), _lootSpawnTotalCounter];
if (DEBUG_MODE) then {diag_log format ["Buggy loot spawns: %1", BUGGEDLOOTCOUNTER]};
2 changes: 1 addition & 1 deletion functions/init/fn_pubVars.sqf
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
if (!isServer) exitWith {};

TIME_UNTIL_ROUND_START = 10; //how long until the round starts after setup\startround.sqf is executed
TIME_UNTIL_ROUND_START = 30; //how long until the round starts after setup is complete
TIME_UNTIL_FIRST_CIRCLE = 300; //how long until the first circle spawns
TIME_UNTIL_GETIN_FIRST = 420; //how long you have to get into the first circle
TIME_UNTIL_GETIN = 180; //how long you have to get into the circles
Expand Down
2 changes: 1 addition & 1 deletion functions/missionStart/fn_blueCircles.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ for [{_i = 0},{_i < (count _circleSizes)},{_i = _i + 1}] do {
diag_log format ["New circle center search radius: %1", _searchradius];
diag_log format ["Searching for new circle center."];

NEWCIRCLEPOS = [NEWCIRCLEPOS, [0,_searchradius], [0,360]] call SHK_pos;
NEWCIRCLEPOS = [NEWCIRCLEPOS, [0,_searchradius], [0,360]] call koka_fnc_randomPos;
diag_log format ["New circle center found at %1", NEWCIRCLEPOS];

//Convert old marker to black
Expand Down
17 changes: 9 additions & 8 deletions functions/missionStart/fn_carePackages.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,26 @@

if (!isServer) exitWith {};

private ["_timeMin", "_timeMax", "_carepackagePos"];
diag_log format ["Carepackages initialized - Waiting %1 seconds to spawn the first one.", TIME_UNTIL_FIRST_CAREPACKAGE];

[{
_spawn = {
koka_fnc_carePackages_spawn = {
private ["_timeMin", "_timeMax"];
_timeMin = CAREPACKAGE_INTERVAL select 0;
_timeMax = CAREPACKAGE_INTERVAL select 1;
[{
private ["_carepackagePos"];
_isWater = true;
while {_isWater} do {
_carepackagePos = [NEWCIRCLEPOS, [0,NEWCIRCLESIZE], [0,360], 1] call SHK_pos;
_isWater = surfaceIsWater _carepackagePos;
for [{_i=0}, {_i<100}, {_i=_i+1}] do {
_carepackagePos = [NEWCIRCLEPOS, [0,NEWCIRCLESIZE], [0,360]] call koka_fnc_randomPos;
if !(surfaceIsWater _carepackagePos) exitWith {};
};

_carepackagePos = _carepackagePos vectorAdd [0,0,CAREPACKAGE_DROPHEIGHT];
[_carepackagePos] spawn koka_fnc_spawnCarepackage;

_this call _this;
}, _this, (random (_timeMax - _timeMax)) + _timeMin] call CBA_fnc_waitAndExecute;
[] call koka_fnc_carePackages_spawn;
}, [], (random (_timeMax - _timeMax)) + _timeMin] call CBA_fnc_waitAndExecute;
};
_spawn call _spawn;
[] call koka_fnc_carePackages_spawn;
}, [], TIME_UNTIL_FIRST_CAREPACKAGE] call CBA_fnc_waitAndExecute;
2 changes: 1 addition & 1 deletion functions/missionStart/fn_winCondition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ PLAYINGGROUPS = allGroups;
} forEach PLAYINGGROUPS;

if ((count PLAYINGGROUPS) < 2) then {
_endrndhndl = [] call koka_fnc_endRound;
[] call koka_fnc_endRound;
[_handle] call CBA_fnc_removePerFrameHandler;
};
}, 5, []] call CBA_fnc_addPerFrameHandler;
6 changes: 3 additions & 3 deletions functions/setup/fn_generateSWfreq.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ _radioMax = 512 * 10;
_x setVariable ["swfreq", _freqString, true];

if (DEBUG_MODE) then {
diag_log format ["Frequency %1 saved for %2", _freqString, (name _teamlead)];
diag_log format ["Frequency %1 saved for %2", _freqString, (name _x)];
};
} forEach TEAMLEADERS;

[] remoteExec ["koka_fnc_setSWfreq",0,false];
/*[] remoteExec ["koka_fnc_setSWfreq",0,false];*/

missionNamespace getVariable ["koka_init_generateSWfreqDone",true,true];
missionNamespace setVariable ["koka_init_generateSWfreqDone",true,true];
2 changes: 1 addition & 1 deletion functions/setup/fn_moveToStartPosition.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
if (!hasInterface) exitWith {};

_spawnPositionCenter = (ISLAND_CONFIG select (ISLANDS find worldName)) select 0;
_teleportPosition = [_spawnPositionCenter,[0,15], [0,360]] call SHK_pos;
_teleportPosition = [_spawnPositionCenter,[0,15], [0,360]] call koka_fnc_randomPos;

diag_log format ["Startposition read - Moving player to: %1", _teleportPosition];

Expand Down
6 changes: 2 additions & 4 deletions functions/setup/fn_randomTeams.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,12 @@ TEAMLEADERS = [];
} forEach _players;

//Enough players?
if (_numberOfTeams < 2) then {
if (_numberOfTeams < 2 && (count _players) > 1) then {
diag_log "Unable to randomize teams - not enough players.";
diag_log format ["Number of players: %1", (count _players)];
diag_log format ["Teamsize selected: %1", TEAM_SIZE];
_numberOfTeams = 2;
}
else
{
} else {
diag_log format ["Randomizing %1 players into %2 teams", (count _players), _numberOfTeams];
};

Expand Down
4 changes: 3 additions & 1 deletion functions/setup/fn_setSWfreq.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
if (!hasInterface) exitWith {};

[{!isNil {(leader player) getVariable "swfreq"}}, {
[{!isNull player && !isNil {(leader player) getVariable "swfreq"}}, {
_freq = (leader player) getVariable "swfreq";
[(call TFAR_fnc_activeSwRadio), _freq] call TFAR_fnc_setSwFrequency;
_settings = [0,7,[_freq,_freq,_freq,_freq,_freq,_freq,_freq,_freq],0,"_bluefor",-1,0,getplayerUID player,false];
[(call TFAR_fnc_activeSwRadio), _settings] call TFAR_fnc_setSwSettings;
diag_log format ["SW frequency set to %1.", _freq];
}, []] call CBA_fnc_waitUntilAndExecute;
4 changes: 2 additions & 2 deletions functions/setup/fn_setupPlayArea.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ if (ISLAND_USEWHOLE) then {
_isWater = true;
_towns = true;
while {_isWater || _towns} do {
PLAYAREACENTER = [ISLAND_CENTER, [0,ISLAND_PLAYAREASEARCHRADIUS], [0,360], 1] call SHK_pos;
PLAYAREACENTER = ISLAND_CENTER getPos [random ISLAND_PLAYAREASEARCHRADIUS, random 360];
_isWater = surfaceIsWater PLAYAREACENTER;
_townsnum = count nearestLocations [PLAYAREACENTER, ["NameVillage", "NameCity", "NameCityCapital"], ISLAND_PLAYAREASIZE];
_townsnum = count nearestLocations [PLAYAREACENTER, ["NameVillage", "NameCity", "NameCityCapital"], ISLAND_PLAYAREASIZE];

if (_townsnum >= 2) then {
_towns = false;
Expand Down
32 changes: 13 additions & 19 deletions functions/setup/fn_spawnBoats.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ _waterPositions = [];
for "_i" from 0 to BOATMAX do {

//find position in playarea
_randomPos = [PLAYAREACENTER, [0,ISLAND_PLAYAREASIZE], [0,360], 1] call SHK_pos;
_randomPos = [PLAYAREACENTER, [0,ISLAND_PLAYAREASIZE], [0,360]] call koka_fnc_randomPos;

//if position is water, add to _waterPositions
if (surfaceIsWater _randomPos) then {_waterPositions pushBack _randomPos};
Expand All @@ -54,27 +54,18 @@ if (DEBUG_MODE) then {
//find closest coast
_coastPositions = [];
{
_tooCloseFound = true;
_tooCloseCounter = 0;
_discardPos = false;

while {_tooCloseFound} do {
_coastPos = [_x, [0,1], [0,360], 0] call SHK_pos;

_discardPos = true;
for [{_i=0}, {_i<10}, {_i=_i+1}] do {
_coastPos = [_x, 500, 4] call koka_fnc_nearestCoast;
_tooCloseFound = false;
{
if ((_x distance2D _coastPos) < BOATMINDISTANCE) exitWith {_tooCloseFound = true};
} forEach _coastPositions;

//if repeated x times, discard position
if (_tooCloseCounter >= 6) then {
_tooCloseFound = false;
_discardPos = true;
};
_tooCloseCounter = _tooCloseCounter +1;
if (str _coastPos != "[0,0,0]" && !_tooCloseFound) exitWith {_discardPos = false};
};


if (_discardPos) then {
diag_log "No position with min distance found. Discarding position.";
} else {
Expand All @@ -99,13 +90,14 @@ if (DEBUG_MODE) then {
//find water position close to coast positions
_closeWaterPositions = [];
{
_isWater = false;
while {!_isWater} do {
_closeWaterPos = [_x, [7, BOATMAXCOASTDISTANCE], [0,360], 2] call SHK_pos;
_isWater = surfaceIsWater _closeWaterPos
for [{_i=0}, {_i<10}, {_i=_i+1}] do {
_closeWaterPos = [_x, [7, BOATMAXCOASTDISTANCE], [0,360], 2] call koka_fnc_randomPos;
if !(surfaceIsWater _closeWaterPos) exitWith {};
};

_closeWaterPositions pushBack _closeWaterPos;
if !(surfaceIsWater _closeWaterPos) then {
_closeWaterPositions pushBack _closeWaterPos;
};
} forEach _coastPositions;

//add markers if debug mode
Expand All @@ -129,3 +121,5 @@ if (DEBUG_MODE) then {
diag_log format ["%1 spawned at %2", _boatType, _x];

} forEach _closeWaterPositions;

missionNamespace setVariable ["koka_init_spawnBoatsDone",true,true];
Loading

0 comments on commit 62ae235

Please sign in to comment.