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,74 +12,58 @@
|
|||||||
Github:
|
Github:
|
||||||
https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_traders/EPOCH_server_spawnTraders.sqf
|
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"];
|
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"];
|
||||||
|
|
||||||
// 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"];
|
|
||||||
|
|
||||||
_spawnCount = count EPOCH_TraderSlots;
|
_spawnCount = count EPOCH_TraderSlots;
|
||||||
|
_config = (configFile >> "CfgEpoch" >> worldName);
|
||||||
//diag_log format["DEBUG: Tradercount EPOCH_TraderSlots: %1", _spawnCount];
|
_aiTables = getArray(_config >> "traderUniforms");
|
||||||
|
_acceptableBlds = getArray(_config >> "traderBlds");
|
||||||
|
_traderHomes = getArray(_config >> "traderHomes");
|
||||||
_usedBuildings = [];
|
_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 {
|
for "_i" from 1 to _spawnCount do {
|
||||||
|
|
||||||
_position = [epoch_centerMarkerPosition, 0, EPOCH_dynamicVehicleArea, 20, 0, 4000, 0] call BIS_fnc_findSafePos;
|
_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 {
|
if (count _position == 2) then {
|
||||||
_randomAIUniform = selectRandom _aiTables;
|
_randomAIUniform = selectRandom _aiTables;
|
||||||
_randomAIClass = "C_man_1"; // static for now
|
_aiClass = "C_man_1";
|
||||||
|
_homes = (nearestObjects[_position, _traderHomes, 500]) select {[_x,_aiClass] call _checkBuilding};
|
||||||
_building = nearestBuilding _position;
|
if !(_homes isEqualTo []) then {
|
||||||
if !(_building in _usedBuildings) then {
|
_buildingHome = selectRandom _homes;
|
||||||
_home = getPosATL _building;
|
_usedBuildings pushBack _buildingHome;
|
||||||
_pos = _home;
|
_buildings = (nearestObjects[_buildingHome, _acceptableBlds, 500]) select {[_x,_aiClass] call _checkBuilding};
|
||||||
_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];
|
|
||||||
if !(_buildings isEqualTo []) then {
|
if !(_buildings isEqualTo []) then {
|
||||||
|
|
||||||
_buildingWork = selectRandom _buildings;
|
_buildingWork = selectRandom _buildings;
|
||||||
if !(_buildingWork in _usedBuildings) then {
|
|
||||||
_usedBuildings pushBack _buildingWork;
|
_usedBuildings pushBack _buildingWork;
|
||||||
_work = getPosATL _buildingWork;
|
_home = selectRandom (_buildingHome buildingPos -1);
|
||||||
|
_work = selectRandom (_buildingWork buildingPos -1);
|
||||||
_buildingPositions = _buildingWork buildingPos -1;
|
|
||||||
if !(_buildingPositions isEqualTo []) then {
|
|
||||||
_work = selectRandom _buildingPositions;
|
|
||||||
};
|
|
||||||
|
|
||||||
_startTime = floor(random 16);
|
_startTime = floor(random 16);
|
||||||
_endTime = _startTime + 8;
|
_endTime = _startTime + 8;
|
||||||
_schedule = [_startTime, _endTime];
|
_schedule = [_startTime, _endTime];
|
||||||
if (daytime > (_schedule select 0) && daytime < (_schedule select 1)) then {
|
_pos = _home;
|
||||||
|
if (daytime > _startTime && daytime < _endTime) then {
|
||||||
_pos = _work;
|
_pos = _work;
|
||||||
};
|
};
|
||||||
|
_agent = createAgent[_aiClass, _pos, [], 0, "CAN_COLLIDE"];
|
||||||
if (_pos nearEntities[_randomAIClass, 50] isEqualTo []) then {
|
|
||||||
|
|
||||||
_agent = createAgent[_randomAIClass, _pos, [], 0, "CAN_COLLIDE"];
|
|
||||||
addToRemainsCollector[_agent];
|
addToRemainsCollector[_agent];
|
||||||
_agent addUniform _randomAIUniform;
|
_agent addUniform _randomAIUniform;
|
||||||
_slot = EPOCH_TraderSlots deleteAt 0;
|
_slot = EPOCH_TraderSlots deleteAt 0;
|
||||||
_agent setVariable["AI_SLOT", _slot, true];
|
_agent setVariable["AI_SLOT", _slot, true];
|
||||||
_agent setVariable["AI_ITEMS", EPOCH_starterTraderItems, true];
|
_agent setVariable["AI_ITEMS", EPOCH_starterTraderItems, true];
|
||||||
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
|
_objHiveKey = format["%1:%2", (call EPOCH_fn_InstanceID), _slot];
|
||||||
|
|
||||||
["AI_ITEMS", _objHiveKey, EPOCH_expiresAIdata, EPOCH_starterTraderItems] call EPOCH_fnc_server_hiveSETEX;
|
["AI_ITEMS", _objHiveKey, EPOCH_expiresAIdata, EPOCH_starterTraderItems] call EPOCH_fnc_server_hiveSETEX;
|
||||||
_agent addEventHandler["Killed", { _this call EPOCH_server_traderKilled; }];
|
_agent addEventHandler["Killed", { _this call EPOCH_server_traderKilled; }];
|
||||||
|
|
||||||
if !(EPOCH_forceStaticTraders) then {
|
if !(EPOCH_forceStaticTraders) then {
|
||||||
[_agent, _home, [_work, _schedule]] execFSM "\epoch_server\system\Trader_brain.fsm";
|
[_agent, _home, [_work, _schedule]] execFSM "\epoch_server\system\Trader_brain.fsm";
|
||||||
};
|
};
|
||||||
|
["AI", _objHiveKey, [_aiClass, _home, [_work, _schedule]]] call EPOCH_fnc_server_hiveSET;
|
||||||
["AI", _objHiveKey, [_randomAIClass, _home, [_work, _schedule]]] call EPOCH_fnc_server_hiveSET;
|
|
||||||
if (EPOCH_SHOW_TRADERS) then {
|
if (EPOCH_SHOW_TRADERS) then {
|
||||||
_marker = createMarker[str(_agent), (_pos)];
|
_marker = createMarker[str(_agent), (_pos)];
|
||||||
_marker setMarkerShape "ICON";
|
_marker setMarkerShape "ICON";
|
||||||
@ -90,7 +74,5 @@ for "_i" from 1 to _spawnCount do {
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
true
|
true
|
||||||
|
@ -59,7 +59,9 @@ class CfgEpoch
|
|||||||
{"NameCityCapital",4},
|
{"NameCityCapital",4},
|
||||||
{"Airport",5}
|
{"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[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {};
|
telePos[] = {};
|
||||||
propsPos[] = {};
|
propsPos[] = {};
|
||||||
|
@ -29,7 +29,7 @@ class Bootcamp_ACR : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Desert_E : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Mountains_ACR : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Napf : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Porto : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class ProvingGrounds_PMC : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Sara : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class SaraLite : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Sara_dbe1 : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Shapur_BAF : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Utes : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
@ -29,7 +29,7 @@ class Woodland_ACR : Default
|
|||||||
{"VegetationFir",1},
|
{"VegetationFir",1},
|
||||||
{"ViewPoint",1}
|
{"ViewPoint",1}
|
||||||
};
|
};
|
||||||
traderBlds[] = {};
|
traderBlds[] = {"House", "Building"};
|
||||||
containerPos[] = {};
|
containerPos[] = {};
|
||||||
telePos[] = {
|
telePos[] = {
|
||||||
// N [-0.286865,8.17383,-10.3098]
|
// N [-0.286865,8.17383,-10.3098]
|
||||||
|
Loading…
Reference in New Issue
Block a user