Jump to content

From Concussion to Destruction (Help)


Recommended Posts

mmm, why you not take a pause from that and make the other new power you need? the solution to a problem appear when someone are not thinking to a problem same time, unconsapevole mind it's very powerful. :) also, if you learn other part of the code, maybe you can find something that can be useful for that dilemma.

I suggest you to take at the end of coding work the hardies part. more experience you have, more easy will be to fight with that.

however i now, i am editing the g_combat just know for debugging my code. the force powers are all in wp_saber and q_shared and g_combat. there are something also on cg_players about the force protect, \ sense \ absorb aura color..

Link to comment

Well, I tried everything...

 

 

@@eezstreet

I was stressed at the time I was working on this particular power, so I couldn't really give a clear answer as to what I was trying to do here.

 

How do you suppose a Fireball would work on JKA's engine? Obviously I can't do a simple copy/paste with the Concussion Rifle onto w_saber.cpp, as it would go in a different direction than the one I'm facing as soon as I, or another NPC would press the "Attack" button.

Wait. Share your code here. I think I know how to fix that.
Link to comment

 

void ForceDestructionShoot( gentity_t *self )
{
trace_t tr;
vec3_t start;
vec3_t end, forward;
gentity_t *traceEnt;
 
if ( self->health <= 0 )
{
return;
}
 
if ( !self->s.number && cg.zoomMode )
{//can't force lightning when zoomed in
return;
}
 
AngleVectors( self->client->ps.viewangles, forward, NULL, NULL );
VectorNormalize( forward );
 
VectorMA( self->client->renderInfo.handLPoint, NULL, forward, end );
ForceDestructionMissile( self );
}
 
static void ForceDestructionMissile( gentity_t *ent )
{//a fast rocket-like projectile
vec3_t dir;
vec3_t start;
gentity_t *traceEnt;
 
int damage = forceDestructionDamage[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
float vel = 3000;
 
WP_TraceSetStart( ent, start, vec3_origin, vec3_origin );//make sure our start point isn't on the other side of a wall
 
gentity_t *missile = CreateMissile( start, forwardVec, vel, 10000, ent, qfalse );
 
VectorCopy( forwardVec, dir );
VectorCopy( muzzle, start );
 
missile->classname = "destruct_proj";
missile->s.weapon = WP_DESTRUCTION;
missile->mass = 10;
 
// Make it easier to hit things
VectorSet( missile->maxs, ROCKET_SIZE, ROCKET_SIZE, ROCKET_SIZE );
VectorScale( missile->maxs, -1, missile->mins );
 
missile->damage = damage;
missile->dflags = DAMAGE_EXTRA_KNOCKBACK|DAMAGE_HEAVY_WEAP_CLASS;
 
missile->methodOfDeath = MOD_FORCE_DESTRUCTION;
missile->splashMethodOfDeath = MOD_FORCE_DESTRUCTION;
 
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
missile->splashDamage = floor((float)damage * 0.75f);
missile->splashRadius = forceDestructionRadius[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
 
// we don't want it to ever bounce
missile->bounceCount = 0;
 
if ( traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_GALAK_SHIELD] )
{
//has shield up
missile->damage = 0;
missile->splashDamage = 0;
}
 
int modPowerLevel = -1;
 
if ( missile->splashDamage 
|| missile->damage )
{
modPowerLevel = WP_AbsorbConversion(ent, ent->client->ps.forcePowerLevel[FP_ABSORB], ent, FP_DESTRUCTION, ent->client->ps.forcePowerLevel[FP_DESTRUCTION], 1);
}
 
if (modPowerLevel != -1)
{
if ( !modPowerLevel )
{
missile->damage = 0;
missile->splashDamage = 0;
}
else if ( modPowerLevel == 1 )
{
missile->damage = floor((float)damage/4.0f);
missile->splashDamage = floor((float)damage/4.0f);
}
else if ( modPowerLevel == 2 )
{
missile->damage = floor((float)damage/2.0f);
missile->splashDamage = floor((float)damage/2.0f);
}
else if ( modPowerLevel == 3 )
{
missile->damage = floor((float)damage/1.0f);
missile->splashDamage = floor((float)damage/1.0f);
}
else if ( modPowerLevel == 4 )
{
missile->damage = floor((float)damage/0.5f);
missile->splashDamage = floor((float)damage/0.5f);
}
else if ( modPowerLevel == 5 )
{
missile->damage = floor((float)damage/0.25f);
missile->splashDamage = floor((float)damage/0.25f);
}
else if ( modPowerLevel == 6 )
{
missile->damage = floor((float)damage/0.12f);
missile->splashDamage = floor((float)damage/0.12f);
}
else if ( modPowerLevel == 7 )
{
missile->damage = floor((float)damage/0.06f);
missile->splashDamage = floor((float)damage/0.06f);
}
else if ( modPowerLevel == 8 )
{
missile->damage = floor((float)damage/0.03f);
missile->splashDamage = floor((float)damage/0.03f);
}
else if ( modPowerLevel > 8 )
{
missile->damage = floor((float)damage/0.01f);
missile->splashDamage = floor((float)damage/0.01f);
}
}
}
 
void ForceDestruction( gentity_t *self )
{
gentity_t *traceEnt;
vec3_t forward;
trace_t tr;
 
if ( self->health <= 0 )
{
return;
}
 
if ( !self->s.number && (cg.zoomMode || in_camera) )
{
return;
}
 
if ( self->client->ps.leanofs )
{
return;
}
 
if (self->client->ps.forcePowersActive & (1 << FP_PROTECT) )
{
WP_ForcePowerStop( self, FP_PROTECT );
}
 
if (self->client->ps.forcePowersActive & (1 << FP_ABSORB) )
{
WP_ForcePowerStop( self, FP_ABSORB );
}
 
if ( self->client->ps.forcePowerLevel[FP_DESTRUCTION] <= FORCE_LEVEL_2 && self->client->ps.forcePower < 80 
|| self->client->ps.forcePowerLevel[FP_DESTRUCTION] > FORCE_LEVEL_2 && self->client->ps.forcePower < 40 
|| !WP_ForcePowerUsable( self, FP_DESTRUCTION, 0 ) )
{
return;
}
 
if ( self->client->ps.saberLockTime > level.time )
{//FIXME: can this be a way to break out?
return;
}
 
if ( self->client->ps.forcePowerLevel[FP_DESTRUCTION] <= FORCE_LEVEL_2 )
{
WP_ForcePowerStart( self, FP_DESTRUCTION, 80 );
NPC_SetAnim( self, SETANIM_TORSO, BOTH_FORCEPUSH, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_RESTART );
ForceDestructionShoot( self );
G_SoundOnEnt( self, CHAN_BODY, "sound/weapons/force/forcedestruct01.wav" );
}
 
if ( self->client->ps.forcePowerLevel[FP_DESTRUCTION] > FORCE_LEVEL_2 )
{
WP_ForcePowerStart( self, FP_DESTRUCTION, 40 );
NPC_SetAnim( self, SETANIM_TORSO, BOTH_FORCEPUSH, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD|SETANIM_FLAG_RESTART );
ForceDestructionShoot( self );
G_SoundOnEnt( self, CHAN_BODY, "sound/weapons/force/forcedestruct01.wav" );
}
 
}
Link to comment
  • 2 weeks later...

Sorry, I missed the above post. But the result is as I would suspect; you're using vectors from the weapons code which only get recalculated prior to firing a weapon, not using a power.

 

To fix this, add two more variables to ForceDestructionShoot:

vec3_t right, up;
Modify the AngleVectors call:

AngleVectors(self->client->ps.viewAngles, forward, right, up);
And directly afterwards, add a CalcMuzzlePoint call:

CalcMuzzlePoint(self, forward, right, up, muzzle);
Lastly, copy the correct forward vector so that the missile shoots in the correct direction.

VectorCopy(forward, forwardVec);
Just to clarify: all of these lines should appear one after another. Let me know if this works for you. :)
Link to comment

Sorry, I missed the above post. But the result is as I would suspect; you're using vectors from the weapons code which only get recalculated prior to firing a weapon, not using a power.

 

To fix this, add two more variables to ForceDestructionShoot:

vec3_t right, up;
Modify the AngleVectors call:

AngleVectors(self->client->ps.viewAngles, forward, right, up);
And directly afterwards, add a CalcMuzzlePoint call:

CalcMuzzlePoint(self, forward, right, up, muzzle);
Lastly, copy the correct forward vector so that the missile shoots in the correct direction.

VectorCopy(forward, forwardVec);
Just to clarify: all of these lines should appear one after another. Let me know if this works for you. :)

 

 

Error 1 error C3861: 'ForceDestructionMissile': identifier not found
 
I have no idea how to fix this.
Link to comment

Where is ForceDestructionMissile located, and where is this error coming from?

 

Never mind, fixed it... But now the game crashes whenever I try to fire it.

 

 

 

static void ForceDestructionMissile( gentity_t *ent )
{//a fast rocket-like projectile
vec3_t dir;
vec3_t start;
gentity_t *traceEnt;
 
int damage = forceDestructionDamage[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
float vel = 3000;
 
WP_TraceSetStart( ent, start, vec3_origin, vec3_origin );//make sure our start point isn't on the other side of a wall
 
gentity_t *missile = CreateMissile( start, forwardVec, vel, 10000, ent, qfalse );
 
VectorCopy( forwardVec, dir );
VectorCopy( muzzle, start );
 
missile->classname = "destruct_proj";
missile->s.weapon = FP_DESTRUCTION;
missile->mass = 10;
 
// Make it easier to hit things
VectorSet( missile->maxs, ROCKET_SIZE, ROCKET_SIZE, ROCKET_SIZE );
VectorScale( missile->maxs, -1, missile->mins );
 
missile->damage = damage;
missile->dflags = DAMAGE_EXTRA_KNOCKBACK|DAMAGE_HEAVY_WEAP_CLASS;
 
missile->methodOfDeath = MOD_FORCE_DESTRUCTION;
missile->splashMethodOfDeath = MOD_FORCE_DESTRUCTION;
 
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
missile->splashDamage = floor((float)damage * 0.75f);
missile->splashRadius = forceDestructionRadius[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
 
// we don't want it to ever bounce
missile->bounceCount = 0;
 
if ( traceEnt && traceEnt->client && traceEnt->client->ps.powerups[PW_GALAK_SHIELD] )
{
//has shield up
missile->damage = 0;
missile->splashDamage = 0;
}
 
int modPowerLevel = -1;
 
if ( missile->splashDamage 
|| missile->damage )
{
modPowerLevel = WP_AbsorbConversion(ent, ent->client->ps.forcePowerLevel[FP_ABSORB], ent, FP_DESTRUCTION, ent->client->ps.forcePowerLevel[FP_DESTRUCTION], 1);
}
 
if (modPowerLevel != -1)
{
if ( !modPowerLevel )
{
missile->damage = 0;
missile->splashDamage = 0;
}
else if ( modPowerLevel == 1 )
{
missile->damage = floor((float)damage/4.0f);
missile->splashDamage = floor((float)damage/4.0f);
}
else if ( modPowerLevel == 2 )
{
missile->damage = floor((float)damage/2.0f);
missile->splashDamage = floor((float)damage/2.0f);
}
else if ( modPowerLevel == 3 )
{
missile->damage = floor((float)damage/1.0f);
missile->splashDamage = floor((float)damage/1.0f);
}
else if ( modPowerLevel == 4 )
{
missile->damage = floor((float)damage/0.5f);
missile->splashDamage = floor((float)damage/0.5f);
}
else if ( modPowerLevel == 5 )
{
missile->damage = floor((float)damage/0.25f);
missile->splashDamage = floor((float)damage/0.25f);
}
else if ( modPowerLevel == 6 )
{
missile->damage = floor((float)damage/0.12f);
missile->splashDamage = floor((float)damage/0.12f);
}
else if ( modPowerLevel == 7 )
{
missile->damage = floor((float)damage/0.06f);
missile->splashDamage = floor((float)damage/0.06f);
}
else if ( modPowerLevel == 8 )
{
missile->damage = floor((float)damage/0.03f);
missile->splashDamage = floor((float)damage/0.03f);
}
else if ( modPowerLevel > 8 )
{
missile->damage = floor((float)damage/0.01f);
missile->splashDamage = floor((float)damage/0.01f);
}
}
}
 
void ForceDestructionShoot( gentity_t *self )
{
int ignore = self->s.number;
int traces = 0;
gentity_t *traceEnt;
vec3_t end, forward;
vec3_t right, up;
trace_t tr;
 
 
if ( self->health <= 0 )
{
return;
}
 
if ( !self->s.number && cg.zoomMode )
{//can't force lightning when zoomed in
return;
}
 
VectorMA( self->client->renderInfo.handLPoint, NULL, forward, end );
VectorNormalize( forward );
VectorCopy(forward, forwardVec);
AngleVectors(self->client->ps.viewangles, forward, right, up);
CalcMuzzlePoint(self, forward, right, up, muzzle, NULL);
traceEnt = &g_entities[tr.entityNum];
ForceDestructionMissile( self );
}
Link to comment

Hm, it's hard to say without setting up a debug rig. Try setting up some Com_Errors in strategic spots in the code to see where it might be crashing. You might also try commenting out where CalcMuzzlePoint is called from.

 

Run-Time Check Failure #3 - The variable 'traceEnt' is being used without being initialized.

Link to comment

Comment out the bits of code which have traceEnt. It doesn't look like it's really used, anyway.

 

I went through and took out all instances of traceEnt in the Destruction code, but now it's just shooting downward no matter what I press... We're making progress, at least.

 

 

static void ForceDestructionMissile( gentity_t *ent )
{//a fast rocket-like projectile
vec3_t start;
int damage = forceDestructionDamage[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
float vel = 2800;
 
VectorCopy( ent->client->renderInfo.handLPoint, start );
WP_TraceSetStart( ent, start, vec3_origin, vec3_origin );//make sure our start point isn't on the other side of a wall
 
gentity_t *missile = CreateMissile( start, forwardVec, vel, 10000, ent, qfalse );
 
missile->classname = "destruct_proj";
missile->s.weapon = WP_DESTRUCTION;
missile->mass = 10;
 
// Make it easier to hit things
VectorSet( missile->maxs, ROCKET_SIZE, ROCKET_SIZE, ROCKET_SIZE );
VectorScale( missile->maxs, -1, missile->mins );
 
missile->damage = damage;
missile->dflags = DAMAGE_EXTRA_KNOCKBACK|DAMAGE_HEAVY_WEAP_CLASS;
 
missile->methodOfDeath = MOD_FORCE_DESTRUCTION;
missile->splashMethodOfDeath = MOD_FORCE_DESTRUCTION;
 
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
missile->splashDamage = floor((float)damage * 0.75f);
missile->splashRadius = forceDestructionRadius[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
 
// we don't want it to ever bounce
missile->bounceCount = 0;
 
if ( ent && ent->client && ent->client->ps.powerups[PW_GALAK_SHIELD] )
{
//has shield up
missile->damage = 0;
missile->splashDamage = 0;
}
 
int modPowerLevel = -1;
 
if ( missile->splashDamage 
|| missile->damage )
{
modPowerLevel = WP_AbsorbConversion(ent, ent->client->ps.forcePowerLevel[FP_ABSORB], ent, FP_DESTRUCTION, ent->client->ps.forcePowerLevel[FP_DESTRUCTION], 1);
}
 
if (modPowerLevel != -1)
{
if ( !modPowerLevel )
{
missile->damage = 0;
missile->splashDamage = 0;
}
else if ( modPowerLevel == 1 )
{
missile->damage = floor((float)damage/4.0f);
missile->splashDamage = floor((float)damage/4.0f);
}
else if ( modPowerLevel == 2 )
{
missile->damage = floor((float)damage/2.0f);
missile->splashDamage = floor((float)damage/2.0f);
}
else if ( modPowerLevel == 3 )
{
missile->damage = floor((float)damage/1.0f);
missile->splashDamage = floor((float)damage/1.0f);
}
else if ( modPowerLevel == 4 )
{
missile->damage = floor((float)damage/0.5f);
missile->splashDamage = floor((float)damage/0.5f);
}
else if ( modPowerLevel == 5 )
{
missile->damage = floor((float)damage/0.25f);
missile->splashDamage = floor((float)damage/0.25f);
}
else if ( modPowerLevel == 6 )
{
missile->damage = floor((float)damage/0.12f);
missile->splashDamage = floor((float)damage/0.12f);
}
else if ( modPowerLevel == 7 )
{
missile->damage = floor((float)damage/0.06f);
missile->splashDamage = floor((float)damage/0.06f);
}
else if ( modPowerLevel == 8 )
{
missile->damage = floor((float)damage/0.03f);
missile->splashDamage = floor((float)damage/0.03f);
}
else if ( modPowerLevel > 8 )
{
missile->damage = floor((float)damage/0.01f);
missile->splashDamage = floor((float)damage/0.01f);
}
}
}
 
void ForceDestructionShoot( gentity_t *self )
{
vec3_t end, forward;
vec3_t right, up;
 
if ( self->health <= 0 )
{
return;
}
 
if ( !self->s.number && cg.zoomMode )
{//can't force lightning when zoomed in
return;
}
 
VectorMA( self->client->renderInfo.handLPoint, NULL, forward, end );
VectorNormalize( forward );
VectorCopy(forward, forwardVec);
AngleVectors(self->client->ps.viewangles, forward, right, up);
CalcMuzzlePoint(self, forward, right, up, muzzle, NULL);
ForceDestructionMissile( self );
}
Asgarath83 likes this
Link to comment

I gave it another look. Try this:

 

static void ForceDestructionMissile( gentity_t *ent )
{//a fast rocket-like projectile
vec3_t start;
vec3_t dir;
int damage = forceDestructionDamage[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
float vel = 2800;
 
VectorCopy( ent->client->renderInfo.handLPoint, start );
AngleVectors( ent->client->ps.viewangles, dir, NULL, NULL);

WP_TraceSetStart( ent, start, vec3_origin, vec3_origin );//make sure our start point isn't on the other side of a wall
 
gentity_t *missile = CreateMissile( start, dir, vel, 10000, ent, qfalse );
 
missile->classname = "destruct_proj";
missile->s.weapon = WP_DESTRUCTION;
missile->mass = 10;
 
// Make it easier to hit things
VectorSet( missile->maxs, ROCKET_SIZE, ROCKET_SIZE, ROCKET_SIZE );
VectorScale( missile->maxs, -1, missile->mins );
 
missile->damage = damage;
missile->dflags = DAMAGE_EXTRA_KNOCKBACK|DAMAGE_HEAVY_WEAP_CLASS;
 
missile->methodOfDeath = MOD_FORCE_DESTRUCTION;
missile->splashMethodOfDeath = MOD_FORCE_DESTRUCTION;
 
missile->clipmask = MASK_SHOT | CONTENTS_LIGHTSABER;
missile->splashDamage = floor((float)damage * 0.75f);
missile->splashRadius = forceDestructionRadius[ent->client->ps.forcePowerLevel[FP_DESTRUCTION]];
 
// we don't want it to ever bounce
missile->bounceCount = 0;
 /*
if ( ent && ent->client && ent->client->ps.powerups[PW_GALAK_SHIELD] )
{
//has shield up
missile->damage = 0;
missile->splashDamage = 0;
}
 */
// NOTENOTE: the above doesn't actually make any sense
int modPowerLevel = -1;
 
if ( missile->splashDamage 
|| missile->damage )
{
modPowerLevel = WP_AbsorbConversion(ent, ent->client->ps.forcePowerLevel[FP_ABSORB], ent, FP_DESTRUCTION, ent->client->ps.forcePowerLevel[FP_DESTRUCTION], 1);
}
 
if (modPowerLevel != -1)
{
if ( !modPowerLevel )
{
missile->damage = 0;
missile->splashDamage = 0;
}
else if ( modPowerLevel == 1 )
{
missile->damage = floor((float)damage/4.0f);
missile->splashDamage = floor((float)damage/4.0f);
}
else if ( modPowerLevel == 2 )
{
missile->damage = floor((float)damage/2.0f);
missile->splashDamage = floor((float)damage/2.0f);
}
else if ( modPowerLevel == 3 )
{
missile->damage = floor((float)damage/1.0f);
missile->splashDamage = floor((float)damage/1.0f);
}
else if ( modPowerLevel == 4 )
{
missile->damage = floor((float)damage/0.5f);
missile->splashDamage = floor((float)damage/0.5f);
}
else if ( modPowerLevel == 5 )
{
missile->damage = floor((float)damage/0.25f);
missile->splashDamage = floor((float)damage/0.25f);
}
else if ( modPowerLevel == 6 )
{
missile->damage = floor((float)damage/0.12f);
missile->splashDamage = floor((float)damage/0.12f);
}
else if ( modPowerLevel == 7 )
{
missile->damage = floor((float)damage/0.06f);
missile->splashDamage = floor((float)damage/0.06f);
}
else if ( modPowerLevel == 8 )
{
missile->damage = floor((float)damage/0.03f);
missile->splashDamage = floor((float)damage/0.03f);
}
else if ( modPowerLevel > 8 )
{
missile->damage = floor((float)damage/0.01f);
missile->splashDamage = floor((float)damage/0.01f);
}
}
}
 
void ForceDestructionShoot( gentity_t *self )
{
if ( self->health <= 0 )
{
return;
}
 
if ( !self->s.number && cg.zoomMode )
{//can't force lightning when zoomed in
return;
}
 
ForceDestructionMissile( self );
}
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...