diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index e17714388..d53ad8d6c 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4531,6 +4531,88 @@ void handle_se27(DDukeActor* actor) // //--------------------------------------------------------------------------- +void handle_se24(DDukeActor *actor, int16_t *list1, int16_t *list2, int TRIPBOMB, int LASERLINE, int CRANE, int shift) +{ + int* t = &actor->temp_data[0]; + + auto testlist = [](int16_t* list, int val) { for (int i = 0; list[i] > 0; i++) if (list[i] == val) return true; return false; }; + + if (t[4]) return; + + int x = (actor->s.yvel * sintable[(actor->s.ang + 512) & 2047]) >> 18; + int l = (actor->s.yvel * sintable[actor->s.ang & 2047]) >> 18; + + DukeSectIterator it(actor->s.sectnum); + while (auto a2 = it.Next()) + { + auto s2 = &a2->s; + if (s2->zvel >= 0) + { + switch (s2->statnum) + { + case 5: + if (testlist(list1, s2->picnum)) + { + s2->xrepeat = s2->yrepeat = 0; + continue; + } + if (s2->picnum == LASERLINE) + { + continue; + } + + //[[fallthrough]] + case 6: + if (s2->picnum == TRIPBOMB) break; + //[[fallthrough]] + case 1: + case 0: + if (testlist(list2, s2->picnum) || + wallswitchcheck(a2)) + break; + + if (!(s2->picnum >= CRANE && s2->picnum <= (CRANE + 3))) + { + if (s2->z > (a2->floorz - (16 << 8))) + { + a2->bposx = s2->x; + a2->bposy = s2->y; + + s2->x += x >> shift; + s2->y += l >> shift; + + setsprite(a2, s2->pos); + + if (sector[s2->sectnum].floorstat & 2) + if (s2->statnum == 2) + makeitfall(a2); + } + } + break; + } + } + } + + for (auto p = connecthead; p >= 0; p = connectpoint2[p]) + { + if (ps[p].cursectnum == actor->s.sectnum && ps[p].on_ground) + { + if (abs(ps[p].pos.z - ps[p].truefz) < PHEIGHT + (9 << 8)) + { + ps[p].fric.x += x << 3; + ps[p].fric.y += l << 3; + } + } + } + sector[actor->s.sectnum].floorxpanning += actor->s.yvel >> 7; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void handle_se32(DDukeActor *actor) { auto s = &actor->s; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 282645afe..b756bbfe2 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -3675,91 +3675,9 @@ void moveeffectors_d(void) //STATNUM 3 case SE_24_CONVEYOR: case 34: { - if (t[4]) break; - - x = (sprite[i].yvel * sintable[(s->ang + 512) & 2047]) >> 18; - l = (sprite[i].yvel * sintable[s->ang & 2047]) >> 18; - - k = 0; - - SectIterator it(s->sectnum); - while ((j = it.NextIndex()) >= 0) - { - auto sprj = &sprite[j]; - if (sprj->zvel >= 0) - switch (sprj->statnum) - { - case 5: - switch (sprj->picnum) - { - case BLOODPOOL: - case PUKE: - case FOOTPRINTS: - case FOOTPRINTS2: - case FOOTPRINTS3: - case FOOTPRINTS4: - case BULLETHOLE: - case BLOODSPLAT1: - case BLOODSPLAT2: - case BLOODSPLAT3: - case BLOODSPLAT4: - sprj->xrepeat = sprj->yrepeat = 0; - continue; - case LASERLINE: - continue; - } - case 6: - if (sprj->picnum == TRIPBOMB) break; - case 1: - case 0: - if ( - sprj->picnum == BOLT1 || - sprj->picnum == BOLT1 + 1 || - sprj->picnum == BOLT1 + 2 || - sprj->picnum == BOLT1 + 3 || - sprj->picnum == SIDEBOLT1 || - sprj->picnum == SIDEBOLT1 + 1 || - sprj->picnum == SIDEBOLT1 + 2 || - sprj->picnum == SIDEBOLT1 + 3 || - wallswitchcheck(j) - ) - break; - - if (!(sprj->picnum >= CRANE && sprj->picnum <= (CRANE + 3))) - { - if (sprj->z > (hittype[j].floorz - (16 << 8))) - { - hittype[j].bposx = sprj->x; - hittype[j].bposy = sprj->y; - - sprj->x += x >> 2; - sprj->y += l >> 2; - - setsprite(j, sprj->x, sprj->y, sprj->z); - - if (sector[sprj->sectnum].floorstat & 2) - if (sprj->statnum == 2) - makeitfall(j); - } - } - break; - } - } - - for (p = connecthead; p >= 0; p = connectpoint2[p]) - { - if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) - { - if (abs(ps[p].pos.z - ps[p].truefz) < PHEIGHT + (9 << 8)) - { - ps[p].fric.x += x << 3; - ps[p].fric.y += l << 3; - } - } - } - - sc->floorxpanning += sprite[i].yvel >> 7; - + static int16_t list1[] = { BLOODPOOL, PUKE, FOOTPRINTS, FOOTPRINTS2, FOOTPRINTS3, FOOTPRINTS4, BULLETHOLE, BLOODSPLAT1, BLOODSPLAT2, BLOODSPLAT3, BLOODSPLAT4, -1 }; + static int16_t list2[] = { BOLT1, BOLT1 + 1,BOLT1 + 2, BOLT1 + 3, SIDEBOLT1, SIDEBOLT1 + 1, SIDEBOLT1 + 2, SIDEBOLT1 + 3, -1 }; + handle_se24(&hittype[i], list1, list2, TRIPBOMB, LASERLINE, CRANE, 2); break; } case 35: diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 6efe97f04..833c71398 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -3648,82 +3648,12 @@ void moveeffectors_r(void) //STATNUM 3 case SE_24_CONVEYOR: case 34: { - if (t[4]) break; - - x = (sprite[i].yvel * sintable[(s->ang + 512) & 2047]) >> 18; - l = (sprite[i].yvel * sintable[s->ang & 2047]) >> 18; - - k = 0; - - SectIterator it(s->sectnum); - while ((j = it.NextIndex()) >= 0) - { - auto sj = &sprite[j]; - if (sj->zvel >= 0) - switch (sj->statnum) - { - case 5: - switch (sj->picnum) - { - case BLOODPOOL: - case FOOTPRINTS: - case FOOTPRINTS2: - case FOOTPRINTS3: - sj->xrepeat = sj->yrepeat = 0; - k = 1; - break; - case BULLETHOLE: - continue; - } - case 6: - case 1: - case 0: - if ( - sj->picnum == BOLT1 || - sj->picnum == BOLT1 + 1 || - sj->picnum == BOLT1 + 2 || - sj->picnum == BOLT1 + 3 || - wallswitchcheck(j) - ) - break; - - if (!(sj->picnum >= CRANE && sj->picnum <= (CRANE + 3))) - { - if (sj->z > (hittype[j].floorz - (16 << 8))) - { - hittype[j].bposx = sj->x; - hittype[j].bposy = sj->y; - - sj->x += x >> 1; - sj->y += l >> 1; - - setsprite(j, sj->x, sj->y, sj->z); - - if (sector[sj->sectnum].floorstat & 2) - if (sj->statnum == 2) - makeitfall(j); - } - } - break; - } - } - - for (p = connecthead; p >= 0; p = connectpoint2[p]) - { - if (ps[p].cursectnum == s->sectnum && ps[p].on_ground) - { - if (abs(ps[p].pos.z - ps[p].truefz) < PHEIGHT + (9 << 8)) - { - ps[p].fric.x += x << 3; - ps[p].fric.y += l << 3; - } - } - } - - sc->floorxpanning += sprite[i].yvel >> 7; - + static int16_t list1[] = { BLOODPOOL, PUKE, FOOTPRINTS, FOOTPRINTS2, FOOTPRINTS3, -1 }; + static int16_t list2[] = { BOLT1, BOLT1 + 1,BOLT1 + 2, BOLT1 + 3, -1 }; + handle_se24(&hittype[i], list1, list2, BULLETHOLE, -1, CRANE, 1); break; } + case 35: handle_se35(&hittype[i], SMALLSMOKE, EXPLOSION2); break; diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index eb8f88775..bc44a4bf1 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -84,6 +84,7 @@ void handle_se19(DDukeActor* i, int BIGFORCE); void handle_se20(DDukeActor* i); void handle_se21(DDukeActor* i); void handle_se22(DDukeActor* i); +void handle_se24(DDukeActor* actor, int16_t* list1, int16_t* list2, int TRIPBOMB, int LASERLINE, int CRANE, int shift); void handle_se26(DDukeActor* i); void handle_se27(DDukeActor* i); void handle_se32(DDukeActor* i);