Encapsulate aplWeapon* array accesses in a PWEAPON(Player, Weapon, Wmember) macro.

In the normal game, these arrays are conceptually [MAX_WEAPONS][MAXPLAYERS],
allocated as CON per-player gamevars (e.g. WEAPONx_WORKSLIKE).
For Lunatic, they are replaced with
weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS].

git-svn-id: https://svn.eduke32.com/eduke32@3328 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
helixhorned 2012-12-28 17:18:16 +00:00
parent f1b1ce2cc3
commit 9c328bf0a5
9 changed files with 222 additions and 195 deletions

View file

@ -4614,7 +4614,7 @@ DETONATEB:
if ((ps->gotweapon & (1<<HANDBOMB_WEAPON)) == 0 || s->owner == ps->i) if ((ps->gotweapon & (1<<HANDBOMB_WEAPON)) == 0 || s->owner == ps->i)
{ {
/* P_AddWeapon(ps,HANDBOMB_WEAPON); */ /* P_AddWeapon(ps,HANDBOMB_WEAPON); */
if (!(ps->weaponswitch & 1) && *aplWeaponWorksLike[ps->curr_weapon] != HANDREMOTE_WEAPON) if (!(ps->weaponswitch & 1) && PWEAPON(0, ps->curr_weapon, WorksLike) != HANDREMOTE_WEAPON)
P_AddWeaponNoSwitch(ps,HANDBOMB_WEAPON); P_AddWeaponNoSwitch(ps,HANDBOMB_WEAPON);
else P_AddWeapon(ps,HANDBOMB_WEAPON); else P_AddWeapon(ps,HANDBOMB_WEAPON);
} }

View file

@ -3884,34 +3884,35 @@ static void G_DumpDebugInfo(void)
OSD_Printf("\n"); OSD_Printf("\n");
OSD_Printf("Current gamevar values:\n"); OSD_Printf("Current gamevar values:\n");
#if !defined LUNATIC
for (i=0; i<MAX_WEAPONS; i++) for (i=0; i<MAX_WEAPONS; i++)
{ {
for (j=0; j<numplayers; j++) for (j=0; j<numplayers; j++)
{ {
OSD_Printf("Player %d\n\n",j); OSD_Printf("Player %d\n\n",j);
OSD_Printf("WEAPON%d_CLIP %" PRIdPTR "\n",i,aplWeaponClip[i][j]); OSD_Printf("WEAPON%d_CLIP %" PRIdPTR "\n", i, PWEAPON(j, i, Clip));
OSD_Printf("WEAPON%d_RELOAD %" PRIdPTR "\n",i,aplWeaponReload[i][j]); OSD_Printf("WEAPON%d_RELOAD %" PRIdPTR "\n", i, PWEAPON(j, i, Reload));
OSD_Printf("WEAPON%d_FIREDELAY %" PRIdPTR "\n",i,aplWeaponFireDelay[i][j]); OSD_Printf("WEAPON%d_FIREDELAY %" PRIdPTR "\n", i, PWEAPON(j, i, FireDelay));
OSD_Printf("WEAPON%d_TOTALTIME %" PRIdPTR "\n",i,aplWeaponTotalTime[i][j]); OSD_Printf("WEAPON%d_TOTALTIME %" PRIdPTR "\n", i, PWEAPON(j, i, TotalTime));
OSD_Printf("WEAPON%d_HOLDDELAY %" PRIdPTR "\n",i,aplWeaponHoldDelay[i][j]); OSD_Printf("WEAPON%d_HOLDDELAY %" PRIdPTR "\n", i, PWEAPON(j, i, HoldDelay));
OSD_Printf("WEAPON%d_FLAGS %" PRIdPTR "\n",i,aplWeaponFlags[i][j]); OSD_Printf("WEAPON%d_FLAGS %" PRIdPTR "\n", i, PWEAPON(j, i, Flags));
OSD_Printf("WEAPON%d_SHOOTS %" PRIdPTR "\n",i,aplWeaponShoots[i][j]); OSD_Printf("WEAPON%d_SHOOTS %" PRIdPTR "\n", i, PWEAPON(j, i, Shoots));
OSD_Printf("WEAPON%d_SPAWNTIME %" PRIdPTR "\n",i,aplWeaponSpawnTime[i][j]); OSD_Printf("WEAPON%d_SPAWNTIME %" PRIdPTR "\n", i, PWEAPON(j, i, SpawnTime));
OSD_Printf("WEAPON%d_SPAWN %" PRIdPTR "\n",i,aplWeaponSpawn[i][j]); OSD_Printf("WEAPON%d_SPAWN %" PRIdPTR "\n", i, PWEAPON(j, i, Spawn));
OSD_Printf("WEAPON%d_SHOTSPERBURST %" PRIdPTR "\n",i,aplWeaponShotsPerBurst[i][j]); OSD_Printf("WEAPON%d_SHOTSPERBURST %" PRIdPTR "\n", i, PWEAPON(j, i, ShotsPerBurst));
OSD_Printf("WEAPON%d_WORKSLIKE %" PRIdPTR "\n",i,aplWeaponWorksLike[i][j]); OSD_Printf("WEAPON%d_WORKSLIKE %" PRIdPTR "\n", i, PWEAPON(j, i, WorksLike));
OSD_Printf("WEAPON%d_INITIALSOUND %" PRIdPTR "\n",i,aplWeaponInitialSound[i][j]); OSD_Printf("WEAPON%d_INITIALSOUND %" PRIdPTR "\n", i, PWEAPON(j, i, InitialSound));
OSD_Printf("WEAPON%d_FIRESOUND %" PRIdPTR "\n",i,aplWeaponFireSound[i][j]); OSD_Printf("WEAPON%d_FIRESOUND %" PRIdPTR "\n", i, PWEAPON(j, i, FireSound));
OSD_Printf("WEAPON%d_SOUND2TIME %" PRIdPTR "\n",i,aplWeaponSound2Time[i][j]); OSD_Printf("WEAPON%d_SOUND2TIME %" PRIdPTR "\n", i, PWEAPON(j, i, Sound2Time));
OSD_Printf("WEAPON%d_SOUND2SOUND %" PRIdPTR "\n",i,aplWeaponSound2Sound[i][j]); OSD_Printf("WEAPON%d_SOUND2SOUND %" PRIdPTR "\n", i, PWEAPON(j, i, Sound2Sound));
OSD_Printf("WEAPON%d_RELOADSOUND1 %" PRIdPTR "\n",i,aplWeaponReloadSound1[i][j]); OSD_Printf("WEAPON%d_RELOADSOUND1 %" PRIdPTR "\n", i, PWEAPON(j, i, ReloadSound1));
OSD_Printf("WEAPON%d_RELOADSOUND2 %" PRIdPTR "\n",i,aplWeaponReloadSound2[i][j]); OSD_Printf("WEAPON%d_RELOADSOUND2 %" PRIdPTR "\n", i, PWEAPON(j, i, ReloadSound2));
OSD_Printf("WEAPON%d_SELECTSOUND %" PRIdPTR "\n",i,aplWeaponSelectSound[i][j]); OSD_Printf("WEAPON%d_SELECTSOUND %" PRIdPTR "\n", i, PWEAPON(j, i, SelectSound));
OSD_Printf("WEAPON%d_FLASHCOLOR %" PRIdPTR "\n",i,aplWeaponFlashColor[i][j]); OSD_Printf("WEAPON%d_FLASHCOLOR %" PRIdPTR "\n", i, PWEAPON(j, i, FlashColor));
} }
OSD_Printf("\n"); OSD_Printf("\n");
} }
#endif
for (x=0; x<MAXSTATUS; x++) for (x=0; x<MAXSTATUS; x++)
{ {
j = headspritestat[x]; j = headspritestat[x];

View file

@ -111,6 +111,9 @@ static int32_t C_SetScriptSize(int32_t size);
int32_t g_numQuoteRedefinitions = 0; int32_t g_numQuoteRedefinitions = 0;
#ifdef LUNATIC
weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS];
#else
// pointers to weapon gamevar data // pointers to weapon gamevar data
intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in magazine
intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire)
@ -131,6 +134,7 @@ intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of magazine being remo
intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted
intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound of weapon being selected intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound of weapon being selected
intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Muzzle flash color
#endif
int32_t g_iReturnVarID=-1; // var ID of "RETURN" int32_t g_iReturnVarID=-1; // var ID of "RETURN"
int32_t g_iWeaponVarID=-1; // var ID of "WEAPON" int32_t g_iWeaponVarID=-1; // var ID of "WEAPON"

View file

@ -78,30 +78,6 @@ extern char g_szBuf[1024];
extern intptr_t *g_scriptPtr; extern intptr_t *g_scriptPtr;
typedef struct
{
// NOTE: the member names must be identical to aplWeapon* suffixes.
int32_t WorksLike; // What the original works like
int32_t Clip; // number of items in magazine
int32_t Reload; // delay to reload (include fire)
int32_t FireDelay; // delay to fire
int32_t TotalTime; // The total time the weapon is cycling before next fire.
int32_t HoldDelay; // delay after release fire button to fire (0 for none)
int32_t Flags; // Flags for weapon
int32_t Shoots; // what the weapon shoots
int32_t SpawnTime; // the frame at which to spawn an item
int32_t Spawn; // the item to spawn
int32_t ShotsPerBurst; // number of shots per 'burst' (one ammo per 'burst')
int32_t InitialSound; // Sound made when weapon starts firing. zero for no sound
int32_t FireSound; // Sound made when firing (each time for automatic)
int32_t Sound2Time; // Alternate sound time
int32_t Sound2Sound; // Alternate sound sound ID
int32_t ReloadSound1; // Sound of magazine being removed
int32_t ReloadSound2; // Sound of magazine being inserted
int32_t SelectSound; // Sound of weapon being selected
int32_t FlashColor; // Muzzle flash color
} weapondata_t;
typedef struct typedef struct
{ {
const char *name; const char *name;

View file

@ -974,6 +974,7 @@ int32_t Gv_GetVarByLabel(const char *szGameLabel, int32_t lDefault, int32_t iAct
return Gv_GetVar(i, iActor, iPlayer); return Gv_GetVar(i, iActor, iPlayer);
} }
#if !defined LUNATIC
static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel) static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
{ {
int32_t i = hash_find(&h_gamevars,szGameLabel); int32_t i = hash_find(&h_gamevars,szGameLabel);
@ -990,12 +991,15 @@ static intptr_t *Gv_GetVarDataPtr(const char *szGameLabel)
return &(aGameVars[i].val.lValue); return &(aGameVars[i].val.lValue);
} }
#endif
void Gv_ResetSystemDefaults(void) void Gv_ResetSystemDefaults(void)
{ {
// call many times... // call many times...
int32_t i,j; int32_t i;
#if !defined LUNATIC
int32_t j;
char aszBuf[64]; char aszBuf[64];
//AddLog("ResetWeaponDefaults"); //AddLog("ResetWeaponDefaults");
@ -1046,7 +1050,7 @@ void Gv_ResetSystemDefaults(void)
aplWeaponFlashColor[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j); aplWeaponFlashColor[i][j]=Gv_GetVarByLabel(aszBuf,0, -1, j);
} }
} }
#endif
g_iReturnVarID=Gv_GetVarIndex("RETURN"); g_iReturnVarID=Gv_GetVarIndex("RETURN");
g_iWeaponVarID=Gv_GetVarIndex("WEAPON"); g_iWeaponVarID=Gv_GetVarIndex("WEAPON");
g_iWorksLikeVarID=Gv_GetVarIndex("WORKSLIKE"); g_iWorksLikeVarID=Gv_GetVarIndex("WORKSLIKE");
@ -1185,16 +1189,26 @@ static int32_t G_StaticToDynamicTile(int32_t tile)
} }
} }
#define ADDWEAPONVAR(Weapidx, Membname) do { \ #ifdef LUNATIC
# define ADDWEAPONVAR(Weapidx, Membname) do { \
int32_t j; \
for (j=0; j<MAXPLAYERS; j++) \
g_playerWeapon[j][Weapidx].Membname = weapondefaults[Weapidx].Membname; \
} while (0)
#else
# define ADDWEAPONVAR(Weapidx, Membname) do { \
Bsprintf(aszBuf, "WEAPON%d_" #Membname, Weapidx); \ Bsprintf(aszBuf, "WEAPON%d_" #Membname, Weapidx); \
Bstrupr(aszBuf); \ Bstrupr(aszBuf); \
Gv_NewVar(aszBuf, weapondefaults[Weapidx].Membname, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); \ Gv_NewVar(aszBuf, weapondefaults[Weapidx].Membname, GAMEVAR_PERPLAYER | GAMEVAR_SYSTEM); \
} while (0) } while (0)
#endif
static void Gv_AddSystemVars(void) static void Gv_AddSystemVars(void)
{ {
// only call ONCE // only call ONCE
#if !defined LUNATIC
char aszBuf[64]; char aszBuf[64];
#endif
int32_t i; int32_t i;
if (NAM) if (NAM)
@ -1379,6 +1393,7 @@ void Gv_Init(void)
void Gv_InitWeaponPointers(void) void Gv_InitWeaponPointers(void)
{ {
#if !defined LUNATIC
int32_t i; int32_t i;
char aszBuf[64]; char aszBuf[64];
// called from game Init AND when level is loaded... // called from game Init AND when level is loaded...
@ -1432,6 +1447,7 @@ void Gv_InitWeaponPointers(void)
Bsprintf(aszBuf,"WEAPON%d_FLASHCOLOR",i); Bsprintf(aszBuf,"WEAPON%d_FLASHCOLOR",i);
aplWeaponFlashColor[i]=Gv_GetVarDataPtr(aszBuf); aplWeaponFlashColor[i]=Gv_GetVarDataPtr(aszBuf);
} }
#endif
} }
void Gv_RefreshPointers(void) void Gv_RefreshPointers(void)

View file

@ -239,8 +239,8 @@ static int32_t A_FindTargetSprite(spritetype *s,int32_t aang,int32_t atwith)
j = -1; j = -1;
gotshrinker = (s->picnum == APLAYER && *aplWeaponWorksLike[g_player[s->yvel].ps->curr_weapon] == SHRINKER_WEAPON); gotshrinker = (s->picnum == APLAYER && PWEAPON(0, g_player[s->yvel].ps->curr_weapon, WorksLike) == SHRINKER_WEAPON);
gotfreezer = (s->picnum == APLAYER && *aplWeaponWorksLike[g_player[s->yvel].ps->curr_weapon] == FREEZE_WEAPON); gotfreezer = (s->picnum == APLAYER && PWEAPON(0, g_player[s->yvel].ps->curr_weapon, WorksLike) == FREEZE_WEAPON);
smax = INT32_MAX; smax = INT32_MAX;
@ -1616,7 +1616,7 @@ SKIPBULLETHOLE:
} }
} }
else if (*aplWeaponWorksLike[g_player[p].ps->curr_weapon] == DEVISTATOR_WEAPON) else if (PWEAPON(0, g_player[p].ps->curr_weapon, WorksLike) == DEVISTATOR_WEAPON)
{ {
sprite[j].extra >>= 2; sprite[j].extra >>= 2;
sprite[j].ang += 16-(krand()&31); sprite[j].ang += 16-(krand()&31);
@ -2094,38 +2094,38 @@ void P_FireWeapon(DukePlayer_t *p)
{ {
if (p->weapon_pos != 0) return; if (p->weapon_pos != 0) return;
if (aplWeaponWorksLike[p->curr_weapon][snum] != KNEE_WEAPON) if (PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON)
p->ammo_amount[p->curr_weapon]--; p->ammo_amount[p->curr_weapon]--;
if (aplWeaponFireSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, FireSound) > 0)
A_PlaySound(aplWeaponFireSound[p->curr_weapon][snum],p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, FireSound),p->i);
Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum);
Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); Gv_SetVar(g_iWorksLikeVarID,PWEAPON(snum, p->curr_weapon, WorksLike), p->i, snum);
// OSD_Printf("doing %d %d %d\n",aplWeaponShoots[p->curr_weapon][snum],p->curr_weapon,snum); // OSD_Printf("doing %d %d %d\n",PWEAPON(snum, p->curr_weapon, Shoots),p->curr_weapon,snum);
A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); A_Shoot(p->i,PWEAPON(snum, p->curr_weapon, Shoots));
for (i=aplWeaponShotsPerBurst[p->curr_weapon][snum]-1; i > 0; i--) for (i=PWEAPON(snum, p->curr_weapon, ShotsPerBurst)-1; i > 0; i--)
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_FIREEVERYOTHER)
{ {
// this makes the projectiles fire on a delay from player code // this makes the projectiles fire on a delay from player code
actor[p->i].t_data[7] = (aplWeaponShotsPerBurst[p->curr_weapon][snum])<<1; actor[p->i].t_data[7] = (PWEAPON(snum, p->curr_weapon, ShotsPerBurst))<<1;
} }
else else
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT && if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_AMMOPERSHOT &&
aplWeaponWorksLike[p->curr_weapon][snum] != KNEE_WEAPON) PWEAPON(snum, p->curr_weapon, WorksLike) != KNEE_WEAPON)
{ {
if (p->ammo_amount[p->curr_weapon] > 0) if (p->ammo_amount[p->curr_weapon] > 0)
p->ammo_amount[p->curr_weapon]--; p->ammo_amount[p->curr_weapon]--;
else break; else break;
} }
A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); A_Shoot(p->i,PWEAPON(snum, p->curr_weapon, Shoots));
} }
} }
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) if (!(PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_NOVISIBLE))
{ {
#ifdef POLYMER #ifdef POLYMER
spritetype *s = &sprite[p->i]; spritetype *s = &sprite[p->i];
@ -2133,7 +2133,7 @@ void P_FireWeapon(DukePlayer_t *p)
s->x += x; s->x += x;
s->y += y; s->y += y;
G_AddGameLight(0, p->i, PHEIGHT, 8192, aplWeaponFlashColor[p->curr_weapon][snum],PR_LIGHT_PRIO_MAX_GAME); G_AddGameLight(0, p->i, PHEIGHT, 8192, PWEAPON(snum, p->curr_weapon, FlashColor),PR_LIGHT_PRIO_MAX_GAME);
actor[p->i].lightcount = 2; actor[p->i].lightcount = 2;
s->x -= x; s->x -= x;
s->y -= y; s->y -= y;
@ -2148,12 +2148,12 @@ void P_DoWeaponSpawn(DukePlayer_t *p)
{ {
int32_t j, snum = sprite[p->i].yvel; int32_t j, snum = sprite[p->i].yvel;
if (aplWeaponSpawn[p->curr_weapon][snum] <= 0) // <=0 : AMC TC beta/RC2 has WEAPONx_SPAWN -1 if (PWEAPON(snum, p->curr_weapon, Spawn) <= 0) // <=0 : AMC TC beta/RC2 has WEAPONx_SPAWN -1
return; return;
j = A_Spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); j = A_Spawn(p->i, PWEAPON(snum, p->curr_weapon, Spawn));
if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SPAWNTYPE3)) if ((PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_SPAWNTYPE3))
{ {
// like chaingun shells // like chaingun shells
sprite[j].ang += 1024; sprite[j].ang += 1024;
@ -2303,9 +2303,9 @@ void P_DisplayWeapon(int32_t snum)
gun_pos -= (p->hard_landing<<3); gun_pos -= (p->hard_landing<<3);
if (p->last_weapon >= 0) if (p->last_weapon >= 0)
cw = aplWeaponWorksLike[p->last_weapon][snum]; cw = PWEAPON(snum, p->last_weapon, WorksLike);
else else
cw = aplWeaponWorksLike[p->curr_weapon][snum]; cw = PWEAPON(snum, p->curr_weapon, WorksLike);
g_gun_pos=gun_pos; g_gun_pos=gun_pos;
g_looking_arc=looking_arc; g_looking_arc=looking_arc;
@ -2536,7 +2536,7 @@ void P_DisplayWeapon(int32_t snum)
break; break;
default: default:
if (*kb > *aplWeaponFireDelay[CHAINGUN_WEAPON] && *kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]) if (*kb > PWEAPON(0, CHAINGUN_WEAPON, FireDelay) && *kb < PWEAPON(0, CHAINGUN_WEAPON, TotalTime))
{ {
i = 0; i = 0;
if (sprite[p->i].pal != 1) i = rand()&7; if (sprite[p->i].pal != 1) i = rand()&7;
@ -2547,7 +2547,7 @@ void P_DisplayWeapon(int32_t snum)
CHAINGUN+5+((*kb-4)/5),gs,o,pal,0); CHAINGUN+5+((*kb-4)/5),gs,o,pal,0);
} }
if (*kb < *aplWeaponTotalTime[CHAINGUN_WEAPON]-4) if (*kb < PWEAPON(0, CHAINGUN_WEAPON, TotalTime)-4)
{ {
i = rand()&7; i = rand()&7;
G_DrawWeaponTile(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos, G_DrawWeaponTile(i+weapon_xoffset-4+162-(p->look_ang>>1),i+looking_arc-((*kb)>>1)+208-gun_pos,
@ -2566,12 +2566,12 @@ void P_DisplayWeapon(int32_t snum)
case PISTOL_WEAPON: case PISTOL_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0)
{ {
if ((*kb) < *aplWeaponTotalTime[PISTOL_WEAPON]+1) if ((*kb) < PWEAPON(0, PISTOL_WEAPON, TotalTime)+1)
{ {
static uint8_t kb_frames[] = { 0, 1, 2 }; static uint8_t kb_frames[] = { 0, 1, 2 };
int32_t l = 195-12+weapon_xoffset; int32_t l = 195-12+weapon_xoffset;
if ((*kb) == *aplWeaponFireDelay[PISTOL_WEAPON]) if ((*kb) == PWEAPON(0, PISTOL_WEAPON, FireDelay))
l -= 3; l -= 3;
guniqhudid = cw; guniqhudid = cw;
@ -2581,20 +2581,20 @@ void P_DisplayWeapon(int32_t snum)
else else
{ {
if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-17) if ((*kb) < PWEAPON(0, PISTOL_WEAPON, Reload)-17)
{ {
guniqhudid = cw; guniqhudid = cw;
G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o|512,pal,0); G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+230-gun_pos,FIRSTGUN+4,gs,o|512,pal,0);
guniqhudid = 0; guniqhudid = 0;
} }
else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-12) else if ((*kb) < PWEAPON(0, PISTOL_WEAPON, Reload)-12)
{ {
G_DrawWeaponTile(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o|512,pal,0); G_DrawWeaponTile(244-((*kb)<<3)-(p->look_ang>>1),looking_arc+130-gun_pos+((*kb)<<4),FIRSTGUN+6,gs,o|512,pal,0);
guniqhudid = cw; guniqhudid = cw;
G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o|512,pal,0); G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o|512,pal,0);
guniqhudid = 0; guniqhudid = 0;
} }
else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-7) else if ((*kb) < PWEAPON(0, PISTOL_WEAPON, Reload)-7)
{ {
G_DrawWeaponTile(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o|512,pal,0); G_DrawWeaponTile(124+((*kb)<<1)-(p->look_ang>>1),looking_arc+430-gun_pos-((*kb)<<3),FIRSTGUN+6,gs,o|512,pal,0);
guniqhudid = cw; guniqhudid = cw;
@ -2602,21 +2602,21 @@ void P_DisplayWeapon(int32_t snum)
guniqhudid = 0; guniqhudid = 0;
} }
else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-4) else if ((*kb) < PWEAPON(0, PISTOL_WEAPON, Reload)-4)
{ {
G_DrawWeaponTile(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o|512,pal,0); G_DrawWeaponTile(184-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+8,gs,o|512,pal,0);
guniqhudid = cw; guniqhudid = cw;
G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o|512,pal,0); G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+210-gun_pos,FIRSTGUN+5,gs,o|512,pal,0);
guniqhudid = 0; guniqhudid = 0;
} }
else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]-2) else if ((*kb) < PWEAPON(0, PISTOL_WEAPON, Reload)-2)
{ {
G_DrawWeaponTile(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o|512,pal,0); G_DrawWeaponTile(164-(p->look_ang>>1),looking_arc+245-gun_pos,FIRSTGUN+8,gs,o|512,pal,0);
guniqhudid = cw; guniqhudid = cw;
G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o|512,pal,0); G_DrawWeaponTile(224-(p->look_ang>>1),looking_arc+220-gun_pos,FIRSTGUN+5,gs,o|512,pal,0);
guniqhudid = 0; guniqhudid = 0;
} }
else if ((*kb) < *aplWeaponReload[PISTOL_WEAPON]) else if ((*kb) < PWEAPON(0, PISTOL_WEAPON, Reload))
{ {
guniqhudid = cw; guniqhudid = cw;
G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o|512,pal,0); G_DrawWeaponTile(194-(p->look_ang>>1),looking_arc+235-gun_pos,FIRSTGUN+5,gs,o|512,pal,0);
@ -2633,7 +2633,7 @@ void P_DisplayWeapon(int32_t snum)
guniqhudid = cw; guniqhudid = cw;
if ((*kb)) if ((*kb))
{ {
if ((*kb) < (*aplWeaponTotalTime[p->curr_weapon])) if ((*kb) < (PWEAPON(0, p->curr_weapon, TotalTime)))
{ {
static uint8_t throw_frames[] = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2}; static uint8_t throw_frames[] = {0,0,0,0,0,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2};
@ -2672,7 +2672,7 @@ void P_DisplayWeapon(int32_t snum)
case DEVISTATOR_WEAPON: case DEVISTATOR_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0)
{ {
if ((*kb) < (*aplWeaponTotalTime[DEVISTATOR_WEAPON]+1) && (*kb) > 0) if ((*kb) < (PWEAPON(0, DEVISTATOR_WEAPON, TotalTime)+1) && (*kb) > 0)
{ {
static uint8_t cycloidy[] = {0,4,12,24,12,4,0}; static uint8_t cycloidy[] = {0,4,12,24,12,4,0};
@ -2709,7 +2709,7 @@ void P_DisplayWeapon(int32_t snum)
case FREEZE_WEAPON: case FREEZE_WEAPON:
if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0) if (VM_OnEvent(EVENT_DRAWWEAPON,g_player[screenpeek].ps->i,screenpeek, -1, 0) == 0)
{ {
if ((*kb) < (aplWeaponTotalTime[p->curr_weapon][snum]+1) && (*kb) > 0) if ((*kb) < (PWEAPON(snum, p->curr_weapon, TotalTime)+1) && (*kb) > 0)
{ {
static uint8_t cat_frames[] = { 0,0,1,1,2,2 }; static uint8_t cat_frames[] = { 0,0,1,1,2,2 };
@ -2740,7 +2740,7 @@ void P_DisplayWeapon(int32_t snum)
weapon_xoffset += 28; weapon_xoffset += 28;
looking_arc += 18; looking_arc += 18;
if ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum] && (*kb) > 0) if ((*kb) < PWEAPON(snum, p->curr_weapon, TotalTime) && (*kb) > 0)
{ {
if (sprite[p->i].pal != 1) if (sprite[p->i].pal != 1)
{ {
@ -2780,7 +2780,7 @@ void P_DisplayWeapon(int32_t snum)
weapon_xoffset += 28; weapon_xoffset += 28;
looking_arc += 18; looking_arc += 18;
if (((*kb) > 0) && ((*kb) < aplWeaponTotalTime[p->curr_weapon][snum])) if (((*kb) > 0) && ((*kb) < PWEAPON(snum, p->curr_weapon, TotalTime)))
{ {
if (sprite[p->i].pal != 1) if (sprite[p->i].pal != 1)
{ {
@ -3080,7 +3080,7 @@ void getinput(int32_t snum)
if (BUTTON(gamefunc_Dpad_Aiming)) if (BUTTON(gamefunc_Dpad_Aiming))
vel = 0; vel = 0;
if (aplWeaponFlags[g_player[snum].ps->curr_weapon][snum] & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire)) if (PWEAPON(snum, g_player[snum].ps->curr_weapon, Flags) & WEAPON_SEMIAUTO && BUTTON(gamefunc_Fire))
CONTROL_ClearButton(gamefunc_Fire); CONTROL_ClearButton(gamefunc_Fire);
loc.extbits = 0; loc.extbits = 0;
@ -3333,7 +3333,7 @@ int16_t WeaponPickupSprites[MAX_WEAPONS] = { KNEE__STATIC, FIRSTGUNSPRITE__STATI
void P_DropWeapon(DukePlayer_t *p) void P_DropWeapon(DukePlayer_t *p)
{ {
int32_t snum = sprite[p->i].yvel, int32_t snum = sprite[p->i].yvel,
cw = aplWeaponWorksLike[p->curr_weapon][snum]; cw = PWEAPON(snum, p->curr_weapon, WorksLike);
if ((unsigned)cw >= MAX_WEAPONS) return; if ((unsigned)cw >= MAX_WEAPONS) return;
@ -3368,11 +3368,11 @@ void P_AddWeaponNoSwitch(DukePlayer_t *p, int32_t weapon)
p->gotweapon |= (1<<GROW_WEAPON); p->gotweapon |= (1<<GROW_WEAPON);
} }
if (aplWeaponSelectSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, SelectSound) > 0)
S_StopEnvSound(aplWeaponSelectSound[p->curr_weapon][snum],p->i); S_StopEnvSound(PWEAPON(snum, p->curr_weapon, SelectSound),p->i);
if (aplWeaponSelectSound[weapon][snum] > 0) if (PWEAPON(snum, weapon, SelectSound) > 0)
A_PlaySound(aplWeaponSelectSound[weapon][snum],p->i); A_PlaySound(PWEAPON(snum, weapon, SelectSound),p->i);
} }
void P_ChangeWeapon(DukePlayer_t *p,int32_t weapon) void P_ChangeWeapon(DukePlayer_t *p,int32_t weapon)
@ -3409,7 +3409,7 @@ void P_ChangeWeapon(DukePlayer_t *p,int32_t weapon)
Gv_SetVar(g_iWeaponVarID, p->curr_weapon, p->i, snum); Gv_SetVar(g_iWeaponVarID, p->curr_weapon, p->i, snum);
Gv_SetVar(g_iWorksLikeVarID, Gv_SetVar(g_iWorksLikeVarID,
(unsigned)p->curr_weapon < MAX_WEAPONS ? aplWeaponWorksLike[p->curr_weapon][snum] : -1, (unsigned)p->curr_weapon < MAX_WEAPONS ? PWEAPON(snum, p->curr_weapon, WorksLike) : -1,
p->i, snum); p->i, snum);
} }
@ -3783,7 +3783,7 @@ void P_ProcessWeapon(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) if (TEST_SYNC_KEY(sb_snum, SK_FIRE))
{ {
Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum);
Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); Gv_SetVar(g_iWorksLikeVarID,PWEAPON(snum, p->curr_weapon, WorksLike),p->i,snum);
if (VM_OnEvent(EVENT_PRESSEDFIRE, p->i, snum, -1, 0) != 0) if (VM_OnEvent(EVENT_PRESSEDFIRE, p->i, snum, -1, 0) != 0)
sb_snum &= ~BIT(SK_FIRE); sb_snum &= ~BIT(SK_FIRE);
@ -3792,11 +3792,11 @@ void P_ProcessWeapon(int32_t snum)
if (TEST_SYNC_KEY(sb_snum, SK_HOLSTER)) // 'Holster Weapon if (TEST_SYNC_KEY(sb_snum, SK_HOLSTER)) // 'Holster Weapon
{ {
Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum);
Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); Gv_SetVar(g_iWorksLikeVarID,PWEAPON(snum, p->curr_weapon, WorksLike),p->i,snum);
if (VM_OnEvent(EVENT_HOLSTER, p->i, snum, -1, 0) == 0) if (VM_OnEvent(EVENT_HOLSTER, p->i, snum, -1, 0) == 0)
{ {
if (*aplWeaponWorksLike[p->curr_weapon] != KNEE_WEAPON) if (PWEAPON(0, p->curr_weapon, WorksLike) != KNEE_WEAPON)
{ {
if (p->holster_weapon == 0 && p->weapon_pos == 0) if (p->holster_weapon == 0 && p->weapon_pos == 0)
{ {
@ -3812,14 +3812,14 @@ void P_ProcessWeapon(int32_t snum)
} }
} }
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_HOLSTER_CLEARS_CLIP) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_HOLSTER_CLEARS_CLIP)
{ {
if (p->ammo_amount[p->curr_weapon] > aplWeaponClip[p->curr_weapon][snum] if (p->ammo_amount[p->curr_weapon] > PWEAPON(snum, p->curr_weapon, Clip)
&& (p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum]) != 0) && (p->ammo_amount[p->curr_weapon] % PWEAPON(snum, p->curr_weapon, Clip)) != 0)
{ {
p->ammo_amount[p->curr_weapon]-= p->ammo_amount[p->curr_weapon]-=
p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum] ; p->ammo_amount[p->curr_weapon] % PWEAPON(snum, p->curr_weapon, Clip) ;
(*kb) = aplWeaponTotalTime[p->curr_weapon][snum]; (*kb) = PWEAPON(snum, p->curr_weapon, TotalTime);
sb_snum &= ~BIT(SK_FIRE); // not firing... sb_snum &= ~BIT(SK_FIRE); // not firing...
} }
return; return;
@ -3827,7 +3827,7 @@ void P_ProcessWeapon(int32_t snum)
} }
} }
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_GLOWS) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_GLOWS)
{ {
p->random_club_frame += 64; // Glowing p->random_club_frame += 64; // Glowing
@ -3839,7 +3839,7 @@ void P_ProcessWeapon(int32_t snum)
s->x += x; s->x += x;
s->y += y; s->y += y;
G_AddGameLight(0, p->i, PHEIGHT, max(r, 0), aplWeaponFlashColor[p->curr_weapon][snum],PR_LIGHT_PRIO_HIGH_GAME); G_AddGameLight(0, p->i, PHEIGHT, max(r, 0), PWEAPON(snum, p->curr_weapon, FlashColor),PR_LIGHT_PRIO_HIGH_GAME);
actor[p->i].lightcount = 2; actor[p->i].lightcount = 2;
s->x -= x; s->x -= x;
s->y -= y; s->y -= y;
@ -3853,7 +3853,7 @@ void P_ProcessWeapon(int32_t snum)
actor[p->i].t_data[7]--; actor[p->i].t_data[7]--;
if (p->last_weapon == -1 && actor[p->i].t_data[7] != 0 && ((actor[p->i].t_data[7] & 1) == 0)) if (p->last_weapon == -1 && actor[p->i].t_data[7] != 0 && ((actor[p->i].t_data[7] & 1) == 0))
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AMMOPERSHOT) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_AMMOPERSHOT)
{ {
if (p->ammo_amount[p->curr_weapon] > 0) if (p->ammo_amount[p->curr_weapon] > 0)
p->ammo_amount[p->curr_weapon]--; p->ammo_amount[p->curr_weapon]--;
@ -3865,7 +3865,7 @@ void P_ProcessWeapon(int32_t snum)
} }
if (actor[p->i].t_data[7] != 0) if (actor[p->i].t_data[7] != 0)
A_Shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); A_Shoot(p->i,PWEAPON(snum, p->curr_weapon, Shoots));
} }
} }
@ -3894,38 +3894,38 @@ void P_ProcessWeapon(int32_t snum)
else else
{ {
Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum);
Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); Gv_SetVar(g_iWorksLikeVarID,PWEAPON(snum, p->curr_weapon, WorksLike),p->i,snum);
if (VM_OnEvent(EVENT_FIRE, p->i, snum, -1, 0) == 0) if (VM_OnEvent(EVENT_FIRE, p->i, snum, -1, 0) == 0)
{ {
if (G_HaveEvent(EVENT_FIREWEAPON)) // this event is deprecated if (G_HaveEvent(EVENT_FIREWEAPON)) // this event is deprecated
VM_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1, 0); VM_OnEvent(EVENT_FIREWEAPON, p->i, snum, -1, 0);
switch (aplWeaponWorksLike[p->curr_weapon][snum]) switch (PWEAPON(snum, p->curr_weapon, WorksLike))
{ {
case HANDBOMB_WEAPON: case HANDBOMB_WEAPON:
p->hbomb_hold_delay = 0; p->hbomb_hold_delay = 0;
if (p->ammo_amount[p->curr_weapon] > 0) if (p->ammo_amount[p->curr_weapon] > 0)
{ {
(*kb)=1; (*kb)=1;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
} }
break; break;
case HANDREMOTE_WEAPON: case HANDREMOTE_WEAPON:
p->hbomb_hold_delay = 0; p->hbomb_hold_delay = 0;
(*kb) = 1; (*kb) = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
break; break;
case SHOTGUN_WEAPON: case SHOTGUN_WEAPON:
if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0) if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0)
{ {
(*kb)=1; (*kb)=1;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
} }
break; break;
@ -3971,9 +3971,9 @@ void P_ProcessWeapon(int32_t snum)
p->pos.z = p->opos.z; p->pos.z = p->opos.z;
p->vel.z = 0; p->vel.z = 0;
(*kb) = 1; (*kb) = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
{ {
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
} }
} }
} }
@ -3988,8 +3988,8 @@ void P_ProcessWeapon(int32_t snum)
if (p->ammo_amount[p->curr_weapon] > 0) if (p->ammo_amount[p->curr_weapon] > 0)
{ {
(*kb) = 1; (*kb) = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
} }
break; break;
@ -3998,8 +3998,8 @@ void P_ProcessWeapon(int32_t snum)
{ {
(*kb) = 1; (*kb) = 1;
p->hbomb_hold_delay = !p->hbomb_hold_delay; p->hbomb_hold_delay = !p->hbomb_hold_delay;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
} }
break; break;
@ -4007,8 +4007,8 @@ void P_ProcessWeapon(int32_t snum)
if (p->quick_kick == 0) if (p->quick_kick == 0)
{ {
(*kb) = 1; (*kb) = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, InitialSound) > 0)
A_PlaySound(aplWeaponInitialSound[p->curr_weapon][snum], p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, InitialSound), p->i);
} }
break; break;
} }
@ -4017,15 +4017,15 @@ void P_ProcessWeapon(int32_t snum)
} }
else if (*kb) else if (*kb)
{ {
if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON) if (PWEAPON(snum, p->curr_weapon, WorksLike) == HANDBOMB_WEAPON)
{ {
if (aplWeaponHoldDelay[p->curr_weapon][snum] && ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) && TEST_SYNC_KEY(sb_snum, SK_FIRE)) if (PWEAPON(snum, p->curr_weapon, HoldDelay) && ((*kb) == PWEAPON(snum, p->curr_weapon, FireDelay)) && TEST_SYNC_KEY(sb_snum, SK_FIRE))
{ {
p->rapid_fire_hold = 1; p->rapid_fire_hold = 1;
return; return;
} }
if (++(*kb) == aplWeaponHoldDelay[p->curr_weapon][snum]) if (++(*kb) == PWEAPON(snum, p->curr_weapon, HoldDelay))
{ {
int32_t lPipeBombControl; int32_t lPipeBombControl;
@ -4047,7 +4047,7 @@ void P_ProcessWeapon(int32_t snum)
j = A_InsertSprite(p->cursectnum, j = A_InsertSprite(p->cursectnum,
p->pos.x+(sintable[(p->ang+512)&2047]>>6), p->pos.x+(sintable[(p->ang+512)&2047]>>6),
p->pos.y+(sintable[p->ang&2047]>>6), p->pos.y+(sintable[p->ang&2047]>>6),
p->pos.z,aplWeaponShoots[p->curr_weapon][snum],-16,9,9, p->pos.z,PWEAPON(snum, p->curr_weapon, Shoots),-16,9,9,
p->ang,(k+(p->hbomb_hold_delay<<5)),i,p->i,1); p->ang,(k+(p->hbomb_hold_delay<<5)),i,p->i,1);
lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum); lPipeBombControl=Gv_GetVarByLabel("PIPEBOMB_CONTROL", PIPEBOMB_REMOTE, -1, snum);
@ -4079,9 +4079,9 @@ void P_ProcessWeapon(int32_t snum)
p->hbomb_on = 1; p->hbomb_on = 1;
} }
else if ((*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && TEST_SYNC_KEY(sb_snum, SK_FIRE)) else if ((*kb) < PWEAPON(snum, p->curr_weapon, HoldDelay) && TEST_SYNC_KEY(sb_snum, SK_FIRE))
p->hbomb_hold_delay++; p->hbomb_hold_delay++;
else if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) else if ((*kb) > PWEAPON(snum, p->curr_weapon, TotalTime))
{ {
(*kb) = 0; (*kb) = 0;
p->weapon_pos = 10; p->weapon_pos = 10;
@ -4094,27 +4094,27 @@ void P_ProcessWeapon(int32_t snum)
else P_CheckWeapon(p); else P_CheckWeapon(p);
} }
} }
else if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) else if (PWEAPON(snum, p->curr_weapon, WorksLike) == HANDREMOTE_WEAPON)
{ {
if (++(*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) if (++(*kb) == PWEAPON(snum, p->curr_weapon, FireDelay))
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_BOMB_TRIGGER) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_BOMB_TRIGGER)
p->hbomb_on = 0; p->hbomb_on = 0;
if (aplWeaponShoots[p->curr_weapon][snum] != 0) if (PWEAPON(snum, p->curr_weapon, Shoots) != 0)
{ {
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_NOVISIBLE)) if (!(PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_NOVISIBLE))
{ {
lastvisinc = totalclock+32; lastvisinc = totalclock+32;
p->visibility = 0; p->visibility = 0;
} }
Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum); Gv_SetVar(g_iWeaponVarID,p->curr_weapon,p->i,snum);
Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); Gv_SetVar(g_iWorksLikeVarID,PWEAPON(snum, p->curr_weapon, WorksLike), p->i, snum);
A_Shoot(p->i, aplWeaponShoots[p->curr_weapon][snum]); A_Shoot(p->i, PWEAPON(snum, p->curr_weapon, Shoots));
} }
} }
if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) if ((*kb) >= PWEAPON(snum, p->curr_weapon, TotalTime))
{ {
(*kb) = 0; (*kb) = 0;
if ((p->ammo_amount[HANDBOMB_WEAPON] > 0) && if ((p->ammo_amount[HANDBOMB_WEAPON] > 0) &&
@ -4128,64 +4128,64 @@ void P_ProcessWeapon(int32_t snum)
// the basic weapon... // the basic weapon...
(*kb)++; (*kb)++;
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_CHECKATRELOAD)
{ {
if (aplWeaponWorksLike[p->curr_weapon][snum] == TRIPBOMB_WEAPON) if (PWEAPON(snum, p->curr_weapon, WorksLike) == TRIPBOMB_WEAPON)
{ {
if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) if ((*kb) >= PWEAPON(snum, p->curr_weapon, TotalTime))
{ {
(*kb) = 0; (*kb) = 0;
P_CheckWeapon(p); P_CheckWeapon(p);
p->weapon_pos = -9; p->weapon_pos = -9;
} }
} }
else if (*kb >= aplWeaponReload[p->curr_weapon][snum]) else if (*kb >= PWEAPON(snum, p->curr_weapon, Reload))
P_CheckWeapon(p); P_CheckWeapon(p);
} }
else if (aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON && *kb >= aplWeaponFireDelay[p->curr_weapon][snum]) else if (PWEAPON(snum, p->curr_weapon, WorksLike)!=KNEE_WEAPON && *kb >= PWEAPON(snum, p->curr_weapon, FireDelay))
P_CheckWeapon(p); P_CheckWeapon(p);
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_STANDSTILL if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_STANDSTILL
&& *kb < (aplWeaponFireDelay[p->curr_weapon][snum]+1)) && *kb < (PWEAPON(snum, p->curr_weapon, FireDelay)+1))
{ {
p->pos.z = p->opos.z; p->pos.z = p->opos.z;
p->vel.z = 0; p->vel.z = 0;
} }
if (*kb == aplWeaponSound2Time[p->curr_weapon][snum]) if (*kb == PWEAPON(snum, p->curr_weapon, Sound2Time))
if (aplWeaponSound2Sound[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, Sound2Sound) > 0)
A_PlaySound(aplWeaponSound2Sound[p->curr_weapon][snum],p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, Sound2Sound),p->i);
if (*kb == aplWeaponSpawnTime[p->curr_weapon][snum]) if (*kb == PWEAPON(snum, p->curr_weapon, SpawnTime))
P_DoWeaponSpawn(p); P_DoWeaponSpawn(p);
if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) if ((*kb) >= PWEAPON(snum, p->curr_weapon, TotalTime))
{ {
if (/*!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_CHECKATRELOAD) && */ p->reloading == 1 || if (/*!(PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_CHECKATRELOAD) && */ p->reloading == 1 ||
(aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] && p->ammo_amount[p->curr_weapon] > 0 (PWEAPON(snum, p->curr_weapon, Reload) > PWEAPON(snum, p->curr_weapon, TotalTime) && p->ammo_amount[p->curr_weapon] > 0
&& (aplWeaponClip[p->curr_weapon][snum]) && (((p->ammo_amount[p->curr_weapon]%(aplWeaponClip[p->curr_weapon][snum]))==0)))) && (PWEAPON(snum, p->curr_weapon, Clip)) && (((p->ammo_amount[p->curr_weapon]%(PWEAPON(snum, p->curr_weapon, Clip)))==0))))
{ {
int32_t i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; int32_t i = PWEAPON(snum, p->curr_weapon, Reload) - PWEAPON(snum, p->curr_weapon, TotalTime);
p->reloading = 1; p->reloading = 1;
if ((*kb) != (aplWeaponTotalTime[p->curr_weapon][snum])) if ((*kb) != (PWEAPON(snum, p->curr_weapon, TotalTime)))
{ {
if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum]+1)) if ((*kb) == (PWEAPON(snum, p->curr_weapon, TotalTime)+1))
{ {
if (aplWeaponReloadSound1[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, ReloadSound1) > 0)
A_PlaySound(aplWeaponReloadSound1[p->curr_weapon][snum],p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, ReloadSound1),p->i);
} }
else if (((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i/3)) && else if (((*kb) == (PWEAPON(snum, p->curr_weapon, Reload) - (i/3)) &&
!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RELOAD_TIMING)) || !(PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_RELOAD_TIMING)) ||
((*kb) == (aplWeaponReload[p->curr_weapon][snum] - i+4) && ((*kb) == (PWEAPON(snum, p->curr_weapon, Reload) - i+4) &&
(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RELOAD_TIMING))) (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_RELOAD_TIMING)))
{ {
if (aplWeaponReloadSound2[p->curr_weapon][snum] > 0) if (PWEAPON(snum, p->curr_weapon, ReloadSound2) > 0)
A_PlaySound(aplWeaponReloadSound2[p->curr_weapon][snum],p->i); A_PlaySound(PWEAPON(snum, p->curr_weapon, ReloadSound2),p->i);
} }
else if ((*kb) >= (aplWeaponReload[p->curr_weapon][snum])) else if ((*kb) >= (PWEAPON(snum, p->curr_weapon, Reload)))
{ {
*kb=0; *kb=0;
p->reloading = 0; p->reloading = 0;
@ -4194,12 +4194,12 @@ void P_ProcessWeapon(int32_t snum)
} }
else else
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AUTOMATIC && if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_AUTOMATIC &&
(aplWeaponWorksLike[p->curr_weapon][snum]==KNEE_WEAPON?1:p->ammo_amount[p->curr_weapon] > 0)) (PWEAPON(snum, p->curr_weapon, WorksLike)==KNEE_WEAPON?1:p->ammo_amount[p->curr_weapon] > 0))
{ {
if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) if (TEST_SYNC_KEY(sb_snum, SK_FIRE))
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RANDOMRESTART) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_RANDOMRESTART)
*kb = 1+(krand()&3); *kb = 1+(krand()&3);
else *kb=1; else *kb=1;
} }
@ -4207,24 +4207,24 @@ void P_ProcessWeapon(int32_t snum)
} }
else *kb = 0; else *kb = 0;
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RESET && if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_RESET &&
((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0)) ((PWEAPON(snum, p->curr_weapon, WorksLike) == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0))
{ {
if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) *kb = 1; if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) *kb = 1;
else *kb = 0; else *kb = 0;
} }
} }
} }
else if (*kb >= aplWeaponFireDelay[p->curr_weapon][snum] && (*kb) < aplWeaponTotalTime[p->curr_weapon][snum] else if (*kb >= PWEAPON(snum, p->curr_weapon, FireDelay) && (*kb) < PWEAPON(snum, p->curr_weapon, TotalTime)
&& ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0)) && ((PWEAPON(snum, p->curr_weapon, WorksLike) == KNEE_WEAPON)?1:p->ammo_amount[p->curr_weapon] > 0))
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_AUTOMATIC) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_AUTOMATIC)
{ {
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_SEMIAUTO)) if (!(PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_SEMIAUTO))
{ {
if (TEST_SYNC_KEY(sb_snum, SK_FIRE) == 0 && aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RESET) if (TEST_SYNC_KEY(sb_snum, SK_FIRE) == 0 && PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_RESET)
*kb = 0; *kb = 0;
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYTHIRD) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_FIREEVERYTHIRD)
{ {
if (((*(kb))%3) == 0) if (((*(kb))%3) == 0)
{ {
@ -4232,22 +4232,22 @@ void P_ProcessWeapon(int32_t snum)
P_DoWeaponSpawn(p); P_DoWeaponSpawn(p);
} }
} }
else if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) else if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_FIREEVERYOTHER)
{ {
P_FireWeapon(p); P_FireWeapon(p);
P_DoWeaponSpawn(p); P_DoWeaponSpawn(p);
} }
else else
{ {
if (*kb == aplWeaponFireDelay[p->curr_weapon][snum]) if (*kb == PWEAPON(snum, p->curr_weapon, FireDelay))
{ {
P_FireWeapon(p); P_FireWeapon(p);
// P_DoWeaponSpawn(p); // P_DoWeaponSpawn(p);
} }
} }
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_RESET && if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_RESET &&
(*kb) > aplWeaponTotalTime[p->curr_weapon][snum]-aplWeaponHoldDelay[p->curr_weapon][snum] && (*kb) > PWEAPON(snum, p->curr_weapon, TotalTime)-PWEAPON(snum, p->curr_weapon, HoldDelay) &&
((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON) || p->ammo_amount[p->curr_weapon] > 0)) ((PWEAPON(snum, p->curr_weapon, WorksLike) == KNEE_WEAPON) || p->ammo_amount[p->curr_weapon] > 0))
{ {
if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) *kb = 1; if (TEST_SYNC_KEY(sb_snum, SK_FIRE)) *kb = 1;
else *kb = 0; else *kb = 0;
@ -4255,14 +4255,14 @@ void P_ProcessWeapon(int32_t snum)
} }
else else
{ {
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FIREEVERYOTHER) if (PWEAPON(snum, p->curr_weapon, Flags) & WEAPON_FIREEVERYOTHER)
{ {
P_FireWeapon(p); P_FireWeapon(p);
P_DoWeaponSpawn(p); P_DoWeaponSpawn(p);
} }
else else
{ {
if (*kb == aplWeaponFireDelay[p->curr_weapon][snum]) if (*kb == PWEAPON(snum, p->curr_weapon, FireDelay))
{ {
P_FireWeapon(p); P_FireWeapon(p);
// P_DoWeaponSpawn(p); // P_DoWeaponSpawn(p);
@ -4270,7 +4270,7 @@ void P_ProcessWeapon(int32_t snum)
} }
} }
} }
else if (*kb == aplWeaponFireDelay[p->curr_weapon][snum]) else if (*kb == PWEAPON(snum, p->curr_weapon, FireDelay))
P_FireWeapon(p); P_FireWeapon(p);
} }
} }
@ -4602,7 +4602,7 @@ void P_ProcessInput(int32_t snum)
P_UpdatePosWhenViewingCam(p); P_UpdatePosWhenViewingCam(p);
P_DoCounters(p); P_DoCounters(p);
if (*aplWeaponWorksLike[p->curr_weapon] == HANDREMOTE_WEAPON) if (PWEAPON(0, p->curr_weapon, WorksLike) == HANDREMOTE_WEAPON)
P_ProcessWeapon(snum); P_ProcessWeapon(snum);
return; return;
@ -5046,8 +5046,8 @@ void P_ProcessInput(int32_t snum)
} }
if (p->fist_incs || p->transporter_hold > 2 || p->hard_landing || p->access_incs > 0 || p->knee_incs > 0 || if (p->fist_incs || p->transporter_hold > 2 || p->hard_landing || p->access_incs > 0 || p->knee_incs > 0 ||
(*aplWeaponWorksLike[p->curr_weapon] == TRIPBOMB_WEAPON && (PWEAPON(0, p->curr_weapon, WorksLike) == TRIPBOMB_WEAPON &&
*kb > 1 && *kb < *aplWeaponFireDelay[p->curr_weapon])) *kb > 1 && *kb < PWEAPON(0, p->curr_weapon, FireDelay)))
{ {
doubvel = 0; doubvel = 0;
p->vel.x = 0; p->vel.x = 0;
@ -5169,7 +5169,7 @@ void P_ProcessInput(int32_t snum)
if (psectlotag == ST_2_UNDERWATER) if (psectlotag == ST_2_UNDERWATER)
j = 0x1400; j = 0x1400;
else if (p->on_ground && (TEST_SYNC_KEY(sb_snum, SK_CROUCH) || (*kb > 10 && aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON))) else if (p->on_ground && (TEST_SYNC_KEY(sb_snum, SK_CROUCH) || (*kb > 10 && PWEAPON(snum, p->curr_weapon, WorksLike) == KNEE_WEAPON)))
j = 0x2000; j = 0x2000;
p->vel.x = mulscale16(p->vel.x,p->runspeed-j); p->vel.x = mulscale16(p->vel.x,p->runspeed-j);

View file

@ -243,9 +243,38 @@ typedef struct {
} playerdata_t; } playerdata_t;
#pragma pack(pop) #pragma pack(pop)
typedef struct
{
// NOTE: the member names must be identical to aplWeapon* suffixes.
int32_t WorksLike; // What the original works like
int32_t Clip; // number of items in magazine
int32_t Reload; // delay to reload (include fire)
int32_t FireDelay; // delay to fire
int32_t TotalTime; // The total time the weapon is cycling before next fire.
int32_t HoldDelay; // delay after release fire button to fire (0 for none)
int32_t Flags; // Flags for weapon
int32_t Shoots; // what the weapon shoots
int32_t SpawnTime; // the frame at which to spawn an item
int32_t Spawn; // the item to spawn
int32_t ShotsPerBurst; // number of shots per 'burst' (one ammo per 'burst')
int32_t InitialSound; // Sound made when weapon starts firing. zero for no sound
int32_t FireSound; // Sound made when firing (each time for automatic)
int32_t Sound2Time; // Alternate sound time
int32_t Sound2Sound; // Alternate sound sound ID
int32_t ReloadSound1; // Sound of magazine being removed
int32_t ReloadSound2; // Sound of magazine being inserted
int32_t SelectSound; // Sound of weapon being selected
int32_t FlashColor; // Muzzle flash color
} weapondata_t;
extern int8_t g_numPlayerSprites; extern int8_t g_numPlayerSprites;
extern int32_t fricxv,fricyv; extern int32_t fricxv,fricyv;
#ifdef LUNATIC
# define PWEAPON(Player, Weapon, Wmember) (g_playerWeapon[Player][Weapon].Wmember)
extern weapondata_t g_playerWeapon[MAXPLAYERS][MAX_WEAPONS];
#else
# define PWEAPON(Player, Weapon, Wmember) (aplWeapon ## Wmember [Weapon][Player])
extern intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in clip extern intptr_t *aplWeaponClip[MAX_WEAPONS]; // number of items in clip
extern intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire) extern intptr_t *aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire)
extern intptr_t *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire extern intptr_t *aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire
@ -265,6 +294,7 @@ extern intptr_t *aplWeaponReloadSound1[MAX_WEAPONS]; // Sound of maga
extern intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted extern intptr_t *aplWeaponReloadSound2[MAX_WEAPONS]; // Sound of magazine being inserted
extern intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound for weapon selection extern intptr_t *aplWeaponSelectSound[MAX_WEAPONS]; // Sound for weapon selection
extern intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Color for polymer muzzle flash extern intptr_t *aplWeaponFlashColor[MAX_WEAPONS]; // Color for polymer muzzle flash
#endif
#pragma pack(push,1) #pragma pack(push,1)
extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS]; extern input_t inputfifo[MOVEFIFOSIZ][MAXPLAYERS];

View file

@ -807,9 +807,9 @@ void P_ResetStatus(int32_t snum)
p->on_crane = -1; p->on_crane = -1;
if ((aplWeaponWorksLike[p->curr_weapon][snum] == PISTOL_WEAPON) && if ((PWEAPON(snum, p->curr_weapon, WorksLike) == PISTOL_WEAPON) &&
(aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum])) (PWEAPON(snum, p->curr_weapon, Reload) > PWEAPON(snum, p->curr_weapon, TotalTime)))
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum]; p->kickback_pic = PWEAPON(snum, p->curr_weapon, TotalTime);
else p->kickback_pic = 0; else p->kickback_pic = 0;
p->weapon_pos = 6; p->weapon_pos = 6;
@ -840,7 +840,7 @@ void P_ResetWeapons(int32_t snum)
p->weapon_pos = 6; p->weapon_pos = 6;
p->curr_weapon = PISTOL_WEAPON; p->curr_weapon = PISTOL_WEAPON;
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum]; p->kickback_pic = PWEAPON(snum, p->curr_weapon, TotalTime);
p->gotweapon = ((1<<PISTOL_WEAPON) | (1<<KNEE_WEAPON) | (1<<HANDREMOTE_WEAPON)); p->gotweapon = ((1<<PISTOL_WEAPON) | (1<<KNEE_WEAPON) | (1<<HANDREMOTE_WEAPON));
p->ammo_amount[PISTOL_WEAPON] = min(p->max_ammo_amount[PISTOL_WEAPON], 48); p->ammo_amount[PISTOL_WEAPON] = min(p->max_ammo_amount[PISTOL_WEAPON], 48);
p->last_weapon = -1; p->last_weapon = -1;
@ -885,9 +885,9 @@ static void resetprestat(int32_t snum,int32_t g)
p->lastrandomspot = 0; p->lastrandomspot = 0;
p->weapon_pos = 6; p->weapon_pos = 6;
if ((aplWeaponWorksLike[p->curr_weapon][snum] == PISTOL_WEAPON) && if ((PWEAPON(snum, p->curr_weapon, WorksLike) == PISTOL_WEAPON) &&
(aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum])) (PWEAPON(snum, p->curr_weapon, Reload) > PWEAPON(snum, p->curr_weapon, TotalTime)))
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum]; p->kickback_pic = PWEAPON(snum, p->curr_weapon, TotalTime);
else p->kickback_pic = 0; else p->kickback_pic = 0;
p->last_weapon = -1; p->last_weapon = -1;
@ -1459,15 +1459,15 @@ void G_NewGame(int32_t vn,int32_t ln,int32_t sk)
{ {
for (i=0; i<MAX_WEAPONS; i++) for (i=0; i<MAX_WEAPONS; i++)
{ {
if (aplWeaponWorksLike[i][0]==PISTOL_WEAPON) if (PWEAPON(0, i, WorksLike)==PISTOL_WEAPON)
{ {
p->curr_weapon = i; p->curr_weapon = i;
p->gotweapon |= (1<<i); p->gotweapon |= (1<<i);
p->ammo_amount[i] = min(p->max_ammo_amount[i], 48); p->ammo_amount[i] = min(p->max_ammo_amount[i], 48);
} }
else if (aplWeaponWorksLike[i][0]==KNEE_WEAPON) else if (PWEAPON(0, i, WorksLike)==KNEE_WEAPON)
p->gotweapon |= (1<<i); p->gotweapon |= (1<<i);
else if (aplWeaponWorksLike[i][0]==HANDREMOTE_WEAPON) else if (PWEAPON(0, i, WorksLike)==HANDREMOTE_WEAPON)
p->gotweapon |= (1<<i); p->gotweapon |= (1<<i);
} }
p->last_weapon = -1; p->last_weapon = -1;

View file

@ -2756,7 +2756,7 @@ CHECKINV1:
} }
} }
Gv_SetVar(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum],p->i,snum); Gv_SetVar(g_iWorksLikeVarID,PWEAPON(snum, p->curr_weapon, WorksLike),p->i,snum);
Gv_SetVar(g_iWeaponVarID,j, p->i, snum); Gv_SetVar(g_iWeaponVarID,j, p->i, snum);
j = VM_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1, j); j = VM_OnEvent(EVENT_SELECTWEAPON,p->i,snum, -1, j);