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

C++ P_Random函数代码示例

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

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



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

示例1: P_SpawnStrobeFlash

//==================================================================
//
//      P_SpawnLightFlash
//
//      After the map has been loaded, scan each sector for specials that spawn thinkers
//
//==================================================================
void P_SpawnStrobeFlash(sector_t * sector, int fastOrSlow, int inSync)
{
    strobe_t *flash;

    flash = Z_Malloc(sizeof(*flash), PU_LEVSPEC, 0);
    P_AddThinker(&flash->thinker);
    flash->sector = sector;
    flash->darktime = fastOrSlow;
    flash->brighttime = STROBEBRIGHT;
    flash->thinker.function = T_StrobeFlash;
    flash->maxlight = sector->lightlevel;
    flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);

    if (flash->minlight == flash->maxlight)
        flash->minlight = 0;
    sector->special = 0;        // nothing special about it during gameplay

    if (!inSync)
        flash->count = (P_Random() & 7) + 1;
    else
        flash->count = 1;
}
开发者ID:Krazygamr,项目名称:D-Touch,代码行数:29,代码来源:p_lights.c


示例2: A_SPosAttack

//
// A_SPosAttack
//
// Sergeant attack.
//
void A_SPosAttack(actionargs_t *actionargs)
{
   Mobj *actor = actionargs->actor;
   int i, bangle, slope;
   
   if (!actor->target)
      return;
   
   S_StartSound(actor, sfx_shotgn);
   A_FaceTarget(actionargs);
   
   bangle = actor->angle;
   slope = P_AimLineAttack(actor, bangle, MISSILERANGE, 0); // killough 8/2/98
   
   for(i = 0; i < 3; ++i)
   {  
      // haleyjd 08/05/04: use new function
      int angle = bangle + (P_SubRandom(pr_sposattack) << 20);
      int damage = ((P_Random(pr_sposattack) % 5) + 1) * 3;
      P_LineAttack(actor, angle, MISSILERANGE, slope, damage);
   }
}
开发者ID:fragglet,项目名称:autodoom,代码行数:27,代码来源:a_doom.cpp


示例3: A_Punch

//
// A_Punch
//
void A_Punch (AActor *mo)
{
	angle_t 	angle;
	int 		damage;
	int 		slope;

    player_t *player = mo->player;

	damage = (P_Random (player->mo)%10+1)<<1;

	if (player->powers[pw_strength])
		damage *= 10;

	angle = player->mo->angle;
	angle += P_RandomDiff(player->mo) << 18;

	// [SL] 2011-07-12 - Move players and sectors back to their positions when
	// this player hit the fire button clientside.
	Unlag::getInstance().reconcile(player->id);

	slope = P_AimLineAttack (player->mo, angle, MELEERANGE);
	P_LineAttack (player->mo, angle, MELEERANGE, slope, damage);

	// [SL] 2011-07-12 - Restore players and sectors to their current position
	// according to the server.
	Unlag::getInstance().restore(player->id);

	// turn to face target
	if (linetarget)
	{
		A_FireSound (player, "player/male/fist");
		//S_Sound (player->mo, CHAN_VOICE, "*fist", 1, ATTN_NORM);
		player->mo->angle = P_PointToAngle (player->mo->x,
											player->mo->y,
											linetarget->x,
											linetarget->y);
	}
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:41,代码来源:p_pspr.cpp


示例4: G_DeathMatchSpawnPlayer

void G_DeathMatchSpawnPlayer (int playernum) 
{ 
	int             i,j; 
	int				selections;
	
	selections = deathmatch_p - deathmatchstarts;
	if (selections < 4)
		I_Error ("Only %i deathmatch spots, 4 required", selections);
		
	for (j=0 ; j<20 ; j++) 
	{ 
		i = P_Random()%selections;
		if (G_CheckSpot (playernum, &deathmatchstarts[i]) ) 
		{ 
			deathmatchstarts[i].type = playernum+1; 
			P_SpawnPlayer (&deathmatchstarts[i]); 
			return; 
		} 
	} 
 
/* no good spot, so the player will probably get stuck  */
	P_SpawnPlayer (&playerstarts[playernum]); 
} 
开发者ID:Arc0re,项目名称:jaguardoom,代码行数:23,代码来源:g_game.c


示例5: A_TroopAttack

//
// A_TroopAttack
//
// Imp attack.
//
void A_TroopAttack(actionargs_t *actionargs)
{
   Mobj *actor = actionargs->actor;

   if(!actor->target)
      return;

   A_FaceTarget(actionargs);
   
   if(P_CheckMeleeRange(actor))
   {
      int damage;
      S_StartSound(actor, sfx_claw);
      damage = (P_Random(pr_troopattack)%8+1)*3;
      P_DamageMobj(actor->target, actor, actor, damage, MOD_HIT);
   }
   else
   {
      // launch a missile
      P_SpawnMissile(actor, actor->target, E_SafeThingType(MT_TROOPSHOT),
                     actor->z + DEFAULTMISSILEZ);
   }
}
开发者ID:twinaphex,项目名称:eternity,代码行数:28,代码来源:a_doom.cpp


示例6: A_BFGSpray

void A_BFGSpray(mobj_t* mo)
{
    int         i;
    int         j;
    int         damage;
    angle_t     an;
    
    // offset angles from its attack angle
    for(i = 0; i < 40; i++)
    {
        an = mo->angle - ANG90/2 + ANG90/40*i;
        
        // mo->target is the originator (player) of the missile
        
        //
        // [kex] add 1 to distance so autoaim can be forced
        //
        P_AimLineAttack(mo->target, an, 0, ATTACKRANGE + 1);
        
        if(!linetarget)
            continue;
        
        //
        // [d64] shift linetarget height by 1 instead of 2
        //
        P_SpawnMobj(linetarget->x, linetarget->y,
            linetarget->z + (linetarget->height >> 1), MT_BFGSPREAD);
        
        damage = 0;
        for(j = 0; j < 15; j++)
            damage += (P_Random() & 7) + 1;
        
        P_DamageMobj(linetarget, mo->target, mo->target, damage);
    }
    
    A_FadeAlpha(mo);
}
开发者ID:alexey-lysiuk,项目名称:doom64ex-osx,代码行数:37,代码来源:p_pspr.c


示例7: EV_FlickerLight

//
// EV_FlickerLight
//
// haleyjd 01/16/07:
// Parameterized flickering light effect. Changes between maxval and minval
// at a randomized time period between 0.2 and 1.8 seconds (7 to 64 tics).
// Uses the normal lightflash thinker.
//
int EV_FlickerLight(line_t *line, int tag, int maxval, int minval)
{
   LightFlashThinker *flash;
   int i, rtn = 0;
   bool backside = false;

   if(line && tag == 0)
   {
      if(!line->backsector)
         return rtn;
      i = line->backsector - sectors;
      backside = true;
      goto dobackside;
   }
   
   for(i = -1; (i = P_FindSectorFromTag(tag, i)) >= 0;)
   {
dobackside:
      rtn = 1;
      flash = new LightFlashThinker;
      flash->addThinker();
      
      flash->sector   = &sectors[i];
      flash->maxlight = maxval;
      flash->minlight = minval;
      flash->maxtime  = 64;
      flash->mintime  = 7;
      flash->count    = (P_Random(pr_lights) & flash->maxtime) + 1;

      flash->sector->lightlevel = flash->maxlight;

      if(backside)
         return rtn;
   }

   return rtn;
}
开发者ID:doomtech,项目名称:eternity,代码行数:45,代码来源:p_lights.cpp


示例8: P_SpawnStrobeFlash

//
// P_SpawnStrobeFlash
//
// Spawns a blinking light thinker
//
// Passed the sector that spawned the thinker, speed of blinking
// and whether blinking is to by syncrhonous with other sectors
//
// Returns nothing
//
void P_SpawnStrobeFlash(sector_t *sector, int fastOrSlow, int inSync)
{
   StrobeThinker *flash;
   
   flash = new StrobeThinker;
   flash->addThinker();
   
   flash->sector = sector;
   flash->darktime = fastOrSlow;
   flash->brighttime = STROBEBRIGHT;
   flash->maxlight = sector->lightlevel;
   flash->minlight = P_FindMinSurroundingLight(sector, sector->lightlevel);
   
   if(flash->minlight == flash->maxlight)
      flash->minlight = 0;
   
   // nothing special about it during gameplay
   sector->special &= ~31; //jff 3/14/98 clear non-generalized sector type
   
   if(!inSync)
      flash->count = (P_Random(pr_lights)&7)+1;
   else
      flash->count = 1;
}
开发者ID:doomtech,项目名称:eternity,代码行数:34,代码来源:p_lights.cpp


示例9: switch


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

        plat->type = type;
        plat->sector = sec;
        plat->sector->floordata = plat; //jff 2/23/98 multiple thinkers
        plat->thinker.function = T_PlatRaise;
        plat->crush = false;
        plat->tag = line->tag;

        //jff 1/26/98 Avoid raise plat bouncing a head off a ceiling and then
        //going down forever -- default low to plat height when triggered
        plat->low = sec->floorheight;

        // set up plat according to type
        switch(type)
        {
        case raiseToNearestAndChange:
            plat->speed = PLATSPEED/2;
            sec->floorpic = sides[line->sidenum[0]].sector->floorpic;
            plat->high = P_FindNextHighestFloor(sec,sec->floorheight);
            plat->wait = 0;
            plat->status = up;
            sec->special = 0;
            //jff 3/14/98 clear old field as well
            sec->oldspecial = 0;

            S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov);
            break;

        case raiseAndChange:
            plat->speed = PLATSPEED/2;
            sec->floorpic = sides[line->sidenum[0]].sector->floorpic;
            plat->high = sec->floorheight + amount*FRACUNIT;
            plat->wait = 0;
            plat->status = up;

            S_StartSound((mobj_t *)&sec->soundorg,sfx_stnmov);
            break;

        case downWaitUpStay:
            plat->speed = PLATSPEED * 4;
            plat->low = P_FindLowestFloorSurrounding(sec);

            if (plat->low > sec->floorheight)
                plat->low = sec->floorheight;

            plat->high = sec->floorheight;
            plat->wait = 35*PLATWAIT;
            plat->status = down;
            S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart);
            break;

        case blazeDWUS:
            plat->speed = PLATSPEED * 8;
            plat->low = P_FindLowestFloorSurrounding(sec);

            if (plat->low > sec->floorheight)
                plat->low = sec->floorheight;

            plat->high = sec->floorheight;
            plat->wait = 35*PLATWAIT;
            plat->status = down;
            S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart);
            break;

        case perpetualRaise:
            plat->speed = PLATSPEED;
            plat->low = P_FindLowestFloorSurrounding(sec);

            if (plat->low > sec->floorheight)
                plat->low = sec->floorheight;

            plat->high = P_FindHighestFloorSurrounding(sec);

            if (plat->high < sec->floorheight)
                plat->high = sec->floorheight;

            plat->wait = 35*PLATWAIT;
            plat->status = P_Random(pr_plats)&1;

            S_StartSound((mobj_t *)&sec->soundorg,sfx_pstart);
            break;

        case toggleUpDn: //jff 3/14/98 add new type to support instant toggle
            plat->speed = PLATSPEED;  //not used
            plat->wait = 35*PLATWAIT; //not used
            plat->crush = true; //jff 3/14/98 crush anything in the way

            // set up toggling between ceiling, floor inclusive
            plat->low = sec->ceilingheight;
            plat->high = sec->floorheight;
            plat->status =  down;
            break;

        default:
            break;
        }
        P_AddActivePlat(plat);  // add plat to list of active plats
    }
    return rtn;
}
开发者ID:TopherLee513,项目名称:prboom4android,代码行数:101,代码来源:p_plats.c


示例10: A_WeaponSetCtr

//
// A_WeaponSetCtr
//
// Sets the value of the indicated counter variable for the thing.
// Can perform numerous operations -- this is more like a virtual
// machine than a codepointer ;)
//
// args[0] : counter # to set
// args[1] : value to utilize
// args[2] : operation to perform
//
void A_WeaponSetCtr(Mobj *mo)
{
   int cnum;
   int value;
   int specialop;
   int *counter;
   player_t *player;
   pspdef_t *pspr;

   if(!(player = mo->player))
      return;

   pspr = &(player->psprites[player->curpsprite]);

   cnum      = E_ArgAsInt(pspr->state->args, 0, 0);
   value     = E_ArgAsInt(pspr->state->args, 1, 0);
   specialop = E_ArgAsKwd(pspr->state->args, 2, &weapsetkwds, 0);

   switch(cnum)
   {
   case 0:
   case 1:
   case 2:
      counter = &(player->weaponctrs[player->readyweapon][cnum]); break;
   default:
      return;
   }

   switch(specialop)
   {
   case CPOP_ASSIGN:
      *counter = value; break;
   case CPOP_ADD:
      *counter += value; break;
   case CPOP_SUB:
      *counter -= value; break;
   case CPOP_MUL:
      *counter *= value; break;
   case CPOP_DIV:
      if(value) // don't divide by zero
         *counter /= value;
      break;
   case CPOP_MOD:
      if(value > 0) // only allow modulus by positive values
         *counter %= value;
      break;
   case CPOP_AND:
      *counter &= value; break;
   case CPOP_ANDNOT:
      *counter &= ~value; break; // compound and-not operation
   case CPOP_OR:
      *counter |= value; break;
   case CPOP_XOR:
      *counter ^= value; break;
   case CPOP_RND:
      *counter = P_Random(pr_weapsetctr); break;
   case CPOP_RNDMOD:
      if(value > 0)
         *counter = P_Random(pr_weapsetctr) % value; break;
   case CPOP_SHIFTLEFT:
      *counter <<= value; break;
   case CPOP_SHIFTRIGHT:
      *counter >>= value; break;
   default:
      break;
   }
}
开发者ID:doomtech,项目名称:eternity,代码行数:78,代码来源:a_counters.cpp


示例11: A_WeaponCtrOp

//
// A_WeaponCtrOp
//
// Sets the value of the indicated counter variable for the weapon
// using two (possibly the same) counters as operands.
//
// args[0] : counter operand #1
// args[1] : counter operand #2
// args[2] : counter destination
// args[3] : operation to perform
//
void A_WeaponCtrOp(Mobj *mo)
{
   player_t *player;
   pspdef_t *pspr;
   int c_oper1_num;
   int c_oper2_num;
   int c_dest_num;
   int specialop;

   int *c_oper1, *c_oper2, *c_dest;

   if(!(player = mo->player))
      return;

   pspr = &(player->psprites[player->curpsprite]);

   c_oper1_num = E_ArgAsInt(pspr->state->args, 0, 0);
   c_oper2_num = E_ArgAsInt(pspr->state->args, 1, 0);
   c_dest_num  = E_ArgAsInt(pspr->state->args, 2, 0);
   specialop   = E_ArgAsKwd(pspr->state->args, 3, &weapctropkwds, 0);

   switch(c_oper1_num)
   {
   case 0:
   case 1:
   case 2:
      c_oper1 = &(player->weaponctrs[player->readyweapon][c_oper1_num]);
      break;
   default:
      return;
   }

   switch(c_oper2_num)
   {
   case 0:
   case 1:
   case 2:
      c_oper2 = &(player->weaponctrs[player->readyweapon][c_oper2_num]);
      break;
   default:
      return;
   }

   switch(c_dest_num)
   {
   case 0:
   case 1:
   case 2:
      c_dest = &(player->weaponctrs[player->readyweapon][c_dest_num]); break;
   default:
      return;
   }

   switch(specialop)
   {
   case CPOP_ADD:
      *c_dest = *c_oper1 + *c_oper2; break;
   case CPOP_SUB:
      *c_dest = *c_oper1 - *c_oper2; break;
   case CPOP_MUL:
      *c_dest = *c_oper1 * *c_oper2; break;
   case CPOP_DIV:
      if(c_oper2) // don't divide by zero
         *c_dest = *c_oper1 / *c_oper2;
      break;
   case CPOP_MOD:
      if(*c_oper2 > 0) // only allow modulus by positive values
         *c_dest = *c_oper1 % *c_oper2;
      break;
   case CPOP_AND:
      *c_dest = *c_oper1 & *c_oper2; break;
   case CPOP_OR:
      *c_dest = *c_oper1 | *c_oper2; break;
   case CPOP_XOR:
      *c_dest = *c_oper1 ^ *c_oper2; break;
   case CPOP_DAMAGE:
      // do a HITDICE-style calculation
      if(*c_oper2 > 0) // the modulus must be positive
         *c_dest = *c_oper1 * ((P_Random(pr_weapsetctr) % *c_oper2) + 1);
      break;
   case CPOP_SHIFTLEFT:
      *c_dest = *c_oper1 << *c_oper2; break;
   case CPOP_SHIFTRIGHT:
      *c_dest = *c_oper1 >> *c_oper2; break;

      // unary operations (c_oper2 is unused for these)
   case CPOP_ABS:
      *c_dest = abs(*c_oper1); break;
   case CPOP_NEGATE:
//.........这里部分代码省略.........
开发者ID:doomtech,项目名称:eternity,代码行数:101,代码来源:a_counters.cpp


示例12: A_CounterOp

//
// A_CounterOp
//
// Sets the value of the indicated counter variable for the thing
// using two (possibly the same) counters as operands.
//
// args[0] : counter operand #1
// args[1] : counter operand #2
// args[2] : counter destination
// args[3] : operation to perform
//
void A_CounterOp(Mobj *mo)
{
   int c_oper1_num, c_oper2_num, c_dest_num, specialop;
   int *c_oper1, *c_oper2, *c_dest;

   c_oper1_num = E_ArgAsInt(mo->state->args, 0, 0);
   c_oper2_num = E_ArgAsInt(mo->state->args, 1, 0);
   c_dest_num  = E_ArgAsInt(mo->state->args, 2, 0);   
   specialop   = E_ArgAsKwd(mo->state->args, 3, &cpopkwds, 0);

   if(c_oper1_num < 0 || c_oper1_num >= NUMMOBJCOUNTERS)
      return; // invalid

   c_oper1 = &(mo->counters[c_oper1_num]);

   if(c_oper2_num < 0 || c_oper2_num >= NUMMOBJCOUNTERS)
      return; // invalid

   c_oper2 = &(mo->counters[c_oper2_num]);

   if(c_dest_num < 0 || c_dest_num >= NUMMOBJCOUNTERS)
      return; // invalid

   c_dest = &(mo->counters[c_dest_num]);

   switch(specialop)
   {
   case CPOP_ADD:
      *c_dest = *c_oper1 + *c_oper2; break;
   case CPOP_SUB:
      *c_dest = *c_oper1 - *c_oper2; break;
   case CPOP_MUL:
      *c_dest = *c_oper1 * *c_oper2; break;
   case CPOP_DIV:
      if(c_oper2) // don't divide by zero
         *c_dest = *c_oper1 / *c_oper2;
      break;
   case CPOP_MOD:
      if(*c_oper2 > 0) // only allow modulus by positive values
         *c_dest = *c_oper1 % *c_oper2;
      break;
   case CPOP_AND:
      *c_dest = *c_oper1 & *c_oper2; break;
   case CPOP_OR:
      *c_dest = *c_oper1 | *c_oper2; break;
   case CPOP_XOR:
      *c_dest = *c_oper1 ^ *c_oper2; break;
   case CPOP_DAMAGE:
      // do a HITDICE-style calculation
      if(*c_oper2 > 0) // the modulus must be positive
         *c_dest = *c_oper1 * ((P_Random(pr_setcounter) % *c_oper2) + 1);
      break;
   case CPOP_SHIFTLEFT:
      *c_dest = *c_oper1 << *c_oper2; break;
   case CPOP_SHIFTRIGHT:
      *c_dest = *c_oper1 >> *c_oper2; break;

      // unary operations (c_oper2 is unused for these)
   case CPOP_ABS:
      *c_dest = abs(*c_oper1); break;
   case CPOP_NEGATE:
      *c_dest = -(*c_oper1); break;
   case CPOP_NOT:
      *c_dest = !(*c_oper1); break;
   case CPOP_INVERT:
      *c_dest = ~(*c_oper1); break;
   default:
      break;
   }
}
开发者ID:doomtech,项目名称:eternity,代码行数:81,代码来源:a_counters.cpp


示例13: EV_DoPlat


//.........这里部分代码省略.........
			if (line)
				sec->floorpic = sides[line->sidenum[0]].sector->floorpic;
			if (change == 1)
				sec->special = 0;	// Stop damage and other stuff, if any
		}

		switch (type)
		{
		case DPlat::platRaiseAndStay:
			plat->m_High = P_FindNextHighestFloor (sec, sec->floorheight);
			plat->m_Status = DPlat::midup;
			plat->PlayPlatSound();
			break;

		case DPlat::platUpByValue:
		case DPlat::platUpByValueStay:
			plat->m_High = sec->floorheight + height;
			plat->m_Status = DPlat::midup;
			plat->PlayPlatSound();
			break;
		
		case DPlat::platDownByValue:
			plat->m_Low = sec->floorheight - height;
			plat->m_Status = DPlat::middown;
			plat->PlayPlatSound();
			break;

		case DPlat::platDownWaitUpStay:
			plat->m_Low = P_FindLowestFloorSurrounding (sec) + lip*FRACUNIT;

			if (plat->m_Low > sec->floorheight)
				plat->m_Low = sec->floorheight;

			plat->m_High = sec->floorheight;
			plat->m_Status = DPlat::down;
			plat->PlayPlatSound();
			break;
		
		case DPlat::platUpWaitDownStay:
			plat->m_High = P_FindHighestFloorSurrounding (sec);

			if (plat->m_High < sec->floorheight)
				plat->m_High = sec->floorheight;

			plat->m_Status = DPlat::up;
			plat->PlayPlatSound();
			break;

		case DPlat::platPerpetualRaise:
			plat->m_Low = P_FindLowestFloorSurrounding (sec) + lip*FRACUNIT;

			if (plat->m_Low > sec->floorheight)
				plat->m_Low = sec->floorheight;

			plat->m_High = P_FindHighestFloorSurrounding (sec);

			if (plat->m_High < sec->floorheight)
				plat->m_High = sec->floorheight;

			plat->m_Status = P_Random () & 1 ? DPlat::down : DPlat::up;

			plat->PlayPlatSound();
			break;

		case DPlat::platToggle:	//jff 3/14/98 add new type to support instant toggle
			plat->m_Crush = false;	//jff 3/14/98 crush anything in the way

			// set up toggling between ceiling, floor inclusive
			plat->m_Low = sec->ceilingheight;
			plat->m_High = sec->floorheight;
			plat->m_Status = DPlat::down;
// 			SN_StartSequence (sec, "Silence");
			break;

		case DPlat::platDownToNearestFloor:
			plat->m_Low = P_FindNextLowestFloor (sec, sec->floorheight) + lip*FRACUNIT;
			plat->m_Status = DPlat::down;
			plat->m_High = sec->floorheight;
			plat->PlayPlatSound();
			break;

		case DPlat::platDownToLowestCeiling:
		    plat->m_Low = P_FindLowestCeilingSurrounding (sec);
			plat->m_High = sec->floorheight;

			if (plat->m_Low > sec->floorheight)
				plat->m_Low = sec->floorheight;

			plat->m_Status = DPlat::down;
			plat->PlayPlatSound();
			break;

		default:
			break;
		}
		if (manual)
			return rtn;
	}
	return rtn;
}
开发者ID:JohnnyonFlame,项目名称:odamex,代码行数:101,代码来源:p_plats.cpp


示例14: P_SubRandom

//
// P_SubRandom
//
// haleyjd 08/05/04: This function eliminates the need to use
// temporary variables everywhere in order to subtract two random
// values without incurring order of evaluation problems.
//
int P_SubRandom(pr_class_t pr_class)
{
   int temp = P_Random(pr_class);

   return (temp - P_Random(pr_class));
}
开发者ID:fragglet,项目名称:autodoom,代码行数:13,代码来源:m_random.cpp


示例15: A_CorpseExplode

void C_DECL A_CorpseExplode(mobj_t* actor)
{
    int i, n;
    mobj_t* mo;

    for(i = (P_Random() & 3) + 3; i; i--)
    {
        if((mo = P_SpawnMobj(MT_CORPSEBIT, actor->origin, P_Random() << 24, 0)))
        {
            P_MobjChangeState(mo, P_GetState(mo->type, SN_SPAWN) + (P_Random() % 3));

            mo->mom[MZ] = FIX2FLT((P_Random() & 7) + 5) * .75f;
            mo->mom[MX] = FIX2FLT((P_Random() - P_Random()) << 10);
            mo->mom[MY] = FIX2FLT((P_Random() - P_Random()) << 10);
        }
    }

    // Spawn a skull.
    if((mo = P_SpawnMobj(MT_CORPSEBIT, actor->origin, P_Random() << 24, 0)))
    {
        P_MobjChangeState(mo, S_CORPSEBIT_4);

        n = (P_Random() & 7) + 5;
        mo->mom[MZ] = FIX2FLT(n) * .75f;
        mo->mom[MX] = FIX2FLT((P_Random() - P_Random()) << 10);
        mo->mom[MY] = FIX2FLT((P_Random() - P_Random()) << 10);
        S_StartSound(SFX_FIRED_DEATH, mo);
    }
    P_MobjRemove(actor, false);
}
开发者ID:skyjake,项目名称:Doomsday-Engine,代码行数:30,代码来源:a_action.c


示例16: doPlat


//.........这里部分代码省略.........
            plat->state = PS_UP;
# if __JHEXEN__
            plat->wait = (int) args[2];
# else
            plat->wait = PLATWAIT * TICSPERSEC;
# endif
# if __JDOOM64__
            plat->speed = PLATSPEED * 8;
            S_PlaneSound((Plane *)P_GetPtrp(sec, DMU_FLOOR_PLANE), SFX_PLATFORMSTART);
# endif
            break;
#endif
#if __JDOOM64__
        case PT_DOWNWAITUPDOOR: // jd64
            plat->speed = PLATSPEED * 8;
            P_FindSectorSurroundingLowestFloor(sec,
                P_GetDoublep(sec, DMU_FLOOR_HEIGHT), &plat->low);

            if(plat->low > floorHeight)
                plat->low = floorHeight;
            if(plat->low != floorHeight)
                plat->low += 6;

            plat->high = floorHeight;
            plat->wait = 50 * PLATWAIT;
            plat->state = PS_DOWN;
            break;
#endif
#if __JHEXEN__
       case PT_DOWNBYVALUEWAITUPSTAY:
            plat->low = floorHeight - (coord_t) args[3] * 8;
            if(plat->low > floorHeight)
                plat->low = floorHeight;
            plat->high = floorHeight;
            plat->wait = (int) args[2];
            plat->state = PS_DOWN;
            break;

        case PT_UPBYVALUEWAITDOWNSTAY:
            plat->high = floorHeight + (coord_t) args[3] * 8;
            if(plat->high < floorHeight)
                plat->high = floorHeight;
            plat->low = floorHeight;
            plat->wait = (int) args[2];
            plat->state = PS_UP;
            break;
#endif
#if __JDOOM__ || __JDOOM64__
        case PT_DOWNWAITUPSTAYBLAZE:
            plat->speed = PLATSPEED * 8;
            P_FindSectorSurroundingLowestFloor(sec,
                P_GetDoublep(sec, DMU_FLOOR_HEIGHT), &plat->low);

            if(plat->low > floorHeight)
                plat->low = floorHeight;

            plat->high = floorHeight;
            plat->wait = PLATWAIT * TICSPERSEC;
            plat->state = PS_DOWN;
            S_PlaneSound((Plane *)P_GetPtrp(sec, DMU_FLOOR_PLANE), SFX_PLATFORMSTART);
            break;
#endif
        case PT_PERPETUALRAISE:
            P_FindSectorSurroundingLowestFloor(sec,
                P_GetDoublep(sec, DMU_FLOOR_HEIGHT), &plat->low);
#if __JHEXEN__
            plat->low += 8;
#else
            plat->speed = PLATSPEED;
#endif
            if(plat->low > floorHeight)
                plat->low = floorHeight;

            P_FindSectorSurroundingHighestFloor(sec, -500, &plat->high);

            if(plat->high < floorHeight)
                plat->high = floorHeight;

            plat->state = platstate_e(P_Random() & 1);
#if __JHEXEN__
            plat->wait = (int) args[2];
#else
            plat->wait = PLATWAIT * TICSPERSEC;
#endif
#if !__JHEXEN__
            S_PlaneSound((Plane *)P_GetPtrp(sec, DMU_FLOOR_PLANE), SFX_PLATFORMSTART);
#endif
            break;

        default:
            break;
        }

#if __JHEXEN__
        SN_StartSequenceInSec(plat->sector, SEQ_PLATFORM);
#endif
    }

    return rtn;
}
开发者ID:gnuzinho,项目名称:Doomsday-Engine,代码行数:101,代码来源:p_plat.cpp


示例17: P_LightningFlash

static void P_LightningFlash(void)
{
    int i;
    sector_t *tempSec;
    bool foundSec;
    int flashLight;
    static PointThinker thunderSndOrigin;

    if(LightningFlash)
    {
        LightningFlash--;

        if(LightningFlash)
        {
            for(i = 0; i < numsectors; i++)
            {
                tempSec = &sectors[i];

                if(tempSec->intflags & SIF_SKY &&
                        tempSec->oldlightlevel < tempSec->lightlevel - 4)
                {
                    tempSec->lightlevel -= 4;
                }
            }
        }
        else
        {
            for(i = 0; i < numsectors; i++)
            {
                tempSec = &sectors[i];

                if(tempSec->intflags & SIF_SKY)
                    tempSec->lightlevel = tempSec->oldlightlevel;
            }

            if(LevelSky != -1 && LevelTempSky != -1)
                skytexture = LevelSky;
        }
    }
    else
    {
        LightningFlash = (P_Random(pr_lightning) & 7) + 8;
        flashLight     = 200 + (P_Random(pr_lightning) & 31);

        foundSec = false;

        for(i = 0; i < numsectors; i++)
        {
            tempSec = &sectors[i];

            if(tempSec->intflags & SIF_SKY)
            {
                tempSec->oldlightlevel = tempSec->lightlevel;
                tempSec->lightlevel    = flashLight;

                if(tempSec->lightlevel < tempSec->oldlightlevel)
                    tempSec->lightlevel = tempSec->oldlightlevel;

                foundSec = true;
            }
        }

        if(foundSec)
        {
            if(LevelSky != -1 && LevelTempSky != -1)
                skytexture = LevelTempSky;

            S_StartSoundAtVolume(&thunderSndOrigin, sfx_thundr,
                                 127, ATTN_NONE, CHAN_AUTO);
        }

        if(!NextLightningFlash)
        {
            if(M_Random() < 50)
                NextLightningFlash = (M_Random() & 15) + 16;
            else
            {
                if(M_Random() < 128 && !(leveltime & 32))
                    NextLightningFlash = ((M_Random() & 7) + 2) * 35;
                else
                    NextLightningFlash = ((M_Random() & 15) + 5) * 35;
            }
        }
    }
}
开发者ID:doomtech,项目名称:eternity,代码行数:85,代码来源:p_anim.cpp


示例18: P_LightningFlash

static void P_LightningFlash(void)
{
	int     i;
	sector_t *tempSec;
	int    *tempLight;
	boolean foundSec;
	int     flashLight;

	if(LightningFlash)
	{
		LightningFlash--;
		if(LightningFlash)
		{
			tempLight = LightningLightLevels;
			tempSec = sectors;
			for(i = 0; i < numsectors; i++, tempSec++)
			{
				if(tempSec->ceilingpic == skyflatnum ||
				   tempSec->special == LIGHTNING_SPECIAL ||
				   tempSec->special == LIGHTNING_SPECIAL2)
				{
					if(*tempLight < tempSec->lightlevel - 4)
					{
						tempSec->lightlevel -= 4;
					}
					tempLight++;
				}
			}
		}
		else
		{						// remove the alternate lightning flash special
			tempLight = LightningLightLevels;
			tempSec = sectors;
			for(i = 0; i < numsectors; i++, tempSec++)
			{
				if(tempSec->ceilingpic == skyflatnum ||
				   tempSec->special == LIGHTNING_SPECIAL ||
				   tempSec->special == LIGHTNING_SPECIAL2)
				{
					tempSec->lightlevel = *tempLight;
					tempLight++;
				}
			}
			Rend_SkyParams(1, DD_DISABLE, 0);
			Rend_SkyParams(0, DD_ENABLE, 0);
			//Sky1Texture = P_GetMapSky1Texture(gamemap);       
		}
		return;
	}
	LightningFlash = (P_Random() & 7) + 8;
	flashLight = 200 + (P_Random() & 31);
	tempSec = sectors;
	tempLight = LightningLightLevels;
	foundSec = false;
	for(i = 0; i < numsectors; i++, tempSec++)
	{
		if(tempSec->ceilingpic == skyflatnum ||
		   tempSec->special == LIGHTNING_SPECIAL ||
		   tempSec->special == LIGHTNING_SPECIAL2)
		{
			*tempLight = tempSec->lightlevel;
			if(tempSec->special == LIGHTNING_SPECIAL)
			{
				tempSec->lightlevel += 64;
				if(tempSec->lightlevel > flashLight)
				{
					tempSec->lightlevel = flashLight;
				}
			}
			else if(tempSec->special == LIGHTNING_SPECIAL2)
			{
				tempSec->lightlevel += 32;
				if(tempSec->lightlevel > flashLight)
				{
					tempSec->lightlevel = flashLight;
				}
			}
			else
			{
				tempSec->lightlevel = flashLight;
			}
			if(tempSec->lightlevel < *tempLight)
			{
				tempSec->lightlevel = *tempLight;
			}
			tempLight++;
			foundSec = true;
		}
	}
	if(foundSec)
	{
		mobj_t *plrmo = players[displayplayer].plr->mo;
		mobj_t *crashorigin = NULL;

		// Set the alternate (lightning) sky.
		Rend_SkyParams(0, DD_DISABLE, 0);
		Rend_SkyParams(1, DD_ENABLE, 0);
		// If 3D sounds are active, position the clap somewhere above
		// the player.
		if(cfg.snd_3D && plrmo)
//.........这里部分代码省略.........
开发者ID:amitahire,项目名称:development,代码行数:101,代码来源:P_anim.c


示例19: sm_random

static cell AMX_NATIVE_CALL sm_random(AMX *amx, cell *params)
{
   return P_Random(pr_script);
}
开发者ID:fragglet,项目名称:autodoom,代码行数:4,代码来源:m_random.cpp


示例20: P_RangeRandom

//
// P_RangeRandom
//
// haleyjd 05/31/06: Returns a random number within a given range.
//
int P_RangeRandom(pr_class_t pr_class, int min, int max)
{
   return (P_Random(pr_class) % (max - min + 1)) + min;
}
开发者ID:fragglet,项目名称:autodoom,代码行数:9,代码来源:m_random.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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