• Visit Rebornbuddy
  • GameManager.Inventory.Bags.Items List never updates

    Discussion in 'Wildbuddy Developers' started by Wirlo, Oct 30, 2015.

    1. Wirlo

      Wirlo New Member

      Joined:
      Jun 4, 2015
      Messages:
      37
      Likes Received:
      0
      Trophy Points:
      0
      [Solved] GameManager.Inventory.Bags.Items List never updates

      Code:
      Buddy.Wildstar.Game.GameManager.Inventory.Bags.Items
      Buddy.Wildstar.Game.GameManager.Inventory.Equipped.Items
      
      List always reflects the items in inventories when the bot was initialized.
      Update never happens.
      Neither will the items properies update; such as when moved to
      a diffrent inventory

      Code:
      ContainedIn.Items.Count()
      Index
      
      will show the values of when the bot was initialized.
      No new items will be shown,
      Nor destroyed items leave.

      Only thing i found to update is to restart the bot.
      i tried:
      waiting 30min
      switching map-zone (load screen)
       
      Last edited: Oct 30, 2015
    2. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      This is not true at all. AutoEquip relies on the inventory being updated when the UpdateInventory Lua event is fired. Please show me your code, I have a feeling you're just not doing something properly.
       
    3. Wirlo

      Wirlo New Member

      Joined:
      Jun 4, 2015
      Messages:
      37
      Likes Received:
      0
      Trophy Points:
      0
      The bot has been started when i hit the hotkey
      i tried:
      Code:
      GameManager.ForceUpdate();
      
      Code:
      class ... : IBot, IUIButtonProvider
          {
              public string Author { get { return "..."; } }
              public string Name { get { return "..."; } }
              public string Version { get { return "..."; } }
              private bool _pulseMe = false;
              public void OnRegistered() { }
              public void OnUnregistered() { }
      
              public void OnInitialize()
              {
                  [B]Buddy.Common.Hotkeys.Register("q", System.Windows.Forms.Keys.Q, Buddy.Common.ModifierKeys.Alt, Btn);[/B]
                  _pulseMe = false;
                  Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
              }
              public void OnUninitialize(){_pulseMe = false;}
      
              public void OnStart()
              {
                  _pulseMe = true;
                  GameEngine.BotPulsator.RegisterForPulse(GameManager.Lua.Events);
                  GameEngine.BotPulsator.RegisterForPulse(GameEngine.CurrentRoutine);
                  SpellManager.SetSpellCastingBehavior(SpellCastingBehavior.HoldToContinue);
              }
              public void OnStop()
              {
                  _pulseMe = false;
                  if (GameEngine.CurrentRoutine != null)
                  {
                      GameEngine.BotPulsator.UnregisterForPulse(GameEngine.CurrentRoutine);
                  }
                  GameEngine.BotPulsator.UnregisterForPulse(GameManager.Lua.Events);
              }
      
              [B]public void Btn(Hotkey key)[/B]
              {
                  if (key.ModifierKeys == Buddy.Common.ModifierKeys.Alt)
                  {
                      switch (key.Name)
                      {
                          case "q":
                              [B]DumpItems();[/B]
                              break;
                      }
                  }
              }
      
              [B]private void DumpItems()
              {
                  foreach (var i in Buddy.Wildstar.Game.GameManager.Inventory.Bags.Items)
                  {
                      Log(i.Name + " dur(" + i.MaxDurability + ")  stack(" + i.StackCount + ")   sell(" + i.SellPrice + "/" + i.SellPriceTotalStack + ")  slot(" + i.EquipSlot + ")  type(" + i.Info.TypeName + ")  catn(" + i.Info.CategoryName + ")");
      
                      Log("#Stats");
                      foreach (var s in i.Stats)
                          Log(s.Property.ToString() + " " + s.Value);
                      Log("#Explicit");
                      foreach (var s in i.ExplicitStats)
                          Log(s.Property.ToString() + " " + s.Value);
                      Log("#Implicit");
                      foreach (var s in i.Info.ImplicitStats)
                          Log(s.Property.ToString() + " " + s.Value);
                      Log("");
                  }
              }[/B]
      
              public bool CanBePulsed { get { return true; } }
              public bool Equals(IBot other) { return true; }
              public void Pulse() { }
              public string ButtonText { get { return "..."; } }
              public void OnButtonClicked(object sender) { }
      
          }
      
      EDIT:
      Your right, if i trace it from a plugin(with profile bot base), it works..
      i dont understand

      EDIT2:
      Extending the Profilebot also works.

      i guess i can do some workaround,
      i have stumbled upon a similar update issue.
      there is something happening inside ProfileBot, that im clearly not doing

      EDIT3:
      it also works from within the Pulse() method from my botbase
      hold on i test more

      EDIT4:
      well i narrowed it down to beeing an issue with btn delegate
      i guess internally it cant use dynamic objects in delegates ?
      im not using c# for long

      my bad :p
       
      Last edited: Oct 30, 2015
    4. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      GreyMagic (the memory library we use) caches memory reads until they are cleared. This is per-thread.

      You'll need to do

      Code:
      GameManager.Memory.ClearCache()
      In your button handler before you pull anything from memory.
       

    Share This Page