A Community discussion forum for Halo Custom Edition, Halo 2 Vista, Portal and Halo Machinima

Home  Search Register  Login Member ListRecent Posts
  
 
»Forums Index »Halo Custom Edition (Bungie/Gearbox) »Halo CE General Discussion »AI Followers Rewritten. Again.

Author Topic: AI Followers Rewritten. Again. (5 messages, Page 1 of 1)
Moderators: Dennis

Jade
Joined: Jan 19, 2020


Posted: May 7, 2020 11:55 AM    Msg. 1 of 5       
This is much better than before. It uses OpenSauce but I'm working on a version for default Halo. It supports up to 121 followers for now. The follow biped must have a seat the followers can enter, they must have enter and exit animations set up in their animation tag. Duplicate the follow biped seat a bunch of times when you are done. You also need a command list that makes them look at you.

GLOBALS:

(global object_definition ar "weapons\assault rifle\assault rifle")
(global object_definition b "weapons\ball\ball")
(global object_definition f "weapons\flag\flag")
(global object_definition ft "weapons\flamethrower\flamethrower")
(global object_definition ne "weapons\needler\needler")
(global object_definition p "weapons\pistol\pistol")
(global object_definition pp "weapons\plasma pistol\plasma pistol")
(global object_definition pr "weapons\plasma rifle\plasma rifle")
(global object_definition rl "weapons\rocket launcher\rocket launcher")
(global object_definition sg "weapons\shotgun\shotgun")
(global object_definition sr "weapons\sniper rifle\sniper rifle")

(global unit follow_target "none")
(global unit ai_target "none")

(script static unit player0 (unit (list_get (players) 0)))
(script static unit player1 (unit (list_get (players) 1)))
(script static unit player2 (unit (list_get (players) 2)))
(script static unit player3 (unit (list_get (players) 3)))
(script static unit player4 (unit (list_get (players) 4)))
(script static unit player5 (unit (list_get (players) 5)))
(script static unit player6 (unit (list_get (players) 6)))
(script static unit player7 (unit (list_get (players) 7)))
(script static unit player8 (unit (list_get (players) 8)))
(script static unit player9 (unit (list_get (players) 9)))
(script static unit player10 (unit (list_get (players) 10)))
(script static unit player11 (unit (list_get (players) 11)))
(script static unit player12 (unit (list_get (players) 12)))
(script static unit player13 (unit (list_get (players) 13)))
(script static unit player14 (unit (list_get (players) 14)))
(script static unit player15 (unit (list_get (players) 15)))

(script static unit red_unit (unit (list_get (ai_actors red) 0)))
(script static unit default_check_unit (unit (list_get (ai_actors red/squad_default_temp) 0)))
(script static unit follow_check_unit (unit (list_get (ai_actors red/squad_follow_temp) 0)))


SCRIPT:

(script startup startstuff
(sleep 60)
(set follow_target (unit (player_data_get_object 0 "slave_unit")))
)

(script static void set_default
(deactivate_nav_point_object follow_target ai_target)
(ai_migrate_by_unit ai_target red/squad_default)
)

(script static void set_follower
(deactivate_nav_point_object follow_target ai_target)
(ai_migrate_by_unit ai_target red/squad_follow)
)

(script static void kill_ai
(unit_kill ai_target)
)

(script continuous follower_units
;each actor is migrated to a temporary squad one by one
;we use this to check stuff about the individual and also manipulate them with commands normally meant for groups of actors
(ai_migrate_by_unit (unit (list_get (ai_actors red/squad_follow) 0)) red/squad_follow_temp)

;how we behave when follow target is on foot
(if (or (= (unit_has_weapon_readied follow_target ar) true)
(= (unit_has_weapon_readied follow_target b) true)
(= (unit_has_weapon_readied follow_target f) true)
(= (unit_has_weapon_readied follow_target ft) true)
(= (unit_has_weapon_readied follow_target ne) true)
(= (unit_has_weapon_readied follow_target p) true)
(= (unit_has_weapon_readied follow_target pp) true)
(= (unit_has_weapon_readied follow_target pr) true)
(= (unit_has_weapon_readied follow_target rl) true)
(= (unit_has_weapon_readied follow_target sg) true)
(= (unit_has_weapon_readied follow_target sr) true)
)
(begin
;if AI is noncombat or guarding, we follow when out of this range
(if (<= (ai_status red) 2)
(begin
;if AI is 5 world units out of range, we make them follow
(if (> (objects_distance_to_object follow_target (follow_check_unit)) 5)
(begin
(ai_go_to_vehicle red/squad_follow_temp follow_target "")
(ai_command_list red/squad_follow_temp look)

;tell AI to exit vehicle if they are in one, and set their animation seat to "flee" so they sprint
(unit_exit_vehicle (follow_check_unit))
(unit_set_seat (follow_check_unit) "flee")
)
)
;if AI is 5 world units in range, we dont tell them to follow anymore
(if (< (objects_distance_to_object follow_target (follow_check_unit)) 5)
(begin
;set AI animation seat back to normal, they will naturally change animation states now
(unit_set_seat (follow_check_unit) "")
)
)
)
)

;if AI is searching or higher combat status, we follow when out of this range
(if (>= (ai_status red) 3)
(begin
(unit_set_seat (follow_check_unit) "")

;if AI is 8 world units out of range, we make them follow
(if (> (objects_distance_to_object follow_target (follow_check_unit)) 8)
(begin
(ai_go_to_vehicle red/squad_follow_temp follow_target "")
(ai_command_list red/squad_follow_temp look)
(unit_exit_vehicle (follow_check_unit))
)
)
)
)

(if (!= (ai_status red/squad_follow_temp) 0)
(begin
;if AI is 5 world units OUT of range, deactivate health nav
(if (or (> (objects_distance_to_object follow_target (follow_check_unit)) 5)
(= (objects_can_see_object follow_target (follow_check_unit) 15) false)
)
(begin
(deactivate_nav_point_object follow_target (follow_check_unit))
)
)

;if AI is 5 world units IN range, AND health is high, activate green health nav
(if (and (< (objects_distance_to_object follow_target (follow_check_unit)) 5)
(= (objects_can_see_object follow_target (follow_check_unit) 15) true)
(> (unit_get_health (follow_check_unit)) 0.5)
)
(begin
(deactivate_nav_point_object follow_target (follow_check_unit))
(activate_nav_point_object "default_green" follow_target (follow_check_unit) 0.35)
)
)

;if AI is 5 world units IN range, AND health is low, activate red health nav
(if (and (< (objects_distance_to_object follow_target (follow_check_unit)) 5)
(= (objects_can_see_object follow_target (follow_check_unit) 15) true)
(< (unit_get_health (follow_check_unit)) 0.5)
)
(begin
(deactivate_nav_point_object follow_target (follow_check_unit))
(activate_nav_point_object "default_red" follow_target (follow_check_unit) 0.35)
)
)

(if (<= (objects_distance_to_object follow_target (follow_check_unit)) 0.5)
(begin
(set ai_target (follow_check_unit))
(objects_attach ai_target "body" follower_control0 "")
(objects_detach ai_target follower_control0)
)
)
)
)

(if (> (objects_distance_to_object ai_target follow_target) 0.5)
(begin
(object_teleport follower_control0 object_away)
)
)

(if (> (device_get_position follower_control0) 0)
(begin
(device_set_position follower_control0 0)
(display_scripted_ui_widget command_menu)
)
)


;how we behave when follow target is in vehicle
(if (and (= (unit_has_weapon_readied follow_target ar) false)
(= (unit_has_weapon_readied follow_target b) false)
(= (unit_has_weapon_readied follow_target f) false)
(= (unit_has_weapon_readied follow_target ft) false)
(= (unit_has_weapon_readied follow_target ne) false)
(= (unit_has_weapon_readied follow_target p) false)
(= (unit_has_weapon_readied follow_target pp) false)
(= (unit_has_weapon_readied follow_target pr) false)
(= (unit_has_weapon_readied follow_target rl) false)
(= (unit_has_weapon_readied follow_target sg) false)
(= (unit_has_weapon_readied follow_target sr) false)
)
(begin
(deactivate_nav_point_object follow_target (follow_check_unit))
(unit_set_seat (follow_check_unit) "")

;if AI is 7 world units out of range, we make them follow
(if (> (objects_distance_to_object follow_target (follow_check_unit)) 7)
(begin
(ai_go_to_vehicle red/squad_follow_temp follow_target "")
(ai_command_list red/squad_follow_temp look)
;tell AI to exit vehicle if they are in one
(unit_exit_vehicle (follow_check_unit))
)
)
)
)

;the actor is migrated back to his normal squad and we move on to the next
(ai_migrate red/squad_follow_temp red/squad_follow)

(ai_migrate_by_unit (unit (list_get (ai_actors red/squad_default) 0)) red/squad_default_temp)

(if (!= (ai_status red/squad_default_temp) 0)
(begin
;if AI is 5 world units OUT of range, deactivate health nav
(if (or (> (objects_distance_to_object follow_target (default_check_unit)) 5)
(= (objects_can_see_object follow_target (default_check_unit) 15) false)
)
(begin
(deactivate_nav_point_object follow_target (default_check_unit))
)
)

;if AI is 5 world units IN range, AND health is high, activate green health nav
(if (and (< (objects_distance_to_object follow_target (default_check_unit)) 5)
(= (objects_can_see_object follow_target (default_check_unit) 15) true)
(> (unit_get_health (default_check_unit)) 0.5)
)
(begin
(deactivate_nav_point_object follow_target (default_check_unit))
(activate_nav_point_object "default_green" follow_target (default_check_unit) 0.35)
)
)

;if AI is 5 world units IN range, AND health is low, activate red health nav
(if (and (< (objects_distance_to_object follow_target (default_check_unit)) 5)
(= (objects_can_see_object follow_target (default_check_unit) 15) true)
(< (unit_get_health (default_check_unit)) 0.5)
)
(begin
(deactivate_nav_point_object follow_target (default_check_unit))
(activate_nav_point_object "default_red" follow_target (default_check_unit) 0.35)
)
)

(if (<= (objects_distance_to_object follow_target (default_check_unit)) 0.5)
(begin
(set ai_target (default_check_unit))
(objects_attach ai_target "body" follower_control0 "")
(objects_detach ai_target follower_control0)
)
)
)
)

(ai_migrate red/squad_default_temp red/squad_default)
)
)
)


Test map UPDATED:


EDIT: new video, updated script in OP


EDIT: I added the menu for commanding AI, you need to get close in order to activate it. This is a small update before I rewrite the script.
Edited by Jade on May 13, 2020 at 05:36 AM
Edited by Jade on May 13, 2020 at 08:52 AM


Spartan314
Joined: Aug 21, 2010

Former biped rigger & FP animator


Posted: May 7, 2020 09:43 PM    Msg. 2 of 5       
This is freakin' sick
I remember wanting a large scale map of 100 vs 100 battles
kudos


Jade
Joined: Jan 19, 2020


Posted: May 9, 2020 02:54 AM    Msg. 3 of 5       
Quote: --- Original message by: Spartan314
This is freakin' sick
I remember wanting a large scale map of 100 vs 100 battles
kudos


Thanks, I plan on making more improvements.

EDIT: OP has all the updated info.
Edited by Jade on May 11, 2020 at 01:00 PM


Spiral
Joined: Apr 3, 2011

I hope i'm out of the way


Posted: May 11, 2020 07:52 PM    Msg. 4 of 5       
Excellent work! This is gonna be a lot of fun to play with.


Jade
Joined: Jan 19, 2020


Posted: May 13, 2020 09:06 AM    Msg. 5 of 5       
I've made progress. The commands and menu are working now. I have big plans for a versatile system.

https://youtu.be/cbgb4lmOxs4
https://drive.google.com/open?id=1mMWaUGL4J2kUkfDPhOePl8n5gc5RRTJe

Quote: --- Original message by: Spiral
Excellent work! This is gonna be a lot of fun to play with.

Thanks a bunch!
Edited by Jade on May 13, 2020 at 09:07 AM

 

 
Previous Older Thread    Next newer Thread







Time: Mon May 25, 2020 4:36 PM 109 ms.
A Halo Maps Website