summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cgame/cg_event.c5
-rw-r--r--src/game/bg_misc.c65
-rw-r--r--src/game/bg_pmove.c205
-rw-r--r--src/game/bg_public.h7
-rw-r--r--src/game/g_active.c20
-rw-r--r--src/game/g_local.h1
-rw-r--r--src/game/g_weapon.c90
7 files changed, 285 insertions, 108 deletions
diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c
index 8ad2f3dd..250349c6 100644
--- a/src/cgame/cg_event.c
+++ b/src/cgame/cg_event.c
@@ -796,7 +796,10 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
DEBUGNAME("EV_FIRE_WEAPON2");
CG_FireWeapon( cent ); //FIXME:??
break;
-
+ case EV_FIRE_WEAPONBOTH:
+ DEBUGNAME("EV_FIRE_WEAPONBOTH");
+ CG_FireWeapon( cent ); //FIXME:??
+ break;
case EV_USE_ITEM0:
DEBUGNAME("EV_USE_ITEM0");
CG_UseItem( cent );
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 2a24d540..db9d804c 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -2524,7 +2524,9 @@ weaponAttributes_t bg_weapons[ ] =
"Rifle",
30,
3,
- 3
+ 3,
+ qfalse,
+ qfalse
},
{
WP_FLAMER,
@@ -2534,7 +2536,9 @@ weaponAttributes_t bg_weapons[ ] =
"Flame Thrower",
400,
0,
- 0
+ 0,
+ qfalse,
+ qfalse
},
{
WP_CHAINGUN,
@@ -2544,7 +2548,9 @@ weaponAttributes_t bg_weapons[ ] =
"Chaingun",
300,
0,
- 0
+ 0,
+ qfalse,
+ qfalse
},
{
WP_HBUILD,
@@ -2554,7 +2560,9 @@ weaponAttributes_t bg_weapons[ ] =
"Construction Kit",
0,
0,
- 0
+ 0,
+ qfalse,
+ qfalse
},
{
WP_ABUILD,
@@ -2564,7 +2572,9 @@ weaponAttributes_t bg_weapons[ ] =
"",
0,
0,
- 0
+ 0,
+ qfalse,
+ qfalse
},
{
WP_SCANNER,
@@ -2574,7 +2584,9 @@ weaponAttributes_t bg_weapons[ ] =
"Scanner",
0,
0,
- 0
+ 0,
+ qfalse,
+ qfalse
}
};
@@ -2703,6 +2715,46 @@ void BG_FindAmmoForWeapon( int weapon, int *quan, int *clips, int *maxClips )
}
}
+/*
+==============
+BG_WeaponHasAltMode
+==============
+*/
+qboolean BG_WeaponHasAltMode( int weapon )
+{
+ int i;
+
+ for( i = 0; i < bg_numWeapons; i++ )
+ {
+ if( bg_weapons[ i ].weaponNum == weapon )
+ {
+ return bg_weapons[ i ].hasAltMode;
+ }
+ }
+
+ return qfalse;
+}
+
+/*
+==============
+BG_WeaponModesAreSynced
+==============
+*/
+qboolean BG_WeaponModesAreSynced( int weapon )
+{
+ int i;
+
+ for( i = 0; i < bg_numWeapons; i++ )
+ {
+ if( bg_weapons[ i ].weaponNum == weapon )
+ {
+ return bg_weapons[ i ].synced;
+ }
+ }
+
+ return qfalse;
+}
+
////////////////////////////////////////////////////////////////////////////////
upgradeAttributes_t bg_upgrades[ ] =
@@ -3240,6 +3292,7 @@ char *eventnames[] = {
"EV_CHANGE_WEAPON",
"EV_FIRE_WEAPON",
"EV_FIRE_WEAPON2",
+ "EV_FIRE_WEAPONBOTH",
"EV_USE_ITEM0",
"EV_USE_ITEM1",
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index b0f5d67a..ba823830 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -2133,6 +2133,27 @@ static void PM_TorsoAnimation( void )
PM_ContinueTorsoAnim( TORSO_STAND );
}
+//synced alt weapons look like the way to go - simpler anyway...
+#if 0
+static void PM_packWeaponTime( int *psWeaponTime, int weaponTime1, int weaponTime2 )
+{
+ if( weaponTime1 < 0 && weaponTime2 >= 0 )
+ *psWeaponTime = ( *psWeaponTime & 0x00FF ) | ( ( ( weaponTime2 / 10 ) << 8 ) & 0xFF00 );
+ if( weaponTime2 < 0 && weaponTime1 >= 0 )
+ *psWeaponTime = ( ( weaponTime1 / 10 ) & 0x00FF ) | ( *psWeaponTime & 0xFF00 );
+ else if( weaponTime1 >= 0 && weaponTime2 >= 0 )
+ *psWeaponTime = ( ( weaponTime1 / 10 ) & 0x00FF ) | ( ( ( weaponTime2 / 10 ) << 8 ) & 0xFF00 );
+}
+
+static void PM_unpackWeaponTime( int psWeaponTime, int *weaponTime1, int *weaponTime2 )
+{
+ if( weaponTime1 != NULL )
+ *weaponTime1 = ( psWeaponTime & 0x00FF ) * 10;
+
+ if( weaponTime2 != NULL )
+ *weaponTime2 = ( ( psWeaponTime & 0x00FF ) >> 8 ) * 10;
+}
+#endif
/*
==============
@@ -2141,25 +2162,25 @@ PM_Weapon
Generates weapon events and modifes the weapon counter
==============
*/
-static void PM_Weapon( void ) {
+static void PM_Weapon( void )
+{
int addTime;
int ammo, clips, maxclips;
-
+
// don't allow attack until all buttons are up
- if ( pm->ps->pm_flags & PMF_RESPAWNED ) {
+ if ( pm->ps->pm_flags & PMF_RESPAWNED )
return;
- }
// ignore if spectator
- if ( pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR ) {
+ if ( pm->ps->persistant[PERS_TEAM] == TEAM_SPECTATOR )
return;
- }
- if( pm->ps->stats[ STAT_STATE ] & SS_INFESTING ) {
+
+ if( pm->ps->stats[ STAT_STATE ] & SS_INFESTING )
return;
- }
// check for dead player
- if ( pm->ps->stats[STAT_HEALTH] <= 0 ) {
+ if ( pm->ps->stats[STAT_HEALTH] <= 0 )
+ {
pm->ps->weapon = WP_NONE;
return;
}
@@ -2176,7 +2197,7 @@ static void PM_Weapon( void ) {
// check for weapon change
// can't change if weapon is firing, but can change
// again if lowering or raising
- if ( pm->ps->weaponTime <= 0 || pm->ps->weaponstate != WEAPON_FIRING )
+ if( pm->ps->weaponTime <= 0 || pm->ps->weaponstate != WEAPON_FIRING )
{
//TA: must press use to switch weapons
if( pm->cmd.buttons & BUTTON_USE_HOLDABLE )
@@ -2207,12 +2228,12 @@ static void PM_Weapon( void ) {
pm->ps->pm_flags &= ~PMF_USE_ITEM_HELD;
}
- if ( pm->ps->weaponTime > 0 ) {
+ if ( pm->ps->weaponTime > 0 )
return;
- }
// change weapon if time
- if ( pm->ps->weaponstate == WEAPON_DROPPING ) {
+ if ( pm->ps->weaponstate == WEAPON_DROPPING )
+ {
PM_FinishWeaponChange();
return;
}
@@ -2232,7 +2253,8 @@ static void PM_Weapon( void ) {
BG_unpackAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, &ammo, &clips, &maxclips );
// check for out of ammo
- if ( !ammo && !clips && !BG_infiniteAmmo( pm->ps->weapon ) ) {
+ if ( !ammo && !clips && !BG_infiniteAmmo( pm->ps->weapon ) )
+ {
PM_AddEvent( EV_NOAMMO );
pm->ps->weaponTime += 200;
return;
@@ -2296,6 +2318,41 @@ static void PM_Weapon( void ) {
break;
}
+ // fire weapon
+/* if( BG_WeaponHasAltMode( pm->ps->weapon ) )
+ {
+ if( BG_WeaponModesAreSynced( pm->ps->weapon ) )
+ {
+ if( ( pm->cmd.buttons & BUTTON_ATTACK ) && ( pm->cmd.buttons & BUTTON_ATTACK2 ) )
+ PM_AddEvent( EV_FIRE_WEAPONBOTH );
+ else if( pm->cmd.buttons & BUTTON_ATTACK2 )
+ PM_AddEvent( EV_FIRE_WEAPON2 );
+ else
+ PM_AddEvent( EV_FIRE_WEAPON );
+ }
+ else if( pm->cmd.buttons & BUTTON_ATTACK2 )
+ PM_AddEvent( EV_FIRE_WEAPON2 );
+ else
+ PM_AddEvent( EV_FIRE_WEAPON );
+ }
+ else
+ PM_AddEvent( EV_FIRE_WEAPON );*/
+
+ if( pm->cmd.buttons & BUTTON_ATTACK2 )
+ {
+ if( BG_WeaponHasAltMode( pm->ps->weapon ) )
+ {
+ if( BG_WeaponModesAreSynced( pm->ps->weapon ) && ( pm->cmd.buttons & BUTTON_ATTACK ) )
+ PM_AddEvent( EV_FIRE_WEAPONBOTH );
+ else
+ PM_AddEvent( EV_FIRE_WEAPON2 );
+ }
+ else
+ return;
+ }
+ else if( pm->cmd.buttons & BUTTON_ATTACK )
+ PM_AddEvent( EV_FIRE_WEAPON );
+
PM_StartTorsoAnim( TORSO_ATTACK );
pm->ps->weaponstate = WEAPON_FIRING;
@@ -2306,63 +2363,56 @@ static void PM_Weapon( void ) {
ammo--;
BG_packAmmoArray( pm->ps->weapon, pm->ps->ammo, pm->ps->powerups, ammo, clips, maxclips );
}
-
- // fire weapon
- if( pm->cmd.buttons & BUTTON_ATTACK ) PM_AddEvent( EV_FIRE_WEAPON );
- if( pm->cmd.buttons & BUTTON_ATTACK2 ) PM_AddEvent( EV_FIRE_WEAPON2 );
-
- switch( pm->ps->weapon ) {
- default:
- case WP_GAUNTLET:
- addTime = 400;
- break;
- case WP_LIGHTNING:
- addTime = 50;
- break;
- case WP_SHOTGUN:
- addTime = 1000;
- break;
- case WP_MACHINEGUN:
- addTime = 100;
- break;
- case WP_CHAINGUN:
- addTime = 50;
- break;
- case WP_GRENADE_LAUNCHER:
- addTime = 800;
- break;
- case WP_ROCKET_LAUNCHER:
- addTime = 800;
- break;
- case WP_FLAMER:
- addTime = 75;
- break;
- case WP_RAILGUN:
- addTime = 1500;
- break;
- case WP_BFG:
- addTime = 200;
- break;
- case WP_GRAPPLING_HOOK:
- addTime = 400;
- break;
- case WP_VENOM:
- addTime = 500;
- break;
- case WP_ABUILD:
- addTime = 1000;
- break;
- case WP_HBUILD:
- addTime = 1000;
- break;
- case WP_SCANNER:
- addTime = 1000; //abritutary since scaner doesn't "fire"
- break;
- }
-
- /*if ( pm->ps->powerups[PW_HASTE] ) {
- addTime /= 1.3;
- }*/
+
+ switch( pm->ps->weapon )
+ {
+ default:
+ case WP_GAUNTLET:
+ addTime = 400;
+ break;
+ case WP_LIGHTNING:
+ addTime = 50;
+ break;
+ case WP_SHOTGUN:
+ addTime = 1000;
+ break;
+ case WP_MACHINEGUN:
+ addTime = 200;
+ break;
+ case WP_CHAINGUN:
+ addTime = 50;
+ break;
+ case WP_GRENADE_LAUNCHER:
+ addTime = 800;
+ break;
+ case WP_ROCKET_LAUNCHER:
+ addTime = 800;
+ break;
+ case WP_FLAMER:
+ addTime = 70;
+ break;
+ case WP_RAILGUN:
+ addTime = 1500;
+ break;
+ case WP_BFG:
+ addTime = 200;
+ break;
+ case WP_GRAPPLING_HOOK:
+ addTime = 400;
+ break;
+ case WP_VENOM:
+ addTime = 500;
+ break;
+ case WP_ABUILD:
+ addTime = 1000;
+ break;
+ case WP_HBUILD:
+ addTime = 1000;
+ break;
+ case WP_SCANNER:
+ addTime = 1000; //abritutary since scaner doesn't "fire"
+ break;
+ }
if( pm->ps->weapon == WP_CHAINGUN )
{
@@ -2599,11 +2649,18 @@ void PmoveSingle (pmove_t *pmove)
// set the firing flag for continuous beam weapons
if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION
- && ( pm->cmd.buttons & BUTTON_ATTACK ) && ( ammo > 0 || clips > 0 ) ) {
+ && ( pm->cmd.buttons & BUTTON_ATTACK ) && ( ammo > 0 || clips > 0 ) )
pm->ps->eFlags |= EF_FIRING;
- } else {
+ else
pm->ps->eFlags &= ~EF_FIRING;
- }
+
+ // set the firing flag for continuous beam weapons
+ if ( !(pm->ps->pm_flags & PMF_RESPAWNED) && pm->ps->pm_type != PM_INTERMISSION
+ && ( pm->cmd.buttons & BUTTON_ATTACK2 ) && ( ammo > 0 || clips > 0 ) )
+ pm->ps->eFlags |= EF_FIRING2;
+ else
+ pm->ps->eFlags &= ~EF_FIRING2;
+
// clear the respawned flag if attack and use are cleared
if ( pm->ps->stats[STAT_HEALTH] > 0 &&
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index b2354531..094c7e12 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -282,6 +282,7 @@ typedef enum {
#define EF_AWARD_GAUNTLET 0x00000040 // draw a gauntlet sprite
#define EF_NODRAW 0x00000080 // may have an event, but no model (unspawned items)
#define EF_FIRING 0x00000100 // for lightning gun
+#define EF_FIRING2 0x00000200 // alt fire
#define EF_MOVER_STOP 0x00000400 // will push otherwise
#define EF_TALK 0x00001000 // draw a talk balloon
#define EF_CONNECTION 0x00002000 // draw a connection trouble sprite
@@ -450,6 +451,7 @@ typedef enum {
EV_CHANGE_WEAPON,
EV_FIRE_WEAPON,
EV_FIRE_WEAPON2,
+ EV_FIRE_WEAPONBOTH,
EV_USE_ITEM0,
EV_USE_ITEM1,
@@ -847,6 +849,9 @@ typedef struct
int quan;
int clips;
int maxClips;
+
+ qboolean hasAltMode;
+ qboolean synced;
} weaponAttributes_t;
//TA: upgrade record
@@ -917,6 +922,8 @@ char *BG_FindNameForWeapon( int weapon );
int BG_FindWeaponNumForName( char *name );
char *BG_FindHumanNameForWeapon( int weapon );
void BG_FindAmmoForWeapon( int weapon, int *quan, int *clips, int *maxClips );
+qboolean BG_WeaponHasAltMode( int weapon );
+qboolean BG_WeaponModesAreSynced( int weapon );
int BG_FindPriceForUpgrade( int upgrade );
int BG_FindSlotsForUpgrade( int upgrade );
diff --git a/src/game/g_active.c b/src/game/g_active.c
index dc981beb..935e88dd 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -360,17 +360,11 @@ void SpectatorThink( gentity_t *ent, usercmd_t *ucmd ) {
if( ( client->buttons & BUTTON_ATTACK ) && !( client->oldbuttons & BUTTON_ATTACK ) )
{
if( client->pers.pteam == PTE_NONE )
- {
G_AddPredictableEvent( ent, EV_MENU, MN_TEAM );
- }
else if( client->pers.pteam == PTE_DROIDS )
- {
G_AddPredictableEvent( ent, EV_MENU, MN_D_CLASS );
- }
else if( client->pers.pteam == PTE_HUMANS )
- {
G_AddPredictableEvent( ent, EV_MENU, MN_H_SPAWN );
- }
}
// attack button cycles through spectators
@@ -504,6 +498,7 @@ ClientIntermissionThink
void ClientIntermissionThink( gclient_t *client ) {
client->ps.eFlags &= ~EF_TALK;
client->ps.eFlags &= ~EF_FIRING;
+ client->ps.eFlags &= ~EF_FIRING2;
// the level will exit when everyone wants to or after timeouts
@@ -570,6 +565,11 @@ void ClientEvents( gentity_t *ent, int oldEventSequence ) {
FireWeapon2( ent );
break;
+ case EV_FIRE_WEAPONBOTH:
+ FireWeapon( ent );
+ FireWeapon2( ent );
+ break;
+
case EV_USE_ITEM1: // teleporter
// drop flags in CTF
item = NULL;
@@ -768,8 +768,7 @@ void ClientThink_real( gentity_t *ent ) {
//TA: slow player if standing in creep
for ( i = 1, creepNode = g_entities + i; i < level.num_entities; i++, creepNode++ )
{
- if( ( !Q_stricmp( creepNode->classname, "team_droid_spawn" ) ) ||
- ( !Q_stricmp( creepNode->classname, "team_droid_def1" ) ) )
+ if( creepNode->biteam == PTE_DROIDS )
{
VectorSubtract( client->ps.origin, creepNode->s.origin, temp_v );
@@ -887,9 +886,10 @@ void ClientThink_real( gentity_t *ent ) {
else {
BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue );
}
- if ( !( ent->client->ps.eFlags & EF_FIRING ) ) {
+ if( !( ent->client->ps.eFlags & EF_FIRING ) )
client->fireHeld = qfalse; // for grapple
- }
+ if( !( ent->client->ps.eFlags & EF_FIRING2 ) )
+ client->fire2Held = qfalse;
// use the snapped origin for linking so it matches client predicted versions
VectorCopy( ent->s.pos.trBase, ent->r.currentOrigin );
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 8e7107fa..1013ea83 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -321,6 +321,7 @@ struct gclient_s {
int lastKillTime; // for multiple kill rewards
qboolean fireHeld; // used for hook
+ qboolean fire2Held; // used for alt fire
gentity_t *hook; // grapple hook if out
int switchTeamTime; // time the player switched teams
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 7012e850..960f375e 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -601,9 +601,13 @@ void Weapon_Hbuild_Fire( gentity_t *ent )
}
///////build weapons
-//=====
-//VENOM
-//=====
+/*
+======================================================================
+
+VENOM
+
+======================================================================
+*/
/*
===============
@@ -760,8 +764,71 @@ FireWeapon2
*/
void FireWeapon2( gentity_t *ent )
{
- //just so i can do a cvs commit on compilable code before sleep
- Com_Printf( "Attack2 pressed\n" );
+ if( ent->client )
+ {
+ // set aiming directions
+ AngleVectors (ent->client->ps.viewangles, forward, right, up);
+ CalcMuzzlePoint( ent, forward, right, up, muzzle );
+ }
+ else
+ {
+ AngleVectors( ent->s.angles2, forward, right, up );
+ VectorCopy( ent->s.pos.trBase, muzzle );
+ }
+
+ // fire the specific weapon
+ switch( ent->s.weapon )
+ {
+ case WP_GAUNTLET:
+ Weapon_Gauntlet( ent );
+ break;
+ case WP_LIGHTNING:
+ Weapon_LightningFire( ent );
+ break;
+ case WP_SHOTGUN:
+ weapon_supershotgun_fire( ent );
+ break;
+ case WP_MACHINEGUN:
+ Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE, MOD_MACHINEGUN );
+ break;
+ case WP_CHAINGUN:
+ Bullet_Fire( ent, CHAINGUN_SPREAD, CHAINGUN_DAMAGE, MOD_CHAINGUN );
+ break;
+ case WP_GRENADE_LAUNCHER:
+ weapon_grenadelauncher_fire( ent );
+ break;
+ case WP_ROCKET_LAUNCHER:
+ Weapon_RocketLauncher_Fire( ent );
+ break;
+ case WP_FLAMER:
+ Weapon_Flamer_Fire( ent );
+ break;
+ case WP_PLASMAGUN:
+ Weapon_Plasma_Fire( ent );
+ break;
+ case WP_RAILGUN:
+ weapon_railgun_fire( ent );
+ break;
+ case WP_BFG:
+ BFG_Fire( ent );
+ break;
+ case WP_GRAPPLING_HOOK:
+ Weapon_GrapplingHook_Fire( ent );
+ break;
+ case WP_VENOM:
+ Weapon_Venom_Fire( ent );
+ break;
+ case WP_ABUILD:
+ Weapon_Abuild_Fire( ent );
+ break;
+ case WP_HBUILD:
+ Weapon_Hbuild_Fire( ent );
+ break;
+ case WP_SCANNER: //scanner doesn't "fire"
+ default:
+ // FIXME G_Error( "Bad ent->s.weapon" );
+ break;
+ }
}
/*
@@ -773,20 +840,13 @@ void FireWeapon( gentity_t *ent )
{
if( ent->client )
{
- // track shots taken for accuracy tracking. Grapple is not a weapon and gauntet is just not tracked
- if( ent->s.weapon != WP_GRAPPLING_HOOK && ent->s.weapon != WP_GAUNTLET ) {
- ent->client->accuracy_shots++;
- }
-
// set aiming directions
AngleVectors (ent->client->ps.viewangles, forward, right, up);
-
CalcMuzzlePoint( ent, forward, right, up, muzzle );
}
else
{
AngleVectors( ent->s.angles2, forward, right, up );
-
VectorCopy( ent->s.pos.trBase, muzzle );
}
@@ -803,11 +863,7 @@ void FireWeapon( gentity_t *ent )
weapon_supershotgun_fire( ent );
break;
case WP_MACHINEGUN:
- if ( g_gametype.integer != GT_TEAM ) {
- Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE, MOD_MACHINEGUN );
- } else {
- Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_TEAM_DAMAGE, MOD_MACHINEGUN );
- }
+ Bullet_Fire( ent, MACHINEGUN_SPREAD, MACHINEGUN_DAMAGE, MOD_MACHINEGUN );
break;
case WP_CHAINGUN:
Bullet_Fire( ent, CHAINGUN_SPREAD, CHAINGUN_DAMAGE, MOD_CHAINGUN );