Update compiles - 2 more files to do

fn_selfActions.sqf
player_updateGui.sqf
This commit is contained in:
icomrade
2016-02-29 00:26:12 -05:00
parent a83909b918
commit b96cd2d971
67 changed files with 3886 additions and 1212 deletions

View File

@@ -1,8 +1,20 @@
private ["_position","_unitTypes","_radius","_method","_agent"];
#include "\z\addons\dayz_code\loot\Loot.hpp"
private ["_bypass","_position","_unitTypes","_radius","_method","_agent","_maxlocalspawned","_doLoiter","_wildspawns","_maxControlledZombies","_cantSee","_isok","_zPos","__FILE__","_fov","_safeDistance","_farDistance","_xasl","_eye","_ed","_deg","_skipFOV","_wildSpawns","_tooClose","_type","_loot","_array","_rnd","_lootType","_index","_weights","_loot_count","_favStance"];
_position = _this select 0;
_doLoiter = _this select 1; // wander around
_doLoiter = _this select 1; // wonder around
_unitTypes = _this select 2; // class of wanted models
//_wildspawns = _this select 3;
_bypass = _this select 3;
_maxlocalspawned = round(dayz_spawnZombies);
//Lets check if we need to divide the amount of zeds
if (r_player_divideinvehicle > 0) then {
_maxlocalspawned = round(dayz_spawnZombies / r_player_divideinvehicle);
};
_maxControlledZombies = round(dayz_maxLocalZombies);
_cantSee = {
@@ -24,140 +36,116 @@ _cantSee = {
if (_xasl distance _zPos < _farDistance) then {
if (_xasl distance _zPos < _safeDistance) then {
_isok = false;
}
else {
} else {
_eye = eyePos _x; // ASL
_ed = eyeDirection _x;
_ed = (_ed select 0) atan2 (_ed select 1);
_deg = [_xasl, _zPos] call BIS_fnc_dirTo;
_deg = (_deg - _ed + 720) % 360;
if (_deg > 180) then { _deg = _deg - 360; };
if ((abs(_deg) < _fov) && {( // in right angle sector?
if ((abs(_deg) < _fov) AND {( // in right angle sector?
(!(terrainIntersectASL [_zPos, _eye]) // no terrain between?
&& {(!(lineIntersects [_zPos, _eye]))}) // && no object between?
AND {(!(lineIntersects [_zPos, _eye]))}) // and no object between?
)}) then {
_isok = false;
};
};
};
if (!_isok) exitWith {false};
} count playableUnits;
sleep 0.001;
} forEach playableUnits;
_isok
};
if ((dayz_spawnZombies < _maxControlledZombies) && (dayz_CurrentNearByZombies < dayz_maxNearByZombies) && (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
if ([_position, dayz_cantseefov, 10, dayz_cantseeDist] call _cantSee) then {
//Check if anyone close
_skipFOV = false;
if ((_maxlocalspawned < _maxControlledZombies) and (dayz_CurrentNearByZombies < dayz_maxNearByZombies) and (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
//if (_wildSpawns) then {
// _skipFOV = true;
// _position = [_position,150,200] call dayz_RandomLocation;
//};
if (_bypass) then {
_skipFOV = true;
_position = [_position,3,20,1] call fn_selectRandomLocation;
};
if (surfaceIsWater _position) exitwith { Diag_log ("Location is in Water Abort"); };
if ((_skipFOV) or {([_position, 15, 10, 70] call _cantSee)}) then {
_tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0;
if (_tooClose) exitwith {
// diag_log ("Zombie_Generate: was too close to player.");
if (_tooClose) exitwith { diag_log ("Zombie_Generate: was too close to player."); };
if (count _unitTypes == 0) then
{
_unitTypes = getArray (configFile >> "CfgLoot" >> "Buildings" >> "Default" >> "zombieClass");
};
//Add zeds if unitTypes equals 0
if (count _unitTypes == 0) then {
if (DZE_MissionLootTable) then {
_unitTypes = []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
} else {
_unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
};
};
// lets create an agent
_type = _unitTypes call BIS_fnc_selectRandom;
_radius = 5;
_method = "NONE";
if (_doLoiter) then {
_radius = 40;
_method = "CAN_COLLIDE";
};
//Check if point is in water
if (surfaceIsWater _position) exitwith { };
_agent = createAgent [_type, _position, [], _radius, _method];
uiSleep 0.001;
//add to global counter
_agent = createAgent [_type, _position, [], _radius, _method];
sleep 0.03;
//add to global counter
dayz_spawnZombies = dayz_spawnZombies + 1;
dayz_CurrentNearByZombies = dayz_CurrentNearByZombies + 1;
dayz_currentGlobalZombies = dayz_currentGlobalZombies + 1;
//Add some loot
_loot = "";
_array = [];
_rnd = random 1;
if (_rnd < 0.2) then {
_lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
if (isText _lootType) then {
_array = [];
if (DZE_MissionLootTable) then {
{
_array set [count _array, _x select 0]
} forEach getArray (missionConfigFile >> "cfgLoot" >> getText(_lootType));
} else {
{
_array set [count _array, _x select 0]
} forEach getArray (configFile >> "cfgLoot" >> getText(_lootType));
};
if (count _array > 0) then {
_index = dayz_CLBase find getText(_lootType);
_weights = dayz_CLChances select _index;
_loot = _array select (_weights select (floor(random (count _weights))));
if(!isNil "_array") then {
_loot_count = getNumber(configFile >> "CfgMagazines" >> _loot >> "count");
if(_loot_count>1) then {
_agent addMagazine [_loot, ceil(random _loot_count)];
} else {
_agent addMagazine _loot;
};
};
};
//_loot = "";
//_array = [];
//_rnd = random 1;
if (0.7 > random 1) then
{
_lootGroup = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
if (isText _lootGroup) then
{
//_lootGroup = dayz_lootGroups find getText (_lootGroup);
_lootGroup = Loot_GetGroup(getText _lootGroup);
//[_agent, _lootGroup, 1] call loot_insert;
Loot_Insert(_agent, _lootGroup, 1);
};
};
_agent setVariable["agentObject",_agent];
if (!isNull _agent) then {
// sometime Z can be seen flying in very high speed while tp. Its altitude is set underground to hide that.
/*
_agtPos = getPosASL _agent;
_agtPos set [2, -3];
_agent setPosASL _agtPos;
uiSleep 0.001;
_agtPos = +(_position);
_agtPos set [2, -3];
_agent setPosASL _agtPos;
uiSleep 0.001;
*/
_agent setDir random 360;
//_agent setPosATL _position;
uiSleep 0.001;
sleep 0.03;
_position = getPosATL _agent;
_favStance = (
switch ceil(random(3^0.5)^2) do {
//case 3: {"DOWN"}; // prone
case 2: {"Middle"}; // Kneel
default {"UP"} // stand-up
case 2: {"middle"}; // Kneel "middle"
default {"Up"}; // stand-up
}
);
_agent setUnitPos _favStance;
_agent setVariable ["stance", _favStance];
_agent setVariable ["BaseLocation", _position];
_agent setVariable ["doLoiter", true]; // true: Z will be wandering, false: stay still
_agent setVariable ["myDest", _position];
_agent setVariable ["newDest", _position];
[_agent, _position] call zombie_loiter;
_agent setVariable ["doLoiter", _doLoiter]; // true: Z will be wandering, false: stay still
//_agent setVariable ["myDest", _position];
//_agent setVariable ["newDest", _position];
//[_agent, _position] call zombie_loiter;
};
//add to monitor
//dayz_zedMonitor set [count dayz_zedMonitor, _agent];
//Disable simulation
PVDZE_Server_Simulation = [_agent, false];
publicVariableServer "PVDZE_Server_Simulation";
//Disable simulation
PVDZ_Server_Simulation = [_agent, false];
publicVariableServer "PVDZ_Server_Simulation";
//Start behavior
_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
};
};
};