diff --git a/source/games/duke/CMakeLists.txt b/source/games/duke/CMakeLists.txt index 621269b79..fe119e300 100644 --- a/source/games/duke/CMakeLists.txt +++ b/source/games/duke/CMakeLists.txt @@ -15,6 +15,7 @@ set( PCH_SOURCES src/player.cpp src/player_d.cpp src/player_r.cpp + src/player_w.cpp src/sectors.cpp src/sectors_d.cpp src/sectors_r.cpp diff --git a/source/games/duke/src/actors.h b/source/games/duke/src/actors.h index da9ddf491..68af275d7 100644 --- a/source/games/duke/src/actors.h +++ b/source/games/duke/src/actors.h @@ -395,6 +395,7 @@ void respawn_rrra(int i, int j); int dodge(spritetype*); void alterang(int a, int g_i, int g_p); void fall_common(int g_i, int g_p, int JIBS6, int DRONE, int BLOODPOOL, int SHOTSPARK1, int squished, int thud, int(*fallspecial)(int, int), void (*falladjustz)(spritetype*)); +void checkavailweapon(struct player_struct* p); // tile names which are identical for all games. enum diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 2821dd0d2..25572fc50 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -83,8 +83,8 @@ void forceplayerangle(struct player_struct* p) p->addhoriz(64); p->return_to_center = 9; - p->look_ang = n >> 1; - p->rotscrnang = n >> 1; + p->setlookang(n >> 1); + p->setrotscrnang(n >> 1); } //--------------------------------------------------------------------------- @@ -269,7 +269,7 @@ int aim(spritetype* s, int aang) if (sdist > 512 && sdist < smax) { if (s->picnum == TILE_APLAYER) - a = (abs(scale(sp->z - s->z, 10, sdist) - (ps[s->yvel].gethorizdiff() - 100)) < 100); + a = (abs(scale(sp->z - s->z, 10, sdist) - (ps[s->yvel].gethorizsum() - 100)) < 100); else a = 1; cans = cansee(sp->x, sp->y, sp->z - (32 << 8) + actorinfo[sp->picnum].aimoffset, sp->sectnum, s->x, s->y, s->z - (32 << 8), s->sectnum); @@ -563,7 +563,7 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) 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->setrotscrnang((p->dead_flag + ((fz + p->posz) >> 7)) & 2047); p->on_warping_sector = 0; @@ -707,8 +707,8 @@ void playerLookLeft(int snum) OnEvent(EVENT_LOOKLEFT, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { - p->look_ang -= 152; - p->rotscrnang += 24; + p->addlookang(-152); + p->addrotscrnang(24); } } @@ -719,8 +719,8 @@ void playerLookRight(int snum) OnEvent(EVENT_LOOKRIGHT, p->i, snum, -1); if (GetGameVarID(g_iReturnVarID, p->i, snum) == 0) { - p->look_ang += 152; - p->rotscrnang -= 24; + p->addlookang(152); + p->addrotscrnang(24); } } diff --git a/source/games/duke/src/player.h b/source/games/duke/src/player.h index 3617bda56..4557bafda 100644 --- a/source/games/duke/src/player.h +++ b/source/games/duke/src/player.h @@ -172,7 +172,15 @@ typedef struct player_struct { fix16_t q16horiz, q16horizoff; fix16_t q16ang, oq16ang; + int look_ang; + int16_t orotscrnang, rotscrnang; // JBF 20031220: added orotscrnang + int getlookang() { return look_ang; } + void setlookang(int b) { look_ang = b; } + void addlookang(int b) { look_ang += b; } + int getrotscrnang() { return rotscrnang; } + void setrotscrnang(int b) { rotscrnang = b; } + void addrotscrnang(int b) { rotscrnang += b; } int getang() { return q16ang >> FRACBITS; } int getoang() { return oq16ang >> FRACBITS; } void setang(int v) { q16ang = v << FRACBITS; } @@ -181,7 +189,7 @@ typedef struct player_struct { void addhoriz(int v) { q16horiz += (v << FRACBITS); } void sethoriz(int v) { q16horiz = (v << FRACBITS); } int gethoriz() { return q16horiz >> FRACBITS; } - int gethorizdiff() { return (q16horiz + q16horizoff) >> FRACBITS; } + int gethorizsum() { return (q16horiz + q16horizoff) >> FRACBITS; } int32_t truefz, truecz, player_par; int32_t randomflamex, exitx, exity; @@ -195,7 +203,7 @@ typedef struct player_struct { int16_t loogiex[64], loogiey[64], sbs, sound_pitch; - int16_t cursectnum, look_ang, last_extra, subweapon; + int16_t cursectnum, last_extra, subweapon; int16_t ammo_amount[MAX_WEAPONS], inv_amount[GET_MAX]; int16_t wackedbyactor, pyoff, opyoff; @@ -209,7 +217,7 @@ typedef struct player_struct { int16_t weaprecs[MAX_WEAPON_RECS], weapon_sway, crack_time, bobcounter; - int16_t orotscrnang, rotscrnang, dead_flag; // JBF 20031220: added orotscrnang + int16_t dead_flag; int16_t holoduke_on, pycount; int16_t transporter_hold/*, clipdist*/; @@ -283,7 +291,7 @@ typedef struct player_struct { #define shield_amount inv_amount[GET_SHIELD] #define raat609 MamaEnd #define raat5dd sea_sick_stat -#define at57e detonate_offset +#define at57e detonate_count #define at57c detonate_time #define at58e drink_timer #define at592 eat_timer @@ -462,6 +470,8 @@ int makepainsounds(int snum, int type); void playerCrouch(int snum); void playerJump(int snum, int fz, int cz); +extern int lastvisinc; + END_DUKE_NS #endif diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index f4efa67f1..95aade846 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -157,7 +157,7 @@ void shoot_d(int i, int atwith) } else { - zvel = 98 * (100 + ps[p].gethorizdiff()); + zvel = 98 * (100 + ps[p].gethorizsum()); sx += sintable[(sa + 860) & 0x7FF] / 448; sy += sintable[(sa + 348) & 0x7FF] / 448; sz += (3 << 8); @@ -215,7 +215,7 @@ void shoot_d(int i, int atwith) } else { - zvel = (int)(100 - ps[p].gethorizdiff()) * 81; + zvel = (int)(100 - ps[p].gethorizsum()) * 81; if (sprite[ps[p].i].xvel != 0) vel = (int)((((512 - (1024 - abs(abs(getangle(sx - ps[p].oposx, sy - ps[p].oposy) - sa) - 1024))) @@ -283,7 +283,7 @@ void shoot_d(int i, int atwith) { if (p >= 0) { - zvel = (100 - ps[p].gethorizdiff()) << 5; + zvel = (100 - ps[p].gethorizsum()) << 5; sz += (6 << 8); sa += 15; } @@ -459,14 +459,14 @@ void shoot_d(int i, int atwith) if (j == -1) { // no target - zvel = (100 - ps[p].gethorizdiff()) << 5; + zvel = (100 - ps[p].gethorizsum()) << 5; } zvel += (zRange / 2) - (krand() & (zRange - 1)); } else if (j == -1 || atwith != SHOTSPARK1) { sa += 16 - (krand() & 31); - zvel = (100 - ps[p].gethorizdiff()) << 5; + zvel = (100 - ps[p].gethorizsum()) << 5; zvel += 128 - (krand() & 255); } @@ -676,7 +676,7 @@ void shoot_d(int i, int atwith) sa = getangle(sprite[j].x - sx, sprite[j].y - sy); } else - zvel = (100 - ps[p].gethorizdiff()) * 98; + zvel = (100 - ps[p].gethorizsum()) * 98; } else { @@ -764,7 +764,7 @@ void shoot_d(int i, int atwith) if (sprite[j].picnum != RECON) sa = getangle(sprite[j].x - sx, sprite[j].y - sy); } - else zvel = (100 - ps[p].gethorizdiff()) * 81; + else zvel = (100 - ps[p].gethorizsum()) * 81; if (atwith == RPG) spritesound(RPG_SHOOT, i); @@ -850,7 +850,7 @@ void shoot_d(int i, int atwith) { sprite[j].x -= sintable[sa & 2047] / 56; sprite[j].y -= sintable[(sa + 1024 + 512) & 2047] / 56; - sprite[j].ang -= 8 + (krand() & 255) - 128; + sprite[j].ang -= 8 + (krand() & 255) - 128; sprite[j].xrepeat = 24; sprite[j].yrepeat = 24; } @@ -892,7 +892,7 @@ void shoot_d(int i, int atwith) case HANDHOLDINGLASER: if (p >= 0) - zvel = (100 - ps[p].gethorizdiff()) * 32; + zvel = (100 - ps[p].gethorizsum()) * 32; else zvel = 0; hitscan(sx, sy, sz - ps[p].pyoff, sect, @@ -993,7 +993,7 @@ void shoot_d(int i, int atwith) else { sa += 16 - (krand() & 31); - zvel = (100 - ps[p].gethorizdiff()) << 5; + zvel = (100 - ps[p].gethorizsum()) << 5; zvel += 128 - (krand() & 255); } @@ -1068,7 +1068,7 @@ void shoot_d(int i, int atwith) zvel = ((sprite[j].z - sz - dal - (4 << 8)) * 768) / (ldist(&sprite[ps[p].i], &sprite[j])); sa = getangle(sprite[j].x - sx, sprite[j].y - sy); } - else zvel = (100 - ps[p].gethorizdiff()) * 98; + else zvel = (100 - ps[p].gethorizsum()) * 98; } else if (s->statnum != 3) { @@ -1483,7 +1483,7 @@ int doincrements_d(struct player_struct* p) p->knuckle_incs++; if (p->knuckle_incs == 10 && !isWW2GI()) { - if (totalclock > 1024) + if ((int)totalclock > 1024) if (snum == screenpeek || ud.coop == 1) { if (rand() & 1) @@ -1877,7 +1877,13 @@ static void underwater(int snum, int sb_snum, int psect, int fz, int cz) } } -static int operateTripbomb(int snum) +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +int operateTripbomb(int snum) { auto p = &ps[snum]; int pi = p->i; @@ -1887,7 +1893,7 @@ static int operateTripbomb(int snum) hitscan(p->posx, p->posy, p->posz, p->cursectnum, sintable[(p->getang() + 512) & 2047], - sintable[p->getang() & 2047], (100 - p->gethorizdiff()) * 32, + sintable[p->getang() & 2047], (100 - p->gethorizsum()) * 32, §, &hw, &hitsp, &sx, &sy, &sz, CLIPMASK1); if (sect < 0 || hitsp >= 0) @@ -1920,172 +1926,6 @@ static int operateTripbomb(int snum) 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; - } - } - } -} //--------------------------------------------------------------------------- // @@ -2187,6 +2027,15 @@ static void fireweapon(int snum, int* kb) } break; + case FLAMETHROWER_WEAPON: // Twentieth Anniversary World Tour + if (isWorldTour() && p->ammo_amount[FLAMETHROWER_WEAPON] > 0) + { + (*kb) = 1; + if (sector[p->cursectnum].lotag != 2) + spritesound(FLAMETHROWER_INTRO, pi); + } + break; + case KNEE_WEAPON: if (p->quick_kick == 0) { @@ -2202,343 +2051,48 @@ static void fireweapon(int snum, int* kb) // //--------------------------------------------------------------------------- -#if 0 -static void operateweapon(int snum) +static void operateweapon(int snum, int sb_snum, int psect, int* kb) { auto p = &ps[snum]; int pi = p->i; + int i, j, k; // 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); + i = ((p->gethorizsum() - 100) * 20); } else { k = 140; - i = -512 - ((p->horiz + p->horizoff - 100) * 20); + i = -512 - ((p->gethorizsum() - 100) * 20); } j = EGS(p->cursectnum, - p->posx + (sintable[(p->ang + 512) & 2047] >> 6), - p->posy + (sintable[p->ang & 2047] >> 6), + p->posx + (sintable[(p->getang() + 512) & 2047] >> 6), + p->posy + (sintable[p->getang() & 2047] >> 6), p->posz, HEAVYHBOMB, -16, 9, 9, - p->ang, (k + (p->hbomb_hold_delay << 5)), i, pi, 1); -#ifdef NAM + p->getang(), (k + (p->hbomb_hold_delay << 5)), i, pi, 1); + if (isNam()) { - 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; + sprite[j].extra = mulscale(krand(), NAM_GRENADE_LIFETIME_VAR, 14); } -#endif if (k == 15) { @@ -2557,28 +2111,19 @@ static void operateweapon(int snum) 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 + if (isNam()) checkavailweapon(p); + else + { + p->curr_weapon = HANDREMOTE_WEAPON; + p->last_weapon = -1; + p->weapon_pos = 10; + } } break; @@ -2588,166 +2133,40 @@ static void operateweapon(int snum) (*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); + int weapon = isNam() ? TRIPBOMB_WEAPON : HANDBOMB_WEAPON; + + if (p->ammo_amount[weapon] > 0) + fi.addweapon(p, 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); + fi.shoot(pi, SHOTSPARK1); spritesound(PISTOL_FIRE, pi); - lastvisinc = totalclock + 32; + lastvisinc = (int)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 + fi.spawn(pi, SHELL); (*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)) + if (p->ammo_amount[PISTOL_WEAPON] <= 0 || (p->ammo_amount[PISTOL_WEAPON] % (isNam() ? 20 : 12))) { (*kb) = 0; checkavailweapon(p); @@ -2768,176 +2187,34 @@ static void operateweapon(int snum) 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) + if ((*kb) == (isNam() ? 50 : 27)) { (*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); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); p->ammo_amount[SHOTGUN_WEAPON]--; spritesound(SHOTGUN_FIRE, pi); - lastvisinc = totalclock + 32; + lastvisinc = (int)totalclock + 32; p->visibility = 0; } @@ -2955,7 +2232,7 @@ static void operateweapon(int snum) p->kickback_pic++; break; case 24: - j = spawn(pi, SHOTGUNSHELL); + j = fi.spawn(pi, SHOTGUNSHELL); sprite[j].ang += 1024; ssp(j, CLIPMASK0); sprite[j].ang += 1024; @@ -2965,172 +2242,12 @@ static void operateweapon(int snum) *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) @@ -3139,7 +2256,7 @@ static void operateweapon(int snum) if ((*(kb) % 3) == 0) { - j = spawn(pi, SHELL); + j = fi.spawn(pi, SHELL); sprite[j].ang += 1024; sprite[j].ang &= 2047; @@ -3149,8 +2266,8 @@ static void operateweapon(int snum) } spritesound(CHAINGUN_FIRE, pi); - shoot(pi, CHAINGUN); - lastvisinc = totalclock + 32; + fi.shoot(pi, CHAINGUN); + lastvisinc = (int)totalclock + 32; p->visibility = 0; checkavailweapon(p); @@ -3166,316 +2283,129 @@ static void operateweapon(int snum) 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]) + bool check; + if (isNam()) { - // 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; - } + (*kb)++; + check = ((*kb) == 3); } else { - // not past total time + check = ((*kb) > 3); } -#endif - if (p->curr_weapon == GROW_WEAPON) + if (check) { -#ifdef NAM -#ifdef WW2 - (*kb)++; - if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) -#else - (*kb)++; - if ((*kb) == 3) -#endif -#else - if ((*kb) > 3) -#endif + // fire now, but don't reload right away... + if (isNam()) { -#ifdef NAM - // fire now, but don't reload right away... - * kb++; + *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... + else *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); + if (screenpeek == snum) pus = 1; + p->ammo_amount[p->curr_weapon]--; + fi.shoot(pi, GROWSPARK); + + //#ifdef NAM + //#else + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) + { + // make them visible if not set... + p->visibility = 0; + lastvisinc = (int)totalclock + 32; } -#else - else (*kb)++; -#endif + checkavailweapon(p); + //#endif } - else + else if (!isNam()) (*kb)++; + if (isNam() && (*kb) > aplWeaponReload[p->curr_weapon][snum]) // 30) { -#ifdef NAM - if ((*kb) == aplWeaponFireDelay[p->curr_weapon][snum]) //10 -#else - if ((*kb) > 10) -#endif + // reload now... + *kb = 0; + if (!(aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE)) { -#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 + // make them visible if not set... p->visibility = 0; - lastvisinc = totalclock + 32; - checkavailweapon(p); -#endif + lastvisinc = (int)totalclock + 32; } -#ifdef NAM - else if ((*kb) > aplWeaponReload[p->curr_weapon][snum]) // 30 - { - *kb = 0; - p->visibility = 0; - lastvisinc = totalclock + 32; - checkavailweapon(p); - } -#endif - else (*kb)++; + checkavailweapon(p); } break; + case SHRINKER_WEAPON: // m-79 in NAM (Grenade launcher) + if ((!isNam() && (*kb) > 10) || (isNam() && (*kb) == 10)) + { + if (isNam()) (*kb)++; // fire now, but wait for reload... + else (*kb) = 0; + + p->ammo_amount[SHRINKER_WEAPON]--; + fi.shoot(pi, SHRINKER); + + if (!isNam()) + { + p->visibility = 0; + //flashColor = 176 + (252 << 8) + (120 << 16); + lastvisinc = (int)totalclock + 32; + checkavailweapon(p); + } + } + else if (isNam() && (*kb) > 30) + { + *kb = 0; + p->visibility = 0; + lastvisinc = (int)totalclock + 32; + checkavailweapon(p); + } + 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; + lastvisinc = (int)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 + fi.shoot(pi, RPG); 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 + lastvisinc = (int)totalclock + 32; + fi.shoot(pi, FREEZEBLAST); checkavailweapon(p); } - if (s->xrepeat < 32) + if (sprite[p->i].xrepeat < 32) { *kb = 0; break; } @@ -3485,115 +2415,65 @@ static void operateweapon(int snum) 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 FLAMETHROWER_WEAPON: + if (!isWorldTour()) // Twentieth Anniversary World Tour + break; + (*kb)++; + if ((*kb) == 2) + { + if (sector[p->cursectnum].lotag != 2) + { + p->ammo_amount[FLAMETHROWER_WEAPON]--; + if (snum == screenpeek) + g_visibility = 0; + fi.shoot(pi, FIREBALL); + } + checkavailweapon(p); + } + else if ((*kb) == 16) + { + if ((sb_snum & SKB_FIRE) != 0) + { + *kb = 1; + spritesound(FLAMETHROWER_INTRO, pi); + } + 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 + fi.shoot(pi, HANDHOLDINGLASER); } -#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); + if ((*kb) == 7) fi.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); @@ -3601,42 +2481,18 @@ static void operateweapon(int snum) 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; + lastvisinc = (int)totalclock + 32; p->visibility = 0; - shoot(pi, RPG); + fi.shoot(pi, RPG); checkavailweapon(p); } else if (*kb == 20) *kb = 0; -#endif break; } -#endif } -#endif + END_DUKE_NS diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 042b726a6..69a5f0811 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -144,7 +144,7 @@ void shoot_r(int i, int atwith) { if (p >= 0) { - zvel = (100 - ps[p].gethorizdiff()) << 5; + zvel = (100 - ps[p].gethorizsum()) << 5; sz += (6 << 8); sa += 15; } @@ -323,7 +323,7 @@ void shoot_r(int i, int atwith) if (j == -1) { sa += 16 - (krand() & 31); - zvel = (100 - ps[p].gethorizdiff()) << 5; + zvel = (100 - ps[p].gethorizsum()) << 5; zvel += 128 - (krand() & 255); } } @@ -333,7 +333,7 @@ void shoot_r(int i, int atwith) sa += 64 - (krand() & 127); else sa += 16 - (krand() & 31); - if (j == -1) zvel = (100 - ps[p].gethorizdiff()) << 5; + if (j == -1) zvel = (100 - ps[p].gethorizsum()) << 5; zvel += 128 - (krand() & 255); } sz -= (2 << 8); @@ -592,7 +592,7 @@ void shoot_r(int i, int atwith) sa = getangle(sprite[j].x - sx, sprite[j].y - sy); } else - zvel = (100 - ps[p].gethorizdiff()) * 98; + zvel = (100 - ps[p].gethorizsum()) * 98; } else { @@ -683,7 +683,7 @@ void shoot_r(int i, int atwith) { sx += sintable[(s->ang + 512 + 160) & 2047] >> 7; sy += sintable[(s->ang + 160) & 2047] >> 7; - zvel = (100 - ps[p].gethorizdiff()) * 98; + zvel = (100 - ps[p].gethorizsum()) * 98; } } else @@ -794,7 +794,7 @@ void shoot_r(int i, int atwith) if (sprite[j].picnum != RECON) sa = getangle(sprite[j].x - sx, sprite[j].y - sy); } - else zvel = (100 - ps[p].gethorizdiff()) * 81; + else zvel = (100 - ps[p].gethorizsum()) * 81; if (atwith == RPG) spritesound(RPG_SHOOT, i); else if (isRRRA()) @@ -2768,25 +2768,27 @@ static void fireWeapon(int snum, int *kb) } } -#if 0 //--------------------------------------------------------------------------- // // // //--------------------------------------------------------------------------- -static void operateweapon(int snum, int sb_snum, int *kb) +static void operateweapon(int snum, int sb_snum, int psect, int *kb) { auto p = &ps[snum]; int pi = p->i; + int i, j, k; + int psectlotag = sector[psect].lotag; + if (!isRRRA() && p->curr_weapon > BOWLING_WEAPON) return; switch (p->curr_weapon) { - case HANDBOMB_WEAPON: + case DYNAMITE_WEAPON: if ((*kb) == 1) sound(401); - if ((*kb) == 6 && (sb_snum & (1 << 2))) + if ((*kb) == 6 && (sb_snum & SKB_FIRE)) p->rapid_fire_hold = 1; (*kb)++; if ((*kb) > 19) @@ -2795,8 +2797,8 @@ static void operateweapon(int snum, int sb_snum, int *kb) p->curr_weapon = HANDREMOTE_WEAPON; p->last_weapon = -1; p->weapon_pos = 10; - p->at57c = 45; - p->at57e = 1; + p->detonate_time = 45; + p->detonate_count = 1; sound(402); } @@ -2807,7 +2809,7 @@ static void operateweapon(int snum, int sb_snum, int *kb) (*kb)++; - if (p->at57c < 0) + if (p->detonate_time < 0) { p->hbomb_on = 0; } @@ -2815,34 +2817,30 @@ static void operateweapon(int snum, int sb_snum, int *kb) if ((*kb) == 39) { p->hbomb_on = 0; - p->at290 = 8192; + p->noise_radius = 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 + p->ammo_amount[DYNAMITE_WEAPON]--; + if (p->ammo_amount[CROSSBOW_WEAPON]) + p->ammo_amount[CROSSBOW_WEAPON]--; + if (p->on_ground && (sb_snum & SKB_CROUCH) && !p->OnMotorcycle) { k = 15; - i = ((p->horiz + p->horizoff - 100) * 20); + i = ((p->gethorizsum() - 100) * 20); } else { k = 140; - i = -512 - ((p->horiz + p->horizoff - 100) * 20); + i = -512 - ((p->gethorizsum() - 100) * 20); } j = EGS(p->cursectnum, - p->posx + (sintable[(p->ang + 512) & 2047] >> 6), - p->posy + (sintable[p->ang & 2047] >> 6), + p->posx + (sintable[(p->getang() + 512) & 2047] >> 6), + p->posy + (sintable[p->getang() & 2047] >> 6), p->posz, HEAVYHBOMB, -16, 9, 9, - p->ang, (k + (p->hbomb_hold_delay << 5)) * 2, i, pi, 1); + p->getang(), (k + (p->hbomb_hold_delay << 5)) * 2, i, pi, 1); if (k == 15) { @@ -2860,19 +2858,19 @@ static void operateweapon(int snum, int sb_snum, int *kb) p->hbomb_on = 1; } - else if ((*kb) < 12 && (sb_snum & 4)) + else if ((*kb) < 12 && (sb_snum & SKB_FIRE)) p->hbomb_hold_delay++; if ((*kb) == 40) { (*kb) = 0; - p->curr_weapon = HANDBOMB_WEAPON; + p->curr_weapon = DYNAMITE_WEAPON; p->last_weapon = -1; - p->at57e = 0; - p->at57c = 45; - if (p->ammo_amount[HANDBOMB_WEAPON] > 0) + p->detonate_count = 0; + p->detonate_time = 45; + if (p->ammo_amount[DYNAMITE_WEAPON] > 0) { - addweapon(p, HANDBOMB_WEAPON); + fi.addweapon(p, DYNAMITE_WEAPON); p->weapon_pos = -9; } else checkavailweapon(p); @@ -2882,17 +2880,17 @@ static void operateweapon(int snum, int sb_snum, int *kb) case PISTOL_WEAPON: if ((*kb) == 1) { - shoot(pi, SHOTSPARK1); + fi.shoot(pi, SHOTSPARK1); spritesound(PISTOL_FIRE, pi); - p->at290 = 8192; + p->noise_radius = 8192; madenoise(snum); - lastvisinc = totalclock + 32; + lastvisinc = (int)totalclock + 32; p->visibility = 0; if (psectlotag != 857) { - p->posxv -= sintable[(p->ang + 512) & 2047] << 4; - p->posyv -= sintable[p->ang & 2047] << 4; + p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; + p->posyv -= sintable[p->getang() & 2047] << 4; } } else if ((*kb) == 2) @@ -2941,49 +2939,49 @@ static void operateweapon(int snum, int sb_snum, int *kb) (*kb)++; if ((*kb) == 6) - if (p->at599 == 0) + if (p->shotgun_state[0] == 0) if (p->ammo_amount[SHOTGUN_WEAPON] > 1) - if (sb_snum & 4) - p->at59a = 1; + if (sb_snum & SKB_FIRE) + p->shotgun_state[1] = 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); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); p->ammo_amount[SHOTGUN_WEAPON]--; spritesound(SHOTGUN_FIRE, pi); - p->at290 = 8192; + p->noise_radius = 8192; madenoise(snum); - lastvisinc = totalclock + 32; + lastvisinc = (int)totalclock + 32; p->visibility = 0; } if (*kb == 7) { - if (p->at59a) + if (p->shotgun_state[1]) { - 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); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); + fi.shoot(pi, SHOTGUN); p->ammo_amount[SHOTGUN_WEAPON]--; @@ -2991,18 +2989,18 @@ static void operateweapon(int snum, int sb_snum, int *kb) if (psectlotag != 857) { - p->posxv -= sintable[(p->ang + 512) & 2047] << 5; - p->posyv -= sintable[p->ang & 2047] << 5; + p->posxv -= sintable[(p->getang() + 512) & 2047] << 5; + p->posyv -= sintable[p->getang() & 2047] << 5; } } else if (psectlotag != 857) { - p->posxv -= sintable[(p->ang + 512) & 2047] << 4; - p->posyv -= sintable[p->ang & 2047] << 4; + p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; + p->posyv -= sintable[p->getang() & 2047] << 4; } } - if (p->at599) + if (p->shotgun_state[0]) { switch (*kb) { @@ -3014,12 +3012,12 @@ static void operateweapon(int snum, int sb_snum, int *kb) break; case 28: *kb = 0; - p->at599 = 0; - p->at59a = 0; + p->shotgun_state[0] = 0; + p->shotgun_state[1] = 0; return; } } - else if (p->at59a) + else if (p->shotgun_state[1]) { switch (*kb) { @@ -3031,8 +3029,8 @@ static void operateweapon(int snum, int sb_snum, int *kb) break; case 38: *kb = 0; - p->at599 = 0; - p->at59a = 0; + p->shotgun_state[0] = 0; + p->shotgun_state[1] = 0; return; } } @@ -3043,28 +3041,28 @@ static void operateweapon(int snum, int sb_snum, int *kb) case 16: checkavailweapon(p); (*kb) = 0; - p->at599 = 1; - p->at59a = 0; + p->shotgun_state[0] = 1; + p->shotgun_state[1] = 0; return; } } break; - case CHAINGUN_WEAPON: + case RIFLEGUN_WEAPON: (*kb)++; - p->horiz++; - p->at59b++; + p->addhoriz(1); + p->recoil++; if ((*kb) <= 12) { if (((*kb) % 3) == 0) { - p->ammo_amount[CHAINGUN_WEAPON]--; + p->ammo_amount[RIFLEGUN_WEAPON]--; if (((*kb) % 3) == 0) { - j = spawn(pi, SHELL); + j = fi.spawn(pi, SHELL); sprite[j].ang += 1024; sprite[j].ang &= 2047; @@ -3074,20 +3072,20 @@ static void operateweapon(int snum, int sb_snum, int *kb) } spritesound(CHAINGUN_FIRE, pi); - shoot(pi, CHAINGUN); - p->at290 = 8192; + fi.shoot(pi, CHAINGUN); + p->noise_radius = 8192; madenoise(snum); - lastvisinc = totalclock + 32; + lastvisinc = (int)totalclock + 32; p->visibility = 0; if (psectlotag != 857) { - p->posxv -= sintable[(p->ang + 512) & 2047] << 4; - p->posyv -= sintable[p->ang & 2047] << 4; + p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; + p->posyv -= sintable[p->getang() & 2047] << 4; } checkavailweapon(p); - if ((sb_snum & (1 << 2)) == 0) + if ((sb_snum & SKB_FIRE) == 0) { *kb = 0; break; @@ -3096,104 +3094,101 @@ static void operateweapon(int snum, int sb_snum, int *kb) } else if ((*kb) > 10) { - if (sb_snum & (1 << 2)) *kb = 1; + if (sb_snum & SKB_FIRE) *kb = 1; else *kb = 0; } break; - case SHRINKER_WEAPON: - case GROW_WEAPON: + case BUZZSAW_WEAPON: - if (p->curr_weapon == GROW_WEAPON) + if ((*kb) > 3) { - 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; + *kb = 0; + if (screenpeek == snum) pus = 1; + fi.shoot(pi, GROWSPARK); + p->noise_radius = 1024; + madenoise(snum); + checkavailweapon(p); } + else (*kb)++; break; - case DEVISTATOR_WEAPON: + case THROWSAW_WEAPON: + + if ((*kb) == 1) + { + p->ammo_amount[SHRINKER_WEAPON]--; + fi.shoot(pi, SHRINKSPARK); + checkavailweapon(p); + } + (*kb)++; + if ((*kb) > 20) + *kb = 0; + break; + + case TIT_WEAPON: (*kb)++; if ((*kb) == 2 || (*kb) == 4) { p->visibility = 0; - lastvisinc = totalclock + 32; + lastvisinc = (int)totalclock + 32; spritesound(CHAINGUN_FIRE, pi); - shoot(pi, SHOTSPARK1); - p->at290 = 16384; + fi.shoot(pi, SHOTSPARK1); + p->noise_radius = 16384; madenoise(snum); - p->ammo_amount[DEVISTATOR_WEAPON]--; + p->ammo_amount[TIT_WEAPON]--; checkavailweapon(p); } if ((*kb) == 2) { - p->ang += 16; + p->addang(16); } else if ((*kb) == 4) { - p->ang -= 16; + p->addang(-16); } if ((*kb) > 4) (*kb) = 1; - if (!(sb_snum & 4)) + if (!(sb_snum & SKB_FIRE)) (*kb) = 0; break; -#ifdef RRRA - case RA13_WEAPON: + + case MOTORCYCLE_WEAPON: (*kb)++; if ((*kb) == 2 || (*kb) == 4) { p->visibility = 0; - lastvisinc = totalclock + 32; + lastvisinc = (int)totalclock + 32; spritesound(CHAINGUN_FIRE, pi); - shoot(pi, CHAINGUN); - p->at290 = 16384; + fi.shoot(pi, CHAINGUN); + p->noise_radius = 16384; madenoise(snum); - p->ammo_amount[RA13_WEAPON]--; - if (p->ammo_amount[RA13_WEAPON] <= 0) + p->ammo_amount[MOTORCYCLE_WEAPON]--; + if (p->ammo_amount[MOTORCYCLE_WEAPON] <= 0) (*kb) = 0; else checkavailweapon(p); } if ((*kb) == 2) { - p->ang += 4; + p->addang(4); } else if ((*kb) == 4) { - p->ang -= 4; + p->addang(-4); } if ((*kb) > 4) (*kb) = 1; - if (!(sb_snum & 4)) + if (!(sb_snum & SKB_FIRE)) (*kb) = 0; break; - case RA14_WEAPON: + case BOAT_WEAPON: if ((*kb) == 3) { p->MotoSpeed -= 20; - p->ammo_amount[RA14_WEAPON]--; - shoot(pi, RRTILE1790); + p->ammo_amount[BOAT_WEAPON]--; + fi.shoot(pi, RRTILE1790); } (*kb)++; if ((*kb) > 20) @@ -3201,112 +3196,102 @@ static void operateweapon(int snum, int sb_snum, int *kb) (*kb) = 0; checkavailweapon(p); } - if (p->ammo_amount[RA14_WEAPON] <= 0) + if (p->ammo_amount[BOAT_WEAPON] <= 0) (*kb) = 0; else checkavailweapon(p); break; - -#endif - case FREEZE_WEAPON: + case ALIENBLASTER_WEAPON: (*kb)++; if ((*kb) >= 7 && (*kb) <= 11) - shoot(pi, FIRELASER); + fi.shoot(pi, FIRELASER); if ((*kb) == 5) { spritesound(CAT_FIRE, pi); - p->at290 = 2048; + p->noise_radius = 2048; madenoise(snum); } else if ((*kb) == 9) { - p->ammo_amount[FREEZE_WEAPON]--; + p->ammo_amount[ALIENBLASTER_WEAPON]--; p->visibility = 0; - lastvisinc = totalclock + 32; + lastvisinc = (int)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; + p->posxv -= sintable[(p->getang() + 512) & 2047] << 4; + p->posyv -= sintable[p->getang() & 2047] << 4; + p->addhoriz(20); + p->recoil += 20; } if ((*kb) > 20) (*kb) = 0; break; - case TRIPBOMB_WEAPON: - case BOWLING_WEAPON: - if (p->curr_weapon == TRIPBOMB_WEAPON) + case POWDERKEG_WEAPON: + if ((*kb) == 3) { - if ((*kb) == 3) + p->ammo_amount[POWDERKEG_WEAPON]--; + p->gotweapon.Clear(POWDERKEG_WEAPON); + if (p->on_ground && (sb_snum & SKB_CROUCH) && !p->OnMotorcycle) { - 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); - } + k = 15; + i = ((p->gethorizsum() - 100) * 20); + } + else + { + k = 32; + i = -512 - ((p->gethorizsum() - 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); - } + j = EGS(p->cursectnum, + p->posx + (sintable[(p->getang() + 512) & 2047] >> 6), + p->posy + (sintable[p->getang() & 2047] >> 6), + p->posz, TRIPBOMBSPRITE, -16, 9, 9, + p->getang(), k * 2, i, pi, 1); } - else + (*kb)++; + if ((*kb) > 20) { - 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); - } + (*kb) = 0; + checkavailweapon(p); } break; + + case BOWLING_WEAPON: + if ((*kb) == 30) + { + p->ammo_amount[BOWLING_WEAPON]--; + spritesound(354, pi); + fi.shoot(pi, BOWLINGBALL); + p->noise_radius = 1024; + madenoise(snum); + } + if ((*kb) < 30) + { + p->posxv += sintable[(p->getang() + 512) & 2047] << 4; + p->posyv += sintable[p->getang() & 2047] << 4; + } + (*kb)++; + if ((*kb) > 40) + { + (*kb) = 0; + p->gotweapon.Clear(BOWLING_WEAPON); + checkavailweapon(p); + } + break; + case KNEE_WEAPON: (*kb)++; if ((*kb) == 3) spritesound(426, pi); if ((*kb) == 12) { - shoot(pi, KNEE); - p->at290 = 1024; + fi.shoot(pi, KNEE); + p->noise_radius = 1024; madenoise(snum); } else if ((*kb) == 16) @@ -3315,15 +3300,16 @@ static void operateweapon(int snum, int sb_snum, int *kb) if (p->wantweaponfire >= 0) checkavailweapon(p); break; -#ifdef RRRA - case RA15_WEAPON: + + + case SLINGBLADE_WEAPON: (*kb)++; if ((*kb) == 3) spritesound(252, pi); if ((*kb) == 8) { - shoot(pi, SLINGBLADE); - p->at290 = 1024; + fi.shoot(pi, SLINGBLADE); + p->noise_radius = 1024; madenoise(snum); } else if ((*kb) == 16) @@ -3332,19 +3318,18 @@ static void operateweapon(int snum, int sb_snum, int *kb) if (p->wantweaponfire >= 0) checkavailweapon(p); break; -#endif - case RPG_WEAPON: + case CROSSBOW_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->ammo_amount[CROSSBOW_WEAPON]--; + if (p->ammo_amount[DYNAMITE_WEAPON]) + p->ammo_amount[DYNAMITE_WEAPON]--; + lastvisinc = (int)totalclock + 32; p->visibility = 0; - shoot(pi, RPG); - p->at290 = 32768; + fi.shoot(pi, RPG); + p->noise_radius = 32768; madenoise(snum); checkavailweapon(p); } @@ -3353,16 +3338,16 @@ static void operateweapon(int snum, int sb_snum, int *kb) else if ((*kb) == 34) (*kb) = 0; break; -#ifdef RRRA - case RA16_WEAPON: + + case CHICKEN_WEAPON: (*kb)++; if ((*kb) == 4) { - p->ammo_amount[RA16_WEAPON]--; - lastvisinc = totalclock + 32; + p->ammo_amount[CHICKEN_WEAPON]--; + lastvisinc = (int)totalclock + 32; p->visibility = 0; - shoot(pi, RPG2); - p->at290 = 32768; + fi.shoot(pi, RPG2); + p->noise_radius = 32768; madenoise(snum); checkavailweapon(p); } @@ -3371,9 +3356,8 @@ static void operateweapon(int snum, int sb_snum, int *kb) else if ((*kb) == 34) (*kb) = 0; break; -#endif + } } -#endif END_DUKE_NS diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp new file mode 100644 index 000000000..9dd84c0e1 --- /dev/null +++ b/source/games/duke/src/player_w.cpp @@ -0,0 +1,550 @@ +//------------------------------------------------------------------------- +/* +Copyright (C) 1996, 2003 - 3D Realms Entertainment +Copyright (C) 2000, 2003 - Matt Saettler (EDuke Enhancements) + +This file is part of Enhanced Duke Nukem 3D version 1.5 - Atomic Edition + +Duke Nukem 3D is free software; you can redistribute it and/or +modify it under the terms of the GNU General Public License +as published by the Free Software Foundation; either version 2 +of the License, or (at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + +See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program; if not, write to the Free Software +Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +Original Source: 1996 - Todd Replogle +Prepared for public release: 03/21/2003 - Charlie Wiederhold, 3D Realms + +EDuke enhancements integrated: 04/13/2003 - Matt Saettler + +Note: EDuke source was in transition. Changes are in-progress in the +source as it is released. + +*/ +//------------------------------------------------------------------------- + + +#include "ns.h" +#include "global.h" +#include "game.h" +#include "gamevar.h" +#include "player.h" +#include "names.h" +#include "macros.h" + +BEGIN_DUKE_NS + +int operateTripbomb(int snum); + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void DoFire(struct player_struct *p, short snum) +{ + int i; + + if(aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) + { + p->ammo_amount[p->curr_weapon]--; + } + + if(aplWeaponFireSound[p->curr_weapon][snum]) + { + spritesound(aplWeaponFireSound[p->curr_weapon][snum],p->i); + } + + SetGameVarID(g_iWeaponVarID,p->curr_weapon,p->i,snum); + SetGameVarID(g_iWorksLikeVarID,aplWeaponWorksLike[p->curr_weapon][snum], p->i, snum); + fi.shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + for(i=1;icurr_weapon][snum];i++) + { + fi.shoot(p->i,aplWeaponShoots[p->curr_weapon][snum]); + if( aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_AMMOPERSHOT) + { + p->ammo_amount[p->curr_weapon]--; + } + } + + if(! (aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_NOVISIBLE )) + { + // make them visible if not set... + lastvisinc = (int)totalclock+32; + p->visibility = 0; + } + + 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) + ) + { + // do clip check... + p->kickback_pic=aplWeaponTotalTime[p->curr_weapon][snum]; + // is same as (*kb).... + } + + if(aplWeaponWorksLike[p->curr_weapon][snum]!=KNEE_WEAPON) + { + checkavailweapon(p); + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void DoSpawn(struct player_struct *p, short snum) +{ + int j; + if(!aplWeaponSpawn[p->curr_weapon][snum]) + return; + + j = fi.spawn(p->i, aplWeaponSpawn[p->curr_weapon][snum]); + + if((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE2 ) ) + { + // like shotgun shells + sprite[j].ang += 1024; + ssp(j,CLIPMASK0); + sprite[j].ang += 1024; +// p->kickback_pic++; + } + else if((aplWeaponFlags[p->curr_weapon][snum] & WEAPON_FLAG_SPAWNTYPE3 ) ) + { + // like chaingun shells + sprite[j].ang += 1024; + sprite[j].ang &= 2047; + sprite[j].xvel += 32; + sprite[j].z += (3<<8); + ssp(j,CLIPMASK0); + } + +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +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; + } + } + } +} + +//--------------------------------------------------------------------------- +// +// +// +//--------------------------------------------------------------------------- + +void operateweapon_ww(int snum, int sb_snum, int psect, int* kb) +{ + auto p = &ps[snum]; + int pi = p->i; + int i, j, k; + int psectlotag = sector[psect].lotag; + + // already firing... + 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 & SKB_CROUCH)) + { + k = 15; + i = ((p->gethorizsum() - 100) * 20); + } + else + { + k = 140; + i = -512 - ((p->gethorizsum() - 100) * 20); + } + + j = EGS(p->cursectnum, + p->posx + (sintable[(p->getang() + 512) & 2047] >> 6), + p->posy + (sintable[p->getang() & 2047] >> 6), + p->posz, HEAVYHBOMB, -16, 9, 9, + p->getang(), (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 & SKB_CROUCH)) + { + 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 = (int)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); + fi.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) + fi.addweapon(p, TRIPBOMB_WEAPON); + else + checkavailweapon(p); + } + + } + 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. +} + + +END_DUKE_NS diff --git a/source/games/duke/src/soundefs.h b/source/games/duke/src/soundefs.h index a151c73aa..59801fc8b 100644 --- a/source/games/duke/src/soundefs.h +++ b/source/games/duke/src/soundefs.h @@ -418,6 +418,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define JOKE 397 #define FLAMETHROWER_INTRO 398 #define FLAMETHROWER_LOOP 399 -#define FLAMETHROWER_END= 400 +#define FLAMETHROWER_END 400 #define E5L7_DUKE_QUIT_YOU 401 \ No newline at end of file diff --git a/source/games/duke/src/soundsdyn.h b/source/games/duke/src/soundsdyn.h index a7853b564..a0e064762 100644 --- a/source/games/duke/src/soundsdyn.h +++ b/source/games/duke/src/soundsdyn.h @@ -308,6 +308,10 @@ extern int32_t VOL4ENDSND2; extern int32_t EXPANDERSHOOT; extern int32_t INTRO4_B; extern int32_t BIGBANG; +#define FLAMETHROWER_INTRO 398 +#define FLAMETHROWER_LOOP 399 +#define FLAMETHROWER_END 400 +#define E5L7_DUKE_QUIT_YOU 401 #define DUKE_SHUCKS 47 // this was missing #define DYNAMICSOUNDMAP(Soundnum) (DynamicSoundMap[Soundnum]) diff --git a/source/games/duke/src/zz_player.cpp b/source/games/duke/src/zz_player.cpp index 12176882b..7e0959de2 100644 --- a/source/games/duke/src/zz_player.cpp +++ b/source/games/duke/src/zz_player.cpp @@ -2798,8 +2798,6 @@ void P_AddAmmo(DukePlayer_t * const pPlayer, int const weaponNum, int const addA pPlayer->ammo_amount[weaponNum] = max_ammo_amount[weaponNum]; } -void checkavailweapon(struct player_struct* p); - void P_AddWeapon(DukePlayer_t *pPlayer, int weaponNum) { fi.addweapon(pPlayer, weaponNum);