Howdy all zed and troll hunters,
I wrote this addon a while back. This addon modifies Zombie_FindTargetAgent.SQF by adding two chunks of code (one small, one larger) that makes zed respond to the of a vehicle's engine by either walking over to the area of the sound or directly trying to attack the vehicle if it's occupied. The idea is to add a little bit of "realism". After all, zed hear gunshots; why wouldn't they hear an airplane or a heli?
When I first wrote this, I did real measurements of distances based on a bunch of different vehicles idling. I would run out and check to see how far away I could hear a particular vehicle. In this addon, most if not all of the regular DayZ vehicles are specifically configured. Aside from that, if there's a vehicle that's not DayZ-standard (such as those re-enabled from rMod), they fall within the 'Generic' category. The distance values for the five generic categories are configurable. In this mod, zed will only walk towards vehicle engine noise if they do not currently have any targets they're chasing after.
On to the mod.
Step 1) Modify Init.SQF
Here we modify Init.SQF to add a chunk of code that gives configurable options for this mod. Append the following chunk to the very bottom of the file:
A detailed explanation of each configuration variable:
dayz_ZedVehicleSoundRealism_Enable -- This enables or disables this addon. More specifically, it either allows or disallows each zed, while running its own looped function looking for targets, from hearing any vehicles. It provides for a quick way to shut the mod off without having to gut it from script files.
dayz_ZedVehicleSoundRealism_DisAudialMaximumRange -- This is the maximum range in meters that a zed could possibly hear a vehicle. On my server, I have it set to 365. However, it may behoove the server owner to keep in mind that this may have an affect on client PC's FPS. I suspect there may be a performance drop if this is set too high. Also, consider the spawn radius of zed on a vanilla DayZ server doesn't extend too far out past 200m.
dayz_ZedVehicleSoundRealism_VeryHeavyRainCorrection -- Corrections factor for very heavy rainfall. Default is 0.40 which represents a correction of 40% of the calculated distance.
dayz_ZedVehicleSoundRealism_HeavyRainCorrection -- Corrections factor for heavy rain. Default 0.55.
dayz_ZedVehicleSoundRealism_ModerateRainCorrection -- Corrections factor for moderate rainfall. Default is 0.70.
dayz_ZedVehicleSoundRealism_LightRainCorrection -- Corrections factor for light rain/sprinkling. Default is 0.85.
dayz_ZedVehicleSoundRealism_DisAudial_GenericPlane -- The distance, in meters, a zed will hear a non-specific, generic plane.
dayz_ZedVehicleSoundRealism_DisAudial_GenericHeli -- The distance a zed will hear an undefined heli.
dayz_ZedVehicleSoundRealism_DisAudial_GenericWheeled -- Distance zed will hear a generic wheeled/tracked vehicle such as a tank, APC, that sort of thing.
dayz_ZedVehicleSoundRealism_DisAudial_GenericCar -- Distance a zed will hear an unspecified car or truck type.
dayz_ZedVehicleSoundRealism_DisAudial_GenericBoat -- Distance a non-specific boat type will be heard.
dayz_ZedVehicleSoundRealism_DisAudial_GrossModifier -- This is a configurable modifier that multiplies the final sound distance calculation. The default is 1.00 (meaning no re-calc) but if a server operator feels the sounds are too loud or too soft, this is the overall value that can be adjusted. An example: A value of 2.00 would mean that the distance a zed would hear a generic car, configured for let's say 50, would be at 100 meters.
Step 2) Modify Zombie_FindTargetAgent.SQF
There's two sections we're adding to zombie_findtargetagent.sqf. But firstly, the original can be located in \z\dayz_code\compiles folder. Extract it out and place it in a folder within your mission folder (usually MPMissions\dayz_1.xxx).
Towards the top of the file, look for this section:
Our first chunk of code needs to be added below that:
This first part clears the vehicle out of the zed's array (list) of targets when the engine shuts off.
Down a little further in the file, we'll find this part:
(continued on post 2)
I wrote this addon a while back. This addon modifies Zombie_FindTargetAgent.SQF by adding two chunks of code (one small, one larger) that makes zed respond to the of a vehicle's engine by either walking over to the area of the sound or directly trying to attack the vehicle if it's occupied. The idea is to add a little bit of "realism". After all, zed hear gunshots; why wouldn't they hear an airplane or a heli?
When I first wrote this, I did real measurements of distances based on a bunch of different vehicles idling. I would run out and check to see how far away I could hear a particular vehicle. In this addon, most if not all of the regular DayZ vehicles are specifically configured. Aside from that, if there's a vehicle that's not DayZ-standard (such as those re-enabled from rMod), they fall within the 'Generic' category. The distance values for the five generic categories are configurable. In this mod, zed will only walk towards vehicle engine noise if they do not currently have any targets they're chasing after.
On to the mod.
Step 1) Modify Init.SQF
Here we modify Init.SQF to add a chunk of code that gives configurable options for this mod. Append the following chunk to the very bottom of the file:
Code:
// Zed respond to vehicle engine noise and loiter/run over mod - modifies zombie_findtargetagent.sqf - ^bdc
dayz_ZedVehicleSoundRealism_Enable = true; // Enable/Disable zed responding to vehicle engine noise
dayz_ZedVehicleSoundRealism_DisAudialMaximumRange = 365; // Maximum range in meters a zed will "hear" a vehicle (defines search parameter)
dayz_ZedVehicleSoundRealism_VeryHeavyRainCorrection = 0.40; // Distance correction factor for very heavy rainfall
dayz_ZedVehicleSoundRealism_HeavyRainCorrection = 0.55; // Distance correction factor for very heavy rainfall
dayz_ZedVehicleSoundRealism_ModerateRainCorrection = 0.70; // Distance correction factor for very heavy rainfall
dayz_ZedVehicleSoundRealism_LightRainCorrection = 0.85; // Distance correction factor for very heavy rainfall
dayz_ZedVehicleSoundRealism_DisAudial_GenericPlane = 355; // Default audible distance for non-specific planes/jets
dayz_ZedVehicleSoundRealism_DisAudial_GenericHeli = 315; // Default audible distance for non-specific helicopters
dayz_ZedVehicleSoundRealism_DisAudial_GenericWheeled = 155; // Default audible distance for all wheeled vehicles (tanks, etc)
dayz_ZedVehicleSoundRealism_DisAudial_GenericCar = 65; // Default audible distance for non-specific cars/trucks
dayz_ZedVehicleSoundRealism_DisAudial_GenericBoat = 75; // Default audible distance for non-specific boats
dayz_ZedVehicleSoundRealism_DisAudial_GrossModifier = 1.00; // Default 1.0; multiplier of final distance value calc'd
A detailed explanation of each configuration variable:
dayz_ZedVehicleSoundRealism_Enable -- This enables or disables this addon. More specifically, it either allows or disallows each zed, while running its own looped function looking for targets, from hearing any vehicles. It provides for a quick way to shut the mod off without having to gut it from script files.
dayz_ZedVehicleSoundRealism_DisAudialMaximumRange -- This is the maximum range in meters that a zed could possibly hear a vehicle. On my server, I have it set to 365. However, it may behoove the server owner to keep in mind that this may have an affect on client PC's FPS. I suspect there may be a performance drop if this is set too high. Also, consider the spawn radius of zed on a vanilla DayZ server doesn't extend too far out past 200m.
dayz_ZedVehicleSoundRealism_VeryHeavyRainCorrection -- Corrections factor for very heavy rainfall. Default is 0.40 which represents a correction of 40% of the calculated distance.
dayz_ZedVehicleSoundRealism_HeavyRainCorrection -- Corrections factor for heavy rain. Default 0.55.
dayz_ZedVehicleSoundRealism_ModerateRainCorrection -- Corrections factor for moderate rainfall. Default is 0.70.
dayz_ZedVehicleSoundRealism_LightRainCorrection -- Corrections factor for light rain/sprinkling. Default is 0.85.
dayz_ZedVehicleSoundRealism_DisAudial_GenericPlane -- The distance, in meters, a zed will hear a non-specific, generic plane.
dayz_ZedVehicleSoundRealism_DisAudial_GenericHeli -- The distance a zed will hear an undefined heli.
dayz_ZedVehicleSoundRealism_DisAudial_GenericWheeled -- Distance zed will hear a generic wheeled/tracked vehicle such as a tank, APC, that sort of thing.
dayz_ZedVehicleSoundRealism_DisAudial_GenericCar -- Distance a zed will hear an unspecified car or truck type.
dayz_ZedVehicleSoundRealism_DisAudial_GenericBoat -- Distance a non-specific boat type will be heard.
dayz_ZedVehicleSoundRealism_DisAudial_GrossModifier -- This is a configurable modifier that multiplies the final sound distance calculation. The default is 1.00 (meaning no re-calc) but if a server operator feels the sounds are too loud or too soft, this is the overall value that can be adjusted. An example: A value of 2.00 would mean that the distance a zed would hear a generic car, configured for let's say 50, would be at 100 meters.
Step 2) Modify Zombie_FindTargetAgent.SQF
There's two sections we're adding to zombie_findtargetagent.sqf. But firstly, the original can be located in \z\dayz_code\compiles folder. Extract it out and place it in a folder within your mission folder (usually MPMissions\dayz_1.xxx).
Towards the top of the file, look for this section:
Code:
if (isNil "_localtargets") then{
_localtargets = [];
};
if (isNil "_remotetargets") then{
_remotetargets = [];
};
_targets = _localtargets + _remotetargets;
Our first chunk of code needs to be added below that:
Code:
// Vehicle to zombie sound realism part 1 - ^bdc
// Chance to clear vehicle target from zombie's targets list if engine shut off
if (count _targets > 0) then {
{
_obj = _targets select 0;
if (_obj isKindOf "AllVehicles") then {
_isEngineOn = isEngineOn _obj;
_Chance = random 100;
if ((_Chance <= 10) and (!_isEngineOn)) then {
_targets = _targets - [_obj]; // Clear vehicle target if engine off
_pos = getPOSATL _obj;
_agent setVariable ["myDest",_pos];
};
};
} forEach _targets;
};
This first part clears the vehicle out of the zed's array (list) of targets when the engine shuts off.
Down a little further in the file, we'll find this part:
Code:
//Check if too far
if (_manDis > _range) then {
_targets = _targets - [_target];
_target = objNull;
};
(continued on post 2)