- use the cleaned up movesprite interface in moveweapons.

This commit is contained in:
Christoph Oelckers 2020-10-22 21:19:24 +02:00
parent 3aaf2e80a9
commit 2d1b8a2b4b
3 changed files with 34 additions and 36 deletions

View file

@ -1408,7 +1408,7 @@ void rpgexplode(DDukeActor *actor, int hit, const vec3_t &pos, int EXPLOSION2, i
explosion->s.xrepeat = 6; explosion->s.xrepeat = 6;
explosion->s.yrepeat = 6; explosion->s.yrepeat = 6;
} }
else if ((hit & kHitTypeMask) == kHitSector) else if (hit == kHitSector)
{ {
if (s->zvel > 0 && EXPLOSION2BOT >= 0) if (s->zvel > 0 && EXPLOSION2BOT >= 0)
spawn(actor, EXPLOSION2BOT); spawn(actor, EXPLOSION2BOT);

View file

@ -1803,13 +1803,14 @@ static void weaponcommon_d(DDukeActor* proj)
break; break;
} }
int j = fi.movesprite(proj->GetIndex(), Collision coll;
movesprite_ex(proj,
(k * (sintable[(s->ang + 512) & 2047])) >> 14, (k * (sintable[(s->ang + 512) & 2047])) >> 14,
(k * (sintable[s->ang & 2047])) >> 14, ll, CLIPMASK1); (k * (sintable[s->ang & 2047])) >> 14, ll, CLIPMASK1, coll);
if (s->picnum == RPG && proj->temp_actor != nullptr) if (s->picnum == RPG && proj->temp_actor != nullptr)
if (FindDistance2D(s->x - proj->temp_actor->s.x, s->y - proj->temp_actor->s.y) < 256) if (FindDistance2D(s->x - proj->temp_actor->s.x, s->y - proj->temp_actor->s.y) < 256)
j = kHitSprite | s->yvel; coll.setSprite(proj->temp_actor);
if (s->sectnum < 0) if (s->sectnum < 0)
{ {
@ -1817,18 +1818,18 @@ static void weaponcommon_d(DDukeActor* proj)
return; return;
} }
if ((j & kHitTypeMask) != kHitSprite && s->picnum != FREEZEBLAST) if (coll.type != kHitSprite && s->picnum != FREEZEBLAST)
{ {
if (s->z < proj->ceilingz) if (s->z < proj->ceilingz)
{ {
j = kHitSector | (s->sectnum); coll.setSector(s->sectnum);
s->zvel = -1; s->zvel = -1;
} }
else else
if ((s->z > proj->floorz && sector[s->sectnum].lotag != 1) || if ((s->z > proj->floorz && sector[s->sectnum].lotag != 1) ||
(s->z > proj->floorz + (16 << 8) && sector[s->sectnum].lotag == 1)) (s->z > proj->floorz + (16 << 8) && sector[s->sectnum].lotag == 1))
{ {
j = kHitSector | (s->sectnum); coll.setSector(s->sectnum);
if (sector[s->sectnum].lotag != 1) if (sector[s->sectnum].lotag != 1)
s->zvel = 1; s->zvel = 1;
} }
@ -1851,11 +1852,11 @@ static void weaponcommon_d(DDukeActor* proj)
else if (s->picnum == SPIT) if (s->zvel < 6144) else if (s->picnum == SPIT) if (s->zvel < 6144)
s->zvel += gc - 112; s->zvel += gc - 112;
if (j != 0) if (coll.type != 0)
{ {
if (s->picnum == COOLEXPLOSION1) if (s->picnum == COOLEXPLOSION1)
{ {
if ((j & kHitTypeMask) == kHitSprite && hittype[j & kHitIndexMask].s.picnum != APLAYER) if (coll.type == kHitSprite && coll.actor->s.picnum != APLAYER)
{ {
return; return;
} }
@ -1865,17 +1866,15 @@ static void weaponcommon_d(DDukeActor* proj)
bool fireball = (isWorldTour() && s->picnum == FIREBALL && (!proj->GetOwner() || proj->GetOwner()->s.picnum != FIREBALL)); bool fireball = (isWorldTour() && s->picnum == FIREBALL && (!proj->GetOwner() || proj->GetOwner()->s.picnum != FIREBALL));
if ((j & kHitTypeMask) == kHitSprite) if (coll.type == kHitSprite)
{ {
j &= kHitIndexMask; if (weaponhitsprite(proj, coll.actor, fireball)) return;
if (weaponhitsprite(proj, &hittype[j], fireball)) return;
} }
else if ((j & kHitTypeMask) == kHitWall) else if (coll.type == kHitWall)
{ {
j &= kHitIndexMask; if (weaponhitwall(proj, coll.index, oldpos)) return;
if (weaponhitwall(proj, j, oldpos)) return;
} }
else if ((j & kHitTypeMask) == kHitSector) else if (coll.type == kHitSector)
{ {
if (weaponhitsector(proj, oldpos, fireball)) return; if (weaponhitsector(proj, oldpos, fireball)) return;
} }
@ -1885,7 +1884,7 @@ static void weaponcommon_d(DDukeActor* proj)
if (s->picnum == RPG) if (s->picnum == RPG)
{ {
// j is only needed for the hit type mask. // j is only needed for the hit type mask.
rpgexplode(proj, j, oldpos, EXPLOSION2, EXPLOSION2BOT, -1, RPG_EXPLODE); rpgexplode(proj, coll.type, oldpos, EXPLOSION2, EXPLOSION2BOT, -1, RPG_EXPLODE);
} }
else if (s->picnum == SHRINKSPARK) else if (s->picnum == SHRINKSPARK)
{ {
@ -1897,7 +1896,7 @@ static void weaponcommon_d(DDukeActor* proj)
{ {
auto k = spawn(proj, EXPLOSION2); auto k = spawn(proj, EXPLOSION2);
k->s.xrepeat = k->s.yrepeat = s->xrepeat >> 1; k->s.xrepeat = k->s.yrepeat = s->xrepeat >> 1;
if ((j & kHitTypeMask) == kHitSector) if (coll.type == kHitSector)
{ {
if (s->zvel < 0) if (s->zvel < 0)
{ {

View file

@ -1416,13 +1416,14 @@ static void weaponcommon_r(DDukeActor *proj)
break; break;
} }
int j = fi.movesprite(proj->GetIndex(), Collision coll;
movesprite_ex(proj,
(k * (sintable[(s->ang + 512) & 2047])) >> 14, (k * (sintable[(s->ang + 512) & 2047])) >> 14,
(k * (sintable[s->ang & 2047])) >> 14, ll, CLIPMASK1); (k * (sintable[s->ang & 2047])) >> 14, ll, CLIPMASK1, coll);
if ((s->picnum == RPG || (isRRRA() && isIn(s->picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr) if ((s->picnum == RPG || (isRRRA() && isIn(s->picnum, RPG2, RRTILE1790))) && proj->temp_actor != nullptr)
if (FindDistance2D(s->x - proj->temp_actor->s.x, s->y - proj->temp_actor->s.y) < 256) if (FindDistance2D(s->x - proj->temp_actor->s.x, s->y - proj->temp_actor->s.y) < 256)
j = kHitSprite | s->yvel; coll.setSprite(proj->temp_actor);
if (s->sectnum < 0) // || (isRR() && sector[s->sectnum].filler == 800)) if (s->sectnum < 0) // || (isRR() && sector[s->sectnum].filler == 800))
{ {
@ -1430,17 +1431,17 @@ static void weaponcommon_r(DDukeActor *proj)
return; return;
} }
if ((j & kHitTypeMask) != kHitSprite && s->picnum != FREEZEBLAST) if (coll.type != kHitSprite && s->picnum != FREEZEBLAST)
{ {
if (s->z < proj->ceilingz) if (s->z < proj->ceilingz)
{ {
j = kHitSector | (s->sectnum); coll.setSector(s->sectnum);
s->zvel = -1; s->zvel = -1;
} }
else else
if (s->z > proj->floorz) if (s->z > proj->floorz)
{ {
j = kHitSector | (s->sectnum); coll.setSector(s->sectnum);
if (sector[s->sectnum].lotag != 1) if (sector[s->sectnum].lotag != 1)
s->zvel = 1; s->zvel = 1;
} }
@ -1463,33 +1464,31 @@ static void weaponcommon_r(DDukeActor *proj)
else if (s->picnum == SPIT) if (s->zvel < 6144) else if (s->picnum == SPIT) if (s->zvel < 6144)
s->zvel += gc - 112; s->zvel += gc - 112;
if (j != 0) if (coll.type != 0)
{ {
if ((j & kHitTypeMask) == kHitSprite) if (coll.type == kHitSprite)
{ {
j &= kHitIndexMask; if (weaponhitsprite(proj, coll.actor, oldpos)) return;
if (weaponhitsprite(proj, &hittype[j], oldpos)) return;
} }
else if ((j & kHitTypeMask) == kHitWall) else if (coll.type == kHitWall)
{ {
j &= kHitIndexMask; if (weaponhitwall(proj, coll.index, oldpos)) return;
if (weaponhitwall(proj, j, oldpos)) return;
} }
else if ((j & kHitTypeMask) == kHitSector) else if (coll.type == kHitSector)
{ {
if (weaponhitsector(proj, oldpos)) return; if (weaponhitsector(proj, oldpos)) return;
} }
if (s->picnum != SPIT) if (s->picnum != SPIT)
{ {
if (s->picnum == RPG) rpgexplode(proj, j, oldpos, EXPLOSION2, -1, -1, RPG_EXPLODE); if (s->picnum == RPG) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, -1, RPG_EXPLODE);
else if (isRRRA() && s->picnum == RPG2) rpgexplode(proj, j, oldpos, EXPLOSION2, -1, 150, 247); else if (isRRRA() && s->picnum == RPG2) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 150, 247);
else if (isRRRA() && s->picnum == RRTILE1790) rpgexplode(proj, j, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE); else if (isRRRA() && s->picnum == RRTILE1790) rpgexplode(proj, coll.type, oldpos, EXPLOSION2, -1, 160, RPG_EXPLODE);
else if (s->picnum != FREEZEBLAST && s->picnum != FIRELASER && s->picnum != SHRINKSPARK) else if (s->picnum != FREEZEBLAST && s->picnum != FIRELASER && s->picnum != SHRINKSPARK)
{ {
auto k = spawn(proj, 1441); auto k = spawn(proj, 1441);
k->s.xrepeat = k->s.yrepeat = s->xrepeat >> 1; k->s.xrepeat = k->s.yrepeat = s->xrepeat >> 1;
if ((j & kHitTypeMask) == kHitSector) if (coll.type == kHitSector)
{ {
if (s->zvel < 0) if (s->zvel < 0)
{ {