PDA

View Full Version : Title NPC in C++



SeGA1964
07-09-08, 08:25 PM
TITLE NPC IN C++



#include "StdAfx.h"
#include "Setup.h"

/************************************ TITLE VENDOR **************************************/

class SCRIPT_DECL Titler : 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 Titler::GossipHello(Object * pObject, Player* Plr, bool AutoSend)
{
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
Menu->AddItem(2, "Get a title", 0);
Menu->AddItem(3, "What requirements do I need to meet for a PVP Title ?", 1);
Menu->SendTo(Plr);
}
void Titler::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code)
{
Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NUL L;
if(pCreature==NULL)
return;

GossipMenu * Menu;
switch(IntId)
{
case 0: //Title
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);

for(int x = 1; x < 28; x++)
{
if(Plr->HasKnownTitle(x))
Plr->RemoveKnownTitle(x);
}

if (Plr->GetTeam() > 0)
{

if (Plr->m_killsLifetime < 50)
{
if(!Plr->HasKnownTitle(15))
Plr->AddKnownTitle(15);
Plr->SetPVPRank(0);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Scout! Please relog for the rank to become visible" );
}

else if (Plr->m_killsLifetime >= 50 && Plr->m_killsLifetime < 100)
{
if(!Plr->HasKnownTitle(16))
Plr->AddKnownTitle(16);
Plr->SetPVPRank(6);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Grunt!" );
}

else if (Plr->m_killsLifetime >= 100 && Plr->m_killsLifetime < 200)
{
if(!Plr->HasKnownTitle(17))
Plr->AddKnownTitle(17);
Plr->SetPVPRank(7);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Sergeant!" );

}

else if (Plr->m_killsLifetime >= 200 && Plr->m_killsLifetime < 400)
{
if(!Plr->HasKnownTitle(18))
Plr->AddKnownTitle(18);
Plr->SetPVPRank(8);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Senior Sergeant!" );
}

else if (Plr->m_killsLifetime >= 400 && Plr->m_killsLifetime < 800)
{
if(!Plr->HasKnownTitle(19))
Plr->AddKnownTitle(19);
Plr->SetPVPRank(9);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to First Sergeant!" );
}

else if (Plr->m_killsLifetime >= 1200 && Plr->m_killsLifetime < 2400)
{
if(!Plr->HasKnownTitle(20))
Plr->AddKnownTitle(20);
Plr->SetPVPRank(10);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Stone Guard!" );
}

else if (Plr->m_killsLifetime >= 2400 && Plr->m_killsLifetime < 4800)
{
if(!Plr->HasKnownTitle(21))
Plr->AddKnownTitle(21);
Plr->SetPVPRank(11);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Blood Guard!" );
}

else if (Plr->m_killsLifetime >= 4800 && Plr->m_killsLifetime < 9000)
{
if(!Plr->HasKnownTitle(22))
Plr->AddKnownTitle(22);
Plr->SetPVPRank(12);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Legionnaire!" );
}

else if (Plr->m_killsLifetime >= 9000 && Plr->m_killsLifetime < 13000)
{
if(!Plr->HasKnownTitle(23))
Plr->AddKnownTitle(23);
Plr->SetPVPRank(13);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Centurion!" );
}

else if (Plr->m_killsLifetime >= 13000 && Plr->m_killsLifetime < 18000)
{
if(!Plr->HasKnownTitle(24))
Plr->AddKnownTitle(24);
Plr->SetPVPRank(14);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Champion!" );
}

else if (Plr->m_killsLifetime >= 18000 && Plr->m_killsLifetime < 20000)
{
if(!Plr->HasKnownTitle(25))
Plr->AddKnownTitle(25);
Plr->SetPVPRank(15);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Lieutenant General!" );
}

else if (Plr->m_killsLifetime >= 20000 && Plr->m_killsLifetime < 24000)
{
if(!Plr->HasKnownTitle(26))
Plr->AddKnownTitle(26);
Plr->SetPVPRank(16);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to General!" );
}

else if (Plr->m_killsLifetime >= 24000 && Plr->m_killsLifetime < 50000)
{
if(!Plr->HasKnownTitle(27))
Plr->AddKnownTitle(27);
Plr->SetPVPRank(17);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Warlord!" );
}

else if (Plr->m_killsLifetime >= 50000)
{
if(!Plr->HasKnownTitle(28))
Plr->AddKnownTitle(28);
Plr->SetPVPRank(18);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to High Warlord!" );
}
Plr->Gossip_Complete();
}

else
{
if (Plr->m_killsLifetime < 50)
{
if(!Plr->HasKnownTitle(1))
Plr->AddKnownTitle(1);
Plr->SetPVPRank(0);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Private! Please relog for the rank to become visible" );
}

else if (Plr->m_killsLifetime >= 50 && Plr->m_killsLifetime < 100)
{
if(!Plr->HasKnownTitle(2))
Plr->AddKnownTitle(2);
Plr->SetPVPRank(6);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Corporal!" );
}

else if (Plr->m_killsLifetime >= 100 && Plr->m_killsLifetime < 200)
{
if(!Plr->HasKnownTitle(3))
Plr->AddKnownTitle(3);
Plr->SetPVPRank(7);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Sergeant!" );
}

else if (Plr->m_killsLifetime >= 200 && Plr->m_killsLifetime < 400)
{
if(!Plr->HasKnownTitle(4))
Plr->AddKnownTitle(4);
Plr->SetPVPRank(8);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Master Sergeant!" );
}

else if (Plr->m_killsLifetime >= 400 && Plr->m_killsLifetime < 800)
{
if(!Plr->HasKnownTitle(5))
Plr->AddKnownTitle(5);
Plr->SetPVPRank(9);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Sergeant Major!" );
}

else if (Plr->m_killsLifetime >= 1200 && Plr->m_killsLifetime < 2400)
{
if(!Plr->HasKnownTitle(6))
Plr->AddKnownTitle(6);
Plr->SetPVPRank(10);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Knight!" );
}

else if (Plr->m_killsLifetime >= 2400 && Plr->m_killsLifetime < 4800)
{
if(!Plr->HasKnownTitle(7))
Plr->AddKnownTitle(7);
Plr->SetPVPRank(11);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Knight Lieutenant!" );
}

else if (Plr->m_killsLifetime >= 4800 && Plr->m_killsLifetime < 9000)
{
if(!Plr->HasKnownTitle(8))
Plr->AddKnownTitle(8);
Plr->SetPVPRank(12);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Knight Captain!" );
}

else if (Plr->m_killsLifetime >= 9000 && Plr->m_killsLifetime < 13000)
{
if(!Plr->HasKnownTitle(9))
Plr->AddKnownTitle(9);
Plr->SetPVPRank(13);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Knight Champion!" );
}

else if (Plr->m_killsLifetime >= 13000 && Plr->m_killsLifetime < 18000)
{
if(!Plr->HasKnownTitle(10))
Plr->AddKnownTitle(10);
Plr->SetPVPRank(14);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Lieutenant Commander!" );
}

else if (Plr->m_killsLifetime >= 18000 && Plr->m_killsLifetime < 20000)
{
if(!Plr->HasKnownTitle(11))
Plr->AddKnownTitle(11);
Plr->SetPVPRank(15);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Commander!" );
}

else if (Plr->m_killsLifetime >= 20000 && Plr->m_killsLifetime < 24000)
{
if(!Plr->HasKnownTitle(12))
Plr->AddKnownTitle(12);
Plr->SetPVPRank(16);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Marshal!" );
}

else if (Plr->m_killsLifetime >= 24000 && Plr->m_killsLifetime < 50000)
{
if(!Plr->HasKnownTitle(13))
Plr->AddKnownTitle(13);
Plr->SetPVPRank(17);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Field Marshal!" );
}

else if (Plr->m_killsLifetime >= 50000)
{
if(!Plr->HasKnownTitle(14))
Plr->AddKnownTitle(14);
Plr->SetPVPRank(18);
pCreature->SendChatMessage(CHAT_MSG_MONSTER_SAY, LANG_UNIVERSAL, "Your rank has been set to Grand Marshal!" );
}
Plr->Gossip_Complete();
}
break;

case 1:
GossipMenu *Menu;
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
if (Plr->GetTeam() > 0)
{
Menu->AddItem(18, "Scout- 0 Kills", 0);
Menu->AddItem(19, "Grunt - 50 Kills", 0);
Menu->AddItem(20, "Sergeant - 100 Kills", 0);
Menu->AddItem(21, "Senior Sergeant - 200 Kills", 0);
Menu->AddItem(22, "First Sergeant - 400 Kills", 0);
Menu->AddItem(23, "Stone Guard - 1200 Kills", 0);
Menu->AddItem(24, "Blood Guard - 2400 Kills", 0);
Menu->AddItem(25, "Legionnaire - 4800 Kills", 0);
Menu->AddItem(26, "Centurion - 9000 Kills", 0);
Menu->AddItem(32, "Show more ranks", 32);
}
else
{
Menu->AddItem(4, "Private - 0 Kills", 0);
Menu->AddItem(5, "Corporal - 50 Kills", 0);
Menu->AddItem(6, "Sergeant - 100 Kills", 0);
Menu->AddItem(7, "Master Sergeant - 200 Kills", 0);
Menu->AddItem(8, "Sergeant Major - 400 Kills", 0);
Menu->AddItem(9, "Knight - 1200 Kills", 0);
Menu->AddItem(10, "Knight Lieutenant - 2400 Kills", 0);
Menu->AddItem(11, "Knight Captain - 4800 Kills", 0);
Menu->AddItem(12, "Knight Champion - 9000 Kills", 0);
Menu->AddItem(33, "Show more ranks", 33);
}
Menu->SendTo(Plr);
break;

case 32:
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
Menu->AddItem(27, "Champion - 13000 Kills", 0);
Menu->AddItem(28, "Lieutenant General - 18000 Kills", 0);
Menu->AddItem(29, "General - 20000 Kills", 0);
Menu->AddItem(30, "Warlord - 24000 Kills", 0);
Menu->AddItem(31, "High Warlord - 50000 Kills", 0);
Menu->AddItem(3, "What requirements do I need to meet for a PVP Title ?", 1);
Menu->SendTo(Plr);
break;

case 33:
objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr);
Menu->AddItem(13, "Lieutenant Commander - 13000 Kills", 0);
Menu->AddItem(14, "Commander - 18000 Kills", 0);
Menu->AddItem(15, "Marshal - 20000 Kills", 0);
Menu->AddItem(16, "Field Marshal - 24000 Kills", 0);
Menu->AddItem(17, "Grand Marshal - 50000 Kills", 0);
Menu->AddItem(3, "What requirements do I need to meet for a PVP Title ?", 1);
Menu->SendTo(Plr);
break;
}
}

void Titler::GossipEnd(Object * pObject, Player* Plr)
{
GossipScript::GossipEnd(pObject, Plr);
}

void SetupTitler(ScriptMgr * mgr)
{
GossipScript * gs = (GossipScript*) new Titler();
mgr->register_gossip_script(30090, gs);
}

SETUP.CPP


#include "StdAfx.h"
#include "Setup.h"

#include <ScriptSetup.h>

extern "C" SCRIPT_DECL uint32 _exp_get_script_type()
{
return SCRIPT_TYPE_MISC;
}

extern "C" SCRIPT_DECL void _exp_script_register(ScriptMgr* mgr)
{
SetupTitler(mgr);
}

#ifdef WIN32

BOOL APIENTRY DllMain( HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
{
return TRUE;
}

#endif


SETUP.H


#ifndef INSTANCE_SCRIPTS_SETUP_H
#define INSTANCE_SCRIPTS_SETUP_H

void SetupTitler(ScriptMgr * mgr);
;

#endifThanks to Scyther for the Help.

No pics ATM

StickyIcky
07-09-08, 08:59 PM
An NPC?

Why not just make it so it will automatically update...?

+rep tho

SeGA1964
07-09-08, 09:02 PM
Becuase the more Npcs the leet your server iz :D

StickyIcky
07-09-08, 09:06 PM
Lol i'm working on one that will auto update...

If i can base it off yours...i'll give credits of course

SeGA1964
07-09-08, 09:12 PM
and morez +Rep?

Apple
07-09-08, 09:13 PM
lol s00n i am going to update the rules for +rep =P , anyway gj + rep

SeGA1964
07-09-08, 09:15 PM
what about them?

Edit:Can i get emu expert now? lol

StickyIcky
07-09-08, 09:16 PM
Yea i'll rep again once i can

SeGA1964
07-09-08, 09:20 PM
Wig could u unblock me from msn...

Crux
08-09-08, 12:18 AM
This is pretty good, but shouldnt it already give you this one you get X number of kills?
Edit: cannot give rep.. Need to spread...

Booty
05-01-10, 12:53 PM
Hey, as the title say: Do this work for mangos?

-Booty