mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-10-29 03:26:38 +00:00 
			
		
		
		
	Correct Dispel effect (use magnitude as chance)
This commit is contained in:
		
							parent
							
								
									94d2ec8e4e
								
							
						
					
					
						commit
						596e0c8a49
					
				
					 3 changed files with 12 additions and 5 deletions
				
			
		|  | @ -169,9 +169,16 @@ namespace MWMechanics | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     void ActiveSpells::purgeAll() |     void ActiveSpells::purgeAll(float chance) | ||||||
|     { |     { | ||||||
|         mSpells.clear(); |         for (TContainer::iterator it = mSpells.begin(); it != mSpells.end(); ) | ||||||
|  |         { | ||||||
|  |             int roll = std::rand()/ (static_cast<double> (RAND_MAX) + 1) * 100; // [0, 99]
 | ||||||
|  |             if (roll < chance) | ||||||
|  |                 mSpells.erase(it++); | ||||||
|  |             else | ||||||
|  |                 ++it; | ||||||
|  |         } | ||||||
|         mSpellsChanged = true; |         mSpellsChanged = true; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
|  | @ -82,8 +82,8 @@ namespace MWMechanics | ||||||
|             /// Remove all active effects with this id
 |             /// Remove all active effects with this id
 | ||||||
|             void purgeEffect (short effectId); |             void purgeEffect (short effectId); | ||||||
| 
 | 
 | ||||||
|             /// Remove all active effects
 |             /// Remove all active effects, if roll succeeds (for each effect)
 | ||||||
|             void purgeAll (); |             void purgeAll (float chance); | ||||||
| 
 | 
 | ||||||
|             bool isSpellActive (std::string id) const; |             bool isSpellActive (std::string id) const; | ||||||
|             ///< case insensitive
 |             ///< case insensitive
 | ||||||
|  |  | ||||||
|  | @ -236,7 +236,7 @@ namespace MWMechanics | ||||||
|             else if (effectId == ESM::MagicEffect::CureCorprusDisease) |             else if (effectId == ESM::MagicEffect::CureCorprusDisease) | ||||||
|                 target.getClass().getCreatureStats(target).getSpells().purgeCorprusDisease(); |                 target.getClass().getCreatureStats(target).getSpells().purgeCorprusDisease(); | ||||||
|             else if (effectId == ESM::MagicEffect::Dispel) |             else if (effectId == ESM::MagicEffect::Dispel) | ||||||
|                 target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(); |                 target.getClass().getCreatureStats(target).getActiveSpells().purgeAll(magnitude); | ||||||
|             else if (effectId == ESM::MagicEffect::RemoveCurse) |             else if (effectId == ESM::MagicEffect::RemoveCurse) | ||||||
|                 target.getClass().getCreatureStats(target).getSpells().purgeCurses(); |                 target.getClass().getCreatureStats(target).getSpells().purgeCurses(); | ||||||
| 
 | 
 | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue