1. /*
  2. *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
  3. *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
  4. *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
  5. *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
  6. * www.emudevs.com
  7. */
  8. class npc_gameobject_state : public CreatureScript
  9. {
  10. public:
  11. npc_gameobject_state() : CreatureScript("npc_gameobject_state") { }
  12. struct npc_gameobject_stateAI : public ScriptedAI
  13. {
  14. npc_gameobject_stateAI(Creature* creature) : ScriptedAI(creature) { }
  15. int objectCount;
  16. uint32 spawnObjectTimer;
  17. uint32 activateObjectTimer;
  18. uint32 activateCleanUpTimer;
  19. void Reset()
  20. {
  21. objectCount = 0;
  22. }
  23. void UpdateAI(uint32 diff)
  24. {
  25. if (objectCount == 0)
  26. {
  27. Player* player = me->SelectNearestPlayer(10.0f);
  28. if (!player)
  29. return;
  30. objectCount = 1;
  31. spawnObjectTimer = 1000;
  32. }
  33. if (spawnObjectTimer <= diff)
  34. {
  35. if (objectCount == 1)
  36. {
  37. gameObject = me->SummonGameObject(187669, me->GetPositionX(), me->GetPositionY() + 15, me->GetPositionZ() + 2, me->GetOrientation(), 0, 0, 0, 0, 0);
  38. gameObjectTwo = me->SummonGameObject(187669, me->GetPositionX(), me->GetPositionY() - 15, me->GetPositionZ() + 2, me->GetOrientation(), 0, 0, 0, 0, 0);
  39. SetGoState(gameObject, gameObjectTwo, GO_STATE_READY);
  40. CreatureYell("BEHOLD!", EMOTE_ONESHOT_EXCLAMATION);
  41. activateObjectTimer = 3000;
  42. spawnObjectTimer = 10000;
  43. objectCount = 2;
  44. }
  45. }
  46. else
  47. spawnObjectTimer -= diff;
  48. if (activateObjectTimer <= diff && objectCount == 2)
  49. {
  50. SetGoState(gameObject, gameObjectTwo, GO_STATE_ACTIVE);
  51. objectCount = 3;
  52. activateCleanUpTimer = 5000;
  53. }
  54. else
  55. activateObjectTimer -= diff;
  56. if (activateCleanUpTimer <= diff && objectCount == 3)
  57. {
  58. if (gameObject && gameObject->IsInWorld())
  59. gameObject->Delete();
  60. if (gameObjectTwo && gameObjectTwo->IsInWorld())
  61. gameObjectTwo->Delete();
  62. objectCount = 0;
  63. }
  64. else
  65. activateCleanUpTimer -= diff;
  66. }
  67. void SetGoState(GameObject* gameObject, GameObject* gameObjectTwo, GOState goState)
  68. {
  69. if (!gameObject || !gameObjectTwo)
  70. return;
  71. gameObject->SetGoState(goState);
  72. gameObjectTwo->SetGoState(goState);
  73. }
  74. void CreatureYell(const char* text, uint32 anim_id)
  75. {
  76. me->MonsterYell(text, LANG_UNIVERSAL, 0);
  77. me->HandleEmoteCommand(anim_id);
  78. }
  79. private:
  80. GameObject* gameObject;
  81. GameObject* gameObjectTwo;
  82. };
  83. CreatureAI* GetAI(Creature* creature) const
  84. {
  85. return new npc_gameobject_stateAI(creature);
  86. }
  87. };
  88. void AddSC_go_state()
  89. {
  90. new npc_gameobject_state;
  91. }

EmuDevs - GameObject State Change Trigger