Make NPC's have output for seeing a corpse?

Grab your favourite IDE and tinker with the innards of game engines

Make NPC's have output for seeing a corpse?

Postby nanoxax on Sun Jul 22, 2012 10:15 am

I've asked this question on here before but I've thought of something new. When I asked this a while ago someone said that there would need to be constant checking by the npc to see if a corpse was in it's sight. But could it be possible to make them detect the corpse the same way they detect whether or not they are looking at a player, enemy, etc..

Would this work? Is it possible?
nanoxax
Member
Member
 
Joined: Tue Oct 18, 2011 8:14 pm

Re: Make NPC's have output for seeing a corpse?

Postby ScarT on Sun Jul 22, 2012 1:13 pm

You could probably, like they're looking at the player, make them look at a prop_ragdoll with a certain model. So yes, it should be possible.
User avatar
ScarT
Senior Member
Senior Member
 
Joined: Sat Apr 02, 2005 7:33 pm
Location: Denmarkian Land

Re: Make NPC's have output for seeing a corpse?

Postby Gambini on Sun Jul 22, 2012 5:51 pm

I´d do something strange but that surely works. Make a trigger brush with trapezoidal shape. Like a rough line of sight. Put one in the face of all NPCs that should react to dead bodies. Parent it to the NPC and with a logic_auto attach it to the eyes bone. Then with a filter_class make those triggers fire an output when the ragdoll triggers the brush.
User avatar
Gambini
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 20, 2008 1:52 am
Location: Buenos Aires, Argentina.

Re: Make NPC's have output for seeing a corpse?

Postby nanoxax on Sun Jul 22, 2012 8:32 pm

I tried the trigger thing and it didn't work. You can look over it if you want here:
http://filesmelt.com/dl/entitystuff.png

The trigger does follow the npc because I've checked in my mod and the relationship change does work because I fired it with a console command. The the trigger just can't detect corpses I assume.
nanoxax
Member
Member
 
Joined: Tue Oct 18, 2011 8:14 pm

Re: Make NPC's have output for seeing a corpse?

Postby shadowmancer471 on Sun Jul 22, 2012 8:50 pm

Have you tried the following?
1) Setting the trigger to detect everything in flags
2) Name all the corpses the same name
3) Use a filter_activator_name to make sure the 'detect all trigger' only triggers on the corpses
4) Put the output "OnTrigger/[target]/[output]"

I can't see why that wouldn't fire a response if it hit the corpse
I want to get off Mr.Bones Wild Ride
shadowmancer471
Regular
Regular
 
Joined: Sat Aug 06, 2011 2:08 am

Re: Make NPC's have output for seeing a corpse?

Postby nanoxax on Sun Jul 22, 2012 8:56 pm

The corpses come from npcs that die, I'm not placing ragdolls in the map I'm placing npcs that later die.

And this might be the problem because I do know of a console command that allows ragdolls to collide with the player I think. I checked all the commands with 'ragdoll' in their name and worked with it but still couldn't get the results I wanted.
nanoxax
Member
Member
 
Joined: Tue Oct 18, 2011 8:14 pm

Re: Make NPC's have output for seeing a corpse?

Postby Gambini on Mon Jul 23, 2012 2:16 am

AFAIK you can do name fixups for NPCs that die. Also, and in fact much more important: Your trigger has the "physic debris" flag unchecked. And I´m pretty sure dead bodies are of that class.
User avatar
Gambini
Sir Post-a-lot
Sir Post-a-lot
 
Joined: Mon Oct 20, 2008 1:52 am
Location: Buenos Aires, Argentina.

Re: Make NPC's have output for seeing a corpse?

Postby Gary on Mon Jul 23, 2012 3:16 am

Aren't NPC ragdolls client side(unless the player has the super physgun or NPC is hit by a car)? I would think you would have to move them serverside(convar) before being able to detect them.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: Make NPC's have output for seeing a corpse?

Postby LordDz on Mon Jul 23, 2012 3:29 am

Can you create.. An invisible prop or something similiar, at the position of the npc that dies, and then use Gambinis' method of using a trigger. The trigger would be activated by the prop (with a filter).

Just make sure the prop is non solid, etc.
User avatar
LordDz
May Contain Skills
May Contain Skills
 
Joined: Mon Sep 01, 2008 12:28 pm
Location: Hammer Crash Logs

Re: Make NPC's have output for seeing a corpse?

Postby nub on Mon Jul 23, 2012 9:39 am

That isn't totally fool proof unfortunately. Unless the NPCs die right where they drop, a prop won't work because it won't follow the corpse. Say if a corpse were tossed by an explosion. The prop would spawn at the point where the NPC died, not where its corpse ended up.

Might I ask what reason you'd want this sort of feature for? Are you perhaps making a stealth-oriented mod/map? If so, then the prop spawn method MAY work if you make it so a NPC's corpse doesn't go flying from the point where the NPC is killed. If you're giving the player a blade or silenced weapon to execute enemies, then you shouldn't have to worry about the corpse going too far.

This is definitely a tough one to accomplish within Hammer though. What kind of reaction do you want living NPCs to have upon seeing a corpse? Do you want them to inspect it or just go on alert?
User avatar
nub
Veteran
Veteran
 
Joined: Tue Nov 15, 2005 1:11 am
Location: Charlotte, NC, US

Re: Make NPC's have output for seeing a corpse?

Postby nanoxax on Mon Jul 23, 2012 10:08 am

Ok it works now, I did check if the ragdolls were serverside, and they were, I enabled the super physgun command, and I checked the trigger to detect physics debris.

Only problem, and this probably cannot be solved in hammer, but if the trigger goes through a wall the body will still be detected.

It's taking some tweaking but I'll work with it for a while. Thanks everyone who helped.
nanoxax
Member
Member
 
Joined: Tue Oct 18, 2011 8:14 pm

Re: Make NPC's have output for seeing a corpse?

Postby Gary on Mon Jul 23, 2012 11:31 am

I'm about to leave for town, which means I won't be able to easily access code. But rough idea(you probably can't do this without basic programming knowledge):


First, assuming that dead NPCs don't change their class upon becoming a ragdoll, you make a loop to check for and create a list of all combine soldiers within a distance. This check is ALL of them within a distance, not sight:

You could do a
Code: Select all
 FindEntityByClassnameWithin(this, "npc_combine_s", this->GetAbsOrigin(), 1024)

This, with the parms I gave it would do a search for "npc_combine_s" starting from the origin of this soldier(assuming this is done within the soldier class), within a max search distance of 1024.

Then within a "for" loop that goes through your list, you would first do a check to see if this solider is alive( ->IsAlive() ). Which I beleive is cheaper than checking if they are in sight. If he is alive, we don't need to check if he is within view.

As for checking if an entity is in view, I've never done this before. But a few minutes of looking through the code shows a few possible options I found:
Code: Select all
GetSenses()->DidSeeEntity( ENTITY )
FVisible( ENTITY ) //Used a lot. One use is to check for grenades in view.
FInViewCone( ENTITY )


"Entity" would be the current dead soldier your testing to see if it's in view.

If it's in view, fire the output function(maybe with a distance out?).


This was just a quick idea I had. I'll probably get around to coding it myself. Cause I wanted to make a stealth mod too. When/if I do code it, I'll make sure to post the source.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Re: Make NPC's have output for seeing a corpse?

Postby Gary on Mon Jul 23, 2012 11:36 am

nanoxax wrote:Ok it works now, I did check if the ragdolls were serverside, and they were, I enabled the super physgun command,


That probably has a lot of unnecessary overhead(unless you are actually using the superphysgun). Use ai_force_serverside_ragdoll instead.
Have a question related to modding or something I posted? Something that needs staff attention? I haven't been active lately, but feel free to PM me or message me on Steam(link below)

User avatar
Gary
Interlopers Staff
Interlopers Staff
 
Joined: Wed Dec 16, 2009 12:40 am
Location: USA, FL

Return to Programming

Who is online

Users browsing this forum: No registered users