- moved gamevar storage to player and actor objects respectively.

For actors this eliminates the need to for sprite indices which was the intended goal. It also properly associates the gamevars with their owners.
This commit is contained in:
Christoph Oelckers 2021-12-05 13:43:31 +01:00
parent fa05cfbaf1
commit 122a1f009d
14 changed files with 651 additions and 691 deletions

View file

@ -176,7 +176,7 @@ void checkavailweapon(struct player_struct* player)
SetGameVarID(g_iWeaponVarID, player->curr_weapon, player->GetActor(), snum); // snum is player index!
if (player->curr_weapon >= 0)
{
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[player->curr_weapon][snum], player->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, snum), player->GetActor(), snum);
}
else
{

View file

@ -240,31 +240,7 @@ void addweapon_d(struct player_struct *p, int weapon)
}
p->okickback_pic = p->kickback_pic = 0;
#ifdef EDUKE
if(p->curr_weapon != weapon)
{
int snum;
snum = p->GetPlayerNum();
SetGameVarID(g_iWeaponVarID,weapon, snum, p->GetActor());
if (p->curr_weapon >= 0)
{
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[weapon][snum], snum, p->GetActor());
}
else
{
SetGameVarID(g_iWorksLikeVarID, -1, snum, p->GetActor());
}
SetGameVarID(g_iReturnVarID, 0, snum, -1);
OnEvent(EVENT_CHANGEWEAPON, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, nullptr, snum) == 0)
{
p->curr_weapon = weapon;
}
}
#else
p->curr_weapon = weapon;
#endif
p->wantweaponfire = -1;
switch (weapon)

View file

@ -197,7 +197,7 @@ const char* GameInterface::GenericCheat(int player, int cheat)
case CHT_RHETT:
ud.god = 0;
memset(ps[player].gotweapon, 0, MAX_WEAPONS);
memset(ps[player].gotweapon, 0, sizeof(ps[player].gotweapon));
ps[player].curr_weapon = KNEE_WEAPON;
ps[player].nocheat = 1;
ps[player].GetActor()->s->extra = 1;

View file

@ -3235,8 +3235,7 @@ void loadcons()
}
// These can only be retrieved AFTER loading the scripts.
InitGameVarPointers();
ResetSystemDefaults();
FinalizeGameVars();
S_WorldTourMappingsForOldSounds(); // create a sound mapping for World Tour.
S_CacheAllSounds();
comp.setmusic();

File diff suppressed because it is too large Load diff

View file

@ -37,21 +37,23 @@ enum
NAM_GRENADE_LIFETIME_VAR = 30,
};
extern int* aplWeaponClip[MAX_WEAPONS]; // number of items in clip
extern int* aplWeaponReload[MAX_WEAPONS]; // delay to reload (include fire)
extern int* aplWeaponFireDelay[MAX_WEAPONS]; // delay to fire
extern int* aplWeaponHoldDelay[MAX_WEAPONS]; // delay after release fire button to fire (0 for none)
extern int* aplWeaponTotalTime[MAX_WEAPONS]; // The total time the weapon is cycling before next fire.
extern int* aplWeaponFlags[MAX_WEAPONS]; // Flags for weapon
extern int* aplWeaponShoots[MAX_WEAPONS]; // what the weapon shoots
extern int* aplWeaponSpawnTime[MAX_WEAPONS]; // the frame at which to spawn an item
extern int* aplWeaponSpawn[MAX_WEAPONS]; // the item to spawn
extern int* aplWeaponShotsPerBurst[MAX_WEAPONS]; // number of shots per 'burst' (one ammo per 'burst'
extern int* aplWeaponWorksLike[MAX_WEAPONS]; // What original the weapon works like
extern int* aplWeaponInitialSound[MAX_WEAPONS]; // Sound made when initialy firing. zero for no sound
extern int* aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each time for automatic)
extern int* aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time
extern int* aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID
// Keep the gory details away from the main game code.
int aplWeaponClip(int weapon, int player); // number of items in clip
int aplWeaponReload(int weapon, int player); // delay to reload (include fire)
int aplWeaponFireDelay(int weapon, int player); // delay to fire
int aplWeaponHoldDelay(int weapon, int player); // delay after release fire button to fire (0 for none)
int aplWeaponTotalTime(int weapon, int player); // The total time the weapon is cycling before next fire.
int aplWeaponFlags(int weapon, int player); // Flags for weapon
int aplWeaponShoots(int weapon, int player); // what the weapon shoots
int aplWeaponSpawnTime(int weapon, int player); // the frame at which to spawn an item
int aplWeaponSpawn(int weapon, int player); // the item to spawn
int aplWeaponShotsPerBurst(int weapon, int player); // number of shots per 'burst' (one ammo per 'burst'
int aplWeaponWorksLike(int weapon, int player); // What original the weapon works like
int aplWeaponInitialSound(int weapon, int player); // Sound made when initialy firing. zero for no sound
int aplWeaponFireSound(int weapon, int player); // Sound made when firing (each time for automatic)
int aplWeaponSound2Time(int weapon, int player); // Alternate sound time
int aplWeaponSound2Sound(int weapon, int player); // Alternate sound sound ID
enum
@ -98,9 +100,9 @@ typedef struct
int (*getter)();
};
int defaultValue;
int initValue; // this is what gets copied to players/actors upon spawn. This is not the same as the default!
unsigned int dwFlags;
char szLabel[MAXVARLABEL];
TArray<int> plArray;
} MATTGAMEVAR;
extern MATTGAMEVAR aGameVars[MAXGAMEVARS];
@ -132,7 +134,8 @@ int GetGameVar(const char* szGameLabel, int lDefault, DDukeActor* sActor, int sP
void ClearGameEvents();
bool IsGameEvent(int i);
void InitGameVarPointers(void);
void ResetSystemDefaults(void);
void FinalizeGameVars(void);
void SetupGameVarsForActor(DDukeActor* actor);

View file

@ -269,11 +269,11 @@ void displayweapon_d(int snum, double smoothratio)
{
if (p->last_weapon >= 0)
{
cw = aplWeaponWorksLike[p->last_weapon][snum];
cw = aplWeaponWorksLike(p->last_weapon, snum);
}
else
{
cw = aplWeaponWorksLike[p->curr_weapon][snum];
cw = aplWeaponWorksLike(p->curr_weapon, snum);
}
}
else
@ -388,7 +388,7 @@ void displayweapon_d(int snum, double smoothratio)
if (*kb > 0)
{
if (*kb < (isWW2GI() ? aplWeaponTotalTime[RPG_WEAPON][snum] : 8))
if (*kb < (isWW2GI() ? aplWeaponTotalTime(RPG_WEAPON, snum) : 8))
{
hud_drawpal(weapon_xoffset + 164, (looking_arc * 2.) + 176 - gun_pos,
RPGGUN + (*kb >> 1), shade, o | pin, pal);
@ -398,20 +398,20 @@ void displayweapon_d(int snum, double smoothratio)
// else we are in 'reload time'
if (*kb <
(
(aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]) / 2
+ aplWeaponTotalTime[p->curr_weapon][snum]
(aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 2
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// down
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime[p->curr_weapon][snum]); //D
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime(p->curr_weapon, snum)); //D
}
else
{
// move back down
// up and left
gun_pos -= 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic); //U
gun_pos -= 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); //U
}
}
}
@ -443,21 +443,20 @@ void displayweapon_d(int snum, double smoothratio)
{
hud_drawpal(weapon_xoffset + 146 - look_anghalf, looking_arc + 202 - gun_pos, SHOTGUN, shade, o, pal);
}
else if (*kb <= aplWeaponTotalTime[SHOTGUN_WEAPON][snum])
else if (*kb <= aplWeaponTotalTime(SHOTGUN_WEAPON, snum))
{
hud_drawpal(weapon_xoffset + 146 - look_anghalf, looking_arc + 202 - gun_pos, SHOTGUN + 1, shade, o, pal);
}
// else we are in 'reload time'
else if (*kb <
(
(aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]) / 2
+ aplWeaponTotalTime[p->curr_weapon][snum]
(aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 2
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// down
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime[p->curr_weapon][snum]); //D
// weapon_xoffset+=80*(*kb-aplWeaponTotalTime[cw][snum]);
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime(p->curr_weapon, snum)); //D
hud_drawpal(weapon_xoffset + 146 - look_anghalf, looking_arc + 202 - gun_pos, SHOTGUN, shade, o, pal);
}
else
@ -465,8 +464,7 @@ void displayweapon_d(int snum, double smoothratio)
// move back down
// up and left
gun_pos -= 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic); //U
// weapon_xoffset+=80*(*kb-aplWeaponTotalTime[cw][snum]);
gun_pos -= 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); //U
hud_drawpal(weapon_xoffset + 146 - look_anghalf, looking_arc + 202 - gun_pos, SHOTGUN, shade, o, pal);
}
};
@ -561,7 +559,7 @@ void displayweapon_d(int snum, double smoothratio)
// CHAINGUN,gs,o,pal);
hud_drawpal(weapon_xoffset + 178 - look_anghalf, looking_arc + 233 - gun_pos, CHAINGUN + 1, shade, o, pal);
}
else if (*kb <= aplWeaponTotalTime[CHAINGUN_WEAPON][snum])
else if (*kb <= aplWeaponTotalTime(CHAINGUN_WEAPON, snum))
{
hud_drawpal(weapon_xoffset + 188 - look_anghalf, looking_arc + 243 - gun_pos, CHAINGUN + 2, shade, o, pal);
}
@ -575,57 +573,57 @@ void displayweapon_d(int snum, double smoothratio)
else
{
int iFifths = (aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]) / 5;
int iFifths = (aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 5;
if (iFifths < 1)
{
iFifths = 1;
}
if (*kb <
(iFifths
+ aplWeaponTotalTime[p->curr_weapon][snum]
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// first segment
//
gun_pos += 80 - (10 * (aplWeaponTotalTime[p->curr_weapon][snum] + iFifths - kickback_pic));
weapon_xoffset += 80 - (10 * (aplWeaponTotalTime[p->curr_weapon][snum] + iFifths - kickback_pic));
gun_pos += 80 - (10 * (aplWeaponTotalTime(p->curr_weapon, snum) + iFifths - kickback_pic));
weapon_xoffset += 80 - (10 * (aplWeaponTotalTime(p->curr_weapon, snum) + iFifths - kickback_pic));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2519, shade, o, pal);
}
else if (*kb <
(iFifths * 2
+ aplWeaponTotalTime[p->curr_weapon][snum]
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// second segment
// down
gun_pos += 80; //5*(iFifthsp->kickback_pic-aplWeaponTotalTime[p->curr_weapon][snum]); //D
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime[p->curr_weapon][snum]);
gun_pos += 80; //5*(iFifthsp->kickback_pic-aplWeaponTotalTime(p->curr_weapon, snum)); //D
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime(p->curr_weapon, snum));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2518, shade, o, pal);
}
else if (*kb <
(iFifths * 3
+ aplWeaponTotalTime[p->curr_weapon][snum]
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// third segment
// up
gun_pos += 80;//5*(iFifths*2);
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime[p->curr_weapon][snum]);
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime(p->curr_weapon, snum));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2517, shade, o, pal);
}
else if (*kb <
(iFifths * 4
+ aplWeaponTotalTime[p->curr_weapon][snum]
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// fourth segment
// down
gun_pos += 80; //5*(aplWeaponTotalTime[p->curr_weapon][snum]- p->kickback_pic); //D
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime[p->curr_weapon][snum]);
gun_pos += 80; //5*(aplWeaponTotalTime(p->curr_weapon, snum)- p->kickback_pic); //D
weapon_xoffset += 80; //80*(*kb-aplWeaponTotalTime(p->curr_weapon, snum));
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2518, shade, o, pal);
}
else
@ -633,10 +631,8 @@ void displayweapon_d(int snum, double smoothratio)
// move back down
// up and left
gun_pos += 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic);
//5*(aplWeaponReload[p->curr_weapon][snum]- p->kickback_pic); //U
weapon_xoffset += 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic);
//80*(*kb-aplWeaponTotalTime[cw][snum]);
gun_pos += 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic);
weapon_xoffset += 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic);
hud_drawpal(weapon_xoffset + 168 - look_anghalf, looking_arc + 260 - gun_pos, 2519, shade, o, pal);
}
}
@ -712,7 +708,7 @@ void displayweapon_d(int snum, double smoothratio)
auto pic_5 = FIRSTGUN+5;
const int WEAPON2_RELOAD_TIME = 50;
auto reload_time = isWW2GI() ? aplWeaponReload[PISTOL_WEAPON][snum] : WEAPON2_RELOAD_TIME;
auto reload_time = isWW2GI() ? aplWeaponReload(PISTOL_WEAPON, snum) : WEAPON2_RELOAD_TIME;
if (*kb < 10)
hud_drawpal(194 - look_anghalf, looking_arc + 230 - gun_pos, FIRSTGUN + 4, shade, o|pin, pal);
else if (*kb < 15)
@ -755,28 +751,28 @@ void displayweapon_d(int snum, double smoothratio)
if (isWW2GI())
{
if (*kb <= aplWeaponFireDelay[HANDBOMB_WEAPON][snum])
if (*kb <= aplWeaponFireDelay(HANDBOMB_WEAPON, snum))
{
// it holds here
gun_pos -= 5 * kickback_pic; //D
}
else if (*kb <
(
(aplWeaponTotalTime[HANDBOMB_WEAPON][snum] - aplWeaponFireDelay[HANDBOMB_WEAPON][snum]) / 2
+ aplWeaponFireDelay[HANDBOMB_WEAPON][snum]
(aplWeaponTotalTime(HANDBOMB_WEAPON, snum) - aplWeaponFireDelay(HANDBOMB_WEAPON, snum)) / 2
+ aplWeaponFireDelay(HANDBOMB_WEAPON, snum)
)
)
{
// up and left
gun_pos += 10 * (kickback_pic - aplWeaponFireDelay[HANDBOMB_WEAPON][snum]); //U
weapon_xoffset += 80 * (kickback_pic - aplWeaponFireDelay[HANDBOMB_WEAPON][snum]);
gun_pos += 10 * (kickback_pic - aplWeaponFireDelay(HANDBOMB_WEAPON, snum)); //U
weapon_xoffset += 80 * (kickback_pic - aplWeaponFireDelay(HANDBOMB_WEAPON, snum));
}
else if (*kb < aplWeaponTotalTime[HANDBOMB_WEAPON][snum])
else if (*kb < aplWeaponTotalTime(HANDBOMB_WEAPON, snum))
{
gun_pos += 240; // start high
gun_pos -= 12 * (kickback_pic - aplWeaponFireDelay[HANDBOMB_WEAPON][snum]); //D
gun_pos -= 12 * (kickback_pic - aplWeaponFireDelay(HANDBOMB_WEAPON, snum)); //D
// move left
weapon_xoffset += 90 - (5 * (aplWeaponTotalTime[HANDBOMB_WEAPON][snum] - kickback_pic));
weapon_xoffset += 90 - (5 * (aplWeaponTotalTime(HANDBOMB_WEAPON, snum) - kickback_pic));
}
}
else
@ -822,7 +818,7 @@ void displayweapon_d(int snum, double smoothratio)
{
if (*kb)
{
if (*kb < aplWeaponTotalTime[p->curr_weapon][snum])
if (*kb < aplWeaponTotalTime(p->curr_weapon, snum))
{
i = Sgn(*kb >> 2);
if (p->ammo_amount[p->curr_weapon] & 1)
@ -839,13 +835,13 @@ void displayweapon_d(int snum, double smoothratio)
// else we are in 'reload time'
else if (*kb <
(
(aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]) / 2
+ aplWeaponTotalTime[p->curr_weapon][snum]
(aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 2
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// down
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime[p->curr_weapon][snum]); //D
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime(p->curr_weapon, snum)); //D
// weapon_xoffset+=80*(*kb-aplWeaponTotalTime[cw][snum]);
hud_drawpal(weapon_xoffset + 268 - look_anghalf, looking_arc + 238 - gun_pos, DEVISTATOR, shade, o, pal);
hud_drawpal(weapon_xoffset + 30 - look_anghalf, looking_arc + 240 - gun_pos, DEVISTATOR, shade, o | 4, pal);
@ -855,7 +851,7 @@ void displayweapon_d(int snum, double smoothratio)
// move back down
// up and left
gun_pos -= 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic); //U
gun_pos -= 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); //U
// weapon_xoffset+=80*(*kb-aplWeaponTotalTime[cw][snum]);
hud_drawpal(weapon_xoffset + 268 - look_anghalf, looking_arc + 238 - gun_pos, DEVISTATOR, shade, o, pal);
hud_drawpal(weapon_xoffset + 30 - look_anghalf, looking_arc + 240 - gun_pos, DEVISTATOR, shade, o | 4, pal);
@ -972,9 +968,9 @@ void displayweapon_d(int snum, double smoothratio)
}
if (*kb < aplWeaponTotalTime[p->curr_weapon][snum])
if (*kb < aplWeaponTotalTime(p->curr_weapon, snum))
{
if (*kb < aplWeaponFireDelay[p->curr_weapon][snum])
if (*kb < aplWeaponFireDelay(p->curr_weapon, snum))
{
// before fire time.
// nothing to modify
@ -985,24 +981,24 @@ void displayweapon_d(int snum, double smoothratio)
// after fire time.
// lower weapon to reload cartridge (not clip)
gun_pos -= 10 * (aplWeaponTotalTime[p->curr_weapon][snum] - kickback_pic);
gun_pos -= 10 * (aplWeaponTotalTime(p->curr_weapon, snum) - kickback_pic);
}
}
// else we are in 'reload time'
else if (*kb <
(
(aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]) / 2
+ aplWeaponTotalTime[p->curr_weapon][snum]
(aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 2
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// down
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime[p->curr_weapon][snum]); //D
gun_pos -= 10 * (kickback_pic - aplWeaponTotalTime(p->curr_weapon, snum)); //D
}
else
{
// up
gun_pos -= 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic); //U
gun_pos -= 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); //U
}
// draw weapon
@ -1043,9 +1039,9 @@ void displayweapon_d(int snum, double smoothratio)
gun_pos += (rand() & 3);
}
if (*kb < aplWeaponTotalTime[p->curr_weapon][snum])
if (*kb < aplWeaponTotalTime(p->curr_weapon, snum))
{
if (*kb < aplWeaponFireDelay[p->curr_weapon][snum])
if (*kb < aplWeaponFireDelay(p->curr_weapon, snum))
{
// before fire time.
// nothing to modify
@ -1056,24 +1052,24 @@ void displayweapon_d(int snum, double smoothratio)
// after fire time.
// lower weapon to reload cartridge (not clip)
gun_pos -= 15 * (aplWeaponTotalTime[p->curr_weapon][snum] - kickback_pic);
gun_pos -= 15 * (aplWeaponTotalTime(p->curr_weapon, snum) - kickback_pic);
}
}
// else we are in 'reload time'
else if (*kb <
(
(aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]) / 2
+ aplWeaponTotalTime[p->curr_weapon][snum]
(aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum)) / 2
+ aplWeaponTotalTime(p->curr_weapon, snum)
)
)
{
// down
gun_pos -= 5 * (kickback_pic - aplWeaponTotalTime[p->curr_weapon][snum]); //D
gun_pos -= 5 * (kickback_pic - aplWeaponTotalTime(p->curr_weapon, snum)); //D
}
else
{
// up
gun_pos -= 10 * (aplWeaponReload[p->curr_weapon][snum] - kickback_pic); //U
gun_pos -= 10 * (aplWeaponReload(p->curr_weapon, snum) - kickback_pic); //U
}
// display weapon

View file

@ -258,7 +258,7 @@ DDukeActor* aim(DDukeActor* actor, int aang)
}
else
{
weap = aplWeaponWorksLike[ps[s->yvel].curr_weapon][s->yvel];
weap = aplWeaponWorksLike(ps[s->yvel].curr_weapon, s->yvel);
}
if (weap > CHAINGUN_WEAPON || weap == KNEE_WEAPON)
{
@ -277,8 +277,8 @@ DDukeActor* aim(DDukeActor* actor, int aang)
}
else if (isWW2GI())
{
gotshrinker = s->picnum == TILE_APLAYER && aplWeaponWorksLike[ps[s->yvel].curr_weapon][s->yvel] == SHRINKER_WEAPON;
gotfreezer = s->picnum == TILE_APLAYER && aplWeaponWorksLike[ps[s->yvel].curr_weapon][s->yvel] == FREEZE_WEAPON;
gotshrinker = s->picnum == TILE_APLAYER && aplWeaponWorksLike(ps[s->yvel].curr_weapon, s->yvel) == SHRINKER_WEAPON;
gotfreezer = s->picnum == TILE_APLAYER && aplWeaponWorksLike(ps[s->yvel].curr_weapon, s->yvel) == FREEZE_WEAPON;
}
else
{
@ -937,13 +937,13 @@ bool movementBlocked(player_struct *p)
auto blockingweapon = [=]()
{
if (isRR()) return false;
if (isWW2GI()) return aplWeaponWorksLike[p->curr_weapon][p->GetPlayerNum()] == TRIPBOMB_WEAPON;
if (isWW2GI()) return aplWeaponWorksLike(p->curr_weapon, p->GetPlayerNum()) == TRIPBOMB_WEAPON;
else return p->curr_weapon == TRIPBOMB_WEAPON;
};
auto weapondelay = [=]()
{
if (isWW2GI()) return aplWeaponFireDelay[p->curr_weapon][p->GetPlayerNum()];
if (isWW2GI()) return aplWeaponFireDelay(p->curr_weapon, p->GetPlayerNum());
else return 4;
};

View file

@ -814,7 +814,7 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i
spj->extra >>= 2;
}
}
else if ((isWW2GI() && aplWeaponWorksLike[ps[p].curr_weapon][p] == DEVISTATOR_WEAPON) || (!isWW2GI() && ps[p].curr_weapon == DEVISTATOR_WEAPON))
else if ((isWW2GI() && aplWeaponWorksLike(ps[p].curr_weapon, p) == DEVISTATOR_WEAPON) || (!isWW2GI() && ps[p].curr_weapon == DEVISTATOR_WEAPON))
{
spj->extra >>= 2;
spj->ang += 16 - (krand() & 31);
@ -1653,7 +1653,7 @@ void checkweapons_d(struct player_struct* p)
if (isWW2GI())
{
int snum = p->GetActor()->s->yvel;
cw = aplWeaponWorksLike[p->curr_weapon][snum];
cw = aplWeaponWorksLike(p->curr_weapon, snum);
}
else
cw = p->curr_weapon;
@ -2449,7 +2449,7 @@ static void operateweapon(int snum, ESyncBits actions)
//#ifdef NAM
//#else
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE))
if (!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_NOVISIBLE))
{
// make them visible if not set...
p->visibility = 0;
@ -2459,11 +2459,11 @@ static void operateweapon(int snum, ESyncBits actions)
//#endif
}
else if (!isNam()) p->kickback_pic++;
if (isNam() && p->kickback_pic > aplWeaponReload[p->curr_weapon][snum]) // 30)
if (isNam() && p->kickback_pic > aplWeaponReload(p->curr_weapon, snum)) // 30)
{
// reload now...
p->okickback_pic = p->kickback_pic = 0;
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE))
if (!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_NOVISIBLE))
{
// make them visible if not set...
p->visibility = 0;
@ -2655,21 +2655,21 @@ static void processweapon(int snum, ESyncBits actions)
{
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
OnEvent(EVENT_HOLSTER, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
// now it uses the game definitions...
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_HOLSTER_CLEARS_CLIP)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_HOLSTER_CLEARS_CLIP)
{
if (p->ammo_amount[p->curr_weapon] > aplWeaponClip[p->curr_weapon][snum]
&& (p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum]) != 0)
if (p->ammo_amount[p->curr_weapon] > aplWeaponClip(p->curr_weapon, snum)
&& (p->ammo_amount[p->curr_weapon] % aplWeaponClip(p->curr_weapon, snum)) != 0)
{
// throw away the remaining clip
p->ammo_amount[p->curr_weapon] -=
p->ammo_amount[p->curr_weapon] % aplWeaponClip[p->curr_weapon][snum];
// p->kickback_pic = aplWeaponFireDelay[p->curr_weapon][snum]+1; // animate, but don't shoot...
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum] + 1; // animate, but don't shoot...
p->ammo_amount[p->curr_weapon] % aplWeaponClip(p->curr_weapon, snum);
// p->kickback_pic = aplWeaponFireDelay(p->curr_weapon, snum)+1; // animate, but don't shoot...
p->kickback_pic = aplWeaponTotalTime(p->curr_weapon, snum) + 1; // animate, but don't shoot...
actions &= ~SB_FIRE; // not firing...
}
return;
@ -2690,7 +2690,7 @@ static void processweapon(int snum, ESyncBits actions)
}
if (isWW2GI() && (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_GLOWS))
if (isWW2GI() && (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_GLOWS))
p->random_club_frame += 64; // Glowing
if (!isWW2GI() && (p->curr_weapon == SHRINKER_WEAPON || p->curr_weapon == GROW_WEAPON))
@ -2849,7 +2849,7 @@ void processinput_d(int snum)
fi.doincrements(p);
if (isWW2GI() && aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) processweapon(snum, actions);
if (isWW2GI() && aplWeaponWorksLike(p->curr_weapon, snum) == HANDREMOTE_WEAPON) processweapon(snum, actions);
if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions);
return;
}
@ -2992,7 +2992,7 @@ void processinput_d(int snum)
bool check;
if (!isWW2GI()) check = ((p->curr_weapon == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)));
else check = ((aplWeaponWorksLike[p->curr_weapon][snum] == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)));
else check = ((aplWeaponWorksLike(p->curr_weapon, snum) == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)));
if (check)
{
p->posxv = MulScale(p->posxv, gs.playerfriction - 0x2000, 16);

View file

@ -53,48 +53,48 @@ void DoFire(struct player_struct* p, int snum)
{
int i;
if (aplWeaponWorksLike[p->curr_weapon][snum] != KNEE_WEAPON)
if (aplWeaponWorksLike(p->curr_weapon, snum) != KNEE_WEAPON)
{
p->ammo_amount[p->curr_weapon]--;
}
if (aplWeaponFireSound[p->curr_weapon][snum])
if (aplWeaponFireSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponFireSound[p->curr_weapon][snum], p->GetActor());
S_PlayActorSound(aplWeaponFireSound(p->curr_weapon, snum), p->GetActor());
}
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
fi.shoot(p->GetActor(), aplWeaponShoots[p->curr_weapon][snum]);
for (i = 1; i < aplWeaponShotsPerBurst[p->curr_weapon][snum]; i++)
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
fi.shoot(p->GetActor(), aplWeaponShoots(p->curr_weapon, snum));
for (i = 1; i < aplWeaponShotsPerBurst(p->curr_weapon, snum); i++)
{
fi.shoot(p->GetActor(), aplWeaponShoots[p->curr_weapon][snum]);
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AMMOPERSHOT)
fi.shoot(p->GetActor(), aplWeaponShoots(p->curr_weapon, snum));
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AMMOPERSHOT)
{
p->ammo_amount[p->curr_weapon]--;
}
}
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE))
if (!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_NOVISIBLE))
{
// make them visible if not set...
lastvisinc = PlayClock + 32;
p->visibility = 0;
}
if ( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]
if ( //!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload(p->curr_weapon, snum) > aplWeaponTotalTime(p->curr_weapon, snum)
&& p->ammo_amount[p->curr_weapon] > 0
&& (aplWeaponClip[p->curr_weapon][snum])
&& ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum])) == 0)
&& (aplWeaponClip(p->curr_weapon, snum))
&& ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip(p->curr_weapon, snum))) == 0)
)
{
// do clip check...
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum];
p->kickback_pic = aplWeaponTotalTime(p->curr_weapon, snum);
// is same as p->kickback_pic....
}
if (aplWeaponWorksLike[p->curr_weapon][snum] != KNEE_WEAPON)
if (aplWeaponWorksLike(p->curr_weapon, snum) != KNEE_WEAPON)
{
checkavailweapon(p);
}
@ -108,13 +108,13 @@ void DoFire(struct player_struct* p, int snum)
void DoSpawn(struct player_struct *p, int snum)
{
if(!aplWeaponSpawn[p->curr_weapon][snum])
if(!aplWeaponSpawn(p->curr_weapon, snum))
return;
auto j = spawn(p->GetActor(), aplWeaponSpawn[p->curr_weapon][snum]);
auto j = spawn(p->GetActor(), aplWeaponSpawn(p->curr_weapon, snum));
if (!j) return;
if((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE2 ) )
if((aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_SPAWNTYPE2 ) )
{
// like shotgun shells
j->s->ang += 1024;
@ -122,7 +122,7 @@ void DoSpawn(struct player_struct *p, int snum)
j->s->ang += 1024;
// p->kickback_pic++;
}
else if((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE3 ) )
else if((aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_SPAWNTYPE3 ) )
{
// like chaingun shells
j->s->ang += 1024;
@ -160,29 +160,29 @@ void fireweapon_ww(int snum)
{
SetGameVarID(g_iReturnVarID, 0, p->GetActor(), snum);
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
OnEvent(EVENT_FIRE, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum) == 0)
{
switch (aplWeaponWorksLike[p->curr_weapon][snum])
switch (aplWeaponWorksLike(p->curr_weapon, snum))
{
case HANDBOMB_WEAPON:
p->hbomb_hold_delay = 0;
if (p->ammo_amount[p->curr_weapon] > 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
case HANDREMOTE_WEAPON:
p->hbomb_hold_delay = 0;
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
break;
@ -191,9 +191,9 @@ void fireweapon_ww(int snum)
{
//p->ammo_amount[p->curr_weapon]--;
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -203,9 +203,9 @@ void fireweapon_ww(int snum)
if (p->ammo_amount[p->curr_weapon] > 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -214,9 +214,9 @@ void fireweapon_ww(int snum)
if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -224,9 +224,9 @@ void fireweapon_ww(int snum)
if (operateTripbomb(snum))
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -235,9 +235,9 @@ void fireweapon_ww(int snum)
if (p->ammo_amount[p->curr_weapon] > 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -246,9 +246,9 @@ void fireweapon_ww(int snum)
if (p->ammo_amount[p->curr_weapon] > 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -257,9 +257,9 @@ void fireweapon_ww(int snum)
if (p->ammo_amount[p->curr_weapon] > 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -268,9 +268,9 @@ void fireweapon_ww(int snum)
{
p->kickback_pic = 1;
p->hbomb_hold_delay = !p->hbomb_hold_delay;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -279,9 +279,9 @@ void fireweapon_ww(int snum)
if (p->ammo_amount[RPG_WEAPON] > 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -290,9 +290,9 @@ void fireweapon_ww(int snum)
if (p->quick_kick == 0)
{
p->kickback_pic = 1;
if (aplWeaponInitialSound[p->curr_weapon][snum])
if (aplWeaponInitialSound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponInitialSound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
}
}
break;
@ -314,10 +314,10 @@ void operateweapon_ww(int snum, ESyncBits actions)
int i, k;
// already firing...
if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON)
if (aplWeaponWorksLike(p->curr_weapon, snum) == HANDBOMB_WEAPON)
{
if (aplWeaponHoldDelay[p->curr_weapon][snum] // there is a hold delay
&& (p->kickback_pic == aplWeaponFireDelay[p->curr_weapon][snum]) // and we are 'at' hold
if (aplWeaponHoldDelay(p->curr_weapon, snum) // there is a hold delay
&& (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, snum)) // and we are 'at' hold
&& (actions & SB_FIRE) // and 'fire' button is still down
)
// just hold here...
@ -326,7 +326,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
return;
}
p->kickback_pic++;
if (p->kickback_pic == aplWeaponHoldDelay[p->curr_weapon][snum])
if (p->kickback_pic == aplWeaponHoldDelay(p->curr_weapon, snum))
{
p->ammo_amount[p->curr_weapon]--;
@ -376,43 +376,43 @@ void operateweapon_ww(int snum, ESyncBits actions)
}
}
else if (p->kickback_pic < aplWeaponHoldDelay[p->curr_weapon][snum] &&
else if (p->kickback_pic < aplWeaponHoldDelay(p->curr_weapon, snum) &&
(actions & SB_CROUCH))
{
p->hbomb_hold_delay++;
}
else if (p->kickback_pic > aplWeaponTotalTime[p->curr_weapon][snum])
else if (p->kickback_pic > aplWeaponTotalTime(p->curr_weapon, snum))
{
p->okickback_pic = p->kickback_pic = 0;
// don't change to remote when in NAM: grenades are timed
checkavailweapon(p);
}
}
else if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON)
else if (aplWeaponWorksLike(p->curr_weapon, snum) == HANDREMOTE_WEAPON)
{
p->kickback_pic++;
if (p->kickback_pic == aplWeaponFireDelay[p->curr_weapon][snum])
if (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, snum))
{
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_BOMB_TRIGGER)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_BOMB_TRIGGER)
{
p->hbomb_on = 0;
}
if (aplWeaponShoots[p->curr_weapon][snum] != 0)
if (aplWeaponShoots(p->curr_weapon, snum) != 0)
{
if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE))
if (!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_NOVISIBLE))
{
// make them visible if not set...
lastvisinc = PlayClock + 32;
p->visibility = 0;
}
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->GetActor(), snum);
fi.shoot(p->GetActor(), aplWeaponShoots[p->curr_weapon][snum]);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
fi.shoot(p->GetActor(), aplWeaponShoots(p->curr_weapon, snum));
}
}
if (p->kickback_pic >= aplWeaponTotalTime[p->curr_weapon][snum])
if (p->kickback_pic >= aplWeaponTotalTime(p->curr_weapon, snum))
{
p->okickback_pic = p->kickback_pic = 0;
/// WHAT THE HELL DOES THIS DO....?????????????
@ -429,47 +429,47 @@ void operateweapon_ww(int snum, ESyncBits actions)
// the basic weapon...
p->kickback_pic++;
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_CHECKATRELOAD)
{
if (p->kickback_pic == aplWeaponReload[p->curr_weapon][snum])
if (p->kickback_pic == aplWeaponReload(p->curr_weapon, snum))
{
checkavailweapon(p);
}
}
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_STANDSTILL
&& p->kickback_pic < (aplWeaponFireDelay[p->curr_weapon][snum] + 1))
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_STANDSTILL
&& p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, snum) + 1))
{
p->pos.z = p->oposz;
p->poszv = 0;
}
if (p->kickback_pic == aplWeaponSound2Time[p->curr_weapon][snum])
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum))
{
if (aplWeaponSound2Sound[p->curr_weapon][snum])
if (aplWeaponSound2Sound(p->curr_weapon, snum))
{
S_PlayActorSound(aplWeaponSound2Sound[p->curr_weapon][snum], pact);
S_PlayActorSound(aplWeaponSound2Sound(p->curr_weapon, snum), pact);
}
}
if (p->kickback_pic == aplWeaponSpawnTime[p->curr_weapon][snum])
if (p->kickback_pic == aplWeaponSpawnTime(p->curr_weapon, snum))
{
DoSpawn(p, snum);
}
if (p->kickback_pic == aplWeaponFireDelay[p->curr_weapon][snum])
if (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, snum))
{
DoFire(p, snum);
}
if (p->kickback_pic > aplWeaponFireDelay[p->curr_weapon][snum]
&& p->kickback_pic < aplWeaponTotalTime[p->curr_weapon][snum])
if (p->kickback_pic > aplWeaponFireDelay(p->curr_weapon, snum)
&& p->kickback_pic < aplWeaponTotalTime(p->curr_weapon, snum))
{
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AUTOMATIC)
{ // an 'automatic'
if ((actions & SB_FIRE) == 0)
{
p->kickback_pic = aplWeaponTotalTime[p->curr_weapon][snum];
p->kickback_pic = aplWeaponTotalTime(p->curr_weapon, snum);
}
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYTHIRD)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_FIREEVERYTHIRD)
{
if (((p->kickback_pic) % 3) == 0)
{
@ -478,7 +478,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
}
}
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_FIREEVERYOTHER)
{
// fire every other...
DoFire(p, snum);
@ -487,31 +487,31 @@ void operateweapon_ww(int snum, ESyncBits actions)
} // 'automatic
}
else if (p->kickback_pic >= aplWeaponTotalTime[p->curr_weapon][snum])
else if (p->kickback_pic >= aplWeaponTotalTime(p->curr_weapon, snum))
{
if ( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]
if ( //!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload(p->curr_weapon, snum) > aplWeaponTotalTime(p->curr_weapon, snum)
&& p->ammo_amount[p->curr_weapon] > 0
&& (aplWeaponClip[p->curr_weapon][snum])
&& ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum])) == 0)
&& (aplWeaponClip(p->curr_weapon, snum))
&& ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip(p->curr_weapon, snum))) == 0)
)
{
// reload in progress...
int i;
i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum];
i = aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum);
// time for 'reload'
if (p->kickback_pic == (aplWeaponTotalTime[p->curr_weapon][snum] + 1))
if (p->kickback_pic == (aplWeaponTotalTime(p->curr_weapon, snum) + 1))
{ // eject shortly after 'total time'
S_PlayActorSound(EJECT_CLIP, pact);
}
else if (p->kickback_pic == (aplWeaponReload[p->curr_weapon][snum] - (i / 3)))
else if (p->kickback_pic == (aplWeaponReload(p->curr_weapon, snum) - (i / 3)))
{
// insert occurs 2/3 of way through reload delay
S_PlayActorSound(INSERT_CLIP, pact);
}
if (p->kickback_pic >= (aplWeaponReload[p->curr_weapon][snum]))
if (p->kickback_pic >= (aplWeaponReload(p->curr_weapon, snum)))
{
p->okickback_pic = p->kickback_pic = 0;
}
@ -519,12 +519,12 @@ void operateweapon_ww(int snum, ESyncBits actions)
}
else
{
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AUTOMATIC)
{ // an 'automatic'
if (actions & SB_FIRE)
{
// we are an AUTOMATIC. Fire again...
if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART)
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_RANDOMRESTART)
{
p->kickback_pic = 1 + (krand() & 3);
}

View file

@ -539,7 +539,7 @@ void resetpspritevars(int g)
resetplayerstats(0);
for (i = 1; i < MAXPLAYERS; i++)
memcpy(&ps[i], &ps[0], sizeof(ps[0]));
ps[i] = ps[0];
if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++)
{
@ -766,13 +766,13 @@ void donewgame(MapRecord* map, int sk)
{
for (int i = 0; i < 12/*MAX_WEAPONS*/; i++) // aboive 12 have no data defined and would crash.
{
if (aplWeaponWorksLike[i][0] == PISTOL_WEAPON)
if (aplWeaponWorksLike(i, 0) == PISTOL_WEAPON)
{
p->curr_weapon = i;
p->gotweapon[i] = true;
p->ammo_amount[i] = 48;
}
else if (aplWeaponWorksLike[i][0] == KNEE_WEAPON || aplWeaponWorksLike[i][0] == HANDREMOTE_WEAPON)
else if (aplWeaponWorksLike(i, 0) == KNEE_WEAPON || aplWeaponWorksLike(i, 0) == HANDREMOTE_WEAPON)
{
p->gotweapon[i] = true;
}

View file

@ -265,6 +265,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w,
// new stuff
("actions", w.sync.actions)
.Array("frags", w.frags, MAXPLAYERS)
("uservars", w.uservars)
.EndObject();
w.invdisptime = 0;
@ -311,7 +312,8 @@ void DDukeActor::Serialize(FSerializer& arc)
("seek_actor", seek_actor)
.Array("temp_data", temp_data, 6)
.Array("temo_wall", temp_walls, 2)
("temp_sect", temp_sect);
("temp_sect", temp_sect)
("uservars", uservars);
}

View file

@ -56,6 +56,8 @@ DDukeActor* EGS(sectortype* whatsectp, int s_x, int s_y, int s_z, int s_pn, int8
auto act = static_cast<DDukeActor*>(::InsertActor(whatsectp, s_ss));
if (act == nullptr) return nullptr;
SetupGameVarsForActor(act);
auto s = act->s;

View file

@ -45,6 +45,8 @@ struct DDukeActor : public DCoreActor
DDukeActor* temp_actor, *seek_actor;
spritetype* s; // direct reference to the corresponding sprite.
TArray<int64_t> uservars;
static DDukeActor* array(); // this is necessary to allow define inline functions referencing the global array inside the definition itself.
DDukeActor()
@ -302,6 +304,9 @@ struct player_struct
double vehForwardScale, vehReverseScale, MotoSpeed;
bool vehTurnLeft, vehTurnRight, vehBraking;
TArray<int64_t> uservars;
// input stuff.
InputPacket sync;