From e99324d98c43e4c2844589912b62a36798f67864 Mon Sep 17 00:00:00 2001 From: q3rally Date: Mon, 2 May 2011 19:09:55 +0000 Subject: [PATCH] Revert to the old breakables. --- engine/code/cgame/cg_effects.c | 248 ++++++++++++++++++++++++++++++++- engine/code/cgame/cg_event.c | 21 +++ engine/code/cgame/cg_main.c | 14 ++ engine/code/game/g_combat.c | 9 +- engine/code/game/g_mover.c | 39 ------ engine/code/game/g_spawn.c | 8 +- q3rallycode.ppr | 28 +++- 7 files changed, 315 insertions(+), 52 deletions(-) diff --git a/engine/code/cgame/cg_effects.c b/engine/code/cgame/cg_effects.c index 7fd4421b..d7e16c40 100644 --- a/engine/code/cgame/cg_effects.c +++ b/engine/code/cgame/cg_effects.c @@ -868,8 +868,254 @@ void CG_LightningArc( vec3_t start, vec3_t end ) { trap_R_AddRefEntityToScene( &arc ); } +/* + ================== + CG_LaunchShard + ================== + */ + void CG_LaunchShard( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { + int bounce; + localEntity_t *le; + refEntity_t *re; + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FRAGMENT; + le->startTime = cg.time; + le->endTime = le->startTime + 30000 + random() * 3000; + + VectorCopy( origin, re->origin ); + AxisCopy( axisDefault, re->axis ); + re->hModel = hModel; + + le->pos.trType = TR_GRAVITY; + VectorCopy( origin, le->pos.trBase ); + VectorCopy( velocity, le->pos.trDelta ); + le->pos.trTime = cg.time; + + bounce = le->bounceFactor; + bounce = 0.3; + + le->leFlags = LEF_TUMBLE; + le->leBounceSoundType = LEBS_BRASS; + le->leMarkType = LEMT_NONE; + } + + + + + /* + =================== + CG_BreakGlass + + Breaks our brush and generates a few models on launches them all over the map :) + =================== + */ + + #define GLASS_VELOCITY 175 //175 + #define GLASS_JUMP 125 //125 + + void CG_BreakGlass( vec3_t playerOrigin ) { + vec3_t origin, velocity; + int value; + int count = 20; //20 + int states[] = {1,2,3}; + int numstates = sizeof(states)/sizeof(states[0]); + + while ( count-- ) { + + value = states[rand()%numstates]; + VectorCopy( playerOrigin, origin ); + velocity[0] = crandom() * 165; //165 + velocity[1] = crandom() * 125; //125 + //velocity[2] = 0; //GLASS_JUMP + crandom() * 1; //165 + velocity[2] = GLASS_JUMP + crandom() * 165; //165 + + switch (value) { + case 1: + CG_LaunchShard( origin, velocity, cgs.media.glass01 ); + break; + case 2: + CG_LaunchShard( origin, velocity, cgs.media.glass02 ); + break; + case 3: + CG_LaunchShard( origin, velocity, cgs.media.glass03 ); + break; + } + } +} + + /* + ================== + CG_LaunchWood + ================== + */ + void CG_LaunchWood( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { + int bounce; + localEntity_t *le; + refEntity_t *re; + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FRAGMENT; + le->startTime = cg.time; + le->endTime = le->startTime + 30000 + random() * 3000; + + VectorCopy( origin, re->origin ); + AxisCopy( axisDefault, re->axis ); + re->hModel = hModel; + + le->pos.trType = TR_GRAVITY; + VectorCopy( origin, le->pos.trBase ); + VectorCopy( velocity, le->pos.trDelta ); + le->pos.trTime = cg.time; + + bounce = le->bounceFactor; + bounce = 0.9; //0.3 + //newq3ball + /* pm->ps->velocity[2] = -vel * 0.5; //2 + if (pm->ps->velocity[2] <= 0.001) { + pm->ps->velocity[2] = 0; + */ + //endnew + le->leFlags = LEF_TUMBLE; + le->leBounceSoundType = LEBS_BRASS; + le->leMarkType = LEMT_NONE; + } + + + + + /* + =================== + CG_BREAKWOOD + + Breaks our brush and generates a few (here 1 model) on launches them all over the map :) + =================== + */ + + #define BOX_VELOCITY 60 //175 + #define BOX_JUMP 85 //125 + + void CG_BREAKWOOD( vec3_t playerOrigin ) { + vec3_t origin, velocity; + int value; + int count = 8; //20 + int states[] = {1,2,3}; + int numstates = sizeof(states)/sizeof(states[0]); + + while ( count-- ) { + + value = states[rand()%numstates]; + VectorCopy( playerOrigin, origin ); + velocity[0] = crandom() * 80; //165 + velocity[1] = crandom() * 125; //125 + velocity[2] = BOX_JUMP + crandom() * 165; //165 + //velocity[2] = 165; //165 + //newq3ball +// velocity[2] = -velocity[0] * 0.5; //2 +// if (velocity[2] <= 0.001) { + // velocity[2] = 0; +// } + //endnew + switch (value) { + case 1: + CG_LaunchWood( origin, velocity, cgs.media.wood01 ); + break; + case 2: + CG_LaunchWood( origin, velocity, cgs.media.wood02 ); + break; + case 3: + CG_LaunchWood( origin, velocity, cgs.media.wood03 ); + break; + } + } +} + + /* + ================== + CG_LaunchMetal + ================== + */ + void CG_LaunchMetal( vec3_t origin, vec3_t velocity, qhandle_t hModel ) { + int bounce; + localEntity_t *le; + refEntity_t *re; + + le = CG_AllocLocalEntity(); + re = &le->refEntity; + + le->leType = LE_FRAGMENT; + le->startTime = cg.time; + le->endTime = le->startTime + 30000 + random() * 3000; + + VectorCopy( origin, re->origin ); + AxisCopy( axisDefault, re->axis ); + re->hModel = hModel; + + le->pos.trType = TR_GRAVITY; + VectorCopy( origin, le->pos.trBase ); + VectorCopy( velocity, le->pos.trDelta ); + le->pos.trTime = cg.time; + + bounce = le->bounceFactor; + bounce = 0.9; //0.3 + + le->leFlags = LEF_TUMBLE; + le->leBounceSoundType = LEBS_BRASS; + le->leMarkType = LEMT_NONE; + } + /* + =================== + CG_BREAKMETAL + + Breaks our brush and generates a few (here 1 model) on launches them all over the map :) + =================== + */ + +#define METAL_VELOCITY 60 //175 + #define METAL_JUMP 85 //125 + + void CG_BREAKMETAL( vec3_t playerOrigin ) { + vec3_t origin, velocity; + int value; + int count = 8; //20 + int states[] = {1,2,3}; + int numstates = sizeof(states)/sizeof(states[0]); + + while ( count-- ) { + + value = states[rand()%numstates]; + VectorCopy( playerOrigin, origin ); + velocity[0] = crandom() * 80; //165 + velocity[1] = crandom() * 125; //125 + velocity[2] = METAL_JUMP + crandom() * 165; //165 + //velocity[2] = 165; //165 + //newq3ball +// velocity[2] = -velocity[0] * 0.5; //2 +// if (velocity[2] <= 0.001) { + // velocity[2] = 0; +// } + //endnew + switch (value) { + case 1: + CG_LaunchMetal( origin, velocity, cgs.media.metal01 ); + break; + case 2: + CG_LaunchMetal( origin, velocity, cgs.media.metal02 ); + break; + case 3: + CG_LaunchMetal( origin, velocity, cgs.media.metal03 ); + break; + } + } +} + + /* ================== CG_LaunchDebris ================== @@ -956,4 +1202,4 @@ void CG_ShowDebris( vec3_t srcOrigin, int count, int type ) { CG_LaunchDebris( origin, velocity, cgs.media.debrisdark8 ); } } -} +} \ No newline at end of file diff --git a/engine/code/cgame/cg_event.c b/engine/code/cgame/cg_event.c index 43067dd5..3b29173b 100644 --- a/engine/code/cgame/cg_event.c +++ b/engine/code/cgame/cg_event.c @@ -1344,6 +1344,27 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) { // Q3Rally Code END break; +// Q3Rally Code Start + case EV_BREAK_GLASS: + DEBUGNAME("EV_BREAK_GLASS"); + trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.glassSound ); + CG_BreakGlass( cent->lerpOrigin ); + break; + + case EV_BREAKWOOD: + DEBUGNAME("EV_BREAKWOOD"); + trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.woodSound ); + CG_BREAKWOOD( cent->lerpOrigin ); + break; + + case EV_BREAKMETAL: + DEBUGNAME("EV_BREAKMETAL"); + trap_S_StartSound( NULL, es->number, CHAN_BODY, cgs.media.metalSound ); + CG_BREAKMETAL( cent->lerpOrigin ); + break; + +// Q3Rally Code END + case EV_STOPLOOPINGSOUND: DEBUGNAME("EV_STOPLOOPINGSOUND"); trap_S_StopLoopingSound( es->number ); diff --git a/engine/code/cgame/cg_main.c b/engine/code/cgame/cg_main.c index c0470e0f..05d8c01e 100644 --- a/engine/code/cgame/cg_main.c +++ b/engine/code/cgame/cg_main.c @@ -1204,6 +1204,20 @@ static void CG_RegisterGraphics( void ) { cgs.media.reverseLightGlow = trap_R_RegisterModel( "gfx/flares/r_lite.md3" ); // Q3Rally Code END +// Q3Rally Code Start - Glass Shards + cgs.media.glass01 = trap_R_RegisterModel( "models/breakables/glass01.md3" ); + cgs.media.glass02 = trap_R_RegisterModel( "models/breakables/glass02.md3" ); + cgs.media.glass03 = trap_R_RegisterModel( "models/breakables/glass03.md3" ); + + cgs.media.wood01 = trap_R_RegisterModel( "models/breakables/wood01.md3" ); + cgs.media.wood02 = trap_R_RegisterModel( "models/breakables/wood02.md3" ); + cgs.media.wood03 = trap_R_RegisterModel( "models/breakables/wood03.md3" ); + + cgs.media.wood01 = trap_R_RegisterModel( "models/breakables/metal01.md3" ); + cgs.media.wood02 = trap_R_RegisterModel( "models/breakables/metal02.md3" ); + cgs.media.wood03 = trap_R_RegisterModel( "models/breakables/metal03.md3" ); + +// Q3Rally Code END cgs.media.smoke2 = trap_R_RegisterModel( "models/weapons2/shells/s_shell.md3" ); cgs.media.balloonShader = trap_R_RegisterShader( "sprites/balloon3" ); diff --git a/engine/code/game/g_combat.c b/engine/code/game/g_combat.c index 9e767634..ab669e15 100644 --- a/engine/code/game/g_combat.c +++ b/engine/code/game/g_combat.c @@ -956,14 +956,11 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker, return; } -// shootable doors / buttons don't actually have any health + // shootable doors / buttons don't actually have any health // Rotating Doors if ( targ->s.eType == ET_MOVER ) { - if ( targ->use && targ->moverState == MOVER_POS1 ) { + if ( targ->use && (targ->moverState == MOVER_POS1 + || targ->moverState == ROTATOR_POS1) ) { targ->use( targ, inflictor, attacker ); - } else if ( targ->use == NULL ) { // entity is a func_breakable - targ->health -= damage; - if (targ->health <= 0) - Break_Breakable(targ, attacker); } return; } diff --git a/engine/code/game/g_mover.c b/engine/code/game/g_mover.c index cfe10e70..c9dd0a7a 100644 --- a/engine/code/game/g_mover.c +++ b/engine/code/game/g_mover.c @@ -1814,45 +1814,6 @@ void SP_func_static( gentity_t *ent ) { VectorCopy( ent->s.origin, ent->r.currentOrigin ); } -/* -=============================================================================== - -BREAKABLE - -=============================================================================== -*/ - -//other is the player that broke the func_breakable -void Break_Breakable(gentity_t *ent, gentity_t *other/*, trace_t *trace */) { - //TODO: make func_breakable play a sound when it's broken? - ent->takedamage = qfalse; - ent->s.eType = ET_INVISIBLE; - //ent->freeAfterEvent = qtrue; - //G_AddEvent( ent, EV_EMIT_DEBRIS, 0 ); - - G_UseTargets( ent, other ); - G_FreeEntity( ent ); -} - - -/*QUAKED func_breakable (0 .5 .8) ? -A bmodel that just sits there, doing nothing. It is removed when it received a set amount of damage. -"model2" .md3 model to also draw -"color" constantLight color -"light" constantLight radius -"health" the amount of damage required before this entity is removed -*/ -void SP_func_breakable( gentity_t *ent ) { - trap_SetBrushModel( ent, ent->model ); - InitMover( ent ); - VectorCopy( ent->s.origin, ent->s.pos.trBase ); - VectorCopy( ent->s.origin, ent->r.currentOrigin ); - ent->takedamage = qtrue; - //ent->touch = Break_Breakable; - ent->use = NULL; - ent->r.contents = CONTENTS_SOLID; - ent->clipmask = MASK_SOLID; -} /* =============================================================================== diff --git a/engine/code/game/g_spawn.c b/engine/code/game/g_spawn.c index c5270add..58f145c2 100644 --- a/engine/code/game/g_spawn.c +++ b/engine/code/game/g_spawn.c @@ -153,7 +153,9 @@ void SP_func_door (gentity_t *ent); void SP_func_train (gentity_t *ent); void SP_func_timer (gentity_t *self); // Q3Rally Code Start -void SP_func_breakable (gentity_t *ent); +void SP_func_breakglass (gentity_t *ent); +void SP_func_breakwood (gentity_t *ent); +void SP_func_breakmetal (gentity_t *ent); // Q3Rally Code END void SP_trigger_always (gentity_t *ent); @@ -247,7 +249,9 @@ spawn_t spawns[] = { {"func_train", SP_func_train}, {"func_group", SP_info_null}, {"func_timer", SP_func_timer}, // rename trigger_timer? - {"func_breakable", SP_func_breakable}, + {"func_breakglass", SP_func_breakglass}, + {"func_breakwood", SP_func_breakwood}, + {"func_breakmetal", SP_func_breakmetal}, // Triggers are brush objects that cause an effect when contacted diff --git a/q3rallycode.ppr b/q3rallycode.ppr index 8bf1b88e..52c442af 100644 --- a/q3rallycode.ppr +++ b/q3rallycode.ppr @@ -857,18 +857,38 @@ q3rallycode 1=engine\code\game\g_combat.c 2=engine\code\game\g_spawn.c 3=engine\code\cgame\cg_main.c +4=engine\code\cgame\cg_effects.c +5=engine\code\game\g_local.h +6=engine\code\game\g_misc.c +7=engine\code\cgame\cg_event.c +8=engine\code\cgame\cg_local.h [Selected Project Files] Main= -Selected=engine\code\cgame\cg_main.c +Selected=engine\code\cgame\cg_local.h [engine\code\game\g_mover.c] TopLine=1825 Caret=2,1855 [engine\code\game\g_combat.c] -TopLine=951 -Caret=10,968 +TopLine=931 +Caret=1,941 [engine\code\game\g_spawn.c] TopLine=235 Caret=40,250 [engine\code\cgame\cg_main.c] -TopLine=1195 +TopLine=1129 Caret=1,1206 +[engine\code\cgame\cg_effects.c] +TopLine=905 +Caret=1,919 +[engine\code\game\g_local.h] +TopLine=675 +Caret=1,691 +[engine\code\game\g_misc.c] +TopLine=751 +Caret=3,768 +[engine\code\cgame\cg_event.c] +TopLine=1337 +Caret=1,1351 +[engine\code\cgame\cg_local.h] +TopLine=1727 +Caret=54,1743