[Commands] Cleanup #peqzone Command. (#1794)

- Cleanup messages and logic.
- Add RULE_INT(Zone, PEQZoneHPRatio, 75, "Required HP Ratio to use #peqzone")
- Modify #peqzone Timer rule to allow it to be disabled.
This commit is contained in:
Kinglykrab 2021-11-21 14:19:08 -05:00 committed by GitHub
parent 5470ec6293
commit 39c27c987d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 121 additions and 58 deletions

View File

@ -263,10 +263,11 @@ RULE_INT(Zone, ClientLinkdeadMS, 90000, "The time a client remains link dead on
RULE_INT(Zone, GraveyardTimeMS, 1200000, "Time until a player corpse is moved to a zone's graveyard, if one is specified for the zone (milliseconds)") RULE_INT(Zone, GraveyardTimeMS, 1200000, "Time until a player corpse is moved to a zone's graveyard, if one is specified for the zone (milliseconds)")
RULE_BOOL(Zone, EnableShadowrest, 1, "Enables or disables the Shadowrest zone feature for player corpses. Default is turned on") RULE_BOOL(Zone, EnableShadowrest, 1, "Enables or disables the Shadowrest zone feature for player corpses. Default is turned on")
RULE_INT(Zone, AutoShutdownDelay, 5000, "How long a dynamic zone stays loaded while empty (milliseconds)") RULE_INT(Zone, AutoShutdownDelay, 5000, "How long a dynamic zone stays loaded while empty (milliseconds)")
RULE_INT(Zone, PEQZoneReuseTime, 900, "Time between two uses of the #peqzone command (seconds)") RULE_INT(Zone, PEQZoneReuseTime, 900, "Seconds between two uses of the #peqzone command (Set to 0 to disable)")
RULE_INT(Zone, PEQZoneDebuff1, 4454, "First debuff casted by #peqzone Default is Cursed Keeper's Blight") RULE_INT(Zone, PEQZoneDebuff1, 4454, "First debuff casted by #peqzone Default is Cursed Keeper's Blight")
RULE_INT(Zone, PEQZoneDebuff2, 2209, "Second debuff casted by #peqzone Default is Tendrils of Apathy") RULE_INT(Zone, PEQZoneDebuff2, 2209, "Second debuff casted by #peqzone Default is Tendrils of Apathy")
RULE_BOOL(Zone, UsePEQZoneDebuffs, true, "Setting if the command #peqzone applies the defined debuffs") RULE_BOOL(Zone, UsePEQZoneDebuffs, true, "Setting if the command #peqzone applies the defined debuffs")
RULE_INT(Zone, PEQZoneHPRatio, 75, "Required HP Ratio to use #peqzone")
RULE_REAL(Zone, HotZoneBonus, 0.75, "Value which is added to the experience multiplier. This also applies to AA experience.") RULE_REAL(Zone, HotZoneBonus, 0.75, "Value which is added to the experience multiplier. This also applies to AA experience.")
RULE_INT(Zone, EbonCrystalItemID, 40902, "Item ID for Ebon Crystal") RULE_INT(Zone, EbonCrystalItemID, 40902, "Item ID for Ebon Crystal")
RULE_INT(Zone, RadiantCrystalItemID, 40903, "Item ID for Radiant Crystal") RULE_INT(Zone, RadiantCrystalItemID, 40903, "Item ID for Radiant Crystal")

View File

@ -9459,7 +9459,7 @@ void Client::CheckVirtualZoneLines()
LogZonePoints( LogZonePoints(
"Virtual Zone Box Sending player [{}] to [{}]", "Virtual Zone Box Sending player [{}] to [{}]",
GetCleanName(), GetCleanName(),
zone_store.GetZoneLongName(virtual_zone_point.target_zone_id) ZoneLongName(virtual_zone_point.target_zone_id)
); );
} }
} }

View File

@ -12876,7 +12876,7 @@ void Client::Handle_OP_SetStartCity(const EQApplicationPacket *app)
else else
zone_id = atoi(row[0]); zone_id = atoi(row[0]);
std::string zone_long_name = zone_store.GetZoneLongName(zone_id); std::string zone_long_name = ZoneLongName(zone_id);
Message(Chat::Yellow, "%d - %s", zone_id, zone_long_name.c_str()); Message(Chat::Yellow, "%d - %s", zone_id, zone_long_name.c_str());
} }

View File

@ -273,7 +273,7 @@ int command_init(void)
command_add("opcode", "- opcode management", AccountStatus::GMImpossible, command_opcode) || command_add("opcode", "- opcode management", AccountStatus::GMImpossible, command_opcode) ||
command_add("path", "- view and edit pathing", AccountStatus::GMMgmt, command_path) || command_add("path", "- view and edit pathing", AccountStatus::GMMgmt, command_path) ||
command_add("peekinv", "[equip/gen/cursor/poss/limbo/curlim/trib/bank/shbank/allbank/trade/world/all] - Print out contents of your player target's inventory", AccountStatus::GMAdmin, command_peekinv) || command_add("peekinv", "[equip/gen/cursor/poss/limbo/curlim/trib/bank/shbank/allbank/trade/world/all] - Print out contents of your player target's inventory", AccountStatus::GMAdmin, command_peekinv) ||
command_add("peqzone", "[zonename] - Go to specified zone, if you have > 75% health", AccountStatus::Player, command_peqzone) || command_add("peqzone", "[Zone ID|Zone Short Name] - Teleports you to the specified zone if you meet the requirements.", AccountStatus::Player, command_peqzone) ||
command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) || command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) ||
command_add("permagender", "[Gender ID] - Change your or your player target's gender", AccountStatus::QuestTroupe, command_permagender) || command_add("permagender", "[Gender ID] - Change your or your player target's gender", AccountStatus::QuestTroupe, command_permagender) ||
command_add("permarace", "[Race ID] - Change your or your player target's race", AccountStatus::QuestTroupe, command_permarace) || command_add("permarace", "[Race ID] - Change your or your player target's race", AccountStatus::QuestTroupe, command_permarace) ||

View File

@ -2,74 +2,109 @@
void command_peqzone(Client *c, const Seperator *sep) void command_peqzone(Client *c, const Seperator *sep)
{ {
uint32 timeleft = c->GetPTimers().GetRemainingTime(pTimerPeqzoneReuse) / 60; int arguments = sep->argnum;
if (!arguments) {
if (!c->GetPTimers().Expired(&database, pTimerPeqzoneReuse, false)) { c->Message(Chat::White, "Usage: #peqzone [Zone ID] or #peqzone [Zone Short Name]");
c->Message(Chat::Red, "You must wait %i minute(s) before using this ability again.", timeleft);
return; return;
} }
if (c->GetHPRatio() < 75) { auto reuse_timer = RuleI(Zone, PEQZoneReuseTime);
c->Message(Chat::White, "You cannot use this command with less than 75 percent health."); if (reuse_timer) {
uint32 time_left = c->GetPTimers().GetRemainingTime(pTimerPeqzoneReuse);
if (!c->GetPTimers().Expired(&database, pTimerPeqzoneReuse, false)) {
c->Message(
Chat::White,
fmt::format(
"You must wait {} before using this command again.",
ConvertSecondsToTime(time_left)
).c_str()
);
return;
}
}
auto hp_ratio = RuleI(Zone, PEQZoneHPRatio);
if (c->GetHPRatio() < hp_ratio) {
c->Message(
Chat::White,
fmt::format(
"You cannot use this command with less than {}%% health.",
hp_ratio
).c_str()
);
return; return;
} }
//this isnt perfect, but its better...
if ( if (
c->IsInvisible(c) c->IsInvisible(c) ||
|| c->IsRooted() c->IsRooted() ||
|| c->IsStunned() c->IsStunned() ||
|| c->IsMezzed() c->IsMezzed() ||
|| c->AutoAttackEnabled() c->AutoAttackEnabled() ||
|| c->GetInvul() c->GetInvul()
) { ) {
c->Message(Chat::White, "You cannot use this command in your current state. Settle down and wait."); c->Message(Chat::White, "You cannot use this command in your current state. Settle down and wait.");
return; return;
} }
uint16 zoneid = 0; auto zone_id = (
uint8 destzone = 0; sep->IsNumber(1) ?
if (sep->IsNumber(1)) { static_cast<uint16>(std::stoul(sep->arg[1])) :
zoneid = atoi(sep->arg[1]); static_cast<uint16>(ZoneID(sep->arg[1]))
destzone = content_db.GetPEQZone(zoneid, 0); );
if (destzone == 0) { auto zone_short_name = ZoneName(zone_id);
c->Message(Chat::Red, "You cannot use this command to enter that zone!"); auto zone_long_name = ZoneLongName(zone_id);
return; if (
} !zone_id ||
if (zoneid == zone->GetZoneID()) { !zone_short_name
c->Message(Chat::Red, "You cannot use this command on the zone you are in!"); ) {
return; c->Message(
} Chat::White,
} fmt::format(
else if (sep->arg[1][0] == 0 || sep->IsNumber(2) || sep->IsNumber(3) || sep->IsNumber(4) || sep->IsNumber(5)) { "No zones were found matching '{}'.",
c->Message(Chat::White, "Usage: #peqzone [zonename]"); sep->arg[1]
c->Message(Chat::White, "Optional Usage: #peqzone [zoneid]"); ).c_str()
);
return; return;
} }
else {
zoneid = ZoneID(sep->arg[1]); bool allows_peqzone = (
destzone = content_db.GetPEQZone(zoneid, 0); content_db.GetPEQZone(zone_id, 0) ?
if (zoneid == 0) { true :
c->Message(Chat::White, "Unable to locate zone '%s'", sep->arg[1]); false
return; );
} if (!allows_peqzone) {
if (destzone == 0) { c->Message(
c->Message(Chat::Red, "You cannot use this command to enter that zone!"); Chat::White,
return; fmt::format(
} "You cannot use this command to enter {} ({}).",
if (zoneid == zone->GetZoneID()) { zone_long_name,
c->Message(Chat::Red, "You cannot use this command on the zone you are in!"); zone_short_name
return; ).c_str()
} );
return;
} }
if (RuleB (Zone, UsePEQZoneDebuffs)) { if (zone_id == zone->GetZoneID()) {
c->Message(
Chat::White,
fmt::format(
"You are already in {} ({}).",
zone->GetLongName(),
zone->GetShortName()
).c_str()
);
return;
}
if (RuleB(Zone, UsePEQZoneDebuffs)) {
c->SpellOnTarget(RuleI(Zone, PEQZoneDebuff1), c); c->SpellOnTarget(RuleI(Zone, PEQZoneDebuff1), c);
c->SpellOnTarget(RuleI(Zone, PEQZoneDebuff2), c); c->SpellOnTarget(RuleI(Zone, PEQZoneDebuff2), c);
} }
//zone to safe coords if (reuse_timer) {
c->GetPTimers().Start(pTimerPeqzoneReuse, RuleI(Zone, PEQZoneReuseTime)); c->GetPTimers().Start(pTimerPeqzoneReuse, reuse_timer);
c->MovePC(zoneid, 0.0f, 0.0f, 0.0f, 0.0f, 0, ZoneToSafeCoords); }
}
c->MoveZone(zone_short_name);
}

View File

@ -16,7 +16,7 @@ void command_showzonepoints(Client *c, const Seperator *sep)
c->SendChatLineBreak(); c->SendChatLineBreak();
for (auto &virtual_zone_point : zone->virtual_zone_point_list) { for (auto &virtual_zone_point : zone->virtual_zone_point_list) {
std::string zone_long_name = zone_store.GetZoneLongName(virtual_zone_point.target_zone_id); std::string zone_long_name = ZoneLongName(virtual_zone_point.target_zone_id);
c->Message( c->Message(
Chat::White, Chat::White,
@ -112,7 +112,7 @@ void command_showzonepoints(Client *c, const Seperator *sep)
iterator.Reset(); iterator.Reset();
while (iterator.MoreElements()) { while (iterator.MoreElements()) {
ZonePoint *zone_point = iterator.GetData(); ZonePoint *zone_point = iterator.GetData();
std::string zone_long_name = zone_store.GetZoneLongName(zone_point->target_zone_id); std::string zone_long_name = ZoneLongName(zone_point->target_zone_id);
std::string node_name = fmt::format("ZonePoint To [{}]", zone_long_name); std::string node_name = fmt::format("ZonePoint To [{}]", zone_long_name);
NPC::SpawnZonePointNodeNPC( NPC::SpawnZonePointNodeNPC(

View File

@ -80,6 +80,26 @@ const char *ZoneStore::GetZoneName(uint32 zone_id, bool error_unknown)
return nullptr; return nullptr;
} }
/**
* @param zone_id
* @param error_unknown
* @return
*/
const char *ZoneStore::GetZoneLongName(uint32 zone_id, bool error_unknown)
{
for (auto &z: zones) {
if (z.zoneidnumber == zone_id) {
return z.long_name.c_str();
}
}
if (error_unknown) {
return "UNKNOWN";
}
return nullptr;
}
/** /**
* @param zone_id * @param zone_id
* @return * @return

View File

@ -41,6 +41,7 @@ public:
std::string GetZoneName(uint32 zone_id); std::string GetZoneName(uint32 zone_id);
std::string GetZoneLongName(uint32 zone_id); std::string GetZoneLongName(uint32 zone_id);
const char *GetZoneName(uint32 zone_id, bool error_unknown = false); const char *GetZoneName(uint32 zone_id, bool error_unknown = false);
const char *GetZoneLongName(uint32 zone_id, bool error_unknown = false);
static void LoadContentFlags(); static void LoadContentFlags();
static void SetContentFlag(const std::string& content_flag_name, bool enabled); static void SetContentFlag(const std::string& content_flag_name, bool enabled);
@ -60,7 +61,13 @@ inline const char *ZoneName(uint32 zone_id, bool error_unknown = false)
error_unknown error_unknown
); );
} }
inline const char *ZoneLongName(uint32 zone_id) { return zone_store.GetZoneLongName(zone_id).c_str(); } inline const char *ZoneLongName(uint32 zone_id, bool error_unknown = false)
{
return zone_store.GetZoneLongName(
zone_id,
error_unknown
);
}
inline ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0) { return zone_store.GetZone(zone_id, version); }; inline ZoneRepository::Zone GetZone(uint32 zone_id, int version = 0) { return zone_store.GetZone(zone_id, version); };
inline ZoneRepository::Zone GetZone(const char *in_zone_name) { return zone_store.GetZone(in_zone_name); }; inline ZoneRepository::Zone GetZone(const char *in_zone_name) { return zone_store.GetZone(in_zone_name); };