Exemplo n.º 1
0
	void AIUpdate()
	{
		if (!IsCasting())
		{
			if (mBlastWaveTimer == -1 || IsTimerFinished(mBlastWaveTimer))
			{
				Unit* unit = GetBestUnitTarget(TargetFilter_Closest);
				if (unit && GetRangeToUnit(unit) < 15.0f)
				{
					CastSpellNowNoScheduling(mBlastWave);
					if (mBlastWaveTimer == -1)
						mBlastWaveTimer = AddTimer(6000);
					else
						ResetTimer(mBlastWaveTimer, 6000);
					ParentClass::AIUpdate();
					return;
				}
			}

			if (IsTimerFinished(mEventTimer))
			{
				ResetTimer(mEventTimer, 30000);
				CastSpellNowNoScheduling(mSpellShield);
			}
		}

		ParentClass::AIUpdate();
	}
Exemplo n.º 2
0
        void AIUpdate()
        {
            SpellDesc* pShield = FindSpellById(OMOR_DEMONIC_SHIELD);
            if (GetHealthPercent() <= 20 && pShield != NULL && !pShield->mEnabled)
            {
                pShield->mEnabled = true;
            }

            Unit* pTarget = _unit->GetAIInterface()->getNextTarget();
            if (pTarget != NULL)
            {
                if (GetRangeToUnit(pTarget) > 10.0f)
                {
                    pTarget = GetBestPlayerTarget(TargetFilter_Closest);
                    if (pTarget != NULL)
                    {
                        if (GetRangeToUnit(pTarget) > 10.0f)
                        {
                            pTarget = NULL;
                        }
                        else
                        {
                            ClearHateList();
                            _unit->GetAIInterface()->AttackReaction(pTarget, 500);
                            _unit->GetAIInterface()->setNextTarget(pTarget);
                        }
                    }
                    else
                        return;
                }

                if (pTarget == NULL)
                {
                    SpellDesc* pWhip = FindSpellById(OMOR_SHADOW_WHIP);    // used for now
                    if (pWhip != NULL)
                    {
                        pWhip->mLastCastTime = 0;
                        CastSpellNowNoScheduling(pWhip);
                        return;
                    }
                }
            }

            ParentClass::AIUpdate();
            SetCanMove(false);
    }
Exemplo n.º 3
0
	void AIUpdate()
	{
		if (!IsCasting())
		{
			if (IsTimerFinished(mGrowthTimer))
			{
				if (mGrowthStacks == 30)
				{
					RemoveAura(GRUUL_THE_DRAGONKILLER_GROWTH);
					mGrowthStacks = 0;
				}
				if (mGrowthStacks != 29)
				{
					ResetTimer(mGrowthTimer, 30000);
				}
				else if (mGrowthStacks == 29)
				{
					ResetTimer(mGrowthTimer, 300000);
				}

				ApplyAura(GRUUL_THE_DRAGONKILLER_GROWTH);
				++mGrowthStacks;
			}
			else if (IsTimerFinished(mHurtfulTimer))
			{
				Unit* pCurrentTarget = _unit->GetAIInterface()->GetNextTarget();
				if (pCurrentTarget != NULL)
				{
					Unit* pTarget = pCurrentTarget;
					for (unordered_set<Player*>::iterator itr = _unit->GetInRangePlayerSetBegin(); itr != _unit->GetInRangePlayerSetEnd(); itr++) 
					{
						Player* pPlayer = TO_PLAYER(*itr);
						if (!pPlayer->isAlive())
							continue;
//						if (pPlayer->m_auracount[SPELL_AURA_MOD_INVISIBILITY])
//							continue;
						if (pPlayer->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_FEIGN_DEATH))
							continue;
						if (GetRangeToUnit(pPlayer) > 8.0f)
							continue;
						if (_unit->GetAIInterface()->getThreatByPtr(pPlayer) >= _unit->GetAIInterface()->getThreatByPtr(pCurrentTarget))
							continue;

						pTarget = TO_UNIT(pPlayer);
					}
					
					if (pTarget == pCurrentTarget)
						CastSpellNowNoScheduling(mHurtfulStrike);
					else
						_unit->CastSpell(pTarget, GRUUL_THE_DRAGONKILLER_HURTFUL_STRIKE, true);
				}

				ResetTimer(mHurtfulTimer, 8000);
			}
		}

		ParentClass::AIUpdate();
	}
Exemplo n.º 4
0
bool ArcScriptCreatureAI::IsUnitInRange(Unit* pTarget, SpellDesc* pSpell)
{
	if( pSpell->mTargetType != Target_Self && pTarget != _unit && (pSpell->mMinRange > 0 || pSpell->mMaxRange > 0) )
	{
		float Range = GetRangeToUnit(pTarget);
		if( pSpell->mMinRange > 0 && (Range < pSpell->mMinRange) ) return false;
		if( pSpell->mMaxRange > 0 && (Range > pSpell->mMaxRange) ) return false;
	}
	return true;
}
Exemplo n.º 5
0
	void OnCombatStart(Unit* pTarget)
	{
		ParentClass::OnCombatStart(pTarget);

		if (GetRangeToUnit(pTarget) <= 40.0f)
		{
			SetBehavior(Behavior_Spell);
			SetCanMove(false);
		}
	}
Exemplo n.º 6
0
	void AIUpdate()
	{
		/*
			They say, if you pull them far enough away from Lucifron, There shalt be no mind control.
		*/
		if(Lucifron && GetRangeToUnit((Unit*)Lucifron) < 500)
			DominateMind->mEnabled = true;
		else
			DominateMind->mEnabled = false;

		ParentClass::AIUpdate();
	}
Exemplo n.º 7
0
	void AIUpdate()
	{
		// 40 yrds
		if((CoreRager1 && CoreRager1->isAlive() && GetRangeToUnit(CoreRager1) < 40) || (CoreRager2 && CoreRager2->isAlive() && GetRangeToUnit(CoreRager2) < 40))
			GolemaggTrust->mEnabled = true;
		else
			GolemaggTrust->mEnabled = false;

		if(GetPhase() == 1 && GetHealthPercent() <= 10)
			SetPhase(2);

		ParentClass::AIUpdate();
	}
Exemplo n.º 8
0
RangeStatusPair MoonScriptCreatureAI::GetSpellRangeStatusToUnit( Unit *pTarget, SpellDesc* pSpell )
{
	if ( pSpell->mTargetType.mTargetGenerator != TargetGen_Self && pTarget != _unit && (pSpell->mMinRange > 0 || pSpell->mMaxRange > 0) )
	{
		float Range = GetRangeToUnit(pTarget);
		if ( pSpell->mMinRange > 0 && (Range < pSpell->mMinRange) )
			return make_pair( RangeStatus_TooClose, pSpell->mMinRange );
		if ( pSpell->mMaxRange > 0 && (Range > pSpell->mMaxRange) )
			return make_pair( RangeStatus_TooFar, pSpell->mMaxRange );
	};

	return make_pair( RangeStatus_Ok, 0.0f );
};
Exemplo n.º 9
0
	void AIUpdate()
	{
		ParentClass::AIUpdate();

		Unit* pTarget = _unit->GetAIInterface()->GetNextTarget();
		if (pTarget != NULL)
		{
			if (GetRangeToUnit(pTarget) <= 40.0f)
			{
				SetBehavior(Behavior_Spell);
				SetCanMove(false);
			}
		}
	}
Exemplo n.º 10
0
Unit* ArcScriptCreatureAI::GetNearestTargetInArray(UnitArray& pTargetArray)
{
	Unit* NearestUnit = NULL;
	float Distance, NearestDistance = 99999;
	for( UnitArray::iterator UnitIter = pTargetArray.begin(); UnitIter != pTargetArray.end(); ++UnitIter )
	{
		Distance = GetRangeToUnit(*UnitIter);
		if( Distance < NearestDistance )
		{
			NearestDistance = Distance;
			NearestUnit = (*UnitIter);
		}
	}
	return NearestUnit;
}
Exemplo n.º 11
0
bool MoonScriptCreatureAI::IsValidUnitTarget( Object *pObject, TargetFilters pFilter, float pMinRange, float pMaxRange )
{
	//Make sure its a valid unit
	if ( !pObject->IsUnit() )
		return false;
	if ( pObject->GetInstanceID() != _unit->GetInstanceID() )
		return false;

	Unit *UnitTarget = TO_UNIT( pObject );
	//Skip dead ( if required ), feign death or invisible targets
	if ( pFilter & TargetFilter_Corpse )
	{
		if ( UnitTarget->isAlive() || !UnitTarget->IsCreature() || TO_CREATURE( UnitTarget )->creature_info->Rank == ELITE_WORLDBOSS )
			return false;
	}
	else if ( !UnitTarget->isAlive() )
		return false;

	if ( UnitTarget->IsPlayer() && TO_PLAYER( UnitTarget )->m_isGmInvisible )
		return false;
	if ( UnitTarget->HasFlag( UNIT_FIELD_FLAGS, UNIT_FLAG_FEIGN_DEATH ) )
		return false;

	//Check if we apply target filtering
	if ( pFilter != TargetFilter_None )
	{
		//Skip units not on threat list
		if ( ( pFilter & TargetFilter_Aggroed ) && _unit->GetAIInterface()->getThreatByPtr( UnitTarget ) == 0 )
			return false;

		//Skip current attacking target if requested
		if ( ( pFilter & TargetFilter_NotCurrent ) && UnitTarget == _unit->GetAIInterface()->GetNextTarget() )
			return false;

		//Keep only wounded targets if requested
		if ( ( pFilter & TargetFilter_Wounded ) && UnitTarget->GetHealthPct() >= 99 )
			return false;

		//Skip targets not in melee range if requested
		if ( ( pFilter & TargetFilter_InMeleeRange ) && GetRangeToUnit( UnitTarget ) > _unit->GetAIInterface()->_CalcCombatRange( UnitTarget, false ) )
			return false;

		//Skip targets not in strict range if requested
		if ( ( pFilter & TargetFilter_InRangeOnly ) && ( pMinRange > 0 || pMaxRange > 0 ) )
		{
			float Range = GetRangeToUnit( UnitTarget );
			if ( pMinRange > 0 && Range < pMinRange )
				return false;
			if ( pMaxRange > 0 && Range > pMaxRange )
				return false;
		};

		//Skip targets not in Line Of Sight if requested
		if ( ( ~pFilter & TargetFilter_IgnoreLineOfSight ) && !_unit->IsInLineOfSight( UnitTarget ) )
			return false;

		//Handle hostile/friendly
		if ( ( ~pFilter & TargetFilter_Corpse ) && ( pFilter & TargetFilter_Friendly ) ) 
		{
			if ( !UnitTarget->CombatStatus.IsInCombat() )
				return false; //Skip not-in-combat targets if friendly
			if ( isHostile( _unit, UnitTarget ) || _unit->GetAIInterface()->getThreatByPtr( UnitTarget ) > 0 )
				return false;
		};
	};

	return true; //This is a valid unit target
};