- refactored shoot API to exclusively work with class pointers.

This commit is contained in:
Christoph Oelckers 2022-12-29 10:56:10 +01:00
parent 65e66a573d
commit f78c971eac
14 changed files with 82 additions and 71 deletions

View file

@ -1055,7 +1055,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, PClassActor* RPG)
{
auto saved_angle = actor->spr.Angles.Yaw;
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle();
shoot(actor, -1, RPG);
shoot(actor, RPG);
actor->spr.Angles.Yaw = saved_angle;
}
}
@ -1541,7 +1541,7 @@ void handle_se05(DDukeActor* actor)
{
auto ang = actor->spr.Angles.Yaw;
actor->spr.Angles.Yaw = (actor->spr.pos.XY() - ps[p].GetActor()->spr.pos.XY()).Angle();
shoot(actor, -1, isRR()? RedneckFirelaserClass : DukeFirelaserClass);
shoot(actor, isRR()? RedneckFirelaserClass : DukeFirelaserClass);
actor->spr.Angles.Yaw = ang;
}
@ -2804,6 +2804,24 @@ void handle_se35(DDukeActor *actor)
//
//---------------------------------------------------------------------------
void handle_se36(DDukeActor* actor)
{
if (actor->counter)
{
if (actor->counter == 1)
shoot(actor, GetSpawnType(actor->sector()->extra));
else if (actor->counter == 26 * 5)
actor->counter = 0;
actor->counter++;
}
}
//---------------------------------------------------------------------------
//
//
//
//---------------------------------------------------------------------------
void handle_se128(DDukeActor *actor)
{
auto wal = actor->temp_walls[0];

View file

@ -1094,15 +1094,7 @@ void moveeffectors_d(void) //STATNUM 3
RANDOMSCRAP(act);
break;
case SE_36_PROJ_SHOOTER:
if (act->counter)
{
if (act->counter == 1)
shoot(act, sc->extra, nullptr);
else if (act->counter == 26 * 5)
act->counter = 0;
act->counter++;
}
handle_se36(act);
break;
case SE_128_GLASS_BREAKING:

View file

@ -1155,15 +1155,7 @@ void moveeffectors_r(void) //STATNUM 3
RANDOMSCRAP(act);
break;
case SE_36_PROJ_SHOOTER:
if (act->counter)
{
if (act->counter == 1)
shoot(act, sc->extra, nullptr);
else if (act->counter == 26 * 5)
act->counter = 0;
act->counter++;
}
handle_se36(act);
break;
case SE_128_GLASS_BREAKING:

View file

@ -81,3 +81,16 @@ xx(RedneckUfo2)
xx(RedneckUfo3)
xx(RedneckUfo4)
xx(RedneckUfoRRRA)
xx(DukeShotgunShot)
xx(DukeChaingunShot)
xx(DukeGrowSpark)
xx(DukeShrinker)
xx(DukeFreezeBlast)
xx(DukeHandHoldingLaser)
xx(RedneckShotgunShot)
xx(RedneckBuzzSaw)
xx(RedneckSawblade)
xx(RedneckBoatGrenade)
xx(RedneckBowlingBall)
xx(RedneckSlingbladeAttack)
xx(RedneckChickenArrow)

View file

@ -77,6 +77,7 @@ void handle_se29(DDukeActor* actor);
void handle_se31(DDukeActor* a, bool choosedir);
void handle_se32(DDukeActor* i);
void handle_se35(DDukeActor* i);
void handle_se36(DDukeActor* i);
void handle_se128(DDukeActor* i);
void handle_se130(DDukeActor* i, int countmax);
@ -108,7 +109,7 @@ void playerAimUp(int snum, ESyncBits actions);
void playerAimDown(int snum, ESyncBits actions);
DDukeActor* aim(DDukeActor* s, int aang, bool force = true);
DDukeActor* aim_(DDukeActor* actor, DDukeActor* weapon, double aimangle);
void shoot(DDukeActor* actor, int atwith, PClass* cls);
void shoot(DDukeActor* actor, PClass* cls);
void checkweapons(player_struct* const p);
int findotherplayer(int p, double* d);
void quickkill(player_struct* p);

View file

@ -1703,7 +1703,7 @@ int ParseState::parse(void)
//if (g_ac->GetClass.TypeName == NAME_RedneckMinion && type == 3390 && g_ac->spr.pal == 8) typecls = RedneckFrogBallClass);
//if (g_ac->GetClass.TypeName == NAME_RedneckMinion && type == 3390 && g_ac->spr.pal == 19)) typecls = RedneckShitBurnClass);
}
shoot(g_ac, *insptr, nullptr);
shoot(g_ac, GetSpawnType(*insptr));
insptr++;
break;
}

View file

@ -131,7 +131,7 @@ void RegisterClasses()
auto cls = PClass::FindActor(classdef.first);
if (cls == nullptr || !cls->IsDescendantOf(RUNTIME_CLASS(DDukeActor)))
{
Printf(TEXTCOLOR_RED, "%s: Attempt to register unknown actor class '%s'\n", classdef.first);
Printf(TEXTCOLOR_RED "%s: Attempt to register unknown actor class\n", classdef.first);
error++;
}

View file

@ -914,7 +914,7 @@ void playerAimDown(int snum, ESyncBits actions)
//
//---------------------------------------------------------------------------
void shoot(DDukeActor* actor, int atwith, PClass* cls)
void shoot(DDukeActor* actor, PClass* cls)
{
int p;
DVector3 spos;
@ -945,7 +945,7 @@ void shoot(DDukeActor* actor, int atwith, PClass* cls)
}
if (cls == nullptr)
cls = GetSpawnType(atwith);
return;
CallShootThis(static_cast<DDukeActor*>(GetDefaultByType(cls)), actor, p, spos, sang);
}

View file

@ -434,7 +434,7 @@ int doincrements_d(player_struct* p)
p->last_quick_kick = p->quick_kick + 1;
p->quick_kick--;
if (p->quick_kick == 8)
shoot(p->GetActor(), DTILE_KNEE, nullptr);
shoot(p->GetActor(), DukeMeleeAttackClass);
}
else if (p->last_quick_kick > 0)
p->last_quick_kick--;
@ -1178,7 +1178,7 @@ static void operateweapon(int snum, ESyncBits actions)
case PISTOL_WEAPON: // m-16 in NAM
if (p->kickback_pic == 1)
{
shoot(pact, DTILE_SHOTSPARK1, nullptr);
shoot(pact, DukeShotSparkClass);
S_PlayActorSound(PISTOL_FIRE, pact);
lastvisinc = PlayClock + 32;
p->visibility = 0;
@ -1229,7 +1229,7 @@ static void operateweapon(int snum, ESyncBits actions)
if (p->kickback_pic == 4)
{
for(int ii = 0; ii < 7; ii++)
shoot(pact, DTILE_SHOTGUN, nullptr);
shoot(pact, DukeShotgunShotClass);
p->ammo_amount[SHOTGUN_WEAPON]--;
S_PlayActorSound(SHOTGUN_FIRE, pact);
@ -1298,7 +1298,7 @@ static void operateweapon(int snum, ESyncBits actions)
}
S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, DTILE_CHAINGUN, nullptr);
shoot(pact, DukeChaingunShotClass);
lastvisinc = PlayClock + 32;
p->visibility = 0;
checkavailweapon(p);
@ -1342,7 +1342,7 @@ static void operateweapon(int snum, ESyncBits actions)
else
p->okickback_pic = p->kickback_pic = 0;
p->ammo_amount[p->curr_weapon]--;
shoot(pact, DTILE_GROWSPARK, nullptr);
shoot(pact, DukeGrowSparkClass);
//#ifdef NAM
//#else
@ -1377,7 +1377,7 @@ static void operateweapon(int snum, ESyncBits actions)
else p->okickback_pic = p->kickback_pic = 0;
p->ammo_amount[SHRINKER_WEAPON]--;
shoot(pact, DTILE_SHRINKER, nullptr);
shoot(pact, DukeShrinkerClass);
if (!isNam())
{
@ -1410,7 +1410,7 @@ static void operateweapon(int snum, ESyncBits actions)
{
p->visibility = 0;
lastvisinc = PlayClock + 32;
shoot(pact, DTILE_RPG, nullptr);
shoot(pact, DukeRPGClass);
p->ammo_amount[DEVISTATOR_WEAPON]--;
checkavailweapon(p);
}
@ -1420,7 +1420,7 @@ static void operateweapon(int snum, ESyncBits actions)
{
p->visibility = 0;
lastvisinc = PlayClock + 32;
shoot(pact, DTILE_RPG, nullptr);
shoot(pact, DukeRPGClass);
p->ammo_amount[DEVISTATOR_WEAPON]--;
checkavailweapon(p);
if (p->ammo_amount[DEVISTATOR_WEAPON] <= 0) p->okickback_pic = p->kickback_pic = 0;
@ -1440,7 +1440,7 @@ static void operateweapon(int snum, ESyncBits actions)
p->visibility = 0;
lastvisinc = PlayClock + 32;
shoot(pact, DTILE_FREEZEBLAST, nullptr);
shoot(pact, DukeFreezeBlastClass);
checkavailweapon(p);
}
if (pact->spr.scale.X < 0.5)
@ -1468,7 +1468,7 @@ static void operateweapon(int snum, ESyncBits actions)
if (p->cursector->lotag != 2)
{
p->ammo_amount[FLAMETHROWER_WEAPON]--;
shoot(pact, DTILE_FIREBALL, nullptr);
shoot(pact, DukeFireballClass);
}
checkavailweapon(p);
}
@ -1490,7 +1490,7 @@ static void operateweapon(int snum, ESyncBits actions)
p->GetActor()->restorez();
p->vel.Z = 0;
if (p->kickback_pic == 3)
shoot(pact, DTILE_HANDHOLDINGLASER, nullptr);
shoot(pact, DukeHandHoldingLaserClass);
}
if (p->kickback_pic == 16)
{
@ -1503,7 +1503,7 @@ static void operateweapon(int snum, ESyncBits actions)
case KNEE_WEAPON:
p->kickback_pic++;
if (p->kickback_pic == 7) shoot(pact, DTILE_KNEE, nullptr);
if (p->kickback_pic == 7) shoot(pact, DukeMeleeAttackClass);
else if (p->kickback_pic == 14)
{
if (actions & SB_FIRE)
@ -1522,7 +1522,7 @@ static void operateweapon(int snum, ESyncBits actions)
p->ammo_amount[RPG_WEAPON]--;
lastvisinc = PlayClock + 32;
p->visibility = 0;
shoot(pact, DTILE_RPG, nullptr);
shoot(pact, DukeRPGClass);
checkavailweapon(p);
}
else if (p->kickback_pic == 20)

View file

@ -1803,7 +1803,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
case PISTOL_WEAPON:
if (p->kickback_pic == 1)
{
shoot(pact, RTILE_SHOTSPARK1, nullptr);
shoot(pact, DukeShotSparkClass);
S_PlayActorSound(PISTOL_FIRE, pact);
p->noise_radius = 512;
madenoise(snum);
@ -1869,7 +1869,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
if (p->kickback_pic == 4)
{
for (int ii = 0; ii < 10; ii++)
shoot(pact, RTILE_SHOTGUN, nullptr);
shoot(pact, RedneckShotgunShotClass);
p->ammo_amount[SHOTGUN_WEAPON]--;
@ -1887,7 +1887,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
if (p->shotgun_state[1])
{
for (int ii = 0; ii < 10; ii++)
shoot(pact, RTILE_SHOTGUN, nullptr);
shoot(pact, RedneckShotgunShotClass);
p->ammo_amount[SHOTGUN_WEAPON]--;
@ -1978,7 +1978,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
}
S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, RTILE_CHAINGUN, nullptr);
shoot(pact, DukeChaingunShotClass);
p->noise_radius = 512;
madenoise(snum);
lastvisinc = PlayClock + 32;
@ -2010,7 +2010,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
if (p->kickback_pic > 3)
{
p->okickback_pic = p->kickback_pic = 0;
shoot(pact, RTILE_GROWSPARK, nullptr);
shoot(pact, RedneckBuzzSawClass);
p->noise_radius = 64;
madenoise(snum);
checkavailweapon(p);
@ -2023,7 +2023,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
if (p->kickback_pic == 1)
{
p->ammo_amount[THROWSAW_WEAPON]--;
shoot(pact, RTILE_SAWBLADE, nullptr);
shoot(pact, RedneckSawbladeClass);
checkavailweapon(p);
}
p->kickback_pic++;
@ -2038,7 +2038,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->visibility = 0;
lastvisinc = PlayClock + 32;
S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, RTILE_SHOTSPARK1, nullptr);
shoot(pact, DukeShotSparkClass);
p->noise_radius = 1024;
madenoise(snum);
p->ammo_amount[TIT_WEAPON]--;
@ -2065,7 +2065,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->visibility = 0;
lastvisinc = PlayClock + 32;
S_PlayActorSound(CHAINGUN_FIRE, pact);
shoot(pact, RTILE_CHAINGUN, nullptr);
shoot(pact, DukeChaingunShotClass);
p->noise_radius = 1024;
madenoise(snum);
p->ammo_amount[MOTORCYCLE_WEAPON]--;
@ -2092,7 +2092,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{
p->MotoSpeed -= 20;
p->ammo_amount[BOAT_WEAPON]--;
shoot(pact, RTILE_BOATGRENADE, nullptr);
shoot(pact, RedneckBoatGrenadeClass);
}
p->kickback_pic++;
if (p->kickback_pic > 20)
@ -2109,7 +2109,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
case ALIENBLASTER_WEAPON:
p->kickback_pic++;
if (p->kickback_pic >= 7 && p->kickback_pic <= 11)
shoot(pact, RTILE_FIRELASER, nullptr);
shoot(pact, RedneckFirelaserClass);
if (p->kickback_pic == 5)
{
@ -2167,7 +2167,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
{
p->ammo_amount[BOWLING_WEAPON]--;
S_PlayActorSound(354, pact);
shoot(pact, RTILE_BOWLINGBALL, nullptr);
shoot(pact, RedneckBowlingBallClass);
p->noise_radius = 64;
madenoise(snum);
}
@ -2190,7 +2190,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(426, pact);
if (p->kickback_pic == 12)
{
shoot(pact, RTILE_KNEE, nullptr);
shoot(pact, DukeMeleeAttackClass);
p->noise_radius = 64;
madenoise(snum);
}
@ -2208,7 +2208,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
S_PlayActorSound(252, pact);
if (p->kickback_pic == 8)
{
shoot(pact, RTILE_SLINGBLADE, nullptr);
shoot(pact, RedneckSlingbladeAttackClass);
p->noise_radius = 64;
madenoise(snum);
}
@ -2228,7 +2228,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->ammo_amount[DYNAMITE_WEAPON]--;
lastvisinc = PlayClock + 32;
p->visibility = 0;
shoot(pact, RTILE_RPG, nullptr);
shoot(pact, RedneckDynamiteArrowClass);
p->noise_radius = 2048;
madenoise(snum);
checkavailweapon(p);
@ -2246,7 +2246,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp)
p->ammo_amount[CHICKEN_WEAPON]--;
lastvisinc = PlayClock + 32;
p->visibility = 0;
shoot(pact, RTILE_RPG2, nullptr);
shoot(pact, RedneckChickenArrowClass);
p->noise_radius = 2048;
madenoise(snum);
checkavailweapon(p);

View file

@ -65,10 +65,10 @@ void DoFire(player_struct* p, int snum)
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
shoot(p->GetActor(), aplWeaponShoots(p->curr_weapon, snum), nullptr);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, snum)));
for (i = 1; i < aplWeaponShotsPerBurst(p->curr_weapon, snum); i++)
{
shoot(p->GetActor(), aplWeaponShoots(p->curr_weapon, snum), nullptr);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, snum)));
if (aplWeaponFlags(p->curr_weapon, snum) & WEAPON_FLAG_AMMOPERSHOT)
{
p->ammo_amount[p->curr_weapon]--;
@ -405,7 +405,7 @@ void operateweapon_ww(int snum, ESyncBits actions)
}
SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->GetActor(), snum);
SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike(p->curr_weapon, snum), p->GetActor(), snum);
shoot(p->GetActor(), aplWeaponShoots(p->curr_weapon, snum), nullptr);
shoot(p->GetActor(), GetSpawnType(aplWeaponShoots(p->curr_weapon, snum)));
}
}

View file

@ -194,10 +194,10 @@ void checkhitdefault_d(DDukeActor* targ, DDukeActor* proj)
if (Owner && Owner->isPlayer() && targ->spr.picnum != DTILE_ROTATEGUN && targ->spr.picnum != DTILE_DRONE)
if (ps[Owner->PlayerIndex()].curr_weapon == SHOTGUN_WEAPON)
{
shoot(targ, -1, DukeBloodSplat3Class);
shoot(targ, -1, DukeBloodSplat1Class);
shoot(targ, -1, DukeBloodSplat2Class);
shoot(targ, -1, DukeBloodSplat4Class);
shoot(targ, DukeBloodSplat3Class);
shoot(targ, DukeBloodSplat1Class);
shoot(targ, DukeBloodSplat2Class);
shoot(targ, DukeBloodSplat4Class);
}
if (!(targ->flags2 & SFLAG2_NODAMAGEPUSH)) // RR does not have this.

View file

@ -192,10 +192,10 @@ void checkhitdefault_r(DDukeActor* targ, DDukeActor* proj)
if (Owner && Owner->isPlayer() && targ->spr.picnum != RTILE_DRONE)
if (ps[Owner->PlayerIndex()].curr_weapon == SHOTGUN_WEAPON)
{
shoot(targ, -1, DukeBloodSplat3Class);
shoot(targ, -1, DukeBloodSplat1Class);
shoot(targ, -1, DukeBloodSplat2Class);
shoot(targ, -1, DukeBloodSplat4Class);
shoot(targ, DukeBloodSplat3Class);
shoot(targ, DukeBloodSplat1Class);
shoot(targ, DukeBloodSplat2Class);
shoot(targ, DukeBloodSplat4Class);
}
if (targ->spr.statnum == STAT_ZOMBIEACTOR)

View file

@ -680,16 +680,11 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, spriteheight, duke_sph)
ACTION_RETURN_INT(duke_sph(self));
}
void DukeActor_shoot(DDukeActor* act, PClassActor* intname)
{
shoot(act, -1, intname);
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, shoot, DukeActor_shoot)
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, shoot, shoot)
{
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_POINTER(type, PClassActor);
DukeActor_shoot(self, type);
shoot(self, type);
return 0;
}