Why does this code effect loot pick up?

Omer

Member
Ok so I have custom AI on my server and I've added this code to make them attack zombies:
_ai = _this select 0;

CIVILIAN setFriend [WEST,0];
WEST setFriend [CIVILIAN,0];

player addRating 50000;


while {alive _ai} do
{
{
_x addRating -200000;
} forEach allMissionObjects "zZombie_Base"; // attacks zombies

sleep 0.1;
};

AI init on mission.sqm:
"execVM ""attackz.sqf"";";

Now when this script is executed people on the server can't pick up loot
I have no idea why. Any ideas?
 
I was having the same issue, what's funny is our code is exactly the same except my sqf is named differently, I also have 2 more variations [opfor, guer]

been working great, except I run into the same issue users cannot pick up loot!.

I also added a few ambient combat modules to the groups of AI I have on my server [It's BEEN AWESOME!]

I'm also considering replacing my AI units with DAC which is much better for randomizing patrols. If you want I can share my DAC code with you when I finish it [could be a few days]
 
i'm wondering if it's because the sleep timer should be a bit longer? I have been fiddling with this for the past two days and that was pretty much the only variable I didn't try changing. Also nothing about the client not being able to pick up loot is mentioned in either server or client rpt. I will fool around with it a bit more tonight
and let you know if I figure out why loot won't spawn
 
Going to try the timer thingy , yea and no errors on rpt for me as well.
I thought maybe this script needs to be executed in server launch? And not on every unit?
 
you could be correct, I'm thinking of that is the case I might just use the ambient combat module with the script executed by init.sqf
 
Is it loot isn't spawning or u can pick up loot that has spawned ?

If it isnt loot spawning..

Pretty sure loot wont spawn within 30 metres of CAManBase in standard dayz-code
I am gonna assume your AI is been detected as a player model & preventing loot from spawning near it.

If so there is changes in new dayz code, look @ the variables.sqf & where they use the player model array instead of CAManBase in server cleanup fsm.
 
Is it loot isn't spawning or u can pick up loot that has spawned ?

If it isnt loot spawning..

Pretty sure loot wont spawn within 30 metres of CAManBase in standard dayz-code
I am gonna assume your AI is been detected as a player model & preventing loot from spawning near it.

If so there is changes in new dayz code, look @ the variables.sqf & where they use the player model array instead of CAManBase in server cleanup fsm.
No, loot is spawning
The problem is I can't pick it up
 
Code:
"execVM ""attackz.sqf"";";
Is this code in the init of the createunit? if so, shouldnt it look like this:
Code:
"[this] execVM ""attackz.sqf"";";

To get the AI to attack zombies I found this to work when I tried to create AI patrols:
Code:
east setFriend [Citizen1,0];


I spawned in patrolling AI soldier groups that will attack both player and zeds in a similar manner as carepackages/wrecks are spawned in. Here is the code I used:

Code:
private["_spawnAISLeader","_AISgroup","_x","_rndCount","_rnd","_position"];
 
waitUntil{!isNil "BIS_fnc_selectRandom"};
if (isDedicated) then {   
    east setFriend [west,0];
    east setFriend [civilian,0];
    east setFriend [Citizen1,0];
   
    _AISgroup = createGroup east;   
   
    _position = [getMarkerPos "center",0,7000,10,0,2000,0] call BIS_fnc_findSafePos;
 
    _rndCount = ceil((random 3) + 1); // no soldiers
    _rnd = random 1; // chance of highend loot on leader
    for "_x" from 1 to _rndCount do {
        private["_spawnAIS"];
       
        if(_x == 1) then {
            "Soldier1_DZ" createunit [[(_position select 0),(_position select 1),0], _AISgroup, "_spawnAISLeader = this;"];
            _spawnAISLeader enableAI "TARGET";
            _spawnAISLeader enableAI "AUTOTARGET";
            _spawnAISLeader enableAI "MOVE";
            _spawnAISLeader enableAI "ANIM";
            _spawnAISLeader enableAI "FSM";
            _spawnAISLeader allowDammage true;
            _spawnAISLeader setCombatMode "YELLOW";
            _spawnAISLeader setBehaviour "Aware";
            _spawnAISLeader setSkill ["aimingAccuracy",0.7];
            _spawnAISLeader setSkill ["aimingShake",0.4];
            _spawnAISLeader setSkill ["aimingSpeed",0.7];
            _spawnAISLeader setSkill ["commanding",0.8];
            _spawnAISLeader addweapon "glock17_EP1";
            _spawnAISLeader addMagazine "17Rnd_9x19_glock17";
            _spawnAISLeader addMagazine "17Rnd_9x19_glock17";
            _spawnAISLeader addMagazine "17Rnd_9x19_glock17";
            _spawnAISLeader addMagazine "ItemBandage";
            _spawnAISLeader addMagazine "ItemBandage";           
            _spawnAISLeader addweapon "Binocular";
            _spawnAISLeader addweapon "ItemCompass";
            _spawnAISLeader addweapon "ItemMap";
            _spawnAISLeader addweapon "ItemHatchet";
            _spawnAISLeader addweapon "ItemKnife";
            _spawnAISLeader addweapon "ItemMatchbox";
            if (_rnd < 0.4) then {
                _spawnAISLeader addweapon "NVGoggles";
                _spawnAISLeader addweapon "ItemGPS";
            };
            _spawnAISLeader addweapon "M16A4_ACG";
            _spawnAISLeader addMagazine "30Rnd_556x45_Stanag";
            _spawnAISLeader addMagazine "30Rnd_556x45_Stanag";
            _spawnAISLeader addMagazine "30Rnd_556x45_Stanag";
            _spawnAISLeader addMagazine "30Rnd_556x45_Stanag";
            _spawnAISLeader selectWeapon "M16A4_ACG";
            _spawnAISLeader addEventHandler ["Fired", {_this call player_fired;}];
           
            waituntil {!isnil "bis_fnc_init"};
            [_AISgroup, [(_position select 0),(_position select 1),0], 2000] call bis_fnc_taskPatrol;
        } else {
            "Soldier1_DZ" createunit [[(_position select 0),(_position select 1),0], _AISgroup, "_spawnAIS = this;"];
            _spawnAIS enableAI "TARGET";
            _spawnAIS enableAI "AUTOTARGET";
            _spawnAIS enableAI "MOVE";
            _spawnAIS enableAI "ANIM";
            _spawnAIS enableAI "FSM";
            _spawnAIS allowDammage true;
            _spawnAIS setCombatMode "YELLOW";
            _spawnAIS setBehaviour "Aware";
            _spawnAIS setSkill ["aimingAccuracy",0.5];
            _spawnAIS setSkill ["aimingShake",0.4];
            _spawnAIS setSkill ["aimingSpeed",0.7];
            _spawnAIS setSkill ["commanding",0.4];
            _spawnAIS addweapon "M16A2";
            _spawnAIS addMagazine "30Rnd_556x45_Stanag";
            _spawnAIS addMagazine "30Rnd_556x45_Stanag";
            _spawnAIS addMagazine "30Rnd_556x45_Stanag";
            _spawnAIS selectWeapon "M16A2";           
            _spawnAIS addEventHandler ["Fired", {_this call player_fired;}];
        };     
    };
   
    diag_log("DEBUG: Spawning " + str(_rndCount) + " soldiers at " + str(_position));
};
 
Hi.
Thanks for the code. I understand that we can control the number of spawned soldier groups by adding some classname at the first line, like;

Code:
spawn_soldier = {

And adding to server_monitor.sqf something like:

Code:
for "_x" from 1 to 10 do {
    _id = [] spawn spawn_soldier;
?
 
What about for AI placed on the mission.sqf? I have a specific layout for AI I would like to keep can I use a script in the init of each unit? it should similair to the spawn code am i correct?
 
you really should only place markers in the mission file and then spawn based on that. here is the code from the wasteland mission that does this for vehicle spawning:

Code:
while {_counter < 770} do
{
    _spawnpoint = floor (random 770);
    _pos = getMarkerPos format ["Spawn_%1", _spawnpoint];
    _type = 0;
    _num = floor (random 100);
    if (_num < 100) then {_type = 0;};
    if (_num < 35) then {_type = 1;};
    if (_num < 10) then {_type = 2;};
    [_pos, _type] call vehicleCreation;
    _counter = _counter + 1;
   
 
    _markerName = format["marker%1",_counter];
    _marker = createMarker [_markerName, _pos];
    _marker setMarkerType "dot";
    _marker setMarkerSize [1.25, 1.25];
    _marker setMarkerColor "ColorRed";
 
};
 
_amountOfVehicles = count currentVehicles;
diag_log format["WASTELAND SERVER - %1 Vehicles Spawned",_amountOfVehicles];

Then in the mission there are a bunch of markers called "Spawn_#"

What you should do is have a while(true) {
do soemthing

sleep 1;
}
loop that runs all your maint code, i wouldn't run it less than sleep 1, its not always a second.
 
The reason this affects loot pickup is because loot boxes and bodies are considered civilian so setting civ to enemy causes the bluefor to not be able to open reammo crates and bodies and stuff.

the fix is to throw out the dayz zombie code for how they are spawned and join them to another side that is not civ and set the friend to 0 on that, im actually playing with this right now because as been discovered in this thread you can't open some things when you have civ set to enemy, atm im modifying my server code to put zombies in a team, which means that they will share information and that means that zombies are going to be more like soldiers ... i wonder what will happen with the ASR_AI addon.... heh i might have to modify some of the server code so that zombies will stay in cities longer... heck maybe i might give them guns..
 
I would refrain from giving them guns, but would you share your server pbo if you end up using a command structure and setting them to team.

COULD IMAGINE THE HORDES WITH ASR_AI

you have truly turned a hole new stone.
 
Im not a stingy bastard, here is my mission and server pbo from my development server:
https://docs.google.com/file/d/0By9zTEuk5q1EYUFCZjVLeUJfcFk/edit

Right now i have a recruitment script working to get units to join my team, i modifyed it according to the siderelations wiki on the bi page so that any units i have join my team wont be affected by sides, they all start out as civ and then join to my side then that team gets deleted which is supposed to fix any issues with them being wrong.

Here is the issue where im at currently:

the zeds are like really stupid now, i ran up to them to see why they didn't see me and they just didn't do anything until i got really close and then one hit me, so they have some type of action going on, i belive the issue is that since i converted them from agents to units they are now under a unit ai.

its funny you mention the ASR AI addon, i have it already in my server folder here on this box so im ready to turn that on at anymoment maybe that will fix the issue im having with the new zeds, i need to get my npcs next to them to see if they will attack.

check out the server_monitor.sqf from the server pbo along with the clean fsm that it boots.

I also modifyed the player actions to give you the meat like audio was attempting in the meat from players thread.
 
Yeah going from agent to unit is going to mess up a bit of thw zombie stuff.

I have asr_ai running on my box as well, making 14 mods in total. Im really curious as to how zeds would react using it

Also thinking about running UPMON

And cheers mate! I'll be sharing what I find as well, if you wanna peep my mission files send me a message I believe there is some stuff you might be interested.
 
Back
Top