Ai_Relationship

Tutorial collection, comprehensive listings on main site.

Ai_Relationship

Postby Tutorial on Sun Mar 06, 2005 11:47 pm

category
General Half-Life 2/Entities

description
This entity allows you to setup how NPCs react to each other and the player.

keywords
ai, relationship, ai_relationship, relation.

This tutorial assumes you know how to make a basic level, and place entities in it.

What I'm going to do is show you how to change relationships of npcs to act differently towards you or other npcs.

In this example, I'm going to make the police friendly to you, so you can watch them administer justice on some rebels.

The first step in making the police friendly is placing an ai_relationship. This will tell the npcs how to feel towards one another. It's position in the map is not relevant, as long as it's inside somewhere. Go to the entities list and place an ai_relationship somewhere in your map.

Image

Once you place your ai_relationship, select it and hit Alt+Enter to view it's properties. "Subjects" is the targetname of the npcs which you are going to change the feelings of. "Targets" is the targetname of the npcs you want to change the feelings TOWARDS. So in this example I put "soldiers" in the Subjects key, because that will be the targetname of my policeman. I put "!player" in the Targets field because "!player" is what you type in when you are referring to the player. The police will change their attitude towards the player. I set "Disposition" to "Like" and "Start Active" to "Yes". "Reciprocal" means the relationship is mirrored the other way, in this case, the player also loves police.

Image


Once your ai_relationship is set up, the next step is to create your policemen. I made 4 npc_metropolice in this example.

Image

Go into each of the policemen's properties, or go through the first one and clone him afterwards. The main thing we want to set is his "Targetname" to "soldiers". As you can see in the picture below, the name soldiers is in bold because more then one entity is using this targetname. The ai_relationship will affect ALL entities by the name of "soldiers".

Since I'm on the topic of metropolice, I'll make a note about manhacks. You can set police to start with manhacks on their back. They just sit on their backs, and the soldier pulls them off in combat and turns them on. If you give them manhacks, they will deploy them, but the manhacks will not like you, so use caution when giving friendly police portable manhacks.

Image


Once all that is set up, compile your map and play, and the policemen should not harm you. I even have a demo for you to watch in case you don't want to play it yourself.


Related:
Example Map

Alcoholic
- Don't send PM's to this user -
Tutorial
Not A Real User
 
Joined: Sun Mar 06, 2005 11:00 pm

Postby RaccoonKing on Sun May 29, 2005 8:26 pm

Is there a way to do this in multiplayer?
RaccoonKing
Been Here A While
Been Here A While
 
Joined: Wed May 18, 2005 2:15 pm

Yes

Postby Puppet_That_Kills on Sun May 29, 2005 9:00 pm

I'm quite sure this can be done in multiplayer. The problem is putting NPCs into multyplayer maps causes the server to lag like a b**ch!

Puppet
User avatar
Puppet_That_Kills
Pheropod
Pheropod
 
Joined: Thu May 05, 2005 10:48 am
Location: Toronto Ont.

Postby RaccoonKing on Sun May 29, 2005 10:03 pm

It's beyond me then.

Do you happen to know if it's server lag, or net lag that it causes mostly?
RaccoonKing
Been Here A While
Been Here A While
 
Joined: Wed May 18, 2005 2:15 pm

Postby Sauce on Sun Dec 11, 2005 3:38 am

how can you make this work with turrets? I've tried, using the steps you've described (and changed their disposition to hate instead), but when I run the map they just sit there doing nothing, instead of attacking the player. What could I possibly be doing wrong? :?

EDIT: Nevermind, I was mapping for HL2 Deathmatch. As soon as I compiled for HL2 it worked fine.
Image
Blink wrote:Do you watch porn and decide you don't need to have sex because you've seen the ending? :-D

zombie@computer wrote:what retarded countries measure in stones anyway?
or feet? or inches? Your dick is a lot longer in cms
User avatar
Sauce
Senior Member
Senior Member
 
Joined: Sat Nov 26, 2005 4:36 am
Location: Australia

Return to Tutorials

Who is online

Users browsing this forum: No registered users