From 27a16fb1fa69d458fb10e6437eb07b85496b46b8 Mon Sep 17 00:00:00 2001 From: Paweł Redman Date: Mon, 9 Sep 2013 00:42:43 +0200 Subject: 0.1.2 and code cleanup --- src/cgame/cg_buildable.c | 206 ++++++++++++++++++++++++----------------------- src/cgame/cg_event.c | 16 +++- src/cgame/cg_local.h | 12 ++- src/cgame/cg_main.c | 12 ++- src/cgame/cg_weapons.c | 3 +- src/game/bg_misc.c | 13 ++- src/game/bg_public.h | 3 +- src/game/g_active.c | 7 +- src/game/g_cmds.c | 11 +++ src/game/g_combat.c | 48 ++++++----- 10 files changed, 192 insertions(+), 139 deletions(-) (limited to 'src') diff --git a/src/cgame/cg_buildable.c b/src/cgame/cg_buildable.c index 7b5b85d..b1d40b0 100644 --- a/src/cgame/cg_buildable.c +++ b/src/cgame/cg_buildable.c @@ -2127,83 +2127,85 @@ Server responded to our cb with either cb2 or cb3. */ void CG_Cuboid_Response(void) { - // cb2 : server sets client-side cuboid - // cb3 : server agrees on player's cuboid - // cb3 : server doesnt agree on player's cuboid and corrects it - static qboolean init=qfalse; - if(!BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid) - return; - if(!Q_stricmp(CG_Argv(0),"cb2")&&trap_Argc()==4) - { - cg.cuboidSelection[0]=atof(CG_Argv(1)); - cg.cuboidSelection[1]=atof(CG_Argv(2)); - cg.cuboidSelection[2]=atof(CG_Argv(3)); - return; - } - else if(!Q_stricmp(CG_Argv(0),"cb3")) - { - if(trap_Argc()==2) + // cb2 : server sets client-side cuboid + // cb3 : server agrees on player's cuboid + // cb3 : server doesnt agree on player's cuboid and corrects it + static qboolean init = qfalse; + + if( !BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid ) + return; + + if( !Q_stricmp( CG_Argv( 0 ), "cb2" ) && trap_Argc( ) == 4 ) { - if(atoi(CG_Argv(1))==cg.latestCBNumber) - cg.forbidCuboids=qfalse; - return; + cg.cuboidSelection[ 0 ] = atof( CG_Argv( 1 ) ); + cg.cuboidSelection[ 1 ] = atof( CG_Argv( 2 ) ); + cg.cuboidSelection[ 2 ] = atof( CG_Argv( 3 ) ); + return; } - else if(trap_Argc()==5) + else if( !Q_stricmp( CG_Argv( 0 ), "cb3" ) ) { - cg.cuboidSelection[0]=atof(CG_Argv(2)); - cg.cuboidSelection[1]=atof(CG_Argv(3)); - cg.cuboidSelection[2]=atof(CG_Argv(4)); - if(atoi(CG_Argv(1))==cg.latestCBNumber) - { - cg.forbidCuboids=qfalse; - if(cg.lastCuboidError+250cuboid) - return; - VectorCopy(cg.cuboidSelection,dims); - switch(cg_cuboidResizeAxis.integer) - { - case 0: - dims[0]+=rate; - break; - case 1: - dims[1]+=rate; - break; - default: - dims[2]+=rate; - break; - } - if(dims[0]<1||dims[1]<1||dims[2]<1|| - dims[0]*dims[1]*dims[2]cuboid ) + return; + + VectorCopy( cg.cuboidSelection, dims ); + switch( cg_cuboidResizeAxis.integer ) + { + case 0: + dims[ 0 ] += rate; + break; + case 1: + dims[ 1 ] += rate; + break; + default: + dims[ 2 ] += rate; + break; + } + + if( dims[ 0 ] * dims[ 1 ] * dims[ 2 ] < CUBOID_MINVOLUME ) + return; + + if( enlarge ) + trap_S_StartLocalSound( cgs.media.cuboidResizeSoundA, CHAN_LOCAL_SOUND ); + else + trap_S_StartLocalSound( cgs.media.cuboidResizeSoundB, CHAN_LOCAL_SOUND ); + + VectorCopy( dims, cg.cuboidSelection ); } /* @@ -2218,25 +2220,24 @@ Syntax: #define SWAPFLOATS(a,b) {float __t;__t=a,a=b,b=__t;} void CG_CuboidRotate_f(void) { - int axis; + int axis; - if(!BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid) - return; - axis=cg_cuboidResizeAxis.integer; - switch(axis) - { - case 0: - SWAPFLOATS(cg.cuboidSelection[1],cg.cuboidSelection[2]); - break; - case 1: - SWAPFLOATS(cg.cuboidSelection[2],cg.cuboidSelection[0]); - break; - case 2: - SWAPFLOATS(cg.cuboidSelection[0],cg.cuboidSelection[1]); - break; - } - trap_S_StartLocalSound(cgs.media.cuboidRotateSound,CHAN_LOCAL_SOUND); - CG_Cuboid_Send(); + if( !BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid ) + return; + switch( cg_cuboidResizeAxis.integer ) + { + case 0: + SWAPFLOATS( cg.cuboidSelection[ 1 ], cg.cuboidSelection[ 2 ] ); + break; + case 1: + SWAPFLOATS( cg.cuboidSelection[ 2 ], cg.cuboidSelection[ 0 ] ); + break; + case 2: + SWAPFLOATS( cg.cuboidSelection[ 0 ], cg.cuboidSelection[ 1 ] ); + break; + } + trap_S_StartLocalSound( cgs.media.cuboidRotateSound, CHAN_LOCAL_SOUND ); + CG_Cuboid_Send( ); } /* @@ -2251,22 +2252,22 @@ Syntax: */ void CG_CuboidAxis_f(void) { - int axis; + int axis; - axis=cg_cuboidResizeAxis.integer; - if(!BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid) - return; - if(!CG_Argv(1)) - { - Com_Printf("cuboidAxis next|0|1|2 : set axis on which you want to resize your cuboid selection (0 - X, 1 - Y, 2 - Z)\n"); - return; - } - if(!Q_stricmp(CG_Argv(1),"next")) - axis++; - else - axis=atoi(CG_Argv(1)); - trap_Cvar_Set("cg_cuboidResizeAxis",va("%i",(axis+3)%3)); - trap_S_StartLocalSound(cgs.media.cuboidAxisChangeSound,CHAN_LOCAL_SOUND); + axis = cg_cuboidResizeAxis.integer; + if( !BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid) + return; + if( !CG_Argv( 1 ) ) + { + Com_Printf( "cuboidAxis next|0|1|2 : set axis on which you want to resize your cuboid selection (0 - X, 1 - Y, 2 - Z)\n" ); + return; + } + if( !Q_stricmp( CG_Argv( 1 ), "next" ) ) + axis++; + else + axis = atoi( CG_Argv( 1 ) ); + trap_Cvar_Set( "cg_cuboidResizeAxis", va( "%i" , ( axis + 3 ) % 3 ) ); + trap_S_StartLocalSound( cgs.media.cuboidAxisChangeSound, CHAN_LOCAL_SOUND ); } /* @@ -2280,11 +2281,12 @@ Otherwise send the normal +attack / -attack; */ void CG_CuboidAttack_f(void) { - if(BG_Buildable(cg.predictedPlayerState.stats[STAT_BUILDABLE]&~SB_VALID_TOGGLEBIT,NULL)->cuboid&&cg.forbidCuboids) - { - trap_S_StartLocalSound(cgs.media.cuboidErrorSound,CHAN_LOCAL_SOUND); - return; - } - trap_SendClientCommand(va("%s",CG_Argv(0))); + if( BG_Buildable( cg.predictedPlayerState.stats[ STAT_BUILDABLE ] & ~SB_VALID_TOGGLEBIT, NULL )->cuboid && + cg.forbidCuboids ) + { + trap_S_StartLocalSound( cgs.media.cuboidErrorSound, CHAN_LOCAL_SOUND ); + return; + } + trap_SendClientCommand( va( "%s", CG_Argv(0) ) ); } diff --git a/src/cgame/cg_event.c b/src/cgame/cg_event.c index ec7b9a6..40df8b9 100644 --- a/src/cgame/cg_event.c +++ b/src/cgame/cg_event.c @@ -322,6 +322,12 @@ static void CG_Obituary( entityState_t *ent ) message = "was crushed under"; message2 = "'s weight"; break; + case MOD_LEVEL4_BOMB: + message = "was bombed by"; + Com_sprintf( className, 64, "'s %s", + BG_ClassConfig( PCL_ALIEN_LEVEL4 )->humanName ); + message2 = className; + break; case MOD_POISON: message = "should have used a medkit against"; @@ -966,7 +972,15 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) break; case EV_MGTURRET_SPINUP: - trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretSpinupSound ); + if( random() >= 0.5f ) + trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretSpinupSoundA ); + else + trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretSpinupSoundB ); + break; + + + case EV_MGTURRET_KILL: + trap_S_StartSound( NULL, es->number, CHAN_AUTO, cgs.media.turretKillSound ); break; case EV_OVERMIND_SPAWNS: diff --git a/src/cgame/cg_local.h b/src/cgame/cg_local.h index 95a6569..11133bf 100644 --- a/src/cgame/cg_local.h +++ b/src/cgame/cg_local.h @@ -1240,8 +1240,10 @@ typedef struct sfxHandle_t humanTalkSound; sfxHandle_t landSound; sfxHandle_t fallSound; - sfxHandle_t turretSpinupSound; - + sfxHandle_t turretSpinupSoundA; + sfxHandle_t turretSpinupSoundB; + sfxHandle_t turretKillSound; + sfxHandle_t hardBounceSound1; sfxHandle_t hardBounceSound2; @@ -1606,6 +1608,7 @@ extern vmCvar_t cg_emoticons; extern vmCvar_t cg_chatTeamPrefix; extern vmCvar_t cg_cuboidResizeAxis; +extern vmCvar_t cg_cuboidResizeRate; extern vmCvar_t cg_cuboidPSQuality; extern vmCvar_t cg_cuboidInfoX; extern vmCvar_t cg_cuboidInfoY; @@ -2168,10 +2171,11 @@ typedef enum // mod version data -#define MODVER_CURRENT 2 +#define MODVER_CURRENT 3 +#define MODVER_C2_0_1_2 3 #define MODVER_C2_0_1_1 2 #define MODVER_C2_0_1_0 1 -#define MODVER_TITLE "0.1.1 (Sep 07)" +#define MODVER_TITLE "0.1.2 (Sep 09)" diff --git a/src/cgame/cg_main.c b/src/cgame/cg_main.c index 48df981..4191cc7 100644 --- a/src/cgame/cg_main.c +++ b/src/cgame/cg_main.c @@ -228,6 +228,7 @@ vmCvar_t cg_emoticons; vmCvar_t cg_chatTeamPrefix; vmCvar_t cg_cuboidResizeAxis; +vmCvar_t cg_cuboidResizeRate; vmCvar_t cg_cuboidPSQuality; vmCvar_t cg_cuboidInfoX; vmCvar_t cg_cuboidInfoY; @@ -370,10 +371,11 @@ static cvarTable_t cvarTable[ ] = { &cg_emoticons, "cg_emoticons", "1", CVAR_LATCH|CVAR_ARCHIVE}, - { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE}, + { &cg_chatTeamPrefix, "cg_chatTeamPrefix", "1", CVAR_ARCHIVE }, - { &cg_cuboidResizeAxis, "cg_cuboidResizeAxis", "2", 0}, - { &cg_cuboidPSQuality, "cg_cuboidPSQuality", "3", CVAR_ARCHIVE}, + { &cg_cuboidResizeAxis, "cg_cuboidResizeAxis", "2", 0 }, + { &cg_cuboidResizeRate, "cg_cuboidResizeRate", "5", CVAR_ARCHIVE }, + { &cg_cuboidPSQuality, "cg_cuboidPSQuality", "3", CVAR_ARCHIVE }, { &cg_cuboidInfoX, "cg_cuboidInfoX" ,"0", CVAR_ARCHIVE }, { &cg_cuboidInfoY, "cg_cuboidInfoY" ,"150", CVAR_ARCHIVE }, @@ -655,7 +657,9 @@ static void CG_RegisterSounds( void ) cgs.media.tracerSound = trap_S_RegisterSound( "sound/weapons/tracer.wav", qfalse ); cgs.media.selectSound = trap_S_RegisterSound( "sound/weapons/change.wav", qfalse ); - cgs.media.turretSpinupSound = trap_S_RegisterSound( "sound/buildables/mgturret/spinup.wav", qfalse ); + cgs.media.turretSpinupSoundA = trap_S_RegisterSound( "sound/buildables/mgturret/spinup_a.wav", qfalse ); + cgs.media.turretSpinupSoundB = trap_S_RegisterSound( "sound/buildables/mgturret/spinup_b.wav", qfalse ); + cgs.media.turretKillSound = trap_S_RegisterSound( "sound/buildables/mgturret/turretkill_a.wav", qfalse ); cgs.media.weaponEmptyClick = trap_S_RegisterSound( "sound/weapons/click.wav", qfalse ); cgs.media.talkSound = trap_S_RegisterSound( "sound/misc/talk.wav", qfalse ); diff --git a/src/cgame/cg_weapons.c b/src/cgame/cg_weapons.c index 2bb23ff..f844f81 100644 --- a/src/cgame/cg_weapons.c +++ b/src/cgame/cg_weapons.c @@ -1765,8 +1765,7 @@ void CG_MissileHitEntity( weapon_t weaponNum, weaponMode_t weaponMode, if( weaponMode <= WPM_NONE || weaponMode >= WPM_NUM_WEAPONMODES ) weaponMode = WPM_PRIMARY; - // always impact! - //if( weapon->wim[ weaponMode ].alwaysImpact ) + if( weapon->wim[ weaponMode ].alwaysImpact ) { int sound; diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 58152f4..3b667a9 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -2997,6 +2997,7 @@ char *eventnames[ ] = "EV_FALLING", "EV_JUMP", + "EV_JETJUMP", "EV_WATER_TOUCH", // foot touches "EV_WATER_LEAVE", // foot leaves "EV_WATER_UNDER", // head touches @@ -3048,6 +3049,7 @@ char *eventnames[ ] = "EV_BUILD_REPAIRED", // buildable has full health "EV_HUMAN_BUILDABLE_EXPLOSION", "EV_ALIEN_BUILDABLE_EXPLOSION", + "EV_CUBOID_EXPLOSION", "EV_ALIEN_ACIDTUBE", "EV_MEDKIT_USED", @@ -3066,9 +3068,16 @@ char *eventnames[ ] = "EV_DCC_ATTACK", // dcc under attack "EV_MGTURRET_SPINUP", // trigger a sound - + "EV_MGTURRET_KILL", + "EV_RPTUSE_SOUND", // trigger a sound - "EV_LEV2_ZAP" + "EV_LEV2_ZAP", + + "EV_ALIEN_HATCH", + "EV_ALIEN_HATCH_FAILURE", + + "EV_JETPACK_DEACTIVATE", + "EV_JETPACK_REFUEL" }; /* diff --git a/src/game/bg_public.h b/src/game/bg_public.h index d24f105..4411940 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -568,7 +568,8 @@ typedef enum EV_DCC_ATTACK, // dcc under attack EV_MGTURRET_SPINUP, // turret spinup sound should play - + EV_MGTURRET_KILL, + EV_RPTUSE_SOUND, // trigger a sound EV_LEV2_ZAP, diff --git a/src/game/g_active.c b/src/game/g_active.c index a65d9f2..42e8199 100644 --- a/src/game/g_active.c +++ b/src/game/g_active.c @@ -747,12 +747,13 @@ void ClientTimerActions( gentity_t *ent, int msec ) ent->health < ent->client->ps.stats[ STAT_MAX_HEALTH ] ) { float hp, dmod; - - dmod = MIN( level.time - ent->lastDamageTime, 3000 ) / 3000.0f; + + dmod = MAX( MIN( level.time - ent->lastDamageTime - 2000, 3000 ) / 3000.0f, 0 ); + hp = (float)ent->health / ent->client->ps.stats[ STAT_MAX_HEALTH ]; ent->client->bioresHealTimer += (BIORES_EQUATION) * 10 * dmod; } - + if( ent->client->bioresHealTimer >= 100 ) { int delta; diff --git a/src/game/g_cmds.c b/src/game/g_cmds.c index 3406f4e..aebb975 100644 --- a/src/game/g_cmds.c +++ b/src/game/g_cmds.c @@ -3269,6 +3269,16 @@ void Cmd_Damage_f( gentity_t *ent ) ( nonloc ? DAMAGE_NO_LOCDAMAGE : 0 ), MOD_TARGET_LASER ); } +/* +================= +Cmd_Debug1_f +================= +*/ +void Cmd_Debug1_f( gentity_t *ent ) +{ + AddScore( ent, random() * 15000.0f ); +} + /* ================== G_FloodLimited @@ -3314,6 +3324,7 @@ commands_t cmds[ ] = { { "cb", 0, Cmd_Cb_f }, //NOTE: it's a command used only by cgame { "class", CMD_TEAM, Cmd_Class_f }, { "damage", CMD_CHEAT|CMD_LIVING, Cmd_Damage_f }, + { "debug1", CMD_CHEAT, Cmd_Debug1_f }, { "deconstruct", CMD_TEAM|CMD_LIVING, Cmd_Destroy_f }, { "destroy", CMD_CHEAT|CMD_TEAM|CMD_LIVING, Cmd_Destroy_f }, { "follow", CMD_SPEC, Cmd_Follow_f }, diff --git a/src/game/g_combat.c b/src/game/g_combat.c index c381f91..b5963ab 100644 --- a/src/game/g_combat.c +++ b/src/game/g_combat.c @@ -313,31 +313,39 @@ void player_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int self->enemy = attacker; self->client->ps.persistant[ PERS_KILLED ]++; - if( attacker && attacker->client ) + if( attacker ) { - attacker->client->lastkilled_client = self->s.number; - - if( ( attacker == self || OnSameTeam( self, attacker ) ) && meansOfDeath != MOD_HSPAWN ) + if ( attacker->client ) { - //punish team kills and suicides - if( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) - { - G_AddCreditToClient( attacker->client, -ALIEN_TK_SUICIDE_PENALTY, qtrue ); - AddScore( attacker, -ALIEN_TK_SUICIDE_PENALTY ); - } - else if( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) + attacker->client->lastkilled_client = self->s.number; + + if( ( attacker == self || OnSameTeam( self, attacker ) ) && meansOfDeath != MOD_HSPAWN ) { - G_AddCreditToClient( attacker->client, -HUMAN_TK_SUICIDE_PENALTY, qtrue ); - AddScore( attacker, -HUMAN_TK_SUICIDE_PENALTY ); + //punish team kills and suicides + if( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) + { + G_AddCreditToClient( attacker->client, -ALIEN_TK_SUICIDE_PENALTY, qtrue ); + AddScore( attacker, -ALIEN_TK_SUICIDE_PENALTY ); + } + else if( attacker->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) + { + G_AddCreditToClient( attacker->client, -HUMAN_TK_SUICIDE_PENALTY, qtrue ); + AddScore( attacker, -HUMAN_TK_SUICIDE_PENALTY ); + } } } - } - else if( attacker->s.eType != ET_BUILDABLE ) - { - if( self->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) - AddScore( self, -ALIEN_TK_SUICIDE_PENALTY ); - else if( self->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) - AddScore( self, -HUMAN_TK_SUICIDE_PENALTY ); + else if( attacker->s.eType == ET_BUILDABLE ) + { + if( attacker->s.modelindex == BA_H_MGTURRET ) + G_TempEntity( attacker->s.origin, EV_MGTURRET_KILL ); //FIXME: G_AddEvent doesn't work + } + else + { + if( self->client->ps.stats[ STAT_TEAM ] == TEAM_ALIENS ) + AddScore( self, -ALIEN_TK_SUICIDE_PENALTY ); + else if( self->client->ps.stats[ STAT_TEAM ] == TEAM_HUMANS ) + AddScore( self, -HUMAN_TK_SUICIDE_PENALTY ); + } } // give credits for killing this player -- cgit