Advertisement
Rochet2

Untitled

May 14th, 2013
294
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.96 KB | None | 0 0
  1. #include "ScriptPCH.h"
  2.  
  3. std::string names[][4] =
  4. {
  5.     {"", "", "", ""},
  6.     {"Warrior", "Arms", "Fury", "Protection"},
  7.     {"Paladin", "Holy", "Protection", "Retribution"},
  8.     {"Hunter", "Survival", "Marksmanship", "Beast Mastery"},
  9.     {"Rogue", "Combat", "Subtlety", "Assassination"},
  10.     {"Priest", "Holy", "Discipline", "Shadow"},
  11.     {"Death Knight", "", "", ""}, // DK MISSING!!!!
  12.     {"Shaman", "Elemental", "Restoration", "Enhancement"},
  13.     {"Mage", "Fire", "Frost", "Arcane"},
  14.     {"Warlock", "Demonology", "Affliction", "Destruction"},
  15.     {"", "", "", ""},
  16.     {"Druid", "Restoration", "Balance", "Feral"},
  17. };
  18.  
  19. std::string* getNames(uint8 Class)
  20. {
  21.     return Class < MAX_CLASSES ? names[Class] : NULL;
  22. }
  23.  
  24. #define ALL_SPELLCOUNT  81
  25. uint32 const all[ALL_SPELLCOUNT] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,72,73,74,75,78,79,80,81};
  26.  
  27. class TalentSequence : public PlayerScript
  28. {
  29. public:
  30.     std::map<uint8, std::vector<std::list<uint32> > > specs;
  31.     TalentSequence() : PlayerScript("TalentSequence")
  32.     {
  33.         printf("goodsofar\n");
  34.         //      addSpec(CLASS,          SPELLCOUNT, SPELL1, SPELL2...);
  35.         addSpec(CLASS_DRUID,    3, 15363, 15031, 64129);
  36.         addSpec(CLASS_DRUID,    3, 15363, 15031, 64129);
  37.         addSpec(CLASS_DRUID,    3, 15363, 15031, 64129);
  38.         addSpec(CLASS_HUNTER,   3, 15363, 15031, 64129);
  39.         addSpec(CLASS_HUNTER,   3, 15363, 15031, 64129);
  40.         addSpec(CLASS_HUNTER,   3, 15363, 15031, 64129);
  41.         addSpec(CLASS_MAGE,     3, 15363, 15031, 64129);
  42.         addSpec(CLASS_MAGE,     3, 15363, 15031, 64129);
  43.         addSpec(CLASS_MAGE,     3, 15363, 15031, 64129);
  44.         addSpec(CLASS_PALADIN,  3, 15363, 15031, 64129);
  45.         addSpec(CLASS_PALADIN,  3, 15363, 15031, 64129);
  46.         addSpec(CLASS_PALADIN,  3, 15363, 15031, 64129);
  47.         addSpec(CLASS_PRIEST,   3, 15363, 15031, 64129);
  48.         addSpec(CLASS_PRIEST,   3, 15363, 15031, 64129);
  49.         addSpec(CLASS_PRIEST,   3, 15363, 15031, 64129);
  50.         addSpec(CLASS_ROGUE,    3, 15363, 15031, 64129);
  51.         addSpec(CLASS_ROGUE,    3, 15363, 15031, 64129);
  52.         addSpec(CLASS_ROGUE,    3, 15363, 15031, 64129);
  53.         addSpec(CLASS_SHAMAN,   3, 15363, 15031, 64129);
  54.         addSpec(CLASS_SHAMAN,   3, 15363, 15031, 64129);
  55.         addSpec(CLASS_SHAMAN,   3, 15363, 15031, 64129);
  56.         addSpec(CLASS_WARLOCK,  3, 15363, 15031, 64129);
  57.         addSpec(CLASS_WARLOCK,  3, 15363, 15031, 64129);
  58.         addSpec(CLASS_WARLOCK,  3, 15363, 15031, 64129);
  59.         addSpec(CLASS_WARRIOR,  3, 15363, 15031, 64129);
  60.         addSpec(CLASS_WARRIOR,  3, 15363, 15031, 64129);
  61.         addSpec(CLASS_WARRIOR,  3, 15363, 15031, 64129);
  62.     }
  63.  
  64.     void addSpec(uint8 Class, uint32 spellAmount, ...)
  65.     {
  66.         uint32 specID = specs[Class].size();
  67.         specs[Class].push_back(std::list<uint32>());
  68.         va_list spells;
  69.         va_start ( spells, spellAmount );
  70.         for ( uint32 i = 0; i < spellAmount; ++i )
  71.             specs[Class][specID].push_back(va_arg ( spells, uint32 ));
  72.         va_end ( spells );
  73.     }
  74.  
  75.     void OnLogin(Player* player)
  76.     {
  77.         printf("OnLogin\n");
  78.         if(player->GetTotalPlayedTime() < 100)
  79.         {
  80.             printf("OnLogin Success\n");
  81.             player->m_Events.AddEvent(new customEvent(player), player->m_Events.CalculateTime(2000));
  82.         }
  83.     }
  84.  
  85.     void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code)
  86.     {
  87.         printf("OnGossipSelectCode\n");
  88.         player->PlayerTalkClass->ClearMenus();
  89.         if(menu_id != 123 || sender != GOSSIP_SENDER_MAIN || action != GOSSIP_ACTION_INFO_DEF+1) // not our menu
  90.             return; // do nothing
  91.         printf("right menu_id\n");
  92.  
  93.         std::string* names = getNames(player->getClass());
  94.         if(!names || names[0].empty() || names[1].empty() || names[2].empty() || names[3].empty())
  95.             return; // something wrong, stop.
  96.         printf("got names\n");
  97.  
  98.         uint8 spec = 0;
  99.         for(uint8 i = 1; i < 4; ++i)
  100.         {
  101.             if(stricmp(names[i].c_str(), code))
  102.             {
  103.                 spec = i;
  104.                 break;
  105.             }
  106.         }
  107.  
  108.         if(spec)
  109.         {
  110.             printf("got spec, learning\n");
  111.             for (uint32 i = 0; i < ALL_SPELLCOUNT; ++i)
  112.                 player->removeSpell(all[i], false, false);
  113.             for (std::list<uint32>::const_iterator it = specs[player->getClass()][spec].begin(); it != specs[player->getClass()][spec].end(); ++it)
  114.                 player->learnSpell(*it, false);
  115.         }
  116.         player->CLOSE_GOSSIP_MENU();
  117.     }
  118.  
  119.     struct customEvent : public BasicEvent
  120.     {
  121.         customEvent(Player* _player) : player(_player), _event(0) {}
  122.  
  123.         bool Execute(uint64 /*time*/, uint32 /*diff*/)
  124.         {
  125.             switch(_event++)
  126.             {
  127.             case 0:
  128.                 printf("first timed event\n");
  129.                 ChatHandler(player->GetSession()).PSendSysMessage("Welcome, %s", player->GetName().c_str());
  130.                 ChatHandler(player->GetSession()).PSendSysMessage("Please wait whilst the system calculates your class and specialisation options");
  131.                 player->m_Events.AddEvent(this, player->m_Events.CalculateTime(4000)); // delay to next event
  132.                 break;
  133.             case 1:
  134.                 {
  135.                     printf("second timed event\n");
  136.                     std::string* names = getNames(player->getClass());
  137.                     if(!names || names[0].empty() || names[1].empty() || names[2].empty() || names[3].empty())
  138.                         return true; // something wrong, stop.
  139.  
  140.                     ChatHandler(player->GetSession()).PSendSysMessage("%s detected", names[0].c_str());
  141.                     std::ostringstream oss;
  142.                     oss << names[1] << ", " << names[2] << " or " << names[3] << ":";
  143.                     player->PlayerTalkClass->ClearMenus();
  144.                     player->PlayerTalkClass->GetGossipMenu().SetMenuId(123);
  145.                     player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_CHAT, "Please enter the role you wish to play within your class. Click this option and type in your specialisation choice", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF+1, oss.str().c_str(), 0, true);
  146.                     player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, player->GetGUID());
  147.                     player->m_Events.AddEvent(this, player->m_Events.CalculateTime(15000)); // note that the timer can have different time
  148.                 }
  149.                 break;
  150.             default:
  151.                 return true; // no events anymore, destroy the struct
  152.             }
  153.             return false; // dont destory event
  154.         }
  155.  
  156.         Player* player;
  157.         uint32 _event;
  158.     };
  159. };
  160.  
  161. void AddSC_TalentSequence()
  162. {
  163.     new TalentSequence();
  164. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement