completed challengemode reward check + more fixes

This commit is contained in:
Yehonal
2021-06-10 17:58:44 +02:00
parent e50e81e112
commit 77d8275a8e
18 changed files with 165 additions and 40 deletions

View File

@@ -34,3 +34,7 @@ add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/modules/mod-smartstone")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/modules/mod-timewalking")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/modules/mod-tournament")
add_subdirectory("${CMAKE_CURRENT_LIST_DIR}/modules/mod-xp-rates")
# Add config file
AC_ADD_CONFIG_FILE("${CMAKE_CURRENT_LIST_DIR}/mod-as-common/conf/azth_mod.conf.dist")

15
conf/azth_mod.conf.dist Normal file
View File

@@ -0,0 +1,15 @@
[worldserver]
#
# Difference between the position level and the player level to disable the reward
# default: 0 (disabled)
#
ChallengeMode.noReward.deltaLevelHigher=0
ChallengeMode.noReward.deltaLevelLower=0
#
# Position levels to start checking for the difference between the position and the player level
# default: 0 (disabled)
#
ChallengeMode.noReward.startLevelHigher=0
ChallengeMode.noReward.startLevelLower=0

View File

@@ -1,8 +1,5 @@
CU_SET_PATH("CMAKE_AZTH_SRC_DIR" "${CMAKE_CURRENT_LIST_DIR}/src/")
# Add config file
AC_ADD_CONFIG_FILE("${CMAKE_AZTH_DIR}/conf/azth_mod.conf.dist")
include("${CMAKE_CURRENT_LIST_DIR}/src/CMakeLists.txt")

View File

@@ -2,6 +2,9 @@
AZTH_LOAD_SRC("mod-as-common/src/game")
AZTH_LOAD_SRC("mod-as-common/src/plugins")
AZTH_LOAD_SRC("mod-pvp-mode/src")
AZTH_LOAD_SRC("mod-as-platform/src")
AZTH_LOAD_SRC("mod-timewalking/src/scripts")
AZTH_LOAD_SRC("mod-playerstats/src/scripts")
if( NOT WIN32 )
message("defined: ${_AZTH_MOD_CONFIG}")

View File

@@ -21,7 +21,6 @@ class Group;
class AzthUtils
{
friend class ACE_Singleton<AzthUtils, ACE_Null_Mutex>;
public:
static AzthUtils* instance();

View File

@@ -16,5 +16,3 @@ AC_ADD_SCRIPT("${MOD_AZTH_DIR}/src/AZTH_SC.cpp")
# Add scripts to script loader
#AC_ADD_SCRIPT_LOADER("AZTH" "${MOD_AZTH_DIR}/src/AZTHLoad.h")
# Add config file
# AC_ADD_CONFIG_FILE("${MOD_AZTH_DIR}/conf/AZTH.conf.dist")

View File

@@ -1,7 +1,3 @@
/*
* Copyright (С) since 2019 Andrei Guluaev (Winfidonarleyan/Kargatum) https://github.com/Winfidonarleyan
*/
#ifndef _AZTH_MODULE_H_
#define _AZTH_MODULE_H_
@@ -50,7 +46,7 @@ public:
float GetRatePvPRankExtraHonor();
//[AZTH] in-game mailer
void SendGameMail(Player* receiver, std::string subject, std::string body, uint32 money, uint32 itemId = 0, uint32 itemCount = 0);
void SendGameMail(Player* receiver, std::string subject, std::string body, uint32 money, uint32 itemId = 0, uint32 itemCount = 0);
// ExternalMail
bool IsExternalMailEnable();
@@ -76,7 +72,7 @@ private:
AZTHLootContainer _lootStore;
// PVP Rank Patch
uint32 _PvP_Ranks[HKRANKMAX];
uint32 _PvP_Ranks[HKRANKMAX];
float _RatePvPRankExtraHonor = 0.0f;
// ExternalMail

View File

@@ -14,7 +14,7 @@
#include "GuildHouse.h"
#include "Teleport.h"
#include "Solo3v3.h"
#include "SpellAuraEffects.h"
#include "ScriptMgr.h"
#include "ArenaTeamMgr.h"
#include "BattlegroundQueue.h"
@@ -27,6 +27,8 @@
#include "MapManager.h"
#include "ExtraDatabase.h"
class AuraEffect;
// SC
class Arena_SC : public ArenaScript
{

View File

@@ -0,0 +1,17 @@
# Challenge Mode
The goal of this module is to provide challenges by giving bonuses, increasing difficulty or disabling certain in-game features
for players who are/not are eligible for them.
## List of current available configurable feature:
- Possibility to disable achievements and loots for low-level/high-level challenges (dungeons & raids)
## List of features available soon:
- Flex Mythic challenging mode (based on mod-autobalance)
- Bonus on loot rates/quantity when you play the content at the right level (including timewalking) or with a higher difficulty (Mythic)
## TODO
- More configurations needed to enable/disable the challenge mode in certains conditions

View File

@@ -0,0 +1,42 @@
#include "ChallengeModeMgr.h"
#include "Config.h"
#include "AzthUtils.h"
ChallengeModeMgr* ChallengeModeMgr::instance()
{
static ChallengeModeMgr instance;
return &instance;
}
void ChallengeModeMgr::LoadConfig(bool /* reload */)
{
this->deltaLevelHigher = sConfigMgr->GetIntDefault("ChallengeMode.noReward.deltaLevelHigher", 0);
this->deltaLevelLower = sConfigMgr->GetIntDefault("ChallengeMode.noReward.deltaLevelLower", 0);
this->startLevelHigher = sConfigMgr->GetIntDefault("ChallengeMode.noReward.startLevelHigher", 0);
this->startLevelLower = sConfigMgr->GetIntDefault("ChallengeMode.noReward.startLevelLower", 0);
}
bool ChallengeModeMgr::isEligibleForReward(Player const *player) {
// disable rewards only for dungeons
if (!player->GetMap()->IsDungeon() && !player->GetMap()->IsRaid())
return true;
WorldLocation pos = WorldLocation(player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
uint32 posLvl=sAzthUtils->getPositionLevel(false, player->GetMap(), pos);
uint32 level = player->getLevel();
// disable reward when the player has a higher level than the one specified in the configs
// it can be useful to force players doing the challenges at the correct level (E.G. during the levelling)
if (this->startLevelLower && this->startLevelLower >= posLvl && level > posLvl && deltaLevelLower >= level - posLvl) {
return false;
}
// disable reward when the player has a lower level than the one specified in the configs
// it can be useful to avoid power-levelling/character-towing or to avoid cheating on certain progression-based servers
if (this->startLevelHigher && posLvl >= this->startLevelHigher && posLvl > level && posLvl - level >= deltaLevelHigher) {
return false;
}
return true;
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (С) since 2019 Andrei Guluaev (Winfidonarleyan/Kargatum) https://github.com/Winfidonarleyan
*/
#ifndef _CHALLENGEMODE_MGR_H_
#define _CHALLENGEMODE_MGR_H_
#include "Common.h"
#include "Player.h"
class ChallengeModeMgr
{
public:
static ChallengeModeMgr* instance();
void LoadConfig(bool reload);
bool isEligibleForReward(Player const *player);
[[nodiscard]] uint32 getStartLevelHigher() {
return this->startLevelHigher;
}
[[nodiscard]] uint32 getDeltaLevelLower() {
return this->deltaLevelLower;
}
[[nodiscard]] uint32 getStartLevelLower() {
return this->startLevelLower;
}
[[nodiscard]] uint32 getDeltaLevelHigher() {
return this->deltaLevelHigher;
}
private:
uint32 deltaLevelHigher = 0;
uint32 startLevelHigher = 0;
uint32 deltaLevelLower = 0;
uint32 startLevelLower = 0;
};
#define sChallengeMode ChallengeModeMgr::instance()
#endif // _CHALLENGEMODE_MGR_H_

View File

@@ -7,11 +7,20 @@
#include "Group.h"
#include "AzthUtils.h"
#include "AZTH.h"
#include "ChallengeModeMgr.h"
class AzthUtils;
#define MAX_HIGHER_LEVEL 3
class ChallengeModeWorld : public WorldScript
{
public:
ChallengeModeWorld() : WorldScript("ChallengeModeWorld") { }
void OnAfterConfigLoad(bool reload) override
{
sChallengeMode->LoadConfig(reload);
}
};
class ChallengeModeMisc : public MiscScript
{
public:
@@ -39,18 +48,7 @@ public:
bool OnBeforeAchiComplete(Player* player, AchievementEntry const* /* achievement */) override
{
WorldLocation pos = WorldLocation(player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
uint32 posLvl=sAzthUtils->getPositionLevel(false, player->GetMap(), pos);
if (!player->GetMap()->IsDungeon() && !player->GetMap()->IsRaid())
return true;
uint32 level = player->getLevel();
if (posLvl > level && posLvl - level == MAX_HIGHER_LEVEL) {
return false;
}
return true;
return sChallengeMode->isEligibleForReward(player);
}
};
@@ -63,15 +61,7 @@ public:
void OnItemRoll(Player const* player, LootStoreItem const */* item */, float &chance, Loot &/* loot */, LootStore const& /* store */) override
{
WorldLocation pos = WorldLocation(player->GetMapId(), player->GetPositionX(), player->GetPositionY(), player->GetPositionZ(), player->GetOrientation());
uint32 posLvl=sAzthUtils->getPositionLevel(false, player->GetMap(), pos);
uint32 level = player->getLevel();
if (!player->GetMap()->IsDungeon() && !player->GetMap()->IsRaid())
return;
if (posLvl > level && posLvl - level == MAX_HIGHER_LEVEL) {
if (!sChallengeMode->isEligibleForReward(player)) {
chance = 0;
return;
}
@@ -116,4 +106,5 @@ void AddSC_challengemode() {
new ChallengeModeMisc();
new ChallengeModeGlobal();
new ChallengeModePlayer();
new ChallengeModeWorld();
}

View File

@@ -1,5 +1,11 @@
#include "AzthAchievement.h"
AzthAchievementMgr* AzthAchievementMgr::instance()
{
static AzthAchievementMgr instance;
return &instance;
}
AzthAchievement::AzthAchievement(uint32 achievement, uint32 criteria, uint32 points, uint32 category, uint32 parentCategory, uint32 difficulty, uint32 levelMax, uint32 levelMin,
uint32 level, uint32 originalPoints, std::string name, std::string description, uint32 reward, uint32 rewardCount, uint32 killCredit, uint32 specialLevelReq, uint32 reqDimension)
{

View File

@@ -4,10 +4,10 @@
#include "Common.h"
#include "Define.h"
#include "Config.h"
#include <map>
class AzthAchievement
{
friend class ACE_Singleton<AzthAchievement, ACE_Null_Mutex>;
public:
//GETTERS
uint32 GetAchievement() const;
@@ -55,9 +55,11 @@ private:
class AzthAchievementMgr {
public:
static AzthAchievementMgr* instance();
std::map<uint32, AzthAchievement> achievementList;
};
#define sAzthAchievementMgr ACE_Singleton<AzthAchievementMgr, ACE_Null_Mutex>::instance()
#define sAzthAchievementMgr AzthAchievementMgr::instance()
#endif

View File

@@ -4,6 +4,7 @@
#include "Common.h"
#include "Define.h"
#include "Config.h"
#include <map>
enum aura_timewalking_enum
{
@@ -86,7 +87,6 @@ enum TWSpecialLevels
class AzthLevelStat
{
friend class ACE_Singleton<AzthLevelStat, ACE_Null_Mutex>;
public:
//GETTERS
uint32 GetLevel() const;

View File

@@ -1,5 +1,11 @@
#include "raid.h"
TwRaid* TwRaid::instance()
{
static TwRaid instance;
return &instance;
}
TwRaid::TwRaid()
{
id = uint32(0);

View File

@@ -4,11 +4,13 @@
#include "Common.h"
#include "Define.h"
#include "Config.h"
#include <map>
class TwRaid
{
friend class ACE_Singleton<TwRaid, ACE_Null_Mutex>;
public:
static TwRaid* instance();
//GETTERS
uint32 GetId() const;
std::string GetName() const;
@@ -45,6 +47,6 @@ private:
std::map<uint32, TwRaid> raidList;
};
#define sAzthRaid ACE_Singleton<TwRaid, ACE_Null_Mutex>::instance()
#define sAzthRaid TwRaid::instance()
#endif