Advertisement
Guest User

UPMod Bug Fixes #5

a guest
Jul 16th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.14 KB | None | 0 0
  1. [ModifiesType]
  2. public class mod_StatusEffect : StatusEffect
  3. {
  4.     [ModifiesMember("UpdateHelper")]
  5.     private void mod_UpdateHelper(float seconds)
  6.     {
  7.         if (this.m_target == null)
  8.         {
  9.             return;
  10.         }
  11.         if (this.IsSuspended)
  12.         {
  13.             return;
  14.         }
  15.         if (this.m_intervalTimer > 0f)
  16.         {
  17.             float num = seconds;
  18.             CharacterStats characterStats = this.m_targetStats;
  19.             if (this.IsFromAura)
  20.             {
  21.                 characterStats = this.m_ownerStats;
  22.             }
  23.             if (characterStats != null)
  24.             {
  25.                 if (this.IsDOT)
  26.                 {
  27.                     num *= characterStats.DOTTickMult;
  28.                 }
  29.                 if (this.IsNegativeMovementEffect)
  30.                 {
  31.                     num *= characterStats.NegMoveTickMult;
  32.                 }
  33.                 if (this.IsPoisonEffect)
  34.                 {
  35.                     num *= characterStats.PoisonTickMult;
  36.                 }
  37.                 if (this.IsDiseaseEffect)
  38.                 {
  39.                     num *= characterStats.DiseaseTickMult;
  40.                 }
  41.             }
  42.             this.m_intervalTimer -= num;
  43.         }
  44.         this.m_timeActive += seconds;
  45.         if (!this.m_suppressed && (this.m_applied || this.IsAura))
  46.         {
  47.             this.UpdateActiveEffect(seconds);
  48.         }
  49.         if (this.Duration > 0f && this.m_timeActive > this.Duration && this.DurationAfterBreak <= 0f)
  50.         {
  51.             this.UpdateFinalTick();
  52.             this.ClearEffect(this.m_target);
  53.         }
  54.         else if (this.m_cachedTeam != null && this.m_targetStats != null)
  55.         {
  56.             this.m_swapTeamTimer -= seconds;
  57.             if (this.m_swapTeamTimer <= 0f)
  58.             {
  59.                 this.m_swapTeamTimer = StatusEffect.SwapTeamTimerMax;
  60.                 AIController aIController = GameUtilities.FindActiveAIController(this.m_target);
  61.  
  62.                 // ORIGINAL:
  63.                 //if (aIController != null && aIController.CurrentTarget == null && !aIController.IsConfused)
  64.                 //{
  65.                 //    if (this.AfflictionOrigin != null)
  66.                 //    {
  67.                 //        this.m_targetStats.ClearEffectFromAffliction(this.AfflictionOrigin);
  68.                 //    }
  69.                 //    else
  70.                 //    {
  71.                 //        this.ClearEffect(this.m_target);
  72.                 //    }
  73.                 //}
  74.  
  75.                 // PATCH START:
  76.                 // RELATED BUGS: #5a, #5b
  77.                 // TASK: fix charm and dominate effects ending prematurely
  78.                 if (aIController != null && aIController.CurrentTarget == null && !aIController.IsConfused)
  79.                 {
  80.                     bool isPartyMember = PartyHelper.IsPartyMember(this.m_target);
  81.                     float range = System.Math.Max(aIController.PerceptionDistance, 15);
  82.                     List<GameObject> enemies = new List<GameObject>();                        
  83.                     GameUtilities.GetEnemiesInRange(this.m_target, aIController, range, enemies);
  84.  
  85.                     if (enemies.Count <= 0)
  86.                     {
  87.                         //  Last enemy will no longer break charm and dominate effects immediately. These effects will last at least 5s
  88.                         if (isPartyMember || this.m_timeActive >= 5) // clear team swap effect
  89.                         {
  90.                             if (this.AfflictionOrigin != null)
  91.                             {
  92.                                 this.m_targetStats.ClearEffectFromAffliction(this.AfflictionOrigin);
  93.                             }
  94.                             else
  95.                             {
  96.                                 this.ClearEffect(this.m_target);
  97.                             }
  98.  
  99.                             if (!isPartyMember)
  100.                               global::Console.AddMessage(this.m_targetStats.DisplayName.GetText() + " has broken free!"); // TODO: localize the string
  101.                         }
  102.                     }  
  103.                 }
  104.                 // PATCH END
  105.             }
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement