Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const uint32 questionsTotal = 4; // Amount of questions asked from player
- const uint32 questionOptions = 2; // Amount of question options in each question
- class npc_nkunchev : public CreatureScript
- {
- public:
- npc_nkunchev() : CreatureScript("npc_nkunchev") { }
- bool OnGossipHello(Player * player, Creature * creature)
- {
- player->ADD_GOSSIP_ITEM(0, "I want to play the game!", 0, 0);
- player->ADD_GOSSIP_ITEM(0, "No thank you. Bye.", 0, 1);
- player->PlayerTalkClass->SendGossipMenu(9425, creature->GetGUID());
- return true;
- }
- bool OnGossipSelect(Player * player, Creature * creature, uint32 question, uint32 answer)
- {
- player->PlayerTalkClass->ClearMenus();
- if(!question && action) // is main menu option (bye)
- {
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- if(answer != 1) // player answered the question
- {
- if(answer) // Answer was not right (right is 0)
- {
- // failed a question (question tells you which one)
- // do something ..
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- // Answer was right
- if(question > (questionsTotal-1)*questionOptions && question <= questionsTotal*questionOptions)
- {
- // Player won the game
- // reward
- player->CLOSE_GOSSIP_MENU();
- return true;
- }
- // Get a new random question from next category
- for (uint32 i = 0; true; ++i)
- {
- if (question <= questionOptions*i)
- {
- question = urand(questionOptions*i+1, questionOptions*i+questionOptions);
- break;
- }
- }
- }
- answer = 0;
- switch (question)
- {
- case 1:
- player->ADD_GOSSIP_ITEM(0, "What are the races for horde?", question, ++answer); // answer is 1 on the question. That allows the question to show up again.
- player->ADD_GOSSIP_ITEM(0, "Blood Elf, Undead, Warlock, Orc, Troll", question, ++answer);
- player->ADD_GOSSIP_ITEM(0, "Blood Elf, Undead, Tauren, Orc, Troll", question, 0); // correct is 0
- player->ADD_GOSSIP_ITEM(0, "Human, Human, Human , Gnome", question, ++answer);
- player->ADD_GOSSIP_ITEM(0, "Troll, Goblin, Hot Dogs", question, ++answer);
- player->PlayerTalkClass->SendGossipMenu(9425, creature->GetGUID());
- break;
- case 2:
- // show menu to player.
- // Use the same model as above. Correct question is still 0.
- break;
- case 3:
- // show menu to player.
- // Use the same model as above. Correct question is still 0.
- break;
- case 4:
- // show menu to player.
- // Use the same model as above. Correct question is still 0.
- break;
- default:
- player->CLOSE_GOSSIP_MENU();
- break;
- }
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement