From 20851677038628f389feb265c5bd5e0aff622fd4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 May 2020 08:26:09 +0200 Subject: [PATCH] - safety commit, weapon code incompletely ported. --- source/games/duke/src/player.cpp | 69 ++ source/games/duke/src/player_d.cpp | 1768 +++++++++++++++++++++++++++- source/games/duke/src/player_r.cpp | 741 ++++++++++++ 3 files changed, 2575 insertions(+), 3 deletions(-) diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 78161ea0b..697012274 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -663,6 +663,12 @@ void timedexit(int snum) } } +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + void playerCrouch(int snum) { auto p = &ps[snum]; @@ -708,6 +714,7 @@ void playerLookLeft(int snum) void playerLookRight(int snum) { + auto p = &ps[snum]; SetGameVarID(g_iReturnVarID, 0, p->i, snum); OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) @@ -716,4 +723,66 @@ void playerLookRight(int snum) p->rotscrnang -= 24; } } + +void playerCenterView(int snum) +{ + auto p = &ps[snum]; + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_RETURNTOCENTER, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->return_to_center = 9; + } +} + +void playerLookUp(int snum, int sb_snum) +{ + auto p = &ps[snum]; + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_LOOKUP, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->return_to_center = 9; + if (sb_snum & SKB_RUN) p->q16horiz += 12 << FRACBITS; // running + p->q16horiz += 12 << FRACBITS; + } +} + +void playerLookDown(int snum, int sb_snum) +{ + auto p = &ps[snum]; + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_LOOKDOWN, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + p->return_to_center = 9; + if (sb_snum & SKB_RUN) p->q16horiz -= 12 << FRACBITS; // running + p->q16horiz -= 12 << FRACBITS; + } +} + +void playerAimUp(int snum, int sb_snum) +{ + auto p = &ps[snum]; + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_AIMUP, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + if (sb_snum & SKB_RUN) p->q16horiz += 6 << FRACBITS; // running + p->q16horiz += 6 << FRACBITS; + } +} + +void playerAimDown(int snum, int sb_snum) +{ + auto p = &ps[snum]; + SetGameVarID(g_iReturnVarID, 0, p->i, snum); + OnEvent(EVENT_AIMDOWN, p->i, snum, -1); + if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) + { + if (sb_snum & SKB_RUN) p->q16horiz -= 6 << FRACBITS; // running + p->q16horiz -= 6 << FRACBITS; + } +} + END_DUKE_NS diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index dcab1f30e..bdade0e49 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1802,7 +1802,7 @@ static void movement(int snum, int sb_snum, int psect, int fz, int cz, int shrun // //--------------------------------------------------------------------------- -void underwater(int snum, int sb_snum, int psect, int fz, int cz) +static void underwater(int snum, int sb_snum, int psect, int fz, int cz) { int j; auto p = &ps[snum]; @@ -1819,14 +1819,14 @@ void underwater(int snum, int sb_snum, int psect, int fz, int cz) if (!A_CheckSoundPlaying(pi, DUKE_UNDERWATER)) A_PlaySound(DUKE_UNDERWATER, pi); - if (sb_snum & 1) + if (sb_snum & SKB_JUMP) { // 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)) + else if (sb_snum & SKB_CROUCH) { // crouch if (p->poszv < 0) p->poszv = 0; @@ -1876,4 +1876,1766 @@ void underwater(int snum, int sb_snum, int psect, int fz, int cz) sprite[j].z = p->posz + (8 << 8); } } + +static int operateTripbomb(int snum) +{ + auto p = &ps[snum]; + int pi = p->i; + + int sx, sy, sz; + short sect, hw, hitsp; + + hitscan(p->posx, p->posy, p->posz, + p->cursectnum, sintable[(p->getang() + 512) & 2047], + sintable[p->getang() & 2047], (100 - p->gethorizdiff()) * 32, + §, &hw, &hitsp, &sx, &sy, &sz, CLIPMASK1); + + if (sect < 0 || hitsp >= 0) + return 0; + + if (hw >= 0 && sector[sect].lotag > 2) + return 0; + + if (hw >= 0 && wall[hw].overpicnum >= 0) + if (wall[hw].overpicnum == BIGFORCE) + return 0; + + int j = headspritesect[sect]; + while (j >= 0) + { + if (sprite[j].picnum == TRIPBOMB && + klabs(sprite[j].z - sz) < (12 << 8) && ((sprite[j].x - sx) * (sprite[j].x - sx) + (sprite[j].y - sy) * (sprite[j].y - sy)) < (290 * 290)) + return 0; + j = nextspritesect[j]; + } + + if (j == -1 && hw >= 0 && (wall[hw].cstat & 16) == 0) + if ((wall[hw].nextsector >= 0 && sector[wall[hw].nextsector].lotag <= 2) || (wall[hw].nextsector == -1 && sector[sect].lotag <= 2)) + if (((sx - p->posx) * (sx - p->posx) + (sy - p->posy) * (sy - p->posy)) < (290 * 290)) + { + p->posz = p->oposz; + p->poszv = 0; + return 1; + } + + return 0; +} +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void fireweapon_ww(int snum, int* kb) +{ + auto p = &ps[snum]; + int pi = p->i; + + p->crack_time = 777; + + if (p->holster_weapon == 1) + { + if (p->last_pissed_time <= (26 * 218) && p->weapon_pos == -9) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + FTA(74, p); + } + } + else + { + SetGameVarID(g_iReturnVarID, 0, pi, snum); + SetGameVarID(g_iWeaponVarID, p->curr_weapon, pi, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], pi, snum); + OnEvent(EVENT_FIRE, pi, snum, -1); + if (GetGameVarID(g_iReturnVarID, pi, snum) == 0) + { + switch (aplWeaponWorksLike[p->curr_weapon][snum]) + { + case HANDBOMB_WEAPON: + p->hbomb_hold_delay = 0; + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + case HANDREMOTE_WEAPON: + p->hbomb_hold_delay = 0; + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + break; + + case PISTOL_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + // p->ammo_amount[p->curr_weapon]--; + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + + case CHAINGUN_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case SHOTGUN_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0 && p->random_club_frame == 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + case TRIPBOMB_WEAPON: + if (operateTripbomb(snum)) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case SHRINKER_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case GROW_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case FREEZE_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + case DEVISTATOR_WEAPON: + if (p->ammo_amount[p->curr_weapon] > 0) + { + (*kb) = 1; + p->hbomb_hold_delay = !p->hbomb_hold_delay; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case RPG_WEAPON: + if (p->ammo_amount[RPG_WEAPON] > 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + + case KNEE_WEAPON: + if (p->quick_kick == 0) + { + (*kb) = 1; + if (aplWeaponInitialSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponInitialSound[p->curr_weapon][snum], pi); + } + } + break; + } + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void fireweapon(int snum, int* kb) +{ + auto p = &ps[snum]; + int pi = p->i; + + p->crack_time = 777; + + if (p->holster_weapon == 1) + { + if (p->last_pissed_time <= (26 * 218) && p->weapon_pos == -9) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + FTA(74, p); + } + } + else switch (p->curr_weapon) + { + case HANDBOMB_WEAPON: + p->hbomb_hold_delay = 0; + if (p->ammo_amount[HANDBOMB_WEAPON] > 0) + (*kb) = 1; + break; + case HANDREMOTE_WEAPON: + p->hbomb_hold_delay = 0; + (*kb) = 1; + break; + + case PISTOL_WEAPON: + if (p->ammo_amount[PISTOL_WEAPON] > 0) + { + p->ammo_amount[PISTOL_WEAPON]--; + (*kb) = 1; + } + break; + + + case CHAINGUN_WEAPON: + if (p->ammo_amount[CHAINGUN_WEAPON] > 0) // && p->random_club_frame == 0) + (*kb) = 1; + break; + + case SHOTGUN_WEAPON: + if (p->ammo_amount[SHOTGUN_WEAPON] > 0 && p->random_club_frame == 0) + (*kb) = 1; + break; + case TRIPBOMB_WEAPON: + if (p->ammo_amount[TRIPBOMB_WEAPON] > 0) + { + if (operateTripbomb(snum)) + *kb = 1; + } + break; + + case SHRINKER_WEAPON: + case GROW_WEAPON: + if (p->curr_weapon == GROW_WEAPON) + { + if (p->ammo_amount[GROW_WEAPON] > 0) + { + (*kb) = 1; + spritesound(EXPANDERSHOOT, pi); + } + } + else if (p->ammo_amount[SHRINKER_WEAPON] > 0) + { + (*kb) = 1; + spritesound(SHRINKER_FIRE, pi); + } + break; + + case FREEZE_WEAPON: + if (p->ammo_amount[FREEZE_WEAPON] > 0) + { + (*kb) = 1; + spritesound(CAT_FIRE, pi); + } + break; + case DEVISTATOR_WEAPON: + if (p->ammo_amount[DEVISTATOR_WEAPON] > 0) + { + (*kb) = 1; + p->hbomb_hold_delay = !p->hbomb_hold_delay; + spritesound(CAT_FIRE, pi); + } + break; + + case RPG_WEAPON: + if (p->ammo_amount[RPG_WEAPON] > 0) + { + (*kb) = 1; + } + break; + + case KNEE_WEAPON: + if (p->quick_kick == 0) + { + (*kb) = 1; + } + break; + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void operateweapon(int snum) +{ + auto p = &ps[snum]; + int pi = p->i; + + // already firing... +#ifdef WW2WEAPON + if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDBOMB_WEAPON) + { + if (aplWeaponHoldDelay[p->curr_weapon][snum] // there is a hold delay + && ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) // and we are 'at' hold + && (sb_snum & (1 << 2)) // and 'fire' button is still down + ) + // just hold here... + { + p->rapid_fire_hold = 1; + return; + } + (*kb)++; + if ((*kb) == aplWeaponHoldDelay[p->curr_weapon][snum]) + { + p->ammo_amount[p->curr_weapon]--; + + if (p->on_ground && (sb_snum & 2)) + { + k = 15; + i = ((p->horiz + p->horizoff - 100) * 20); + } + else + { + k = 140; + i = -512 - ((p->horiz + p->horizoff - 100) * 20); + } + + j = EGS(p->cursectnum, + p->posx + (sintable[(p->ang + 512) & 2047] >> 6), + p->posy + (sintable[p->ang & 2047] >> 6), + p->posz, HEAVYHBOMB, -16, 9, 9, + p->ang, (k + (p->hbomb_hold_delay << 5)), i, pi, 1); + + { + long lGrenadeLifetime = GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); + long lGrenadeLifetimeVar = GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); + // set timer. blows up when at zero.... + sprite[j].extra = lGrenadeLifetime + + mulscale(krand(), lGrenadeLifetimeVar, 14) + - lGrenadeLifetimeVar; + } + + if (k == 15) + { + sprite[j].yvel = 3; + sprite[j].z += (8 << 8); + } + + k = hits(pi); + if (k < 512) + { + sprite[j].ang += 1024; + sprite[j].zvel /= 3; + sprite[j].xvel /= 3; + } + + p->hbomb_on = 1; + + } + else if ((*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && + (sb_snum & (1 << 2))) + { + p->hbomb_hold_delay++; + } + else if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) + { + (*kb) = 0; + // don't change to remote when in NAM: grenades are timed + checkavailweapon(p); + } + } + else if (aplWeaponWorksLike[p->curr_weapon][snum] == HANDREMOTE_WEAPON) + { + (*kb)++; + + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_BOMB_TRIGGER) + { + p->hbomb_on = 0; + } + if (aplWeaponShoots[p->curr_weapon][snum] != 0) + { + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + lastvisinc = totalclock + 32; + p->visibility = 0; + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } + } + + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + (*kb) = 0; + /// WHAT THE HELL DOES THIS DO....????????????? + if (p->ammo_amount[TRIPBOMB_WEAPON] > 0) + addweapon(p, TRIPBOMB_WEAPON); + else + checkavailweapon(p); + } + + } +#if 0 + else if (aplWeaponWorksLike[p->curr_weapon][snum] == TRIPBOMB_WEAPON) + { + if (*kb < (aplWeaponFireDelay[p->curr_weapon][snum] + 1)) + { + p->posz = p->oposz; + p->poszv = 0; + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } + } + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + (*kb) = 0; +#ifdef FUTURENAM + // in NAM, the trip bomb uses the remote... + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; +#else + checkavailweapon(p); + p->weapon_pos = -9; +#endif + } + else (*kb)++; + } +#endif + else + { + if (IsGameEvent(EVENT_PROCESSWEAPON)) + { + OnEvent(EVENT_PROCESSWEAPON, p->i, snum, -1); + } + else + { + // the basic weapon... + (*kb)++; + + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) + { + if (*kb == aplWeaponReload[p->curr_weapon][snum]) + { + checkavailweapon(p); + } + } + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_STANDSTILL + && *kb < (aplWeaponFireDelay[p->curr_weapon][snum] + 1)) + { + p->posz = p->oposz; + p->poszv = 0; + } + if (*kb == aplWeaponSound2Time[p->curr_weapon][snum]) + { + if (aplWeaponSound2Sound[p->curr_weapon][snum]) + { + spritesound(aplWeaponSound2Sound[p->curr_weapon][snum], pi); + } + } + if (*kb == aplWeaponSpawnTime[p->curr_weapon][snum]) + { + DoSpawn(p, snum); + } + if (*kb == aplWeaponFireDelay[p->curr_weapon][snum]) + { + DoFire(p, snum); + } + + if (*kb > aplWeaponFireDelay[p->curr_weapon][snum] + && (*kb) < aplWeaponTotalTime[p->curr_weapon][snum]) + { + + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) + { // an 'automatic' + if ((sb_snum & (1 << 2)) == 0) + { + *kb = aplWeaponTotalTime[p->curr_weapon][snum]; + } + + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYTHIRD) + { + if (((*(kb)) % 3) == 0) + { + DoFire(p, snum); + DoSpawn(p, snum); + } + + } + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER) + { + // fire every other... + DoFire(p, snum); + DoSpawn(p, snum); + } + + } // 'automatic + } + else if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + if ( //!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) && + aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum] + && p->ammo_amount[p->curr_weapon] > 0 + && (aplWeaponClip[p->curr_weapon][snum]) + && ((p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum])) == 0) + ) + { + // reload in progress... + int i; + i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + + if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + spritesound(EJECT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i / 3))) + { + // insert occurs 2/3 of way through reload delay + spritesound(INSERT_CLIP, pi); + } + + if ((*kb) >= (aplWeaponReload[p->curr_weapon][snum])) + { + *kb = 0; + } + + } + else + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) + { // an 'automatic' + if (sb_snum & (1 << 2)) + { + // we are an AUTOMATIC. Fire again... + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART) + { + *kb = 1 + (krand() & 3); + } + else + { + *kb = 1; + } + } + else + { + *kb = 0; + } + } + else + { // not 'automatic' and >totaltime + *kb = 0; + } + } + } + } // process the event ourselves if no handler provided. + } + +#else + +#ifdef WW2 + switch (aplWeaponWorksLike[p->curr_weapon][snum]) +#else + switch (p->curr_weapon) +#endif + { + case HANDBOMB_WEAPON: // grenade in NAM +#ifdef WW2 + if (aplWeaponHoldDelay[p->curr_weapon][snum] // there is a hold delay + && ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) // and we are 'at' hold + && (sb_snum & (1 << 2)) // and 'fire' button is still down + ) + // just hold here... +#else + if ((*kb) == 6 && (sb_snum & (1 << 2))) +#endif + { + p->rapid_fire_hold = 1; + break; + } + (*kb)++; +#ifdef WW2 + if ((*kb) == aplWeaponHoldDelay[p->curr_weapon][snum]) +#else + if ((*kb) == 12) +#endif + { +#ifdef WW2 + p->ammo_amount[p->curr_weapon]--; +#else + p->ammo_amount[HANDBOMB_WEAPON]--; +#endif + + if (p->on_ground && (sb_snum & 2)) + { + k = 15; + i = ((p->horiz + p->horizoff - 100) * 20); + } + else + { + k = 140; + i = -512 - ((p->horiz + p->horizoff - 100) * 20); + } + + j = EGS(p->cursectnum, + p->posx + (sintable[(p->ang + 512) & 2047] >> 6), + p->posy + (sintable[p->ang & 2047] >> 6), + p->posz, HEAVYHBOMB, -16, 9, 9, + p->ang, (k + (p->hbomb_hold_delay << 5)), i, pi, 1); +#ifdef NAM + + { + long lGrenadeLifetime = GetGameVar("GRENADE_LIFETIME", NAM_GRENADE_LIFETIME, -1, snum); + long lGrenadeLifetimeVar = GetGameVar("GRENADE_LIFETIME_VAR", NAM_GRENADE_LIFETIME_VAR, -1, snum); + //sprintf(g_szBuf,"Lifetime=%ld Var=%ld snum=%d",lGrenadeLifetime, lGrenadeLifetimeVar, snum); + //AddLog(g_szBuf); + // set timer. blows up when at zero.... + sprite[j].extra = lGrenadeLifetime + + mulscale(krand(), lGrenadeLifetimeVar, 14) + - lGrenadeLifetimeVar; + } +#endif + + if (k == 15) + { + sprite[j].yvel = 3; + sprite[j].z += (8 << 8); + } + + k = hits(pi); + if (k < 512) + { + sprite[j].ang += 1024; + sprite[j].zvel /= 3; + sprite[j].xvel /= 3; + } + + p->hbomb_on = 1; + + } +#ifdef WW2 + else if ((*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && + (sb_snum & (1 << 2))) +#else + else if ((*kb) < 12 && (sb_snum & (1 << 2))) +#endif + p->hbomb_hold_delay++; +#ifdef WW2 + else if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) +#else + else if ((*kb) > 19) +#endif + { + (*kb) = 0; +#ifdef NAM + // don't change to remote when in NAM: grenades are timed + checkavailweapon(p); +#else + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; +#endif + } + + break; + + + case HANDREMOTE_WEAPON: // knife in NAM + + (*kb)++; + +#ifdef WW2 + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_BOMB_TRIGGER) + { + p->hbomb_on = 0; + } + if (aplWeaponShoots[p->curr_weapon][snum] != 0) + { + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + lastvisinc = totalclock + 32; + p->visibility = 0; + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } + } +#else + if ((*kb) == 2) + { + p->hbomb_on = 0; + } +#endif + +#ifdef WW2 + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) +#else + if ((*kb) == 10) +#endif + { + (*kb) = 0; +#ifdef NAM +#ifdef WW2 + /// WHAT THE HELL DOES THIS DO....????????????? + if (p->ammo_amount[TRIPBOMB_WEAPON] > 0) + addweapon(p, TRIPBOMB_WEAPON); + else +#else + if (p->ammo_amount[TRIPBOMB_WEAPON] > 0) + addweapon(p, TRIPBOMB_WEAPON); + else +#endif +#else + if (p->ammo_amount[HANDBOMB_WEAPON] > 0) + addweapon(p, HANDBOMB_WEAPON); + else +#endif + checkavailweapon(p); + } + break; + + case PISTOL_WEAPON: // m-16 in NAM +#if 0 +// TODO: +#ifdef WW2 +//sprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); +//AddLog(g_szBuf); + if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) + { + (*kb) = 0; + checkavailweapon(p); + } +#endif +#endif +#ifdef WW2 + if (*kb == aplWeaponFireDelay[p->curr_weapon][snum]) + { + //sprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + lastvisinc = totalclock + 32; + p->visibility = 0; + } + } +#else + if ((*kb) == 1) + { + shoot(pi, SHOTSPARK1); + spritesound(PISTOL_FIRE, pi); + lastvisinc = totalclock + 32; + p->visibility = 0; + } +#endif + +#ifdef WW2 + else if ((*kb) == aplWeaponSpawnTime[p->curr_weapon][snum]) + { + //sprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + spawn(pi, aplWeaponSpawn[p->curr_weapon][snum]); + } +#else + else if ((*kb) == 2) + spawn(pi, SHELL); +#endif + + (*kb)++; + +#ifdef WW2 + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) +#else + if ((*kb) >= 5) +#endif + { +#ifdef NAM +#ifdef WW2 + //sprintf(g_szBuf,"CP:%s %d",__FILE__,__LINE__); + //AddLog(g_szBuf); + if (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]) + { + // we have a reload to check for... + + if (p->ammo_amount[p->curr_weapon] <= 0 || (p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum]))) + { + // no reload needed.. + (*kb) = 0; + checkavailweapon(p); + } + else + { + // reload in progress... + int i; + i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + + if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + spritesound(EJECT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i / 3))) + { + // insert occurs 2/3 of way through reload delay + spritesound(INSERT_CLIP, pi); + } + } + } + else + { + // no reload time to check... just reset... + (*kb) = 0; + } + } + else + { + // not past total time + } +#else + if (p->ammo_amount[PISTOL_WEAPON] <= 0 || (p->ammo_amount[PISTOL_WEAPON] % 20)) + { + (*kb) = 0; + checkavailweapon(p); + } + else + { + switch ((*kb)) + { + case 5: + spritesound(EJECT_CLIP, pi); + break; + //#ifdef NAM + // case WEAPON2_RELOAD_TIME - 15: + //#else + case 8: + //#endif + spritesound(INSERT_CLIP, pi); + break; + } + } + } +#endif +#else + if (p->ammo_amount[PISTOL_WEAPON] <= 0 || (p->ammo_amount[PISTOL_WEAPON] % 12)) + { + (*kb) = 0; + checkavailweapon(p); + } + else + { + switch ((*kb)) + { + case 5: + spritesound(EJECT_CLIP, pi); + break; + //#ifdef NAM + // case WEAPON2_RELOAD_TIME - 15: + //#else + case 8: + //#endif + spritesound(INSERT_CLIP, pi); + break; + } + } +} +#endif + +#ifdef NAM +#ifdef WW2 + if ((*kb) >= aplWeaponReload[p->curr_weapon][snum])// 50) + { + + (*kb) = 0; + checkavailweapon(p); + } +#else + // 3 second re-load time + if ((*kb) == 50) + { + (*kb) = 0; + checkavailweapon(p); + } +#endif +#else + if ((*kb) == 27) + { + (*kb) = 0; + checkavailweapon(p); + } +#endif + + break; + + case SHOTGUN_WEAPON: + + (*kb)++; + +#ifdef WW2 + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + // check for clip. + if (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]) + { + // we have a reload to check for... + + if (p->ammo_amount[p->curr_weapon] <= 0 || (p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum]))) + { + // no reload needed.. + (*kb) = 0; + checkavailweapon(p); + } + else + { + // reload in progress... + int i; + i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + + if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + spritesound(EJECT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i / 3))) + { + // insert occurs 2/3 of way through reload delay + spritesound(INSERT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum])) + { + // done with clip... restart + *kb = 0; + } + } + } + else + { + // no reload time to check... just reset... + (*kb) = 0; + } + } + else + { + // not past total time + } + + if (*kb == aplWeaponFireDelay[p->curr_weapon][snum]) + { + { + int i; + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + for (i = 0; i < aplWeaponShotsPerBurst[p->curr_weapon][snum]; i++) + { + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } + } + p->ammo_amount[p->curr_weapon]--; + + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + lastvisinc = totalclock + 32; + p->visibility = 0; + } + + } + + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_CHECKATRELOAD) + { + if (*kb == aplWeaponReload[p->curr_weapon][snum]) + { + checkavailweapon(p); + } + } + if (*kb == aplWeaponSound2Time[p->curr_weapon][snum]) + { + spritesound(aplWeaponSound2Sound[p->curr_weapon][snum], pi); + } + if (*kb == aplWeaponSpawnTime[p->curr_weapon][snum]) + { + j = spawn(pi, aplWeaponSpawn[p->curr_weapon][snum]); + sprite[j].ang += 1024; + ssp(j, CLIPMASK0); + sprite[j].ang += 1024; + p->kickback_pic++; + } + if (*kb >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + *kb = 0; + } +#else + if (*kb == 4) + { + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + p->ammo_amount[SHOTGUN_WEAPON]--; + + spritesound(SHOTGUN_FIRE, pi); + + lastvisinc = totalclock + 32; + p->visibility = 0; + + } + + switch (*kb) + { + case 13: + checkavailweapon(p); + break; + case 15: + spritesound(SHOTGUN_COCK, pi); + break; + case 17: + case 20: + p->kickback_pic++; + break; + case 24: + j = spawn(pi, SHOTGUNSHELL); + sprite[j].ang += 1024; + ssp(j, CLIPMASK0); + sprite[j].ang += 1024; + p->kickback_pic++; + break; + case 31: + *kb = 0; + return; + } +#endif + break; + + case CHAINGUN_WEAPON: // m-60 in NAM + + (*kb)++; + +#ifdef WW2 + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + // check for clip. + if (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]) + { + // we have a reload to check for... + + if (p->ammo_amount[p->curr_weapon] <= 0 || (p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum]))) + { + // no reload needed.. + (*kb) = 0; + checkavailweapon(p); + } + else + { + // reload in progress... + int i; + i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + + if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + spritesound(EJECT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i / 3))) + { + // insert occurs 2/3 of way through reload delay + spritesound(INSERT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum])) + { + // done with clip... restart + *kb = 0; + } + } + } + else + { + // no reload time to check... just reset... + (*kb) = 0; + } + } + else + { + // not past total time + } + // if( (*kb) < aplWeaponTotalTime[p->curr_weapon][snum] ) + { + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + // first fire... + p->ammo_amount[p->curr_weapon]--; + + if (aplWeaponSpawn[p->curr_weapon][snum]) + { + j = spawn(pi, aplWeaponSpawn[p->curr_weapon][snum]); + + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3 << 8); + ssp(j, CLIPMASK0); + } + + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + lastvisinc = totalclock + 32; + p->visibility = 0; + } + + checkavailweapon(p); + } + else if ((*kb) <= aplWeaponHoldDelay[p->curr_weapon][snum]) + { // check for 'automatic' + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) + { // an 'automatic' + + if ((sb_snum & (1 << 2)) == 0) + { + // 'fire' not still down... stop... + *kb = 0; + break; + } + + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYTHIRD) + { + if (((*(kb)) % 3) == 0) + { + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AMMOPERSHOT) + { + p->ammo_amount[p->curr_weapon]--; + } + + if (aplWeaponSpawn[p->curr_weapon][snum]) + { + j = spawn(pi, aplWeaponSpawn[p->curr_weapon][snum]); + + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3 << 8); + ssp(j, CLIPMASK0); + } + + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + lastvisinc = totalclock + 32; + p->visibility = 0; + } + + checkavailweapon(p); + + } + + } + + } + } + else if ((*kb) > aplWeaponHoldDelay[p->curr_weapon][snum]) + { // if automatic, hold delay is time to wait before re-cycle + + if ((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) && + sb_snum & (1 << 2)) + { + // cycle the firing... + *kb = 1; + } + else + { + *kb = 0; + } + } + } + else + { + *kb = 0; + } +#else + if (*(kb) <= 12) + { + if (((*(kb)) % 3) == 0) + { + p->ammo_amount[CHAINGUN_WEAPON]--; + + if ((*(kb) % 3) == 0) + { + j = spawn(pi, SHELL); + + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3 << 8); + ssp(j, CLIPMASK0); + } + + spritesound(CHAINGUN_FIRE, pi); + shoot(pi, CHAINGUN); + lastvisinc = totalclock + 32; + p->visibility = 0; + checkavailweapon(p); + + if ((sb_snum & (1 << 2)) == 0) + { + *kb = 0; + break; + } + } + } + else if ((*kb) > 10) + { + if (sb_snum & (1 << 2)) *kb = 1; + else *kb = 0; + } +#endif + + break; + + case SHRINKER_WEAPON: // m-79 in NAM (Grenade launcher) + case GROW_WEAPON: // m-14 with scope (sniper rifle) + +#ifdef WW2 + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + // check for clip. + if (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]) + { + // we have a reload to check for... + + if (p->ammo_amount[p->curr_weapon] <= 0 || (p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum]))) + { + // no reload needed.. + (*kb) = 0; + checkavailweapon(p); + } + else + { + // reload in progress... + int i; + i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + + if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + spritesound(EJECT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i / 3))) + { + // insert occurs 2/3 of way through reload delay + spritesound(INSERT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum])) + { + // done with clip... restart + *kb = 0; + } + } + } + else + { + // no reload time to check... just reset... + (*kb) = 0; + } + } + else + { + // not past total time + } +#endif + if (p->curr_weapon == GROW_WEAPON) + { +#ifdef NAM +#ifdef WW2 + (*kb)++; + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) +#else + (*kb)++; + if ((*kb) == 3) +#endif +#else + if ((*kb) > 3) +#endif + { +#ifdef NAM + // fire now, but don't reload right away... + * kb++; + if (p->ammo_amount[p->curr_weapon] <= 1) + *kb = 0; +#else + * kb = 0; +#endif + if (screenpeek == snum) pus = 1; + p->ammo_amount[p->curr_weapon]--; +#ifdef WW2 + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); +#else + shoot(pi, GROWSPARK); +#endif + + //#ifdef NAM + //#else + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = totalclock + 32; + } + checkavailweapon(p); + //#endif + } +#ifdef NAM + if ((*kb) > aplWeaponReload[p->curr_weapon][snum]) // 30) + { + // reload now... + *kb = 0; + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = totalclock + 32; + } + checkavailweapon(p); + } +#else + else (*kb)++; +#endif + } + else + { +#ifdef NAM + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) //10 +#else + if ((*kb) > 10) +#endif + { +#ifdef NAM + // fire now, but wait for reload... + (*kb)++; +#else + (*kb) = 0; +#endif + +#ifdef WW2 + p->ammo_amount[p->curr_weapon]--; + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); +#else + p->ammo_amount[SHRINKER_WEAPON]--; + shoot(pi, SHRINKER); +#endif + +#ifdef NAM + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = totalclock + 32; + } +#else + p->visibility = 0; + lastvisinc = totalclock + 32; + checkavailweapon(p); +#endif + } +#ifdef NAM + else if ((*kb) > aplWeaponReload[p->curr_weapon][snum]) // 30 + { + *kb = 0; + p->visibility = 0; + lastvisinc = totalclock + 32; + checkavailweapon(p); + } +#endif + else (*kb)++; + } + break; + + case DEVISTATOR_WEAPON: + if (*kb) + { + (*kb)++; + +#ifdef WW2 + if ((*kb) & 1) +#else + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_FIREEVERYOTHER) + // fire every other... + + if (((*kb) >= aplWeaponFireDelay[p->curr_weapon][snum]) && + (*kb) < aplWeaponHoldDelay[p->curr_weapon][snum] && + ((*kb) & 1)) +#endif + { +#ifdef WW2 + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) +#endif + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = totalclock + 32; + } +#ifdef WW2 + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); +#else + shoot(pi, RPG); +#endif + p->ammo_amount[DEVISTATOR_WEAPON]--; + checkavailweapon(p); + } +#ifdef NAM +#ifdef WW2 + if ((*kb) > aplWeaponTotalTime[p->curr_weapon][snum]) + { + (*kb) = 0; + } +#else + if ((*kb) > 5) (*kb) = 0; +#endif +#else + if ((*kb) > 5) (*kb) = 0; +#endif + } + break; + case FREEZE_WEAPON: + // flame thrower in NAM + +#ifdef WW2 + if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + // check for clip. + if (aplWeaponReload[p->curr_weapon][snum] > aplWeaponTotalTime[p->curr_weapon][snum]) + { + // we have a reload to check for... + + if (p->ammo_amount[p->curr_weapon] <= 0 || (p->ammo_amount[p->curr_weapon] % (aplWeaponClip[p->curr_weapon][snum]))) + { + // no reload needed.. + (*kb) = 0; + checkavailweapon(p); + } + else + { + // reload in progress... + int i; + i = aplWeaponReload[p->curr_weapon][snum] - aplWeaponTotalTime[p->curr_weapon][snum]; + // time for 'reload' + + if ((*kb) == (aplWeaponTotalTime[p->curr_weapon][snum] + 1)) + { // eject shortly after 'total time' + spritesound(EJECT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum] - (i / 3))) + { + // insert occurs 2/3 of way through reload delay + spritesound(INSERT_CLIP, pi); + } + else if ((*kb) == (aplWeaponReload[p->curr_weapon][snum])) + { + // done with clip... restart + *kb = 0; + } + } + } + else + { + // no reload time to check... just reset... + (*kb) = 0; + } + } + else + { + // not past total time + } +#endif +#ifdef WW2 + if ((*kb) < (aplWeaponFireDelay[p->curr_weapon][snum] + 1)) +#else + if ((*kb) < 4) +#endif + { + (*kb)++; +#ifdef WW2 + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) +#else + if ((*kb) == 3) +#endif + { + p->ammo_amount[p->curr_weapon]--; + +#ifdef WW2 + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = totalclock + 32; + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); +#else + p->visibility = 0; + lastvisinc = totalclock + 32; + shoot(pi, FREEZEBLAST); +#endif + checkavailweapon(p); + } + if (s->xrepeat < 32) + { + *kb = 0; break; + } + } + else + { + if (sb_snum & (1 << 2)) + { + *kb = 1; +#ifdef WW2 + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } +#else + spritesound(CAT_FIRE, pi); +#endif + } + else *kb = 0; + } + break; + + case TRIPBOMB_WEAPON: // Claymore in NAM +#ifdef WW2 + if (*kb < (aplWeaponFireDelay[p->curr_weapon][snum] + 1)) +#else + if (*kb < 4) +#endif + { + p->posz = p->oposz; + p->poszv = 0; +#ifdef WW2 + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } +#else + if ((*kb) == 3) + shoot(pi, HANDHOLDINGLASER); +#endif + } +#ifdef WW2 + if ((*kb) == aplWeaponHoldDelay[p->curr_weapon][snum]) +#else + if ((*kb) == 16) +#endif + { + (*kb) = 0; +#ifdef FUTURENAM + // in NAM, the trip bomb uses the remote... + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; +#else + checkavailweapon(p); + p->weapon_pos = -9; +#endif + } + else (*kb)++; + break; + case KNEE_WEAPON: + (*kb)++; + +#ifdef WW2 + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + } + else if (sb_snum & (1 << 2)) + { + // 'fire' is still down. + + if ((*kb) == aplWeaponHoldDelay[p->curr_weapon][snum]) + { + // we are AT hold time + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AUTOMATIC) + { + // we are an AUTOMATIC. Fire again... + if (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_RANDOMRESTART) + { + *kb = 1 + (krand() & 3); + } + else + { + *kb = 1; + } + } + else + { + // nothing special to do + } + + } + else if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + // we have reached 'totaltime' and 'fire' is down + ///... should not get here if 'automatic'... + *kb = 0; + } + } + else if ((*kb) >= aplWeaponTotalTime[p->curr_weapon][snum]) + { + // 'fire' isn't down and we've reached the end... + *kb = 0; + } +#else + if ((*kb) == 7) shoot(pi, KNEE); + else if ((*kb) == 14) + { + if (sb_snum & (1 << 2)) + *kb = 1 + (krand() & 3); + else *kb = 0; + } +#endif + + if (p->wantweaponfire >= 0) + checkavailweapon(p); + break; + + case RPG_WEAPON: // m-72 in NAM (LAW) + (*kb)++; +#ifdef WW2 + if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) + { + p->ammo_amount[p->curr_weapon]--; + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = totalclock + 32; + } + if (aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum], pi); + } + SetGameVarID(g_iWeaponVarID, p->curr_weapon, p->i, snum); + SetGameVarID(g_iWorksLikeVarID, aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + shoot(pi, aplWeaponShoots[p->curr_weapon][snum]); + checkavailweapon(p); + } + else if (*kb == aplWeaponTotalTime[p->curr_weapon][snum]) + *kb = 0; +#else + if ((*kb) == 4) + { + p->ammo_amount[RPG_WEAPON]--; + lastvisinc = totalclock + 32; + p->visibility = 0; + shoot(pi, RPG); + checkavailweapon(p); + } + else if (*kb == 20) + *kb = 0; +#endif + break; + } +#endif +} + END_DUKE_NS diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 7f693340b..01b3cebdb 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -2634,4 +2634,745 @@ void onBoatHit(int snum, int var60) p->TurbCount = 6; } } + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void fireWeapon(int snum, int *kb) +{ + auto p = &ps[snum]; + int pi = p->i; + + p->crack_time = 777; + + if (p->holster_weapon == 1) + { + if (p->last_pissed_time <= (26 * 218) && p->weapon_pos == -9) + { + p->holster_weapon = 0; + p->weapon_pos = 10; + FTA(74, p); + } + } + else + { + if (isRRRA() && p->curr_weapon >= MOTORCYCLE_WEAPON) return; + switch (p->curr_weapon) + { + case DYNAMITE_WEAPON: + p->hbomb_hold_delay = 0; + if (p->ammo_amount[DYNAMITE_WEAPON] > 0) + (*kb) = 1; + break; + case HANDREMOTE_WEAPON: + p->hbomb_hold_delay = 0; + (*kb) = 1; + break; + + case PISTOL_WEAPON: + if (p->ammo_amount[PISTOL_WEAPON] > 0) + { + p->ammo_amount[PISTOL_WEAPON]--; + (*kb) = 1; + } + break; + + case RIFLEGUN_WEAPON: + if (p->ammo_amount[RIFLEGUN_WEAPON] > 0) // && p->random_club_frame == 0) + (*kb) = 1; + break; + + case SHOTGUN_WEAPON: + if (p->ammo_amount[SHOTGUN_WEAPON] > 0 && p->random_club_frame == 0) + (*kb) = 1; + break; + + case BOWLING_WEAPON: + if (p->ammo_amount[BOWLING_WEAPON] > 0) + (*kb) = 1; + break; + case POWDERKEG_WEAPON: + if (p->ammo_amount[POWDERKEG_WEAPON] > 0) + (*kb) = 1; + break; + + case BUZZSAW_WEAPON: + case THROWSAW_WEAPON: + if (p->curr_weapon == BUZZSAW_WEAPON) + { + if (p->ammo_amount[BUZZSAW_WEAPON] > 0) + { + (*kb) = 1; + spritesound(431, pi); + } + } + else if (p->ammo_amount[THROWSAW_WEAPON] > 0) + { + (*kb) = 1; + spritesound(SHRINKER_FIRE, pi); + } + break; + + case ALIENBLASTER_WEAPON: + if (p->ammo_amount[ALIENBLASTER_WEAPON] > 0) + (*kb) = 1; + break; + + case TIT_WEAPON: + if (p->ammo_amount[TIT_WEAPON] > 0) + { + (*kb) = 1; + p->hbomb_hold_delay = !p->hbomb_hold_delay; + } + break; + + case MOTORCYCLE_WEAPON: + if (p->ammo_amount[MOTORCYCLE_WEAPON] > 0) + { + (*kb) = 1; + p->hbomb_hold_delay = !p->hbomb_hold_delay; + } + break; + + case BOAT_WEAPON: + if (p->ammo_amount[BOAT_WEAPON] > 0) + (*kb) = 1; + break; + + case CROSSBOW_WEAPON: + if (p->ammo_amount[CROSSBOW_WEAPON] > 0) + (*kb) = 1; + break; + + case CHICKEN_WEAPON: + if (p->ammo_amount[CHICKEN_WEAPON] > 0) + (*kb) = 1; + break; + + case KNEE_WEAPON: + case SLINGBLADE_WEAPON: + if (p->curr_weapon == SLINGBLADE_WEAPON) + { + if (p->ammo_amount[SLINGBLADE_WEAPON] > 0) + if (p->quick_kick == 0) + (*kb) = 1; + } + else if (!isRRRA() || p->ammo_amount[KNEE_WEAPON] > 0) + if (p->quick_kick == 0) + (*kb) = 1; + break; + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +static void operateweapon(int snum) +{ + auto p = &ps[snum]; + int pi = p->i; + + switch (p->curr_weapon) + { + case HANDBOMB_WEAPON: + + if ((*kb) == 1) + sound(401); + if ((*kb) == 6 && (sb_snum & (1 << 2))) + p->rapid_fire_hold = 1; + (*kb)++; + if ((*kb) > 19) + { + (*kb) = 0; + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; + p->at57c = 45; + p->at57e = 1; + sound(402); + } + + break; + + + case HANDREMOTE_WEAPON: + + (*kb)++; + + if (p->at57c < 0) + { + p->hbomb_on = 0; + } + + if ((*kb) == 39) + { + p->hbomb_on = 0; + p->at290 = 8192; + madenoise(snum); + } + if ((*kb) == 12) + { + p->ammo_amount[HANDBOMB_WEAPON]--; + if (p->ammo_amount[RPG_WEAPON]) + p->ammo_amount[RPG_WEAPON]--; +#ifdef RRRA + if (p->on_ground && (sb_snum & 2) && !p->OnMotorcycle) +#else + if (p->on_ground && (sb_snum & 2)) +#endif + { + k = 15; + i = ((p->horiz + p->horizoff - 100) * 20); + } + else + { + k = 140; + i = -512 - ((p->horiz + p->horizoff - 100) * 20); + } + + j = EGS(p->cursectnum, + p->posx + (sintable[(p->ang + 512) & 2047] >> 6), + p->posy + (sintable[p->ang & 2047] >> 6), + p->posz, HEAVYHBOMB, -16, 9, 9, + p->ang, (k + (p->hbomb_hold_delay << 5)) * 2, i, pi, 1); + + if (k == 15) + { + sprite[j].yvel = 3; + sprite[j].z += (8 << 8); + } + + k = hits(pi); + if (k < 512) + { + sprite[j].ang += 1024; + sprite[j].zvel /= 3; + sprite[j].xvel /= 3; + } + + p->hbomb_on = 1; + } + else if ((*kb) < 12 && (sb_snum & 4)) + p->hbomb_hold_delay++; + + if ((*kb) == 40) + { + (*kb) = 0; + p->curr_weapon = HANDBOMB_WEAPON; + p->last_weapon = -1; + p->at57e = 0; + p->at57c = 45; + if (p->ammo_amount[HANDBOMB_WEAPON] > 0) + { + addweapon(p, HANDBOMB_WEAPON); + p->weapon_pos = -9; + } + else checkavailweapon(p); + } + break; + + case PISTOL_WEAPON: + if ((*kb) == 1) + { + shoot(pi, SHOTSPARK1); + spritesound(PISTOL_FIRE, pi); + p->at290 = 8192; + madenoise(snum); + + lastvisinc = totalclock + 32; + p->visibility = 0; + if (psectlotag != 857) + { + p->posxv -= sintable[(p->ang + 512) & 2047] << 4; + p->posyv -= sintable[p->ang & 2047] << 4; + } + } + else if ((*kb) == 2) + if (p->ammo_amount[PISTOL_WEAPON] <= 0) + { + (*kb) = 0; + checkavailweapon(p); + } + + (*kb)++; + + if ((*kb) >= 22) + { + if (p->ammo_amount[PISTOL_WEAPON] <= 0) + { + (*kb) = 0; + checkavailweapon(p); + break; + } + else if ((p->ammo_amount[PISTOL_WEAPON] % 6) == 0) + { + switch ((*kb)) + { + case 24: + spritesound(EJECT_CLIP, pi); + break; + case 30: + spritesound(INSERT_CLIP, pi); + break; + } + } + else + (*kb) = 38; + } + + if ((*kb) == 38) + { + (*kb) = 0; + checkavailweapon(p); + } + + break; + + case SHOTGUN_WEAPON: + + (*kb)++; + + if ((*kb) == 6) + if (p->at599 == 0) + if (p->ammo_amount[SHOTGUN_WEAPON] > 1) + if (sb_snum & 4) + p->at59a = 1; + + if (*kb == 4) + { + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + + p->ammo_amount[SHOTGUN_WEAPON]--; + + spritesound(SHOTGUN_FIRE, pi); + + p->at290 = 8192; + madenoise(snum); + + lastvisinc = totalclock + 32; + p->visibility = 0; + } + + if (*kb == 7) + { + if (p->at59a) + { + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + shoot(pi, SHOTGUN); + + p->ammo_amount[SHOTGUN_WEAPON]--; + + spritesound(SHOTGUN_FIRE, pi); + + if (psectlotag != 857) + { + p->posxv -= sintable[(p->ang + 512) & 2047] << 5; + p->posyv -= sintable[p->ang & 2047] << 5; + } + } + else if (psectlotag != 857) + { + p->posxv -= sintable[(p->ang + 512) & 2047] << 4; + p->posyv -= sintable[p->ang & 2047] << 4; + } + } + + if (p->at599) + { + switch (*kb) + { + case 16: + checkavailweapon(p); + break; + case 17: + spritesound(SHOTGUN_COCK, pi); + break; + case 28: + *kb = 0; + p->at599 = 0; + p->at59a = 0; + return; + } + } + else if (p->at59a) + { + switch (*kb) + { + case 26: + checkavailweapon(p); + break; + case 27: + spritesound(SHOTGUN_COCK, pi); + break; + case 38: + *kb = 0; + p->at599 = 0; + p->at59a = 0; + return; + } + } + else + { + switch (*kb) + { + case 16: + checkavailweapon(p); + (*kb) = 0; + p->at599 = 1; + p->at59a = 0; + return; + } + } + break; + + case CHAINGUN_WEAPON: + + (*kb)++; + p->horiz++; + p->at59b++; + + if ((*kb) <= 12) + { + if (((*kb) % 3) == 0) + { + p->ammo_amount[CHAINGUN_WEAPON]--; + + if (((*kb) % 3) == 0) + { + j = spawn(pi, SHELL); + + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3 << 8); + ssp(j, CLIPMASK0); + } + + spritesound(CHAINGUN_FIRE, pi); + shoot(pi, CHAINGUN); + p->at290 = 8192; + madenoise(snum); + lastvisinc = totalclock + 32; + p->visibility = 0; + + if (psectlotag != 857) + { + p->posxv -= sintable[(p->ang + 512) & 2047] << 4; + p->posyv -= sintable[p->ang & 2047] << 4; + } + checkavailweapon(p); + + if ((sb_snum & (1 << 2)) == 0) + { + *kb = 0; + break; + } + } + } + else if ((*kb) > 10) + { + if (sb_snum & (1 << 2)) *kb = 1; + else *kb = 0; + } + + break; + + case SHRINKER_WEAPON: + case GROW_WEAPON: + + if (p->curr_weapon == GROW_WEAPON) + { + if ((*kb) > 3) + { + *kb = 0; + if (screenpeek == snum) pus = 1; + shoot(pi, GROWSPARK); + p->at290 = 1024; + madenoise(snum); + checkavailweapon(p); + } + else (*kb)++; + } + else + { + if ((*kb) == 1) + { + p->ammo_amount[SHRINKER_WEAPON]--; + shoot(pi, SHRINKSPARK); + checkavailweapon(p); + } + (*kb)++; + if ((*kb) > 20) + *kb = 0; + } + break; + + case DEVISTATOR_WEAPON: + (*kb)++; + if ((*kb) == 2 || (*kb) == 4) + { + p->visibility = 0; + lastvisinc = totalclock + 32; + spritesound(CHAINGUN_FIRE, pi); + shoot(pi, SHOTSPARK1); + p->at290 = 16384; + madenoise(snum); + p->ammo_amount[DEVISTATOR_WEAPON]--; + checkavailweapon(p); + } + if ((*kb) == 2) + { + p->ang += 16; + } + else if ((*kb) == 4) + { + p->ang -= 16; + } + if ((*kb) > 4) + (*kb) = 1; + if (!(sb_snum & 4)) + (*kb) = 0; + break; +#ifdef RRRA + case RA13_WEAPON: + (*kb)++; + if ((*kb) == 2 || (*kb) == 4) + { + p->visibility = 0; + lastvisinc = totalclock + 32; + spritesound(CHAINGUN_FIRE, pi); + shoot(pi, CHAINGUN); + p->at290 = 16384; + madenoise(snum); + p->ammo_amount[RA13_WEAPON]--; + if (p->ammo_amount[RA13_WEAPON] <= 0) + (*kb) = 0; + else + checkavailweapon(p); + } + if ((*kb) == 2) + { + p->ang += 4; + } + else if ((*kb) == 4) + { + p->ang -= 4; + } + if ((*kb) > 4) + (*kb) = 1; + if (!(sb_snum & 4)) + (*kb) = 0; + break; + case RA14_WEAPON: + if ((*kb) == 3) + { + p->MotoSpeed -= 20; + p->ammo_amount[RA14_WEAPON]--; + shoot(pi, RRTILE1790); + } + (*kb)++; + if ((*kb) > 20) + { + (*kb) = 0; + checkavailweapon(p); + } + if (p->ammo_amount[RA14_WEAPON] <= 0) + (*kb) = 0; + else + checkavailweapon(p); + break; + + +#endif + case FREEZE_WEAPON: + (*kb)++; + if ((*kb) >= 7 && (*kb) <= 11) + shoot(pi, FIRELASER); + + if ((*kb) == 5) + { + spritesound(CAT_FIRE, pi); + p->at290 = 2048; + madenoise(snum); + } + else if ((*kb) == 9) + { + p->ammo_amount[FREEZE_WEAPON]--; + p->visibility = 0; + lastvisinc = totalclock + 32; + checkavailweapon(p); + } + else if ((*kb) == 12) + { + p->posxv -= sintable[(p->ang + 512) & 2047] << 4; + p->posyv -= sintable[p->ang & 2047] << 4; + p->horiz += 20; + p->at59b += 20; + } + if ((*kb) > 20) + (*kb) = 0; + break; + + case TRIPBOMB_WEAPON: + case BOWLING_WEAPON: + if (p->curr_weapon == TRIPBOMB_WEAPON) + { + if ((*kb) == 3) + { + if (screenpeek == snum) pus = 1; + p->ammo_amount[TRIPBOMB_WEAPON]--; + p->gotweapon[TRIPBOMB_WEAPON] = 0; +#ifdef RRRA + if (p->on_ground && (sb_snum & 2) && !p->OnMotorcycle) +#else + if (p->on_ground && (sb_snum & 2)) +#endif + { + k = 15; + i = ((p->horiz + p->horizoff - 100) * 20); + } + else + { + k = 32; + i = -512 - ((p->horiz + p->horizoff - 100) * 20); + } + + j = EGS(p->cursectnum, + p->posx + (sintable[(p->ang + 512) & 2047] >> 6), + p->posy + (sintable[p->ang & 2047] >> 6), + p->posz, TRIPBOMBSPRITE, -16, 9, 9, + p->ang, k * 2, i, pi, 1); + } + (*kb)++; + if ((*kb) > 20) + { + (*kb) = 0; + checkavailweapon(p); + } + } + else + { + if ((*kb) == 30) + { + p->ammo_amount[BOWLING_WEAPON]--; + spritesound(354, pi); + shoot(pi, BOWLINGBALL); + p->at290 = 1024; + madenoise(snum); + } + if ((*kb) < 30) + { + p->posxv += sintable[(p->ang + 512) & 2047] << 4; + p->posyv += sintable[p->ang & 2047] << 4; + } + (*kb)++; + if ((*kb) > 40) + { + (*kb) = 0; + p->gotweapon[BOWLING_WEAPON] = 0; + checkavailweapon(p); + } + } + break; + case KNEE_WEAPON: + (*kb)++; + if ((*kb) == 3) + spritesound(426, pi); + if ((*kb) == 12) + { + shoot(pi, KNEE); + p->at290 = 1024; + madenoise(snum); + } + else if ((*kb) == 16) + (*kb) = 0; + + if (p->wantweaponfire >= 0) + checkavailweapon(p); + break; +#ifdef RRRA + case RA15_WEAPON: + (*kb)++; + if ((*kb) == 3) + spritesound(252, pi); + if ((*kb) == 8) + { + shoot(pi, SLINGBLADE); + p->at290 = 1024; + madenoise(snum); + } + else if ((*kb) == 16) + (*kb) = 0; + + if (p->wantweaponfire >= 0) + checkavailweapon(p); + break; +#endif + + case RPG_WEAPON: + (*kb)++; + if ((*kb) == 4) + { + p->ammo_amount[RPG_WEAPON]--; + if (p->ammo_amount[HANDBOMB_WEAPON]) + p->ammo_amount[HANDBOMB_WEAPON]--; + lastvisinc = totalclock + 32; + p->visibility = 0; + shoot(pi, RPG); + p->at290 = 32768; + madenoise(snum); + checkavailweapon(p); + } + else if ((*kb) == 16) + spritesound(450, pi); + else if ((*kb) == 34) + (*kb) = 0; + break; +#ifdef RRRA + case RA16_WEAPON: + (*kb)++; + if ((*kb) == 4) + { + p->ammo_amount[RA16_WEAPON]--; + lastvisinc = totalclock + 32; + p->visibility = 0; + shoot(pi, RPG2); + p->at290 = 32768; + madenoise(snum); + checkavailweapon(p); + } + else if ((*kb) == 16) + spritesound(450, pi); + else if ((*kb) == 34) + (*kb) = 0; + break; +#endif + } + +} + END_DUKE_NS