-Leading AIs-
-By HKPrince-




 

Leading AIs

Bad AIs in SS2 chase and hunt the player until one of them kill the other.
Good and neutral AIs ignore the player, so it is quite difficult to interact with them.
Some of us want to have team members in single player game FM, or have some NPC to work for us.
To make an AI follow the player, AIFollowObj link is one of the solutions, AIWatchObj link is another.
You can simply add AIFollowObj link from the AI to the player, adjust the distances and angles in data menu of the link.
Use distances of more than 4 to avoid the AI stepping on player's feet.
Remember to compute pathfinding database so that the AI knows where to find the player.
Then the AI fight for you and return to you after the battle. However, this is only an experiment of the link. You have no player object before game mode or real game, the link should be invalid.
If you link the AI to The Player (-384), it will go to the starting location or level start marker. Is the link useless? No, you can use a signal response to add the link from the AI to the player. Add AI->Response->Signal response to the AI, name the signal SwitchOn (don't try other name, otherwire you have to use AI signal trap to activate the signal response).
On Response Step 1, select add link, enter AIFollowObj on Argument 1, player on Argument 2, AI's object number on Argument 3. Then add an once tripwire, add switchlink from the tripwire to the AI. When the player cross the tripwire, the AI will follow you everywhere. But you can't adjust the distances (I can't, may be someone can). To make the AI stay away from you as a bodyguard, you can still use AIFollowObj link, this time link the AI to compass HUD (-3634). This object exists before the game and the AI chases compass HUD attached to the player in game. One problem of this is the AI looks for you once you enter game, they probably walk through doors to find you.
Frozen or docile metaproperties can't stop them. So you may need to teleport the AI in the map if you want the player meets it later in game.
Another method is to use AIWatchObj link, add it from the AI to itself. Then in data menu, select Player intrusion on Watch kind, enter Trigger radius 40 and height 30, select Don't kill on Exit: Link kill option, then on Response Step 1, select Goto object, enter player on Argument 1. The AI will go to the player once it sees him. However, I can't adjust the distance of the AI from the player. (This method is actually suggested by ndru.) A Demo Mission of the above exists and can be found Here (100kb)


Leading an AI to open a door

We may want an AI to open a door for us, and the door can only be opened by the AI, so we use AIWatchObj link.
Add the link from the AI to the door or an invisible button to the door or any object close to the door.
In data menu, select Self entry on Watch kind, enter Trigger radius 8 and height 8 (depending how close you want to), select After completion on Exit: Link kill option, then on Response Step 1, select frob object, enter button's object number on Argument 1.
Remember not to shut the door or let the AI die, otherwise I can't help you.
However, the results of my expts aren't very satisfactory and promsing.
AI following the player with AIFollowobj link freezes after opening the door.
To defrost the AI, remove the AIFollowobj link before or after frobing the button.
Select Remove link on Step 1 or 2, enter AIFollowObj on Argument 1, enter player or compass HUD as you have chosen before on Argument 2, enter object number of the AI on Argument 3.
Also AI following the player with AIWatchObj link seems to have some difficulties to find the button or door.
Here is a demo FM. (119Kb)

 

Travel to:Tutorials / Printer Friendly Version of This Tutorial
 

Electronic Email Addresses.
David "BigDave" Cornish / Brett "UnderTow" Williams / JediK


Travel to: SShock2.com (home) / TTLG.com