Ticket #47: instantWeaponSwitch.patch

File instantWeaponSwitch.patch, 2.3 KB (added by ilag, 5 years ago)

Implements a new client console command instaswap to help resolve the issue.

  • code/cgame/cg_consolecmds.c

    diff --git a/code/cgame/cg_consolecmds.c b/code/cgame/cg_consolecmds.c
    index 039acfb..d84bc02 100644
    a b static consoleCommand_t commands[] = { 
    833833        { "node_savefile", CG_SaveFileAiNode_f},
    834834        { "node_openfile", CG_OpenFileAiNode_f},
    835835        { "wq_buy", CG_BuyMenu },
     836        { "instaswap", CG_InstaSwap },
    836837#endif
    837838        { "startOrbit", CG_StartOrbit_f },
    838839        //{ "camera", CG_Camera_f },
  • code/cgame/cg_local.h

    diff --git a/code/cgame/cg_local.h b/code/cgame/cg_local.h
    index a252e0e..c4a8817 100644
    a b void CG_AddPlayerWeapon( refEntity_t *parent, playerState_t *ps, centity_t *cent 
    21162116void CG_DrawWeaponSelect( void );
    21172117
    21182118void CG_OutOfAmmoChange( void );        // should this be in pmove?
     2119void CG_InstaSwap ( void );
    21192120
    21202121//
    21212122// cg_marks.c
  • code/cgame/cg_weapons.c

    diff --git a/code/cgame/cg_weapons.c b/code/cgame/cg_weapons.c
    index 6e9d199..35315c3 100644
    a b void CG_BulletTracer( vec3_t start, vec3_t end, int number, int entityNum ) { 
    43744374        VectorCopy(start, re->origin);
    43754375        re->origin[2] += 2 ;
    43764376}
     4377
     4378void CG_InstaSwap(){
     4379        playerState_t *ps = &cg.predictedPlayerState;
     4380        char weapon[MAX_STRING_TOKENS];
     4381        trap_Argv( 1, weapon , sizeof( weapon ) );
     4382       
     4383        if (!Q_stricmp(weapon,"knife")){
     4384                cg.weaponSelect=WP_KNIFE;
     4385        } else if (!Q_stricmp(weapon,"pistol1")){
     4386                int pistol;
     4387                if (pistol=BG_SearchTypeWeapon(WPS_PISTOL,ps->stats[STAT_WEAPONS],0)){
     4388                        cg.weaponSelect=pistol;
     4389                       
     4390                }
     4391        } else if (!Q_stricmp(weapon,"pistol2")){
     4392                int pistol;
     4393                if (pistol=BG_SearchTypeWeapon(WPS_PISTOL,ps->stats[STAT_WEAPONS],BG_SearchTypeWeapon(WPS_PISTOL,ps->stats[STAT_WEAPONS],0))){
     4394                        //Something tells me there should be a better way to do this.
     4395                        cg.weaponSelect=pistol;
     4396                       
     4397                }
     4398        } else if (!Q_stricmp(weapon,"akimbo")){
     4399                cg.weaponSelect=WP_AKIMBO;
     4400        } else if (!Q_stricmp(weapon,"longgun")){
     4401                int longgun;
     4402                if (longgun=BG_SearchTypeWeapon(WPS_GUN,ps->stats[STAT_WEAPONS],0)){
     4403                        cg.weaponSelect=longgun;
     4404                }
     4405        } else if (!Q_stricmp(weapon,"dynamite")){
     4406                cg.weaponSelect=WP_DYNAMITE;
     4407        } else if (!Q_stricmp(weapon,"molotov")){
     4408                cg.weaponSelect=WP_MOLOTOV;
     4409        } else {
     4410                CG_Printf("Unrecognized weapon: %s",weapon);
     4411        }
     4412}
     4413
    43774414#endif