AIs Following the Player.
This tutorial will show you how to make a character who follows the player
- the first time he is frobbed, or used, he will begin to (slowly) follow
the player. Another frob will result in him stopping to guard the current
area. This follower could be used for a number of things: a bodyguard,
a thug hired for an ambush, someone you have to escort to safety, a pet
burrick, a very annoying passer-by, a rescuee, etc.
This tutorial also demonstrates how
to make the Follower move at different speeds using a custom Act/React
stimulus.
You will need:
1) The follower. Let's use a sword guard (-51),
and name him 'Follower'
2) A marker. Name it 'FollowerFollowPlayer'
3) Another marker. Name this one 'FollowerNotFollowPlayer'
4) Any other creature. Let's use a frogbeast.
OR
1) Download Follower.zip, but this
version does NOT change speeds.
First of all, you have to create all the objects you need, and give them
the appropriate names.
Next, we need to make the Follower act as a button. To do this, open his
properties and add Engine Features>Frobinfo,
then give it the following settings:
World: |
|
Script |
Inventory: |
|
None |
Tool Cursor: |
|
None |
Next, add S>Scripts, and enter 'StdButton'
into the 'Script 0' box.
Our follower now acts like a button when you frob him.
Now, seeing as we want our follower to stay and guard where you tell
him to, add AI>Ability Settings>Idle: Returns
to Origins, and set it to False so that he doesn't
go running off on you.
If you want, you can add AI>Ability Settings>Idle:
Directions too. Make the directions something like: 1,
120, 240. This will make your follower
'guard' the area where you leave him, continually searching for some threat.
Finally, you may want to add AI->AI Core>Team
and set it to 'Good', so that your follower doesn't attack
you, but your enemies.
Now, as we want something to happen when the Follower is frobbed, we
have to give him the following link:
Flavour: ControlDevice
From: Follower
To: FollowerFollowPlayer
Now, move on to the first marker, 'FollowerFollowPlayer'.
This marker is going to control the conversation
that makes the Follower start following you.
It needs one link:
Flavour: AIConversationActor
From: FollowerFollowPlayer
To: Follower
Data: 1
Next, open it's properties.
As we want this marker to act as a conversation,
we have to add S>Scripts and set Script
0 to 'TrapConverse'.
And, of course, we need the actual conversation.
Enter the following data into the '00' part of the conversation.
Actor: |
|
ActorOne |
Action 1: |
|
Remove Link |
Argument 1: |
|
ControlDevice |
Argument 2: |
|
FollowerFollowPlayer |
Argument 3: |
|
Follower |
|
|
|
Actor: |
|
ActorOne |
Action 2: |
|
Add Link |
Argument 1: |
|
ContolDevice |
Argument 2: |
|
FollowerNotFollowPlayer |
Argument 3: |
|
Follower |
|
|
|
Actor: |
|
ActorOne |
Action 3: |
|
Add Link |
Argument 1: |
|
AiFollowObj |
Argument 2: |
|
Player |
Argument 3: |
|
Follower |
What you've just done makes the Follower's ControlDevice
link point to the second marker, FollowerNotFollowPlayer,
instead of FollowerFollowPlayer, and makes the Follower begin to follow
you using an AIFollowObj link. Optionally,
you can also add a play/sound motion action, using a sample such as "Let's
Go!".
Now, let's move on again, this time to FollowerNotFollowPlayer.
This time, the frog will be the actor:
Flavour: AIConversationActor
From: FollowerFollowPlayer
To: [Object number of frogbeast]
Data: 1
Also, add the 'TrapConverse' Script, and
configure the AI>Conversations>Conversation
like this:
Actor: |
|
ActorOne |
Action 1: |
|
Remove Link |
Argument 1: |
|
ControlDevice |
Argument 2: |
|
FollowerNotFollowPlayer |
Argument 3: |
|
Follower |
|
|
|
Actor: |
|
ActorOne |
Action 2: |
|
Add Link |
Argument 1: |
|
ContolDevice |
Argument 2: |
|
FollowerFollowPlayer |
Argument 3: |
|
Follower |
|
|
|
Actor: |
|
ActorOne |
Action 3: |
|
Remove Link |
Argument 1: |
|
AiFollowObj |
Argument 2: |
|
Player |
Argument 3: |
|
Follower |
Which changes the Follower's ControlDevice
link back to FollowerFollowPlayer, and removes the AIFollowObj
link.
Finally, add the metaproperty M-NeverEfficient (-5516)
to the frog; if you don't, the Follower won't respond unless you are near
the frog's hiding place. And now, your Follower should be set up and working
correctly. Go into game mode and try it out!
OR
If you chose the alternative option of downloading Follower.zip, then hide the apebeast in a blue
room, otherwise the Follower may kill him, which would ruin the system.
KNOWN BUGS:
1) The follower only ever WALKS, and never runs. You could give him a
TimeWarp, but that'd just look stupid. See below.
2) He keeps on walking towards you even when he's walking into you...
He's not very clever.
3) He cannot be picked up when he's dead/unconcious
4) He will attack everyone he sees who is not on the 'neutral' or 'good'
team. Now, you may not think this is such a bad thing, but if you have
some 'innocents', you don't really want him to kill them.
Making people who you don't want killed 'neutral' is probably best. But
then they won't flee from the player. So you could try this instead:
Open up 'Follower's properties again, and remove AI>AI
Core>Team, or just change it to 'BAD1'
Now, add AI>Ability Settings>Investigate
Style, and set it to 'Don't Investigate'
Next, add AI>Ability Settings>Combat: Non
Hostile, and set it to 'Always to Player'
Now your follower will only attack people on teams BAD 2,
BAD 3, BAD 4, BAD 5 &
GOOD (but not you).
To anyone you want the follower to fight, just add AI>AICore>Team:
Bad2. This doesn't quite work either, though, as these
'BAD 2' people will attack their own servants (or anyone
else on team BAD 1).
Also, your follower will now say "Don't Move!", or something
similar, when he sees you, but does nothing.
Either way, it's not perfect, but it works.
You might want to use some furniture that's being used in the map instead
of the markers, to save objects...
If that doesn't work, or you can't be bothered, etc., you can download
one I made earlier:
Get Follower.zip here!
Making the Follower change speeds using a custom Act/React
Stimulus.
Here is a complicated method to make the Follower change speeds while
following you. It involves using a custom Act/React stimulus, and creating
a new metaproperty, and as such using it will require saving and distributing
the gamesys with your level. For more information, see: Using
a custom gamesys.
This part is for advanced DromEd users who have read Totality's
Act/React Tutorials only.
First, we have to create a new stimulus. Let's call it 'FollowerStim'.
Remember that you have to save the gamesys, enter 'set_gamesys [gamesys
name]' in the console, and then save and reload the level after adding
new stimuli.
Next, create two new archetypes. Let's call them 'FollowerSpeed1'
and 'FollowerSpeed2'. Give each of
them the AI->AI Core->Motion Tags property,
and set it as follows:
FollowerSpeed1 |
Scan |
FollowerSpeed2 |
Scan, LocoUrgent |
Now, we have to create a new Metaproperty called 'M-FollowerSpeeds',
and give it several Act/React Receptron:
We also have to add one Act/React Source:
FollowerStim, Radius, Intensity 40, Radius
40, Dispersion Linear, No Max Firings.
Add the following action to FollowerFollowPlayer:
Actor: |
|
ActorOne |
Action 4: |
|
Add/Remove Meta-property |
Argument 1: |
|
Add |
Argument 2: |
|
M-FollowerSpeeds |
FollowerNotFollowPlayer also needs another action:
Actor: |
|
ActorOne |
Action 4: |
|
Add/Remove Meta-property |
Argument 1: |
|
Remove |
Argument 2: |
|
M-FollowerSpeeds |
Argument 3: |
|
Follower |
We also need to make the player 'bounce' the FollowerStim
back. Add the following Act/React Receptron
to Physical->Avatar->Garrett
Stimulus |
Min |
Max |
Effect |
Target |
Agent |
Addition Data |
FollowerStim |
0 |
No Max |
Stimulate Object |
Follower |
[Source] |
FollowerStim, Mutliply by 1, add
0 |
Finally, we need to make our Follower stop when he reaches you. To do
this, just add a AIWatchObj from the Follower
to himself with the following properties:
Trigger Radius: |
|
Player Intrusion |
Radius: |
|
10 |
Height: |
|
20 |
|
|
|
Action 1: |
|
Play Sound/Motion |
Argument 1: |
|
[Leave blank] |
Argument 2: |
|
[Leave blank] |
Argument 3: |
|
IdleGesture |
And there we have our Follower changing speeds depending on his distance
from you, and idling when he reaches you.
He still doesn't use the pathfinding database, but getting him to do so
is a tutorial for another time... |