Permalink
Browse files

Fix github bug #4 where lit dynamite doesn't explode in fire

Molotov and dynamite related code cleaning and refactoring to make it more understandable
Fixed minor performance bug where whiskey world entities dies in loop
Added world entity classname when damage is reported as g_debugDamage is set

git-svn-id: https://smokinguns.svn.sourceforge.net/svnroot/smokinguns/trunk@651 07eb42f0-b032-4355-afd3-42b1f3832223
  • Loading branch information...
sg_tequila
sg_tequila committed Dec 14, 2012
1 parent af5d34c commit 1a1f0a79e8dceeb6577e89cba60e7b4853027f12
View
@@ -1343,7 +1343,7 @@ qboolean BG_CanItemBeGrabbed( int gametype, const entityState_t *ent, const play
#ifndef SMOKINGUNS
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_BODY|CONTENTS_CORPSE)
#else
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_TRIGGER2|CONTENTS_BODY|CONTENTS_CORPSE)
#define MASK_SHOT (CONTENTS_SOLID|CONTENTS_EXPLOSIVE|CONTENTS_BODY|CONTENTS_CORPSE)
#endif
View
@@ -292,7 +292,7 @@ void G_TouchTriggers( gentity_t *ent ) {
#ifndef SMOKINGUNS
if ( !( hit->r.contents & CONTENTS_TRIGGER ) ) {
#else
if ( !( hit->r.contents & CONTENTS_TRIGGER ) && !( hit->r.contents & CONTENTS_TRIGGER2 ) &&
if ( !( hit->r.contents & CONTENTS_TRIGGER ) && !( hit->r.contents & CONTENTS_EXPLOSIVE ) &&
!(hit->s.eType == ET_MOVER && hit->s.angles2[0] == -1000) &&
hit->s.eType != ET_ESCAPE) {
#endif
View
@@ -1901,8 +1901,8 @@ void G_Damage( gentity_t *targ, gentity_t *inflictor, gentity_t *attacker,
: hit_info[client->lasthurt_location].backname,
modNames[mod], attacker->s.number );
} else {
G_LogPrintf( "%i: world:%i health:%i damage:%.1f from:%s by:%i\n", level.time,
targ->s.number, targ->health, take, modNames[mod] , attacker->s.number );
G_LogPrintf( "%i: world:%i/%s health:%i damage:%.1f from:%s by:%i\n", level.time,
targ->s.number, targ->classname, targ->health, take, modNames[mod] , attacker->s.number );
}
}
View
@@ -493,7 +493,7 @@ void RespawnItem( gentity_t *ent ) {
#ifdef SMOKINGUNS
if(ent->item->giTag == WP_DYNAMITE && ent->item->giType == IT_WEAPON)
ent->r.contents = CONTENTS_TRIGGER2;
ent->r.contents = CONTENTS_EXPLOSIVE;
#endif
ent->s.eFlags &= ~EF_NODRAW;
@@ -756,7 +756,7 @@ gentity_t *LaunchItem( gitem_t *item, vec3_t origin, vec3_t velocity, int droppe
dropped->r.contents = CONTENTS_TRIGGER;
#ifdef SMOKINGUNS
if(dropped->item->giTag == WP_DYNAMITE && dropped->item->giType == IT_WEAPON)
dropped->r.contents = CONTENTS_TRIGGER2;
dropped->r.contents = CONTENTS_EXPLOSIVE;
#endif
dropped->touch = Touch_Item;
@@ -937,7 +937,7 @@ void FinishSpawningItem( gentity_t *ent ) {
#ifdef SMOKINGUNS
if(ent->item->giTag == WP_DYNAMITE && ent->item->giType == IT_WEAPON)
ent->r.contents = CONTENTS_TRIGGER2;
ent->r.contents = CONTENTS_EXPLOSIVE;
#endif
ent->touch = Touch_Item;
View
@@ -797,7 +797,6 @@ void LookAtKiller( gentity_t *self, gentity_t *attacker );
//
void G_RunMissile( gentity_t *ent );
#ifdef SMOKINGUNS
void G_ExplodeMissile( gentity_t *ent );
void G_InstantExplode(vec3_t orig, gentity_t *attacker);
#endif
gentity_t *fire_blaster (gentity_t *self, vec3_t start, vec3_t aimdir);
View
@@ -322,9 +322,6 @@ void SP_misc_portal_camera(gentity_t *ent) {
======================================================================
*/
#ifdef SMOKINGUNS
void G_DynamiteDie( gentity_t *self, gentity_t *inflictor, gentity_t *attacker, int damage, int mod );
#endif
void Use_Shooter( gentity_t *ent, gentity_t *other, gentity_t *activator ) {
vec3_t dir;
View
@@ -27,7 +27,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define MISSILE_PRESTEP_TIME 50
#ifdef SMOKINGUNS
void G_KnifeThink( gentity_t *self ) {
static void G_KnifeThink( gentity_t *self ) {
trace_t trace;
int mask;
@@ -56,7 +56,7 @@ G_BounceMissile
================
*/
void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
static void G_BounceMissile( gentity_t *ent, trace_t *trace ) {
vec3_t velocity;
float dot;
int hitTime;
@@ -100,7 +100,7 @@ G_ExplodeMissile
Explode a missile without an impact
================
*/
void G_ExplodeMissile( gentity_t *ent ) {
static void G_ExplodeMissile( gentity_t *ent ) {
vec3_t dir;
vec3_t origin;
@@ -116,16 +116,12 @@ void G_ExplodeMissile( gentity_t *ent ) {
G_AddEvent( ent, EV_MISSILE_MISS, DirToByte( dir ) );
ent->freeAfterEvent = qtrue;
ent->takedamage = qfalse;
// splash damage
if ( ent->splashDamage ) {
if( G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage, ent->splashRadius, ent
, ent->splashMethodOfDeath ) ) {
#ifndef SMOKINGUNS
g_entities[ent->r.ownerNum].client->accuracy_hits++;
#endif
}
}
if ( ent->splashDamage )
G_RadiusDamage( ent->r.currentOrigin, ent->parent, ent->splashDamage,
ent->splashRadius, ent, ent->splashMethodOfDeath );
trap_LinkEntity( ent );
}
@@ -163,6 +159,7 @@ void G_InstantExplode(vec3_t orig, gentity_t *attacker) {
dynamite->methodOfDeath = MOD_DYNAMITE;
dynamite->splashMethodOfDeath = MOD_DYNAMITE;
dynamite->clipmask = MASK_SHOT;
dynamite->takedamage = qfalse;
G_ExplodeMissile(dynamite);
}
@@ -346,7 +343,7 @@ static void ProximityMine_Player( gentity_t *mine, gentity_t *player ) {
*/
/////////////////////////////////////////////
#ifdef SMOKINGUNS
void WhiskeyBurn( gentity_t *self, gentity_t *other, trace_t *trace ) {
static void WhiskeyBurn( gentity_t *self, gentity_t *other, trace_t *trace ) {
int dflags;
// it's not burning!
@@ -374,7 +371,7 @@ void WhiskeyBurn( gentity_t *self, gentity_t *other, trace_t *trace ) {
other->client->ps.powerups[PW_BURNBIT] = level.time;
}
void WhiskeyThink( gentity_t *self){
static void WhiskeyThink(gentity_t *self){
if(self->wait <= level.time){
G_FreeEntity(self);
@@ -399,41 +396,29 @@ void WhiskeyThink( gentity_t *self){
for(i = 0; i < num; i++){
gentity_t *hit = &g_entities[touch[i]];
if(!Q_stricmp(hit->classname, "whiskey_pool") &&
hit->s.apos.trDelta[0] == 0.0f){
G_AddEvent( hit, EV_WHISKEY_BURNS, DirToByte(hit->s.angles2));
hit->s.apos.trDelta[0] = 1;
hit->wait = level.time + WHISKEY_BURNTIME;
}
// make the dynamite explode
if(hit->r.contents & CONTENTS_TRIGGER2 && hit->takedamage){
G_Damage (hit, self, self->parent, NULL, NULL, 100, 0, MOD_MOLOTOV);
}
// make the dynamite explode and molotov burning
if (hit->r.contents & CONTENTS_EXPLOSIVE && hit->takedamage)
G_Damage (hit, self, self->parent, NULL, NULL, 100.0f, 0, MOD_MOLOTOV);
else if (hit->r.contents & CONTENTS_FLAMMABLE && hit->takedamage)
G_Damage (hit, self, self->parent, NULL, NULL, 10.0f, 0, MOD_MOLOTOV);
}
}
self->nextthink = level.time + 100;
}
// pool doesnt die it just burns
void WhiskeyDie ( gentity_t *self, gentity_t *inflictor,
static void WhiskeyDie ( gentity_t *self, gentity_t *inflictor,
gentity_t *attacker, int damage, int mod ) {
if(mod != MOD_DYNAMITE || self->s.apos.trDelta[0]){
self->health = 1;
self->takedamage = qtrue;
return;
}
G_AddEvent( self, EV_WHISKEY_BURNS, DirToByte(self->s.angles2));
self->s.apos.trDelta[0] = 1;
self->wait = level.time + WHISKEY_BURNTIME;
self->takedamage = qfalse;
}
gentity_t *SetWhiskeyPool (gentity_t *self, vec3_t origin, vec3_t normal, qboolean fire) {
static gentity_t *SetWhiskeyPool (gentity_t *self, vec3_t origin, vec3_t normal, qboolean fire) {
gentity_t *pool;
pool = G_Spawn();
@@ -453,18 +438,19 @@ gentity_t *SetWhiskeyPool (gentity_t *self, vec3_t origin, vec3_t normal, qboole
pool->touch = WhiskeyBurn;
pool->think = WhiskeyThink;
pool->nextthink = level.time + 100;
pool->r.contents |= CONTENTS_TRIGGER;
pool->r.contents |= CONTENTS_FLAMMABLE|CONTENTS_TRIGGER;
pool->die = WhiskeyDie;
pool->health = 1;
pool->takedamage = qtrue;
if(fire) {
pool->wait = level.time + WHISKEY_BURNTIME;
pool->s.apos.trDelta[0] = 1;
pool->takedamage = qfalse;
} else {
pool->wait = level.time + WHISKEY_SICKERTIME;
pool->s.apos.trDelta[0] = 0;
pool->takedamage = qtrue;
}
pool->noise_index = G_SoundIndex( "sound/world/electro.wav" );
@@ -482,7 +468,7 @@ gentity_t *SetWhiskeyPool (gentity_t *self, vec3_t origin, vec3_t normal, qboole
return pool;
}
void SprotzThink(gentity_t *self){
static void SprotzThink(gentity_t *self){
vec3_t newOrigin, oldorg;
trace_t trace;
int contents;
@@ -549,7 +535,7 @@ G_MissileImpact
#ifndef SMOKINGUNS
void G_MissileImpact( gentity_t *ent, trace_t *trace ) {
#else
void G_MissileImpact( gentity_t *ent, trace_t *trace, int shaderNum ) {
static void G_MissileImpact( gentity_t *ent, trace_t *trace, int shaderNum ) {
#endif
gentity_t *other;
qboolean hitClient = qfalse;
@@ -1246,7 +1232,7 @@ gentity_t *fire_prox( gentity_t *self, vec3_t start, vec3_t dir ) {
#endif
#else
void G_Temp(gentity_t *self){
static void G_Temp(gentity_t *self){
self->nextthink = level.time + 100;
}
@@ -1306,7 +1292,7 @@ G_Suck
=================
*/
void G_Suck( gentity_t *self ) {
static void G_Suck( gentity_t *self ) {
int wait = self->wait;
// if in water disable burning
@@ -1323,7 +1309,7 @@ void G_Suck( gentity_t *self ) {
self->item = item;
self->s.eType = ET_ITEM;
self->r.contents = CONTENTS_TRIGGER2;
self->r.contents = CONTENTS_EXPLOSIVE;
self->wait = -1;
self->flags |= FL_THROWN_ITEM;
@@ -1361,7 +1347,7 @@ G_DynamiteDie
Spoon - Destroy the dynamite
================
*/
void G_DynamiteDie( gentity_t *self, gentity_t *inflictor,
static void G_DynamiteDie( gentity_t *self, gentity_t *inflictor,
gentity_t *attacker, int damage, int mod ) {
self->takedamage = qfalse;
@@ -1397,7 +1383,7 @@ gentity_t *fire_dynamite (gentity_t *self, vec3_t start, vec3_t dir, int speed)
bolt->health = 5;
bolt->takedamage = qtrue;
bolt->die = G_DynamiteDie;
bolt->r.contents = CONTENTS_CORPSE;
bolt->r.contents = CONTENTS_EXPLOSIVE;

This comment has been minimized.

Show comment
Hide comment
@ghost

ghost Dec 14, 2012

Collaborator

Only this line really fixes #4

@ghost

ghost Dec 14, 2012

Collaborator

Only this line really fixes #4

VectorSet(bolt->r.mins, -8, -8, -1);
VectorCopy(bolt->r.mins, bolt->r.absmin);
VectorSet(bolt->r.maxs, 8, 8, 8);
View
@@ -264,9 +264,9 @@ qboolean G_TryPushingProxMine( gentity_t *check, gentity_t *pusher, vec3_t move,
}
return ret;
}
#endif
void G_ExplodeMissile( gentity_t *ent );
#endif
/*
============
@@ -32,8 +32,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
#define CONTENTS_SOLID 1 // an eye is never valid in a solid
#ifdef SMOKINGUNS
//make dynamite shootable
#define CONTENTS_TRIGGER2 2
//make dynamite shootable and molotov burning
#define CONTENTS_EXPLOSIVE 2
#define CONTENTS_FLAMMABLE 4
#endif
#define CONTENTS_LAVA 8

0 comments on commit 1a1f0a7

Please sign in to comment.