diff options
author | Aokromes <Aokromes@users.noreply.github.com> | 2018-11-28 16:44:28 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-11-16 00:50:23 +0100 |
commit | c44650502cf7e7285e3e504d238638ac0ccc7ec6 (patch) | |
tree | 27e79d81d16793b4851da65f6768ec844ca276b1 | |
parent | a0de41af6934b630dd29bc2c7a23deb1e46f71a4 (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
(cherry picked from commit 538c5b86873a4c57e1eb37f0c81c2a7b4552ebc1)
-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 da32b6edab3..22e1d89be4f 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -602,6 +602,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 2bc273d7885..aad6025a6b4 100644 --- a/src/server/game/World/World.h +++ b/src/server/game/World/World.h @@ -362,6 +362,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, @@ -501,6 +502,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 0a507b9fe04..ea930bd7529 100644 --- a/src/server/scripts/World/world_script_loader.cpp +++ b/src/server/scripts/World/world_script_loader.cpp @@ -32,6 +32,7 @@ void AddSC_npcs_special(); void AddSC_achievement_scripts(); void AddSC_action_ip_logger(); void AddSC_scene_scripts(); +void AddSC_xp_boost(); // player void AddSC_chat_log(); void AddSC_duel_reset(); @@ -59,4 +60,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 f9dd474a05a..05d151a8835 100644 --- a/src/server/worldserver/worldserver.conf.dist +++ b/src/server/worldserver/worldserver.conf.dist @@ -3155,6 +3155,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 |