diff --git a/scripts/sp/T4ZM_zbots_main.gsc b/scripts/sp/T4ZM_zbots_main.gsc index ffb1220..179dd51 100644 --- a/scripts/sp/T4ZM_zbots_main.gsc +++ b/scripts/sp/T4ZM_zbots_main.gsc @@ -3,7 +3,7 @@ #include maps\_zombiemode_utility; - +#include scripts\sp\bots\bot_actions_common; #include scripts\sp\bots\actions\combat; #include scripts\sp\bots\actions\movement; #include scripts\sp\bots\actions\objective; @@ -13,37 +13,37 @@ main() //3 separate bot think threads //Objective group is for things to go to usually allowing the bot to kill zombies on the way and survive as normal //Objectives can be canceled/postponed by combat thread, movement thread or by other objectives - register_bot_action( "objective", "magicbox", ::bot_magicbox_purchase, ::bot_magicbox_process_order, ::bot_should_purchase_magicbox, ::bot_magicbox_purchase_on_completion, ::bot_magicbox_purchase_should_cancel, ::bot_magicbox_purchase_on_cancel, ::bot_magicbox_purchase_should_postpone, ::bot_magicbox_purchase_on_postpone, ::bot_magicbox_purchase_priority ); - register_bot_action( "objective", "wallbuy", ::bot_wallbuy_purchase, ::bot_wallbuy_process_order, ::bot_should_purchase_wallbuy, ::bot_wallbuy_purchase_on_completion, ::bot_wallbuy_purchase_should_cancel, ::bot_wallbuy_purchase_on_cancel, ::bot_wallbuy_purchase_should_postpone, ::bot_wallbuy_purchase_on_postpone, ::bot_wallbuy_purchase_priority ); - register_bot_action( "objective", "wallbuyammo", ::bot_wallbuy_ammo_purchase, ::bot_wallbuyammo_process_order, ::bot_should_purchase_wallbuy_ammo, ::bot_wallbuy_ammo_purchase_on_completion, ::bot_wallbuy_ammo_purchase_should_cancel, ::bot_wallbuy_ammo_purchase_on_cancel, ::bot_wallbuy_ammo_purchase_should_postpone, ::bot_wallbuy_ammo_purchase_on_postpone, ::bot_wallbuy_ammo_purchase_priority ); - register_bot_action( "objective", "perk", ::bot_perk_purchase, ::bot_perk_process_order, ::bot_should_purchase_perk, ::bot_perk_purchase_on_completion, ::bot_perk_purchase_should_cancel, ::bot_perk_purchase_on_cancel, ::bot_perk_purchase_should_postpone, ::bot_perk_purchase_on_postpone, ::bot_perk_purchase_priority ); - register_bot_action( "objective", "door", ::bot_door_purchase, ::bot_door_process_order, ::bot_should_purchase_door, ::bot_door_purchase_on_completion, ::bot_door_purchase_should_cancel, ::bot_door_purchase_on_cancel, ::bot_door_purchase_should_postpone, ::bot_door_purchase_on_postpone, ::bot_door_purchase_priority ); - register_bot_action( "objective", "debris", ::bot_debris_purchase, ::bot_debris_process_order, ::bot_should_purchase_debris, ::bot_debris_purchase_on_completion, ::bot_debris_purchase_should_cancel, ::bot_debris_purchase_on_cancel, ::bot_debris_purchase_should_postpone, ::bot_debris_purchase_on_postpone, ::bot_debris_purchase_priority ); - register_bot_action( "objective", "trap", ::bot_trap_purchase, ::bot_trap_process_order, ::bot_should_purchase_trap, ::bot_trap_purchase_on_completion, ::bot_trap_purchase_should_cancel, ::bot_trap_purchase_on_cancel, ::bot_trap_purchase_should_postpone, ::bot_trap_purchase_on_postpone, ::bot_trap_purchase_priority ); - register_bot_action( "objective", "packapunch", ::bot_packapunch_purchase, ::bot_packapunch_process_order, ::bot_should_purchase_packapunch, ::bot_packapunch_purchase_on_completion, ::bot_packapunch_purchase_should_cancel, ::bot_packapunch_purchase_on_cancel, ::bot_packapunch_purchase_should_postpone, ::bot_packapunch_purchase_on_postpone, ::bot_packapunch_purchase_priority ); - register_bot_action( "objective", "revive", ::bot_revive_player, ::bot_revive_process_order, ::bot_should_revive_player, ::bot_revive_player_on_completion, ::bot_revive_player_should_cancel, ::bot_revive_player_on_cancel, ::bot_revive_player_should_postpone, ::bot_revive_player_on_postpone, ::bot_revive_player_priority ); - register_bot_action( "objective", "grabbuildable", ::bot_grab_buildable, ::bot_grabbuildable_process_order, ::bot_should_grab_buildable, ::bot_grab_buildable_on_completion, ::bot_grab_buildable_should_cancel, ::bot_grabbuild_buildable_on_cancel, ::bot_grab_buildable_should_postpone, ::bot_grab_buildable_on_postpone, ::bot_grab_buildable_priority ); - register_bot_action( "objective", "buildbuildable", ::bot_build_buildable, ::bot_buildbuildable_process_order, ::bot_should_build_buildable, ::bot_build_buildable_on_completion, ::bot_build_buildable_should_cancel, ::bot_build_buildable_on_cancel, ::bot_build_buildable_should_postpone, ::bot_build_buildable_on_postpone, ::bot_build_buildable_priority ); - register_bot_action( "objective", "part", ::bot_grab_part, ::bot_part_process_order, ::bot_should_grab_part, ::bot_part_on_completion, ::bot_part_should_cancel, ::bot_part_on_cancel, ::bot_part_should_postpone, ::bot_part_on_postpone, ::bot_part_priority ); - register_bot_action( "objective", "powerup", ::bot_grab_powerup, ::bot_powerup_process_order, ::bot_should_grab_powerup, ::bot_powerup_on_completion, ::bot_powerup_should_cancel, ::bot_powerup_on_cancel, ::bot_powerup_should_postpone, ::bot_powerup_on_postpone, ::bot_powerup_priority ); + register_bot_action( "objective", "magicbox", ::bot_magicbox_purchase, ::bot_magicbox_process_order, ::bot_should_purchase_magicbox, ::bot_check_complete_magicbox, ::bot_set_complete_magicbox, ::bot_magicbox_purchase_on_completion, ::bot_magicbox_purchase_should_cancel, ::bot_magicbox_purchase_on_cancel, ::bot_magicbox_purchase_should_postpone, ::bot_magicbox_purchase_on_postpone, ::bot_magicbox_purchase_priority ); + register_bot_action( "objective", "wallbuy", ::bot_wallbuy_purchase, ::bot_wallbuy_process_order, ::bot_should_purchase_wallbuy, ::bot_check_complete_wallbuy, ::bot_set_complete_wallbuy, ::bot_wallbuy_purchase_on_completion, ::bot_wallbuy_purchase_should_cancel, ::bot_wallbuy_purchase_on_cancel, ::bot_wallbuy_purchase_should_postpone, ::bot_wallbuy_purchase_on_postpone, ::bot_wallbuy_purchase_priority ); + register_bot_action( "objective", "wallbuyammo", ::bot_wallbuy_ammo_purchase, ::bot_wallbuyammo_process_order, ::bot_should_purchase_wallbuy_ammo, ::bot_check_complete_wallbuy_ammo, ::bot_set_complete_wallbuy_ammo, ::bot_wallbuy_ammo_purchase_on_completion, ::bot_wallbuy_ammo_purchase_should_cancel, ::bot_wallbuy_ammo_purchase_on_cancel, ::bot_wallbuy_ammo_purchase_should_postpone, ::bot_wallbuy_ammo_purchase_on_postpone, ::bot_wallbuy_ammo_purchase_priority ); + register_bot_action( "objective", "perk", ::bot_perk_purchase, ::bot_perk_process_order, ::bot_should_purchase_perk, ::bot_check_complete_perk_purchase, ::bot_set_complete_perk_purchase, ::bot_perk_purchase_on_completion, ::bot_perk_purchase_should_cancel, ::bot_perk_purchase_on_cancel, ::bot_perk_purchase_should_postpone, ::bot_perk_purchase_on_postpone, ::bot_perk_purchase_priority ); + register_bot_action( "objective", "door", ::bot_door_purchase, ::bot_door_process_order, ::bot_should_purchase_door, ::bot_check_complete_door_purchase, ::bot_set_complete_door_purchase, ::bot_door_purchase_on_completion, ::bot_door_purchase_should_cancel, ::bot_door_purchase_on_cancel, ::bot_door_purchase_should_postpone, ::bot_door_purchase_on_postpone, ::bot_door_purchase_priority ); + register_bot_action( "objective", "debris", ::bot_debris_purchase, ::bot_debris_process_order, ::bot_should_purchase_debris, ::bot_check_complete_debris_purchase, ::bot_set_complete_debris_purchase, ::bot_debris_purchase_on_completion, ::bot_debris_purchase_should_cancel, ::bot_debris_purchase_on_cancel, ::bot_debris_purchase_should_postpone, ::bot_debris_purchase_on_postpone, ::bot_debris_purchase_priority ); + register_bot_action( "objective", "trap", ::bot_trap_purchase, ::bot_trap_process_order, ::bot_should_purchase_trap, ::bot_check_complete_trap_purchase, ::bot_set_complete_trap_purchase, ::bot_trap_purchase_on_completion, ::bot_trap_purchase_should_cancel, ::bot_trap_purchase_on_cancel, ::bot_trap_purchase_should_postpone, ::bot_trap_purchase_on_postpone, ::bot_trap_purchase_priority ); + register_bot_action( "objective", "packapunch", ::bot_packapunch_purchase, ::bot_packapunch_process_order, ::bot_should_purchase_packapunch, ::bot_check_complete_packapunch_purchase, ::bot_set_complete_packapunch_purchase, ::bot_packapunch_purchase_on_completion, ::bot_packapunch_purchase_should_cancel, ::bot_packapunch_purchase_on_cancel, ::bot_packapunch_purchase_should_postpone, ::bot_packapunch_purchase_on_postpone, ::bot_packapunch_purchase_priority ); + register_bot_action( "objective", "revive", ::bot_revive_player, ::bot_revive_process_order, ::bot_should_revive_player, ::bot_check_complete_revive_player, ::bot_set_complete_revive_player, ::bot_revive_player_on_completion, ::bot_revive_player_should_cancel, ::bot_revive_player_on_cancel, ::bot_revive_player_should_postpone, ::bot_revive_player_on_postpone, ::bot_revive_player_priority ); + register_bot_action( "objective", "grabbuildable", ::bot_grab_buildable, ::bot_grab_buildable_process_order, ::bot_should_grab_buildable, ::bot_check_complete_grab_buildable, ::bot_set_complete_grab_buildable, ::bot_grab_buildable_on_completion, ::bot_grab_buildable_should_cancel, ::bot_grabbuild_buildable_on_cancel, ::bot_grab_buildable_should_postpone, ::bot_grab_buildable_on_postpone, ::bot_grab_buildable_priority ); + register_bot_action( "objective", "buildbuildable", ::bot_build_buildable, ::bot_build_buildable_process_order, ::bot_should_build_buildable, ::bot_check_complete_build_buildable, ::bot_set_complete_build_buildable, ::bot_build_buildable_on_completion, ::bot_build_buildable_should_cancel, ::bot_build_buildable_on_cancel, ::bot_build_buildable_should_postpone, ::bot_build_buildable_on_postpone, ::bot_build_buildable_priority ); + register_bot_action( "objective", "part", ::bot_grab_part, ::bot_part_process_order, ::bot_should_grab_part, ::bot_check_complete_grab_part, ::bot_set_complete_grab_part, ::bot_part_on_completion, ::bot_part_should_cancel, ::bot_part_on_cancel, ::bot_part_should_postpone, ::bot_part_on_postpone, ::bot_part_priority ); + register_bot_action( "objective", "powerup", ::bot_grab_powerup, ::bot_powerup_process_order, ::bot_should_grab_powerup, ::bot_check_complete_grab_powerup, ::bot_set_complete_grab_powerup, ::bot_powerup_on_completion, ::bot_powerup_should_cancel, ::bot_powerup_on_cancel, ::bot_powerup_should_postpone, ::bot_powerup_on_postpone, ::bot_powerup_priority ); //Combat thread actions //These all need definitions - register_bot_action( "combat", "aimatsinglenormalzombie", ::bot_aimatsinglenormalzombie, ::bot_aimatsinglenormalzombie_process_order ::bot_should_aimatsinglenormalzombie, ::bot_aimatsinglenormalzombie_on_completion, ::bot_aimatsinglenormalzombie_should_cancel, ::bot_aimatsinglenormalzombie_on_cancel, ::bot_aimatsinglenormalzombie_should_postpone, ::bot_aimatsinglenormalzombie_on_postpone, ::bot_aimatsinglenormalzombie_priority ); - register_bot_action( "combat", "shootsinglenormalzombie", ::bot_shootsinglenormalzombie, ::bot_shootsinglenormalzombie_process_order ::bot_should_shootsinglenormalzombie, ::bot_shootsinglenormalzombie_on_completion, ::bot_shootsinglenormalzombie_should_cancel, ::bot_shootsinglenormalzombie_on_cancel, ::bot_shootsinglenormalzombie_should_postpone, ::bot_shootsinglenormalzombie_on_postpone, ::bot_shootsinglenormalzombie_priority ); - register_bot_action( "combat", "aimatmultiplenormalzombies", ::bot_aimatmultiplenormalzombies, ::bot_aimatmultiplenormalzombies_process_order ::bot_should_aimatmultiplenormalzombies, ::bot_aimatmultiplenormalzombies_on_completion, ::bot_aimatmultiplenormalzombies_should_cancel, ::bot_aimatmultiplenormalzombies_on_cancel, ::bot_aimatmultiplenormalzombies_should_postpone, ::bot_aimatmultiplenormalzombies_on_postpone, ::bot_aimatmultiplenormalzombies_priority ); - register_bot_action( "combat", "shootmultiplenormalzombies", ::bot_shootmultiplenormalzombies, ::bot_shootmultiplenormalzombies_process_order ::bot_should_shootmultiplenormalzombies, ::bot_shootmultiplenormalzombie_on_completion, ::bot_shootmultiplenormalzombie_should_cancel, ::bot_shootmultiplenormalzombie_on_cancel, ::bot_shootmultiplenormalzombie_should_postpone, ::bot_shootmultiplenormalzombie_on_postpone, ::bot_shootmultiplenormalzombie_priority ); - register_bot_action( "combat", "meleesinglenormalzombie", ::bot_meleesinglenormalzombie, ::bot_meleesinglenormalzombie_process_order ::bot_should_meleesinglenormalzombie, ::bot_meleesinglenormalzombie_on_completion, ::bot_meleesinglenormalzombie_should_cancel, ::bot_meleesinglenormalzombie_on_cancel, ::bot_meleesinglenormalzombie_should_postpone, ::bot_meleesinglenormalzombie_on_postpone, ::bot_meleesinglenormalzombie_priority ); - register_bot_action( "combat", "shootsingledogzombie", ::bot_shootsingledogzombie, ::bot_shootsingledogzombie_process_order ::bot_should_shootsingledogzombie, ::bot_shootsingledogzombie_on_completion, ::bot_shootsingledogzombie_should_cancel, ::bot_shootsingledogzombie_on_cancel, ::bot_shootsingledogzombie_should_postpone, ::bot_shootsingledogzombie_on_postpone, ::bot_shootsingledogzombie_priority ); - register_bot_action( "combat", "shootmultipledogzombies", ::bot_shootmultipledogzombies, ::bot_shootmultipledogzombies_process_order ::bot_should_shootmultipledogzombies, ::bot_shootmultipledogzombies_on_completion, ::bot_shootmultipledogzombies_should_cancel, ::bot_shootmultipledogzombies_on_cancel, ::bot_shootmultipledogzombies_should_postpone, ::bot_shootmultipledogzombies_on_postpone, ::bot_shootmultipledogzombies_priority ); - register_bot_action( "combat", "meleesingledogzombie", ::bot_meleesingledogzombie, ::bot_meleesingledogzombie_process_order ::bot_should_meleesingledogzombie, ::bot_meleesingledogzombie_on_completion, ::bot_meleesingledogzombie_should_cancel, ::bot_meleesingledogzombie_on_cancel, ::bot_meleesingledogzombie_should_postpone, ::bot_meleesingledogzombie_on_postpone, ::bot_meleesingledogzombie_priority ); + register_bot_action( "combat", "aimatsinglenormalzombie", ::bot_aimatsinglenormalzombie, ::bot_aimatsinglenormalzombie_process_order ::bot_should_aimatsinglenormalzombie, ::bot_check_complete_aimatsinglenormalzombie, ::bot_set_complete_aimatsinglenormalzombie, ::bot_aimatsinglenormalzombie_on_completion, ::bot_aimatsinglenormalzombie_should_cancel, ::bot_aimatsinglenormalzombie_on_cancel, ::bot_aimatsinglenormalzombie_should_postpone, ::bot_aimatsinglenormalzombie_on_postpone, ::bot_aimatsinglenormalzombie_priority ); + register_bot_action( "combat", "shootsinglenormalzombie", ::bot_shootsinglenormalzombie, ::bot_shootsinglenormalzombie_process_order ::bot_should_shootsinglenormalzombie, ::bot_check_complete_shootsinglenormalzombie, ::bot_set_complete_shootsinglenormalzombie, ::bot_shootsinglenormalzombie_on_completion, ::bot_shootsinglenormalzombie_should_cancel, ::bot_shootsinglenormalzombie_on_cancel, ::bot_shootsinglenormalzombie_should_postpone, ::bot_shootsinglenormalzombie_on_postpone, ::bot_shootsinglenormalzombie_priority ); + register_bot_action( "combat", "aimatmultiplenormalzombies", ::bot_aimatmultiplenormalzombies, ::bot_aimatmultiplenormalzombies_process_order ::bot_should_aimatmultiplenormalzombies, ::bot_check_complete_aimatmultiplenormalzombies, ::bot_set_complete_aimatmultiplenormalzombies, ::bot_aimatmultiplenormalzombies_on_completion, ::bot_aimatmultiplenormalzombies_should_cancel, ::bot_aimatmultiplenormalzombies_on_cancel, ::bot_aimatmultiplenormalzombies_should_postpone, ::bot_aimatmultiplenormalzombies_on_postpone, ::bot_aimatmultiplenormalzombies_priority ); + register_bot_action( "combat", "shootmultiplenormalzombies", ::bot_shootmultiplenormalzombies, ::bot_shootmultiplenormalzombies_process_order ::bot_should_shootmultiplenormalzombies, ::bot_check_complete_shootmultiplenormalzombies, ::bot_set_complete_shootmultiplenormalzombies, ::bot_shootmultiplenormalzombie_on_completion, ::bot_shootmultiplenormalzombie_should_cancel, ::bot_shootmultiplenormalzombie_on_cancel, ::bot_shootmultiplenormalzombie_should_postpone, ::bot_shootmultiplenormalzombie_on_postpone, ::bot_shootmultiplenormalzombie_priority ); + register_bot_action( "combat", "meleesinglenormalzombie", ::bot_meleesinglenormalzombie, ::bot_meleesinglenormalzombie_process_order ::bot_should_meleesinglenormalzombie, ::bot_check_complete_meleesinglenormalzombie, ::bot_set_complete_meleesinglenormalzombie, ::bot_meleesinglenormalzombie_on_completion, ::bot_meleesinglenormalzombie_should_cancel, ::bot_meleesinglenormalzombie_on_cancel, ::bot_meleesinglenormalzombie_should_postpone, ::bot_meleesinglenormalzombie_on_postpone, ::bot_meleesinglenormalzombie_priority ); + register_bot_action( "combat", "shootsingledogzombie", ::bot_shootsingledogzombie, ::bot_shootsingledogzombie_process_order ::bot_should_shootsingledogzombie, ::bot_check_complete_shootsingledogzombie, ::bot_set_complete_shootsingledogzombie, ::bot_shootsingledogzombie_on_completion, ::bot_shootsingledogzombie_should_cancel, ::bot_shootsingledogzombie_on_cancel, ::bot_shootsingledogzombie_should_postpone, ::bot_shootsingledogzombie_on_postpone, ::bot_shootsingledogzombie_priority ); + register_bot_action( "combat", "shootmultipledogzombies", ::bot_shootmultipledogzombies, ::bot_shootmultipledogzombies_process_order ::bot_should_shootmultipledogzombies, ::bot_check_complete_shootmultipledogzombies, ::bot_set_complete_shootmultipledogzombies, ::bot_shootmultipledogzombies_on_completion, ::bot_shootmultipledogzombies_should_cancel, ::bot_shootmultipledogzombies_on_cancel, ::bot_shootmultipledogzombies_should_postpone, ::bot_shootmultipledogzombies_on_postpone, ::bot_shootmultipledogzombies_priority ); + register_bot_action( "combat", "meleesingledogzombie", ::bot_meleesingledogzombie, ::bot_meleesingledogzombie_process_order ::bot_should_meleesingledogzombie, ::bot_check_complete_meleesingledogzombie, ::bot_set_complete_meleesingledogzombie, ::bot_meleesingledogzombie_on_completion, ::bot_meleesingledogzombie_should_cancel, ::bot_meleesingledogzombie_on_cancel, ::bot_meleesingledogzombie_should_postpone, ::bot_meleesingledogzombie_on_postpone, ::bot_meleesingledogzombie_priority ); //Movement thread actions //These all need definitions - register_bot_action( "movement", "movetoobjective", ::bot_movetoobjective, ::bot_movetoobjective_process_order ::bot_should_movetoobjective, ::bot_movetoobjective_on_completion, ::bot_movetoobjective_should_cancel, ::bot_movetoobjective_on_cancel, ::bot_movetoobjective_should_postpone, ::bot_movetoobjective_on_postpone, ::bot_movetoobjective_priority ); - register_bot_action( "movement", "train", ::bot_train, ::bot_train_process_order ::bot_should_train, ::bot_train_on_completion, ::bot_train_should_cancel, ::bot_train_on_cancel, ::bot_train_should_postpone, ::bot_train_on_postpone, ::bot_train_priority ); - register_bot_action( "movement", "camp", ::bot_camp, ::bot_camp_process_order ::bot_should_camp, ::bot_camp_on_completion, ::bot_camp_should_cancel, ::bot_camp_on_cancel, ::bot_camp_should_postpone, ::bot_camp_on_postpone, ::bot_camp_priority ); - register_bot_action( "movement", "flee", ::bot_flee, ::bot_flee_process_order ::bot_should_flee, ::bot_flee_on_completion, ::bot_flee_should_cancel, ::bot_flee_on_cancel, ::bot_flee_should_postpone, ::bot_flee_on_postpone, ::bot_flee_priority ); + register_bot_action( "movement", "movetoobjective", ::bot_movetoobjective, ::bot_movetoobjective_process_order ::bot_should_movetoobjective, ::bot_check_complete_movetoobjective, ::bot_set_complete_movetoobjective, ::bot_movetoobjective_on_completion, ::bot_movetoobjective_should_cancel, ::bot_movetoobjective_on_cancel, ::bot_movetoobjective_should_postpone, ::bot_movetoobjective_on_postpone, ::bot_movetoobjective_priority ); + register_bot_action( "movement", "train", ::bot_train, ::bot_train_process_order ::bot_should_train, ::bot_check_complete_train, ::bot_set_complete_train, ::bot_train_on_completion, ::bot_train_should_cancel, ::bot_train_on_cancel, ::bot_train_should_postpone, ::bot_train_on_postpone, ::bot_train_priority ); + register_bot_action( "movement", "camp", ::bot_camp, ::bot_camp_process_order ::bot_should_camp, ::bot_check_complete_camp, ::bot_set_complete_camp, ::bot_camp_on_completion, ::bot_camp_should_cancel, ::bot_camp_on_cancel, ::bot_camp_should_postpone, ::bot_camp_on_postpone, ::bot_camp_priority ); + register_bot_action( "movement", "flee", ::bot_flee, ::bot_flee_process_order ::bot_should_flee, ::bot_check_complete_flee, ::bot_set_complete_flee, ::bot_flee_on_completion, ::bot_flee_should_cancel, ::bot_flee_on_cancel, ::bot_flee_should_postpone, ::bot_flee_on_postpone, ::bot_flee_priority ); level.bot_weapon_quality_poor = 0; level.bot_weapon_quality_fair = 1; @@ -75,22 +75,6 @@ init() parse_bot_weapon_stats_from_table(); } -register_action_queue_actions() -{ - self register_bot_action_queue_action( "magicbox" ); - self register_bot_action_queue_action( "wallbuy" ); - self register_bot_action_queue_action( "wallbuyammo" ); - self register_bot_action_queue_action( "perk" ); - self register_bot_action_queue_action( "door" ); - self register_bot_action_queue_action( "debris" ); - self register_bot_action_queue_action( "trap" ); - self register_bot_action_queue_action( "revive" ); - self register_bot_action_queue_action( "buildable" ); - self register_bot_action_queue_action( "buildbuildable" ); - self register_bot_action_queue_action( "part" ); - self register_bot_action_queue_action( "powerup" ); -} - spawn_bots() { level waittill( "connected", player ); @@ -115,66 +99,21 @@ spawn_bots() } bot.pers[ "isBot" ] = true; bot.action_queue = []; + bot.action_queue[ "objective" ] = []; + bot.action_queue[ "combat" ] = []; + bot.action_queue[ "movement" ] = []; bot register_action_queue_actions(); bot thread bot_movement_think(); //bot thread bot_combat_think(); - bot thread bot_think(); + bot thread bot_objective_think(); bot_count++; } } -copy_default_action_settings_to_queue( action_name ) +bot_objective_think() { - //self.group = level.zbots_actions[ action_name ].group; - self.action = level.zbots_actions[ action_name ].action; - //self.should_do_func = level.zbots_actions[ action_name ].should_do_func; - self.on_completion_func = level.zbots_actions[ action_name ].on_completion_func; - self.should_cancel_func = level.zbots_actions[ action_name ].should_cancel_func; - self.on_cancel_func = level.zbots_actions[ action_name ].on_cancel_func; - self.should_postpone_func = level.zbots_actions[ action_name ].should_postpone_func; - self.on_postpone_func = level.zbots_actions[ action_name ].on_postpone_func; - self.priority_func = level.zbots_actions[ action_name ].priority_func; -} + group_name = "objective"; -process_next_queued_action() -{ - if ( self.action_queue.size <= 0 ) - { - return; - } - self thread [[ self.action_queue[ 0 ].on_completion_func ]](); - if ( self.action_queue[ 0 ].can_cancel ) - { - self thread [[ self.action_queue[ 0 ].on_cancel_func ]](); - } - if ( self.action_queue[ 0 ].can_postpone ) - { - self thread [[ self.action_queue[ 0 ].on_postpone_func ]](); - } - self [[ self.action_queue[ 0 ].action ]](); - - self wait_for_action_completion( self.action_queue[ 0 ].action_name ); -} - -wait_for_action_completion( action_name ) -{ - result = self waittill_any_return( action_name + "_completion", action_name + "_cancel", action_name + "_postpone" ); - if ( isDefined( result ) && ( result == action_name + "_completion" || result == action_name + "_cancel" ) ) - { - self.actions_in_queue[ self.action_queue[ 0 ].action_name ].queued = false; - arrayRemoveIndex( self.action_queue, 0 ); - } - else if ( result == action_name + "_postpone" ) - { - postponed_action = self.action_queue[ 0 ]; - arrayRemoveIndex( self.action_queue, 0 ); - postponed_action.priority = 0; - self.action_queue[ self.action_queue.size ] = postponed_action; - } -} - -bot_think() -{ level endon( "end_game" ); self endon( "disconnect" ); @@ -193,33 +132,31 @@ bot_think() action_keys = getArrayKeys( level.zbots_actions ); for ( i = 0; i < action_keys.size; i++ ) { - if ( self.actions_in_queue[ action_keys[ i ] ].canceled ) + if ( self.zbot_actions_in_queue[ action_keys[ i ] ].canceled ) { - self.actions_in_queue[ action_keys[ i ] ].canceled = false; + self.zbot_actions_in_queue[ action_keys[ i ] ].canceled = false; } } action_keys = getArrayKeys( level.zbots_actions ); for ( i = 0; i < action_keys.size; i++ ) { - if ( self.actions_in_queue[ action_keys[ i ] ].postponed ) + if ( self.zbot_actions_in_queue[ action_keys[ i ] ].postponed ) { - self.actions_in_queue[ action_keys[ i ] ].postponed = false; + self.zbot_actions_in_queue[ action_keys[ i ] ].postponed = false; } } */ - action_keys = getArrayKeys( level.zbots_actions ); - for ( i = 0; i < action_keys.size; i++ ) + action_keys = getArrayKeys( level.zbots_actions[ group_name ] ); + + //TODO: Use process order funcs to determine the order of actions being added to the queue + /* + for ( i = 0; i < action_keys; i++ ) { - if ( !self.actions_in_queue[ action_keys[ i ] ].queued && [[ level.zbots_actions[ action_keys[ i ] ].should_do_func ]]() ) - { - self.action_queue[ self.action_queue.size ] = spawnStruct(); - self.action_queue[ self.action_queue.size - 1 ] copy_default_action_settings_to_queue( action_keys[ i ] ); - self.action_queue[ self.action_queue.size - 1 ].action_name = action_keys[ i ]; - self.action_queue[ self.action_queue.size - 1 ].priority = self [[ level.zbots_actions[ action_keys[ i ] ].priority_func ]](); - self.actions_in_queue[ action_keys[ i ] ].queued = true; - } + } - self.action_queue = self sort_array_by_priority_field( self.action_queue ); + */ + self pick_actions_to_add_to_queue( group_name, action_keys ); + self.action_queue[ group_name ] = self sort_array_by_priority_field( self.action_queue[ group_name ] ); self process_next_queued_action(); } } diff --git a/scripts/sp/bots/actions/combat.gsc b/scripts/sp/bots/actions/combat.gsc index ed9662c..f7b563f 100644 --- a/scripts/sp/bots/actions/combat.gsc +++ b/scripts/sp/bots/actions/combat.gsc @@ -1,5 +1,3 @@ - - bot_aimatsinglenormalzombie() { @@ -15,6 +13,16 @@ bot_should_aimatsinglenormalzombie() return false; } +bot_check_complete_aimatsinglenormalzombie() +{ + +} + +bot_set_complete_aimatsinglenormalzombie() +{ + +} + bot_aimatsinglenormalzombie_on_completion() { @@ -60,6 +68,16 @@ bot_should_shootsinglenormalzombie() return false; } +bot_check_complete_shootsinglenormalzombie() +{ + +} + +bot_set_complete_shootsinglenormalzombie() +{ + +} + bot_shootsinglenormalzombie_on_completion() { @@ -105,6 +123,16 @@ bot_should_aimatmultiplenormalzombies() return false; } +bot_check_complete_aimatmultiplenormalzombies() +{ + +} + +bot_set_complete_aimatmultiplenormalzombies() +{ + +} + bot_aimatmultiplenormalzombies_on_completion() { @@ -150,6 +178,16 @@ bot_should_shootmultiplenormalzombies() return false; } +bot_check_complete_shootmultiplenormalzombies() +{ + +} + +bot_set_complete_shootmultiplenormalzombies() +{ + +} + bot_shootmultiplenormalzombie_on_completion() { @@ -195,6 +233,16 @@ bot_should_meleesinglenormalzombie() } +bot_check_complete_meleesinglenormalzombie() +{ + +} + +bot_set_complete_meleesinglenormalzombie() +{ + +} + bot_meleesinglenormalzombie_on_completion() { @@ -240,6 +288,16 @@ bot_should_shootsingledogzombie() return false; } +bot_check_complete_shootsingledogzombie() +{ + +} + +bot_set_complete_shootsingledogzombie() +{ + +} + bot_shootsingledogzombie_on_completion() { @@ -285,6 +343,16 @@ bot_should_shootmultipledogzombies() return false; } +bot_check_complete_shootmultipledogzombies() +{ + +} + +bot_set_complete_shootmultipledogzombies() +{ + +} + bot_shootmultipledogzombies_on_completion() { @@ -330,6 +398,16 @@ bot_should_meleesingledogzombie() return false; } +bot_check_complete_meleesingledogzombie() +{ + +} + +bot_set_complete_meleesingledogzombie() +{ + +} + bot_meleesingledogzombie_on_completion() { diff --git a/scripts/sp/bots/actions/movement.gsc b/scripts/sp/bots/actions/movement.gsc index 49fd713..fa7fd2e 100644 --- a/scripts/sp/bots/actions/movement.gsc +++ b/scripts/sp/bots/actions/movement.gsc @@ -13,6 +13,16 @@ bot_should_movetoobjective() return false; } +bot_check_complete_movetoobjective() +{ + +} + +bot_set_complete_movetoobjective() +{ + +} + bot_movetoobjective_on_completion() { @@ -58,6 +68,16 @@ bot_should_train() return false; } +bot_check_complete_train() +{ + +} + +bot_set_complete_train() +{ + +} + bot_train_on_completion() { @@ -103,6 +123,16 @@ bot_should_camp() return false; } +bot_check_complete_camp() +{ + +} + +bot_set_complete_camp() +{ + +} + bot_camp_on_completion() { @@ -148,6 +178,16 @@ bot_should_flee() return false; } +bot_check_complete_flee() +{ + +} + +bot_set_complete_flee() +{ + +} + bot_flee_on_completion() { diff --git a/scripts/sp/bots/actions/objective.gsc b/scripts/sp/bots/actions/objective.gsc index 537f7e6..e977605 100644 --- a/scripts/sp/bots/actions/objective.gsc +++ b/scripts/sp/bots/actions/objective.gsc @@ -45,6 +45,16 @@ bot_should_purchase_magicbox() return self.available_chests.size > 0; } +bot_check_complete_magicbox() +{ + +} + +bot_set_complete_magicbox() +{ + +} + bot_magicbox_purchase_on_completion() { @@ -104,6 +114,16 @@ bot_should_purchase_wallbuy() return false; } +bot_check_complete_wallbuy() +{ + +} + +bot_set_complete_wallbuy() +{ + +} + bot_wallbuy_purchase_on_completion() { @@ -149,6 +169,16 @@ bot_should_purchase_wallbuy_ammo() return false; } +bot_check_complete_wallbuy_ammo() +{ + +} + +bot_set_complete_wallbuy_ammo() +{ + +} + bot_wallbuy_ammo_purchase_on_completion() { @@ -194,6 +224,16 @@ bot_should_purchase_perk() return false; } +bot_check_complete_perk_purchase() +{ + +} + +bot_set_complete_perk_purchase() +{ + +} + bot_perk_purchase_on_completion() { @@ -239,6 +279,16 @@ bot_should_purchase_door() return false; } +bot_check_complete_door_purchase() +{ + +} + +bot_set_complete_door_purchase() +{ + +} + bot_door_purchase_on_completion() { @@ -284,6 +334,16 @@ bot_should_purchase_debris() return false; } +bot_check_complete_debris_purchase() +{ + +} + +bot_set_complete_debris_purchase() +{ + +} + bot_debris_purchase_on_completion() { @@ -329,6 +389,16 @@ bot_should_purchase_trap() return false; } +bot_check_complete_trap_purchase() +{ + +} + +bot_set_complete_trap_purchase() +{ + +} + bot_trap_purchase_on_completion() { @@ -374,6 +444,16 @@ bot_should_purchase_packapunch() return false; } +bot_check_complete_packapunch_purchase() +{ + +} + +bot_set_complete_packapunch_purchase() +{ + +} + bot_packapunch_purchase_on_completion() { @@ -419,6 +499,16 @@ bot_should_revive_player() return false; } +bot_check_complete_revive_player() +{ + +} + +bot_set_complete_revive_player() +{ + +} + bot_revive_player_on_completion() { @@ -454,7 +544,7 @@ bot_grab_buildable() } -bot_grabbuildable_process_order() +bot_grab_buildable_process_order() { return 0; } @@ -464,6 +554,16 @@ bot_should_grab_buildable() return false; } +bot_check_complete_grab_buildable() +{ + +} + +bot_set_complete_grab_buildable() +{ + +} + bot_grab_buildable_on_completion() { @@ -499,7 +599,7 @@ bot_build_buildable() } -bot_buildbuildable_process_order() +bot_build_buildable_process_order() { return 0; } @@ -509,6 +609,16 @@ bot_should_build_buildable() return false; } +bot_check_complete_build_buildable() +{ + +} + +bot_set_complete_build_buildable() +{ + +} + bot_build_buildable_on_completion() { @@ -564,6 +674,16 @@ bot_part_should_cancel() return false; } +bot_check_complete_grab_part() +{ + +} + +bot_set_complete_grab_part() +{ + +} + bot_part_on_cancel() { @@ -651,6 +771,16 @@ bot_should_grab_powerup() return self.available_powerups.size > 0; } +bot_check_complete_grab_powerup() +{ + +} + +bot_set_complete_grab_powerup() +{ + +} + bot_powerup_on_completion() { level endon( "end_game" ); diff --git a/scripts/sp/bots/bot_actions_common.gsc b/scripts/sp/bots/bot_actions_common.gsc index d28391f..6c67f3f 100644 --- a/scripts/sp/bots/bot_actions_common.gsc +++ b/scripts/sp/bots/bot_actions_common.gsc @@ -5,7 +5,7 @@ #include maps\_utility; #include maps\_zombiemode_utility; -register_bot_action( group, action_name, action_func, should_do_func, action_process_order_func, action_completion_func, should_cancel_func, on_cancel_func, should_postpone_func, on_postpone_func, priority_func ) +register_bot_action( group, action_name, action_func, action_process_order_func, should_do_func, check_if_complete_func, set_complete_func, on_completion_func, should_cancel_func, on_cancel_func, should_postpone_func, on_postpone_func, priority_func ) { if ( !isDefined( level.zbots_actions ) ) { @@ -20,7 +20,9 @@ register_bot_action( group, action_name, action_func, should_do_func, action_pro level.zbots_actions[ action_name ].action = action_func; level.zbots_actions[ action_name ].should_do_func = should_do_func; level.zbots_actions[ action_name ].action_process_order_func = action_process_order_func; - level.zbots_actions[ action_name ].on_completion_func = action_completion_func; + level.zbots_actions[ action_name ].check_if_complete_func = check_if_complete_func; + level.zbots_actions[ action_name ].set_complete_func = set_complete_func; + level.zbots_actions[ action_name ].on_completion_func = on_completion_func; level.zbots_actions[ action_name ].should_cancel_func = should_cancel_func; level.zbots_actions[ action_name ].on_cancel_func = on_cancel_func; level.zbots_actions[ action_name ].should_postpone_func = should_postpone_func; @@ -28,15 +30,125 @@ register_bot_action( group, action_name, action_func, should_do_func, action_pro level.zbots_actions[ action_name ].priority_func = priority_func; } -register_bot_action_queue_action( action_name ) +initialize_bot_actions_queue() { - if ( !isDefined( self.actions_in_queue ) ) + keys = getArrayKeys( level.zbots_actions ); + for ( i = 0; i < keys.size; i++ ) { - self.actions_in_queue = []; + self register_bot_objective_action_for_queue( keys[ i ], level.zbots_actions[ keys[ i ] ].group ); + } +} + +register_bot_objective_action_for_queue( action_name ) +{ + if ( !isDefined( self.zbot_actions_in_queue ) ) + { + self.zbot_actions_in_queue = []; + } + if ( !isDefined( self.zbot_actions_in_queue[ group_name ] ) ) + { + self.zbot_actions_in_queue[ group_name ] = []; + } + self.zbot_actions_in_queue[ group_name ][ action_name ] = spawnStruct(); + self.zbot_actions_in_queue[ group_name ][ action_name ].postponed = false; + self.zbot_actions_in_queue[ group_name ][ action_name ].canceled = false; + self.zbot_actions_in_queue[ group_name ][ action_name ].queued = false; + self.zbot_actions_in_queue[ group_name ][ action_name ].completed = false; + self.zbot_actions_in_queue[ group_name ][ action_name ].is_current = false; +} + +process_next_queued_action( group_name ) +{ + if ( self.action_queue.size <= 0 ) + { + return; + } + self [[ self.action_queue[ group_name ][ 0 ].action ]](); + + self wait_for_action_completion( self.action_queue[ group_name ][ 0 ].action_name ); +} + +wait_for_action_completion( group_name, action_name ) +{ + result = self waittill_any_return( action_name + "_completion", action_name + "_cancel", action_name + "_postpone", "disconnect" ); + if ( !isDefined( result ) ) + { + return; + } + if ( result == "disconnect" ) + { + return; + } + if ( ( result == action_name + "_completion" ) ) + { + self.zbot_actions_in_queue[ group_name ][ self.action_queue[ group_name ][ 0 ].action_name ].postponed = false; + self.zbot_actions_in_queue[ group_name ][ self.action_queue[ group_name ][ 0 ].action_name ].queued = false; + arrayRemoveIndex( self.action_queue[ group_name ], 0 ); + self thread [[ self.action_queue[ group_name ][ 0 ].on_completion_func ]](); + } + else if ( result == action_name + "_cancel" ) + { + self.zbot_actions_in_queue[ group_name ][ self.action_queue[ group_name ][ 0 ].action_name ].postponed = false; + self.zbot_actions_in_queue[ group_name ][ self.action_queue[ group_name ][ 0 ].action_name ].queued = false; + arrayRemoveIndex( self.action_queue[ group_name ], 0 ); + self thread [[ self.action_queue[ group_name ][ 0 ].on_cancel_func ]](); + } + else if ( result == action_name + "_postpone" ) + { + self.zbot_actions_in_queue[ group_name ][ self.action_queue[ group_name ][ 0 ].action_name ].postponed = true; + postponed_action = self.action_queue[ group_name ][ 0 ]; + arrayRemoveIndex( self.action_queue[ group_name ], 0 ); + postponed_action.priority = 0; + self.action_queue[ group_name ][ self.action_queue[ group_name ].size ] = postponed_action; + self thread [[ self.action_queue[ group_name ][ 0 ].on_postpone_func ]](); + } +} + +copy_default_action_settings_to_queue( group_name, action_name ) +{ + //self.group = level.zbots_actions[ group_name ][ action_name ].group; + self.action = level.zbots_actions[ group_name ][ action_name ].action; + //self.should_do_func = level.zbots_actions[ group_name ][ action_name ].should_do_func; + self.on_completion_func = level.zbots_actions[ group_name ][ action_name ].on_completion_func; + self.should_cancel_func = level.zbots_actions[ group_name ][ action_name ].should_cancel_func; + self.on_cancel_func = level.zbots_actions[ group_name ][ action_name ].on_cancel_func; + self.should_postpone_func = level.zbots_actions[ group_name ][ action_name ].should_postpone_func; + self.on_postpone_func = level.zbots_actions[ group_name ][ action_name ].on_postpone_func; + self.priority_func = level.zbots_actions[ group_name ][ action_name ].priority_func; +} + +pick_actions_to_add_to_queue( group_name, action_keys ) +{ + for ( i = 0; i < action_keys.size; i++ ) + { + if ( !self.zbot_actions_in_queue[ group_name ][ action_keys[ i ] ].queued && [[ level.zbots_actions[ group_name ][ action_keys[ i ] ].should_do_func ]]() ) + { + self.action_queue[ group_name ][ self.action_queue[ group_name ].size ] = spawnStruct(); + self.action_queue[ group_name ][ self.action_queue[ group_name ].size - 1 ].action_name = action_keys[ i ]; + self.action_queue[ group_name ][ self.action_queue[ group_name ].size - 1 ].priority = self [[ level.zbots_actions[ group_name ][ action_keys[ i ] ].priority_func ]](); + self.zbot_actions_in_queue[ group_name ][ action_keys[ i ] ].queued = true; + } + } +} + +check_if_actions_should_be_canceled_in_group( group_name, action_keys ) +{ + for ( i = 0; i < action_keys.size; i++ ) + { + if ( self.zbot_actions_in_queue[ group_name ][ action_keys[ i ] ].queued && [[ level.zbots_actions[ group_name ][ action_keys[ i ] ].should_cancel_func ]]() ) + { + self notify( action_keys[ i ] + "_cancel" ); + } + } +} + +check_if_actions_should_be_postponed_in_group( group_name, action_keys ) +{ + for ( i = 0; i < action_keys.size; i++ ) + { + if ( self.zbot_actions_in_queue[ group_name ][ action_keys[ i ] ].queued && [[ level.zbots_actions[ group_name ][ action_keys[ i ] ].should_postpone_func ]]() ) + { + self notify( action_keys[ i ] + "_postpone" ); + } } - self.actions_in_queue[ action_name ] = spawnStruct(); - self.actions_in_queue[ action_name ].postponed = false; - self.actions_in_queue[ action_name ].canceled = false; - self.actions_in_queue[ action_name ].queued = false; - self.actions_in_queue[ action_name ].completed = false; } \ No newline at end of file