Weapons not using their correct case statements (impacts)
Posted: Fri Sep 23, 2005 5:50 pm
Ok here is the issue, my LightningGun, Chainsaw and Axe are all using the same impact.
If I put the case WP_GAUNTLET at the top, all 3 of the weapons will use it, if I put WP_CHAINSAW at the top, all 3 will use it, same goes for WP_LIGHTNING
So I don't have a clue what to do.
The weapons code:
g_weapons.c
oid Weapon_LightningFire( gentity_t *ent ) {
trace_t tr;
vec3_t end;
gentity_t *traceEnt, *tent;
int damage, i, passent;
damage = 18 * s_quadFactor;
VectorMA( muzzle, LIGHTNING_RANGE, forward, end );
// The SARACEN's Lightning Discharge - START
if (trap_PointContents (muzzle, -1) & MASK_WATER)
{
int zaps;
int ddamage;
int dradius;
gentity_t *tent;
zaps = (ent->client->ps.ammo[WP_LIGHTNING] + 1); // determines size/power of discharge
if (!zaps) return; // prevents any subsequent frames causing second discharge + error
ddamage = 90 + (zaps * 10);
dradius = (90 + (zaps * 10)) * 1.5;
//zaps++; // pmove does an ammo[gun]--, so we must compensate
SnapVectorTowards (muzzle, ent->s.origin); // save bandwidth
tent = G_TempEntity (muzzle, EV_LIGHTNING_DISCHARGE);
tent->s.eventParm = zaps; // duration / size of explosion graphic
G_RadiusDamage (muzzle, ent, ddamage, dradius, NULL, MOD_LIGHTNING_DISCHARGE);
ent->client->ps.ammo[WP_LIGHTNING] = 0; // drain ent's lightning count
ent->client->ps.ammo[WP_DOOMPLASMAGUN] = 0; // drain ent's lightning count
//g_entities[ent->r.ownerNum].client->ps.persistant[PERS_ACCURACY_HITS]++;
return;
}
// The SARACEN's Lightning Discharge - END
trap_Trace( &tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT );
if ( tr.entityNum == ENTITYNUM_NONE ) {
return;
}
traceEnt = &g_entities[ tr.entityNum ];
//taras changed && to || in order to make blood spurts still affect hit corpses
if ( traceEnt->takedamage || traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_LIGHTNING);
}
}
void Weapon_Chainsaw( gentity_t *ent ) {
trace_t tr;
vec3_t end;
gentity_t *traceEnt, *tent;
int damage, i, passent;
damage = 10 * s_quadFactor;
passent = ent->s.number;
for (i = 0; i < 10; i++) {
VectorMA( muzzle, 32, forward, end );
trap_Trace( &tr, muzzle, NULL, NULL, end, ENTITYNUM_NONE, MASK_SHOT );
if ( tr.entityNum == ENTITYNUM_NONE ) {
return;
}
traceEnt = &g_entities[ tr.entityNum ];
if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_CHAINSAW);
}
if ( traceEnt == ent ) {
return;
}
//taras changed && to || in order to make blood spurts still affect hit corpses
if ( traceEnt->takedamage || traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
if( LogAccuracyHit( traceEnt, ent ) ) {
ent->client->accuracy_hits++;
}
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
break;
}
}
void Weapon_Gauntlet( gentity_t *ent ) {
trace_t tr;
vec3_t end;
gentity_t *traceEnt, *tent;
int damage, i, passent;
damage = 100 * s_quadFactor;
passent = ent->s.number;
for (i = 0; i < 10; i++) {
VectorMA( muzzle, 32, forward, end );
trap_Trace( &tr, muzzle, NULL, NULL, end, ENTITYNUM_NONE, MASK_SHOT );
if ( tr.entityNum == ENTITYNUM_NONE ) {
return;
}
traceEnt = &g_entities[ tr.entityNum ];
if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_GAUNTLET);
}
if ( traceEnt == ent ) {
return;
}
//taras changed && to || in order to make blood spurts still affect hit corpses
if ( traceEnt->takedamage || traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
if( LogAccuracyHit( traceEnt, ent ) ) {
ent->client->accuracy_hits++;
}
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
break;
}
}
in cg_weapons.c:
CG_RegisterWeapon
case WP_GAUNTLET:
MAKERGB( weaponInfo->flashDlightColor, 1.0f, 0.25f, 0.0f );
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse );
//weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
cgs.media.axeExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
break;
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/chainsaw/DSSAWIDL.wav", qfalse );
MAKERGB( weaponInfo->flashDlightColor, 1.0f, 0.25f, 0.0f );
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/chainsaw/DSSAWFUL.wav", qfalse );
cgs.media.chainsawExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
break;
case WP_LIGHTNING:
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
MAKERGB( weaponInfo->flashDlightColor, 0.5f, 0.75f, 1.0f );
MAKERGB( weaponInfo->missileDlightColor, 0.5f, 0.75f, 1.0f );
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse );
weaponInfo->missileDlight = 150;
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
cgs.media.lightningShader = trap_R_RegisterShader( "lightningBoltNew");
cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
cgs.media.sfx_lghit1 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit.wav", qfalse );
cgs.media.sfx_lghit2 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit2.wav", qfalse );
cgs.media.sfx_lghit3 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit3.wav", qfalse );
break;
CG_MissileHitWall
case WP_GAUNTLET:
// no explosion at LG impact, it is added with the beam
sfx = cgs.media.sfx_axeexp;
mod = cgs.media.axeExplosionModel;
mark = cgs.media.burnMarkShader;
radius = 8;
light = 50;
duration = 50;
lightColor[0] = 0.75;
lightColor[1] = 0.75;
lightColor[2] = 0.75;
break;
case WP_CHAINSAW:
// no explosion at LG impact, it is added with the beam
sfx = cgs.media.sfx_plasmaexp;
mod = cgs.media.chainsawExplosionModel;
mark = cgs.media.holeMarkShader;
radius = 4;
light = 50;
duration = 50;
lightColor[0] = 0.75;
lightColor[1] = 0.75;
lightColor[2] = 0.75;
break;
case WP_LIGHTNING:
// no explosion at LG impact, it is added with the beam
r = rand() & 3;
if ( r < 2 ) {
sfx = cgs.media.sfx_lghit2;
} else if ( r == 2 ) {
sfx = cgs.media.sfx_lghit1;
} else {
sfx = cgs.media.sfx_lghit3;
}
mod = cgs.media.lightningExplosionModel;
mark = cgs.media.holeMarkShader;
radius = 8;
light = 200;
duration = 50;
lightColor[0] = 0.5;
lightColor[1] = 0.75;
lightColor[2] = 1.0;
break;
What is happening is all 3 of the weapons are using the WP_GAUNTLET impact. If I saw the chainsaw and axe, it uses the chainsaw for all 3 weapons ect...
If I put the case WP_GAUNTLET at the top, all 3 of the weapons will use it, if I put WP_CHAINSAW at the top, all 3 will use it, same goes for WP_LIGHTNING
So I don't have a clue what to do.
The weapons code:
g_weapons.c
oid Weapon_LightningFire( gentity_t *ent ) {
trace_t tr;
vec3_t end;
gentity_t *traceEnt, *tent;
int damage, i, passent;
damage = 18 * s_quadFactor;
VectorMA( muzzle, LIGHTNING_RANGE, forward, end );
// The SARACEN's Lightning Discharge - START
if (trap_PointContents (muzzle, -1) & MASK_WATER)
{
int zaps;
int ddamage;
int dradius;
gentity_t *tent;
zaps = (ent->client->ps.ammo[WP_LIGHTNING] + 1); // determines size/power of discharge
if (!zaps) return; // prevents any subsequent frames causing second discharge + error
ddamage = 90 + (zaps * 10);
dradius = (90 + (zaps * 10)) * 1.5;
//zaps++; // pmove does an ammo[gun]--, so we must compensate
SnapVectorTowards (muzzle, ent->s.origin); // save bandwidth
tent = G_TempEntity (muzzle, EV_LIGHTNING_DISCHARGE);
tent->s.eventParm = zaps; // duration / size of explosion graphic
G_RadiusDamage (muzzle, ent, ddamage, dradius, NULL, MOD_LIGHTNING_DISCHARGE);
ent->client->ps.ammo[WP_LIGHTNING] = 0; // drain ent's lightning count
ent->client->ps.ammo[WP_DOOMPLASMAGUN] = 0; // drain ent's lightning count
//g_entities[ent->r.ownerNum].client->ps.persistant[PERS_ACCURACY_HITS]++;
return;
}
// The SARACEN's Lightning Discharge - END
trap_Trace( &tr, muzzle, NULL, NULL, end, ent->s.number, MASK_SHOT );
if ( tr.entityNum == ENTITYNUM_NONE ) {
return;
}
traceEnt = &g_entities[ tr.entityNum ];
//taras changed && to || in order to make blood spurts still affect hit corpses
if ( traceEnt->takedamage || traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_LIGHTNING);
}
}
void Weapon_Chainsaw( gentity_t *ent ) {
trace_t tr;
vec3_t end;
gentity_t *traceEnt, *tent;
int damage, i, passent;
damage = 10 * s_quadFactor;
passent = ent->s.number;
for (i = 0; i < 10; i++) {
VectorMA( muzzle, 32, forward, end );
trap_Trace( &tr, muzzle, NULL, NULL, end, ENTITYNUM_NONE, MASK_SHOT );
if ( tr.entityNum == ENTITYNUM_NONE ) {
return;
}
traceEnt = &g_entities[ tr.entityNum ];
if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_CHAINSAW);
}
if ( traceEnt == ent ) {
return;
}
//taras changed && to || in order to make blood spurts still affect hit corpses
if ( traceEnt->takedamage || traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
if( LogAccuracyHit( traceEnt, ent ) ) {
ent->client->accuracy_hits++;
}
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
break;
}
}
void Weapon_Gauntlet( gentity_t *ent ) {
trace_t tr;
vec3_t end;
gentity_t *traceEnt, *tent;
int damage, i, passent;
damage = 100 * s_quadFactor;
passent = ent->s.number;
for (i = 0; i < 10; i++) {
VectorMA( muzzle, 32, forward, end );
trap_Trace( &tr, muzzle, NULL, NULL, end, ENTITYNUM_NONE, MASK_SHOT );
if ( tr.entityNum == ENTITYNUM_NONE ) {
return;
}
traceEnt = &g_entities[ tr.entityNum ];
if ( traceEnt->takedamage) {
G_Damage( traceEnt, ent, ent, forward, tr.endpos,
damage, 0, MOD_GAUNTLET);
}
if ( traceEnt == ent ) {
return;
}
//taras changed && to || in order to make blood spurts still affect hit corpses
if ( traceEnt->takedamage || traceEnt->client ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_HIT );
tent->s.otherEntityNum = traceEnt->s.number;
tent->s.eventParm = DirToByte( tr.plane.normal );
tent->s.weapon = ent->s.weapon;
if( LogAccuracyHit( traceEnt, ent ) ) {
ent->client->accuracy_hits++;
}
} else if ( !( tr.surfaceFlags & SURF_NOIMPACT ) ) {
tent = G_TempEntity( tr.endpos, EV_MISSILE_MISS );
tent->s.eventParm = DirToByte( tr.plane.normal );
}
break;
}
}
in cg_weapons.c:
CG_RegisterWeapon
case WP_GAUNTLET:
MAKERGB( weaponInfo->flashDlightColor, 1.0f, 0.25f, 0.0f );
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/melee/fstrun.wav", qfalse );
//weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/melee/fstatck.wav", qfalse );
cgs.media.axeExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
break;
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/chainsaw/DSSAWIDL.wav", qfalse );
MAKERGB( weaponInfo->flashDlightColor, 1.0f, 0.25f, 0.0f );
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/chainsaw/DSSAWFUL.wav", qfalse );
cgs.media.chainsawExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
break;
case WP_LIGHTNING:
weaponInfo->missileModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
MAKERGB( weaponInfo->flashDlightColor, 0.5f, 0.75f, 1.0f );
MAKERGB( weaponInfo->missileDlightColor, 0.5f, 0.75f, 1.0f );
weaponInfo->readySound = trap_S_RegisterSound( "sound/weapons/melee/fsthum.wav", qfalse );
weaponInfo->firingSound = trap_S_RegisterSound( "sound/weapons/lightning/lg_hum.wav", qfalse );
weaponInfo->missileDlight = 150;
weaponInfo->flashSound[0] = trap_S_RegisterSound( "sound/weapons/lightning/lg_fire.wav", qfalse );
cgs.media.lightningShader = trap_R_RegisterShader( "lightningBoltNew");
cgs.media.lightningExplosionModel = trap_R_RegisterModel( "models/weaphits/crackle.md3" );
cgs.media.sfx_lghit1 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit.wav", qfalse );
cgs.media.sfx_lghit2 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit2.wav", qfalse );
cgs.media.sfx_lghit3 = trap_S_RegisterSound( "sound/weapons/lightning/lg_hit3.wav", qfalse );
break;
CG_MissileHitWall
case WP_GAUNTLET:
// no explosion at LG impact, it is added with the beam
sfx = cgs.media.sfx_axeexp;
mod = cgs.media.axeExplosionModel;
mark = cgs.media.burnMarkShader;
radius = 8;
light = 50;
duration = 50;
lightColor[0] = 0.75;
lightColor[1] = 0.75;
lightColor[2] = 0.75;
break;
case WP_CHAINSAW:
// no explosion at LG impact, it is added with the beam
sfx = cgs.media.sfx_plasmaexp;
mod = cgs.media.chainsawExplosionModel;
mark = cgs.media.holeMarkShader;
radius = 4;
light = 50;
duration = 50;
lightColor[0] = 0.75;
lightColor[1] = 0.75;
lightColor[2] = 0.75;
break;
case WP_LIGHTNING:
// no explosion at LG impact, it is added with the beam
r = rand() & 3;
if ( r < 2 ) {
sfx = cgs.media.sfx_lghit2;
} else if ( r == 2 ) {
sfx = cgs.media.sfx_lghit1;
} else {
sfx = cgs.media.sfx_lghit3;
}
mod = cgs.media.lightningExplosionModel;
mark = cgs.media.holeMarkShader;
radius = 8;
light = 200;
duration = 50;
lightColor[0] = 0.5;
lightColor[1] = 0.75;
lightColor[2] = 1.0;
break;
What is happening is all 3 of the weapons are using the WP_GAUNTLET impact. If I saw the chainsaw and axe, it uses the chainsaw for all 3 weapons ect...