Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/code/cgame/cg_consolecmds.c b/code/cgame/cg_consolecmds.c
- index 6f58e31..296ab0f 100644
- --- a/code/cgame/cg_consolecmds.c
- +++ b/code/cgame/cg_consolecmds.c
- @@ -996,7 +996,8 @@ static playerConsoleCommand_t playerCommands[] = {
- { "viewpos", CG_Viewpos_f, CMD_INGAME },
- { "weapnext", CG_NextWeapon_f, CMD_INGAME },
- { "weapprev", CG_PrevWeapon_f, CMD_INGAME },
- - { "weapon", CG_Weapon_f, CMD_INGAME }
- + { "weapon", CG_Weapon_f, CMD_INGAME },
- + { "weaponToggle", CG_WeaponToggle_f, CMD_INGAME }
- };
- static int numPlayerCommands = ARRAY_LEN( playerCommands );
- diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h
- index 1ccf7d3..54974b6 100644
- --- a/code/cgame/cg_local.h
- +++ b/code/cgame/cg_local.h
- @@ -634,6 +634,7 @@ typedef struct {
- int weaponSelectTime;
- int weaponAnimation;
- int weaponAnimationTime;
- + int weaponToggledFrom;
- // blend blobs
- float damageTime;
- @@ -1425,6 +1426,7 @@ extern vmCvar_t cg_antiLag;
- extern vmCvar_t cg_forceBitmapFonts;
- extern vmCvar_t cg_drawGrappleHook;
- extern vmCvar_t cg_drawBBox;
- +extern vmCvar_t cg_gauntletCycle;
- extern vmCvar_t ui_stretch;
- #ifdef MISSIONPACK
- extern vmCvar_t cg_redTeamName;
- @@ -1722,6 +1724,7 @@ qboolean CG_PositionRotatedEntityOnTag( refEntity_t *entity, const refEntity_t *
- void CG_NextWeapon_f( int localPlayerNum );
- void CG_PrevWeapon_f( int localPlayerNum );
- void CG_Weapon_f( int localPlayerNum );
- +void CG_WeaponToggle_f( int localPlayerNum );
- void CG_RegisterWeapon( int weaponNum );
- void CG_RegisterItemVisuals( int itemNum );
- diff --git a/code/cgame/cg_main.c b/code/cgame/cg_main.c
- index eb6430b..4a7c238 100644
- --- a/code/cgame/cg_main.c
- +++ b/code/cgame/cg_main.c
- @@ -268,6 +268,7 @@ vmCvar_t cg_antiLag;
- vmCvar_t cg_forceBitmapFonts;
- vmCvar_t cg_drawGrappleHook;
- vmCvar_t cg_drawBBox;
- +vmCvar_t cg_gauntletCycle;
- vmCvar_t cg_introPlayed;
- vmCvar_t cg_joystickDebug;
- @@ -469,6 +470,7 @@ static cvarTable_t cgameCvarTable[] = {
- { &cg_forceBitmapFonts, "cg_forceBitmapFonts", "0", CVAR_ARCHIVE | CVAR_LATCH, RANGE_BOOL },
- { &cg_drawGrappleHook, "cg_drawGrappleHook", "1", CVAR_ARCHIVE, RANGE_BOOL },
- { &cg_drawBBox, "cg_drawBBox", "0", CVAR_CHEAT, RANGE_BOOL },
- + { &cg_gauntletCycle, "cg_gauntletCycle", "0", CVAR_ARCHIVE, RANGE_BOOL },
- // { &cg_pmove_fixed, "cg_pmove_fixed", "0", CVAR_USERINFO | CVAR_ARCHIVE, RANGE_BOOL }
- { &cg_introPlayed, "com_introPlayed", "0", CVAR_ARCHIVE, RANGE_BOOL },
- diff --git a/code/cgame/cg_weapons.c b/code/cgame/cg_weapons.c
- index 29d7a2b..8ea57eb 100644
- --- a/code/cgame/cg_weapons.c
- +++ b/code/cgame/cg_weapons.c
- @@ -1573,7 +1573,7 @@ void CG_NextWeapon_f( int localPlayerNum ) {
- if ( player->weaponSelect == MAX_WEAPONS ) {
- player->weaponSelect = 0;
- }
- - if ( player->weaponSelect == WP_GAUNTLET ) {
- + if ( player->weaponSelect == WP_GAUNTLET && !cg_gauntletCycle.integer ) {
- continue;
- }
- if ( CG_WeaponSelectable( ps, player->weaponSelect ) ) {
- @@ -1615,7 +1615,7 @@ void CG_PrevWeapon_f( int localPlayerNum ) {
- if ( player->weaponSelect == -1 ) {
- player->weaponSelect = MAX_WEAPONS - 1;
- }
- - if ( player->weaponSelect == WP_GAUNTLET ) {
- + if ( player->weaponSelect == WP_GAUNTLET && !cg_gauntletCycle.integer ) {
- continue;
- }
- if ( CG_WeaponSelectable( ps, player->weaponSelect ) ) {
- @@ -1664,6 +1664,55 @@ void CG_Weapon_f( int localPlayerNum ) {
- }
- /*
- +===============
- +CG_WeaponToggle_f
- +
- +select weapon and store old weapon or if already selecting the weapon
- +switch back to old weapon
- +===============
- +*/
- +void CG_WeaponToggle_f( int localPlayerNum ) {
- + int num;
- + int weapon, oldweapon;
- + playerState_t *ps;
- + localPlayer_t *player;
- +
- + if ( cg.localPlayers[localPlayerNum].playerNum == -1 ) {
- + return;
- + }
- +
- + ps = &cg.snap->pss[localPlayerNum];
- + player = &cg.localPlayers[localPlayerNum];
- +
- + if ( ps->pm_flags & PMF_FOLLOW ) {
- + return;
- + }
- +
- + num = atoi( CG_Argv( 1 ) );
- +
- + if ( num < 1 || num > MAX_WEAPONS-1 ) {
- + return;
- + }
- +
- + player->weaponSelectTime = cg.time;
- +
- + if ( player->weaponSelect != num ) {
- + weapon = num;
- + oldweapon = player->weaponSelect;
- + } else {
- + weapon = player->weaponToggledFrom;
- + oldweapon = WP_NONE;
- + }
- +
- + if ( ! ( ps->stats[STAT_WEAPONS] & ( 1 << weapon ) ) ) {
- + return; // don't have the weapon
- + }
- +
- + player->weaponSelect = weapon;
- + player->weaponToggledFrom = oldweapon;
- +}
- +
- +/*
- ===================
- CG_OutOfAmmoChange
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement