forked from mirror/openmw-tes3mp
Merge pull request #1200 from Allofich/fix
Fix trying to access stats on non-actors
This commit is contained in:
commit
ec5587ddd3
3 changed files with 7 additions and 8 deletions
|
@ -328,7 +328,7 @@ namespace MWClass
|
||||||
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
|
MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr);
|
||||||
|
|
||||||
// NOTE: 'object' and/or 'attacker' may be empty.
|
// NOTE: 'object' and/or 'attacker' may be empty.
|
||||||
if (!attacker.isEmpty() && !stats.getAiSequence().isInCombat(attacker))
|
if (!attacker.isEmpty() && attacker.getClass().isActor() && !stats.getAiSequence().isInCombat(attacker))
|
||||||
stats.setAttacked(true);
|
stats.setAttacked(true);
|
||||||
|
|
||||||
// Self defense
|
// Self defense
|
||||||
|
@ -339,7 +339,7 @@ namespace MWClass
|
||||||
setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker);
|
setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker);
|
||||||
|
|
||||||
// Attacker and target store each other as hitattemptactor if they have no one stored yet
|
// Attacker and target store each other as hitattemptactor if they have no one stored yet
|
||||||
if (!attacker.isEmpty() && !ptr.isEmpty())
|
if (!attacker.isEmpty() && attacker.getClass().isActor() && !ptr.isEmpty() && ptr.getClass().isActor())
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& statsAttacker = attacker.getClass().getCreatureStats(attacker);
|
MWMechanics::CreatureStats& statsAttacker = attacker.getClass().getCreatureStats(attacker);
|
||||||
// First handle the attacked actor
|
// First handle the attacked actor
|
||||||
|
|
|
@ -661,14 +661,14 @@ namespace MWClass
|
||||||
bool setOnPcHitMe = true;
|
bool setOnPcHitMe = true;
|
||||||
|
|
||||||
// NOTE: 'object' and/or 'attacker' may be empty.
|
// NOTE: 'object' and/or 'attacker' may be empty.
|
||||||
if (!attacker.isEmpty() && !stats.getAiSequence().isInCombat(attacker))
|
if (!attacker.isEmpty() && attacker.getClass().isActor() && !stats.getAiSequence().isInCombat(attacker))
|
||||||
{
|
{
|
||||||
stats.setAttacked(true);
|
stats.setAttacked(true);
|
||||||
setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker);
|
setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Attacker and target store each other as hitattemptactor if they have no one stored yet
|
// Attacker and target store each other as hitattemptactor if they have no one stored yet
|
||||||
if (!attacker.isEmpty() && !ptr.isEmpty())
|
if (!attacker.isEmpty() && attacker.getClass().isActor() && !ptr.isEmpty() && ptr.getClass().isActor())
|
||||||
{
|
{
|
||||||
MWMechanics::CreatureStats& statsAttacker = attacker.getClass().getCreatureStats(attacker);
|
MWMechanics::CreatureStats& statsAttacker = attacker.getClass().getCreatureStats(attacker);
|
||||||
// First handle the attacked actor
|
// First handle the attacked actor
|
||||||
|
|
|
@ -1216,14 +1216,13 @@ namespace MWMechanics
|
||||||
|
|
||||||
bool MechanicsManager::actorAttacked(const MWWorld::Ptr &target, const MWWorld::Ptr &attacker)
|
bool MechanicsManager::actorAttacked(const MWWorld::Ptr &target, const MWWorld::Ptr &attacker)
|
||||||
{
|
{
|
||||||
|
if (target == getPlayer() || !attacker.getClass().isActor())
|
||||||
|
return false;
|
||||||
|
|
||||||
std::list<MWWorld::Ptr> followersAttacker = getActorsSidingWith(attacker);
|
std::list<MWWorld::Ptr> followersAttacker = getActorsSidingWith(attacker);
|
||||||
std::list<MWWorld::Ptr> followersTarget = getActorsSidingWith(target);
|
|
||||||
|
|
||||||
MWMechanics::CreatureStats& statsTarget = target.getClass().getCreatureStats(target);
|
MWMechanics::CreatureStats& statsTarget = target.getClass().getCreatureStats(target);
|
||||||
|
|
||||||
if (target == getPlayer())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (std::find(followersAttacker.begin(), followersAttacker.end(), target) != followersAttacker.end())
|
if (std::find(followersAttacker.begin(), followersAttacker.end(), target) != followersAttacker.end())
|
||||||
{
|
{
|
||||||
statsTarget.friendlyHit();
|
statsTarget.friendlyHit();
|
||||||
|
|
Loading…
Reference in a new issue