[FIXED] NPC still staying in war mode sometimes

Here we stuff all the bugs we've managed to squash/squish/squelch.
Locked
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

[FIXED] NPC still staying in war mode sometimes

Post 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;
	}
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post by Grimson »

Seems like those changes did it. I haven't seen a NPC staying in war mode for quite some time.
giwo
Developer
Posts: 1780
Joined: Fri Jun 18, 2004 4:17 pm
Location: California
Has thanked: 0
Been thanked: 0

Post 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?
Scott
Grimson
Developer
Posts: 802
Joined: Sat Jun 04, 2005 1:52 am
Location: Germany
Has thanked: 0
Been thanked: 0

Post 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.
Locked