Exemple #1
0
void Summon::OnPreRemoveFromWorld()
{
    if (owner == NULL)
        return;

    if (GetCreatedBySpell() != 0)
        owner->RemoveAura(GetCreatedBySpell());

    if (summonslot != -1)
        owner->summonhandler.RemoveSummonFromSlot(summonslot, false);
    else
        owner->summonhandler.RemoveSummon(this);

    summonslot = -1;
    owner = NULL;

    SendDestroyObject();
}
Exemple #2
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);
}