Skip to content

Commit a202672

Browse files
authored
Add Joyous Journeys event support to double XP module (#37)
Introduces configuration options and logic for the Joyous Journeys promotional event, including additional XP and reputation rate modifiers and an option to exclude certain reputations. Updates both the configuration file and the module code to support enabling/disabling the event and customizing its effects.
1 parent d1e7746 commit a202672

2 files changed

Lines changed: 63 additions & 2 deletions

File tree

conf/mod-double-xp-weekend.conf.dist

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,28 @@ XPWeekend.MaxLevel = 80
5959
# Default: 0 (Disabled)
6060

6161
XPWeekend.IsDKStartZoneRequired = 0
62+
63+
# XPWeekend.IsJoyousJourneysActive = 0
64+
# Promotional event, adds yet another layer of bonus on top of the current bonus (yay!)
65+
# Default: 0 (Disabled)
66+
67+
XPWeekend.IsJoyousJourneysActive = 0
68+
69+
# XPWeekend.JoyousJourneysXPRate = 1
70+
# Bonus experience rate during joyous journeys.
71+
# ADDS to the base one. So if base 2x + 1x from this = 3x (50% increase).
72+
# Default: 1
73+
74+
XPWeekend.JoyousJourneysXPRate = 1
75+
76+
# XPWeekend.JoyousJourneysRepRate = 1.10
77+
# Reputation bonus while joyous journeys is active.
78+
# Default: 1.10 (10%)
79+
80+
XPWeekend.JoyousJourneysRepRate = 1.10
81+
82+
# XPWeekend.ExcludeInsaneReps = 1
83+
# Exclude the insane title reputations e.g ravenholdt
84+
# Default: 1 (Enabled)
85+
86+
XPWeekend.ExcludeInsaneReps = 1

src/mod-double-xp-weekend.cpp

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,11 @@ class DoubleXpWeekend
141141
return true;
142142
}
143143

144+
bool IsJoyousJourneysActive() const { return sConfigMgr->GetOption<bool>("XPWeekend.IsJoyousJourneysActive", false); }
145+
float ConfigJoyousJourneysXPRate() const { return sConfigMgr->GetOption<float>("XPWeekend.JoyousJourneysXPRate", 1.0f); }
146+
float ConfigJoyousJourneysRepRate() const { return sConfigMgr->GetOption<float>("XPWeekend.JoyousJourneysRepRate", 1.10f); }
147+
bool ExcludeInsaneReps() const { return sConfigMgr->GetOption<bool>("XPWeekend.ExcludeInsaneReps", true); }
148+
144149
private:
145150

146151
// NOTE keep options together to prevent having more than 1 potential default value
@@ -151,7 +156,7 @@ class DoubleXpWeekend
151156
float ConfigxpAmount() const { return sConfigMgr->GetOption<float>("XPWeekend.xpAmount", 2.0f); }
152157
bool ConfigIndividualXPEnabled() const { return sConfigMgr->GetOption<bool>("XPWeekend.IndividualXPEnabled", false); }
153158
bool ConfigEnabled() const { return sConfigMgr->GetOption<bool>("XPWeekend.Enabled", false); }
154-
float ConfigMaxAllowedRate() const { return sConfigMgr->GetOption<float>("XPWeekend.MaxAllowedRate", 2.0f); }
159+
float ConfigMaxAllowedRate() const { return sConfigMgr->GetOption<float>("XPWeekend.MaxAllowedRate", 2.0f) + (IsJoyousJourneysActive() ? ConfigJoyousJourneysXPRate() : 0.0f); }
155160
bool ConfigIsDKStartZoneRequired() const { return sConfigMgr->GetOption<bool>("XPWeekend.IsDKStartZoneRequired", false); }
156161

157162
bool IsDKStartZoneComplete(Player* player) const
@@ -230,6 +235,11 @@ class DoubleXpWeekend
230235
return 1.0f;
231236
}
232237

238+
if (IsJoyousJourneysActive())
239+
{
240+
rate += ConfigJoyousJourneysXPRate();
241+
}
242+
233243
// If individualxp setting is enabled... and a rate was set, overwrite it.
234244
if (ConfigIndividualXPEnabled())
235245
{
@@ -293,7 +303,8 @@ class DoubleXpWeekendPlayerScript : public PlayerScript
293303
public:
294304
DoubleXpWeekendPlayerScript() : PlayerScript("DoubleXpWeekend", {
295305
PLAYERHOOK_ON_LOGIN,
296-
PLAYERHOOK_ON_GIVE_EXP
306+
PLAYERHOOK_ON_GIVE_EXP,
307+
PLAYERHOOK_ON_GIVE_REPUTATION
297308
}) { }
298309

299310
void OnPlayerLogin(Player* player) override
@@ -309,6 +320,31 @@ class DoubleXpWeekendPlayerScript : public PlayerScript
309320
amount = mod->OnPlayerGiveXP(player, amount, xpSource);
310321
}
311322

323+
void OnPlayerGiveReputation(Player* /*player*/, int32 factionID, float& amount, ReputationSource /*repSource*/) override
324+
{
325+
DoubleXpWeekend* mod = DoubleXpWeekend::instance();
326+
if (!mod->IsJoyousJourneysActive() || !mod->ConfigJoyousJourneysRepRate())
327+
return;
328+
329+
if (mod->ExcludeInsaneReps())
330+
{
331+
switch (factionID)
332+
{
333+
case 349: // Ravenholdt
334+
case 87: // bloodsail bucaneers
335+
case 21: // Booty Bay
336+
case 577: // Everlook
337+
case 369: // Gadgetzan
338+
case 470: // Ratchet
339+
case 909: // Darkmoon Faire
340+
case 809: // Shen'dralar
341+
return;
342+
}
343+
}
344+
345+
amount *= mod->ConfigJoyousJourneysRepRate();
346+
}
347+
312348
};
313349

314350
void AdddoublexpScripts()

0 commit comments

Comments
 (0)