Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding

Reply
 
Thread Tools Display Modes
Old 08-31-2012, 01:09 PM   #1
AniCator
 
Join Date: Aug 2010
Reputation: 8
Posts: 45
What makes npc_citizen immune to your bullets?

Hey everyone,

I've been messing around with the default AI relationships and I made the Rebels hostile to the player.

My problem is that when I shoot the Rebels, they don't get hurt. All I see is a blood decal on their models.

I've been looking through the source code for quite a while now but haven't been able to find anything to change that.

Does anyone know how to modify this immunity to player fire?

Kind regards.
AniCator is offline  
Reply With Quote
Old 08-31-2012, 01:26 PM   #2
CrAzYpotpie
 
Join Date: Sep 2010
Reputation: 49
Posts: 485
You just have to make the player hostile to the rebels. Just do what you did for changing the rebels relationship with the player, except make the player hate the rebel instead.

If the player likes something, he can cause it no harm. If he hates it, is neutral about it, or is afraid of it, he can harm it.

Last edited by CrAzYpotpie: 08-31-2012 at 02:06 PM.
CrAzYpotpie is offline   Reply With Quote
Old 08-31-2012, 02:09 PM   #3
AniCator
 
Join Date: Aug 2010
Reputation: 8
Posts: 45
Thanks but it doesn't work yet.
I'm using HL2MP for the mod, integrated a bunch of AI fixes.
Does HL2MP maybe use a different gamerule for it's players? (I'm editing the relationships in hl2mp_gamerules.cpp)

Edit: Pastebin link: http://pastebin.com/ne7R8XFi

Last edited by AniCator: 08-31-2012 at 02:11 PM.
AniCator is offline   Reply With Quote
Old 08-31-2012, 02:26 PM   #4
CrAzYpotpie
 
Join Date: Sep 2010
Reputation: 49
Posts: 485
Hmmm, I didn't know this was for an MP mod, so my guess is something isn't set right in part of the AI Patch, as I just re-read your first post saying they bleed but with no damage. I just looked through your code changes, and they would have been sufficient enough to work in a Single-player build, so I once again assume it has to do with the patch.

And yeah, it should be hl2_gamerules.cpp (or for you hl2mp)

Or maybe try to set CLASS_PLAYER_ALLY to Hate? Just a thought. I peeked at my code and think I may have changed that one in the past to make citizen's hated in my game. . . but probably not.
CrAzYpotpie is offline   Reply With Quote
Old 08-31-2012, 02:52 PM   #5
AniCator
 
Join Date: Aug 2010
Reputation: 8
Posts: 45
Sadly that didn't seem to work either.

EDIT: Hold on, there seems to be a change. Rebels die. Combine still alive.

Last edited by AniCator: 08-31-2012 at 02:57 PM.
AniCator is offline   Reply With Quote
Old 08-31-2012, 03:13 PM   #6
AniCator
 
Join Date: Aug 2010
Reputation: 8
Posts: 45
Ok, the relationships seem to work now. (I can kill the Rebels, Combine still live but that might just have been my fault)

Only issue that remains is the fact they won't fire their guns. I added the Operator_AnimationEvent stuff to the AR2 code to test it including it's required functions and contained it in an ifndef CLIENT_DLL .

They don't shoot their guns though. I put down some breakpoints and the function didn't even seem to be executed.
AniCator is offline   Reply With Quote
Old 08-31-2012, 04:17 PM   #7
CrAzYpotpie
 
Join Date: Sep 2010
Reputation: 49
Posts: 485
Well according to your code, the player likes the combine due to you changing it from D_HT to D_LI, so if you want them to die to you again, change it back.

As for why they wont fire, has it always been that way? Hopefully someone more knowledgeable will come along for that.
CrAzYpotpie is offline   Reply With Quote
Old 08-31-2012, 04:19 PM   #8
ProZak
 
Join Date: Mar 2004
Reputation: 60
Posts: 678
Check out "OnTakeDamage_Alive" and "PassesDamageFilter" in ai_basenpc.cpp. They handle that.
ProZak is offline   Reply With Quote
Old 09-04-2012, 04:19 PM   #9
charlysotelo2
 
 
 
Join Date: Oct 2005
Reputation: 187
Posts: 735
An alternate solution is to make the bullets have no knowledge of who fired them. ( make the bullets have no owner, or attacker). I did this on the mod I'm working on. This is done in the FireBullet_t structure I believe. Additionally, look at the FireBullets function and determine where it is called for the player using the call stack
charlysotelo2 is offline   Reply With Quote
Old 09-05-2012, 04:37 AM   #10
ProZak
 
Join Date: Mar 2004
Reputation: 60
Posts: 678
Honestly that sounds like a terrible solution that could come back with multiple problems later.
ProZak is offline   Reply With Quote
Old 09-05-2012, 04:19 PM   #11
charlysotelo2
 
 
 
Join Date: Oct 2005
Reputation: 187
Posts: 735
We'll i've had no problems with it. I find its a much more realistic foundation as well. None of the code requires that the bullets have owners.
charlysotelo2 is offline   Reply With Quote
Old 09-05-2012, 04:24 PM   #12
CrAzYpotpie
 
Join Date: Sep 2010
Reputation: 49
Posts: 485
So did you modify how your mod keeps score? Or, am I just not following you here? I assume the thread creator would want to keep that function intact.
CrAzYpotpie is offline   Reply With Quote
Old 09-05-2012, 04:25 PM   #13
charlysotelo2
 
 
 
Join Date: Oct 2005
Reputation: 187
Posts: 735
Oh Doh! didn't realize it was multiplayer. Yeah i made my changes for a singleplayer mod.
charlysotelo2 is offline   Reply With Quote
Old 09-06-2012, 05:29 AM   #14
ProZak
 
Join Date: Mar 2004
Reputation: 60
Posts: 678
Quote:
Originally Posted by CrAzYpotpie View Post
So did you modify how your mod keeps score? Or, am I just not following you here? I assume the thread creator would want to keep that function intact.
Exactly why his solution was terrible.
ProZak is offline   Reply With Quote
Old 09-19-2012, 02:34 AM   #15
ExoBacon
 
 
 
Join Date: Apr 2012
Reputation: 12
Posts: 106
Found this in ai_basenpc.cpp
Code:
	// If we're not allowed to die, refuse to die
	// Allow my interaction partner to kill me though
	if ( m_iHealth <= 0 && HasInteractionCantDie() && info.GetAttacker() != m_hInteractionPartner )
	{
		m_iHealth = 1;
	}
Hope that helps.
ExoBacon is offline   Reply With Quote
Reply

Go Back   Steam Users' Forums > Steam Tool Discussions > Source Coding


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



All times are GMT -7. The time now is 06:57 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.
Site Content Copyright Valve Corporation 1998-2014, All Rights Reserved.