Simple AI Tutorial (no rMod or DayZ_Factions)

hmm i now have anew problem that has arisen since putting the AI in my vehicles are no longer showing up in game my side it says that they are in and should be in there positions but map side there nowhere to be found and this was last thing that i did
 
Hey guys, my code got corrupted somewhere, but I will give you quick instructions on how to add the respawn.

After your createUnit commads you're going to add "addMPEventHandler["MPKilled",[this] execVM 'YOURFILENAME.SQF'];"
In that file, you're going to put a sleeptimer and then another createUnit. Where this gets tricks is if you want it to be the same type of spawn, then you're going to have to pass the variables into the event handler. so [this] will become something more like [this,_pos,_radius,_waypoints,_number,_faction] or whatever the relevant variables are depending on your version of the script. If you need more detailed help let me know and I will make it more understandable. My server has expired, so i'm not coding this up anymore, and i'm playing on Axemans server ;D


Code:
_aiunit addMPEventHandler ["MPkilled", {Null = [_this,_aispawnpos,_wpradius,_wpnum,_numunits,_unittype,_faction] execVM "scripts\unit_killed.sqf";}];
This will be in your unit_killed
Code:
private["_handler","_aispawnpos","_wpradius","_wpnum","_numunits","_unittype","_faction"];
_position = this select 1;
_radius = this select 2;
_waypoints = this select 3;
_unitNum = this select 4;
_unitType = this select 5;
_faction = this select 6;
 
sleep 1800; //30 minutes
_aispawn = [_position,_waypoints,_unitNum,_unitType,_faction] execVM "scripts\add_unit_server.sqf";

This should work, but with 1 exception. If your original unitType is 0 or 4, then you have to change your add_unit_server, and above the eventHandler change _unitType to either _rndLoadout for the randoms, or y for the squads, so that it will choose the appropriate troop. Let me know if you need even more details.
 
AI will not shoot at zeds, as they are classified as agents. the AI do not see them as threats.
for this to work you need to change the zeds to units instead of agents, we do this using dayz_factions.
 
AI will not shoot at zeds, as they are classified as agents. the AI do not see them as threats.
for this to work you need to change the zeds to units instead of agents, we do this using dayz_factions.
You just have to drop their rating, which we do. The problem we have is making the zeds attack the AI, which is a little trickier. According to the API's you can turn zeds from Civilian into another faction, but I never got around to that before I quit working on this project.
 
If you need more detailed help let me know and I will make it more understandable.
If you wouldn't mind adding some more details please :) My guys spawn in and perform great and all that's missing is respawning them.

If you can give an example of the code i'm sure we'll be able to work the rest out :)
 
AI will not shoot at zeds, as they are classified as agents. the AI do not see them as threats.
for this to work you need to change the zeds to units instead of agents, we do this using dayz_factions.

If you add AI's as they describe in this thread they will shoot at zombies without needing to change anything.

A question about this whole getting zombies to agro when AI shoot. How do you get this working? Cant get it to work..
http://opendayz.net/index.php?threa...-rmod-or-dayz_factions.8106/page-3#post-22211
 
If you add AI's as they describe in this thread they will shoot at zombies without needing to change anything.

A question about this whole getting zombies to agro when AI shoot. How do you get this working? Cant get it to work..
http://opendayz.net/index.php?threa...-rmod-or-dayz_factions.8106/page-3#post-22211


yeah the player rating trick works. but its a hackjob of a work around, also civilian isn't the best side to put them on as they are neutral to all factions by default. having them changed to indep works better, then simply just use opfor or blufor ai
 
yeah the player rating trick works. but its a hackjob of a work around, also civilian isn't the best side to put them on as they are neutral to all factions by default. having them changed to indep works better, then simply just use opfor or blufor ai
They're naturally civilian, I was going to make them east for my purposes since east hates everyone anyway, and on the island that I store east they don't have zombies, but like I said, I stopped coding this because my server expired and i'm just waiting for standalone.
 
they can't have a side as by default they are agents.

lol yeah sorry mate. thought you were replying me the last time. my bad
 
Still not getting all this, sorry to be a pain Sycosis :)

Correct me if i'm wrong here :
1 - In my init.sqf after adding the _aispawn i add the _aiunit addMPEventHandler line ? Example
Code:
_aispawn = [[7544.88,7917.35,0],400,15,4,1,1] execVM "scripts\add_unit_server.sqf"; _aiunit addMPEventHandler ["MPkilled", {Null = [_this,_aispawnpos,_wpradius,_wpnum,_numunits,_unittype,_faction] execVM "scripts\unit_killed.sqf";}];
Do i add this after every _aispawn line ?

2 - I then create a new file called unit_killed.sqf and inside that add :
Code:
private["_handler","_aispawnpos","_wpradius","_wpnum","_numunits","_unittype","_faction"];
_position = this select 1;
_radius = this select 2;
_waypoints = this select 3;
_unitNum = this select 4;
_unitType = this select 5;
_faction = this select 6;
 
sleep 1800; //30 minutes
_aispawn = [[7544.88,7917.35,0],400,15,4,1,1] execVM "scripts\add_unit_server.sqf";
Do i have to copy all the _aispawn lines ? so technically we could choose which units respawn and which units will stay dead

The bit i don't get is when it comes to respawning the randoms and squads, I have a few squads and this you're referring to the entry in the add_unit_server.sqf file ? On line 7 i have this :
Code:
_unitType = _this select 4;
So would i change the 4 to y ? I'm not understanding that part.

Thank you in advance :)
 
i know you're not updating this any more, so fair enough, wont trouble you too much more. i was just curious if with the updated code its still possible to add a third set of spawns?
you have resistance which ive set as basic friendly AI. west which i set as well armed bandit AI, but i also want a set of lowly bandit AI...where i can set low level loadout and put the accuracy and such way down. pop them near spawn cities just to liven it up, but less chance of being wasted in seconds.
in set_unit_faction could i add another as something like OppFor (do faction names have to be real or is it just reference?) with the createcenter and also the setfriend commands
then in the add_unit sqf would i just add another section same as the section for west/resistance.
would that work or is there more to it?

and just lastly, thanks for your work on this :)
 
No. You ad
Still not getting all this, sorry to be a pain Sycosis :)

Correct me if i'm wrong here :
1 - In my init.sqf after adding the _aispawn i add the _aiunit addMPEventHandler line ? Example
Code:
_aispawn = [[7544.88,7917.35,0],400,15,4,1,1] execVM "scripts\add_unit_server.sqf"; _aiunit addMPEventHandler ["MPkilled", {Null = [_this,_aispawnpos,_wpradius,_wpnum,_numunits,_unittype,_faction] execVM "scripts\unit_killed.sqf";}];
Do i add this after every _aispawn line ?

2 - I then create a new file called unit_killed.sqf and inside that add :
Code:
private["_handler","_aispawnpos","_wpradius","_wpnum","_numunits","_unittype","_faction"];
_position = this select 1;
_radius = this select 2;
_waypoints = this select 3;
_unitNum = this select 4;
_unitType = this select 5;
_faction = this select 6;
 
sleep 1800; //30 minutes
_aispawn = [[7544.88,7917.35,0],400,15,4,1,1] execVM "scripts\add_unit_server.sqf";
Do i have to copy all the _aispawn lines ? so technically we could choose which units respawn and which units will stay dead

The bit i don't get is when it comes to respawning the randoms and squads, I have a few squads and this you're referring to the entry in the add_unit_server.sqf file ? On line 7 i have this :
Code:
_unitType = _this select 4;
So would i change the 4 to y ? I'm not understanding that part.

Thank you in advance :)
No, you add that first line below every createUnit line in your add_unit_server.sqf. You place the file that you created in your scripts folder just the way it is. You don't put the actual numbers in there, you put the variables I had in there. As for replacing the 4 to y, no. In the add_unit_server.sqf you need to type "_unitType = y" above the addMPEventHandler in the "Squad" logic, and "_unitType = _rndLoadout" in the "Random" logic, which are cases 0 and 4 inside of the (_unitType) switch in both case 0 and 1 for the (_faction) cases. Don't worry about asking me question. I like helping.
 
Back
Top