[Commands] Cleanup #cast Command. (#1706)

* [Commands] Cleanup #cast Command.
- Cleanup message.

* Add optional cast non-instant parameter.
- Fix cast time.

* Fix message.
This commit is contained in:
Kinglykrab 2021-11-11 16:48:35 -05:00 committed by GitHub
parent 33c30d3cbb
commit 994ef712b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,7 +182,7 @@ int command_init(void)
#endif #endif
command_add("camerashake", "Shakes the camera on everyone's screen globally.", 80, command_camerashake) || command_add("camerashake", "Shakes the camera on everyone's screen globally.", 80, command_camerashake) ||
command_add("castspell", "[spellid] - Cast a spell", 50, command_castspell) || command_add("castspell", "[Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)] - Cast a spell", 50, command_castspell) ||
command_add("chat", "[channel num] [message] - Send a channel message to all zones", 200, command_chat) || command_add("chat", "[channel num] [message] - Send a channel message to all zones", 200, command_chat) ||
command_add("checklos", "- Check for line of sight to your target", 50, command_checklos) || command_add("checklos", "- Check for line of sight to your target", 50, command_checklos) ||
command_add("copycharacter", "[source_char_name] [dest_char_name] [dest_account_name] Copies character to destination account", 250, command_copycharacter) || command_add("copycharacter", "[source_char_name] [dest_char_name] [dest_account_name] Copies character to destination account", 250, command_copycharacter) ||
@ -3638,28 +3638,61 @@ inline bool CastRestrictedSpell(int spellid)
void command_castspell(Client *c, const Seperator *sep) void command_castspell(Client *c, const Seperator *sep)
{ {
if (!sep->IsNumber(1)) if (SPDAT_RECORDS <= 0) {
c->Message(Chat::White, "Usage: #CastSpell spellid"); c->Message(Chat::White, "Spells not loaded.");
else { return;
uint16 spellid = atoi(sep->arg[1]); }
/*
Spell restrictions. Mob *target = c;
*/ if(c->GetTarget()) {
if (CastRestrictedSpell(spellid) && c->Admin() < commandCastSpecials) target = c->GetTarget();
}
if (!sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #castspell [Spell ID] [Instant (0 = False, 1 = True, Default is 1 if Unused)]");
} else {
uint16 spell_id = std::stoul(sep->arg[1]);
if (CastRestrictedSpell(spell_id) && c->Admin() < commandCastSpecials) {
c->Message(Chat::Red, "Unable to cast spell."); c->Message(Chat::Red, "Unable to cast spell.");
else if (spellid >= SPDAT_RECORDS) } else if (spell_id >= SPDAT_RECORDS) {
c->Message(Chat::White, "Error: #CastSpell: Argument out of range"); c->Message(Chat::White, "Invalid Spell ID.");
else } else {
if (c->GetTarget() == 0) bool instant_cast = (c->Admin() >= commandInstacast ? true : false);
if(c->Admin() >= commandInstacast) if (instant_cast && sep->IsNumber(2)) {
c->SpellFinished(spellid, 0, EQ::spells::CastingSlot::Item, 0, -1, spells[spellid].resist_difficulty); instant_cast = std::stoi(sep->arg[2]) ? true : false;
else c->Message(Chat::White, fmt::format("{}", std::stoi(sep->arg[2])).c_str());
c->CastSpell(spellid, 0, EQ::spells::CastingSlot::Item, 0); }
else
if(c->Admin() >= commandInstacast) if (c->Admin() >= commandInstacast && instant_cast) {
c->SpellFinished(spellid, c->GetTarget(), EQ::spells::CastingSlot::Item, 0, -1, spells[spellid].resist_difficulty); c->SpellFinished(spell_id, target, EQ::spells::CastingSlot::Item, 0, -1, spells[spell_id].resist_difficulty);
else } else {
c->CastSpell(spellid, c->GetTarget()->GetID(), EQ::spells::CastingSlot::Item, 0); c->CastSpell(spell_id, target->GetID(), EQ::spells::CastingSlot::Item, spells[spell_id].cast_time);
}
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"Cast {} ({}) on {}{}.",
GetSpellName(spell_id),
spell_id,
target->GetCleanName(),
instant_cast ? " instantly" : ""
).c_str()
);
} else {
c->Message(
Chat::White,
fmt::format(
"Cast {} ({}) on yourself{}.",
GetSpellName(spell_id),
spell_id,
instant_cast ? " instantly" : ""
).c_str()
);
}
}
} }
} }