Code:
/*
* Sex Change Kit
* Copyright (C) 2008 Spidey <http://www.aspiredev.org/>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "StdAfx.h"
#include "Setup.h"
#define KITID 90008
class SCRIPT_DECL sexchange : public GossipScript
{
public:
void GossipHello(Object * pObject, Player* Plr, bool AutoSend);
void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code);
void GossipEnd(Object * pObject, Player* Plr);
void Destroy()
{
delete this;
}
};
void sexchange::GossipHello(Object* pObject, Player * Plr, bool AutoSend)
{
GossipMenu * Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 0, Plr);
Menu->AddItem(0, "Apply the kit", 1);
Menu->AddItem(1, "Leave it for another time", 2);
if(AutoSend)
Menu->SendTo(Plr);
};
void sexchange::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
GossipMenu * Menu;
switch(IntId)
{
case 0:
{
GossipHello(pObject, Plr, true);
}break;
case 1:
{
Plr->setGender(Plr->getGender() ? 0 : 1);
Plr->GetItemInterface()->RemoveItemAmt(KITID, 1);
Plr->BroadcastMessage("Log out to complete the kit's instructions");
Plr->Gossip_Complete();
}break;
case 2:
{
Plr->Gossip_Complete();
}break;
}
};
void sexchange::GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
}
void Setupsexchange(ScriptMgr * mgr)
{
GossipScript * gs = (GossipScript*) new sexchange();
mgr->register_item_gossip_script(KITID, gs);
}