From 4a2fd85f5dc0184ce616e797c97b0f905015956e Mon Sep 17 00:00:00 2001 From: Revision Date: Wed, 8 Dec 2021 18:11:27 +0100 Subject: [PATCH] Initial commit Added the script taken directly from the old assistant code. --- README.md | 18 +++++++++++++++- conf/WeekendBonus.conf.dist | 7 ++++++ conf/conf.sh.dist | 1 + include.sh | 8 +++++++ src/ModWeekendBonus_Loader.cpp | 6 ++++++ src/WeekendBonus.cpp | 39 ++++++++++++++++++++++++++++++++++ 6 files changed, 78 insertions(+), 1 deletion(-) create mode 100644 conf/WeekendBonus.conf.dist create mode 100644 conf/conf.sh.dist create mode 100644 include.sh create mode 100644 src/ModWeekendBonus_Loader.cpp create mode 100644 src/WeekendBonus.cpp diff --git a/README.md b/README.md index 8b991f3..9d96b20 100644 --- a/README.md +++ b/README.md @@ -1 +1,17 @@ -# mod-weekendbonus \ No newline at end of file +# Weekend Bonus +This is a module for [AzerothCore](https://github.com/azerothcore/azerothcore-wotlk). + +# Features +This module will increase the experience and reputation gained on weekends. That means friday, saturday and sunday. + +The multiplier can be changed using the config. + +# Additional information +This module is part of my collection of modules. + +[ActivateZones](https://github.com/tkn963/mod-activatezones) : Set creatures as active in zones that has players in it. +[Assistant](https://github.com/tkn963/mod-assistant) : Allows players to obtain certain items and utilities from an NPC. +[LearnSpells](https://github.com/tkn963/mod-learnspells) : Lets players learn class spells, talent ranks, proficiencies and mounts when leveling up or logging into the world. +[RecruitAFriend](https://github.com/tkn963/mod-recruitafriend) : Lets players activate recruit a friend with an in-game command. +[SpawnPoints](https://github.com/tkn963/mod-spawnpoints) : Makes new characters spawn in specified locations when entering the world for the first time. +[WeekendBonus](https://github.com/tkn963/mod-weekendbonus) : Increases the experience and reputation gained on weekends. diff --git a/conf/WeekendBonus.conf.dist b/conf/WeekendBonus.conf.dist new file mode 100644 index 0000000..42cd35d --- /dev/null +++ b/conf/WeekendBonus.conf.dist @@ -0,0 +1,7 @@ +[worldserver] + +# Multiplier for experience gains on weekends +Multiplier.Experience = 1 + +# Multiplier for reputation gains on weekends +Multiplier.Reputation = 1 diff --git a/conf/conf.sh.dist b/conf/conf.sh.dist new file mode 100644 index 0000000..f1f641a --- /dev/null +++ b/conf/conf.sh.dist @@ -0,0 +1 @@ +#!/usr/bin/env bash diff --git a/include.sh b/include.sh new file mode 100644 index 0000000..9b66ae2 --- /dev/null +++ b/include.sh @@ -0,0 +1,8 @@ +#!/usr/bin/env bash +MOD_WEEKENDBONUS_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )/" && pwd )" + +source $MOD_WEEKENDBONUS_ROOT"/conf/conf.sh.dist" + +if [ -f $MOD_WEEKENDBONUS_ROOT"/conf/conf.sh" ]; then + source $MOD_WEEKENDBONUS_ROOT"/conf/conf.sh" +fi diff --git a/src/ModWeekendBonus_Loader.cpp b/src/ModWeekendBonus_Loader.cpp new file mode 100644 index 0000000..6cd2b5c --- /dev/null +++ b/src/ModWeekendBonus_Loader.cpp @@ -0,0 +1,6 @@ +void AddWeekendBonusScripts(); + +void Addmod_weekendbonusScripts() +{ + AddWeekendBonusScripts(); +} diff --git a/src/WeekendBonus.cpp b/src/WeekendBonus.cpp new file mode 100644 index 0000000..921cc72 --- /dev/null +++ b/src/WeekendBonus.cpp @@ -0,0 +1,39 @@ +#include "Chat.h" +#include "Config.h" +#include "Player.h" +#include "ScriptMgr.h" + +class WeekendBonus : public PlayerScript +{ + public: + WeekendBonus() : PlayerScript("WeekendBonus") {} + + void OnGiveXP(Player* player, uint32& amount, Unit* /*victim*/) override + { + time_t t = time(NULL); + + if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/) + amount *= sConfigMgr->GetIntDefault("Multiplier.Experience", 1); + } + + void OnReputationChange(Player* player, uint32 /*factionId*/, int32& standing, bool /*incremental*/) override + { + time_t t = time(NULL); + + if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/) + standing *= sConfigMgr->GetIntDefault("Multiplier.Reputation", 1); + } + + void OnLogin(Player* player) override + { + time_t t = time(NULL); + + if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/) + ChatHandler(player->GetSession()).SendSysMessage("The weekend bonus is active, increasing the experience and reputation received!"); + } +}; + +void AddWeekendBonusScripts() +{ + new WeekendBonus(); +}