mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-25 11:26:37 +00:00 
			
		
		
		
	Set OnPcHitMe even for missed hits
This commit is contained in:
		
							parent
							
								
									76799982a5
								
							
						
					
					
						commit
						04010b8a1a
					
				
					 2 changed files with 16 additions and 15 deletions
				
			
		|  | @ -345,6 +345,14 @@ namespace MWClass | ||||||
|         if(!object.isEmpty()) |         if(!object.isEmpty()) | ||||||
|             getCreatureStats(ptr).setLastHitAttemptObject(object.getClass().getId(object)); |             getCreatureStats(ptr).setLastHitAttemptObject(object.getClass().getId(object)); | ||||||
| 
 | 
 | ||||||
|  |         if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) | ||||||
|  |         { | ||||||
|  |             const std::string &script = ptr.get<ESM::Creature>()->mBase->mScript; | ||||||
|  |             /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ | ||||||
|  |             if(!script.empty()) | ||||||
|  |                 ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         if(!successful) |         if(!successful) | ||||||
|         { |         { | ||||||
|             // Missed
 |             // Missed
 | ||||||
|  | @ -355,14 +363,6 @@ namespace MWClass | ||||||
|         if(!object.isEmpty()) |         if(!object.isEmpty()) | ||||||
|             getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); |             getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); | ||||||
| 
 | 
 | ||||||
|         if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) |  | ||||||
|         { |  | ||||||
|             const std::string &script = ptr.get<ESM::Creature>()->mBase->mScript; |  | ||||||
|             /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ |  | ||||||
|             if(!script.empty()) |  | ||||||
|                 ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); |  | ||||||
|         } |  | ||||||
| 
 |  | ||||||
|         if (damage > 0.0f && !object.isEmpty()) |         if (damage > 0.0f && !object.isEmpty()) | ||||||
|             MWMechanics::resistNormalWeapon(ptr, attacker, object, damage); |             MWMechanics::resistNormalWeapon(ptr, attacker, object, damage); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -610,6 +610,14 @@ namespace MWClass | ||||||
|         if(!object.isEmpty()) |         if(!object.isEmpty()) | ||||||
|             getCreatureStats(ptr).setLastHitAttemptObject(object.getClass().getId(object)); |             getCreatureStats(ptr).setLastHitAttemptObject(object.getClass().getId(object)); | ||||||
| 
 | 
 | ||||||
|  |         if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) | ||||||
|  |         { | ||||||
|  |             const std::string &script = ptr.getClass().getScript(ptr); | ||||||
|  |             /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ | ||||||
|  |             if(!script.empty()) | ||||||
|  |                 ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); | ||||||
|  |         } | ||||||
|  | 
 | ||||||
|         if(!successful) |         if(!successful) | ||||||
|         { |         { | ||||||
|             // Missed
 |             // Missed
 | ||||||
|  | @ -620,13 +628,6 @@ namespace MWClass | ||||||
|         if(!object.isEmpty()) |         if(!object.isEmpty()) | ||||||
|             getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); |             getCreatureStats(ptr).setLastHitObject(object.getClass().getId(object)); | ||||||
| 
 | 
 | ||||||
|         if(setOnPcHitMe && !attacker.isEmpty() && attacker == MWBase::Environment::get().getWorld()->getPlayerPtr()) |  | ||||||
|         { |  | ||||||
|             const std::string &script = ptr.getClass().getScript(ptr); |  | ||||||
|             /* Set the OnPCHitMe script variable. The script is responsible for clearing it. */ |  | ||||||
|             if(!script.empty()) |  | ||||||
|                 ptr.getRefData().getLocals().setVarByInt(script, "onpchitme", 1); |  | ||||||
|         } |  | ||||||
| 
 | 
 | ||||||
|         if (damage > 0.0f && !object.isEmpty()) |         if (damage > 0.0f && !object.isEmpty()) | ||||||
|             MWMechanics::resistNormalWeapon(ptr, attacker, object, damage); |             MWMechanics::resistNormalWeapon(ptr, attacker, object, damage); | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue