mirror of
https://github.com/EpochModTeam/Epoch.git
synced 2024-08-30 18:22:13 +00:00
reworked trader spawn
fixes #489 traders now only spawn in traderBlds classes for work and traderHomes for homes and only if the building has AI positions. traders now also use traderUniforms config array for what uniforms they randomly use.
This commit is contained in:
parent
1da15073d8
commit
bb94bb429e
@ -12,82 +12,64 @@
|
||||
Github:
|
||||
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_traders/EPOCH_server_spawnTraders.sqf
|
||||
*/
|
||||
private ["_home","_work","_pos","_marker","_buildingPositions","_startTime","_endTime","_schedule","_agent","_slot","_objHiveKey","_buildingWork","_homeBuildingPositions","_acceptableBlds","_buildings","_randomAIUniform","_randomAIClass","_building","_position","_aiTables","_spawnCount","_usedBuildings"];
|
||||
|
||||
// TODO: configize
|
||||
_aiTables = ["U_OG_leader", "U_C_Poloshirt_stripped", "U_C_Poloshirt_blue", "U_C_Poloshirt_burgundy", "U_C_Poloshirt_tricolour", "U_C_Poloshirt_salmon", "U_C_Poloshirt_redwhite", "U_C_Poor_1", "U_C_WorkerCoveralls", "U_C_Journalist", "U_C_Scientist", "U_OrestesBody"];
|
||||
|
||||
private ["_pos","_marker","_buildingWork","_home","_work","_startTime","_endTime","_schedule","_agent","_slot","_objHiveKey","_buildingHome","_buildings","_randomAIUniform","_aiClass","_homes","_position","_spawnCount","_config","_aiTables","_acceptableBlds","_traderHomes","_usedBuildings","_checkBuilding"];
|
||||
_spawnCount = count EPOCH_TraderSlots;
|
||||
|
||||
//diag_log format["DEBUG: Tradercount EPOCH_TraderSlots: %1", _spawnCount];
|
||||
|
||||
_config = (configFile >> "CfgEpoch" >> worldName);
|
||||
_aiTables = getArray(_config >> "traderUniforms");
|
||||
_acceptableBlds = getArray(_config >> "traderBlds");
|
||||
_traderHomes = getArray(_config >> "traderHomes");
|
||||
_usedBuildings = [];
|
||||
_checkBuilding = {
|
||||
private ["_return"];
|
||||
params ["_building","_aiClass"];
|
||||
_return = !(_building in _usedBuildings);
|
||||
if !(_return) exitWith {_return};
|
||||
_return = !((_building buildingPos -1) isEqualTo []);
|
||||
if !(_return) exitWith {_return};
|
||||
_return = (_building nearEntities [_aiClass, 50]) isEqualTo [];
|
||||
_return
|
||||
};
|
||||
for "_i" from 1 to _spawnCount do {
|
||||
|
||||
_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 20, 0, 4000, 0] call BIS_fnc_findSafePos;
|
||||
// only proceed if two params otherwise BIS_fnc_findSafePos failed and may spawn in air
|
||||
if (count _position == 2) then {
|
||||
_randomAIUniform = selectRandom _aiTables;
|
||||
_randomAIClass = "C_man_1"; // static for now
|
||||
|
||||
_building = nearestBuilding _position;
|
||||
if !(_building in _usedBuildings) then {
|
||||
_home = getPosATL _building;
|
||||
_pos = _home;
|
||||
_usedBuildings pushBack _building;
|
||||
|
||||
_homeBuildingPositions = _building buildingPos -1;
|
||||
if !(_homeBuildingPositions isEqualTo []) then {
|
||||
_home = selectRandom _homeBuildingPositions;
|
||||
};
|
||||
_acceptableBlds = getArray(configFile >> "CfgEpoch" >> worldName >> "traderBlds");
|
||||
|
||||
_buildings = nearestObjects[_home, _acceptableBlds, 500];
|
||||
_aiClass = "C_man_1";
|
||||
_homes = (nearestObjects[_position, _traderHomes, 500]) select {[_x,_aiClass] call _checkBuilding};
|
||||
if !(_homes isEqualTo []) then {
|
||||
_buildingHome = selectRandom _homes;
|
||||
_usedBuildings pushBack _buildingHome;
|
||||
_buildings = (nearestObjects[_buildingHome, _acceptableBlds, 500]) select {[_x,_aiClass] call _checkBuilding};
|
||||
if !(_buildings isEqualTo []) then {
|
||||
|
||||
_buildingWork = selectRandom _buildings;
|
||||
if !(_buildingWork in _usedBuildings) then {
|
||||
_usedBuildings pushBack _buildingWork;
|
||||
_work = getPosATL _buildingWork;
|
||||
|
||||
_buildingPositions = _buildingWork buildingPos -1;
|
||||
if !(_buildingPositions isEqualTo []) then {
|
||||
_work = selectRandom _buildingPositions;
|
||||
};
|
||||
|
||||
_startTime = floor(random 16);
|
||||
_endTime = _startTime + 8;
|
||||
_schedule = [_startTime, _endTime];
|
||||
if (daytime > (_schedule select 0) && daytime < (_schedule select 1)) then {
|
||||
_pos = _work;
|
||||
};
|
||||
|
||||
if (_pos nearEntities[_randomAIClass, 50] isEqualTo []) then {
|
||||
|
||||
_agent = createAgent[_randomAIClass, _pos, [], 0, "CAN_COLLIDE"];
|
||||
addToRemainsCollector[_agent];
|
||||
_agent addUniform _randomAIUniform;
|
||||
_slot = EPOCH_TraderSlots deleteAt 0;
|
||||
_agent setVariable["AI_SLOT", _slot, true];
|
||||
_agent setVariable["AI_ITEMS", EPOCH_starterTraderItems, true];
|
||||
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
|
||||
|
||||
["AI_ITEMS", _objHiveKey, EPOCH_expiresAIdata, EPOCH_starterTraderItems] call EPOCH_fnc_server_hiveSETEX;
|
||||
_agent addEventHandler["Killed", { _this call EPOCH_server_traderKilled; }];
|
||||
|
||||
if !(EPOCH_forceStaticTraders) then {
|
||||
[_agent, _home, [_work, _schedule]] execFSM "\epoch_server\system\Trader_brain.fsm";
|
||||
};
|
||||
|
||||
["AI", _objHiveKey, [_randomAIClass, _home, [_work, _schedule]]] call EPOCH_fnc_server_hiveSET;
|
||||
if (EPOCH_SHOW_TRADERS) then {
|
||||
_marker = createMarker[str(_agent), (_pos)];
|
||||
_marker setMarkerShape "ICON";
|
||||
_marker setMarkerType "mil_dot";
|
||||
_marker setMarkerColor "ColorKhaki";
|
||||
_agent setVariable["MARKER_REF", _marker];
|
||||
};
|
||||
};
|
||||
_usedBuildings pushBack _buildingWork;
|
||||
_home = selectRandom (_buildingHome buildingPos -1);
|
||||
_work = selectRandom (_buildingWork buildingPos -1);
|
||||
_startTime = floor(random 16);
|
||||
_endTime = _startTime + 8;
|
||||
_schedule = [_startTime, _endTime];
|
||||
_pos = _home;
|
||||
if (daytime > _startTime && daytime < _endTime) then {
|
||||
_pos = _work;
|
||||
};
|
||||
_agent = createAgent[_aiClass, _pos, [], 0, "CAN_COLLIDE"];
|
||||
addToRemainsCollector[_agent];
|
||||
_agent addUniform _randomAIUniform;
|
||||
_slot = EPOCH_TraderSlots deleteAt 0;
|
||||
_agent setVariable["AI_SLOT", _slot, true];
|
||||
_agent setVariable["AI_ITEMS", EPOCH_starterTraderItems, true];
|
||||
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
|
||||
["AI_ITEMS", _objHiveKey, EPOCH_expiresAIdata, EPOCH_starterTraderItems] call EPOCH_fnc_server_hiveSETEX;
|
||||
_agent addEventHandler["Killed", { _this call EPOCH_server_traderKilled; }];
|
||||
if !(EPOCH_forceStaticTraders) then {
|
||||
[_agent, _home, [_work, _schedule]] execFSM "\epoch_server\system\Trader_brain.fsm";
|
||||
};
|
||||
["AI", _objHiveKey, [_aiClass, _home, [_work, _schedule]]] call EPOCH_fnc_server_hiveSET;
|
||||
if (EPOCH_SHOW_TRADERS) then {
|
||||
_marker = createMarker[str(_agent), (_pos)];
|
||||
_marker setMarkerShape "ICON";
|
||||
_marker setMarkerType "mil_dot";
|
||||
_marker setMarkerColor "ColorKhaki";
|
||||
_agent setVariable["MARKER_REF", _marker];
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -59,7 +59,9 @@ class CfgEpoch
|
||||
{"NameCityCapital",4},
|
||||
{"Airport",5}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
traderHomes[] = {"House", "Building"};
|
||||
traderUniforms[] = {"U_OG_leader", "U_C_Poloshirt_stripped", "U_C_Poloshirt_blue", "U_C_Poloshirt_burgundy", "U_C_Poloshirt_tricolour", "U_C_Poloshirt_salmon", "U_C_Poloshirt_redwhite", "U_C_Poor_1", "U_C_WorkerCoveralls", "U_C_Journalist", "U_C_Scientist", "U_OrestesBody"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {};
|
||||
propsPos[] = {};
|
||||
|
@ -29,7 +29,7 @@ class Bootcamp_ACR : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Desert_E : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Mountains_ACR : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Napf : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Porto : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class ProvingGrounds_PMC : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Sara : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class SaraLite : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Sara_dbe1 : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Shapur_BAF : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Utes : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
@ -29,7 +29,7 @@ class Woodland_ACR : Default
|
||||
{"VegetationFir",1},
|
||||
{"ViewPoint",1}
|
||||
};
|
||||
traderBlds[] = {};
|
||||
traderBlds[] = {"House", "Building"};
|
||||
containerPos[] = {};
|
||||
telePos[] = {
|
||||
// N [-0.286865,8.17383,-10.3098]
|
||||
|
Loading…
Reference in New Issue
Block a user