From c2d9f86832618b6c0c39923e1fee8b6badecddcd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 May 2020 23:44:53 +0200 Subject: [PATCH] - safety commit. --- source/games/duke/src/dispatch.cpp | 4 + source/games/duke/src/game.h | 2 + source/games/duke/src/gameexec.cpp | 2 +- source/games/duke/src/global.h | 7 +- source/games/duke/src/macros.h | 29 + source/games/duke/src/player.cpp | 427 ++++++++++++ source/games/duke/src/player.h | 14 +- source/games/duke/src/player_d.cpp | 375 +++++++++++ source/games/duke/src/player_r.cpp | 962 ++++++++++++++++++++++++++++ source/games/duke/src/zz_game.cpp | 16 +- source/games/duke/src/zz_net.cpp | 40 +- source/games/duke/src/zz_player.cpp | 242 +++---- source/games/duke/src/zz_premap.cpp | 14 +- 13 files changed, 1973 insertions(+), 161 deletions(-) diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 078cc7520..b45d3cf7e 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -101,6 +101,8 @@ void selectweapon_d(int snum, int j); void selectweapon_r(int snum, int j); int doincrements_d(struct player_struct* p); int doincrements_r(struct player_struct* p); +void checkweapons_d(struct player_struct* p); +void checkweapons_r(struct player_struct* p); @@ -148,6 +150,7 @@ void SetDispatcher() shoot_d, selectweapon_d, doincrements_d, + checkweapons_d, }; } else @@ -190,6 +193,7 @@ void SetDispatcher() shoot_r, selectweapon_r, doincrements_r, + checkweapons_r, }; } } diff --git a/source/games/duke/src/game.h b/source/games/duke/src/game.h index 27e14b23d..6f9773204 100644 --- a/source/games/duke/src/game.h +++ b/source/games/duke/src/game.h @@ -530,6 +530,8 @@ struct Dispatcher void (*shoot)(int, int); void (*selectweapon)(int snum, int j); int (*doincrements)(struct player_struct* p); + void (*checkweapons)(struct player_struct* p); + diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 8e3eea414..70fad42ed 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -417,7 +417,7 @@ int parse(void) break; case concmd_tossweapon: insptr++; - checkweapons(&ps[g_sp->yvel]); + fi.checkweapons(&ps[g_sp->yvel]); break; case concmd_nullop: insptr++; diff --git a/source/games/duke/src/global.h b/source/games/duke/src/global.h index 4912a9c4f..83994c6de 100644 --- a/source/games/duke/src/global.h +++ b/source/games/duke/src/global.h @@ -93,7 +93,7 @@ G_EXTERN fix16_t myhoriz, omyhoriz, myhorizoff, omyhorizoff, myang, omyang; G_EXTERN int16_t mycursectnum, myjumpingcounter; G_EXTERN uint8_t myjumpingtoggle, myonground, myhardlanding, myreturntocenter; G_EXTERN int16_t my_MotoSpeed; -G_EXTERN uint8_t my_not_on_water, my_moto_on_ground; +G_EXTERN uint8_t my_NotOnWater, my_MotoOnGround; G_EXTERN uint8_t my_moto_do_bump, my_moto_bump_fast, my_moto_on_oil, my_moto_on_mud; G_EXTERN int16_t my_moto_bump, my_moto_bump_target, my_moto_turb; G_EXTERN int32_t my_stairs; @@ -388,6 +388,11 @@ inline void PlayerSetInput(int pl, int bit) g_player[pl].input->bits |= (1 << bit); } +inline void PlayerClearInput(int pl, int bit) +{ + g_player[pl].input->bits &= ~(1 << bit); +} + inline int PlayerInputBits(int pl, int bits) { return (g_player[pl].input->bits & bits); diff --git a/source/games/duke/src/macros.h b/source/games/duke/src/macros.h index 7f3593883..bd4e116c7 100644 --- a/source/games/duke/src/macros.h +++ b/source/games/duke/src/macros.h @@ -109,6 +109,35 @@ enum SK_INVENTORY = 30, SK_ESCAPE = 31, + SKB_JUMP = 1 << 0, + SKB_CROUCH = 1 << 1, + SKB_FIRE = 1 << 2, + SKB_AIM_UP = 1 << 3, + SKB_AIM_DOWN = 1 << 4, + SKB_RUN = 1 << 5, + SKB_LOOK_LEFT = 1 << 6, + SKB_LOOK_RIGHT = 1 << 7, + SKB_STEROIDS = 1 << 12, + SKB_LOOK_UP = 1 << 13, + SKB_LOOK_DOWN = 1 << 14, + SKB_NIGHTVISION = 1 << 15, + SKB_MEDKIT = 1 << 16, + SKB_MULTIFLAG = 1 << 17, + SKB_CENTER_VIEW = 1 << 18, + SKB_HOLSTER = 1 << 19, + SKB_INV_LEFT = 1 << 20, + SKB_PAUSE = 1 << 21, + SKB_QUICK_KICK = 1 << 22, + SKB_AIMMODE = 1 << 23, + SKB_HOLODUKE = 1 << 24, + SKB_JETPACK = 1 << 25, + SKB_GAMEQUIT = 1 << 26, + SKB_INV_RIGHT = 1 << 27, + SKB_TURNAROUND = 1 << 28, + SKB_OPEN = 1 << 29, + SKB_INVENTORY = 1 << 30, + SKB_ESCAPE = 1 << 31, + SK_WEAPONMASK_BITS = (15u << SK_WEAPON_BITS), SK_INTERFACE_BITS = (SK_WEAPONMASK_BITS | BIT(SK_STEROIDS) | BIT(SK_NIGHTVISION) | BIT(SK_MEDKIT) | BIT(SK_QUICK_KICK) | \ BIT(SK_HOLSTER) | BIT(SK_INV_LEFT) | BIT(SK_PAUSE) | BIT(SK_HOLODUKE) | BIT(SK_JETPACK) | BIT(SK_INV_RIGHT) | \ diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 15faa77d9..78161ea0b 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -287,6 +287,433 @@ int aim(spritetype* s, int aang) return j; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void dokneeattack(int snum, int pi, const std::initializer_list & respawnlist) +{ + auto p = &ps[snum]; + + if (p->knee_incs > 0) + { + p->knee_incs++; + p->addhoriz(-48); + p->return_to_center = 9; + if (p->knee_incs > 15) + { + p->knee_incs = 0; + p->holster_weapon = 0; + if (p->weapon_pos < 0) + p->weapon_pos = -p->weapon_pos; + if (p->actorsqu >= 0 && dist(&sprite[pi], &sprite[p->actorsqu]) < 1400) + { + fi.guts(&sprite[p->actorsqu], TILE_JIBS6, 7, myconnectindex); + fi.spawn(p->actorsqu, TILE_BLOODPOOL); + spritesound(SQUISHED, p->actorsqu); + if (isIn(sprite[p->actorsqu].picnum, respawnlist)) + { + if (sprite[p->actorsqu].yvel) + fi.operaterespawns(sprite[p->actorsqu].yvel); + } + + if (sprite[p->actorsqu].picnum == TILE_APLAYER) + { + quickkill(&ps[sprite[p->actorsqu].yvel]); + ps[sprite[p->actorsqu].yvel].frag_ps = snum; + } + else if (badguy(&sprite[p->actorsqu])) + { + deletesprite(p->actorsqu); + p->actors_killed++; + } + else deletesprite(p->actorsqu); + } + p->actorsqu = -1; + } + else if (p->actorsqu >= 0) + p->addang(getincangle(p->getang(), getangle(sprite[p->actorsqu].x - p->posx, sprite[p->actorsqu].y - p->posy)) >> 2); + } + +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int makepainsounds(int snum, int type) +{ + auto p = &ps[snum]; + auto pi = p->i; + auto s = &sprite[pi]; + int k = 0; + + switch (type) + { + case 0: + if (rnd(32)) + { + if (p->boot_amount > 0) + k = 1; + else + { + if (!A_CheckSoundPlaying(pi, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN, pi); + SetPlayerPal(p, PalEntry(32, 64, 64, 64)); + s->extra -= 1 + (krand() & 3); + if (!A_CheckSoundPlaying(pi, SHORT_CIRCUIT)) + spritesound(SHORT_CIRCUIT, pi); + } + } + break; + case 1: + if (rnd(16)) + { + if (p->boot_amount > 0) + k = 1; + else + { + if (!A_CheckSoundPlaying(pi, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN, pi); + SetPlayerPal(p, PalEntry(32, 0, 8, 0)); + s->extra -= 1 + (krand() & 3); + } + } + break; + case 2: + if (rnd(32)) + { + if (p->boot_amount > 0) + k = 1; + else + { + if (!A_CheckSoundPlaying(pi, DUKE_LONGTERM_PAIN)) + spritesound(DUKE_LONGTERM_PAIN, pi); + SetPlayerPal(p, PalEntry(32, 8, 0, 0)); + s->extra -= 1 + (krand() & 3); + } + } + break; + case 3: + if ((krand() & 3) == 1) + if (p->on_ground) + { + if (p->OnMotorcycle) + s->extra -= 2; + else + s->extra -= 4; + spritesound(DUKE_LONGTERM_PAIN, pi); + } + break; + } + return k; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void footprints(int snum) +{ + auto p = &ps[snum]; + auto pi = p->i; + auto s = &sprite[pi]; + auto psect = s->sectnum; + + if (p->footprintcount > 0 && p->on_ground) + if ((sector[p->cursectnum].floorstat & 2) != 2) + { + int j; + for (j = headspritesect[psect]; j >= 0; j = nextspritesect[j]) + if (sprite[j].picnum == TILE_FOOTPRINTS || sprite[j].picnum == TILE_FOOTPRINTS2 || sprite[j].picnum == TILE_FOOTPRINTS3 || sprite[j].picnum == TILE_FOOTPRINTS4) + if (abs(sprite[j].x - p->posx) < 384) + if (abs(sprite[j].y - p->posy) < 384) + break; + if (j < 0) + { + p->footprintcount--; + if (sector[p->cursectnum].lotag == 0 && sector[p->cursectnum].hitag == 0) + { + switch (krand() & 3) + { + case 0: j = fi.spawn(pi, TILE_FOOTPRINTS); break; + case 1: j = fi.spawn(pi, TILE_FOOTPRINTS2); break; + case 2: j = fi.spawn(pi, TILE_FOOTPRINTS3); break; + default: j = fi.spawn(pi, TILE_FOOTPRINTS4); break; + } + sprite[j].pal = p->footprintpal; + sprite[j].shade = p->footprintshade; + } + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void playerisdead(int snum, int psectlotag, int fz, int cz) +{ + auto p = &ps[snum]; + auto pi = p->i; + auto s = &sprite[pi]; + + if (p->dead_flag == 0) + { + if (s->pal != 1) + { + SetPlayerPal(p, PalEntry(63, 63, 0, 0)); + p->posz -= (16 << 8); + s->z -= (16 << 8); + } +#if 0 + if (ud.recstat == 1 && ud.multimode < 2) + closedemowrite(); +#endif + + if (s->pal != 1) + p->dead_flag = (512 - ((krand() & 1) << 10) + (krand() & 255) - 512) & 2047; + + p->jetpack_on = 0; + p->holoduke_on = -1; + + if (!isRR())S_StopEnvSound(DUKE_JETPACK_IDLE, pi); + S_StopEnvSound(-1, pi, CHAN_VOICE); + if (s->pal != 1 && (s->cstat & 32768) == 0) s->cstat = 0; + + if (ud.multimode > 1 && (s->pal != 1 || (s->cstat & 32768))) + { + if (p->frag_ps != snum) + { + ps[p->frag_ps].frag++; + //frags[p->frag_ps][snum]++; + g_player[p->frag_ps].frags[snum]++; // TRANSITIONAL + g_player[snum].frags[snum]++; // deaths + + auto pname = &g_player[p->frag_ps].user_name[0]; // TRANSITIONAL + //&ud.user_name[p->frag_ps][0]); + if (snum == screenpeek) + { + quoteMgr.InitializeQuote(QUOTE_RESERVED, "Killed by %s", pname); + FTA(QUOTE_RESERVED, p); + } + else + { + quoteMgr.InitializeQuote(QUOTE_RESERVED2, "Killed %s", pname); + FTA(QUOTE_RESERVED2, p); + } + + } + else p->fraggedself++; + +#if 0 + if (myconnectindex == connecthead) + { + sprintf(tempbuf, "frag %d killed %d\n", p->frag_ps + 1, snum + 1); + sendscore(tempbuf); + // printf(tempbuf); + } +#endif + + p->frag_ps = snum; + pus = NUMPAGES; + } + } + + if (psectlotag == ST_2_UNDERWATER) + { + if (p->on_warping_sector == 0) + { + if (abs(p->posz - fz) > (PHEIGHT >> 1)) + p->posz += 348; + } + else + { + s->z -= 512; + s->zvel = -348; + } + + clipmove(&p->posx, &p->posy, + &p->posz, &p->cursectnum, + 0, 0, 164L, (4L << 8), (4L << 8), CLIPMASK0); + // p->bobcounter += 32; + } + + p->oposx = p->posx; + p->oposy = p->posy; + p->oposz = p->posz; + p->oq16ang = p->q16ang; + p->opyoff = p->pyoff; + + p->q16horiz = 100 << FRACBITS; + p->q16horizoff = 0; + + updatesector(p->posx, p->posy, &p->cursectnum); + + pushmove(&p->posx, &p->posy, &p->posz, &p->cursectnum, 128L, (4L << 8), (20L << 8), CLIPMASK0); + + if (fz > cz + (16 << 8) && s->pal != 1) + p->rotscrnang = (p->dead_flag + ((fz + p->posz) >> 7)) & 2047; + + p->on_warping_sector = 0; + +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int endoflevel(int snum) +{ + auto p = &ps[snum]; + + // the fist puching the end-of-level thing... + p->fist_incs++; + if (p->fist_incs == 28) + { +#if 0 + if (ud.recstat == 1) closedemowrite(); +#endif + sound(PIPEBOMB_EXPLODE); + SetPlayerPal(p, PalEntry(48, 64, 64, 64)); + } + if (p->fist_incs > 42) + { + // Fixme: Take level orogression logic out of here. + if (p->buttonpalette && ud.from_bonus == 0) + { + ud.from_bonus = ud.level_number + 1; + if (ud.secretlevel > 0 && ud.secretlevel < (isRR() ? 9 : 12)) ud.level_number = ud.secretlevel - 1; + ud.m_level_number = ud.level_number; + } + else + { + if (ud.from_bonus) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + if (ud.level_number == ud.secretlevel && ud.from_bonus > 0) + ud.level_number = ud.from_bonus; + else ud.level_number++; + + if (ud.level_number > (isRR() ? 6 : 10)) ud.level_number = 0; + ud.m_level_number = ud.level_number; + + } + } + for (int i = connecthead; i >= 0; i = connectpoint2[i]) + ps[i].gm = MODE_EOL; + p->fist_incs = 0; + return 1; + } + return 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void timedexit(int snum) +{ + auto p = &ps[snum]; + p->timebeforeexit--; + if (p->timebeforeexit == 26 * 5) + { + FX_StopAllSounds(); + if (p->customexitsound >= 0) + { + sound(p->customexitsound); + FTA(102, p); + } + } + else if (p->timebeforeexit == 1) + { + for (int i = connecthead; i >= 0; i = connectpoint2[i]) + ps[i].gm = MODE_EOL; + if (ud.from_bonus && !isRR()) + { + ud.level_number = ud.from_bonus; + ud.m_level_number = ud.level_number; + ud.from_bonus = 0; + } + else + { + ud.level_number++; + ud.m_level_number = ud.level_number; + } + return; + } +} + +void playerCrouch(int snum) +{ + auto p = &ps[snum]; + // crouching + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_CROUCH, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->posz += (2048 + 768); + p->crack_time = 777; + } +} + +void playerJump(int snum, int fz, int cz) +{ + auto p = &ps[snum]; + if (p->jumping_toggle == 0 && p->jumping_counter == 0) + { + if ((fz - cz) > (56 << 8)) + { + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_JUMP, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->jumping_counter = 1; + p->jumping_toggle = 1; + } + } + } +} + +void playerLookLeft(int snum) +{ + auto p = &ps[snum]; + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_LOOKLEFT, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->look_ang -= 152; + p->rotscrnang += 24; + } +} + +void playerLookRight(int snum) +{ + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->look_ang += 152; + p->rotscrnang -= 24; + } +} END_DUKE_NS diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 6298d5673..50bcc158b 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -252,10 +252,10 @@ typedef struct player_struct { int16_t drink_amt, eat, drunkang, eatang; int32_t drink_timer, eat_timer; int16_t MamaEnd; - int16_t MotoSpeed, tilt_status, moto_drink; - uint8_t OnMotorcycle, OnBoat, moto_underwater, not_on_water, moto_on_ground; + int16_t MotoSpeed, TiltStatus, moto_drink; + uint8_t OnMotorcycle, OnBoat, moto_underwater, NotOnWater, MotoOnGround; uint8_t moto_do_bump, moto_bump_fast, moto_on_oil, moto_on_mud; - int16_t moto_bump, moto_bump_target, moto_turb; + int16_t VBumpNow, VBumpTarget, TurbCount; int16_t drug_stat[3]; int32_t drug_aspect; uint8_t DrugMode, lotag800kill, sea_sick_stat; @@ -453,6 +453,14 @@ int hits(int i); int hitasprite(int i, short* hitsp); int aim(spritetype* s, int aang); +void timedexit(int snum); +int endoflevel(int snum); +void playerisdead(int snum, int psectlotag, int fz, int cz); +void footprints(int snum); +int makepainsounds(int snum, int type); +void playerCrouch(int snum); +void playerJump(int snum, int fz, int cz); + END_DUKE_NS #endif diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index a0d0f2c9b..dcab1f30e 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1501,4 +1501,379 @@ int doincrements_d(struct player_struct* p) } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void checkweapons_d(struct player_struct* p) +{ + static const short weapon_sprites[MAX_WEAPONS] = { KNEE, FIRSTGUNSPRITE, SHOTGUNSPRITE, + CHAINGUNSPRITE, RPGSPRITE, HEAVYHBOMB, SHRINKERSPRITE, DEVISTATORSPRITE, + TRIPBOMBSPRITE, FREEZESPRITE, HEAVYHBOMB, SHRINKERSPRITE }; + + int cw; + + if (isWW2GI()) + { + int snum = sprite[p->i].yvel; + cw = aplWeaponWorksLike[p->curr_weapon][snum]; + } + else + cw = p->curr_weapon; + + + if (cw < 1 || cw >= MAX_WEAPONS) return; + + if (cw) + { + if (krand() & 1) + fi.spawn(p->i, weapon_sprites[cw]); + else switch (cw) + { + case RPG_WEAPON: + case HANDBOMB_WEAPON: + fi.spawn(p->i, EXPLOSION2); + break; + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void operateJetpack(int snum, int sb_snum, int psectlotag, int fz, int cz, int shrunk) +{ + int j; + auto p = &ps[snum]; + int pi = p->i; + p->on_ground = 0; + p->jumping_counter = 0; + p->hard_landing = 0; + p->falling_counter = 0; + + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount] >> 7; + + if (p->jetpack_on < 11) + { + p->jetpack_on++; + p->posz -= (p->jetpack_on << 7); //Goin up + } + else if (p->jetpack_on == 11 && !A_CheckSoundPlaying(pi, DUKE_JETPACK_IDLE)) + spritesound(DUKE_JETPACK_IDLE, pi); + + if (shrunk) j = 512; + else j = 2048; + + if (sb_snum & SKB_JUMP) //A (soar high) + { + // jump + SetGameVarID(g_iReturnVarID, 0, pi, snum); + OnEvent(EVENT_SOARUP, pi, snum, -1); + if (GetGameVarID(g_iReturnVarID, pi, snum) == 0) + { + p->posz -= j; + p->crack_time = 777; + } + } + + if (sb_snum & SKB_CROUCH) //Z (soar low) + { + // crouch + SetGameVarID(g_iReturnVarID, 0, pi, snum); + OnEvent(EVENT_SOARDOWN, pi, snum, -1); + if (GetGameVarID(g_iReturnVarID, pi, snum) == 0) + { + p->posz += j; + p->crack_time = 777; + } + p->posz += j; + p->crack_time = 777; + } + + int k; + if (shrunk == 0 && (psectlotag == 0 || psectlotag == 2)) k = 32; + else k = 16; + + if (psectlotag != 2 && p->scuba_on == 1) + p->scuba_on = 0; + + if (p->posz > (fz - (k << 8))) + p->posz += ((fz - (k << 8)) - p->posz) >> 1; + if (p->posz < (hittype[pi].ceilingz + (18 << 8))) + p->posz = hittype[pi].ceilingz + (18 << 8); + +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void movement(int snum, int sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) +{ + int j; + auto p = &ps[snum]; + int pi = p->i; + int psectlotag = sector[psect].lotag; + + if (p->airleft != 15 * 26) + p->airleft = 15 * 26; //Aprox twenty seconds. + + if (p->scuba_on == 1) + p->scuba_on = 0; + + int i = 40; + if (psectlotag == 1 && p->spritebridge == 0) + { + if (shrunk == 0) + { + i = 34; + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount] >> 6; + } + else i = 12; + + if (shrunk == 0 && truefdist <= PHEIGHT) + { + if (p->on_ground == 1) + { + if (p->dummyplayersprite == -1) + p->dummyplayersprite = + fi.spawn(pi, PLAYERONWATER); + + p->footprintcount = 6; + if (sector[p->cursectnum].floorpicnum == FLOORSLIME) + p->footprintpal = 8; + else p->footprintpal = 0; + p->footprintshade = 0; + } + } + } + else + { + footprints(snum); + } + + if (p->posz < (fz - (i << 8))) //falling + { + + // not jumping or crouching + if ((sb_snum & 3) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) + p->posz = fz - (i << 8); + else + { + p->on_ground = 0; + p->poszv += (gc + 80); // (TICSPERFRAME<<6); + if (p->poszv >= (4096 + 2048)) p->poszv = (4096 + 2048); + if (p->poszv > 2400 && p->falling_counter < 255) + { + p->falling_counter++; + if (p->falling_counter == 38) + p->scream_voice = spritesound(DUKE_SCREAM, pi); + } + + if ((p->posz + p->poszv) >= (fz - (i << 8))) // hit the ground + if (sector[p->cursectnum].lotag != 1) + { + if (p->falling_counter > 62) quickkill(p); + + else if (p->falling_counter > 9) + { + j = p->falling_counter; + sprite[pi].extra -= j - (krand() & 3); + if (sprite[pi].extra <= 0) + { + spritesound(SQUISHED, pi); + SetPlayerPal(p, PalEntry(63, 63, 0, 0)); + } + else + { + spritesound(DUKE_LAND, pi); + spritesound(DUKE_LAND_HURT, pi); + } + + SetPlayerPal(p, PalEntry(32, 16, 0, 0)); + } + else if (p->poszv > 2048) spritesound(DUKE_LAND, pi); + } + } + } + + else + { + p->falling_counter = 0; + S_StopEnvSound(-1, pi, CHAN_VOICE); + + if (psectlotag != 1 && psectlotag != 2 && p->on_ground == 0 && p->poszv > (6144 >> 1)) + p->hard_landing = p->poszv >> 10; + + p->on_ground = 1; + + if (i == 40) + { + //Smooth on the ground + + int k = ((fz - (i << 8)) - p->posz) >> 1; + if (abs(k) < 256) k = 0; + p->posz += k; + p->poszv -= 768; + if (p->poszv < 0) p->poszv = 0; + } + else if (p->jumping_counter == 0) + { + p->posz += ((fz - (i << 7)) - p->posz) >> 1; //Smooth on the water + if (p->on_warping_sector == 0 && p->posz > fz - (16 << 8)) + { + p->posz = fz - (16 << 8); + p->poszv >>= 1; + } + } + + p->on_warping_sector = 0; + + if (sb_snum & SKB_CROUCH) + { + playerCrouch(snum); + } + + // jumping + if ((sb_snum & SKB_JUMP) == 0 && p->jumping_toggle == 1) + p->jumping_toggle = 0; + + else if ((sb_snum & SKB_JUMP)) + { + playerJump(snum, fz, cz); + } + + if (p->jumping_counter && (sb_snum & SKB_JUMP) == 0) + p->jumping_toggle = 0; + } + + if (p->jumping_counter) + { + if ((sb_snum & SKB_JUMP) == 0 && p->jumping_toggle == 1) + p->jumping_toggle = 0; + + if (p->jumping_counter < (1024 + 256)) + { + if (psectlotag == 1 && p->jumping_counter > 768) + { + p->jumping_counter = 0; + p->poszv = -512; + } + else + { + p->poszv -= (sintable[(2048 - 128 + p->jumping_counter) & 2047]) / 12; + p->jumping_counter += 180; + p->on_ground = 0; + } + } + else + { + p->jumping_counter = 0; + p->poszv = 0; + } + } + + p->posz += p->poszv; + + if (p->posz < (cz + (4 << 8))) + { + p->jumping_counter = 0; + if (p->poszv < 0) + p->posxv = p->posyv = 0; + p->poszv = 128; + p->posz = cz + (4 << 8); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void underwater(int snum, int sb_snum, int psect, int fz, int cz) +{ + int j; + auto p = &ps[snum]; + int pi = p->i; + int psectlotag = sector[psect].lotag; + + // under water + p->jumping_counter = 0; + + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount] >> 7; + + if (!A_CheckSoundPlaying(pi, DUKE_UNDERWATER)) + A_PlaySound(DUKE_UNDERWATER, pi); + + if (sb_snum & 1) + { + // jump + if (p->poszv > 0) p->poszv = 0; + p->poszv -= 348; + if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); + } + else if (sb_snum & (1 << 1)) + { + // crouch + if (p->poszv < 0) p->poszv = 0; + p->poszv += 348; + if (p->poszv > (256 * 6)) p->poszv = (256 * 6); + } + else + { + // normal view + if (p->poszv < 0) + { + p->poszv += 256; + if (p->poszv > 0) + p->poszv = 0; + } + if (p->poszv > 0) + { + p->poszv -= 256; + if (p->poszv < 0) + p->poszv = 0; + } + } + + if (p->poszv > 2048) + p->poszv >>= 1; + + p->posz += p->poszv; + + if (p->posz > (fz - (15 << 8))) + p->posz += ((fz - (15 << 8)) - p->posz) >> 1; + + if (p->posz < (cz + (4 << 8))) + { + p->posz = cz + (4 << 8); + p->poszv = 0; + } + + if (p->scuba_on && (krand() & 255) < 8) + { + j = fi.spawn(pi, WATERBUBBLE); + sprite[j].x += + sintable[(p->getang() + 512 + 64 - (global_random & 128)) & 2047] >> 6; + sprite[j].y += + sintable[(p->getang() + 64 - (global_random & 128)) & 2047] >> 6; + sprite[j].xrepeat = 3; + sprite[j].yrepeat = 2; + sprite[j].z = p->posz + (8 << 8); + } +} END_DUKE_NS diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 1d2ef59c3..41e95f8f4 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1463,5 +1463,967 @@ int doincrements_r(struct player_struct* p) return 0; } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- +void checkweapons_r(struct player_struct* p) +{ + static const short weapon_sprites[MAX_WEAPONS] = { KNEE, FIRSTGUNSPRITE, SHOTGUNSPRITE, + CHAINGUNSPRITE, RPGSPRITE, HEAVYHBOMB, SHRINKERSPRITE, DEVISTATORSPRITE, + TRIPBOMBSPRITE, BOWLINGBALLSPRITE, FREEZEBLAST, HEAVYHBOMB }; + short i, j; + + if (isRRRA()) + { + if (p->OnMotorcycle && numplayers > 1) + { + j = fi.spawn(p->i, 7220); + sprite[j].ang = p->getang(); + sprite[j].owner = p->ammo_amount[MOTORCYCLE_WEAPON]; + p->OnMotorcycle = 0; + p->gotweapon.Clear(MOTORCYCLE_WEAPON); + p->q16horiz = 100 << FRACBITS; + p->moto_do_bump = 0; + p->MotoSpeed = 0; + p->TiltStatus = 0; + p->moto_drink = 0; + p->VBumpTarget = 0; + p->VBumpNow = 0; + p->TurbCount = 0; + } + else if (p->OnBoat && numplayers > 1) + { + j = fi.spawn(p->i, 7233); + sprite[j].ang = p->getang(); + sprite[j].owner = p->ammo_amount[BOAT_WEAPON]; + p->OnBoat = 0; + p->gotweapon.Clear(BOAT_WEAPON); + p->q16horiz = 100 << FRACBITS; + p->moto_do_bump = 0; + p->MotoSpeed = 0; + p->TiltStatus = 0; + p->moto_drink = 0; + p->VBumpTarget = 0; + p->VBumpNow = 0; + p->TurbCount = 0; + } + } + + if (p->curr_weapon > 0) + { + if (krand() & 1) + fi.spawn(p->i, weapon_sprites[p->curr_weapon]); + else switch (p->curr_weapon) + { + case CHICKEN_WEAPON: + if (!isRRRA()) break; + case DYNAMITE_WEAPON: + case CROSSBOW_WEAPON: + fi.spawn(p->i, EXPLOSION2); + break; + } + } + + for (i = 0; i < 5; i++) + { + if (p->keys[i] == 1) + { + j = fi.spawn(p->i, ACCESSCARD); + switch (i) + { + case 1: + sprite[j].lotag = 100; + break; + case 2: + sprite[j].lotag = 101; + break; + case 3: + sprite[j].lotag = 102; + break; + case 4: + sprite[j].lotag = 103; + break; + } + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void onMotorcycle(int snum, int &sb_snum) +{ + auto p = &ps[snum]; + auto pi = p->i; + auto s = &sprite[pi]; + + int var64, var68, var6c, var70, var74, var78, var7c, var80; + short var84; + if (p->MotoSpeed < 0) + p->MotoSpeed = 0; + if (sb_snum & SKB_CROUCH) + { + var64 = 1; + sb_snum &= ~SKB_CROUCH; + } + else + var64 = 0; + + if (sb_snum & SKB_JUMP) + { + var68 = 1; + sb_snum &= ~SKB_JUMP; + if (p->on_ground) + { + if (p->MotoSpeed == 0 && var64) + { + if (!A_CheckSoundPlaying(pi, 187)) + spritesound(187, pi); + } + else if (p->MotoSpeed == 0 && !A_CheckSoundPlaying(pi, 214)) + { + if (A_CheckSoundPlaying(pi, 187)) + S_StopEnvSound(187, pi); + spritesound(214, pi); + } + else if (p->MotoSpeed >= 50 && !A_CheckSoundPlaying(pi, 188)) + { + A_PlaySound(188, pi); + } + else if (!A_CheckSoundPlaying(pi, 188) && !A_CheckSoundPlaying(pi, 214)) + { + A_PlaySound(188, pi); + } + } + } + else + { + var68 = 0; + if (A_CheckSoundPlaying(pi, 214)) + { + S_StopEnvSound(214, pi); + if (!A_CheckSoundPlaying(pi, 189)) + A_PlaySound(189, pi); + } + if (A_CheckSoundPlaying(pi, 188)) + { + S_StopEnvSound(188, pi); + if (!A_CheckSoundPlaying(pi, 189)) + A_PlaySound(189, pi); + } + if (!A_CheckSoundPlaying(pi, 189) && !A_CheckSoundPlaying(pi, 187)) + A_PlaySound(187, pi); + } + if (sb_snum & SK_AIM_UP) + { + var6c = 1; + sb_snum &= ~SK_AIM_UP; + } + else + var6c = 0; + if (sb_snum & SK_AIM_DOWN) + { + var70 = 1; + var74 = 1; + sb_snum &= ~SK_AIM_DOWN; + } + else + { + var70 = 0; + var74 = 0; + } + if (sb_snum & SK_LOOK_LEFT) + { + var78 = 1; + var7c = 1; + sb_snum &= ~SK_LOOK_LEFT; + } + else + { + var78 = 0; + var7c = 0; + } + var80 = 0; + if (p->drink_amt > 88 && p->moto_drink == 0) + { + var84 = krand() & 63; + if (var84 == 1) + p->moto_drink = -10; + else if (var84 == 2) + p->moto_drink = 10; + } + else if (p->drink_amt > 99 && p->moto_drink == 0) + { + var84 = krand() & 31; + if (var84 == 1) + p->moto_drink = -20; + else if (var84 == 2) + p->moto_drink = 20; + } + if (p->on_ground == 1) + { + if (var64 && p->MotoSpeed > 0) + { + if (p->moto_on_oil) + p->MotoSpeed -= 2; + else + p->MotoSpeed -= 4; + if (p->MotoSpeed < 0) + p->MotoSpeed = 0; + p->VBumpTarget = -30; + p->moto_do_bump = 1; + } + else if (var68 && !var64) + { + if (p->MotoSpeed < 40) + { + p->VBumpTarget = 70; + p->moto_bump_fast = 1; + } + p->MotoSpeed += 2; + if (p->MotoSpeed > 120) + p->MotoSpeed = 120; + if (!p->NotOnWater) + if (p->MotoSpeed > 80) + p->MotoSpeed = 80; + } + else if (p->MotoSpeed > 0) + p->MotoSpeed--; + if (p->moto_do_bump && (!var64 || p->MotoSpeed == 0)) + { + p->VBumpTarget = 0; + p->moto_do_bump = 0; + } + if (var6c && p->MotoSpeed <= 0 && !var64) + { + int var88; + p->MotoSpeed = -15; + var88 = var7c; + var7c = var74; + var74 = var88; + var80 = 1; + } + } + if (p->MotoSpeed != 0 && p->on_ground == 1) + { + if (!p->VBumpNow) + if ((krand() & 3) == 2) + p->VBumpTarget = (p->MotoSpeed >> 4) * ((krand() & 7) - 4); + if (var74 || p->moto_drink < 0) + { + if (p->moto_drink < 0) + p->moto_drink++; + } + else if (var7c || p->moto_drink > 0) + { + if (p->moto_drink > 0) + p->moto_drink--; + } + } + if (p->TurbCount) + { + if (p->TurbCount <= 1) + { + p->q16horiz = 100 << FRACBITS; + p->TurbCount = 0; + p->VBumpTarget = 0; + p->VBumpNow = 0; + } + else + { + p->q16horiz = (100 + ((krand2() & 15) - 7)) << FRACBITS; + p->TurbCount--; + p->moto_drink = (krand() & 3) - 2; + } + } + else if (p->VBumpTarget > p->VBumpNow) + { + if (p->moto_bump_fast) + p->VBumpNow += 6; + else + p->VBumpNow++; + if (p->VBumpTarget < p->VBumpNow) + p->VBumpNow = p->VBumpTarget; + p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS; + } + else if (p->VBumpTarget < p->VBumpNow) + { + if (p->moto_bump_fast) + p->VBumpNow -= 6; + else + p->VBumpNow--; + if (p->VBumpTarget > p->VBumpNow) + p->VBumpNow = p->VBumpTarget; + p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS; + } + else + { + p->VBumpTarget = 0; + p->moto_bump_fast = 0; + } + if (p->MotoSpeed >= 20 && p->on_ground == 1 && (var74 || var7c)) + { + short var8c, var90, var94, var98; + var8c = p->MotoSpeed; + var90 = p->getang(); + if (var74) + var94 = -10; + else + var94 = 10; + if (var94 < 0) + var98 = 350; + else + var98 = -350; + if (p->moto_on_mud || p->moto_on_oil || !p->NotOnWater) + { + if (p->moto_on_oil) + var8c <<= 3; + else + var8c <<= 2; + if (p->moto_do_bump) + { + p->posxv += (var8c >> 5) * (sintable[(var94 * -51 + var90 + 512) & 2047] << 4); + p->posyv += (var8c >> 5) * (sintable[(var94 * -51 + var90) & 2047] << 4); + p->setang((var90 - (var98 >> 2)) & 2047); + } + else + { + p->posxv += (var8c >> 7) * (sintable[(var94 * -51 + var90 + 512) & 2047] << 4); + p->posyv += (var8c >> 7) * (sintable[(var94 * -51 + var90) & 2047] << 4); + p->setang((var90 - (var98 >> 6)) & 2047); + } + p->moto_on_mud = 0; + p->moto_on_oil = 0; + } + else + { + if (p->moto_do_bump) + { + p->posxv += (var8c >> 5) * (sintable[(var94 * -51 + var90 + 512) & 2047] << 4); + p->posyv += (var8c >> 5) * (sintable[(var94 * -51 + var90) & 2047] << 4); + p->setang((var90 - (var98 >> 4)) & 2047); + if (!A_CheckSoundPlaying(pi, 220)) + A_PlaySound(220, pi); + } + else + { + p->posxv += (var8c >> 7) * (sintable[(var94 * -51 + var90 + 512) & 2047] << 4); + p->posyv += (var8c >> 7) * (sintable[(var94 * -51 + var90) & 2047] << 4); + p->setang((var90 - (var98 >> 7)) & 2047); + } + } + } + else if (p->MotoSpeed >= 20 && p->on_ground == 1 && (p->moto_on_mud || p->moto_on_oil)) + { + short var9c, vara0, vara4; + var9c = p->MotoSpeed; + vara0 = p->getang(); + var84 = krand() & 1; + if (var84 == 0) + vara4 = -10; + else if (var84 == 1) + vara4 = 10; + if (p->moto_on_oil) + var9c *= 10; + else + var9c *= 5; + p->posxv += (var9c >> 7) * (sintable[(vara4 * -51 + vara0 + 512) & 2047] << 4); + p->posyv += (var9c >> 7) * (sintable[(vara4 * -51 + vara0) & 2047] << 4); + } + p->moto_on_mud = 0; + p->moto_on_oil = 0; +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void onBoat(int snum, int sb_snum) +{ + auto p = &ps[snum]; + auto pi = p->i; + auto s = &sprite[pi]; + + int vara8, varac, varb0, varb4, varb8, varbc, varc0, varc4, varc8; + short varcc; + if (p->NotOnWater) + { + if (p->MotoSpeed > 0) + { + if (!A_CheckSoundPlaying(pi, 88)) + A_PlaySound(88, pi); + } + else + { + if (!A_CheckSoundPlaying(pi, 87)) + A_PlaySound(87, pi); + } + } + if (p->MotoSpeed < 0) + p->MotoSpeed = 0; + if ((sb_snum & SKB_CROUCH) && (sb_snum & SKB_JUMP)) + { + vara8 = 1; + varac = 0; + varb0 = 0; + sb_snum &= ~(SKB_JUMP|SKB_CROUCH); + } + else + vara8 = 0; + if (sb_snum & SKB_JUMP) + { + varac = 1; + sb_snum &= ~SKB_JUMP; + if (p->MotoSpeed == 0 && !A_CheckSoundPlaying(pi, 89)) + { + if (A_CheckSoundPlaying(pi, 87)) + S_StopEnvSound(pi, 87); + A_PlaySound(89, pi); + } + else if (p->MotoSpeed >= 50 && !A_CheckSoundPlaying(pi, 88)) + A_PlaySound(88, pi); + else if (!A_CheckSoundPlaying(pi, 88) && !A_CheckSoundPlaying(pi, 89)) + A_PlaySound(88, pi); + } + else + { + varac = 0; + if (A_CheckSoundPlaying(pi, 89)) + { + S_StopEnvSound(pi, 89); + if (!A_CheckSoundPlaying(pi, 90)) + A_PlaySound(90, pi); + } + if (A_CheckSoundPlaying(pi, 88)) + { + S_StopEnvSound(pi, 88); + if (!A_CheckSoundPlaying(pi, 90)) + A_PlaySound(90, pi); + } + if (!A_CheckSoundPlaying(pi, 90) && !A_CheckSoundPlaying(pi, 87)) + A_PlaySound(87, pi); + } + + if (sb_snum & SKB_CROUCH) + { + varb0 = 1; + sb_snum &= ~SKB_CROUCH; + } + else + varb0 = 0; + if (sb_snum & SKB_AIM_UP) + { + varb4 = 1; + sb_snum &= ~SKB_AIM_UP; + } + else varb4 = 0; + if (sb_snum & SKB_AIM_DOWN) + { + varb8 = 1; + varbc = 1; + sb_snum &= ~SKB_AIM_DOWN; + if (!A_CheckSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater) + A_PlaySound(91, pi); + } + else + { + varb8 = 0; + varbc = 0; + } + if (sb_snum & SKB_LOOK_LEFT) + { + varc0 = 1; + varc4 = 1; + sb_snum &= ~SKB_LOOK_LEFT; + if (!A_CheckSoundPlaying(pi, 91) && p->MotoSpeed > 30 && !p->NotOnWater) + A_PlaySound(91, pi); + } + else + { + varc0 = 0; + varc4 = 0; + } + varc8 = 0; + if (!p->NotOnWater) + { + if (p->drink_amt > 88 && p->moto_drink == 0) + { + varcc = krand() & 63; + if (varcc == 1) + p->moto_drink = -10; + else if (varcc == 2) + p->moto_drink = 10; + } + else if (p->drink_amt > 99 && p->moto_drink == 0) + { + varcc = krand() & 31; + if (varcc == 1) + p->moto_drink = -20; + else if (varcc == 2) + p->moto_drink = 20; + } + } + if (p->on_ground == 1) + { + if (vara8) + { + if (p->MotoSpeed <= 25) + { + p->MotoSpeed++; + if (!A_CheckSoundPlaying(pi, 182)) + A_PlaySound(182, pi); + } + else + { + p->MotoSpeed -= 2; + if (p->MotoSpeed < 0) + p->MotoSpeed = 0; + p->VBumpTarget = 30; + p->moto_do_bump = 1; + } + } + else if (varb0 && p->MotoSpeed > 0) + { + p->MotoSpeed -= 2; + if (p->MotoSpeed < 0) + p->MotoSpeed = 0; + p->VBumpTarget = 30; + p->moto_do_bump = 1; + } + else if (varac) + { + if (p->MotoSpeed < 40) + if (!p->NotOnWater) + { + p->VBumpTarget = -30; + p->moto_bump_fast = 1; + } + p->MotoSpeed++; + if (p->MotoSpeed > 120) + p->MotoSpeed = 120; + } + else if (p->MotoSpeed > 0) + p->MotoSpeed--; + if (p->moto_do_bump && (!varb0 || p->MotoSpeed == 0)) + { + p->VBumpTarget = 0; + p->moto_do_bump = 0; + } + if (varb4 && p->MotoSpeed == 0 && !varb0) + { + int vard0; + if (!p->NotOnWater) + p->MotoSpeed = -25; + else + p->MotoSpeed = -20; + vard0 = varc4; + varc4 = varbc; + varbc = vard0; + varc8 = 1; + } + } + if (p->MotoSpeed != 0 && p->on_ground == 1) + { + if (!p->VBumpNow) + if ((krand() & 15) == 14) + p->VBumpTarget = (p->MotoSpeed >> 4) * ((krand() & 3) - 2); + if (varbc || p->moto_drink < 0) + { + if (p->moto_drink < 0) + p->moto_drink++; + } + else if (varc4 || p->moto_drink > 0) + { + if (p->moto_drink > 0) + p->moto_drink--; + } + } + if (p->TurbCount) + { + if (p->TurbCount <= 1) + { + p->q16horiz = 100 << FRACBITS; + p->TurbCount = 0; + p->VBumpTarget = 0; + p->VBumpNow = 0; + } + else + { + p->q16horiz = (100 + ((krand() & 15) - 7)) << FRACBITS; + p->TurbCount--; + p->moto_drink = (krand() & 3) - 2; + } + } + else if (p->VBumpTarget > p->VBumpNow) + { + if (p->moto_bump_fast) + p->VBumpNow += 6; + else + p->VBumpNow++; + if (p->VBumpTarget < p->VBumpNow) + p->VBumpNow = p->VBumpTarget; + p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS; + } + else if (p->VBumpTarget < p->VBumpNow) + { + if (p->moto_bump_fast) + p->VBumpNow -= 6; + else + p->VBumpNow--; + if (p->VBumpTarget > p->VBumpNow) + p->VBumpNow = p->VBumpTarget; + p->q16horiz = (100 + p->VBumpNow / 3) << FRACBITS; + } + else + { + p->VBumpTarget = 0; + p->moto_bump_fast = 0; + } + if (p->MotoSpeed > 0 && p->on_ground == 1 && (varbc || varc4)) + { + short vard4, vard8, vardc, vare0; + vard4 = p->MotoSpeed; + vard8 = p->getang(); + if (varbc) + vardc = -10; + else + vardc = 10; + if (vardc < 0) + vare0 = 350; + else + vare0 = -350; + vard4 <<= 2; + if (p->moto_do_bump) + { + p->posxv += (vard4 >> 6) * (sintable[(vardc * -51 + vard8 + 512) & 2047] << 4); + p->posyv += (vard4 >> 6) * (sintable[(vardc * -51 + vard8) & 2047] << 4); + p->setang((vard8 - (vare0 >> 5)) & 2047); + } + else + { + p->posxv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8 + 512) & 2047] << 4); + p->posyv += (vard4 >> 7) * (sintable[(vardc * -51 + vard8) & 2047] << 4); + p->setang((vard8 - (vare0 >> 6)) & 2047); + } + } + if (p->NotOnWater) + if (p->MotoSpeed > 50) + p->MotoSpeed -= (p->MotoSpeed >> 1); + +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void movement(int snum, int sb_snum, int psect, int fz, int cz, int shrunk, int truefdist) +{ + auto p = &ps[snum]; + auto pi = p->i; + auto s = &sprite[pi]; + int psectlotag = sector[psect].lotag; + + if (p->airleft != 15 * 26) + p->airleft = 15 * 26; //Aprox twenty seconds. + + if (p->scuba_on == 1) + p->scuba_on = 0; + + int i = 40; + if (psectlotag == 1 && p->spritebridge == 0) + { + if (shrunk == 0) + { + i = 34; + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount] >> 6; + } + else i = 12; + + if (shrunk == 0 && truefdist <= PHEIGHT) + { + if (p->on_ground == 1) + { + if (p->dummyplayersprite == -1) + p->dummyplayersprite = + fi.spawn(pi, PLAYERONWATER); + + p->footprintcount = 6; + if (sector[p->cursectnum].floorpicnum == FLOORSLIME) + { + p->footprintpal = 8; + p->footprintshade = 0; + } + else if (isRRRA() && (sector[p->cursectnum].floorpicnum == RRTILE7756 || sector[p->cursectnum].floorpicnum == RRTILE7888)) + { + p->footprintpal = 0; + p->footprintshade = 40; + } + else + { + p->footprintpal = 0; + p->footprintshade = 0; + } + } + } + } + else if (!p->OnMotorcycle) + { + footprints(snum); + } + + if (p->posz < (fz - (i << 8))) //falling + { + if ((sb_snum & 3) == 0 && p->on_ground && (sector[psect].floorstat & 2) && p->posz >= (fz - (i << 8) - (16 << 8))) + p->posz = fz - (i << 8); + else + { + p->on_ground = 0; + + if ((p->OnMotorcycle || p->OnBoat) && fz - (i << 8) * 2 > p->posz) + { + if (p->MotoOnGround) + { + p->VBumpTarget = 80; + p->moto_bump_fast = 1; + p->poszv -= gc * (p->MotoSpeed >> 4); + p->MotoOnGround = 0; + if (A_CheckSoundPlaying(pi, 188)) + S_StopEnvSound(188, pi); + spritesound(189, pi); + } + else + { + p->poszv += gc - 80 + (120 - p->MotoSpeed); + if (!A_CheckSoundPlaying(pi, 189) && !A_CheckSoundPlaying(pi, 190)) + A_PlaySound(190, pi); + } + } + else + p->poszv += (gc + 80); // (TICSPERFRAME<<6); + + if (p->poszv >= (4096 + 2048)) p->poszv = (4096 + 2048); + if (p->poszv > 2400 && p->falling_counter < 255) + { + p->falling_counter++; + if (p->falling_counter == 38) + p->scream_voice = spritesound(DUKE_SCREAM, pi); + } + + if ((p->posz + p->poszv) >= (fz - (i << 8))) // hit the ground + if (sector[p->cursectnum].lotag != 1) + { + if (isRRRA()) p->MotoOnGround = 1; + if (p->falling_counter > 62 || (isRRRA() && p->falling_counter > 2 && sector[p->cursectnum].lotag == 802)) + quickkill(p); + + else if (p->falling_counter > 9) + { + int j = p->falling_counter; + s->extra -= j - (krand() & 3); + if (s->extra <= 0) + { + spritesound(SQUISHED, pi); + } + else + { + spritesound(DUKE_LAND, pi); + spritesound(DUKE_LAND_HURT, pi); + } + + SetPlayerPal(p, PalEntry(32, 16, 0, 0)); + } + else if (p->poszv > 2048) + { + if (p->OnMotorcycle) + { + if (A_CheckSoundPlaying(pi, 190)) + S_StopEnvSound(pi, 190); + spritesound(191, pi); + p->TurbCount = 12; + } + else spritesound(DUKE_LAND, pi); + } + else if (p->poszv > 1024 && p->OnMotorcycle) + { + spritesound(DUKE_LAND, pi); + p->TurbCount = 12; + } + } + } + } + + else + { + p->falling_counter = 0; + S_StopEnvSound(-1, pi, CHAN_VOICE); + + if (psectlotag != ST_1_ABOVE_WATER && psectlotag != ST_2_UNDERWATER && p->on_ground == 0 && p->poszv > (6144 >> 1)) + p->hard_landing = p->poszv >> 10; + + p->on_ground = 1; + + if (i == 40) + { + //Smooth on the ground + + int k = ((fz - (i << 8)) - p->posz) >> 1; + if (abs(k) < 256) k = 0; + p->posz += k; + p->poszv -= 768; + if (p->poszv < 0) p->poszv = 0; + } + else if (p->jumping_counter == 0) + { + p->posz += ((fz - (i << 7)) - p->posz) >> 1; //Smooth on the water + if (p->on_warping_sector == 0 && p->posz > fz - (16 << 8)) + { + p->posz = fz - (16 << 8); + p->poszv >>= 1; + } + } + + p->on_warping_sector = 0; + + if ((sb_snum & SKB_CROUCH) && !p->OnMotorcycle) + { + playerCrouch(snum); + } + + if ((sb_snum & SKB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1) + p->jumping_toggle = 0; + + else if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle && p->jumping_toggle == 0) + { + playerJump(snum, fz, cz); + } + } + + if (p->jumping_counter) + { + if ((sb_snum & SKB_JUMP) == 0 && !p->OnMotorcycle && p->jumping_toggle == 1) + p->jumping_toggle = 0; + + if (p->jumping_counter < 768) + { + if (psectlotag == 1 && p->jumping_counter > 768) + { + p->jumping_counter = 0; + p->poszv = -512; + } + else + { + p->poszv -= (sintable[(2048 - 128 + p->jumping_counter) & 2047]) / 12; + p->jumping_counter += 180; + p->on_ground = 0; + } + } + else + { + p->jumping_counter = 0; + p->poszv = 0; + } + } + + p->posz += p->poszv; + + if (p->posz < (cz + (4 << 8))) + { + p->jumping_counter = 0; + if (p->poszv < 0) + p->posxv = p->posyv = 0; + p->poszv = 128; + p->posz = cz + (4 << 8); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void underwater(int snum, int sb_snum, int psect, int fz, int cz) +{ + int j; + auto p = &ps[snum]; + int pi = p->i; + int psectlotag = sector[psect].lotag; + + p->jumping_counter = 0; + + p->pycount += 32; + p->pycount &= 2047; + p->pyoff = sintable[p->pycount] >> 7; + + if (!A_CheckSoundPlaying(pi, DUKE_UNDERWATER)) + A_PlaySound(DUKE_UNDERWATER, pi); + + if ((sb_snum & SKB_JUMP) && !p->OnMotorcycle) + { + if (p->poszv > 0) p->poszv = 0; + p->poszv -= 348; + if (p->poszv < -(256 * 6)) p->poszv = -(256 * 6); + } + else if ((sb_snum & SKB_CROUCH) || p->OnMotorcycle) + { + if (p->poszv < 0) p->poszv = 0; + p->poszv += 348; + if (p->poszv > (256 * 6)) p->poszv = (256 * 6); + } + else + { + if (p->poszv < 0) + { + p->poszv += 256; + if (p->poszv > 0) + p->poszv = 0; + } + if (p->poszv > 0) + { + p->poszv -= 256; + if (p->poszv < 0) + p->poszv = 0; + } + } + + if (p->poszv > 2048) + p->poszv >>= 1; + + p->posz += p->poszv; + + if (p->posz > (fz - (15 << 8))) + p->posz += ((fz - (15 << 8)) - p->posz) >> 1; + + if (p->posz < (cz + (4 << 8))) + { + p->posz = cz + (4 << 8); + p->poszv = 0; + } + + if (p->scuba_on && (krand() & 255) < 8) + { + j = fi.spawn(pi, WATERBUBBLE); + sprite[j].x += + sintable[(p->getang() + 512 + 64 - (global_random & 128) + 128) & 2047] >> 6; + sprite[j].y += + sintable[(p->getang() + 64 - (global_random & 128) + 128) & 2047] >> 6; + sprite[j].xrepeat = 3; + sprite[j].yrepeat = 2; + sprite[j].z = p->posz + (8 << 8); + sprite[j].cstat = 514; + } + +} END_DUKE_NS diff --git a/source/games/duke/src/zz_game.cpp b/source/games/duke/src/zz_game.cpp index 173598e26..b4666a70c 100644 --- a/source/games/duke/src/zz_game.cpp +++ b/source/games/duke/src/zz_game.cpp @@ -243,11 +243,11 @@ void OffMotorcycle(DukePlayer_t *pPlayer) pPlayer->q16horiz = F16(100); pPlayer->moto_do_bump = 0; pPlayer->MotoSpeed = 0; - pPlayer->tilt_status = 0; + pPlayer->TiltStatus = 0; pPlayer->moto_drink = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; - pPlayer->moto_turb = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; + pPlayer->TurbCount = 0; pPlayer->vel.x = 0; pPlayer->vel.y = 0; pPlayer->vel.x -= sintable[(fix16_to_int(pPlayer->q16ang)+512)&2047]<<7; @@ -296,11 +296,11 @@ void OffBoat(DukePlayer_t *pPlayer) pPlayer->q16horiz = F16(100); pPlayer->moto_do_bump = 0; pPlayer->MotoSpeed = 0; - pPlayer->tilt_status = 0; + pPlayer->TiltStatus = 0; pPlayer->moto_drink = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; - pPlayer->moto_turb = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; + pPlayer->TurbCount = 0; pPlayer->vel.x = 0; pPlayer->vel.y = 0; pPlayer->vel.x -= sintable[(fix16_to_int(pPlayer->q16ang)+512)&2047]<<7; diff --git a/source/games/duke/src/zz_net.cpp b/source/games/duke/src/zz_net.cpp index 4a2712e0f..f50e0c139 100644 --- a/source/games/duke/src/zz_net.cpp +++ b/source/games/duke/src/zz_net.cpp @@ -220,15 +220,15 @@ void Net_ResetPrediction(void) myhardlanding = g_player[myconnectindex].ps->hard_landing; myreturntocenter = g_player[myconnectindex].ps->return_to_center; my_MotoSpeed = g_player[myconnectindex].ps->MotoSpeed; - my_not_on_water = g_player[myconnectindex].ps->not_on_water; - my_moto_on_ground = g_player[myconnectindex].ps->moto_on_ground; + my_NotOnWater = g_player[myconnectindex].ps->NotOnWater; + my_MotoOnGround = g_player[myconnectindex].ps->MotoOnGround; my_moto_do_bump = g_player[myconnectindex].ps->moto_do_bump; my_moto_bump_fast = g_player[myconnectindex].ps->moto_bump_fast; my_moto_on_oil = g_player[myconnectindex].ps->moto_on_oil; my_moto_on_mud = g_player[myconnectindex].ps->moto_on_mud; my_moto_bump = g_player[myconnectindex].ps->moto_do_bump; - my_moto_bump_target = g_player[myconnectindex].ps->moto_bump_target; - my_moto_turb = g_player[myconnectindex].ps->moto_turb; + my_moto_bump_target = g_player[myconnectindex].ps->VBumpTarget; + my_moto_turb = g_player[myconnectindex].ps->TurbCount; my_stairs = g_player[myconnectindex].ps->stairs; } @@ -316,7 +316,7 @@ void Net_DoPrediction(void) my_MotoSpeed += 2; if (my_MotoSpeed > 120) my_MotoSpeed = 120; - if (!my_not_on_water) + if (!my_NotOnWater) if (my_MotoSpeed > 80) my_MotoSpeed = 80; } @@ -393,7 +393,7 @@ void Net_DoPrediction(void) var98 = 350; else var98 = -350; - if (my_moto_on_mud || my_moto_on_oil || !my_not_on_water) + if (my_moto_on_mud || my_moto_on_oil || !my_NotOnWater) { if (my_moto_on_oil) var8c <<= 3; @@ -528,7 +528,7 @@ void Net_DoPrediction(void) else if (varac) { if (my_MotoSpeed < 40) - if (!my_not_on_water) + if (!my_NotOnWater) { my_moto_bump_target = -30; my_moto_bump_fast = 1; @@ -547,7 +547,7 @@ void Net_DoPrediction(void) if (varb4 && my_MotoSpeed == 0 && !varb0) { int vard0; - if (!my_not_on_water) + if (!my_NotOnWater) my_MotoSpeed = -25; else my_MotoSpeed = -20; @@ -629,7 +629,7 @@ void Net_DoPrediction(void) myang = F16((vard8-(vare0>>6))&2047); } } - if (my_not_on_water) + if (my_NotOnWater) if (my_MotoSpeed > 50) my_MotoSpeed -= (my_MotoSpeed>>1); } @@ -938,12 +938,12 @@ check_enemy_sprite: if (RRRA && (pPlayer->OnMotorcycle || pPlayer->OnBoat) && floorZ - (floorZOffset << 9) > mypos.z) { - if (my_moto_on_ground) + if (my_MotoOnGround) { my_moto_bump_target = 80; my_moto_bump_fast = 1; myvel.z -= g_spriteGravity*(my_MotoSpeed>>4); - my_moto_on_ground = 0; + my_MotoOnGround = 0; } else { @@ -961,7 +961,7 @@ check_enemy_sprite: if (sector[mycursectnum].lotag != ST_1_ABOVE_WATER) { if (RRRA) - my_moto_on_ground = 1; + my_MotoOnGround = 1; } } } @@ -1081,16 +1081,16 @@ check_enemy_sprite: if (spritebridge == 0 && myonground) { if (sectorLotag == ST_1_ABOVE_WATER) - my_not_on_water = 0; + my_NotOnWater = 0; else if (pPlayer->OnBoat) { if (sectorLotag == 1234) - my_not_on_water = 0; + my_NotOnWater = 0; else - my_not_on_water = 1; + my_NotOnWater = 1; } else - my_not_on_water = 1; + my_NotOnWater = 1; } } if (pPlayer->jetpack_on == 0 && pPlayer->inv_amount[GET_STEROIDS] > 0 && pPlayer->inv_amount[GET_STEROIDS] < 400) @@ -1351,15 +1351,15 @@ void Net_CorrectPrediction(void) myhardlanding = p->hard_landing; myreturntocenter = p->return_to_center; my_MotoSpeed = p->MotoSpeed; - my_not_on_water = p->not_on_water; - my_moto_on_ground = p->moto_on_ground; + my_NotOnWater = p->NotOnWater; + my_MotoOnGround = p->MotoOnGround; my_moto_do_bump = p->moto_do_bump; my_moto_bump_fast = p->moto_bump_fast; my_moto_on_oil = p->moto_on_oil; my_moto_on_mud = p->moto_on_mud; my_moto_bump = p->moto_do_bump; - my_moto_bump_target = p->moto_bump_target; - my_moto_turb = p->moto_turb; + my_moto_bump_target = p->VBumpTarget; + my_moto_turb = p->TurbCount; my_stairs = p->stairs; predictfifoplc = movefifoplc; diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 42ae56f60..12176882b 100644 --- a/source/games/duke/src/zz_player.cpp +++ b/source/games/duke/src/zz_player.cpp @@ -701,13 +701,13 @@ void P_DisplayWeapon(void) int const weaponPal = P_GetHudPal(pPlayer); G_DrawTileScaled(160-(pPlayer->look_ang>>1), 174, motoTile, weaponShade, 2 | DRAWEAP_CENTER, - weaponPal, 34816, pPlayer->tilt_status * 5 + (pPlayer->tilt_status < 0 ? 2047 : 0)); + weaponPal, 34816, pPlayer->TiltStatus * 5 + (pPlayer->TiltStatus < 0 ? 2047 : 0)); return; } if (pPlayer->OnBoat) { int boatTile; - if (pPlayer->tilt_status > 0) + if (pPlayer->TiltStatus > 0) { if (*weaponFrame == 0) boatTile = TILE_BOATHIT+1; @@ -724,7 +724,7 @@ void P_DisplayWeapon(void) else boatTile = TILE_BOATHIT+1; } - else if (pPlayer->tilt_status < 0) + else if (pPlayer->TiltStatus < 0) { if (*weaponFrame == 0) boatTile = TILE_BOATHIT+2; @@ -762,13 +762,13 @@ void P_DisplayWeapon(void) int const weaponPal = P_GetHudPal(pPlayer); int weaponY; - if (pPlayer->not_on_water) + if (pPlayer->NotOnWater) weaponY = 170; else weaponY = 170 + (*weaponFrame>>2); G_DrawTileScaled(160-(pPlayer->look_ang>>1), weaponY, boatTile, weaponShade, 2 | DRAWEAP_CENTER, - weaponPal, 66048, pPlayer->tilt_status + (pPlayer->tilt_status < 0 ? 2047 : 0)); + weaponPal, 66048, pPlayer->TiltStatus + (pPlayer->TiltStatus < 0 ? 2047 : 0)); return; } } @@ -2399,15 +2399,15 @@ void P_GetInputMotorcycle(int playerNum) { if (turnLeft) { - pPlayer->tilt_status--; - if (pPlayer->tilt_status < -10) - pPlayer->tilt_status = -10; + pPlayer->TiltStatus--; + if (pPlayer->TiltStatus < -10) + pPlayer->TiltStatus = -10; } else if (turnRight) { - pPlayer->tilt_status++; - if (pPlayer->tilt_status > 10) - pPlayer->tilt_status = 10; + pPlayer->TiltStatus++; + if (pPlayer->TiltStatus > 10) + pPlayer->TiltStatus = 10; } } else @@ -2415,9 +2415,9 @@ void P_GetInputMotorcycle(int playerNum) if (turnLeft || pPlayer->moto_drink < 0) { turnHeldTime += elapsedTics; - pPlayer->tilt_status--; - if (pPlayer->tilt_status < -10) - pPlayer->tilt_status = -10; + pPlayer->TiltStatus--; + if (pPlayer->TiltStatus < -10) + pPlayer->TiltStatus = -10; if (turnHeldTime >= TURBOTURNTIME && pPlayer->MotoSpeed > 0) { if (moveBack) @@ -2436,9 +2436,9 @@ void P_GetInputMotorcycle(int playerNum) else if (turnRight || pPlayer->moto_drink > 0) { turnHeldTime += elapsedTics; - pPlayer->tilt_status++; - if (pPlayer->tilt_status > 10) - pPlayer->tilt_status = 10; + pPlayer->TiltStatus++; + if (pPlayer->TiltStatus > 10) + pPlayer->TiltStatus = 10; if (turnHeldTime >= TURBOTURNTIME && pPlayer->MotoSpeed > 0) { if (moveBack) @@ -2458,10 +2458,10 @@ void P_GetInputMotorcycle(int playerNum) { turnHeldTime = 0; - if (pPlayer->tilt_status > 0) - pPlayer->tilt_status--; - else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status++; + if (pPlayer->TiltStatus > 0) + pPlayer->TiltStatus--; + else if (pPlayer->TiltStatus < 0) + pPlayer->TiltStatus++; } } @@ -2608,11 +2608,11 @@ void P_GetInputBoat(int playerNum) if (turnLeft || pPlayer->moto_drink < 0) { turnHeldTime += elapsedTics; - if (!pPlayer->not_on_water) + if (!pPlayer->NotOnWater) { - pPlayer->tilt_status--; - if (pPlayer->tilt_status < -10) - pPlayer->tilt_status = -10; + pPlayer->TiltStatus--; + if (pPlayer->TiltStatus < -10) + pPlayer->TiltStatus = -10; if (turnHeldTime >= TURBOTURNTIME) input.q16avel = fix16_ssub(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); else @@ -2627,11 +2627,11 @@ void P_GetInputBoat(int playerNum) else if (turnRight || pPlayer->moto_drink > 0) { turnHeldTime += elapsedTics; - if (!pPlayer->not_on_water) + if (!pPlayer->NotOnWater) { - pPlayer->tilt_status++; - if (pPlayer->tilt_status > 10) - pPlayer->tilt_status = 10; + pPlayer->TiltStatus++; + if (pPlayer->TiltStatus > 10) + pPlayer->TiltStatus = 10; if (turnHeldTime >= TURBOTURNTIME) input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval(turnAmount))); else @@ -2643,24 +2643,24 @@ void P_GetInputBoat(int playerNum) else input.q16avel = fix16_sadd(input.q16avel, fix16_from_dbl(scaleAdjustmentToInterval((turnAmount / (10 / 3)) / 3))); } - else if (!pPlayer->not_on_water) + else if (!pPlayer->NotOnWater) { turnHeldTime = 0; - if (pPlayer->tilt_status > 0) - pPlayer->tilt_status--; - else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status++; + if (pPlayer->TiltStatus > 0) + pPlayer->TiltStatus--; + else if (pPlayer->TiltStatus < 0) + pPlayer->TiltStatus++; } } - else if (!pPlayer->not_on_water) + else if (!pPlayer->NotOnWater) { turnHeldTime = 0; - if (pPlayer->tilt_status > 0) - pPlayer->tilt_status--; - else if (pPlayer->tilt_status < 0) - pPlayer->tilt_status++; + if (pPlayer->TiltStatus > 0) + pPlayer->TiltStatus--; + else if (pPlayer->TiltStatus < 0) + pPlayer->TiltStatus++; } input.q16avel = fix16_mul(input.q16avel, avelScale); @@ -2724,11 +2724,11 @@ void checkweapons(DukePlayer_t* const pPlayer) pPlayer->q16horiz = F16(100); pPlayer->moto_do_bump = 0; pPlayer->MotoSpeed = 0; - pPlayer->tilt_status = 0; + pPlayer->TiltStatus = 0; pPlayer->moto_drink = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; - pPlayer->moto_turb = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; + pPlayer->TurbCount = 0; } else if (pPlayer->OnBoat) { @@ -2740,11 +2740,11 @@ void checkweapons(DukePlayer_t* const pPlayer) pPlayer->q16horiz = F16(100); pPlayer->moto_do_bump = 0; pPlayer->MotoSpeed = 0; - pPlayer->tilt_status = 0; + pPlayer->TiltStatus = 0; pPlayer->moto_drink = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; - pPlayer->moto_turb = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; + pPlayer->TurbCount = 0; } } @@ -4988,20 +4988,20 @@ void P_ProcessInput(int playerNum) pPlayer->MotoSpeed -= 4; if (pPlayer->MotoSpeed < 0) pPlayer->MotoSpeed = 0; - pPlayer->moto_bump_target = -30; + pPlayer->VBumpTarget = -30; pPlayer->moto_do_bump = 1; } else if (var68 && !var64) { if (pPlayer->MotoSpeed < 40) { - pPlayer->moto_bump_target = 70; + pPlayer->VBumpTarget = 70; pPlayer->moto_bump_fast = 1; } pPlayer->MotoSpeed += 2; if (pPlayer->MotoSpeed > 120) pPlayer->MotoSpeed = 120; - if (!pPlayer->not_on_water) + if (!pPlayer->NotOnWater) if (pPlayer->MotoSpeed > 80) pPlayer->MotoSpeed = 80; } @@ -5009,7 +5009,7 @@ void P_ProcessInput(int playerNum) pPlayer->MotoSpeed--; if (pPlayer->moto_do_bump && (!var64 || pPlayer->MotoSpeed == 0)) { - pPlayer->moto_bump_target = 0; + pPlayer->VBumpTarget = 0; pPlayer->moto_do_bump = 0; } if (var6c && pPlayer->MotoSpeed <= 0 && !var64) @@ -5023,9 +5023,9 @@ void P_ProcessInput(int playerNum) } if (pPlayer->MotoSpeed != 0 && pPlayer->on_ground == 1) { - if (!pPlayer->moto_bump) + if (!pPlayer->VBumpNow) if ((krand2() & 3) == 2) - pPlayer->moto_bump_target = (pPlayer->MotoSpeed>>4)*((krand2()&7)-4); + pPlayer->VBumpTarget = (pPlayer->MotoSpeed >> 4) * ((krand2() & 7) - 4); if (var74 || pPlayer->moto_drink < 0) { if (pPlayer->moto_drink < 0) @@ -5037,45 +5037,45 @@ void P_ProcessInput(int playerNum) pPlayer->moto_drink--; } } - if (pPlayer->moto_turb) + if (pPlayer->TurbCount) { - if (pPlayer->moto_turb <= 1) + if (pPlayer->TurbCount <= 1) { pPlayer->q16horiz = F16(100); - pPlayer->moto_turb = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; + pPlayer->TurbCount = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; } else { pPlayer->q16horiz = F16(100+((krand2()&15)-7)); - pPlayer->moto_turb--; + pPlayer->TurbCount--; pPlayer->moto_drink = (krand2()&3)-2; } } - else if (pPlayer->moto_bump_target > pPlayer->moto_bump) + else if (pPlayer->VBumpTarget > pPlayer->VBumpNow) { if (pPlayer->moto_bump_fast) - pPlayer->moto_bump += 6; + pPlayer->VBumpNow += 6; else - pPlayer->moto_bump++; - if (pPlayer->moto_bump_target < pPlayer->moto_bump) - pPlayer->moto_bump = pPlayer->moto_bump_target; - pPlayer->q16horiz = F16(100+pPlayer->moto_bump/3); + pPlayer->VBumpNow++; + if (pPlayer->VBumpTarget < pPlayer->VBumpNow) + pPlayer->VBumpNow = pPlayer->VBumpTarget; + pPlayer->q16horiz = F16(100+pPlayer->VBumpNow/3); } - else if (pPlayer->moto_bump_target < pPlayer->moto_bump) + else if (pPlayer->VBumpTarget < pPlayer->VBumpNow) { if (pPlayer->moto_bump_fast) - pPlayer->moto_bump -= 6; + pPlayer->VBumpNow -= 6; else - pPlayer->moto_bump--; - if (pPlayer->moto_bump_target > pPlayer->moto_bump) - pPlayer->moto_bump = pPlayer->moto_bump_target; - pPlayer->q16horiz = F16(100+pPlayer->moto_bump/3); + pPlayer->VBumpNow--; + if (pPlayer->VBumpTarget > pPlayer->VBumpNow) + pPlayer->VBumpNow = pPlayer->VBumpTarget; + pPlayer->q16horiz = F16(100+pPlayer->VBumpNow/3); } else { - pPlayer->moto_bump_target = 0; + pPlayer->VBumpTarget = 0; pPlayer->moto_bump_fast = 0; } if (pPlayer->MotoSpeed >= 20 && pPlayer->on_ground == 1 && (var74 || var7c)) @@ -5091,7 +5091,7 @@ void P_ProcessInput(int playerNum) var98 = 350; else var98 = -350; - if (pPlayer->moto_on_mud || pPlayer->moto_on_oil || !pPlayer->not_on_water) + if (pPlayer->moto_on_mud || pPlayer->moto_on_oil || !pPlayer->NotOnWater) { if (pPlayer->moto_on_oil) var8c <<= 3; @@ -5154,7 +5154,7 @@ void P_ProcessInput(int playerNum) { int vara8, varac, varb0, varb4, varbc, varc4; int16_t varcc; - if (pPlayer->not_on_water) + if (pPlayer->NotOnWater) { if (pPlayer->MotoSpeed > 0) { @@ -5229,7 +5229,7 @@ void P_ProcessInput(int playerNum) { varbc = 1; playerBits &= ~(1<i, 91) && pPlayer->MotoSpeed > 30 && !pPlayer->not_on_water) + if (!A_CheckSoundPlaying(pPlayer->i, 91) && pPlayer->MotoSpeed > 30 && !pPlayer->NotOnWater) A_PlaySound(91,pPlayer->i); } else @@ -5240,14 +5240,14 @@ void P_ProcessInput(int playerNum) { varc4 = 1; playerBits &= ~(1<< SK_LOOK_LEFT); - if (!A_CheckSoundPlaying(pPlayer->i, 91) && pPlayer->MotoSpeed > 30 && !pPlayer->not_on_water) + if (!A_CheckSoundPlaying(pPlayer->i, 91) && pPlayer->MotoSpeed > 30 && !pPlayer->NotOnWater) A_PlaySound(91,pPlayer->i); } else { varc4 = 0; } - if (!pPlayer->not_on_water) + if (!pPlayer->NotOnWater) { if (pPlayer->drink_amt > 88 && pPlayer->moto_drink == 0) { @@ -5281,7 +5281,7 @@ void P_ProcessInput(int playerNum) pPlayer->MotoSpeed -= 2; if (pPlayer->MotoSpeed < 0) pPlayer->MotoSpeed = 0; - pPlayer->moto_bump_target = 30; + pPlayer->VBumpTarget = 30; pPlayer->moto_do_bump = 1; } } @@ -5290,15 +5290,15 @@ void P_ProcessInput(int playerNum) pPlayer->MotoSpeed -= 2; if (pPlayer->MotoSpeed < 0) pPlayer->MotoSpeed = 0; - pPlayer->moto_bump_target = 30; + pPlayer->VBumpTarget = 30; pPlayer->moto_do_bump = 1; } else if (varac) { if (pPlayer->MotoSpeed < 40) - if (!pPlayer->not_on_water) + if (!pPlayer->NotOnWater) { - pPlayer->moto_bump_target = -30; + pPlayer->VBumpTarget = -30; pPlayer->moto_bump_fast = 1; } pPlayer->MotoSpeed++; @@ -5309,13 +5309,13 @@ void P_ProcessInput(int playerNum) pPlayer->MotoSpeed--; if (pPlayer->moto_do_bump && (!varb0 || pPlayer->MotoSpeed == 0)) { - pPlayer->moto_bump_target = 0; + pPlayer->VBumpTarget = 0; pPlayer->moto_do_bump = 0; } if (varb4 && pPlayer->MotoSpeed == 0 && !varb0) { int vard0; - if (!pPlayer->not_on_water) + if (!pPlayer->NotOnWater) pPlayer->MotoSpeed = -25; else pPlayer->MotoSpeed = -20; @@ -5326,9 +5326,9 @@ void P_ProcessInput(int playerNum) } if (pPlayer->MotoSpeed != 0 && pPlayer->on_ground == 1) { - if (!pPlayer->moto_bump) + if (!pPlayer->VBumpNow) if ((krand2() & 15) == 14) - pPlayer->moto_bump_target = (pPlayer->MotoSpeed>>4)*((krand2()&3)-2); + pPlayer->VBumpTarget = (pPlayer->MotoSpeed>>4)*((krand2()&3)-2); if (varbc || pPlayer->moto_drink < 0) { if (pPlayer->moto_drink < 0) @@ -5340,45 +5340,45 @@ void P_ProcessInput(int playerNum) pPlayer->moto_drink--; } } - if (pPlayer->moto_turb) + if (pPlayer->TurbCount) { - if (pPlayer->moto_turb <= 1) + if (pPlayer->TurbCount <= 1) { pPlayer->q16horiz = F16(100); - pPlayer->moto_turb = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; + pPlayer->TurbCount = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; } else { pPlayer->q16horiz = F16(100+((krand2()&15)-7)); - pPlayer->moto_turb--; + pPlayer->TurbCount--; pPlayer->moto_drink = (krand2()&3)-2; } } - else if (pPlayer->moto_bump_target > pPlayer->moto_bump) + else if (pPlayer->VBumpTarget > pPlayer->VBumpNow) { if (pPlayer->moto_bump_fast) - pPlayer->moto_bump += 6; + pPlayer->VBumpNow += 6; else - pPlayer->moto_bump++; - if (pPlayer->moto_bump_target < pPlayer->moto_bump) - pPlayer->moto_bump = pPlayer->moto_bump_target; - pPlayer->q16horiz = F16(100+pPlayer->moto_bump/3); + pPlayer->VBumpNow++; + if (pPlayer->VBumpTarget < pPlayer->VBumpNow) + pPlayer->VBumpNow = pPlayer->VBumpTarget; + pPlayer->q16horiz = F16(100+pPlayer->VBumpNow/3); } - else if (pPlayer->moto_bump_target < pPlayer->moto_bump) + else if (pPlayer->VBumpTarget < pPlayer->VBumpNow) { if (pPlayer->moto_bump_fast) - pPlayer->moto_bump -= 6; + pPlayer->VBumpNow -= 6; else - pPlayer->moto_bump--; - if (pPlayer->moto_bump_target > pPlayer->moto_bump) - pPlayer->moto_bump = pPlayer->moto_bump_target; - pPlayer->q16horiz = F16(100+pPlayer->moto_bump/3); + pPlayer->VBumpNow--; + if (pPlayer->VBumpTarget > pPlayer->VBumpNow) + pPlayer->VBumpNow = pPlayer->VBumpTarget; + pPlayer->q16horiz = F16(100+pPlayer->VBumpNow/3); } else { - pPlayer->moto_bump_target = 0; + pPlayer->VBumpTarget = 0; pPlayer->moto_bump_fast = 0; } if (pPlayer->MotoSpeed > 0 && pPlayer->on_ground == 1 && (varbc || varc4)) @@ -5408,7 +5408,7 @@ void P_ProcessInput(int playerNum) pPlayer->q16ang = F16((vard8-(vare0>>6))&2047); } } - if (pPlayer->not_on_water) + if (pPlayer->NotOnWater) if (pPlayer->MotoSpeed > 50) pPlayer->MotoSpeed -= (pPlayer->MotoSpeed>>1); } @@ -5884,12 +5884,12 @@ check_enemy_sprite: { if (RRRA && (pPlayer->OnMotorcycle || pPlayer->OnBoat) && floorZ - (floorZOffset << 9) > pPlayer->pos.z) { - if (pPlayer->moto_on_ground) + if (pPlayer->MotoOnGround) { - pPlayer->moto_bump_target = 80; + pPlayer->VBumpTarget = 80; pPlayer->moto_bump_fast = 1; pPlayer->vel.z -= g_spriteGravity*(pPlayer->MotoSpeed>>4); - pPlayer->moto_on_ground = 0; + pPlayer->MotoOnGround = 0; if (A_CheckSoundPlaying(pPlayer->i, 188)) S_StopEnvSound(188, pPlayer->i); A_PlaySound(189, pPlayer->i); @@ -5921,7 +5921,7 @@ check_enemy_sprite: if (sector[pPlayer->cursectnum].lotag != ST_1_ABOVE_WATER) { if (RRRA) - pPlayer->moto_on_ground = 1; + pPlayer->MotoOnGround = 1; if (pPlayer->falling_counter > 62 || (RRRA && pPlayer->falling_counter > 2 && sector[pPlayer->cursectnum].lotag == 802)) quickkill(pPlayer); else if (pPlayer->falling_counter > 9) @@ -5946,7 +5946,7 @@ check_enemy_sprite: if (A_CheckSoundPlaying(pPlayer->i, 190)) S_StopEnvSound(pPlayer->i, 190); A_PlaySound(191, pPlayer->i); - pPlayer->moto_turb = 12; + pPlayer->TurbCount = 12; } else A_PlaySound(DUKE_LAND, pPlayer->i); @@ -5954,7 +5954,7 @@ check_enemy_sprite: else if (RRRA && pPlayer->vel.z > 1024 && pPlayer->OnMotorcycle) { A_PlaySound(DUKE_LAND, pPlayer->i); - pPlayer->moto_turb = 12; + pPlayer->TurbCount = 12; } } pPlayer->on_ground = 1; @@ -6135,16 +6135,16 @@ check_enemy_sprite: if (pPlayer->spritebridge == 0 && pPlayer->on_ground) { if (sectorLotag == ST_1_ABOVE_WATER) - pPlayer->not_on_water = 0; + pPlayer->NotOnWater = 0; else if (pPlayer->OnBoat) { if (sectorLotag == 1234) - pPlayer->not_on_water = 0; + pPlayer->NotOnWater = 0; else - pPlayer->not_on_water = 1; + pPlayer->NotOnWater = 1; } else - pPlayer->not_on_water = 1; + pPlayer->NotOnWater = 1; } } @@ -6436,8 +6436,8 @@ HORIZONLY:; if (numplayers == 1) { vec3_t const vect = { - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>8, - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>8,sprite[spriteNum].zvel + sintable[(pPlayer->TiltStatus*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>8, + sintable[(pPlayer->TiltStatus*20+fix16_to_int(pPlayer->q16ang))&2047]>>8,sprite[spriteNum].zvel }; A_MoveSprite(spriteNum,&vect,CLIPMASK0); @@ -6448,7 +6448,7 @@ HORIZONLY:; actor[spriteNum].picnum = TILE_MOTOHIT; actor[spriteNum].extra = pPlayer->MotoSpeed>>1; pPlayer->MotoSpeed -= pPlayer->MotoSpeed>>2; - pPlayer->moto_turb = 6; + pPlayer->TurbCount = 6; } else if ((sprite[spriteNum].picnum == TILE_RRTILE2431 || sprite[spriteNum].picnum == TILE_RRTILE2443 || sprite[spriteNum].picnum == TILE_RRTILE2451 || sprite[spriteNum].picnum == TILE_RRTILE2455) && sprite[spriteNum].picnum != TILE_ACTIVATORLOCKED && pPlayer->MotoSpeed > 45) @@ -6489,8 +6489,8 @@ HORIZONLY:; if (numplayers == 1) { vec3_t const vect = { - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>9, - sintable[(pPlayer->tilt_status*20+fix16_to_int(pPlayer->q16ang))&2047]>>9,sprite[spriteNum].zvel + sintable[(pPlayer->TiltStatus*20+fix16_to_int(pPlayer->q16ang)+512)&2047]>>9, + sintable[(pPlayer->TiltStatus*20+fix16_to_int(pPlayer->q16ang))&2047]>>9,sprite[spriteNum].zvel }; A_MoveSprite(spriteNum,&vect,CLIPMASK0); @@ -6501,7 +6501,7 @@ HORIZONLY:; actor[spriteNum].picnum = TILE_MOTOHIT; actor[spriteNum].extra = pPlayer->MotoSpeed>>2; pPlayer->MotoSpeed -= pPlayer->MotoSpeed>>2; - pPlayer->moto_turb = 6; + pPlayer->TurbCount = 6; } } else if (A_CheckEnemySprite(&sprite[spriteNum])) diff --git a/source/games/duke/src/zz_premap.cpp b/source/games/duke/src/zz_premap.cpp index a84aa2037..a79b86387 100644 --- a/source/games/duke/src/zz_premap.cpp +++ b/source/games/duke/src/zz_premap.cpp @@ -970,15 +970,15 @@ void P_ResetStatus(int playerNum) } pPlayer->lotag800kill = 0; pPlayer->moto_do_bump = 0; - pPlayer->moto_on_ground = 1; + pPlayer->MotoOnGround = 1; pPlayer->moto_underwater = 0; pPlayer->MotoSpeed = 0; - pPlayer->tilt_status = 0; + pPlayer->TiltStatus = 0; pPlayer->moto_drink = 0; - pPlayer->moto_bump_target = 0; - pPlayer->moto_bump = 0; + pPlayer->VBumpTarget = 0; + pPlayer->VBumpNow = 0; pPlayer->moto_bump_fast = 0; - pPlayer->moto_turb = 0; + pPlayer->TurbCount = 0; pPlayer->moto_on_mud = 0; pPlayer->moto_on_oil = 0; if (pPlayer->OnBoat) @@ -987,7 +987,7 @@ void P_ResetStatus(int playerNum) pPlayer->gotweapon.Clear(BOAT_WEAPON); pPlayer->curr_weapon = SLINGBLADE_WEAPON; } - pPlayer->not_on_water = 0; + pPlayer->NotOnWater = 0; pPlayer->sea_sick = 0; pPlayer->nocheat = 0; pPlayer->DrugMode = 0; @@ -1859,7 +1859,7 @@ void G_NewGame(int volumeNum, int levelNum, int skillNum) G_BonusScreenRRRA(1); } - if (RR && !RRRA && g_turdLevel && !g_lastLevel) + if (RR && !RRRA && ud.level_number == 6 && ud.volume_number == 0) G_BonusScreen(0); g_showShareware = GAMETICSPERSEC*34;