Friendly turrets
by Mexses (view all articles)

unrated
A basic application of the ai_relationship entity
by Mexses (view all articles)

unrated

This tutorial shows you how to handle ai_relationship. Now, for example, you want to create turrets that shoot combine instead of you. Or other things.
We need a room, one npc_turret_floor, one npc_citizen, and an info_player_start, one npc_combine_s. Set these NPCs up to your wishes.
Now place 4 ai_relationships. Name the turret turret or something else. Go to one of the ai_relationships properties and set the first one up like this:
subject(s): turret
target(s): !player
Disposition: Like
Disposition Priority: 9
Start Active: Yes
And the second one:
subject(s): turret
target(s): npc_citizen
Disposition: Like
Disposition Priority: 9
Start Active: Yes
Third:
subject(s): turret
target(s): npc_combine_s
Disposition: Hate
Disposition Priority: 9
Start Active: Yes
Now you got the turret to like you, the citizen and hate the combine. But the citizen is afraid of the turret now (it wont shoot it but run away from it) so you have to set the fourth ai_relationship like this:
subject(s): npc_citizen
target(s): npc_turret_floor
Disposition: Like
Disposition Priority: 9
Start Active: Yes
Compile, and enjoy.
If you want turrets that start inactive like the nova prospekt ones then follow this.
Set the output on your turret like this:
| My output > | Target entity | Target input |
1:OnPhysgunPickup Turret Disable
2:OnPhysgunDrop Turret Enable
And the spawn flags of the npc_turret_floor to start inactive.
We need a room, one npc_turret_floor, one npc_citizen, and an info_player_start, one npc_combine_s. Set these NPCs up to your wishes.
Now place 4 ai_relationships. Name the turret turret or something else. Go to one of the ai_relationships properties and set the first one up like this:
subject(s): turret
target(s): !player
Disposition: Like
Disposition Priority: 9
Start Active: Yes
And the second one:
subject(s): turret
target(s): npc_citizen
Disposition: Like
Disposition Priority: 9
Start Active: Yes
Third:
subject(s): turret
target(s): npc_combine_s
Disposition: Hate
Disposition Priority: 9
Start Active: Yes
Now you got the turret to like you, the citizen and hate the combine. But the citizen is afraid of the turret now (it wont shoot it but run away from it) so you have to set the fourth ai_relationship like this:
subject(s): npc_citizen
target(s): npc_turret_floor
Disposition: Like
Disposition Priority: 9
Start Active: Yes
Compile, and enjoy.
If you want turrets that start inactive like the nova prospekt ones then follow this.
Set the output on your turret like this:
| My output > | Target entity | Target input |
1:OnPhysgunPickup Turret Disable
2:OnPhysgunDrop Turret Enable
And the spawn flags of the npc_turret_floor to start inactive.