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 <[email protected]> * Fix xp multiplier not applying to quest rewards * Disable xp boost script when no boosted days selected (cherry picked from commit 538c5b86873a4c57e1eb37f0c81c2a7b4552ebc1)
This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -3154,6 +3154,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).
|
||||
|
||||
Reference in New Issue
Block a user