Page 1 of 1

[FIXED] NPC still staying in war mode sometimes

Posted: Mon Jul 18, 2005 1:59 am
by Grimson
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:

Code: Select all

		tempChar = GetAttacker();
		if( ValidateObject( tempChar ) )
		{
			if( tempChar->GetAttacker() == this )
				tempChar->SetAttacker( NULL );
			SetAttacker( NULL );
		}
change it this way:

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 );
		}
open combat.cpp and find the "CHandleCombat::Kill( CChar *mChar, CChar *ourTarg )" function, there:

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;
	}
change it this way:

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;
	}

Posted: Wed Jul 20, 2005 2:02 am
by Grimson
Seems like those changes did it. I haven't seen a NPC staying in war mode for quite some time.

Posted: Fri Aug 12, 2005 4:56 am
by giwo
These changes (modified only slightly) are a part of the exe starting at least 0.98-3.0e, can we get verification that it's working properly?

Posted: Fri Aug 12, 2005 4:34 pm
by Grimson
giwo wrote:These changes (modified only slightly) are a part of the exe starting at least 0.98-3.0e, can we get verification that it's working properly?
Well, I'm still using the above code here. And I haven't seen an NPC in war mode, without a reason, since I implemented it.