コード例 #1
0
ファイル: TemporarySummon.cpp プロジェクト: GlassFace/XC_CORE
void TempSummon::UnSummon(uint32 msTime)
{
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

    //ASSERT(!IsPet());
    if (IsPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    //npcbot
    if (GetIAmABot() || GetIAmABotsPet())
    {
        //TC_LOG_ERROR("entities.player", "TempSummon::UnSummon(): Trying to unsummon Bot %s (guidLow: %u owner: %s)", GetName().c_str(), GetGUIDLow(), GetBotOwner()->GetName().c_str());
        if (IsTempBot())
            AI()->JustDied(NULL);
        return;
    }
    //end npcbots

    AddObjectToRemoveList();
}
コード例 #2
0
void TempSummon::UnSummon(uint32 msTime)
{
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

    //ASSERT(!isPet());
    if (isPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
	   if (owner && GetEntry() == 30230) // Risen ally
       {
          owner->RemoveAurasDueToSpell(62218);
          owner->RemoveAurasDueToSpell(46619);
       }
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #3
0
void TempSummon::UnSummon(uint32 msTime)
{
    if (msTime)
    {
        ForcedUnsummonDelayEvent *pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

    //ASSERT(!isPet());
    if (isPet())
    {
        if(((Pet*)this)->getPetType() == HUNTER_PET)
            ((Pet*)this)->Remove(PET_SAVE_AS_CURRENT);
        else
            ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #4
0
void TempSummon::UnSummon(uint32 msTime)
{
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

    //ASSERT(!isPet());
    if (isPet())
    {
        if (ToPet()->getPetType() == HUNTER_PET)
            ToPet()->Remove(PET_SLOT_ACTUAL_PET_SLOT, false, ToPet()->m_Stampeded);
        else
            ToPet()->Remove(PET_SLOT_OTHER_PET, false, ToPet()->m_Stampeded);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #5
0
void TempSummon::UnSummon(uint32 msTime)
{ 
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

	// Dont allow to call this function twice (possible)
	if (m_type == TEMPSUMMON_DESPAWNED)
		return;
	SetTempSummonType(TEMPSUMMON_DESPAWNED);

    //ASSERT(!IsPet());
    if (IsPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #6
0
ファイル: TemporarySummon.cpp プロジェクト: XEQT/SkyFireEMU
void TempSummon::UnSummon()
{
    //ASSERT(!isPet());
    if (isPet())
    {
        if (((Pet*)this)->getPetType() == HUNTER_PET)
            ((Pet*)this)->Remove(PET_SLOT_ACTUAL_PET_SLOT);
        else
            ((Pet*)this)->Remove(PET_SLOT_OTHER_PET);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    if (owner &&
        owner->GetTypeId() == TYPEID_PLAYER &&
       ((Player*)owner)->HaveBot() &&
       ((Player*)owner)->GetBot()->GetGUID()==this->GetGUID() &&
       this->isDead()) {    // dont unsummon corpse if a bot
        return;
    }

    AddObjectToRemoveList();
}
コード例 #7
0
ファイル: TemporarySummon.cpp プロジェクト: rexy/ArkCORE
void TempSummon::InitSummon() {
	Unit* owner = GetSummoner();
	if (owner) {
		if (owner->GetTypeId() == TYPEID_UNIT
				&& owner->ToCreature()->IsAIEnabled)
			owner->ToCreature()->AI()->JustSummoned(this);
		if (IsAIEnabled)
			AI()->IsSummonedBy(owner);
	}
}
コード例 #8
0
void TempSummon::InitSummon()
{ 
    Unit* owner = GetSummoner();
    if (owner)
    {
        if (owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
            owner->ToCreature()->AI()->JustSummoned(this);
    }

	// Xinef: Allow to call this hook when npc is summoned by gameobject, in this case pass this as summoner to avoid possible null checks
	if (IsAIEnabled)
		AI()->IsSummonedBy(owner);
}
コード例 #9
0
void TempSummon::UnSummon()
{
    if (isPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #10
0
ファイル: TemporarySummon.cpp プロジェクト: rexy/ArkCORE
void TempSummon::RemoveFromWorld() {
	if (!IsInWorld())
		return;

	if (m_Properties)
		if (uint32 slot = m_Properties->Slot)
			if (Unit* owner = GetSummoner())
				if (owner->m_SummonSlot[slot] == GetGUID())
					owner->m_SummonSlot[slot] = 0;

	//if (GetOwnerGUID())
	//    sLog->outError("Unit %u has owner guid when removed from world", GetEntry());

	Creature::RemoveFromWorld();
}
コード例 #11
0
ファイル: TemporarySummon.cpp プロジェクト: GlassFace/XC_CORE
void TempSummon::RemoveFromWorld()
{
    if (!IsInWorld())
        return;

    if (m_Properties)
        if (uint32 slot = m_Properties->Slot)
            if (Unit* owner = GetSummoner())
                if (owner->m_SummonSlot[slot] == GetGUID())
                    owner->m_SummonSlot[slot].Clear();

    //if (GetOwnerGUID())
    //    TC_LOG_ERROR("entities.unit", "Unit %u has owner guid when removed from world", GetEntry());

    Creature::RemoveFromWorld();
}
コード例 #12
0
void TempSummon::InitStats(uint32 duration)
{ 
    ASSERT(!IsPet());

    m_timer = duration;
    m_lifetime = duration;

    if (m_type == TEMPSUMMON_MANUAL_DESPAWN)
        m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;

    Unit* owner = GetSummoner();
    if (owner)
	{
		if (IsTrigger() && m_spells[0])
		{
			setFaction(owner->getFaction());
			SetLevel(owner->getLevel());
			if (owner->GetTypeId() == TYPEID_PLAYER)
				m_ControlledByPlayer = true;
		}

		if (owner->GetTypeId() == TYPEID_PLAYER)
			m_CreatedByPlayer = true;
    }

    if (!m_Properties)
        return;

    if (owner)
    {
        if (uint32 slot = m_Properties->Slot)
        {
            if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID())
            {
                Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]);
                if (oldSummon && oldSummon->IsSummon())
                    oldSummon->ToTempSummon()->UnSummon();
            }
            owner->m_SummonSlot[slot] = GetGUID();
        }
    }

    if (m_Properties->Faction)
        setFaction(m_Properties->Faction);
    else if (IsVehicle() && owner) // properties should be vehicle
        setFaction(owner->getFaction());
}
コード例 #13
0
ファイル: TemporarySummon.cpp プロジェクト: kmishima/DarkCore
void TempSummon::UnSummon()
{
    //ASSERT(!isPet());
    if (isPet())
    {
        if (((Pet*)this)->getPetType() == HUNTER_PET)
            ((Pet*)this)->Remove(PET_SLOT_ACTUAL_PET_SLOT);
        else
            ((Pet*)this)->Remove(PET_SLOT_OTHER_PET);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #14
0
void TempSummon::RemoveFromWorld()
{
    if (!IsInWorld())
        return;

    if (m_Properties)
    {
        int32 slot = m_Properties->Slot;
        if (slot > 0)
            if (Unit* owner = GetSummoner())
                if (owner->m_SummonSlot[slot] == GetGUID())
                    owner->m_SummonSlot[slot] = 0;
    }

    //if (GetOwnerGUID())
    //    TC_LOG_ERROR(LOG_FILTER_UNITS, "Unit %u has owner guid when removed from world", GetEntry());

    Creature::RemoveFromWorld();
}
コード例 #15
0
ファイル: TemporarySummon.cpp プロジェクト: Jildor/4.3.4-Core
void TempSummon::UnSummon(uint32 msTime)
{
    if (msTime)
    {
        ForcedUnsummonDelayEvent* pEvent = new ForcedUnsummonDelayEvent(*this);

        m_Events.AddEvent(pEvent, m_Events.CalculateTime(msTime));
        return;
    }

    // Custom operations
    switch(GetEntry())
    {
        // Force of Nature
        case 36070:
            // If not it's directly handled in JustDied
            if(IsAIEnabled && isAlive())
            {
                 AI()->JustDied(this);
            }
            break;
    }

    //ASSERT(!isPet());
    if (isPet())
    {
        ((Pet*)this)->Remove(PET_SAVE_NOT_IN_SLOT);
        ASSERT(!IsInWorld());
        return;
    }

    Unit* owner = GetSummoner();
    if (owner && owner->GetTypeId() == TYPEID_UNIT && owner->ToCreature()->IsAIEnabled)
        owner->ToCreature()->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
コード例 #16
0
void TempSummon::InitStats(uint32 duration)
{
    ASSERT(!isPet());

    m_timer = duration;
    m_lifetime = duration;

    if (m_type == TEMPSUMMON_MANUAL_DESPAWN)
        m_type = (duration == 0) ? TEMPSUMMON_DEAD_DESPAWN : TEMPSUMMON_TIMED_DESPAWN;

    Unit* owner = GetSummoner();

    if (owner && isTrigger() && m_spells[0])
    {
        setFaction(owner->getFaction());
        SetLevel(owner->getLevel());
        if (owner->GetTypeId() == TYPEID_PLAYER)
            m_ControlledByPlayer = true;
    }

    if (!m_Properties)
        return;

    // Fix Force of Nature treants stats
    if (owner && owner->getClass() == CLASS_DRUID && owner->HasSpell(106737))
    {
        float damage = 0.0f;

        switch (GetEntry())
        {
        case ENTRY_TREANT_RESTO:
        case ENTRY_TREANT_BALANCE:
            SetMaxHealth(owner->CountPctFromMaxHealth(40));
            break;
        case ENTRY_TREANT_GUARDIAN:
            SetMaxHealth(owner->CountPctFromMaxHealth(40));
            // (Attack power / 14 * 2 * 0.75) * 0.2f
            damage = ((owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f) * 0.2f;
            SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage);
            SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage);
        case ENTRY_TREANT_FERAL:
            SetMaxHealth(owner->CountPctFromMaxHealth(40));
            // Attack power / 14 * 2 * 0.75
            damage = (owner->GetTotalAttackPowerValue(BASE_ATTACK) / 14.0f) * 2.0f * 0.75f;
            SetStatFloatValue(UNIT_FIELD_MINDAMAGE, damage);
            SetStatFloatValue(UNIT_FIELD_MAXDAMAGE, damage);
        default:
            break;
        }
    }

    if (owner)
    {
        if (uint32 slot = m_Properties->Slot)
        {
            if (owner->m_SummonSlot[slot] && owner->m_SummonSlot[slot] != GetGUID())
            {
                Creature* oldSummon = GetMap()->GetCreature(owner->m_SummonSlot[slot]);
                if (oldSummon && oldSummon->IsSummon())
                    oldSummon->ToTempSummon()->UnSummon();
            }
            owner->m_SummonSlot[slot] = GetGUID();
        }
    }

    if (m_Properties->Faction)
        setFaction(m_Properties->Faction);
    else if (IsVehicle() && owner) // properties should be vehicle
        setFaction(owner->getFaction());
}
コード例 #17
0
void TemporarySummon::Update(uint32 update_diff, uint32 diff)
{
    TSUpdateActions ua = TSUA_NONE;

    switch (m_type)
    {
        case TEMPSUMMON_MANUAL_DESPAWN:
            break;
        case TEMPSUMMON_DEAD_DESPAWN:
        {
            if (IsDespawned())
                ua = TSUA_UNSUMMON;
            break;
        }
        case TEMPSUMMON_CORPSE_DESPAWN:
        {
            // if m_deathState is DEAD, CORPSE was skipped
            if (isDead())
                ua = TSUA_UNSUMMON;
            break;
        }
        case TEMPSUMMON_CORPSE_TIMED_DESPAWN:
        {
            if (IsDespawned())
                ua = TSUA_UNSUMMON;
            else if (IsCorpse())
                ua = TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_DESPAWN:
        {
            ua = TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_OOC_DESPAWN:
        {
            ua = isInCombat() ? TSUA_RESET_TIMER : TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_OR_DEAD_DESPAWN:
        {
            ua = IsDespawned() ? TSUA_UNSUMMON : TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN:
        {
            // if m_deathState is DEAD, CORPSE was skipped
            ua = isDead() ? TSUA_UNSUMMON : TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_OOC_OR_DEAD_DESPAWN:
        {
            if (IsDespawned())
                ua = TSUA_UNSUMMON;
            else
                ua = (!isInCombat() && isAlive()) ? TSUA_CHECK_TIMER : TSUA_RESET_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_OOC_OR_CORPSE_DESPAWN:
        {
            if (isDead())
                ua = TSUA_UNSUMMON;
            else
                ua = isInCombat() ? TSUA_RESET_TIMER : TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_LOST_OWNER_DESPAWN:
        case TEMPSUMMON_DEAD_OR_LOST_OWNER_DESPAWN:
        {
            if (m_type == TEMPSUMMON_DEAD_OR_LOST_OWNER_DESPAWN && IsDespawned())
                ua = TSUA_UNSUMMON;
            else if (!GetSummoner())
            {
                m_type = TEMPSUMMON_TIMED_DESPAWN;
                m_lifetime = DEFAULT_DESPAWN_DELAY;
                ua = TSUA_RESET_TIMER;
            }
            break;
        }
        case TEMPSUMMON_TIMED_OR_DEAD_OR_LOST_OWNER_DESPAWN:
        {
            ua = (IsDespawned() || !GetSummoner()) ? TSUA_UNSUMMON : TSUA_CHECK_TIMER;
            break;
        }
        case TEMPSUMMON_TIMED_OR_DEAD_OR_LOST_UNIQUENESS_DESPAWN:
        {
            ua = IsDespawned() ? TSUA_UNSUMMON : TSUpdateActions(TSUA_CHECK_UNIQUENESS | TSUA_CHECK_TIMER);
            break;
        }
        case TEMPSUMMON_DEAD_OR_LOST_UNIQUENESS_DESPAWN:
        {
            ua = IsDespawned() ? TSUA_UNSUMMON : TSUA_CHECK_UNIQUENESS;
            break;
        }
        default:
            ua = TSUA_UNSUMMON;
            sLog.outError("Temporary summoned %s have unknown type %u of", GetGuidStr().c_str(), m_type);
            break;
    }

    if (ua & TSUA_RESET_TIMER)
    {
        if (m_timer != m_lifetime)
            m_timer = m_lifetime;
    }
    else if (ua & TSUA_CHECK_TIMER)
    {
        if (m_timer <= update_diff)
            ua = TSUA_UNSUMMON;
        else
            m_timer -= update_diff;
    }

    if (ua & TSUA_CHECK_UNIQUENESS)
    {
        std::list<Creature*> tlist;
        MaNGOS::AllIdenticalObjectsInRangeCheck check(this, GetMap()->GetVisibilityDistance());
        MaNGOS::CreatureListSearcher<MaNGOS::AllIdenticalObjectsInRangeCheck> searcher(tlist, check);
        Cell::VisitGridObjects(this, searcher, GetMap()->GetVisibilityDistance(), true);

        for (std::list<Creature*>::const_iterator itr = tlist.begin(); itr != tlist.end(); ++itr)
        {
            Creature* pCre = *itr;
            if (!pCre || !pCre->isAlive() || !pCre->IsTemporarySummon())
                continue;

            if (((TemporarySummon*)pCre)->GetTempSummonType() == GetTempSummonType() &&
                ((TemporarySummon*)pCre)->GetSummonerGuid() == GetSummonerGuid())
            {
                ua = TSUA_UNSUMMON;
                break;
            }
        }
    }

    if (ua & TSUA_UNSUMMON)
    {
        UnSummon();
        return;
    }

    if (!m_isActive)
        return;

    Creature::Update(update_diff, diff);
}