[Cleanup] Cleanup magic numbers (#2662)

* [Cleanup] Cleanup magic numbers

* renamed RACE_NODE
This commit is contained in:
Aeadoin 2022-12-20 11:31:42 -05:00 committed by GitHub
parent ed6194ad19
commit 900e1aecf6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 43 additions and 27 deletions

View File

@ -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

View File

@ -76,6 +76,7 @@
#include "classes.h"
#include "spdat.h"
#include "../common/rulesys.h"
#ifndef WIN32
#include <stdlib.h>
@ -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;
}

View File

@ -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);

View File

@ -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();
}
}

View File

@ -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();
}
}

View File

@ -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)