Hi,
I made some mods in relation with zombie (PvZmod)
One of them add the possibility for zombies to attack players on obstacle but since the 1.13 I have a Null message when they do so.
After investigating it is because the m_ActualAttackType = Null when I launch the attack
Maybe I don’t do it the right way but it was working in 1.12
I think the new vanilla ability for zombie to hit moving player is the cause.
I try to get an new ActualAttackType but I’m stuck because GetAttackGroup is protected
My side, I finaly found a way to avoid the Null error messages but it force me to override the FightLogic () and I’m not sure it will work for all possible cases.
So I was wandering if it would be possible to add Null check in FightLogic or make modifications with the same result or make GetAttackGroup non protected or give a workaround to “trigger” a zombie attack without Null message.
Here is the change I made :
```
override bool FightLogic(int pCurrentCommandID, DayZInfectedInputController pInputController, float pDt)
{
if ( pCurrentCommandID == DayZInfectedConstants.COMMANDID_MOVE )
{
// we attack only in chase & fight state
int mindState = pInputController.GetMindState();
if ( mindState == DayZInfectedConstants.MINDSTATE_CHASE )
{
return ChaseAttackLogic(pCurrentCommandID, pInputController, pDt);
}
else if ( mindState == DayZInfectedConstants.MINDSTATE_FIGHT )
{
return FightAttackLogic(pCurrentCommandID, pInputController, pDt);
}
}
else if ( pCurrentCommandID == DayZInfectedConstants.COMMANDID_ATTACK )
{
DayZInfectedCommandAttack attackCommand = GetCommand_Attack();
if ( attackCommand && attackCommand.WasHit() )
{
if ( m_ActualTarget != NULL )
{
if (m_ActualTarget.GetMeleeTargetType() == EMeleeTargetType.NONALIGNABLE )
{
return false;
}
bool playerInBlockStance = false;
vector targetPos = m_ActualTarget.GetPosition();
vector hitPosWS = targetPos;
vector zombiePos = GetPosition();
PlayerBase playerTarget = PlayerBase.Cast(m_ActualTarget);
if ( playerTarget )
{
playerInBlockStance = playerTarget.GetMeleeFightLogic() && playerTarget.GetMeleeFightLogic().IsInBlock();
}
if ( m_ActualAttackType == NULL || vector.DistanceSq(targetPos, zombiePos) <= m_ActualAttackType.m_Distance * m_ActualAttackType.m_Distance ) /////////////////////////// Control m_ActualAttackType added
{
//! player is in block stance and facing the infected
if ( playerInBlockStance && (Math.RAD2DEG * Math.AbsFloat(Math3D.AngleFromPosition(targetPos, MiscGameplayFunctions.GetHeadingVector(playerTarget), zombiePos))) <= GameConstants.AI_MAX_BLOCKABLE_ANGLE )
{
//! infected is playing heavy attack - decrease the dmg to light
if ( m_ActualAttackType && m_ActualAttackType.m_IsHeavy != 0 ) /////////////////////////// Control m_ActualAttackType added
{
hitPosWS = m_ActualTarget.ModelToWorld(m_ActualTarget.GetDefaultHitPosition()); //! override hit pos by pos defined in type
DamageSystem.CloseCombatDamageName(this, m_ActualTarget, m_ActualTarget.GetHitComponentForAI(), "MeleeZombie", hitPosWS);
}
else
{
//! infected is playing light attack - do not send damage, play animation instead
if ( GetGame().IsServer() )
{
hitPosWS = m_ActualTarget.GetDefaultHitPosition(); //! override hit pos by pos defined in type
m_ActualTarget.EEHitBy(null, 0, this, -1, m_ActualTarget.GetDefaultHitComponent(), "Dummy_Light", hitPosWS, 1.0);
}
}
}
else
{
hitPosWS = m_ActualTarget.ModelToWorld(m_ActualTarget.GetDefaultHitPosition()); //! override hit pos by pos defined in type
if (m_ActualAttackType) /////////////////////////// Control m_ActualAttackType added
DamageSystem.CloseCombatDamageName(this, m_ActualTarget, m_ActualTarget.GetHitComponentForAI(), m_ActualAttackType.m_AmmoType, hitPosWS);
else
DamageSystem.CloseCombatDamageName(this, m_ActualTarget, m_ActualTarget.GetHitComponentForAI(), "MeleeZombie", hitPosWS); /////////////////////////// if no m_ActualAttackType case added
}
}
}
}
return true;
}
return false;
}
```