mirror of
https://github.com/DrBeef/Raze.git
synced 2025-01-18 23:21:43 +00:00
- weapon code cleaned up
This commit is contained in:
parent
1c29a44d3e
commit
df41875aa6
10 changed files with 947 additions and 1543 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
|
550
source/games/duke/src/player_w.cpp
Normal file
550
source/games/duke/src/player_w.cpp
Normal file
|
@ -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;i<aplWeaponShotsPerBurst[p->curr_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
|
|
@ -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
|
||||
|
|
@ -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])
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue