Example #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();
	}
Example #2
0
void ArcScriptCreatureAI::AggroRandomUnit(int pInitialThreat)
{
	Unit* RandomTarget = GetBestUnitTarget();
	if( RandomTarget )
	{
		_unit->GetAIInterface()->AttackReaction(RandomTarget, pInitialThreat);
		OnCombatStart(RandomTarget);	//Patch, for some reason, OnCombatStart isn't called in this case
	}
}
Example #3
0
void MoonScriptCreatureAI::AggroNearestUnit(int pInitialThreat)
{
	Unit* NearestRandomTarget = GetBestUnitTarget(TargetFilter_Closest);
	if( NearestRandomTarget )
	{
		_unit->GetAIInterface()->AttackReaction(NearestRandomTarget, pInitialThreat);
		OnCombatStart(NearestRandomTarget);	//Patch, for some reason, OnCombatStart isn't called in this case
	}
}
Example #4
0
Unit *AIInterface::GetTargetForSpell( AI_Spell* pSpell )
{
	if(pSpell == NULL)
		return NULLUNIT;

	//Check if run-to-target cache and return it if its valid
	if ( m_nextTarget && IsValidUnitTarget( m_nextTarget, pSpell->TargetFilter, pSpell->mindist2cast, pSpell->maxdist2cast ) )
		return m_nextTarget;

	// Find a suitable target for the described situation :)
	switch( pSpell->TargetType )
	{
	case TargetGen_Self:
		{
			if ( !m_Unit->isAlive() )
				return NULLUNIT;
			if ( ( pSpell->TargetFilter & TargetFilter_Wounded ) && m_Unit->GetHealthPct() >= 99 )
				return NULLUNIT;
			if(pSpell->mPredefinedTarget != NULL)
				return pSpell->mPredefinedTarget;
			return m_Unit;
		}break;
	case TargetGen_SecondMostHated:
		{
			Unit* m_Result = GetSecondHated(pSpell);
			if(m_Result == NULLUNIT)
				m_Result = GetMostHated(pSpell);
			return m_Result;
		}break;
	case TargetGen_Current:
	case TargetGen_Destination:
		return m_nextTarget;
	case TargetGen_Predefined:
		return pSpell->mPredefinedTarget;
	case TargetGen_RandomPlayer:
	case TargetGen_RandomPlayerApplyAura:
	case TargetGen_RandomPlayerDestination:
		return GetBestPlayerTarget( pSpell->TargetFilter, pSpell->mindist2cast, pSpell->maxdist2cast );
	case TargetGen_RandomUnit:
	case TargetGen_RandomUnitApplyAura:
	case TargetGen_RandomUnitDestination:
	case TargetGen_ManaClass:
		return GetBestUnitTarget( pSpell->TargetFilter, pSpell->mindist2cast, pSpell->maxdist2cast );
	default:
		sLog.outDebug("MoonScriptCreatureAI::GetTargetForSpell() : Invalid target type!\n");
		return NULLUNIT;
	}
}
Example #5
0
Unit *MoonScriptCreatureAI::GetTargetForSpell( SpellDesc* pSpell )
{
	//Check if run-to-target cache and return it if its valid
	if ( mRunToTargetCache && mRunToTargetSpellCache == pSpell && IsValidUnitTarget( mRunToTargetCache, TargetFilter_None ) )
		return mRunToTargetCache;

	//Find a suitable target for the described situation :)
	switch( pSpell->mTargetType.mTargetGenerator )
	{
	case TargetGen_Self:
		if ( !IsAlive() )
			return NULLUNIT;
		if ( ( pSpell->mTargetType.mTargetFilter & TargetFilter_Wounded ) && _unit->GetHealthPct() >= 99 )
			return NULLUNIT;

		return _unit;
	case TargetGen_SecondMostHated:
		return _unit->GetAIInterface()->GetSecondHated();
	case TargetGen_Current:
	case TargetGen_Destination:
		return _unit->GetAIInterface()->GetNextTarget();
	case TargetGen_Predefined:
		return pSpell->mPredefinedTarget;
	case TargetGen_RandomPlayer:
	case TargetGen_RandomPlayerApplyAura:
	case TargetGen_RandomPlayerDestination:
		return GetBestPlayerTarget( pSpell->mTargetType.mTargetFilter, pSpell->mMinRange, pSpell->mMaxRange );
	case TargetGen_RandomUnit:
	case TargetGen_RandomUnitApplyAura:
	case TargetGen_RandomUnitDestination:
	case TargetGen_ManaClass:
		return GetBestUnitTarget( pSpell->mTargetType.mTargetFilter, pSpell->mMinRange, pSpell->mMaxRange );
	default:
		sLog.outDebug("MoonScriptCreatureAI::GetTargetForSpell() : Invalid target type!\n");
		return NULLUNIT;
	};
};
Example #6
0
Unit* ArcScriptCreatureAI::GetTargetForSpell(SpellDesc* pSpell)
{
	//Check if run-to-target cache and return it if its valid
	if( mRunToTargetCache && mRunToTargetSpellCache == pSpell && IsValidUnitTarget(mRunToTargetCache, TargetFilter_None) )
	{
		return mRunToTargetCache;
	}

	//Find a suitable target for the described situation :)
	switch( pSpell->mTargetType )
	{
		case Target_Self:
			return _unit;

		case Target_SecondMostHated:
			return GetBestPlayerTarget(TargetFilter_SecondMostHated);

		case Target_Current:
		case Target_Destination:
			return _unit->GetAIInterface()->GetNextTarget();

		case Target_Predefined:
			return pSpell->mPredefinedTarget;

		case Target_RandomPlayer:
		case Target_RandomDestination:
		case Target_RandomPlayerApplyAura:
			return GetBestPlayerTarget();

		case Target_RandomPlayerNotCurrent:
			return GetBestPlayerTarget(TargetFilter_NotCurrent);

		case Target_RandomUnit:
			return GetBestUnitTarget();

		case Target_RandomUnitNotCurrent:
			return GetBestUnitTarget(TargetFilter_NotCurrent);

		case Target_RandomFriendly:
			return GetBestUnitTarget(TargetFilter_Friendly);

		case Target_WoundedPlayer:
			return GetBestPlayerTarget(TargetFilter_Wounded);

		case Target_WoundedUnit:
			return GetBestUnitTarget(TargetFilter_Wounded);

		case Target_WoundedFriendly:
			return GetBestUnitTarget(TargetFilter(TargetFilter_Wounded | TargetFilter_Friendly));

		case Target_ClosestPlayer:
			return GetBestPlayerTarget(TargetFilter_Closest);

		case Target_ClosestPlayerNotCurrent:
			return GetBestPlayerTarget(TargetFilter(TargetFilter_Closest | TargetFilter_NotCurrent));

		case Target_ClosestUnit:
			return GetBestUnitTarget(TargetFilter_Closest);

		case Target_ClosestUnitNotCurrent:
			return GetBestUnitTarget(TargetFilter(TargetFilter_Closest | TargetFilter_NotCurrent));

		case Target_ClosestFriendly:
			return GetBestUnitTarget(TargetFilter(TargetFilter_Closest | TargetFilter_Friendly));

		default:
			sLog.outDebug("ArcScriptCreatureAI::GetTargetForSpell() : Invalid target type!\n");
			return NULL;
	}
}