Hey all,
so I've decided to add two new weapons in my mod and I have defined everything along with adding additional keybinds to the source code, but what is strange is that when I pick up one of the weapons, it wouldn't allow me to go there when I pressed that key.
(e.g. keys 1-6 changes weapons, 1-knife, 2-pistol, 3-machine gun, 4-chaingun, 5-silent pistol, 6-stg 44) When I pick up other weapons from 1-4 there was no problem, but when I picked up 5 or 6, I couldn't switch to them (unless I pressed the grave accent '`' key on the keyboard). I'm not sure what the problem is, because I went through my check weapon change code and didn't see any problem with it, I added the new weapon definitions in the wl_def.h header file, and also in wl_play.cpp I added the additional key binds. If there is something missing or an oversight, I would like to know since I can't track down the root of the problem.
From Wl_play.cpp
From Wl_agent.cpp
From wl_def.h
so I've decided to add two new weapons in my mod and I have defined everything along with adding additional keybinds to the source code, but what is strange is that when I pick up one of the weapons, it wouldn't allow me to go there when I pressed that key.
(e.g. keys 1-6 changes weapons, 1-knife, 2-pistol, 3-machine gun, 4-chaingun, 5-silent pistol, 6-stg 44) When I pick up other weapons from 1-4 there was no problem, but when I picked up 5 or 6, I couldn't switch to them (unless I pressed the grave accent '`' key on the keyboard). I'm not sure what the problem is, because I went through my check weapon change code and didn't see any problem with it, I added the new weapon definitions in the wl_def.h header file, and also in wl_play.cpp I added the additional key binds. If there is something missing or an oversight, I would like to know since I can't track down the root of the problem.
From Wl_play.cpp
- Code:
//
// control info
//
boolean mouseenabled, joystickenabled;
int dirscan[4] = { sc_UpArrow, sc_RightArrow, sc_DownArrow, sc_LeftArrow };
int buttonscan[NUMBUTTONS] = { sc_Control, sc_Alt, sc_LShift, sc_Space, sc_1, sc_2, sc_3, sc_4, sc_5, sc_6 }; //sc_5 and sc_6 for silent pistol and stg 44.
int buttonmouse[4] = { bt_attack, bt_strafe, bt_use, bt_nobutton };
int buttonjoy[32] = {
#ifdef _arch_dreamcast
bt_attack, bt_strafe, bt_use, bt_run, bt_esc, bt_prevweapon, bt_nobutton, bt_nextweapon,
bt_pause, bt_strafeleft, bt_straferight, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton,
#else
bt_attack, bt_strafe, bt_use, bt_run, bt_strafeleft, bt_straferight, bt_esc, bt_pause,
bt_prevweapon, bt_nextweapon, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton,
#endif
bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton,
bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton, bt_nobutton
};
From Wl_agent.cpp
- Code:
/*
======================
=
= CheckWeaponChange
=
= Keys 1-6 change weapons
=
======================
*/
void CheckWeaponChange (void)
{
int newWeapon = -1;
if (!gamestate.ammo) // must use knife with no ammo
return;
#ifdef _arch_dreamcast
int joyx, joyy;
IN_GetJoyFineDelta (&joyx, &joyy);
if(joyx < -64)
buttonstate[bt_prevweapon] = true;
else if(joyx > 64)
buttonstate[bt_nextweapon] = true;
#endif
//
if(buttonstate[bt_nextweapon] && !buttonheld[bt_nextweapon])
{
newWeapon = gamestate.weapon + 1;
if(newWeapon > gamestate.bestweapon) newWeapon = 0;
}
else if(buttonstate[bt_prevweapon] && !buttonheld[bt_prevweapon])
{
newWeapon = gamestate.weapon - 1;
if(newWeapon < 0) newWeapon = gamestate.bestweapon;
}
else
{
for(int i = wp_knife; i <= gamestate.bestweapon; i++)
{
if (buttonstate[bt_readyknife + i - wp_knife])
{
newWeapon = i;
break;
}
}
}
if(newWeapon != -1)
{
gamestate.weapon = gamestate.chosenweapon = (weapontype) newWeapon;
DrawWeapon();
}
}
From wl_def.h
- Code:
enum
{
bt_nobutton=-1,
bt_attack=0,
bt_strafe,
bt_run,
bt_use,
bt_readyknife,
bt_readypistol,
bt_readymachinegun,
bt_readychaingun,
bt_readyspistol, //ready silent pistol.
bt_readystg44, //ready stg44.
bt_nextweapon,
bt_prevweapon,
bt_esc,
bt_pause,
bt_strafeleft,
bt_straferight,
bt_moveforward,
bt_movebackward,
bt_turnleft,
bt_turnright,
NUMBUTTONS
};
#define NUMWEAPONS 6 //added more weapons
typedef enum
{
wp_knife,
wp_pistol,
wp_machinegun,
wp_chaingun,
wp_spistol,
wp_stg44
} weapontype;