mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 12:26:39 +00:00 
			
		
		
		
	Fixed enchant points calculations formula
This commit is contained in:
		
							parent
							
								
									f17badb3cd
								
							
						
					
					
						commit
						46c8842808
					
				
					 1 changed files with 11 additions and 10 deletions
				
			
		| 
						 | 
					@ -172,14 +172,14 @@ namespace MWMechanics
 | 
				
			||||||
        const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
 | 
					        const MWWorld::ESMStore &store = MWBase::Environment::get().getWorld()->getStore();
 | 
				
			||||||
        std::vector<ESM::ENAMstruct> mEffects = mEffectList.mList;
 | 
					        std::vector<ESM::ENAMstruct> mEffects = mEffectList.mList;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        float enchantmentCost = 0;
 | 
					        int enchantmentCost = 0;
 | 
				
			||||||
        int effectsLeftCnt = mEffects.size();
 | 
					        float cost = 0;
 | 
				
			||||||
        for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
 | 
					        for (std::vector<ESM::ENAMstruct>::const_iterator it = mEffects.begin(); it != mEffects.end(); ++it)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            float baseCost = (store.get<ESM::MagicEffect>().find(it->mEffectID))->mData.mBaseCost;
 | 
					            float baseCost = (store.get<ESM::MagicEffect>().find(it->mEffectID))->mData.mBaseCost;
 | 
				
			||||||
            int magMin = (it->mMagnMin == 0) ? 1 : it->mMagnMin;
 | 
					            int magMin = std::max(1, it->mMagnMin);
 | 
				
			||||||
            int magMax = (it->mMagnMax == 0) ? 1 : it->mMagnMax;
 | 
					            int magMax = std::max(1, it->mMagnMax);
 | 
				
			||||||
            int area = (it->mArea == 0) ? 1 : it->mArea;
 | 
					            int area = std::max(1, it->mArea);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            float magnitudeCost = (magMin + magMax) * baseCost * 0.05f;
 | 
					            float magnitudeCost = (magMin + magMax) * baseCost * 0.05f;
 | 
				
			||||||
            if (mCastStyle == ESM::Enchantment::ConstantEffect)
 | 
					            if (mCastStyle == ESM::Enchantment::ConstantEffect)
 | 
				
			||||||
| 
						 | 
					@ -195,16 +195,17 @@ namespace MWMechanics
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const float fEffectCostMult = store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat();
 | 
					            const float fEffectCostMult = store.get<ESM::GameSetting>().find("fEffectCostMult")->getFloat();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            float cost = (magnitudeCost + areaCost) * fEffectCostMult;
 | 
					            cost += (magnitudeCost + areaCost) * fEffectCostMult;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            cost = std::max(1.f, cost);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            if (it->mRange == ESM::RT_Target)
 | 
					            if (it->mRange == ESM::RT_Target)
 | 
				
			||||||
                cost *= 1.5;
 | 
					                cost *= 1.5;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            enchantmentCost += cost * effectsLeftCnt;
 | 
					            enchantmentCost += static_cast<int>(cost);
 | 
				
			||||||
            enchantmentCost = std::max(1.f, enchantmentCost);
 | 
					 | 
				
			||||||
            --effectsLeftCnt;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return static_cast<int>(enchantmentCost);
 | 
					        return enchantmentCost;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue