Jump to content

hard-coded npc health modifiers


Recommended Posts

There was a thread a while back here regarding the game's code, where a then-developer answered some of the questions. It would appear that npcs (all of them, even your allies) have 100% of their health on Padawan, 125% on Jedi and 150% on Jedi Knight. I have done some testing and this more or less checks out.

Bosses have 75% of their health on Padawan, 100% on Jedi and 125% on Jedi Knight. In my testing this wasn't true upon spawning known bosses in like Tavion and Alora, it might happen in their respective maps.

It is said that npcs that belong to force user classes don't have any health modifiers but upon testing that's incorrect - I was spawning them in on Jedi Knight difficulty and they have what seems like arbitrary health increases since I couldn't pinpoint an exact percentage. Cultist Saberists, for example, had around 115 health instead of their base 100; Shadowtroopers had 235 instead of 200 and Desann had 800 something (I don't remember the approximate value) instead of 500.

Anyone knows the real math behind this? Also I would like to know what sect of the code should I delete to remove this "feature".

 

EDIT: I found the developers' reply to my question, that's where I got the percentages you see here

 

Link to comment

Are you talking about SP or MP? In MP, g_npcspskill is definitely the variable used to calculate the health, not g_spskill. The actual calculation for NPC health is in NPC_spawn.cc, around line 930:

	if ( ent->health )	// Was health supplied in map
	{
		client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->health;
	}
	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
			ent->NPC->stats.health += ent->NPC->stats.health/4 * g_npcspskill.integer; // 100% on easy, 125% on medium, 150% on hard
		}

		client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = ent->NPC->stats.health;
	}
	else
	{
		client->pers.maxHealth = client->ps.stats[STAT_MAX_HEALTH] = 100;
	}

That said - it looks like it also affects some other things with the AI directly below that segment, so modify it with some caution.

Edit: It also shows up all over the place in the NPC code in general, so yes, definitely use caution editing that.

Link to comment

I'm talking about sp. A quick glance at the code in g_spskill confirms what is said, for non force-users. Reborn and Jedi do get a health increase, contrary to what is stated, but I don't know what's behind that.

And yes there needs to be caution editing this, goes without saying. But I won't be doing anything until I know exactly what's happening.

Link to comment
  • 2 weeks later...
On 8/7/2020 at 1:16 AM, NAB622 said:

{// up everyone except jedi ent->NPC->stats.health += ent->NPC->stats.health/4 * g_npcspskill.integer; // 100% on easy, 125% on medium, 150% on hard }

basically these chunk of code:

for not NPC- player: cap the max health to 100 . (ah ty was a lot of time that i was searching this damned chunk of code -.- )

NPC: Health of NPC on game is the result of this operation:

HP point of NPC files or stat health of NPC + BONUS.

BONUS = NPC health / 4 * Difficulty level of game add HP to NPCs:

so if NPC have 40 HP, and game difficult is 2: obtain bonus +20HP

 

 

Link to comment

Well yes, I know what that code says but it's a lie. It also says that several force-user classes don't receive bonuses but they do, and those don't even follow the 100%>125%>150% code, they just seem like arbitrary bonuses. For bosses it also doesn't work like it's written there.

You can do some simple testing yourself, get the player(you), set undying mode on and set your health to a value of a npc you know. Spawn it in and place both of you near a damage source that deals 1 dmg per sec and after you health gets to 1 see if both of you die at the same time and if not then count the seconds until npc death and you'll have a solid approximate or even correct value of the health. After some simple math you can get the percentage increase and for some classes you'll see it doesn't add up.

Link to comment
On 8/20/2020 at 2:11 PM, Username said:

Well yes, I know what that code says but it's a lie. It also says that several force-user classes don't receive bonuses but they do, and those don't even follow the 100%>125%>150% code, they just seem like arbitrary bonuses. For bosses it also doesn't work like it's written there.

You can do some simple testing yourself, get the player(you), set undying mode on and set your health to a value of a npc you know. Spawn it in and place both of you near a damage source that deals 1 dmg per sec and after you health gets to 1 see if both of you die at the same time and if not then count the seconds until npc death and you'll have a solid approximate or even correct value of the health. After some simple math you can get the percentage increase and for some classes you'll see it doesn't add up.

yes, i noticed the difference of health of enemies during my plays on game. i was not sure about the math but that explain a lot of thing. but i guess the solution should be simple. IF there are not other chunks of code that occurs on that: look at this:

ent->client->NPC_class != CLASS_REBORN
			&& ent->client->NPC_class != CLASS_SHADOWTROOPER
			

NPC_class != CLASS_REBORN and != CLASS_SHADOWTROOPER

basically:

== mean equal, != equal different! So that stuff NOT apply to REBORN and SHADOWTROOPER classes (maybe there is some other kind of modification on that classes? or they simply are not affected?)  that code apply to ALL classes EXCEPT Reborn and Shadowtrooper. if you want it affect reborn and shadowtrooper you should edit code for do something like

NPC_class == CLASS_REBORN

NPC_class == CLASS_SHADOWTROOPER

so, chunk of code have the other effect: the edit will affect  ONLy that the classes.

If you want that ALL NPCs will be affected from that you need to edit the code line on that way:

 

"else if ( ent-->NPC->stats.health ) // was health supplied in NPC.cfg?

opened brank

then

if ( ent->client->NPC_class )  /* != CLASS_REBORN && CLASS_SHADOWTROOPER */

Explanation: /* */ commented out the text inside in, so it will not more affect the game. and you can preserve however the code lines in case of issues, so you can quickly restore if something go wrong.

if ( ent client-> NPC_class ) is generic, basically it mean that it affect ALL NPCs  without discriminations ) in that way it will work for every characters instead only of "all classes except REBORN and SHADOWTROOPER" like original code tells.

good luck! if there are not other parts of code that act as health modifiers of NPCs it should work. ?

 

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 )
		

 

Link to comment
  • 2 weeks later...

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