mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 01:11:29 +00:00
[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:
parent
33c30d3cbb
commit
994ef712b2
@ -182,7 +182,7 @@ int command_init(void)
|
||||
#endif
|
||||
|
||||
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("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) ||
|
||||
@ -3638,28 +3638,61 @@ inline bool CastRestrictedSpell(int spellid)
|
||||
|
||||
void command_castspell(Client *c, const Seperator *sep)
|
||||
{
|
||||
if (!sep->IsNumber(1))
|
||||
c->Message(Chat::White, "Usage: #CastSpell spellid");
|
||||
else {
|
||||
uint16 spellid = atoi(sep->arg[1]);
|
||||
/*
|
||||
Spell restrictions.
|
||||
*/
|
||||
if (CastRestrictedSpell(spellid) && c->Admin() < commandCastSpecials)
|
||||
if (SPDAT_RECORDS <= 0) {
|
||||
c->Message(Chat::White, "Spells not loaded.");
|
||||
return;
|
||||
}
|
||||
|
||||
Mob *target = c;
|
||||
if(c->GetTarget()) {
|
||||
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.");
|
||||
else if (spellid >= SPDAT_RECORDS)
|
||||
c->Message(Chat::White, "Error: #CastSpell: Argument out of range");
|
||||
else
|
||||
if (c->GetTarget() == 0)
|
||||
if(c->Admin() >= commandInstacast)
|
||||
c->SpellFinished(spellid, 0, EQ::spells::CastingSlot::Item, 0, -1, spells[spellid].resist_difficulty);
|
||||
else
|
||||
c->CastSpell(spellid, 0, EQ::spells::CastingSlot::Item, 0);
|
||||
else
|
||||
if(c->Admin() >= commandInstacast)
|
||||
c->SpellFinished(spellid, c->GetTarget(), EQ::spells::CastingSlot::Item, 0, -1, spells[spellid].resist_difficulty);
|
||||
else
|
||||
c->CastSpell(spellid, c->GetTarget()->GetID(), EQ::spells::CastingSlot::Item, 0);
|
||||
} else if (spell_id >= SPDAT_RECORDS) {
|
||||
c->Message(Chat::White, "Invalid Spell ID.");
|
||||
} else {
|
||||
bool instant_cast = (c->Admin() >= commandInstacast ? true : false);
|
||||
if (instant_cast && sep->IsNumber(2)) {
|
||||
instant_cast = std::stoi(sep->arg[2]) ? true : false;
|
||||
c->Message(Chat::White, fmt::format("{}", std::stoi(sep->arg[2])).c_str());
|
||||
}
|
||||
|
||||
if (c->Admin() >= commandInstacast && instant_cast) {
|
||||
c->SpellFinished(spell_id, target, EQ::spells::CastingSlot::Item, 0, -1, spells[spell_id].resist_difficulty);
|
||||
} else {
|
||||
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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user