From 900e1aecf694bf4546301e65a7b42105482d2ba4 Mon Sep 17 00:00:00 2001 From: Aeadoin <109764533+Aeadoin@users.noreply.github.com> Date: Tue, 20 Dec 2022 11:31:42 -0500 Subject: [PATCH] [Cleanup] Cleanup magic numbers (#2662) * [Cleanup] Cleanup magic numbers * renamed RACE_NODE --- common/races.h | 1 + common/spdat.cpp | 4 +++- zone/bot.cpp | 37 +++++++++++++++++------------ zone/entity.cpp | 5 ++-- zone/gm_commands/showzonepoints.cpp | 2 +- zone/merc.cpp | 21 +++++++++------- 6 files changed, 43 insertions(+), 27 deletions(-) diff --git a/common/races.h b/common/races.h index 68e6fa061..3373c8353 100644 --- a/common/races.h +++ b/common/races.h @@ -1612,6 +1612,7 @@ namespace PlayerAppearance #define RACE_LUCLIN_731 731 #define RACE_PEGASUS_732 732 #define RACE_INTERACTIVE_OBJECT_2250 2250 +#define RACE_NODE_2254 2254 #endif diff --git a/common/spdat.cpp b/common/spdat.cpp index 164601458..02d001485 100644 --- a/common/spdat.cpp +++ b/common/spdat.cpp @@ -76,6 +76,7 @@ #include "classes.h" #include "spdat.h" +#include "../common/rulesys.h" #ifndef WIN32 #include @@ -747,8 +748,9 @@ bool IsCombatSkill(uint16 spell_id) bool IsResurrectionEffects(uint16 spell_id) { // spell id 756 is Resurrection Effects spell - if(IsValidSpell(spell_id) && (spell_id == 756 || spell_id == 757)) + if (IsValidSpell(spell_id) && (spell_id == RuleI(Character, ResurrectionSicknessSpellID) || spell_id == RuleI(Character, OldResurrectionSicknessSpellID))) { return true; + } return false; } diff --git a/zone/bot.cpp b/zone/bot.cpp index c58225ee4..de599718d 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -263,15 +263,17 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to //reapply some buffs uint32 buff_count = GetMaxTotalSlots(); for (uint32 j1 = 0; j1 < buff_count; j1++) { - if (!IsValidSpell(buffs[j1].spellid)) + if (!IsValidSpell(buffs[j1].spellid)) { continue; + } const SPDat_Spell_Struct& spell = spells[buffs[j1].spellid]; int NimbusEffect = GetNimbusEffect(buffs[j1].spellid); if (NimbusEffect) { - if (!IsNimbusEffectActive(NimbusEffect)) + if (!IsNimbusEffectActive(NimbusEffect)) { SendSpellEffect(NimbusEffect, 500, 0, 1, 3000, true); + } } for (int x1 = 0; x1 < EFFECT_COUNT; x1++) { @@ -287,8 +289,9 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to } else if (spell.base_value[x1] == -2) // WTF IS THIS { - if (GetRace() == 128 || GetRace() == 130 || GetRace() <= 12) + if (GetRace() == IKSAR || GetRace() == VAHSHIR || GetRace() <= GNOME) { SendIllusionPacket(GetRace(), GetGender(), spell.limit_value[x1], spell.max_value[x1]); + } } else if (spell.max_value[x1] > 0) { @@ -401,8 +404,6 @@ Bot::Bot(uint32 botID, uint32 botOwnerCharacterID, uint32 botSpellsID, double to } } } - - } else { bot_owner->Message(Chat::White, "&s for '%s'", BotDatabase::fail::LoadBuffs(), GetCleanName()); @@ -1205,21 +1206,25 @@ void Bot::GenerateBaseStats() void Bot::GenerateAppearance() { // Randomize facial appearance int iFace = 0; - if(GetRace() == 2) // Barbarian w/Tatoo + if (GetRace() == BARBARIAN) // Barbarian w/Tatoo + { iFace = zone->random.Int(0, 79); + } else + { iFace = zone->random.Int(0, 7); + } int iHair = 0; int iBeard = 0; int iBeardColor = 1; - if(GetRace() == 522) { + if (GetRace() == DRAKKIN) { iHair = zone->random.Int(0, 8); iBeard = zone->random.Int(0, 11); iBeardColor = zone->random.Int(0, 3); - } else if(GetGender()) { + } else if (GetGender()) { iHair = zone->random.Int(0, 2); - if(GetRace() == 8) { // Dwarven Females can have a beard + if (GetRace() == DWARF) { // Dwarven Females can have a beard if(zone->random.Int(1, 100) < 50) iFace += 10; } @@ -1230,24 +1235,26 @@ void Bot::GenerateAppearance() { } int iHairColor = 0; - if(GetRace() == 522) + if (GetRace() == DRAKKIN) { iHairColor = zone->random.Int(0, 3); - else + } else { iHairColor = zone->random.Int(0, 19); + } uint8 iEyeColor1 = (uint8)zone->random.Int(0, 9); uint8 iEyeColor2 = 0; - if(GetRace() == 522) + if (GetRace() == DRAKKIN) { iEyeColor1 = iEyeColor2 = (uint8)zone->random.Int(0, 11); - else if(zone->random.Int(1, 100) > 96) + } else if(zone->random.Int(1, 100) > 96) { iEyeColor2 = zone->random.Int(0, 9); - else + } else { iEyeColor2 = iEyeColor1; + } int iHeritage = 0; int iTattoo = 0; int iDetails = 0; - if(GetRace() == 522) { + if (GetRace() == DRAKKIN) { iHeritage = zone->random.Int(0, 6); iTattoo = zone->random.Int(0, 7); iDetails = zone->random.Int(0, 7); diff --git a/zone/entity.cpp b/zone/entity.cpp index 4a701df6b..7c865450a 100644 --- a/zone/entity.cpp +++ b/zone/entity.cpp @@ -5833,9 +5833,10 @@ void EntityList::DespawnGridNodes(int32 grid_id) { Mob *mob = m.second; if ( mob->IsNPC() && - mob->GetRace() == 2254 && + mob->GetRace() == RACE_NODE_2254 && mob->EntityVariableExists("grid_id") && - std::stoi(mob->GetEntityVariable("grid_id")) == grid_id) { + std::stoi(mob->GetEntityVariable("grid_id")) == grid_id) + { mob->Depop(); } } diff --git a/zone/gm_commands/showzonepoints.cpp b/zone/gm_commands/showzonepoints.cpp index 65f0bc37e..4b98217a0 100755 --- a/zone/gm_commands/showzonepoints.cpp +++ b/zone/gm_commands/showzonepoints.cpp @@ -5,7 +5,7 @@ void command_showzonepoints(Client *c, const Seperator *sep) auto &mob_list = entity_list.GetMobList(); for (auto itr : mob_list) { Mob *mob = itr.second; - if (mob->IsNPC() && mob->GetRace() == 2254) { + if (mob->IsNPC() && mob->GetRace() == RACE_NODE_2254) { mob->Depop(); } } diff --git a/zone/merc.cpp b/zone/merc.cpp index f5c7aed41..c3013a954 100644 --- a/zone/merc.cpp +++ b/zone/merc.cpp @@ -4363,19 +4363,23 @@ bool Merc::IsStanding() { float Merc::GetMaxMeleeRangeToTarget(Mob* target) { float result = 0; - if(target) { + if (target) { float size_mod = GetSize(); float other_size_mod = target->GetSize(); - if(GetRace() == 49 || GetRace() == 158 || GetRace() == 196) //For races with a fixed size + if (GetRace() == RACE_LAVA_DRAGON_49 || GetRace() == RACE_WURM_158 || GetRace() == RACE_GHOST_DRAGON_196) //For races with a fixed size + { size_mod = 60.0f; - else if (size_mod < 6.0) + } else if (size_mod < 6.0) { size_mod = 8.0f; + } - if(target->GetRace() == 49 || target->GetRace() == 158 || target->GetRace() == 196) //For races with a fixed size + if (target->GetRace() == RACE_LAVA_DRAGON_49 || target->GetRace() == RACE_WURM_158 || target->GetRace() == RACE_GHOST_DRAGON_196) //For races with a fixed size + { other_size_mod = 60.0f; - else if (other_size_mod < 6.0) + } else if (other_size_mod < 6.0) { other_size_mod = 8.0f; + } if (other_size_mod > size_mod) { size_mod = other_size_mod; @@ -4383,12 +4387,13 @@ float Merc::GetMaxMeleeRangeToTarget(Mob* target) { // this could still use some work, but for now it's an improvement.... - if (size_mod > 29) + if (size_mod > 29) { size_mod *= size_mod; - else if (size_mod > 19) + } else if (size_mod > 19) { size_mod *= size_mod * 2; - else + } else { size_mod *= size_mod * 4; + } // prevention of ridiculously sized hit boxes if (size_mod > 10000)