Jump to content

[Release] Random Speed Zombies (walking and running)


McKeighan

Recommended Posts

Hey great script idea,

 

im getting spams in my client rpt

Error in expression < _yt;
_dir = _dy atan2 _dx;
_dx = _dx - _r * cos _dir;
_dy = _dy - _r * sin _dir>

zombie_generate.sqf

 

private ["_position","_unitTypes","_radius","_method","_agent","_isrunner"];
 
_position = _this select 0;
_doLoiter = _this select 1; // wander around
_unitTypes = _this select 2; // class of wanted models
_maxControlledZombies = round(dayz_maxLocalZombies);
 
_cantSee = {
private ["_isok"];
 
_isok = true;
_zPos = +(_this select 0);
if (count _zPos < 3) exitWith {
diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos];
false
};
_zPos = ATLtoASL _zPos;
_fov = _this select 1; // players half field of view
_safeDistance = _this select 2; // minimum distance. closer is wrong
_farDistance = _this select 3; // distance further we won't check
_zPos set [2, (_zPos select 2) + 1.7];
{
_xasl = getPosASL _x;
if (_xasl distance _zPos < _farDistance) then {
if (_xasl distance _zPos < _safeDistance) then {
_isok = false;
}
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?
(!(terrainIntersectASL [_zPos, _eye]) // no terrain between?
&& {(!(lineIntersects [_zPos, _eye]))}) // && no object between?
)}) then {
_isok = false;
};
};
};
if (!_isok) exitWith {false};
} count 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
_tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0;
if (_tooClose) exitwith {
// diag_log ("Zombie_Generate: was too close to player.");
};
 
//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];
sleep 0.001;
 
//add to global counter
dayz_spawnZombies = dayz_spawnZombies + 1;
 
//Add some loot
_loot = "";
_array = [];
_rnd = random 1;
if (_rnd < 0.2) then {
_lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
if (isText _lootType) then {
_array = [];
{
_array set [count _array, _x select 0]
} count 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;
};
};
};
};
};
 
_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;
sleep 0.001;
_agtPos = +(_position);
_agtPos set [2, -3];
_agent setPosASL _agtPos;
sleep 0.001;
*/
_agent setDir random 360;
//_agent setPosATL _position;
sleep 0.001;
 
_position = getPosATL _agent;
 
_favStance = (
switch ceil(random(3^0.5)^2) do {
//case 3: {"DOWN"}; // prone
case 2: {"Middle"}; // Kneel
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;
};
//add to monitor
//dayz_zedMonitor set [count dayz_zedMonitor, _agent];
 
//Disable simulation
        PVDZE_Server_Simulation = [_agent, false];
        publicVariableServer "PVDZE_Server_Simulation";
 
// Set zombie initial walkspeed 
_agent forceSpeed 2; 
 
// Create random runners 
_rnd = random(1);
if (_rnd > .8) then {
_isrunner = true;
} else {
_isrunner = false;
};
 
//Start behavior
_id = [_position,_agent,_isrunner] execFSM "custom\walkers\zombie_agent.fsm";
};
};

 

 

zombie_agent.fsm

 

 
/*%FSM<COMPILE "C:\Program Files (x86)\Bohemia Interactive\Tools\FSM Editor Personal Edition\scriptedFSM.cfg, DayZ Zombie Agent">*/
/*%FSM<HEAD>*/
/*
item0[] = {"init",0,4346,-75.000000,-250.000000,25.000000,-200.000000,0.000000,"init"};
item1[] = {"End",1,250,175.000000,-250.000000,275.000000,-200.000000,0.000000,"End"};
item2[] = {"wait",4,218,-75.000000,0.000000,25.000000,50.000000,0.000000,"wait"};
item3[] = {"Looking_for_Targ",2,250,-75.000000,75.000000,25.000000,125.000000,0.000000,"Looking for" \n "Target"};
item4[] = {"Not_Alive",4,218,0.000000,300.000000,100.000000,350.000000,5.000000,"Not" \n "Alive"};
item5[] = {"Nobody_Near",4,218,0.000000,375.000000,100.000000,425.000000,4.000000,"Nobody" \n "Near"};
item6[] = {"loiter",4,218,-325.000000,0.000000,-225.000000,50.000000,0.000000,"loiter"};
item7[] = {"Loiter",2,250,-325.000000,75.000000,-225.000000,125.000000,0.000000,"Loiter"};
item8[] = {"In_Position",4,218,-200.000000,75.000000,-100.000000,125.000000,1.000000,"In Position"};
item9[] = {"",7,210,-29.000042,321.000000,-20.999958,329.000000,0.000000,""};
item10[] = {"",7,210,-29.000042,395.999939,-20.999958,404.000061,0.000000,""};
item11[] = {"true",8,218,-75.000000,-175.000000,25.000000,-125.000000,0.000000,"true"};
item12[] = {"Begin",2,250,-75.000000,-100.000000,25.000000,-50.000000,0.000000,"Begin"};
item13[] = {"",7,210,-29.000006,-29.000004,-20.999996,-20.999996,0.000000,""};
item14[] = {"",7,210,-279.000061,-29.000004,-270.999969,-20.999996,0.000000,""};
item15[] = {"",7,210,-254.000046,146.000000,-245.999954,154.000000,0.000000,""};
item16[] = {"Has_Target",4,218,-150.000000,225.000000,-50.000000,275.000000,1.000000,"Has" \n "Target"};
item17[] = {"Chase",2,250,-150.000000,300.000000,-50.000000,350.000000,0.000000,"Chase"};
item18[] = {"Time_Check",4,218,50.000000,75.000000,150.000000,125.000000,0.000000,"Time" \n "Check"};
item19[] = {"",7,210,-29.000006,146.000000,-20.999996,154.000000,0.000000,""};
item20[] = {"",7,210,-29.000006,196.000000,-20.999996,204.000000,0.000000,""};
item21[] = {"",7,210,-104.000000,196.000000,-95.999992,204.000000,0.000000,""};
item22[] = {"Time_Check",4,218,-450.000000,75.000000,-350.000000,125.000000,0.000000,"Time" \n "Check"};
item23[] = {"Time_Check",4,218,-275.000000,300.000000,-175.000000,350.000000,0.000000,"Time" \n "Check"};
item24[] = {"No_Target",4,218,-275.000000,375.000000,-175.000000,425.000000,3.000000,"No" \n "Target"};
item25[] = {"",7,210,-479.000000,396.000000,-471.000000,404.000000,0.000000,""};
item26[] = {"",7,210,-479.000000,146.000000,-471.000000,154.000000,0.000000,""};
item27[] = {"",7,210,221.000000,321.000000,229.000000,329.000000,0.000000,""};
item28[] = {"",7,210,221.000000,396.000000,229.000000,404.000000,0.000000,""};
item29[] = {"Cleanup_",2,250,175.000000,200.000000,275.000000,250.000000,0.000000,"Cleanup?"};
item30[] = {"nobody_around",4,218,175.000000,-25.000000,275.000000,25.000000,0.000000,"nobody" \n "around"};
item31[] = {"",7,210,-104.000023,396.000000,-95.999992,404.000000,0.000000,""};
item32[] = {"cant_see",4,218,-275.000000,450.000000,-175.000000,500.000000,2.000000,"cant" \n "see"};
item33[] = {"Finish_Move",2,250,-275.000000,525.000000,-175.000000,575.000000,0.000000,"Finish" \n "Move"};
item34[] = {"finished",4,218,-425.000000,525.000000,-325.000000,575.000000,1.000000,"finished"};
item35[] = {"",7,210,-479.000000,546.000000,-471.000000,554.000000,0.000000,""};
item36[] = {"",7,210,-29.000002,546.000000,-20.999998,554.000000,0.000000,""};
item37[] = {"",7,210,-304.000000,146.000000,-296.000000,154.000000,0.000000,""};
item38[] = {"someone_here",4,218,300.000000,200.000000,400.000000,250.000000,0.000000,"someone" \n "here"};
item39[] = {"wait",2,250,300.000000,125.000000,400.000000,175.000000,0.000000,"wait"};
item40[] = {"time_up",4,218,300.000000,-25.000000,400.000000,25.000000,0.000000,"time" \n "up"};
item41[] = {"",7,210,346.000000,95.999992,354.000000,104.000000,0.000000,""};
item42[] = {"",7,210,221.000000,96.000008,229.000000,103.999977,0.000000,""};
item43[] = {"Time_Check",4,218,425.000000,125.000000,525.000000,175.000000,0.000000,"Time" \n "Check"};
item44[] = {"",7,210,346.000000,-79.000000,354.000000,-71.000000,0.000000,""};
item45[] = {"",7,210,221.000000,-79.000000,229.000000,-71.000000,0.000000,""};
item46[] = {"too_long",4,218,-425.000000,600.000000,-325.000000,650.000000,0.000000,"too long"};
item47[] = {"",7,210,-229.000000,621.000000,-221.000000,629.000000,0.000000,""};
item48[] = {"",7,210,-479.000000,621.000000,-471.000000,629.000000,0.000000,""};
item49[] = {"Reset_Targeting",2,250,-525.000000,325.000000,-425.000000,375.000000,0.000000,"Reset" \n "Targeting"};
item50[] = {"true",8,218,-525.000000,250.000000,-425.000000,300.000000,0.000000,"true"};
item51[] = {"deleted",4,218,425.000000,-25.000000,525.000000,25.000000,0.000000,"deleted"};
item52[] = {"",7,210,471.000000,-79.000000,479.000000,-71.000000,0.000000,""};
item53[] = {"",7,210,471.000000,95.999977,479.000000,104.000023,0.000000,""};
item54[] = {"",7,210,-104.000000,471.000000,-95.999992,479.000000,0.000000,""};
item55[] = {"player_check",4,218,-450.000000,0.000000,-350.000000,50.000000,0.000000,"player" \n "check"};
item56[] = {"player_check",4,218,50.000000,0.000000,150.000000,50.000000,0.000000,"player" \n "check"};
item57[] = {"is_Dedicated",4,218,50.000000,-250.000000,150.000000,-200.000000,5.000000,"is" \n "Dedicated"};
link0[] = {0,11};
link1[] = {0,57};
link2[] = {2,3};
link3[] = {3,18};
link4[] = {3,19};
link5[] = {3,56};
link6[] = {4,27};
link7[] = {5,28};
link8[] = {6,7};
link9[] = {7,8};
link10[] = {7,15};
link11[] = {7,22};
link12[] = {7,55};
link13[] = {8,7};
link14[] = {9,4};
link15[] = {9,10};
link16[] = {10,5};
link17[] = {11,12};
link18[] = {12,13};
link19[] = {13,2};
link20[] = {13,14};
link21[] = {14,6};
link22[] = {15,19};
link23[] = {16,17};
link24[] = {17,9};
link25[] = {17,23};
link26[] = {17,31};
link27[] = {18,3};
link28[] = {19,20};
link29[] = {20,9};
link30[] = {20,21};
link31[] = {21,16};
link32[] = {22,7};
link33[] = {23,17};
link34[] = {24,25};
link35[] = {25,49};
link36[] = {26,37};
link37[] = {27,29};
link38[] = {28,27};
link39[] = {29,38};
link40[] = {29,42};
link41[] = {30,45};
link42[] = {31,24};
link43[] = {31,54};
link44[] = {32,33};
link45[] = {33,34};
link46[] = {33,36};
link47[] = {33,47};
link48[] = {34,35};
link49[] = {35,25};
link50[] = {36,10};
link51[] = {37,7};
link52[] = {38,39};
link53[] = {39,41};
link54[] = {39,43};
link55[] = {40,44};
link56[] = {41,40};
link57[] = {41,42};
link58[] = {41,53};
link59[] = {42,30};
link60[] = {43,39};
link61[] = {44,45};
link62[] = {45,1};
link63[] = {46,48};
link64[] = {47,46};
link65[] = {48,35};
link66[] = {49,50};
link67[] = {50,26};
link68[] = {51,52};
link69[] = {52,44};
link70[] = {53,51};
link71[] = {54,32};
link72[] = {55,7};
link73[] = {56,3};
link74[] = {57,1};
globals[] = {25.000000,1,0,0,0,640,480,1,98,6316128,1,-542.928589,768.370728,784.378479,-389.521301,983,1030,1};
window[] = {2,-1,-1,-1,-1,806,26,1234,26,3,1001};
*//*%FSM</HEAD>*/
class FSM
{
  fsmName = "DayZ Zombie Agent";
  class States
  {
    /*%FSM<STATE "init">*/
    class init
    {
      name = "init";
      init = /*%FSM<STATEINIT""">*/"_position =  _this select 0;" \n
       "_agent =  _this select 1;" \n
       "_secondHand = false;" \n
  "_isrunner = _this select 2;" \n
       "" \n
       "if (count _this > 2) then {" \n
       " _secondHand = true;" \n
       " //diag_log (""Second Hand Zombie Initialized: "" + str(_this));" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "is_Dedicated">*/
        class is_Dedicated
        {
          priority = 5.000000;
          to="End";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"isDedicated"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Begin";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"dayz_clientPreload && !(isNull _agent)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "End">*/
    class End
    {
      name = "End";
      init = /*%FSM<STATEINIT""">*/"if (!isDedicated) then {" \n
       " if (!isNull _agent) then {" \n
       " deleteVehicle _agent;" \n
       " };" \n
       "} else {" \n
       " [_agent] call zombie_findOwner;" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Looking_for_Targ">*/
    class Looking_for_Targ
    {
      name = "Looking_for_Targ";
      init = /*%FSM<STATEINIT""">*/"_isAlive = alive _agent;" \n
       "_target = _agent call zombie_findTargetAgent;" \n
       "_timeN = time;" \n
       "" \n
       "_newDest = _agent getVariable [""myDest"",getposATL _agent];" \n
       "if (!isNil ""_newDest"") then {" \n
       " if (_newDest distance _myDest > 0) then {" \n
       " _myDest = _newDest;" \n
       " _agent moveTo _myDest;" \n
       " _agent forceSpeed 2;" \n
       " };" \n
       "};" \n
       "" \n
       "//diag_log (""Zombie "" + str(_agent) + "" Wait "");"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Not_Alive">*/
        class Not_Alive
        {
          priority = 5.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isAlive"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Nobody_Near">*/
        class Nobody_Near
        {
          priority = 4.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Has_Target">*/
        class Has_Target
        {
          priority = 1.000000;
          to="Chase";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!(isNull _target)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"//Leader cries out" \n
           "if (_isSomeone) then {" \n
           " [_agent,""spotted"",0,false] call dayz_zombieSpeak;" \n
           "};" \n
           "if (!_hasMoved) then {" \n
           " _agent setVariable[""doLoiter"",true,true];" \n
           "};" \n
           "_countr = 0;" \n
           "_losCheck = 0;" \n
           "_cantSee = false;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "player_check">*/
        class player_check
        {
          priority = 0.000000;
          to="Looking_for_Targ";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _entityTime) > 30"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_entityTime = time;" \n
           "" \n
           "_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],300];" \n
           "_isSomeone = ({isPlayer _x} count _list) > 0;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Time_Check">*/
        class Time_Check
        {
          priority = 0.000000;
          to="Looking_for_Targ";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _timeN) > 1"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Loiter">*/
    class Loiter
    {
      name = "Loiter";
      init = /*%FSM<STATEINIT""">*/"_isAlive = alive _agent;" \n
       "_target = _agent call zombie_findTargetAgent;" \n
       "" \n
       "_agent forceSpeed 2;" \n
       "" \n
       "_newDest = _agent getVariable [""myDest"",getposATL _agent];" \n
       "if (!isNil ""_newDest"") then {" \n
       " if (_newDest distance _myDest > 0) then {" \n
       " _myDest = _newDest;" \n
       " _agent moveTo _myDest;" \n
       " _agent forceSpeed 2;" \n
       " };" \n
       "};" \n
       "" \n
       "_timeN = time;" \n
       "" \n
       "//hintSilent (""loitering..."" + str(_agent distance (_agent getVariable [""myDest"",getposATL _agent])));" \n
       "" \n
       "if (_secondHand) then {" \n
       " diag_log (""Zombie "" + str(_agent) + "" Loiter "" + "" distance: "" + str(_newDest distance _myDest));" \n
       " _agent doMove (getPosATL player);" \n
       " _agent moveTo (getPosATL player);" \n
       "};"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Not_Alive">*/
        class Not_Alive
        {
          priority = 5.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isAlive"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Nobody_Near">*/
        class Nobody_Near
        {
          priority = 4.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Has_Target">*/
        class Has_Target
        {
          priority = 1.000000;
          to="Chase";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!(isNull _target)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"//Leader cries out" \n
           "if (_isSomeone) then {" \n
           " [_agent,""spotted"",0,false] call dayz_zombieSpeak;" \n
           "};" \n
           "if (!_hasMoved) then {" \n
           " _agent setVariable[""doLoiter"",true,true];" \n
           "};" \n
           "_countr = 0;" \n
           "_losCheck = 0;" \n
           "_cantSee = false;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "In_Position">*/
        class In_Position
        {
          priority = 1.000000;
          to="Loiter";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_agent distance (_agent getVariable [""myDest"",getposATL _agent]) < 3"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"[_agent,_position] call zombie_loiter;" \n
           "_myDest = _agent getVariable [""myDest"",getposATL _agent];" \n
           ""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "player_check">*/
        class player_check
        {
          priority = 0.000000;
          to="Loiter";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _entityTime) > 30"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_entityTime = time;" \n
           "" \n
           "_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],300];" \n
           "_isSomeone = ({isPlayer _x} count _list) > 0;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Time_Check">*/
        class Time_Check
        {
          priority = 0.000000;
          to="Loiter";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _timeN) > 1"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Begin">*/
    class Begin
    {
      name = "Begin";
      init = /*%FSM<STATEINIT""">*/"_doLoiter =  _agent getVariable[""doLoiter"",true];" \n
       "" \n
       "_myDest =  _position;" \n
       "_newDest =  _position;" \n
       "_array =  [];" \n
       "" \n
       "_bodyStay =  60;" \n
       "" \n
       "_hasMoved = _doLoiter;" \n
       "" \n
       "_agent disableAI ""FSM"";" \n
       "_agent setBehaviour ""CARELESS"";" \n
       "_agent setCombatMode ""RED"";" \n
       "_agent setSkill 0;" \n
       "" \n
       "_newDest = getPosATL _agent;" \n
       "_timeN = time;" \n
       "" \n
       " _id = _agent addeventhandler [""HandleDamage"",{_this call local_zombieDamage}];" \n
       "" \n
       "//hint ""run local zombie"";" \n
       "_isSomeone = true;" \n
       "" \n
       "_target = objNull;" \n
       "_targetPos = [];" \n
       "_countr = 0;" \n
       "" \n
       "//Spawn roaming script (individual to unit)" \n
       "_entityTime = time;" \n
       "" \n
       "//Debug" \n
       "if (_secondHand) then {" \n
       " diag_log (""Zombie Brain Initialized "" + str(_agent) + "" doLoiter: "" + str(_doLoiter));" \n
       " [_agent,_position] call zombie_loiter;" \n
       " _myDest = _agent getVariable [""myDest"",getposATL _agent];" \n
       "" \n
       "};" \n
       ""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "loiter">*/
        class loiter
        {
          priority = 0.000000;
          to="Loiter";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_hasMoved"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "wait">*/
        class wait
        {
          priority = 0.000000;
          to="Looking_for_Targ";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_hasMoved"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Chase">*/
    class Chase
    {
      name = "Chase";
      init = /*%FSM<STATEINIT""">*/
 "_timeN = time;" \n
"" \n
"if (speed _agent < 0.1) then {_countr = _countr + 1} else {_countr = 0};" \n
"_target = _agent call zombie_findTargetAgent;" \n
"_targetPosition = getPosATL _target;" \n
"_agentPosition = getPosATL _agent;" \n
"_targetdistance = _agent distance _target;" \n
"if ( _targetdistance < 2.2 ) then" \n
"{_r = 1;};" \n
"if (_targetdistance > 2.2 AND _targetdistance < 10) then" \n
"{_r = 6;};" \n
"if ( _targetdistance > 10 AND _targetdistance < 25 ) then" \n
"{_r = 8;};" \n
"if ( _targetdistance > 25 ) then" \n
"{_r = 15;};" \n
"_xt = _targetPosition select 0;" \n
"_yt = _targetPosition select 1;" \n
"_xa = _agentPosition select 0;" \n
"_ya = _agentPosition select 1;" \n
"_dx = (_xa - _xt);" \n
"_dy = (_ya - _yt);" \n
"_dir = _dy atan2 _dx;" \n
"_dx = ((_dx - _r) * (cos _dir));" \n
"_dy = ((_dy - _r) * (sin _dir));" \n
"_targetPos = [_xt + _dx, _yt + _dy, 0];" \n
"_agent moveTo _targetPos;" \n
"_isaggro = true;" \n
"if (_isrunner) then {" \n
"_agent forceSpeed 8;" \n
"} else {" \n
"_agent forceSpeed 2;" \n
"};" \n
"if (_losCheck == 2) then {" \n
"_losCheck = 0;" \n
"_cantSee = [_agent,_target] call dayz_losCheck;" \n
"};" \n 
       ""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Not_Alive">*/
        class Not_Alive
        {
          priority = 5.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isAlive"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Nobody_Near">*/
        class Nobody_Near
        {
          priority = 4.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "No_Target">*/
        class No_Target
        {
          priority = 3.000000;
          to="Reset_Targeting";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(isNull _target)"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "cant_see">*/
        class cant_see
        {
          priority = 2.000000;
          to="Finish_Move";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_cantSee"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Time_Check">*/
        class Time_Check
        {
          priority = 0.000000;
          to="Chase";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _timeN) > 1"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"_losCheck = _losCheck + 1;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Cleanup_">*/
    class Cleanup_
    {
      name = "Cleanup_";
      init = /*%FSM<STATEINIT""">*/"_waitStart = time;" \n
       "" \n
       "_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],300];" \n
       "_isSomeone = ({isPlayer _x} count _list) > 0;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "nobody_around">*/
        class nobody_around
        {
          priority = 0.000000;
          to="End";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"dayz_spawnZombies = dayz_spawnZombies - 1;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "someone_here">*/
        class someone_here
        {
          priority = 0.000000;
          to="wait";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Finish_Move">*/
    class Finish_Move
    {
      name = "Finish_Move";
      init = /*%FSM<STATEINIT""">*/"_timeN = time;" \n
       "" \n
       "_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],300];" \n
       "_isSomeone = ({isPlayer _x} count _list) > 0;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "Nobody_Near">*/
        class Nobody_Near
        {
          priority = 4.000000;
          to="Cleanup_";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "finished">*/
        class finished
        {
          priority = 1.000000;
          to="Reset_Targeting";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"_agent distance _targetPos < 1"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "too_long">*/
        class too_long
        {
          priority = 0.000000;
          to="Reset_Targeting";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _timeN) > 10"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "wait">*/
    class wait
    {
      name = "wait";
      init = /*%FSM<STATEINIT""">*/"_list = (getposATL _agent) nearEntities [[""CAManBase"",""AllVehicles""],300];" \n
       "_isSomeone = ({isPlayer _x} count _list) > 0;" \n
       "" \n
       "_timeN = time;"/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "time_up">*/
        class time_up
        {
          priority = 0.000000;
          to="End";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _waitStart) > 300"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "nobody_around">*/
        class nobody_around
        {
          priority = 0.000000;
          to="End";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"!_isSomeone"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/"dayz_spawnZombies = dayz_spawnZombies - 1;"/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "deleted">*/
        class deleted
        {
          priority = 0.000000;
          to="End";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"isNull _agent;"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
        /*%FSM<LINK "Time_Check">*/
        class Time_Check
        {
          priority = 0.000000;
          to="wait";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"(time - _timeN) > 30"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
    /*%FSM<STATE "Reset_Targeting">*/
    class Reset_Targeting
    {
      name = "Reset_Targeting";
      init = /*%FSM<STATEINIT""">*/"if (!isNull _target) then {" \n
       " _targetPos = getPosATL _target;" \n
       " _agent setVariable [""myDest"",_targetPos];" \n
       " _agent moveTo _targetPos;" \n
       "};" \n
       "" \n
       "_agent setVariable [""targets"",[],true];" \n
       "_target = objNull;" \n
       ""/*%FSM</STATEINIT""">*/;
      precondition = /*%FSM<STATEPRECONDITION""">*/""/*%FSM</STATEPRECONDITION""">*/;
      class Links
      {
        /*%FSM<LINK "true">*/
        class true
        {
          priority = 0.000000;
          to="Loiter";
          precondition = /*%FSM<CONDPRECONDITION""">*/""/*%FSM</CONDPRECONDITION""">*/;
          condition=/*%FSM<CONDITION""">*/"true"/*%FSM</CONDITION""">*/;
          action=/*%FSM<ACTION""">*/""/*%FSM</ACTION""">*/;
        };
        /*%FSM</LINK>*/
      };
    };
    /*%FSM</STATE>*/
  };
  initState="init";
  finalStates[] =
  {
    "End"
  };
};
/*%FSM</COMPILE>*/
 

 

 

wild_spawnzombie.sqf

 

 
private ["_unitTypes","_isrunner","_lootType","_lootTypeCfg","_loot_count","_index","_weights","_loot","_array","_player","_doLoiter","_agent","_type","_radius","_method","_position","_isAlive","_myDest","_newDest","_rnd","_id"];
_player = _this select 0;
 
_unitTypes = [];
if (DZE_MissionLootTable) then {
_unitTypes =  []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
} else {
_unitTypes =  []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
};
_doLoiter =  true;
 
_loot =  "";
_array =  [];
_agent =  objNull;
 
_type = _unitTypes call BIS_fnc_selectRandom;
 
//Create the Group && populate it
//diag_log ("Spawned: " + _type);
_radius = 40;
_method = "NONE";
 
_position = [_player,120,200,10,0,0,0] call BIS_fnc_findSafePos;
 
_agent = createAgent [_type, _position, [], _radius, _method];
 
if (_doLoiter) then {
//_agent setPosATL _position;
//_agent setVariable ["doLoiter",true,true];
_agent setDir round(random 180);
};
 
dayz_spawnZombies = dayz_spawnZombies + 1;
 
if (random 1 > 0.7) then {
_agent setUnitPos "Middle";
};
 
if (isNull _agent) exitWith {
dayz_spawnZombies = dayz_spawnZombies - 1;
};
 
_isAlive = alive _agent;
 
_myDest = getPosATL _agent;
_newDest = getPosATL _agent;
_agent setVariable ["myDest",_myDest];
_agent setVariable ["newDest",_newDest];
 
//Add some loot
_rnd = random 1;
if (_rnd > 0.3) then {
if (DZE_MissionLootTable) then {
_lootType = getText (missionConfigFile >> "CfgVehicles" >> _type >> "zombieLoot");
} else {
_lootType = getText (configFile >> "CfgVehicles" >> _type >> "zombieLoot");
};
 
if (DZE_MissionLootTable) then {
_lootTypeCfg = getArray (missionConfigFile >> "CfgLoot" >> _lootType);
} else {
_lootTypeCfg = getArray (configFile >> "CfgLoot" >> _lootType);
};
_array = [];
{
_array set [count _array, _x select 0]
} count _lootTypeCfg;
if (count _array > 0) then {
_index = dayz_CLBase find _lootType;
_weights = dayz_CLChances select _index;
_loot = _array select (_weights select (floor(random (count _weights))));
if(!isNil "_array") then {
if (DZE_MissionLootTable) then {
_loot_count = getNumber(missionConfigFile >> "CfgMagazines" >> _loot >> "count");
} else {
_loot_count = getNumber(configFile >> "CfgMagazines" >> _loot >> "count");
};
if(_loot_count>1) then {
_agent addMagazine [_loot, ceil(random _loot_count)];
} else {
_agent addMagazine _loot;
};
};
};
};
 
// Slow zombie down.
_agent forceSpeed 2; 
// Create random runners 
_rnd = random(1);
if (_rnd > .8) then {
_isrunner = true;
} else {
_isrunner = false;
};
 
//Start behavior
_id = [_position,_agent,_isrunner] execFSM "custom\walkers\zombie_agent.fsm";
 

 

 

*EDIT*

 

To fix this spammage of my client rpt, 

 

Inside fsm, where you put

 "_timeN = time;" \n
"" \n
"if (speed _agent < 0.1) then {_countr = _countr + 1} else {_countr = 0};" \n
"_target = _agent call zombie_findTargetAgent;" \n
"_targetPosition = getPosATL _target;" \n
"_agentPosition = getPosATL _agent;" \n
"_targetdistance = _agent distance _target;" \n
 
 
"_r = 0;" \n           //<------ ADD THIS RIGHT BETWEEN LIKE I HAVE
 

"if ( _targetdistance < 2.2 ) then" \n
"{_r = 1;};" \n
"if (_targetdistance > 2.2 AND _targetdistance < 10) then" \n
"{_r = 6;};" \n
"if ( _targetdistance > 10 AND _targetdistance < 25 ) then" \n
"{_r = 8;};" \n
"if ( _targetdistance > 25 ) then" \n
"{_r = 15;};" \n
"_xt = _targetPosition select 0;" \n
"_yt = _targetPosition select 1;" \n
"_xa = _agentPosition select 0;" \n
"_ya = _agentPosition select 1;" \n
"_dx = (_xa - _xt);" \n
"_dy = (_ya - _yt);" \n
"_dir = _dy atan2 _dx;" \n
"_dx = ((_dx - _r) * (cos _dir));" \n
"_dy = ((_dy - _r) * (sin _dir));" \n
"_targetPos = [_xt + _dx, _yt + _dy, 0];" \n
"_agent moveTo _targetPos;" \n
"_isaggro = true;" \n
"if (_isrunner) then {" \n
"_agent forceSpeed 8;" \n
"} else {" \n
"_agent forceSpeed 2;" \n
"};" \n
"if (_losCheck == 2) then {" \n
"_losCheck = 0;" \n
"_cantSee = [_agent,_target] call dayz_losCheck;" \n
"};" \n

 

 

Link to comment
Share on other sites

  • 2 weeks later...

Hey - sorry been working on a diff project for a while now.


se7en = that's mostly right.   The zombies ARE chasing you, they're just doing it at a walking pace.  When you hear them shout, they have targeted something, and are walking toward it stupidly slow.  They do have a tendancy to mill around aimlessly when they don't have agro.

ALKINDA - That's because those variables aren't defined somewhere - but it looks like you figured that out.   My R value starts as _r = 20.   That might help keep them milling around some as well and not so stationary.

 

 

 

 

 


 

Link to comment
Share on other sites

ALKINDA - That's because those variables aren't defined somewhere - but it looks like you figured that out.   My R value starts as _r = 20.   That might help keep them milling around some as well and not so stationary.

 

so should i set it to _r=20 and not _r=0? 

 

I havent seen any issues with the zombies yet, i will try out setting it to 20 though.

Link to comment
Share on other sites

  • 4 weeks later...

Further development could lead to the following  (all of these are currently in development on my testbed...)

  • Zombie Speed based on skin
  • Zombie Speed based on type of building that spawned them
  • Zombie Speed based on time of day (in game).
  • Zombie Speed based on length of time the zombie has been "alive".

Anyway, hope this makes sense to some of you that have been looking for this solution!

- McK

You now have Zombies that determine their top speed as soon as they're spawned in, with a 20% chance to be fast.  If you want more to be faster, alter the _rnd check in the wildspawn and zombie generate sqf's.

seem to have much more than 20% fast.. more like 90% fast .. what shout lower to to get say 5 percent ??

 

Link to comment
Share on other sites

  • 4 months later...

Altered damage for fast zeds were mentioned earlier in this thread. Did anyone ever get that working? I'd like to have reduced damage for the fast zeds. 

I've managed to get this script installed and working.  The only issue i has is when a "fast" zombie would spawn, it killed the server FPS.  Once you killed that zombie, FPS came back.  Oddly enough.  So i havnt had the time to really test it as i pulled it out once i found that out. But i know there are a couple threads out there that explain how to change the amount of damage they do. I would need to find them.

Link to comment
Share on other sites

  • 5 months later...

Hi

Where do i add this in my zombie_agent? Can't get that part to work get some errors in the file

_timeN = time;

if (speed _agent < 0.1) then {_countr = _countr + 1} else {_countr = 0};
_target = _agent call zombie_findTargetAgent;
_targetPosition = getPosATL _target;
_agentPosition = getPosATL _agent;
_targetdistance = _agent distance _target;

//target distance calculation coding provided by the Unleashed Project.

if ( _targetdistance < 2.2 ) then
{_r = 1;};
if (_targetdistance > 2.2 AND _targetdistance < 10) then
{_r = 6;};
if ( _targetdistance > 10 AND _targetdistance < 25 ) then
{_r = 8;};
if ( _targetdistance > 25 ) then
{_r = 15;};

_xt = _targetPosition select 0;
_yt = _targetPosition select 1;
_xa = _agentPosition select 0;
_ya = _agentPosition select 1;
_dx = _xa - _xt;
_dy = _ya - _yt;
_dir = _dy atan2 _dx;
_dx = _dx - _r * cos _dir;
_dy = _dy - _r * sin _dir;
_targetPos = [_xt + _dx, _yt + _dy, 0];

//Move to target
_agent moveTo _targetPos;

//The following code is provided by McKeighan to give random zombies speed.

//flag turns zombie into second hand z once loiter state is re initiated.
_isaggro = true;

//this flag is set in the zombie_generate.sqf / wildzombie_generate.sqf

if (_isrunner) then {
    _agent forceSpeed 8;
} else {
    _agent forceSpeed 2;
};

if (_losCheck == 2) then {
    _losCheck = 0;
    _cantSee = [_agent,_target] call dayz_losCheck;
};

Link to comment
Share on other sites

I'm having trouble installing this.

I added these lines to my custom compiles:

zombie_loiter             = compile preprocessFileLineNumbers "custom\zombie_loiter.sqf";        
zombie_generate         = compile preprocessFileLineNumbers "custom\zombie_generate.sqf";        
wild_spawnZombies         = compile preprocessFileLineNumbers "custom\wild_spawnZombies.sqf";    
player_zombieAttack =             compile preprocessFileLineNumbers "custom\player_zombieAttack.sqf";

 

I placed the sqf files in my custom folder:

zombie_loiter.sqf

zombie_generate.sqf

wild_spawnZombies.sqf

player_zombieAttack.sqf (from McKeighan's )

 

I used the FSM editor to change code in zombie_agent.fsm

 

I've seen 1 zombie that moved slow and the rest all run as usual.

I used the authors player_zombieAttack.sqf  and I do get pulled out of cars but the zombies don't seem to hit harder than usual.

 

Here are my files:

 

player_zombieAttack.sqf

Spoiler

private ["_unit","_move","_damage","_wound","_index","_cnt","_dir","_hpList","_hp","_strH","_dam","_vehicle","_tPos","_zPos","_cantSee","_inAngle","_rnd","_openVehicles","_chance","_attackanimations","_type","_targets"];
_unit = _this select 0;
_type = _this select 1;
_vehicle = (vehicle player);

_targets = _unit getVariable ["targets",[]];

if (!dayz_zedsAttackVehicles && !(_vehicle in _targets)) exitWith {
    //diag_log ("not attacking vehicle" + str(_vehicle));  
};

if ((speed _vehicle > 15)) exitWith {  // up from 10.
    //diag_log ("too fast abort attack" + str(_vehicle));
};

//Do the attack - ADJUSTING _rnd variable for hit damage? - McK
if (r_player_unconscious && _vehicle == player && _type == "zombie") then {
    _rnd = (round(random 4)) + 1;
    _move = "ZombieFeed" + str(_rnd);
} else {
    if (_type == "zombie") then {
        _rnd = (round(random 9)) + 1;
        _move = "ZombieStandingAttack" + str(_rnd);
    } else {
        _move = "Dog_Attack";
    };
};

_tPos = visiblePositionASL _vehicle;
_zPos = visiblePositionASL _unit;        

_dir = [_zpos,_tPos] call BIS_Fnc_dirTo;
_unit setDir _dir;

// _unit playMove _move;

if (local _unit) then {
    _unit switchMove _move;
} else {
    [objNull,  _unit,  rSwitchMove,  _move] call RE;
};

//Wait
sleep 0.3;

if (_vehicle != player) then {
    _hpList =     _vehicle call vehicle_getHitpoints;
    _hp =         _hpList call BIS_fnc_selectRandom;
    _wound =     getText(configFile >> "cfgVehicles" >> (typeOf _vehicle) >> "HitPoints" >> _hp >> "name");
    _damage =     random 0.50;  // was 0.08
    _chance =    round(random 12);

    
    if ((_chance % 4) == 0) then {
        _openVehicles = ["TowingTractor","tractorold","CSJ_GyroC","CSJ_GyroP","UH1_Base","BTR40_MG_TK_INS_EP1","LandRover_MG_TK_EP1_DZE","HMMWV_M998A2_SOV_DES_EP1_DZ","UAZ_MG_Base","datsun1_civil_1_open","datsun1_civil_3_open","TT650_Base","HMMWV_M998A2_SOV_DES_EP1_DZE","AH6_Base_EP1","LandRover_Special_CZ_EP1_DZ","LandRover_Special_CZ_EP1_DZE","LandRover_MG_TK_EP1_DZ","ATV_Base_EP1","Motorcycle","Bicycle"];
        {
            if (_vehicle isKindOf _x) exitWith {
                player action ["eject", _vehicle];
            };
        } count _openVehicles;
    };

    diag_log ("TESTING-YANK FROM VEHICLE = Hitpoints " +str(_wound) + "hit points " + str(_hpList));

    if (_wound in DZE_vehicleZwounds) then {
        
        _strH = "hit_" + (_wound);
        _dam = _vehicle getVariable [_strH,0];
        
        //diag_log ("Hitpoints " +str(_wound) +str(_total));
        
        if (_dam >= 1) then {
            if (r_player_blood < (r_player_bloodTotal * 0.8)) then {
                _cnt = count (DAYZ_woundHit select 1);
                _index = floor (random _cnt);
                _index = (DAYZ_woundHit select 1) select _index;
                _wound = (DAYZ_woundHit select 0) select _index;
            } else {
                _cnt = count (DAYZ_woundHit_ok select 1);
                _index = floor (random _cnt);
                _index = (DAYZ_woundHit_ok select 1) select _index;
                _wound = (DAYZ_woundHit_ok select 0) select _index;
            };
            _damage = 0.1 + random (8);  // was random (1.2)
            //diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage));
            [player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler;
            [_unit,"hit",2,false] call dayz_zombieSpeak;    
        };
    };
} else {
    //diag_log ("Animation state: " +(_currentAnim));
    _attackanimations = ["zombiestandingattack1","zombiestandingattack2","zombiestandingattack3","zombiestandingattack4","zombiestandingattack5","zombiestandingattack6","zombiestandingattack7","zombiestandingattack8","zombiestandingattack9","zombiestandingattack10","zombiefeed1","zombiefeed2","zombiefeed3","zombiefeed4","zombiefeed5"];
    if (((_unit distance player) <= dayz_areaAffect) && ((animationState _unit) in _attackanimations)) then {
        //check LOS
        _inAngle = [_zPos,(getdir _unit),180,_tPos] call fnc_inAngleSector;
        if (_inAngle) then {
            //LOS check
            _cantSee = [_unit,_vehicle] call dayz_losCheck;
            if (!_cantSee) then {
                if (r_player_blood < (r_player_bloodTotal * 0.8)) then {
                    _cnt = count (DAYZ_woundHit select 1);
                    _index = floor (random _cnt);
                    _index = (DAYZ_woundHit select 1) select _index;
                    _wound = (DAYZ_woundHit select 0) select _index;
                } else {
                    _cnt = count (DAYZ_woundHit_ok select 1);
                    _index = floor (random _cnt);
                    _index = (DAYZ_woundHit_ok select 1) select _index;
                    _wound = (DAYZ_woundHit_ok select 0) select _index;
                };
                _damage = 0.1 + random (6); // was random 1.2
                //diag_log ("START DAM: Player Hit on " + _wound + " for " + str(_damage));
                [player, _wound, _damage, _unit,"zombie"] call fnc_usec_damageHandler;
                [_unit,"hit",2,false] call dayz_zombieSpeak;
            };
        };
    };
};

 

wild_spawnZombies.sqf

Spoiler

private ["_unitTypes","_isrunner","_lootType","_lootTypeCfg","_loot_count","_index","_weights","_loot","_array","_player","_doLoiter","_agent","_type","_radius","_method","_position","_isAlive","_myDest","_newDest","_rnd","_id"];
_player = _this select 0;

_unitTypes = [];
if (DZE_MissionLootTable) then {
    _unitTypes =     []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
} else {
    _unitTypes =     []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
};
_doLoiter =     true;

_loot =     "";
_array =     [];
_agent =     objNull;

_type = _unitTypes call BIS_fnc_selectRandom;

//Create the Group && populate it
//diag_log ("Spawned: " + _type);
_radius = 40;
_method = "NONE";

_position = [_player,120,200,10,0,0,0] call BIS_fnc_findSafePos;

_agent = createAgent [_type, _position, [], _radius, _method];

if (_doLoiter) then {
    //_agent setPosATL _position;
    //_agent setVariable ["doLoiter",true,true];
    _agent setDir round(random 180);
};

dayz_spawnZombies = dayz_spawnZombies + 1;

if (random 1 > 0.7) then {
    _agent setUnitPos "Middle";
};

if (isNull _agent) exitWith {
    dayz_spawnZombies = dayz_spawnZombies - 1;
};

_isAlive = alive _agent;

_myDest = getPosATL _agent;
_newDest = getPosATL _agent;
_agent setVariable ["myDest",_myDest];
_agent setVariable ["newDest",_newDest];

//Add some loot
_rnd = random 1;
if (_rnd > 0.3) then {
    if (DZE_MissionLootTable) then {
        _lootType = getText (missionConfigFile >> "CfgVehicles" >> _type >> "zombieLoot");
    } else {
        _lootType = getText (configFile >> "CfgVehicles" >> _type >> "zombieLoot");
    };

    if (DZE_MissionLootTable) then {
        _lootTypeCfg = getArray (missionConfigFile >> "CfgLoot" >> _lootType);
    } else {
        _lootTypeCfg = getArray (configFile >> "CfgLoot" >> _lootType);
    };
    _array = [];
    {
        _array set [count _array, _x select 0]
    } count _lootTypeCfg;
    if (count _array > 0) then {
        _index = dayz_CLBase find _lootType;
        _weights = dayz_CLChances select _index;
        _loot = _array select (_weights select (floor(random (count _weights))));
        if(!isNil "_array") then {
            if (DZE_MissionLootTable) then {
                _loot_count =    getNumber(missionConfigFile >> "CfgMagazines" >> _loot >> "count");
            } else {
                _loot_count =    getNumber(configFile >> "CfgMagazines" >> _loot >> "count");
            };
            if(_loot_count>1) then {
                _agent addMagazine [_loot, ceil(random _loot_count)];
            } else {
                _agent addMagazine _loot;
            };
        };
    };
};

// Slow zombie down.
_agent forceSpeed 2;
// Create random runners
_rnd = random(1);
if (_rnd > .8) then {
    _isrunner = true;
} else {
    _isrunner = false;
};

//Start behavior
_id = [_position,_agent] execFSM "custom\zombie_agent.fsm";

 

zombie_generate.sqf

Spoiler

private ["_position","_unitTypes","_radius","_method","_agent","_isrunner"];

_position = _this select 0;
_doLoiter = _this select 1; // wander around
_unitTypes = _this select 2; // class of wanted models
_maxControlledZombies = round(dayz_maxLocalZombies);

_cantSee = {
    private ["_isok"];

    _isok = true;
    _zPos = +(_this select 0);
    if (count _zPos < 3) exitWith {
        diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos];
        false
    };
    _zPos = ATLtoASL _zPos;
    _fov = _this select 1; // players half field of view
    _safeDistance = _this select 2; // minimum distance. closer is wrong
    _farDistance = _this select 3; // distance further we won't check
    _zPos set [2, (_zPos select 2) + 1.7];
    {
        _xasl = getPosASL _x;
        if (_xasl distance _zPos < _farDistance) then {
            if (_xasl distance _zPos < _safeDistance) then {
                _isok = false;
            }
            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?
                        (!(terrainIntersectASL [_zPos, _eye]) // no terrain between?
                        && {(!(lineIntersects [_zPos, _eye]))}) // && no object between?
                    )}) then {
                    _isok = false;
                };
            };
        };
        if (!_isok) exitWith {false};
    } count 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
        _tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0;
        if (_tooClose) exitwith {
            // diag_log ("Zombie_Generate: was too close to player.");
        };

        //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];
        sleep 0.001;

        //add to global counter
        dayz_spawnZombies = dayz_spawnZombies + 1;

        //Add some loot
        _loot = "";
        _array = [];
        _rnd = random 1;
        if (_rnd < 0.2) then {
            _lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
            if (isText _lootType) then {
                _array = [];
                {
                    _array set [count _array, _x select 0]
                } count 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;
                        };
                    };
                };
            };
        };

        _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;
            sleep 0.001;
            _agtPos = +(_position);
            _agtPos set [2, -3];
            _agent setPosASL _agtPos;
            sleep 0.001;
            */
            _agent setDir random 360;
            //_agent setPosATL _position;
            sleep 0.001;

            _position = getPosATL _agent;

            _favStance = (
                switch ceil(random(3^0.5)^2) do {
                    //case 3: {"DOWN"}; // prone
                    case 2: {"Middle"}; // Kneel
                    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;
        };
        //add to monitor
        //dayz_zedMonitor set [count dayz_zedMonitor, _agent];

        //Disable simulation
        PVDZE_Server_Simulation = [_agent, false];
        publicVariableServer "PVDZE_Server_Simulation";
        
       // Make AI Companions fire at zeds
        _agent addRating -1000000;
        // Set zombie initial walkspeed - McK 11/18/14
        _agent forceSpeed 2;
        // Create random runners - McK 11/18/14
        _rnd = random(1);
        if (_rnd > .925) then {
            _isrunner = true;
        } else {
            _isrunner = false;
        };
        
        //Start behavior
        _id = [_position,_agent] execFSM "custom\zombie_agent.fsm";
    };
};

 

zombie_loiter.sqf

Spoiler

private ["_unit","_originalPos","_pos","_chance","_playerpos"];
_unit =         _this select 0;
_originalPos =     _this select 1;
_pos =             getPosATL _unit;
_playerpos =     ([player] call FNC_GetPos);

if (count _this > 2) then {
    _pos = _this select 2;
} else {
    //_unit enableAI "MOVE";
    //_unit enableAI "ANIM";
    
    _chance =    round(random 12);
    if ((_chance % 4) == 0) then {
        //_Offset = [0,0,0];
        //_playerworldPos = _playerpos modelToWorld _Offset;
        _pos = [_playerpos,30,120,4,0,5,0] call BIS_fnc_findSafePos;
    } else {
    _pos = [_originalPos,10,90,4,0,5,0] call BIS_fnc_findSafePos;
    };
    
    if (_unit distance player > 250) then {
        _pos = [_playerpos,120,200,4,0,5,0] call BIS_fnc_findSafePos;
    };
};

if(isNull group _unit) then {
    _unit moveTo _pos;
} else {
    _unit domove _pos;        
};    
_unit forceSpeed 2;
_unit setVariable ["myDest",_pos];

 

 

https://www.dropbox.com/home?preview=zombie_agent.fsm

 

If someone would be so kind as to take a look at this.

 

Thank you.

Link to comment
Share on other sites

On 1/10/2016 at 3:50 AM, meanbeandk said:

Hi

Where do i add this in my zombie_agent? Can't get that part to work get some errors in the file


_timeN = time;

if (speed _agent < 0.1) then {_countr = _countr + 1} else {_countr = 0};
_target = _agent call zombie_findTargetAgent;
_targetPosition = getPosATL _target;
_agentPosition = getPosATL _agent;
_targetdistance = _agent distance _target;

//target distance calculation coding provided by the Unleashed Project.

if ( _targetdistance < 2.2 ) then
{_r = 1;};
if (_targetdistance > 2.2 AND _targetdistance < 10) then
{_r = 6;};
if ( _targetdistance > 10 AND _targetdistance < 25 ) then
{_r = 8;};
if ( _targetdistance > 25 ) then
{_r = 15;};

_xt = _targetPosition select 0;
_yt = _targetPosition select 1;
_xa = _agentPosition select 0;
_ya = _agentPosition select 1;
_dx = _xa - _xt;
_dy = _ya - _yt;
_dir = _dy atan2 _dx;
_dx = _dx - _r * cos _dir;
_dy = _dy - _r * sin _dir;
_targetPos = [_xt + _dx, _yt + _dy, 0];

//Move to target
_agent moveTo _targetPos;

//The following code is provided by McKeighan to give random zombies speed.

//flag turns zombie into second hand z once loiter state is re initiated.
_isaggro = true;

//this flag is set in the zombie_generate.sqf / wildzombie_generate.sqf

if (_isrunner) then {
    _agent forceSpeed 8;
} else {
    _agent forceSpeed 2;
};

if (_losCheck == 2) then {
    _losCheck = 0;
    _cantSee = [_agent,_target] call dayz_losCheck;
};

For that part it says to click on the Chase box & replace the code that,s in there.

Did you use the FSM tool?

Link to comment
Share on other sites

10 hours ago, Hux said:

I'm having trouble installing this.

I added these lines to my custom compiles:

zombie_loiter             = compile preprocessFileLineNumbers "custom\zombie_loiter.sqf";        
zombie_generate         = compile preprocessFileLineNumbers "custom\zombie_generate.sqf";        
wild_spawnZombies         = compile preprocessFileLineNumbers "custom\wild_spawnZombies.sqf";    
player_zombieAttack =             compile preprocessFileLineNumbers "custom\player_zombieAttack.sqf";

...

I had major FPS issues with the random speed zombies.  I had to go to only walking zombies.

As for the the zombie hitting harder, i think you need the damagehandlerZ.sqf also

here are my files, use them as needed or compare them to yours.

My zombies, take many more bullets to the body, headshots kill them easily.  They walk and they hit harder.

As for changing the speeds of the zombies, its in the FSM.  Look for 

_agent forceSpeed

and change the number.

(this method ^^ using NP++)

Or FSM editor, click on the white "chase" box and you will see "_agent forceSpeed"

From what i've found researching, zombies can only go fast or slow, theres no in between.  2 is slow, 8 is fast.

https://www.dropbox.com/s/1ocw6z9w3o8owr8/SlowZeds.rar?dl=0

GL

Link to comment
Share on other sites

3 hours ago, theduke said:

I had major FPS issues with the random speed zombies.  I had to go to only walking zombies.

As for the the zombie hitting harder, i think you need the damagehandlerZ.sqf also

here are my files, use them as needed or compare them to yours.

My zombies, take many more bullets to the body, headshots kill them easily.  They walk and they hit harder.

As for changing the speeds of the zombies, its in the FSM.  Look for 

 

Hidden Content

 

and change the number.

(this method ^^ using NP++)

Or FSM editor, click on the white "chase" box and you will see "_agent forceSpeed"

From what i've found researching, zombies can only go fast or slow, theres no in between.  2 is slow, 8 is fast.

https://www.dropbox.com/s/1ocw6z9w3o8owr8/SlowZeds.rar?dl=0

GL

Thank you for the info.

I wanted at least half the zeds to run (maybe 3/4).

Right now after testing several times I've only seen 1 zed move slow. The rest are behaving as usual.

The only difference I've seen so far is being pulled out of vehicle by the zeds.

So I'm wondering if I set the path right and am calling the sqf files properly.

I'm using all default settings right now and the zombie attack sqf provided by the author.

Do the lines in the custom compiles look right to you? (I have all sqf files in my custom folder)

Does the code look right in the sqf files?

I've looked at it several times and it looks fine to me but I could be misunderstanding the instructions...

Thanks for the help.

Link to comment
Share on other sites

1 hour ago, Hux said:

Thank you for the info.

I wanted at least half the zeds to run (maybe 3/4).

Right now after testing several times I've only seen 1 zed move slow. The rest are behaving as usual.

The only difference I've seen so far is being pulled out of vehicle by the zeds.

So I'm wondering if I set the path right and am calling the sqf files properly.

I'm using all default settings right now and the zombie attack sqf provided by the author.

Do the lines in the custom compiles look right to you? (I have all sqf files in my custom folder)

Does the code look right in the sqf files?

I've looked at it several times and it looks fine to me but I could be misunderstanding the instructions...

Thanks for the help.

unfortunately i dont understand the code, language if you want...i only understand the file structure and able to modify the code a bit...

The compiles look fine, if you have all your files in that folder like you mentioned.  Just make sure you done have 2 compiles, or 2 lines calling the same file in y our mission pbo.

but as for the half running half slow. i hope you can figure it out...I never was able to lol the secnd a fast zombie would spawn, the FPS would drop...kill that running zombie, FPS came back up to normal.  I even tried to go 20% fast, 80% slow, or vice versa, and it was the same issue... and i dont have the files anymore to be able to compare them :(   Quite possible i did something wrong, or didnt have the correct files to begin with.  So instead i went the "hit harder and harder to kill" way lol

GL let me know if you figure it out

Link to comment
Share on other sites

4 hours ago, theduke said:

unfortunately i dont understand the code, language if you want...i only understand the file structure and able to modify the code a bit...

The compiles look fine, if you have all your files in that folder like you mentioned.  Just make sure you done have 2 compiles, or 2 lines calling the same file in y our mission pbo.

but as for the half running half slow. i hope you can figure it out...I never was able to lol the secnd a fast zombie would spawn, the FPS would drop...kill that running zombie, FPS came back up to normal.  I even tried to go 20% fast, 80% slow, or vice versa, and it was the same issue... and i dont have the files anymore to be able to compare them :(   Quite possible i did something wrong, or didnt have the correct files to begin with.  So instead i went the "hit harder and harder to kill" way lol

GL let me know if you figure it out

Thanks.

Your files are helpful. I'm trying a few different things and I'll let you know how it goes.

Link to comment
Share on other sites

20 hours ago, Hux said:

I was wondering if there is a way to increase the chance of being infected by a zed?

Anyone?

In my search I've only found "chance of infection" for bloodbag use but not for being hit by zed and I can't find anything in the files I'm using.

BTW, theduke I'm using your fn_damageHandlerZ.sqf   and it works great. I love how zeds knock players out.

Thank you.

Link to comment
Share on other sites

1 hour ago, Hux said:

Anyone?

In my search I've only found "chance of infection" for bloodbag use but not for being hit by zed and I can't find anything in the files I'm using.

BTW, theduke I'm using your fn_damageHandlerZ.sqf   and it works great. I love how zeds knock players out.

Thank you.

Glad it worked for you.  I looked at the chance of infection increased on zombie hit, but i cant find it either. but i cam accross this... it might help you

 

 

Link to comment
Share on other sites

7 hours ago, Hux said:

Anyone?

In my search I've only found "chance of infection" for bloodbag use but not for being hit by zed and I can't find anything in the files I'm using.

BTW, theduke I'm using your fn_damageHandlerZ.sqf   and it works great. I love how zeds knock players out.

Thank you.

Yes, took me 10 minutes to search throught files ;)

Anyways, you need to change your fn_damageHandler.sqf

The lines you're looking for is line 129

Here is the code, with my comment (line 3) :

In this exemple, on each hit, you have 1 chance on 500 to be infected

if (_unitIsPlayer) then {
		_rndPain = 		(random 10);
		_rndInfection = (random 500); // HERE, lower the number to increase chance of infection on hit
		_hitPain = 		(_rndPain < _damage);
		if ((_isHeadHit) || (_damage > 1.2 && _hitPain)) then {
			_hitPain = true;
		};
		_hitInfection = (_rndInfection < 1);
		//player sidechat format["HitPain: %1, HitInfection %2 (Damage: %3)",_rndPain,_rndInfection,_damage]; //r_player_infected
		if (_isHit) then {
			//Make hit worse
			if (_unitIsPlayer) then {
				r_player_blood = r_player_blood - 50;
			};
		};
		if (_hitInfection) then {
			//Set Infection if not already
			if (_unitIsPlayer && !_isPZombie) then {
				r_player_infected = true;
				player setVariable["USEC_infected",true,true];
			};

		};
		if (_hitPain) then {
			//Set Pain if not already
			if (_unitIsPlayer) then {
				r_player_inpain = true;
				player setVariable["USEC_inPain",true,true];
			};
		};
		if ((_damage > 1.5) && _isHeadHit) then {
			[_source,"shothead"] spawn player_death;
		};
	};

To call you custom eventHandler, you need to have custom compiles.sqf

Then, you need to find the line starting with fnc_usec_damageHandler

and change it to where you put your custom fn_damageHandler.sqf

Example :

fnc_usec_damageHandler = compile preprocessFileLineNumbers "custom\fn_damageHandler.sqf"; //Event handler run on damage

 

Link to comment
Share on other sites

14 hours ago, Oshydaka said:

Yes, took me 10 minutes to search throught files ;)

Anyways, you need to change your fn_damageHandler.sqf

The lines you're looking for is line 129

Here is the code, with my comment (line 3) :

In this exemple, on each hit, you have 1 chance on 500 to be infected


if (_unitIsPlayer) then {
		_rndPain = 		(random 10);
		_rndInfection = (random 500); // HERE, lower the number to increase chance of infection on hit
		_hitPain = 		(_rndPain < _damage);
		if ((_isHeadHit) || (_damage > 1.2 && _hitPain)) then {
			_hitPain = true;
		};
		_hitInfection = (_rndInfection < 1);
		//player sidechat format["HitPain: %1, HitInfection %2 (Damage: %3)",_rndPain,_rndInfection,_damage]; //r_player_infected
		if (_isHit) then {
			//Make hit worse
			if (_unitIsPlayer) then {
				r_player_blood = r_player_blood - 50;
			};
		};
		if (_hitInfection) then {
			//Set Infection if not already
			if (_unitIsPlayer && !_isPZombie) then {
				r_player_infected = true;
				player setVariable["USEC_infected",true,true];
			};

		};
		if (_hitPain) then {
			//Set Pain if not already
			if (_unitIsPlayer) then {
				r_player_inpain = true;
				player setVariable["USEC_inPain",true,true];
			};
		};
		if ((_damage > 1.5) && _isHeadHit) then {
			[_source,"shothead"] spawn player_death;
		};
	};

To call you custom eventHandler, you need to have custom compiles.sqf

Then, you need to find the line starting with fnc_usec_damageHandler

and change it to where you put your custom fn_damageHandler.sqf

Example :


fnc_usec_damageHandler = compile preprocessFileLineNumbers "custom\fn_damageHandler.sqf"; //Event handler run on damage

 

Ahh, I was looking in the wrong file.

I was looking in the fn_damageHandlerZ.sqf  that theduke so kindly provided.

So I found the fn_damageHandler.sqf in my client files and I'll put that in my mission folder as you described.

I really appreciate the detailed explanation.

Thank you.

Link to comment
Share on other sites

On 1/12/2016 at 7:21 AM, theduke said:

As for the the zombie hitting harder, i think you need the damagehandlerZ.sqf

 

 

How did you get the zeds to knock out players?

Is it a % of a chance setting?

I'd like to lower that chance if possible.

Link to comment
Share on other sites

51 minutes ago, Hux said:

How did you get the zeds to knock out players?

Is it a % of a chance setting?

I'd like to lower that chance if possible.

check post #7

http://opendayz.net/threads/increasing-zombie-damage-in-epoch.17695/

EDIT: I do remember changing it when i first got the code, but i cant remember for the life of me what i changed. sry dude

Link to comment
Share on other sites

  • 10 months later...

Hi, sorry. I'm still learning and a bit confused by this part.

the "chase" box in the agent.fsm?

I'm not sure where to put this

 

as you may of surmised, you're not quite done... you also have to edit the zombie_agent.fsm file. 

In the init step (red box at the top of the flowchart), change that coding to the following
 

_position = _this select 0;
_agent = _this select 1;
_secondHand = false;
_isrunner = _this select 2;

if (count _this > 2) then {
	_secondHand = true;
	//diag_log ("Second Hand Zombie Initialized: " + str(_this));
};

in the "chase" box, change the coding to the following.

 

_timeN = time;

if (speed _agent < 0.1) then {_countr = _countr + 1} else {_countr = 0};
_target = _agent call zombie_findTargetAgent;
_targetPosition = getPosATL _target;
_agentPosition = getPosATL _agent;
_targetdistance = _agent distance _target;

//target distance calculation coding provided by the Unleashed Project.

if ( _targetdistance < 2.2 ) then
{_r = 1;};
if (_targetdistance > 2.2 AND _targetdistance < 10) then
{_r = 6;};
if ( _targetdistance > 10 AND _targetdistance < 25 ) then
{_r = 8;};
if ( _targetdistance > 25 ) then
{_r = 15;};

_xt = _targetPosition select 0;
_yt = _targetPosition select 1;
_xa = _agentPosition select 0;
_ya = _agentPosition select 1;
_dx = _xa - _xt;
_dy = _ya - _yt;
_dir = _dy atan2 _dx;
_dx = _dx - _r * cos _dir;
_dy = _dy - _r * sin _dir;
_targetPos = [_xt + _dx, _yt + _dy, 0];

//Move to target
_agent moveTo _targetPos;

//The following code is provided by McKeighan to give random zombies speed.

//flag turns zombie into second hand z once loiter state is re initiated.
_isaggro = true;

//this flag is set in the zombie_generate.sqf / wildzombie_generate.sqf

if (_isrunner) then {
    _agent forceSpeed 8;
} else {
    _agent forceSpeed 2;
};

if (_losCheck == 2) then {
    _losCheck = 0;
    _cantSee = [_agent,_target] call dayz_losCheck;
};

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
×
×
  • Create New...