mirror of
https://github.com/EQEmu/Server.git
synced 2026-09-02 20:56:37 +00:00
[GM Commands] Split GM Commands Into Separate Files (#1766)
* Split GM commands into their own files * Code cleanup
This commit is contained in:
Executable
+77
@@ -0,0 +1,77 @@
|
||||
#include "../client.h"
|
||||
|
||||
void command_castspell(Client *c, const Seperator *sep)
|
||||
{
|
||||
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 (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()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user