Edit config/script

Players can now enable or disable each feature with config.
This commit is contained in:
Lee
2017-05-26 01:42:50 +01:00
committed by GitHub
3 changed files with 190 additions and 124 deletions

View File

@@ -5,7 +5,41 @@
# Description: Enable PremiumAccount for players # Description: Enable PremiumAccount for players
# Default: 1 - (Enabled) # Default: 1 - (Enabled)
# 0 - (Disabled) # 0 - (Disabled)
PremiumAccount = 1 PremiumAccount = 1
# Morph
# Description: Enable Morph & demorph option for players
# Default: 1 - (Enabled)
# 0 - (Disabled)
Morph = 1
# Bank
# Description: Allow Players to use mobile bank
# Default: 1 - (Enabled)
# 0 - (Disabled)
Bank = 1
# Auction
# Description: Allow Players to use mobile Auction
# Default: 1 - (Enabled)
# 0 - (Disabled)
Auction = 1
# Mount
# Description: Allow Players to use mount
# Default: 1 - (Enabled)
# 0 - (Disabled)
Mount = 1
# Vendor
# Description: Allow Players to use vendor
# Default: 1 - (Enabled)
# 0 - (Disabled)
Vendor = 1
# Mail Box
# Description: Allow Players Access ingame Mail
# Default: 1 - (Enabled)
# 0 - (Disabled)
MailBox = 1

View File

@@ -1,3 +1,5 @@
void AddSC_premium_account();
void AddPremiumScripts() { void AddPremiumScripts() {
AddSC_premium_account(); AddSC_premium_account();
} }

View File

@@ -5,145 +5,175 @@
#include "ScriptedGossip.h" #include "ScriptedGossip.h"
#include "ScriptMgr.h" #include "ScriptMgr.h"
#include "Spell.h" #include "Spell.h"
#include "Configuration/Config.h"
enum vendor enum vendor
{ {
NPC_VENDOR = 54, NPC_VENDOR = 54,
NPC_AUCTION = 9856, //Horde NPC_AUCTION = 9856, //Horde
NPC_AUCTION2 = 8670, //Alliance NPC_AUCTION2 = 8670, //Alliance
ALLIANCE_MOUNT = 470, ALLIANCE_MOUNT = 470,
HORDE_MOUNT = 6653 HORDE_MOUNT = 6653
}; };
class premium_account : public ItemScript class premium_account : public ItemScript
{ {
public: public:
premium_account() : ItemScript("premium_account") { } premium_account() : ItemScript("premium_account") { }
bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/) override // Any hook here bool OnUse(Player* player, Item* item, SpellCastTargets const& /*targets*/) override // Any hook here
{ {
if (!sConfigMgr->GetBoolDefault("PremiumAccount", true)) if (!sConfigMgr->GetBoolDefault("PremiumAccount", true))
return false;
QueryResult result = CharacterDatabase.PQuery("SELECT AccountId FROM premium WHERE active = 1 and AccountId = %u", player->GetSession()->GetAccountId());
if (!result)
return false; return false;
QueryResult result = CharacterDatabase.PQuery("SELECT AccountId FROM premium WHERE active = 1 and AccountId = %u", player->GetSession()->GetAccountId()); if (player->IsInCombat())
return false;
if (!result) player->PlayerTalkClass->ClearMenus();
return false;
if (player->IsInCombat())
return false;
player->PlayerTalkClass->ClearMenus(); if (sConfigMgr->GetBoolDefault("Morph", true))
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Morph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Demorph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Show Bank", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Mail Box", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Vendor", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT_16, "Mount", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Auction House", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
return false; // Cast the spell on use normally
}
void OnGossipSelect(Player* player, Item* /*item*/, uint32 /*sender*/, uint32 action) override
{
switch (action)
{ {
case GOSSIP_ACTION_INFO_DEF + 1: /*Morph*/ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Morph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 1);
{ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Demorph", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 2);
player->CLOSE_GOSSIP_MENU(); }
uint32 random = (urand(1, 26)); /* change this line when adding more morphs */ if (sConfigMgr->GetBoolDefault("Bank", true))
{ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Show Bank", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 3);
switch (random) if (sConfigMgr->GetBoolDefault("MailBox", true))
{ player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Mail Box", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 4);
case 1: player->SetDisplayId(10134); break; // Troll Female 'Orb of Deception' if (sConfigMgr->GetBoolDefault("Vendor", true))
case 2: player->SetDisplayId(10135); break; // Troll Male 'Orb of Deception' player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Vendor", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 5);
case 3: player->SetDisplayId(10136); break; // Tauren Male 'Orb of Deception' if (sConfigMgr->GetBoolDefault("Mount", true))
case 4: player->SetDisplayId(10137); break; // Human Male 'Orb of Deception' player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT_16, "Mount", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 6);
case 5: player->SetDisplayId(10138); break; // Human Female 'Orb of Deception' if (sConfigMgr->GetBoolDefault("Auction", true))
case 6: player->SetDisplayId(10139); break; // Orc Male 'Orb of Deception' player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Auction House", GOSSIP_SENDER_MAIN, GOSSIP_ACTION_INFO_DEF + 7);
case 7: player->SetDisplayId(10140); break; // Orc Female 'Orb of Deception' player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, item->GetGUID());
case 8: player->SetDisplayId(10141); break; // Dwarf Male 'Orb of Deception' return false; // Cast the spell on use normally
case 9: player->SetDisplayId(10142); break; // Dwarf Female 'Orb of Deception' }
case 10: player->SetDisplayId(10143); break; // NightElf Male 'Orb of Deception'
case 11: player->SetDisplayId(10144); break; // NightElf Female 'Orb of Deception'
case 12: player->SetDisplayId(10145); break; // Undead Female 'Orb of Deception'
case 13: player->SetDisplayId(10146); break; // Undead Male 'Orb of Deception'
case 14: player->SetDisplayId(10147); break; // Tauren Female 'Orb of Deception'
case 15: player->SetDisplayId(10148); break; // Gnome Male 'Orb of Deception'
case 16: player->SetDisplayId(10149); break; // Gnome Female 'Orb of Deception'
case 17: player->SetDisplayId(4527); break; // Thrall 'Orgrimmar Boss'
case 18: player->SetDisplayId(11657); break; // Lady Sylvanas 'Undercity Boss'
case 19: player->SetDisplayId(4307); break; // Cairne Bloodhoof 'Thunderbluff Boss'
case 20: player->SetDisplayId(17122); break; // Lor´themar Theron 'Silvermoon City Boss'
case 21: player->SetDisplayId(3597); break; // King Magni Bronzebeard 'Ironforge Boss'
case 22: player->SetDisplayId(5566); break; // Highlord Bolvar Fordragon 'Stormwind Boss'
case 23: player->SetDisplayId(7006); break; // High Tinker Mekkatorque 'Gnomer Boss'
case 24: player->SetDisplayId(7274); break; // Tyrande Whisperwind 'Darnassus Boss'
case 25: player->SetDisplayId(21976); break; // Arthus Small 'Arthus'
case 26: player->SetDisplayId(24641); break; // Arthus Ghost 'Arthus Ghost'
default: void OnGossipSelect(Player* player, Item* /*item*/, uint32 /*sender*/, uint32 action) override
break; {
}
} switch (action)
break; {
} case GOSSIP_ACTION_INFO_DEF + 1: /*Morph*/
case GOSSIP_ACTION_INFO_DEF + 2: /*Demorph*/ {
player->DeMorph(); player->CLOSE_GOSSIP_MENU();
player->CLOSE_GOSSIP_MENU(); uint32 random = (urand(1, 26)); /* change this line when adding more morphs */
break; {
case GOSSIP_ACTION_INFO_DEF + 3: /*Show Bank*/ switch (random)
player->GetSession()->SendShowBank(player->GetGUID()); {
break; case 1: player->SetDisplayId(10134); break; // Troll Female 'Orb of Deception'
case GOSSIP_ACTION_INFO_DEF + 4: /*Mail Box*/ case 2: player->SetDisplayId(10135); break; // Troll Male 'Orb of Deception'
player->GetSession()->SendShowMailBox(player->GetGUID()); case 3: player->SetDisplayId(10136); break; // Tauren Male 'Orb of Deception'
break; case 4: player->SetDisplayId(10137); break; // Human Male 'Orb of Deception'
case GOSSIP_ACTION_INFO_DEF + 5: /*Vendor*/ case 5: player->SetDisplayId(10138); break; // Human Female 'Orb of Deception'
{ case 6: player->SetDisplayId(10139); break; // Orc Male 'Orb of Deception'
Creature* vendor = player->SummonCreature(NPC_VENDOR, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000); case 7: player->SetDisplayId(10140); break; // Orc Female 'Orb of Deception'
vendor->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); case 8: player->SetDisplayId(10141); break; // Dwarf Male 'Orb of Deception'
vendor->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle()); case 9: player->SetDisplayId(10142); break; // Dwarf Female 'Orb of Deception'
vendor->setFaction(player->getFaction()); case 10: player->SetDisplayId(10143); break; // NightElf Male 'Orb of Deception'
vendor->MonsterWhisper("At your service", player, false); case 11: player->SetDisplayId(10144); break; // NightElf Female 'Orb of Deception'
player->CLOSE_GOSSIP_MENU(); case 12: player->SetDisplayId(10145); break; // Undead Female 'Orb of Deception'
} case 13: player->SetDisplayId(10146); break; // Undead Male 'Orb of Deception'
break; case 14: player->SetDisplayId(10147); break; // Tauren Female 'Orb of Deception'
case GOSSIP_ACTION_INFO_DEF + 6: /*Mount*/ case 15: player->SetDisplayId(10148); break; // Gnome Male 'Orb of Deception'
player->CLOSE_GOSSIP_MENU(); case 16: player->SetDisplayId(10149); break; // Gnome Female 'Orb of Deception'
if (player->GetTeamId() == TEAM_HORDE) case 17: player->SetDisplayId(4527); break; // Thrall 'Orgrimmar Boss'
player->CastSpell(player, HORDE_MOUNT); case 18: player->SetDisplayId(11657); break; // Lady Sylvanas 'Undercity Boss'
else case 19: player->SetDisplayId(4307); break; // Cairne Bloodhoof 'Thunderbluff Boss'
player->CastSpell(player, ALLIANCE_MOUNT); case 20: player->SetDisplayId(17122); break; // Lor´themar Theron 'Silvermoon City Boss'
break; case 21: player->SetDisplayId(3597); break; // King Magni Bronzebeard 'Ironforge Boss'
case GOSSIP_ACTION_INFO_DEF + 7: /*Auction House*/ case 22: player->SetDisplayId(5566); break; // Highlord Bolvar Fordragon 'Stormwind Boss'
case 23: player->SetDisplayId(7006); break; // High Tinker Mekkatorque 'Gnomer Boss'
if (player->GetTeamId() == TEAM_HORDE) case 24: player->SetDisplayId(7274); break; // Tyrande Whisperwind 'Darnassus Boss'
{ case 25: player->SetDisplayId(21976); break; // Arthus Small 'Arthus'
Creature* auction = player->SummonCreature(NPC_AUCTION, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); case 26: player->SetDisplayId(24641); break; // Arthus Ghost 'Arthus Ghost'
auction->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
auction->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle()); default:
auction->setFaction(player->getFaction()); break;
auction->MonsterWhisper("I will go shortly, i need to get back to Orgrimmar", player, false); }
} }
else break;
{ }
Creature* auction = player->SummonCreature(NPC_AUCTION2, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000); case GOSSIP_ACTION_INFO_DEF + 2: /*Demorph*/
auction->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE); player->DeMorph();
auction->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle()); player->CLOSE_GOSSIP_MENU();
auction->setFaction(player->getFaction()); break;
auction->MonsterWhisper("I will go shortly, i need to get back to Stormwind City", player, false); case GOSSIP_ACTION_INFO_DEF + 3: /*Show Bank*/
} player->GetSession()->SendShowBank(player->GetGUID());
player->CLOSE_GOSSIP_MENU(); break;
case GOSSIP_ACTION_INFO_DEF + 4: /*Mail Box*/
break; player->GetSession()->SendShowMailBox(player->GetGUID());
} break;
player->PlayerTalkClass->ClearMenus(); case GOSSIP_ACTION_INFO_DEF + 5: /*Vendor*/
} {
Creature* vendor = player->SummonCreature(NPC_VENDOR, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 10000);
vendor->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
vendor->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle());
vendor->setFaction(player->getFaction());
vendor->MonsterWhisper("At your service", player, false);
player->CLOSE_GOSSIP_MENU();
}
break;
case GOSSIP_ACTION_INFO_DEF + 6: /*Mount*/
player->CLOSE_GOSSIP_MENU();
if (player->GetTeamId() == TEAM_HORDE)
player->CastSpell(player, HORDE_MOUNT);
else
player->CastSpell(player, ALLIANCE_MOUNT);
break;
case GOSSIP_ACTION_INFO_DEF + 7: /*Auction House*/
if (player->GetTeamId() == TEAM_HORDE)
{
Creature* auction = player->SummonCreature(NPC_AUCTION, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
auction->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
auction->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle());
auction->setFaction(player->getFaction());
auction->MonsterWhisper("I will go shortly, i need to get back to Orgrimmar", player, false);
}
else
{
Creature* auction = player->SummonCreature(NPC_AUCTION2, player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 30000);
auction->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
auction->GetMotionMaster()->MoveFollow(player, PET_FOLLOW_DIST, player->GetFollowAngle());
auction->setFaction(player->getFaction());
auction->MonsterWhisper("I will go shortly, i need to get back to Stormwind City", player, false);
}
player->CLOSE_GOSSIP_MENU();
break;
}
player->PlayerTalkClass->ClearMenus();
}
}; };
void AddSC_premium_account()
class premium_world : public WorldScript
{ {
new premium_account(); public:
premium_world() : WorldScript("premiumworld") { }
void OnBeforeConfigLoad(bool reload) override
{
if (!reload) {
std::string cfg_file = "premium.conf";
std::string cfg_def_file = cfg_file + ".dist";
sConfigMgr->LoadMore(cfg_def_file.c_str());
sConfigMgr->LoadMore(cfg_file.c_str());
}
}
};
void AddSC_premium_account()
{
new premium_account();
new premium_world();
} }