- Duke: Convert all the aplWeapon* crap to work on player pointers.

This commit is contained in:
Mitchell Richters 2023-10-03 19:55:11 +11:00
parent 836ed7d931
commit d8b670276a
8 changed files with 149 additions and 143 deletions

View file

@ -306,7 +306,7 @@ void checkavailweapon(DDukePlayer* player)
if (player->curr_weapon >= 0)
{
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, snum), pact, snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(player->curr_weapon, player), pact, snum);
}
else
{

View file

@ -518,21 +518,21 @@ static int i_aplWeaponFireSound[MAX_WEAPONS]; // Sound made when firing (each ti
static int i_aplWeaponSound2Time[MAX_WEAPONS]; // Alternate sound time
static int i_aplWeaponSound2Sound[MAX_WEAPONS]; // Alternate sound sound ID
int aplWeaponClip(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponClip[weapon]].safeValue(); }
int aplWeaponReload(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponReload[weapon]].safeValue(); }
int aplWeaponFireDelay(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponFireDelay[weapon]].safeValue(); }
int aplWeaponHoldDelay(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponHoldDelay[weapon]].safeValue(); }
int aplWeaponTotalTime(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponTotalTime[weapon]].safeValue(); }
int aplWeaponFlags(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponFlags[weapon]].safeValue(); }
int aplWeaponShoots(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponShoots[weapon]].safeValue(); }
int aplWeaponSpawnTime(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSpawnTime[weapon]].safeValue(); }
int aplWeaponSpawn(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSpawn[weapon]].safeValue(); }
int aplWeaponShotsPerBurst(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponShotsPerBurst[weapon]].safeValue(); }
int aplWeaponWorksLike(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponWorksLike[weapon]].safeValue(); }
int aplWeaponInitialSound(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponInitialSound[weapon]].safeValue(); }
int aplWeaponFireSound(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponFireSound[weapon]].safeValue(); }
int aplWeaponSound2Time(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSound2Time[weapon]].safeValue(); }
int aplWeaponSound2Sound(int weapon, int player) { return getPlayer(player)->uservars[i_aplWeaponSound2Sound[weapon]].safeValue(); }
int aplWeaponClip(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponClip[weapon]].safeValue(); }
int aplWeaponReload(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponReload[weapon]].safeValue(); }
int aplWeaponFireDelay(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponFireDelay[weapon]].safeValue(); }
int aplWeaponHoldDelay(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponHoldDelay[weapon]].safeValue(); }
int aplWeaponTotalTime(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponTotalTime[weapon]].safeValue(); }
int aplWeaponFlags(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponFlags[weapon]].safeValue(); }
int aplWeaponShoots(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponShoots[weapon]].safeValue(); }
int aplWeaponSpawnTime(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponSpawnTime[weapon]].safeValue(); }
int aplWeaponSpawn(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponSpawn[weapon]].safeValue(); }
int aplWeaponShotsPerBurst(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponShotsPerBurst[weapon]].safeValue(); }
int aplWeaponWorksLike(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponWorksLike[weapon]].safeValue(); }
int aplWeaponInitialSound(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponInitialSound[weapon]].safeValue(); }
int aplWeaponFireSound(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponFireSound[weapon]].safeValue(); }
int aplWeaponSound2Time(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponSound2Time[weapon]].safeValue(); }
int aplWeaponSound2Sound(int weapon, DDukePlayer* const p) { return p->uservars[i_aplWeaponSound2Sound[weapon]].safeValue(); }
//---------------------------------------------------------------------------
//

View file

@ -7,6 +7,7 @@ BEGIN_DUKE_NS
// gamedef.c
class DDukeActor;
class DDukePlayer;
// Game vars can reference actors, we need a type-safe way to handle that so that index values won't get misappropriated and actors can be GC'd.
class GameVarValue
@ -76,21 +77,21 @@ enum
// 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
int aplWeaponClip(int weapon, DDukePlayer* const p); // number of items in clip
int aplWeaponReload(int weapon, DDukePlayer* const p); // delay to reload (include fire)
int aplWeaponFireDelay(int weapon, DDukePlayer* const p); // delay to fire
int aplWeaponHoldDelay(int weapon, DDukePlayer* const p); // delay after release fire button to fire (0 for none)
int aplWeaponTotalTime(int weapon, DDukePlayer* const p); // The total time the weapon is cycling before next fire.
int aplWeaponFlags(int weapon, DDukePlayer* const p); // Flags for weapon
int aplWeaponShoots(int weapon, DDukePlayer* const p); // what the weapon shoots
int aplWeaponSpawnTime(int weapon, DDukePlayer* const p); // the frame at which to spawn an item
int aplWeaponSpawn(int weapon, DDukePlayer* const p); // the item to spawn
int aplWeaponShotsPerBurst(int weapon, DDukePlayer* const p); // number of shots per 'burst' (one ammo per 'burst'
int aplWeaponWorksLike(int weapon, DDukePlayer* const p); // What original the weapon works like
int aplWeaponInitialSound(int weapon, DDukePlayer* const p); // Sound made when initialy firing. zero for no sound
int aplWeaponFireSound(int weapon, DDukePlayer* const p); // Sound made when firing (each time for automatic)
int aplWeaponSound2Time(int weapon, DDukePlayer* const p); // Alternate sound time
int aplWeaponSound2Sound(int weapon, DDukePlayer* const p); // Alternate sound sound ID
enum

View file

@ -277,7 +277,7 @@ void displayweapon_d(int snum, double interpfrac)
offsets.Y -= gun_pos;
int cw = p->last_weapon >= 0 ? p->last_weapon : p->curr_weapon;
if (isWW2GI()) cw = aplWeaponWorksLike(cw, snum);
if (isWW2GI()) cw = aplWeaponWorksLike(cw, p);
// onevent should go here..
// rest of code should be moved to CON..
@ -305,9 +305,9 @@ void displayweapon_d(int snum, double interpfrac)
int weapTotalTime = 0, weapFireDelay = 0, weapReload = 0;
if (isWW2GI())
{
weapTotalTime = aplWeaponTotalTime(p->curr_weapon, snum);
weapFireDelay = aplWeaponFireDelay(p->curr_weapon, snum);
weapReload = aplWeaponReload(p->curr_weapon, snum);
weapTotalTime = aplWeaponTotalTime(p->curr_weapon, p);
weapFireDelay = aplWeaponFireDelay(p->curr_weapon, p);
weapReload = aplWeaponReload(p->curr_weapon, p);
}
//---------------------------------------------------------------------------

View file

@ -244,7 +244,7 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
}
else
{
weap = aplWeaponWorksLike(plr->curr_weapon, actor->PlayerIndex());
weap = aplWeaponWorksLike(plr->curr_weapon, plr);
}
// The chickens in RRRA are homing and must always autoaim.
if (!isRRRA() || plr->curr_weapon != CHICKEN_WEAPON)
@ -265,15 +265,20 @@ DDukeActor* aim(DDukeActor* actor, int abase, bool force, bool* b)
gotshrinker = false;
gotfreezer = false;
}
else if (isWW2GI())
else if (actor->isPlayer())
{
gotshrinker = actor->isPlayer() && aplWeaponWorksLike(getPlayer(actor->PlayerIndex())->curr_weapon, actor->PlayerIndex()) == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && aplWeaponWorksLike(getPlayer(actor->PlayerIndex())->curr_weapon, actor->PlayerIndex()) == FREEZE_WEAPON;
}
else
{
gotshrinker = actor->isPlayer() && getPlayer(actor->PlayerIndex())->curr_weapon == SHRINKER_WEAPON;
gotfreezer = actor->isPlayer() && getPlayer(actor->PlayerIndex())->curr_weapon == FREEZE_WEAPON;
const auto plr = getPlayer(actor->PlayerIndex());
if (isWW2GI())
{
gotshrinker = aplWeaponWorksLike(plr->curr_weapon, plr) == SHRINKER_WEAPON;
gotfreezer = aplWeaponWorksLike(plr->curr_weapon, plr) == FREEZE_WEAPON;
}
else
{
gotshrinker = plr->curr_weapon == SHRINKER_WEAPON;
gotfreezer = plr->curr_weapon == FREEZE_WEAPON;
}
}
double smax = 0x7fffffff;
@ -971,13 +976,13 @@ bool movementBlocked(DDukePlayer *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) == 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);
else return 4;
};

View file

@ -547,7 +547,7 @@ void checkweapons_d(DDukePlayer* p)
if (isWW2GI())
{
int snum = p->GetActor()->PlayerIndex();
cw = aplWeaponWorksLike(p->curr_weapon, snum);
cw = aplWeaponWorksLike(p->curr_weapon, p);
}
else
cw = p->curr_weapon;
@ -1463,20 +1463,20 @@ 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, p), p->GetActor(), snum);
OnEvent(EVENT_HOLSTER, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
{
// now it uses the game definitions...
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_HOLSTER_CLEARS_CLIP)
if (aplWeaponFlags(p->curr_weapon, p) & 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, p)
&& (p->ammo_amount[p->curr_weapon] % aplWeaponClip(p->curr_weapon, p)) != 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 = aplWeaponTotalTime(p->curr_weapon, snum) + 1; // animate, but don't shoot...
p->ammo_amount[p->curr_weapon] % aplWeaponClip(p->curr_weapon, p);
p->kickback_pic = aplWeaponTotalTime(p->curr_weapon, p) + 1; // animate, but don't shoot...
actions &= ~SB_FIRE; // not firing...
}
return;
@ -1497,7 +1497,7 @@ static void processweapon(int snum, ESyncBits actions)
}
if (isWW2GI() && (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_GLOWS))
if (isWW2GI() && (aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_GLOWS))
p->random_club_frame += 64; // Glowing
if (!isWW2GI() && (p->curr_weapon == SHRINKER_WEAPON || p->curr_weapon == GROW_WEAPON))
@ -1665,7 +1665,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, p) == HANDREMOTE_WEAPON) processweapon(snum, actions);
if (!isWW2GI() && p->curr_weapon == HANDREMOTE_WEAPON) processweapon(snum, actions);
return;
}
@ -1787,7 +1787,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, p) == KNEE_WEAPON && p->kickback_pic > 10 && p->on_ground) || (p->on_ground && (actions & SB_CROUCH)));
if (check)
{
p->vel.XY() *= gs.playerfriction - 0.125;

View file

@ -52,48 +52,48 @@ void DoFire(DDukePlayer* p, int snum)
{
int i;
if (aplWeaponWorksLike(p->curr_weapon, snum) != KNEE_WEAPON)
if (aplWeaponWorksLike(p->curr_weapon, p) != KNEE_WEAPON)
{
p->ammo_amount[p->curr_weapon]--;
}
if (aplWeaponFireSound(p->curr_weapon, snum))
if (aplWeaponFireSound(p->curr_weapon, p))
{
S_PlayActorSound(aplWeaponFireSound(p->curr_weapon, snum), p->GetActor());
S_PlayActorSound(aplWeaponFireSound(p->curr_weapon, p), p->GetActor());
}
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, snum)));
for (i = 1; i < aplWeaponShotsPerBurst(p->curr_weapon, snum); i++)
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, p), p->GetActor(), snum);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, p)));
for (i = 1; i < aplWeaponShotsPerBurst(p->curr_weapon, p); i++)
{
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, snum)));
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AMMOPERSHOT)
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, p)));
if (aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_AMMOPERSHOT)
{
p->ammo_amount[p->curr_weapon]--;
}
}
if (!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_NOVISIBLE))
if (!(aplWeaponFlags(p->curr_weapon, p) & 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, p) & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload(p->curr_weapon, p) > aplWeaponTotalTime(p->curr_weapon, p)
&& 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, p))
&& ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip(p->curr_weapon, p))) == 0)
)
{
// do clip check...
p->kickback_pic = aplWeaponTotalTime(p->curr_weapon, snum);
p->kickback_pic = aplWeaponTotalTime(p->curr_weapon, p);
// is same as p->kickback_pic....
}
if (aplWeaponWorksLike(p->curr_weapon, snum) != KNEE_WEAPON)
if (aplWeaponWorksLike(p->curr_weapon, p) != KNEE_WEAPON)
{
checkavailweapon(p);
}
@ -107,13 +107,13 @@ void DoFire(DDukePlayer* p, int snum)
void DoSpawn(DDukePlayer *p, int snum)
{
if(!aplWeaponSpawn(p->curr_weapon, snum))
if(!aplWeaponSpawn(p->curr_weapon, p))
return;
auto j = spawn(p->GetActor(), GetSpawnType(aplWeaponSpawn(p->curr_weapon, snum)));
auto j = spawn(p->GetActor(), GetSpawnType(aplWeaponSpawn(p->curr_weapon, p)));
if (!j) return;
if((aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_SPAWNTYPE2 ) )
if((aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_SPAWNTYPE2 ) )
{
// like shotgun shells
j->spr.Angles.Yaw += DAngle180;
@ -121,7 +121,7 @@ void DoSpawn(DDukePlayer *p, int snum)
j->spr.Angles.Yaw += DAngle180;
// p->kickback_pic++;
}
else if((aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_SPAWNTYPE3 ) )
else if((aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_SPAWNTYPE3 ) )
{
// like chaingun shells
j->spr.Angles.Yaw += DAngle90;
@ -158,29 +158,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, p), p->GetActor(), snum);
OnEvent(EVENT_FIRE, snum, p->GetActor(), -1);
if (GetGameVarID(g_iReturnVarID, p->GetActor(), snum).value() == 0)
{
switch (aplWeaponWorksLike(p->curr_weapon, snum))
switch (aplWeaponWorksLike(p->curr_weapon, p))
{
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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), 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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
break;
@ -189,9 +189,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -201,9 +201,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -212,9 +212,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -222,9 +222,9 @@ void fireweapon_ww(int snum)
if (operateTripbomb(snum))
{
p->kickback_pic = 1;
if (aplWeaponInitialSound(p->curr_weapon, snum))
if (aplWeaponInitialSound(p->curr_weapon, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -233,9 +233,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -244,9 +244,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -255,9 +255,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -266,9 +266,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -277,9 +277,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -288,9 +288,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, p))
{
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponInitialSound(p->curr_weapon, p), pact);
}
}
break;
@ -311,10 +311,10 @@ void operateweapon_ww(int snum, ESyncBits actions)
auto pact = p->GetActor();
// already firing...
if (aplWeaponWorksLike(p->curr_weapon, snum) == HANDBOMB_WEAPON)
if (aplWeaponWorksLike(p->curr_weapon, p) == 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, p) // there is a hold delay
&& (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, p)) // and we are 'at' hold
&& (actions & SB_FIRE) // and 'fire' button is still down
)
// just hold here...
@ -323,7 +323,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, p))
{
double zvel, vel;
@ -372,43 +372,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, p) &&
(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, p))
{
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, p) == HANDREMOTE_WEAPON)
{
p->kickback_pic++;
if (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, snum))
if (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, p))
{
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_BOMB_TRIGGER)
if (aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_BOMB_TRIGGER)
{
p->hbomb_on = 0;
}
if (aplWeaponShoots(p->curr_weapon, snum) != 0)
if (aplWeaponShoots(p->curr_weapon, p) != 0)
{
if (!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_NOVISIBLE))
if (!(aplWeaponFlags(p->curr_weapon, p) & 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);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, snum)));
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, p), p->GetActor(), snum);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, p)));
}
}
if (p->kickback_pic >= aplWeaponTotalTime(p->curr_weapon, snum))
if (p->kickback_pic >= aplWeaponTotalTime(p->curr_weapon, p))
{
p->okickback_pic = p->kickback_pic = 0;
/// WHAT THE HELL DOES THIS DO....?????????????
@ -425,47 +425,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, p) & WEAPON_FLAG_CHECKATRELOAD)
{
if (p->kickback_pic == aplWeaponReload(p->curr_weapon, snum))
if (p->kickback_pic == aplWeaponReload(p->curr_weapon, p))
{
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, p) & WEAPON_FLAG_STANDSTILL
&& p->kickback_pic < (aplWeaponFireDelay(p->curr_weapon, p) + 1))
{
p->GetActor()->restorez();
p->vel.Z = 0;
}
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, snum))
if (p->kickback_pic == aplWeaponSound2Time(p->curr_weapon, p))
{
if (aplWeaponSound2Sound(p->curr_weapon, snum))
if (aplWeaponSound2Sound(p->curr_weapon, p))
{
S_PlayActorSound(aplWeaponSound2Sound(p->curr_weapon, snum), pact);
S_PlayActorSound(aplWeaponSound2Sound(p->curr_weapon, p), pact);
}
}
if (p->kickback_pic == aplWeaponSpawnTime(p->curr_weapon, snum))
if (p->kickback_pic == aplWeaponSpawnTime(p->curr_weapon, p))
{
DoSpawn(p, snum);
}
if (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, snum))
if (p->kickback_pic == aplWeaponFireDelay(p->curr_weapon, p))
{
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, p)
&& p->kickback_pic < aplWeaponTotalTime(p->curr_weapon, p))
{
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AUTOMATIC)
if (aplWeaponFlags(p->curr_weapon, p) & 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, p);
}
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_FIREEVERYTHIRD)
if (aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_FIREEVERYTHIRD)
{
if (((p->kickback_pic) % 3) == 0)
{
@ -474,7 +474,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
}
}
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_FIREEVERYOTHER)
if (aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_FIREEVERYOTHER)
{
// fire every other...
DoFire(p, snum);
@ -483,30 +483,30 @@ 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, p))
{
if ( //!(aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload(p->curr_weapon, snum) > aplWeaponTotalTime(p->curr_weapon, snum)
if ( //!(aplWeaponFlags(p->curr_weapon, p) & WEAPON_FLAG_CHECKATRELOAD) &&
aplWeaponReload(p->curr_weapon, p) > aplWeaponTotalTime(p->curr_weapon, p)
&& 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, p))
&& ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip(p->curr_weapon, p))) == 0)
)
{
// reload in progress...
int timer = aplWeaponReload(p->curr_weapon, snum) - aplWeaponTotalTime(p->curr_weapon, snum);
int timer = aplWeaponReload(p->curr_weapon, p) - aplWeaponTotalTime(p->curr_weapon, p);
// time for 'reload'
if (p->kickback_pic == (aplWeaponTotalTime(p->curr_weapon, snum) + 1))
if (p->kickback_pic == (aplWeaponTotalTime(p->curr_weapon, p) + 1))
{ // eject shortly after 'total time'
S_PlayActorSound(EJECT_CLIP, pact);
}
else if (p->kickback_pic == (aplWeaponReload(p->curr_weapon, snum) - (timer / 3)))
else if (p->kickback_pic == (aplWeaponReload(p->curr_weapon, p) - (timer / 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, p)))
{
p->okickback_pic = p->kickback_pic = 0;
}
@ -514,12 +514,12 @@ void operateweapon_ww(int snum, ESyncBits actions)
}
else
{
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AUTOMATIC)
if (aplWeaponFlags(p->curr_weapon, p) & 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, p) & WEAPON_FLAG_RANDOMRESTART)
{
p->kickback_pic = 1 + (krand() & 3);
}

View file

@ -797,13 +797,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, p) == 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, p) == KNEE_WEAPON || aplWeaponWorksLike(i, p) == HANDREMOTE_WEAPON)
{
p->gotweapon[i] = true;
}