Advertisement
EmuDevs

EmuDevs - TrinityCore Talents and Level change PlayerScript

Jul 16th, 2013
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. /*
  2.     EmuDevs
  3.     http://emudevs.com
  4.  
  5.     Tutorial
  6. */
  7.  
  8. class npc_tutorial_playerscript : public PlayerScript
  9. {
  10. public:
  11.     npc_tutorial_playerscript() : PlayerScript("npc_tutorial_playerscript") { }
  12.  
  13.     void OnLevelChanged(Player* player, uint8 oldLevel)
  14.     {
  15.         if (oldLevel == 55)
  16.             player->AddItem(30000, 3);
  17.     }
  18.  
  19.     void OnFreeTalentPointsChanged(Player* player, uint32 points)
  20.     {
  21.         switch (points)
  22.         {
  23.             case 5:
  24.                 Randomize(player);
  25.                 break;
  26.             case 10:
  27.                 Randomize(player);
  28.                 break;
  29.             case 15:
  30.                 Randomize(player);
  31.                 break;
  32.         }
  33.     }
  34.  
  35.     void Randomize(Player* player)
  36.     {
  37.         int rand = urand(0, 2);
  38.         if (rand == 0)
  39.             player->SetFreeTalentPoints(player->GetFreeTalentPoints() + 2);
  40.         else if (rand == 1)
  41.             player->SetFreeTalentPoints(player->GetFreeTalentPoints() + 4);
  42.         else if (rand == 2)
  43.             player->SetFreeTalentPoints(player->GetFreeTalentPoints() + 6);
  44.         player->GetSession()->SendNotification("You received more talent points after spending or receiving them!");
  45.     }
  46. };
  47.  
  48. void AddSC_tutorial_playerscript()
  49. {
  50.     new npc_tutorial_playerscript;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement