- refactoring CreateActor - part 2

This commit is contained in:
Christoph Oelckers 2022-10-07 18:57:09 +02:00
parent 1a22127123
commit bc26f16ed5
6 changed files with 27 additions and 30 deletions

View file

@ -174,12 +174,6 @@ void OnEvent(int id, int pnum = -1, DDukeActor* snum = nullptr, int dist = -1);
DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, const DVector2& scale, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat);
[[deprecated]]
inline DDukeActor* CreateActor(sectortype* whatsectp, const DVector3& pos, int s_pn, int8_t s_shd, int8_t s_xr, int8_t s_yr, DAngle s_ang, double s_vel, double s_zvel, DDukeActor* s_ow, int8_t s_stat)
{
return CreateActor(whatsectp, pos, s_pn, s_shd, DVector2(s_xr * inttoscale, s_yr * inttoscale), s_ang, s_vel, s_zvel, s_ow, s_stat);
}
void ceilingglass(DDukeActor* snum, sectortype* sectnum, int cnt);
void spriteglass(DDukeActor* snum, int cnt);
void lotsofcolourglass(DDukeActor* snum, walltype* wallNum, int cnt);

View file

@ -146,9 +146,12 @@ void tracers(const DVector3& start, const DVector3& dest, int n)
if (sect)
{
if (sect->lotag == 2)
CreateActor(sect, pos, TILE_WATERBUBBLE, -32, 4 + (krand() & 3), 4 + (krand() & 3), randomAngle(), 0., 0., ps[0].GetActor(), 5);
{
DVector2 scale(0.0625 + (krand() & 3) * REPEAT_SCALE, 0.0625 + (krand() & 3) * REPEAT_SCALE);
CreateActor(sect, pos, TILE_WATERBUBBLE, -32, scale, randomAngle(), 0., 0., ps[0].GetActor(), 5);
}
else
CreateActor(sect, pos, TILE_SMALLSMOKE, -32, 14, 14, nullAngle, 0., 0., ps[0].GetActor(), 5);
CreateActor(sect, pos, TILE_SMALLSMOKE, -32, DVector2(0.21875, 0.21875), nullAngle, 0., 0., ps[0].GetActor(), 5);
}
}
}

View file

@ -539,7 +539,7 @@ void resetpspritevars(int g)
STATUSBARTYPE tsbar[MAXPLAYERS];
CreateActor(ps[0].cursector, ps[0].pos,
TILE_APLAYER, 0, 0, 0, ps[0].angle.ang, 0., 0., nullptr, 10);
TILE_APLAYER, 0, DVector2(0, 0), ps[0].angle.ang, 0., 0., nullptr, 10);
if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++)
{

View file

@ -669,12 +669,12 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw
if (sptr == nullptr) return;
DDukeActor* spawned;
if (atwith == -1)
spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 8, 8, nullAngle, 0., 0., spr, 5);
spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, DVector2(0.125, 0.125), nullAngle, 0., 0., spr, 5);
else
{
if (atwith == CHAINGUN)
spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 16 + spr->spr.xrepeat, 16 + spr->spr.yrepeat, nullAngle, 0., 0., spr, 5);
else spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, 32, 32, nullAngle, 0., 0., spr, 5);
spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, DVector2(0.25, 0.25) + spr->spr.Scale(), nullAngle, 0., 0., spr, 5);
else spawned = CreateActor(sptr, pos, FORCERIPPLE, -127, DVector2(0.5, 0.5), nullAngle, 0., 0., spr, 5);
}
if (spawned)
{
@ -709,7 +709,7 @@ void checkhitwall_d(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw
if (wal->twoSided())
wal->nextWall()->cstat = 0;
auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang, 0., 0., spr, 3);
auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, DVector2(0, 0), ps[0].angle.ang, 0., 0., spr, 3);
if (spawned)
{
spawned->spr.lotag = SE_128_GLASS_BREAKING;
@ -1082,7 +1082,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
auto vel = krandf(4) + 4;
auto zvel = -krandf(16) - targ->vel.Z * 0.25;
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-48), SCRAP3 + (krand() & 3), -8, 48, 48, a, vel, zvel, targ, 5);
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-48), SCRAP3 + (krand() & 3), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, 5);
spawned->spr.pal = 8;
}
@ -1099,7 +1099,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
auto a = randomAngle();
auto vel = krandf(4) + 4;
auto zvel = -krandf(16) - targ->vel.Z * 0.25;
CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP1 + (krand() & 15), -8, 48, 48, a, vel, zvel, targ, 5);
CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP1 + (krand() & 15), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, 5);
}
S_PlayActorSound(GLASS_HEAVYBREAK, targ);
deletesprite(targ);
@ -1135,7 +1135,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj)
auto vel = krandf(8) + 4;
auto zvel = -krandf(2) - 1;
CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), SCRAP1 + (krand() & 15), -8, 64, 64,
CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), SCRAP1 + (krand() & 15), -8, DVector2(1, 1),
a, vel, zvel, targ, 5);
}
spawn(targ, EXPLOSION2);

View file

@ -937,7 +937,7 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n)
auto vel = krandf(4) + 2;
auto zvel = 4 - krandf(4);
CreateActor(actor->sector(), actor->spr.pos, POPCORN, -32, 36, 36, a, vel, zvel, actor, 5);
CreateActor(actor->sector(), actor->spr.pos, POPCORN, -32, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5);
}
return;
}
@ -962,7 +962,7 @@ static void lotsofpopcorn(DDukeActor *actor, walltype* wal, int n)
auto vel = krandf(4) + 2;
auto zvel = -krandf(4);
CreateActor(actor->sector(), DVector3(pos, z), POPCORN, -32, 36, 36, a, vel, zvel, actor, 5);
CreateActor(actor->sector(), DVector3(pos, z), POPCORN, -32, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5);
}
}
}
@ -1017,7 +1017,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw
if (wal->twoSided())
wal->nextWall()->cstat = 0;
auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang, 0., 0., spr, 3);
auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, DVector2(0, 0), ps[0].angle.ang, 0., 0., spr, 3);
if (spawned)
{
spawned->spr.lotag = SE_128_GLASS_BREAKING;
@ -1038,7 +1038,7 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, const DVector3& pos, int atw
if (wal->twoSided())
wal->nextWall()->cstat = 0;
auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, 0, 0, ps[0].angle.ang, 0., 0., spr, 3);
auto spawned = CreateActor(sptr, pos, SECTOREFFECTOR, 0, DVector2(0, 0), ps[0].angle.ang, 0., 0., spr, 3);
if (spawned)
{
spawned->spr.lotag = SE_128_GLASS_BREAKING;
@ -2055,7 +2055,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
auto vel = krandf(4) + 4;
auto zvel = -krandf(16) - targ->vel.Z * 0.25;
CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP6 + (krand() & 15), -8, 48, 48, a, vel, zvel, targ, 5);
CreateActor(targ->sector(), targ->spr.pos.plusZ(-8), SCRAP6 + (krand() & 15), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, 5);
}
break;
case BOWLINGBALL:
@ -2127,7 +2127,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
auto vel = krandf(4) + 4;
auto zvel = -krandf(16) - targ->vel.Z * 0.25;
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-krandf(48)), SCRAP6 + (krand() & 3), -8, 48, 48, a, vel, zvel, targ, 5);
auto spawned = CreateActor(targ->sector(), targ->spr.pos.plusZ(-krandf(48)), SCRAP6 + (krand() & 3), -8, DVector2(0.75, 0.75), a, vel, zvel, targ, 5);
if (spawned) spawned->spr.pal = 8;
}
@ -2164,7 +2164,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj)
auto vel = krandf(8) + 4;
auto zvel = -krandf(2) - 1;
CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), SCRAP1 + (krand() & 15), -8, 64, 64,
CreateActor(targ->sector(), DVector3(targ->spr.pos.XY(), targ->sector()->floorz - 12 - j * 2), SCRAP1 + (krand() & 15), -8, DVector2(1, 1),
a, vel, zvel, targ, 5);
}
spawn(targ, EXPLOSION2);

View file

@ -202,7 +202,7 @@ DDukeActor* spawn(DDukeActor* actj, int pn)
{
if (actj)
{
auto spawned = CreateActor(actj->sector(), actj->spr.pos, pn, 0, 0, 0, nullAngle, 0., 0., actj, 0);
auto spawned = CreateActor(actj->sector(), actj->spr.pos, pn, 0, DVector2(0, 0), nullAngle, 0., 0., actj, 0);
if (spawned)
{
spawned->attackertype = actj->spr.picnum;
@ -1021,7 +1021,7 @@ void lotsofglass(DDukeActor *actor, walltype* wal, int n)
auto vel = krandf(4) + 2;
auto zvel = 4 - krandf(4);
CreateActor(actor->sector(), actor->spr.pos, TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, vel, zvel, actor, 5);
CreateActor(actor->sector(), actor->spr.pos, TILE_GLASSPIECES + (j % 3), -32, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5);
}
return;
}
@ -1048,7 +1048,7 @@ void lotsofglass(DDukeActor *actor, walltype* wal, int n)
auto vel = krandf(4) + 2;
auto zvel = 4 - krandf(4);
CreateActor(actor->sector(), DVector3(pos, z), TILE_GLASSPIECES + (j % 3), -32, 36, 36, angl, vel, zvel, actor, 5);
CreateActor(actor->sector(), DVector3(pos, z), TILE_GLASSPIECES + (j % 3), -32, DVector2(0.5625, 0.5625), angl, vel, zvel, actor, 5);
}
}
}
@ -1067,7 +1067,7 @@ void spriteglass(DDukeActor* actor, int n)
auto vel = krandf(4) + 2;
auto zvel = -2 - krandf(8);
auto k = CreateActor(actor->sector(), actor->spr.pos.plusZ(-(krand() & 16)), TILE_GLASSPIECES + (j % 3), krand() & 15, 36, 36, a, vel, zvel, actor, 5);
auto k = CreateActor(actor->sector(), actor->spr.pos.plusZ(-(krand() & 16)), TILE_GLASSPIECES + (j % 3), krand() & 15, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5);
if (k) k->spr.pal = actor->spr.pal;
}
}
@ -1092,7 +1092,7 @@ void ceilingglass(DDukeActor* actor, sectortype* sectp, int n)
auto vel = krandf(2);
double z = sectp->ceilingz + krandf(16);
CreateActor(sectp, DVector3(pos, z), TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, vel, 0, actor, 5);
CreateActor(sectp, DVector3(pos, z), TILE_GLASSPIECES + (j % 3), -32, DVector2(0.5625, 0.5625), a, vel, 0, actor, 5);
}
}
}
@ -1116,7 +1116,7 @@ void lotsofcolourglass(DDukeActor* actor, walltype* wal, int n)
auto vel = krandf(4) + 2;
auto zvel = 4 - krandf(4);
auto k = CreateActor(actor->sector(), actor->spr.pos.plusZ(-(krand() & 63)), TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, vel, zvel, actor, 5);
auto k = CreateActor(actor->sector(), actor->spr.pos.plusZ(-(krand() & 63)), TILE_GLASSPIECES + (j % 3), -32, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5);
if (k) k->spr.pal = krand() & 15;
}
return;
@ -1140,7 +1140,7 @@ void lotsofcolourglass(DDukeActor* actor, walltype* wal, int n)
auto vel = krandf(4) + 2;
auto zvel = - krandf(8);
auto k = CreateActor(actor->sector(), DVector3(pos, z), TILE_GLASSPIECES + (j % 3), -32, 36, 36, a, vel, zvel, actor, 5);
auto k = CreateActor(actor->sector(), DVector3(pos, z), TILE_GLASSPIECES + (j % 3), -32, DVector2(0.5625, 0.5625), a, vel, zvel, actor, 5);
if (k) k->spr.pal = krand() & 7;
}
}