void ScriptMgr::register_dummy_aura(uint32 entry, exp_handle_dummy_aura callback) { if(_auras.find(entry) != _auras.end()) { LOG_ERROR("ScriptMgr is trying to register a script for Aura ID: %u even if there's already one for that Aura. Remove one of those scripts.", entry); } SpellEntry* sp = dbcSpell.LookupEntryForced(entry); if(sp == NULL) { LOG_ERROR("ScriptMgr is trying to register a dummy aura handler for Spell ID: %u which is invalid.", entry); return; } if(!sp->AppliesAura(SPELL_AURA_DUMMY) && !sp->AppliesAura(SPELL_AURA_PERIODIC_TRIGGER_DUMMY)) LOG_ERROR("ScriptMgr has registered a dummy aura handler for Spell ID: %u ( %s ), but spell has no dummy aura!", entry, sp->Name); _auras.insert(HandleDummyAuraMap::value_type(entry, callback)); }
void TotemSummon::SetupSpells() { if(GetOwner() == NULL) return; SpellEntry* creatorspell = dbcSpell.LookupEntry(GetCreatedBySpell()); SpellEntry* TotemSpell = dbcSpell.LookupEntry(proto->AISpells[ 0 ]); SpellEntry* TotemSpell2 = dbcSpell.LookupEntry(proto->AISpells[ 1 ]); if(TotemSpell == NULL) { printf("Totem %u does not have any spells to cast", creature_info->Id); return; } // Set up AI, depending on our spells. bool castingtotem = true; if(TotemSpell->HasEffect(SPELL_EFFECT_SUMMON) || TotemSpell->HasEffect(SPELL_EFFECT_APPLY_GROUP_AREA_AURA) || TotemSpell->HasEffect(SPELL_EFFECT_APPLY_RAID_AREA_AURA) || TotemSpell->HasEffect(SPELL_EFFECT_PERSISTENT_AREA_AURA) || (TotemSpell->HasEffect(SPELL_EFFECT_APPLY_AURA) && TotemSpell->AppliesAura(SPELL_AURA_PERIODIC_TRIGGER_SPELL))) castingtotem = false; if(!castingtotem) { // We're an area aura. Simply cast the spell. m_aiInterface->totemspell = creatorspell; Spell* pSpell = sSpellFactoryMgr.NewSpell(this, TotemSpell, true, 0); SpellCastTargets targets; if(!TotemSpell->HasEffect(SPELL_AURA_PERIODIC_TRIGGER_SPELL)) { targets.m_destX = GetPositionX(); targets.m_destY = GetPositionY(); targets.m_destZ = GetPositionZ(); targets.m_targetMask = TARGET_FLAG_DEST_LOCATION; } pSpell->prepare(&targets); } else { // We're a casting totem. Switch AI on, and tell it to cast this spell. EnableAI(); m_aiInterface->totemspell = TotemSpell; m_aiInterface->m_totemspelltimer = 0; m_aiInterface->m_totemspelltime = 3 * MSTIME_SECOND; } if(TotemSpell2) CastSpell(this, TotemSpell2, true); }
void ScriptMgr::DumpUnimplementedSpells() { std::ofstream of; LOG_BASIC("Dumping IDs for spells with unimplemented dummy/script effect(s)"); uint32 count = 0; of.open("unimplemented1.txt"); for(DBCStorage< SpellEntry >::iterator itr = dbcSpell.begin(); itr != dbcSpell.end(); ++itr) { SpellEntry* sp = *itr; if(!sp->HasEffect(SPELL_EFFECT_DUMMY) && !sp->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT) && !sp->HasEffect(SPELL_EFFECT_SEND_EVENT)) continue; HandleDummySpellMap::iterator sitr = _spells.find(sp->Id); if(sitr != _spells.end()) continue; HandleScriptEffectMap::iterator seitr = SpellScriptEffects.find(sp->Id); if(seitr != SpellScriptEffects.end()) continue; std::stringstream ss; ss << sp->Id; ss << std::endl; of.write(ss.str().c_str(), ss.str().length()); count++; } of.close(); LOG_BASIC("Dumped %u IDs.", count); LOG_BASIC("Dumping IDs for spells with unimplemented dummy aura effect."); std::ofstream of2; of2.open("unimplemented2.txt"); count = 0; for(DBCStorage< SpellEntry >::iterator itr = dbcSpell.begin(); itr != dbcSpell.end(); ++itr) { SpellEntry* sp = *itr; if(!sp->AppliesAura(SPELL_AURA_DUMMY)) continue; HandleDummyAuraMap::iterator ditr = _auras.find(sp->Id); if(ditr != _auras.end()) continue; std::stringstream ss; ss << sp->Id; ss << std::endl; of2.write(ss.str().c_str(), ss.str().length()); count++; } of2.close(); LOG_BASIC("Dumped %u IDs.", count); }