diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index b067f2a8a..380773943 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -5279,16 +5279,16 @@ void alterang(int ang, DDukeActor* actor, int playernum) // //--------------------------------------------------------------------------- -void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*)) +void fall_common(DDukeActor *actor, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(DDukeActor*, int)) { - auto g_sp = &sprite[g_i]; + auto g_sp = &actor->s; g_sp->xoffset = 0; g_sp->yoffset = 0; // if(!gotz) { int c; - int sphit = fallspecial? fallspecial(g_i, g_p) : 0; + int sphit = fallspecial? fallspecial(actor, g_p) : 0; if (fi.floorspace(g_sp->sectnum)) c = 0; else @@ -5298,14 +5298,14 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT else c = gc; } - if (hittype[g_i].cgg <= 0 || (sector[g_sp->sectnum].floorstat & 2)) + if (actor->cgg <= 0 || (sector[g_sp->sectnum].floorstat & 2)) { - getglobalz(g_i); - hittype[g_i].cgg = 6; + getglobalz(actor); + actor->cgg = 6; } - else hittype[g_i].cgg--; + else actor->cgg--; - if (g_sp->z < (hittype[g_i].floorz - FOURSLEIGHT)) + if (g_sp->z < (actor->floorz - FOURSLEIGHT)) { g_sp->zvel += c; g_sp->z += g_sp->zvel; @@ -5314,9 +5314,9 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT } else { - g_sp->z = hittype[g_i].floorz - FOURSLEIGHT; + g_sp->z = actor->floorz - FOURSLEIGHT; - if (badguy(g_sp) || (g_sp->picnum == TILE_APLAYER && g_sp->owner >= 0)) + if (badguy(actor) || (g_sp->picnum == TILE_APLAYER && actor->GetOwner())) { if (g_sp->zvel > 3084 && g_sp->extra <= 1) @@ -5327,21 +5327,21 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT goto SKIPJIBS; if (sphit) { - fi.guts(g_sp, JIBS6, 5, g_p); - S_PlayActorSound(squished, g_i); + fi.guts(&actor->s, JIBS6, 5, g_p); + S_PlayActorSound(squished, actor); } else { - fi.guts(g_sp, JIBS6, 15, g_p); - S_PlayActorSound(squished, g_i); - fi.spawn(g_i, BLOODPOOL); + fi.guts(&actor->s, JIBS6, 15, g_p); + S_PlayActorSound(squished, actor); + spawn(actor, BLOODPOOL); } } SKIPJIBS: - hittype[g_i].picnum = SHOTSPARK1; - hittype[g_i].extra = 1; + actor->picnum = SHOTSPARK1; + actor->extra = 1; g_sp->zvel = 0; } else if (g_sp->zvel > 2048 && sector[g_sp->sectnum].lotag != 1) @@ -5350,15 +5350,15 @@ void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOT short j = g_sp->sectnum; int x = g_sp->x, y = g_sp->y, z = g_sp->z; pushmove(&x, &y, &z, &j, 128, (4 << 8), (4 << 8), CLIPMASK0); - setspritepos(g_i, x, y, z); // wrap this for safety. The renderer may need processing of the new position. + setspritepos(actor->GetIndex(), x, y, z); // wrap this for safety. The renderer may need processing of the new position. if (j != g_sp->sectnum && j >= 0 && j < MAXSECTORS) - changespritesect(g_i, j); + changespritesect(actor, j); - S_PlayActorSound(thud, g_i); + S_PlayActorSound(thud, actor); } } if (sector[g_sp->sectnum].lotag == 1) - falladjustz(g_sp); + g_sp->z += actorinfo[g_sp->picnum].falladjustz; else g_sp->zvel = 0; } } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 4c98c07b0..b8b1605b0 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -4037,29 +4037,9 @@ void move_d(int g_i, int g_p, int g_x) } } -//--------------------------------------------------------------------------- -// -// -// -//--------------------------------------------------------------------------- - -static void falladjustz(spritetype* g_sp) -{ - switch (g_sp->picnum) - { - case OCTABRAIN: - case COMMANDER: - case DRONE: - break; - default: - g_sp->z += (24 << 8); - break; - } -} - void fall_d(int g_i, int g_p) { - fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, SQUISHED, THUD, nullptr, falladjustz); + fall_common(&hittype[g_i], g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, SQUISHED, THUD, nullptr); } bool spawnweapondebris_d(int picnum, int dnum) diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 58bddd57b..31bb9b8f5 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -4078,36 +4078,36 @@ void fakebubbaspawn(int g_i, int g_p) // //--------------------------------------------------------------------------- -static int fallspecial(int g_i, int g_p) +static int fallspecial(DDukeActor *actor, int g_p) { + auto g_sp = &actor->s; int sphit = 0; - auto g_sp = &sprite[g_i]; if (isRRRA()) { if (sector[g_sp->sectnum].lotag == 801) { if (g_sp->picnum == ROCK) { - fi.spawn(g_i, ROCK2); - fi.spawn(g_i, ROCK2); - addspritetodelete(g_i); + spawn(actor, ROCK2); + spawn(actor, ROCK2); + addspritetodelete(); } return 0; } else if (sector[g_sp->sectnum].lotag == 802) { - if (g_sp->picnum != APLAYER && badguy(g_sp) && g_sp->z == hittype[g_i].floorz - FOURSLEIGHT) + if (g_sp->picnum != APLAYER && badguy(actor) && g_sp->z == actor->floorz - FOURSLEIGHT) { - fi.guts(g_sp, JIBS6, 5, g_p); - S_PlayActorSound(SQUISHED, g_i); - addspritetodelete(g_i); + fi.guts(&actor->s, JIBS6, 5, g_p); + S_PlayActorSound(SQUISHED, actor); + addspritetodelete(); } return 0; } else if (sector[g_sp->sectnum].lotag == 803) { if (g_sp->picnum == ROCK2) - addspritetodelete(g_i); + addspritetodelete(); return 0; } } @@ -4115,25 +4115,25 @@ static int fallspecial(int g_i, int g_p) { if (g_sp->picnum == 40) { - addspritetodelete(g_i); + addspritetodelete(); return 0; } - if (g_sp->picnum != APLAYER && (badguy(g_sp) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && (!isRRRA() || hittype[g_i].spriteextra < 128)) + if (g_sp->picnum != APLAYER && (badguy(actor) || g_sp->picnum == HEN || g_sp->picnum == COW || g_sp->picnum == PIG || g_sp->picnum == DOGRUN || g_sp->picnum == RABBIT) && (!isRRRA() || actor->spriteextra < 128)) { - g_sp->z = hittype[g_i].floorz - FOURSLEIGHT; + g_sp->z = actor->floorz - FOURSLEIGHT; g_sp->zvel = 8000; g_sp->extra = 0; - hittype[g_i].spriteextra++; + actor->spriteextra++; sphit = 1; } else if (g_sp->picnum != APLAYER) { - if (!hittype[g_i].spriteextra) - addspritetodelete(g_i); + if (!actor->spriteextra) + addspritetodelete(); return 0; } - hittype[g_i].picnum = SHOTSPARK1; - hittype[g_i].extra = 1; + actor->picnum = SHOTSPARK1; + actor->extra = 1; } else if (isRRRA() && (sector[g_sp->sectnum].floorpicnum == RRTILE7820 || sector[g_sp->sectnum].floorpicnum == RRTILE7768)) { @@ -4141,8 +4141,8 @@ static int fallspecial(int g_i, int g_p) { if ((krand() & 3) == 1) { - hittype[g_i].picnum = SHOTSPARK1; - hittype[g_i].extra = 5; + actor->picnum = SHOTSPARK1; + actor->extra = 5; } } } @@ -4155,28 +4155,9 @@ static int fallspecial(int g_i, int g_p) // //--------------------------------------------------------------------------- -static void falladjustz(spritetype* g_sp) -{ - if (isRRRA()) switch (g_sp->picnum) - { - case HULKBOAT: - g_sp->z += (12 << 8); - return; - case MINIONBOAT: - g_sp->z += (3 << 8); - return; - case CHEERBOAT: - case EMPTYBOAT: - g_sp->z += (6 << 8); - return; - } - if (g_sp->picnum != DRONE) - g_sp->z += (24 << 8); -} - void fall_r(int g_i, int g_p) { - fall_common(g_i, g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, 69, 158, fallspecial, falladjustz); + fall_common(&hittype[g_i], g_p, JIBS6, DRONE, BLOODPOOL, SHOTSPARK1, 69, 158, fallspecial); } //--------------------------------------------------------------------------- diff --git a/source/games/duke/src/flags_d.cpp b/source/games/duke/src/flags_d.cpp index 4e7e04e74..81656ac3c 100644 --- a/source/games/duke/src/flags_d.cpp +++ b/source/games/duke/src/flags_d.cpp @@ -42,6 +42,12 @@ void initactorflags_d() { actorinfo[COMMANDER].gutsoffset = -(24 << 8); + for (auto &fa : actorinfo) + { + fa.falladjustz = 24 << 8; + } + actorinfo[OCTABRAIN].falladjustz = actorinfo[COMMANDER].falladjustz = actorinfo[DRONE].falladjustz = 0; + setflag(SFLAG_INTERNAL_BADGUY, { SHARK, RECON, diff --git a/source/games/duke/src/flags_r.cpp b/source/games/duke/src/flags_r.cpp index 900dc7ac7..8319b9d06 100644 --- a/source/games/duke/src/flags_r.cpp +++ b/source/games/duke/src/flags_r.cpp @@ -34,6 +34,19 @@ BEGIN_DUKE_NS void initactorflags_r() { + for (auto &fa : actorinfo) + { + fa.falladjustz = 24 << 8; + } + if (isRRRA()) + { + actorinfo[HULKBOAT].falladjustz = 12 << 8; + actorinfo[MINIONBOAT].falladjustz = 3 << 8; + actorinfo[CHEERBOAT].falladjustz = actorinfo[EMPTYBOAT].falladjustz = 6 << 8; + } + actorinfo[DRONE].falladjustz = 0; + + setflag(SFLAG_INTERNAL_BADGUY|SFLAG_KILLCOUNT, { BOULDER, BOULDER1, diff --git a/source/games/duke/src/funct.h b/source/games/duke/src/funct.h index 821cba00d..974dde41c 100644 --- a/source/games/duke/src/funct.h +++ b/source/games/duke/src/funct.h @@ -98,7 +98,7 @@ void respawn_rrra(DDukeActor* oldact, DDukeActor* newact); int dodge(DDukeActor*); void alterang(int ang, DDukeActor* actor, int g_p); -void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*)); +void fall_common(DDukeActor* g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(DDukeActor*, int)); void checkavailweapon(struct player_struct* p); void deletesprite(DDukeActor* num); void addammo(int weapon, struct player_struct* p, int amount); @@ -181,7 +181,7 @@ void spriteglass(int snum, int cnt); void lotsofcolourglass(int snum, int wallNum, int cnt); void lotsofglass(int snum, int wallnum, int cnt); -void addspritetodelete(int spnum); +void addspritetodelete(int spnum=0); void checkavailinven(struct player_struct* p); int initspriteforspawn(int j, int pn, const std::initializer_list &excludes); void spawninitdefault(int j, int i); diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index afaeff7a7..dc909f4bc 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -13,7 +13,7 @@ BEGIN_DUKE_NS struct STATUSBARTYPE { short frag[MAXPLAYERS], got_access, last_extra, shield_amount, curr_weapon; - short ammo_amount[MAX_WEAPONS], holoduke_on; + short ammo_amount[MAX_WEAPONS]; unsigned char inven_icon, jetpack_on, heat_on; short firstaid_amount, steroids_amount, holoduke_amount, jetpack_amount; short heat_amount, scuba_amount, boot_amount; @@ -104,6 +104,7 @@ struct ActorInfo uint32_t scriptaddress; uint32_t flags; int aimoffset; + int falladjustz; int gutsoffset; };