Code cleanup, add chat command

This commit is contained in:
郑佩茹
2022-09-15 14:26:20 -06:00
parent 2f1d419ee4
commit 58b2dc67b4
6 changed files with 363 additions and 287 deletions

View File

@@ -0,0 +1,3 @@
DELETE FROM `command` WHERE `name` IN ('individualProgression set');
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('individualProgression set', 2, 'Syntax: .individualProgression set $player $progressionLevel\nSets the player to the given progression level.');

File diff suppressed because it is too large Load Diff

View File

@@ -108,5 +108,28 @@ enum ProgressionState : uint8
PROGRESSION_WOTLK_TIER_5 = 16 // Ruby Sanctum PROGRESSION_WOTLK_TIER_5 = 16 // Ruby Sanctum
}; };
class IndividualProgression
{
public:
static IndividualProgression* instance();
questXpMapType questXpMap;
float vanillaPowerAdjustment, vanillaHealthAdjustment, tbcPowerAdjustment, tbcHealthAdjustment, vanillaHealingAdjustment, tbcHealingAdjustment, previousGearTuning;
bool enabled, questXpFix, hunterPetLevelFix, requirePreAQQuests, enforceGroupRules, fishingFix, simpleConfigOverride, questMoneyAtLevelCap;
int progressionLimit, startingProgression;
bool hasPassedProgression(Player* player, ProgressionState state) const;
bool isBeforeProgression(Player* player, ProgressionState state) const;
void UpdateProgressionState(Player* player, ProgressionState newState) const;
void CheckAdjustments(Player* player) const;
void ApplyGearStatsTuning(Player* player, float& computedAdjustment, ItemTemplate const* item) const;
void ApplyGearHealthTuning(Player* player, float& computedAdjustment, ItemTemplate const* item) const;
void AdjustVanillaStats(Player* player) const;
void AdjustTBCStats(Player* player) const;
void AdjustWotLKStats(Player* player) const;
static void AdjustStats(Player* player, float computedAdjustment, float computedHealingAdjustment);
};
#define sIndividualProgression IndividualProgression::instance()
#endif //AZEROTHCORE_INDIVIDUALPROGRESSION_H #endif //AZEROTHCORE_INDIVIDUALPROGRESSION_H

View File

@@ -0,0 +1,51 @@
#include "Chat.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Tokenize.h"
#include "IndividualProgression.h"
using namespace Acore::ChatCommands;
class individualProgression_commandscript : public CommandScript
{
public:
individualProgression_commandscript() : CommandScript("individualProgression_commandscript") { }
ChatCommandTable GetCommands() const override
{
static ChatCommandTable individualProgressionTable =
{
{ "set", HandleSetIndividualProgressionCommand, SEC_GAMEMASTER, Console::Yes },
};
static ChatCommandTable commandTable =
{
{ "individualProgression", individualProgressionTable },
};
return commandTable;
}
static bool HandleSetIndividualProgressionCommand(ChatHandler* handler, Optional<PlayerIdentifier> player, uint32 progressionLevel)
{
if (progressionLevel > PROGRESSION_WOTLK_TIER_5)
{
handler->SendSysMessage("Invalid progression level.");
return false;
}
Player* target = player->GetConnectedPlayer();
if (target)
{
sIndividualProgression->UpdateProgressionState(target, static_cast<ProgressionState>(progressionLevel));
handler->SendSysMessage("Progression state updated successfully");
}
return true;
}
};
void AddSC_individualProgression_commandscript()
{
new individualProgression_commandscript();
}

View File

@@ -27,7 +27,7 @@ public:
return true; return true;
} }
Player* target = ObjectAccessor::FindConnectedPlayer(player->GetGUID()); Player* target = ObjectAccessor::FindConnectedPlayer(player->GetGUID());
return target->GetPlayerSetting("mod-individual-progression", SETTING_PROGRESSION_STATE).value < PROGRESSION_NAXX40; return sIndividualProgression->isBeforeProgression(target, PROGRESSION_NAXX40);
} }
}; };

View File

@@ -107,7 +107,7 @@ public:
return true; return true;
} }
Player* target = ObjectAccessor::FindConnectedPlayer(player->GetGUID()); Player* target = ObjectAccessor::FindConnectedPlayer(player->GetGUID());
return target->GetPlayerSetting("mod-individual-progression", SETTING_PROGRESSION_STATE).value >= PROGRESSION_TBC_TIER_5; return sIndividualProgression->hasPassedProgression(target, PROGRESSION_TBC_TIER_5);
} }
EventMap events; EventMap events;