void OGL_GrabScreen (void) { int i, len, temp; char tganame[MAX_OSPATH], *p; byte *buffer; // // find a file name to save it to // snprintf (tganame, sizeof(tganame), "%shexen00.tga", basePath); p = tganame + strlen(basePath); for (i = 0; i <= 99; i++) { p[5] = i/10 + '0'; p[6] = i%10 + '0'; if (access(tganame, F_OK) == -1) break; // file doesn't exist } if (i == 100) { P_SetMessage(&players[consoleplayer], "SCREEN SHOT FAILED", false); return; } // NOTE: 18 == sizeof(TargaHeader) len = 18 + screenWidth * screenHeight * 3; // Z_Malloc would fail here (Z mem is too little) buffer = (byte *) malloc (len); if (buffer == NULL) I_Error ("OGL_GrabScreen: No memory for screenshot"); memset (buffer, 0, 18); buffer[2] = 2; // uncompressed type buffer[12] = screenWidth & 255; buffer[13] = screenWidth >> 8; buffer[14] = screenHeight & 255; buffer[15] = screenHeight >> 8; buffer[16] = 24; // pixel size glReadPixels (0, 0, screenWidth, screenHeight, GL_RGB, GL_UNSIGNED_BYTE, buffer + 18); // swap rgb to bgr for (i = 18; i < len; i += 3) { temp = buffer[i]; buffer[i] = buffer[i+2]; buffer[i+2] = temp; } M_WriteFile (tganame, buffer, len); free (buffer); P_SetMessage(&players[consoleplayer], "SCREEN SHOT", false); }
static boolean SCMessages(int option) { messageson ^= 1; if (messageson) { P_SetMessage(&players[consoleplayer], DEH_String("MESSAGES ON"), true); } else { P_SetMessage(&players[consoleplayer], DEH_String("MESSAGES OFF"), true); } S_StartSound(NULL, sfx_chat); return true; }
int EV_DoLockedDoor(line_t *line, vldoor_e type, mobj_t *thing) { player_t *p; p = thing->player; if(!p) return 0; switch (line->special) { case 99: // Blue Lock case 133: if(!p) return 0; if(!p->cards[it_bluecard] && !p->cards[it_blueskull]) { P_SetMessage(p, PD_BLUEO); S_StartSound(sfx_oof, p->plr->mo); return 0; } break; case 134: // Red Lock case 135: if(!p) return 0; if(!p->cards[it_redcard] && !p->cards[it_redskull]) { P_SetMessage(p, PD_REDO); S_StartSound(sfx_oof, p->plr->mo); return 0; } break; case 136: // Yellow Lock case 137: if(!p) return 0; if(!p->cards[it_yellowcard] && !p->cards[it_yellowskull]) { P_SetMessage(p, PD_YELLOWO); S_StartSound(sfx_oof, p->plr->mo); return 0; } break; } return EV_DoDoor(line, type); }
static void CheatDebugFunc(player_t *player, cheat_t * cheat) { char lumpName[9]; char textBuffer[256]; subsector_t *sub; if(!player->plr->mo || !usergame) return; P_GetMapLumpName(gameepisode, gamemap, lumpName); sprintf(textBuffer, "MAP [%s] X:%5d Y:%5d Z:%5d", lumpName, player->plr->mo->pos[VX] >> FRACBITS, player->plr->mo->pos[VY] >> FRACBITS, player->plr->mo->pos[VZ] >> FRACBITS); P_SetMessage(player, textBuffer, false); // Also print some information to the console. Con_Message(textBuffer); sub = player->plr->mo->subsector; Con_Message("\nSubsector %i:\n", P_ToIndex(sub)); Con_Message(" Floorz:%d pic:%d\n", P_GetIntp(sub, DMU_FLOOR_HEIGHT), P_GetIntp(sub, DMU_FLOOR_MATERIAL)); Con_Message(" Ceilingz:%d pic:%d\n", P_GetIntp(sub, DMU_CEILING_HEIGHT), P_GetIntp(sub, DMU_CEILING_MATERIAL)); Con_Message("Player height:%g Player radius:%x\n", player->plr->mo->height, player->plr->mo->radius); }
void G_DoLoadLevel(void) { int i; levelstarttic = gametic; // for time calculation gamestate = GS_LEVEL; for (i = 0; i < MAXPLAYERS; i++) { if (playeringame[i] && players[i].playerstate == PST_DEAD) players[i].playerstate = PST_REBORN; memset(players[i].frags, 0, sizeof(players[i].frags)); } P_SetupLevel(gameepisode, gamemap, 0, gameskill); displayplayer = consoleplayer; // view the guy you are playing gameaction = ga_nothing; Z_CheckHeap(); // // clear cmd building stuff // memset(gamekeydown, 0, sizeof(gamekeydown)); joyxmove = joyymove = joystrafemove = 0; mousex = mousey = 0; sendpause = sendsave = paused = false; memset(mousearray, 0, sizeof(mousearray)); memset(joyarray, 0, sizeof(joyarray)); if (testcontrols) { P_SetMessage(&players[consoleplayer], "PRESS ESCAPE TO QUIT.", false); } }
boolean Cht_WarpFunc(player_t *plyr, char *buf) { int epsd, map; if(gamemode == commercial) { epsd = 1; map = (buf[0] - '0') * 10 + buf[1] - '0'; } else { epsd = buf[0] - '0'; map = buf[1] - '0'; } // Catch invalid maps. if(!G_ValidateMap(&epsd, &map)) return false; // So be it. P_SetMessage(plyr, STSTR_CLEV, false); G_DeferedInitNew(gameskill, epsd, map); // Clear the menu if open Hu_MenuCommand(MCMD_CLOSE); briefDisabled = true; return true; }
boolean P_StartLockedACS(line_t * line, byte * args, mobj_t * mo, int side) { int i; int lock; byte newArgs[5]; char LockedBuffer[80]; extern char *TextKeyMessages[11]; lock = args[4]; if (!mo->player) { return false; } if (lock) { if (!(mo->player->keys & (1 << (lock - 1)))) { snprintf(LockedBuffer, sizeof(LockedBuffer), "YOU NEED THE %s\n", TextKeyMessages[lock - 1]); P_SetMessage(mo->player, LockedBuffer, true); S_StartSound(mo, SFX_DOOR_LOCKED); return false; } } for (i = 0; i < 4; i++) { newArgs[i] = args[i]; } newArgs[4] = 0; return P_StartACS(newArgs[0], newArgs[1], &newArgs[2], mo, line, side); }
void M_ScreenShot (void) { int i; byte *linear; char lbmname[12]; byte *pal; #ifdef _WATCOMC_ extern byte *pcscreen; #endif // // munge planar buffer to linear // #ifdef _WATCOMC_ linear = pcscreen; #else linear = screen; #endif // // find a file name to save it to // strcpy(lbmname,"HEXEN00.pcx"); for (i=0 ; i<=99 ; i++) { lbmname[5] = i/10 + '0'; lbmname[6] = i%10 + '0'; if (access(lbmname,0) == -1) break; // file doesn't exist } if (i==100) I_Error ("M_ScreenShot: Couldn't create a PCX"); // // save the pcx file // #ifdef __WATCOMC__ pal = (byte *)Z_Malloc(768, PU_STATIC, NULL); outp(0x3c7, 0); for(i = 0; i < 768; i++) { *(pal+i) = inp(0x3c9)<<2; } #else pal = (byte *)W_CacheLumpName("PLAYPAL", PU_CACHE); #endif WritePCXfile (lbmname, linear, SCREENWIDTH, SCREENHEIGHT , pal); P_SetMessage(&players[consoleplayer], "SCREEN SHOT", false); #ifdef __WATCOMC__ Z_Free(pal); #endif }
void Cht_MyPosFunc(player_t *plyr) { static char buf[ST_MSGWIDTH]; sprintf(buf, "ang=0x%x;x,y,z=(0x%x,0x%x,0x%x)", players[CONSOLEPLAYER].plr->mo->angle, players[CONSOLEPLAYER].plr->mo->pos[VX], players[CONSOLEPLAYER].plr->mo->pos[VY], players[CONSOLEPLAYER].plr->mo->pos[VZ]); P_SetMessage(plyr, buf, false); }
static boolean SCNetCheck(int option) { if (!netgame) { // okay to go into the menu return true; } switch (option) { case 1: P_SetMessage(&players[consoleplayer], "YOU CAN'T START A NEW GAME IN NETPLAY!", true); break; case 2: P_SetMessage(&players[consoleplayer], "YOU CAN'T LOAD A GAME IN NETPLAY!", true); break; default: break; } MenuActive = false; return false; }
void Cht_MusicFunc(player_t *plyr, char *buf) { int off, musnum; if(gamemode == commercial) { off = (buf[0] - '0') * 10 + buf[1] - '0'; musnum = MUS_MAP01 + off - 1; if(off < 1 || off > 35) P_SetMessage(plyr, STSTR_NOMUS, false); else S_StartMusicNum(musnum, true); } else { off = (buf[0] - '1') * 9 + (buf[1] - '1'); musnum = MUS_E1M1 + off; if(off > 31) P_SetMessage(plyr, STSTR_NOMUS, false); else S_StartMusicNum(musnum, true); } }
static boolean SCEpisode(int option) { if (gamemode == shareware && option > 1) { P_SetMessage(&players[consoleplayer], "ONLY AVAILABLE IN THE REGISTERED VERSION", true); } else { MenuEpisode = option; SetMenu(MENU_SKILL); } return true; }
void Cht_GodFunc(player_t *plyr) { plyr->cheats ^= CF_GODMODE; plyr->update |= PSF_STATE; if(P_GetPlayerCheats(plyr) & CF_GODMODE) { if(plyr->plr->mo) plyr->plr->mo->health = maxhealth; plyr->health = godmodehealth; plyr->update |= PSF_HEALTH; } P_SetMessage(plyr, ((P_GetPlayerCheats(plyr) & CF_GODMODE) ? STSTR_DQDON : STSTR_DQDOFF), false); }
boolean P_StartACS(int number, int map, byte * args, mobj_t * activator, line_t * line, int side) { int i; acs_t *script; int infoIndex; aste_t *statePtr; NewScript = NULL; if (map && map != gamemap) { // Add to the script store return AddToACSStore(map, number, args); } infoIndex = GetACSIndex(number); if (infoIndex == -1) { // Script not found //I_Error("P_StartACS: Unknown script number %d", number); snprintf(ErrorMsg, sizeof(ErrorMsg), "P_STARTACS ERROR: UNKNOWN SCRIPT %d", number); P_SetMessage(&players[consoleplayer], ErrorMsg, true); } statePtr = &ACSInfo[infoIndex].state; if (*statePtr == ASTE_SUSPENDED) { // Resume a suspended script *statePtr = ASTE_RUNNING; return true; } if (*statePtr != ASTE_INACTIVE) { // Script is already executing return false; } script = Z_Malloc(sizeof(acs_t), PU_LEVSPEC, 0); memset(script, 0, sizeof(acs_t)); script->number = number; script->infoIndex = infoIndex; script->activator = activator; script->line = line; script->side = side; script->ip = ACSInfo[infoIndex].address; script->thinker.function = T_InterpretACS; for (i = 0; i < ACSInfo[infoIndex].argCount; i++) { script->vars[i] = args[i]; } *statePtr = ASTE_RUNNING; P_AddThinker(&script->thinker); NewScript = script; return true; }
static int CmdEndPrint(void) { player_t *player; if (ACScript->activator && ACScript->activator->player) { player = ACScript->activator->player; } else { player = &players[consoleplayer]; } P_SetMessage(player, PrintBuffer, true); return SCRIPT_CONTINUE; }
/** * Called every tic frame that the player origin is in a special sector */ void P_PlayerInSpecialSector(player_t *player) { Sector *sector = Mobj_Sector(player->plr->mo); if(IS_CLIENT) return; // Falling, not all the way down yet? if(!FEQUAL(player->plr->mo->origin[VZ], P_GetDoublep(sector, DMU_FLOOR_HEIGHT))) return; // Has hitten ground. switch(P_ToXSector(sector)->special) { default: break; case 5: ///< HELLSLIME DAMAGE if(!player->powers[PT_IRONFEET]) if(!(mapTime & 0x1f)) P_DamageMobj(player->plr->mo, NULL, NULL, 10, false); break; case 7: ///< NUKAGE DAMAGE if(!player->powers[PT_IRONFEET]) if(!(mapTime & 0x1f)) P_DamageMobj(player->plr->mo, NULL, NULL, 5, false); break; case 16: ///< SUPER HELLSLIME DAMAGE case 4: ///< STROBE HURT if(!player->powers[PT_IRONFEET] || (P_Random() < 5)) { if(!(mapTime & 0x1f)) P_DamageMobj(player->plr->mo, NULL, NULL, 20, false); } break; case 9: ///< SECRET SECTOR player->secretCount++; P_ToXSector(sector)->special = 0; if(cfg.secretMsg) { P_SetMessage(player, "You've found a secret area!"); // S_ConsoleSound(SFX_SECRET, 0, player - players); // jd64 } break; } }
static void PlayerQuitGame(player_t *player) { static char exitmsg[80]; unsigned int player_num; player_num = player - players; M_StringCopy(exitmsg, "PLAYER 1 LEFT THE GAME", sizeof(exitmsg)); exitmsg[7] += player_num; P_SetMessage(&players[consoleplayer], exitmsg, true); S_StartSound(NULL, SFX_CHAT); playeringame[player_num] = false; // TODO: check if it is sensible to do this: if (demorecording) { G_CheckDemoStatus (); } }
void P_GiveBackpack(player_t *plr) { int i; if(!plr->backpack) { plr->update |= PSF_MAX_AMMO; for(i = 0; i < NUM_AMMO_TYPES; ++i) { plr->ammo[i].max *= 2; } plr->backpack = true; } for(i = 0; i < NUM_AMMO_TYPES; ++i) { P_GiveAmmo(plr, i, 1); } P_SetMessage(plr, 0, GOTBACKPACK); }
static boolean CheckedLockedDoor(mobj_t *mo, byte lock) { extern int TextKeyMessages[11]; char LockedBuffer[80]; if(!mo->player) { return false; } if(!lock) { return true; } if(!(mo->player->keys & (1 << (lock - 1)))) { sprintf(LockedBuffer, "YOU NEED THE %s\n", GET_TXT(TextKeyMessages[lock - 1])); P_SetMessage(mo->player, LockedBuffer, true); S_StartSound(SFX_DOOR_LOCKED, mo); return false; } return true; }
/** * Attempt to pickup the found weapon type. * * @param plr Player to attempt the pickup. * @param weaponType Weapon type to pickup. * @param dropped @c true= the weapon was dropped by someone. * @param pickupMessage Message to display if picked up. * * @return @c true if the player picked up the weapon. */ static dd_bool pickupWeapon(player_t *plr, weapontype_t weaponType, dd_bool dropped, char const *pickupMessage) { dd_bool pickedWeapon; DENG_ASSERT(plr != 0); DENG_ASSERT(weaponType >= WT_FIRST && weaponType < NUM_WEAPON_TYPES); // Depending on the game rules the player should ignore the weapon. if(plr->weapons[weaponType].owned) { // Leave placed weapons forever on net games. if(IS_NETGAME && G_Ruleset_Deathmatch() != 2 && !dropped) return false; } // Attempt the pickup. pickedWeapon = P_GiveWeapon(plr, weaponType, dropped); if(pickedWeapon) { // Notify the user. P_SetMessage(plr, 0, pickupMessage); if(!mapSetup) // Pickup sounds are not played during map setup. { S_ConsoleSound(SFX_WPNUP, NULL, plr - players); } } if(IS_NETGAME && G_Ruleset_Deathmatch() != 2 && !dropped) { // Leave placed weapons forever on net games. return false; } return pickedWeapon; }
// Respond to keyboard input events, // intercept cheats. boolean ST_Responder(event_t *ev) { int i; // Filter automap on/off. if(ev->type == ev_keyup && ((ev->data1 & 0xffff0000) == AM_MSGHEADER)) { switch (ev->data1) { case AM_MSGENTERED: st_gamestate = AutomapState; st_firsttime = true; break; case AM_MSGEXITED: st_gamestate = FirstPersonState; break; } } // if a user keypress... else if(ev->type == ev_keydown) { if(!IS_NETGAME) { // b. - enabled for more debug fun. // if (gameskill != sk_nightmare) { // 'dqd' cheat for toggleable god mode if(cht_CheckCheat(&cheat_god, ev->data1)) { cht_GodFunc(plyr); } // 'fa' cheat for killer f*****g arsenal else if(cht_CheckCheat(&cheat_ammonokey, ev->data1)) { cht_GiveFunc(plyr, true, true, true, false); P_SetMessage(plyr, STSTR_FAADDED); } // 'kfa' cheat for key full ammo else if(cht_CheckCheat(&cheat_ammo, ev->data1)) { cht_GiveFunc(plyr, true, true, true, true); P_SetMessage(plyr, STSTR_KFAADDED); } // 'mus' cheat for changing music else if(cht_CheckCheat(&cheat_mus, ev->data1)) { char buf[3]; P_SetMessage(plyr, STSTR_MUS); cht_GetParam(&cheat_mus, buf); cht_MusicFunc(plyr, buf); // Might set plyr->message. } // Simplified, accepting both "noclip" and "idspispopd". // no clipping mode cheat else if(cht_CheckCheat(&cheat_noclip, ev->data1) || cht_CheckCheat(&cheat_commercial_noclip, ev->data1)) { cht_NoClipFunc(plyr); } // 'behold?' power-up cheats for(i = 0; i < 6; i++) { if(cht_CheckCheat(&cheat_powerup[i], ev->data1)) { cht_PowerUpFunc(plyr, i); P_SetMessage(plyr, STSTR_BEHOLDX); } } // 'behold' power-up menu if(cht_CheckCheat(&cheat_powerup[6], ev->data1)) { P_SetMessage(plyr, STSTR_BEHOLD); } // 'choppers' invulnerability & chainsaw else if(cht_CheckCheat(&cheat_choppers, ev->data1)) { cht_ChoppersFunc(plyr); P_SetMessage(plyr, STSTR_CHOPPERS); } // 'mypos' for player position else if(cht_CheckCheat(&cheat_mypos, ev->data1)) { cht_PosFunc(plyr); } } // 'clev' change-level cheat if(cht_CheckCheat(&cheat_clev, ev->data1)) { char buf[3]; cht_GetParam(&cheat_clev, buf); cht_WarpFunc(plyr, buf); } } return false; }
//================================================================== // // EV_VerticalDoor : open a door manually, no tag value // //================================================================== void EV_VerticalDoor(line_t * line, mobj_t * thing) { player_t *player; sector_t *sec; vldoor_t *door; int side; side = 0; // only front sides can be used // // Check for locks // player = thing->player; switch (line->special) { case 26: // Blue Lock case 32: if (!player) { return; } if (!player->keys[key_blue]) { P_SetMessage(player, DEH_String(TXT_NEEDBLUEKEY), false); S_StartSound(NULL, sfx_plroof); return; } break; case 27: // Yellow Lock case 34: if (!player) { return; } if (!player->keys[key_yellow]) { P_SetMessage(player, DEH_String(TXT_NEEDYELLOWKEY), false); S_StartSound(NULL, sfx_plroof); return; } break; case 28: // Green Lock case 33: if (!player) { return; } if (!player->keys[key_green]) { P_SetMessage(player, DEH_String(TXT_NEEDGREENKEY), false); S_StartSound(NULL, sfx_plroof); return; } break; } // if the sector has an active thinker, use it sec = sides[line->sidenum[side ^ 1]].sector; if (sec->specialdata) { door = sec->specialdata; switch (line->special) { case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s case 26: case 27: case 28: if (door->direction == -1) { door->direction = 1; // go back up } else { if (!thing->player) { // Monsters don't close doors return; } door->direction = -1; // start going down immediately } return; } } // for proper sound switch (line->special) { case 1: // NORMAL DOOR SOUND case 31: S_StartSound(&sec->soundorg, sfx_doropn); //S_StartSound(&sec->soundorg, sfx_dormov); break; default: // LOCKED DOOR SOUND S_StartSound(&sec->soundorg, sfx_doropn); //S_StartSound(&sec->soundorg, sfx_dormov); break; } // // new door thinker // door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0); P_AddThinker(&door->thinker); sec->specialdata = door; door->thinker.function = T_VerticalDoor; door->sector = sec; door->direction = 1; switch (line->special) { case 1: case 26: case 27: case 28: door->type = normal; break; case 31: case 32: case 33: case 34: door->type = open; line->special = 0; break; } door->speed = VDOORSPEED; door->topwait = VDOORWAIT; // // find the top and bottom of the movement range // door->topheight = P_FindLowestCeilingSurrounding(sec); door->topheight -= 4 * FRACUNIT; }
void CT_Ticker(void) { int i; int j; char c; int numplayers; for (i = 0; i < maxplayers; i++) { if (!playeringame[i]) { continue; } if ((c = players[i].cmd.chatchar) != 0) { if (c <= CT_PLR_ALL) { chat_dest[i] = c; continue; } else if (c == CT_ESCAPE) { CT_ClearChatMessage(i); } else if (c == KEY_ENTER) { numplayers = 0; for (j = 0; j < maxplayers; j++) { numplayers += playeringame[j]; } CT_AddChar(i, 0); // set the end of message character if (numplayers > 2) { M_StringCopy(plr_lastmsg[i], CT_FromPlrText[i], sizeof(plr_lastmsg[i])); M_StringConcat(plr_lastmsg[i], chat_msg[i], sizeof(plr_lastmsg[i])); } else { M_StringCopy(plr_lastmsg[i], chat_msg[i], sizeof(plr_lastmsg[i])); } if (i != consoleplayer && (chat_dest[i] == consoleplayer + 1 || chat_dest[i] == CT_PLR_ALL) && *chat_msg[i]) { P_SetMessage(&players[consoleplayer], plr_lastmsg[i], true); S_StartSound(NULL, SFX_CHAT); } else if (i == consoleplayer && (*chat_msg[i])) { if (numplayers <= 1) { P_SetMessage(&players[consoleplayer], "THERE ARE NO OTHER PLAYERS IN THE GAME!", true); S_StartSound(NULL, SFX_CHAT); } } CT_ClearChatMessage(i); } else if (c == KEY_BACKSPACE) { CT_BackSpace(i); } else { CT_AddChar(i, c); } } } return; }
// // EV_VerticalDoor : open a door manually, no tag value // void EV_VerticalDoor(line_t *line, mobj_t *thing) { player_t *player; int secnum; sector_t *sec; vldoor_t *door; int side; side = 0; // only front sides can be used // Check for locks player = thing->player; switch (line->special) { case 26: // Blue Lock case 32: if(!player) return; if(!player->cards[it_bluecard] && !player->cards[it_blueskull]) { P_SetMessage(player, PD_BLUEK); S_StartSound(sfx_oof, player->plr->mo); return; } break; case 27: // Yellow Lock case 34: if(!player) return; if(!player->cards[it_yellowcard] && !player->cards[it_yellowskull]) { P_SetMessage(player, PD_YELLOWK); S_StartSound(sfx_oof, player->plr->mo); return; } break; case 28: // Red Lock case 33: if(!player) return; if(!player->cards[it_redcard] && !player->cards[it_redskull]) { P_SetMessage(player, PD_REDK); S_StartSound(sfx_oof, player->plr->mo); return; } break; } // if the sector has an active thinker, use it sec = sides[line->sidenum[side ^ 1]].sector; secnum = sec - sectors; if(sec->specialdata) { door = sec->specialdata; switch (line->special) { case 1: // ONLY FOR "RAISE" DOORS, NOT "OPEN"s case 26: case 27: case 28: case 117: if(door->direction == -1) door->direction = 1; // go back up else { if(!thing->player) return; // JDC: bad guys never close doors door->direction = -1; // start going down immediately } return; } } // for proper sound switch (line->special) { case 117: // BLAZING DOOR RAISE case 118: // BLAZING DOOR OPEN S_SectorSound(sec, sfx_bdopn); break; case 1: // NORMAL DOOR SOUND case 31: S_SectorSound(sec, sfx_doropn); break; default: // LOCKED DOOR SOUND S_SectorSound(sec, sfx_doropn); break; } // new door thinker door = Z_Malloc(sizeof(*door), PU_LEVSPEC, 0); P_AddThinker(&door->thinker); sec->specialdata = door; door->thinker.function = T_VerticalDoor; door->sector = sec; door->direction = 1; door->speed = VDOORSPEED; door->topwait = VDOORWAIT; switch (line->special) { case 1: case 26: case 27: case 28: door->type = normal; break; case 31: case 32: case 33: case 34: door->type = open; line->special = 0; break; case 117: // blazing door raise door->type = blazeRaise; door->speed = VDOORSPEED * 4; break; case 118: // blazing door open door->type = blazeOpen; line->special = 0; door->speed = VDOORSPEED * 4; break; } // find the top and bottom of the movement range door->topheight = P_FindLowestCeilingSurrounding(sec); door->topheight -= 4 * FRACUNIT; }
boolean AM_Responder(event_t * ev) { int rc; int key; static int bigstate = 0; static int joywait = 0; key = ev->data1; rc = false; if (ev->type == ev_joystick && joybautomap >= 0 && (ev->data1 & (1 << joybautomap)) != 0 && joywait < I_GetTime()) { joywait = I_GetTime() + 5; if (!automapactive) { AM_Start (); viewactive = false; } else { bigstate = 0; viewactive = true; AM_Stop (); } } if (!automapactive) { if (ev->type == ev_keydown && key == key_map_toggle && gamestate == GS_LEVEL) { AM_Start(); viewactive = false; // viewactive = true; rc = true; } } else if (ev->type == ev_keydown) { rc = true; if (key == key_map_east) // pan right { if (!followplayer) m_paninc.x = FTOM(F_PANINC); else rc = false; } else if (key == key_map_west) // pan left { if (!followplayer) m_paninc.x = -FTOM(F_PANINC); else rc = false; } else if (key == key_map_north) // pan up { if (!followplayer) m_paninc.y = FTOM(F_PANINC); else rc = false; } else if (key == key_map_south) // pan down { if (!followplayer) m_paninc.y = -FTOM(F_PANINC); else rc = false; } else if (key == key_map_zoomout) // zoom out { mtof_zoommul = M_ZOOMOUT; ftom_zoommul = M_ZOOMIN; } else if (key == key_map_zoomin) // zoom in { mtof_zoommul = M_ZOOMIN; ftom_zoommul = M_ZOOMOUT; } else if (key == key_map_toggle) // toggle map (tab) { bigstate = 0; viewactive = true; AM_Stop(); } else if (key == key_map_maxzoom) { bigstate = !bigstate; if (bigstate) { AM_saveScaleAndLoc(); AM_minOutWindowScale(); } else AM_restoreScaleAndLoc(); } else if (key == key_map_follow) { followplayer = !followplayer; f_oldloc.x = INT_MAX; P_SetMessage(plr, followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF, true); } /* else if (key == key_map_grid) { grid = !grid; plr->message = grid ? AMSTR_GRIDON : AMSTR_GRIDOFF; } else if (key == key_map_mark) { M_snprintf(buffer, sizeof(buffer), "%s %d", AMSTR_MARKEDSPOT, markpointnum); plr->message = buffer; AM_addMark(); } else if (key == key_map_clearmark) { AM_clearMarks(); plr->message = AMSTR_MARKSCLEARED; } */ else { rc = false; } if (cheat_amap[cheatcount] == ev->data1 && !netgame) cheatcount++; else cheatcount = 0; if (cheatcount == 6) { cheatcount = 0; rc = false; cheating = (cheating + 1) % 3; } } else if (ev->type == ev_keyup) { rc = false; if (key == key_map_east) { if (!followplayer) m_paninc.x = 0; } else if (key == key_map_west) { if (!followplayer) m_paninc.x = 0; } else if (key == key_map_north) { if (!followplayer) m_paninc.y = 0; } else if (key == key_map_south) { if (!followplayer) m_paninc.y = 0; } else if (key == key_map_zoomout || key == key_map_zoomin) { mtof_zoommul = FRACUNIT; ftom_zoommul = FRACUNIT; } } return rc; }
boolean AM_Responder (event_t *ev) { int rc; static int cheatstate=0; static int bigstate=0; rc = false; if (!automapactive) { if (ev->type == ev_keydown && ev->data1 == AM_STARTKEY && gamestate == GS_LEVEL) { AM_Start (); SB_state = -1; viewactive = false; rc = true; } } else if (ev->type == ev_keydown) { rc = true; switch(ev->data1) { case AM_PANRIGHTKEY: // pan right if (!followplayer) m_paninc.x = FTOM(F_PANINC); else rc = false; break; case AM_PANLEFTKEY: // pan left if (!followplayer) m_paninc.x = -FTOM(F_PANINC); else rc = false; break; case AM_PANUPKEY: // pan up if (!followplayer) m_paninc.y = FTOM(F_PANINC); else rc = false; break; case AM_PANDOWNKEY: // pan down if (!followplayer) m_paninc.y = -FTOM(F_PANINC); else rc = false; break; case AM_ZOOMOUTKEY: // zoom out mtof_zoommul = M_ZOOMOUT; ftom_zoommul = M_ZOOMIN; break; case AM_ZOOMINKEY: // zoom in mtof_zoommul = M_ZOOMIN; ftom_zoommul = M_ZOOMOUT; break; case AM_ENDKEY: bigstate = 0; viewactive = true; AM_Stop (); SB_state = -1; break; case AM_GOBIGKEY: bigstate = !bigstate; if (bigstate) { AM_saveScaleAndLoc(); AM_minOutWindowScale(); } else AM_restoreScaleAndLoc(); break; case AM_FOLLOWKEY: followplayer = !followplayer; f_oldloc.x = MAXINT; P_SetMessage(plr, followplayer ? AMSTR_FOLLOWON : AMSTR_FOLLOWOFF, true); break; default: cheatstate=0; rc = false; } if(cheat_kills[ShowKillsCount] == ev->data1 && netgame && deathmatch) { ShowKillsCount++; if(ShowKillsCount == 5) { ShowKillsCount = 0; rc = false; ShowKills ^= 1; } } else { ShowKillsCount = 0; } } else if (ev->type == ev_keyup) { rc = false; switch (ev->data1) { case AM_PANRIGHTKEY: if (!followplayer) m_paninc.x = 0; break; case AM_PANLEFTKEY: if (!followplayer) m_paninc.x = 0; break; case AM_PANUPKEY: if (!followplayer) m_paninc.y = 0; break; case AM_PANDOWNKEY: if (!followplayer) m_paninc.y = 0; break; case AM_ZOOMOUTKEY: case AM_ZOOMINKEY: mtof_zoommul = FRACUNIT; ftom_zoommul = FRACUNIT; break; } } return rc; }
/** * @param plr Player being given item. * @param item Type of item being given. * @param dropped @c true = the item was dropped by some entity. * * @return @c true iff the item should be destroyed. */ static dd_bool pickupItem(player_t *plr, itemtype_t item, dd_bool dropped) { if(!plr) return false; switch(item) { case IT_ARMOR_GREEN: if(!P_GiveArmor(plr, armorClass[0], armorPoints[MINMAX_OF(0, armorClass[0] - 1, 1)])) return false; P_SetMessage(plr, 0, GOTARMOR); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_ARMOR_BLUE: if(!P_GiveArmor(plr, armorClass[1], armorPoints[MINMAX_OF(0, armorClass[1] - 1, 1)])) return false; P_SetMessage(plr, 0, GOTMEGA); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_ARMOR_BONUS: if(!plr->armorType) P_PlayerSetArmorType(plr, armorClass[0]); if(plr->armorPoints < armorPoints[1]) P_PlayerGiveArmorBonus(plr, 1); P_SetMessage(plr, 0, GOTARMBONUS); if(!mapSetup) { S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); // Maybe unhide the HUD? ST_HUDUnHide(plr - players, HUE_ON_PICKUP_ARMOR); } break; case IT_HEALTH_PACK: if(!P_GiveHealth(plr, 10)) return false; P_SetMessage(plr, 0, GOTSTIM); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_HEALTH_KIT: { int oldHealth = plr->health; /** * DOOM bug: * The following test was originaly placed AFTER the call to * P_GiveHealth thereby making the first outcome impossible as * the medikit gives 25 points of health. This resulted that * the GOTMEDINEED "Picked up a medikit that you REALLY need" * was never used. */ if(!P_GiveHealth(plr, 25)) return false; P_SetMessage(plr, 0, GET_TXT((oldHealth < 25)? TXT_GOTMEDINEED : TXT_GOTMEDIKIT)); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; } case IT_HEALTH_BONUS: plr->health++; // Can go over 100%. if(plr->health > healthLimit) plr->health = healthLimit; plr->plr->mo->health = plr->health; plr->update |= PSF_HEALTH; P_SetMessage(plr, 0, GOTHTHBONUS); if(!mapSetup) { S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); // Maybe unhide the HUD? ST_HUDUnHide(plr - players, HUE_ON_PICKUP_HEALTH); } break; case IT_HEALTH_SOULSPHERE: plr->health += soulSphereHealth; if(plr->health > soulSphereLimit) plr->health = soulSphereLimit; plr->plr->mo->health = plr->health; plr->update |= PSF_HEALTH; P_SetMessage(plr, 0, GOTSUPER); if(!mapSetup) { S_ConsoleSound(SFX_GETPOW, NULL, plr - players); // Maybe unhide the HUD? ST_HUDUnHide(plr - players, HUE_ON_PICKUP_HEALTH); } break; case IT_KEY_BLUE: if(!plr->keys[KT_BLUECARD]) { P_GiveKey(plr, KT_BLUECARD); P_SetMessage(plr, 0, GOTBLUECARD); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); } if(IS_NETGAME) return false; break; case IT_KEY_YELLOW: if(!plr->keys[KT_YELLOWCARD]) { P_GiveKey(plr, KT_YELLOWCARD); P_SetMessage(plr, 0, GOTYELWCARD); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); } if(IS_NETGAME) return false; break; case IT_KEY_RED: if(!plr->keys[KT_REDCARD]) { P_GiveKey(plr, KT_REDCARD); P_SetMessage(plr, 0, GOTREDCARD); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); } if(IS_NETGAME) return false; break; case IT_KEY_BLUESKULL: if(!plr->keys[KT_BLUESKULL]) { P_GiveKey(plr, KT_BLUESKULL); P_SetMessage(plr, 0, GOTBLUESKUL); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); } if(IS_NETGAME) return false; break; case IT_KEY_YELLOWSKULL: if(!plr->keys[KT_YELLOWSKULL]) { P_GiveKey(plr, KT_YELLOWSKULL); P_SetMessage(plr, 0, GOTYELWSKUL); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); } if(IS_NETGAME) return false; break; case IT_KEY_REDSKULL: if(!plr->keys[KT_REDSKULL]) { P_GiveKey(plr, KT_REDSKULL); P_SetMessage(plr, 0, GOTREDSKULL); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); } if(IS_NETGAME) return false; break; case IT_MEGASPHERE: if(!(gameModeBits & GM_ANY_DOOM2)) return false; plr->health = megaSphereHealth; plr->plr->mo->health = plr->health; plr->update |= PSF_HEALTH; P_GiveArmor(plr, armorClass[1], armorPoints[MINMAX_OF(0, armorClass[1] - 1, 1)]); P_SetMessage(plr, 0, GOTMSPHERE); if(!mapSetup) { S_ConsoleSound(SFX_GETPOW, NULL, plr - players); // Maybe unhide the HUD? ST_HUDUnHide(plr - players, HUE_ON_PICKUP_HEALTH); } break; case IT_INVUL: if(!P_GivePower(plr, PT_INVULNERABILITY)) return false; P_SetMessage(plr, 0, GOTINVUL); if(!mapSetup) S_ConsoleSound(SFX_GETPOW, NULL, plr - players); break; case IT_BERSERK: if(!P_GivePower(plr, PT_STRENGTH)) return false; P_SetMessage(plr, 0, GOTBERSERK); if(plr->readyWeapon != WT_FIRST && cfg.berserkAutoSwitch) { plr->pendingWeapon = WT_FIRST; plr->update |= PSF_PENDING_WEAPON | PSF_READY_WEAPON; } if(!mapSetup) S_ConsoleSound(SFX_GETPOW, NULL, plr - players); break; case IT_INVIS: if(!P_GivePower(plr, PT_INVISIBILITY)) return false; P_SetMessage(plr, 0, GOTINVIS); if(!mapSetup) S_ConsoleSound(SFX_GETPOW, NULL, plr - players); break; case IT_SUIT: if(!P_GivePower(plr, PT_IRONFEET)) return false; P_SetMessage(plr, 0, GOTSUIT); if(!mapSetup) S_ConsoleSound(SFX_GETPOW, NULL, plr - players); break; case IT_ALLMAP: if(!P_GivePower(plr, PT_ALLMAP)) return false; P_SetMessage(plr, 0, GOTMAP); if(!mapSetup) S_ConsoleSound(SFX_GETPOW, NULL, plr - players); break; case IT_VISOR: if(!P_GivePower(plr, PT_INFRARED)) return false; P_SetMessage(plr, 0, GOTVISOR); if(!mapSetup) S_ConsoleSound(SFX_GETPOW, NULL, plr - players); break; case IT_BACKPACK: P_GiveBackpack(plr); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_CLIP: if(!P_GiveAmmo(plr, AT_CLIP, dropped? 0 /*half a clip*/ : 1)) return false; P_SetMessage(plr, 0, GOTCLIP); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_CLIP_BOX: if(!P_GiveAmmo(plr, AT_CLIP, 5)) return false; P_SetMessage(plr, 0, GOTCLIPBOX); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_ROCKET: if(!P_GiveAmmo(plr, AT_MISSILE, 1)) return false; P_SetMessage(plr, 0, GOTROCKET); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_ROCKET_BOX: if(!P_GiveAmmo(plr, AT_MISSILE, 5)) return false; P_SetMessage(plr, 0, GOTROCKBOX); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_CELL: if(!P_GiveAmmo(plr, AT_CELL, 1)) return false; P_SetMessage(plr, 0, GOTCELL); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_CELL_BOX: if(!P_GiveAmmo(plr, AT_CELL, 5)) return false; P_SetMessage(plr, 0, GOTCELLBOX); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_SHELL: if(!P_GiveAmmo(plr, AT_SHELL, 1)) return false; P_SetMessage(plr, 0, GOTSHELLS); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_AMMO_SHELL_BOX: if(!P_GiveAmmo(plr, AT_SHELL, 5)) return false; P_SetMessage(plr, 0, GOTSHELLBOX); if(!mapSetup) S_ConsoleSound(SFX_ITEMUP, NULL, plr - players); break; case IT_WEAPON_BFG: return pickupWeapon(plr, WT_SEVENTH, dropped, GOTBFG9000); case IT_WEAPON_CHAINGUN: return pickupWeapon(plr, WT_FOURTH, dropped, GOTCHAINGUN); case IT_WEAPON_CHAINSAW: return pickupWeapon(plr, WT_EIGHTH, dropped, GOTCHAINSAW); case IT_WEAPON_RLAUNCHER: return pickupWeapon(plr, WT_FIFTH, dropped, GOTLAUNCHER); case IT_WEAPON_PLASMARIFLE: return pickupWeapon(plr, WT_SIXTH, dropped, GOTPLASMA); case IT_WEAPON_SHOTGUN: return pickupWeapon(plr, WT_THIRD, dropped, GOTSHOTGUN); case IT_WEAPON_SSHOTGUN: return pickupWeapon(plr, WT_NINETH, dropped, GOTSHOTGUN2); default: Con_Error("pickupItem: Unknown item %i.", (int) item); } return true; }
void Cht_NoClipFunc(player_t *plyr) { plyr->cheats ^= CF_NOCLIP; plyr->update |= PSF_STATE; P_SetMessage(plyr, ((P_GetPlayerCheats(plyr) & CF_NOCLIP) ? STSTR_NCON : STSTR_NCOFF), false); }
void GetPackets (void) { int netconsole; int netnode; ticcmd_t *src, *dest; int realend; int realstart; while (HGetPacket ()) { if (netbuffer->checksum & NCMD_SETUP) continue; // extra setup packet netconsole = netbuffer->player & ~PL_DRONE; netnode = doomcom->remotenode; // // to save bytes, only the low byte of tic numbers are sent // Figure out what the rest of the bytes are // realstart = ExpandTics (netbuffer->starttic); realend = (realstart+netbuffer->numtics); // // check for exiting the game // if (netbuffer->checksum & NCMD_EXIT) { if (!nodeingame[netnode]) continue; nodeingame[netnode] = false; playeringame[netconsole] = false; strcpy(exitmsg, "PLAYER 1 LEFT THE GAME"); S_StartSound(NULL, sfx_chat); exitmsg[7] += netconsole; //players[consoleplayer].message = exitmsg; P_SetMessage(&players[consoleplayer], exitmsg, true); /* if (demorecording) G_CheckDemoStatus (); */ // DEBUG continue; } // // check for a remote game kill // if (netbuffer->checksum & NCMD_KILL) I_Error ("Killed by network driver"); nodeforplayer[netconsole] = netnode; // // check for retransmit request // if ( resendcount[netnode] <= 0 && (netbuffer->checksum & NCMD_RETRANSMIT) ) { resendto[netnode] = ExpandTics(netbuffer->retransmitfrom); if (debugfile) fprintf (debugfile,"retransmit from %i\n", resendto[netnode]); resendcount[netnode] = RESENDCOUNT; } else resendcount[netnode]--; // // check for out of order / duplicated packet // if (realend == nettics[netnode]) continue; if (realend < nettics[netnode]) { if (debugfile) fprintf (debugfile,"out of order packet (%i + %i)\n" ,realstart,netbuffer->numtics); continue; } // // check for a missed packet // if (realstart > nettics[netnode]) { // stop processing until the other system resends the missed tics if (debugfile) fprintf (debugfile,"missed tics from %i (%i - %i)\n", netnode, realstart, nettics[netnode]); remoteresend[netnode] = true; continue; } // // update command store from the packet // { int start; remoteresend[netnode] = false; start = nettics[netnode] - realstart; src = &netbuffer->cmds[start]; while (nettics[netnode] < realend) { dest = &netcmds[netconsole][nettics[netnode]%BACKUPTICS]; nettics[netnode]++; *dest = *src; src++; } } } }
/** * Responds to user input to see if a cheat sequence * has been entered. Events are never eaten. * * @parm ev: ptr to the event to be checked */ boolean Cht_Responder(event_t *ev) { int i; if(G_GetGameState() != GS_MAP) return false; plyr = &players[CONSOLEPLAYER]; if(gameskill != SM_NIGHTMARE && (ev->type == EV_KEY && ev->state == EVS_DOWN)) { if(!IS_NETGAME) { // b. - enabled for more debug fun. // if (gameskill != SM_NIGHTMARE) { // 'dqd' cheat for toggleable god mode if(Cht_CheckCheat(&cheat_god, ev->data1)) { Cht_GodFunc(plyr); } // 'fa' cheat for killer f*****g arsenal else if(Cht_CheckCheat(&cheat_ammonokey, ev->data1)) { Cht_GiveFunc(plyr, true, true, true, false, &cheat_ammonokey); P_SetMessage(plyr, STSTR_FAADDED, false); } // 'kfa' cheat for key full ammo else if(Cht_CheckCheat(&cheat_ammo, ev->data1)) { Cht_GiveFunc(plyr, true, true, true, true, &cheat_ammo); P_SetMessage(plyr, STSTR_KFAADDED, false); } // 'mus' cheat for changing music else if(Cht_CheckCheat(&cheat_mus, ev->data1)) { char buf[3]; P_SetMessage(plyr, STSTR_MUS, false); Cht_GetParam(&cheat_mus, buf); Cht_MusicFunc(plyr, buf); // Might set plyr->message. } // Simplified, accepting both "noclip" and "idspispopd". // no clipping mode cheat else if(Cht_CheckCheat(&cheat_noclip, ev->data1) || Cht_CheckCheat(&cheat_commercial_noclip, ev->data1)) { Cht_NoClipFunc(plyr); } // 'behold?' power-up cheats for(i = 0; i < 6; i++) { if(Cht_CheckCheat(&cheat_powerup[i], ev->data1)) { Cht_PowerUpFunc(plyr, i); P_SetMessage(plyr, STSTR_BEHOLDX, false); } } // 'behold' power-up menu if(Cht_CheckCheat(&cheat_powerup[6], ev->data1)) { P_SetMessage(plyr, STSTR_BEHOLD, false); } // 'choppers' invulnerability & chainsaw else if(Cht_CheckCheat(&cheat_choppers, ev->data1)) { Cht_ChoppersFunc(plyr); P_SetMessage(plyr, STSTR_CHOPPERS, false); } // 'mypos' for player position else if(Cht_CheckCheat(&cheat_mypos, ev->data1)) { Cht_MyPosFunc(plyr); } } if(Cht_CheckCheat(&cheat_clev, ev->data1)) { // 'clev' change-level cheat char buf[3]; Cht_GetParam(&cheat_clev, buf); Cht_WarpFunc(plyr, buf); } } if(AM_IsMapActive(CONSOLEPLAYER) && ev->type == EV_KEY) { if(ev->state == EVS_DOWN) { if(!deathmatch && Cht_CheckCheat(&cheat_amap, (char) ev->data1)) { AM_IncMapCheatLevel(CONSOLEPLAYER); return false; } } else if(ev->state == EVS_UP) { return false; } else if(ev->state == EVS_REPEAT) return true; } return false; }