Jump to content

Make npcs unable to jump at low health?


Guest Redemption
Go to solution Solved by Guest Redemption,

Recommended Posts

Guest Redemption

Here is what I've got:

if (pm->ps->clientNum && !PM_ControlledByPlayer() && client->ps.stats[STAT_HEALTH] < 20)
	{
		return qfalse;
	}

This is called in bg_pmove under PM_CheckJump( void ). I usually spend a while with trial and error here, but I thought I'd ask for help instead this time :) Any takers on helping me to getting this working?

 

@@Boothand

@@redsaurus

Link to comment

I've barely ever looked into the SP code. Are you sure that this function is called for NPCs? Are they counted as 'clients'?

 

Try to print a message to the console every time they perform a jump. If the message shows up, they use the function, and if not you need to check somewhere else. The condition itself looks correct though.

Link to comment

I'm not sure if that statement is valid in C, I think it wouldn't compile in C# at least, but note the exclamation mark before cent.

 

If anything, it would probably be interpreted as

"if health stats is not less than 50".

 

Your first post looked more likely to nail the issue.

 

Either way, I don't really know the context there, and I would still suggest either:

Doing a console print to determine if the jump code in question is run on the NPC (search for trap_SendConsoleCommand or Com_Printf with Ctrl F to see how it's done)

In Visual Studio, press Shift F12 on the PM_CheckJump to get a list over all calls to the function, and see if it's being called in any AI related parts.

Link to comment
Guest Redemption

@@Boothand Thanks for you're time, you give a lot of help. Yeah, after posting that I realised it was backwards - with the health bit. The context is, to see if you can jump, so what I tried was to say, if not the player at this health, don't jump. It's because in scaling the fall damage without really using a velocity gauge, when an NPC does a little jump at low health, they die... rather pathetically I may add lol. You're right, the game wouldn't load most of the time due to getting my attempts at this working; but I haven't had a go today. I had seen some com_print examples; from you're work and the source and use the find cmd all the time... but I didn't know about shift F12...

 

Kind Regards

Link to comment
  • Solution
Guest Redemption

@@Boothand I got it working. Why is it when you figure something out, you think to yourself... WTF was I playing at before???

Well the solution to the problem was in  AI_JEDI.cpp.  In there I added this to all the checks for jumping and wham-bam, thank you mam!

if (NPC->health < 28)
	{
		return qfalse;
	}
Asgarath83, Noodle and Boothand like this
Link to comment

 

@@Boothand I got it working. Why is it when you figure something out, you think to yourself... WTF was I playing at before???

Well the solution to the problem was in  AI_JEDI.cpp.  In there I added this to all the checks for jumping and wham-bam, thank you mam!

if (NPC->health < 28)
	{
		return qfalse;
	}

 

Thanks so much for sharing the solution, I'm sure it'll help many in the future, me included.

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