From 1de6a342d598d3875b35f24b0d019ebc9305c8c2 Mon Sep 17 00:00:00 2001 From: Richard Allen Date: Thu, 24 Jan 2002 14:20:53 +0000 Subject: [PATCH] Adding func_explosive and a few new surfaceparms --- reaction/cgame/cg_effects.c | 98 ++++++++++++++++++++++++++++++++++++ reaction/cgame/cg_event.c | 44 +++++++++++++++- reaction/cgame/cg_local.h | 19 ++++++- reaction/cgame/cg_main.c | 21 ++++++-- reaction/game/bg_misc.c | 11 +++- reaction/game/bg_pmove.c | 28 +++++++++-- reaction/game/bg_public.h | 12 ++++- reaction/game/g_local.h | 10 ++++ reaction/game/g_mover.c | 71 ++++++++++++++++++++++++++ reaction/game/g_spawn.c | 6 +++ reaction/game/surfaceflags.h | 14 ++++-- 11 files changed, 319 insertions(+), 15 deletions(-) diff --git a/reaction/cgame/cg_effects.c b/reaction/cgame/cg_effects.c index 491a529f..7815dc52 100644 --- a/reaction/cgame/cg_effects.c +++ b/reaction/cgame/cg_effects.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.19 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.18 2002/01/11 19:48:29 jbravo // Formatted the source in non DOS format. // @@ -1075,3 +1078,98 @@ void CG_BreakGlass( vec3_t playerOrigin, int glassParm, int type ) { } } } + +// JBravo: For func_explosive +void CG_LaunchBreakableFrag( vec3_t origin, vec3_t velocity, qhandle_t hModel, float bouncyness, float size ) { + localEntity_t *le; + refEntity_t *re; + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FRAGMENT; + le->startTime = cg.time - (rand() & 63); + le->endTime = le->startTime + 5000 + random() * 3000; + + VectorCopy( origin, re->origin ); + AxisCopy( axisDefault, re->axis ); + re->hModel = hModel; +// re->customShader = hShader; + + le->pos.trType = TR_GRAVITY; + VectorCopy( origin, le->pos.trBase ); + VectorCopy( velocity, le->pos.trDelta ); + le->pos.trTime = cg.time; + + le->size = size; + VectorScale(re->axis[0], size, re->axis[0]); + VectorScale(re->axis[1], size, re->axis[1]); + VectorScale(re->axis[2], size, re->axis[2]); + re->nonNormalizedAxes = qtrue; + + le->angles.trType = TR_LINEAR; + le->angles.trTime = cg.time; + le->angles.trBase[0] = rand()&63; + le->angles.trBase[1] = rand()&63; + le->angles.trBase[2] = rand()&63; + le->angles.trDelta[0] = rand()&127; + le->angles.trDelta[1] = rand()&127; + le->angles.trDelta[2] = rand()&127; + le->leFlags = LEF_TUMBLE; + + le->bounceFactor = bouncyness; + + le->leBounceSoundType = LEBS_NONE; + le->leMarkType = LEMT_NONE; +} + +// JBravo: also for func_explosive +/* +=================== +CG_BreakBreakable + +Generated a bunch of gibs launching out from the breakables location +=================== +*/ +#define BREAK_VELOCITY 550 +#define BREAK_JUMP 150 + +void CG_BreakBreakable( centity_t *cent, int eParam ) { + vec3_t origin, velocity; + qhandle_t model; + sfxHandle_t sound; + int i, mass, material; + float tension, bouncyness, size; + int modelbias[10] = { 0, 0, 0, 0, 1, 1, 1, 2, 2 }; + + // allow gibs to be turned off for speed + if ( !cg_gibs.integer ) { + return; + } + mass = ((eParam >> 4) & 0x0F) + 1; + tension = 0.25 * (((eParam >> 2) & 0x03) + 1); + bouncyness = 0.25 * (((eParam) & 0x3) + 1); + + mass = eParam; + material = (cent->currentState.powerups >> 12) & 0x000F; + tension = 0.0667 * (float)((cent->currentState.powerups >> 8) & 0x000F); + bouncyness = 0.0667 * (float)((cent->currentState.powerups >> 4) & 0x000F); + size = 0.1333 * (float)((cent->currentState.powerups) & 0x000F); + + if (mass == 0) mass = 1; + if (size <= 0) size = 1; + if (material) material--; + + VectorCopy( cent->currentState.origin, origin ); + + sound = cgs.media.breakable_snd[material]; + trap_S_StartSound( origin, cent->currentState.number, CHAN_BODY, sound ); + + for (i = 0; i < mass; i++) { + velocity[0] = (crandom() * BREAK_VELOCITY) * tension; + velocity[1] = (crandom() * BREAK_VELOCITY) * tension; + velocity[2] = ( random() * BREAK_JUMP) * tension; + model = cgs.media.breakable_frag[material][(int)(2.0 * random())]; + CG_LaunchBreakableFrag( origin, velocity, model, bouncyness, size ); + } +} diff --git a/reaction/cgame/cg_event.c b/reaction/cgame/cg_event.c index 94b10e90..9a928308 100644 --- a/reaction/cgame/cg_event.c +++ b/reaction/cgame/cg_event.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.35 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.34 2002/01/14 01:19:23 niceass // No more default 800 gravity on items - NiceAss // @@ -1502,7 +1505,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { cgs.media.footsteps[ FOOTSTEP_GRASS ][rand()&3] ); } break; - /* + case EV_FOOTSTEP_GRAVEL: DEBUGNAME("EV_FOOTSTEP_GRAVEL"); if (cg_footsteps.integer) { @@ -1510,7 +1513,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { cgs.media.footsteps[ FOOTSTEP_GRAVEL ][rand()&3] ); } break; - */ + case EV_FOOTSTEP_WOOD: DEBUGNAME("EV_FOOTSTEP_WOOD"); if (cg_footsteps.integer) { @@ -1525,6 +1528,36 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { cgs.media.footsteps[ FOOTSTEP_CARPET ][rand()&3] ); } break; +// JBravo: begin new sounds + case EV_FOOTSTEP_SNOW: + DEBUGNAME("EV_FOOTSTEP_SNOW"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_SNOW ][rand()&3] ); + } + break; + case EV_FOOTSTEP_MUD: + DEBUGNAME("EV_FOOTSTEP_MUD"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_MUD ][rand()&3] ); + } + break; + case EV_FOOTSTEP_WOOD2: + DEBUGNAME("EV_FOOTSTEP_WOOD2"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_WOOD2 ][rand()&3] ); + } + break; + case EV_FOOTSTEP_HARDMETAL: + DEBUGNAME("EV_FOOTSTEP_HARDMETAL"); + if (cg_footsteps.integer) { + trap_S_StartSound (NULL, es->number, CHAN_BODY, + cgs.media.footsteps[ FOOTSTEP_HARDMETAL ][rand()&3] ); + } + break; +// JBravo: end new sounds case EV_FOOTSTEP_METAL2: DEBUGNAME("EV_FOOTSTEP_METAL2"); if (cg_footsteps.integer) { @@ -2451,6 +2484,13 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { CG_Beam( cent ); break; +// JBravo: adding func_explosive + case EV_GIB_GLASS: + DEBUGNAME("EV_GIB_GLASS"); + //trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.gibSound ); + CG_BreakBreakable( cent, es->eventParm ); + break; + default: DEBUGNAME("UNKNOWN"); CG_Error( "Unknown event: %i", event ); diff --git a/reaction/cgame/cg_local.h b/reaction/cgame/cg_local.h index f95e987a..72c53b7e 100644 --- a/reaction/cgame/cg_local.h +++ b/reaction/cgame/cg_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.41 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.40 2002/01/14 01:19:23 niceass // No more default 800 gravity on items - NiceAss // @@ -135,11 +138,17 @@ typedef enum { FOOTSTEP_METAL, FOOTSTEP_SPLASH, // Elder: new surface sounds - FOOTSTEP_GRASS, + FOOTSTEP_GRAVEL, FOOTSTEP_WOOD, FOOTSTEP_CARPET, FOOTSTEP_METAL2, - //FOOTSTEP_GRAVEL, + FOOTSTEP_GLASS, + FOOTSTEP_GRASS, + // JBravo: new surface sounds + FOOTSTEP_SNOW, + FOOTSTEP_MUD, + FOOTSTEP_WOOD2, + FOOTSTEP_HARDMETAL, FOOTSTEP_TOTAL } footstep_t; @@ -330,6 +339,8 @@ typedef struct localEntity_s { leBounceSoundType_t leBounceSoundType; refEntity_t refEntity; +// JBravo: for func_explosive + float size; } localEntity_t; //====================================================================== @@ -846,6 +857,10 @@ typedef struct { qhandle_t akimbo1stModel; qhandle_t akimboHandModel; +// JBravo: func_brakable stuff + qhandle_t breakable_frag[15][3]; + sfxHandle_t breakable_snd[15]; + qhandle_t smoke2; qhandle_t machinegunBrassModel; diff --git a/reaction/cgame/cg_main.c b/reaction/cgame/cg_main.c index f67fc2fb..facf02a7 100644 --- a/reaction/cgame/cg_main.c +++ b/reaction/cgame/cg_main.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.36 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.35 2002/01/11 20:20:57 jbravo // Adding TP to main branch // @@ -793,7 +796,7 @@ static void CG_RegisterSounds( void ) { cgs.media.footsteps[FOOTSTEP_METAL][i] = trap_S_RegisterSound (name, qfalse); //Elder: new footsteps - Com_sprintf (name, sizeof(name), "sound/player/footsteps/gravel%i.wav", i+1); + Com_sprintf (name, sizeof(name), "sound/player/footsteps/grass%i.wav", i+1); cgs.media.footsteps[FOOTSTEP_GRASS][i] = trap_S_RegisterSound (name, qfalse); Com_sprintf (name, sizeof(name), "sound/player/footsteps/wood%i.wav", i+1); @@ -805,8 +808,20 @@ static void CG_RegisterSounds( void ) { Com_sprintf (name, sizeof(name), "sound/player/footsteps/metal%i.wav", i+1); cgs.media.footsteps[FOOTSTEP_METAL2][i] = trap_S_RegisterSound (name, qfalse); - //Com_sprintf (name, sizeof(name), "sound/player/footsteps/gravel%i.wav", i+1); - //cgs.media.footsteps[FOOTSTEP_GRAVEL][i] = trap_S_RegisterSound (name, qfalse); + Com_sprintf (name, sizeof(name), "sound/player/footsteps/gravel%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_GRAVEL][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/snow%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_SNOW][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/mud%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_MUD][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/hollowwood%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_WOOD2][i] = trap_S_RegisterSound (name, qfalse); + + Com_sprintf (name, sizeof(name), "sound/player/footsteps/hardmetal%i.wav", i+1); + cgs.media.footsteps[FOOTSTEP_HARDMETAL][i] = trap_S_RegisterSound (name, qfalse); } // only register the items that the server says we need diff --git a/reaction/game/bg_misc.c b/reaction/game/bg_misc.c index c5ffc8bf..8485ea0d 100644 --- a/reaction/game/bg_misc.c +++ b/reaction/game/bg_misc.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.28 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.27 2002/01/14 07:31:33 jbravo // Added a small workaround for the HoldableItem not found crash during // mapchanges. @@ -1283,10 +1286,16 @@ char *eventnames[] = { "EV_FOOTSTEP", "EV_FOOTSTEP_METAL", - "EV_FOOTSTEP_GRASS", // Elder: grass stuff + "EV_FOOTSTEP_GRAVEL", "EV_FOOTSTEP_WOOD", "EV_FOOTSTEP_CARPET", "EV_FOOTSTEP_METAL2", + "EV_FOOTSTEP_GLASS", + "EV_FOOTSTEP_GRASS", + "EV_FOOTSTEP_SNOW", // JBravo: adding new sounds + "EV_FOOTSTEP_MUD", + "EV_FOOTSTEP_WOOD2", + "EV_FOOTSTEP_HARDMETAL", "EV_FOOTSPLASH", "EV_FOOTWADE", "EV_SWIM", diff --git a/reaction/game/bg_pmove.c b/reaction/game/bg_pmove.c index 7432d7e9..7e884382 100644 --- a/reaction/game/bg_pmove.c +++ b/reaction/game/bg_pmove.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.55 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.54 2002/01/11 20:20:58 jbravo // Adding TP to main branch // @@ -1221,9 +1224,10 @@ static int PM_FootstepForSurface( void ) { return EV_FOOTSTEP_GRASS; } - //if ( pml.groundTrace.surfaceFlags & SURF_GRAVEL ) { - //return EV_FOOTSTEP_GRAVEL; - //} +// JBravo: re-enables Gravel. + if ( pml.groundTrace.surfaceFlags & SURF_GRAVEL ) { + return EV_FOOTSTEP_GRAVEL; + } if ( pml.groundTrace.surfaceFlags & SURF_WOOD ) { return EV_FOOTSTEP_WOOD; @@ -1237,6 +1241,24 @@ static int PM_FootstepForSurface( void ) { return EV_FOOTSTEP_METAL2; } +// JBravo: Begin adding new sounds + if ( pml.groundTrace.surfaceFlags & SURF_SNOW ) { + return EV_FOOTSTEP_SNOW; + } + + if ( pml.groundTrace.surfaceFlags & SURF_MUD ) { + return EV_FOOTSTEP_MUD; + } + + if ( pml.groundTrace.surfaceFlags & SURF_WOOD2 ) { + return EV_FOOTSTEP_WOOD2; + } + + if ( pml.groundTrace.surfaceFlags & SURF_HARDMETAL ) { + return EV_FOOTSTEP_HARDMETAL; + } +// JBravo: end adding new sounds + return EV_FOOTSTEP; } diff --git a/reaction/game/bg_public.h b/reaction/game/bg_public.h index 6b4b48b7..296f7fd3 100644 --- a/reaction/game/bg_public.h +++ b/reaction/game/bg_public.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.44 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.43 2002/01/11 20:20:58 jbravo // Adding TP to main branch // @@ -818,11 +821,18 @@ typedef enum { EV_FOOTSTEP_WOOD, EV_FOOTSTEP_CARPET, EV_FOOTSTEP_METAL2, - //EV_FOOTSTEP_GRAVEL, + EV_FOOTSTEP_GRAVEL, + EV_FOOTSTEP_SNOW, // JBravo: new surfaces + EV_FOOTSTEP_MUD, + EV_FOOTSTEP_WOOD2, + EV_FOOTSTEP_HARDMETAL, EV_FOOTSPLASH, EV_FOOTWADE, EV_SWIM, +// JBravo: for func_explosive + EV_GIB_GLASS, + EV_STEP_4, EV_STEP_8, EV_STEP_12, diff --git a/reaction/game/g_local.h b/reaction/game/g_local.h index 94512eae..f2bdb683 100644 --- a/reaction/game/g_local.h +++ b/reaction/game/g_local.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.36 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.35 2002/01/14 01:20:45 niceass // No more default 800 gravity on items // Thrown knife+Glass fix - NiceAss @@ -126,6 +129,13 @@ struct gentity_s { qboolean neverFree; // if true, FreeEntity will only unlink // bodyque uses this +// JBravo: adding func_explosive + int damage_radius; + int mass; + int tension; + int bounce; + int material; + int size; int flags; // FL_* variables diff --git a/reaction/game/g_mover.c b/reaction/game/g_mover.c index cbde006e..e58e0355 100644 --- a/reaction/game/g_mover.c +++ b/reaction/game/g_mover.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.20 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.19 2002/01/14 01:20:44 niceass // No more default 800 gravity on items // Thrown knife+Glass fix - NiceAss @@ -2242,3 +2245,71 @@ void SP_func_pendulum(gentity_t *ent) { ent->s.apos.trType = TR_SINE; ent->s.apos.trDelta[2] = speed; } + +// JBravo: adding for func_explosive +void func_explosive_explode( gentity_t *self , vec3_t pos ) { + int eParam; +// GibEntity( self, 0 ); + eParam = self->mass; + G_AddEvent(self, EV_GIB_GLASS, eParam); + +// G_Printf("Explode_explode\n" ); + self->takedamage = qfalse; + self->s.eType = ET_INVISIBLE; + self->r.contents = 0; + self->s.solid = 0; +} + +// JBravo: adding for func_explosive +void func_explosive_die( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int meansOfDeath ) +{ + G_RadiusDamage(self->s.origin,attacker,self->damage,self->damage_radius,self,0); + +// G_Printf("%s: explode @ %s\n", self->classname , vtos(self->s.origin) ); + G_ExplodeMissile(self); +// radius damage + func_explosive_explode( self , self->s.origin ); +} + +// JBravo: adding for func_explosive +void SP_func_explosive (gentity_t *ent) +{ + G_SpawnInt( "material", "1", &ent->material ); + G_SpawnInt( "tension", "100", &ent->tension ); + G_SpawnInt( "bounce", "5", &ent->bounce ); + G_SpawnInt( "health", "100", &ent->health ); + G_SpawnInt( "size", "10", &ent->size ); + G_SpawnInt( "mass", "100", &ent->mass ); + + ent->takedamage = qtrue; + ent->die = func_explosive_die; + if (!ent->health) { + ent->health = 2; + } + + if (!ent->damage) { + ent->damage = 2; + } + VectorCopy( ent->s.origin, ent->pos1 ); + + trap_SetBrushModel( ent, ent->model ); + InitMover( ent ); + +// VectorSubtract( ent->r.maxs, ent->r.mins, ent->s.origin ); + VectorCopy( ent->s.pos.trBase, ent->s.origin ); +/* VectorCopy( ent->s.origin, ent->s.pos.trBase ); + VectorCopy( ent->s.pos.trBase, ent->r.currentOrigin ); + VectorCopy( ent->s.apos.trBase, ent->r.currentAngles ); + VectorCopy( ent->s.origin, ent->r.currentOrigin ); */ + ent->s.origin[0] = ent->r.mins[0] + (0.5 * (ent->r.maxs[0] - ent->r.mins[0])); + ent->s.origin[1] = ent->r.mins[1] + (0.5 * (ent->r.maxs[1] - ent->r.mins[1])); + ent->s.origin[2] = ent->r.mins[2] + (0.5 * (ent->r.maxs[2] - ent->r.mins[2])); + + ent->s.powerups = ((ent->material << 12) & 0xF000) + + ((ent->tension << 8) & 0x0F00) + + ((ent->bounce << 4) & 0x00F0) + + ((ent->size) & 0x000F); + + trap_LinkEntity( ent ); + G_Printf("at : %s %s\n", vtos(ent->r.currentAngles), vtos(ent->r.currentOrigin ) ); +} diff --git a/reaction/game/g_spawn.c b/reaction/game/g_spawn.c index c984ce2a..bff3899d 100644 --- a/reaction/game/g_spawn.c +++ b/reaction/game/g_spawn.c @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.9 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.8 2002/01/11 20:20:58 jbravo // Adding TP to main branch // @@ -194,6 +197,8 @@ void SP_team_redobelisk( gentity_t *ent ); void SP_team_neutralobelisk( gentity_t *ent ); #endif void SP_item_botroam( gentity_t *ent ) {}; +// JBravo: adding explosive +void SP_func_explosive (gentity_t *self); spawn_t spawns[] = { // info entities don't do anything at all, but provide positional @@ -269,6 +274,7 @@ spawn_t spawns[] = { {"team_blueobelisk", SP_team_blueobelisk}, {"team_neutralobelisk", SP_team_neutralobelisk}, #endif + {"func_explosive", SP_func_explosive}, // JBravo: for explosive. {"item_botroam", SP_item_botroam}, {0, 0} diff --git a/reaction/game/surfaceflags.h b/reaction/game/surfaceflags.h index 9905d451..bc8b9962 100644 --- a/reaction/game/surfaceflags.h +++ b/reaction/game/surfaceflags.h @@ -5,6 +5,9 @@ //----------------------------------------------------------------------------- // // $Log$ +// Revision 1.10 2002/01/24 14:20:53 jbravo +// Adding func_explosive and a few new surfaceparms +// // Revision 1.9 2002/01/11 19:48:30 jbravo // Formatted the source in non DOS format. // @@ -74,9 +77,14 @@ #define SURF_NODLIGHT 0x20000 // don't dlight even if solid (solid lava, skies) #define SURF_DUST 0x40000 // leave a dust trail when walking on this surface //Elder: new surfaces -#define SURF_GRASS 0x80000 +#define SURF_GRAVEL 0x80000 #define SURF_WOOD 0x100000 #define SURF_CARPET 0x200000 #define SURF_METAL2 0x400000 -#define SURF_GLASS 0x800000 // not really a surface; more for marks -//#define SURF_GRAVEL 0x1000000 +#define SURF_GLASS 0x800000 +#define SURF_GRASS 0x1000000 +// JBravo: new sounds +#define SURF_SNOW 0x2000000 +#define SURF_MUD 0x4000000 +#define SURF_WOOD2 0x8000000 +#define SURF_HARDMETAL 0x10000000