TUROK 2(EX) Creating AI Path Points

TUROK 2(EX) Modding Tutorial:

CREATING AI PATH POINTS

Authored by Sharev

Adapted for the TurokSanctum by Badger

Using tools made by Behemoth Programmer

RESOURCES

Download Behemoth Programmer‘s Turok 1&2 Unity tools, as well as Unity if you haven’t already.

(Unity Tools)

https://turoksanctum.com/turok-model-and-animation-editor-scripts-for-unity/

https://www.turokforums.com/index.php?topic=582.0

—————————

(Turok 2 API)

https://turoksanctum.com/turok-2-api/

https://www.turokforums.com/index.php?topic=339.0

—————————

PDF and DOCX Guide Download

https://turoksanctum.com/download/turok-2-ai-pathing-guide/

INTRODUCTION

Turok 2 (EX) allows you to create new levels through its level editor, accessible through the console command ‘kexstudio‘. Despite the level editor’s unfinished default-state, most gameplay components can be added back in to your editor through community tools and/or mods.

This tutorial is intended to walk you through one such method for adding new AI paths to a level, as well as how to get AI to follow them.

To accomplish this, you’ll need to open up a ‘.unitypackage’ file with Unity, as well as have your desired Turok 2 ‘.map’ file ready to add in the new path points. This obviously means you need to have Unity installed, as well as the tools (links provided earlier). If you are unfamiliar with Turok 2 (EX)’s level editor, please consult additional tutorials first, as that program is highly prone to crashing.

INSTRUCTIONS

Begin by acquiring the files/programs listed earlier, under ‘Resources‘.

Open ‘TurokEditors.unitypackagewith Unity.

Make and name a new 3D project, then import all components when it asks.

Under ‘Project’, open the ‘Assets‘ folder.

Open the sub-Folder ‘TurokEditors’, then load TurokEditors.unity.

When the file loads, under ‘TurokEditors’ in your newly added Hierarchy,
select ‘
T2 Map Editor.

Your inspector window should now show ‘T2 Map Mono(Script)’, as pictured below.

Under ‘T2 Map Mono’, click ‘Load File‘ then select the .map file you wish to modify. The displayed Filename should update– if need-be, click reload.

Below the divide, select ‘Add Path’. Specific drop-boxes under the button should appear.

Spawn Pos: Where the new points will be placed in the map. Points are lined up horizontally from the Starting Path Point.

# of Points: How many path points will be made after the Starting Path Point.

Start TID: The Starting Path Point’s TID number. Each point’s TID made after is +1, consecutively. Additionally, the starting path point isn’t a part of the actual path.
Start Point TID Value + # of Path point = Path Points’ TID.

Path Type: Loop makes a circuit, going from the last point to the first. Ping Pong randomly sets decides the next chosen point.

WARNING: When making multiple sets of paths, make sure NO path TIDs match another. This can easily happen on accident if you have paths with 9 or more points. AI follows (for loop type) the TID in numerical sequence, and confusing paths results in problems.

Once you’ve set up the ‘Add Path’ options as you want, press ‘Create Path‘.

Repeat this process as many times as needed, taking note of the already created TID’s to avoid later extra cleanup. Additionally, changing the Spawn Position’s values between ‘Create Paths’ will make it easier to manipulate sets of them, else they’ll all appear stacked in the same place when you go to move them in the editor.

When you’re finished, press ‘Save File‘. Assuming everything worked right, it should have updated your .map file with the new path points.

——————

Open your modified .map file again in Turok 2 Ex’s Kex Level Editor.

Your newly placed points should now exist in the map (in a straight line starting wherever you set as the Spawn POS back in Unity), and when you select the Start TID object, there should now be a line connecting them.

To link an AI to a path, open up the actor’s properties. At the bottom of the list should be a value called pathTID. Enter the Start TID of the path you want it to walk.

Upon selecting the AI, it should now be tied to the intended Start TID object.

Next, you’ll want to make sure the AI walking along the path isn’t automatically aware of the player. Under ‘commonFlags‘, make sure the set of flags has ‘restrict vision’ enabled.

You can do easily do this by using Behemoth Programmer‘s T2 Flags tool, included in the Turok 2 API folder.

(In-Editor common flags for the earlier pictured Endtrail in my Infiltration mod, and what they translate to in the T2 Flags tool, pictured below.)

IMPORTANT: Make sure groundBehavior is set to 0 for pathing AI.

Move the path points to their intended locations.

IMPORTANT: AI cannot path sharp turns between points. Place multiple path points close together to have the AI make a turn, as pictured below.

Once you have the path points placed in the intended location and everything seems to be working properly, be sure save your level.

Congratulations! You’re done!