#include "ScriptPCH.h"#include "ScriptMgr.h"#include "GameObject.h"#include "LootMgr.h"class despawn_script : public GameObjectScript{ public: despawn_script() : GameObjectScript("despawn_script") { } bool OnLootStateChanged(GameObject* go, LootState* state, Player* player) { if (go->getLootState() == GO_JUST_DEACTIVATED) { go->SetRespawnTime(0); go->Delete(); go->DeleteFromDB(); } return true; } };void AddSC_despawn_script(){ new despawn_script();}
#include "GameObject.h"#include "LootMgr.h"#include "ScriptPCH.h"#include "ScriptMgr.h"class despawn_script : public GameObjectScript{ public: despawn_script() : GameObjectScript("despawn_script") { } bool OnLootStateChanged(GameObject* go, LootState* state, Player* player) { if (go->getLootState() == GO_JUST_DEACTIVATED && go->GetGoType() == 3) { go->SetRespawnTime(0); go->Delete(); go->DeleteFromDB(); } return true; } };void AddSC_despawn_script(){ new despawn_script();}
States go in order:GO_ACTIVATED - You open loot table and take itemsO_JUST_DEACTIVATED - The loot table is closed and object come invisibleGO_NOT_READY - GameObject waits for respawn, is invisible (not for GM)GO_READY - Gameobject waits for looter...
#include "ScriptPCH.h"#include "ScriptMgr.h"#include "GameObject.h"#include "LootMgr.h"class despawn_script : public GameObjectScript{ public: despawn_script() : GameObjectScript("despawn_script") { } void OnLootStateChanged(GameObject* go, uint32 state, Unit* player) { switch (go->getLootState()) { case GO_NOT_READY: { sLog->outString("GO_NOT_READY"); break; } case GO_READY: { sLog->outString("GO_READY"); break; } case GO_ACTIVATED: { sLog->outString("GO_ACTIVATED"); break; } case GO_JUST_DEACTIVATED: { sLog->outString("GO_JUST_DEACTIVATED"); } } } };void AddSC_despawn_script(){ new despawn_script();}