Expand "Switch weapons on pickup" to three options: "Off", "All weapons", and a new one, "Fav priority". It switches to the weapon you have just picked up only if it is ranked higher in the favorite weapon hierarchy using the "-u" parameter.

Suggested at: http://forums.duke4.net/topic/5667-tiny-request/

git-svn-id: https://svn.eduke32.com/eduke32@2975 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2012-08-27 03:52:38 +00:00
parent 574f83dc76
commit a0dc378eda
2 changed files with 59 additions and 11 deletions

View file

@ -740,10 +740,33 @@ dead:
void addweapon_maybeswitch(DukePlayer_t *ps, int32_t weap)
{
if (!(ps->weaponswitch & 1))
P_AddWeaponNoSwitch(ps, weap);
else
if ((ps->weaponswitch & 1) && (ps->weaponswitch & 4))
{
int32_t snum = sprite[ps->i].yvel;
int32_t i, w, new_wchoice = -1, curr_wchoice = -1;
for (i=0; i<10 && (new_wchoice < 0 || curr_wchoice < 0); i++)
{
w = g_player[snum].wchoice[i];
if (w == 0) w = 9;
else w--;
if (w == ps->curr_weapon)
curr_wchoice = i;
if (w == weap)
new_wchoice = i;
}
if (new_wchoice < curr_wchoice)
P_AddWeapon(ps, weap);
else
P_AddWeaponNoSwitch(ps, weap);
}
else if (ps->weaponswitch & 1)
P_AddWeapon(ps, weap);
else
P_AddWeaponNoSwitch(ps, weap);
}
void addweapon_addammo_common(DukePlayer_t *ps, int32_t weap, int32_t amount)

View file

@ -960,13 +960,28 @@ void M_DisplayMenus(void)
case 5:
i = 0;
if (ud.weaponswitch & 1)
i = 1;
if (x == io)
i = 1-i;
modval(0,1,(int32_t *)&i,1,probey==5);
if ((ud.weaponswitch & 1 && !i) || (!(ud.weaponswitch & 1) && i))
{
ud.weaponswitch ^= 1;
i = 1;
if (ud.weaponswitch & 4)
i = 2;
}
l = i;
if (x == io)
i = (i == 2) ? 0 : i+1;
modval(0,2,(int32_t *)&i,1,probey==5);
if (i != l)
{
if (i > 0)
{
ud.weaponswitch |= 1;
if (i == 2)
ud.weaponswitch |= 4;
else
ud.weaponswitch &= ~4;
}
else
ud.weaponswitch &= ~(1|4);
G_UpdatePlayerFromMenu();
}
break;
@ -1073,11 +1088,21 @@ void M_DisplayMenus(void)
break;
case 5:
mgametext(d+70,yy,ud.weaponswitch&1?"On":"Off",MENUHIGHLIGHT(io),2+8+16);
{
const char *s[] = { "Off", "All weapons", "Fav priority" };
i = 0;
if (ud.weaponswitch & 1)
{
i = 1;
if (ud.weaponswitch & 4)
i = 2;
}
mgametext(d+40,yy,s[i],MENUHIGHLIGHT(io),2+8+16);
}
break;
case 6:
mgametext(d+70,yy,ud.weaponswitch&2?"On":"Off",MENUHIGHLIGHT(io),2+8+16);
mgametext(d+40,yy,ud.weaponswitch&2?"On":"Off",MENUHIGHLIGHT(io),2+8+16);
break;
default: