mirror of
https://github.com/noisiver/mod-weekendbonus.git
synced 2026-01-13 00:58:36 +00:00
Changes
Added the WorldScript to load config options into variables. Changed the way the multipliers are handled. It will only print when options are actually increased from the default 1.
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "ScriptMgr.h"
|
#include "ScriptMgr.h"
|
||||||
|
|
||||||
|
uint32 multiplierExperience;
|
||||||
|
uint32 multiplierReputation;
|
||||||
|
|
||||||
class WeekendBonus : public PlayerScript
|
class WeekendBonus : public PlayerScript
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -13,7 +16,8 @@ class WeekendBonus : public PlayerScript
|
|||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
|
|
||||||
if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/)
|
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);
|
if (multiplierExperience > 1)
|
||||||
|
amount *= multiplierExperience;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnReputationChange(Player* player, uint32 /*factionId*/, int32& standing, bool /*incremental*/) override
|
void OnReputationChange(Player* player, uint32 /*factionId*/, int32& standing, bool /*incremental*/) override
|
||||||
@@ -21,7 +25,8 @@ class WeekendBonus : public PlayerScript
|
|||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
|
|
||||||
if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/)
|
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);
|
if (multiplierReputation > 1)
|
||||||
|
standing *= multiplierReputation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnLogin(Player* player) override
|
void OnLogin(Player* player) override
|
||||||
@@ -29,11 +34,37 @@ class WeekendBonus : public PlayerScript
|
|||||||
time_t t = time(NULL);
|
time_t t = time(NULL);
|
||||||
|
|
||||||
if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/)
|
if (localtime(&t)->tm_wday == 5 /*Friday*/ || localtime(&t)->tm_wday == 6 /*Saturday*/ || localtime(&t)->tm_wday == 0 /*Sunday*/)
|
||||||
|
{
|
||||||
|
if (multiplierExperience > 1 && multiplierReputation > 1)
|
||||||
|
{
|
||||||
ChatHandler(player->GetSession()).SendSysMessage("The weekend bonus is active, increasing the experience and reputation received!");
|
ChatHandler(player->GetSession()).SendSysMessage("The weekend bonus is active, increasing the experience and reputation received!");
|
||||||
}
|
}
|
||||||
|
else if (multiplierExperience > 1)
|
||||||
|
{
|
||||||
|
ChatHandler(player->GetSession()).SendSysMessage("The weekend bonus is active, increasing the experience received!");
|
||||||
|
}
|
||||||
|
else if (multiplierReputation > 1)
|
||||||
|
{
|
||||||
|
ChatHandler(player->GetSession()).SendSysMessage("The weekend bonus is active, increasing the reputation received!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class WeekendBonusConfig : WorldScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
WeekendBonusConfig() : WorldScript("WeekendBonusConfig") {}
|
||||||
|
|
||||||
|
void OnAfterConfigLoad(bool /*reload*/) override
|
||||||
|
{
|
||||||
|
multiplierExperience = sConfigMgr->GetIntDefault("Multiplier.Experience", 1);
|
||||||
|
multiplierReputation = sConfigMgr->GetIntDefault("Multiplier.reputation", 1);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
void AddWeekendBonusScripts()
|
void AddWeekendBonusScripts()
|
||||||
{
|
{
|
||||||
new WeekendBonus();
|
new WeekendBonus();
|
||||||
|
new WeekendBonusConfig();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user