📄 g_game.c
字号:
continue; // skip plasma-bfg in sharware if (gamemode==shareware && (w==wp_plasma || w==wp_bfg)) continue; if ( player->weaponowned[w] && player->ammo[player->weaponinfo[w].ammo] >= player->weaponinfo[w].ammopershoot ) { if(w==wp_chainsaw) return (BT_CHANGE | BT_EXTRAWEAPON | (wp_fist<<BT_WEAPONSHIFT)); if(w==wp_supershotgun) return (BT_CHANGE | BT_EXTRAWEAPON | (wp_shotgun<<BT_WEAPONSHIFT)); return (BT_CHANGE | (w<<BT_WEAPONSHIFT)); } } return 0;}boolean G_InventoryResponder(player_t *ply, int gc[num_gamecontrols][2], event_t *ev){ if( !inventory ) return false; switch (ev->type) { case ev_keydown : if( ev->data1 == gc[gc_invprev][0] || ev->data1 == gc[gc_invprev][1] ) { if( ply->st_inventoryTics ) { ply->inv_ptr--; if( ply->inv_ptr < 0 ) ply->inv_ptr = 0; else { ply->st_curpos--; if( ply->st_curpos < 0 ) ply->st_curpos = 0; } } ply->st_inventoryTics = 5*TICRATE; return true; } else if( ev->data1 == gc[gc_invnext][0] || ev->data1 == gc[gc_invnext][1] ) { if( ply->st_inventoryTics ) { ply->inv_ptr++; if( ply->inv_ptr >= ply->inventorySlotNum ) { ply->inv_ptr--; if( ply->inv_ptr < 0) ply->inv_ptr = 0; } else { ply->st_curpos++; if( ply->st_curpos > 6 ) ply->st_curpos = 6; } } ply->st_inventoryTics = 5*TICRATE; return true; } else if( ev->data1 == gc[gc_invuse ][0] || ev->data1 == gc[gc_invuse ][1] ) return true; break; case ev_keyup: if( ev->data1 == gc[gc_invuse ][0] || ev->data1 == gc[gc_invuse ][1] ) { if( ply->st_inventoryTics ) ply->st_inventoryTics = 0; else if( ply->inventory[ply->inv_ptr].count>0 ) { if( ply == &players[consoleplayer] ) SendNetXCmd(XD_USEARTEFACT, &ply->inventory[ply->inv_ptr].type, 1); else SendNetXCmd2(XD_USEARTEFACT, &ply->inventory[ply->inv_ptr].type, 1); } } else if( ev->data1 == gc[gc_invprev][0] || ev->data1 == gc[gc_invprev][1] || ev->data1 == gc[gc_invnext][0] || ev->data1 == gc[gc_invnext][1] ) return true; break; default: break; // shut up compiler } return false;}void G_BuildTiccmd (ticcmd_t* cmd, int realtics){ int i; boolean strafe; int speed; int tspeed; int forward; int side; ticcmd_t* base; //added:14-02-98: these ones used for multiple conditions boolean turnleft,turnright,mouseaiming,analogjoystickmove,gamepadjoystickmove; static int turnheld; // for accelerative turning static boolean keyboard_look; // true if lookup/down using keyboard base = I_BaseTiccmd (); // empty, or external driver memcpy (cmd,base,sizeof(*cmd)); // a little clumsy, but then the g_input.c became a lot simpler! strafe = gamekeydown[gamecontrol[gc_strafe][0]] || gamekeydown[gamecontrol[gc_strafe][1]]; speed = (gamekeydown[gamecontrol[gc_speed][0]] || gamekeydown[gamecontrol[gc_speed][1]]) ^ cv_autorun.value; turnright = gamekeydown[gamecontrol[gc_turnright][0]] ||gamekeydown[gamecontrol[gc_turnright][1]]; turnleft = gamekeydown[gamecontrol[gc_turnleft][0]] ||gamekeydown[gamecontrol[gc_turnleft][1]]; mouseaiming = (gamekeydown[gamecontrol[gc_mouseaiming][0]] ||gamekeydown[gamecontrol[gc_mouseaiming][1]]) ^ cv_alwaysfreelook.value; analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle && !cv_splitscreen.value; gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle && !cv_splitscreen.value; if( gamepadjoystickmove ) { turnright = turnright || (joyxmove > 0); turnleft = turnleft || (joyxmove < 0); } forward = side = 0; // use two stage accelerative turning // on the keyboard and joystick if (turnleft || turnright) turnheld += realtics; else turnheld = 0; if (turnheld < SLOWTURNTICS) tspeed = 2; // slow turn else tspeed = speed; // let movement keys cancel each other out if (strafe) { if (turnright) side += sidemove[speed]; if (turnleft) side -= sidemove[speed]; if (analogjoystickmove) { //faB: JOYAXISRANGE is supposed to be 1023 ( divide by 1024 ) side += ( (joyxmove * sidemove[1]) >> 10 ); } } else { if ( turnright ) cmd->angleturn -= angleturn[tspeed]; else if ( turnleft ) cmd->angleturn += angleturn[tspeed]; if ( joyxmove && analogjoystickmove) { //faB: JOYAXISRANGE should be 1023 ( divide by 1024 ) cmd->angleturn -= ( (joyxmove * angleturn[1]) >> 10 ); // ANALOG! //CONS_Printf ("joyxmove %d angleturn %d\n", joyxmove, cmd->angleturn); } } //added:07-02-98: forward with key or button if (gamekeydown[gamecontrol[gc_forward][0]] || gamekeydown[gamecontrol[gc_forward][1]] || ( joyymove < 0 && gamepadjoystickmove) ) { forward += forwardmove[speed]; } if (gamekeydown[gamecontrol[gc_backward][0]] || gamekeydown[gamecontrol[gc_backward][1]] || ( joyymove > 0 && gamepadjoystickmove) ) { forward -= forwardmove[speed]; } if ( joyymove && analogjoystickmove ) forward -= ( (joyymove * forwardmove[1]) >> 10 ); // ANALOG! //added:07-02-98: some people strafe left & right with mouse buttons if (gamekeydown[gamecontrol[gc_straferight][0]] || gamekeydown[gamecontrol[gc_straferight][1]]) side += sidemove[speed]; if (gamekeydown[gamecontrol[gc_strafeleft][0]] || gamekeydown[gamecontrol[gc_strafeleft][1]]) side -= sidemove[speed]; //added:07-02-98: fire with any button/key if (gamekeydown[gamecontrol[gc_fire][0]] || gamekeydown[gamecontrol[gc_fire][1]]) cmd->buttons |= BT_ATTACK; //added:07-02-98: use with any button/key if (gamekeydown[gamecontrol[gc_use][0]] || gamekeydown[gamecontrol[gc_use][1]]) cmd->buttons |= BT_USE; //added:22-02-98: jump button if (cv_allowjump.value && (gamekeydown[gamecontrol[gc_jump][0]] || gamekeydown[gamecontrol[gc_jump][1]])) cmd->buttons |= BT_JUMP; //added:07-02-98: any key / button can trigger a weapon // chainsaw overrides if (gamekeydown[gamecontrol[gc_nextweapon][0]] || gamekeydown[gamecontrol[gc_nextweapon][1]]) cmd->buttons |= NextWeapon(&players[consoleplayer],1); else if (gamekeydown[gamecontrol[gc_prevweapon][0]] || gamekeydown[gamecontrol[gc_prevweapon][1]]) cmd->buttons |= NextWeapon(&players[consoleplayer],-1); else for (i=gc_weapon1; i<gc_weapon1+NUMWEAPONS-1; i++) if (gamekeydown[gamecontrol[i][0]] || gamekeydown[gamecontrol[i][1]]) { 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[consoleplayer].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_invertmouse.value) localaiming -= mlooky<<19; else localaiming += mlooky<<19; } if (cv_usejoystick.value && analogjoystickmove) localaiming += joyymove<<16; // spring back if not using keyboard neither mouselookin' if (!keyboard_look && !cv_joystickfreelook.value && !mouseaiming) localaiming = 0; if (gamekeydown[gamecontrol[gc_lookup][0]] || gamekeydown[gamecontrol[gc_lookup][1]]) { localaiming += KB_LOOKSPEED; keyboard_look = true; } else if (gamekeydown[gamecontrol[gc_lookdown][0]] || gamekeydown[gamecontrol[gc_lookdown][1]]) { localaiming -= KB_LOOKSPEED; keyboard_look = true; } else if (gamekeydown[gamecontrol[gc_centerview][0]] || gamekeydown[gamecontrol[gc_centerview][1]]) localaiming = 0; //26/02/2000: added by Hurdler: accept no mlook for network games if (!cv_allowmlook.value) localaiming = 0; cmd->aiming = G_ClipAimingPitch (&localaiming); if (!mouseaiming && cv_mousemove.value) forward += mousey; if (strafe) side += mousex*2; else cmd->angleturn -= mousex*8; mousex = mousey = mlooky = 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 localangle += (cmd->angleturn<<16); cmd->angleturn = localangle >> 16;#endif if( gamemode == heretic ) { if (gamekeydown[gamecontrol[gc_flydown][0]] || gamekeydown[gamecontrol[gc_flydown][1]]) cmd->angleturn |= BT_FLYDOWN; else cmd->angleturn &= ~BT_FLYDOWN; }}// like the g_buildticcmd 1 but using mouse2, gamcontrolbis, ...void G_BuildTiccmd2 (ticcmd_t* cmd, int realtics){ int i; boolean strafe; int speed; int tspeed; int forward; int side; ticcmd_t* base; //added:14-02-98: these ones used for multiple conditions boolean turnleft,turnright,mouseaiming,analogjoystickmove,gamepadjoystickmove; static int turnheld; // for accelerative turning static boolean keyboard_look; // true if lookup/down using keyboard base = I_BaseTiccmd (); // empty, or external driver memcpy (cmd,base,sizeof(*cmd)); // a little clumsy, but then the g_input.c became a lot simpler! strafe = gamekeydown[gamecontrolbis[gc_strafe][0]] || gamekeydown[gamecontrolbis[gc_strafe][1]]; speed = (gamekeydown[gamecontrolbis[gc_speed][0]] || gamekeydown[gamecontrolbis[gc_speed][1]]) ^ cv_autorun2.value; turnright = gamekeydown[gamecontrolbis[gc_turnright][0]] ||gamekeydown[gamecontrolbis[gc_turnright][1]]; turnleft = gamekeydown[gamecontrolbis[gc_turnleft][0]] ||gamekeydown[gamecontrolbis[gc_turnleft][1]]; mouseaiming = (gamekeydown[gamecontrolbis[gc_mouseaiming][0]] ||gamekeydown[gamecontrolbis[gc_mouseaiming][1]]) ^ cv_alwaysfreelook2.value; analogjoystickmove = cv_usejoystick.value && !Joystick.bGamepadStyle; gamepadjoystickmove = cv_usejoystick.value && Joystick.bGamepadStyle; if(gamepadjoystickmove) { turnright = turnright || joyxmove > 0; turnleft = turnleft || joyxmove < 0; } forward = side = 0; // use two stage accelerative turning // on the keyboard and joystick if (turnleft || turnright) turnheld += realtics; else turnheld = 0; if (turnheld < SLOWTURNTICS) tspeed = 2; // slow turn else tspeed = speed; // let movement keys cancel each other out if (strafe) { if (turnright) side += sidemove[speed]; if (turnleft) side -= sidemove[speed]; if (analogjoystickmove) { //faB: JOYAXISRANGE is supposed to be 1023 ( divide by 1024 ) side += ( (joyxmove * sidemove[1]) >> 10 ); } } else { if (turnright ) cmd->angleturn -= angleturn[tspeed]; if (turnleft ) cmd->angleturn += angleturn[tspeed]; if ( joyxmove && analogjoystickmove ) { //faB: JOYAXISRANGE should be 1023 ( divide by 1024 ) cmd->angleturn -= ( (joyxmove * angleturn[1]) >> 10 ); // ANALOG! //CONS_Printf ("joyxmove %d angleturn %d\n", joyxmove, cmd->angleturn); } } //added:07-02-98: forward with key or button if (gamekeydown[gamecontrolbis[gc_forward][0]] || gamekeydown[gamecontrolbis[gc_forward][1]] || (joyymove < 0 && gamepadjoystickmove)) { forward += forwardmove[speed]; } if (gamekeydown[gamecontrolbis[gc_backward][0]] || gamekeydown[gamecontrolbis[gc_backward][1]] || (joyymove > 0 && gamepadjoystickmove)) { forward -= forwardmove[speed]; } if ( joyymove && analogjoystickmove && !cv_joystickfreelook.value) forward -= ( (joyymove * forwardmove[1]) >> 10 ); // ANALOG! //added:07-02-98: some people strafe left & right with mouse buttons if (gamekeydown[gamecontrolbis[gc_straferight][0]] || gamekeydown[gamecontrolbis[gc_straferight][1]]) side += sidemove[speed]; if (gamekeydown[gamecontrolbis[gc_strafeleft][0]] || gamekeydown[gamecontrolbis[gc_strafeleft][1]]) side -= sidemove[speed]; //added:07-02-98: fire with any button/key if (gamekeydown[gamecontrolbis[gc_fire][0]] || gamekeydown[gamecontrolbis[gc_fire][1]]) cmd->buttons |= BT_ATTACK; //added:07-02-98: use with any button/key if (gamekeydown[gamecontrolbis[gc_use][0]] || gamekeydown[gamecontrolbis[gc_use][1]]) cmd->buttons |= BT_USE; //added:22-02-98: jump button if (cv_allowjump.value && (gamekeydown[gamecontrolbis[gc_jump][0]] || gamekeydown[gamecontrolbis[gc_jump][1]])) cmd->buttons |= BT_JUMP; //added:07-02-98: any key / button can trigger a weapon // chainsaw overrides if (gamekeydown[gamecontrolbis[gc_nextweapon][0]] || gamekeydown[gamecontrolbis[gc_nextweapon][1]]) cmd->buttons |= NextWeapon(&players[secondarydisplayplayer],1); else if (gamekeydown[gamecontrolbis[gc_prevweapon][0]] || gamekeydown[gamecontrolbis[gc_prevweapon][1]]) cmd->buttons |= NextWeapon(&players[secondarydisplayplayer],-1); else for (i=gc_weapon1; i<gc_weapon1+NUMWEAPONS-1; i++) if (gamekeydown[gamecontrolbis[i][0]] || gamekeydown[gamecontrolbis[i][1]]) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -