Page MenuHomeFeedback Tracker

Component Index not returning the Door Index
Assigned, UrgentPublic

Description

The component index from Object::EEOnDamageCalculated and DayZGame::FirearmEffects does not return the door index when passing the component index to Building::GetDoorIndex. I would like to be able to nullify opening locked doors with damage, without using SetAllowDamage(false), as this prevents projectiles from penetrating the entire entity. The component index from the raytrace for ActionTarger seems to correctly get the door index from the hit component index.

Example video:

Details

Severity
Minor
Resolution
Open
Reproducibility
Random
Operating System
Windows 11 x64
Category
General
Additional Information
modded class BuildingBase
{
    override bool EEOnDamageCalculated(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
    {
        int index = GetDoorIndex(component);

        DbgUI.BeginCleanupScope();
        DbgUI.Begin("Building Debug", 5, 5);

        DbgUI.Text("Building: " + this);
        DbgUI.Text("Component: " + component);
        DbgUI.Text("DoorIndex: " + index);

        if (index != -1)
            DbgUI.Text("Locked: " + IsDoorLocked(index));

        DbgUI.End();
        DbgUI.EndCleanupScope();

        // nullify damage to door (prevent opening locked doors by damage)
        if (index != -1 && IsDoorLocked(index))
            return false;

        return super.EEOnDamageCalculated(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
    }
}

Event Timeline

Geez changed the task status from New to Assigned.Feb 13 2023, 10:16 AM

This was the most "efficient" solution I could come up with to solve this problem. Not sure if this would support all modded buildings I'm unsure if they'll follow the same naming scheme as vanilla. Was an annoying issue to solve since component name and damage zones from the parameters never seemed to be consistent across the following:

  • CfgVehicles {Type} Doors
  • DamageSystem.GetComponentNamesFromDamageZone
  • Object::GetActionComponentName(componentIndex, LOD.NAME_FIRE)
modded class BuildingBase
{
	override bool EEOnDamageCalculated(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
	{
		string testDmgZone = dmgZone; // local copy
		if (testDmgZone.Replace("door", string.Empty) > 0 || testDmgZone.Replace("twin", string.Empty) > 0)
		{
			int doorIndex = testDmgZone.ToInt();
			doorIndex--; // array index start position

			if (doorIndex != -1 && IsDoorLocked(doorIndex))
			{
				return false;
			}
		}

		return super.EEOnDamageCalculated(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);
	}
}

Nevermind this solution doesn't always work, due to some twin doors not following the naming scheme and order in CfgDoors.

OfficialWardog added a comment.EditedJun 13 2023, 7:01 AM

This is the final fully working solution. which is still not pretty.

modded class BuildingBase
{
	private int ConvertComponent(int srcComponentIdx, string srcGeometry, string dstGeometry)
	{
		string selection = GetActionComponentName(srcComponentIdx, srcGeometry);

		const int maxComponents = 512;
		for (int componentIndex = 0; componentIndex < maxComponents; componentIndex++)
		{
			if (IsActionComponentPartOfSelection(componentIndex, selection, dstGeometry))
			{
				return componentIndex;
			}
		}

		return -1;
	}

	override bool EEOnDamageCalculated(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
	{
		if (!super.EEOnDamageCalculated(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef))
		{
			return false;
		}

		int dstComponent = ConvertComponent(component, LOD.NAME_FIRE, LOD.NAME_VIEW);
		if (dstComponent != -1)
		{
			int doorIndex = GetDoorIndex(dstComponent);
			if (IsDoorLocked(doorIndex))
			{
				return false;
			}
		}

		return true;
	}
}