Jump to content

Help with Force Breach?


Recommended Posts

Posted

Had to rework most of my stuff on OpenJK after erasing a disk, and now Breach is messing up on me.

void ForceBreach(gentity_t *self)
{
trace_t tr;
vec3_t end, forward;
gentity_t *traceEnt;
qboolean targetLive = qfalse;
 
if (WP_CheckBreakControl(self))
{
return;
}
if (self->health <= 0)
{
return;
}
//FIXME: if mind trick 3 and aiming at an enemy need more force power
if (!WP_ForcePowerUsable(self, FP_TELEPATHY, 0))
{
return;
}
 
if (self->client->ps.weaponTime >= 800)
{//just did one!
return;
}
if (self->client->ps.saberLockTime > level.time)
{//FIXME: can this be a way to break out?
return;
}
 
AngleVectors(self->client->ps.viewangles, forward, NULL, NULL);
VectorNormalize(forward);
VectorMA(self->client->renderInfo.eyePoint, 2048, forward, end);
 
//Cause a distraction if enemy is not fighting
gi.trace(&tr, self->client->renderInfo.eyePoint, vec3_origin, vec3_origin, end, self->s.number, MASK_OPAQUE | CONTENTS_BODY, (EG2_Collision)0, 0);
if (tr.entityNum == ENTITYNUM_NONE || tr.fraction == 1.0 || tr.allsolid || tr.startsolid)
{
return;
}
 
traceEnt = &g_entities[tr.entityNum];
 
if (traceEnt->NPC && traceEnt->NPC->scriptFlags & SCF_NO_FORCE)
{
return;
}
 
if (targetLive
&& traceEnt->health > 0)
{//hit an organic non-player
traceEnt->s.powerups |= (1 << PW_FORCE_BREACH);
traceEnt->client->ps.powerups[PW_FORCE_BREACH] = level.time + 500;
if (traceEnt->s.powerups |= (1 << PW_FORCE_BREACH))
{
if (traceEnt->client->playerTeam != self->client->playerTeam)
{//an enemy
switch (self->client->ps.forcePowerLevel[FP_BREACH])
{
case FORCE_LEVEL_10:
case FORCE_LEVEL_9:
case FORCE_LEVEL_8:
case FORCE_LEVEL_7:
case FORCE_LEVEL_6:
case FORCE_LEVEL_5:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(traceEnt, FP_SPEED);
WP_ForcePowerStop(traceEnt, FP_DEADLYSIGHT);
WP_ForcePowerStop(traceEnt, FP_RAGE);
break;
case FORCE_LEVEL_4:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(traceEnt, FP_DEADLYSIGHT);
WP_ForcePowerStop(traceEnt, FP_RAGE);
break;
case FORCE_LEVEL_3:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(traceEnt, FP_RAGE);
break;
case FORCE_LEVEL_2:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(self, FP_ABSORB);
WP_ForcePowerStop(self, FP_PROTECT);
break;
case FORCE_LEVEL_1:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(self, FP_ABSORB);
WP_ForcePowerStop(self, FP_PROTECT);
break;
default:
break;
}
vec3_t eyeDir;
AngleVectors(traceEnt->client->renderInfo.eyeAngles, eyeDir, NULL, NULL);
VectorNormalize(eyeDir);
WP_ForcePowerStart(self, FP_BREACH, 0);
}
NPC_SetAnim(self, SETANIM_TORSO, BOTH_FORCELIGHTNING_START, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_RESTART | SETANIM_FLAG_HOLD);
}
self->client->ps.saberMove = self->client->ps.saberBounceMove = LS_READY;//don't finish whatever saber anim you may have been in
self->client->ps.saberBlocked = BLOCKED_NONE;
self->client->ps.weaponTime = 1000;
if (self->client->ps.forcePowersActive&(1 << FP_SPEED))
{
self->client->ps.weaponTime = floor(self->client->ps.weaponTime * g_timescale->value);
}
}
}
Posted

...so what is Force Breach? What is it supposed to do? What are you seeing happen? When does it happen? How often does it happen? What have you tried to fix it?

Posted

If you've played Knights of the Old Republic, Force Breach cancels out any self-buff you have on your character, so I'm trying to get it to where it cancels out any buff powers the target might currently have active.

 

As for what happens at this present moment, absolutely nothing, and crashes after a certain amount of time prior to casting it. I've tried using parts of the Force Grip code, but I can't remember what I did in the previous build that got it working.

Posted

So you lost your data? Since you'll have to release the source code anyway (as per the license) you should just upload it to github as you go, that way you'll have a backup.

Posted

That's seriously not a good sign :) If your mod runs okay in release mode but crashes in debug mode, then you likely have some uninitialized memory issues. You should use the debugger in Visual Studio to find out why it's crashing first!

Posted

I occasionally get the 'Debug Assertion Failed!' message, and other times, It'll just crash outright.

 

I did some more tweaking to Breach and the 'Release' version seems to work, but I'm worried that it'll crash on some areas in the final release. (If I ever do manage to finish it... :/ )

 

 

 

void ForceBreach(gentity_t *self)
{
trace_t tr;
vec3_t end, forward;
gentity_t *traceEnt;
 
if (WP_CheckBreakControl(self))
{
return;
}
if (self->health <= 0)
{
return;
}

if (!WP_ForcePowerUsable(self, FP_BREACH, 0))
{
return;
}
 
switch (self->client->ps.forcePowerLevel[FP_BREACH])
{
case FORCE_LEVEL_10:
case FORCE_LEVEL_9:
case FORCE_LEVEL_8:
case FORCE_LEVEL_7:
case FORCE_LEVEL_6:
case FORCE_LEVEL_5:
case FORCE_LEVEL_4:
forcePowerNeeded[FP_BREACH] = 5;
break;
case FORCE_LEVEL_3:
forcePowerNeeded[FP_BREACH] = 20;
break;
case FORCE_LEVEL_2:
case FORCE_LEVEL_1:
forcePowerNeeded[FP_BREACH] = 35;
break;
default:
break;
}
 
if (self->client->ps.saberLockTime > level.time)
{//FIXME: can this be a way to break out?
return;
}
 
AngleVectors(self->client->ps.viewangles, forward, NULL, NULL);
VectorNormalize(forward);
VectorMA(self->client->renderInfo.eyePoint, 2048, forward, end);
 
if (self->enemy)
{//I have an enemy
if (!self->enemy->message
&& !(self->flags&FL_NO_KNOCKBACK))
{//don't auto-pickup guys with keys
if (DistanceSquared(self->enemy->currentOrigin, self->currentOrigin) < FORCE_GRIP_DIST_SQUARED)
{//close enough to grab
float minDot = 0.5f;
if (self->s.number < MAX_CLIENTS)
{//player needs to be facing more directly
minDot = 0.2f;
}
if (InFront(self->enemy->currentOrigin, self->client->renderInfo.eyePoint, self->client->ps.viewangles, minDot)) //self->s.number || //NPCs can always lift enemy since we assume they're looking at them...?
{//need to be facing the enemy
if (gi.inPVS(self->enemy->currentOrigin, self->client->renderInfo.eyePoint))
{//must be in PVS
gi.trace(&tr, self->client->renderInfo.eyePoint, vec3_origin, vec3_origin, self->enemy->currentOrigin, self->s.number, MASK_SHOT, (EG2_Collision)0, 0);
if (tr.fraction == 1.0f || tr.entityNum == self->enemy->s.number)
{//must have clear LOS
traceEnt = self->enemy;
}
}
}
}
}
}
if (!traceEnt)
{//okay, trace straight ahead and see what's there
gi.trace(&tr, self->client->renderInfo.handLPoint, vec3_origin, vec3_origin, end, self->s.number, MASK_SHOT, (EG2_Collision)0, 0);
if (tr.entityNum >= ENTITYNUM_WORLD || tr.fraction == 1.0 || tr.allsolid || tr.startsolid)
{
return;
}
 
traceEnt = &g_entities[tr.entityNum];
}
 
if (traceEnt->NPC && traceEnt->NPC->scriptFlags & SCF_NO_FORCE)
{
return;
}
 
if (traceEnt->health > 0)
{//hit an organic non-player
traceEnt->s.powerups |= (1 << PW_FORCE_BREACH);
traceEnt->client->ps.powerups[PW_FORCE_BREACH] = level.time + 500;
if (traceEnt->client->playerTeam != self->client->playerTeam)
{//an enemy
if (traceEnt->s.powerups |= (1 << PW_FORCE_BREACH))
{
switch (self->client->ps.forcePowerLevel[FP_BREACH])
{
case FORCE_LEVEL_10:
case FORCE_LEVEL_9:
case FORCE_LEVEL_8:
case FORCE_LEVEL_7:
case FORCE_LEVEL_6:
case FORCE_LEVEL_5:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(traceEnt, FP_SPEED);
WP_ForcePowerStop(traceEnt, FP_DEADLYSIGHT);
WP_ForcePowerStop(traceEnt, FP_RAGE);
break;
case FORCE_LEVEL_4:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(traceEnt, FP_DEADLYSIGHT);
WP_ForcePowerStop(traceEnt, FP_RAGE);
break;
case FORCE_LEVEL_3:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
WP_ForcePowerStop(traceEnt, FP_RAGE);
break;
case FORCE_LEVEL_2:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
WP_ForcePowerStop(traceEnt, FP_PROTECT);
break;
case FORCE_LEVEL_1:
WP_ForcePowerStop(traceEnt, FP_ABSORB);
break;
default:
break;
}
}
}
vec3_t eyeDir;
AngleVectors(traceEnt->client->renderInfo.eyeAngles, eyeDir, NULL, NULL);
VectorNormalize(eyeDir);
WP_ForcePowerStart(self, FP_BREACH, 0);
}
NPC_SetAnim(self, SETANIM_TORSO, BOTH_FORCELIGHTNING_START, SETANIM_FLAG_OVERRIDE | SETANIM_FLAG_RESTART | SETANIM_FLAG_HOLD);
self->client->ps.saberMove = self->client->ps.saberBounceMove = LS_READY;//don't finish whatever saber anim you may have been in
self->client->ps.saberBlocked = BLOCKED_NONE;
self->client->ps.weaponTime = 1000;
if (self->client->ps.forcePowersActive&(1 << FP_SPEED))
{
self->client->ps.weaponTime = floor(self->client->ps.weaponTime * g_timescale->value);
}
}

 

 

 

Posted

@@Asgarath83 Yeah, I've been planning on doing Stasis after I've finished with Breach. I have a feeling that I'll need to make a new PowerUp type (PW_FORCE_STASIS) in order to both freeze enemies and play the .efx on them instead of the caster. 

 

Also yes, Breach cancels out Rage, Absorb, and Protect, but not Heal, since it heals you instantaneously at levels 4 and higher.

Posted

@@Asgarath83 Yeah, I've been planning on doing Stasis after I've finished with Breach. I have a feeling that I'll need to make a new PowerUp type (PW_FORCE_STASIS) in order to both freeze enemies and play the .efx on them instead of the caster. 

 

Also yes, Breach cancels out Rage, Absorb, and Protect, but not Heal, since it heals you instantaneously at levels 4 and higher.

understood :D Okay, i'll waiting. because for my Legacy of Kain mod, if you want to share code, i can use the stasis code for the spell called "incapacitate" that make paralysis. but i planned too that boss classes cannot be paralyzed and also player can break paralysis with a push or an absorb casting.

NOTE: i working on SP code. :\

Posted

I checked, and you appear to have fixed the erroneous code. tr.entNum isn't always a valid entity (sometimes it's ENTITYNUM_WORLD or possibly -1)

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...