Exemplo n.º 1
0
	void OnCombatStart(Unit* pTarget)
	{
		SetDisplayWeapon(true, true);
		ParentClass::OnCombatStart(pTarget);

		mAliveAdds = 0;
		mLastYell = -1;
		for (int i = 0; i < 4; ++i)
		{
			Unit* pAdd = ForceCreatureFind(Adds[i]);
			if (pAdd != NULL && pAdd->isAlive())
			{
				Unit* pTarget = GetBestPlayerTarget();
				if (pTarget != NULL)
				{
					pAdd->GetAIInterface()->AttackReaction(pTarget, 200);
				}

				++mAliveAdds;
			}
		}
		if (mAliveAdds > 1)
		{
			SetCanEnterCombat(false);
			SetBehavior(Behavior_Spell);
			SetCanMove(false);
		}
	}
Exemplo n.º 2
0
void MoonScriptCreatureAI::AggroRandomPlayer(int pInitialThreat)
{
	Unit* RandomPlayer = GetBestPlayerTarget();
	if( RandomPlayer )
	{
		_unit->GetAIInterface()->AttackReaction(RandomPlayer, pInitialThreat);
		OnCombatStart(RandomPlayer);	//Patch, for some reason, OnCombatStart isn't called in this case
	}
}
Exemplo n.º 3
0
void AscentScriptCreatureAI::AggroNearestPlayer(int pInitialThreat)
{
	Unit* NearestRandomPlayer = GetBestPlayerTarget(TargetFilter_Closest);
	if( NearestRandomPlayer )
	{
		_unit->GetAIInterface()->AttackReaction(NearestRandomPlayer, pInitialThreat);
		OnCombatStart(NearestRandomPlayer);	//Patch, for some reason, OnCombatStart isn't called in this case
	}
}
Exemplo n.º 4
0
	FellFireFiendAI(Creature* pCreature) : MoonScriptCreatureAI(pCreature)
	{
		_unit->GetAIInterface()->SetAllowedToEnterCombat( false );
		Player* randPlr = static_cast<Player*>(GetBestPlayerTarget());
		Coords _coord;
		_coord.mX = randPlr->GetPositionX();
		_coord.mY = randPlr->GetPositionY();
		_coord.mZ = randPlr->GetPositionZ();
		_coord.mO = randPlr->GetOrientation();
		AddWaypoint( CreateWaypoint( 1, 0, Flag_Run, _coord ) );

		mForceDied = false;
	};
Exemplo n.º 5
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;
	}
}
Exemplo n.º 6
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.º 7
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;
	};
};
Exemplo n.º 8
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;
	}
}
Exemplo n.º 9
0
	void OnLoad()
	{
		BoomTarget = GetBestPlayerTarget(TargetFilter_NotCurrent);
		MoveTo(BoomTarget);
	}