ModuleInventory.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. using CommonAI.ZoneClient;
  2. using pomelo.area;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using ZeusBattleClientBot.Bot;
  9. using pomelo.connector;
  10. using CommonLang.Reflection;
  11. namespace ZeusBotTest.Runner
  12. {
  13. public class ModuleInventory : BotRunner.RunnerModule
  14. {
  15. public ModuleInventory(BotRunner r) : base(r)
  16. {
  17. client.GameSocket.listen<BagNewItemPush>(on_got_new_item);
  18. client.GameSocket.listen<BagNewEquipPush>(on_got_new_equip);
  19. }
  20. protected internal override void OnGateBindPlayer(BindPlayerResponse e)
  21. {
  22. base.OnGateBindPlayer(e);
  23. runner.do_gm_add_diamond(99999999);
  24. runner.do_gm_add_gold(99999999);
  25. }
  26. protected internal override void OnBattleActorReady(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneActor actor)
  27. {
  28. if (Enable)
  29. {
  30. if (bot.CurrentInventories != null)
  31. {
  32. bot.CurrentInventories.Bag.OpenStorage(5,
  33. (e, r) => { runner.log_response("open Bag done : ", e, r); });
  34. bot.CurrentInventories.Warehouse.OpenStorage(5,
  35. (e, r) => { runner.log_response("open Warehouse done : ", e, r); });
  36. }
  37. }
  38. layer.AddTimePeriodicMS(Config.CheckIntervalMS, (t) =>
  39. {
  40. if (Enable)
  41. {
  42. on_do_1s(layer);
  43. }
  44. });
  45. }
  46. private void on_do_1s(ZoneLayer layer)
  47. {
  48. runner.do_start_pick_any_item();
  49. }
  50. private void on_got_new_item(BagNewItemPush e)
  51. {
  52. foreach (var i in e.s2c_data)
  53. {
  54. log.Info("got new item : " + i.name);
  55. }
  56. }
  57. private void on_got_new_equip(BagNewEquipPush e)
  58. {
  59. foreach (var i in e.s2c_data)
  60. {
  61. log.Info("got new equip : " + i);
  62. bot.gs_EquipItemByID(i, (err, rsp) =>
  63. {
  64. runner.log_response("equip new item ", err, rsp);
  65. });
  66. }
  67. }
  68. [Desc("道具配置")]
  69. [Expandable]
  70. public class Config
  71. {
  72. [Desc("检取间隔")]
  73. public static int CheckIntervalMS = 1000;
  74. public override string ToString()
  75. {
  76. return "道具配置";
  77. }
  78. }
  79. }
  80. }