Jump to content
Sign in to follow this  
MGummelt

Ask me anything about the Jedi source code

Recommended Posts

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!

Share this post


Link to post
Guest Redemption

^^ Quick answer for yu, yes they(some anyway for sure) do indeed.

Share this post


Link to post

I typed a whole, long response about what g_spskill does, but this board erased it all when it went to post it.  It's been doing this to me for a month, now, in posts and DMs.  After the post auto-delete, I have to edit the post and type it all again.

 

I don't think I'll be bothering to comment here anymore until this is fixed.

 

Here's the short version:

 

Yes, search for the g_spskill cvar and you'll find that it ups health and a whole lot more (spawning more/different enemies, making them faster, have better reactions, do more damage, gain new abilities, etc.)  I never liked the "damage sponge" approach to difficulty, it ruins the balance of the game, IMO.

 

Specifically, look in the NPC_Begin() function in the NPC_Spawn.cpp:

	else if ( ent->NPC->stats.health )	// Was health supplied in NPC.cfg?
	{
		
		if ( ent->client->NPC_class != CLASS_REBORN
			&& ent->client->NPC_class != CLASS_SHADOWTROOPER 
			//&& ent->client->NPC_class != CLASS_TAVION
			//&& ent->client->NPC_class != CLASS_DESANN 
			&& ent->client->NPC_class != CLASS_JEDI )
		{// up everyone except jedi
			if ( !Q_stricmp("tavion_sith_sword", ent->NPC_type )
				|| !Q_stricmp("tavion_scepter", ent->NPC_type )
				|| !Q_stricmp("kyle_boss", ent->NPC_type )
				|| !Q_stricmp("alora_dual", ent->NPC_type )
				|| !Q_stricmp("alora_boss", ent->NPC_type ) )
			{//bosses are a bit different
				ent->NPC->stats.health = ceil((float)ent->NPC->stats.health*0.75f + ((float)ent->NPC->stats.health/4.0f*g_spskill->value)); // 75% on easy, 100% on medium, 125% on hard
			}
			else
			{
				ent->NPC->stats.health += ent->NPC->stats.health/4 * g_spskill->integer; // 100% on easy, 125% on medium, 150% on hard
			}
		}
		
		ent->max_health = client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->NPC->stats.health;
	}

Note that the Reborn are not scaled - again, instead of making them just take more saber hits to kill, I made it harder to outwit and outduel them.

Username, Smoo, Langerd and 1 other like this

Share this post


Link to post

I typed a whole, long response about what g_spskill does, but this board erased it all when it went to post it. It's been doing this to me for a month, now, in posts and DMs. After the post auto-delete, I have to edit the post and type it all again.

Three people pointed me to this post, so I'll just post what I told them here: this should be fixed by the upcoming major software upgrade (see also the last part of my contest Chinese New Year contest announcement). Until then,known issue, but not much I can sensibly do.

Smoo likes this

Share this post


Link to post

Three people pointed me to this post, so I'll just post what I told them here: this should be fixed by the upcoming major software upgrade (see also the last part of my contest Chinese New Year contest announcement). Until then,known issue, but not much I can sensibly do.

Ah, good to know, thanks.

Share this post


Link to post

3

Thank you so much, man. There's always speculation to how high it goes in the code.

 

Back in the day people were saying "Max saber offense and defense is 5".

 

Then I had one guy on this website say it goes as high as 7.

 

Nice to finally get closure on it.

Share this post


Link to post

Thank you so much, man. There's always speculation to how high it goes in the code.

 

Back in the day people were saying "Max saber offense and defense is 5".

 

Then I had one guy on this website say it goes as high as 7.

 

Nice to finally get closure on it.

When i was looking in the code and i was trying things in the game with force and lightsaber 

 

-Saber offense is shown to be from 0 to 7

-Some force powers on level 4 act diffrent mind trick on level 4 control the oppenent completely, force grip on level 5 (which i couldnt found in the code) deals 10000dmg . Force protect on level 4 makes us invicible on all dmg.

Share this post


Link to post

When i was looking in the code and i was trying things in the game with force and lightsaber 

 

-Saber offense is shown to be from 0 to 7

-Some force powers on level 4 act diffrent mind trick on level 4 control the oppenent completely, force grip on level 5 (which i couldnt found in the code) deals 10000dmg . Force protect on level 4 makes us invicible on all dmg.

Nothing for defense?

Share this post


Link to post

Posted this multiple times already but, again, here are all powas

 

LVL 5 DRAIN - Can drain enemies even if they have absorb on

LVL 5 SPEED - Makes you run at speeds of "timescale 99" 

LVL 5 SABER THROW - You can throw your lightsaber to infinite lenghts until your force meter goes to zero

LVL 5 SABER DEFENSE - You can't deflect blaster bolts (crap)

LVL 5 SABER OFFENSE - pushes harder in saber locks/parries 

LVL 5 PUSH/PULL - Push and pull don't push or pull anything so they become worse than lvl 1 and thus are useless.

LVL 5 JUMP - Makes you jump to a height between lvl1 and lvl2 jump while retaining the ability to make wall acrobatics.

LVL 4 MINDTRICK - Makes you able to control any npc 

LVL 4 DARKRAGE - Enhanced effect over 3 (more dmg and slowmo) and you also lose less health

LVL 5 GRIP - Instakills enemy in one second (Deals 1000 damage)

LVL 4 PROTECT - Invulnerability

 

Other FPs dont do anything else

Langerd likes this

Share this post


Link to post

Nothing for defense?

 

Nothing more for defense.  Nowhere in the code does it check for saber defense to be anything higher than 3.  And if you try to set it higher than that on the console, it tries to clamp it at a max of 3.  This is because saber defense is used in calculations that compare the relative offense/defense skill/strength of two sabers when they come together, to figure out if one should break the block of another, or parry the other one or go into a saberlock.  Allowing defense to go out of range would break those calculations and cause unwanted behavior.

DT85, Lord Of Hate and Smoo like this

Share this post


Link to post

Hello there MGummelt,

 

I am thinking of making a mod that allows Japanese translation and being able to type hiragana, katana and kanji in chat. Wondering whether you know where abouts in the renderer code that I should look at to change? I also tried making a Japanese language patch by modifying .str files but only kanji seem to show up and not hiragana and katana. Although it may just be an encoding setting I need to change as someone got a Korean patch working.

 

Cheers.

Share this post


Link to post

Greetings!

 

I have a question that relates to a thread I made awhile back. I had the random thought on if it were possible to enable the player's lightsaber to damage/dismember their own body? We figured its most likely related to hitboxes, but in order for the lightsaber to detect the player's hitbox itself as a "target" then I imagine that would require some sort of coding. Is such a thing even possible? I'm curious cause, even though such an idea is completely pointless and silly, it could be interesting to pull off and have pretty funny results (with dismembering limits turned off of course)!  For example, if you use the "hilt spinning" taunt but then turn the lightsaber on then the blade clips through your neck with no damage, however that would be hilarious if such a thing could actually kill you and lop your head off. (Or if an NPC does it to themselves, lol)

Share this post


Link to post

Hello again,

I actually got japanese working :D on .str files i just add Japanese Shift-JIS encoding and same for my .cfg file if i want to give myself japanese name. For chat it only shows if I make binds atm. I am wandering now if I can mess with the direct input to allow more symbols to show up when typing in game. (sorry big image)

 

shot2018-03-07_08-10-44.jpg

Share this post


Link to post

@NubSmoo Fantastic work!  Next time I talk to my Japanese friends I'll let them know, maybe they'll be interested in getting the game with such language support as this!  :3

Smoo likes this

Share this post


Link to post

Hello there MGummelt,

 

I have a question. Is there anyway in the code (cvar or else) to change the players size? Npc files have the option to change the size but the player has not?

 

Thank you

Share this post


Link to post

Ehy Mgummelt, i have too a little question.

There is a icarus comand called set_forward move. that can affect an entity to move ever forward. +64 at walkspeed +128 at runspeed . negative value move walkback and runback.

i tryed this on game but i see it works only for player and not on NPC. there is some way for works also on NPC too about that, or the function is callind on code? (ent->client->forceforwardmove)

how it works? it need an integer for works and i think to add to the AI of my class for force an NPC using this class, when is spawn, to move ever forward, at desired speed (maybe walk when is in idle \ patrol behavour and run speed when is attacking \ fleeing).

it need something like NPC->client->setforceforward = int value (like 127, 64 etc)

or it need a command like NPC->client->setforceforward, 64 (or another value between 0 an 127)

what i want is that an NPC when spawning or calling ai functions of his behavour, can use this function for force him to move forward.

if this is not possible. i am asking if there is some way with vectors, for move costantly and entity (player and NPCs)  to forward, along Y direction axis.

 

Thanks for any answers.

Share this post


Link to post

Greetings!

 

I have a question that relates to a thread I made awhile back. I had the random thought on if it were possible to enable the player's lightsaber to damage/dismember their own body? We figured its most likely related to hitboxes, but in order for the lightsaber to detect the player's hitbox itself as a "target" then I imagine that would require some sort of coding. Is such a thing even possible? I'm curious cause, even though such an idea is completely pointless and silly, it could be interesting to pull off and have pretty funny results (with dismembering limits turned off of course)!  For example, if you use the "hilt spinning" taunt but then turn the lightsaber on then the blade clips through your neck with no damage, however that would be hilarious if such a thing could actually kill you and lop your head off. (Or if an NPC does it to themselves, lol)

 

Sure, it's possible.  First you'd need to stop passing the owner of the saber as the "ignore" entity in the lightsaber damage traces, for example (line 4175 of WP_Saber.cpp):

gi.trace( &trace, ent->currentOrigin, vec3_origin, vec3_origin, mp1, ent->s.number, (MASK_SHOT&~(CONTENTS_CORPSE|CONTENTS_ITEM)) );

You can see in the definition below of the "trace" function it's calling that the 6th parameter is the "passEntityNum", which tells the trace to ignore that entity when doing the trace (pass right through it as if it's not there):

	void	(*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, 
			const int passEntityNum, const int contentmask , const EG2_Collision eG2TraceType = (EG2_Collision)0, const int useLod = 0);

If you pass nothing there instead, it should hit the owner (pass ENTITYNUM_NONE insteadf of ent->s.number).

 

After that, you may need to remove all the checks that try to prevent an entity from damaging itself?  I don't see any offhand, but there may be some?

 

And you'll have to do the same with places that make sure an entity (player/NPC) doesn't damage people on their own team, like here (WP_Saber.cpp, line 4186):

	&& traceEnt->client->playerTeam != ent->client->playerTeam 

You'd have to do something like this:

	&& (traceEnt->client->playerTeam != ent->client->playerTeam || traceEnt == ent )

Which would still stop you from damaging teammates, but allow you to hurt yourself.

 

I quickly looked through G_Damage() in g_combat.cpp and I didn't see anything that should stop a player or NPC from damaging themselves, so I think it might be fine after that.  So you may only need to make the above changes in WP_SaberDamageTrace() and it might work?  If not, look for similar cases in the wp_saber.cpp file or lower down in the G_Damage() code.

Archangel35757 likes this

Share this post


Link to post

Hello again,

I actually got japanese working :D on .str files i just add Japanese Shift-JIS encoding and same for my .cfg file if i want to give myself japanese name. For chat it only shows if I make binds atm. I am wandering now if I can mess with the direct input to allow more symbols to show up when typing in game. (sorry big image)

 

 

 

Nice work!  Unfortunately, I know nothing about the rendering, direct input and localization code... That's more a tech programmer's side - like James Monroe.

Smoo likes this

Share this post


Link to post

Hello there MGummelt,

 

I have a question. Is there anyway in the code (cvar or else) to change the players size? Npc files have the option to change the size but the player has not?

 

Thank you

 

Well, you can just have the player "become" an NPC - like we do when you take over the droid in Jedi Outcast or when you drive a vehicle.  Changing the player's size dynamically isn't really supported.  You'd have to change these defines in g_client.cpp:

float DEFAULT_MINS_0 = -16;
float DEFAULT_MINS_1 = -16;
float DEFAULT_MAXS_0 = 16;
float DEFAULT_MAXS_1 = 16;
float DEFAULT_PLAYER_RADIUS	= sqrt((DEFAULT_MAXS_0*DEFAULT_MAXS_0) + (DEFAULT_MAXS_1*DEFAULT_MAXS_1));
vec3_t playerMins = {DEFAULT_MINS_0, DEFAULT_MINS_1, DEFAULT_MINS_2};
vec3_t playerMinsStep = {DEFAULT_MINS_0, DEFAULT_MINS_1, DEFAULT_MINS_2+STEPSIZE};
vec3_t playerMaxs = {DEFAULT_MAXS_0, DEFAULT_MAXS_1, DEFAULT_MAXS_2};

And bg_public.h:

#define DEFAULT_MINS_2		-24
#define DEFAULT_MAXS_2		40// was 32, but too short for player
#define CROUCH_MAXS_2		16

Even then, there may be some places in code that make some assumptions about the player's size (especially their width).  Height can and does vary dynamically (when you crouch and stand back up), so it should handle dynamic changes in height, but I don't know about size.

 

Really, your best option might be to just have the player take over an NPC (the player's input just gets sent to the NPC instead of the player and the player's camera gets attached to that NPC).

Smoo likes this

Share this post


Link to post

Ehy Mgummelt, i have too a little question.

There is a icarus comand called set_forward move. that can affect an entity to move ever forward. +64 at walkspeed +128 at runspeed . negative value move walkback and runback.

i tryed this on game but i see it works only for player and not on NPC. there is some way for works also on NPC too about that, or the function is callind on code? (ent->client->forceforwardmove)

how it works? it need an integer for works and i think to add to the AI of my class for force an NPC using this class, when is spawn, to move ever forward, at desired speed (maybe walk when is in idle \ patrol behavour and run speed when is attacking \ fleeing).

it need something like NPC->client->setforceforward = int value (like 127, 64 etc)

or it need a command like NPC->client->setforceforward, 64 (or another value between 0 an 127)

what i want is that an NPC when spawning or calling ai functions of his behavour, can use this function for force him to move forward.

if this is not possible. i am asking if there is some way with vectors, for move costantly and entity (player and NPCs)  to forward, along Y direction axis.

 

Thanks for any answers.

 

It should be possible, with some coding, to allow this to work on NPCs because NPCs use forwardmove just like clients do (this is how a player can take over an NPC - like with vehicles like the AT-ST).

 

You could just store the force_forwardmove on the NPC struct (NPC->force_forwardmove) and then read that later to override the NPC's ucmd->forwardmove.  Much of the navigation of AI was rewritten by Chris Reed between Jedi Outcast and Jedi Academy (where you see stuff like NAV:: and STEER::, that's Chris Reed).  So I'm not as intimately familiar with how it pushes the NPCs around in Jedi Academy (in SP, in MP I'm pretty sure it's all ucmds), but I'm pretty sure that NPCs still go through Pmove()?  So you should be able to check the force_forwardmove in there for NPCs and override the pm->cmd.forwardmove right there at the last second...

 

Something like this:

void Pmove( pmove_t *pmove )
{
.
.
.
if ( pm->gent && pm->gent->NPC && pm->gent->NPC->force_forwardmove != 0 )
{
     pm->cmd.forwardmove = pm->gent->NPC->force_forwardmove;
}

Archangel35757 and Asgarath83 like this

Share this post


Link to post

 

It should be possible, with some coding, to allow this to work on NPCs because NPCs use forwardmove just like clients do (this is how a player can take over an NPC - like with vehicles like the AT-ST).

 

You could just store the force_forwardmove on the NPC struct (NPC->force_forwardmove) and then read that later to override the NPC's ucmd->forwardmove.  Much of the navigation of AI was rewritten by Chris Reed between Jedi Outcast and Jedi Academy (where you see stuff like NAV:: and STEER::, that's Chris Reed).  So I'm not as intimately familiar with how it pushes the NPCs around in Jedi Academy (in SP, in MP I'm pretty sure it's all ucmds), but I'm pretty sure that NPCs still go through Pmove()?  So you should be able to check the force_forwardmove in there for NPCs and override the pm->cmd.forwardmove right there at the last second...

 

Something like this:

void Pmove( pmove_t *pmove )
{
.
.
.
if ( pm->gent && pm->gent->NPC && pm->gent->NPC->force_forwardmove != 0 )
{
     pm->cmd.forwardmove = pm->gent->NPC->force_forwardmove;
}

 

Oh... is on pm array... D: i used until now with failure this

 

if ( NPC->client->NPC_class == CLASS_FIGHTER)
{
NPC->client->forced_forwardmove = 127; // force to runspeed
}

 

example on NPC_spawn.CPP i tried

 

else if ( ent->client->NPC_class == CLASS_FIGHTER )
            {        
                ent->client->ps.gravity = 0;
                ent->svFlags |= SVF_CUSTOM_GRAVITY;
                ent->client->moveType = MT_FLYSWIM;
                ent->s.loopSound = G_SoundIndex( "sound/vehicles/tie-bomber/loop.wav" );
                ent->client->force_forwardmove = 127;
                // For start to fly?
                ent->client->ps.forcePowersKnown |= ( 1 << FP_LEVITATION );
                ent->client->ps.forcePowerLevel[FP_LEVITATION] = FORCE_LEVEL_3;
                ent->client->ps.forcePower = 100;
                ent->NPC->scriptFlags |= (SCF_NAV_CAN_FLY|SCF_FLY_WITH_JET|SCF_NAV_CAN_JUMP);//no groups, no combat points!
                //start in the air, use spotlight
                //ent->NPC->scriptFlags |= SCF_NO_GROUPS;
                ent->NPC->scriptFlags &= ~SCF_FLY_WITH_JET;
                RT_FlyStart( ent );
                NPC_SetMoveGoal( ent, ent->currentOrigin, 16, qfalse, -1, NULL );
                VectorCopy( ent->currentOrigin, ent->pos1 );
                // Spawn Floating until see an enemy!
                NPC_SetAnim( ent, SETANIM_LEGS, BOTH_SWIM_IDLE1, SETANIM_FLAG_NORMAL );
                NPC_SetAnim( ent, SETANIM_TORSO, BOTH_SWIM_IDLE1, SETANIM_FLAG_OVERRIDE|SETANIM_FLAG_HOLD );
                ent->client->ps.torsoAnimTimer = level.time + cg.time;
            }

(i tryed to worked around a merged copy of  Seeker, Sentry and rockettrooper\Bobafett AI,

Seeker \ sentry ai for flight movement and strafing and death with explosion and corpse disappering; boba fett for switching weapons and tactics.

niceful for fight, but not force forwarding. so my fighter act like assault chopters, like tornadoes of saint row series LOL. )

i will try the pm way! thanks! :3

Share this post


Link to post

I do two edit one in BS_Fighter_Default

void NPC_BSFighter_Default( void )
{
    NPC->client->forced_forwardmove = 127;

and the other on bg_pmove.cpp on void pmove, near to end of file.

i added the last condition

}

    if ( pm->ps->pm_flags & PMF_SLOW_MO_FALL )
    {//half grav
        pm->ps->gravity *= 2;
    }

    // FIX FOR NPC MOVE FORWARD
    if ( pm->gent && pm->gent->NPC && pm->gent->NPC->force_forwardmove != 0)
    {// Boost up forward! EVER!
        pm->cmd.forwardmove = pm->gent->NPC->force_forwardmove;
    }
}

when i build i get a build error because forceforwardmove is not a member of gNPC_t (on b_public.h)

Okay i am adding on gNPC_t . but is forced_forwardmove not forceforward. now i understand the code errors.

stilling building Dll. :)

Share this post


Link to post

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
Sign in to follow this  

×
×
  • Create New...