Simple AI Tutorial (no rMod or DayZ_Factions)

I made this as simple as possible, with central places for configuration so you aren't jumping all over. Added fairly dynamic gear addition so you aren't adding lines for every item. Made the skills random so you have a mix of good and bad troops. Did a bit of organization so that it's easier to understand. Updated the original post.
 
Hi!

I just saw that you change the script, it seems easier if I'm not mistaken?

Compared to my previous message, I no longer need to create twice the same file for both factions. All but simply change the 0 or 1 in the line parameters added to the file init.sqf?


Otherwise, I came to ask you how to change the skill of the NPC. Some players have had the opportunity of meeting with hostile NPC and friends. In both cases, they found it easy to kill them.
So I looked in the file add_unit_server.sqf

And I saw this part here:
Code:
                //set skills
                _aiunit setSkill ["aimingAccuracy",(floor(random 4)+6)/10];
                _aiunit setSkill ["aimingShake",(floor(random 4)+6)/10];
                _aiunit setSkill ["aimingSpeed",(floor(random 4)+6)/10];
                _aiunit setSkill ["endurance",(floor(random 4)+6)/10];
                _aiunit setSkill ["spotDistance",(floor(random 4)+6)/10];
                _aiunit setSkill ["spotTime",(floor(random 4)+6)/10];
                _aiunit setSkill ["courage",(floor(random 4)+6)/10];
                _aiunit setSkill ["reloadSpeed",(floor(random 4)+6)/10];
                _aiunit setSkill ["commanding",(floor(random 4)+6)/10];
                _aiunit setSkill ["general",(floor(random 4)+6)/10];
I guess this is where I have to make these changes. The problem is that I do not know what number change ..

Edit:
I saw here the same configuration. But yours is different.
_aiunit setSkill ["aimingAccuracy",(floor(random 4)+6)/10];
_aiunit setSkill ["aimingAccuracy",1];
 
Hi!

I just saw that you change the script, it seems easier if I'm not mistaken?

Compared to my previous message, I no longer need to create twice the same file for both factions. All but simply change the 0 or 1 in the line parameters added to the file init.sqf?


Otherwise, I came to ask you how to change the skill of the NPC. Some players have had the opportunity of meeting with hostile NPC and friends. In both cases, they found it easy to kill them.
So I looked in the file add_unit_server.sqf

And I saw this part here:
Code:
                //set skills
                _aiunit setSkill ["aimingAccuracy",(floor(random 4)+6)/10];
                _aiunit setSkill ["aimingShake",(floor(random 4)+6)/10];
                _aiunit setSkill ["aimingSpeed",(floor(random 4)+6)/10];
                _aiunit setSkill ["endurance",(floor(random 4)+6)/10];
                _aiunit setSkill ["spotDistance",(floor(random 4)+6)/10];
                _aiunit setSkill ["spotTime",(floor(random 4)+6)/10];
                _aiunit setSkill ["courage",(floor(random 4)+6)/10];
                _aiunit setSkill ["reloadSpeed",(floor(random 4)+6)/10];
                _aiunit setSkill ["commanding",(floor(random 4)+6)/10];
                _aiunit setSkill ["general",(floor(random 4)+6)/10];
I guess this is where I have to make these changes. The problem is that I do not know what number change ..

Edit:
I saw here the same configuration. But yours is different.
_aiunit setSkill ["aimingAccuracy",(floor(random 4)+6)/10];
_aiunit setSkill ["aimingAccuracy",1];

The first part is correct. 0/1 is what you do now to make the 2 different factions.

The second part there is 2 things you can. 1) in your createUnit areas in the add_unit_server.sqf, when you initialize them you give them a value of .6, up that to 1, like this:
_resistanceRandomSkin createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"Private"];
and 2) in the code you copied with the setSkill, you are correct that you would change those from randoms to higher values like this:
_aiunit setSkill ["spotDistance",1];
i'm currently working on updating the script to fix a few more things, but in the meantime these will work.
 
hey, me again! with the waypoints and the radius, does each member of the squad use random waypoints continuously? i only ask as i set a 500m radius with 100 waypoints, spawn in calamar in lingor island. by the time i make it there, they are all camped in one spot near the airfield, not moving. they only move slightly when i get within range to spawn zombies then they move about, but no more than 20/30m around.
i was hoping if i added say 500m radius i could get to the city and they would be spread out, but as it stands i can find 99% of them in one area.
is there some other way i should be adding them, like smaller radius but more lines to add different squads?
 
also, with the new files, will the old call line in init.sqf do the same?
again i only ask as i had a set of friendlies (faction 1) set to spawn in an area, i was there when they spawned and they all instantly turned to me and became a firing squad on me!! they had the civilian skins though so assumed it had picked them up as resistance
 
also, with the new files, will the old call line in init.sqf do the same?
again i only ask as i had a set of friendlies (faction 1) set to spawn in an area, i was there when they spawned and they all instantly turned to me and became a firing squad on me!! they had the civilian skins though so assumed it had picked them up as resistance
lmao.. yeah.. depending on which version of the lines you have they should i work.. ive been systematically adding more options on the init lines, so you may have to add more..

change the set_unit_factions.sqf setFriend to make them friendly again.. anything above .6 and they should stop attacking..
 
ok i'll change that.....after i get my revenge! i went back in a chopper and they shot it down, so this is personal now!

any idea on the patrol radius, each time they all spawn i can guarantee where they will end up, and they then stay in that spot
 
ok i'll change that.....after i get my revenge! i went back in a chopper and they shot it down, so this is personal now!

any idea on the patrol radius, each time they all spawn i can guarantee where they will end up, and they then stay in that spot
it depends on what you set the 2 settings for in your create line..

there is 1 for patrol radius, and 1 for waypoints.. the patrol radius is used only by the waypoints.. the higher the patrol radius, the farther away it will put your waypoints, and the more waypoints you put, the more thoroughly they will cover the patrol radius.. if that makes sense.. if you have a patrol radius of 100 and a waypoint of 1, they are just gonna stay in the same spot.. if you have a patrol radius of 50 and a waypoint of 5, they are going to move between 5 different locations that are between 0 and 50 meters away.. they always stand around for a bit, because they sit at a waypoint for a certain duration before moving on to the next waypoint, but adding more waypoints and increasing the duration will make them move around more..
 
can you let the AI respawn like the zombies
when you kill zombies they will respawn after 2 a 5 min
can you do this also with AI ?
 
it depends on what you set the 2 settings for in your create line..

there is 1 for patrol radius, and 1 for waypoints.. the patrol radius is used only by the waypoints.. the higher the patrol radius, the farther away it will put your waypoints, and the more waypoints you put, the more thoroughly they will cover the patrol radius.. if that makes sense.. if you have a patrol radius of 100 and a waypoint of 1, they are just gonna stay in the same spot.. if you have a patrol radius of 50 and a waypoint of 5, they are going to move between 5 different locations that are between 0 and 50 meters away.. they always stand around for a bit, because they sit at a waypoint for a certain duration before moving on to the next waypoint, but adding more waypoints and increasing the duration will make them move around more..

i see what you mean, but when i added some to certain cities i had something like 500 radius and 100 waypoints, and every single time they ended up camped directly outside the airfield, same spot. i could watch from far away with sniper rifle and see they didnt move on from there, it's as though it was their end point. its as though they spawned and just headed due east for all 100 waypoints, reached the end and stopped.

also if you do create the respawn script, could it be an optional variable. it's still quite nice to know if you've killed 15 guys you aren't going to be shot in the back by them respawning two mins later. maybe a variable for each add line to say canRespawn or something? :)
 
i see what you mean, but when i added some to certain cities i had something like 500 radius and 100 waypoints, and every single time they ended up camped directly outside the airfield, same spot. i could watch from far away with sniper rifle and see they didnt move on from there, it's as though it was their end point. its as though they spawned and just headed due east for all 100 waypoints, reached the end and stopped.

also if you do create the respawn script, could it be an optional variable. it's still quite nice to know if you've killed 15 guys you aren't going to be shot in the back by them respawning two mins later. maybe a variable for each add line to say canRespawn or something? :)

I've heard other people say that as well. Mine all continue moving around.

The respawn will be optional and with custom timers.
 
Fantastic work Sycosis and of course Axeman, ButtFace and 3djoker :)

Time to play about with the options, I'd like to have fixed points so they don't patrol, eg add a sniper to a deerstand who shoots anyone who walks/drives past - Would i set the patrol radius to zero or would i need to edit the "MOVE" command ?

How hard would it be to add a new group ? eg add a 4th group so i have 1:
Sniper, 2: Gunner, 3: Militiaman,4: New group
 
Time to play about with the options, I'd like to have fixed points so they don't patrol, eg add a sniper to a deerstand who shoots anyone who walks/drives past - Would i set the patrol radius to zero or would i need to edit the "MOVE" command ?

not sure if this is correct, but from what sycosis said to me about waypoints... "if you have a patrol radius of 100 and a waypoint of 1, they are just gonna stay in the same spot.." so i'd assume add 1 waypoint, and he shouldn't move. worth a try i suppose :)
 
would anything in the 1.7.6 update have killed this? i just created a fresh server with 1.7.6 files, lingorskaro, and when i set the spawn line nothing happens. i've even tried mistyping the scripts folder (which caused an error before) and now it does nothing :/

--EDIT
my mistake, i can't even copy/paste correctly! i'd missed the start of the zombie_generate line off when copying! ugh!
 
Thanks d0pefish :) I'll try that
I need to sort out the set skill levels first, I'd like them a bit more hardcore or maybe have them see and engage from longer ranges but not be a crack shot, so they will shoot at people but it might take them a few shots before they hit the target.

At the minute they get killed quite easily and don't respawn until a server restart.
 
on the first page you say 0 is resistance and 1 is east for faction in the init.sqf.
so i add a group of resistance which to me are the friendly guys (judging by previous loadouts), and set this in add_unit
RESISTANCE setFriend [WEST,.8];
yet on spawn, i get shot. if i do
EAST setFriend [WEST,.8]; and spawn east guys who get the SVD and MK48 loadout, they leave me alone.
 
Thanks d0pefish :) I'll try that
I need to sort out the set skill levels first, I'd like them a bit more hardcore or maybe have them see and engage from longer ranges but not be a crack shot, so they will shoot at people but it might take them a few shots before they hit the target.

At the minute they get killed quite easily and don't respawn until a server restart.

i think sycosis said he was going to look at a respawn function too.

will placing ai in deerstands work? doesn't it place them at ground level? never actually tried it, but would be good
 
Back
Top