Jump to content

Ask me anything about the Jedi source code


Recommended Posts

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.

Langerd, Username, eezstreet and 1 other like this
Link to comment

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.

Link to comment

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.

Link to comment

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.

Link to comment

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?

Link to comment

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
Link to comment

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, Smoo and Xioth like this
Link to comment

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.

Link to comment

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)

Link to comment
  • 2 weeks later...

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

Link to comment
  • 4 months later...

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.

Link to comment

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
Link to comment

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
Link to comment

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
Link to comment

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
Link to comment

 

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

Link to comment

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

Link to comment
Guest Redemption

@@MGummelt

Hello pal! Good to hear/read of you once again ☺

 

I really hope you can help me out a little, or if any at all would be nice.

 

In g.client at the bottom in clientspawn, I've edited the on loading of a map different models for Kyle, but the problem occurs when I save a game and on loading of that save, the ghoul2 model's animations are locked is the best way I can describe it; he fires always in the same direction and float across the screen with the navigation all wrong. I've had it working with changing loadtransition ==qtrue, but I start back at the map beginning and looking up.

 

How can I leave loadtransition==qfalse but unlock my models animation?

In g.main right at the very bottom, there is a bit of code tbat calls playerlocked.. Does that have anything to do with it?

 

Kind Regards

Link to comment

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

tested but fighters not run forward on spawning like i desire. :(

I think there is something missing again.

Well i will focus on that when i'll got more time. now is hot day.

basically i am trying to recreate the forward movement of fighters of Rogue Squadron 3D game.

Have nice time and thanks for answer!

 

i think use icarus command is not sufficient ( on SP forced_forwardmove is a signed_chars on the scructure g_client_s )

maybe i not sufficient to add command to the AI behavour, or calling with icarus scripting after i added on p_move.

maybe i near really to write an entire function structure for automatically move NPCs forward when  is called, and add on gNPC_t and after add on p_move... mmm headaching. :S

there is not possibility to simply add a movement on a character with a vector Y setting on his AI code? at the end i need only that my AI Class automatically move forward along Y axis.

Link to comment

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

 

Here's the thing - force_forwardmove does nothing by itself.  There's a function that takes the value of force_forwardmove and turns that into the pm->cmd.forwardmove of the entity (I can't remember the name of it and I'm at work right now, but if you search for force_forwardmove, you'll find it).  But that function is only called on actual clients (like the player), not on NPC vehicles with no driver.  So you'll need to do that yourself (like the example I gave with force_forwardmove if you put it on the NPC struct).  You can put the force_forwardmove variable wherever you want as long as you can access it later in Pmove() or some setup function called before Pmove().

 

Keep in mind that the NPC struct doesn't already have a force_forwardmove variable on it, you'll have to add it.

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