Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *╔═╦═╦═╦╦╦══╦═╦╗─╔╦══╗
- *║╦╣║║║║║╠╗╗║╦╣╚╦╝║══╣
- *║╩╣║║║║║╠╩╝║╩╬╗║╔╬══║
- *╚═╩╩═╩╩═╩══╩═╝╚═╝╚══╝
- * www.emudevs.com
- */
- class npc_gameobject_state : public CreatureScript
- {
- public:
- npc_gameobject_state() : CreatureScript("npc_gameobject_state") { }
- struct npc_gameobject_stateAI : public ScriptedAI
- {
- npc_gameobject_stateAI(Creature* creature) : ScriptedAI(creature) { }
- int objectCount;
- uint32 spawnObjectTimer;
- uint32 activateObjectTimer;
- uint32 activateCleanUpTimer;
- void Reset()
- {
- objectCount = 0;
- }
- void UpdateAI(uint32 diff)
- {
- if (objectCount == 0)
- {
- Player* player = me->SelectNearestPlayer(10.0f);
- if (!player)
- return;
- objectCount = 1;
- spawnObjectTimer = 1000;
- }
- if (spawnObjectTimer <= diff)
- {
- if (objectCount == 1)
- {
- gameObject = me->SummonGameObject(187669, me->GetPositionX(), me->GetPositionY() + 15, me->GetPositionZ() + 2, me->GetOrientation(), 0, 0, 0, 0, 0);
- gameObjectTwo = me->SummonGameObject(187669, me->GetPositionX(), me->GetPositionY() - 15, me->GetPositionZ() + 2, me->GetOrientation(), 0, 0, 0, 0, 0);
- SetGoState(gameObject, gameObjectTwo, GO_STATE_READY);
- CreatureYell("BEHOLD!", EMOTE_ONESHOT_EXCLAMATION);
- activateObjectTimer = 3000;
- spawnObjectTimer = 10000;
- objectCount = 2;
- }
- }
- else
- spawnObjectTimer -= diff;
- if (activateObjectTimer <= diff && objectCount == 2)
- {
- SetGoState(gameObject, gameObjectTwo, GO_STATE_ACTIVE);
- objectCount = 3;
- activateCleanUpTimer = 5000;
- }
- else
- activateObjectTimer -= diff;
- if (activateCleanUpTimer <= diff && objectCount == 3)
- {
- if (gameObject && gameObject->IsInWorld())
- gameObject->Delete();
- if (gameObjectTwo && gameObjectTwo->IsInWorld())
- gameObjectTwo->Delete();
- objectCount = 0;
- }
- else
- activateCleanUpTimer -= diff;
- }
- void SetGoState(GameObject* gameObject, GameObject* gameObjectTwo, GOState goState)
- {
- if (!gameObject || !gameObjectTwo)
- return;
- gameObject->SetGoState(goState);
- gameObjectTwo->SetGoState(goState);
- }
- void CreatureYell(const char* text, uint32 anim_id)
- {
- me->MonsterYell(text, LANG_UNIVERSAL, 0);
- me->HandleEmoteCommand(anim_id);
- }
- private:
- GameObject* gameObject;
- GameObject* gameObjectTwo;
- };
- CreatureAI* GetAI(Creature* creature) const
- {
- return new npc_gameobject_stateAI(creature);
- }
- };
- void AddSC_go_state()
- {
- new npc_gameobject_state;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement