Ejemplo n.º 1
0
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);
}
Ejemplo n.º 2
0
void ScriptMgr::register_dummy_spell(uint32 entry, exp_handle_dummy_spell callback)
{
	if(_spells.find(entry) != _spells.end())
	{
		LOG_ERROR("ScriptMgr is trying to register a script for Spell ID: %u even if there's already one for that Spell. Remove one of those scripts.", entry);
		return;
	}

	SpellEntry* sp = dbcSpell.LookupEntryForced(entry);
	if(sp == NULL)
	{
		LOG_ERROR("ScriptMgr is trying to register a dummy handler for Spell ID: %u which is invalid.", entry);
		return;
	}

	if(!sp->HasEffect(SPELL_EFFECT_DUMMY) && !sp->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT) && !sp->HasEffect(SPELL_EFFECT_SEND_EVENT))
		LOG_ERROR("ScriptMgr has registered a dummy handler for Spell ID: %u ( %s ), but spell has no dummy/script/send event effect!", entry, sp->Name);

	_spells.insert(HandleDummySpellMap::value_type(entry, callback));
}
Ejemplo n.º 3
0
void ScriptMgr::register_script_effect(uint32 entry, exp_handle_script_effect callback)
{

	HandleScriptEffectMap::iterator itr = SpellScriptEffects.find(entry);

	if(itr != SpellScriptEffects.end())
	{
		LOG_ERROR("ScriptMgr tried to register more than 1 script effect handlers for Spell %u", entry);
		return;
	}

	SpellEntry* sp = dbcSpell.LookupEntryForced(entry);
	if(sp == NULL)
	{
		LOG_ERROR("ScriptMgr tried to register a script effect handler for Spell %u, which is invalid.", entry);
		return;
	}

	if(!sp->HasEffect(SPELL_EFFECT_SCRIPT_EFFECT) && !sp->HasEffect(SPELL_EFFECT_SEND_EVENT))
		LOG_ERROR("ScriptMgr has registered a script effect handler for Spell ID: %u ( %s ), but spell has no scripted effect!", entry, sp->Name);

	SpellScriptEffects.insert(std::pair< uint32, exp_handle_script_effect >(entry, callback));
}
Ejemplo n.º 4
0
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);
}