当前位置: 首页>>代码示例>>C++>>正文


C++ Creature::Attack方法代码示例

本文整理汇总了C++中Creature::Attack方法的典型用法代码示例。如果您正苦于以下问题:C++ Creature::Attack方法的具体用法?C++ Creature::Attack怎么用?C++ Creature::Attack使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Creature的用法示例。


在下文中一共展示了Creature::Attack方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: SetData_trial_of_the_king


//.........这里部分代码省略.........
                }
                break;
            case TYPE_HAIYAN_ATTACK:
                {
                    //Move the scrappers
                    for (auto guid : grunts)
                    {
                        Creature* creature = instance->GetCreature(guid);

                        if (creature && creature->GetAI())
                            creature->GetAI()->DoAction(0); //EVENT_ENCOURAGE
                    }
                    Creature* haiyan = instance->GetCreature(haiyan_guid);
                    if (!haiyan)
                        return;
                    haiyan->GetMotionMaster()->MovePoint(0, -4215.772f, -2627.216f, 16.48f);
                    haiyan->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
                    haiyan->SetReactState(REACT_AGGRESSIVE);
                }
                break;
            case TYPE_ALL_ATTACK:
                {
                    for (auto guid : adepts)
                    {
                        Creature* creature = instance->GetCreature(guid);

                        if (creature && creature->GetAI())
                            creature->GetAI()->DoAction(2); //ACTION_ATTACK
                        
                        std::list<uint64>::iterator itr = grunts.begin();
                        std::advance(itr, urand(0, grunts.size() - 1));

                        Creature* grunt = instance->GetCreature(*itr);
                        if (creature && grunt)
                            creature->Attack(grunt, true);
                    }
                    for (auto guid : grunts)
                    {
                        Creature* creature = instance->GetCreature(guid);

                        if (creature && creature->GetAI())
                            creature->GetAI()->DoAction(2); //ACTION_ATTACK

                        std::list<uint64>::iterator itr = scrappers.begin();
                        std::advance(itr, urand(0, scrappers.size() - 1));

                        Creature* scrapper = instance->GetCreature(*itr);
                        if (creature && scrapper)
                            creature->Attack(scrapper, true);
                    }
                    for (auto guid : scrappers)
                    {
                        Creature* creature = instance->GetCreature(guid);

                        if (creature && creature->GetAI())
                            creature->GetAI()->DoAction(2); //ACTION_ATTACK

                        std::list<uint64>::iterator itr = adepts.begin();
                        std::advance(itr, urand(0, adepts.size() - 1));

                        Creature* adept = instance->GetCreature(*itr);
                        if (creature && adept)
                            creature->Attack(adept, true);
                    }

                    SetBossState(DATA_TRIAL_OF_THE_KING, DONE);
                }
                break;
            case TYPE_MING_RETIRED:
                //Retire the adepts
                for (auto guid : adepts)
                {
                    Creature* creature = instance->GetCreature(guid);

                    if (creature && creature->GetAI())
                        creature->GetAI()->DoAction(1); //EVENT_RETIRE
                }
                break;
            case TYPE_KUAI_RETIRED:
                //Retire the adepts
                for (auto guid : scrappers)
                {
                    Creature* creature = instance->GetCreature(guid);

                    if (creature && creature->GetAI())
                        creature->GetAI()->DoAction(1); //EVENT_RETIRE
                }
                break;
            case TYPE_HAIYAN_RETIRED:
                //Retire the adepts
                for (auto guid : grunts)
                {
                    Creature* creature = instance->GetCreature(guid);

                    if (creature && creature->GetAI())
                        creature->GetAI()->DoAction(1); //EVENT_RETIRE
                }
                break;
            }
        }
开发者ID:UnstableZero,项目名称:AnotherMoPCore,代码行数:101,代码来源:instance_mogu_shan_palace.cpp

示例2: UpdateAI

    void UpdateAI(const uint32 diff)
    {
        if (!StartCombat)
            return;

        if (IsBanished)
        {
            // Akama is set in the threatlist so when we reset, we make sure that he is not included in our check
            if (me->getThreatManager().getThreatList().size() < 2)
            {
                EnterEvadeMode();
                return;
            }

            if (DefenderTimer <= diff)
            {
                uint32 ran = rand() % 2;
                Creature* Defender = me->SummonCreature(CREATURE_DEFENDER, SpawnLocations[ran].x, SpawnLocations[ran].y, Z_SPAWN, 0, TEMPSUMMON_TIMED_OR_CORPSE_DESPAWN, 25000);
                if (Defender)
                {
                    Defender->SetWalk(false);
                    bool move = true;
                    if (AkamaGUID)
                    {
                        if (Creature* Akama = Unit::GetCreature(*me, AkamaGUID))
                        {
                            float x, y, z;
                            Akama->GetPosition(x, y, z);
                            // They move towards AKama
                            Defender->GetMotionMaster()->MovePoint(0, x, y, z);
                            Defender->AI()->AttackStart(Akama);
                        }
                        else move = false;
                    }
                    else move = false;
                    if (!move)
                        Defender->GetMotionMaster()->MovePoint(0, AKAMA_X, AKAMA_Y, AKAMA_Z);
                }
                DefenderTimer = 15000;
            }
            else DefenderTimer -= diff;

            if (SummonTimer <= diff)
            {
                SummonCreature();
                SummonTimer = 35000;
            }
            else SummonTimer -= diff;

            if (DeathCount >= 6)
            {
                if (AkamaGUID)
                {
                    Creature* Akama = Unit::GetCreature((*me), AkamaGUID);
                    if (Akama && Akama->IsAlive())
                    {
                        IsBanished = false;
                        me->GetMotionMaster()->Clear(false);
                        me->GetMotionMaster()->MoveChase(Akama);
                        Akama->GetMotionMaster()->Clear();
                        // Shade should move to Akama, not the other way around
                        Akama->GetMotionMaster()->MoveIdle();
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                        // Crazy amount of threat
                        me->AddThreat(Akama, 10000000.0f);
                        Akama->AddThreat(me, 10000000.0f);
                        me->Attack(Akama, true);
                        Akama->Attack(me, true);
                    }
                }
            }
        }
        else                                                // No longer banished, let's fight Akama now
        {
            if (ReduceHealthTimer <= diff)
            {
                if (AkamaGUID)
                {
                    Creature* Akama = Unit::GetCreature((*me), AkamaGUID);
                    if (Akama && Akama->IsAlive())
                    {
                        //10 % less health every few seconds.
                        me->DealDamage(Akama, Akama->GetMaxHealth() / 10, NULL, DIRECT_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, NULL, false);
                        ReduceHealthTimer = 12000;
                    }
                }
            }
            else ReduceHealthTimer -= diff;

            if (HasKilledAkama)
            {
                if (!HasKilledAkamaAndReseting)//do not let players kill Shade if Akama is dead and Shade is waiting for ResetTimer!! event would bug
                {
                    HasKilledAkamaAndReseting = true;
                    me->RemoveAllAuras();
                    me->DeleteThreatList();
                    me->CombatStop();
                    //me->SetHealth(me->GetMaxHealth());
                    me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE);
                    me->GetMotionMaster()->MoveTargetedHome();
//.........这里部分代码省略.........
开发者ID:Adeer,项目名称:OregonCore,代码行数:101,代码来源:boss_shade_of_akama.cpp

示例3: UpdateAI


//.........这里部分代码省略.........
                    {
                        Spawn->setFaction(m_creature->getFaction());
                        Spawn->CastSpell(Spawn, SPELL_CIRCULAR_BLIZZARD, false);
                    }
                    break;
            }

            SuperCastTimer = 35000 + (rand()%5000);
        }else SuperCastTimer -= diff;

        if(!ElementalsSpawned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40)
        {
            ElementalsSpawned = true;

            for (uint32 i = 0; i < 4; i++)
            {
				float xm,ym = 0;
				switch(i)
				{
				case 0:
					xm = -11191.08;
					ym = -1909.36;
					break;
				case 1:
					xm = -11167.75;
					ym = -1938.19;
					break;
				case 2:
					xm = -11138.91;
					ym = -1914.5;
					break;
				case 3:
					xm = -11162.14;
					ym = -1886.025;
					break;
				}
				Creature* pUnit = m_creature->SummonCreature(CREATURE_WATER_ELEMENTAL, xm, ym, m_creature->GetPositionZ(), 0, TEMPSUMMON_TIMED_DESPAWN, 90000);
                if (pUnit)
                {
                    pUnit->Attack(m_creature->getVictim(), true);
                    pUnit->setFaction(m_creature->getFaction());
                }
            }

            DoScriptText(SAY_ELEMENTALS, m_creature);
        }

        if(BerserkTimer < diff)
        {
            for (uint32 i = 0; i < 5; i++)
            {
                Creature* pUnit = DoSpawnCreature(CREATURE_SHADOW_OF_ARAN, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                if (pUnit)
                {
                    pUnit->Attack(m_creature->getVictim(), true);
                    pUnit->setFaction(m_creature->getFaction());
                }
            }

            DoScriptText(SAY_TIMEOVER, m_creature);

            BerserkTimer = 60000;
        }else BerserkTimer -= diff;

        //Flame Wreath check
        if (FlameWreathTimer)
        {
            if (FlameWreathTimer >= diff)
                FlameWreathTimer -= diff;
            else FlameWreathTimer = 0;

            if (FlameWreathCheckTime < diff)
            {
                for (uint32 i = 0; i < 3; i++)
                {
                    if (!FlameWreathTarget[i])
                        continue;

                    Unit* pUnit = Unit::GetUnit(*m_creature, FlameWreathTarget[i]);
                    if (pUnit && pUnit->GetDistance2d(FWTargPosX[i], FWTargPosY[i]) > 3)
                    {
                        pUnit->CastSpell(pUnit, 20476, true, 0, 0, m_creature->GetGUID());
                        pUnit->CastSpell(pUnit, 11027, true);
                        FlameWreathTarget[i] = 0;
                    }
                }
                FlameWreathCheckTime = 500;
            }else FlameWreathCheckTime -= diff;
        }

        if (ArcaneCooldown && FireCooldown && FrostCooldown)
            DoMeleeAttackIfReady();
		if(CastAE)
			if(AETimer < diff)
			{
				m_creature->CastSpell(m_creature, SPELL_AEXPLOSION, false);
				AETimer = 1500;
				CastAE = false;
			}else AETimer -= diff;
    }
开发者ID:,项目名称:,代码行数:101,代码来源:

示例4: DoIntro

    void DoIntro()
    {
        Creature *pMadrigosa = (Creature*)me->GetUnit(pInstance->GetData64(DATA_MADRIGOSA));
        if (!pMadrigosa)
            return;

        switch (IntroPhase)
        {
        case 0:
            DoScriptText(YELL_MADR_ICE_BARRIER, pMadrigosa);
            pMadrigosa->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            for (uint8 i = 0; i < 8; ++i)
                pMadrigosa->SetSpeed(UnitMoveType(i), 2.5);

            pMadrigosa->GetMotionMaster()->MovePoint(1, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z);
            IntroPhaseTimer = 6500;
            ++IntroPhase;
            break;
        case 1:
            pInstance->SetData(DATA_BRUTALLUS_INTRO_EVENT, IN_PROGRESS);
            pMadrigosa->SetLevitate(false);
            pMadrigosa->SetWalk(true);
            pMadrigosa->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
            IntroPhaseTimer = 2500;
            ++IntroPhase;
            break;
        case 2:
            pMadrigosa->SendHeartBeat();
            DoScriptText(YELL_MADR_INTRO, pMadrigosa);
            IntroPhaseTimer = 5000;
            ++IntroPhase;
            break;
        case 3:
            float x, y, z;
            pMadrigosa->GetMap()->CreatureRelocation((Creature*)pMadrigosa, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z, me->GetOrientation());
            me->SetInFront(pMadrigosa);
            pMadrigosa->SetInFront(me);
            DoScriptText(YELL_INTRO, me);
            IntroPhaseTimer = 6000;
            ++IntroPhase;
            break;
        case 4:
            pMadrigosa->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE);
            DoStartMovement(pMadrigosa);
            pMadrigosa->GetMotionMaster()->MoveChase(me);
            me->Attack(pMadrigosa, true);
            pMadrigosa->Attack(me, true);
            IntroPhaseTimer = 7000;
            ++IntroPhase;
            break;
        case 5:
            pMadrigosa->CastSpell(me, SPELL_INTRO_FROST_BREATH, false);
            me->CastSpell(me, SPELL_INTRO_FROST_BREATH, true);
            IntroPhaseTimer = 2500;
            ++IntroPhase;
            break;
        case 6:
            me->GetMotionMaster()->MoveIdle();
            pMadrigosa->SetLevitate(true);
            pMadrigosa->GetPosition(x, y, z);
            pMadrigosa->GetMotionMaster()->MovePoint(2, x, y, z+15);
            pMadrigosa->setHover(true);
            IntroPhaseTimer = 4500;
            ++IntroPhase;
        case 7:
            pMadrigosa->SetInFront(me);
            pMadrigosa->CastSpell(me, SPELL_INTRO_FROST_BLAST, false);
            me->CastSpell(me, SPELL_INTRO_FROST_BLAST, true);
            DoScriptText(YELL_MADR_ICE_BLOCK, pMadrigosa);
            IntroFrostBoltTimer = 500;
            IntroPhaseTimer = 10000;
            ++IntroPhase;
            break;
        case 8:
            DoScriptText(YELL_INTRO_BREAK_ICE, me);
            IntroPhaseTimer = 2000;
            ++IntroPhase;
            break;
        case 9:
            me->GetMotionMaster()->MoveIdle();
            me->AttackStop();
            pMadrigosa->setHover(false);
            pMadrigosa->SetLevitate(false);
            pMadrigosa->SetWalk(true);
            pMadrigosa->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
            pMadrigosa->SendHeartBeat();
            IntroPhaseTimer = 1000;
            ++IntroPhase;
            break;
        case 10:
            pMadrigosa->GetMotionMaster()->MoveIdle();
            IntroPhaseTimer = 2500;
            ++IntroPhase;
            break;
        case 11:
            pMadrigosa->GetMap()->CreatureRelocation((Creature*)pMadrigosa, MADRI_FLY_X, MADRI_FLY_Y, MADRI_FLY_Z, me->GetOrientation());
            pMadrigosa->GetMotionMaster()->MoveIdle();
            IntroPhaseTimer = 2000;
//.........这里部分代码省略.........
开发者ID:mynew4,项目名称:looking4group-core,代码行数:101,代码来源:boss_brutallus.cpp

示例5: UpdateAI

    void UpdateAI(const uint32 diff)
    {
        if(!m_creature->getVictim() && !m_creature->SelectHostilTarget())
            return;

        switch(Phase)
        {
            case 0:
            {
                // *Heroic mode only:
                if(Heroic)
                    if(PyroblastTimer < diff)
                {
                    DoCast(m_creature, SPELL_SHOCK_BARRIER, true);
                    DoCast(m_creature->getVictim(), SPELL_PYROBLAST);
                    PyroblastTimer = 60000;
                }else PyroblastTimer -= diff;

                if(FireballTimer < diff)
                {
                    // *Normal/Heroic mode support
                    if(Heroic) DoCast(m_creature->getVictim(), SPELL_FIREBALL_HEROIC);
                    else       DoCast(m_creature->getVictim(), SPELL_FIREBALL_NORMAL);
                    FireballTimer = 2000 + rand()%4000;
                }else FireballTimer -= diff;

                if(PhoenixTimer < diff)
                {
                    uint32 random = rand()%2 + 1;
                    float x = KaelLocations[random][0];
                    float y = KaelLocations[random][1];
                    Creature* Phoenix = m_creature->SummonCreature(CREATURE_PHOENIX, x, y, LOCATION_Z, 0, TEMPSUMMON_CORPSE_DESPAWN, 60000);
                    if(Phoenix)
                    {
                        Phoenix->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE + UNIT_FLAG_NON_ATTACKABLE);
                        SetThreatList(Phoenix);
						Unit *target = SelectUnit(SELECT_TARGET_RANDOM,1);
						if(target)
						{
							Phoenix->AddThreat(target,1000);
							Phoenix->Attack(target,true);
							Phoenix->GetMotionMaster()->MoveChase(target);
						}
						else
						{
							Phoenix->AddThreat(m_creature->getVictim(),1000);
							Phoenix->Attack(m_creature->getVictim(),true);
							Phoenix->GetMotionMaster()->MoveChase(m_creature->getVictim());
						}
                    }

                    DoYell(SAY_PHOENIX, LANG_UNIVERSAL, NULL);
                    DoPlaySoundToSet(m_creature,SOUND_PHOENIX);

                    PhoenixTimer = 40000;
                }else PhoenixTimer -= diff;

                if(FlameStrikeTimer < diff)
                {
                    Unit* target = SelectUnit(SELECT_TARGET_RANDOM, 0);
                    if(target)
                    {
						m_creature->InterruptNonMeleeSpells(false);
                        DoCast(target, SPELL_FLAMESTRIKE3, true);
                        FlameStrikeTimer = 20000 + rand()%5000;

                        DoYell(SAY_FLAMESTRIKE, LANG_UNIVERSAL, NULL);
                        DoPlaySoundToSet(m_creature, SOUND_FLAMESTRIKE);
                    }
                }else FlameStrikeTimer -= diff;

                // Below 50%
                if(m_creature->GetMaxHealth() * 0.5 > m_creature->GetHealth())
                {
                    m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_INTERRUPT_CAST, true);
                    m_creature->StopMoving();
                    m_creature->GetMotionMaster()->Clear();
                    m_creature->GetMotionMaster()->MoveIdle();
                    GravityLapseTimer = 0;
                    GravityLapsePhase = 0;
                    Phase = 1;
                }
                DoMeleeAttackIfReady();
            }
            break;

            case 1:
            {
				m_creature->StopMoving();
                if(GravityLapseTimer < diff)
                {
                    switch(GravityLapsePhase)
                    {
                        case 0:
                            if(FirstGravityLapse)           // Different yells at 50%, and at every following Gravity Lapse
                            {
                                DoYell(SAY_GRAVITY_LAPSE,LANG_UNIVERSAL,NULL);
                                DoPlaySoundToSet(m_creature,SOUND_GRAVITY_LAPSE);
                                FirstGravityLapse = false;
                                if(pInstance)
//.........这里部分代码省略.........
开发者ID:megamage,项目名称:mangos,代码行数:101,代码来源:boss_felblood_kaelthas.cpp

示例6: UpdateAI

		void UpdateAI(const uint32 diff)
		{

			ReduceCD(diff);

			if(IAmDead()) return;

			if(!m_creature->isInCombat())
			{
				DoNonCombatActions();
			}

			if(pet && pet != NULL && pet->isDead())
			{
				master->SetBotsPetDied();
				pet = NULL;
			}

			//if we think we have a pet, but master doesn't, it means we teleported
			if(pet && master->m_botHasPet == false)
			{
				master->SetBotsPetDied();
				pet = NULL;
			}

			DoNormalAttack(diff);
			ScriptedAI::UpdateAI(diff);

			//if low on health, drink a potion
			if(m_creature->GetHealth() < m_creature->GetMaxHealth()*0.6 && isTimerReady(Potion_cd))
			{
				doCast(m_creature, HEALINGPOTION);
				Potion_cd = 1500;
			}

			//if low on mana, drink a potion
			 if(m_creature->GetPower(POWER_MANA) < m_creature->GetMaxPower(POWER_MANA)*0.2)
			{
				if(isTimerReady(Potion_cd))
				{
					doCast(m_creature, MANAPOTION);
					//MonsterSay("MANA POTION", LANG_UNIVERSAL, NULL);
					Potion_cd = 1500;
				}
			 }

			opponent = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
			if(!opponent && !m_creature->getVictim())
			{
				ResetOrGetNextTarget();

				//to reduce the number of crashes, remove pet whenever we are not in combat
				if(pet != NULL && pet->isAlive())
				{
					master->SetBotsPetDied();
					pet = NULL;
				}
				return;
			}


			if(pet == NULL)
				CreatePet();

			if (pet && pet->isAlive() &&
				!pet->isInCombat() &&
				m_creature->getVictim()) {
				pet->Attack (m_creature->getVictim(), true);
				pet->GetMotionMaster()->MoveChase(m_creature->getVictim(), 1, 0);

			}
		}
开发者ID:Erotix8210,项目名称:prydevserv_backup,代码行数:72,代码来源:bot_hunter_ai.cpp

示例7: if

bool
TargetedMovementGenerator::Update(Creature &owner, const uint32 & time_diff)
{
    if( !&owner || !owner.isAlive() || !&i_target )
        return true;
    if( owner.hasUnitState(UNIT_STAT_ROOT) || owner.hasUnitState(UNIT_STAT_STUNDED) || owner.hasUnitState(UNIT_STAT_FLEEING))
        return true;
    if( !owner.isInCombat() && !owner.hasUnitState(UNIT_STAT_FOLLOW) )
    {
        //owner.AIM_Initialize();   This case must be the one, when a creature aggroed you. By Initalized a new AI, we prevented to Ai::_stopAttack() to be executed properly.
        return true;
    }

    // prevent crash after creature killed pet
    if (!owner.hasUnitState(UNIT_STAT_FOLLOW) && owner.getVictim() != &i_target)
        return true;

    Traveller<Creature> traveller(owner);

    if (i_destinationHolder.UpdateTraveller(traveller, time_diff, false))
    {
        // put targeted movement generators on a higher priority
        if (owner.GetObjectSize())
            i_destinationHolder.ResetUpdate(50);

        float  dist = i_target.GetObjectSize() + owner.GetObjectSize() + OBJECT_CONTACT_DISTANCE;

        // try to counter precision differences
        if( i_destinationHolder.GetDistanceFromDestSq(i_target) > dist * dist + 0.1)
            _setTargetLocation(owner, 0);
        else if ( !owner.HasInArc( 0.1f, &i_target ) )
        {
            owner.SetInFront(&i_target);
            if( i_target.GetTypeId() == TYPEID_PLAYER )
                owner.SendUpdateToPlayer( (Player*)&i_target );
        }
        if( !owner.IsStopped() && i_destinationHolder.HasArrived())
        {
            owner.StopMoving();
            if(owner.canReachWithAttack(&i_target) && !owner.hasUnitState(UNIT_STAT_FOLLOW))
                owner.Attack(&i_target);
        }
    }
    /*

         //SpellEntry* spellInfo;
        if( reach )
        {
            if( owner.GetDistance2dSq( &i_target ) > 0.0f )
            {
                DEBUG_LOG("MOVEMENT : Distance = %f",owner.GetDistance2dSq( &i_target ));
                owner.addUnitState(UNIT_STAT_CHASE);
                _setTargetLocation(owner, 0);
            }
            else if ( !owner.HasInArc( 0.0f, &i_target ) )
            {
                DEBUG_LOG("MOVEMENT : Orientation = %f",owner.GetAngle(&i_target));
                owner.SetInFront(&i_target);
                if( i_target.GetTypeId() == TYPEID_PLAYER )
                    owner.SendUpdateToPlayer( (Player*)&i_target );
            }
            if( !owner.isInCombat() )
            {
                owner.AIM_Initialize();
                return;
            }
        }
        else if( i_target.isAlive() )
        {
            if( !owner.hasUnitState(UNIT_STAT_FOLLOW) && owner.isInCombat() )
            {
                if( spellInfo = owner.reachWithSpellAttack( &i_target ) )
                {
                    _spellAtack(owner, spellInfo);
                    return;
                }
            }
            if( owner.GetDistance2dSq( &i_target ) > 0.0f )
            {
                DEBUG_LOG("MOVEMENT : Distance = %f",owner.GetDistance2dSq( &i_target ));
                owner.addUnitState(UNIT_STAT_CHASE);
                _setTargetLocation(owner, 0);
            }
        }
        else if( !i_targetedHome )
        {
            if( !owner.hasUnitState(UNIT_STAT_FOLLOW) && owner.isInCombat() && (spellInfo = owner.reachWithSpellAttack(&i_target)) )
            {
                _spellAtack(owner, spellInfo);
                return;
            }
            _setTargetLocation(owner, 0);
            if(reach)
            {
                if( reach && owner.canReachWithAttack(&i_target) )
                {
                    owner.StopMoving();
                    if(!owner.hasUnitState(UNIT_STAT_FOLLOW))
                        owner.Attack(&i_target);
                    owner.clearUnitState(UNIT_STAT_CHASE);
//.........这里部分代码省略.........
开发者ID:Artea,项目名称:mangos-svn,代码行数:101,代码来源:TargetedMovementGenerator.cpp

示例8: UpdateAI

    void UpdateAI(const uint32 uiDiff)
    {
        if (!m_creature->SelectHostileTarget() || !m_creature->getVictim())
        {
            // En cas de bug pathfinding
            CheckBug_Timer += uiDiff;
            if (CheckBug_Timer > 5000)
            {
                EnterEvadeMode();
                m_creature->CombatStop();
                m_creature->SetHealth(m_creature->GetMaxHealth());
            }
            return;
        }
        else
            CheckBug_Timer = 0;

        if (m_creature->IsNonMeleeSpellCasted(false))
            return;

        if (ManageTimer(uiDiff, &m_uiTrampleTimer,              urand(9000, 14000)))
            DoCastSpellIfCan(m_creature, SPELL_TRAMPLE);

        if (ManageTimer(uiDiff, &m_uiInfectedBiteTimer,         urand(8000, 12000)))
            DoCastSpellIfCan(m_creature->getVictim(), SPELL_INFECTED_BITE);

        if (ManageTimer(uiDiff, &m_uiEyeOfImmolTharTimer,       urand(15000, 22000)))
        {
            Creature* tmp = m_creature->SummonCreature(14396,
                                               m_creature->GetPositionX(),
                                               m_creature->GetPositionY(),
                                               m_creature->GetPositionZ(),
                                               m_creature->GetOrientation(),
                                               TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
            m_creature->SendSpellGo(tmp, 25681);
            tmp->Attack(m_creature->getVictim(),true);
        }

        if (ManageTimer(uiDiff, &m_uiPortalOfImmolTharTimer,    urand(17000, 24000)))
        {
            if (Unit* pTarget = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0))
            {
                /** Invoque player in front of him */
                float x = m_creature->GetPositionX();
                float y = m_creature->GetPositionY();
                float z = m_creature->GetPositionZ() + 1;
                float orientation = pTarget->GetOrientation();
                m_creature->SendSpellGo(pTarget, 25681);
                pTarget->NearTeleportTo(x, y, z, orientation);
                m_creature->getThreatManager().modifyThreatPercent(pTarget, -100);
            }
        }
        if (m_uiEnrageTimer < uiDiff)
        {
            if (!m_creature->HasAura(SPELL_ENRAGE) && m_bEngage)
                m_creature->CastSpell(m_creature, SPELL_ENRAGE, true);
        }
        else
            m_uiEnrageTimer -= uiDiff;

        DoMeleeAttackIfReady();
    }
开发者ID:Maduse,项目名称:server,代码行数:62,代码来源:boss_immol_thar.cpp

示例9: UpdateAI


//.........这里部分代码省略.........

                case SUPER_FLAME:
                    if (rand()%2)
                        DoScriptText(SAY_FLAMEWREATH1, m_creature);
                    else
                        DoScriptText(SAY_FLAMEWREATH2, m_creature);

                    FlameWreathTimer = 20000;
                    FlameWreathCheckTime = 500;

                    FlameWreathTarget[0] = 0;
                    FlameWreathTarget[1] = 0;
                    FlameWreathTarget[2] = 0;

                    FlameWreathEffect();
                    break;

                case SUPER_BLIZZARD:

                    if (rand()%2)
                        DoScriptText(SAY_BLIZZARD1, m_creature);
                    else
                        DoScriptText(SAY_BLIZZARD2, m_creature);

                    Creature* Spawn = NULL;
                    Spawn = DoSpawnCreature(CREATURE_ARAN_BLIZZARD, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 25000);
                    if (Spawn)
                    {
                        Spawn->setFaction(m_creature->getFaction());
                        Spawn->CastSpell(Spawn, SPELL_CIRCULAR_BLIZZARD, false);
                    }
                    break;
            }

            SuperCastTimer = 35000 + (rand()%5000);
        }else SuperCastTimer -= diff;

        if(!ElementalsSpawned && m_creature->GetHealth()*100 / m_creature->GetMaxHealth() < 40)
        {
            ElementalsSpawned = true;

            for (uint32 i = 0; i < 4; i++)
            {
                Creature* pUnit = DoSpawnCreature(CREATURE_WATER_ELEMENTAL, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN, 90000);
                if (pUnit)
                {
                    pUnit->Attack(m_creature->getVictim(), true);
                    pUnit->setFaction(m_creature->getFaction());
                }
            }

            DoScriptText(SAY_ELEMENTALS, m_creature);
        }

        if(BerserkTimer < diff)
        {
            for (uint32 i = 0; i < 5; i++)
            {
                Creature* pUnit = DoSpawnCreature(CREATURE_SHADOW_OF_ARAN, 0, 0, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 5000);
                if (pUnit)
                {
                    pUnit->Attack(m_creature->getVictim(), true);
                    pUnit->setFaction(m_creature->getFaction());
                }
            }

            DoScriptText(SAY_TIMEOVER, m_creature);

            BerserkTimer = 60000;
        }else BerserkTimer -= diff;

        //Flame Wreath check
        if (FlameWreathTimer)
        {
            if (FlameWreathTimer >= diff)
                FlameWreathTimer -= diff;
            else FlameWreathTimer = 0;

            if (FlameWreathCheckTime < diff)
            {
                for (uint32 i = 0; i < 3; i++)
                {
                    if (!FlameWreathTarget[i])
                        continue;

                    Unit* pUnit = Unit::GetUnit(*m_creature, FlameWreathTarget[i]);
                    if (pUnit && pUnit->GetDistance2d(FWTargPosX[i], FWTargPosY[i]) > 3)
                    {
                        pUnit->CastSpell(pUnit, 20476, true, 0, 0, m_creature->GetGUID());
                        pUnit->CastSpell(pUnit, 11027, true);
                        FlameWreathTarget[i] = 0;
                    }
                }
                FlameWreathCheckTime = 500;
            }else FlameWreathCheckTime -= diff;
        }

        if (ArcaneCooldown && FireCooldown && FrostCooldown)
            DoMeleeAttackIfReady();
    }
开发者ID:Denominator13,项目名称:NeoCore,代码行数:101,代码来源:boss_shade_of_aran.cpp

示例10: UpdateAI

    void UpdateAI(const uint32 diff)
    {

        ReduceCD();

        if(IAmDead()) return;

        if(pet && pet != NULL && pet->isDead())
        {
            master->SetBotsPetDied();
            pet = NULL;
        }

        //if we think we have a pet, but master doesn't, it means we teleported
        if(pet && master->m_botHasPet == false)
        {
            master->SetBotsPetDied();
            pet = NULL;
        }

        m_creature->ApplySpellImmune(0, IMMUNITY_STATE, SPELL_AURA_MOD_TAUNT, true);
        m_creature->ApplySpellImmune(0, IMMUNITY_EFFECT, SPELL_EFFECT_ATTACK_ME, true);

        if(m_creature->GetHealth() < m_creature->GetMaxHealth()*0.3 && isTimerReady(Potion_cd))
        {
            doCast(m_creature, HEALINGPOTION);
            Potion_cd = Potion_cd;
        }
        if(m_creature->GetPower(POWER_MANA) < m_creature->GetMaxPower(POWER_MANA)*0.2)
        {
            if(isTimerReady(Potion_cd))
            {
                doCast(m_creature, MANAPOTION);
                //MonsterSay("MANA POTION", LANG_UNIVERSAL, NULL);
                Potion_cd = Potion_cd;
            } else {
                if(oom_spam == false)
                {
                    //MonsterSay("OOM", LANG_UNIVERSAL, NULL);
                    oom_spam = true;
                }
                ScriptedAI::UpdateAI(diff);
                //return; //can't do anything without mana
           }
        }
        oom_spam = false;

        ScriptedAI::UpdateAI(diff);

        opponent = SelectUnit(SELECT_TARGET_TOPAGGRO, 0);
        if(!opponent && !m_creature->getVictim())
        {
            ResetOrGetNextTarget();

            //to reduce the number of crashes, remove pet whenever we are not in combat
            if(pet != NULL && pet->isAlive())
            {
                master->SetBotsPetDied();
                pet = NULL;
            }

            return;
        }

        if(pet == NULL)
            CreatePet();

        if (pet && pet->isAlive() && 
            !pet->isInCombat() &&
            m_creature->getVictim()) {
            pet->Attack (m_creature->getVictim(), true);
            pet->GetMotionMaster()->MoveChase(m_creature->getVictim(), 1, 0);
        }

        if(m_creature->hasUnitState(UNIT_STAT_CASTING))
            return;
 
        DoNormalAttack(diff);
    }
开发者ID:Rhyuk,项目名称:Dev,代码行数:79,代码来源:bot_warlock_ai.cpp


注:本文中的Creature::Attack方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。