• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ RAND函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中RAND函数的典型用法代码示例。如果您正苦于以下问题:C++ RAND函数的具体用法?C++ RAND怎么用?C++ RAND使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: KilledUnit

 void KilledUnit(Unit* /*victim*/)
 {
     DoScriptText(RAND(SAY_SLAY1,SAY_SLAY2), me);
 }
开发者ID:Dudelzack,项目名称:blizzlikecore,代码行数:4,代码来源:boss_teron_gorefiend.cpp


示例2: UpdateAI

            // *** HANDLED FUNCTION ***
            //Update AI is called Every single map update (roughly once every 50ms if a player is within the grid)
            void UpdateAI(const uint32 uiDiff)
            {
                //Out of combat timers
                if (!me->getVictim())
                {
                    //Random Say timer
                    if (m_uiSayTimer <= uiDiff)
                    {
                        //Random switch between 5 outcomes
                        DoScriptText(RAND(SAY_RANDOM_0, SAY_RANDOM_1, SAY_RANDOM_2, SAY_RANDOM_3, SAY_RANDOM_4), me);

                        m_uiSayTimer = 45000;                      //Say something agian in 45 seconds
                    }
                    else
                        m_uiSayTimer -= uiDiff;

                    //Rebuff timer
                    if (m_uiRebuffTimer <= uiDiff)
                    {
                        DoCast(me, SPELL_BUFF);
                        m_uiRebuffTimer = 900000;                  //Rebuff agian in 15 minutes
                    }
                    else
                        m_uiRebuffTimer -= uiDiff;
                }

                //Return since we have no target
                if (!UpdateVictim())
                    return;

                //Spell 1 timer
                if (m_uiSpell1Timer <= uiDiff)
                {
                    //Cast spell one on our current target.
                    if (rand()%50 > 10)
                        DoCast(me->getVictim(), SPELL_ONE_ALT);
                    else if (me->IsWithinDist(me->getVictim(), 25.0f))
                        DoCast(me->getVictim(), SPELL_ONE);

                    m_uiSpell1Timer = 5000;
                }
                else
                    m_uiSpell1Timer -= uiDiff;

                //Spell 2 timer
                if (m_uiSpell2Timer <= uiDiff)
                {
                    //Cast spell two on our current target.
                    DoCast(me->getVictim(), SPELL_TWO);
                    m_uiSpell2Timer = 37000;
                }
                else
                    m_uiSpell2Timer -= uiDiff;

                //Beserk timer
                if (m_uiPhase > 1)
                {
                    //Spell 3 timer
                    if (m_uiSpell3Timer <= uiDiff)
                    {
                        //Cast spell one on our current target.
                        DoCast(me->getVictim(), SPELL_THREE);

                        m_uiSpell3Timer = 19000;
                    }
                    else
                        m_uiSpell3Timer -= uiDiff;

                    if (m_uiBeserkTimer <= uiDiff)
                    {
                        //Say our line then cast uber death spell
                        DoScriptText(SAY_BERSERK, me, me->getVictim());
                        DoCast(me->getVictim(), SPELL_BERSERK);

                        //Cast our beserk spell agian in 12 seconds if we didn't kill everyone
                        m_uiBeserkTimer = 12000;
                    }
                    else
                        m_uiBeserkTimer -= uiDiff;
                }
                else if (m_uiPhase == 1)                            //Phase timer
                {
                    if (m_uiPhaseTimer <= uiDiff)
                    {
                        //Go to next phase
                        ++m_uiPhase;
                        DoScriptText(SAY_PHASE, me);
                        DoCast(me, SPELL_FRENZY);
                    }
                    else
                        m_uiPhaseTimer -= uiDiff;
                }

                DoMeleeAttackIfReady();
            }
开发者ID:FirstCore,项目名称:GaryMoveOut_4.3.4,代码行数:97,代码来源:example_creature.cpp


示例3: EnterCombat

 void EnterCombat(Unit* /*who*/)
 {
     DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2), me);
     _EnterCombat();
 }
开发者ID:Exodius,项目名称:chuspi,代码行数:5,代码来源:boss_thorim.cpp


示例4: KilledUnit

 void KilledUnit(Unit* victim)
 {
     if (victim->GetTypeId() == TYPEID_PLAYER)
         Talk(RAND(SAY_PLAYER_KILL_01, SAY_PLAYER_KILL_02));
 }
开发者ID:AwkwardDev,项目名称:WoWSource434,代码行数:5,代码来源:boss_hazzarah.cpp


示例5: UpdateAI

        void UpdateAI(uint32 diff) override
        {
            //Check if we have a target
            if (!UpdateVictim())
                return;

            uint32 currentPhase = instance->GetData(DATA_CTHUN_PHASE);
            if (currentPhase == PHASE_EYE_GREEN_BEAM || currentPhase == PHASE_EYE_RED_BEAM)
            {
                // EyeTentacleTimer
                if (EyeTentacleTimer <= diff)
                {
                    //Spawn the 8 Eye Tentacles in the corret spots
                    SpawnEyeTentacle(0, 20);                //south
                    SpawnEyeTentacle(10, 10);               //south west
                    SpawnEyeTentacle(20, 0);                //west
                    SpawnEyeTentacle(10, -10);              //north west

                    SpawnEyeTentacle(0, -20);               //north
                    SpawnEyeTentacle(-10, -10);             //north east
                    SpawnEyeTentacle(-20, 0);               // east
                    SpawnEyeTentacle(-10, 10);              // south east

                    EyeTentacleTimer = 45000;
                } else EyeTentacleTimer -= diff;
            }

            switch (currentPhase)
            {
                case PHASE_EYE_GREEN_BEAM:
                    //BeamTimer
                    if (BeamTimer <= diff)
                    {
                        //SPELL_GREEN_BEAM
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            me->InterruptNonMeleeSpells(false);
                            DoCast(target, SPELL_GREEN_BEAM);

                            //Correctly update our target
                            me->SetTarget(target->GetGUID());
                        }

                        //Beam every 3 seconds
                        BeamTimer = 3000;
                    } else BeamTimer -= diff;

                    //ClawTentacleTimer
                    if (ClawTentacleTimer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            Creature* Spawned = NULL;

                            //Spawn claw tentacle on the random target
                            Spawned = me->SummonCreature(NPC_CLAW_TENTACLE, *target, TEMPSUMMON_CORPSE_DESPAWN, 500);

                            if (Spawned && Spawned->AI())
                                Spawned->AI()->AttackStart(target);
                        }

                        //One claw tentacle every 12.5 seconds
                        ClawTentacleTimer = 12500;
                    } else ClawTentacleTimer -= diff;

                    //PhaseTimer
                    if (PhaseTimer <= diff)
                    {
                        //Switch to Dark Beam
                        instance->SetData(DATA_CTHUN_PHASE, PHASE_EYE_RED_BEAM);

                        me->InterruptNonMeleeSpells(false);
                        me->SetReactState(REACT_PASSIVE);

                        //Remove any target
                        me->SetTarget(ObjectGuid::Empty);

                        //Select random target for dark beam to start on
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0))
                        {
                            //Face our target
                            DarkGlareAngle = me->GetAngle(target);
                            DarkGlareTickTimer = 1000;
                            DarkGlareTick = 0;
                            ClockWise = RAND(true, false);
                        }

                        //Add red coloration to C'thun
                        DoCast(me, SPELL_RED_COLORATION, true);

                        //Freeze animation
                        DoCast(me, SPELL_FREEZE_ANIM);
                        me->SetOrientation(DarkGlareAngle);
                        me->StopMoving();

                        //Darkbeam for 35 seconds
                        PhaseTimer = 35000;
                    } else PhaseTimer -= diff;

                    break;
//.........这里部分代码省略.........
开发者ID:Aravu,项目名称:Talador-Project,代码行数:101,代码来源:boss_cthun.cpp


示例6: KilledUnit

 void KilledUnit(Unit* /*Killed*/)
 {
     DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), me);
 }
开发者ID:AwkwardDev,项目名称:Darkcore-Rebase,代码行数:4,代码来源:boss_high_prophet_barim.cpp


示例7: KilledUnit

 void KilledUnit(Unit* /*victim*/)
 {
     DoScriptText(RAND(YELL_KILL1, YELL_KILL2, YELL_KILL3), me);
 }
开发者ID:A-Shox,项目名称:TrinityCore,代码行数:4,代码来源:boss_brutallus.cpp


示例8: UpdateAI

        void UpdateAI(const uint32 diff)
        {
            if (!me->isInCombat())
                return;

            if (!me->getVictim() && me->getThreatManager().isThreatListEmpty())
            {
                EnterEvadeMode();
                return;
            }

            events.Update(diff);

            if (me->HasUnitState(UNIT_STAT_CASTING))
                return;

            switch(events.ExecuteEvent())
            {
                case EVENT_PURSUE:
                    if (Creature* pKrick = GetKrick())
                        DoScriptText(RAND(SAY_KRICK_CHASE_1, SAY_KRICK_CHASE_2, SAY_KRICK_CHASE_3), pKrick);

                    if (Unit *pTarget = SelectUnit(SELECT_TARGET_RANDOM, 0))
                    {
                        me->Attack(pTarget, false);
                        DoScriptText(SAY_ICK_CHASE_1, me, pTarget);
                        DoCast(pTarget, SPELL_PURSUED);
                    }

                    DoCast(SPELL_CONFUSION);
                    events.ScheduleEvent(EVENT_PURSUE, 30000, GCD_1);
                    return;

                case EVENT_MIGHTY_KICK:
                    DoCast(me->getVictim(), SPELL_MIGHTY_KICK);
                    events.ScheduleEvent(EVENT_MIGHTY_KICK, 25000, GCD_1);
                    return;

                case EVENT_POISON_NOVA:
                    if (Creature* pKrick = GetKrick())
                        DoScriptText(SAY_KRICK_POISON_NOVA, pKrick);

                    DoScriptText(SAY_ICK_POISON_NOVA, me);
                    DoCastAOE(SPELL_POISON_NOVA);
                    events.ScheduleEvent(EVENT_POISON_NOVA, 30000, GCD_1);
                    return;

                case EVENT_TOXIC_WASTE:
                    DoCast(me->getVictim(), SPELL_TOXIC_WASTE);
                    events.ScheduleEvent(EVENT_TOXIC_WASTE, 5000);
                    return;

                case EVENT_SHADOW_BOLT:
                    DoCast(me->getVictim(), SPELL_SHADOW_BOLT);
                    events.ScheduleEvent(EVENT_SHADOW_BOLT, 15000);
                    return;

                case EVENT_EXPLOSIVE_BARRAGE:
                    if (Creature *pKrick = GetKrick())
                    {
                        DoScriptText(SAY_KRICK_BARRAGE_1, pKrick);
                        DoScriptText(SAY_KRICK_BARRAGE_2, pKrick);
                    }

                    DoCastAOE(SPELL_EXPLOSIVE_BARRAGE);
                    me->GetMotionMaster()->MoveIdle();
                    events.DelayEvents(20000, GCD_1); // 2 sec cast + 18 sec
                    events.ScheduleEvent(EVENT_END_EXPLOSIVE_BARRAGE, 20000);
                    return;

                case EVENT_END_EXPLOSIVE_BARRAGE:
                    me->GetMotionMaster()->Clear();
                    me->GetMotionMaster()->MoveChase(me->getVictim());
                    events.ScheduleEvent(EVENT_EXPLOSIVE_BARRAGE, 25000);
                    break;
            }

            DoMeleeAttackIfReady();
        }
开发者ID:techno42,项目名称:SkyFireEMU,代码行数:79,代码来源:boss_krickandick.cpp


示例9: KilledUnit

 void KilledUnit(Unit* who)
 {
     if (who && who->GetEntry() != ENTRY_VAZRUDEN)
         DoScriptText(RAND(SAY_KILL_1, SAY_KILL_2), me);
 }
开发者ID:BoThay,项目名称:ArkCORE,代码行数:5,代码来源:boss_vazruden_the_herald.cpp


示例10: UpdateAI

        void UpdateAI(const uint32 diff)
        {
            switch (Phase)
            {
                case FLYING:
                    if (!UpdateVictim())
                        return;

                    if (me->GetPositionX() >= 519)
                    {
                        me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                        if (!m_bSaidEmote)
                        {
                            DoScriptText(EMOTE_RANGE, me);
                            m_bSaidEmote = true;
                        }
                    }
                    else
                    {
                        me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
                        m_bSaidEmote = false;
                    }

                    if (m_uiMountTimer && m_uiMountTimer <= diff)
                    {
                        me->Mount(DATA_MOUNT);
                        me->SetCanFly(true);
                        m_uiMountTimer = 0;
                    } else m_uiMountTimer -= diff;

                    if (m_uiSummonTimer <= diff)
                    {
                        SpawnMobs();
                        m_uiSummonTimer = 25000;
                    } else m_uiSummonTimer -= diff;

                    if (m_uiMovementTimer <= diff)
                    {
                        switch (m_uiWaypointId)
                        {
                            case 0:
                                me->GetMotionMaster()->MovePoint(0, Location[1].GetPositionX(), Location[1].GetPositionY(), Location[1].GetPositionZ());
                                m_uiMovementTimer = 5000;
                                break;
                            case 1:
                                me->GetMotionMaster()->MovePoint(0, Location[2].GetPositionX(), Location[2].GetPositionY(), Location[2].GetPositionZ());
                                m_uiMovementTimer = 2000;
                                break;
                            case 2:
                                me->GetMotionMaster()->MovePoint(0, Location[3].GetPositionX(), Location[3].GetPositionY(), Location[3].GetPositionZ());
                                m_uiMovementTimer = 15000;
                                break;
                            case 3:
                                me->GetMotionMaster()->MovePoint(0, Location[69].GetPositionX(), Location[69].GetPositionY(), Location[69].GetPositionZ());
                                DoScriptText(RAND(SAY_DRAKE_BREATH_1, SAY_DRAKE_BREATH_2), me);
                                DoScriptText(EMOTE_BREATH, me);
                                m_uiMovementTimer = 2500;
                                break;
                            case 4:
                                me->GetMotionMaster()->MovePoint(0, Location[70].GetPositionX(), Location[70].GetPositionY(), Location[70].GetPositionZ());
                                m_uiMovementTimer = 2000;
                                SpawnTrigger();
                                break;
                            case 5:
                                me->GetMotionMaster()->MovePoint(0, Location[71].GetPositionX(), Location[71].GetPositionY(), Location[71].GetPositionZ());
                                m_uiMovementTimer = 3000;
                                break;
                            case 6:
                                me->GetMotionMaster()->MovePoint(0, Location[3].GetPositionX(), Location[3].GetPositionY(), Location[3].GetPositionZ());
                                m_uiWaypointId = 2;
                                m_uiMovementTimer = 15000;
                                break;
                        }
                        m_uiWaypointId++;
                    } else m_uiMovementTimer -= diff;
                    break;
                case SKADI:
                    //Return since we have no target
                    if (!UpdateVictim())
                        return;

                    if (m_uiCrushTimer <= diff)
                    {
                        DoCastVictim(SPELL_CRUSH);
                        m_uiCrushTimer = 8000;
                    } else m_uiCrushTimer -= diff;

                    if (m_uiPoisonedSpearTimer <= diff)
                    {
                        if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM))
                            DoCast(target, SPELL_POISONED_SPEAR);
                        m_uiPoisonedSpearTimer = 10000;
                    } else m_uiPoisonedSpearTimer -= diff;

                    if (m_uiWhirlwindTimer <= diff)
                    {
                        DoCastAOE(SPELL_WHIRLWIND);
                        m_uiWhirlwindTimer = 20000;
                    } else m_uiWhirlwindTimer -= diff;

//.........这里部分代码省略.........
开发者ID:FirstCore,项目名称:GaryMoveOut_4.3.4,代码行数:101,代码来源:boss_skadi.cpp


示例11: EnterCombat

 void EnterCombat(Unit* who)
 {
     DoScriptText(RAND(SAY_AGGRO_1, SAY_AGGRO_2), me, who);
 }
开发者ID:Bootz,项目名称:SkyFireEMU_430,代码行数:4,代码来源:westfall.cpp


示例12: KilledUnit

	void KilledUnit(Unit *victim)
    {
        DoScriptText(RAND(SAY_SLAY_1,SAY_SLAY_2), me);
    }
开发者ID:PhantomCore,项目名称:PhantomCore,代码行数:4,代码来源:lord_marrowgar.cpp


示例13: UpdateAI

        void UpdateAI(const uint32 diff)
        {
            if (IsIntro)
            {
                if (IntroPhaseTimer <= diff)
                    DoIntro();
                else IntroPhaseTimer -= diff;

                if (IntroPhase == 3 + 1)
                {
                    if (IntroFrostBoltTimer <= diff)
                    {
                        if (Creature* Madrigosa = Unit::GetCreature(*me, instance ? instance->GetData64(DATA_MADRIGOSA) : 0))
                        {
                            Madrigosa->CastSpell(me, SPELL_INTRO_FROSTBOLT, true);
                            IntroFrostBoltTimer = 2000;
                        }
                    } else IntroFrostBoltTimer -= diff;
                }
                if (!UpdateVictim())
                    return;
                DoMeleeAttackIfReady();
            }

            if (!UpdateVictim() || IsIntro)
                return;

            if (SlashTimer <= diff)
            {
                DoCast(me->getVictim(), SPELL_METEOR_SLASH);
                SlashTimer = 11000;
            } else SlashTimer -= diff;

            if (StompTimer <= diff)
            {
                DoScriptText(RAND(YELL_LOVE1, YELL_LOVE2, YELL_LOVE3), me);
                DoCast(me->getVictim(), SPELL_STOMP);
                StompTimer = 30000;
            } else StompTimer -= diff;

            if (BurnTimer <= diff)
            {
                std::list<Unit*> targets;
                SelectTargetList(targets, 10, SELECT_TARGET_RANDOM, 100, true);
                for (std::list<Unit*>::const_iterator i = targets.begin(); i != targets.end(); ++i)
                    if (!(*i)->HasAura(SPELL_BURN))
                    {
                        (*i)->CastSpell((*i), SPELL_BURN, true);
                        break;
                    }
                BurnTimer = urand(60000, 180000);
            } else BurnTimer -= diff;

            if (BerserkTimer < diff && !Enraged)
            {
                DoScriptText(YELL_BERSERK, me);
                DoCast(me, SPELL_BERSERK);
                Enraged = true;
            } else BerserkTimer -= diff;

            DoMeleeAttackIfReady();
        }
开发者ID:A-Shox,项目名称:TrinityCore,代码行数:62,代码来源:boss_brutallus.cpp


示例14: KilledUnit

 void KilledUnit(Unit*)
 {
     DoScriptText(RAND(SAY_TH_RANDOM_KILL1,SAY_TH_RANDOM_KILL2,SAY_TH_RANDOM_KILL3), me);
 }
开发者ID:cocely,项目名称:blizzlikecore,代码行数:4,代码来源:old_hillsbrad.cpp


示例15: EnterCombat

 void EnterCombat(Unit* /*who*/)
 {
     //For an small probability the npc says something when he get aggro
     if (urand(0, 9) > 7)
         DoScriptText(RAND(SAY_OOX_AGGRO1, SAY_OOX_AGGRO2), me);
 }
开发者ID:AwkwardDev,项目名称:PlaygroundCore,代码行数:6,代码来源:feralas.cpp


示例16: EnterCombat

 void EnterCombat(Unit* /*who*/)
 {
     DoScriptText(RAND(SAY_OOX_AGGRO1, SAY_OOX_AGGRO2), me);
 }
开发者ID:AnthoDevMoP,项目名称:Genesis,代码行数:4,代码来源:tanaris.cpp


示例17: UpdateAI

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

        //Shimmer_Timer Timer
        if (Shimmer_Timer <= diff)
        {
            //Remove old vulnerabilty spell
            if (CurrentVurln_Spell)
                me->RemoveAurasDueToSpell(CurrentVurln_Spell);

            //Cast new random vulnerabilty on self
            uint32 spell = RAND(SPELL_FIRE_VULNERABILITY, SPELL_FROST_VULNERABILITY,
                SPELL_SHADOW_VULNERABILITY, SPELL_NATURE_VULNERABILITY, SPELL_ARCANE_VULNERABILITY);

            DoCast(me, spell);
            CurrentVurln_Spell = spell;

            DoScriptText(EMOTE_SHIMMER, me);
            Shimmer_Timer = 45000;
        } else Shimmer_Timer -= diff;

        //Breath1_Timer
        if (Breath1_Timer <= diff)
        {
            DoCast(me->getVictim(), Breath1_Spell);
            Breath1_Timer = 60000;
        } else Breath1_Timer -= diff;

        //Breath2_Timer
        if (Breath2_Timer <= diff)
        {
            DoCast(me->getVictim(), Breath2_Spell);
            Breath2_Timer = 60000;
        } else Breath2_Timer -= diff;

        //Affliction_Timer
        if (Affliction_Timer <= diff)
        {
            std::list<HostileReference*> threatlist = me->getThreatManager().getThreatList();
            for (std::list<HostileReference*>::const_iterator i = threatlist.begin(); i != threatlist.end(); ++i)
            {
                Unit* pUnit;
                if ((*i) && (*i)->getSource())
                {
                    pUnit = Unit::GetUnit((*me), (*i)->getUnitGuid());
                    if (pUnit)
                    {
                        //Cast affliction
                        DoCast(pUnit, RAND(SPELL_BROODAF_BLUE, SPELL_BROODAF_BLACK,
                                           SPELL_BROODAF_RED, SPELL_BROODAF_BRONZE, SPELL_BROODAF_GREEN), true);

                        //Chromatic mutation if target is effected by all afflictions
                        if (pUnit->HasAura(SPELL_BROODAF_BLUE, 0)
                            && pUnit->HasAura(SPELL_BROODAF_BLACK, 0)
                            && pUnit->HasAura(SPELL_BROODAF_RED, 0)
                            && pUnit->HasAura(SPELL_BROODAF_BRONZE, 0)
                            && pUnit->HasAura(SPELL_BROODAF_GREEN, 0))
                        {
                            //pTarget->RemoveAllAuras();
                            //DoCast(pTarget, SPELL_CHROMATIC_MUT_1);

                            //Chromatic mutation is causing issues
                            //Assuming it is caused by a lack of core support for Charm
                            //So instead we instant kill our target

                            //WORKAROUND
                            if (pUnit->GetTypeId() == TYPEID_PLAYER)
                                pUnit->CastSpell(pUnit, 5, false);
                        }
                    }
                }
            }

            Affliction_Timer = 10000;
        } else Affliction_Timer -= diff;

        //Frenzy_Timer
        if (Frenzy_Timer <= diff)
        {
            DoCast(me, SPELL_FRENZY);
            DoScriptText(EMOTE_FRENZY, me);
            Frenzy_Timer = urand(10000,15000);
        } else Frenzy_Timer -= diff;

        //Enrage if not already enraged and below 20%
        if (!Enraged && (me->GetHealth()*100 / me->GetMaxHealth()) < 20)
        {
            DoCast(me, SPELL_ENRAGE);
            Enraged = true;
        }

        DoMeleeAttackIfReady();
    }
开发者ID:FirstCore,项目名称:Battle_2.4.3,代码行数:95,代码来源:boss_chromaggus.cpp


示例18: UpdateAI

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

                    if (Intro_Timer <= diff)
                    {
                        switch (Intro_Phase)
                        {
                        case 1:
                            DoScriptText(SAY_INTRO, me);
                            instance->HandleGameObject(instance->GetData64(DATA_SPHERE_SHIELD), true);
                            ++Intro_Phase;
                            Intro_Timer = 25000;
                            break;
                        case 2:
                            DoScriptText(SAY_AGGRO, me);
                            if (Unit* mellic = Unit::GetUnit(*me, instance->GetData64(DATA_MELLICHAR)))
                            {
                                //should have a better way to do this. possibly spell exist.
                                mellic->setDeathState(JUST_DIED);
                                mellic->SetHealth(0);
                                instance->SetData(TYPE_SHIELD_OPEN, IN_PROGRESS);
                            }
                            ++Intro_Phase;
                            Intro_Timer = 3000;
                            break;
                        case 3:
                            me->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IMMUNE_TO_PC);
                            Intro = true;
                            break;
                        }
                    }
                    else
                        Intro_Timer -=diff;
                }
                if (!UpdateVictim())
                    return;

                if (!IsImage66 && !HealthAbovePct(66))
                {
                    DoSplit(66);
                    IsImage66 = true;
                }
                if (!IsImage33 && !HealthAbovePct(33))
                {
                    DoSplit(33);
                    IsImage33 = true;
                }

                if (MindRend_Timer <= diff)
                {
                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
                        DoCast(target, SPELL_MIND_REND);
                    else
                        DoCast(me->getVictim(), SPELL_MIND_REND);

                    MindRend_Timer = 8000;
                }
                else
                    MindRend_Timer -=diff;

                if (Fear_Timer <= diff)
                {
                    if (me->IsNonMeleeSpellCasted(false))
                        return;

                    DoScriptText(RAND(SAY_FEAR_1, SAY_FEAR_2), me);

                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
                        DoCast(target, SPELL_FEAR);
                    else
                        DoCast(me->getVictim(), SPELL_FEAR);

                    Fear_Timer = 25000;
                }
                else
                    Fear_Timer -=diff;

                if (Domination_Timer <= diff)
                {
                    if (me->IsNonMeleeSpellCasted(false))
                        return;

                    DoScriptText(RAND(SAY_MIND_1, SAY_MIND_2), me);

                    if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 1))
                        DoCast(target, SPELL_DOMINATION);
                    else
                        DoCast(me->getVictim(), SPELL_DOMINATION);

                    Domination_Timer = 16000+rand()%16000;
                }
                else
                    Domination_Timer -=diff;

                if (IsHeroic())
                {
//.........这里部分代码省略.........
开发者ID:Eralan,项目名称:Darkcore,代码行数:101,代码来源:boss_harbinger_skyriss.cpp


示例19: makeTestQuery

void makeTestQuery(QUERY_TYPE qt, char *query)
{
	switch(qt)
	{
	case Q_POINT_SELECTION:
		{
			int a=RAND(TEST_MAX);
			//cout<<"point: "<<a<<endl;
			sprintf(query, "PRO;R;$;R.a00,;$;:SEL;R;$;R.a00,;=,R.a00,$,$,%d,$,$,;:$:$:$:", a);
		}break;
	case Q_RANGE_SELECTION:
		{
			int a=RAND(TEST_MAX);
			int b=RAND(TEST_MAX);
			int minmin=min(a,b);
			int maxmax=minmin+20000000;//max(a,b);
			//result: 155943, 10000000
			//result: 311916, 20000000
			//cout<<"range: ["<<minmin<<", "<<maxmax<<"]"<<endl;
			sprintf(query, "PRO;R;$;R.a00,;$;:SEL;R;$;R.a00,;AND,>,R.a00,$,$,%d,$,$,<,R.a00,$,$,%d,$,$,;:$:$:$:", minmin, maxmax);
		}break;
	case Q_AGG:
		{
			sprintf(query, "AGG;R;MAX;R.a00,;$;:$:$:");
		}break;
	case Q_ORDERBY:
		{
			sprintf(query, "AGG;R;MAX;R.a00,;$;:ORD;R;$;R.a00,;$;:$:$:$:");
			//sprintf(query, "PRO;$;$;R.b00,;$;:ORD;R;$;R.a00,;$;:$:$:$:");
			//sprintf(query, "PRO;R;$;R.b00,;$;:ORD;R;$;R.a00,;$;:SEL;R;$;R.b00,;<,R.b00,$,$,8,$,$,;:$:$:$:$:");
		}break;
	case Q_AGG_GROUPBY:
		{
			sprintf(query, "AGG;R;MAX;R.a00,;$;:GRP;R;$;R.b00,;$;:$:$:$:");
		}break;
	case Q_NINLJ:
		{
			//sprintf(query, "JOIN;R;S;R.a00,S.a00,;<,R.a00,$,$,S.a00,$,$,;:$:$:");
			/*int a1=RAND(TEST_MAX);
			int a2=RAND(TEST_MAX);
			int minmin1=a1;
			int maxmax1=minmin1+20000000;//max(a,b);
			int minmin2=a2;
			int maxmax2=minmin2+20000000;//max(a,b);
			sprintf(query, "PRO;R;$;R.a00,;$;:JOIN;R;S;R.a00,S.a00,;<,R.a00,$,$,S.a00,$,$,;:SEL;R;$;R.a00,;AND,>,R.a00,$,$,%d,$,$,<,R.a00,$,$,%d,$,$,;:$:$:SEL;S;$;S.a00,;AND,>,S.a00,$,$,%d,$,$,<,S.a00,$,$,%d,$,$,;:$:$:$:",minmin1,maxmax1,minmin2,maxmax2);*/
			//cout<<"I have changed the NLJ for testing"<<endl;
			int a1=RAND(TEST_MAX);
			int a2=RAND(TEST_MAX);
			int delta=(int)(20*1000000.0);
			int minmin1=a1;
			int maxmax1=minmin1+delta;//max(a,b);
			int minmin2=a2;
			int maxmax2=minmin2+delta;//max(a,b);
			sprintf(query, "PRO;R;$;R.a00,;$;:JOIN;R;S;R.a00,S.a00,;<,R.a00,$,$,S.a00,$,$,;:SEL;R;$;R.a00,;AND,>,R.a00,$,$,%d,$,$,<,R.a00,$,$,%d,$,$,;:$:$:SEL;S;$;S.a00,;AND,>,S.a00,$,$,%d,$,$,<,S.a00,$,$,%d,$,$,;:$:$:$:",minmin1,maxmax1,minmin2,maxmax2);
		}break;
	case Q_INLJ:
		{

			sprintf(query,"PRO;R;$;R.a00,;$;:JOIN;R;S;R.a00,S.a00,;=,R.a00,$,$,S.a00,$,$,;:$:$:$:");//my own invension. =  -> INLJ
		}break;
	case Q_SMJ:
		{
			sprintf(query,"PRO;R;$;R.a00,;$;:JOIN;R;S;R.a00,S.a00,;+,R.a00,$,$,S.a00,$,$,;:$:$:$:");//my own invension. +  -> SMJ
		}break;
	case Q_HJ:
		{
			sprintf(query,"PRO;R;$;R.a00,;$;:JOIN;R;S;R.a00,S.a00,;-,R.a00,$,$,S.a00,$,$,;:$:$:$:");//my own invension. - -> HJ
		}break;
	case Q_DBMBENCH1:
		{
			int a=RAND(20000);
			int b=(a-2000);
			if(b<0) b=a+2000;
			int minmin=min(a,b);
			int maxmax=max(a,b);
			sprintf(query,"PRO;$;$;T1.a3,;$;:SEL;$;T1;T1.a2,;AND,<,%d,$,$,T1.a2,$,$,<,T1.a2,$,$,%d,$,$,;:$:$:$:",minmin,maxmax);
		}break;
	case Q_DBMBENCH2:
		{
			int a=RAND(20000);
			int b=(a-4000);
			if(b<0) b=a+4000;
			int minmin=min(a,b);
			int maxmax=max(a,b);
			sprintf(query,"AGG;T1;AVG;T1.a3,;$;:JOIN;T1;T2;T1.a1,T2.a1,;=,T1.a1,$,$,T2.a1,$,$,;:SEL;$;T1;T1.a2,;AND,<,%d,$,$,T1.a2,$,$,<,T1.a2,$,$,%d,$,$,;:$:$:$:$:",minmin,maxmax);
			//sprintf(query,"PRO;T1;$;T1.a3,;$;:JOIN;T1;T2;T1.a1,T2.a1,;=,T1.a1,$,$,T2.a1,$,$,;:$:$:$:");
		}break;
	case Q_DBMBENCH3:
		{
			int a=RAND(20000);
			int b=(a-100);
			if(b<0) b=a+100;
			int minmin=min(a,b);
			int maxmax=max(a,b);
			sprintf(query,"AGG;T1;AVG;T1.a3,;$;:SEL;$;T1;T1.a2,;AND,<,%d,$,$,T1.a2,$,$,<,T1.a2,$,$,%d,$,$,;:$:$:$:",minmin,maxmax);
		}break;
	}
	__DEBUG__(query);
}
开发者ID:johnspaul92,项目名称:omnidb-paralleldbonapu,代码行数:99,代码来源:CoProcessorTest.cpp


示例20: UpdateAI

        void UpdateAI(const uint32 uiDiff)
        {
            //Return since we have no target
            if (!UpdateVictim())
                return;

            //exploit fix, remove later
            if (m_uiCheckZ <= uiDiff)
            {
                if (me->GetPositionZ() < 50.0f)
                {
                    EnterEvadeMode();
                    return;
                }
                m_uiCheckZ = 1000;
            }
            else m_uiCheckZ -= uiDiff;

            if (m_bIsStriking && !m_bMove)
            {
                if (m_uiPause_Timer <= uiDiff)
                {
                    if (me->GetMotionMaster()->GetCurrentMovementGeneratorType() != TARGETED_MOTION_TYPE)
                    {
                        if (me->getVictim())
                            me->GetMotionMaster()->MoveChase(me->getVictim());
                    }

                    m_bHasTemper = false;
                    m_bIsStriking = false;
                    m_uiPause_Timer = 1500;
                }
                else
                    m_uiPause_Timer -= uiDiff;

                return;
            }

            // ShatteringStomp all the Time, 
            if (!m_bHasTemper && !m_bMove)
            {
                if (m_uiShatteringStomp_Timer <= uiDiff)
                {
                    DoScriptText(RAND(SAY_STOMP_1,SAY_STOMP_2), me);

                    DoCast(me, DUNGEON_MODE(SPELL_SHATTERING_STOMP_N,SPELL_SHATTERING_STOMP_H));

                    if (Creature* temp = me->FindNearestCreature(NPC_BRITTLE_GOLEM,99))
                    {
                    DoScriptText(EMOTE_SHATTER, me);
                    m_bCanShatterGolem = true;
                }

                    m_uiShatteringStomp_Timer = 30000;
                }
                else
                    m_uiShatteringStomp_Timer -= uiDiff;
            }

            // Shatter Golems 3 seconds after Shattering Stomp
            if (m_bCanShatterGolem)
            {
                if (m_uiShatter_Timer <= uiDiff)
                {
                    ShatterGolem();
                    m_uiShatter_Timer = 3000;
                    m_bCanShatterGolem = false;
                }
                else
                    m_uiShatter_Timer -= uiDiff;
            }

            Creature* pAnvil = m_pInstance->instance->GetCreature(m_pInstance->GetData64(DATA_VOLKHAN_ANVIL));

            float fX, fY, fZ;
            me->GetContactPoint(pAnvil, fX, fY, fZ, INTERACTION_DISTANCE);

            // Health check
            if (!m_bCanShatterGolem && me->HealthBelowPct(100 - 20 * m_uiHealthAmountModifier) && !m_bMove)
            {
                ++m_uiHealthAmountModifier;

                if (me->IsNonMeleeSpellCasted(false))
                    me->InterruptNonMeleeSpells(false);

                DoScriptText(RAND(SAY_FORGE_1, SAY_FORGE_2), me);


                if (me->GetDistance(pAnvil) > 5)
                {
                    me->GetMotionMaster()->Clear();
                    me->SetReactState(REACT_PASSIVE);
                    me->GetMotionMaster()->MovePoint(5,fX,fY,fZ);
            }

                    DoScriptText(EMOTE_TO_ANVIL, me);
                m_bMove=true;
                    }

            if (me->IsWithinMeleeRange(pAnvil,5) && m_bMove)
//.........这里部分代码省略.........
开发者ID:FrenchCORE,项目名称:Server,代码行数:101,代码来源:boss_volkhan.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ RANDOM函数代码示例发布时间:2022-05-30
下一篇:
C++ RAMEN_ASSERT函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap