bool ChatHandler::HandleUnlearnCommand(const char* args, WorldSession* m_session) { Player* plr = getSelectedChar(m_session, true); if(plr == 0) return true; uint32 SpellId = atol(args); if(SpellId == 0) { SpellId = GetSpellIDFromLink(args); if(SpellId == 0) { RedSystemMessage(m_session, "You must specify a spell id."); return true; } } sGMLog.writefromsession(m_session, "removed spell %u from %s", SpellId, plr->GetName()); if(plr->HasSpell(SpellId)) { GreenSystemMessageToPlr(plr, "Removed spell %u.", SpellId); GreenSystemMessage(m_session, "Removed spell %u from %s.", SpellId, plr->GetName()); plr->removeSpell(SpellId, false, false, 0); } else { RedSystemMessage(m_session, "That player does not have spell %u learnt.", SpellId); } return true; }
bool ChatHandler::HandleCastSpellCommand(const char* args, WorldSession *m_session) { Unit* caster = m_session->GetPlayer(); Unit* target = getSelectedUnit(m_session, false); if(!target) target = caster; uint32 spellid = atol(args); if(spellid == 0) spellid = GetSpellIDFromLink( args ); SpellEntry *spellentry = dbcSpell.LookupEntryForced(spellid); if(spellentry == NULL) { RedSystemMessage(m_session, "Invalid spell id!"); return false; } Spell* sp = new Spell(caster, spellentry, false, NULLAURA); if(!sp) { RedSystemMessage(m_session, "Spell failed creation!"); return false; } BlueSystemMessage(m_session, "Casting spell %d on target.", spellid); SpellCastTargets targets; targets.m_unitTarget = target->GetGUID(); sp->prepare(&targets); sWorld.LogGM(m_session, "Used castspell command on %s" , target->GetName()); return true; }
bool ChatHandler::HandleMonsterCastCommand(const char * args, WorldSession * m_session) { Unit* crt = getSelectedCreature(m_session, false); if(crt == NULL) { RedSystemMessage(m_session, "Please select a creature before using this command."); return true; } uint32 spellId = (uint32)atoi(args); if(spellId == 0) spellId = GetSpellIDFromLink( args ); SpellEntry * tmpsp = dbcSpell.LookupEntryForced(spellId); if(tmpsp == NULL) return false; crt->CastSpell(reinterpret_cast<Unit*>(NULL), tmpsp, false); sWorld.LogGM(m_session, "Used npc cast command on %s", crt->GetName()); return true; }