only allow weapon switching within keybinds

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@4743 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Lee Salzman
2009-12-23 18:47:15 +00:00
parent 4a79c898cf
commit fc81cb9834
3 changed files with 31 additions and 12 deletions
-8
View File
@@ -92,14 +92,6 @@ alias altaction [
(concatword altaction_ (curweapon))
]
alias quicknadethrow [
if (> (magcontent 6) 0) [
if (!= (curweapon) 6) [grenades]
attack
]
onrelease [ sleep 1 [ if (= (curweapon) 6) [weapon (prevweapon)] ] ]
]
loop i 8 [ alias (concatword altaction_ $i) quicknadethrow ] // Quick nade throw is default
alias altaction_4 [ zoom 1; onrelease [ zoom 0 ] ] // Sniper
alias altaction_6 [ attack ] // Grenade
+3
View File
@@ -91,6 +91,8 @@ struct keym
~keym() { DELETEA(name); DELETEA(action); }
};
extern keym *keypressed;
extern bool bindkey(keym *km, const char *action);
extern keym *findbinda(const char *action);
extern bool bindc(int code, const char *action);
@@ -608,6 +610,7 @@ extern void fixcamerarange(physent *cam = camera1);
extern void updatecrouch(playerent *p, bool on);
extern bool objcollide(physent *d, const vec &objpos, float objrad, float objheight);
extern bool collide(physent *d, bool spawn = false, float drop = 0, float rise = 0);
extern void attack(bool on);
// sound
/*
+28 -4
View File
@@ -42,9 +42,9 @@ void selectweapon(weapon *w)
}
}
void selectweaponi(int w)
void requestweapon(int w)
{
if(player1->state == CS_ALIVE && w >= 0 && w < NUMGUNS)
if(keypressed && player1->state == CS_ALIVE && w >= 0 && w < NUMGUNS)
{
selectweapon(player1->weapons[w]);
}
@@ -52,7 +52,7 @@ void selectweaponi(int w)
void shiftweapon(int s)
{
if(player1->state == CS_ALIVE)
if(keypressed && player1->state == CS_ALIVE)
{
if(!player1->weaponsel->deselectable()) return;
@@ -95,6 +95,28 @@ void shiftweapon(int s)
else if(player1->isspectating()) updatefollowplayer(s);
}
void quicknaderelease()
{
if(player1->state == CS_ALIVE && player1->weaponsel->type == GUN_GRENADE)
{
attack(false);
selectweapon(player1->prevweaponsel);
}
}
void quicknadethrow()
{
if(keypressed && player1->state == CS_ALIVE)
{
if(player1->weapons[GUN_GRENADE]->mag > 0)
{
if(player1->weaponsel->type != GUN_GRENADE) selectweapon(player1->weapons[GUN_GRENADE]);
attack(true);
}
addreleaseaction("sleep 1 [ quicknaderelease ]");
}
}
int currentprimary() { return player1->primweap->type; }
int prevweapon() { return player1->prevweaponsel->type; }
int curweapon() { return player1->weaponsel->type; }
@@ -102,8 +124,10 @@ int curweapon() { return player1->weaponsel->type; }
int magcontent(int w) { if(w >= 0 && w < NUMGUNS) return player1->weapons[w]->mag; else return -1;}
int magreserve(int w) { if(w >= 0 && w < NUMGUNS) return player1->weapons[w]->ammo; else return -1;}
COMMANDN(weapon, selectweaponi, ARG_1INT);
COMMANDN(weapon, requestweapon, ARG_1INT);
COMMAND(shiftweapon, ARG_1INT);
COMMAND(quicknadethrow, ARG_NONE);
COMMAND(quicknaderelease, ARG_NONE);
COMMAND(currentprimary, ARG_IVAL);
COMMAND(prevweapon, ARG_IVAL);
COMMAND(curweapon, ARG_IVAL);