Simple AI Tutorial (no rMod or DayZ_Factions)

Gunslinger,

Grab the OP files, I can walk you through the rest - what server package are you using?
 
Bf2freak,

Are you using a packed pbo or an active mpmissions folder?

Also it may be easier to use the "upload a file" function for future files or add the code braces around it which is [ C O D E ] at the top before the file and [ / C O D E ] at the bottom of your file here on the forum, of course without the spaces between the letters.

Here is my pbo.
 

Attachments

  • dayz_private_1.oring.pbo
    111.7 KB · Views: 1
I see you do not have the scripts folder in there with the needed scripts, I tried packing one for you, though you may need to extract it and manually add scripts and repack yourself before it runs on your server.
 

Attachments

  • dayz_private_1.oring.pbo
    129.9 KB · Views: 3
Gunslinger,

You want to put the 3 files from the OP and your extracted zombie_generate.sqf in a /scripts folder underneath your MPMissions/"map" folder, if you are only using one map it may be the root of the folder. After which you edit the init.sqf in this same place and it should just work. If you are running Chernarus this init should work, I have added the files here for ease (only diff here is the change of MPKilled and MPEventhandler in add_server_unit.sqf due to issues I had on pg 26).
 

Attachments

  • init.sqf
    2.7 KB · Views: 9
  • add_unit_server.sqf
    13 KB · Views: 19
  • set_unit_faction.sqf
    298 bytes · Views: 6
  • unit_killed.sqf
    1.4 KB · Views: 8
  • zombie_generate.sqf
    3 KB · Views: 6
Hey Sycosis,
I followed your first AI tutorial you put up after myself asking 3DJoker if he had done his.
I have since been using your first method since then with dogs, auto refuel and some other mods added with no errors but decided to try the respawning version out
everything seems to work except 3 things,

1, Changed some weapons, NPC's did not have em, the weapons was M4A1 camoSD and CZ550.

2, Upon killing them, Bodys instantly vanish

3, They are not respawning

I cant find any obvious errors in the files but it does seem as it is not calling the code correctly.
Any Idea's as I am testing this ready for our new reality server.
 
Gunslinger,

You want to put the 3 files from the OP and your extracted zombie_generate.sqf in a /scripts folder underneath your MPMissions/"map" folder, if you are only using one map it may be the root of the folder. After which you edit the init.sqf in this same place and it should just work. If you are running Chernarus this init should work, I have added the files here for ease (only diff here is the change of MPKilled and MPEventhandler in add_server_unit.sqf due to issues I had on pg 26).

Many thanks, will try this as soon as I can :)
 
Stealth,

Can you provide your mission pbo, or the files themselves so I can test this out.

Right away I can tell you to deal with issue #2 open your add_unit_server.sqf and replace the word MPKilled with Killed and the word addMPEventhandler with addEventhandler < example of this in my file attached in the post before yours

Also are you sure they are not respawning? There is an issue with the initial files here where if you have more than one _aispawn line in your init.sqf all the AI respawn at the last lines position. This was also solved by a change to the add_unit_server.sqf by changing the _aispawnpos line in the eventhandler line to (getPosATL (_this Select 0)) < also shown in my file above.

On the weapons thing I would have to see your loadouts.

The known issues I have with this that I have not been able to solve.

1. The gearset/wpradius/wpnum/baseskill/potentialskill/respawntime of any killed AI changes to the the values of the last instance of aispawn in the init.sqf (same as position issue - but have not found fix for this yet)​
I have found the solution for the faction however changing the globalfaction part of the line in the eventhandler to (side (group (_this Select 0))).

Let me know if anyone needs more clarification on this.
 
@Morox,

Thanks for the reply and sorry about my slow reaction as I have been busy with family over here,
Anyway back to the task at hand, lol.
I got the AI working with your instructions for the MPeventhandler changes however I am trying to change the dmr and heavy machine guns for more basic weapons however the AI spawn with the ammo but not the weapon itself.

Still cannot figure this out.

EDIT: 31/03/2013, 10:20pm AEST
It's All Good I managed To Get It All Working Fine, Thanks Anyway Guys.
 
@Morox,

Thanks for the reply and sorry about my slow reaction as I have been busy with family over here,
Anyway back to the task at hand, lol.
I got the AI working with your instructions for the MPeventhandler changes however I am trying to change the dmr and heavy machine guns for more basic weapons however the AI spawn with the ammo but not the weapon itself.

Still cannot figure this out.
So they just run around with nothing in hands / on their backs? May have a fix for this
 
Hello
My npc's don't spawn :(
i don't no whats wrong
i think it's the init.sqf
please help me



init.sqf

/*
INITILIZATION
*/
startLoadingScreen ["","RscDisplayLoadCustom"];
cutText ["","BLACK OUT"];
enableSaving [false, false];

//REALLY IMPORTANT VALUES
dayZ_instance = 1; //The instance
dayzHiveRequest = [];
initialized = false;
dayz_previousID = 0;

//disable greeting menu
player setVariable ["BIS_noCoreConversations", true];
//disable radio messages to be heard and shown in the left lower corner of the screen
enableRadio false;

//Load in compiled functions
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\variables.sqf"; //Initilize the Variables (IMPORTANT: Must happen very early)
progressLoadingScreen 0.1;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\publicEH.sqf"; //Initilize the publicVariable event handlers
progressLoadingScreen 0.2;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\setup_functions_med.sqf"; //Functions used by CLIENT for medical
progressLoadingScreen 0.4;
call compile preprocessFileLineNumbers "\z\addons\dayz_code\init\compiles.sqf"; //Compile regular functions
progressLoadingScreen 1.0;

"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 {
_serverMonitor = [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
};

if (!isDedicated) then {
//Conduct map operations
0 fadeSound 0;
waitUntil {!isNil "dayz_loadScreenMsg"};
dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
[] execVM "fixes\kh_actions.sqf";
zombie_generate = compile preprocessFileLineNumbers "scripts\zombie_generate.sqf";

//Run the player monitor
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
};
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 = [[4829.9868,2450.1104,0],100,5,4,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Ballota airstrip West
_aispawn = [[12954.624,9783.1533,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Berezino East
_aispawn = [[12043.963,9091.3477,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Berezino 2 east
_aispawn = [[10276.416,12049.664,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Black Muntain East
_aispawn = [[3320.1643,3938.3496,0],100,5,4,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Bor West
_aispawn = [[6743.8853,2581.1865,0],100,5,4,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Cherno West
_aispawn = [6891.9189,11438.73,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Devils Castle East
_aispawn = [[7788.2856,12613.048,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Dons Camp East
_aispawn = [[3442.2849,4955.7129,0],100,5,4,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Drozhino West
_aispawn = [[10445.011,9868.9912,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Dubrovka East
_aispawn = [[10480.69,2217.8027,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Elektro East
_aispawn = [[13060.078,7094.0596,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // factrory East
_aispawn = [[9659.084,8795.334,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Gorka East
_aispawn = [[5979.6953,10343.341,0],100,5,4,4,0,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Grishno Resistance
_aispawn = [[8517.8682,6676.3276,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Guglovo East
_aispawn = [[8614.4316,11868.967,0],100,5,4,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Gvozdno East
_aispawn = [[5318.8369,8602.6328,0],100,5,4,4,0,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Kabanino Res
_aispawn = [[12290.833,10904.328,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Khelm east
_aispawn = [[12127.406,3496.2185,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // kamyoshovo east
_aispawn = [[3654.0908,2475.9468,0],100,5,2,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // komarova west
_aispawn = [[4483.6777,4616.1675,0],100,5,2,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // kotzlovka west
_aispawn = [[11212.624,12256.609,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Krastonav east
_aispawn = [[2780.3135,10018.82,0],100,5,2,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Lopatino west
_aispawn = [[7544.5845,5148.7822,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // moglievka east
_aispawn = [[11275.323,5495.4053,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Msta east
_aispawn = [[2019.2487,7327.7178,0],100,5,2,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // myshkino west
_aispawn = [[5846.4434,4706.708,0],100,5,2,4,0,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // nadezdhino res
_aispawn = [[12073.906,12724.305,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // NE airfield east
_aispawn = [[13002.393,8285.8574,0],100,5,2,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Nizhnoye east
_aispawn = [[7074.4854,7683.4883,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // novy Sobor east
_aispawn = [[4480.0781,10375.544,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // NW airfield west
_aispawn = [[12146.174,7266.5801,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // orlovets east
_aispawn = [[1693.9392,3845.0657,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Pavlovo west
_aispawn = [[5014.1143,12493.039,0],100,5,1,4,0,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Petrovka res
_aispawn = [[4473.5957,6411.3198,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // pogorevka west
_aispawn = [[10753.393,8132.6606,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // polana east
_aispawn = [[7976.5557,3299.5386,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Prigorodki east
_aispawn = [[4915.0903,5605.6401,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Pulkovo west
_aispawn = [[9156.2549,3897.7598,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Pusta east
_aispawn = [[3072.9629,7945.4404,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // pustoshka west
_aispawn = [[4808.0024,6805.0518,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // rogovo west
_aispawn = [[9654.5244,6555.2583,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // shakhovka east
_aispawn = [[13454.279,6233.647,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Solnichy east
_aispawn = [[2528.7561,6354.9839,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Soosnovka west
_aispawn = [[10140.659,5434.4302,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // staroye east
_aispawn = [[4808.0024,6805.0518,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Stary sobor west
_aispawn = [[12803.296,4450.7466,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Tulga east
_aispawn = [[3815.0635,8865.0938,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Vybor west
_aispawn = [[6590.3159,6029.1128,0],100,5,1,4,1,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // vyshnoye east
_aispawn = [[2758.7144,5304.3457,0],100,5,1,4,2,7,10,0,900] execVM "scripts\add_unit_server.sqf"; // Zellengorsk west

_serverMonitor = [] execVM "\z\addons\dayz_code\system\server_monitor.sqf";
};
 
Morox, thanks to you I've signed up for the forum, woah I'm amazed you took the effort to reply and help every single one of us here.

Perhaps it's my turn to trouble you, I am running reality dayz ( chernarus ) what would be the direction and steps I should be doing ? Can I follow the directions you have provided for GunSlinger though I recall he's on a different server setup.

For reality pbo, it's located in @reality_1.chernarus\dayz_server.pbo. I will upload and perhaps you can take a look for me ?
 

Attachments

  • dayz_server.pbo
    90.6 KB · Views: 2
Reiben,

For this AI addon the file you need to modify is your dayz_missions.pbo and not the server pbo, all the additions are added to the missions so that clients can download them when they connect.
 
Reiben,

For this AI addon the file you need to modify is your dayz_missions.pbo and not the server pbo, all the additions are added to the missions so that clients can download them when they connect.

I assumed that will be the file " MPMissions\dayz_1.chernarus.pbo " yeah ?

Where should I place them or edit them right in original location ?

PS: Thank you for getting back so soon.
 

Attachments

  • dayz_1.chernarus.pbo
    41.6 KB · Views: 1
Morox,

After some messing around and a lot of forum serching I have finally sorted out the respawn from last line bug but I do have a funny Question for you,

When the AI did respawn they respawned as faction 0 but they where killed as faction 1, (or they respawned as civilian but where killed as BAF soldiers), is this normal?

EDIT:

All AI no matter what faction they where at beginning respawn as global faction 0,
Freindlies, how do we change this.
 
Just follwed everything, there are no AI's but I think they spawned as zombies as some zombies have a red dot, how to fix?
 
Stealth,

The faction thing I have solved, if you look at my original answer to you it talks about this, look at the addEventhandler line and change the part that says _globalfaction or globalfaction to (side (group (_this Select 0))) this will ensure they remain the same faction. As I mentioned in that post though the gearset is not persistant - it has the same issue the position and global faction has before the fix - it takes the value of the last _aispawn line, I am working on fixes for this but have not had as much time to dedicate to it.

Tiger,

Can you post your missions pbo or your init.sqf so I can take a look

Reiben,

Yes that is the correct file, you need to unpack it edit the files and then repack it - I will take a look when I get back to my server and can run tests.
 
Back
Top