Advertisement
Guest User

script

a guest
Jan 27th, 2014
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 12.24 KB | None | 0 0
  1. #include "scriptPCH.h"
  2. #include "MapManager.h"
  3. #include "Chat.h"
  4. #include "Pet.h"
  5. #include "Config.h"
  6. #include "WorldSession.h"
  7. #include "World.h"
  8.  
  9. /* SQL (Only if you use Rating System) (Characters database)
  10. ALTER TABLE `characters`
  11. ADD COLUMN `duelW` int(10) UNSIGNED NOT NULL DEFAULT '0',
  12. ADD COLUMN `duelL` int(10) UNSIGNED NOT NULL DEFAULT '0',
  13. ADD COLUMN `duelR` int(10) UNSIGNED NOT NULL DEFAULT '1000';
  14. */
  15.  
  16. /* WorldConf (At the end of the file)
  17. # Duel_Reward.Cata_User
  18. # Default: 0 - (Disabled)
  19. # 1 - (Enabled)
  20.  
  21. Duel_Reward.Cata_User = 0
  22.  
  23. # Duel_Reward.Wotlk_User
  24. # Default: 0 - (Disabled)
  25. # 1 - (Enabled)
  26.  
  27. Duel_Reward.Wotlk_User = 0
  28.  
  29. # Duel_Reward.Rating
  30. # Default: 0 - (Disabled)
  31. # 1 - (Enabled)
  32.  
  33. Duel_Reward.Rating = 0
  34.  
  35. # Duel_Reward.Security
  36. # Default: 1 - (Enabled)
  37. # 0 - (Disabled)
  38.  
  39. Duel_Reward.Security = 1
  40.  
  41. # Duel_Phasing.Activation
  42. # Default: 0 - (Disabled)
  43. # 1 - (Enabled)
  44.  
  45. Duel_Phasing.Activation = 0
  46. */
  47.  
  48. /*
  49. Ultimate Duel Script (Reward/Rating/Phasing/Security/Zoned & Reset)
  50. Author : Philippe
  51. Version : V1.3
  52. Release Date : 14/01/14
  53. Script Complete : 100 %
  54. Version : 3.3.5 & 4.3.4
  55. TrinityCore based.
  56. Tested on 4.3.4 Works Well
  57.  
  58. Note :
  59. -Reward Part is explain you need to read.
  60. -For the Rating system please use SQL given. You can add a Top for you're website or create a rating npc.
  61.  
  62. -Phasing system isn't done by me, Credits go to Deathmane1337 (Ac-Web) & Rewrite by Rochet & Tommy (EmuDevs)
  63. Rochet & Tommy (EmuDevs) :
  64. http://emudevs.com/showthread.php/2316-new-phaseing-out-duel-dont-work-100?highlight=duel
  65. http://emudevs.com/showthread.php/2282-phase-out-dueling-error/page2
  66. */
  67.  
  68. // Need both to work.
  69. enum Zone_ID
  70. {
  71. Zone_ID_1 = 12 // Change Zone ID
  72. };
  73.  
  74. enum Area_ID
  75. {
  76. Area_ID_1 = 12 // Change Area ID
  77. };
  78.  
  79. #define Item_Reward_ID 241 // Currency ID For Cata User Or Item ID For Wotlk
  80.  
  81. #define Token_Winner 3 // Reward Count (Winner)
  82. #define Token_loser 1 // Reward Count (Loser)
  83.  
  84.  
  85. // Rating Info Setup Config
  86. void RatingInfo(Player* player)
  87. {
  88. if(sConfigMgr->GetBoolDefault("Duel_Reward.Rating", 1))
  89. {
  90. QueryResult result = CharacterDatabase.PQuery("SELECT duelW,duelL,duelR FROM characters WHERE guid = '%u'", player->GetGUID());
  91. if(!result)
  92. return;
  93.  
  94. Field * fields = NULL;
  95. do
  96. {
  97. fields = result->Fetch();
  98. uint32 duelW = fields[0].GetUInt32();
  99. uint32 duelL = fields[1].GetUInt32();
  100. uint32 duelR = fields[2].GetUInt32();
  101. char msg[250];
  102. snprintf(msg, 250, "[System Information] - [Duel Stats] : |cffFFFF00%u |cFF90EE90Duel win & |cffFFFF00%u |cFF90EE90Duel lose |cffff6060[Rating] : |cffFFFF00%u \n", duelW,duelL,duelR);
  103. ChatHandler(player->GetSession()).PSendSysMessage(msg);
  104. }
  105. while(result->NextRow());
  106. }
  107. }
  108.  
  109. class Duel_Reset : public PlayerScript
  110. {
  111. public:
  112. Duel_Reset() : PlayerScript("Duel_Reset") {}
  113.  
  114. void RevivePlayer(Player* player)
  115. {
  116. player->SetHealth(player->GetMaxHealth());
  117. if(player->getPowerType() == POWER_MANA)
  118. player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA));
  119. if(player->getPowerType() == POWER_ENERGY)
  120. player->SetPower(POWER_ENERGY, player->GetMaxPower(POWER_ENERGY));
  121. }
  122.  
  123. void OnDuelStart(Player *player, Player *plTarget)
  124. {
  125. // Duel Start Reset (Hp/Mana etc)
  126. RevivePlayer(player);
  127. RevivePlayer(plTarget);
  128. player->SetPower(POWER_RAGE, 0);
  129. plTarget->SetPower(POWER_RAGE, 0);
  130. player->SetPower(POWER_RUNIC_POWER, 0);
  131. plTarget->SetPower(POWER_RUNIC_POWER, 0);
  132.  
  133. if(sConfigMgr->GetBoolDefault("Duel_Reward.Rating", 1))
  134. {
  135. // Rating checkup
  136. RatingInfo(player);
  137. RatingInfo(plTarget);
  138. }
  139. }
  140.  
  141. void OnDuelEnd(Player *player, Player * plTarget, DuelCompleteType type)
  142. {
  143. //Removing all Cooldown
  144. player->RemoveAllSpellCooldown();
  145. plTarget->RemoveAllSpellCooldown();
  146. // Duel Reset (Hp/Mana etc)
  147. RevivePlayer(player);
  148. RevivePlayer(plTarget);
  149. // Stopping Combat (Auto Hit/Cast/Range Auto Hit) Break (Useful)
  150. player->CombatStop();
  151. plTarget->CombatStop();
  152.  
  153. player->InterruptSpell(CURRENT_AUTOREPEAT_SPELL); // break Auto Shot and auto hit
  154. plTarget->InterruptSpell(CURRENT_CHANNELED_SPELL); // break channelled spells
  155.  
  156. player->AttackStop();
  157. plTarget->AttackStop();
  158. }
  159.  
  160. };
  161.  
  162. class Duel_Token_Reward : public PlayerScript
  163. {
  164. public:
  165. Duel_Token_Reward() : PlayerScript("Duel_Token_Reward") { }
  166.  
  167. void OnDuelEnd(Player *winner, Player *looser, DuelCompleteType type)
  168. {
  169. //Zone & Area Check Please change value in enum.
  170. if ((winner->GetZoneId() == Zone_ID_1 && looser->GetZoneId() == Zone_ID_1 || winner->GetAreaId() == Area_ID_1 && looser->GetAreaId() == Area_ID_1) && type == DUEL_WON)
  171. {
  172. if(sConfigMgr->GetBoolDefault("Duel_Reward.Security", 1))
  173. {
  174. // Level Check if player is not MaxLevel (80+)
  175. if (winner->getLevel() >= 1 && looser->getLevel() <= 79 && (type == DUEL_WON || type == DUEL_INTERRUPTED || type == DUEL_FLED))
  176. {
  177. return;
  178. }
  179. // Check Latency of both (Not Really needed)
  180. if (looser->GetSession()->GetLatency() > 350 && (type == DUEL_WON || type == DUEL_INTERRUPTED || type == DUEL_FLED))
  181. {
  182. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF !! ALERT !! One of you has a latency superior to 350");
  183. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF !! ALERT !! One of you has a latency superior to 350");
  184. return;
  185. }
  186. // Used if player didn't reach less than 10 life.
  187. if (looser->GetHealth() > 10)
  188. {
  189. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF No one killed the other !");
  190. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF No one killed the other !");
  191. }
  192. // Used For Test Versus GM
  193. if (looser->GetSession()->GetSecurity() >= 2 && (type == DUEL_WON || type == DUEL_INTERRUPTED || type == DUEL_FLED))
  194. {
  195. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF You Can't Claim Reward When you're versus a GameMaster !");
  196. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF You Can't Claim Reward When you're versus a GameMaster !" );
  197. return;
  198. }
  199. if (winner->GetSession()->GetSecurity() >= 2 && (type == DUEL_WON || type == DUEL_INTERRUPTED || type == DUEL_FLED))
  200. {
  201. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF You Can't Claim Reward When you're versus a GameMaster !");
  202. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[System]|cFF00FFFF You Can't Claim Reward When you're versus a GameMaster !");
  203. return;
  204. }
  205. // Used for Cata user if player doesn't have enough gear equipped based on (Stamina/life)
  206. // *Could be adapted for Wotlk Users.
  207. if (looser->GetStat(STAT_STAMINA) < 4000 && type == DUEL_WON)
  208. {
  209. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[Cheating System]|cFF00FFFF The player you are fighting doesn't have enough gear equipped !");
  210. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[Cheating System]|cFF00FFFF you don't have enough gear equipped !");
  211. return;
  212. }
  213. // Used for Local Connections, same IP
  214. if (winner->GetSession()->GetRemoteAddress() == looser->GetSession()->GetRemoteAddress())
  215. {
  216. ChatHandler(winner->GetSession()).SendGlobalGMSysMessage("|cFFFFFC00[Cheating System]|cFF00FFFF A player is trying to cheat in duel Area !");
  217. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[Cheating System]|cFF00FFFF you can't claim reward versus a same ip address !");
  218. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[Cheating System]|cFF00FFFF you can't claim reward versus a same ip address !");
  219. }
  220. }
  221. //If everything is passed then reward will be.
  222. else
  223. {
  224. //To make it work please make sure the worldserver.conf is correctly configurate
  225.  
  226. /*----------------Wotlk Users---------------*/
  227. if(sConfigMgr->GetBoolDefault("Duel_Reward.Wotlk_User", 1))
  228. {
  229. winner->AddItem(Item_Reward_ID, Token_Winner);
  230. looser->AddItem(Item_Reward_ID, Token_loser);
  231. }
  232.  
  233. /*Duel Rating*/
  234. //Duel Ratio, Win/lose
  235. if(sConfigMgr->GetBoolDefault("Duel_Reward.Rating", 1))
  236. {
  237. //Duel Rating, Win/lose (Change Points Manually)
  238. CharacterDatabase.PExecute("UPDATE characters SET duelW = (duelW+1), duelR = (duelR+48) WHERE guid = '%u'", winner->GetGUID());
  239. CharacterDatabase.PExecute("UPDATE characters SET duelL = (duelL+1), duelR = (duelR-12) WHERE guid = '%u'", looser->GetGUID());
  240. //Duel Announcement, Win/lose (Change Points Manually.
  241. ChatHandler(winner->GetSession()).PSendSysMessage("|cFFFFFC00[System Information]|cFF00FFFF Well done, you won!");
  242. ChatHandler(looser->GetSession()).PSendSysMessage("|cFFFFFC00[System Information]|cFF00FFFF You lost!");
  243. }
  244. winner->SaveToDB();
  245. looser->SaveToDB();
  246. }
  247. }
  248. }
  249. };
  250.  
  251. void AddSC_Reset()
  252. {
  253. new Duel_Token_Reward();
  254. new Duel_Reset();
  255. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement