summaryrefslogtreecommitdiff
path: root/src/game
diff options
context:
space:
mode:
Diffstat (limited to 'src/game')
-rw-r--r--src/game/bg_misc.c1
-rw-r--r--src/game/bg_pmove.c7
-rw-r--r--src/game/bg_public.h8
-rw-r--r--src/game/g_active.c7
-rw-r--r--src/game/g_buildable.c39
-rw-r--r--src/game/g_cmds.c85
-rw-r--r--src/game/g_combat.c15
-rw-r--r--src/game/g_local.h19
-rw-r--r--src/game/g_weapon.c81
-rw-r--r--src/game/tremulous.h5
10 files changed, 117 insertions, 150 deletions
diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c
index 3c4134fd..dcd33bf1 100644
--- a/src/game/bg_misc.c
+++ b/src/game/bg_misc.c
@@ -4394,7 +4394,6 @@ char *eventnames[ ] =
"EV_NOAMMO",
"EV_CHANGE_WEAPON",
- "EV_NEXT_WEAPON",
"EV_FIRE_WEAPON",
"EV_FIRE_WEAPON2",
"EV_FIRE_WEAPON3",
diff --git a/src/game/bg_pmove.c b/src/game/bg_pmove.c
index e349958d..bceba335 100644
--- a/src/game/bg_pmove.c
+++ b/src/game/bg_pmove.c
@@ -2587,6 +2587,7 @@ static void PM_BeginWeaponChange( int weapon )
PM_AddEvent( EV_CHANGE_WEAPON );
pm->ps->weaponstate = WEAPON_DROPPING;
pm->ps->weaponTime += 200;
+ pm->ps->persistant[ PERS_NEWWEAPON ] = weapon;
//reset build weapon
pm->ps->stats[ STAT_BUILDABLE ] = BA_NONE;
@@ -2605,7 +2606,7 @@ static void PM_FinishWeaponChange( void )
{
int weapon;
- weapon = pm->cmd.weapon;
+ weapon = pm->ps->persistant[ PERS_NEWWEAPON ];
if( weapon < WP_NONE || weapon >= WP_NUM_WEAPONS )
weapon = WP_NONE;
@@ -2716,10 +2717,10 @@ static void PM_Weapon( void )
pm->ps->pm_flags &= ~PMF_USE_ITEM_HELD;
//something external thinks a weapon change is necessary
- if( pm->ps->weapon != pm->cmd.weapon && pm->ps->pm_flags & PMF_WEAPON_SWITCH )
+ if( pm->ps->pm_flags & PMF_WEAPON_SWITCH )
{
pm->ps->pm_flags &= ~PMF_WEAPON_SWITCH;
- PM_BeginWeaponChange( pm->cmd.weapon );
+ PM_BeginWeaponChange( pm->ps->persistant[ PERS_NEWWEAPON ] );
}
}
diff --git a/src/game/bg_public.h b/src/game/bg_public.h
index 1104dccb..5055a632 100644
--- a/src/game/bg_public.h
+++ b/src/game/bg_public.h
@@ -257,9 +257,10 @@ typedef enum
//TA:
PERS_STATE,
- PERS_CREDIT, //TA: human credit
- PERS_BANK, //TA: human credit in the bank
- PERS_QUEUEPOS //TA: position in the spawn queue
+ PERS_CREDIT, // human credit
+ PERS_BANK, // human credit in the bank
+ PERS_QUEUEPOS, // position in the spawn queue
+ PERS_NEWWEAPON // weapon to switch to
} persEnum_t;
#define PS_WALLCLIMBINGFOLLOW 0x00000001
@@ -506,7 +507,6 @@ typedef enum
EV_NOAMMO,
EV_CHANGE_WEAPON,
- EV_NEXT_WEAPON,
EV_FIRE_WEAPON,
EV_FIRE_WEAPON2,
EV_FIRE_WEAPON3,
diff --git a/src/game/g_active.c b/src/game/g_active.c
index 581069cc..58667447 100644
--- a/src/game/g_active.c
+++ b/src/game/g_active.c
@@ -871,9 +871,6 @@ void ClientEvents( gentity_t *ent, int oldEventSequence )
BG_RemoveWeaponFromInventory( ent->s.weapon, ent->client->ps.stats );
- //force a weapon change
- ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
-
//switch to the first non blaster weapon
for( j = WP_NONE + 1; j < WP_NUM_WEAPONS; j++ )
{
@@ -882,14 +879,14 @@ void ClientEvents( gentity_t *ent, int oldEventSequence )
if( BG_InventoryContainsWeapon( j, ent->client->ps.stats ) )
{
- G_SendCommandFromServer( ent - g_entities, va( "weaponswitch %d", j ) );
+ G_ForceWeaponChange( ent, j );
break;
}
}
//only got the blaster to switch to
if( j == WP_NUM_WEAPONS )
- G_SendCommandFromServer( ent - g_entities, va( "weaponswitch %d", WP_BLASTER ) );
+ G_ForceWeaponChange( ent, WP_BLASTER );
//update ClientInfo
ClientUserinfoChanged( ent->client->ps.clientNum );
diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c
index 21a3d059..fef7697c 100644
--- a/src/game/g_buildable.c
+++ b/src/game/g_buildable.c
@@ -1457,12 +1457,12 @@ void ATrapper_Think( gentity_t *self )
/*
================
-HRpt_Think
+HRepeater_Think
Think for human power repeater
================
*/
-void HRpt_Think( gentity_t *self )
+void HRepeater_Think( gentity_t *self )
{
int i;
qboolean reactor = qfalse;
@@ -1499,43 +1499,20 @@ void HRpt_Think( gentity_t *self )
/*
================
-HRpt_Use
+HRepeater_Use
Use for human power repeater
================
*/
-void HRpt_Use( gentity_t *self, gentity_t *other, gentity_t *activator )
+void HRepeater_Use( gentity_t *self, gentity_t *other, gentity_t *activator )
{
- int maxAmmo, maxClips;
- weapon_t weapon;
- playerState_t *ps = &activator->client->ps;
-
- weapon = ps->weapon;
-
if( self->health <= 0 )
return;
if( !self->spawned )
return;
- if( activator->client->lastRefilTime + ENERGY_REFIL_TIME > level.time )
- return;
-
- if( !BG_FindUsesEnergyForWeapon( weapon ) )
- return;
-
- if( !BG_WeaponIsFull( weapon, ps->stats, ps->ammo, ps->powerups ) )
- {
- BG_FindAmmoForWeapon( weapon, &maxAmmo, &maxClips );
-
- if( BG_InventoryContainsUpgrade( UP_BATTPACK, ps->stats ) )
- maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
-
- BG_PackAmmoArray( weapon, ps->ammo, ps->powerups, maxAmmo, maxClips );
-
- G_AddEvent( activator, EV_RPTUSE_SOUND, 0 );
- activator->client->lastRefilTime = level.time;
- }
+ G_GiveClientMaxAmmo( self, qtrue );
}
@@ -2717,14 +2694,14 @@ gentity_t *G_buildItem( gentity_t *builder, buildable_t buildable, vec3_t origin
case BA_H_REACTOR:
built->think = HReactor_Think;
built->die = HSpawn_Die;
- built->use = HRpt_Use;
+ built->use = HRepeater_Use;
built->powered = built->active = qtrue;
break;
case BA_H_REPEATER:
- built->think = HRpt_Think;
+ built->think = HRepeater_Think;
built->die = HSpawn_Die;
- built->use = HRpt_Use;
+ built->use = HRepeater_Use;
built->count = -1;
break;
diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c
index 3451eadb..1df1f1ab 100644
--- a/src/game/g_cmds.c
+++ b/src/game/g_cmds.c
@@ -1379,11 +1379,7 @@ void Cmd_ActivateItem_f( gentity_t *ent )
if( upgrade != UP_NONE && BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) )
BG_ActivateUpgrade( upgrade, ent->client->ps.stats );
else if( weapon != WP_NONE && BG_InventoryContainsWeapon( weapon, ent->client->ps.stats ) )
- {
- //force a weapon change
- ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
- G_SendCommandFromServer( ent-g_entities, va( "weaponswitch %d", weapon ) );
- }
+ G_ForceWeaponChange( ent, weapon );
else
G_SendCommandFromServer( ent-g_entities, va( "print \"You don't have the %s\n\"", s ) );
}
@@ -1457,9 +1453,7 @@ void Cmd_ToggleItem_f( gentity_t *ent )
weapon = WP_BLASTER;
}
- //force a weapon change
- ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
- G_SendCommandFromServer( ent-g_entities, va( "weaponswitch %d", weapon ) );
+ G_ForceWeaponChange( ent, weapon );
}
else if( BG_InventoryContainsUpgrade( upgrade, ent->client->ps.stats ) )
{
@@ -1474,53 +1468,6 @@ void Cmd_ToggleItem_f( gentity_t *ent )
/*
=================
-G_GiveClientMaxAmmo
-=================
-*/
-static void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo )
-{
- int i;
- int maxAmmo, maxClips;
- qboolean weaponType;
-
- for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
- {
- if( buyingEnergyAmmo )
- weaponType = BG_FindUsesEnergyForWeapon( i );
- else
- weaponType = !BG_FindUsesEnergyForWeapon( i );
-
- if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
- weaponType && !BG_FindInfinteAmmoForWeapon( i ) &&
- !BG_WeaponIsFull( i, ent->client->ps.stats,
- ent->client->ps.ammo, ent->client->ps.powerups ) )
- {
- BG_FindAmmoForWeapon( i, &maxAmmo, &maxClips );
-
- if( buyingEnergyAmmo )
- {
- G_AddEvent( ent, EV_RPTUSE_SOUND, 0 );
- ent->client->lastRefilTime = level.time;
-
- if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
- maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
- }
- else
- G_AddEvent( ent, EV_CHANGE_WEAPON, 0 );
-
- BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups,
- maxAmmo, maxClips );
-
- //force a weapon change
- //FIXME: needs to work even if weapon is the same
- //ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
- //G_SendCommandFromServer( ent-g_entities, va( "weaponswitch %d", ent->client->ps.weapon ) );
- }
- }
-}
-
-/*
-=================
Cmd_Buy_f
=================
*/
@@ -1632,9 +1579,7 @@ void Cmd_Buy_f( gentity_t *ent )
BG_PackAmmoArray( weapon, ent->client->ps.ammo, ent->client->ps.powerups,
maxAmmo, maxClips );
- //force a weapon change
- ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
- G_SendCommandFromServer( ent-g_entities, va( "weaponswitch %d", weapon ) );
+ G_ForceWeaponChange( ent, weapon );
//set build delay/pounce etc to 0
ent->client->ps.stats[ STAT_MISC ] = 0;
@@ -1711,10 +1656,6 @@ void Cmd_Buy_f( gentity_t *ent )
G_SendCommandFromServer( ent-g_entities, va( "print \"Unknown item\n\"" ) );
}
- //if the buyer previously had no items at all, force a new selection
- if( numItems == 0 )
- G_AddEvent( ent, EV_NEXT_WEAPON, ent->client->ps.clientNum );
-
if( trap_Argc( ) >= 2 )
{
trap_Argv( 2, s, sizeof( s ) );
@@ -1784,11 +1725,7 @@ void Cmd_Sell_f( gentity_t *ent )
//if we have this weapon selected, force a new selection
if( weapon == ent->client->ps.weapon )
- {
- //force a weapon change
- ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
- G_SendCommandFromServer( ent-g_entities, va( "weaponswitch %d", WP_BLASTER ) );
- }
+ G_ForceWeaponChange( ent, WP_NONE );
}
else if( upgrade != UP_NONE )
{
@@ -1809,10 +1746,6 @@ void Cmd_Sell_f( gentity_t *ent )
//add to funds
G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( upgrade ), qfalse );
}
-
- //if we have this upgrade selected, force a new selection
- if( upgrade == ent->client->pers.cmd.weapon - 32 )
- G_AddEvent( ent, EV_NEXT_WEAPON, ent->client->ps.clientNum );
}
else if( !Q_stricmp( s, "weapons" ) )
{
@@ -1837,11 +1770,7 @@ void Cmd_Sell_f( gentity_t *ent )
//if we have this weapon selected, force a new selection
if( i == ent->client->ps.weapon )
- {
- //force a weapon change
- ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
- G_SendCommandFromServer( ent-g_entities, va( "weaponswitch %d", WP_BLASTER ) );
- }
+ G_ForceWeaponChange( ent, WP_NONE );
}
}
else if( !Q_stricmp( s, "upgrades" ) )
@@ -1873,10 +1802,6 @@ void Cmd_Sell_f( gentity_t *ent )
//add to funds
G_AddCreditToClient( ent->client, (short)BG_FindPriceForUpgrade( i ), qfalse );
}
-
- //if we have this upgrade selected, force a new selection
- if( i == ent->client->pers.cmd.weapon - 32 )
- G_AddEvent( ent, EV_NEXT_WEAPON, ent->client->ps.clientNum );
}
}
else
diff --git a/src/game/g_combat.c b/src/game/g_combat.c
index 3df21614..29032050 100644
--- a/src/game/g_combat.c
+++ b/src/game/g_combat.c
@@ -227,12 +227,6 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
AddScore( attacker, 1 );
attacker->client->lastKillTime = level.time;
-
- if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
- trap_Cvar_Set( "g_alienKills", va( "%d", g_alienKills.integer + 1 ) );
- else if( attacker->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
- trap_Cvar_Set( "g_humanKills", va( "%d", g_humanKills.integer + 1 ) );
-
}
}
else if( attacker->s.eType != ET_BUILDABLE )
@@ -242,6 +236,15 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int
for( i = 0; i < MAX_CLIENTS; i++ )
totalDamage += (float)self->credits[ i ];
+ // if players did more than DAMAGE_FRACTION_FOR_KILL increment the stage counters
+ if( totalDamage >= ( self->client->ps.stats[ STAT_MAX_HEALTH ] * DAMAGE_FRACTION_FOR_KILL ) )
+ {
+ if( self->client->ps.stats[ STAT_PTEAM ] == PTE_HUMANS )
+ trap_Cvar_Set( "g_alienKills", va( "%d", g_alienKills.integer + 1 ) );
+ else if( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
+ trap_Cvar_Set( "g_humanKills", va( "%d", g_humanKills.integer + 1 ) );
+ }
+
if( totalDamage > 0.0f )
{
if( self->client->ps.stats[ STAT_PTEAM ] == PTE_ALIENS )
diff --git a/src/game/g_local.h b/src/game/g_local.h
index 63a4970e..4642686a 100644
--- a/src/game/g_local.h
+++ b/src/game/g_local.h
@@ -421,8 +421,6 @@ struct gclient_s
int lastFlameBall; //TA: s.number of the last flame ball fired
- int lastRefilTime; //TA: last time human got a refil from rpt/rctr
-
#define RAM_FRAMES 1 //TA: number of frames to wait before retriggering
int retriggerArmouryMenu; //TA: frame number to retrigger the armoury menu
};
@@ -796,21 +794,6 @@ void ShineTorch( gentity_t *self );
// g_weapon.c
//
-/*typedef struct zap_s
-{
- qboolean used;
-
- gentity_t *creator;
- gentity_t *source;
- gentity_t *target;
-
- int timeToLive;
-
- int depth;
-
- gentity_t *effectTempEnt;
-} zap_t;*/
-
#define MAX_ZAP_TARGETS LEVEL2_AREAZAP_MAX_TARGETS
typedef struct zap_s
@@ -826,6 +809,8 @@ typedef struct zap_s
gentity_t *effectChannel;
} zap_t;
+void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon );
+void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo );
void CalcMuzzlePoint( gentity_t *ent, vec3_t forward, vec3_t right, vec3_t up, vec3_t muzzlePoint );
void SnapVectorTowards( vec3_t v, vec3_t to );
qboolean CheckVenomAttack( gentity_t *ent );
diff --git a/src/game/g_weapon.c b/src/game/g_weapon.c
index 1dbd5c15..997d0f7a 100644
--- a/src/game/g_weapon.c
+++ b/src/game/g_weapon.c
@@ -21,7 +21,86 @@
static vec3_t forward, right, up;
static vec3_t muzzle;
-#define NUM_NAILSHOTS 15
+/*
+================
+G_ForceWeaponChange
+================
+*/
+void G_ForceWeaponChange( gentity_t *ent, weapon_t weapon )
+{
+ int i;
+
+ if( ent )
+ {
+ ent->client->ps.pm_flags |= PMF_WEAPON_SWITCH;
+
+ if( weapon == WP_NONE )
+ {
+ //switch to the first non blaster weapon
+ for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
+ {
+ if( i == WP_BLASTER )
+ continue;
+
+ if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) )
+ {
+ ent->client->ps.persistant[ PERS_NEWWEAPON ] = i;
+ break;
+ }
+ }
+
+ //only got the blaster to switch to
+ if( i == WP_NUM_WEAPONS )
+ ent->client->ps.persistant[ PERS_NEWWEAPON ] = WP_BLASTER;
+ }
+ else
+ ent->client->ps.persistant[ PERS_NEWWEAPON ] = weapon;
+ }
+}
+
+/*
+=================
+G_GiveClientMaxAmmo
+=================
+*/
+void G_GiveClientMaxAmmo( gentity_t *ent, qboolean buyingEnergyAmmo )
+{
+ int i;
+ int maxAmmo, maxClips;
+ qboolean weaponType, restoredAmmo = qfalse;
+
+ for( i = WP_NONE + 1; i < WP_NUM_WEAPONS; i++ )
+ {
+ if( buyingEnergyAmmo )
+ weaponType = BG_FindUsesEnergyForWeapon( i );
+ else
+ weaponType = !BG_FindUsesEnergyForWeapon( i );
+
+ if( BG_InventoryContainsWeapon( i, ent->client->ps.stats ) &&
+ weaponType && !BG_FindInfinteAmmoForWeapon( i ) &&
+ !BG_WeaponIsFull( i, ent->client->ps.stats,
+ ent->client->ps.ammo, ent->client->ps.powerups ) )
+ {
+ BG_FindAmmoForWeapon( i, &maxAmmo, &maxClips );
+
+ if( buyingEnergyAmmo )
+ {
+ G_AddEvent( ent, EV_RPTUSE_SOUND, 0 );
+
+ if( BG_InventoryContainsUpgrade( UP_BATTPACK, ent->client->ps.stats ) )
+ maxAmmo = (int)( (float)maxAmmo * BATTPACK_MODIFIER );
+ }
+
+ BG_PackAmmoArray( i, ent->client->ps.ammo, ent->client->ps.powerups,
+ maxAmmo, maxClips );
+
+ restoredAmmo = qtrue;
+ }
+ }
+
+ if( restoredAmmo )
+ G_ForceWeaponChange( ent, ent->client->ps.weapon );
+}
/*
================
diff --git a/src/game/tremulous.h b/src/game/tremulous.h
index 98fb60de..1d994313 100644
--- a/src/game/tremulous.h
+++ b/src/game/tremulous.h
@@ -530,8 +530,6 @@
#define REPEATER_SPLASHRADIUS 100
#define REPEATER_INACTIVE_TIME 90000
-#define ENERGY_REFIL_TIME 1000 //1/2 second between every clip refil
-
/*
* HUMAN misc
*/
@@ -567,3 +565,6 @@
#define DEFAULT_ALIEN_BUILDPOINTS "100"
#define DEFAULT_HUMAN_BUILDPOINTS "100"
+
+#define DAMAGE_FRACTION_FOR_KILL 0.5f //how much damage players (versus structures) need to
+ //do to increment the stage kill counters