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

C++ rand_norm函数代码示例

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

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



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

示例1: _InitSpecific

void ConfusedMovementGenerator<T>::Initialize(T &unit) {
	const float wander_distance = 11;
	float x, y, z;
	x = unit.GetPositionX();
	y = unit.GetPositionY();
	z = unit.GetPositionZ();

	Map const* map = unit.GetBaseMap();

	i_nextMove = 1;

	bool is_water_ok, is_land_ok;
	_InitSpecific(unit, is_water_ok, is_land_ok);

	for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx) {
		float wanderX = x + wander_distance * (float) rand_norm()
				- wander_distance / 2;
		float wanderY = y + wander_distance * (float) rand_norm()
				- wander_distance / 2;
		Trinity::NormalizeMapCoord(wanderX);
		Trinity::NormalizeMapCoord(wanderY);

		float new_z = map->GetHeight(wanderX, wanderY, z, true);
		if (new_z > INVALID_HEIGHT
				&& unit.IsWithinLOS(wanderX, wanderY, new_z)) {
			// Don't move in water if we're not already in
			// Don't move on land if we're not already on it either
			bool is_water_now = map->IsInWater(x, y, z);
			bool is_water_next = map->IsInWater(wanderX, wanderY, new_z);
			if ((is_water_now && !is_water_next && !is_land_ok)
					|| (!is_water_now && is_water_next && !is_water_ok)) {
				i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx - 1][0] : x; // Back to previous location
				i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx - 1][1] : y;
				i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx - 1][2] : z;
				continue;
			}

			// Taken from FleeingMovementGenerator
			if (!(new_z - z) || wander_distance / fabs(new_z - z) > 1.0f) {
				i_waypoints[idx][0] = wanderX;
				i_waypoints[idx][1] = wanderY;
				i_waypoints[idx][2] = new_z;
				continue;
			}
		} else // Back to previous location
		{
			i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx - 1][0] : x;
			i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx - 1][1] : y;
			i_waypoints[idx][2] = idx > 0 ? i_waypoints[idx - 1][2] : z;
			continue;
		}
	}

	unit.SetUInt64Value(UNIT_FIELD_TARGET, 0);
	unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
	unit.CastStop();
	unit.StopMoving();
	unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALKING);
	unit.AddUnitState(UNIT_STAT_CONFUSED);
}
开发者ID:ProjectStarGate,项目名称:StarGate-Plus-EMU,代码行数:60,代码来源:ConfusedMovementGenerator.cpp


示例2: GetRandomPointInCircle

 void GetRandomPointInCircle(float max_rad, float &x, float &y)
 {
     float ang = 2*M_PI * rand_norm();
     float rad = max_rad * sqrt(rand_norm());
     x = rad * cos(ang);
     y = rad * sin(ang);
 }
开发者ID:Archives,项目名称:pwow_scriptdev2,代码行数:7,代码来源:boss_algalon.cpp


示例3: GetRandomPositionOnCircle

// uniformly distribute on the circle
static Position GetRandomPositionOnCircle(Position const& center, float radius)
{
    double angle = rand_norm() * 2.0 * M_PI;
    double relDistance = rand_norm() + rand_norm();
    if (relDistance > 1)
        relDistance = 1 - relDistance;
    return Position(center.GetPositionX() + std::sin(angle)*relDistance*radius, center.GetPositionY() + std::cos(angle)*relDistance*radius, center.GetPositionZ());
}
开发者ID:090809,项目名称:TrinityCore,代码行数:9,代码来源:boss_kelthuzad.cpp


示例4: SummonConservator

 void SummonConservator()
 {
     float x = (rand_norm() * 30.0f) - 15.0f;
     float y = (rand_norm() * 30.0f) - 15.0f;
     Creature *add = DoSpawnCreature(CR_ANCIENT_CONSERVATOR, x, y, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 2000);
     Unit *target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
     if(add && target)
         add->AddThreat(target, 1.0f);
 }
开发者ID:leecher228,项目名称:scriptdev2,代码行数:9,代码来源:boss_freya.cpp


示例5: _InitSpecific

void
ConfusedMovementGenerator<T>::Initialize(T &unit)
{
    const float wander_distance = 11;
    float x,y,z;
    x = unit.GetPositionX();
    y = unit.GetPositionY();
    z = unit.GetPositionZ();

    Map const* map = unit.GetBaseMap();

    i_nextMove = 1;

    bool is_water_ok, is_land_ok;
    _InitSpecific(unit, is_water_ok, is_land_ok);

    VMAP::IVMapManager *vMaps = VMAP::VMapFactory::createOrGetVMapManager();

    for (uint8 idx = 0; idx <= MAX_CONF_WAYPOINTS; ++idx)
    {
        const bool isInLoS = vMaps->isInLineOfSight(unit.GetMapId(), x, y, z + 2.0f, i_waypoints[idx][0], i_waypoints[idx][1], z + 2.0f);
        if (isInLoS)
        {
            const float wanderX = wander_distance*rand_norm() - wander_distance/2;
            const float wanderY = wander_distance*rand_norm() - wander_distance/2;
            i_waypoints[idx][0] = x + wanderX;
            i_waypoints[idx][1] = y + wanderY;
        }
        else
        {
            i_waypoints[idx][0] = x;
            i_waypoints[idx][1] = y;
        }

        // prevent invalid coordinates generation
        Quad::NormalizeMapCoord(i_waypoints[idx][0]);
        Quad::NormalizeMapCoord(i_waypoints[idx][1]);

        bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1],z);
        // if generated wrong path just ignore
        if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
        {
            i_waypoints[idx][0] = idx > 0 ? i_waypoints[idx-1][0] : x;
            i_waypoints[idx][1] = idx > 0 ? i_waypoints[idx-1][1] : y;
        }

        unit.UpdateGroundPositionZ(i_waypoints[idx][0],i_waypoints[idx][1],z);
        i_waypoints[idx][2] = z;
    }

    unit.SetUInt64Value(UNIT_FIELD_TARGET, 0);
    unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
    unit.CastStop();
    unit.StopMoving();
    unit.RemoveUnitMovementFlag(MOVEMENTFLAG_WALK_MODE);
    unit.addUnitState(UNIT_STAT_CONFUSED);
}
开发者ID:artas,项目名称:quademu,代码行数:57,代码来源:ConfusedMovementGenerator.cpp


示例6: _InitSpecific

void ConfusedMovementGenerator<T>::Initialize(T &unit)
{
    unit.StopMoving();
    float const wander_distance = 2;
    float x = unit.GetPositionX();
    float y = unit.GetPositionY();
    float z = unit.GetPositionZ();

    Map const* map = unit.GetBaseMap();

    i_nextMove = 1;

    bool is_water_ok, is_land_ok;
    _InitSpecific(unit, is_water_ok, is_land_ok);

    for (uint8 idx = 0; idx < MAX_CONF_WAYPOINTS + 1; ++idx)
    {
        float wanderX = x + (wander_distance * (float)rand_norm() - wander_distance/2);
        float wanderY = y + (wander_distance * (float)rand_norm() - wander_distance/2);

        // prevent invalid coordinates generation
        WoWSource::NormalizeMapCoord(wanderX);
        WoWSource::NormalizeMapCoord(wanderY);

        if (unit.IsWithinLOS(wanderX, wanderY, z))
        {
            bool is_water = map->IsInWater(wanderX, wanderY, z);

            if ((is_water && !is_water_ok) || (!is_water && !is_land_ok))
            {
                //! Cannot use coordinates outside our InhabitType. Use the current or previous position.
                wanderX = idx > 0 ? i_waypoints[idx-1][0] : x;
                wanderY = idx > 0 ? i_waypoints[idx-1][1] : y;
            }
        }
        else
        {
            //! Trying to access path outside line of sight. Skip this by using the current or previous position.
            wanderX = idx > 0 ? i_waypoints[idx-1][0] : x;
            wanderY = idx > 0 ? i_waypoints[idx-1][1] : y;
        }

        unit.UpdateAllowedPositionZ(wanderX, wanderY, z);

        //! Positions are fine - apply them to this waypoint
        i_waypoints[idx][0] = wanderX;
        i_waypoints[idx][1] = wanderY;
        i_waypoints[idx][2] = z;
    }

    unit.StopMoving();
    unit.SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_CONFUSED);
    unit.AddUnitState(UNIT_STATE_CONFUSED | UNIT_STATE_CONFUSED_MOVE);
}
开发者ID:Cailiaock,项目名称:5.4.7-Wow-source,代码行数:54,代码来源:ConfusedMovementGenerator.cpp


示例7: urand

bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
{
    if (unit.HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
        return true;

    if (i_nextMoveTime.Passed())
    {
        // currently moving, update location
        unit.AddUnitState(UNIT_STATE_CONFUSED_MOVE);

        if (unit.movespline->Finalized())
            i_nextMoveTime.Reset(urand(800, 1500));
 /*    {
            i_nextMove = urand(1, MAX_CONF_WAYPOINTS);
            i_nextMoveTime.Reset(urand(0, 1500-1));     // TODO: check the minimum reset time, should be probably higher
        }*/
    }
    else
    {
        // waiting for next move
        i_nextMoveTime.Update(diff);
        if (i_nextMoveTime.Passed())
        {
            // start moving
            unit.AddUnitState(UNIT_STATE_CONFUSED_MOVE);

         //   ASSERT( i_nextMove <= MAX_CONF_WAYPOINTS );
         //   float x = i_waypoints[i_nextMove][0];
         //   float y = i_waypoints[i_nextMove][1];
         //   float z = i_waypoints[i_nextMove][2];
            float x = i_x + 10.0f * ((float)rand_norm() - 0.5f);
            float y = i_y + 10.0f * ((float)rand_norm() - 0.5f);
            float z = i_z;

            unit.UpdateAllowedPositionZ(x, y, z);

            PathFinderMovementGenerator path(&unit);
            path.setPathLengthLimit(30.0f);
            path.calculate(x, y, z);
            if (path.getPathType() & PATHFIND_NOPATH)
            {
                i_nextMoveTime.Reset(urand(800, 1000));
               return true;
            }
            Movement::MoveSplineInit init(unit);
            // init.MoveTo(x, y, z);
            init.MovebyPath(path.getPath());
            init.SetWalk(true);
            init.Launch();
        }
    }

    return true;
}
开发者ID:Altair69,项目名称:SkyFireEMU,代码行数:54,代码来源:ConfusedMovementGenerator.cpp


示例8: UpdateAI

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

			events.Update(diff);

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

			DoMeleeAttackIfReady();

			switch( events.GetEvent() )
			{
				case 0:
					break;
				case EVENT_MAGIC_PULL:
					{
						Talk(SAY_PULL);
						//me->MonsterTextEmote(TEXT_MAGIC_PULL, 0, true);

						me->CastSpell(me, SPELL_MAGIC_PULL, false);
						events.RepeatEvent(urand(15000,25000));
						events.ScheduleEvent(EVENT_SUMMON_x4, 1500);
					}
					break;
				case EVENT_THUNDERING_STOMP:
					{
						Talk(SAY_STOMP);

						me->CastSpell(me, SPELL_THUNDERING_STOMP, false);
						events.RepeatEvent(urand(10000,20000));
					}
					break;
				case EVENT_SUMMON:
					{
						for( uint8 i=0; i<2; ++i )
						{
							float angle = rand_norm()*2*M_PI;
							me->SummonCreature(NPC_UNSTABLE_SPHERE, me->GetPositionX() + 5.0f*cos(angle), me->GetPositionY() + 5.0f*sin(angle), me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 18000);
						}
						events.RepeatEvent(2000);
					}
					break;
				case EVENT_SUMMON_x4:
					for( uint8 i=0; i<4; ++i )
					{
						float angle = rand_norm()*2*M_PI;
						me->SummonCreature(NPC_UNSTABLE_SPHERE, me->GetPositionX() + 5.0f*cos(angle), me->GetPositionY() + 5.0f*sin(angle), me->GetPositionZ(), 0.0f, TEMPSUMMON_TIMED_DESPAWN, 18000);
					}
					events.PopEvent();
					break;
			}
		}
开发者ID:GlassFace,项目名称:sunwell,代码行数:54,代码来源:boss_drakos.cpp


示例9: cos

void
RandomMovementGenerator<Creature>::Initialize(Creature &creature)
{
    float x,y,z,z2, wander_distance;
    creature.GetRespawnCoord(x, y, z);
    creature.GetRespawnDist(wander_distance);
    uint32 mapid=creature.GetMapId();

    Map* map = MapManager::Instance().GetMap(mapid, &creature);
    // Initialization is done in bulk. Don’t use vamps for that (4. parameter = false). It is too costly when entering a new map grid
    z2 = map->GetHeight(x,y,z, false);
    if( fabs( z2 - z ) < 5 )
        z = z2;

    i_nextMove = 1;
    i_waypoints[0][0] = x;
    i_waypoints[0][1] = y;
    i_waypoints[0][2] = z;

    bool is_water_ok = creature.isCanSwimOrFly();
    bool is_land_ok  = creature.isCanWalkOrFly();

    for(unsigned int idx=1; idx < MAX_RAND_WAYPOINTS+1; ++idx)
    {
        const float angle = 2*M_PI*rand_norm();
        const float range = wander_distance*rand_norm();

        i_waypoints[idx][0] = x+ range * cos(angle);
        i_waypoints[idx][1] = y+ range * sin(angle);

        // prevent invalid coordinates generation
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][0]);
        MaNGOS::NormalizeMapCoord(i_waypoints[idx][1]);

        bool is_water = map->IsInWater(i_waypoints[idx][0],i_waypoints[idx][1],z);
        // if generated wrong path just ignore
        if( is_water && !is_water_ok || !is_water && !is_land_ok )
        {
            i_waypoints[idx][0] = i_waypoints[idx-1][0];
            i_waypoints[idx][1] = i_waypoints[idx-1][1];
            i_waypoints[idx][2] = i_waypoints[idx-1][2];
            continue;
        }

        // Initialization is done in bulk. Don’t use vamps for that (4. parameter = false). It is too costly when entering a new map grid
        z2 = map->GetHeight(i_waypoints[idx][0],i_waypoints[idx][1],z, false);
        if( fabs( z2 - z ) < 5 )
            z = z2;
        i_waypoints[idx][2] =  z;
    }
    i_nextMoveTime.Reset(urand(0, 10000-1));                // TODO: check the lower bound (it is probably too small)
    creature.StopMoving();
}
开发者ID:Artea,项目名称:mangos-svn,代码行数:53,代码来源:RandomMovementGenerator.cpp


示例10: path

bool ConfusedMovementGenerator<T>::Update(T &unit, const uint32 &diff)
{
    if (unit.HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED | UNIT_STATE_DISTRACTED))
        return true;

    if (i_nextMoveTime.Passed())
    {
        // currently moving, update location
        unit.AddUnitState(UNIT_STATE_CONFUSED_MOVE);

        if (unit.movespline->Finalized())
            i_nextMoveTime.Reset(100); // short reset
    }
    else
    {
        // waiting for next move
        i_nextMoveTime.Update(diff);
        if (i_nextMoveTime.Passed())
        {
            // start moving
            unit.AddUnitState(UNIT_STATE_CONFUSED_MOVE);

            float x = i_x + 4.0f*((float)rand_norm() - 0.5f); 
            float y = i_y + 4.0f*((float)rand_norm() - 0.5f);
			float z = i_z;

			Trinity::NormalizeMapCoord(x);	
            Trinity::NormalizeMapCoord(y);

            unit.UpdateAllowedPositionZ(x, y, z);

            if (z <= INVALID_HEIGHT)	
                i_z = unit.GetBaseMap()->GetHeight(unit.GetPhaseMask(), x, y, MAX_HEIGHT) + 2.0f;

            PathFinderMovementGenerator path(&unit);
            path.setPathLengthLimit(20.0f);
            path.setUseStrightPath(false);

            if (!unit.IsWithinLOS(x, y, z) || !path.calculate(x, y, z) || (path.getPathType() & PATHFIND_NOPATH))
            {
                i_nextMoveTime.Reset(100);
                return true;
            }

            Movement::MoveSplineInit init(unit);
            init.MovebyPath(path.getPath());
            init.SetWalk(true); 
            init.Launch();
        }
    }

    return true;
}
开发者ID:Laintime,项目名称:BattleArenas,代码行数:53,代码来源:ConfusedMovementGenerator.cpp


示例11: SummonLashers

 void SummonLashers()
 {
     int i;
     float x,y;
     for(i=0; i<10; ++i)
     {
         x = (rand_norm() * 30.0f) - 15.0f;
         y = (rand_norm() * 30.0f) - 15.0f;
         Creature *lasher = DoSpawnCreature(CR_DETONATING_LASHER, x, y, 0, 0, TEMPSUMMON_TIMED_DESPAWN_OUT_OF_COMBAT, 2000);
         Unit *target = m_creature->SelectAttackingTarget(ATTACKING_TARGET_RANDOM, 0);
         if(lasher && target)
             lasher->AddThreat(target, 1.0f);
     }
 }
开发者ID:leecher228,项目名称:scriptdev2,代码行数:14,代码来源:boss_freya.cpp


示例12: UpdateAI

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

            events.Update(diff);
            
            if( me->HasUnitState(UNIT_STATE_CASTING) )
                return;

            switch( events.GetEvent() )
            {
                case 0:
                    break;
                case EVENT_SPELL_SHADOWBOLT:
                    me->CastSpell(me->GetVictim(), SPELL_SHADOWBOLT, false);
                    events.RepeatEvent(urand(4000,5000));
                    break;
                case EVENT_FROST_TOMB:
                    if( Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true) )
                        if( !target->HasAura(SPELL_FROST_TOMB_AURA) )
                        {
                            Talk(SAY_FROST_TOMB_EMOTE, target);
                            Talk(SAY_FROST_TOMB);
                            me->CastSpell(target, SPELL_FROST_TOMB, false);
                            events.RepeatEvent(15000);
                            break;
                        }
                    events.RepeatEvent(1000);
                    break;
                case EVENT_SUMMON_SKELETONS:
                    Talk(SAY_SUMMON_SKELETONS);
                    for (uint8 i = 0; i < 5; ++i)
                    {
                        float dist = rand_norm()*4+3.0f;
                        float angle = rand_norm()*2*M_PI;
                        if( Creature* c = me->SummonCreature(NPC_SKELETON, 156.2f+cos(angle)*dist, 259.1f+sin(angle)*dist, 42.9f, 0, TEMPSUMMON_CORPSE_TIMED_DESPAWN, 20000) )
                            if( Unit* target = c->SelectNearestTarget(250.0f) )
                            {
                                c->AddThreat(target, 5.0f);
                                DoZoneInCombat(c);
                            }
                    }
                    events.PopEvent();
                    break;
            }

            DoMeleeAttackIfReady();
        }
开发者ID:boom8866,项目名称:azerothcore-wotlk,代码行数:49,代码来源:boss_keleseth.cpp


示例13: molten_flameAI

 molten_flameAI(Creature *c) : NullCreatureAI(c)
 {
     float x, y, z;
     me->CastSpell(me,SPELL_MOLTEN_FLAME,true);
     me->GetNearPoint(me, x, y, z, 1.0f, 50.0f, float(M_PI*2*rand_norm()));
     me->GetMotionMaster()->MovePoint(0, x, y, z);
 }
开发者ID:B3NNY,项目名称:TrinityCore,代码行数:7,代码来源:boss_supremus.cpp


示例14: ReceiveEmote

        void ReceiveEmote(Player* player, uint32 emote)
        {
            if (emote == TEXTEMOTE_KISS)
            {
                alreadykissed = true;

                if(urand(0,3) == 0)
                {
                    DoCast(me,SPELL_TRANSFORM,true);
                    me->MonsterSay(SAY_FREED,LANG_UNIVERSAL,player->GetGUID());
                    me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_GOSSIP);
                }else
                {
                    if (!player->HasAura(SPELL_WARTS_B_GONE))
                    {
                    //FIXME    me->CastSpell(player,SPELL_WARTS);
                    }else
                        player->RemoveAurasDueToSpell(SPELL_WARTS_B_GONE);

                        me->CastSpell(me,SPELL_FROG_LOVE,true);
                        me->GetMotionMaster()->MoveFollow(player,1,float(rand_norm()*2*M_PI));
                }

                me->DespawnOrUnsummon(15000);
            }
        }
开发者ID:dsstest,项目名称:ArkCORE,代码行数:26,代码来源:grizzly_hills.cpp


示例15: UpdateAI

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

           if (uiChargeTimer <= uiDiff)
           {
               chargeing = true;
               float x,y,z;
               me->GetNearPoint(me, x, y, z, 1.0f, 15.0f, float(2 * M_PI * rand_norm()));
               me->GetMotionMaster()->MovePoint(1,x,y,z);

               uiChargeTimer = 15*IN_MILLISECONDS;
           } else uiChargeTimer -= uiDiff;

           if (uiShieldBreakerTimer <= uiDiff)
           {
               DoCastVictim(SPELL_SHIELD_BREAKER);
               uiShieldBreakerTimer = 10*IN_MILLISECONDS;
           } else uiShieldBreakerTimer -= uiDiff;

           if (me->isAttackReady())
           {
               DoCast(me->getVictim(), SPELL_PLAYER_THRUST, true);
               me->resetAttackTimer();
           }

           if (Player* player = Player::GetPlayer(*me,guidAttacker))
                if (!player->HasAura(SPELL_AURA_TOURNAMENT_MOUNT))
                    EnterEvadeMode();
       }
开发者ID:Xavy34,项目名称:GaryMoveOut,代码行数:31,代码来源:icecrown.cpp


示例16: urand

void RandomMovementGenerator<Creature>::DoInitialize(Creature* creature)
{
    if (!creature->IsAlive())
        return;

    if (!_wanderDistance)
        _wanderDistance = creature->GetRespawnRadius();

    _nextMoveTime.Reset(creature->GetDBTableGUIDLow() && creature->GetRespawnRadius() == _wanderDistance ? urand(1, 5000) : 0);
    _wanderDistance = std::max((creature->GetRespawnRadius() == _wanderDistance && creature->GetInstanceId() == 0) ? (creature->CanFly() ? MIN_WANDER_DISTANCE_AIR : MIN_WANDER_DISTANCE_GROUND) : 0.0f, _wanderDistance);

    if (G3D::fuzzyEq(_initialPosition.GetExactDist2d(0.0f, 0.0f), 0.0f))
    {
        _initialPosition.Relocate(creature);
        _destinationPoints.clear();
        for (uint8 i = 0; i < RANDOM_POINTS_NUMBER; ++i)
        {
            float angle = (M_PI*2.0f/(float)RANDOM_POINTS_NUMBER)*i;
            float factor = 0.5f + rand_norm()*0.5f;
            _destinationPoints.push_back(G3D::Vector3(_initialPosition.GetPositionX() + _wanderDistance*cos(angle)*factor, _initialPosition.GetPositionY() + _wanderDistance*sin(angle)*factor, _initialPosition.GetPositionZ()));
        }
    }

    if (!_pathGenerator)
        _pathGenerator = new PathGenerator(creature);
    creature->AddUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
}
开发者ID:lineagedr,项目名称:azerothcore-wotlk,代码行数:27,代码来源:RandomMovementGenerator.cpp


示例17: InitializeAI

            void InitializeAI()
            {
                if (me->isDead() || !me->GetOwner())
                    return;

                Reset();

                switch (urand(0, 3))
                {
                    case 0:
                        _mountModel = 6471;
                        break;
                    case 1:
                        _mountModel = 6473;
                        break;
                    case 2:
                        _mountModel = 6469;
                        break;
                    default:
                        _mountModel = 6472;
                        break;
                }
                me->SetDisplayId(trollmodel[urand(0, 39)]);
                if (Player* player = me->GetOwner()->ToPlayer())
                    me->GetMotionMaster()->MoveFollow(player, 5.0f, float(rand_norm() + 1.0f) * M_PI / 3.0f * 4.0f);
            }
开发者ID:Angmon,项目名称:TrinityCore,代码行数:26,代码来源:zone_durotar.cpp


示例18: SetRandomEnchantVisual

void SetRandomEnchantVisual(Player* player, Item* item)
{
    if (!player || !item)
        return;
    const ItemTemplate* temp = item->GetTemplate();
    if (temp->Class != ITEM_CLASS_WEAPON)
        return;
    if (temp->SubClass == ITEM_SUBCLASS_WEAPON_BOW ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_GUN ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_obsolete ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_FIST ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_THROWN ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_SPEAR ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_CROSSBOW ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_WAND ||
        temp->SubClass == ITEM_SUBCLASS_WEAPON_FISHING_POLE)
        return;
    if (rand_norm() >= CHANCE)
        return;

    uint32 enchant = ItemEnchants[urand(0, ItemEnchants_size)];
    uint32 iguid = item->GetGUIDLow();
    CharacterDatabase.PExecute("REPLACE INTO custom_item_enchant_visuals (iguid, display) VALUES (%u, %u)", iguid, enchant);
    ItemStore[player->GetGUIDLow()][iguid] = enchant;
    player->SaveToDB();
    player->SetVisibleItemSlot(EQUIPMENT_SLOT_MAINHAND, player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_MAINHAND));
    player->SetVisibleItemSlot(EQUIPMENT_SLOT_OFFHAND, player->GetItemByPos(INVENTORY_SLOT_BAG_0, EQUIPMENT_SLOT_OFFHAND));
}
开发者ID:EdwardTuring,项目名称:TrinityCore,代码行数:28,代码来源:enchant_visuals.cpp


示例19: GetRandomPositionAround

 Position GetRandomPositionAround(Creature* anubarak)
 {
     static float DISTANCE_MIN = 10.0f;
     static float DISTANCE_MAX = 30.0f;
     double angle = rand_norm() * 2.0 * M_PI;
     return { anubarak->GetPositionX() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::sin(angle)), anubarak->GetPositionY() + (float)(frand(DISTANCE_MIN, DISTANCE_MAX)*std::cos(angle)), anubarak->GetPositionZ() };
 }
开发者ID:Declipe,项目名称:ElunaTrinityWotlk,代码行数:7,代码来源:boss_anubarak.cpp


示例20: UpdateAI

        void UpdateAI(uint32 diff)
        {
            if (working)
            {
                if (timer <= diff)
                {
                    timer = 3000;

                    if (fixingGUID)
                    {
                        if (Creature* c = ObjectAccessor::GetCreature(*me, fixingGUID))
                            if (me->GetExactDist2dSq(c) <= 25.0f)
                            {
                                if( me->GetUInt32Value(UNIT_NPC_EMOTESTATE) != EMOTE_STATE_WORK )
                                    me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_WORK);

                                if (fabs(me->GetOrientation()-me->GetAngle(c)) > M_PI/4)
                                    me->SetFacingToObject(c);

                                c->AI()->SetData(2, 0);
                                if (c->AI()->GetData(2))
                                    fixingGUID = 0;
                            }
                    }

                    if (!fixingGUID)
                    {
                        Creature* razorscale = NULL;
                        if( uint64 rsGUID = pInstance->GetData64(TYPE_RAZORSCALE) )
                            razorscale = ObjectAccessor::GetCreature(*me, rsGUID);

                        if( !razorscale || !razorscale->IsInCombat() )
                        {
                            Reset();
                            me->GetMotionMaster()->MoveTargetedHome();
                            return;
                        }

                        for( int i=0; i<4; ++i )
                            if( uint64 fs_GUID = pInstance->GetData64(DATA_HARPOON_FIRE_STATE_1 + i) )
                                if( Creature* fs = ObjectAccessor::GetCreature(*me, fs_GUID) )
                                    if (!fs->AI()->GetData(2))
                                        {
                                            float a = rand_norm()*M_PI;
                                            me->GetMotionMaster()->MovePoint(0, fs->GetPositionX()+3.0f*cos(a), fs->GetPositionY()+3.0f*sin(a), fs->GetPositionZ());
                                            fixingGUID = fs->GetGUID();
                                            return;
                                        }

                        Reset(); // all harpoons repaired
                        me->GetMotionMaster()->MoveTargetedHome();
                    }
                }
                else
                    timer -= diff;
            }
            else if (me->GetUInt32Value(UNIT_NPC_EMOTESTATE) == EMOTE_STATE_WORK)
                me->SetUInt32Value(UNIT_NPC_EMOTESTATE, EMOTE_STATE_STAND);
        }
开发者ID:boom8866,项目名称:azerothcore-wotlk,代码行数:59,代码来源:boss_razorscale.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ rand_r函数代码示例发布时间:2022-05-30
下一篇:
C++ rand_int函数代码示例发布时间: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