mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-31 23:26:41 +00:00 
			
		
		
		
	Fix trying to access stats on non-actors
This commit is contained in:
		
							parent
							
								
									bef29fc717
								
							
						
					
					
						commit
						e047679595
					
				
					 3 changed files with 7 additions and 8 deletions
				
			
		|  | @ -328,7 +328,7 @@ namespace MWClass | |||
|         MWMechanics::CreatureStats& stats = ptr.getClass().getCreatureStats(ptr); | ||||
| 
 | ||||
|         // 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); | ||||
| 
 | ||||
|         // Self defense
 | ||||
|  | @ -339,7 +339,7 @@ namespace MWClass | |||
|             setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); | ||||
| 
 | ||||
|         // 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); | ||||
|             // First handle the attacked actor
 | ||||
|  |  | |||
|  | @ -661,14 +661,14 @@ namespace MWClass | |||
|         bool setOnPcHitMe = true; | ||||
| 
 | ||||
|         // 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); | ||||
|             setOnPcHitMe = MWBase::Environment::get().getMechanicsManager()->actorAttacked(ptr, attacker); | ||||
|         } | ||||
| 
 | ||||
|         // 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); | ||||
|             // First handle the attacked actor
 | ||||
|  |  | |||
|  | @ -1216,14 +1216,13 @@ namespace MWMechanics | |||
| 
 | ||||
|     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> followersTarget = getActorsSidingWith(target); | ||||
| 
 | ||||
|         MWMechanics::CreatureStats& statsTarget = target.getClass().getCreatureStats(target); | ||||
| 
 | ||||
|         if (target == getPlayer()) | ||||
|             return false; | ||||
| 
 | ||||
|         if (std::find(followersAttacker.begin(), followersAttacker.end(), target) != followersAttacker.end()) | ||||
|         { | ||||
|             statsTarget.friendlyHit(); | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue