Jump to content

Ask me anything about the Jedi source code


Recommended Posts

Posted

Have you checked the source code of the Serenity Jedi Engine Mod?

The source for that doesn't exist to my knowledge. It was claimed as having been lost but the game is still released unfortunately without the source.
Posted

Trying to make dismember guns and i am half on my way .. still after killing the enemy his body doesnt react on eny hitloc mechanic. Even if i shot the bodies head g_debugdamage 1 code shows me that hitloc is set to - none. Is any way to fix that? I also find out that if g_sabermorerealistic is set to the default 0 (i think it is default value) saber is not using hit_loc as well.. only on the hands and arms. Someone knows where i can find the code fot the g_sabermorerealistic cheat command and how to fix this body issue? It is not like i want to shot the bodies. If i will shot the enemy with flechette for example - all of thoise shots will dismember the enemy into pieces. 

find on code all entry for g_saberrealisticcombat function

there is something that maybe can like you on wp_saber.cpp

 

pretty long and complex code, but you should check all the:

qboolean WP_SaberApplyDamage

 

function contains

    if ( victim->client
                            && (victim->s.weapon == WP_SABER || (victim->client->NPC_class==CLASS_REBORN) || (victim->client->NPC_class==CLASS_WAMPA))
                            && !g_saberRealisticCombat->integer )
                        {//dmg vs other saber fighters is modded by hitloc and capped
                            totalDmg[i] *= damageModifier[hitLoc[i]];
                            if ( hitLoc[i] == HL_NONE )
                            {
                                maxDmg = 33*baseDamage;
                            }
                            else
                            {
                                maxDmg = 50*hitLocHealthPercentage[hitLoc[i]]*baseDamage;//*victim->client->ps.stats[STAT_MAX_HEALTH]*2.0f;
                            }
                            if ( maxDmg < totalDmg[i] )
                            {
                                totalDmg[i] = maxDmg;
                            }
                            //dFlags |= DAMAGE_NO_HIT_LOC;
                        }
                        //clamp the dmg
                        if ( victim->s.weapon != WP_SABER )
                        {//clamp the dmg between 25 and maxhealth
                            /*
                            if ( totalDmg[i] > victim->max_health )
                            {
                                totalDmg[i] = victim->max_health;
                            }
                            else */if ( totalDmg[i] < 25 )
                            {
                                totalDmg[i] = 25;
                            }
                            if ( totalDmg[i] > 100 )//+(50*g_spskill->integer) )
                            {//clamp using same adjustment as in NPC_Begin
                                totalDmg[i] = 100;//+(50*g_spskill->integer);
                            }
                        }
                        else
                        {//clamp the dmg between 5 and 100
                            if ( !victim->s.number && totalDmg[i] > 50 )
                            {//never do more than half full health damage to player
                                //prevents one-hit kills
                                totalDmg[i] = 50;
                            }
                            else if ( totalDmg[i] > 100 )
                            {
                                totalDmg[i] = 100;
                            }
                            else
                            {
                                if ( totalDmg[i] < 5 )
                                {
                                    totalDmg[i] = 5;
                                }
                            }
                        }
                    }
 
Smoo likes this
Posted

also this on g_combat

 

static qboolean G_Dismemberable2( gentity_t *self, int hitLoc )
{
    if ( self->client->dismembered )
    {//cannot dismember me right now
        return qfalse;
    }
    if ( !debug_subdivision->integer && g_saberRealisticCombat->integer < 2 )
    {
        if ( g_dismemberProbabilities->value <= 0.0f )
        {//add the passed-in damage to the locationDamage array, check to see if it's taken enough damage to actually dismember
            if ( self->locationDamage[hitLoc] < (self->client->ps.stats[STAT_MAX_HEALTH]*hitLocHealthPercentage[hitLoc]) )
            {//this location has not taken enough damage to dismember
                return qfalse;
            }
        }
    }
    return qtrue;
}
 
Smoo likes this
  • 2 months later...
Posted

Is it possible to create a complex Cinematic fight with Icarus without adding every move as an animation, @@MGummelt? At the moment, I've looked at some scripts, and it looks like no script actually triggers a real attack, but fakes it by just playing an animation.

General Howard likes this
Posted

Hey, just made an account for JKHub to respond to a thread about manual saber blocking and figured I'd offer up my insights if anyone had any questions about the Jedi Outcast or Jedi Academy source code (SP or MP). It's been almost 15 years since I've written or even seen most of it, but hopefully if you ask me a specific question about a specific chunk of code (copy/paste a chunk or gimme a file name and line number) I can at least try to jog my memory and speak intelligently about it. ;)

 

I'll try to check back if people have questions.

@@MGummelt

 

How high does the Jedi Academy saber skill levels go to?

 

Does it only go up to 3? Or do they both go higher?

 

(I'm talking about FP_SABER_DEFENSE and FP_SABER_OFFENSE)

  • 2 months later...
Posted

I dont know if this thread is no longer active but i have a small question about dismember the enemies with the saber. If I will spawn 20 enemies on my map not all of them have working dismember - not like the Jedi Outcast .. this game has no limit with that. 

But i found out that Jk3 has this weird issue only with the lightsaber. When i dismember someone with the guns (I coded weapons to dismember enemies) and when i use script - everyone dismember. Lightsaber has this weird issue - when i kill 20 enemies the hitloc for lightsaber turns off. How to fix this or how to increase the limit of the entities that has wroking hitloc system to make saber work fine every time?

Posted

@@MGummelt - so we are having a discussion on Discord about the in-game size of the players in Star Wars Jedi Outcast/Jedi Academy...

 

Legacy Quake3 documentation states the Game Units are: 8 game units equal 1 foot. Other sources stated that Q3 player models were 56 units tall... thus 7 feet tall using that scale.

 

Please tell us... do Jedi Outcast and Jedi Academy use that same scale for game units

(8 game units = 1 foot), or did Raven change the in-game scale? In 3dsMax the skeleton and Kyle are 100 units tall (to tip of his skull... hair is a smidge more) and ModView ruler shows Kyle at ~ 64 units tall. So by that standard Kyle would be 8 feet tall in game units. Is this correct?

Smoo likes this
Posted

@@MGummelt - so we are having a discussion on Discord about the in-game size of the players in Star Wars Jedi Outcast/Jedi Academy...

 

Legacy Quake3 documentation states the Game Units are: 8 game units equal 1 foot. Other sources stated that Q3 player models were 56 units tall... thus 7 feet tall using that scale.

 

Please tell us... do Jedi Outcast and Jedi Academy use that same scale for game units

(8 game units = 1 foot), or did Raven change the in-game scale? In 3dsMax the skeleton and Kyle are 100 units tall (to tip of his skull... hair is a smidge more) and ModView ruler shows Kyle at ~ 64 units tall. So by that standard Kyle would be 8 feet tall in game units. Is this correct?

 

Seems like a player scale of 100 equals to about 64 units tall.

 

 

shot0018.jpg

 

 

If we go with the calculation that 64 units = 1.80 meters (which is the scale I generally use for everything), then 8 units equal to 22.5 cm, which is a bit more than 2/3 of one "international" foot measure (30.48 cm) - exactly 73.8% of one foot.

Makes sense that Kyle isn't 2.40 meters tall this way :P

Posted

Don't expect that MGummelt will respond soon. The last time he was online was in August, and who knows if he has any time or interest at the moment to return here.

Smoo likes this
Posted

Seems like a player scale of 100 equals to about 64 units tall.

 

If we go with the calculation that 64 units = 1.80 meters (which is the scale I generally use for everything), then 8 units equal to 22.5 cm, which is a bit more than 2/3 of one "international" foot measure (30.48 cm) - exactly 73.8% of one foot.

Makes sense that Kyle isn't 2.40 meters tall this way :P

This is the correct answer.

 

Back then, we used a height of 64 units for player height, because it divided nicely into 8 sets of 8 units each. Later games (COD, for example), players are 72 units high (because 6 feet is 72 inches, so this made a nice, neat 1 unit in radiant = 1 inch).

 

\Wookipedia says is Kyle's height of 1.8 meters (5'-11"). @@MGummelt

Yes, but Kyle’s boots have a one-inch heal. ;)

 

Player characters are always 6 feet tall, regardless of what other sources say. :)

Smoo likes this
Posted

I dont know if this thread is no longer active but i have a small question about dismember the enemies with the saber. If I will spawn 20 enemies on my map not all of them have working dismember - not like the Jedi Outcast .. this game has no limit with that. 

But i found out that Jk3 has this weird issue only with the lightsaber. When i dismember someone with the guns (I coded weapons to dismember enemies) and when i use script - everyone dismember. Lightsaber has this weird issue - when i kill 20 enemies the hitloc for lightsaber turns off. How to fix this or how to increase the limit of the entities that has wroking hitloc system to make saber work fine every time?

Hmm, I don’t recall there being a limit to the number of dismemberments - this doesn’t happen to me when I play the Ladder map, for example - I can dismember every AI that spawns. Are you keeping the corpses or pieces around an abnormally long time? Does it stop working 100% of the time after 20 dismembered characters? If so, you should be able to debug the 21st character and see where in the code it rejects the dismemberment.

Xioth likes this
Posted

@MrGummelt

Ok! I Am 100% sure that this is code issue. And i may found the issue:

In the wp_saber.cpp i found this lines and most importantly i found one line that i will select here with red font (I am not coder but maybe We will found a solution to fix this)

 

 

qboolean WP_SaberDamageEffects( trace_t *tr, const vec3_t start, float length, float dmg, vec3_t dmgDir, vec3_t bladeVec, int enemyTeam, saberType_t saberType, saberInfo_t *saber, int bladeNum )

{
 
int hitEntNum[MAX_G2_COLLISIONS];
for ( int hen = 0; hen < MAX_G2_COLLISIONS; hen++ )
{
hitEntNum[hen] = ENTITYNUM_NONE;
}
//NOTE: = {0} does NOT work on anything but bytes?
float hitEntDmgAdd[MAX_G2_COLLISIONS] = {0};
float hitEntDmgSub[MAX_G2_COLLISIONS] = {0};
vec3_t hitEntPoint[MAX_G2_COLLISIONS];
vec3_t hitEntNormal[MAX_G2_COLLISIONS];
vec3_t bladeDir;
float hitEntStartFrac[MAX_G2_COLLISIONS] = {0};
int trHitLoc[MAX_G2_COLLISIONS] = {HL_NONE};//same as 0
int trDismemberLoc[MAX_G2_COLLISIONS] = {HL_NONE};//same as 0
qboolean trDismember[MAX_G2_COLLISIONS] = {qfalse};//same as 0
int i,z;
int numHitEnts = 0;
float distFromStart,doDmg;
int hitEffect = 0;
const char *trSurfName;
gentity_t *hitEnt;
 
VectorNormalize2( bladeVec, bladeDir );
 
for (z=0; z < MAX_G2_COLLISIONS; z++)
{
if ( tr->G2CollisionMap[z].mEntityNum == -1 )
{//actually, completely break out of this for loop since nothing after this in the aray should ever be valid either
continue;//break;//
}
 
CCollisionRecord &coll = tr->G2CollisionMap[z];
//distFromStart = Distance( start, coll.mCollisionPosition );
distFromStart = coll.mDistance;
 
/*
//FIXME: (distFromStart/length) is not guaranteed to be from 0 to 1... *sigh*...
if ( length && saberHitFraction < 1.0f && (distFromStart/length) < 1.0f && (distFromStart/length) > saberHitFraction )
{//a saber was hit before this point, don't count it
#ifndef FINAL_BUILD
if ( d_saberCombat->integer )
{
gi.Printf( S_COLOR_MAGENTA"rejecting G2 collision- %4.2f farther than saberHitFraction %4.2f\n", (distFromStart/length), saberHitFraction  );
}
#endif
continue;
}
*/
 
for ( i = 0; i < numHitEnts; i++ )
{
if ( hitEntNum == coll.mEntityNum )
{//we hit this ent before
//we'll want to add this dist
hitEntDmgAdd = distFromStart;
break;
}
}
if ( i == numHitEnts )
{//first time we hit this ent
if ( numHitEnts == MAX_G2_COLLISIONS )
{//hit too many damn ents!
continue;
}
hitEntNum[numHitEnts] = coll.mEntityNum;
if ( !coll.mFlags )
{//hmm, we came out first, so we must have started inside
//we'll want to subtract this dist
hitEntDmgAdd[numHitEnts] = distFromStart;
}
else
{//we're entering the model
//we'll want to subtract this dist
hitEntDmgSub[numHitEnts] = distFromStart;
}
//keep track of how far in the damage was done
hitEntStartFrac[numHitEnts] = hitEntDmgSub[numHitEnts]/length;
//remember the entrance point
VectorCopy( coll.mCollisionPosition, hitEntPoint[numHitEnts] );
//remember the normal of the face we hit
VectorCopy( coll.mCollisionNormal, hitEntNormal[numHitEnts] );
VectorNormalize( hitEntNormal[numHitEnts] );
 
//do the effect
 
//FIXME: check material rather than team?
hitEnt = &g_entities[hitEntNum[numHitEnts]];
if ( hitEnt
&& hitEnt->client
&& coll.mModelIndex > 0 )
{//hit a submodel on the enemy, not their actual body!
if ( !WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitOtherEffect )
{
hitEffect = saber->hitOtherEffect;
}
else if ( WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitOtherEffect2 )
{
hitEffect = saber->hitOtherEffect2;
}
else
{
hitEffect = G_EffectIndex( hit_sparks );
}
}
else
{
if ( !WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitPersonEffect )
{
hitEffect = saber->hitPersonEffect;
}
else if ( WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitPersonEffect2 )
{
hitEffect = saber->hitPersonEffect2;
}
else
{
hitEffect = G_EffectIndex( hit_blood_sparks );
}
}
if ( hitEnt != NULL )
{
if ( hitEnt->client )
{
class_t npc_class = hitEnt->client->NPC_class;
if ( npc_class == CLASS_SEEKER || npc_class == CLASS_PROBE || npc_class == CLASS_MOUSE || npc_class == CLASS_REMOTE ||
     npc_class == CLASS_GONK || npc_class == CLASS_R2D2 || npc_class == CLASS_R5D2 ||
     npc_class == CLASS_PROTOCOL || npc_class == CLASS_MARK1 || npc_class == CLASS_MARK2 ||
     npc_class == CLASS_INTERROGATOR || npc_class == CLASS_ATST || npc_class == CLASS_SENTRY )
{
if ( !WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitOtherEffect )
{
hitEffect = saber->hitOtherEffect;
}
else if ( WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitOtherEffect2 )
{
hitEffect = saber->hitOtherEffect2;
}
else
{
hitEffect = G_EffectIndex( hit_sparks );
}
}
}
else
{
// So sue me, this is the easiest way to check to see if this is the turbo laser from t2_wedge,
// in which case I don't want the saber effects goin off on it.
if ( (hitEnt->flags&FL_DMG_BY_HEAVY_WEAP_ONLY)
&& hitEnt->takedamage == qfalse
&& Q_stricmp( hitEnt->classname, "misc_turret" ) == 0 )
{
continue;
}
else
{
if ( dmg )
{//only do these effects if actually trying to damage the thing...
if ( (hitEnt->svFlags&SVF_BBRUSH)//a breakable brush
&& ( (hitEnt->spawnflags&1)//INVINCIBLE
||(hitEnt->flags&FL_DMG_BY_HEAVY_WEAP_ONLY) )//HEAVY weapon damage only
)
{//no hit effect (besides regular client-side one)
hitEffect = 0;
}
else
{
if ( !WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitOtherEffect )
{
hitEffect = saber->hitOtherEffect;
}
else if ( WP_SaberBladeUseSecondBladeStyle( saber, bladeNum )
&& saber->hitOtherEffect2 )
{
hitEffect = saber->hitOtherEffect2;
}
else
{
hitEffect = G_EffectIndex( hit_sparks );
}
}
}
}
}
}
 
//FIXME: play less if damage is less?
if ( !g_saberNoEffects )
{
if ( hitEffect != 0 )
{
//FIXME: when you have multiple blades hitting someone for many sequential server frames, this can get a bit chuggy!
G_PlayEffect( hitEffect, coll.mCollisionPosition, coll.mCollisionNormal );
}
}
 
//Get the hit location based on surface name
if ( (hitLoc[hitEntNum[numHitEnts]] == HL_NONE && trHitLoc[numHitEnts] == HL_NONE)
|| (hitDismemberLoc[hitEntNum[numHitEnts]] == HL_NONE && trDismemberLoc[numHitEnts] == HL_NONE)
|| (!hitDismember[hitEntNum[numHitEnts]] && !trDismember[numHitEnts]) )
{//no hit loc set for this ent this damage cycle yet
//FIXME: find closest impact surf *first* (per ent), then call G_GetHitLocFromSurfName?
//FIXED: if hit multiple ents in this collision record, these trSurfName, trDismember and trDismemberLoc will get stomped/confused over the multiple ents I hit
trSurfName = gi.G2API_GetSurfaceName( &g_entities[coll.mEntityNum].ghoul2[coll.mModelIndex], coll.mSurfaceIndex );
trDismember[numHitEnts] = G_GetHitLocFromSurfName( &g_entities[coll.mEntityNum], trSurfName, &trHitLoc[numHitEnts], coll.mCollisionPosition, dmgDir, bladeDir, MOD_SABER, saberType );
if ( trDismember[numHitEnts] )
{
trDismemberLoc[numHitEnts] = trHitLoc[numHitEnts];
}
/*
if ( trDismember[numHitEnts] )
{
Com_Printf( S_COLOR_RED"Okay to dismember %s on ent %d\n", hitLocName[trDismemberLoc[numHitEnts]], hitEntNum[numHitEnts] );
}
else
{
Com_Printf( "Hit (no dismember) %s on ent %d\n", hitLocName[trHitLoc[numHitEnts]], hitEntNum[numHitEnts] );
}
*/
}
numHitEnts++;
}
}

 



Ok now the observations - THIS Line is (i am 100% sure) for the entities (Mostly for npc's because they have hitloc system) that are one of the 20th - 40th etc. loaded glm model on the map. I dont know if this for optimalization purpose but for some reason game turns off the dismember for npc's completely. It hit limit but i dont know what is this limit and where i can increase it. The best solution would be to remove this system COMPLETELY. And now some weird stuff..  i was checking some things and see how they works in the game and i end up confused... When i removed these lines from the code - wp_saber.cpp

2275 to 2299 something weird... happend. The enemies are now completely not dismember able... ALL of them. So it screwed up the npc's that were working. I turned on the g_debugdamage code  and i see this 

UT3BdHI.jpg

Hitloc shows -none- so game doesnt reconize the saber hit as the dismember hit. .. and the this is not the weirdest part...

in the begining of the code i changed the 
 

float hitEntStartFrac[MAX_G2_COLLISIONS] = {0};
int trHitLoc[MAX_G2_COLLISIONS] = {HL_NONE};//same as 0  HL_MAX
int trDismemberLoc[MAX_G2_COLLISIONS] = {HL_NONE};//same as 0 to HL_MAX
qboolean trDismember[MAX_G2_COLLISIONS] = {qfalse};//same as 0

 

 

Aaaaaandddd... this is the part i am 100% SURE that these lines in this code optimalize the game to turn of the dismember for reaching the limit or bytes that game is using. Blocks only for saber.. of course.

The enemies after this change.... are completely invincible because the hitloc on the saber .. shows (null). I created a bug (for observation purpose of course) and i cant kill the enemies... THIS IS NOT TRUE because ENEMIES with working dismemberment (as i said in one of the threads .. i played my cloud city map so often that i remember which enemy i can dismember and which not) ARE DYING WITH THE SABER *Mindblow* Soooo the enemies with not working dismember are not dying with the lightsaber hit but the guys with the dismember working - are dying.. with dismember. 

Here are screens to prove it to all of you.

ySt0Qvu.jpg
pYs6jEV.jpg
stPUPjC.jpg
apQFNrs.jpg
8ApVfjE.jpg
VRN8TJi.jpg

AAAAAA how to fix this!!!! Grrryyyyrrrrrwwrwrw

Smoo likes this
Posted

 

@MrGummelt

 

Ok! I Am 100% sure that this is code issue. And i may found the issue:

 

In the wp_saber.cpp i found this lines and most importantly i found one line that i will select here with red font (I am not coder but maybe We will found a solution to fix this)

 

 

 

 

 

 

Ok now the observations - THIS Line is (i am 100% sure) for the entities (Mostly for npc's because they have hitloc system) that are one of the 20th - 40th etc. loaded glm model on the map. I dont know if this for optimalization purpose but for some reason game turns off the dismember for npc's completely. It hit limit but i dont know what is this limit and where i can increase it. The best solution would be to remove this system COMPLETELY. And now some weird stuff..  i was checking some things and see how they works in the game and i end up confused... When i removed these lines from the code - wp_saber.cpp

 

2275 to 2299 something weird... happend. The enemies are now completely not dismember able... ALL of them. So it screwed up the npc's that were working. I turned on the g_debugdamage code  and i see this 

 

UT3BdHI.jpg

 

Hitloc shows -none- so game doesnt reconize the saber hit as the dismember hit. .. and the this is not the weirdest part...

 

in the begining of the code i changed the 

 

 

Aaaaaandddd... this is the part i am 100% SURE that these lines in this code optimalize the game to turn of the dismember for reaching the limit or bytes that game is using. Blocks only for saber.. of course.

 

The enemies after this change.... are completely invincible because the hitloc on the saber .. shows (null). I created a bug (for observation purpose of course) and i cant kill the enemies... THIS IS NOT TRUE because ENEMIES with working dismemberment (as i said in one of the threads .. i played my cloud city map so often that i remember which enemy i can dismember and which not) ARE DYING WITH THE SABER *Mindblow* Soooo the enemies with not working dismember are not dying with the lightsaber hit but the guys with the dismember working - are dying.. with dismember. 

 

Here are screens to prove it to all of you.

 

ySt0Qvu.jpg

pYs6jEV.jpg

stPUPjC.jpg

apQFNrs.jpg

8ApVfjE.jpg

VRN8TJi.jpg

 

AAAAAA how to fix this!!!! Grrryyyyrrrrrwwrwrw

 

 

I understand that it is annoying.. but..

 

450cad08717f32f05faa5ec65e63bb71.png

 

4ceff0b0128591267963dc056708f79b.png

Langerd, Xioth, SomaZ and 6 others like this
Posted
float hitEntStartFrac[MAX_G2_COLLISIONS] = {0};
int trHitLoc[MAX_G2_COLLISIONS] = {HL_NONE};//same as 0  HL_MAX
int trDismemberLoc[MAX_G2_COLLISIONS] = {HL_NONE};//same as 0 to HL_MAX
qboolean trDismember[MAX_G2_COLLISIONS] = {qfalse};//same as 0

 

I'll have to look at the code to see if I see any issues, but I can tell you that changing the HL_NONE above to HL_MAX is not a good idea.  Those lines are declaring and initializing arrays of data - basically creating an array of size MAX_G2_COLLISIONS and filling it in with blank data.  By setting them to HL_MAX instead of HL_NONE, all you're doing is initializing those arrays to something other than 0, which would make the code think that every part of the array has already been filled in with a hit location, which would make it think it's out of collisions.

 

Without looking at your code, all I can imagine is that whatever you're doing to cause hit location/dismemberment with guns is filling up this array (is MAX_G2_COLLISIONS == 20?) and somehow your code is not clearing that array for the next frame as it should.  I'd look and see where those arrays are referenced and find where they are getting cleared/reset back to their default values (0, HL_NONE, HL_NONE and qfalse, respectively).  That should be happening at the end or start of each frame somewhere.  If those global arrays are never cleared, they will fill up and you will no longer get any more valid hitlocs or dismemberments.

Boothand, Noodle and Smoo like this
Posted

I'll have to look at the code to see if I see any issues, but I can tell you that changing the HL_NONE above to HL_MAX is not a good idea. Those lines are declaring and initializing arrays of data - basically creating an array of size MAX_G2_COLLISIONS and filling it in with blank data. By setting them to HL_MAX instead of HL_NONE, all you're doing is initializing those arrays to something other than 0, which would make the code think that every part of the array has already been filled in with a hit location, which would make it think it's out of collisions.

 

Without looking at your code, all I can imagine is that whatever you're doing to cause hit location/dismemberment with guns is filling up this array (is MAX_G2_COLLISIONS == 20?) and somehow your code is not clearing that array for the next frame as it should. I'd look and see where those arrays are referenced and find where they are getting cleared/reset back to their default values (0, HL_NONE, HL_NONE and qfalse, respectively). That should be happening at the end or start of each frame somewhere. If those global arrays are never cleared, they will fill up and you will no longer get any more valid hitlocs or dismemberments.

The point is i always had this issue in jk3 - but not in jk2.

 

Check it by yourself - spawn 20-30 enemies and just try kill them all. I bet that some guys wont dismember. I rly hope to find a way to remove this code fence.

It mostly happens on the large maps too.

Posted

I FOUND THE ANSWER!!! The change of the code is simple 

In the beginning of the wp_saber.cpp we have line like this - 
 

#define JK2_RAGDOLL_GRIPNOHEALTH
 
#define MAX_SABER_VICTIMS 100
static int victimEntityNum[MAX_SABER_VICTIMS];
static float totalDmg[MAX_SABER_VICTIMS];
static vec3_t dmgDir[MAX_SABER_VICTIMS];
static vec3_t dmgNormal[MAX_SABER_VICTIMS];
static vec3_t dmgBladeVec[MAX_SABER_VICTIMS];
static vec3_t dmgSpot[MAX_SABER_VICTIMS];
static float dmgFraction[MAX_SABER_VICTIMS];
static int hitLoc[MAX_SABER_VICTIMS];
static qboolean hitDismember[MAX_SABER_VICTIMS];
static int hitDismemberLoc[MAX_SABER_VICTIMS];
static vec3_t saberHitLocation, saberHitNormal={0,0,1.0};
static float saberHitFraction;
static float sabersCrossed;
static int saberHitEntity;
static int numVictims = 0;


We must change : #define MAX_SABER_VICTIMS 100

i change to 600 and it works fine. No issues so far - And for bonus i played entire cloud city map with corpseremoval time set to 0. Every enemy is dismemberable with the saber! 

Many thanks :) (i will check the second thing - what will happen if i will set this value to 1 or 0) .
Noodle likes this
Posted

So does this only happen if you set the corpses to never remove? I had asked that earlier...

No. It only happend after multiple enemies on the map - already spawned - around 20 but it acted kinda weird. When 30 npc's were spawning in the begining of my map (so instantly when i play the map) it is random which npc will be like kebab and which not. (but not exactly.. as i said before - every enemy i killed on my map i remembered which will lose arm and which will not)

 

The game is removing this likely to optimimalize itself... And it happens only with the lightsaber.

Posted

No. It only happend after multiple enemies on the map - already spawned - around 20 but it acted kinda weird. When 30 npc's were spawning in the begining of my map (so instantly when i play the map) it is random which npc will be like kebab and which not. (but not exactly.. as i said before - every enemy i killed on my map i remembered which will lose arm and which will not)

 

The game is removing this likely to optimimalize itself... And it happens only with the lightsaber.

 

Well, that doesn't make any sense.  MAX_SABER_VICTIMS is 16 in the vanilla code, it's not 100.  I don't know what codebase you're using.  It that OpenJK or something?

 

The victimEntityNum array exists just to prevent a single saber damage check from hitting more than 16 entities in a single frame.  It gets reset at the start of every call to saber damage checking (so for each blade, it's reset each frame, basically).  There's no way you should be hitting that limit - if you need to raise it over 16, something is going very wrong in your code.  100 is insane, much less 600!

 

Do you still have this bit that clears the victimEntityNum array at the top of WP_SaberDamageTrace()?

void WP_SaberDamageTrace( gentity_t *ent, int saberNum, int bladeNum )
{
	vec3_t		mp1, mp2, md1, md2, baseOld, baseNew, baseDiff, endOld, endNew, bladePointOld, bladePointNew;
	float		tipDmgMod = 1.0f;
	float		baseDamage;
	int			baseDFlags = 0;
	qboolean	hit_wall = qfalse;
	qboolean	brokenParry = qfalse;

	for ( int ven = 0; ven < MAX_SABER_VICTIMS; ven++ )
	{
		victimEntityNum[ven] = ENTITYNUM_NONE;
	}

If not, then the victimEntityNum array could start getting filled up and it will think you already hit that ent that frame - when you really hit it some previous frame.  But even that seems unlikely.

 

Have you tried actually debug-stepping through the saber damage routine (starting at the top of WP_SaberDamageTrace) and seeing where your bad trace returns before the damage?  That would be the one sure way to know what's going wrong.

 

Also, turn on the visual saber trace lines, they can be helpful when debugging what's going on with saber traces.

 

d_saberCombat 2

 

Should turn them on. I think you will need to compile a debug build for those to work though?

 

timescale 0.1 

 

Will slow things down enough to see the saber traces in action as you swing.

Smoo likes this
Posted

Well, that doesn't make any sense.  MAX_SABER_VICTIMS is 16 in the vanilla code, it's not 100.  I don't know what codebase you're using.  It that OpenJK or something?

 

The victimEntityNum array exists just to prevent a single saber damage check from hitting more than 16 entities in a single frame.  It gets reset at the start of every call to saber damage checking (so for each blade, it's reset each frame, basically).  There's no way you should be hitting that limit - if you need to raise it over 16, something is going very wrong in your code.  100 is insane, much less 600!

 

Do you still have this bit that clears the victimEntityNum array at the top of WP_SaberDamageTrace()?

void WP_SaberDamageTrace( gentity_t *ent, int saberNum, int bladeNum )
{
	vec3_t		mp1, mp2, md1, md2, baseOld, baseNew, baseDiff, endOld, endNew, bladePointOld, bladePointNew;
	float		tipDmgMod = 1.0f;
	float		baseDamage;
	int			baseDFlags = 0;
	qboolean	hit_wall = qfalse;
	qboolean	brokenParry = qfalse;

	for ( int ven = 0; ven < MAX_SABER_VICTIMS; ven++ )
	{
		victimEntityNum[ven] = ENTITYNUM_NONE;
	}

If not, then the victimEntityNum array could start getting filled up and it will think you already hit that ent that frame - when you really hit it some previous frame.  But even that seems unlikely.

 

Have you tried actually debug-stepping through the saber damage routine (starting at the top of WP_SaberDamageTrace) and seeing where your bad trace returns before the damage?  That would be the one sure way to know what's going wrong.

 

Also, turn on the visual saber trace lines, they can be helpful when debugging what's going on with saber traces.

 

d_saberCombat 2

 

Should turn them on. I think you will need to compile a debug build for those to work though?

 

timescale 0.1 

 

Will slow things down enough to see the saber traces in action as you swing.

@@MGummelt

 

How high does FP_SABEROFFENSE and DEFENSE go up to?

Posted

Well, that doesn't make any sense.  MAX_SABER_VICTIMS is 16 in the vanilla code, it's not 100.  I don't know what codebase you're using.  It that OpenJK or something?

 

The victimEntityNum array exists just to prevent a single saber damage check from hitting more than 16 entities in a single frame.  It gets reset at the start of every call to saber damage checking (so for each blade, it's reset each frame, basically).  There's no way you should be hitting that limit - if you need to raise it over 16, something is going very wrong in your code.  100 is insane, much less 600!

 

Do you still have this bit that clears the victimEntityNum array at the top of WP_SaberDamageTrace()?

void WP_SaberDamageTrace( gentity_t *ent, int saberNum, int bladeNum )
{
	vec3_t		mp1, mp2, md1, md2, baseOld, baseNew, baseDiff, endOld, endNew, bladePointOld, bladePointNew;
	float		tipDmgMod = 1.0f;
	float		baseDamage;
	int			baseDFlags = 0;
	qboolean	hit_wall = qfalse;
	qboolean	brokenParry = qfalse;

	for ( int ven = 0; ven < MAX_SABER_VICTIMS; ven++ )
	{
		victimEntityNum[ven] = ENTITYNUM_NONE;
	}

If not, then the victimEntityNum array could start getting filled up and it will think you already hit that ent that frame - when you really hit it some previous frame.  But even that seems unlikely.

 

Have you tried actually debug-stepping through the saber damage routine (starting at the top of WP_SaberDamageTrace) and seeing where your bad trace returns before the damage?  That would be the one sure way to know what's going wrong.

 

Also, turn on the visual saber trace lines, they can be helpful when debugging what's going on with saber traces.

 

d_saberCombat 2

 

Should turn them on. I think you will need to compile a debug build for those to work though?

 

timescale 0.1 

 

Will slow things down enough to see the saber traces in action as you swing.

Hmm sorry fo bad info - maybe i changed it and thought that it is set to 100 by default but i changed this value. ... Well sorry to tell You but i am not 100% exactly sure what You mean . The thing i have done worked .. But i will keep it on mind and try to understand what i need to change to fix this. If increasing this value may cause problems - i will try to what You showed me or find something new.

 

Many Thanks for answer!

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