Advertisement
Guest User

UPMod Bug Fixes #4

a guest
Jul 16th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.47 KB | None | 0 0
  1. [ModifiesType]
  2. public class mod_StatusEffect : StatusEffect
  3. {
  4.     [ModifiesMember("ApplyEffect")]
  5.     private bool mod_ApplyEffect(GameObject target, float appliedValue)
  6.     {          
  7.         this.m_restored = true;
  8.         if (this.m_target == null)
  9.         {
  10.             this.m_target = target;
  11.             if (this.m_target != null)
  12.             {
  13.                 this.m_targetStats = this.m_target.GetComponent<CharacterStats>();
  14.             }
  15.         }
  16.         if (!this.Params.CanApply((!(this.AbilityOrigin != null)) ? this.Owner : this.AbilityOrigin.gameObject, target, (!this.IsFromAura) ? this.m_target : this.Owner))
  17.         {
  18.             return false;
  19.         }
  20.         bool flag = this.Params.Apply == StatusEffect.ApplyType.ApplyOverTime || this.Params.Apply == StatusEffect.ApplyType.ApplyAtEnd || this.Params.IntervalRate != StatusEffectParams.IntervalRateType.None;
  21.         if (this.m_applied && !flag && target == this.m_target)
  22.         {
  23.             return false;
  24.         }
  25.         if (this.IsSuppressed)
  26.         {
  27.             return false;
  28.         }
  29.         if (this.m_triggerCount > 0 && this.Params.TriggerAdjustment != null)
  30.         {
  31.             if (this.IsScaledMultiplier)
  32.             {
  33.                 appliedValue *= (float)System.Math.Pow((double)this.Params.TriggerAdjustment.ValueAdjustment, (double)this.m_triggerCount);
  34.             }
  35.             else
  36.             {
  37.                 appliedValue += this.Params.TriggerAdjustment.ValueAdjustment * (float)this.m_triggerCount;
  38.             }
  39.         }
  40.  
  41.         // PATCH START:
  42.         // RELATED BUGS: #4
  43.         // TASK: do not apply TransferDamageToCaster (like TakeTheHit) to non party members
  44.  
  45.         if (this.Params.AffectsStat == StatusEffect.ModifiedStat.TransferDamageToCaster && target != null)
  46.         {
  47.             GameObject animalCompanionMaster = GameUtilities.FindMaster(target);
  48.             bool isPartyMember = PartyHelper.IsPartyMember(target);
  49.             bool isPartyAnimalCompanion = animalCompanionMaster != null && PartyHelper.IsPartyMember(animalCompanionMaster);
  50.  
  51.             if (!isPartyMember && !isPartyAnimalCompanion)
  52.                 return false;
  53.         }
  54.         // PATCH END
  55.  
  56.         if (!this.ApplyEffectHelper(target, appliedValue))
  57.         {
  58.             return false;
  59.         }
  60.         this.m_applied = true;
  61.         if (this.m_target == target)
  62.         {
  63.             this.m_effect_is_on_main_target = true;
  64.         }
  65.         return true;
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement