ACTOR AI EXPLAINED v1-01-2003 Release 1 © RTCM
Reaper_Man
/!\ Attention: These FAQ's where written before the development of EDuke, many limits do not apply anymore. These CON FAQs was written because I believe that there is no one place where CON information can be found - from the
simplest ideas to the most complex effects. After the fall of Dukeworld and 3D Portal, a web-edition of the CON FAQ seems to have been lost, and that leaves Duke RTCM as the only other source of CON information. Though they do have information on CONs and how to edit them, I don't
believe that this information is easily understood by the newest of newbie's. This section is a little thick. I would suggest reading it slowly, at
least twice. 1) The ai primitive must proceed anything else in the definitionOk, now that we have some basic understanding of AI definitions, lets take a closer look at what's following the ai primitive. The first line following the ai primitive is a name for the AI definition. Like I said before, it is not necessary to have the letters AI before the names of you AI definitions, but it is a good idea to do so. This way you don't get the names of your AI definitions mixed up with action or move definitions, and have duplicate name errors during compiling. The second line in the AI definition is the name of the action that is to be played when the AI routine is called. For example, if you were to code a DOG actor, it's AI definitions might look like this: action ADOGWALK 0 4 5 1 12 action ADOGRUN 20 4 5 1 8 ... ai AIDOGWALK ADOGWALK DOGWALKVELS randomangle ai AIDOGRUN ADOGRUN DOGRUNVELS randomangle When the ai routine AIDOGWALK is called, the DOG actor starts playing the action ADOGWALK. When the ai routine AIDOGRUN is called, it starts playing the action ADOGRUN. The third line is exactly the same as the second, except it defines the movement for that AI routine instead of the action. The last line in the AI definition is probably the most important. It tells what basic AI routine to have the AI definition run when it is called. Thats a little hard to understand, so lets modify our DOG actor to see if I can clear it up: ai AIDOGWALK ADOGWALK DOGWALKVELS randomangle ai AIDOGRUN ADOGRUN DOGRUNVELS seekplayer ai AIDOGATTACK ADOGATTACK DOGSTOPPED faceplayer First, the basic routines for the AI definitions have been changed. The first routine, AIDOGWALK, has a basic routine randomangle. The basic routine randomangle does exactly that, picks a random angle when AIDOGWALK is called and keeps heading that direction, playing the action ADOGWALK and moving at DOGWALKVELS speed. The DOG actor will only pick another randomangle when AIDOGWALK routine is called again. The second routine, AIDOGRUN, has a basic routine seekplayer. The basic routine seekplayer is a bit more complicated. Every time it is called, it finds the distance between the DOG actor and the player, decides which direction would be the best to take in order to get to the player, and heads in that direction. Since the player and the DOG actor are probably both moving, it is a good idea to call any AI definition with the basic routine seekplayer as often as possible. The last routine, AIDOGATTACK, has a basic routine faceplayer. The basic routine faceplayer is probably one of the simpilest basic routines in the language. It does exactly what it says, faces the player at all times. If we were able to get a BUILD-style map, we would be able to see that the DOG actor's tail is constantly looking in the direction of the player. Note - There are 12 basic AI routines, and they are all listed and explained in the PRIMITIVE_LIST. Defining your AI types for your actor is just the beginning part of the long process of AI coding. I would consider writing AI effectivly and properly one of the hardest parts of CON coding. Since both the actor and the player are constantly moving, it can be difficult to get the code perfect and work the way you want it to. I will go through the next steps in the AI coding process in the BASIC_ACTOR3 page.
|