no pistol when akimbo is present

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@2030 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
driAn
2008-05-18 10:41:29 +00:00
parent 5fed58050b
commit 3b68f096fc
6 changed files with 20 additions and 15 deletions
+1 -1
View File
@@ -393,7 +393,7 @@ bool tryrespawn()
player1->attacking = false;
if(m_arena) { conoutf("waiting for new round to start..."); return false; }
respawnself();
weaponswitch(player1->primweap);
player1->weaponswitch(player1->primweap);
player1->lastaction -= weapon::weaponchangetime/2;
return true;
}
+9
View File
@@ -405,6 +405,15 @@ struct playerent : dynent, playerstate
void setprimary(int w) { primweap = weapons[(primary = w)]; }
void setnextprimary(int w) { nextprimweap = weapons[(nextprimary = w)]; }
bool isspectating() { return state==CS_SPECTATE || (state==CS_DEAD && spectatemode > SM_NONE); }
void weaponswitch(weapon *w)
{
if(!w) return;
extern int lastmillis;
weaponsel->ondeselecting();
weaponchanging = lastmillis;
nextweaponsel = w;
w->onselecting();
}
};
-1
View File
@@ -522,7 +522,6 @@ extern void addgib(playerent *d);
extern playerent *playerincrosshair();
extern int magsize(int gun);
extern void checkweaponswitch();
extern void weaponswitch(weapon *w);
extern void setscope(bool activate);
extern bool intersect(dynent *d, const vec &from, const vec &to, vec *end = NULL);
extern bool intersect(entity *e, const vec &from, const vec &to, vec *end = NULL);
+1 -1
View File
@@ -570,7 +570,7 @@ void setmusicvol()
extern int musicvol;
gamemusic.setvolume(musicvol/255.0f);
}
VARFP(musicvol, 0, 128, 255, setmusicvol());
VARFP(musicvol, 0, 64, 255, setmusicvol());
char *musicdonecmd = NULL;
+8 -12
View File
@@ -27,19 +27,10 @@ void checkweaponswitch()
else if(timeprogress>weapon::weaponchangetime/2) player1->weaponsel = player1->nextweaponsel;
}
void weaponswitch(weapon *w)
{
if(!w) return;
player1->weaponsel->ondeselecting();
player1->weaponchanging = lastmillis;
player1->nextweaponsel = w;
w->onselecting();
}
void selectweapon(weapon *w)
{
if(w && w->selectable() && player1->weaponsel->deselectable())
weaponswitch(w);
player1->weaponswitch(w);
}
void selectweaponi(int w)
@@ -896,6 +887,11 @@ bool assaultrifle::selectable() { return weapon::selectable() && !m_noprimary &&
pistol::pistol(playerent *owner) : gun(owner, GUN_PISTOL) {}
bool pistol::selectable() { return weapon::selectable() && !m_nopistol; }
void pistol::onselecting()
{
// switch immediately to akimbo if present
if(owner->akimbo) owner->weaponswitch(owner->weapons[GUN_AKIMBO]);
}
// akimbo
@@ -921,7 +917,7 @@ void akimbo::onammopicked()
akimbomillis = lastmillis + 30000;
if(owner==player1)
{
if(owner->weaponsel->type!=GUN_SNIPER && owner->weaponsel->type!=GUN_GRENADE) weaponswitch(this);
if(owner->weaponsel->type!=GUN_SNIPER && owner->weaponsel->type!=GUN_GRENADE) owner->weaponswitch(this);
addmsg(SV_AKIMBO, "ri", lastmillis);
}
}
@@ -1017,7 +1013,7 @@ void checkakimbo()
// transfer ammo to pistol
p.mag = min((int)p.info.magsize, max(a.mag, p.mag));
p.ammo = max(p.ammo, p.ammo);
if(player1->weaponsel->type==GUN_AKIMBO) weaponswitch(&p);
if(player1->weaponsel->type==GUN_AKIMBO) player1->weaponswitch(&p);
playsoundc(S_AKIMBOOUT);
}
}
+1
View File
@@ -130,6 +130,7 @@ struct pistol : gun
{
pistol(playerent *owner);
bool selectable();
void onselecting();
};