[Cleanup] Cleanup Body Type Code (#4366)

* [Cleanup] Cleanup Body Type-based Code

* Update bodytypes.cpp

* Final

* Update body_type.cpp

* Cleanup

* Cleanup

* Formatting

---------

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Alex King 2024-06-02 04:25:06 -04:00 committed by GitHub
parent 0c45d3b09e
commit 8640776a21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
39 changed files with 324 additions and 250 deletions

View File

@ -3,6 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.12)
SET(common_sources
base_packet.cpp
bazaar.cpp
bodytypes.cpp
classes.cpp
cli/eqemu_command_handler.cpp
compression.cpp

12
common/bodytypes.cpp Normal file
View File

@ -0,0 +1,12 @@
#include "../common/global_define.h"
#include "../common/bodytypes.h"
std::string BodyType::GetName(uint8 body_type_id)
{
return IsValid(body_type_id) ? body_type_names[body_type_id] : "UNKNOWN BODY TYPE";
}
bool BodyType::IsValid(uint8 body_type_id)
{
return body_type_names.find(body_type_id) != body_type_names.end();
}

View File

@ -18,52 +18,96 @@
#ifndef BODYTYPES_H
#define BODYTYPES_H
typedef enum {
BT_Humanoid = 1,
BT_Lycanthrope = 2,
BT_Undead = 3,
BT_Giant = 4,
BT_Construct = 5,
BT_Extraplanar = 6,
BT_Magical = 7, //this name might be a bit off,
BT_SummonedUndead = 8,
BT_RaidGiant = 9, //Velious era Raid Giant
BT_RaidColdain = 10, //Velious era Raid Coldain
BT_NoTarget = 11, //no name, can't target this bodytype
BT_Vampire = 12,
BT_Atenha_Ra = 13,
BT_Greater_Akheva = 14,
BT_Khati_Sha = 15,
BT_Seru = 16,
BT_Grieg_Veneficus = 17,
BT_Draz_Nurakk = 18,
BT_Zek = 19, //"creatures from the Plane of War."
BT_Luggald = 20,
BT_Animal = 21,
BT_Insect = 22,
BT_Monster = 23,
BT_Summoned = 24, //Elemental?
BT_Plant = 25,
BT_Dragon = 26,
BT_Summoned2 = 27,
BT_Summoned3 = 28,
BT_Dragon2 = 29, //database data indicates this is a dragon type (kunark and DoN?)
BT_VeliousDragon = 30, //might not be a tight set
BT_Familiar = 31,
BT_Dragon3 = 32,
BT_Boxes = 33,
BT_Muramite = 34, //tribal dudes
// ...
BT_NoTarget2 = 60,
// ...
BT_SwarmPet = 63, //Looks like weapon proc related temp pets and few misc pets, should not be used for checking swarm pets in general.
BT_MonsterSummon = 64,
// 65, trap or effect related?
BT_InvisMan = 66, //no name, seen on 'InvisMan', can be /targeted
BT_Special = 67
} bodyType;
/* bodytypes above 64 make the mob not show up */
#include "types.h"
#include <map>
#include <string>
constexpr int format_as(bodyType type) { return static_cast<int>(type); }
// body types above 64 make the mob invisible
namespace BodyType {
constexpr uint8 Humanoid = 1;
constexpr uint8 Lycanthrope = 2;
constexpr uint8 Undead = 3;
constexpr uint8 Giant = 4;
constexpr uint8 Construct = 5;
constexpr uint8 Extraplanar = 6;
constexpr uint8 Magical = 7; // this name might be a bit off,
constexpr uint8 SummonedUndead = 8;
constexpr uint8 RaidGiant = 9; // Velious era Raid Giant
constexpr uint8 RaidColdain = 10; // Velious era Raid Coldain
constexpr uint8 NoTarget = 11; // no name, can't target this bodytype
constexpr uint8 Vampire = 12;
constexpr uint8 AtenHaRa = 13;
constexpr uint8 GreaterAkheva = 14;
constexpr uint8 KhatiSha = 15;
constexpr uint8 Seru = 16;
constexpr uint8 GriegVeneficus = 17;
constexpr uint8 DrazNurakk = 18;
constexpr uint8 Zek = 19; //"creatures from the Plane of War."
constexpr uint8 Luggald = 20;
constexpr uint8 Animal = 21;
constexpr uint8 Insect = 22;
constexpr uint8 Monster = 23;
constexpr uint8 Summoned = 24; // Elemental?
constexpr uint8 Plant = 25;
constexpr uint8 Dragon = 26;
constexpr uint8 Summoned2 = 27;
constexpr uint8 Summoned3 = 28;
constexpr uint8 Dragon2 = 29; // database data indicates this is a dragon type (Kunark and DoN?)
constexpr uint8 VeliousDragon = 30; // might not be a tight set
constexpr uint8 Familiar = 31;
constexpr uint8 Dragon3 = 32;
constexpr uint8 Boxes = 33;
constexpr uint8 Muramite = 34; // tribal dudes
constexpr uint8 NoTarget2 = 60;
constexpr uint8 SwarmPet = 63; // Looks like weapon proc related temp pets and few misc pets, should not be used for checking swarm pets in general.
constexpr uint8 MonsterSummon = 64;
constexpr uint8 InvisibleMan = 66; // no name, seen on 'InvisMan', can be /targeted
constexpr uint8 Special = 67;
std::string GetName(uint8 body_type_id);
bool IsValid(uint8 body_type_id);
}
static std::map<uint8, std::string> body_type_names = {
{ BodyType::Humanoid, "Humanoid" },
{ BodyType::Lycanthrope, "Lycanthrope" },
{ BodyType::Undead, "Undead" },
{ BodyType::Giant, "Giant" },
{ BodyType::Construct, "Construct" },
{ BodyType::Extraplanar, "Extraplanar" },
{ BodyType::Magical, "Magical" },
{ BodyType::SummonedUndead, "Summoned Undead" },
{ BodyType::RaidGiant, "Raid Giant" },
{ BodyType::RaidColdain, "Raid Coldain" },
{ BodyType::NoTarget, "Untargetable" },
{ BodyType::Vampire, "Vampire" },
{ BodyType::AtenHaRa, "Aten Ha Ra" },
{ BodyType::GreaterAkheva, "Greater Akheva" },
{ BodyType::KhatiSha, "Khati Sha" },
{ BodyType::Seru, "Seru" },
{ BodyType::GriegVeneficus, "Grieg Veneficus" },
{ BodyType::DrazNurakk, "Draz Nurakk" },
{ BodyType::Zek, "Zek" },
{ BodyType::Luggald, "Luggald" },
{ BodyType::Animal, "Animal" },
{ BodyType::Insect, "Insect" },
{ BodyType::Monster, "Monster" },
{ BodyType::Summoned, "Summoned" },
{ BodyType::Plant, "Plant" },
{ BodyType::Dragon, "Dragon" },
{ BodyType::Summoned2, "Summoned 2" },
{ BodyType::Summoned3, "Summoned 3" },
{ BodyType::Dragon2, "Dragon 2" },
{ BodyType::VeliousDragon, "Velious Dragon" },
{ BodyType::Familiar, "Familiar" },
{ BodyType::Dragon3, "Dragon 3" },
{ BodyType::Boxes, "Boxes" },
{ BodyType::Muramite, "Muramite" },
{ BodyType::NoTarget2, "Untargetable 2" },
{ BodyType::SwarmPet, "Swarm Pet" },
{ BodyType::MonsterSummon, "Monster Summon" },
{ BodyType::InvisibleMan, "Invisible Man" },
{ BodyType::Special, "Special" },
};
#endif

View File

@ -206,62 +206,6 @@ std::string EQ::constants::GetFlyModeName(int8 flymode_id)
return EQ::constants::GetFlyModeMap().find(flymode_id)->second;
}
const std::map<bodyType, std::string>& EQ::constants::GetBodyTypeMap()
{
static const std::map<bodyType, std::string> bodytype_map = {
{ BT_Humanoid, "Humanoid" },
{ BT_Lycanthrope, "Lycanthrope" },
{ BT_Undead, "Undead" },
{ BT_Giant, "Giant" },
{ BT_Construct, "Construct" },
{ BT_Extraplanar, "Extraplanar" },
{ BT_Magical, "Magical" },
{ BT_SummonedUndead, "Summoned Undead" },
{ BT_RaidGiant, "Raid Giant" },
{ BT_RaidColdain, "Raid Coldain" },
{ BT_NoTarget, "Untargetable" },
{ BT_Vampire, "Vampire" },
{ BT_Atenha_Ra, "Aten Ha Ra" },
{ BT_Greater_Akheva, "Greater Akheva" },
{ BT_Khati_Sha, "Khati Sha" },
{ BT_Seru, "Seru" },
{ BT_Grieg_Veneficus, "Grieg Veneficus" },
{ BT_Draz_Nurakk, "Draz Nurakk" },
{ BT_Zek, "Zek" },
{ BT_Luggald, "Luggald" },
{ BT_Animal, "Animal" },
{ BT_Insect, "Insect" },
{ BT_Monster, "Monster" },
{ BT_Summoned, "Summoned" },
{ BT_Plant, "Plant" },
{ BT_Dragon, "Dragon" },
{ BT_Summoned2, "Summoned 2" },
{ BT_Summoned3, "Summoned 3" },
{ BT_Dragon2, "Dragon 2" },
{ BT_VeliousDragon, "Velious Dragon" },
{ BT_Familiar, "Familiar" },
{ BT_Dragon3, "Dragon 3" },
{ BT_Boxes, "Boxes" },
{ BT_Muramite, "Muramite" },
{ BT_NoTarget2, "Untargetable 2" },
{ BT_SwarmPet, "Swarm Pet" },
{ BT_MonsterSummon, "Monster Summon" },
{ BT_InvisMan, "Invisible Man" },
{ BT_Special, "Special" },
};
return bodytype_map;
}
std::string EQ::constants::GetBodyTypeName(bodyType bodytype_id)
{
if (EQ::constants::GetBodyTypeMap().find(bodytype_id) != EQ::constants::GetBodyTypeMap().end()) {
return EQ::constants::GetBodyTypeMap().find(bodytype_id)->second;
}
return std::string();
}
const std::map<uint8, std::string>& EQ::constants::GetAccountStatusMap()
{
static const std::map<uint8, std::string> account_status_map = {

View File

@ -397,9 +397,6 @@ namespace EQ
extern const std::map<int8, std::string>& GetFlyModeMap();
std::string GetFlyModeName(int8 flymode_id);
extern const std::map<bodyType, std::string>& GetBodyTypeMap();
std::string GetBodyTypeName(bodyType bodytype_id);
extern const std::map<uint8, std::string>& GetAccountStatusMap();
std::string GetAccountStatusName(uint8 account_status);

View File

@ -1292,7 +1292,7 @@ int EQ::ItemInstance::GetItemBaneDamageRace(bool augments) const
return race;
}
int EQ::ItemInstance::GetItemBaneDamageBody(bodyType against, bool augments) const
int EQ::ItemInstance::GetItemBaneDamageBody(uint8 against, bool augments) const
{
int64 damage = 0;
const auto item = GetItem();

View File

@ -265,7 +265,7 @@ namespace EQ
// these two are just quick checks
int GetItemBaneDamageBody(bool augments = false) const;
int GetItemBaneDamageRace(bool augments = false) const;
int GetItemBaneDamageBody(bodyType against, bool augments = false) const;
int GetItemBaneDamageBody(uint8 against, bool augments = false) const;
int GetItemBaneDamageRace(uint16 against, bool augments = false) const;
int GetItemMagical(bool augments = false) const;
int GetItemHP(bool augments = false) const;

View File

@ -49,6 +49,7 @@ public:
// these are the base definitions for command_subsettings and can be over-ridden by the database
std::vector<CommandSubsettingsRepository::CommandSubsettings> static_records = {
{.parent_command = "find", .sub_command = "aa", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findaa"},
{.parent_command = "find", .sub_command = "body_type", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findbodytype"},
{.parent_command = "find", .sub_command = "bug_category", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findbugcategory"},
{.parent_command = "find", .sub_command = "character", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findcharacter"},
{.parent_command = "find", .sub_command = "class", .access_level = AccountStatus::QuestTroupe, .top_level_aliases = "findclass"},

View File

@ -222,7 +222,7 @@ void NPC::DescribeAggro(Client *to_who, Mob *mob, bool verbose) {
if (
GetLevel() < RuleI(Aggro, MinAggroLevel) &&
mob->GetLevelCon(GetLevel()) == ConsiderColor::Gray &&
GetBodyType() != BT_Undead &&
GetBodyType() != BodyType::Undead &&
!AlwaysAggro()
) {
to_who->Message(
@ -496,7 +496,7 @@ bool Mob::CheckWillAggro(Mob *mob) {
RuleB(Aggro, UseLevelAggro) &&
(
GetLevel() >= RuleI(Aggro, MinAggroLevel) ||
GetBodyType() == BT_Undead ||
GetBodyType() == BodyType::Undead ||
AlwaysAggro() ||
(
mob->IsClient() &&
@ -524,7 +524,7 @@ bool Mob::CheckWillAggro(Mob *mob) {
} else {
if (
(
(RuleB(Aggro, UndeadAlwaysAggro) && GetBodyType() == BT_Undead) ||
(RuleB(Aggro, UndeadAlwaysAggro) && GetBodyType() == BodyType::Undead) ||
(GetINT() <= RuleI(Aggro, IntAggroThreshold)) ||
AlwaysAggro() ||
(
@ -671,9 +671,9 @@ bool Mob::IsAttackAllowed(Mob *target, bool isSpellAttack)
target_owner = nullptr;
//cannot hurt untargetable mobs
bodyType bt = target->GetBodyType();
uint8 bt = target->GetBodyType();
if(bt == BT_NoTarget || bt == BT_NoTarget2) {
if(bt == BodyType::NoTarget || bt == BodyType::NoTarget2) {
if (RuleB(Pets, UnTargetableSwarmPet)) {
if (target->IsNPC()) {
if (!target->CastToNPC()->GetSwarmOwner()) {

View File

@ -52,7 +52,7 @@ Beacon::Beacon(const glm::vec4 &in_pos, int lifetime) : Mob(
Gender::Male, // in_gender
Race::InvisibleMan, // in_race
Class::None, // in_class
BT_NoTarget, // in_bodytype
BodyType::NoTarget, // in_bodytype
Deity::Unknown, // in_deity
0, // in_level
0, // in_npctype_id

View File

@ -5481,13 +5481,13 @@ bool Bot::IsImmuneToSpell(uint16 spell_id, Mob *caster) {
if (!Result) {
if (caster->IsBot()) {
if (spells[spell_id].target_type == ST_Undead) {
if ((GetBodyType() != BT_SummonedUndead) && (GetBodyType() != BT_Undead) && (GetBodyType() != BT_Vampire)) {
if ((GetBodyType() != BodyType::SummonedUndead) && (GetBodyType() != BodyType::Undead) && (GetBodyType() != BodyType::Vampire)) {
LogSpellsDetail("Bot's target is not an undead");
return true;
}
}
if (spells[spell_id].target_type == ST_Summoned) {
if ((GetBodyType() != BT_SummonedUndead) && (GetBodyType() != BT_Summoned) && (GetBodyType() != BT_Summoned2) && (GetBodyType() != BT_Summoned3)) {
if ((GetBodyType() != BodyType::SummonedUndead) && (GetBodyType() != BodyType::Summoned) && (GetBodyType() != BodyType::Summoned2) && (GetBodyType() != BodyType::Summoned3)) {
LogSpellsDetail("Bot's target is not a summoned creature");
return true;
}

View File

@ -753,19 +753,19 @@ namespace ActionableTarget
verified_friendly = target_mob;
break;
case BCEnum::TT_Animal:
if (target_mob && target_mob->GetBodyType() == BT_Animal)
if (target_mob && target_mob->GetBodyType() == BodyType::Animal)
verified_friendly = target_mob;
break;
case BCEnum::TT_Undead:
if (target_mob && target_mob->GetBodyType() == BT_Undead)
if (target_mob && target_mob->GetBodyType() == BodyType::Undead)
verified_friendly = target_mob;
break;
case BCEnum::TT_Summoned:
if (target_mob && target_mob->GetBodyType() == BT_Summoned)
if (target_mob && target_mob->GetBodyType() == BodyType::Summoned)
verified_friendly = target_mob;
break;
case BCEnum::TT_Plant:
if (target_mob && target_mob->GetBodyType() == BT_Plant)
if (target_mob && target_mob->GetBodyType() == BodyType::Plant)
verified_friendly = target_mob;
break;
case BCEnum::TT_Corpse:
@ -800,19 +800,19 @@ namespace ActionableTarget
Mob* verified_enemy = nullptr;
switch (target_type) {
case BCEnum::TT_Animal:
if (target_mob->GetBodyType() == BT_Animal)
if (target_mob->GetBodyType() == BodyType::Animal)
verified_enemy = target_mob;
break;
case BCEnum::TT_Undead:
if (target_mob->GetBodyType() == BT_Undead)
if (target_mob->GetBodyType() == BodyType::Undead)
verified_enemy = target_mob;
break;
case BCEnum::TT_Summoned:
if (target_mob->GetBodyType() == BT_Summoned)
if (target_mob->GetBodyType() == BodyType::Summoned)
verified_enemy = target_mob;
break;
case BCEnum::TT_Plant:
if (target_mob->GetBodyType() == BT_Plant)
if (target_mob->GetBodyType() == BodyType::Plant)
verified_enemy = target_mob;
break;
case BCEnum::TT_Single:

View File

@ -771,9 +771,9 @@ bool Bot::BotCastNuke(Mob* tar, uint8 botLevel, uint8 botClass, BotSpell& botSpe
}
if (botClass == Class::Magician || botClass == Class::ShadowKnight || botClass == Class::Necromancer || botClass == Class::Paladin || botClass == Class::Ranger || botClass == Class::Druid || botClass == Class::Cleric) {
if (tar->GetBodyType() == BT_Undead || tar->GetBodyType() == BT_SummonedUndead || tar->GetBodyType() == BT_Vampire)
if (tar->GetBodyType() == BodyType::Undead || tar->GetBodyType() == BodyType::SummonedUndead || tar->GetBodyType() == BodyType::Vampire)
botSpell = GetBestBotSpellForNukeByTargetType(this, ST_Undead);
else if (tar->GetBodyType() == BT_Summoned || tar->GetBodyType() == BT_Summoned2 || tar->GetBodyType() == BT_Summoned3)
else if (tar->GetBodyType() == BodyType::Summoned || tar->GetBodyType() == BodyType::Summoned2 || tar->GetBodyType() == BodyType::Summoned3)
botSpell = GetBestBotSpellForNukeByTargetType(this, ST_Summoned);
}

View File

@ -95,7 +95,7 @@ Client::Client(EQStreamInterface *ieqs) : Mob(
Gender::Male, // in_gender
Race::Doug, // in_race
Class::None, // in_class
BT_Humanoid, // in_bodytype
BodyType::Humanoid, // in_bodytype
Deity::Unknown, // in_deity
0, // in_level
0, // in_npctype_id

View File

@ -11882,8 +11882,8 @@ void Client::Handle_OP_PickPocket(const EQApplicationPacket *app)
}
else if (victim->IsNPC()) {
auto body = victim->GetBodyType();
if (body == BT_Humanoid || body == BT_Monster || body == BT_Giant ||
body == BT_Lycanthrope) {
if (body == BodyType::Humanoid || body == BodyType::Monster || body == BodyType::Giant ||
body == BodyType::Lycanthrope) {
victim->CastToNPC()->PickPocket(this);
return;
}
@ -14999,9 +14999,9 @@ void Client::Handle_OP_TargetCommand(const EQApplicationPacket *app)
if (nt) {
if (GetGM() || (!nt->IsInvisible(this) && (DistanceSquared(m_Position, nt->GetPosition()) <= TARGETING_RANGE*TARGETING_RANGE))) {
if (nt->GetBodyType() == BT_NoTarget2 ||
nt->GetBodyType() == BT_Special ||
nt->GetBodyType() == BT_NoTarget) {
if (nt->GetBodyType() == BodyType::NoTarget2 ||
nt->GetBodyType() == BodyType::Special ||
nt->GetBodyType() == BodyType::NoTarget) {
can_target = false;
}
else {
@ -15144,8 +15144,8 @@ void Client::Handle_OP_TargetMouse(const EQApplicationPacket *app)
GetTarget()->IsTargeted(1);
return;
}
else if (GetTarget()->GetBodyType() == BT_NoTarget2 || GetTarget()->GetBodyType() == BT_Special
|| GetTarget()->GetBodyType() == BT_NoTarget)
else if (GetTarget()->GetBodyType() == BodyType::NoTarget2 || GetTarget()->GetBodyType() == BodyType::Special
|| GetTarget()->GetBodyType() == BodyType::NoTarget)
{
auto message = fmt::format(
"[{}] attempting to target something untargetable [{}] bodytype [{}]",

View File

@ -70,7 +70,7 @@ Corpse::Corpse(
npc->GetGender(), // in_gender
npc->GetRace(), // in_race
npc->GetClass(), // in_class
BT_Humanoid, // in_bodytype
BodyType::Humanoid, // in_bodytype
npc->GetDeity(), // in_deity
npc->GetLevel(), // in_level
npc->GetNPCTypeID(), // in_npctype_id
@ -189,7 +189,7 @@ Corpse::Corpse(Client *c, int32 rez_exp, KilledByTypes in_killed_by) : Mob(
c->GetGender(), // in_gender
c->GetRace(), // in_race
c->GetClass(), // in_class
BT_Humanoid, // in_bodytype
BodyType::Humanoid, // in_bodytype
c->GetDeity(), // in_deity
c->GetLevel(), // in_level
0, // in_npctype_id
@ -495,7 +495,7 @@ Corpse::Corpse(
gender, // in_gender
race, // in_race
class_, // in_class
BT_Humanoid, // in_bodytype
BodyType::Humanoid, // in_bodytype
deity, // in_deity
level, // in_level
0, // in_npctype_id

View File

@ -4740,9 +4740,9 @@ std::string Perl__getlanguagename(uint8 language_id)
return quest_manager.getlanguagename(language_id);
}
std::string Perl__getbodytypename(uint32 bodytype_id)
std::string Perl__getbodytypename(uint8 body_type_id)
{
return quest_manager.getbodytypename(bodytype_id);
return quest_manager.getbodytypename(body_type_id);
}
std::string Perl__getconsiderlevelname(uint8 consider_level)

View File

@ -40,7 +40,7 @@ Encounter::Encounter(const char *enc_name) : Mob(
Gender::Male, // in_gender
Race::InvisibleMan, // in_race
Class::None, // in_class
BT_NoTarget, // in_bodytype
BodyType::NoTarget, // in_bodytype
Deity::Unknown, // in_deity
0, // in_level
0, // in_npcype_id

View File

@ -5059,7 +5059,7 @@ uint32 EntityList::CheckNPCsClose(Mob *center)
while (it != npc_list.end()) {
NPC *cur = it->second;
if (!cur || cur == center || cur->IsPet() || cur->GetClass() == Class::LDoNTreasure ||
cur->GetBodyType() == BT_NoTarget || cur->GetBodyType() == BT_Special) {
cur->GetBodyType() == BodyType::NoTarget || cur->GetBodyType() == BodyType::Special) {
++it;
continue;
}
@ -5419,9 +5419,9 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count)
while (it != npc_list.end()) {
if (!it->second->IsPet()
&& it->second->GetClass() != Class::LDoNTreasure
&& it->second->GetBodyType() != BT_NoTarget
&& it->second->GetBodyType() != BT_NoTarget2
&& it->second->GetBodyType() != BT_Special)
&& it->second->GetBodyType() != BodyType::NoTarget
&& it->second->GetBodyType() != BodyType::NoTarget2
&& it->second->GetBodyType() != BodyType::Special)
npc_count++;
++it;
}
@ -5440,9 +5440,9 @@ void EntityList::AddLootToNPCS(uint32 item_id, uint32 count)
while (it != npc_list.end()) {
if (!it->second->IsPet()
&& it->second->GetClass() != Class::LDoNTreasure
&& it->second->GetBodyType() != BT_NoTarget
&& it->second->GetBodyType() != BT_NoTarget2
&& it->second->GetBodyType() != BT_Special)
&& it->second->GetBodyType() != BodyType::NoTarget
&& it->second->GetBodyType() != BodyType::NoTarget2
&& it->second->GetBodyType() != BodyType::Special)
npcs[i++] = it->second;
++it;
}
@ -5520,7 +5520,7 @@ void EntityList::ExpeditionWarning(uint32 minutes_left)
safe_delete(outapp);
}
Mob *EntityList::GetClosestMobByBodyType(Mob *sender, bodyType BodyType, bool skip_client_pets)
Mob *EntityList::GetClosestMobByBodyType(Mob *sender, uint8 BodyType, bool skip_client_pets)
{
if (!sender)

View File

@ -505,7 +505,7 @@ public:
void TryWakeTheDead(Mob* sender, Mob* target, int32 spell_id, uint32 max_distance, uint32 duration, uint32 amount_pets);
NPC* GetClosestBanker(Mob* sender, uint32 &distance);
void CameraEffect(uint32 duration, float intensity);
Mob* GetClosestMobByBodyType(Mob* sender, bodyType BodyType, bool skip_client_pets=false);
Mob* GetClosestMobByBodyType(Mob* sender, uint8 BodyType, bool skip_client_pets=false);
void ForceGroupUpdate(uint32 gid);
void SendGroupLeave(uint32 gid, const char *name);
void SendGroupJoin(uint32 gid, const char *name);

View File

@ -50,7 +50,7 @@ void Mob::CheckFlee()
}
// Undead do not flee
if (GetBodyType() == BT_Undead) {
if (GetBodyType() == BodyType::Undead) {
return;
}

View File

@ -1,5 +1,6 @@
#include "../client.h"
#include "find/aa.cpp"
#include "find/body_type.cpp"
#include "find/bug_category.cpp"
#include "find/character.cpp"
#include "find/class.cpp"
@ -33,6 +34,7 @@ void command_find(Client *c, const Seperator *sep)
std::vector<Cmd> commands = {
Cmd{.cmd = "aa", .u = "aa [Search Criteria]", .fn = FindAA, .a = {"#findaa"}},
Cmd{.cmd = "body_type", .u = "body_type [Search Criteria]", .fn = FindBodyType, .a = {"#findbodytype"}},
Cmd{.cmd = "bug_category", .u = "bug_category [Search Criteria]", .fn = FindBugCategory, .a = {"#findbugcategory"}},
Cmd{.cmd = "character", .u = "character [Search Criteria]", .fn = FindCharacter, .a = {"#findcharacter"}},
Cmd{.cmd = "class", .u = "class [Search Criteria]", .fn = FindClass, .a = {"#findclass"}},

View File

@ -0,0 +1,62 @@
#include "../../client.h"
void FindBodyType(Client *c, const Seperator *sep)
{
if (sep->IsNumber(2)) {
const uint8 body_type_id = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[2]));
const std::string& body_type_name = BodyType::GetName(body_type_id);
if (Strings::EqualFold(body_type_name, "UNKNOWN BODY TYPE")) {
c->Message(
Chat::White,
fmt::format(
"Body Type {} does not exist.",
body_type_id
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"Body Type {} | {}",
body_type_id,
body_type_name
).c_str()
);
return;
}
const std::string& search_criteria = Strings::ToLower(sep->argplus[2]);
uint32 found_count = 0;
for (const auto& e : body_type_names) {
const std::string& body_type_name_lower = Strings::ToLower(e.second);
if (!Strings::Contains(body_type_name_lower, search_criteria)) {
continue;
}
c->Message(
Chat::White,
fmt::format(
"Body Type {} | {}",
e.first,
e.second
).c_str()
);
found_count++;
}
c->Message(
Chat::White,
fmt::format(
"{} Body Type{} found matching '{}'.",
found_count,
found_count != 1 ? "s" : "",
sep->argplus[2]
).c_str()
);
}

View File

@ -100,21 +100,25 @@ void command_npcedit(Client *c, const Seperator *sep)
}
} else if (!strcasecmp(sep->arg[1], "bodytype")) {
if (sep->IsNumber(2)) {
auto body_type_id = static_cast<uint8_t>(Strings::ToUnsignedInt(sep->arg[2]));
auto body_type_name = EQ::constants::GetBodyTypeName(static_cast<bodyType>(body_type_id));
const uint8 body_type_id = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[2]));
const std::string& body_type_name = BodyType::GetName(body_type_id);
if (Strings::EqualFold(body_type_name, "UNKNOWN BODY TYPE")) {
c->Message(
Chat::White,
fmt::format(
"Body Type {} does not exist.",
body_type_id
).c_str()
);
return;
}
n.bodytype = body_type_id;
d = fmt::format(
"{} is now using Body Type {}.",
"{} is now using Body Type {} ({}).",
npc_id_string,
(
!body_type_name.empty() ?
fmt::format(
"{} ({})",
body_type_name,
body_type_id
) :
std::to_string(body_type_id)
)
body_type_name,
body_type_id
);
} else {
c->Message(Chat::White, "Usage: #npcedit bodytype [Body Type ID] - Sets an NPC's Bodytype");

View File

@ -3790,8 +3790,8 @@ std::string lua_get_language_name(uint8 language_id) {
return quest_manager.getlanguagename(language_id);
}
std::string lua_get_body_type_name(uint32 bodytype_id) {
return quest_manager.getbodytypename(bodytype_id);
std::string lua_get_body_type_name(uint8 body_type_id) {
return quest_manager.getbodytypename(body_type_id);
}
std::string lua_get_consider_level_name(uint8 consider_level) {

View File

@ -1995,9 +1995,9 @@ void Lua_Mob::SetRunning(bool running) {
self->SetRunning(running);
}
void Lua_Mob::SetBodyType(int new_body, bool overwrite_orig) {
void Lua_Mob::SetBodyType(uint8 new_body, bool overwrite_orig) {
Lua_Safe_Call_Void();
self->SetBodyType(static_cast<bodyType>(new_body), overwrite_orig);
self->SetBodyType(new_body, overwrite_orig);
}
void Lua_Mob::SetTargetable(bool on) {
@ -3869,7 +3869,7 @@ luabind::scope lua_register_mob() {
.def("SetAllowBeneficial", (void(Lua_Mob::*)(bool))&Lua_Mob::SetAllowBeneficial)
.def("SetAppearance", (void(Lua_Mob::*)(int))&Lua_Mob::SetAppearance)
.def("SetAppearance", (void(Lua_Mob::*)(int,bool))&Lua_Mob::SetAppearance)
.def("SetBodyType", (void(Lua_Mob::*)(int,bool))&Lua_Mob::SetBodyType)
.def("SetBodyType", (void(Lua_Mob::*)(uint8,bool))&Lua_Mob::SetBodyType)
.def("SetBucket", (void(Lua_Mob::*)(std::string,std::string))&Lua_Mob::SetBucket)
.def("SetBucket", (void(Lua_Mob::*)(std::string,std::string,std::string))&Lua_Mob::SetBucket)
.def("SetBuffDuration", (void(Lua_Mob::*)(int))&Lua_Mob::SetBuffDuration)

View File

@ -399,7 +399,7 @@ public:
void RemoveAllNimbusEffects();
bool IsRunning();
void SetRunning(bool running);
void SetBodyType(int new_body, bool overwrite_orig);
void SetBodyType(uint8 new_body, bool overwrite_orig);
void SetTargetable(bool on);
void ModSkillDmgTaken(int skill, int value);
int GetModSkillDmgTaken(int skill);

View File

@ -52,7 +52,7 @@ Mob::Mob(
uint8 in_gender,
uint16 in_race,
uint8 in_class,
bodyType in_bodytype,
uint8 in_bodytype,
uint8 in_deity,
uint8 in_level,
uint32 in_npctype_id,
@ -696,14 +696,14 @@ bool Mob::IsInvisible(Mob* other) const
}
//check invis vs. undead
if (other->GetBodyType() == BT_Undead || other->GetBodyType() == BT_SummonedUndead) {
if (other->GetBodyType() == BodyType::Undead || other->GetBodyType() == BodyType::SummonedUndead) {
if (invisible_undead && (invisible_undead > other->SeeInvisibleUndead())) {
return true;
}
}
//check invis vs. animals. //TODO: should we have a specific see invisible animal stat or this how live does it?
if (other->GetBodyType() == BT_Animal){
if (other->GetBodyType() == BodyType::Animal){
if (invisible_animals && (invisible_animals > other->SeeInvisible())) {
return true;
}
@ -2913,7 +2913,7 @@ void Mob::ShowStats(Client* c)
}
// Body
auto bodytype_name = EQ::constants::GetBodyTypeName(t->GetBodyType());
auto bodytype_name = BodyType::GetName(t->GetBodyType());
c->Message(
Chat::White,
fmt::format(
@ -7073,7 +7073,7 @@ bool Mob::IsControllableBoat() const {
);
}
void Mob::SetBodyType(bodyType new_body, bool overwrite_orig) {
void Mob::SetBodyType(uint8 new_body, bool overwrite_orig) {
bool needs_spawn_packet = false;
if(bodytype == 11 || bodytype >= 65 || new_body == 11 || new_body >= 65) {
needs_spawn_packet = true;

View File

@ -143,7 +143,7 @@ public:
uint8 in_gender,
uint16 in_race,
uint8 in_class,
bodyType in_bodytype,
uint8 in_bodytype,
uint8 in_deity,
uint8 in_level,
uint32 in_npctype_id,
@ -236,7 +236,7 @@ public:
bool CheckHitChance(Mob* attacker, DamageHitInfo &hit);
bool RollMeleeCritCheck(Mob *defender, EQ::skills::SkillType skill);
inline bool CanUndeadSlay() { return static_cast<bool>(GetUndeadSlayRate());}
inline bool IsUndeadForSlay() { return (GetBodyType() == BT_Undead || GetBodyType() == BT_SummonedUndead || GetBodyType() == BT_Vampire); }
inline bool IsUndeadForSlay() { return (GetBodyType() == BodyType::Undead || GetBodyType() == BodyType::SummonedUndead || GetBodyType() == BodyType::Vampire); }
int GetUndeadSlayRate();
void DoUndeadSlay(DamageHitInfo &hit, int crit_mod);
void TryCriticalHit(Mob *defender, DamageHitInfo &hit, ExtraAttackOptions *opts = nullptr);
@ -1098,9 +1098,9 @@ public:
int GetPetACBonusFromOwner();
int GetPetATKBonusFromOwner();
inline const bodyType GetBodyType() const { return bodytype; }
inline const bodyType GetOrigBodyType() const { return orig_bodytype; }
void SetBodyType(bodyType new_body, bool overwrite_orig);
inline const uint8 GetBodyType() const { return bodytype; }
inline const uint8 GetOrigBodyType() const { return orig_bodytype; }
void SetBodyType(uint8 new_body, bool overwrite_orig);
bool invulnerable;
bool qglobal;
@ -1575,8 +1575,8 @@ protected:
uint8 base_gender;
uint16 base_race;
uint8 class_;
bodyType bodytype;
bodyType orig_bodytype;
uint8 bodytype;
uint8 orig_bodytype;
uint16 deity;
uint8 level;
uint8 orig_level;

View File

@ -443,7 +443,7 @@ void Mob::AI_Start(uint32 iMoveDelay) {
AI_feign_remember_timer = std::make_unique<Timer>(AIfeignremember_delay);
AI_scan_door_open_timer = std::make_unique<Timer>(AI_scan_door_open_interval);
if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) {
if (GetBodyType() == BodyType::Animal && !RuleB(NPC, AnimalsOpenDoors)) {
SetCanOpenDoors(false);
}

View File

@ -76,7 +76,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
npc_type_data->gender,
npc_type_data->race,
npc_type_data->class_,
(bodyType) npc_type_data->bodytype,
npc_type_data->bodytype,
npc_type_data->deity,
npc_type_data->level,
npc_type_data->npc_id,
@ -451,7 +451,7 @@ NPC::NPC(const NPCType *npc_type_data, Spawn2 *in_respawn, const glm::vec4 &posi
RestoreMana();
if (GetBodyType() == BT_Animal && !RuleB(NPC, AnimalsOpenDoors)) {
if (GetBodyType() == BodyType::Animal && !RuleB(NPC, AnimalsOpenDoors)) {
m_can_open_doors = false;
}
@ -582,7 +582,7 @@ bool NPC::Process()
Mob* owner = entity_list.GetMob(ownerid);
if (owner != 0)
{
//if(GetBodyType() != BT_SwarmPet)
//if(GetBodyType() != BodyType::SwarmPet)
// owner->SetPetID(0);
ownerid = 0;
petid = 0;
@ -1183,7 +1183,14 @@ NPC* NPC::SpawnNPC(const char* spawncommand, const glm::vec4& position, Client*
}
if (npc->bodytype) {
client->Message(Chat::White, fmt::format("Body Type | {} ({})", EQ::constants::GetBodyTypeName(npc->bodytype), npc->bodytype).c_str());
client->Message(
Chat::White,
fmt::format(
"Body Type | {} ({})",
BodyType::GetName(npc->bodytype),
npc->bodytype
).c_str()
);
}
client->Message(Chat::White, "New NPC spawned!");
@ -1836,7 +1843,7 @@ void NPC::Disarm(Client* client, int chance) {
int matslot = eslot == EQ::invslot::slotPrimary ? EQ::textures::weaponPrimary : EQ::textures::weaponSecondary;
if (matslot != -1)
SendWearChange(matslot);
if ((CastToMob()->GetBodyType() == BT_Humanoid || CastToMob()->GetBodyType() == BT_Summoned) && eslot == EQ::invslot::slotPrimary)
if ((CastToMob()->GetBodyType() == BodyType::Humanoid || CastToMob()->GetBodyType() == BodyType::Summoned) && eslot == EQ::invslot::slotPrimary)
Say("Ahh! My weapon!");
client->MessageString(Chat::Skills, DISARM_SUCCESS, GetCleanName());
if (chance != 1000)
@ -2200,7 +2207,7 @@ void NPC::PetOnSpawn(NewSpawn_Struct* ns)
//Not recommended if using above (However, this will work better on older clients).
if (RuleB(Pets, UnTargetableSwarmPet)) {
ns->spawn.bodytype = BT_NoTarget;
ns->spawn.bodytype = BodyType::NoTarget;
}
if (

View File

@ -313,7 +313,7 @@ public:
float GetSlowMitigation() const { return slow_mitigation; }
float GetAttackSpeed() const {return attack_speed;}
int GetAttackDelay() const {return attack_delay;}
bool IsAnimal() const { return(bodytype == BT_Animal); }
bool IsAnimal() const { return(bodytype == BodyType::Animal); }
uint16 GetPetSpellID() const {return pet_spell_id;}
void SetPetSpellID(uint16 amt) {pet_spell_id = amt;}
uint32 GetMaxDamage(uint8 tlevel);

View File

@ -2309,14 +2309,14 @@ bool Perl_Mob_IsRunning(Mob* self) // @categories Script Utility
return self->IsRunning();
}
void Perl_Mob_SetBodyType(Mob* self, int32 type) // @categories Stats and Attributes
void Perl_Mob_SetBodyType(Mob* self, uint8 body_type_id) // @categories Stats and Attributes
{
self->SetBodyType(static_cast<bodyType>(type), false);
self->SetBodyType(body_type_id, false);
}
void Perl_Mob_SetBodyType(Mob* self, int32 type, bool overwrite_orig) // @categories Stats and Attributes
void Perl_Mob_SetBodyType(Mob* self, uint8 body_type_id, bool overwrite_orig) // @categories Stats and Attributes
{
self->SetBodyType(static_cast<bodyType>(type), overwrite_orig);
self->SetBodyType(body_type_id, overwrite_orig);
}
void Perl_Mob_SetDeltas(Mob* self, float delta_x, float delta_y, float delta_z, float delta_h) // @categories Script Utility
@ -4023,8 +4023,8 @@ void perl_register_mob()
package.add("SetAllowBeneficial", &Perl_Mob_SetAllowBeneficial);
package.add("SetAppearance", (void(*)(Mob*, int))&Perl_Mob_SetAppearance);
package.add("SetAppearance", (void(*)(Mob*, int, bool))&Perl_Mob_SetAppearance);
package.add("SetBodyType", (void(*)(Mob*, int32))&Perl_Mob_SetBodyType);
package.add("SetBodyType", (void(*)(Mob*, int32, bool))&Perl_Mob_SetBodyType);
package.add("SetBodyType", (void(*)(Mob*, uint8))&Perl_Mob_SetBodyType);
package.add("SetBodyType", (void(*)(Mob*, uint8, bool))&Perl_Mob_SetBodyType);
package.add("SetBucket", (void(*)(Mob*, std::string, std::string))&Perl_Mob_SetBucket);
package.add("SetBucket", (void(*)(Mob*, std::string, std::string, std::string))&Perl_Mob_SetBucket);
package.add("SetBuffDuration", (void(*)(Mob*, int))&Perl_Mob_SetBuffDuration);

View File

@ -1483,8 +1483,8 @@ std::string QuestManager::getlanguagename(uint8 language_id) {
return EQ::constants::GetLanguageName(language_id);
}
std::string QuestManager::getbodytypename(uint32 bodytype_id) {
return EQ::constants::GetBodyTypeName(static_cast<bodyType>(bodytype_id));
std::string QuestManager::getbodytypename(uint8 body_type_id) {
return BodyType::GetName(body_type_id);
}
std::string QuestManager::getconsiderlevelname(uint8 consider_level) {

View File

@ -121,7 +121,7 @@ public:
std::string getldonthemename(uint32 theme_id);
std::string getfactionname(int faction_id);
std::string getlanguagename(uint8 language_id);
std::string getbodytypename(uint32 bodytype_id);
std::string getbodytypename(uint8 body_type_id);
std::string getconsiderlevelname(uint8 consider_level);
void safemove();
void rain(int weather);

View File

@ -1854,7 +1854,7 @@ void NPC::DoClassAttacks(Mob *target) {
IsTaunting() &&
HasOwner() &&
target->IsNPC() &&
target->GetBodyType() != BT_Undead &&
target->GetBodyType() != BodyType::Undead &&
taunt_time &&
type_of_pet &&
type_of_pet != petTargetLock &&
@ -2403,7 +2403,7 @@ int Mob::TryHeadShot(Mob *defender, EQ::skills::SkillType skillInUse)
!defender->IsClient() &&
skillInUse == EQ::skills::SkillArchery &&
GetTarget() == defender &&
(defender->GetBodyType() == BT_Humanoid || !RuleB(Combat, HeadshotOnlyHumanoids)) &&
(defender->GetBodyType() == BodyType::Humanoid || !RuleB(Combat, HeadshotOnlyHumanoids)) &&
!defender->GetSpecialAbility(SpecialAbility::HeadshotImmunity)
) {
uint32 HeadShot_Dmg = aabonuses.HeadShot[SBIndex::FINISHING_EFFECT_DMG] + spellbonuses.HeadShot[SBIndex::FINISHING_EFFECT_DMG] + itembonuses.HeadShot[SBIndex::FINISHING_EFFECT_DMG];
@ -2440,7 +2440,7 @@ int Mob::TryAssassinate(Mob *defender, EQ::skills::SkillType skillInUse)
!defender->IsClient() &&
GetLevel() >= RuleI(Combat, AssassinateLevelRequirement) &&
(skillInUse == EQ::skills::SkillBackstab || skillInUse == EQ::skills::SkillThrowing) &&
(defender->GetBodyType() == BT_Humanoid || !RuleB(Combat, AssassinateOnlyHumanoids)) &&
(defender->GetBodyType() == BodyType::Humanoid || !RuleB(Combat, AssassinateOnlyHumanoids)) &&
!defender->GetSpecialAbility(SpecialAbility::AssassinateImmunity)
) {
int chance = GetDEX();

View File

@ -878,18 +878,18 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
{
if (CastToClient()->ClientVersionBit() & EQ::versions::maskSoDAndLater)
{
bodyType bt = BT_Undead;
uint8 bt = BodyType::Undead;
int MessageID = SENSE_UNDEAD;
if(effect == SE_SenseSummoned)
{
bt = BT_Summoned;
bt = BodyType::Summoned;
MessageID = SENSE_SUMMONED;
}
else if(effect == SE_SenseAnimals)
{
bt = BT_Animal;
bt = BodyType::Animal;
MessageID = SENSE_ANIMAL;
}
@ -2758,7 +2758,7 @@ bool Mob::SpellEffect(Mob* caster, uint16 spell_id, float partial, int level_ove
case SE_SetBodyType:
{
SetBodyType((bodyType)spell.base_value[i], false);
SetBodyType(spell.base_value[i], false);
break;
}
@ -7562,47 +7562,47 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_ANIMAL_OR_HUMANOID:
if ((GetBodyType() == BT_Animal) || (GetBodyType() == BT_Humanoid))
if ((GetBodyType() == BodyType::Animal) || (GetBodyType() == BodyType::Humanoid))
return true;
break;
case IS_DRAGON:
if (GetBodyType() == BT_Dragon || GetBodyType() == BT_VeliousDragon || GetBodyType() == BT_Dragon3)
if (GetBodyType() == BodyType::Dragon || GetBodyType() == BodyType::VeliousDragon || GetBodyType() == BodyType::Dragon3)
return true;
break;
case IS_ANIMAL_OR_INSECT:
if ((GetBodyType() == BT_Animal) || (GetBodyType() == BT_Insect))
if ((GetBodyType() == BodyType::Animal) || (GetBodyType() == BodyType::Insect))
return true;
break;
case IS_BODY_TYPE_MISC:
if ((GetBodyType() == BT_Humanoid) || (GetBodyType() == BT_Lycanthrope) || (GetBodyType() == BT_Giant) ||
(GetBodyType() == BT_RaidGiant) || (GetBodyType() == BT_RaidColdain) || (GetBodyType() == BT_Animal)||
(GetBodyType() == BT_Construct) || (GetBodyType() == BT_Dragon) || (GetBodyType() == BT_Insect)||
(GetBodyType() == BT_VeliousDragon) || (GetBodyType() == BT_Muramite) || (GetBodyType() == BT_Magical))
if ((GetBodyType() == BodyType::Humanoid) || (GetBodyType() == BodyType::Lycanthrope) || (GetBodyType() == BodyType::Giant) ||
(GetBodyType() == BodyType::RaidGiant) || (GetBodyType() == BodyType::RaidColdain) || (GetBodyType() == BodyType::Animal)||
(GetBodyType() == BodyType::Construct) || (GetBodyType() == BodyType::Dragon) || (GetBodyType() == BodyType::Insect)||
(GetBodyType() == BodyType::VeliousDragon) || (GetBodyType() == BodyType::Muramite) || (GetBodyType() == BodyType::Magical))
return true;
break;
case IS_BODY_TYPE_MISC2:
if ((GetBodyType() == BT_Humanoid) || (GetBodyType() == BT_Lycanthrope) || (GetBodyType() == BT_Giant) ||
(GetBodyType() == BT_RaidGiant) || (GetBodyType() == BT_RaidColdain) || (GetBodyType() == BT_Animal) ||
(GetBodyType() == BT_Insect))
if ((GetBodyType() == BodyType::Humanoid) || (GetBodyType() == BodyType::Lycanthrope) || (GetBodyType() == BodyType::Giant) ||
(GetBodyType() == BodyType::RaidGiant) || (GetBodyType() == BodyType::RaidColdain) || (GetBodyType() == BodyType::Animal) ||
(GetBodyType() == BodyType::Insect))
return true;
break;
case IS_PLANT:
if (GetBodyType() == BT_Plant)
if (GetBodyType() == BodyType::Plant)
return true;
break;
case IS_GIANT:
if (GetBodyType() == BT_Giant)
if (GetBodyType() == BodyType::Giant)
return true;
break;
case IS_NOT_ANIMAL_OR_HUMANOID:
if ((GetBodyType() != BT_Animal) || (GetBodyType() != BT_Humanoid))
if ((GetBodyType() != BodyType::Animal) || (GetBodyType() != BodyType::Humanoid))
return true;
break;
@ -7643,17 +7643,17 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_UNDEAD_OR_VALDEHOLM_GIANT:
if (GetBodyType() == BT_Undead || GetRace() == Race::Giant2 || GetRace() == Race::Giant3)
if (GetBodyType() == BodyType::Undead || GetRace() == Race::Giant2 || GetRace() == Race::Giant3)
return true;
break;
case IS_ANIMAL_OR_PLANT:
if ((GetBodyType() == BT_Animal) || (GetBodyType() == BT_Plant))
if ((GetBodyType() == BodyType::Animal) || (GetBodyType() == BodyType::Plant))
return true;
break;
case IS_SUMMONED:
if (GetBodyType() == BT_Summoned)
if (GetBodyType() == BodyType::Summoned)
return true;
break;
@ -7664,12 +7664,12 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_UNDEAD:
if (GetBodyType() == BT_Undead)
if (GetBodyType() == BodyType::Undead)
return true;
break;
case IS_NOT_UNDEAD_OR_SUMMONED_OR_VAMPIRE:
if ((GetBodyType() != BT_Undead) && (GetBodyType() != BT_Summoned) && (GetBodyType() != BT_Vampire))
if ((GetBodyType() != BodyType::Undead) && (GetBodyType() != BodyType::Summoned) && (GetBodyType() != BodyType::Vampire))
return true;
break;
@ -7679,12 +7679,12 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_HUMANOID:
if (GetBodyType() == BT_Humanoid)
if (GetBodyType() == BodyType::Humanoid)
return true;
break;
case IS_UNDEAD_AND_HP_LESS_THAN_10_PCT:
if ((GetBodyType() == BT_Undead) && (GetHPRatio() < 10))
if ((GetBodyType() == BodyType::Undead) && (GetHPRatio() < 10))
return true;
break;
@ -8042,12 +8042,12 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_NOT_UNDEAD_OR_SUMMONED:
if ((GetBodyType() != BT_Undead) && (GetBodyType() != BT_Summoned))
if ((GetBodyType() != BodyType::Undead) && (GetBodyType() != BodyType::Summoned))
return true;
break;
case IS_NOT_PLANT:
if (GetBodyType() != BT_Plant)
if (GetBodyType() != BodyType::Plant)
return true;
break;
@ -8077,12 +8077,12 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_VAMPIRE_OR_UNDEAD_OR_UNDEADPET:
if (GetBodyType() == BT_Vampire || GetBodyType() == BT_Undead || GetBodyType() == BT_SummonedUndead)
if (GetBodyType() == BodyType::Vampire || GetBodyType() == BodyType::Undead || GetBodyType() == BodyType::SummonedUndead)
return true;
break;
case IS_NOT_VAMPIRE_OR_UNDEAD:
if (GetBodyType() != BT_Vampire && GetBodyType() != BT_Undead && GetBodyType() != BT_SummonedUndead)
if (GetBodyType() != BodyType::Vampire && GetBodyType() != BodyType::Undead && GetBodyType() != BodyType::SummonedUndead)
return true;
break;
@ -8124,17 +8124,17 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_HUMANOID_LEVEL_84_MAX:
if (GetBodyType() == BT_Humanoid && GetLevel() <= 84)
if (GetBodyType() == BodyType::Humanoid && GetLevel() <= 84)
return true;
break;
case IS_HUMANOID_LEVEL_86_MAX:
if (GetBodyType() == BT_Humanoid && GetLevel() <= 86)
if (GetBodyType() == BodyType::Humanoid && GetLevel() <= 86)
return true;
break;
case IS_HUMANOID_LEVEL_88_MAX:
if (GetBodyType() == BT_Humanoid && GetLevel() <= 88)
if (GetBodyType() == BodyType::Humanoid && GetLevel() <= 88)
return true;
break;
@ -8312,7 +8312,7 @@ bool Mob::PassCastRestriction(int value)
break;
case IS_SUMMONED_OR_UNDEAD:
if (GetBodyType() == BT_Summoned || GetBodyType() == BT_Undead)
if (GetBodyType() == BodyType::Summoned || GetBodyType() == BodyType::Undead)
return true;
break;

View File

@ -1955,9 +1955,9 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
// during this switch, this variable gets set to one of these things
// and that causes the spell to be executed differently
bodyType target_bt = BT_Humanoid;
uint8 target_bt = BodyType::Humanoid;
SpellTargetType targetType = spells[spell_id].target_type;
bodyType mob_body = spell_target ? spell_target->GetBodyType() : BT_Humanoid;
uint8 mob_body = spell_target ? spell_target->GetBodyType() : BodyType::Humanoid;
if(IsIllusionSpell(spell_id)
&& spell_target != nullptr // null ptr crash safeguard
@ -2000,9 +2000,9 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
// target required for these
case ST_Undead: {
if(!spell_target || (
mob_body != BT_SummonedUndead
&& mob_body != BT_Undead
&& mob_body != BT_Vampire
mob_body != BodyType::SummonedUndead
&& mob_body != BodyType::Undead
&& mob_body != BodyType::Vampire
)
)
{
@ -2019,7 +2019,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
}
case ST_Summoned: {
if(!spell_target || (mob_body != BT_Summoned && mob_body != BT_Summoned2 && mob_body != BT_Summoned3))
if(!spell_target || (mob_body != BodyType::Summoned && mob_body != BodyType::Summoned2 && mob_body != BodyType::Summoned3))
{
//invalid target
LogSpells("Spell [{}] canceled: invalid target of body type [{}] (summoned)", spell_id, mob_body);
@ -2033,7 +2033,7 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
case ST_SummonedPet:
{
if(!spell_target || (spell_target != GetPet()) ||
(mob_body != BT_Summoned && mob_body != BT_Summoned2 && mob_body != BT_Summoned3 && mob_body != BT_Animal))
(mob_body != BodyType::Summoned && mob_body != BodyType::Summoned2 && mob_body != BodyType::Summoned3 && mob_body != BodyType::Animal))
{
LogSpells("Spell [{}] canceled: invalid target of body type [{}] (summoned pet)",
spell_id, mob_body);
@ -2047,14 +2047,14 @@ bool Mob::DetermineSpellTargets(uint16 spell_id, Mob *&spell_target, Mob *&ae_ce
}
//single body type target spells...
//this is a little hackish, but better than duplicating code IMO
case ST_Plant: if(target_bt == BT_Humanoid) target_bt = BT_Plant;
case ST_Dragon: if(target_bt == BT_Humanoid) target_bt = BT_Dragon;
case ST_Giant: if(target_bt == BT_Humanoid) target_bt = BT_Giant;
case ST_Animal: if(target_bt == BT_Humanoid) target_bt = BT_Animal;
case ST_Plant: if(target_bt == BodyType::Humanoid) target_bt = BodyType::Plant;
case ST_Dragon: if(target_bt == BodyType::Humanoid) target_bt = BodyType::Dragon;
case ST_Giant: if(target_bt == BodyType::Humanoid) target_bt = BodyType::Giant;
case ST_Animal: if(target_bt == BodyType::Humanoid) target_bt = BodyType::Animal;
// check for special case body types (Velious dragons/giants)
if(mob_body == BT_RaidGiant) mob_body = BT_Giant;
if(mob_body == BT_VeliousDragon) mob_body = BT_Dragon;
if(mob_body == BodyType::RaidGiant) mob_body = BodyType::Giant;
if(mob_body == BodyType::VeliousDragon) mob_body = BodyType::Dragon;
{
if(!spell_target || mob_body != target_bt)
@ -4120,8 +4120,8 @@ bool Mob::SpellOnTarget(
}
//cannot hurt untargetable mobs
bodyType bt = spelltar->GetBodyType();
if (bt == BT_NoTarget || bt == BT_NoTarget2) {
uint8 bt = spelltar->GetBodyType();
if (bt == BodyType::NoTarget || bt == BodyType::NoTarget2) {
if (RuleB(Pets, UnTargetableSwarmPet)) {
if (spelltar->IsNPC()) {
if (!spelltar->CastToNPC()->GetSwarmOwner()) {
@ -4303,9 +4303,9 @@ bool Mob::SpellOnTarget(
//check for AE_Undead
if (spells[spell_id].target_type == ST_UndeadAE){
if (
spelltar->GetBodyType() != BT_SummonedUndead &&
spelltar->GetBodyType() != BT_Undead &&
spelltar->GetBodyType() != BT_Vampire
spelltar->GetBodyType() != BodyType::SummonedUndead &&
spelltar->GetBodyType() != BodyType::Undead &&
spelltar->GetBodyType() != BodyType::Vampire
) {
safe_delete(action_packet);
return false;

View File

@ -521,7 +521,7 @@ void Trap::CreateHiddenTrigger()
make_npc->current_hp = 100000;
strcpy(make_npc->name, "a_trap");
make_npc->runspeed = 0.0f;
make_npc->bodytype = BT_Special;
make_npc->bodytype = BodyType::Special;
make_npc->race = 127;
make_npc->gender = Gender::Male;
make_npc->loottable_id = 0;