Basic AI Attack and Patrol
NOTE: This tutorial was originally posted Nov 26, 2001 by Matt RAZOR Jones on Red Faction Center, which is no longer available. Given the age of the tutorial, some information may be obsolete. Also, this tutorial originally contained some images, which I can't find.
This tutorial covers Basic Attack and Patrol.
I am assuming coming in to this tutorial you already have a basic understanding of brush editing and a basic idea of the object menu. I will cover basic movement of AI entities and and a small portion of the event system.
- The first step is to make a room. Divide this room with a wall and put a regular door opening in it.
- Now go to your OBJECTS list and open entities/ULTOR. Find Guard1. Click on it and place the guard in the opposite room from the PLAYER START.(Note: If you are having trouble seeing the entity right click and select LEVEL PROPERTIES. Change the Ambient light to a light grey color or whatever you prefer.) Rotate the actor so he is facing the door. Select him again and set his properties like this:
- Now we want to put EVENT TRIGGER around the door. Leave the size standard for now.
- Then go to EVENTS/ Modifier/unhide and click on it. Set this Event next to your Actor.
- Select the trigger then hold CTRL and select the UNHIDE( so that both things are highlight and hit "K". This links the two together you should see a blue arrow pointing form the trigger to the event.
Now UN highlight this stuff and highlight the UNHIDE event Hit CTRL and highlight the ACTOR. Hit "K". Now you should have the same arrow going from the event the player.
NOTE: this setup allows the Actor not to be seen until the player crosses the event trigger.
Now we will give the actor a path to follow while he attacks you. There are several settings in the Actor property menu you will want to play with to find your best attack pattern. I will only discuss the basics.
- The first thing that needs to be done is to go to view on top of you screen and click "SHOW PATH NODE CONNECTIONS" all the way at the bottom of the Menu.
- Now find "NAV POINTS" in your "OBJECTS MENU" and click on it. You will see a green circle come up.
Place this so the circle is partly around the ACTOR. NOTE: you can make the circle bigger by adjusting the RADIUS in the NAV POINTS PROPERTY MENU.
- Now to save time I will CUT & PASTE ANOTHER NAVE POINT.highlight the NAV POINT and hold CTRL+"C" then CTRL"V". Move your new NAV POINT around your opening in the wall.
- Now we have got to link the 2 points together. HIGHLIGHT both of them while holding CTRL. Then hit "J" key. You will see a green box go between the 2 nav points. This is the WAYPOINT PATH.
- while both nav points are highlighted hit CTRL+"W". This will bring up the way point list.
Give your PATH a name and in the "NEW WAYPOINT(NAV POINT UID)" area give it the number of the way point closest to the ACTOR. IN our case it is "7".
Sometimes you will have to check the nav points UID number. Then hit the "INSERT BEFORE" button.
- Go back and highlight the ACTOR and hit CTRL+"P". In his properties menu you will see a line called waypoint path. Enter the name of the Path (FIRSTPATH).
Now your Done. He will attack you when you walk threw the door. play the map and see. Do not discard the map when your done we will build the Event system up based on this MAP.
- Now the first step will be to place an actor in the same room(I used a HEAVY MERC) as the player start you will want to look at his property menu good we will make several changes and include his waypoint path and friendliness, before we do anything else:
- Now we are going to put in some small nav points around the perimeter of the room:
- Then link them together by highlighting the first one closest to the ACTOR holding control, highlight the second one and this time we are going to hit "J" twice. you will notice a green arrow in your box pointing form the first NAV to THE second.
UNhighlight everything then Highlight the second NAV and hold CTRL and highlight the third NAV hit "J" twice then unhighlight and do the same for the next NAV connection between 3 and 4. Then highlight all of them. IT should look like this when you get done:
- While all of them are Highlighted hit CTRL+"W" and bring up your waypoint path and fill it in like this make sure to hit "INSERT BEFORE" before you hit "OK".
- Now we want to make him go into action at a certain point. Look in your EVENT? CATALYST menu and find the WHEN DEAD event. Move this towards your First actor. While it is Highlighted hold CTRL and highlight the Gaurd1( your first actor) then hit "K". Now there should be an arrow between them.
- Go to the Second Actor (HEAVY MERC). Now place a Follow waypoints next to him. You can find this under EVENTS/AI/FOLLOW WAYPOINTS. While the FW(follow waypoints) is highlighted use CTRL and highlight the MERC and hit "K". You should have a line going from the FW event to the MERC.
- Deselect everything and Highlight the WHEN_DEAD event use CTRL and highlight the FW event, HIT "K" and they should now be linked together.
- This next step is important so follow close. Select the WP and right click select properties. Fill in the properties as follows:
If you neglect to put in the pathname the game will kick you out at this point. Your done!!