diff options
author | Aokromes <Aokromes@users.noreply.github.com> | 2018-11-28 16:44:28 +0100 |
---|---|---|
committer | Giacomo Pozzoni <giacomopoz@gmail.com> | 2018-11-28 16:44:28 +0100 |
commit | 538c5b86873a4c57e1eb37f0c81c2a7b4552ebc1 (patch) | |
tree | 2cd1a7d80a446f4242176002057a17cc1a384cde /src | |
parent | f1f05767edf35d759d107d3fad4ec56d6d2a3202 (diff) |
Core/GameEvent: weekend xp rate (#17782)
* Core/GameEvent: weekend xp rate
by kline
* Update to recent code
* compile fix try
things of copy and paste 4 years old code xd
* more code update
* forgot to change this
* Update worldserver.conf.dist
* Added function to calculate weekend event xp rates
By greenbagels
* Cleaning using scripts
* Implement daymask and rename variables etc.
* Rename script file weekend -> boosted
* Update src/server/game/World/World.cpp
Co-Authored-By: Aokromes <Aokromes@users.noreply.github.com>
* Fix xp multiplier not applying to quest rewards
* Disable xp boost script when no boosted days selected
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/World/World.cpp | 4 | ||||
-rw-r--r-- | src/server/game/World/World.h | 2 | ||||
-rw-r--r-- | src/server/scripts/World/boosted_xp.cpp | 51 | ||||
-rw-r--r-- | src/server/scripts/World/world_script_loader.cpp | 3 | ||||
-rw-r--r-- | src/server/worldserver/worldserver.conf.dist | 24 |
5 files changed, 84 insertions, 0 deletions
diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index 3cf43f85850..13c3b7b161c 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -524,6 +524,10 @@ void World::LoadConfigSettings(bool reload) rate_values[RATE_XP_BG_KILL] = sConfigMgr->GetFloatDefault("Rate.XP.BattlegroundKill", 1.0f); rate_values[RATE_XP_QUEST] = sConfigMgr->GetFloatDefault("Rate.XP.Quest", 1.0f); rate_values[RATE_XP_EXPLORE] = sConfigMgr->GetFloatDefault("Rate.XP.Explore", 1.0f); + + m_int_configs[CONFIG_XP_BOOST_DAYMASK] = sConfigMgr->GetIntDefault("XP.Boost.Daymask", 0); + rate_values[RATE_XP_BOOST] = sConfigMgr->GetFloatDefault("XP.Boost.Rate", 2.0f); + rate_values[RATE_REPAIRCOST] = sConfigMgr->GetFloatDefault("Rate.RepairCost", 1.0f); if (rate_values[RATE_REPAIRCOST] < 0.0f) { diff --git a/src/server/game/World/World.h b/src/server/game/World/World.h index 6d0bc442055..4412f6f963e 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -347,6 +347,7 @@ enum WorldIntConfigs CONFIG_PERSISTENT_CHARACTER_CLEAN_FLAGS, CONFIG_LFG_OPTIONSMASK, CONFIG_MAX_INSTANCES_PER_HOUR, + CONFIG_XP_BOOST_DAYMASK, CONFIG_WARDEN_CLIENT_RESPONSE_DELAY, CONFIG_WARDEN_CLIENT_CHECK_HOLDOFF, CONFIG_WARDEN_CLIENT_FAIL_ACTION, @@ -459,6 +460,7 @@ enum Rates RATE_DURABILITY_LOSS_ABSORB, RATE_DURABILITY_LOSS_BLOCK, RATE_MOVESPEED, + RATE_XP_BOOST, RATE_MONEY_QUEST, RATE_MONEY_MAX_LEVEL_QUEST, MAX_RATES diff --git a/src/server/scripts/World/boosted_xp.cpp b/src/server/scripts/World/boosted_xp.cpp new file mode 100644 index 00000000000..df03dab4a81 --- /dev/null +++ b/src/server/scripts/World/boosted_xp.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/> + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation; either version 2 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#include "GameTime.h" +#include "ScriptMgr.h" +#include "World.h" + +#include <boost/date_time/posix_time/posix_time.hpp> + +namespace +{ + bool IsXPBoostActive() + { + auto now = boost::posix_time::to_tm(boost::posix_time::from_time_t(GameTime::GetGameTime())); + uint32 weekdayMaskBoosted = sWorld->getIntConfig(CONFIG_XP_BOOST_DAYMASK); + uint32 weekdayMask = (1 << now.tm_wday); + bool currentDayBoosted = (weekdayMask & weekdayMaskBoosted) != 0; + return currentDayBoosted; + } +} + +class xp_boost_PlayerScript : public PlayerScript +{ +public: + xp_boost_PlayerScript() : PlayerScript("xp_boost_PlayerScript") { } + + void OnGiveXP(Player* /*player*/, uint32& amount, Unit* /*unit*/) override + { + if (IsXPBoostActive()) + amount *= sWorld->getRate(RATE_XP_BOOST); + } +}; + +void AddSC_xp_boost() +{ + new xp_boost_PlayerScript(); +} diff --git a/src/server/scripts/World/world_script_loader.cpp b/src/server/scripts/World/world_script_loader.cpp index 53c19bbc3a1..352f62265c2 100644 --- a/src/server/scripts/World/world_script_loader.cpp +++ b/src/server/scripts/World/world_script_loader.cpp @@ -31,6 +31,7 @@ void AddSC_npcs_special(); void AddSC_achievement_scripts(); void AddSC_action_ip_logger(); void AddSC_duel_reset(); +void AddSC_xp_boost(); // player void AddSC_chat_log(); void AddSC_action_ip_logger(); @@ -56,4 +57,6 @@ void AddWorldScripts() if (sWorld->getBoolConfig(CONFIG_IP_BASED_ACTION_LOGGING)) AddSC_action_ip_logger(); // location: scripts\World\action_ip_logger.cpp AddSC_duel_reset(); + if (sWorld->getIntConfig(CONFIG_XP_BOOST_DAYMASK) != 0) + AddSC_xp_boost(); } diff --git a/src/server/worldserver/worldserver.conf.dist b/src/server/worldserver/worldserver.conf.dist index 49ee6ab3cfd..99b888c9ff2 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -3019,6 +3019,30 @@ AllowTrackBothResources = 0 PlayerStart.AllReputation = 0 # +# XP.Boost.Daymask +# Description: Enables experience boost during the defined days. This field is a bitmask. +# +# Default: 0 - (Disabled) +# 1 - (Sunday) +# 2 - (Monday) +# 4 - (Tuesday) +# 8 - (Wednesday) +# 16 - (Thrusday) +# 32 - (Friday) +# 64 - (Saturday) +# 65 - (Weekend only) +# 127 - (Always active) + +XP.Boost.Daymask = 0 + +# +# XP.Boost.Rate +# Description: The boost multiplier for experience gain during XP boosted days. +# Default: 2.0 - (Double experience) + +XP.Boost.Rate = 2.0 + +# # PlayerStart.AllSpells # Description: If enabled, players will start with all their class spells (not talents). # You must populate playercreateinfo_spell_custom table with the spells you |