Advertisement
Rochet2

Dominent

Mar 25th, 2013
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.18 KB | None | 0 0
  1. const uint32 questionsTotal = 4; // Amount of questions asked from player
  2. const uint32 questionOptions = 2; // Amount of question options in each question
  3.  
  4. class npc_nkunchev : public CreatureScript
  5. {
  6. public:
  7.     npc_nkunchev() : CreatureScript("npc_nkunchev") { }
  8.  
  9.     bool OnGossipHello(Player * player, Creature * creature)
  10.     {
  11.         player->ADD_GOSSIP_ITEM(0, "I want to play the game!", 0, 0);
  12.         player->ADD_GOSSIP_ITEM(0, "No thank you. Bye.", 0, 1);
  13.         player->PlayerTalkClass->SendGossipMenu(9425, creature->GetGUID());
  14.         return true;
  15.     }
  16.  
  17.     bool OnGossipSelect(Player * player, Creature * creature, uint32 question, uint32 answer)
  18.     {
  19.         player->PlayerTalkClass->ClearMenus();
  20.  
  21.         if(!question && action) // is main menu option (bye)
  22.         {
  23.             player->CLOSE_GOSSIP_MENU();
  24.             return true;
  25.         }
  26.        
  27.         if(answer != 1) // player answered the question
  28.         {
  29.             if(answer) // Answer was not right (right is 0)
  30.             {
  31.                 // failed a question (question tells you which one)
  32.                 // do something ..
  33.                 player->CLOSE_GOSSIP_MENU();
  34.                 return true;
  35.             }
  36.            
  37.             // Answer was right
  38.            
  39.             if(question > (questionsTotal-1)*questionOptions && question <= questionsTotal*questionOptions)
  40.             {
  41.                 // Player won the game
  42.                 // reward
  43.                 player->CLOSE_GOSSIP_MENU();
  44.                 return true;
  45.             }
  46.            
  47.             // Get a new random question from next category
  48.             for (uint32 i = 0; true; ++i)
  49.             {
  50.                 if (question <= questionOptions*i)
  51.                 {
  52.                     question = urand(questionOptions*i+1, questionOptions*i+questionOptions);
  53.                     break;
  54.                 }
  55.             }
  56.         }
  57.        
  58.         answer = 0;
  59.         switch (question)
  60.         {
  61.         case 1:
  62.             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.
  63.             player->ADD_GOSSIP_ITEM(0, "Blood Elf, Undead, Warlock, Orc, Troll", question, ++answer);
  64.             player->ADD_GOSSIP_ITEM(0, "Blood Elf, Undead, Tauren, Orc, Troll", question, 0); // correct is 0
  65.             player->ADD_GOSSIP_ITEM(0, "Human, Human, Human , Gnome", question, ++answer);
  66.             player->ADD_GOSSIP_ITEM(0, "Troll, Goblin, Hot Dogs", question, ++answer);
  67.             player->PlayerTalkClass->SendGossipMenu(9425, creature->GetGUID());
  68.             break;
  69.         case 2:
  70.             // show menu to player.
  71.  
  72.             // Use the same model as above. Correct question is still 0.
  73.             break;
  74.         case 3:
  75.             // show menu to player.
  76.  
  77.             // Use the same model as above. Correct question is still 0.
  78.             break;
  79.         case 4:
  80.             // show menu to player.
  81.  
  82.             // Use the same model as above. Correct question is still 0.
  83.             break;
  84.         default:
  85.             player->CLOSE_GOSSIP_MENU();
  86.             break;
  87.         }
  88.     }
  89. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement