Fix error when AI equips a shield and has a ranged weapon

The shield and bow both use fx.aim_weapon, but the ranged weapons AI thinks that a shield works the same way as a bow and tries to fire it - in order to prevent this, the AI now also checks whether the equipped item is a IsRangedWeapon. This _could_ have an impact on the vehicle AI, but the unit test worked fine.
install-platforms
Mark 2018-01-07 14:39:07 +01:00
parent dd86c05b9f
commit 8bf90871e1
3 changed files with 7 additions and 2 deletions

View File

@ -287,7 +287,7 @@ private func ExecuteRanged(effect fx)
// Look at target
this->ExecuteLookAtTarget(fx);
// Make sure we can shoot
if (!this->IsAimingOrLoading(fx) || !fx.aim_weapon)
if (!this->IsAimingOrLoading(fx) || !fx.aim_weapon || !fx.aim_weapon->~IsRangedWeapon())
{
CancelAiming(fx);
if (!this->CheckHandsAction(fx)) return true;

View File

@ -34,7 +34,7 @@ private func ExecuteRanged(effect fx)
// Look at target.
this->ExecuteLookAtTarget(fx);
// Make sure we can shoot.
if (!this->IsAimingOrLoading(fx) || !fx.aim_weapon)
if (!this->IsAimingOrLoading(fx) || !fx.aim_weapon || !fx.aim_weapon->~IsRangedWeapon())
{
this->CancelAiming(fx);
if (!this->CheckHandsAction(fx)) return true;

View File

@ -14,6 +14,11 @@ local DefaultLoadTime2 = nil;
local DefaultShootTime = nil;
local DefaultShootTime2 = nil;
public func IsRangedWeapon()
{
return true; // identify this as a ranged weapon for the AI
}
public func Initialize(...)
{
// Set initial animation speeds