diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index d53ad8d6c..f03b29b5c 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4613,6 +4613,44 @@ void handle_se24(DDukeActor *actor, int16_t *list1, int16_t *list2, int TRIPBOMB // //--------------------------------------------------------------------------- +void handle_se25(DDukeActor* actor, int t_index, int snd1, int snd2) +{ + int* t = &actor->temp_data[0]; + auto sec = §or[actor->s.sectnum]; + + if (sec->floorz <= sec->ceilingz) + actor->s.shade = 0; + else if (sec->ceilingz <= t[t_index]) + actor->s.shade = 1; + + if (actor->s.shade) + { + sec->ceilingz += actor->s.yvel << 4; + if (sec->ceilingz > sec->floorz) + { + sec->ceilingz = sec->floorz; + if (pistonsound && snd1 >= 0) + S_PlayActorSound(snd1, actor); + } + } + else + { + sec->ceilingz -= actor->s.yvel << 4; + if (sec->ceilingz < t[t_index]) + { + sec->ceilingz = t[t_index]; + if (pistonsound && snd2 >= 0) + S_PlayActorSound(snd2, actor); + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + 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 b756bbfe2..fa36aca84 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -3685,27 +3685,8 @@ void moveeffectors_d(void) //STATNUM 3 break; case 25: //PISTONS - - if (t[4] == 0) break; - - if (sc->floorz <= sc->ceilingz) - s->shade = 0; - else if (sc->ceilingz <= t[3]) - s->shade = 1; - - if (s->shade) - { - sc->ceilingz += sprite[i].yvel << 4; - if (sc->ceilingz > sc->floorz) - sc->ceilingz = sc->floorz; - } - else - { - sc->ceilingz -= sprite[i].yvel << 4; - if (sc->ceilingz < t[3]) - sc->ceilingz = t[3]; - } - + if (hittype[i].temp_data[4] == 0) break; + handle_se25(&hittype[i], 3, -1, -1); break; case 26: diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 833c71398..158bf8087 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -3421,7 +3421,7 @@ void moveexplosions_r(void) // STATNUM 5 void moveeffectors_r(void) //STATNUM 3 { int l, x, st, j, * t; - int p, sh, ns, pn; + int sh, ns, pn; short k; spritetype* s; sectortype* sc; @@ -3659,35 +3659,8 @@ void moveeffectors_r(void) //STATNUM 3 break; case 25: //PISTONS - if (t[4] == 0) break; - - if (sc->floorz <= sc->ceilingz) - s->shade = 0; - else if (sc->ceilingz <= t[4]) - s->shade = 1; - - if (s->shade) - { - sc->ceilingz += sprite[i].yvel << 4; - if (sc->ceilingz > sc->floorz) - { - sc->ceilingz = sc->floorz; - if (isRRRA() && pistonsound) - S_PlayActorSound(371, i); - } - } - else - { - sc->ceilingz -= sprite[i].yvel << 4; - if (sc->ceilingz < t[4]) - { - sc->ceilingz = t[4]; - if (isRRRA() && pistonsound) - S_PlayActorSound(167, i); - } - } - + handle_se25(&hittype[i], 4, isRRRA() ? 371 : -1, isRRRA() ? 167 : -1); break; case 26: diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index bc44a4bf1..1784dd243 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -85,6 +85,7 @@ 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_se25(DDukeActor* a, int t_index, int snd1, int snd2); void handle_se26(DDukeActor* i); void handle_se27(DDukeActor* i); void handle_se32(DDukeActor* i);