Beispiel #1
0
    void DamageTaken(Unit* pKiller, uint32 &damage)
    {
        if (damage < me->GetHealth())
            return;

        //Prevent glitch if in fake death
        if (FakeDeath && m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) != 0)
        {
            damage = 0;
            return;
        }

        //Don't really die in phase 1 & 3, only die after that
        if (m_pInstance && m_pInstance->GetData(DATA_KAELTHASEVENT) != 0)
        {
            //prevent death
            damage = 0;
            FakeDeath = true;

            me->InterruptNonMeleeSpells(false);
            me->SetHealth(0);
            me->StopMoving();
            me->ClearComboPointHolders();
            me->RemoveAllAurasOnDeath();
            me->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false);
            me->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
            me->ClearAllReactives();
            me->SetUInt64Value(UNIT_FIELD_TARGET,0);
            me->GetMotionMaster()->Clear();
            me->GetMotionMaster()->MoveIdle();
            me->SetStandState(UNIT_STAND_STATE_DEAD);
            JustDied(pKiller);
        }
    }
    void DamageTaken(Unit* pKiller, uint32& uiDamage) override
    {
        if (uiDamage < m_creature->GetHealth())
            return;

        // Prevent glitch if in fake death
        if (m_bFakeDeath)
        {
            uiDamage = 0;
            return;
        }

        // prevent death
        uiDamage = 0;
        m_bFakeDeath = true;

        m_creature->InterruptNonMeleeSpells(false);
        m_creature->SetHealth(0);
        m_creature->StopMoving();
        m_creature->ClearComboPointHolders();
        m_creature->RemoveAllAurasOnDeath();
        m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_20_PERCENT, false);
        m_creature->ModifyAuraState(AURA_STATE_HEALTHLESS_35_PERCENT, false);
        m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
        m_creature->ClearAllReactives();
        m_creature->GetMotionMaster()->Clear();
        m_creature->GetMotionMaster()->MoveIdle();
        m_creature->SetStandState(UNIT_STAND_STATE_DEAD);

        JustDied(pKiller);                                  // Texts
    }
		void DamageTaken(Unit* who, uint32& damage)
		{
			if (damage >= me->GetHealth())
			{
				damage = 0;
				evade = true;
				JustDied(who);
			}
		}
 void DamageTaken(Unit *pDoneBy, uint32& uiDamage)
 {
     if(uiDamage > m_creature->GetHealth())
     {
         m_creature->RemoveAllAuras();
         m_creature->SetHealth(1);
         m_creature->RemoveAllAttackers();
         IsInUse = false;
         m_creature->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
         uiDamage = 0;
         if(IsVoltron)
         {
             if(!IsDeadAsVoltron)
             {
                 IsDeadAsVoltron = true;
                 JustDied(pDoneBy);
             }
         }
         else
             JustDied(pDoneBy);
     }
 }
Beispiel #5
0
 void WaypointReached(uint32 uiPointId) override
 {
     switch (uiPointId)
     {
         case 2:
             SetRun();
             m_creature->RemoveAurasDueToSpell(SPELL_STEALTH);
             m_creature->SetFactionTemporary(FACTION_ENEMY, TEMPFACTION_RESTORE_RESPAWN | TEMPFACTION_RESTORE_COMBAT_STOP);
             break;
         case 6:
             // fail the quest if he escapes
             if (Player* pPlayer = GetPlayerForEscort())
                 JustDied(pPlayer);
             break;
     }
 }
Beispiel #6
0
void npc_escortAI::UpdateAI(const uint32 diff)
{
    //Waypoint Updating
    if (IsBeingEscorted && !m_creature->isInCombat() && WaitTimer && !Returning)
    {
        if (WaitTimer <= diff)
    {
        if (ReconnectWP)
        {
            //Correct movement speed
            if (bIsRunning && m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
                m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
            else if (!bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
                    m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);

            //Continue with waypoints
            if( !IsOnHold )
            {
                    if (CurrentWP != WaypointList.end())
                    {
                        m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
                        debug_log("RSCR: EscortAI Reconnect WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);

                        WaitTimer = 0;
                        ReconnectWP = false;
                        return;
                    }
                    else
                        debug_log("RSCR: EscortAI Reconnected to end of WP list");
            }
        }

        //End of the line, Despawn self then immediatly respawn
        if (CurrentWP == WaypointList.end())
        {
            if(DespawnAtEnd)
            {
                debug_log("RSCR: EscortAI reached end of waypoints");

                m_creature->setDeathState(JUST_DIED);
                m_creature->Respawn();
                m_creature->GetMotionMaster()->Clear(true);

                //Restore original NpcFlags
                m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_uiNpcFlags);

                IsBeingEscorted = false;
                WaitTimer = 0;
                return;
            }
            else
            {
                debug_log("RSCR: EscortAI reached end of waypoints with Despawn off");
                IsBeingEscorted = false;
                WaitTimer = 0;
                return;
            }
        }

        if( !IsOnHold )
        {
            m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
            debug_log("RSCR: EscortAI Next WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
            WaitTimer = 0;
        }
    }else WaitTimer -= diff;
    }

    //Check if player is within range
    if (IsBeingEscorted && !m_creature->isInCombat() && PlayerGUID)
    {
        if (PlayerTimer < diff)
    {
        Unit* p = Unit::GetUnit(*m_creature, PlayerGUID);

        if (DespawnAtFar && (!p || !m_creature->IsWithinDist(p,GetMaxPlayerDistance())))
        {
            JustDied(m_creature);
            IsBeingEscorted = false;

            debug_log("RSCR: EscortAI Evaded back to spawn point because player was to far away or not found");

            m_creature->setDeathState(JUST_DIED);
            m_creature->SetHealth(0);
            m_creature->CombatStop(true);
            m_creature->DeleteThreatList();
            m_creature->Respawn();
            m_creature->GetMotionMaster()->Clear(true);

            //Restore original NpcFlags
            m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_uiNpcFlags);

        }

        PlayerTimer = 1000;
    }else PlayerTimer -= diff;
    }

    if(CanMelee && UpdateVictim())
        DoMeleeAttackIfReady();
}
Beispiel #7
0
void npc_escortAI::UpdateAI(const uint32 diff)
{
    //Waypoint Updating
    if (IsBeingEscorted && !InCombat && WaitTimer && !Returning)
    {
        if (WaitTimer <= diff)
        {
            if (ReconnectWP)
            {
                //Correct movement speed
                if (bIsRunning && m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
                    m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
                else if (!bIsRunning && !m_creature->HasUnitMovementFlag(MOVEMENTFLAG_WALK_MODE))
                    m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);

                //Continue with waypoints
                if (!IsOnHold)
                {
                    if (CurrentWP != WaypointList.end())
                    {
                        m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
                        debug_log("SD2: EscortAI Reconnect WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);

                        WaitTimer = 0;
                        ReconnectWP = false;
                        return;
                    }
                    else
                        debug_log("SD2: EscortAI Reconnected to end of WP list");
                }
            }

            //End of the line, Despawn self then immediatly respawn
            if (CurrentWP == WaypointList.end())
            {
                debug_log("SD2: EscortAI reached end of waypoints");

                m_creature->setDeathState(JUST_DIED);
                m_creature->SetHealth(0);
                m_creature->CombatStop();
                m_creature->DeleteThreatList();
                m_creature->Respawn();
                m_creature->GetMotionMaster()->Clear(true);

                //Restore original NpcFlags
                m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_uiNpcFlags);

                IsBeingEscorted = false;
                WaitTimer = 0;
                return;
            }

            if (!IsOnHold)
            {
                m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
                debug_log("SD2: EscortAI Next WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
                WaitTimer = 0;
            }
        }else WaitTimer -= diff;
    }

    //Check if player is within range
    if (IsBeingEscorted && !InCombat && PlayerGUID)
    {
        if (PlayerTimer < diff)
        {
            Unit* p = Unit::GetUnit(*m_creature, PlayerGUID);

            if (!p || m_creature->GetDistance(p) > MAX_PLAYER_DISTANCE)
            {
                JustDied(m_creature);
                IsBeingEscorted = false;

                debug_log("SD2: EscortAI Evaded back to spawn point because player was to far away or not found");

                m_creature->setDeathState(JUST_DIED);
                m_creature->SetHealth(0);
                m_creature->CombatStop();
                m_creature->DeleteThreatList();
                m_creature->Respawn();
                m_creature->GetMotionMaster()->Clear(true);

                //Restore original NpcFlags
                m_creature->SetUInt32Value(UNIT_NPC_FLAGS, m_uiNpcFlags);
            }

            PlayerTimer = 1000;
        }else PlayerTimer -= diff;
    }

    //Check if we have a current target
    if (m_creature->isAlive() && m_creature->SelectHostilTarget() && m_creature->getVictim())
    {
        //If we are within range melee the target
        if (m_creature->IsWithinDistInMap(m_creature->getVictim(), ATTACK_DISTANCE))
        {
            if (m_creature->isAttackReady())
            {
                m_creature->AttackerStateUpdate(m_creature->getVictim());
                m_creature->resetAttackTimer();
            }
        }
    }
}
Beispiel #8
0
void npc_escortAI::UpdateAI(const uint32 diff)
{
    //Waypoint Updating
    if (IsBeingEscorted && !InCombat && WaitTimer && !Returning)
    {
        if (WaitTimer <= diff)
        {
            if (ReconnectWP)
            {
                //Correct movement speed
                if (Run)
                    m_creature->RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
                else m_creature->AddUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);

                //Continue with waypoints
                if( !IsOnHold )
                {
                    m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
                debug_log("TSCR: EscortAI Reconnect WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
                    WaitTimer = 0;
                    ReconnectWP = false;
                    return;
                }
            }

        //End of the line, Despawn self then immediatly respawn
            if (CurrentWP == WaypointList.end())
            {
                if(DespawnAtEnd)
                {
                debug_log("TSCR: EscortAI reached end of waypoints");

                    m_creature->setDeathState(JUST_DIED);
                    m_creature->SetHealth(0);
                    m_creature->CombatStop();
                    m_creature->DeleteThreatList();
                    m_creature->Respawn();
                    m_creature->GetMotionMaster()->Clear(true);

                    //Re-Enable gossip
                    m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);

                    IsBeingEscorted = false;
                    WaitTimer = 0;
                    return;
                }else{
                debug_log("TSCR: EscortAI reached end of waypoints with Despawn off");
                    IsBeingEscorted = false;
                    WaitTimer = 0;
                    return;
                }
            }

        if( !IsOnHold )
        {
            m_creature->GetMotionMaster()->MovePoint(CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z );
            debug_log("TSCR: EscortAI Next WP is: %u, %f, %f, %f", CurrentWP->id, CurrentWP->x, CurrentWP->y, CurrentWP->z);
            WaitTimer = 0;
        }
    }else WaitTimer -= diff;
}

    //Check if player is within range
    if (IsBeingEscorted && !InCombat && PlayerGUID)
    {
        if (PlayerTimer < diff)
    {
        Unit* p = Unit::GetUnit(*m_creature, PlayerGUID);

        if (DespawnAtFar && (!p || m_creature->GetDistance(p) > GetMaxPlayerDistance()))
        {
            JustDied(m_creature);
            IsBeingEscorted = false;

            debug_log("TSCR: EscortAI Evaded back to spawn point because player was to far away or not found");

            m_creature->setDeathState(JUST_DIED);
            m_creature->SetHealth(0);
            m_creature->CombatStop();
            m_creature->DeleteThreatList();
            m_creature->Respawn();
            m_creature->GetMotionMaster()->Clear(true);

            //Re-Enable gossip
            m_creature->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
        }

        PlayerTimer = 1000;
    }else PlayerTimer -= diff;
    }

    if(CanMelee)
    {
        //Check if we have a current target
        if( m_creature->isAlive() && UpdateVictim() && m_creature->canMelee() )
        {
            //If we are within range melee the target
            if( m_creature->IsWithinMeleeRange(m_creature->getVictim()))
            {
                if( m_creature->isAttackReady() )
                {
                        m_creature->AttackerStateUpdate(m_creature->getVictim());
                        m_creature->resetAttackTimer();
                }
            }
        }
    }
}