mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-29 03:26:38 +00:00 
			
		
		
		
	Closes #947: Decrease fatigue when running, swimming and attacking
This commit is contained in:
		
							parent
							
								
									dddc0979a2
								
							
						
					
					
						commit
						44b2380874
					
				
					 3 changed files with 50 additions and 4 deletions
				
			
		|  | @ -436,6 +436,20 @@ namespace MWClass | ||||||
|         if(!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name()) |         if(!weapon.isEmpty() && weapon.getTypeName() != typeid(ESM::Weapon).name()) | ||||||
|             weapon = MWWorld::Ptr(); |             weapon = MWWorld::Ptr(); | ||||||
| 
 | 
 | ||||||
|  |         // Reduce fatigue
 | ||||||
|  |         // somewhat of a guess, but using the weapon weight makes sense
 | ||||||
|  |         const float fFatigueAttackBase = gmst.find("fFatigueAttackBase")->getFloat(); | ||||||
|  |         const float fFatigueAttackMult = gmst.find("fFatigueAttackMult")->getFloat(); | ||||||
|  |         const float fWeaponFatigueMult = gmst.find("fWeaponFatigueMult")->getFloat(); | ||||||
|  |         MWMechanics::DynamicStat<float> fatigue = getCreatureStats(ptr).getFatigue(); | ||||||
|  |         const float normalizedEncumbrance = getEncumbrance(ptr) / getCapacity(ptr); | ||||||
|  |         float fatigueLoss = fFatigueAttackBase + normalizedEncumbrance * fFatigueAttackMult; | ||||||
|  |         if (!weapon.isEmpty()) | ||||||
|  |             fatigueLoss += weapon.getClass().getWeight(weapon) * getNpcStats(ptr).getAttackStrength() * fWeaponFatigueMult; | ||||||
|  |         fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); | ||||||
|  |         getCreatureStats(ptr).setFatigue(fatigue); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|         float dist = 100.0f * (!weapon.isEmpty() ? |         float dist = 100.0f * (!weapon.isEmpty() ? | ||||||
|                                weapon.get<ESM::Weapon>()->mBase->mData.mReach : |                                weapon.get<ESM::Weapon>()->mBase->mData.mReach : | ||||||
|                                gmst.find("fHandToHandReach")->getFloat()); |                                gmst.find("fHandToHandReach")->getFloat()); | ||||||
|  |  | ||||||
|  | @ -900,6 +900,41 @@ void CharacterController::update(float duration) | ||||||
|             } |             } | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|  |         // reduce fatigue
 | ||||||
|  |         const MWWorld::Store<ESM::GameSetting> &gmst = world->getStore().get<ESM::GameSetting>(); | ||||||
|  |         float fatigueLoss = 0; | ||||||
|  |         static const float fFatigueRunBase = gmst.find("fFatigueRunBase")->getFloat(); | ||||||
|  |         static const float fFatigueRunMult = gmst.find("fFatigueRunMult")->getFloat(); | ||||||
|  |         static const float fFatigueSwimWalkBase = gmst.find("fFatigueSwimWalkBase")->getFloat(); | ||||||
|  |         static const float fFatigueSwimRunBase = gmst.find("fFatigueSwimRunBase")->getFloat(); | ||||||
|  |         static const float fFatigueSwimWalkMult = gmst.find("fFatigueSwimWalkMult")->getFloat(); | ||||||
|  |         static const float fFatigueSwimRunMult = gmst.find("fFatigueSwimRunMult")->getFloat(); | ||||||
|  |         static const float fFatigueSneakBase = gmst.find("fFatigueSneakBase")->getFloat(); | ||||||
|  |         static const float fFatigueSneakMult = gmst.find("fFatigueSneakMult")->getFloat(); | ||||||
|  | 
 | ||||||
|  |         const float encumbrance = cls.getEncumbrance(mPtr) / cls.getCapacity(mPtr); | ||||||
|  |         if (encumbrance < 1) | ||||||
|  |         { | ||||||
|  |             if (sneak) | ||||||
|  |                 fatigueLoss = fFatigueSneakBase + encumbrance * fFatigueSneakMult; | ||||||
|  |             else | ||||||
|  |             { | ||||||
|  |                 if (inwater) | ||||||
|  |                 { | ||||||
|  |                     if (!isrunning) | ||||||
|  |                         fatigueLoss = fFatigueSwimWalkBase + encumbrance * fFatigueSwimWalkMult; | ||||||
|  |                     else | ||||||
|  |                         fatigueLoss = fFatigueSwimRunBase + encumbrance * fFatigueSwimRunMult; | ||||||
|  |                 } | ||||||
|  |                 if (isrunning) | ||||||
|  |                     fatigueLoss = fFatigueRunBase + encumbrance * fFatigueRunMult; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         fatigueLoss *= duration; | ||||||
|  |         DynamicStat<float> fatigue = cls.getCreatureStats(mPtr).getFatigue(); | ||||||
|  |         fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss, fatigue.getCurrent() < 0); | ||||||
|  |         cls.getCreatureStats(mPtr).setFatigue(fatigue); | ||||||
|  | 
 | ||||||
|         if(sneak || inwater || flying) |         if(sneak || inwater || flying) | ||||||
|             vec.z = 0.0f; |             vec.z = 0.0f; | ||||||
| 
 | 
 | ||||||
|  | @ -916,8 +951,6 @@ void CharacterController::update(float duration) | ||||||
|                 cls.getCreatureStats(mPtr).land(); |                 cls.getCreatureStats(mPtr).land(); | ||||||
|             } |             } | ||||||
| 
 | 
 | ||||||
|             const MWWorld::Store<ESM::GameSetting> &gmst = world->getStore().get<ESM::GameSetting>(); |  | ||||||
| 
 |  | ||||||
|             forcestateupdate = (mJumpState != JumpState_Falling); |             forcestateupdate = (mJumpState != JumpState_Falling); | ||||||
|             mJumpState = JumpState_Falling; |             mJumpState = JumpState_Falling; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -437,8 +437,7 @@ namespace MWMechanics | ||||||
|             DynamicStat<float> fatigue = stats.getFatigue(); |             DynamicStat<float> fatigue = stats.getFatigue(); | ||||||
|             const float normalizedEncumbrance = mCaster.getClass().getEncumbrance(mCaster) / mCaster.getClass().getCapacity(mCaster); |             const float normalizedEncumbrance = mCaster.getClass().getEncumbrance(mCaster) / mCaster.getClass().getCapacity(mCaster); | ||||||
|             float fatigueLoss = spell->mData.mCost * (fFatigueSpellBase + normalizedEncumbrance * fFatigueSpellMult); |             float fatigueLoss = spell->mData.mCost * (fFatigueSpellBase + normalizedEncumbrance * fFatigueSpellMult); | ||||||
|             fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); |             fatigue.setCurrent(fatigue.getCurrent() - fatigueLoss); stats.setFatigue(fatigue); | ||||||
|             stats.setFatigue(fatigue); |  | ||||||
| 
 | 
 | ||||||
|             bool fail = false; |             bool fail = false; | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue