Spawn too close to players

Discussion in 'Support & Release' started by Chester Cheetoz, Dec 26, 2014.

  1. Chester Cheetoz

    Chester Cheetoz Member

    Joined:
    Aug 15, 2013
    Messages:
    31
    Likes Received:
    0
    Alright, so my players keep complaining about AI spawning either nearly on top of them or too close to them. I've played several hours, even after lowering the spawn chance and have yet to come across this problem. But they say it's happening. Is there a way to make it so they don't spawn so close to the players? I've gone through the settings and the only thing I've found is the feature so they dont spawn within 600m of a fresh spawn.
     
  2. Buttface

    Buttface OpenDayZ Rockstar!

    Joined:
    Dec 6, 2012
    Messages:
    599
    Likes Received:
    141
    There is a 10 second window of non-hostility if AI spawns within 100m of a player. If players can't respond within 10 seconds, the issue is not with DZAI.
     
    wriley likes this.
  3. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,443
    Likes Received:
    337
    The issue with the "10 second rule" is if the AI dont spawn in front of you then you dont notice them. How about when the AI are spawned in, they yell "ALLAH AKBAR!" .. so if players are near, they will hear it and be instantly alerted about an impending ambush, and if they aren't near AI then it didn't matter. I haven't fooled with the ai sounds but I am sure you can cause a certain AI to say something which is only heard in his vicinity.
     
    Geekin likes this.
  4. Brave Sir Robin

    Brave Sir Robin Valued Member!

    Joined:
    Jun 7, 2014
    Messages:
    270
    Likes Received:
    66
    The is the section of code that Buttface is reffering too. Its in fn_spawnGroup.sqf
    Code:
    if (DZAI_debugLevel > 1) then {diag_log format ["DZAI Extended Debug: Found spawn position at %3 meters away at position %1 after %2 retries.",_pos,_attempts,(_pos distance _spawnPos)]};
    
    _unitGroup = if (isNull (_this select 1)) then {[] call DZAI_createGroup} else {_this select 1};
    if (({isPlayer _x} count (_pos nearEntities ["CAManBase",100])) == 0) then {
        _unitGroup setCombatMode "RED";   
    } else {
        _unitGroup setCombatMode "BLUE";
        _nul = _unitGroup spawn {
            uiSleep 10;
            _this setCombatMode "RED";    //Activate AI group hostility after 5 seconds
        };
    };
    
    I think if you want to increase their "blue" time then change the uiSleep to what ever you want.
    For me I think the issue is that the
    Code:
    if (({isPlayer _x} count (_pos nearEntities ["CAManBase",100])) == 0) then {
    
    I think there should be a variable that allows you to configure a minimum and maximum distance. Currently it looks for spawn point that are within 100. If you are running through a town then the buildings are the spawn markers so there is a fair chance that they spawn infront of you.
    With the above code when this happens it looks like they are already red. It maybe an option to set a delay from when they spawn in and then go "red" by adding a uiSleep 15.
     
  5. Brave Sir Robin

    Brave Sir Robin Valued Member!

    Joined:
    Jun 7, 2014
    Messages:
    270
    Likes Received:
    66
    After further look it appears to me that the issue resides in
    Code:
    while {((count _pos) < 1) && {(_attempts < 3)}} do {
        _pos = _spawnPos findEmptyPosition [0.5,_baseDist,"Misc_cargo_cont_small_EP1"];
        if ((count _pos) > 1) then {
            _pos = _pos isFlatEmpty [0,0,0.75,5,0,false,objNull];
        }; 
        if ((count _pos) < 1) then {
            _baseDist = (_baseDist + 25);    _attempts = (_attempts + 1);
            if (_attempts == 3) then {
                _pos = [_trigger,random (_trigger getVariable ["patrolDist",125]),random(360),0] call SHK_pos;
                _attempts = (_attempts + 1);
            };
        };
    };
    
    The minimum distance for findEmptyPosition is 0.5 mtrs so thats right ontop of you. Perhaps if this was increased to say 10-15mtrs and then _baseDist then get increased by the same amount. This then sets the positions for the canmanbase etc..
     
  6. Buttface

    Buttface OpenDayZ Rockstar!

    Joined:
    Dec 6, 2012
    Messages:
    599
    Likes Received:
    141
    The minimum distance should be fine as it is. If you increase the value, a position would be searched at longer distance even if the original position was empty already, which increases the likelihood that a bad (ie: non-empty) position is found. The quoted code checks if a selected area has enough space to fit a "Misc_cargo_cont_small_EP1" which is a pretty large object to begin with.

    The actual anti-player check is made here using a nearEntities check. The range check is 75 meters for canceling spawn for nearby players. If you increase it to 100m or higher then you should also further increase the distance in fn_spawnGroup.sqf that places the 10 second non-hostility timer.
     
  7. Brave Sir Robin

    Brave Sir Robin Valued Member!

    Joined:
    Jun 7, 2014
    Messages:
    270
    Likes Received:
    66
    Hmm ok then cool I understand the construct now.
    Is it possible then that the ai are queuing. While the nearEntities appears to work I have had first hand experience of sitting next to a guy while helping with some admin things in game and the Ai just spawned out of the building in front of us. This in a small location with 3 buildings. We had moved to the location about 30 seconds before.
    granted I have now changed a few things and i will let you know how we go.
    Cheers for the response.
     
  8. BetterDeadThanZed

    BetterDeadThanZed Well-Known Member

    Joined:
    Mar 1, 2013
    Messages:
    537
    Likes Received:
    22
    What exactly would we change in fn_spawnGroup.sqf to go along with a change from 75 meters to 150 meters? Also, I'm not sure that "non hostility timer" works because I've had several players tell me the AI spawns in front of them and shoots them, apparently in a lot less than 10 seconds.
     
    Last edited: Mar 7, 2015
  9. BetterDeadThanZed

    BetterDeadThanZed Well-Known Member

    Joined:
    Mar 1, 2013
    Messages:
    537
    Likes Received:
    22
    Can I get a bump on this? It's really bad having AI spawn directly in front of players. I'd really like to see a way to prevent static AI from spawning if they haven't spawned by the time a player gets within X meters of that spawn point. Not sure why the AI wouldn't spawn earlier as a player approaches a static spawn point.
     
  10. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,443
    Likes Received:
    337
    you need to post your files because i dont think anyone else has that issue so it must be unique to your server
     
  11. BetterDeadThanZed

    BetterDeadThanZed Well-Known Member

    Joined:
    Mar 1, 2013
    Messages:
    537
    Likes Received:
    22
    I am using the default files. I think other admins aren't reporting it here or their player base isn't reporting it to them.
     
  12. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,443
    Likes Received:
    337
    DZAI , what version? Are you sure its not WAI though?
    I will do a test tonight,
     
  13. BetterDeadThanZed

    BetterDeadThanZed Well-Known Member

    Joined:
    Mar 1, 2013
    Messages:
    537
    Likes Received:
    22
    I think I know the difference between WAI and DZMS. It is the latest version of DZMS.
     
  14. ShootingBlanks

    ShootingBlanks OpenDayZ Guru!

    Joined:
    Mar 31, 2013
    Messages:
    2,443
    Likes Received:
    337
    well all the ai look the same to me once spawned in ;)
     
  15. BetterDeadThanZed

    BetterDeadThanZed Well-Known Member

    Joined:
    Mar 1, 2013
    Messages:
    537
    Likes Received:
    22
    I don't use WAI, so Yeah. They are DZAI.
     

Share This Page