📄 g_game.c
字号:
cmd->buttons |= BT_CHANGE | BT_EXTRAWEAPON; // extra by default cmd->buttons |= (i-gc_weapon1)<<BT_WEAPONSHIFT; // already have extraweapon in hand switch to the normal one if( players[secondarydisplayplayer].readyweapon==extraweapons[i-gc_weapon1] ) cmd->buttons &= ~BT_EXTRAWEAPON; break; } // mouse look stuff (mouse look is not the same as mouse aim) if (mouseaiming) { keyboard_look = false; // looking up/down if (cv_invertmouse2.value) localaiming2 -= mlook2y<<19; else localaiming2 += mlook2y<<19; } if( analogjoystickmove && cv_joystickfreelook.value ) localaiming2 += joyymove<<16; // spring back if not using keyboard neither mouselookin' if (!keyboard_look && !cv_joystickfreelook.value && !mouseaiming) localaiming2 = 0; if (gamekeydown[gamecontrolbis[gc_lookup][0]] || gamekeydown[gamecontrolbis[gc_lookup][1]]) { localaiming2 += KB_LOOKSPEED; keyboard_look = true; } else if (gamekeydown[gamecontrolbis[gc_lookdown][0]] || gamekeydown[gamecontrolbis[gc_lookdown][1]]) { localaiming2 -= KB_LOOKSPEED; keyboard_look = true; } else if (gamekeydown[gamecontrolbis[gc_centerview][0]] || gamekeydown[gamecontrolbis[gc_centerview][1]]) localaiming2 = 0; //26/02/2000: added by Hurdler: accept no mlook for network games if (!cv_allowmlook.value) localaiming2 = 0; // look up max (viewheight/2) look down min -(viewheight/2) cmd->aiming = G_ClipAimingPitch (&localaiming2);; if (!mouseaiming && cv_mousemove2.value) forward += mouse2y; if (strafe) side += mouse2x*2; else cmd->angleturn -= mouse2x*8; mouse2x = mouse2y = mlook2y = 0; if (forward > MAXPLMOVE) forward = MAXPLMOVE; else if (forward < -MAXPLMOVE) forward = -MAXPLMOVE; if (side > MAXPLMOVE) side = MAXPLMOVE; else if (side < -MAXPLMOVE) side = -MAXPLMOVE; cmd->forwardmove += forward; cmd->sidemove += side;#ifdef ABSOLUTEANGLE localangle2 += (cmd->angleturn<<16); cmd->angleturn = localangle2 >> 16;#endif if( gamemode == heretic ) { if (gamekeydown[gamecontrolbis[gc_flydown][0]] || gamekeydown[gamecontrolbis[gc_flydown][1]]) cmd->angleturn |= BT_FLYDOWN; else cmd->angleturn &= ~BT_FLYDOWN; }}static fixed_t originalforwardmove[2] = {0x19, 0x32};static fixed_t originalsidemove[2] = {0x18, 0x28};void AllowTurbo_OnChange(void){ if(!cv_allowturbo.value && netgame) { // like turbo 100 forwardmove[0] = originalforwardmove[0]; forwardmove[1] = originalforwardmove[1]; sidemove[0] = originalsidemove[0]; sidemove[1] = originalsidemove[1]; }}// turbo <10-255>//void Command_Turbo_f (void){ int scale = 200; if(!cv_allowturbo.value && netgame) { CONS_Printf("This server don't allow turbo\n"); return; } if (COM_Argc()!=2) { CONS_Printf("turbo <10-255> : set turbo"); return; } scale = atoi (COM_Argv(1)); if (scale < 10) scale = 10; if (scale > 255) scale = 255; CONS_Printf ("turbo scale: %i%%\n",scale); forwardmove[0] = originalforwardmove[0]*scale/100; forwardmove[1] = originalforwardmove[1]*scale/100; sidemove[0] = originalsidemove[0]*scale/100; sidemove[1] = originalsidemove[1]*scale/100;}//// G_DoLoadLevel//void G_DoLoadLevel (boolean resetplayer){ int i; levelstarttic = gametic; // for time calculation if (wipegamestate == GS_LEVEL) wipegamestate = -1; // force a wipe gamestate = GS_LEVEL; for (i=0 ; i<MAXPLAYERS ; i++) { if( resetplayer || (playeringame[i] && players[i].playerstate == PST_DEAD)) players[i].playerstate = PST_REBORN; memset (players[i].frags,0,sizeof(players[i].frags)); players[i].addfrags = 0; } if (!P_SetupLevel (gameepisode, gamemap, gameskill, gamemapname[0] ? gamemapname:NULL) ) { // fail so reset game stuff Command_ExitGame_f(); return; } //BOT_InitLevelBots (); displayplayer = consoleplayer; // view the guy you are playing if(!cv_splitscreen.value) secondarydisplayplayer = consoleplayer; gameaction = ga_nothing;#ifdef PARANOIA Z_CheckHeap (-2);#endif if (camera.chase) P_ResetCamera (&players[displayplayer]); // clear cmd building stuff memset (gamekeydown, 0, sizeof(gamekeydown)); joyxmove = joyymove = 0; mousex = mousey = 0; // clear hud messages remains (usually from game startup) CON_ClearHUD ();}//// G_Responder// Get info needed to make ticcmd_ts for the players.//boolean G_Responder (event_t* ev){ // allow spy mode changes even during the demo if (gamestate == GS_LEVEL && ev->type == ev_keydown && ev->data1 == KEY_F12 && (singledemo || !cv_deathmatch.value) ) { // spy mode do { displayplayer++; if (displayplayer == MAXPLAYERS) displayplayer = 0; } while (!playeringame[displayplayer] && displayplayer != consoleplayer); //added:16-01-98:change statusbar also if playingback demo if( singledemo ) ST_changeDemoView (); //added:11-04-98: tell who's the view CONS_Printf("Viewpoint : %s\n", player_names[displayplayer]); return true; } // any other key pops up menu if in demos if (gameaction == ga_nothing && !singledemo && (demoplayback || gamestate == GS_DEMOSCREEN) ) { if (ev->type == ev_keydown) { M_StartControlPanel (); return true; } return false; } if (gamestate == GS_LEVEL) {#if 0 if (devparm && ev->type == ev_keydown && ev->data1 == ';') { // added Boris : test different player colors players[consoleplayer].skincolor = (players[consoleplayer].skincolor+1) %MAXSKINCOLORS; players[consoleplayer].mo->flags |= (players[consoleplayer].skincolor)<<MF_TRANSSHIFT; G_DeathMatchSpawnPlayer (0); return true; }#endif if(!multiplayer) if( cht_Responder (ev)) return true; if (HU_Responder (ev)) return true; // chat ate the event if (ST_Responder (ev)) return true; // status window ate it if (AM_Responder (ev)) return true; // automap ate it if (G_InventoryResponder (&players[consoleplayer], gamecontrol, ev)) return true; if (cv_splitscreen.value && G_InventoryResponder (&players[secondarydisplayplayer], gamecontrolbis, ev)) return true; //added:07-02-98: map the event (key/mouse/joy) to a gamecontrol } if (gamestate == GS_FINALE) { if (F_Responder (ev)) return true; // finale ate the event } // update keys current state G_MapEventsToControls (ev); switch (ev->type) { case ev_keydown: if (ev->data1 == KEY_PAUSE) { COM_BufAddText("pause\n"); return true; } return true; case ev_keyup: return false; // always let key up events filter down case ev_mouse: return true; // eat events case ev_joystick: return true; // eat events default: break; } return false;}//// G_Ticker// Make ticcmd_ts for the players.//void G_Ticker (void){ ULONG i; int buf; ticcmd_t* cmd; // do player reborns if needed if( gamestate == GS_LEVEL ) { for (i=0 ; i<MAXPLAYERS ; i++) if (playeringame[i]) { if( players[i].playerstate == PST_REBORN ) G_DoReborn (i); if( players[i].st_inventoryTics ) players[i].st_inventoryTics--; } } // do things to change the game state while (gameaction != ga_nothing) switch (gameaction) { case ga_completed : G_DoCompleted (); break; case ga_worlddone : G_DoWorldDone (); break; case ga_nothing : break; default : I_Error("gameaction = %d\n", gameaction); } buf = gametic%BACKUPTICS; // read/write demo and check turbo cheat for (i=0 ; i<MAXPLAYERS ; i++) { // BP: i==0 for playback of demos 1.29 now new players is added with xcmd if (playeringame[i] || i==0) { cmd = &players[i].cmd; if (demoplayback) G_ReadDemoTiccmd (cmd,i); else memcpy (cmd, &netcmds[buf][i], sizeof(ticcmd_t)); if (demorecording) G_WriteDemoTiccmd (cmd,i); // check for turbo cheats if (cmd->forwardmove > TURBOTHRESHOLD && !(gametic % (32*NEWTICRATERATIO)) && ((gametic / (32*NEWTICRATERATIO))&3) == i ) { static char turbomessage[80]; sprintf (turbomessage, "%s is turbo!",player_names[i]); players[consoleplayer].message = turbomessage; } } } // do main actions switch (gamestate) { case GS_LEVEL: //IO_Color(0,255,0,0); P_Ticker (); // tic the game //IO_Color(0,0,255,0); ST_Ticker (); AM_Ticker (); HU_Ticker (); break; case GS_INTERMISSION: WI_Ticker (); break; case GS_FINALE: F_Ticker (); break; case GS_DEMOSCREEN: D_PageTicker (); break; case GS_WAITINGPLAYERS: case GS_DEDICATEDSERVER: case GS_NULL: // do nothing break; }}//// PLAYER STRUCTURE FUNCTIONS// also see P_SpawnPlayer in P_Things////// G_InitPlayer// Called at the start.// Called by the game initialization functions.///* BP:UNUSED !void G_InitPlayer (int player){ player_t* p; // set up the saved info p = &players[player]; // clear everything else to defaults G_PlayerReborn (player);}*///// G_PlayerFinishLevel// Can when a player completes a level.//void G_PlayerFinishLevel (int player){ player_t* p; int i; p = &players[player]; for(i=0; i<p->inventorySlotNum; i++) if( p->inventory[i].count>1) p->inventory[i].count = 1; if(!cv_deathmatch.value) for(i = 0; i < MAXARTECONT; i++) P_PlayerUseArtifact(p, arti_fly); memset (p->powers, 0, sizeof (p->powers)); if( gamemode == heretic ) p->weaponinfo = wpnlev1info; // cancel power weapons else p->weaponinfo = doomweaponinfo; p->cards = 0; p->mo->flags &= ~MF_SHADOW; // cancel invisibility p->extralight = 0; // cancel gun flashes p->fixedcolormap = 0; // cancel ir gogles p->damagecount = 0; // no palette changes p->bonuscount = 0; if(p->chickenTics) { p->readyweapon = p->mo->special1; // Restore weapon p->chickenTics = 0; } p->rain1 = NULL; p->rain2 = NULL;}// added 2-2-98 for hacking with dehacked patchint initial_health=100; //MAXHEALTH;int initial_bullets=50;void VerifFavoritWeapon (player_t *player);//// G_PlayerReborn
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -