Last active
May 9, 2019 11:31
-
-
Save callmephil/9692037 to your computer and use it in GitHub Desktop.
[V1.4] Ultimate Duel Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ultimate Duel Script (Reward/Rating/Security/Zoned & Reset) | |
Author : Philippe | |
Version : V1.4 (Full Rewrite) | |
Release Date : 21/03/14 | |
Script Complete : 80 % | |
Version : 3.3.5 & 4.3.4 | |
TrinityCore based. | |
Tested and Works Well. | |
Phasing System is in rewrite state. (V1.5) | |
Note : | |
For setup, Please follow instruction in readme.txt file. | |
or on thoses thread | |
AC-Web : http://www.ac-web.org/forums/showthread.php?195691-Ultimate-Duel-Script | |
Emudevs : http://emudevs.com/showthread.php/2390-Wotlk-Cata-Ultimate-Duel-Script | |
*/ | |
#include "Ultimate_Duel_Script.h" | |
class Ultimate_Duel_Script : public PlayerScript | |
{ | |
public: | |
Ultimate_Duel_Script() : PlayerScript("Ultimate_Duel_Script") {} | |
void OnDuelStart(Player* player, Player* playerTarget) | |
{ | |
// Resewing HP/MANA-ENERGY/ | |
RevivePlayerStart(player); | |
RevivePlayerStart(playerTarget); | |
// Check if rated system is active & check if they are in the good area | |
if(isActivated(player,playerTarget)) | |
{ | |
RatingInfo(player); | |
RatingInfo(playerTarget); | |
} | |
} | |
void OnDuelEnd(Player* player, Player* playerTarget, DuelCompleteType type) | |
{ | |
// Resewing HP/MANA-ENERGY/COOLDOWN | |
RevivePlayerEnd(player); | |
RevivePlayerEnd(playerTarget); | |
// Check if rated system is active & check if they are in the good area | |
if(isActivated(player,playerTarget)) | |
{ // Checking if player is trying to auto-farm | |
if(isSecurityActive(player,playerTarget) && (type == DUEL_WON || type == DUEL_INTERRUPTED || type == DUEL_FLED)) | |
{ return; } // Do not remove | |
Update_Stats(player,playerTarget); | |
} | |
// Check again if Security is active for Token Reward (It's need to be checked another time if user don't want to use rated system) | |
if(isSecurityActive(player,playerTarget) && (type == DUEL_WON || type == DUEL_INTERRUPTED || type == DUEL_FLED)) | |
{ return; } // Do not remove | |
Reward_Token(player,playerTarget); | |
} | |
}; | |
void AddSC_Ultimate_Duel_Script() | |
{ | |
new Ultimate_Duel_Script(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "Pet.h" | |
#include "Config.h" | |
enum Misc | |
{ | |
// Player Level Check | |
MIN_LEVEL_REQ = 80, | |
// Token Reward Default Setup || Can be change by using config | |
TOKEN_LOSER = 1, // Default | |
TOKEN_WINNER = 3, // Default | |
ITEMORCURRENCY_REWARD_ID = 0, // Default | |
// Minimum Gear Stats REQ | |
#if GEAR_STAMINA_REQ == 1 | |
GEAR_STAMINA_REQ = 4000, | |
#else // WotLK | |
GEAR_STAMINA_REQ = 1750, | |
#endif | |
}; | |
bool isAreaValide(Player* player) | |
{ | |
// Maps Check (Only for Rating system) || Can be NULL please make sure to configure | |
uint32 ZONE_1 = sConfigMgr->GetIntDefault("Rated_Duel.Zone_1", NULL); uint32 AREA_1 = sConfigMgr->GetIntDefault("Rated_Duel.Area_1", NULL); | |
uint32 ZONE_2 = sConfigMgr->GetIntDefault("Rated_Duel.Zone_2", NULL); uint32 AREA_2 = sConfigMgr->GetIntDefault("Rated_Duel.Area_2", NULL); | |
uint32 ZONE_3 = sConfigMgr->GetIntDefault("Rated_Duel.Zone_3", NULL); uint32 AREA_3 = sConfigMgr->GetIntDefault("Rated_Duel.Area_3", NULL); | |
uint32 ZONE_4 = sConfigMgr->GetIntDefault("Rated_Duel.Zone_4", NULL); uint32 AREA_4 = sConfigMgr->GetIntDefault("Rated_Duel.Area_4", NULL); | |
if ((player->GetZoneId() == ZONE_1 || player->GetZoneId() == ZONE_2 || player->GetZoneId() == ZONE_3 || player->GetZoneId() == ZONE_4) | |
|| (player->GetAreaId() == AREA_1 || player->GetAreaId() == AREA_2 || player->GetAreaId() == AREA_3 || player->GetAreaId() == AREA_4)) | |
{ return true; } // boolean need to return to a value | |
return false; // boolean need to return to a value | |
} | |
bool isActivated(Player* player,Player* playerTarget) | |
{ | |
uint32 isActivated = sConfigMgr->GetIntDefault("Duel_Reward.Rating", 1); | |
if(isActivated && (isAreaValide(player) && isAreaValide(playerTarget))) | |
{ return true; } // boolean need to return to a value | |
return false; // boolean need to return to a value | |
} | |
// Rating Info || Config Setup | |
void RatingInfo(Player* player) | |
{ | |
QueryResult result = CharacterDatabase.PQuery("SELECT duelW,duelL,duelR FROM characters WHERE guid = '%u'", player->GetGUIDLow()); | |
if(!result) | |
return; | |
Field * fields = result->Fetch(); | |
uint32 duelW = fields[0].GetUInt32(); | |
uint32 duelL = fields[1].GetUInt32(); | |
uint32 duelR = fields[2].GetUInt32(); | |
ChatHandler(player->GetSession()).PSendSysMessage("[System Information] - [Duel Stats] : |cffFFFF00%u |cFF90EE90Duel win & |cffFFFF00%u |cFF90EE90Duel lose |cffff6060[Rating] : |cffFFFF00%u \n", duelW,duelL,duelR); | |
} | |
// Resewing Health & Mana || Energy at start. | |
void RevivePlayerStart(Player* player) | |
{ | |
player->SetHealth(player->GetMaxHealth()); | |
if(player->getPowerType() == POWER_MANA) | |
player->SetPower(POWER_MANA, player->GetMaxPower(POWER_MANA)); | |
if(player->getPowerType() == POWER_ENERGY) | |
player->SetPower(POWER_ENERGY, player->GetMaxPower(POWER_ENERGY)); | |
} | |
// Resewing Health & Mana || Energy, Cooldown & stopcombat at End of the duel. | |
void RevivePlayerEnd(Player* player) | |
{ | |
RevivePlayerStart(player); | |
player->CombatStop(); | |
player->RemoveAllSpellCooldown(); | |
} | |
// Check if player is cheating | |
bool isSecurityActive(Player* player, Player* playerTarget) | |
{ | |
if(sConfigMgr->GetIntDefault("Duel_Reward.Security", 1)) | |
{ | |
if (player->getLevel() != MIN_LEVEL_REQ || playerTarget->getLevel() != MIN_LEVEL_REQ) { | |
std::ostringstream ss; | |
ss << "|cFFFFFC00[Information System]|r : |cFF00FFFF You or Your Opponent Need to be both level " << MIN_LEVEL_REQ << " to be eligible for a rated duel|r \n"; | |
ChatHandler(player->GetSession()).SendSysMessage(ss.str().c_str()); | |
ChatHandler(playerTarget->GetSession()).SendSysMessage(ss.str().c_str()); | |
return true; } | |
if (player->GetHealth() > 10 || playerTarget->GetStat(STAT_STAMINA) < GEAR_STAMINA_REQ) { | |
std::ostringstream ss; | |
ss << "|cFFFFFC00[Information System]|r : |cFF00FFFF You or Your Opponent has surrender or does not have enough gear to be eligible for a rated duel|r \n"; | |
ChatHandler(player->GetSession()).SendSysMessage(ss.str().c_str()); | |
ChatHandler(playerTarget->GetSession()).SendSysMessage(ss.str().c_str()); | |
return true; } | |
if (player->GetSession()->GetSecurity() != 1 || playerTarget->GetSession()->GetSecurity() != 1) { | |
std::ostringstream ss; | |
ss << "|cFFFFFC00[Information System]|r : |cFF00FFFF Can't be rewarded if the fight is versus a GameMaster |r \n"; | |
ChatHandler(player->GetSession()).SendSysMessage(ss.str().c_str()); | |
ChatHandler(playerTarget->GetSession()).SendSysMessage(ss.str().c_str()); | |
return true; } | |
if (player->GetSession()->GetRemoteAddress() == playerTarget->GetSession()->GetRemoteAddress()) { | |
std::ostringstream ss; | |
ss << "|cFFFFFC00[Information System]|r : |cFF00FFFF The Multi-Housing is not eligible for awards. |r \n"; | |
ChatHandler(player->GetSession()).SendSysMessage(ss.str().c_str()); | |
ChatHandler(playerTarget->GetSession()).SendSysMessage(ss.str().c_str()); } | |
} | |
return false; | |
} | |
// Stats Updater Winner/Loser | |
void Update_Stats(Player* player, Player* playerTarget) | |
{ | |
// Winner | |
CharacterDatabase.PExecute("UPDATE characters SET duelW = (duelW+1) WHERE guid = '%u'", player->GetGUIDLow()); | |
CharacterDatabase.PExecute("UPDATE characters SET duelR = (duelR+14) WHERE guid = '%u'", player->GetGUIDLow()); | |
ChatHandler(player->GetSession()).SendSysMessage("|cFFFFFC00[System]|cFF00FFFF Well done you won 14 Points !"); | |
// Loser | |
CharacterDatabase.PExecute("UPDATE characters SET duelL = (duelL+1) WHERE guid = '%u'", playerTarget->GetGUIDLow()); | |
CharacterDatabase.PExecute("UPDATE characters SET duelR = (duelR-7) WHERE guid = '%u'", playerTarget->GetGUIDLow()); | |
ChatHandler(playerTarget->GetSession()).SendSysMessage("|cFFFFFC00[System]|cFF00FFFF Ow you lose 7 Points !"); | |
} | |
void Reward_Token(Player* player, Player* playerTarget) | |
{ | |
if(sConfigMgr->GetIntDefault("Duel_Reward.isEnable", 1)) { | |
#if REWARD_CATA == 1 | |
player->ModifyCurrency(sConfigMgr->GetIntDefault("Duel_Reward.ItemOrCurrencyID", ITEMORCURRENCY_REWARD_ID), sConfigMgr->GetIntDefault("Duel_Reward.ItemCount_Winner", TOKEN_WINNER), true, true); | |
playerTarget->ModifyCurrency(sConfigMgr->GetIntDefault("Duel_Reward.ItemOrCurrencyID", ITEMORCURRENCY_REWARD_ID), sConfigMgr->GetIntDefault("Duel_Reward.ItemCount_loser", TOKEN_LOSER), true, true); | |
#else // WotLK | |
player->AddItem(sConfigMgr->GetIntDefault("Duel_Reward.ItemOrCurrencyID", ITEMORCURRENCY_REWARD_ID), sConfigMgr->GetIntDefault("Duel_Reward.ItemCount_Winner", TOKEN_WINNER)); | |
playerTarget->AddItem(sConfigMgr->GetIntDefault("Duel_Reward.ItemOrCurrencyID", ITEMORCURRENCY_REWARD_ID), sConfigMgr->GetIntDefault("Duel_Reward.ItemCount_loser", TOKEN_LOSER)); | |
#endif | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################################################################################################### | |
# CONFIGURE TO ACTIVATE RATED DUEL # | |
#################################### | |
# Duel_Reward.Rating | |
# Default: 0 - (Disabled) | |
# 1 - (Enabled) | |
Duel_Reward.Rating = 0 | |
################################## | |
# SECURITY (IN CASE OF CHEATERS) # | |
################################## | |
# Duel_Reward.Security | |
# Default: 1 - (Enabled) | |
# 0 - (Disabled) | |
Duel_Reward.Security = 1 | |
################################## | |
# ITEM AWARD CONFIGURATIONS # | |
################################## | |
# Duel_Reward.isEnable || Activate Item or Currency Reward if rated system is active | |
# Default: 0 - (Disabled) | |
# 1 - (Enabled) | |
# | |
Duel_Reward.isEnable = 0 | |
# Duel_Reward.ItemOrCurrencyID || Define ID for Item or Currency | |
# Default: 0 - (Disabled) | |
# Enabled: (Wotlk) - ItemID, Exemple : 40752 | |
# (Cata) - CurrencyID, Exemple : 241 | |
Duel_Reward.ItemOrCurrencyID = 0 | |
# Duel_Reward.ItemCount || Define how much token will be rewarded | |
# default : ItemCount_Winner = 3 | |
# ItemCount_loser = 1 | |
# | |
Duel_Reward.ItemCount_Winner = 3 | |
Duel_Reward.ItemCount_loser = 1 | |
################################################################################################### | |
# SELECT ZONE & AREA ID FOR YOUR RATED DUEL ZONE | |
######################## ZONE CHECK | |
# Rated_Duel.Zone | |
# Default: NULL - (Disabled) | |
# ZONEID - (Enabled) (Exemple 1) use .gps ingame to know zone. | |
Rated_Duel.Zone_1 = NULL | |
Rated_Duel.Zone_2 = NULL | |
Rated_Duel.Zone_3 = NULL | |
Rated_Duel.Zone_4 = NULL | |
######################## AREA CHECK | |
# Rated_Duel.Area | |
# Default: NULL - (Disabled) | |
# AREAID - (Enabled) (Exemple 5) use .gps ingame to know area. | |
Rated_Duel.Area_1 = NULL | |
Rated_Duel.Area_2 = NULL | |
Rated_Duel.Area_3 = NULL | |
Rated_Duel.Area_4 = NULL | |
############################################################################## |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Ultimate Duel Script (Reward/Rating/Security/Zoned & Reset) | |
Author : Philippe | |
Version : V1.4 (Full Rewrite) | |
Release Date : 21/03/14 | |
Script Complete : 80 % | |
Version : 3.3.5 & 4.3.4 | |
TrinityCore based. | |
Special Thanks for Tommy. | |
http://emudevs.com/showthread.php/2881-looking-for-help-Learning-Purposes | |
*/ | |
/* SQL (Only if you use Rating System) (Characters database) | |
ALTER TABLE `characters` | |
ADD COLUMN `duelW` INT(10) UNSIGNED NOT NULL DEFAULT '0', | |
ADD COLUMN `duelL` INT(10) UNSIGNED NOT NULL DEFAULT '0', | |
ADD COLUMN `duelR` INT(10) UNSIGNED NOT NULL DEFAULT '1000'; | |
*/ | |
How to setup : | |
--------- [WORLD CONFIG] --------- | |
Please make sure you have paste correctly the world config. | |
2 - [SECURITY] : | |
Security are checking if the player is cheating with another one, reward are unallowed if player does not have all condition. | |
Condition One : If player does not have the good level default : 80 | |
Condition Two : If player has left | surrender or if he's not enough geared (Average is done by Stamina stats) | |
Condition Three : If player is fighting a Gamemaster, it will consider it like testing. | |
Condition Three : If player are using the same internet connexion. | |
Note * You can Activate or Desactive by using config | |
3 - [ITEM REWARD SYSTEM] | |
Reward system is a simple Item reward when player win/lose a duel. it's working for Cata(Currency) & Wotlk(ItemID) | |
You can activate and modify ItemID Or CurrencyID and modify the number of reward with config. | |
4 - [RATING SYSTEM] (2.0 Will have a better Distribution System) | |
(if you activate this system) ***BE SURE TO ADD SQL OR YOUR SERVER WILL CRASH*** | |
Point Distribution : | |
Start With : 1000 | |
Winner +14 : Duel Won+1 | |
Loser - 7 : Duel Lose+1 | |
*You can activate or desactivate this option by using config. | |
5 - [AREA SYSTEM] | |
Area system is here to define where you would like to place you're Rated Duel Area. | |
You can Choose 4 Area AND 4 Zones. | |
if you don't want to configurate AREA or ZONES just let NULL | |
To setup AREA/ZONE CHECKING please make sure to know what's the id of thoses by using the command .GPS ingame, | |
In Your WorldConf REPLACE One of the 4 : NULL by the valor you want for exemple Elwyn is 12. So NULL will be 12. | |
if you want to do express change without re-compiling or restarting server use the command .reload conf | |
YOU'RE DONE ! | |
#hashtag #happyno? | |
keep in mind this is not the final version and if you have any suggestion please contact me here. | |
AC-Web : http://www.ac-web.org/forums/showthread.php?195691-Ultimate-Duel-Script | |
Emudevs : http://emudevs.com/showthread.php/2390-Wotlk-Cata-Ultimate-Duel-Script |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment