Page MenuHomeFeedback Tracker

Vehicle Sound Issue
New, UrgentPublic

Description

With the CarHorn mod I have created: https://steamcommunity.com/workshop/filedetails/discussion/1748971864, there is a strange bug that I am trying to resolve. I am thinking is a core issue at this point, because I cannot seem to find any logical reason for it otherwise.

Basically when a vehicle takes damage enough to cause the damage sound to be played, any "toot horn" will play the horn sound as well as the crash sound (Example.

Details

Severity
Minor
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
N/A
Category
General
Steps To Reproduce

See "Code Used" in Additional Information.

  1. Spawn vehicle.
  2. Jump in vehicle (test horn toot).
  3. Drive and hit into something enough to make a noise.
  4. Toot Horn again (you will get the horn noise and the crash noise again).
Additional Information

Code used:

modded class CarScript
{
	protected string		m_HornSoundSet_EXT;
	protected string		m_HornSoundSet_INT;
	protected EffectSound	m_HornSound;
	protected bool			m_IsSoundSynchRemote;
	
	void CarScript()
	{
		OnInit();
	}
	
	void OnInit()
	{
		string cHSSE = ConfigGetString("hornSoundSetEXT");
		if (cHSSE != "")
			m_HornSoundSet_EXT = cHSSE;
		else
			m_HornSoundSet_EXT = "car_horn_EXT_SoundSet";
		
		string cHSSI = ConfigGetString("hornSoundSetINT");
		if (cHSSI != "")
			m_HornSoundSet_INT = cHSSI;
		else
			m_HornSoundSet_INT = "car_horn_INT_SoundSet";
		
		RegisterNetSyncVariableBool("m_IsSoundSynchRemote");
	}
	
	void HonkHorn()
	{
		SoundSynchRemote();
		if (GetGame().IsServer())
		{
			ref NoiseParams npar = new NoiseParams();
			npar.LoadFromPath("CfgVehicles CarScript NoiseCarHorn");
			vector pos = this.GetPosition();
			float surfaceCoef = GetGame().SurfaceGetNoiseMultiplier(pos[0], pos[2]);
			GetGame().GetNoiseSystem().AddNoisePos(EntityAI.Cast(this), pos, npar, surfaceCoef);
		}
	}

	override void OnVariablesSynchronized()
	{
		super.OnVariablesSynchronized();
		
		if (IsSoundSynchRemote())
			HonkSoundPlay();
	}
	
	void HonkSoundPlay()
	{
		Object battery;
		EffectSound sound;
		if (IsVitalCarBattery()) battery = Object.Cast(this.FindAttachmentBySlotName("CarBattery"));
		if (IsVitalTruckBattery()) battery = Object.Cast(this.FindAttachmentBySlotName("TruckBattery"));
		
		if (battery)
		{
			if (GetGame().GetPlayer().IsCameraInsideVehicle())
				sound =	SEffectManager.PlaySoundOnObject(m_HornSoundSet_INT, battery);
			else
				sound =	SEffectManager.PlaySoundOnObject(m_HornSoundSet_EXT, battery);
				
		}
		
		if (sound)
			sound.SetSoundAutodestroy(true);
	}
	
	void SoundSynchRemoteReset()
	{	
		m_IsSoundSynchRemote = false;
		SetSynchDirty();
	}
	
	void SoundSynchRemote()
	{	
		m_IsSoundSynchRemote = true;
		SetSynchDirty();
	}
	
	bool IsSoundSynchRemote()
	{	
		return m_IsSoundSynchRemote;
	}
}

modded class PlayerBase
{	
	override void SetActions()
	{
		super.SetActions();
		AddAction(ActionCarHorn);
	}
}

class ActionCarHorn: ActionInteractBase
{
	void ActionStartEngine()
	{
		m_MessageSuccess    = "";
		m_CommandUID = DayZPlayerConstants.CMD_ACTIONMOD_TOOTHORN;
		m_StanceMask = DayZPlayerConstants.STANCEMASK_CROUCH | DayZPlayerConstants.STANCEMASK_ERECT;
	}

	override void CreateConditionComponents()  
	{	
		m_ConditionItem = new CCINone;
		m_ConditionTarget = new CCTNone;
	}
		
	override string GetText()
	{
		return "Toot Horn";
	}
	
	override bool ActionCondition(PlayerBase player, ActionTarget target, ItemBase item)
	{
		HumanCommandVehicle vehCmd = player.GetCommand_Vehicle();
		CarScript car;
		EntityAI battery = null;
		
		if (vehCmd && vehCmd.GetVehicleSeat() == DayZPlayerConstants.VEHICLESEAT_DRIVER)
		{
			Transport trans = vehCmd.GetTransport();
			if (trans)
			{
				if (Class.CastTo(car, trans))
				{
					if (car.IsVitalCarBattery() || car.IsVitalTruckBattery())
					{
						if (car.IsVitalCarBattery()) battery = EntityAI.Cast(car.FindAttachmentBySlotName("CarBattery"));
						if (car.IsVitalTruckBattery()) battery = EntityAI.Cast(car.FindAttachmentBySlotName("TruckBattery"));
						if (battery && !battery.IsRuined()) return true;
					}
				}
			}
		}
		return false;
	}

	override void OnExecuteServer(ActionData action_data)
	{
		HumanCommandVehicle vehCmd = action_data.m_Player.GetCommand_Vehicle();
		CarScript car;

		if (vehCmd)
		{
			Transport trans = vehCmd.GetTransport();
			if (trans)
			{
				if (Class.CastTo(car, trans))
				{
					car.HonkHorn();
				}
			}
		}
	}
	
	override void OnEndServer(ActionData action_data)
	{
		HumanCommandVehicle vehCmd = action_data.m_Player.GetCommand_Vehicle();
		CarScript car;

		if (vehCmd)
		{
			Transport trans = vehCmd.GetTransport();
			if (trans)
			{
				if (Class.CastTo(car, trans))
				{
					car.SoundSynchRemoteReset();
				}
			}
		}
	}
	
	override bool CanBeUsedInVehicle()
	{
		return true;
	}
}

modded class ActionConstructor
{
	override void RegisterActions(TTypenameArray actions)
	{
        super.RegisterActions(actions);
		actions.Insert(ActionCarHorn);
    }
}

Event Timeline

the CarHorn mod I have created: https://steamcommunity.com/workshop/filedetails/discussion/1748971864 geometry dash scratch , there is a strange bug that I am trying to resolve. I am thinking is a core issue at this point, because I cannot seem to find any logical reason for it otherwise. Basically when a vehicle takes damage enough to cause the damage sound to be played, any "toot horn" will play the horn sound as well as the crash sound (Example.

Exactly the same issue. Do you find the solution?