Halo: The Master Chief Collection
REACH MULTIPLAYER AI PATHFINDING TUTORIAL

Image information

Added on

Uploaded by

DunkSauZ3

About this image

Multiplayer bots and Scripted Pathfinding
Converting Multiplayer into Firefight

This tutorial is updated when errors are found and if something has not yet been explained

Other:
Teleporting in Winter Contingency<<
Other scripting Ideas<<
Adding friendly bots into Firefight<<
Sprinting bots<<



1. Make sure your Multiplayer map has Character tags, or import them.
A. Check for Generic tag

Currently, there are six multiplayer maps with Character tags. It's easier to know if the map has AI in it if it's an invasion map due to Pelicans and/or Phantoms having integrated Ai properties for their turrets. If you spawn characters in those maps with player bipeds, Xbox players can see them and synchronize their map placement and animations without any problems. In regards to Firefight, the old update used to allow duplicating Character tags that already exist without causing desync issues for non-host players. It is no longer possible. BUT, you can modify an already existing tag to prevent desync issues. For Custom games, it is recommended that you use the generic tag for the ai to behave properly.
REMEMBER, maps that do not originally have character tags cannot synchronize bots with Xbox players. NON-HOST players will black screen or disconnect from the game.
B. Pros and Cons of Synchronizing Ai-controlled Player-bipeds
Pros:
1. Name specific spartan armors synchronize without issues.
default, male, female, carter, jun, emile, kat, emile_knifeless, player_skull, comicon, mcfarlane_mp2, mcfarlane_exo, mcfarlane_militarypolice, john117

2. Animations and map placements synchronize well.
3. All elite armors synchronize without issues.
Cons:
1. AI-controlled player-bipeds cannot melee or assassinate players.
2. Player bipeds have infinite look sensitivity and can aim at targets in an instant.
3. There are two special spartan variants that generate random armors and colors called, "dead_male" and "dead_female" They do not synchronize properly. The host might see a red ODST, but the non-host might see a blue EVA. However, if a dead_male or dead_female is spawned in multiplayer, the colors might frequently appear as zombie green for all clients, but with random and unsynchronized armor variants.

2. Apply Player bipeds into the character tags

A. Choose a biped

Inside the generic tag, you will notice that the AI does not have a biped. Choose Spartan or elite.

3. Edit the styl tag

A. Disable Camo
The generic tag is likely to use the normal styl tag. Enter the tag and then disable all instances of camo, there are currently two camo options inside the styl tag. It's easier to find it if you type "camo" in the search bar. If you don't do this, your bot will use camo to hide upon targetting an enemy.

4. Go to the SCNR tag
A. Create a squad
After you have entered the SCNR tag, type in the search bar "squads" and create a new instance of the squad. Or create as many as you want if you have experience.
For your squad, I recommend you create 1 spawn point for the sake of this tutorial. DO NOT USE SPAWN FORMATIONS... Yet. Don't worry, it works but it's for spawning multiple bots at a time in one group. But we want each bot to be unique and think for itself.
B. Add a character
Type "character palette" inside the search bar and then add as many characters as you need. The first character corresponds to the index of 0, meanwhile, the next character will correspond to a greater index like 1. The same shall apply to newer characters.
C. Designer set
Create a Designer set and then add your character and set the amount you wish to spawn.

5. DELETE TWITTER
A. Delete Twitter
This will help stop social media from distracting you, allowing you more time to complete your mod.

6. In spawn points, replace every 0 with -1 unless it's the XYZ coordinates.

A. Copy Paste -1
If you don't change every 0 into a -1, your game will crash, because it's attempting to spawn what does not yet exist inside the palette. If this process is too slow, copy the -1 with ctrl + c and click the 0, and press Ctrl + a to select all, then paste with ctrl + v to replace the value of 0. This action can be performed with speed after some practice.
B. Character index
In squads, go to the spawn point and set the character index to the character you wish to spawn. Hint: 0 is the first choice. This becomes unnecessary if you've already added a character inside your designer set.

7. Find the coordinates to spawn your bot.
A. Play Forge Mode
Hop into forge mode and explore the map.
B. Become a monitor and Use Forge Menu
 
On PC, Become a monitor with the ~ key. Also, you may find the forge menu with the 1 key. Once you find a nice spot on the map, choose a spawn point or objective hill, and then place it down. To delete an object, press backspace or delete on your keyboard. If these controls suck, go fix it yourself.
C. XYZ Coordinates with forge tools
With the spawn point or objective hill, you may find the coordinates by pressing b on your controller or by pressing 2 on the keyboard. Then select the edit coordinates menu. Identify the X Y and Z number combinations and then apply them to where you wish to spawn your bot. OPTIONAL, but DON'T forget to copy the numbers for where the bot will be facing.

8. Spawning your bot
A. Limitations set by developers.
Currently, only Halo 3 allows spawning bots with scripted events in custom games without the use of developer modding tools. Therefore this tutorial can be used in halo 3 if you wish, although Halo 3 might not have as many scripting options as Reach. But for halo Reach, unreliable methods must be used just to do the same thing with poorer results. It would be better to convert Multiplayer maps into Firefight maps in order to regain the ability to spawn bots with scripting.
B. Initially placed
Go to the SCNR tag and type in the search bar, "squads" then click "Initially placed" on your squad of choice.
This allows your bot to spawn at the start of the game. However, your bot will not have pathfinding, nor the ability to respawn after death or spawn after the round resets. In other words, your bot is completely useless and there's no point in making this kind of mod on Halo Reach... Unless it's for machinima or to flex on Console peasants.


9. Scripted Pathfinding with Point Sets

A. More limitations
 Currently, only one Point Set can be used without crashing forge world. However, I have used up to 400 points in my Point Set for my recently unreleased mod. (For personal use only) It's possible that more points can be used but that has not yet been tested by me and neither did I need to use all 400 points at a time.
New: As of editing this, i have used up to 1000 points without crashing Battle Canyon.

B. Creating Point Sets
1. Choose a map, ideally an invasion map or Forge World

2. Create only ONE point set. Give it the name "Path" for example. 
3. Inside the point set, Create up to 400 points or more. Also, make sure your modded map doesn't crash.


10. Recording Points with efficiency and speed. 
(Because Too slow = boring to mod)
A. SPEED = FUN
1. Set your game to windowed mode and place the window on the top right part of your screen. Then place the Assembly window on the lower left part of your screen. Stretch the window to your preference. In order to switch between game and assembly as fast as possible, perform an action that makes your mouse cursor appear, like pressing the tab or using the forge menu to get coordinates. Do not Pause. Just don't.
2. With forge mode, find the coordinates for your points. Only record X and Y because ground units don't require height for their scripted pathfinding. Don't worry about Z, it's a waste of time unless you are making paths for flying vehicles.
3. Only use the first name slot for identifying your point. In this tutorial, the second slot is useless. Also, the facing position is useless too. 
4. Create at least 5 idle positions for your bot. Your bot will seem smarter if it walks around while looking for targets

B. Be Creative
1. Bots are dumb, but you are not. It's not enough to let the bot walk somewhere, it needs to feel alive and do stuff. Make sure your points have names that help you remember what part of the map you placed pathfinding. Also, bots don't know how to move around obstacles unless specifically scripted to do so.

C. DO NOT BURN OUT
1. You might be excited to forge your own firefight map now, but only make pathfinding for areas you believe the Ai will seek a fight with the player.
2. Do not put points in areas that you think are not fun. Make sure your bots know where the fun is.

D. Example: Bot idles in repeat
The script below will make your bot choose a random spot to idle with a random waiting time, if you wish for the bot to idle for much longer, you may duplicate the contents of the script to repeat several times. Don't overdo it.


(script startup void Bot_startup
(cs_run_command_script "my_first_bot" near_range_idle)
)
(script command_script void near_range_idle
    (cs_enable_targeting true)
(begin_random_count
        1
        (cs_walk true)
        (cs_walk false)
    )
    (begin_random_count
        1
        (cs_move_towards_point "path/near_range_idle_1" 0.5)
     (cs_move_towards_point "path/near_range_idle_2" 0.5)
     (cs_move_towards_point "path/near_range_idle_3" 0.5)
     (cs_move_towards_point "path/near_range_idle_4" 0.5)
     (cs_move_towards_point "path/near_range_idle_5" 0.5)
    )
    (begin_random_count
        1
        (sleep 60)
        (sleep 90)
        (sleep 120)
    )
(cs_run_command_script ai_current_actor near_range_idle)
)


D. Bots moving to an objective

(script startup void Bot_startup
(cs_run_command_script "my_first_bot" go_to_range)
)
(script command_script void go_to_range
    (cs_enable_targeting true)
        (cs_move_towards_point "path/go_to_range_1" 0.5)
    (cs_move_towards_point "path/go_to_range_2" 0.5)
        (cs_move_towards_point "path/go_to_range_3" 0.5)
        (cs_move_towards_point "path/go_to_range_4" 0.5)
        (cs_move_towards_point "path/go_to_range_5" 0.5)
(cs_run_command_script ai_current_actor near_range_idle)
)


E. Bots are still dumb.
It's not enough to let the bot idle in place. You probably want the bot to explore the map on its own to find its next victim. It's indeed possible, but scripted pathfinding takes too long to complete in comparison to generating a navigation mesh.

Here's a list of command scripts that worked properly. There are obviously more scripting options, so you'll need to use your modding experience to fill in the blanks.




(cs_fly_to "path/sky_idle_1" 0.5A flying vehicle will fly to the XYZ axis

(cs_fly_to_and_face "path/sky_idle_1" "path/sky_face_1" 0.5) A flying vehicle will fly to the XYZ axis while facing the specified point

(cs_move_towards_point "path/armory_idle_1" 0.5) A ground unit or ground vehicle will move towards the XY axis. The number at the end is the radius of the final destination.

(cs_walk true) The ground unit will slow down to walk
(cs_walk "Ai_Machinima_bot" true)

(cs_walk false) The ground unit will speed up and move at full speed.
(cs_walk "Ai_Machinima_bot" false)

(cs_crouch true) The ground unit will crouch
(cs_crouch "Ai_Machinima_bot" true)

(cs_crouch false) The ground unit will stop crouching
(cs_crouch "Ai_Machinima_bot" false)

(cs_stow true) The ground unit will put their weapon on their back
(cs_stow "Ai_Machinima_bot" true)

(cs_stow false) The ground unit will equip their weapon from their back
(cs_stow "Ai_Machinima_bot" false)

(cs_shoot_point true "path/shoot_target_1") Ground or air unit will ignore everything in order to fire upon the point.

(cs_use_equipment 1) Ai bot will activate armor lock for the duration applied. Visit my older tutorial to learn fancy ways of using this script.

(cs_enable_targeting true) To be used when your bot refuses to fight when scripted pathfinding with "cs_move_towards_point."

(cs_enable_targeting false) To be used to stop a bot or flying vehicle from attacking while using scripted pathfinding.

(cs_go_to "path/pathfind_01" 0.5) Works best in Campaign or Firefight because those maps have integrated pathfinding. This script fails in Multiplayer.



11. Changing from one idle location to another idle location.

A. Entrance sequence and exit sequence
Your bot needs to be able to change positions without walking against obstacles or a destroyed vehicle during the match because it can only move from point to point with scripted pathfinding. This is why the (cs_enable_pathfinding_failsafe true) exists. Obviously, this script only works in Campaign/Firefight, or modded halo 3 maps with pathfinding implemented.
So we need to get creative.
Make sure your idle sequence doesn't force the bot to walk into walls or crates in an attempt to move to another part of the map. So you create a transition script. This should allow the bot to position itself accordingly so that it may enter another zone.
B. Natural behaviors
At the very end when your character has finished idling, your script should contain this;
)
 
begin_random_count
1
    (cs_run_command_script ai_current_actor example_1)
    (cs_run_command_script ai_current_actor example_2)
    (cs_run_command_script ai_current_actor example_3)

)
This is an example of giving the bot multiple choices of scripts to explore the map of its own free will. This should be used at the very end when the bot has completed its idle sequence.


Example:

(script command_script void tank_hangar_exit_left
    (cs_enable_targeting true)
    (begin_random_count
        1
        (cs_walk true)
        (cs_walk false)
    )
    (cs_stow true)
    (cs_enable_looking true)
    (cs_move_towards_point "path/crate_trans_any_b_4" 0.5)
    (cs_move_towards_point "path/crate_trans_any_b_3" 0.5)
    (cs_move_towards_point "path/crate_trans_any_b_1" 0.5)
    (begin_random_count
        1
        (cs_move_towards_point "path/crate_trans_any_a" 0.5)
        (cs_move_towards_point "path/crate_trans_any_b" 0.5)
    )
    (begin_random_count
        1
        (cs_run_command_script ai_current_actor near_crates)
        (cs_run_command_script ai_current_actor outisde_arm_left_idle)
        (cs_run_command_script ai_current_actor outisde_arm_right_idle)
    )
)



Sample Videos:
Pathfinding on Highlands
AI battle on Battle Canyon
Pathfinding on Forge World

0 comments