mirror of
https://github.com/DrBeef/Raze.git
synced 2025-03-11 03:31:43 +00:00
- implemented cl_weaponswitch for Duke.
This commit is contained in:
parent
0033826544
commit
ac4be79e96
13 changed files with 63 additions and 49 deletions
|
@ -102,8 +102,7 @@ CUSTOM_CVARD(Int, cl_weaponswitch, 3, CVAR_ARCHIVE|CVAR_USERINFO, "enable/disabl
|
|||
{
|
||||
if (self < 0) self = 0;
|
||||
if (self > 1 && isSWALL()) self = 1;
|
||||
if (self > 3 && isBlood()) self = 3;
|
||||
if (self > 7) self = 7;
|
||||
if (self > 3) self = 3;
|
||||
}
|
||||
|
||||
// Sound
|
||||
|
|
|
@ -106,18 +106,24 @@ EXTERN_CVAR(Int, m_ffire)
|
|||
EXTERN_CVAR(Int, m_noexits)
|
||||
EXTERN_CVAR(Int, playercolor)
|
||||
|
||||
inline const char* PlayerName(int pindex)
|
||||
inline const char* PlayerName(size_t pindex)
|
||||
{
|
||||
// Todo: proper implementation of user CVARs.
|
||||
return playername;
|
||||
}
|
||||
|
||||
inline int Autoaim(int player)
|
||||
inline int Autoaim(size_t player)
|
||||
{
|
||||
// Todo: proper implementation of user CVARs.
|
||||
return cl_autoaim;
|
||||
}
|
||||
|
||||
inline int WeaponSwitch(size_t player)
|
||||
{
|
||||
// Todo: proper implementation of user CVARs.
|
||||
return cl_weaponswitch;
|
||||
}
|
||||
|
||||
extern bool gNoAutoLoad;
|
||||
extern int hud_statusbarrange; // will be set by the game's configuration setup.
|
||||
bool G_CheckAutorun(bool button);
|
||||
|
|
|
@ -2062,8 +2062,9 @@ static const uint8_t gWeaponUpgrade[][13] = {
|
|||
|
||||
int WeaponUpgrade(PLAYER* pPlayer, int newWeapon)
|
||||
{
|
||||
int weaponswitch = WeaponSwitch(pPlayer - gPlayer);
|
||||
int weapon = pPlayer->curWeapon;
|
||||
if (!checkLitSprayOrTNT(pPlayer) && (cl_weaponswitch & 1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (cl_weaponswitch & 2)))
|
||||
if (!checkLitSprayOrTNT(pPlayer) && (weaponswitch & 1) && (gWeaponUpgrade[pPlayer->curWeapon][newWeapon] || (weaponswitch & 2)))
|
||||
weapon = newWeapon;
|
||||
return weapon;
|
||||
}
|
||||
|
|
|
@ -147,14 +147,17 @@ void checkavailweapon(player_struct* player)
|
|||
if (weap == player->curr_weapon) return;
|
||||
else if (player->gotweapon[weap] && player->ammo_amount[weap] > 0)
|
||||
{
|
||||
fi.addweapon(player, weap);
|
||||
fi.addweapon(player, weap, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
weap = player->curr_weapon;
|
||||
if (player->gotweapon[weap] && player->ammo_amount[weap] > 0)
|
||||
return;
|
||||
if (player->gotweapon[weap])
|
||||
{
|
||||
if (player->ammo_amount[weap] > 0 || (WeaponSwitch(player - ps) & 2) == 0)
|
||||
return;
|
||||
}
|
||||
|
||||
snum = player->GetPlayerNum();
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ void check_fta_sounds_d(DDukeActor* actor)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void addweapon_d(player_struct *p, int weapon)
|
||||
void addweapon_d(player_struct *p, int weapon, bool wswitch)
|
||||
{
|
||||
if ( p->gotweapon[weapon] == 0 )
|
||||
{
|
||||
|
@ -169,6 +169,7 @@ void addweapon_d(player_struct *p, int weapon)
|
|||
if (weapon == SHRINKER_WEAPON)
|
||||
p->gotweapon[GROW_WEAPON] = true;
|
||||
}
|
||||
if (!wswitch) return;
|
||||
|
||||
p->random_club_frame = 0;
|
||||
|
||||
|
@ -2717,7 +2718,7 @@ DETONATEB:
|
|||
S_PlayActorSound(DUKE_GET, ps[p].GetActor());
|
||||
|
||||
if (ps[p].gotweapon[HANDBOMB_WEAPON] == 0 || Owner == ps[p].GetActor())
|
||||
fi.addweapon(&ps[p], HANDBOMB_WEAPON);
|
||||
fi.addweapon(&ps[p], HANDBOMB_WEAPON, true);
|
||||
|
||||
if (!Owner || Owner->spr.picnum != APLAYER)
|
||||
{
|
||||
|
|
|
@ -114,7 +114,7 @@ void check_fta_sounds_r(DDukeActor* actor)
|
|||
//
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
void addweapon_r(player_struct* p, int weapon)
|
||||
void addweapon_r(player_struct* p, int weapon, bool wswitch)
|
||||
{
|
||||
int cw = p->curr_weapon;
|
||||
if (p->OnMotorcycle || p->OnBoat)
|
||||
|
@ -167,6 +167,8 @@ void addweapon_r(player_struct* p, int weapon)
|
|||
else
|
||||
cw = weapon;
|
||||
|
||||
if (!wswitch) return;
|
||||
|
||||
if (weapon == DYNAMITE_WEAPON)
|
||||
p->last_weapon = -1;
|
||||
|
||||
|
@ -2481,7 +2483,7 @@ DETONATEB:
|
|||
S_PlayActorSound(DUKE_GET, ps[p].GetActor());
|
||||
|
||||
if (ps[p].gotweapon[DYNAMITE_WEAPON] == 0 || Owner == ps[p].GetActor())
|
||||
fi.addweapon(&ps[p], DYNAMITE_WEAPON);
|
||||
fi.addweapon(&ps[p], DYNAMITE_WEAPON, true);
|
||||
|
||||
if (!Owner || Owner->spr.picnum != APLAYER)
|
||||
{
|
||||
|
|
|
@ -60,8 +60,8 @@ bool ceilingspace_d(sectortype*);
|
|||
bool ceilingspace_r(sectortype*);
|
||||
bool floorspace_d(sectortype*);
|
||||
bool floorspace_r(sectortype*);
|
||||
void addweapon_d(player_struct* p, int weapon);
|
||||
void addweapon_r(player_struct* p, int weapon);
|
||||
void addweapon_d(player_struct* p, int weapon, bool wswitch);
|
||||
void addweapon_r(player_struct* p, int weapon, bool wswitch);
|
||||
void hitradius_d(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
|
||||
void hitradius_r(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
|
||||
void lotsofmoney_d(DDukeActor* s, int n);
|
||||
|
|
|
@ -84,7 +84,7 @@ struct Dispatcher
|
|||
|
||||
bool (*ceilingspace)(sectortype* sectp);
|
||||
bool (*floorspace)(sectortype* sectp);
|
||||
void (*addweapon)(player_struct *p, int weapon);
|
||||
void (*addweapon)(player_struct *p, int weapon, bool wswitch);
|
||||
void (*hitradius)(DDukeActor* i, int r, int hp1, int hp2, int hp3, int hp4);
|
||||
void (*lotsofmoney)(DDukeActor *s, int n);
|
||||
void (*lotsofmail)(DDukeActor *s, int n);
|
||||
|
|
|
@ -1862,8 +1862,8 @@ int ParseState::parse(void)
|
|||
}
|
||||
addammo( *insptr, &ps[g_p], *(insptr+1) );
|
||||
if(ps[g_p].curr_weapon == KNEE_WEAPON)
|
||||
if( ps[g_p].gotweapon[*insptr] )
|
||||
fi.addweapon( &ps[g_p], *insptr );
|
||||
if( ps[g_p].gotweapon[*insptr] && (WeaponSwitch(g_p) & 1))
|
||||
fi.addweapon(&ps[g_p], *insptr, true);
|
||||
insptr += 2;
|
||||
break;
|
||||
case concmd_money:
|
||||
|
@ -1911,7 +1911,7 @@ int ParseState::parse(void)
|
|||
break;
|
||||
case concmd_addweapon:
|
||||
insptr++;
|
||||
if( ps[g_p].gotweapon[*insptr] == 0 ) fi.addweapon( &ps[g_p], *insptr );
|
||||
if( ps[g_p].gotweapon[*insptr] == 0 ) fi.addweapon( &ps[g_p], *insptr, !!(WeaponSwitch(g_p) & 1));
|
||||
else if( ps[g_p].ammo_amount[*insptr] >= gs.max_ammo_amount[*insptr] )
|
||||
{
|
||||
killit_flag = 2;
|
||||
|
@ -1919,8 +1919,8 @@ int ParseState::parse(void)
|
|||
}
|
||||
addammo( *insptr, &ps[g_p], *(insptr+1) );
|
||||
if(ps[g_p].curr_weapon == KNEE_WEAPON)
|
||||
if( ps[g_p].gotweapon[*insptr] )
|
||||
fi.addweapon( &ps[g_p], *insptr );
|
||||
if( ps[g_p].gotweapon[*insptr] && (WeaponSwitch(g_p) & 1))
|
||||
fi.addweapon(&ps[g_p], *insptr, true);
|
||||
insptr+=2;
|
||||
break;
|
||||
case concmd_debug:
|
||||
|
|
|
@ -1297,7 +1297,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
|
|||
i++; // absolutely no weapons, so use foot
|
||||
if (i == 10)
|
||||
{
|
||||
fi.addweapon(p, KNEE_WEAPON);
|
||||
fi.addweapon(p, KNEE_WEAPON, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1381,7 +1381,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
|
|||
else if (j >= MIN_WEAPON && p->gotweapon[j] && p->curr_weapon != j) switch (j)
|
||||
{
|
||||
case KNEE_WEAPON:
|
||||
fi.addweapon(p, KNEE_WEAPON);
|
||||
fi.addweapon(p, KNEE_WEAPON, true);
|
||||
break;
|
||||
case PISTOL_WEAPON:
|
||||
case SHOTGUN_WEAPON:
|
||||
|
@ -1399,7 +1399,7 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
|
|||
p->last_full_weapon = p->curr_weapon;
|
||||
}
|
||||
|
||||
fi.addweapon(p, j);
|
||||
fi.addweapon(p, j, true);
|
||||
break;
|
||||
case HANDREMOTE_WEAPON:
|
||||
if (k >= 0) // Found in list of [1]'s
|
||||
|
@ -1411,11 +1411,11 @@ void selectweapon_d(int snum, int weap) // playernum, weaponnum
|
|||
break;
|
||||
case HANDBOMB_WEAPON:
|
||||
if (p->ammo_amount[HANDBOMB_WEAPON] > 0 && p->gotweapon[HANDBOMB_WEAPON])
|
||||
fi.addweapon(p, HANDBOMB_WEAPON);
|
||||
fi.addweapon(p, HANDBOMB_WEAPON, true);
|
||||
break;
|
||||
case TRIPBOMB_WEAPON:
|
||||
if (p->ammo_amount[TRIPBOMB_WEAPON] > 0 && p->gotweapon[TRIPBOMB_WEAPON])
|
||||
fi.addweapon(p, TRIPBOMB_WEAPON);
|
||||
fi.addweapon(p, TRIPBOMB_WEAPON, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2265,7 +2265,7 @@ static void operateweapon(int snum, ESyncBits actions)
|
|||
int weapon = isNam() ? TRIPBOMB_WEAPON : HANDBOMB_WEAPON;
|
||||
|
||||
if (p->ammo_amount[weapon] > 0)
|
||||
fi.addweapon(p, weapon);
|
||||
fi.addweapon(p, weapon, true);
|
||||
else
|
||||
checkavailweapon(p);
|
||||
}
|
||||
|
@ -3139,13 +3139,13 @@ HORIZONLY:
|
|||
if (p->show_empty_weapon > 0)
|
||||
{
|
||||
p->show_empty_weapon--;
|
||||
if (p->show_empty_weapon == 0)
|
||||
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - ps) & 2))
|
||||
{
|
||||
if (p->last_full_weapon == GROW_WEAPON)
|
||||
p->subweapon |= (1 << GROW_WEAPON);
|
||||
else if (p->last_full_weapon == SHRINKER_WEAPON)
|
||||
p->subweapon &= ~(1 << GROW_WEAPON);
|
||||
fi.addweapon(p, p->last_full_weapon);
|
||||
fi.addweapon(p, p->last_full_weapon, true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1030,7 +1030,7 @@ void selectweapon_r(int snum, int weap)
|
|||
i++;
|
||||
if (i == 10)
|
||||
{
|
||||
fi.addweapon(p, KNEE_WEAPON);
|
||||
fi.addweapon(p, KNEE_WEAPON, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1116,13 +1116,13 @@ void selectweapon_r(int snum, int weap)
|
|||
else if (j >= MIN_WEAPON && p->gotweapon[j] && p->curr_weapon != j) switch (j)
|
||||
{
|
||||
case KNEE_WEAPON:
|
||||
fi.addweapon(p, j);
|
||||
fi.addweapon(p, j, true);
|
||||
break;
|
||||
case SLINGBLADE_WEAPON:
|
||||
if (isRRRA())
|
||||
{
|
||||
S_PlayActorSound(496, ps[screenpeek].GetActor());
|
||||
fi.addweapon(p, j);
|
||||
fi.addweapon(p, j, true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1133,7 +1133,7 @@ void selectweapon_r(int snum, int weap)
|
|||
p->last_full_weapon = p->curr_weapon;
|
||||
p->show_empty_weapon = 32;
|
||||
}
|
||||
fi.addweapon(p, PISTOL_WEAPON);
|
||||
fi.addweapon(p, PISTOL_WEAPON, true);
|
||||
break;
|
||||
|
||||
case CHICKEN_WEAPON:
|
||||
|
@ -1153,7 +1153,7 @@ void selectweapon_r(int snum, int weap)
|
|||
p->last_full_weapon = p->curr_weapon;
|
||||
p->show_empty_weapon = 32;
|
||||
}
|
||||
fi.addweapon(p, j);
|
||||
fi.addweapon(p, j, true);
|
||||
break;
|
||||
|
||||
case MOTORCYCLE_WEAPON:
|
||||
|
@ -1164,7 +1164,7 @@ void selectweapon_r(int snum, int weap)
|
|||
{
|
||||
p->show_empty_weapon = 32;
|
||||
}
|
||||
fi.addweapon(p, j);
|
||||
fi.addweapon(p, j, true);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -1178,7 +1178,7 @@ void selectweapon_r(int snum, int weap)
|
|||
break;
|
||||
case DYNAMITE_WEAPON:
|
||||
if (p->ammo_amount[DYNAMITE_WEAPON] > 0 && p->gotweapon[DYNAMITE_WEAPON])
|
||||
fi.addweapon(p, DYNAMITE_WEAPON);
|
||||
fi.addweapon(p, DYNAMITE_WEAPON, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -2741,7 +2741,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
|
|||
p->detonate_time = 45;
|
||||
if (p->ammo_amount[DYNAMITE_WEAPON] > 0)
|
||||
{
|
||||
fi.addweapon(p, DYNAMITE_WEAPON);
|
||||
fi.addweapon(p, DYNAMITE_WEAPON, true);
|
||||
p->oweapon_pos = p->weapon_pos = -9;
|
||||
}
|
||||
else checkavailweapon(p);
|
||||
|
@ -3947,9 +3947,9 @@ HORIZONLY:
|
|||
if (p->show_empty_weapon > 0)
|
||||
p->show_empty_weapon--;
|
||||
|
||||
if (p->show_empty_weapon == 1)
|
||||
if (p->show_empty_weapon == 0 && (WeaponSwitch(p - ps) & 2))
|
||||
{
|
||||
fi.addweapon(p, p->last_full_weapon);
|
||||
fi.addweapon(p, p->last_full_weapon, true);
|
||||
return;
|
||||
}
|
||||
dokneeattack(snum, { FEM10, NAKED1, STATUE });
|
||||
|
|
|
@ -414,7 +414,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
|
|||
p->okickback_pic = p->kickback_pic = 0;
|
||||
/// WHAT THE HELL DOES THIS DO....?????????????
|
||||
if (p->ammo_amount[TRIPBOMB_WEAPON] > 0)
|
||||
fi.addweapon(p, TRIPBOMB_WEAPON);
|
||||
fi.addweapon(p, TRIPBOMB_WEAPON, true);
|
||||
else
|
||||
checkavailweapon(p);
|
||||
}
|
||||
|
|
|
@ -5097,6 +5097,7 @@ int DoGet(DSWActor* actor)
|
|||
short pnum, key_num;
|
||||
bool can_see;
|
||||
|
||||
|
||||
// For flag stuff
|
||||
|
||||
// Invisiblility is only used for DeathMatch type games
|
||||
|
@ -5128,6 +5129,7 @@ int DoGet(DSWActor* actor)
|
|||
{
|
||||
pp = &Player[pnum];
|
||||
DSWActor* plActor = pp->actor;
|
||||
int weaponswitch = WeaponSwitch(pnum);
|
||||
|
||||
if (pp->Flags & (PF_DEAD))
|
||||
continue;
|
||||
|
@ -5462,7 +5464,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_STAR));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum <= WPN_STAR && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5490,7 +5492,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_MINE));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum > WPN_MINE && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5533,7 +5535,7 @@ KeyMain:
|
|||
ChoosePlayerGetSound(pp);
|
||||
}
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
|
||||
if (plActor->user.WeaponNum > WPN_UZI && plActor->user.WeaponNum != WPN_SWORD)
|
||||
|
@ -5576,7 +5578,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_MICRO));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum > WPN_MICRO && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5645,7 +5647,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_GRENADE));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum > WPN_GRENADE && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5674,7 +5676,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_ROCKET));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
InitWeaponRocket(pp);
|
||||
break;
|
||||
|
@ -5719,7 +5721,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_RAIL));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum > WPN_RAIL && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5761,7 +5763,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_SHOTGUN));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum > WPN_SHOTGUN && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5829,7 +5831,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_NAPALM) | BIT(WPN_RING) | BIT(WPN_HOTHEAD));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
if (plActor->user.WeaponNum > WPN_HOTHEAD && plActor->user.WeaponNum != WPN_SWORD)
|
||||
break;
|
||||
|
@ -5874,7 +5876,7 @@ KeyMain:
|
|||
break;
|
||||
pp->WpnFlags |= (BIT(WPN_HEART));
|
||||
|
||||
if (!cl_weaponswitch)
|
||||
if (!weaponswitch)
|
||||
break;
|
||||
|
||||
if (plActor->user.WeaponNum > WPN_HEART && plActor->user.WeaponNum != WPN_SWORD)
|
||||
|
|
Loading…
Reference in a new issue