Skip to content

Commit

Permalink
Add udmf thrust
Browse files Browse the repository at this point in the history
  • Loading branch information
kraflab committed Sep 23, 2023
1 parent fc5246f commit 7545b77
Show file tree
Hide file tree
Showing 4 changed files with 98 additions and 0 deletions.
74 changes: 74 additions & 0 deletions prboom2/src/dsda/scroll.c
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,71 @@ void dsda_UpdateZDoomCeilingScroller(scroll_t* s) {
}
}

void dsda_UpdateThruster(scroll_t* s) {
sector_t* sec;
msecnode_t* node;
mobj_t* thing;

if (!s->dx && !s->dy)
return;

sec = sectors + s->affectee;

for (node = sec->touching_thinglist; node; node = node->m_snext) {
dboolean thrust_it;

thrust_it = false;
thing = node->m_thing;

if (thing->flags & MF_NOCLIP)
continue;

if (!(thing->flags & MF_NOGRAVITY) && thing->z <= thing->floorz) {
if (s->flags & THRUST_GROUNDED)
thrust_it = true;
}
else if (thing->z > sec->floorheight && thing->z + thing->height < sec->ceilingheight) {
if (s->flags & THRUST_AIRBORNE)
thrust_it = true;
}
else if (thing->flags & MF_SPAWNCEILING &&
thing->flags & MF_NOGRAVITY &&
thing->z + thing->height == sec->ceilingheight) {
if (s->flags & THRUST_CEILING)
thrust_it = true;
}

if (thrust_it) {
thrust_it = false;

if (thing->flags2 & MF2_WINDTHRUST && s->flags & THRUST_WINDTHRUST)
thrust_it = true;
else if (thing->type == MT_SKULL || thing->flags & MF_COUNTKILL) {
if (s->flags & THRUST_MONSTER)
thrust_it = true;
}
else if (thing->player) {
if (s->flags & THRUST_PLAYER)
thrust_it = true;
}
else if (thing->flags & MF_MISSILE) {
if (s->flags & THRUST_PROJECTILE)
thrust_it = true;
}
else {
if (s->flags & THRUST_STATIC)
thrust_it = true;
}

if (thrust_it) {
thing->momx += s->dx;
thing->momy += s->dy;
thing->intflags |= MIF_SCROLLING;
}
}
}
}

static void dsda_InitScroller(scroll_t* scroll, fixed_t dx, fixed_t dy, int affectee, int flags) {
scroll->dx = dx;
scroll->dy = dy;
Expand Down Expand Up @@ -407,3 +472,12 @@ void dsda_AddZDoomCeilingScroller(fixed_t dx, fixed_t dy, int affectee, int flag
dsda_InitScroller(scroll, dx, dy, affectee, flags);
P_AddThinker(&scroll->thinker);
}

void dsda_AddThruster(fixed_t dx, fixed_t dy, int affectee, int flags) {
scroll_t* scroll;

scroll = Z_MallocLevel(sizeof(*scroll));
scroll->thinker.function = dsda_UpdateThruster;
dsda_InitScroller(scroll, dx, dy, affectee, flags);
P_AddThinker(&scroll->thinker);
}
2 changes: 2 additions & 0 deletions prboom2/src/dsda/scroll.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void dsda_UpdateControlFloorCarryScroller(control_scroll_t* s);
void dsda_UpdateFloorCarryScroller(scroll_t* s);
void dsda_UpdateZDoomFloorScroller(scroll_t* s);
void dsda_UpdateZDoomCeilingScroller(scroll_t* s);
void dsda_UpdateThruster(scroll_t* s);

void dsda_AddSideScroller(fixed_t dx, fixed_t dy, int affectee, int flags);
void dsda_AddControlSideScroller(fixed_t dx, fixed_t dy,
Expand All @@ -83,5 +84,6 @@ void dsda_AddControlFloorCarryScroller(fixed_t dx, fixed_t dy,
int control, int affectee, int accel, int flags);
void dsda_AddZDoomFloorScroller(fixed_t dx, fixed_t dy, int affectee, int flags);
void dsda_AddZDoomCeilingScroller(fixed_t dx, fixed_t dy, int affectee, int flags);
void dsda_AddThruster(fixed_t dx, fixed_t dy, int affectee, int flags);

#endif
18 changes: 18 additions & 0 deletions prboom2/src/p_saveg.c
Original file line number Diff line number Diff line change
Expand Up @@ -725,6 +725,7 @@ typedef enum {
tc_true_scroll_floor_carry_control,
tc_true_zdoom_scroll_floor,
tc_true_zdoom_scroll_ceiling,
tc_true_thrust,
tc_true_pusher,
tc_true_flicker,
tc_true_zdoom_flicker,
Expand Down Expand Up @@ -920,6 +921,13 @@ void P_TrueArchiveThinkers(void) {
continue;
}

if (th->function == dsda_UpdateThruster)
{
P_SAVE_BYTE(tc_true_thrust);
P_SAVE_TYPE(th, scroll_t);
continue;
}

if (th->function == dsda_UpdateControlSideScroller)
{
P_SAVE_BYTE(tc_true_scroll_side_control);
Expand Down Expand Up @@ -1187,6 +1195,7 @@ void P_TrueUnArchiveThinkers(void) {
tc == tc_true_scroll_floor_carry ? sizeof(scroll_t) :
tc == tc_true_zdoom_scroll_floor ? sizeof(scroll_t) :
tc == tc_true_zdoom_scroll_ceiling ? sizeof(scroll_t) :
tc == tc_true_thrust ? sizeof(scroll_t) :
tc == tc_true_scroll_side_control ? sizeof(control_scroll_t) :
tc == tc_true_scroll_floor_control ? sizeof(control_scroll_t) :
tc == tc_true_scroll_ceiling_control ? sizeof(control_scroll_t) :
Expand Down Expand Up @@ -1416,6 +1425,15 @@ void P_TrueUnArchiveThinkers(void) {
break;
}

case tc_true_thrust:
{
scroll_t *scroll = Z_MallocLevel (sizeof(*scroll));
P_LOAD_P(scroll);
scroll->thinker.function = dsda_UpdateThruster;
P_AddThinker(&scroll->thinker);
break;
}

case tc_true_scroll_side_control:
{
control_scroll_t *scroll = Z_MallocLevel (sizeof(*scroll));
Expand Down
4 changes: 4 additions & 0 deletions prboom2/src/p_setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -1024,6 +1024,10 @@ static void P_LoadUDMFSectors(int lump)
dsda_AddZDoomCeilingScroller(dsda_FloatToFixed(ms->xscrollceiling),
dsda_FloatToFixed(ms->yscrollceiling), i, ms->scrollceilingmode);

if ((ms->xthrust || ms->ythrust) && ms->thrustgroup && ms->thrustlocation)
dsda_AddThruster(dsda_FloatToFixed(ms->xthrust), dsda_FloatToFixed(ms->ythrust),
i, ms->thrustgroup + (ms->thrustlocation << THRUST_LOCATION_SHIFT));

if (ms->flags & UDMF_SECF_DAMAGEHAZARD)
ss->flags |= SECF_HAZARD;

Expand Down

0 comments on commit 7545b77

Please sign in to comment.