Page MenuHomeFeedback Tracker

Problem to identify the "killer" of zombies (and animals) since 1.20
Confirmed Internally, UrgentPublic

Description

One of my mod needs to be able to force kill zombies when they are hit by a player (in EEHitBy).

It worked perfectly fine with 1.19 and before

Since the 1.20 I'm still able to kill the zombie in EEHitBy but now the EEKilled doesn't identify the source anymore, it just use the zombie itself.

Zombies who commit suicide can makes sense (in some way) but it makes my mod unusable with mods like HeroesAndBandits or ExpansionHardLine and lot of other mod that need to identify the killers to give them rewards.

I use "SetHealth(0);" to kill zombies I tried "DecreaseHealth" too, maybe there is a more appropriate way I don't know.

Details

Severity
Block
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Category
General
Steps To Reproduce

Load this code and hit a zombie ingame,
look at server log you will see something like :
"The killer is ZmbF_SkaterYoung_Base<f1a1d040>" instead of "The killer is AKM_Base<b47d60b0>"

modded class ZombieBase
{
	override void EEKilled(Object killer)
    {
		Print("The killer is " + killer.ToString()); // => return the zombie itself
		super.EEKilled(killer);
	}
	
	override void EEHitBy(TotalDamageResult damageResult, int damageType, EntityAI source, int component, string dmgZone, string ammo, vector modelPos, float speedCoef)
	{
		SetHealth(0);
		super.EEHitBy(damageResult, damageType, source, component, dmgZone, ammo, modelPos, speedCoef);		
	}
}

Note that I tried to force killer identification by adding this before the SetHealth(0);
But it didn't work :-(
If I add prints to verify the data seems well save in "EEHitBy" but not used in "EEKilled" name

			Man killer = source.GetHierarchyRootPlayer();
			if ( !m_ZombieBase.m_KillerData )
			{
				m_ZombieBase.m_KillerData = new KillerData;
				m_ZombieBase.m_KillerData.m_Killer = killer;
				m_ZombieBase.m_KillerData.m_MurderWeapon = source;
			}
			SyncEvents.SendEntityKilled(this, m_KillerData.m_Killer, m_KillerData.m_MurderWeapon, m_KillerData.m_KillerHiTheBrain);
Additional Information

I heard the problem concern the animals too but I didn't investigate it.

I spend a lot of time to try to make a fix my side but it seems to be an endless job as more and more mods use these kind of feature, some are private, some will come the future...

At this point I feel that my mod could become deprecated while I still want to maintain and develope it (Above all that you now announced you will take care about zombies in 2023).

Here is a link to my main mod affected by this bug: PvZmoD Customisable Zombies
Of course not the best mod ever made but you'll see not a tiny, useless, unpopular one. Really think it worth keep it alive.

Event Timeline

Liven created this task.Feb 16 2023, 10:19 PM
Liven edited Steps To Reproduce. (Show Details)Feb 16 2023, 10:45 PM
Liven edited Steps To Reproduce. (Show Details)
Liven edited Additional Information. (Show Details)Feb 16 2023, 10:49 PM

This MOD is very popular and hopefully developers can help out with this.

Geez changed the task status from New to Reviewed.Feb 17 2023, 1:02 PM
Geez added a subscriber: Geez.

Hello Liven.
The developers suggest to use the method Object::ProcessDirectDamage instead of Object::SetHealth to deal the damage in a situation like this.
Regards,
Geez

Liven added a comment.Feb 18 2023, 1:02 AM
This comment was removed by Liven.
Liven added a comment.Feb 18 2023, 3:29 PM

@Geez Thank you very much that's exactly what I was looking for.
I had hard time to figure out how to use it for my needs but now it's done and all seems work well.

For the animals I thing there is a bug as the DayZCreatureAI::EEKilled alway return the animal itself as the killer.
I tried it on Animal_CanisLupus_Grey and AKM and without any mod except CF and Community Online Tool to make the wolves spawn.

Salutesh added a subscriber: Salutesh.EditedFeb 23 2023, 10:53 AM

I was also able to reproduce the mentioned issue with the kill source.
No matter with what a animal gets killed the entity returns itself as the killer in the EEKilled method on server side if it is inheriting from AnimalBase.

Salutesh added a subscriber: Salutesh.
Geez changed the task status from Reviewed to Confirmed Internally.Feb 23 2023, 1:25 PM
Salutesh added a comment.EditedFeb 23 2023, 2:37 PM

Further testing showed that the kill source is fine in the EEHitBy and in EEOnDamageCalculated methods.
Just EEKilled fails to return the correct entity in AnimalBase:

SCRIPT       : Animal_CanisLupus<a61548b0>::EEOnDamageCalculated - Start
SCRIPT       : Animal_CanisLupus<a61548b0>::EEOnDamageCalculated - Damage type: 1
SCRIPT       : Animal_CanisLupus<a61548b0>::EEOnDamageCalculated - Source entity: AKM
SCRIPT       : Animal_CanisLupus<a61548b0>::EEOnDamageCalculated - Damage Zone: Zone_Chest
SCRIPT       : Animal_CanisLupus<a61548b0>::EEOnDamageCalculated - Ammo: Bullet_762x39
SCRIPT       : Animal_CanisLupus<a61548b0>::EEOnDamageCalculated - End
SCRIPT       : Animal_CanisLupus<a61548b0>::EEHitBy - Start
SCRIPT       : Animal_CanisLupus<a61548b0>::EEKilled - Start
SCRIPT       : Animal_CanisLupus<a61548b0>::EEKilled - Killed entity: Animal_CanisLupus_Grey
SCRIPT       : Animal_CanisLupus<a61548b0>::EEKilled - Killer entity: Animal_CanisLupus_Grey
SCRIPT       : Animal_CanisLupus<a61548b0>::CheckAssignedObjectivesForEntity - Start
SCRIPT       : Animal_CanisLupus<a61548b0>::EEKilled - End
SCRIPT       : Animal_CanisLupus<a61548b0>::EEHitBy - Damage type: 1
SCRIPT       : Animal_CanisLupus<a61548b0>::EEHitBy - Source entity: AKM
SCRIPT       : Animal_CanisLupus<a61548b0>::EEHitBy - Damage Zone: Zone_Chest
SCRIPT       : Animal_CanisLupus<a61548b0>::EEHitBy - Ammo: Bullet_762x39
SCRIPT       : Animal_CanisLupus<a61548b0>::EEHitBy - End
komer added a subscriber: komer.Feb 24 2023, 8:23 PM
lava76 added a subscriber: lava76.May 26 2023, 2:07 PM

its not a bug, its feature, its needed remove super call

	override void EEKilled( Object killer )
	{
		EntityAI vrah = EntityAI.Cast(killer);
		if (GetOwnerId()>0 && vrah.GetHierarchyRootPlayer() && vrah.GetHierarchyRootPlayer().GetIdentity() && vrah.GetHierarchyRootPlayer().GetIdentity().GetName())
		{
			DoggoLogger.Log("Dog " + this.GetType() + " killed by " + vrah.GetHierarchyRootPlayer().GetIdentity().GetName() + " (" + vrah.GetHierarchyRootPlayer().GetIdentity().GetPlainId() + ")" );
			DoggoConfig config = GetDayZGame().GetDayzDogConfig();
			if (config.PunishDogKillers)
			{
				vrah.GetHierarchyRootPlayer().InsertAgent(eAgents.BRAIN, 1999);
			}
			
		}
		
		//super.EEKilled( killer );
	}

when killing dog it produce in log file:

08.07.2023 20:50:32 [Dayz-Dog] Player Hunterz tamed dog at pos <12597.992188, 6.352537, 9915.495117>
08.07.2023 20:52:48 [Dayz-Dog] Dog Doggo_Follow24 killed by Hunterz (76561198829279936)

when super call is present it not works...

Yes I know without super call nobody else will be able override that method :)

Just sharing what I found.