void ST_Ticker (void) { st_clock++; st_randomnumber = M_Random(); st_highscore = SC_GetHighScore()->score; ST_updateWidgets(); st_oldhealth = plyr->health; }
void ST_Ticker(void) { st_clock++; st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = plyr->health; }
FMugShotState::FMugShotState(FName name) { State = name; bUsesLevels = false; bHealth2 = false; bHealthSpecial = false; bDirectional = false; bFinished = true; Random = M_Random(); }
// [XA] Added "drift speed" multiplier setting for enhanced railgun stuffs. FParticle *JitterParticle (FLevelLocals *Level, int ttl, double drift) { FParticle *particle = NewParticle (Level); if (particle) { int i; // Set initial velocities for (i = 3; i; i--) particle->Vel[i] = ((1./4096) * (M_Random () - 128) * drift); // Set initial accelerations for (i = 3; i; i--) particle->Acc[i] = ((1./16384) * (M_Random () - 128) * drift); particle->alpha = 1.f; // fully opaque particle->ttl = ttl; particle->renderstyle = STYLE_Translucent; particle->fadestep = FADEFROMTTL(ttl); } return particle; }
static void InitAnimatedBack(int episode) { if (episode < 1 || episode > 3) return; for (int i=0; i<NUMANIMS[episode-1]; i++) { anim_t *a = &anims[episode-1][i]; // init variables a->ctr = -1; // specify the next time to draw it if (a->type == ANIM_ALWAYS) a->nexttic = 1 + (M_Random() % a->period); else if (a->type == ANIM_RANDOM) a->nexttic = 1 + a->data2 + (M_Random() % a->data1); else if (a->type == ANIM_LEVEL) a->nexttic = 1; } }
void Wipe_Initwipe() { int x; inwipe = true; starting_height = current_height<<hires; // use console height worms[0] = starting_height - M_Random()%16; for(x=1; x<SCREENWIDTH; x++) { int r = (M_Random()%3) - 1; worms[x] = worms[x-1] + r; if (worms[x] > 0) worms[x] = 0; else if (worms[x] == -16) worms[x] = -15; } }
BOOL P_ActivateMobj (AActor *mobj, AActor *activator) { if (mobj->flags & MF_COUNTKILL) { mobj->flags2 &= !(MF2_DORMANT | MF2_INVULNERABLE); return true; } else { switch (mobj->type) { case MT_SPARK: { int count = mobj->args[0]; char sound[16]; if (count == 0) count = 32; P_DrawSplash (count, mobj->x, mobj->y, mobj->z, mobj->angle, 1); sprintf (sound, "world/spark%d", 1+(M_Random() % 3)); S_Sound (mobj, CHAN_AUTO, sound, 1, ATTN_STATIC); break; } case MT_FOUNTAIN: mobj->effects &= ~FX_FOUNTAINMASK; mobj->effects |= mobj->args[0] << FX_FOUNTAINSHIFT; break; case MT_SECRETTRIGGER: if (activator->player->mo == consoleplayer().camera) { if (mobj->args[0] <= 1) { C_MidPrint ("A secret is revealed!"); } if (mobj->args[0] == 0 || mobj->args[0] == 2) { S_Sound (activator, CHAN_AUTO, "misc/secret", 1, ATTN_NORM); } } level.found_secrets++; mobj->Destroy (); break; default: break; } } return false; }
void WI_updateAnimatedBack(void) { int i; anim_t *a; if (gamemode == commercial) return; if (wbs->epsd > 2) return; for (i = 0; i < NUMANIMS[wbs->epsd]; i++) { a = &anims[wbs->epsd][i]; if (bcnt == a->nexttic) { switch (a->type) { case ANIM_ALWAYS: if (++a->ctr >= a->nanims) a->ctr = 0; a->nexttic = bcnt + a->period; break; case ANIM_RANDOM: a->ctr++; if (a->ctr == a->nanims) { a->ctr = -1; a->nexttic = bcnt + a->data2 + (M_Random() % a->data1); } else a->nexttic = bcnt + a->period; break; case ANIM_LEVEL: // gawd-awful hack for level anims if (!(state == StatCount && i == 7) && wbs->next == a->data1) { a->ctr++; if (a->ctr == a->nanims) a->ctr--; a->nexttic = bcnt + a->period; } break; } } } }
//========================================================================== // P_DealPlayerStarts // Gives all the players in the game a playerstart. // Only needed in co-op games (start spots are random in deathmatch). //========================================================================== void P_DealPlayerStarts(void) { int i, k, num = playerstart_p - playerstarts; player_t *pl; mapthing_t *mt; int spotNumber; if(!num) Con_Error("No playerstarts!\n"); // First assign one start per player, only accepting perfect matches. for(i = 0, pl = players; i < MAXPLAYERS; i++, pl++) { if(!pl->plr->ingame) continue; // The number of the start spot this player will use. spotNumber = i % MAX_START_SPOTS; pl->startspot = -1; for(k = 0, mt = playerstarts; k < num; k++, mt++) { if(spotNumber == mt->type - 1) { // This is a match. pl->startspot = k; // Keep looking. } } // If still without a start spot, assign one randomly. if(pl->startspot == -1) { // It's likely that some players will get the same start // spots. pl->startspot = M_Random() % num; } } if(IS_NETGAME) { Con_Printf("Player starting spots:\n"); for(i = 0, pl = players; i < MAXPLAYERS; i++, pl++) { if(!pl->plr->ingame) continue; Con_Printf("- pl%i: color %i, spot %i\n", i, cfg.PlayerColor[i], pl->startspot); } } }
static int wipe_initMelt(int ticks) { int i; // copy start screen to main screen for(i=0;i<SCREENHEIGHT;i++) memcpy(wipe_scr.data+i*wipe_scr.byte_pitch, wipe_scr_start.data+i*wipe_scr.byte_pitch, SCREENWIDTH*V_GetPixelDepth()); // setup initial column positions (y<0 => not ready to scroll yet) y_lookup[0] = -(M_Random()%16); for (i=1;i<SCREENWIDTH;i++) { int r = (M_Random()%3) - 1; y_lookup[i] = y_lookup[i-1] + r; if (y_lookup[i] > 0) y_lookup[i] = 0; else if (y_lookup[i] == -16) y_lookup[i] = -15; } return 0; }
int wipe_initMelt ( int width, int height, int ticks ) { int i, r; // [SVE] svillarreal if(use3drenderer) { return 0; } // copy start screen to main screen memcpy(wipe_scr, wipe_scr_start, width*height); // makes this wipe faster (in theory) // to have stuff in column-major format wipe_shittyColMajorXform((short*)wipe_scr_start, width/2, height); wipe_shittyColMajorXform((short*)wipe_scr_end, width/2, height); // setup initial column positions // (y<0 => not ready to scroll yet) y = (int *) Z_Malloc(width*sizeof(int), PU_STATIC, 0); y[0] = -(M_Random()%16); for (i=1;i<width;i++) { r = (M_Random()%3) - 1; y[i] = y[i-1] + r; if (y[i] > 0) y[i] = 0; else if (y[i] == -16) y[i] = -15; } return 0; }
// // P_InitLightning(void) // // Called from P_SetupLevel // void P_InitLightning(void) { if(!LevelInfo.hasLightning) LightningFlash = 0; else { LevelSky = skytexture; if(LevelInfo.altSkyName) LevelTempSky = R_FindWall(LevelInfo.altSkyName); else LevelTempSky = -1; LightningFlash = 0; NextLightningFlash = ((M_Random() & 15) + 5) * 35; } }
void Intermission::UpdateAnimatedBack() { if (episode < 1 || episode > 3) return; for (int i=0; i<NUMANIMS[episode-1]; i++) { anim_t *a = &anims[episode-1][i]; if (bcount >= a->nexttic) { switch (a->type) { case ANIM_ALWAYS: if (++a->ctr >= a->nanims) a->ctr = 0; a->nexttic = bcount + a->period; break; case ANIM_RANDOM: a->ctr++; if (a->ctr == a->nanims) { a->ctr = -1; a->nexttic = bcount + a->data2 + (M_Random() % a->data1); } else a->nexttic = bcount + a->period; break; case ANIM_LEVEL: // gawd-awful hack for level anims if (!(state == StatCount && i == 7) && (next % 10) == a->data1) { a->ctr++; if (a->ctr == a->nanims) a->ctr--; a->nexttic = bcount + a->period; } break; } } } }
// // TextureManager::updateAnimatedTextures // // Handles ticking the animated textures and cyles the Textures within an // animation definition. // void TextureManager::updateAnimatedTextures() { if (!clientside) return; // cycle the animdef textures for (size_t i = 0; i < mAnimDefs.size(); i++) { anim_t* anim = &mAnimDefs[i]; if (--anim->countdown == 0) { anim->curframe = (anim->curframe + 1) % anim->numframes; if (anim->speedmin[anim->curframe] == anim->speedmax[anim->curframe]) anim->countdown = anim->speedmin[anim->curframe]; else anim->countdown = M_Random() % (anim->speedmax[anim->curframe] - anim->speedmin[anim->curframe]) + anim->speedmin[anim->curframe]; // cycle the Textures getTexture(anim->framepic[0]); // ensure Texture is still cached Texture* first_texture = mHandleMap[anim->framepic[0]]; for (int frame1 = 0; frame1 < anim->numframes - 1; frame1++) { int frame2 = (frame1 + 1) % anim->numframes; getTexture(anim->framepic[frame2]); // ensure Texture is still cached mHandleMap[anim->framepic[frame1]] = mHandleMap[anim->framepic[frame2]]; } mHandleMap[anim->framepic[anim->numframes - 1]] = first_texture; } } // warp textures for (size_t i = 0; i < mWarpDefs.size(); i++) { const Texture* original_texture = mWarpDefs[i].original_texture; Texture* warped_texture = mWarpDefs[i].warped_texture; R_WarpTexture(warped_texture, original_texture); } }
void FMugShotState::Tick() { if (Time == -1) { //When the delay is negative 1, stay on this frame indefinitely. return; } if (Time != 0) { Time--; } else if (Position < Frames.Size() - 1) { Position++; Time = Frames[Position].Delay; Random = M_Random(); } else { bFinished = true; } }
void WI_initAnimatedBack () { int i; in_anim_t *a; if (gamemode == commercial) { return; } if (gameinfo.gametype == GAME_Doom) { if (epsd > 2) { return; } for (i = 0; i < NUMANIMS[epsd]; i++) { a = &anims[epsd][i]; // init variables a->ctr = -1; // specify the next time to draw it if (a->type == ANIM_ALWAYS) a->nexttic = bcnt + 1 + (M_Random()%a->period); else if (a->type == ANIM_LEVEL) a->nexttic = bcnt + 1; } } else if (state == ShowNextLoc) { if (epsd <= 2) { char name[9]; sprintf (name, "MAPE%d", epsd + 1); background = TexMan[name]; } } }
// // P_InitLightning(void) // // Called from P_SetupLevel // void P_InitLightning() { if(!LevelInfo.hasLightning) LightningFlash = 0; else { skyflat_t *sky1 = R_SkyFlatForIndex(0); if(!sky1) return; LevelSky = sky1->texture; if(LevelInfo.altSkyName) LevelTempSky = R_FindWall(LevelInfo.altSkyName); else LevelTempSky = -1; LightningFlash = 0; NextLightningFlash = ((M_Random() & 15) + 5) * 35; } }
void WI_initAnimatedBack (void) { int i; anim_t *a; if ((gameinfo.flags & GI_MAPxx) || wbs->epsd > 2) return; for (i = 0; i < NUMANIMS[wbs->epsd]; i++) { a = &anims[wbs->epsd][i]; // init variables a->ctr = -1; // specify the next time to draw it if (a->type == ANIM_ALWAYS) a->nexttic = bcnt + 1 + (M_Random()%a->period); else if (a->type == ANIM_LEVEL) a->nexttic = bcnt + 1; } }
// // HUDCrossHairWidget::ticker // // Updates the crosshair on each gametic. // void HUDCrossHairWidget::ticker() { // default to no target color = notargetcolour; // fast as possible: don't bother with this crap if the crosshair // isn't going to be displayed anyway if(!crosshairnum || !crosshair_hilite || crosshairs[crosshairnum-1] == -1) return; // search for targets // ioanch 20160101: don't let P_AimLineAttack change global trace.attackrange fixed_t oldAttackRange = trace.attackrange; P_AimLineAttack(players[displayplayer].mo, players[displayplayer].mo->angle, 16*64*FRACUNIT, false); trace.attackrange = oldAttackRange; if(clip.linetarget) { // target found color = targetcolour; // default // haleyjd 06/06/09: some special behaviors if(clip.linetarget->flags & MF_FRIEND) color = friendcolour; if(((clip.linetarget->flags & MF_SHADOW || clip.linetarget->flags3 & MF3_GHOST) && M_Random() & 0x0F) || clip.linetarget->flags4 & MF4_TOTALINVISIBLE) { color = notargetcolour; } } }
static rbDecal_t *RB_CreateDecal(rbDecalDef_t *decalDef) { rbDecal_t *decal; decal = Z_Calloc(1, sizeof(*decal), PU_LEVEL, 0); decal->def = decalDef; decal->tics = decalDef->lifetime; decal->lump = decalDef->lumpnum + (M_Random() % decalDef->count); decal->offset = M_Random() & 7; decal->alpha = (float)decalDef->startingAlpha / 255.0f; decal->fadetime = decalDef->fadetime; decal->scale = decalDef->scale; decal->stickSector = NULL; decal->initialStickZ = 0; if(decalDef->randScaleFactor != 0) { decal->scale += (decalDef->randScaleFactor * ((float)M_Random() / 255.0f)); } if(decalDef->randRotate) { decal->rotation = DEG2RAD(((M_Random() - M_Random()) + ((M_Random() & 3) * 35)) - M_PI); } else { decal->rotation = 0; } decalhead.prev->next = decal; decal->next = &decalhead; decal->prev = decalhead.prev; decalhead.prev = decal; return decal; }
void SN_UpdateActiveSequences(void) { seqnode_t *node; boolean sndPlaying; if(!ActiveSequences || paused) { // No sequences currently playing/game is paused return; } for(node = SequenceListHead; node; node = node->next) { if(node->delayTics) { node->delayTics--; continue; } sndPlaying = S_GetSoundPlayingInfo(node->mobj, node->currentSoundID); switch(*node->sequencePtr) { case SS_CMD_PLAY: if(!sndPlaying) { node->currentSoundID = *(node->sequencePtr+1); S_StartSoundAtVolume(node->mobj, node->currentSoundID, node->volume); } node->sequencePtr += 2; break; case SS_CMD_WAITUNTILDONE: if(!sndPlaying) { node->sequencePtr++; node->currentSoundID = 0; } break; case SS_CMD_PLAYREPEAT: if(!sndPlaying) { node->currentSoundID = *(node->sequencePtr+1); S_StartSoundAtVolume(node->mobj, node->currentSoundID, node->volume); } break; case SS_CMD_DELAY: node->delayTics = *(node->sequencePtr+1); node->sequencePtr += 2; node->currentSoundID = 0; break; case SS_CMD_DELAYRAND: node->delayTics = *(node->sequencePtr+1)+ M_Random()%(*(node->sequencePtr+2)-*(node->sequencePtr+1)); node->sequencePtr += 2; node->currentSoundID = 0; break; case SS_CMD_VOLUME: node->volume = (127*(*(node->sequencePtr+1)))/100; node->sequencePtr += 2; break; case SS_CMD_STOPSOUND: // Wait until something else stops the sequence break; case SS_CMD_END: SN_StopSequence(node->mobj); break; default: break; } } }
// // P_DialogStart // // villsa [STRIFE] New function // void P_DialogStart(player_t *player) { int i = 0; int pic; int rnd = 0; char* byetext; int jumptoconv; if(menuactive || netgame) return; // are we facing towards our NPC? P_AimLineAttack(player->mo, player->mo->angle, (128*FRACUNIT)); if(!linetarget) { P_AimLineAttack(player->mo, player->mo->angle + (ANG90/16), (128*FRACUNIT)); if(!linetarget) P_AimLineAttack(player->mo, player->mo->angle - (ANG90/16), (128*FRACUNIT)); } if(!linetarget) return; // already in combat, can't talk to it if(linetarget->flags & MF_NODIALOG) return; // set pointer to the character talking dialogtalker = linetarget; // play a sound if(player == &players[consoleplayer]) S_StartSound(0, sfx_radio); linetarget->target = player->mo; // target the player dialogtalker->reactiontime = 2; // set reactiontime dialogtalkerangle = dialogtalker->angle; // remember original angle // face talker towards player A_FaceTarget(dialogtalker); // face towards NPC's direction player->mo->angle = R_PointToAngle2(player->mo->x, player->mo->y, dialogtalker->x, dialogtalker->y); // set pointer to player talking dialogplayer = player; // haleyjd 09/08/10: get any stored dialog state from this object jumptoconv = linetarget->miscdata; // check item requirements while(1) { int i = 0; currentdialog = P_DialogFind(linetarget->type, jumptoconv); // dialog's jumptoconv equal to 0? There's nothing to jump to. if(currentdialog->jumptoconv == 0) break; // villsa 09/08/10: converted into for loop for(i = 0; i < MDLG_MAXITEMS; i++) { // if the item is non-zero, the player must have at least one in his // or her inventory if(currentdialog->checkitem[i] != 0 && P_PlayerHasItem(dialogplayer, currentdialog->checkitem[i]) < 1) break; } if(i < MDLG_MAXITEMS) // didn't find them all? this is our dialog! break; jumptoconv = currentdialog->jumptoconv; } M_DialogDimMsg(20, 28, currentdialog->text, false); dialogtext = P_DialogGetMsg(currentdialog->text); // get states dialogtalkerstates = P_DialogGetStates(linetarget->type); // have talker greet the player if(dialogtalkerstates->greet) P_SetMobjState(dialogtalker, dialogtalkerstates->greet); // get talker's name if(currentdialog->name[0]) dialogname = currentdialog->name; else { // use a fallback: if(mobjinfo[linetarget->type].name) dialogname = DEH_String(mobjinfo[linetarget->type].name); // mobjtype name else dialogname = DEH_String("Person"); // default name - like Joe in Doom 3 :P } // setup number of choices to choose from for(i = 0; i < MDLG_MAXCHOICES; i++) { if(!currentdialog->choices[i].giveitem) break; } // set number of choices to menu dialogmenu.numitems = i + 1; rnd = M_Random() % 3; // setup dialog menu M_StartControlPanel(); menupause = false; menuindialog = true; menupausetime = gametic + 17; currentMenu = &dialogmenu; if(i >= dialogmenu.lastOn) itemOn = dialogmenu.lastOn; else itemOn = 0; // get backdrop pic = W_CheckNumForName(currentdialog->backpic); dialogbgpiclumpnum = pic; if(pic != -1) V_DrawPatchDirect(0, 0, W_CacheLumpNum(pic, PU_CACHE)); // get voice I_StartVoice(currentdialog->voice); // get bye text switch(rnd) { case 2: byetext = DEH_String("BYE!"); break; case 1: byetext = DEH_String("Thanks, Bye!"); break; default: case 0: byetext = DEH_String("See you later!"); break; } DEH_snprintf(dialoglastmsgbuffer, sizeof(dialoglastmsgbuffer), "%d) %s", i + 1, byetext); }
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 = §ors[i]; if(tempSec->intflags & SIF_SKY && tempSec->oldlightlevel < tempSec->lightlevel - 4) { tempSec->lightlevel -= 4; } } } else { for(i = 0; i < numsectors; i++) { tempSec = §ors[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 = §ors[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; } } } }
void ST_Ticker (void) { st_randomnumber = M_Random(); ST_updateWidgets(); st_oldhealth = consoleplayer().health; }
boolean cht_Responder(event_t *ev) { static player_t *plyr; if (ev->type == ev_keydown && 0x00 <= ev->data1 && ev->data1 <= 0xFF) // SRB2CBTODO: && 0x00 <= ev->data1 && ev->data1 <= 0xFF? { plyr = &players[consoleplayer]; // devmode cheat if (cht_CheckCheat(&cheat_bulmer, (char)ev->data1)) { sfxenum_t sfxid; const char *emoticon; byte mrandom; /* Shows a picture of David Bulmer with one the following messages: "*B^C", "*B^D", "*B^I", "*B^J", "*B^L", "*B^O", "*B^P", "*B^S", "*B^X" Accompany each emoticon with sound clip. */ M_StartControlPanel(); M_SetupNextMenu(&ReadDef2); mrandom = M_Random(); if (mrandom < 64) { emoticon = "*B^O"; sfxid = sfx_beeoh; } else if (mrandom < 128) { emoticon = "*B^L"; sfxid = sfx_beeel; } else if (mrandom < 192) { emoticon = "*B^J"; sfxid = sfx_beejay; } else { emoticon = "*B^D"; sfxid = sfx_beedee; } HU_DoCEcho(emoticon); COM_BufExecute(); S_StartSound(0, sfxid); } else if (cht_CheckCheat(&cheat_poksoc, (char)ev->data1)) { sfxenum_t sfxid; byte mrandom = M_Random(); /* Plays one of these sounds: "You cheating, lying GIT!" "Hey... are you my Grandma?" "PIIIKKAAA!" "You little bugger!" "Oxy-pad, Oxy-pad, Oxy-pad, Ox--eeaygggh!" "(Eggman's Japanese) That's not fair, now two of your players have to die!" */ if (mrandom < 48) sfxid = sfx_poksoc1; else if (mrandom < 96) sfxid = sfx_poksoc2; else if (mrandom < 144) sfxid = sfx_poksoc3; else if (mrandom < 192) sfxid = sfx_poksoc4; else if (mrandom < 240) sfxid = sfx_poksoc5; else sfxid = sfx_poksoc6; S_StartSound(0, sfxid); } else if (cht_CheckCheat(&cheat_apl, (char)ev->data1)) { sfxenum_t sfxid; byte mrandom = M_Random(); /* Plays one of these sounds: "You do realize those are prohibited on planes, right?" "IT'S A HUNKY DUNKY SUPER SIZE BIG FAT REALLY REALLY BIG BOMB!" "Let's order a pizza!" "Tails, you made the engines quit! "Buggery! What happened out here?!" "Oh no! A GigaDoomBot!" */ if (mrandom < 48) sfxid = sfx_apl1; else if (mrandom < 96) sfxid = sfx_apl2; else if (mrandom < 144) sfxid = sfx_apl3; else if (mrandom < 192) sfxid = sfx_apl4; else if (mrandom < 240) sfxid = sfx_apl5; else sfxid = sfx_apl6; S_StartSound(0, sfxid); } else if (cht_CheckCheat(&cheat_ultimate, (char)ev->data1)) // SRB2CBTODO: USE THIS FOR OTHER COOL STUFF! { // Plays the ring sound effect, then begins a single player game at ultimate difficulty. S_StartSound(0, sfx_itemup); ultmode = true; startmap = spstage_start; M_SetupNextMenu(&PlayerDef); } } return false; }
// // ST_updateFaceWidget // // This is a not-very-pretty routine which handles // the face states and their timing. // the precedence of expressions is: // dead > evil grin > turned head > straight ahead // static void ST_updateFaceWidget() { int i; angle_t badguyangle; angle_t diffang; static int lastattackdown = -1; static int priority = ST_PRIORITY_NONE; bool doevilgrin; if(priority < ST_PRIORITY_MAX) { // dead if(!plyr->health) { priority = ST_PRIORITY_DEAD; st_faceindex = ST_DEADFACE; st_facecount = 1; } } // haleyjd 06/27/08: ouch face when player screams from falling if(priority < ST_PRIORITY_DEAD) { if(plyr->mo->intflags & MIF_SCREAMED) { priority = ST_PRIORITY_FALLING; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; st_facecount = 1; } } if(priority < ST_PRIORITY_FALLING) { if(plyr->bonuscount) { // picking up bonus doevilgrin = false; for(i = 0; i < NUMWEAPONS; i++) { if(oldweaponsowned[i] != weaponsowned[i]) { doevilgrin = true; oldweaponsowned[i] = weaponsowned[i]; } } if(doevilgrin) { // evil grin if just picked up weapon priority = ST_PRIORITY_EVILGRIN; st_facecount = ST_EVILGRINCOUNT; st_faceindex = ST_calcPainOffset() + ST_EVILGRINOFFSET; } } } if(priority < ST_PRIORITY_EVILGRIN) { if(plyr->damagecount && plyr->attacker && plyr->attacker != plyr->mo) { // being attacked priority = ST_PRIORITY_PAIN; // haleyjd 10/12/03: classic DOOM problem of missing OUCH face // was due to inversion of this test: // if(plyr->health - st_oldhealth > ST_MUCHPAIN) if(st_oldhealth - plyr->health > ST_MUCHPAIN) { priority = ST_PRIORITY_MUCHPAIN; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; } else { badguyangle = R_PointToAngle2(plyr->mo->x, plyr->mo->y, getThingX(plyr->mo, plyr->attacker), getThingY(plyr->mo, plyr->attacker)); if(badguyangle > plyr->mo->angle) { // whether right or left diffang = badguyangle - plyr->mo->angle; i = diffang > ANG180; } else { // whether left or right diffang = plyr->mo->angle - badguyangle; i = diffang <= ANG180; } // confusing, aint it? st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset(); if(diffang < ANG45) { // head-on st_faceindex += ST_RAMPAGEOFFSET; } else if(i) { // turn face right st_faceindex += ST_TURNOFFSET; } else { // turn face left st_faceindex += ST_TURNOFFSET+1; } } } } if(priority < ST_PRIORITY_PAIN) { // getting hurt because of your own damn stupidity if(plyr->damagecount) { // haleyjd 10/12/03: classic DOOM problem of missing OUCH face // was due to inversion of this test: // if(plyr->health - st_oldhealth > ST_MUCHPAIN) if(st_oldhealth - plyr->health > ST_MUCHPAIN) { priority = ST_PRIORITY_MUCHPAIN_SELF; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_OUCHOFFSET; } else { priority = ST_PRIORITY_PAIN_SELF; st_facecount = ST_TURNCOUNT; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; } } } if(priority < ST_PRIORITY_PAIN_SELF) { // rapid firing if(plyr->attackdown) { if(lastattackdown==-1) lastattackdown = ST_RAMPAGEDELAY; else if(!--lastattackdown) { priority = ST_PRIORITY_RAMPAGE; st_faceindex = ST_calcPainOffset() + ST_RAMPAGEOFFSET; st_facecount = 1; lastattackdown = 1; } } else lastattackdown = -1; } if(priority < ST_PRIORITY_RAMPAGE) { // invulnerability if((plyr->cheats & CF_GODMODE) || plyr->powers[pw_invulnerability]) { priority = ST_PRIORITY_GODMODE; st_faceindex = ST_GODFACE; st_facecount = 1; } } // look left or look right if the facecount has timed out if(!st_facecount) { // sf: remove st_randomnumber st_faceindex = ST_calcPainOffset() + (M_Random() % 3); st_facecount = ST_STRAIGHTFACECOUNT; priority = ST_PRIORITY_NONE; } st_facecount--; }
// // sm_mrandom // // Implements M_Random() // // This is strictly for non-demo-sync-critical stuff such as // particle effects. // static cell AMX_NATIVE_CALL sm_mrandom(AMX *amx, cell *params) { return M_Random(); }
// // Do Platforms // "amount" is only used for SOME platforms. // dboolean EV_DoPlat(line_t *line, plattype_e type, int amount) { plat_t *plat; int secnum = -1; dboolean rtn = false; sector_t *sec = NULL; // Activate all <type> plats that are in_stasis switch (type) { case perpetualRaise: P_ActivateInStasis(line->tag); break; case toggleUpDn: P_ActivateInStasis(line->tag); rtn = true; break; default: break; } while ((secnum = P_FindSectorFromLineTag(line, secnum)) >= 0) { sec = sectors + secnum; if (P_SectorActive(floor_special, sec)) continue; // Find lowest & highest floors around sector rtn = true; plat = Z_Calloc(1, sizeof(*plat), PU_LEVSPEC, NULL); P_AddThinker(&plat->thinker); plat->type = type; plat->sector = sec; plat->sector->floordata = plat; plat->thinker.function = T_PlatRaise; plat->tag = line->tag; plat->low = sec->floorheight; switch (type) { case raiseToNearestAndChange: plat->speed = PLATSPEED / 2; sec->floorpic = sides[line->sidenum[0]].sector->floorpic; plat->high = P_FindNextHighestFloor(sec, sec->floorheight); plat->status = up; sec->special = 0; S_StartSectorSound(&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->status = up; S_StartSectorSound(&sec->soundorg, sfx_stnmov); break; case downWaitUpStay: plat->speed = PLATSPEED * 4; plat->low = MIN(P_FindLowestFloorSurrounding(sec), sec->floorheight); plat->high = sec->floorheight; plat->wait = TICRATE * PLATWAIT; plat->status = down; S_StartSectorSound(&sec->soundorg, sfx_pstart); break; case blazeDWUS: plat->speed = PLATSPEED * 8; plat->low = MIN(P_FindLowestFloorSurrounding(sec), sec->floorheight); plat->high = sec->floorheight; plat->wait = TICRATE * PLATWAIT; plat->status = down; S_StartSectorSound(&sec->soundorg, sfx_pstart); break; case perpetualRaise: plat->speed = PLATSPEED; plat->low = MIN(P_FindLowestFloorSurrounding(sec), sec->floorheight); plat->high = MAX(sec->floorheight, P_FindHighestFloorSurrounding(sec)); plat->wait = TICRATE * PLATWAIT; plat->status = (plat_e)(M_Random() & 1); S_StartSectorSound(&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 = TICRATE * 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); } if (sec) for (int i = 0; i < sec->linecount; i++) sec->lines[i]->flags &= ~ML_SECRET; return rtn; }
// // [Toke - CTF] CTF_SelectTeamPlaySpot // Randomly selects a team spawn point // mapthing2_t *CTF_SelectTeamPlaySpot (player_t &player, int selections) { switch (player.userinfo.team) { case TEAM_BLUE: { if (gametype != GM_CTF && teamsinplay < 1) break; for (int j = 0; j < MaxBlueTeamStarts; ++j) { size_t i = M_Random () % selections; if (G_CheckSpot (player, &blueteamstarts[i]) ) { return &blueteamstarts[i]; } } } break; case TEAM_RED: { if (gametype != GM_CTF && teamsinplay < 2) break; for (size_t j = 0; j < MaxRedTeamStarts; ++j) { size_t i = M_Random () % selections; if (G_CheckSpot (player, &redteamstarts[i]) ) { return &redteamstarts[i]; } } } break; case TEAM_GOLD: { if (gametype != GM_CTF && teamsinplay < 3) break; for (size_t j = 0; j < MaxGoldTeamStarts; ++j) { size_t i = M_Random () % selections; if (G_CheckSpot (player, &goldteamstarts[i]) ) { return &goldteamstarts[i]; } } } break; default: { } break; } if (gametype == GM_CTF) { if (MaxBlueTeamStarts) return &blueteamstarts[0]; else if (MaxRedTeamStarts) return &redteamstarts[0]; } else { if (teamsinplay >= 1 && MaxBlueTeamStarts) return &blueteamstarts[0]; else if (teamsinplay >= 2 && MaxRedTeamStarts) return &redteamstarts[0]; else if (teamsinplay >= 3 && MaxGoldTeamStarts) return &goldteamstarts[0]; } return NULL; }
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) { // SpawnMobj calls P_Random, and we don't want that the // random number generator gets out of sync. //P_SaveRandom(); crashorigin = P_SpawnMobj(plrmo->x + (16 * (M_Random() - 127) << FRACBITS), plrmo->y + (16 * (M_Random() - 127) << FRACBITS), plrmo->z + (4000 << FRACBITS), MT_CAMERA); //P_RestoreRandom(); crashorigin->tics = 5 * 35; // Five seconds will do. } // Make it loud! S_StartSound(SFX_THUNDER_CRASH | DDSF_NO_ATTENUATION, crashorigin); } // Calculate the next lighting flash if(!NextLightningFlash) { if(P_Random() < 50) { // Immediate Quick flash NextLightningFlash = (P_Random() & 15) + 16; } else { if(P_Random() < 128 && !(leveltime & 32)) { NextLightningFlash = ((P_Random() & 7) + 2) * 35; } else { NextLightningFlash = ((P_Random() & 15) + 5) * 35; } } } }