Weapons not using their correct case statements (impacts)

Locked
OoPpEe
Posts: 4
Joined: Fri Feb 25, 2005 2:44 am

Weapons not using their correct case statements (impacts)

Post by OoPpEe »

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...
ensiform
Posts: 93
Joined: Mon Jul 25, 2005 5:20 am

Post by ensiform »

where is WP_CHAINSAW and the others defined? let's see your enum in bg_public.h u know ~16 weaps is max... i think including WP_NONE.
OoPpEe
Posts: 4
Joined: Fri Feb 25, 2005 2:44 am

Post by OoPpEe »

I managed to get it fixed,
I changed the:
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 );

in each of the 3 weapons to:
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 );
tent->s.weapon = ent->s.weapon;

Adding the extra:
tent->s.weapon = ent->s.weapon;
fixed it

Yeah I know about the 16 weapon limit, sucks. I am trying to plan on how I would make WP_NONE into a weapon you can use, making it into the Quake 2 HyperBlaster. Easy enough to do, however would have to alot of if statements, like spectators ROF with it (as they would have it) to make it so they cannot fire (or # so high they can rarely fire), make weapon invisible (know how to already), make damage nulled if the owner is a spectator.
ensiform
Posts: 93
Joined: Mon Jul 25, 2005 5:20 am

Post by ensiform »

i wouldnt do that, WP_NONE is used for not having any weapon period, ie: dead.

technically ur only at 14/15 depending on how you count. so u could potentially add at least 1 more gun to base / ta.
Xamis
Posts: 4
Joined: Mon Feb 15, 2010 12:17 am

Re: Weapons not using their correct case statements (impacts)

Post by Xamis »

DOH
thread necromancy
you could always extend the weapons list to use two stats slots if you really have to have more than the current limit

ex.

Code: Select all

void BG_AddWeapon( int weapon, int stats[ ] )
{
  unsigned int  weaponList;
  
    // create one big list with from our 2
  weaponList = (unsigned int)stats[ STAT_WEAPONS ] | ((unsigned int)stats[ STAT_WEAPONS_EXT ] << 16 );
    // add that bit to our "bigger list"
  weaponList |= ( 1 << weapon );
    // statweapons 1 is the lower half part ( 0-15)
  stats[ STAT_WEAPONS ] = weaponList & 0x0000FFFF;
    // weapons2 is the upper part ( 17-31 )
  stats[ STAT_WEAPONS_EXT ] = ( weaponList & 0xFFFF0000 ) >> 16;
}
Locked