Added more options to func_breakable

!!! use the new entities.def !!!
This commit is contained in:
P3rlE 2022-03-19 21:49:08 +01:00
parent 1fe5dba1f0
commit e0418bd2d4
8 changed files with 107 additions and 50 deletions

View file

@ -1334,17 +1334,18 @@ static void CG_RegisterGraphics( void ) {
// wall marks
cgs.media.bulletMarkShader = trap_R_RegisterShader( "gfx/damage/bullet_mrk" );
cgs.media.burnMarkShader = trap_R_RegisterShader( "gfx/damage/burn_med_mrk" );
// Q3Rally Code Start
cgs.media.bioMarkShader = trap_R_RegisterShader( "gfx/damage/bio_mark" );
cgs.media.oilMarkShader = trap_R_RegisterShader( "gfx/damage/oil_mark" );
cgs.media.sparkShader = trap_R_RegisterShader( "gfx/damage/spark" );
// Q3Rally Code END
cgs.media.holeMarkShader = trap_R_RegisterShader( "gfx/damage/hole_lg_mrk" );
cgs.media.energyMarkShader = trap_R_RegisterShader( "gfx/damage/plasma_mrk" );
cgs.media.shadowMarkShader = trap_R_RegisterShader( "markShadow" );
cgs.media.wakeMarkShader = trap_R_RegisterShader( "wake" );
cgs.media.bloodMarkShader = trap_R_RegisterShader( "bloodMark" );
//explosion effect
cgs.media.rocketExplosionShader = trap_R_RegisterShader("rocketExplosion");
// register the inline models
cgs.numInlineModels = trap_CM_NumInlineModels();
for ( i = 1 ; i < cgs.numInlineModels ; i++ ) {

View file

@ -763,7 +763,7 @@ void CG_RegisterWeapon( int weaponNum ) {
MAKERGB( weaponInfo->flashDlightColor, 1, 0.75f, 0 );
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/rocket/rocklf1a.wav", qfalse );
cgs.media.rocketExplosionShader = trap_R_RegisterShader( "rocketExplosion" );
//cgs.media.rocketExplosionShader = trap_R_RegisterShader( "rocketExplosion" );
break;
#ifdef MISSIONPACK

View file

@ -1693,7 +1693,7 @@ int CIN_PlayCinematic( const char *arg, int x, int y, int w, int h, int systemBi
*/
if (cinTable[currentHandle].alterGameState) {
CL_ShowMainMenu();
VM_Call( uivm, UI_SET_ACTIVE_MENU, UIMENU_NONE );
} else {
cinTable[currentHandle].playonwalls = cl_inGameVideo->integer;
}

View file

@ -764,9 +764,7 @@ typedef enum {
MOD_ROCKET_SPLASH,
MOD_PLASMA,
MOD_PLASMA_SPLASH,
// Q3Rally Code Start
MOD_FLAME_THROWER,
// Q3Rally Code End
MOD_RAILGUN,
MOD_LIGHTNING,
MOD_BFG,
@ -787,7 +785,6 @@ typedef enum {
MOD_KAMIKAZE,
MOD_JUICED,
#endif
// STONELANCE
MOD_UPSIDEDOWN,
MOD_BO_SHOCKS,
MOD_CAR_COLLISION,
@ -799,8 +796,8 @@ typedef enum {
MOD_MINE,
MOD_POISON,
MOD_FIRE,
// END
MOD_GRAPPLE
MOD_GRAPPLE,
MOD_BREAKABLE_SPLASH
} meansOfDeath_t;

View file

@ -1869,40 +1869,83 @@ BREAKABLE
===============================================================================
*/
void Think_Breakable( gentity_t *ent ) {
Break_Breakable( ent, ent->activator );
}
//other is the player that broke the func_breakable
void Break_Breakable(gentity_t *ent, gentity_t *other) {
vec3_t size;
vec3_t center;
int count = 0;
int sound = 0;
int spawnflags = 0;
gentity_t *tmp;
//int type = EV_EMIT_DEBRIS_LIGHT;
gentity_t *tmp, *tmp2;
int type = EV_EMIT_DEBRIS_LIGHT;
// Get the center of the glass (code donated by Perle)
if ( other != ent->activator && !strcmp( other->classname, "func_breakable" ) ) {
//if the splash damage from another func_breakable is causing this func_breakable to break
//then delay the break to get a nice chain explosion effect
ent->activator = other;
ent->think = Think_Breakable;
ent->nextthink = level.time + 400;
return;
}
// Get the center of the func_breakable (code donated by Perle)
VectorSubtract(ent->r.maxs, ent->r.mins, size);
VectorScale(size, 0.5, size);
VectorAdd(ent->r.mins, size, center);
ent->takedamage = qfalse;
ent->s.eType = ET_INVISIBLE;
G_UseTargets( ent, other );
//need to store properties of the entity in seperate variables because we're going to free the entity
//need to store properties of the entity in separate variables because we're going to free the entity
if ( ent->count > 0) {
count = ent->count;
spawnflags = ent->spawnflags;
}
if ( ent->soundPos2 )
sound = ent->soundPos2;
//apply radius damage
if ( ent->damage )
G_RadiusDamage( center, ent, ent->damage, ent->splashRadius, ent, MOD_BREAKABLE_SPLASH );
//free the entity so it disappears
G_FreeEntity( ent );
//spray out debris
if ( count > 0 ) {
tmp = G_TempEntity( center, PickDebrisType( spawnflags ) );
tmp->s.eventParm = count;
}
//play sound
if ( sound )
{
tmp2 = G_TempEntity( center, EV_GENERAL_SOUND );
tmp2->s.eventParm = sound;
}
//show explosion effect
if (spawnflags & 8192) {
G_TempEntity(center, EV_EXPLOSION);
}
}
void Use_Breakable (gentity_t *ent, gentity_t *other, gentity_t *activator) {
Break_Breakable( ent, activator );
}
/*QUAKED func_breakable (0 .5 .8) ? see PickDebrisType in g_util.c for spawnflags
A bmodel that just sits there, doing nothing. It is removed when it received a set amount of damage.
@ -1912,14 +1955,24 @@ A bmodel that just sits there, doing nothing. It is removed when it received a s
"health" the amount of damage required before this entity is removed
*/
void SP_func_breakable( gentity_t *ent ) {
char *noise;
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->use = 0;
ent->use = Use_Breakable;
ent->r.contents = CONTENTS_SOLID;
ent->clipmask = MASK_SOLID;
G_SpawnInt( "dmg", "0", &ent->damage );
G_SpawnInt( "radius", "120", &ent->splashRadius ); //120 is default splash radius of a rocket
G_SpawnString("breaksound", "", &noise);
if (strlen(noise) > 0) {
ent->soundPos2 = G_SoundIndex(noise);
}
}
/*

View file

@ -67,7 +67,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define BASETA "missionpack"
#ifndef PRODUCT_VERSION
#define PRODUCT_VERSION "v0.4_r518"
#define PRODUCT_VERSION "v0.4_r519"
#endif
@ -1609,7 +1609,7 @@ signed signed_10bit4:10; //-511 to 511
unsigned :24; //Do not use
unsigned c7:8; //Unsigned char 0 to 255
//powerups
ÿpo??ps
unsigned :16; //Do not use
signed s2:16; //Signed -32767 to 32767

Binary file not shown.

View file

@ -313,18 +313,20 @@ Target this entity with a misc_model to have the model attached to the entity (s
//=============================================================================
/*QUAKED func_breakable (0 .5 .8) ? LIGHT_DEBRIS DARK_DEBRIS LIGHT_LARGE_DEBRIS DARK_LARGE_DEBRIS WOOD_DEBRIS FLESH_DEBRIS GLASS_DEBRIS STONE_DEBRIS
/*QUAKED func_breakable (0 .5 .8) ? LIGHT_DEBRIS DARK_DEBRIS LIGHT_LARGE_DEBRIS DARK_LARGE_DEBRIS WOOD_DEBRIS FLESH_DEBRIS GLASS_DEBRIS STONE_DEBRIS - - NO_PLAYER NO_BOTS NO_SHOOTER EXPLOSION
A static entity that is removed when it receives a set amount of damage.
-------- KEYS --------
health : The entire entity is removed once this amount of damages has been inflicted to it.
count : The entity will spew out this number of chunks of debris when it's broken (default = 0).
dmg : Amount of splashdamage the func_breakable will deal when it is removed (default = 0).
radius : The radius in which the splashdamage is dealt (default = 120).
breaksound : Sound to play when it's broken (by default, no sound will be played)
target : Targetted entity will be triggered once the func_breakable is destroyed.
target2 : Targetted entity will be triggered once the func_breakable is destroyed.
targetname : activating entity points to this.
targetname2 : activating entity points to this.
light : constantLight radius of .md3 model included with entity. Has no effect on the entity's brushes (default 0).
color : constantLight color of .md3 model included with entity. Has no effect on the entity's brushes (default 1 1 1).
notfree : when set to 1, entity will not spawn in "Free for all" and "Tournament" modes.
notteam : when set to 1, entity will not spawn in "Teamplay" and "CTF" modes.
notsingle : when set to 1, entity will not spawn in Single Player mode.
-------- Q3MAP2 KEYS --------
_targetname : Used to attach a misc_model entity to this entity.
_lightmapscale : Floating point value scaling the resolution of lightmaps on brushes/patches in this entity (default 1.0).
@ -344,6 +346,10 @@ WOOD_DEBRIS : Emit pieces of wooden debris.
FLESH_DEBRIS : Emit gibs.
GLASS_DEBRIS : Emit shards of glass.
STONE_DEBRIS : Emit chunks of stone.
NO_PLAYER : The player cannot damage the func_breakable.
NO_BOTS : Bots cannot damage the func_breakable.
NO_SHOOTER : Shooter entities cannot damage the func_breakable.
EXPLOSION : When the func_breakable is destroyed, an explosion effect is shown.
-------- NOTES --------
Target this entity with a misc_model to have the model attached to the entity (set the model's "target" key to the same value as this entity's "targetname").