Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- struct HonorGossip
- {
- uint8 icon;
- std::string name;
- uint32 HK, titleID;
- };
- // {icon, "title name", honored_kills, titleID}
- HonorGossip Titles [] =
- {
- {9, "Private", 1, 1 },
- {9, "Corporal", 100, 2 },
- {9, "Sergeant", 250, 3 },
- {9, "Master Sergeant", 500, 4 },
- {9, "Sergeant Major", 750, 5 },
- {9, "Knight", 1000, 6 },
- {9, "Knight-Lieutenant", 1500, 7 },
- {9, "Knight-Captain", 2000, 8 },
- {9, "Knight-Champion", 2500, 9 },
- {9, "Lieutenant Commander", 3000, 10 },
- {9, "Commander", 3500, 11 },
- {9, "Marshal", 4000, 12 },
- {9, "Field Marshal", 4500, 13 },
- {9, "Grand Marshal", 5000, 14 },
- {9, "Scout", 1, 15 },
- {9, "Grunt", 100, 16 },
- {9, "Sergeant", 250, 17 },
- {9, "Senior Sergeant", 500, 18 },
- {9, "First Sergeant", 750, 19 },
- {9, "Stone Guard", 1000, 20 },
- {9, "Blood Guard", 1500, 21 },
- {9, "Legionnaire", 2000, 22 },
- {9, "Centurion", 2500, 23 },
- {9, "Champion", 3000, 24 },
- {9, "Lieutenant General", 3500, 25 },
- {9, "General", 4000, 26 },
- {9, "Warlord", 4500, 27 },
- {9, "High Warlord", 5000, 28 },
- };
- static const uint32 TITLES_SIZE = (sizeof(Titles) / sizeof(*Titles)); // NOTE, this was wrong. it was uint32 instead of *Titles or HonorGossip in the sizeof.
- class npc_honor_gossip : public CreatureScript
- {
- public:
- npc_honor_gossip() : CreatureScript("npc_honor_gossip") { }
- bool OnGossipHello(Player* player, Creature* creature)
- {
- player->ADD_GOSSIP_ITEM(0, "|TInterface\\icons\\INV_Misc_QuestionMark:30|tHow does this npc work?|r", GOSSIP_SENDER_MAIN, 100);
- player->ADD_GOSSIP_ITEM(4, "|TInterface\\icons\\Achievement_PVP_H_15:30|tHonorable Kills Titles|r", GOSSIP_SENDER_MAIN, 101);
- player->ADD_GOSSIP_ITEM(7, "|TInterface\\icons\\Ability_Spy:30|tNevermind|r", GOSSIP_SENDER_MAIN, 102);
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player* player, Creature* creature, uint32 /* sender */, uint32 actions)
- {
- player->PlayerTalkClass->ClearMenus();
- if (actions == 100)
- {
- ChatHandler(player->GetSession()).SendSysMessage("|cffff6060[Information]:|r This npc show you 2 different options,Honorable Kills Titles costed on LifeTime Kills,Devium WoW Titles show you our own titles |cffff0000[Patch Required]|r,and costed on [Devium Title Token].");
- OnGossipHello(player, creature);
- }
- else if(actions == 101)
- {
- if (player->GetTeamId() == ALLIANCE)
- for (int i = 0; i < TITLES_SIZE/2; ++i)
- player->ADD_GOSSIP_ITEM(Titles[i].icon, Titles[i].name.c_str(), GOSSIP_SENDER_MAIN, i);
- else
- for (int i = TITLES_SIZE/2; i < TITLES_SIZE; ++i)
- player->ADD_GOSSIP_ITEM(Titles[i].icon, Titles[i].name.c_str(), GOSSIP_SENDER_MAIN, i);
- player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "<- Back", GOSSIP_SENDER_MAIN, 999);
- player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
- }
- else if (actions == 102)
- player->CLOSE_GOSSIP_MENU();
- else if (actions == 999) // NOTE main menu, no need to write the options twice, use the function like this.
- OnGossipHello(player, creature);
- else if (actions < TITLES_SIZE) // must check so we wont accidently go overboard
- {
- if (player->HasTitle(Titles[actions].titleID))
- player->GetSession()->SendNotification("You already have this title!");
- else if (player->GetUInt32Value(PLAYER_FIELD_LIFETIME_HONORABLE_KILLS) < Titles[actions].HK)
- player->GetSession()->SendNotification("You don't have enough kills!");
- else if (CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(Titles[actions].titleID))
- {
- player->SetTitle(titleEntry);
- player->GetSession()->SendAreaTriggerMessage("Title granted!");
- }
- OnGossipHello(player, creature);
- }
- return true; // NOTE always return true, unless you want to send the default gossip menu from DB
- }
- };
- void AddSC_honor_gossip()
- {
- new npc_honor_gossip;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement