mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 05:21:29 +00:00
[Commands] Cleanup #findclass and #findrace Commands. (#2211)
- Cleanup messages and logic. - Add bitmasks to player race messages.
This commit is contained in:
parent
e6db71e31e
commit
123bc5f19a
@ -3,9 +3,8 @@
|
|||||||
void command_findclass(Client *c, const Seperator *sep)
|
void command_findclass(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
int arguments = sep->argnum;
|
int arguments = sep->argnum;
|
||||||
|
if (!arguments) {
|
||||||
if (arguments == 0) {
|
c->Message(Chat::White, "Command Syntax: #findclass [Search Criteria]");
|
||||||
c->Message(Chat::White, "Command Syntax: #findclass [search criteria]");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -16,9 +15,17 @@ void command_findclass(Client *c, const Seperator *sep)
|
|||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Class {}: {}",
|
"Class {} | {}{}",
|
||||||
class_id,
|
class_id,
|
||||||
class_name
|
class_name,
|
||||||
|
(
|
||||||
|
c->IsPlayerClass(class_id) ?
|
||||||
|
fmt::format(
|
||||||
|
" ({})",
|
||||||
|
GetPlayerClassBit(class_id)
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
)
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@ -31,51 +38,52 @@ void command_findclass(Client *c, const Seperator *sep)
|
|||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
auto search_criteria = str_tolower(sep->argplus[1]);
|
||||||
std::string search_criteria = str_tolower(sep->argplus[1]);
|
|
||||||
int found_count = 0;
|
int found_count = 0;
|
||||||
for (int class_id = WARRIOR; class_id <= MERCERNARY_MASTER; class_id++) {
|
for (uint16 class_id = WARRIOR; class_id <= MERCERNARY_MASTER; class_id++) {
|
||||||
std::string class_name = GetClassIDName(class_id);
|
std::string class_name = GetClassIDName(class_id);
|
||||||
std::string class_name_lower = str_tolower(class_name);
|
auto class_name_lower = str_tolower(class_name);
|
||||||
if (search_criteria.length() > 0 && class_name_lower.find(search_criteria) == std::string::npos) {
|
if (
|
||||||
|
search_criteria.length() &&
|
||||||
|
class_name_lower.find(search_criteria) == std::string::npos
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Class {}: {}",
|
"Class {} | {}{}",
|
||||||
class_id,
|
class_id,
|
||||||
class_name
|
class_name,
|
||||||
|
(
|
||||||
|
c->IsPlayerClass(class_id) ?
|
||||||
|
fmt::format(
|
||||||
|
" ({})",
|
||||||
|
GetPlayerClassBit(class_id)
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
)
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
found_count++;
|
found_count++;
|
||||||
|
|
||||||
if (found_count == 20) {
|
if (found_count == 50) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_count == 20) {
|
if (found_count == 50) {
|
||||||
c->Message(Chat::White, "20 Classes found... max reached.");
|
c->Message(Chat::White, "50 Classes found, max reached.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
auto class_message = (
|
|
||||||
found_count > 0 ?
|
|
||||||
(
|
|
||||||
found_count == 1 ?
|
|
||||||
"A Class was" :
|
|
||||||
fmt::format("{} Classes were", found_count)
|
|
||||||
) :
|
|
||||||
"No Classes were"
|
|
||||||
);
|
|
||||||
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} found.",
|
"{} Class{} found.",
|
||||||
class_message
|
found_count,
|
||||||
|
found_count != 1 ? "es" : ""
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -3,26 +3,35 @@
|
|||||||
void command_findrace(Client *c, const Seperator *sep)
|
void command_findrace(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
int arguments = sep->argnum;
|
int arguments = sep->argnum;
|
||||||
|
if (!arguments) {
|
||||||
if (arguments == 0) {
|
c->Message(Chat::White, "Command Syntax: #findrace [Search Criteria]");
|
||||||
c->Message(Chat::White, "Command Syntax: #findrace [search criteria]");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sep->IsNumber(1)) {
|
if (sep->IsNumber(1)) {
|
||||||
int race_id = std::stoi(sep->arg[1]);
|
auto race_id = static_cast<uint16>(std::stoul(sep->arg[1]));
|
||||||
std::string race_name = GetRaceIDName(race_id);
|
std::string race_name = GetRaceIDName(race_id);
|
||||||
if (race_id >= RACE_HUMAN_1 && race_id <= RACE_PEGASUS_732) {
|
if (
|
||||||
|
race_id >= RACE_HUMAN_1 &&
|
||||||
|
race_id <= RACE_PEGASUS_732
|
||||||
|
) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Race {}: {}",
|
"Race {} | {}{}",
|
||||||
race_id,
|
race_id,
|
||||||
race_name
|
race_name,
|
||||||
|
(
|
||||||
|
c->IsPlayerRace(race_id) ?
|
||||||
|
fmt::format(
|
||||||
|
" ({})",
|
||||||
|
GetPlayerRaceBit(race_id)
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
)
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -31,51 +40,52 @@ void command_findrace(Client *c, const Seperator *sep)
|
|||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
auto search_criteria = str_tolower(sep->argplus[1]);
|
||||||
std::string search_criteria = str_tolower(sep->argplus[1]);
|
|
||||||
int found_count = 0;
|
int found_count = 0;
|
||||||
for (int race_id = RACE_HUMAN_1; race_id <= RACE_PEGASUS_732; race_id++) {
|
for (uint16 race_id = RACE_HUMAN_1; race_id <= RACE_PEGASUS_732; race_id++) {
|
||||||
std::string race_name = GetRaceIDName(race_id);
|
std::string race_name = GetRaceIDName(race_id);
|
||||||
std::string race_name_lower = str_tolower(race_name);
|
auto race_name_lower = str_tolower(race_name);
|
||||||
if (search_criteria.length() > 0 && race_name_lower.find(search_criteria) == std::string::npos) {
|
if (
|
||||||
|
search_criteria.length() &&
|
||||||
|
race_name_lower.find(search_criteria) == std::string::npos
|
||||||
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Race {}: {}",
|
"Race {} | {}{}",
|
||||||
race_id,
|
race_id,
|
||||||
race_name
|
race_name,
|
||||||
|
(
|
||||||
|
c->IsPlayerRace(race_id) ?
|
||||||
|
fmt::format(
|
||||||
|
" ({})",
|
||||||
|
GetPlayerRaceBit(race_id)
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
)
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
|
|
||||||
found_count++;
|
found_count++;
|
||||||
|
|
||||||
if (found_count == 20) {
|
if (found_count == 50) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found_count == 20) {
|
if (found_count == 50) {
|
||||||
c->Message(Chat::White, "20 Races found... max reached.");
|
c->Message(Chat::White, "50 Races found, max reached.");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
auto race_message = (
|
|
||||||
found_count > 0 ?
|
|
||||||
(
|
|
||||||
found_count == 1 ?
|
|
||||||
"A Race was" :
|
|
||||||
fmt::format("{} Races were", found_count)
|
|
||||||
) :
|
|
||||||
"No Races were"
|
|
||||||
);
|
|
||||||
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"{} found.",
|
"{} Race{} found.",
|
||||||
race_message
|
found_count,
|
||||||
|
found_count != 1 ? "s" : ""
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
10
zone/mob.cpp
10
zone/mob.cpp
@ -2854,6 +2854,16 @@ bool Mob::RandomizeFeatures(bool send_illusion, bool set_variables)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Mob::IsPlayerClass(uint16 in_class) {
|
||||||
|
if (
|
||||||
|
in_class >= WARRIOR &&
|
||||||
|
in_class <= BERSERKER
|
||||||
|
) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool Mob::IsPlayerRace(uint16 in_race) {
|
bool Mob::IsPlayerRace(uint16 in_race) {
|
||||||
|
|
||||||
|
|||||||
@ -741,6 +741,7 @@ public:
|
|||||||
//Util
|
//Util
|
||||||
static uint32 RandomTimer(int min, int max);
|
static uint32 RandomTimer(int min, int max);
|
||||||
static uint8 GetDefaultGender(uint16 in_race, uint8 in_gender = 0xFF);
|
static uint8 GetDefaultGender(uint16 in_race, uint8 in_gender = 0xFF);
|
||||||
|
static bool IsPlayerClass(uint16 in_class);
|
||||||
static bool IsPlayerRace(uint16 in_race);
|
static bool IsPlayerRace(uint16 in_race);
|
||||||
EQ::skills::SkillType GetSkillByItemType(int ItemType);
|
EQ::skills::SkillType GetSkillByItemType(int ItemType);
|
||||||
uint8 GetItemTypeBySkill(EQ::skills::SkillType skill);
|
uint8 GetItemTypeBySkill(EQ::skills::SkillType skill);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user