[FIXED] NPC still staying in war mode sometimes
Posted: Mon Jul 18, 2005 1:59 am
I noticed that NPCs, especially guards, sometimes still stay in war mode after the target has been killed. So I looked through the code and made some more changes. I haven't tested them much, but they shouldn't hurt eighter.
open cChar.cpp and find the "CChar::Cleanup( void )" function, there the following:
change it this way:
open combat.cpp and find the "CHandleCombat::Kill( CChar *mChar, CChar *ourTarg )" function, there:
change it this way:
open cChar.cpp and find the "CChar::Cleanup( void )" function, there the following:
Code: Select all
tempChar = GetAttacker();
if( ValidateObject( tempChar ) )
{
if( tempChar->GetAttacker() == this )
tempChar->SetAttacker( NULL );
SetAttacker( NULL );
}
Code: Select all
tempChar = GetAttacker();
if( ValidateObject( tempChar ) )
{
if( tempChar->GetAttacker() == this ) {
tempChar->SetAttacker( NULL );
tempChar->SetTarg( NULL );
tempChar->SetAttackFirst( false );
if( tempChar->IsAtWar() )
tempChar->ToggleCombat();
}
SetAttacker( NULL );
}
Code: Select all
if( mChar->GetNPCAiType() == aiGUARD && ourTarg->IsNpc() )
{
Effects->PlayCharacterAnimation( ourTarg, 0x15 );
Effects->playDeathSound( ourTarg );
ourTarg->Delete(); // Guards, don't give body
mChar->ToggleCombat();
return;
}
Code: Select all
if( mChar->GetNPCAiType() == aiGUARD && ourTarg->IsNpc() )
{
Effects->PlayCharacterAnimation( ourTarg, 0x15 );
Effects->playDeathSound( ourTarg );
ourTarg->Delete(); // Guards, don't give body
if( mChar->IsAtWar() )
mChar->ToggleCombat();
return;
}