mirror of
				https://github.com/TES3MP/openmw-tes3mp.git
				synced 2025-10-26 14:56:43 +00:00 
			
		
		
		
	Make sure cast chance checks mana when necessary (bug #5112)
This commit is contained in:
		
							parent
							
								
									134631ad72
								
							
						
					
					
						commit
						a9c4b18d38
					
				
					 5 changed files with 6 additions and 8 deletions
				
			
		|  | @ -121,6 +121,7 @@ | ||||||
|     Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels |     Bug #5104: Black Dart's enchantment doesn't trigger at low Enchant levels | ||||||
|     Bug #5105: NPCs start combat with werewolves from any distance |     Bug #5105: NPCs start combat with werewolves from any distance | ||||||
|     Bug #5110: ModRegion with a redundant numerical argument breaks script execution |     Bug #5110: ModRegion with a redundant numerical argument breaks script execution | ||||||
|  |     Bug #5112: Insufficient magicka for current spell not reflected on HUD icon | ||||||
|     Bug #5123: Script won't run on respawn |     Bug #5123: Script won't run on respawn | ||||||
|     Bug #5124: Arrow remains attached to actor if pulling animation was cancelled |     Bug #5124: Arrow remains attached to actor if pulling animation was cancelled | ||||||
|     Feature #1774: Handle AvoidNode |     Feature #1774: Handle AvoidNode | ||||||
|  |  | ||||||
|  | @ -71,7 +71,7 @@ namespace MWGui | ||||||
|             { |             { | ||||||
|                 newSpell.mType = Spell::Type_Spell; |                 newSpell.mType = Spell::Type_Spell; | ||||||
|                 std::string cost = std::to_string(spell->mData.mCost); |                 std::string cost = std::to_string(spell->mData.mCost); | ||||||
|                 std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor, nullptr, true, true))); |                 std::string chance = std::to_string(int(MWMechanics::getSpellSuccessChance(spell, mActor))); | ||||||
|                 newSpell.mCostColumn = cost + "/" + chance; |                 newSpell.mCostColumn = cost + "/" + chance; | ||||||
|             } |             } | ||||||
|             else |             else | ||||||
|  |  | ||||||
|  | @ -241,7 +241,7 @@ namespace MWMechanics | ||||||
|         float castChance = 100.f; |         float castChance = 100.f; | ||||||
|         if (spell != nullptr && !caster.isEmpty() && caster.getClass().isActor()) |         if (spell != nullptr && !caster.isEmpty() && caster.getClass().isActor()) | ||||||
|         { |         { | ||||||
|             castChance = getSpellSuccessChance(spell, caster, nullptr, false); // Uncapped casting chance
 |             castChance = getSpellSuccessChance(spell, caster, nullptr, false, false); // Uncapped casting chance
 | ||||||
|         } |         } | ||||||
|         if (castChance > 0) |         if (castChance > 0) | ||||||
|             x *= 50 / castChance; |             x *= 50 / castChance; | ||||||
|  | @ -939,7 +939,7 @@ namespace MWMechanics | ||||||
|                 bool fail = false; |                 bool fail = false; | ||||||
| 
 | 
 | ||||||
|                 // Check success
 |                 // Check success
 | ||||||
|                 float successChance = getSpellSuccessChance(spell, mCaster); |                 float successChance = getSpellSuccessChance(spell, mCaster, nullptr, true, false); | ||||||
|                 if (Misc::Rng::roll0to99() >= successChance) |                 if (Misc::Rng::roll0to99() >= successChance) | ||||||
|                 { |                 { | ||||||
|                     if (mCaster == getPlayer()) |                     if (mCaster == getPlayer()) | ||||||
|  |  | ||||||
|  | @ -39,8 +39,8 @@ namespace MWMechanics | ||||||
|      * @note actor can be an NPC or a creature |      * @note actor can be an NPC or a creature | ||||||
|      * @return success chance from 0 to 100 (in percent), if cap=false then chance above 100 may be returned. |      * @return success chance from 0 to 100 (in percent), if cap=false then chance above 100 may be returned. | ||||||
|      */ |      */ | ||||||
|     float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=false); |     float getSpellSuccessChance (const ESM::Spell* spell, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=true); | ||||||
|     float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=false); |     float getSpellSuccessChance (const std::string& spellId, const MWWorld::Ptr& actor, int* effectiveSchool = nullptr, bool cap=true, bool checkMagicka=true); | ||||||
| 
 | 
 | ||||||
|     int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor); |     int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor); | ||||||
|     int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor); |     int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor); | ||||||
|  |  | ||||||
|  | @ -122,9 +122,6 @@ namespace MWMechanics | ||||||
|                 return 0.f; |                 return 0.f; | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (spell->mData.mCost > stats.getMagicka().getCurrent()) |  | ||||||
|             return 0.f; |  | ||||||
| 
 |  | ||||||
|         // Spells don't stack, so early out if the spell is still active on the target
 |         // Spells don't stack, so early out if the spell is still active on the target
 | ||||||
|         int types = getRangeTypes(spell->mEffects); |         int types = getRangeTypes(spell->mEffects); | ||||||
|         if ((types & Self) && stats.getActiveSpells().isSpellActive(spell->mId)) |         if ((types & Self) && stats.getActiveSpells().isSpellActive(spell->mId)) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue