From 7545b77e2872caf66916cb9f3555b2a3f3d4e554 Mon Sep 17 00:00:00 2001 From: kraflab Date: Sun, 24 Sep 2023 01:58:27 +0200 Subject: [PATCH] Add udmf thrust --- prboom2/src/dsda/scroll.c | 74 +++++++++++++++++++++++++++++++++++++++ prboom2/src/dsda/scroll.h | 2 ++ prboom2/src/p_saveg.c | 18 ++++++++++ prboom2/src/p_setup.c | 4 +++ 4 files changed, 98 insertions(+) diff --git a/prboom2/src/dsda/scroll.c b/prboom2/src/dsda/scroll.c index 579a75935..2451f3b57 100644 --- a/prboom2/src/dsda/scroll.c +++ b/prboom2/src/dsda/scroll.c @@ -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; @@ -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); +} diff --git a/prboom2/src/dsda/scroll.h b/prboom2/src/dsda/scroll.h index 03471b86c..a414f8345 100644 --- a/prboom2/src/dsda/scroll.h +++ b/prboom2/src/dsda/scroll.h @@ -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, @@ -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 diff --git a/prboom2/src/p_saveg.c b/prboom2/src/p_saveg.c index 1cb68f32e..618d99687 100644 --- a/prboom2/src/p_saveg.c +++ b/prboom2/src/p_saveg.c @@ -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, @@ -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); @@ -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) : @@ -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)); diff --git a/prboom2/src/p_setup.c b/prboom2/src/p_setup.c index 0a78d8dc0..7aed8905f 100644 --- a/prboom2/src/p_setup.c +++ b/prboom2/src/p_setup.c @@ -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;