Merge branch '144-scrolltweaks' into 'master'

Resolve "Let scrollers and wind/current affect front sector if untagged, and use texture offsets as parameters if different from 0"

Closes #144

See merge request STJr/SRB2Internal!213
This commit is contained in:
Nev3r 2019-04-05 06:41:11 -04:00
commit 1d401d8481
1 changed files with 107 additions and 38 deletions

View File

@ -7738,11 +7738,22 @@ static void P_SpawnScrollers(void)
for (i = 0; i < numlines; i++, l++) for (i = 0; i < numlines; i++, l++)
{ {
fixed_t dx = l->dx >> SCROLL_SHIFT; // direction and speed of scrolling fixed_t dx = l->dx; // direction and speed of scrolling
fixed_t dy = l->dy >> SCROLL_SHIFT; fixed_t dy = l->dy;
INT32 control = -1, accel = 0; // no control sector or acceleration INT32 control = -1, accel = 0; // no control sector or acceleration
INT32 special = l->special; INT32 special = l->special;
// If front texture X offset provided, override the amount with it.
if (sides[l->sidenum[0]].textureoffset != 0)
{
fixed_t len = sides[l->sidenum[0]].textureoffset;
fixed_t h = FixedHypot(dx, dy);
dx = FixedMul(FixedDiv(dx, h), len);
dy = FixedMul(FixedDiv(dy, h), len);
}
dx = dx >> SCROLL_SHIFT;
dy = dy >> SCROLL_SHIFT;
// These types are same as the ones they get set to except that the // These types are same as the ones they get set to except that the
// first side's sector's heights cause scrolling when they change, and // first side's sector's heights cause scrolling when they change, and
// this linedef controls the direction and speed of the scrolling. The // this linedef controls the direction and speed of the scrolling. The
@ -7777,8 +7788,14 @@ static void P_SpawnScrollers(void)
case 513: // scroll effect ceiling case 513: // scroll effect ceiling
case 533: // scroll and carry objects on ceiling case 533: // scroll and carry objects on ceiling
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) if (l->tag == 0)
Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); Add_Scroller(sc_ceiling, -dx, dy, control, l->frontsector - sectors, accel, l->flags & ML_NOCLIMB);
else
{
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Scroller(sc_ceiling, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB);
}
if (special != 533) if (special != 533)
break; break;
/* FALLTHRU */ /* FALLTHRU */
@ -7786,14 +7803,26 @@ static void P_SpawnScrollers(void)
case 523: // carry objects on ceiling case 523: // carry objects on ceiling
dx = FixedMul(dx, CARRYFACTOR); dx = FixedMul(dx, CARRYFACTOR);
dy = FixedMul(dy, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR);
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (l->tag == 0)
Add_Scroller(sc_carry_ceiling, dx, dy, control, l->frontsector - sectors, accel, l->flags & ML_NOCLIMB);
else
{
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Scroller(sc_carry_ceiling, dx, dy, control, s, accel, l->flags & ML_NOCLIMB);
}
break; break;
case 510: // scroll effect floor case 510: // scroll effect floor
case 530: // scroll and carry objects on floor case 530: // scroll and carry objects on floor
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) if (l->tag == 0)
Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB); Add_Scroller(sc_floor, -dx, dy, control, l->frontsector - sectors, accel, l->flags & ML_NOCLIMB);
else
{
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Scroller(sc_floor, -dx, dy, control, s, accel, l->flags & ML_NOCLIMB);
}
if (special != 530) if (special != 530)
break; break;
/* FALLTHRU */ /* FALLTHRU */
@ -7801,8 +7830,14 @@ static void P_SpawnScrollers(void)
case 520: // carry objects on floor case 520: // carry objects on floor
dx = FixedMul(dx, CARRYFACTOR); dx = FixedMul(dx, CARRYFACTOR);
dy = FixedMul(dy, CARRYFACTOR); dy = FixedMul(dy, CARRYFACTOR);
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB); if (l->tag == 0)
Add_Scroller(sc_carry, dx, dy, control, l->frontsector - sectors, accel, l->flags & ML_NOCLIMB);
else
{
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Scroller(sc_carry, dx, dy, control, s, accel, l->flags & ML_NOCLIMB);
}
break; break;
// scroll wall according to linedef // scroll wall according to linedef
@ -9165,43 +9200,77 @@ static void P_SpawnPushers(void)
line_t *l = lines; line_t *l = lines;
register INT32 s; register INT32 s;
mobj_t *thing; mobj_t *thing;
pushertype_e pushertype;
fixed_t dx, dy;
for (i = 0; i < numlines; i++, l++) for (i = 0; i < numlines; i++, l++)
{
switch (l->special) switch (l->special)
{ {
case 541: // wind case 541: // wind
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) pushertype = p_wind;
Add_Pusher(p_wind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break;
break;
case 544: // current case 544: // current
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) pushertype = p_current;
Add_Pusher(p_current, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); break;
break; case 547: // push/pull
case 547: // push/pull if (l->tag == 0)
{
s = l->frontsector - sectors;
if ((thing = P_GetPushThing(s)) != NULL) // No MT_P* means no effect
Add_Pusher(p_push, l->dx, l->dy, thing, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4);
}
else
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;) for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
{ {
thing = P_GetPushThing(s); if ((thing = P_GetPushThing(s)) != NULL) // No MT_P* means no effect
if (thing) // No MT_P* means no effect
Add_Pusher(p_push, l->dx, l->dy, thing, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); Add_Pusher(p_push, l->dx, l->dy, thing, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4);
} }
break;
case 545: // current up continue;
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Pusher(p_upcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); case 545: // current up
break; pushertype = p_upcurrent;
case 546: // current down break;
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Pusher(p_downcurrent, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); case 546: // current down
break; pushertype = p_downcurrent;
case 542: // wind up break;
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Pusher(p_upwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); case 542: // wind up
break; pushertype = p_upwind;
case 543: // wind down break;
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Pusher(p_downwind, l->dx, l->dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4); case 543: // wind down
break; pushertype = p_downwind;
break;
default:
continue;
} }
dx = l->dx;
dy = l->dy;
// Obtain versor and scale it up according to texture offset, if provided; line length is ignored in this case.
if (sides[l->sidenum[0]].textureoffset != 0)
{
fixed_t len = sides[l->sidenum[0]].textureoffset;
fixed_t h = FixedHypot(dx, dy);
dx = FixedMul(FixedDiv(dx, h), len);
dy = FixedMul(FixedDiv(dy, h), len);
}
if (l->tag == 0)
Add_Pusher(pushertype, dx, dy, NULL, l->frontsector - sectors, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4);
else
{
for (s = -1; (s = P_FindSectorFromLineTag(l, s)) >= 0 ;)
Add_Pusher(pushertype, dx, dy, NULL, s, -1, l->flags & ML_NOCLIMB, l->flags & ML_EFFECT4);
}
}
} }
static void P_SearchForDisableLinedefs(void) static void P_SearchForDisableLinedefs(void)