Exemplo n.º 1
0
void TemporarySummon::UnSummon(uint32 delay)
{
    if (delay > 0)
    {
        m_type = TEMPSUMMON_TIMED_OR_DEAD_DESPAWN;
        m_timer = delay;
        return;
    }

    m_isActive = false;

    CombatStop();

    if (GetSummonerGuid().IsCreatureOrVehicle())
    {
        if (Creature* sum = GetMap()->GetCreature(GetSummonerGuid()))
        {
            if (sum->AI())
                sum->AI()->SummonedCreatureDespawn(this);
        }
    }

    KillAllEvents(false);

    AddObjectToRemoveList();

    // Prevent double unsummonig before remove from world
    m_type = TEMPSUMMON_MANUAL_DESPAWN;
}
Exemplo n.º 2
0
void TemporarySummon::UnSummon()
{
    CombatStop();

    if (GetSummonerGuid().IsCreature())
        if(Creature* sum = GetMap()->GetCreature(GetSummonerGuid()))
            if (sum->AI())
                sum->AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
Exemplo n.º 3
0
/////////////////////////////////////////////////
/// [Serverside] Fog of War: Unit's stat values can be seen by other unit
///
/// @note Relations API Tier 3
///
/// This function is not intented to have client-side counterpart by original design.
/// A helper function to determine if unit's stat values are always visible to another unit.
/////////////////////////////////////////////////
bool Unit::IsFogOfWarVisibleStats(Unit const* other) const
{
    // Gamemasters can see stat values
    if (other->GetTypeId() == TYPEID_PLAYER && static_cast<Player const*>(other)->isGameMaster())
        return true;

    switch (sWorld.getConfig(CONFIG_UINT32_FOGOFWAR_STATS))
    {
        default: return (this == other || GetSummonerGuid() == other->GetObjectGuid());
        case 1:  return CanCooperate(other);
        case 2:  return true;
    }
}
Exemplo n.º 4
0
void TemporarySummon::UnSummon()
{
    CombatStop();

    if (m_linkedToOwnerAura & TEMPSUMMON_LINKED_AURA_REMOVE_OWNER)
        RemoveAuraFromOwner();

    if (GetSummonerGuid().IsCreatureOrVehicle())
    {
        if (Creature* sum = GetMap()->GetCreature(GetSummonerGuid()))
            if (sum->AI())
                sum->AI()->SummonedCreatureDespawn(this);
    }
    else if (GetSummonerGuid().IsPlayer()) // if player that summoned this creature was MCing it, uncharm
        if (Player* player = GetMap()->GetPlayer(GetSummonerGuid()))
            if (player->GetMover() == this)
                player->Uncharm();

    if (AI())
        AI()->SummonedCreatureDespawn(this);

    AddObjectToRemoveList();
}
Exemplo n.º 5
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);
}