From fa669c5deefde1d19695b81e0cf4f8fe8f1369a5 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Sat, 25 Aug 2001 01:34:09 +0000 Subject: Float mines --- src/game/bg_misc.c | 113 ++++++++++++++++++++++++++++++++++++++++++++++++- src/game/bg_public.h | 45 +++++++++++--------- src/game/g_buildable.c | 94 ++++++++++++++++++++++++++++++++++++++-- src/game/q_shared.h | 4 +- 4 files changed, 231 insertions(+), 25 deletions(-) (limited to 'src') diff --git a/src/game/bg_misc.c b/src/game/bg_misc.c index 702d28f5..bbe1f333 100644 --- a/src/game/bg_misc.c +++ b/src/game/bg_misc.c @@ -962,6 +962,22 @@ TA: human power item "" //sounds }, +/*QUAKED team_human_floatmine (0 0 1) (-16 -16 -16) (16 16 16) +TA: human defense item +*/ + { + "team_human_floatmine", + "sound/items/holdable.wav", + { "models/buildables/floatmine/floatmine.md3", 0, 0, 0 }, + "icons/teleporter", //icon + "Human Floatmine", //pickup + 0, + IT_BUILDABLE, + BA_H_FLOATMINE, + "", //precache + "" //sounds + }, + /*QUAKED upgrade_torch (0 0 1) (-16 -16 -16) (16 16 16) */ { @@ -1102,6 +1118,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_droid_spawn", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 100, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1123,6 +1141,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_droid_def1", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 80, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1144,6 +1164,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_droid_def2", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 80, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1165,6 +1187,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_droid_hivemind", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 0, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1186,6 +1210,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_spawn", //char *entityName; { -40, -40, -4 }, //vec3_t mins; { 40, 40, 4 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 100, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1207,6 +1233,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_def1", //char *entityName; { -24, -24, -11 }, //vec3_t mins; { 24, 24, 11 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 80, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1228,6 +1256,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_def2", //char *entityName; { -24, -24, -11 }, //vec3_t mins; { 24, 24, 11 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 80, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1249,6 +1279,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_def3", //char *entityName; { -24, -24, -11 }, //vec3_t mins; { 24, 24, 11 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 80, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1270,6 +1302,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_mcu", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 200, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1291,6 +1325,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_reactor", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 0, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1312,6 +1348,8 @@ buildableAttributes_t bg_buildableList[ ] = "team_human_repeater", //char *entityName; { -15, -15, -15 }, //vec3_t mins; { 15, 15, 15 }, //vec3_t maxs; + TR_GRAVITY, //trType_t traj; + 0.0, //float bounce; 10, //int buildPoints; 1000, //int health; 50, //int damage; @@ -1319,7 +1357,30 @@ buildableAttributes_t bg_buildableList[ ] = 150, //int splashRadius; MOD_HSPAWN, //int meansOfDeath; BIT_HUMANS, //int team; - BANIM_IDLE1, //int constructAnim; + BANIM_IDLE1, //int constructAnim; + 100, //int nextthink; + 0, //int turretFireSpeed; + 0, //int turretRange; + WP_NONE, //weapon_t turretProjType; + qfalse, //qboolean creepTest; + qfalse //qboolean reactorTest; + }, + { + BA_H_FLOATMINE, //int buildNum; + "floatmine", //char *buildName; + "team_human_floatmine",//char *entityName; + { -15, -15, -15 }, //vec3_t mins; + { 15, 15, 15 }, //vec3_t maxs; + TR_BUOYANCY, //trType_t traj; + 0.2, //float bounce; + 10, //int buildPoints; + 100, //int health; + 50, //int damage; + 50, //int splashDamage; + 150, //int splashRadius; + MOD_HSPAWN, //int meansOfDeath; + BIT_HUMANS, //int team; + BANIM_IDLE1, //int constructAnim; 100, //int nextthink; 0, //int turretFireSpeed; 0, //int turretRange; @@ -1437,6 +1498,46 @@ void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ) VectorCopy( bg_buildableList[ 0 ].maxs, maxs ); } +/* +============== +BG_FindTrajectoryForBuildable +============== +*/ +trType_t BG_FindTrajectoryForBuildable( int bclass ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + return bg_buildableList[ i ].traj; + } + } + + return TR_GRAVITY; +} + +/* +============== +BG_FindBounceForBuildable +============== +*/ +float BG_FindBounceForBuildable( int bclass ) +{ + int i; + + for( i = 0; i < bg_numBuildables; i++ ) + { + if( bg_buildableList[ i ].buildNum == bclass ) + { + return bg_buildableList[ i ].bounce; + } + } + + return 0.0; +} + /* ============== BG_FindBuildPointsForBuildable @@ -3338,6 +3439,11 @@ void BG_EvaluateTrajectory( const trajectory_t *tr, int atTime, vec3_t result ) VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); result[2] -= 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity... break; + case TR_BUOYANCY: + deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds + VectorMA( tr->trBase, deltaTime, tr->trDelta, result ); + result[2] += 0.5 * DEFAULT_GRAVITY * deltaTime * deltaTime; // FIXME: local gravity... + break; default: Com_Error( ERR_DROP, "BG_EvaluateTrajectory: unknown trType: %i", tr->trTime ); break; @@ -3381,6 +3487,11 @@ void BG_EvaluateTrajectoryDelta( const trajectory_t *tr, int atTime, vec3_t resu VectorCopy( tr->trDelta, result ); result[2] -= DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity... break; + case TR_BUOYANCY: + deltaTime = ( atTime - tr->trTime ) * 0.001; // milliseconds to seconds + VectorCopy( tr->trDelta, result ); + result[2] += DEFAULT_GRAVITY * deltaTime; // FIXME: local gravity... + break; default: Com_Error( ERR_DROP, "BG_EvaluateTrajectoryDelta: unknown trType: %i", tr->trTime ); break; diff --git a/src/game/bg_public.h b/src/game/bg_public.h index e4fd3704..8ebf4a10 100644 --- a/src/game/bg_public.h +++ b/src/game/bg_public.h @@ -400,6 +400,8 @@ typedef enum { BA_H_REACTOR, BA_H_REPEATER, + BA_H_FLOATMINE, + BA_NUM_BUILDABLES } buildable_t; @@ -844,6 +846,9 @@ typedef struct vec3_t mins; vec3_t maxs; + + trType_t traj; + float bounce; int buildPoints; @@ -914,25 +919,27 @@ gitem_t *BG_FindItemForPowerup( powerup_t pw ); gitem_t *BG_FindItemForHoldable( holdable_t pw ); //TA: -int BG_FindBuildNumForName( char *name ); -int BG_FindBuildNumForEntityName( char *name ); -char *BG_FindNameForBuildable( int bclass ); -char *BG_FindEntityNameForBuildable( int bclass ); -void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ); -int BG_FindHealthForBuildable( int bclass ); -int BG_FindBuildPointsForBuildable( int bclass ); -int BG_FindDamageForBuildable( int bclass ); -int BG_FindSplashDamageForBuildable( int bclass ); -int BG_FindSplashRadiusForBuildable( int bclass ); -int BG_FindMODForBuildable( int bclass ); -int BG_FindTeamForBuildable( int bclass ); -int BG_FindAnimForBuildable( int bclass ); -int BG_FindNextThinkForBuildable( int bclass ); -int BG_FindFireSpeedForBuildable( int bclass ); -int BG_FindRangeForBuildable( int bclass ); -weapon_t BG_FindProjTypeForBuildable( int bclass ); -int BG_FindCreepTestForBuildable( int bclass ); -int BG_FindUniqueTestForBuildable( int bclass ); +int BG_FindBuildNumForName( char *name ); +int BG_FindBuildNumForEntityName( char *name ); +char *BG_FindNameForBuildable( int bclass ); +char *BG_FindEntityNameForBuildable( int bclass ); +void BG_FindBBoxForBuildable( int bclass, vec3_t mins, vec3_t maxs ); +int BG_FindHealthForBuildable( int bclass ); +trType_t BG_FindTrajectoryForBuildable( int bclass ); +float BG_FindBounceForBuildable( int bclass ); +int BG_FindBuildPointsForBuildable( int bclass ); +int BG_FindDamageForBuildable( int bclass ); +int BG_FindSplashDamageForBuildable( int bclass ); +int BG_FindSplashRadiusForBuildable( int bclass ); +int BG_FindMODForBuildable( int bclass ); +int BG_FindTeamForBuildable( int bclass ); +int BG_FindAnimForBuildable( int bclass ); +int BG_FindNextThinkForBuildable( int bclass ); +int BG_FindFireSpeedForBuildable( int bclass ); +int BG_FindRangeForBuildable( int bclass ); +weapon_t BG_FindProjTypeForBuildable( int bclass ); +int BG_FindCreepTestForBuildable( int bclass ); +int BG_FindUniqueTestForBuildable( int bclass ); int BG_FindClassNumForName( char *name ); char *BG_FindNameForClassNum( int pclass ); diff --git a/src/game/g_buildable.c b/src/game/g_buildable.c index bd01e49a..00f911c5 100644 --- a/src/game/g_buildable.c +++ b/src/game/g_buildable.c @@ -180,11 +180,19 @@ nullDieFunction hack to prevent compilers complaining about function pointer -> NULL conversion ================ */ -void nullDieFunction( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ) +static void nullDieFunction( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ) { } - +/* +================ +freeBuildable +================ +*/ +static void freeBuildable( gentity_t *self ) +{ + G_FreeEntity( self ); +} //================================================================================== @@ -590,6 +598,79 @@ void HMCU_Think( gentity_t *self ) +/* +================ +HFM_Touch + +Called when a floatmine is triggered +================ +*/ +void HFM_Touch( gentity_t *self, gentity_t *other, trace_t *trace ) +{ + //can't blow up twice + if( self->health > 0 ) + return; + + //go boom + G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); +} + +/* +================ +HFM_Die + +Called when a floatmine dies +================ +*/ +void HFM_Die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod ) +{ + vec3_t dir; + + // we don't have a valid direction, so just point straight up + dir[0] = dir[1] = 0; + dir[2] = -1; + + //do a bit of radius damage + G_RadiusDamage( self->s.pos.trBase, self->parent, self->splashDamage, + self->splashRadius, self, self->splashMethodOfDeath ); + + //pretty events and item cleanup + self->s.modelindex = 0; //don't draw the model once its destroyed + G_AddEvent( self, EV_ITEM_EXPLOSION, DirToByte( dir ) ); + self->r.contents = CONTENTS_TRIGGER; + self->timestamp = level.time; + + self->think = freeBuildable; + self->die = nullDieFunction; + self->nextthink = level.time + 100; + + trap_LinkEntity( self ); +} + +/* +================ +HFM_Think + +Think for floatmine +================ +*/ +void HFM_Think( gentity_t *self ) +{ + //make sure we have power + self->nextthink = level.time + REFRESH_TIME; + + if( !( self->powered = findPower( self ) ) ) + G_Damage( self, NULL, NULL, NULL, NULL, 10000, 0, MOD_SUICIDE ); +} + + + + +//================================================================================== + + + + //TA: the following defense turret code was written by // "fuzzysteve" (fuzzysteve@quakefiles.com) and // Anthony "inolen" Pesch (www.inolen.com) @@ -1301,6 +1382,12 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { built->die = HSpawn_Die; break; + case BA_H_FLOATMINE: + built->think = HFM_Think; + built->die = HFM_Die; + built->touch = HFM_Touch; + break; + default: //erk break; @@ -1320,7 +1407,8 @@ gentity_t *Build_Item( gentity_t *ent, buildable_t buildable, int distance ) { VectorCopy( angles, built->s.angles ); built->s.angles2[ YAW ] = angles[ YAW ]; VectorCopy( origin, built->s.origin ); - built->s.pos.trType = TR_GRAVITY; + built->s.pos.trType = BG_FindTrajectoryForBuildable( buildable ); + built->physicsBounce = BG_FindBounceForBuildable( buildable ); built->s.pos.trTime = level.time; G_AddEvent( built, EV_BUILD_CONSTRUCT, BANIM_CONSTRUCT1 ); diff --git a/src/game/q_shared.h b/src/game/q_shared.h index 18db9dd4..349369c8 100644 --- a/src/game/q_shared.h +++ b/src/game/q_shared.h @@ -1264,7 +1264,8 @@ typedef enum { TR_LINEAR, TR_LINEAR_STOP, TR_SINE, // value = base + sin( time / duration ) * delta - TR_GRAVITY + TR_GRAVITY, + TR_BUOYANCY //TA: what the hell is this doing in here anyway? } trType_t; typedef struct { @@ -1364,7 +1365,6 @@ typedef struct { typedef struct { glyphInfo_t glyphs [GLYPHS_PER_FONT]; - float glyphScale; char name[MAX_QPATH]; } fontInfo_t; -- cgit