ArenMook

Remove invalid item stats

Dec 29th, 2015
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.20 KB | None | 0 0
  1. int count = 0;
  2. DataNode eq = MyPlayer.equipment;
  3.  
  4. for (int i = 0; i < eq.children.size; ++i)
  5. {
  6.     PlayerItem item = eq.children[i].Get<PlayerItem>();
  7.  
  8.     if (item != null)
  9.     {
  10.         int off = item.GetStat(GameTools.specOffense);
  11.         int sup = item.GetStat(GameTools.specSupport);
  12.         int def = item.GetStat(GameTools.specDefense);
  13.  
  14.         if (off + sup + def != 0 ||
  15.             Mathf.Abs(off) > 1 ||
  16.             Mathf.Abs(sup) > 1 ||
  17.             Mathf.Abs(def) > 1)
  18.         {
  19.             item.SetStat(GameTools.specOffense, 0);
  20.             item.SetStat(GameTools.specSupport, 0);
  21.             item.SetStat(GameTools.specDefense, 0);
  22.             MyPlayer.syncNeeded = true;
  23.             MyPlayer.saveNeeded = true;
  24.             ++count;
  25.         }
  26.         else if (item.quest != null && item.quest.value is TNet.List<PlayerItem>)
  27.         {
  28.             TNet.List<PlayerItem> items = item.quest.Get<TNet.List<PlayerItem>>();
  29.  
  30.             foreach (PlayerItem pi in items)
  31.             {
  32.                 off = pi.GetStat(GameTools.specOffense);
  33.                 sup = pi.GetStat(GameTools.specSupport);
  34.                 def = pi.GetStat(GameTools.specDefense);
  35.  
  36.                 if (off + sup + def != 0 ||
  37.                     Mathf.Abs(off) > 1 ||
  38.                     Mathf.Abs(sup) > 1 ||
  39.                     Mathf.Abs(def) > 1)
  40.                 {
  41.                     pi.SetStat(GameTools.specOffense, 0);
  42.                     pi.SetStat(GameTools.specSupport, 0);
  43.                     pi.SetStat(GameTools.specDefense, 0);
  44.                     MyPlayer.syncNeeded = true;
  45.                     MyPlayer.saveNeeded = true;
  46.                     ++count;
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }
  52.  
  53. eq = MyPlayer.inventory;
  54.  
  55. for (int i = 0; i < eq.children.size; ++i)
  56. {
  57.     PlayerItem item = eq.children[i].Get<PlayerItem>();
  58.  
  59.     if (item != null)
  60.     {
  61.         int off = item.GetStat(GameTools.specOffense);
  62.         int sup = item.GetStat(GameTools.specSupport);
  63.         int def = item.GetStat(GameTools.specDefense);
  64.  
  65.         if (off + sup + def != 0 ||
  66.             Mathf.Abs(off) > 1 ||
  67.             Mathf.Abs(sup) > 1 ||
  68.             Mathf.Abs(def) > 1)
  69.         {
  70.             item.SetStat(GameTools.specOffense, 0);
  71.             item.SetStat(GameTools.specSupport, 0);
  72.             item.SetStat(GameTools.specDefense, 0);
  73.             MyPlayer.syncNeeded = true;
  74.             MyPlayer.saveNeeded = true;
  75.             ++count;
  76.         }
  77.         else if (item.quest != null && item.quest.value is TNet.List<PlayerItem>)
  78.         {
  79.             TNet.List<PlayerItem> items = item.quest.Get<TNet.List<PlayerItem>>();
  80.  
  81.             foreach (PlayerItem pi in items)
  82.             {
  83.                 off = pi.GetStat(GameTools.specOffense);
  84.                 sup = pi.GetStat(GameTools.specSupport);
  85.                 def = pi.GetStat(GameTools.specDefense);
  86.  
  87.                 if (off + sup + def != 0 ||
  88.                     Mathf.Abs(off) > 1 ||
  89.                     Mathf.Abs(sup) > 1 ||
  90.                     Mathf.Abs(def) > 1)
  91.                 {
  92.                     pi.SetStat(GameTools.specOffense, 0);
  93.                     pi.SetStat(GameTools.specSupport, 0);
  94.                     pi.SetStat(GameTools.specDefense, 0);
  95.                     MyPlayer.syncNeeded = true;
  96.                     MyPlayer.saveNeeded = true;
  97.                     ++count;
  98.                 }
  99.             }
  100.         }
  101.     }
  102. }
  103.  
  104. eq = MyPlayer.vault;
  105.  
  106. for (int i = 0; i < eq.children.size; ++i)
  107. {
  108.     DataNode n = eq.children[i];
  109.  
  110.     if (n.value is PlayerItem)
  111.     {
  112.         PlayerItem item = n.Get<PlayerItem>();
  113.  
  114.         if (item != null)
  115.         {
  116.             int off = item.GetStat(GameTools.specOffense);
  117.             int sup = item.GetStat(GameTools.specSupport);
  118.             int def = item.GetStat(GameTools.specDefense);
  119.  
  120.             if (off + sup + def != 0 ||
  121.                 Mathf.Abs(off) > 1 ||
  122.                 Mathf.Abs(sup) > 1 ||
  123.                 Mathf.Abs(def) > 1)
  124.             {
  125.                 item.SetStat(GameTools.specOffense, 0);
  126.                 item.SetStat(GameTools.specSupport, 0);
  127.                 item.SetStat(GameTools.specDefense, 0);
  128.                 MyPlayer.syncNeeded = true;
  129.                 MyPlayer.saveNeeded = true;
  130.                 ++count;
  131.             }
  132.             else if (item.quest != null && item.quest.value is TNet.List<PlayerItem>)
  133.             {
  134.                 TNet.List<PlayerItem> items = item.quest.Get<TNet.List<PlayerItem>>();
  135.  
  136.                 foreach (PlayerItem pi in items)
  137.                 {
  138.                     off = pi.GetStat(GameTools.specOffense);
  139.                     sup = pi.GetStat(GameTools.specSupport);
  140.                     def = pi.GetStat(GameTools.specDefense);
  141.  
  142.                     if (off + sup + def != 0 ||
  143.                         Mathf.Abs(off) > 1 ||
  144.                         Mathf.Abs(sup) > 1 ||
  145.                         Mathf.Abs(def) > 1)
  146.                     {
  147.                         pi.SetStat(GameTools.specOffense, 0);
  148.                         pi.SetStat(GameTools.specSupport, 0);
  149.                         pi.SetStat(GameTools.specDefense, 0);
  150.                         MyPlayer.syncNeeded = true;
  151.                         MyPlayer.saveNeeded = true;
  152.                         ++count;
  153.                     }
  154.                 }
  155.             }
  156.         }
  157.     }
  158. }
  159.  
  160. if (count != 0)
  161. {
  162.     GameChat.SendPM("Aren Mook", "Invalid items: " + count);
  163.     UIGameChat.AddCurrent("Found " + count + " non-legit items. Fixing...", Color.red);
  164. }
Advertisement
Add Comment
Please, Sign In to add comment