Simple AI Tutorial (no rMod or DayZ_Factions)

I will start over but I did originate with the beginning setup. Could you look at my init.sql real quick? I believe that is where the problem is. Thanks
Your init isn't passing enough arguments, and your add_unit isn't accepting enough arguments.. both of the files are not only outdated, but are separate version from each other..
 
Alright, I updated the unit_killed.sqf in the first post. It now properly respawns.. The code for adding zombie kills for npc kills is in there as well, if you want to change it to bandits then replace zombieKills with banditKills
 
Hey Sycosis, were is the instructions on how to add NPC kills to the debug Monitor? I've been all over these pages and haven't seen it, I thought I saw it at one point but can't find it anymore. Thanks for your help man
 
Change this:
Code:
_zombieKills = 0;
_humanity = 0;
 
_zombieKills = _killer getVariable["zombieKills",0];
_killer setVariable["zombieKills",_zombieKills+1,true];
 
_humanity = _killer getVariable["humanity",0];
_killer setVariable["humanity",_humanity+100,true];

To this:
Code:
_banditKills = 0;
_humanity = 0;
 
//AI kill counter & humanity
_banditKills = _killer getVariable["banditKills",0];
_killer setVariable["banditKills",_banditKills+1,true];
 
_humanity = _killer getVariable["humanity",0];
_killer setVariable["humanity",_humanity+100,true];

In the unit_Killed.sqf, then you should register a kill for bandits and increment your humanity.
 
Your init isn't passing enough arguments, and your add_unit isn't accepting enough arguments.. both of the files are not only outdated, but are separate version from each other..

Ok, I did as you said and started over. Good news: server works without any errors. Bad news: no AI spawning. Im still not sure I have the Init correct. Could ya take a quick look again? Thanks again for all the help!!
 

Attachments

  • init.sqf
    4.5 KB · Views: 11
Sorry to keep pestering you Sycosis :) I've tried the new unit_killed.sqf and they still won't respawn, I've even tried with and without the _ on respawnTime = _this select 9;
The AI also do not despawn, the bodies just like there forever.
My RPT shows no mention of a respawn timer.

Any ideas what i can try next ?
 
i to have issue with despawning...bodies end up stacking up tall lol...and some of my positions dont respawn at all
 
Find this line:
Code:
switch (_gearSet) do {
Below this line is a series of variables with self explanatory names. There is a case for each gearSet. To add more gearSets, simply follow the numbering scheme and add the next number, then go to your init and reference that number in the proper location. Keep in mind that if you create a new case, you need to keep the naming scheme the same so that the variable names matchup. That should be the extent of your interaction with that file.

What do you mean by "then go to your init and reference that number in the proper location."

I am confused here, but have everything else set up. Please clarify what I have to do here. Thanks.
 
You reference the gear set in the parameters in the init, so if you include a new case let's say case 2 then pass 2 in the parameter for gear set in your init, iirc its the second last param before the respawn time
 
Find this line:
Code:
switch (_gearSet) do {
Below this line is a series of variables with self explanatory names. There is a case for each gearSet. To add more gearSets, simply follow the numbering scheme and add the next number, then go to your init and reference that number in the proper location. Keep in mind that if you create a new case, you need to keep the naming scheme the same so that the variable names matchup. That should be the extent of your interaction with that file.

What do you mean by "then go to your init and reference that number in the proper location."

I am confused here, but have everything else set up. Please clarify what I have to do here. Thanks.
You reference the gear set in the parameters in the init, so if you include a new case let's say case 2 then pass 2 in the parameter for gear set in your init, iirc its the second last param before the respawn time
Correct. Once you create case 2, go back into your init, and set the troops you want to use it to have a gearSet of 2.
 
Sorry to keep pestering you Sycosis :) I've tried the new unit_killed.sqf and they still won't respawn, I've even tried with and without the _ on respawnTime = _this select 9;
The AI also do not despawn, the bodies just like there forever.
My RPT shows no mention of a respawn timer.

Any ideas what i can try next ?

Code:
private ["_player","_killer","_aispawnpos","_wpradius","_wpnum","_numUnits","_unitType","_faction","_baseSkill","_potentialSkill","_gearSet","_respawnTime","_zombieKills","_humanity"];
_player = _this select 0;
_killer = _this select 1;
_aispawnpos = _this select 2;
_wpradius = _this select 3;
_wpnum = _this select 4;
_numUnits = _this select 5;
_unitType = _this select 6;
_faction = _this select 7;
_baseSkill = _this select 8;
_potentialSkill = _this select 9;
_gearSet = _this select 10;
_respawnTime = _this select 11;
_zombieKills = 0;
_humanity = 0;
 
_zombieKills = _killer getVariable["zombieKills",0];
_killer setVariable["zombieKills",_zombieKills+1,true];
_humanity = _killer getVariable["humanity",0];
_killer setVariable["humanity",_humanity+100,true];
 
diag_log format["NPC killed, respawning in %1 seconds",_respawnTime];
sleep _respawnTime;
 
aispawnpos = _aispawnpos;
wpradius = _wpradius;
wpnum = _wpnum;
numUnits = _numUnits;
unitType = _unitType;
globalFaction = _faction;
baseSkill = _baseSkill;
potentialSkill = _potentialSkill;
gearSet = _gearSet;
respawnTime = _respawnTime;
 
diag_log format["Position: %1, Radius: %2, Waypoints: %3, Units: %4, Unit Type: %5, Faction: %6, Base Skill: %7, Potential Skill: %8, Gear Set: %9, Respawn Time: %10",aispawnpos,wpradius,wpnum,numUnits,unitType,globalFaction,baseSkill,potentialSkill,gearSet,respawnTime];
_aispawn = [aispawnpos,wpradius,wpnum,numUnits,unitType,globalFaction,baseSkill,potentialSkill,gearSet,respawnTime] execVM "scripts\add_unit_server.sqf";

Replace your unit_killed with this code, and then set your respawn timer for your AI to 60 seconds, and then kill them for a few minutes and then post me your rpt.
 
Ok, I did as you said and started over. Good news: server works without any errors. Bad news: no AI spawning. Im still not sure I have the Init correct. Could ya take a quick look again? Thanks again for all the help!!
Find this code..
Code:
// Extra actions for Taviana:
if (!isDedicated) then {
    [] execVM "kh_actions.sqf";
   
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";

Code:
// Extra actions for Taviana:
if (!isDedicated) then {
    [] execVM "kh_actions.sqf";
};
   
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";
Replace with this.

Also, put that zombie_generate line, below your preprocesses.. Right above this line:
Code:
"filmic" setToneMappingParams [0.153, 0.357, 0.231, 0.1573, 0.011, 3.750, 6, 4]; setToneMapping "Filmic";
 
Change this:
Code:
_zombieKills = 0;
_humanity = 0;
 
_zombieKills = _killer getVariable["zombieKills",0];
_killer setVariable["zombieKills",_zombieKills+1,true];
 
_humanity = _killer getVariable["humanity",0];
_killer setVariable["humanity",_humanity+100,true];

To this:
Code:
_banditKills = 0;
_humanity = 0;
 
//AI kill counter & humanity
_banditKills = _killer getVariable["banditKills",0];
_killer setVariable["banditKills",_banditKills+1,true];
 
_humanity = _killer getVariable["humanity",0];
_killer setVariable["humanity",_humanity+100,true];

In the unit_Killed.sqf, then you should register a kill for bandits and increment your humanity.
Correct. Make sure to change the variable in your local variable declaration as well (first line of the file).
 
can u help me with this buddy error from RPT log cnt get the ais to spawn ingame

Code:
18:12:44  Error Zero divisor
18:12:44 File mpmissions\__cur_mp.Chernarus\scripts\add_unit_server.sqf, line 7
18:12:44 "globalFaction is any"
18:12:44 Error in expression < _this select 4;
_globalFaction = _this select 5;
_baseSkill = _this select 6;
_>
18:12:44  Error position: <select 5;
_baseSkill = _this select 6;

My INIT.sqf

Code:
startLoadingScreen ["","RscDisplayLoadCustom"];
cutText ["","BLACK OUT"];
enableSaving [false, false];
 
dayZ_instance =    1;
hiveInUse    =    true;
dayzHiveRequest = [];
initialized = false;
dayz_previousID = 0;
 
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf";
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf";
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf";
progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "compiles.sqf";
progressLoadingScreen 1.0;
 
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";
 
"filmic" setToneMappingParams [0.153, 0.357, 0.231, 0.1573, 0.011, 3.750, 6, 4]; setToneMapping "Filmic";
 
 
if ((!isServer) && (isNull player) ) then {
    waitUntil {!isNull player};
    waitUntil {time > 3};
};
 
if ((!isServer) && (player != player)) then {
  waitUntil {player == player};
  waitUntil {time > 3};
};
 
if (isServer) then {
// For settings involving the factions, go to scripts\add_unit_server.sqf and adjust the settings at the top of the file
    _factions = [] execVM "scripts\set_unit_faction.sqf";
//_aispawnpos - Worldspace location
//_wpradius - Distance you want units to be able to travel
//_wpnum - Number of waypoints to place withing that distance. The higher the number, the more extensively the units will travel
//_numunits - Number of units to place. Keep in mind that squads will be placed in multiples of this number
//_unitType - Type of unit to place. 0: Random, 1: Sniper, 2: Gunner, 3: Militia, 4: Squad of the previous 3 types
//_faction - The type of faction you want this unit to adhere to. 0: RESISTANCE, 1: EAST, 2: WEST. Factions loyalties are set in scripts\set_unit_faction.sqf
//_baseSkill - Lowest possible skill that the units can posess from 1 to 10
//_potentialSkill - Highes possible skill that the units can posess from 1 to 10
//_gearSet - Which set of gear your units will use. To set the types of gear, edit the variables at the top of scripts\add_units_server.sqf
//_respawnTime - How long to wait until NPCs respawn (in seconds)
    _aispawn = [[4598.66,10197.7,0],650,12,4,0,0,1,5,0,1800] execVM "scripts\add_unit_server.sqf";
    _aispawn = [[6689.49,2623.59,0],160,8,4,0,0,1,5,1,1800] execVM "scripts\add_unit_server.sqf";//Stary Sabor
    _aispawn = [[10447.5,2246.96,0],180,3,3,0,1,1,5,0,1800] execVM "scripts\add_unit_server.sqf";//Stary Sabor
    _aispawn = [[4334.96,10496.3,0],500,20,4,0,1,1,5,1,1800] execVM "scripts\add_unit_server.sqf";//Stary Sabor   
};
 
if (isServer) then {
    hiveInUse    =    true;
    _serverMonitor =    [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
};
 
if (!isDedicated) then {[] execVM "Scripts\kh_actions.sqf";
    0 fadeSound 0;
    0 cutText [(localize "STR_AUTHENTICATING"), "BLACK FADED",60];
    _id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
    _playerMonitor =    [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";   
};
 
Find this code..
Code:
// Extra actions for Taviana:
if (!isDedicated) then {
    [] execVM "kh_actions.sqf";
 
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";

Code:
// Extra actions for Taviana:
if (!isDedicated) then {
    [] execVM "kh_actions.sqf";
};
 
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";
Replace with this.

Also, put that zombie_generate line, below your preprocesses.. Right above this line:
Code:
"filmic" setToneMappingParams [0.153, 0.357, 0.231, 0.1573, 0.011, 3.750, 6, 4]; setToneMapping "Filmic";

Ok, thank you. I made that change. Where is the rest supose to go tho? The: if (isServer) then { //for settings with the list of aispawn.......
 
can u help me with this buddy error from RPT log cnt get the ais to spawn ingame

Code:
18:12:44  Error Zero divisor
18:12:44 File mpmissions\__cur_mp.Chernarus\scripts\add_unit_server.sqf, line 7
18:12:44 "globalFaction is any"
18:12:44 Error in expression < _this select 4;
_globalFaction = _this select 5;
_baseSkill = _this select 6;
_>
18:12:44  Error position: <select 5;
_baseSkill = _this select 6;

My INIT.sqf

Code:
startLoadingScreen ["","RscDisplayLoadCustom"];
cutText ["","BLACK OUT"];
enableSaving [false, false];
 
dayZ_instance =    1;
hiveInUse    =    true;
dayzHiveRequest = [];
initialized = false;
dayz_previousID = 0;
 
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf";
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf";
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf";
progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "compiles.sqf";
progressLoadingScreen 1.0;
 
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";
 
"filmic" setToneMappingParams [0.153, 0.357, 0.231, 0.1573, 0.011, 3.750, 6, 4]; setToneMapping "Filmic";
 
 
if ((!isServer) && (isNull player) ) then {
    waitUntil {!isNull player};
    waitUntil {time > 3};
};
 
if ((!isServer) && (player != player)) then {
  waitUntil {player == player};
  waitUntil {time > 3};
};
 
if (isServer) then {
// For settings involving the factions, go to scripts\add_unit_server.sqf and adjust the settings at the top of the file
    _factions = [] execVM "scripts\set_unit_faction.sqf";
//_aispawnpos - Worldspace location
//_wpradius - Distance you want units to be able to travel
//_wpnum - Number of waypoints to place withing that distance. The higher the number, the more extensively the units will travel
//_numunits - Number of units to place. Keep in mind that squads will be placed in multiples of this number
//_unitType - Type of unit to place. 0: Random, 1: Sniper, 2: Gunner, 3: Militia, 4: Squad of the previous 3 types
//_faction - The type of faction you want this unit to adhere to. 0: RESISTANCE, 1: EAST, 2: WEST. Factions loyalties are set in scripts\set_unit_faction.sqf
//_baseSkill - Lowest possible skill that the units can posess from 1 to 10
//_potentialSkill - Highes possible skill that the units can posess from 1 to 10
//_gearSet - Which set of gear your units will use. To set the types of gear, edit the variables at the top of scripts\add_units_server.sqf
//_respawnTime - How long to wait until NPCs respawn (in seconds)
    _aispawn = [[4598.66,10197.7,0],650,12,4,0,0,1,5,0,1800] execVM "scripts\add_unit_server.sqf";
    _aispawn = [[6689.49,2623.59,0],160,8,4,0,0,1,5,1,1800] execVM "scripts\add_unit_server.sqf";//Stary Sabor
    _aispawn = [[10447.5,2246.96,0],180,3,3,0,1,1,5,0,1800] execVM "scripts\add_unit_server.sqf";//Stary Sabor
    _aispawn = [[4334.96,10496.3,0],500,20,4,0,1,1,5,1,1800] execVM "scripts\add_unit_server.sqf";//Stary Sabor 
};
 
if (isServer) then {
    hiveInUse    =    true;
    _serverMonitor =    [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
};
 
if (!isDedicated) then {[] execVM "Scripts\kh_actions.sqf";
    0 fadeSound 0;
    0 cutText [(localize "STR_AUTHENTICATING"), "BLACK FADED",60];
    _id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
    _playerMonitor =    [] execVM "\z\addons\dayz_code\system\player_monitor.sqf"; 
};
The error is coming from your add_unit_server.. link that instead..
 
Back
Top