bot_testspamuseractions.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. class BotTestSpamUserActions_Start : BotTimedWait
  2. {
  3. override void OnEntry (BotEventBase e)
  4. {
  5. super.OnEntry(e);
  6. }
  7. override void OnExit (BotEventBase e)
  8. {
  9. botDebugPrint("[bot] + " + m_Owner + "BotTestSpamUserActions_Start::OnExit");
  10. /*if (GetGame().IsServer() && GetGame().IsMultiplayer())
  11. {
  12. botDebugPrint("[bot] + " + m_Owner + "BotTestSpamUserActions_Start spamming!");
  13. for (int i = 0; i < 10000; ++i)
  14. Print("Lovely SPAAAAAM!");
  15. }*/
  16. super.OnExit(e);
  17. }
  18. }
  19. class BotTestSpamUserActions_GetEntityFromSlot : BotTimedWait
  20. {
  21. EntityAI m_Entity = null;
  22. bool m_Run = false;
  23. int m_RunStage = 0;
  24. ref InventoryLocation m_Src = new InventoryLocation;
  25. override void OnEntry (BotEventBase e)
  26. {
  27. m_Entity = m_Owner.GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("Legs"));
  28. botDebugPrint("[bot] + " + m_Owner + "BotTestSpamUserActions_GetEntityFromSlot item=" + m_Entity);
  29. GameInventory.SetGroundPosByOwner(m_Owner, m_Entity, m_Src);
  30. /*if (!m_Entity.GetInventory().GetCurrentInventoryLocation(m_Src))
  31. {
  32. Error("NI!");
  33. }*/
  34. if (!GetGame().IsDedicatedServer())
  35. {
  36. m_Entity = m_Owner.GetInventory().FindAttachment(InventorySlots.GetSlotIdFromString("Legs"));
  37. m_Owner.PredictiveDropEntity(m_Entity);
  38. }
  39. super.OnEntry(e);
  40. }
  41. override void OnExit (BotEventBase e)
  42. {
  43. m_Entity = null;
  44. super.OnExit(e);
  45. }
  46. override void OnUpdate (float dt)
  47. {
  48. super.OnUpdate(dt);
  49. if (!GetGame().IsDedicatedServer())
  50. {
  51. if (m_Run && m_Entity)
  52. {
  53. switch (m_RunStage)
  54. {
  55. case 0:
  56. botDebugPrint("[bot] + " + m_Owner + " STS = " + m_Owner.GetSimulationTimeStamp() + " Stage=" + m_RunStage + " item=" + m_Entity);
  57. ScriptInputUserData ctx = new ScriptInputUserData;
  58. HandEventTake e = new HandEventTake(m_Owner, m_Src);
  59. InventoryInputUserData.SerializeHandEvent(ctx, e);
  60. ctx.Send();
  61. break;
  62. case 1:
  63. botDebugPrint("[bot] + " + m_Owner + " STS = " + m_Owner.GetSimulationTimeStamp() + " Stage=" + m_RunStage + " item=" + m_Entity);
  64. ScriptInputUserData ctx1 = new ScriptInputUserData;
  65. HandEventTake e1 = new HandEventTake(m_Owner, m_Src);
  66. InventoryInputUserData.SerializeHandEvent(ctx1, e1);
  67. ctx1.Send();
  68. break;
  69. case 5:
  70. botDebugPrint("[bot] + " + m_Owner + " STS = " + m_Owner.GetSimulationTimeStamp() + " Stage=" + m_RunStage + " item=" + m_Entity);
  71. ScriptInputUserData ctx2 = new ScriptInputUserData;
  72. InventoryLocation dst = new InventoryLocation;
  73. dst.SetAttachment(m_Owner, m_Entity, InventorySlots.GetSlotIdFromString("Legs"));
  74. InventoryInputUserData.SerializeMove(ctx2, InventoryCommandType.SYNC_MOVE, m_Src, dst);
  75. ctx2.Send();
  76. break;
  77. case 10:
  78. botDebugPrint("[bot] + " + m_Owner + " STS = " + m_Owner.GetSimulationTimeStamp() + " Stage=" + m_RunStage + " item=" + m_Entity);
  79. ScriptInputUserData ctx3 = new ScriptInputUserData;
  80. InventoryLocation dst2 = new InventoryLocation;
  81. dst2.SetAttachment(m_Owner, m_Entity, InventorySlots.GetSlotIdFromString("Legs"));
  82. InventoryInputUserData.SerializeMove(ctx3, InventoryCommandType.SYNC_MOVE, m_Src, dst2);
  83. ctx3.Send();
  84. break;
  85. /*
  86. case 0:
  87. botDebugPrint("[bot] + " + m_Owner + "Stage0 item=" + m_Entity);
  88. m_Owner.PredictiveTakeEntityToHands(m_Entity);
  89. break;
  90. case 1:
  91. botDebugPrint("[bot] + " + m_Owner + "Stage1 item=" + m_Entity);
  92. m_Owner.PredictiveTakeEntityToHands(m_Entity);
  93. break;
  94. case 2:
  95. botDebugPrint("[bot] + " + m_Owner + "Stage2 item=" + m_Entity);
  96. m_Owner.PredictiveTakeEntityAsAttachmentEx(m_Entity, InventorySlots.GetSlotIdFromString("Legs"));
  97. break;
  98. case 3:
  99. botDebugPrint("[bot] + " + m_Owner + "Stage3 item=" + m_Entity);
  100. m_Owner.PredictiveTakeEntityAsAttachmentEx(m_Entity, InventorySlots.GetSlotIdFromString("Legs"));
  101. break;*/
  102. }
  103. ++m_RunStage;
  104. }
  105. }
  106. }
  107. override void OnTimeout ()
  108. {
  109. super.OnTimeout();
  110. botDebugPrint("[bot] + " + m_Owner + "BotTestSpamUserActions_GetEntityFromSlot item=" + m_Entity);
  111. if (m_Entity && m_Run == false)
  112. {
  113. m_Run = true;
  114. m_RunStage = 0;
  115. }
  116. }
  117. }
  118. class BotTestSpamUserActions : BotStateBase
  119. {
  120. EntityAI m_Entity;
  121. ref BotTestSpamUserActions_Start m_Start;
  122. ref BotTestSpamUserActions_GetEntityFromSlot m_GetRef;
  123. //ref BotTimedWait m_Wait;
  124. void BotTestSpamUserActions (Bot bot = NULL, BotStateBase parent = NULL)
  125. {
  126. // setup nested state machine
  127. m_FSM = new BotFSM(this); // @NOTE: set owner of the submachine fsm
  128. m_Start = new BotTestSpamUserActions_Start(m_Bot, this, 1.0);
  129. m_GetRef = new BotTestSpamUserActions_GetEntityFromSlot(m_Bot, this, 2.0);
  130. // events
  131. BotEventBase __EntWait__ = new BotEventWaitTimeout;
  132. // transitions
  133. m_FSM.AddTransition(new BotTransition( m_Start, __EntWait__, m_GetRef));
  134. m_FSM.SetInitialState(m_Start);
  135. }
  136. override void OnEntry (BotEventBase e)
  137. {
  138. m_Entity = null;
  139. if (GetGame().IsServer())
  140. {
  141. m_Owner.GetInventory().CreateAttachment("PolicePantsOrel"); // no assign to m_Entity
  142. botDebugPrint("[bot] + " + m_Owner + " created attachment item=" + m_Entity);
  143. }
  144. super.OnEntry(e);
  145. }
  146. override void OnExit (BotEventBase e)
  147. {
  148. m_Entity = null;
  149. super.OnExit(e);
  150. }
  151. override void OnUpdate (float dt)
  152. {
  153. super.OnUpdate(dt);
  154. }
  155. }