parent
9fdaea5893
commit
477a871c21
10 changed files with 306 additions and 263 deletions
|
@ -51,4 +51,5 @@
|
|||
{./goal.cfg}
|
||||
{./stage.cfg}
|
||||
{./modify.cfg}
|
||||
{./micro.cfg}
|
||||
[/tag]
|
||||
|
|
267
data/schema/ai/micro.cfg
Normal file
267
data/schema/ai/micro.cfg
Normal file
|
@ -0,0 +1,267 @@
|
|||
|
||||
[tag]
|
||||
name="micro_ai"
|
||||
max=infinite
|
||||
{REQUIRED_KEY ai_type string}
|
||||
{SIMPLE_KEY ca_id string}
|
||||
[switch]
|
||||
key=ai_type
|
||||
[case]
|
||||
value=wolves
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_second" unit min=1}
|
||||
{DEFAULT_KEY attack_only_prey s_bool no}
|
||||
{SIMPLE_KEY avoid_type string_list}
|
||||
{DEFAULT_KEY ca_score s_unsigned 90000}
|
||||
[/case]
|
||||
[case]
|
||||
value=wolves_multipacks
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY pack_size s_unsigned 3}
|
||||
{DEFAULT_KEY show_pack_number s_bool no}
|
||||
{DEFAULT_KEY type string Wolf}
|
||||
[/case]
|
||||
[case]
|
||||
value=big_animals
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
{FILTER_TAG "filter_location_wander" location ()}
|
||||
{FILTER_TAG "avoid_unit" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=forest_animals
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{SIMPLE_KEY rabbit_type string}
|
||||
{SIMPLE_KEY tusker_type string}
|
||||
{SIMPLE_KEY tusklet_type string}
|
||||
{SIMPLE_KEY deer_type string}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
{DEFAULT_KEY rabbit_number s_unsigned 6}
|
||||
{DEFAULT_KEY rabbit_enemy_distance s_unsigned 3}
|
||||
{SIMPLE_KEY rabbit_hole_img string}
|
||||
[/case]
|
||||
[case]
|
||||
value=herding
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_second" unit min=1}
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{REQUIRED_KEYS_LOC_OR_XY herd string s_unsigned}
|
||||
{DEFAULT_KEY attention_distance s_unsigned 8}
|
||||
{DEFAULT_KEY attack_distance s_unsigned 4}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
[/case]
|
||||
[case]
|
||||
value=hunter
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY home string s_unsigned}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
{DEFAULT_KEY rest_turns s_unsigned 3}
|
||||
{DEFAULT_KEY show_messages s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=swarm
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY enemy_distance s_unsigned 5}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{DEFAULT_KEY scatter_distance s_unsigned 3}
|
||||
{DEFAULT_KEY vision_distance s_unsigned 12}
|
||||
[/case]
|
||||
[case]
|
||||
value=assassin
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_second" unit min=1}
|
||||
{FILTER_TAG "prefer" location ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=bottleneck_defense
|
||||
[if]
|
||||
[not]
|
||||
glob_on_location_id=*
|
||||
[/not]
|
||||
[then]
|
||||
{REQUIRED_KEY x s_range_list}
|
||||
{REQUIRED_KEY y s_range_list}
|
||||
[/then]
|
||||
[else]
|
||||
{REQUIRED_KEY location_id string_list}
|
||||
[/else]
|
||||
[/if]
|
||||
{REQUIRED_KEYS_LOC_OR_XY enemy string_list s_range_list}
|
||||
{DEFAULT_KEY active_side_leader s_bool no}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{SIMPLE_KEY healer_x s_range_list}
|
||||
{SIMPLE_KEY healer_y s_range_list}
|
||||
{SIMPLE_KEY healer_loc string_list}
|
||||
{SIMPLE_KEY leadership_x s_range_list}
|
||||
{SIMPLE_KEY leadership_y s_range_list}
|
||||
{SIMPLE_KEY leadership_loc string_list}
|
||||
[/case]
|
||||
[case]
|
||||
value=fast_ai
|
||||
{DEFAULT_KEY attack_hidden_enemies s_bool no}
|
||||
{DEFAULT_KEY dungeon_mode s_bool no}
|
||||
{DEFAULT_KEY include_occupied_attack_hexes s_bool no}
|
||||
{DEFAULT_KEY leader_weight s_unsigned 2}
|
||||
{DEFAULT_KEY leader_additional_threat s_unsigned 1}
|
||||
{DEFAULT_KEY leader_attack_max_units s_unsigned 3}
|
||||
{DEFAULT_KEY move_cost_factor s_real 2}
|
||||
{DEFAULT_KEY weak_units_first s_bool no}
|
||||
{DEFAULT_KEY skip_combat_ca s_bool no}
|
||||
{DEFAULT_KEY skip_move_ca s_bool no}
|
||||
{DEFAULT_KEY threatened_leader_fights s_bool no}
|
||||
{FILTER_TAG "avoid" location ()}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_secont" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=goto
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{DEFAULT_KEY avoid_enemies s_unsigned 0}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY ignore_enemy_at_goal s_bool no}
|
||||
{DEFAULT_KEY ignore_units s_bool no}
|
||||
{DEFAULT_KEY release_unit_at_goal s_bool no}
|
||||
{DEFAULT_KEY release_all_units_at_goal s_bool no}
|
||||
{DEFAULT_KEY unique_goals s_bool no}
|
||||
{DEFAULT_KEY use_straight_line s_bool no}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=return_guardian
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{SIMPLE_KEY return_x s_unsigned}
|
||||
{SIMPLE_KEY return_y s_unsigned}
|
||||
{SIMPLE_KEY return_loc string}
|
||||
{DEFAULT_KEY ca_score s_unsigned 100100}
|
||||
[/case]
|
||||
[case]
|
||||
value=stationed_guardian
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEY distance s_unsigned}
|
||||
{REQUIRED_KEYS_LOC_OR_XY station string s_unsigned}
|
||||
{REQUIRED_KEYS_LOC_OR_XY guard string s_unsigned}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
[/case]
|
||||
[case]
|
||||
value=coward
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEY distance s_unsigned}
|
||||
{DEFAULT_KEY attack_if_trapped s_bool no}
|
||||
{SIMPLE_KEY avoid_x s_unsigned}
|
||||
{SIMPLE_KEY avoid_y s_unsigned}
|
||||
{SIMPLE_KEY avoid_loc string}
|
||||
{SIMPLE_KEY seek_x s_unsigned}
|
||||
{SIMPLE_KEY seek_y s_unsigned}
|
||||
{SIMPLE_KEY seek_loc string}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=zone_guardian
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{SIMPLE_KEY station_x s_unsigned}
|
||||
{SIMPLE_KEY station_y s_unsigned}
|
||||
{SIMPLE_KEY station_loc string}
|
||||
{FILTER_TAG "filter_location_enemy" location ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=hang_out
|
||||
{DEFAULT_KEY ca_score s_unsigned 170000}
|
||||
{SIMPLE_KEY mobilize_on_gold_less_than s_unsigned}
|
||||
{FILTER_TAG "avoid" location ()}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
[tag]
|
||||
name="mobilize_condition"
|
||||
super="$conditional_wml"
|
||||
[/tag]
|
||||
[/case]
|
||||
[case]
|
||||
value=healer_support
|
||||
{DEFAULT_KEY aggression s_real 1.0}
|
||||
{DEFAULT_KEY injured_units_only s_bool no}
|
||||
{DEFAULT_KEY max_threats s_unsigned 9999}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=lurkers
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{FILTER_TAG "filter_location_wander" location ()}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY stationary s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=messenger_escort
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY waypoint string_list s_range_list}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY enemy_death_chance s_real 0.67}
|
||||
{DEFAULT_KEY messenger_death_chance s_bool 0.0}
|
||||
{DEFAULT_KEY invert_order s_bool no}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=patrol
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY waypoint string_list s_range_list}
|
||||
{SIMPLE_KEY attack string_list}
|
||||
{DEFAULT_KEY attack_range s_int 1}
|
||||
{DEFAULT_KEY attack_invisible_enemies s_bool no}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY one_time_only s_bool no}
|
||||
{DEFAULT_KEY out_and_back s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=protect_unit
|
||||
[tag]
|
||||
name="unit"
|
||||
min=1
|
||||
max=infinite
|
||||
{REQUIRED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY goal string s_unsigned}
|
||||
[/tag]
|
||||
{DEFAULT_KEY disable_move_leader_to_keep s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=recruit_random
|
||||
{DEFAULT_KEY ca_score s_unsigned 180000}
|
||||
{DEFAULT_KEY skip_low_gold_recruiting s_bool no}
|
||||
[tag]
|
||||
name="probability"
|
||||
max=infinite
|
||||
{REQUIRED_KEY type string_list}
|
||||
{REQUIRED_KEY probability s_real}
|
||||
[/tag]
|
||||
[/case]
|
||||
[case]
|
||||
value=recruit_rushers
|
||||
{DEFAULT_KEY ca_score s_unsigned 180000}
|
||||
{DEFAULT_KEY randomness s_real 0.1}
|
||||
[/case]
|
||||
[case]
|
||||
value=simple_attack
|
||||
{DEFAULT_KEY ca_score s_unsigned 110000}
|
||||
{DEFAULT_KEY weapon s_int -1}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[else]
|
||||
# For unknown ai_type, accept anything
|
||||
any_tag=yes
|
||||
{ANY_KEY any}
|
||||
[/else]
|
||||
[/switch]
|
||||
[/tag]
|
|
@ -1242,7 +1242,6 @@
|
|||
{ACTION_TAG "command" min=1}
|
||||
[/tag]
|
||||
{EMPTY_TAG "break,continue,return" 0 infinite}
|
||||
# The MicroAI tag is in a league of its own...
|
||||
[tag]
|
||||
name="micro_ai"
|
||||
max=infinite
|
||||
|
@ -1256,266 +1255,7 @@
|
|||
action=delete
|
||||
[/not]
|
||||
[then]
|
||||
[switch]
|
||||
key=ai_type
|
||||
[case]
|
||||
value=wolves
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_second" unit min=1}
|
||||
{DEFAULT_KEY attack_only_prey s_bool no}
|
||||
{SIMPLE_KEY avoid_type string_list}
|
||||
{DEFAULT_KEY ca_score s_unsigned 90000}
|
||||
[/case]
|
||||
[case]
|
||||
value=wolves_multipacks
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY pack_size s_unsigned 3}
|
||||
{DEFAULT_KEY show_pack_number s_bool no}
|
||||
{DEFAULT_KEY type string Wolf}
|
||||
[/case]
|
||||
[case]
|
||||
value=big_animals
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
{FILTER_TAG "filter_location_wander" location ()}
|
||||
{FILTER_TAG "avoid_unit" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=forest_animals
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{SIMPLE_KEY rabbit_type string}
|
||||
{SIMPLE_KEY tusker_type string}
|
||||
{SIMPLE_KEY tusklet_type string}
|
||||
{SIMPLE_KEY deer_type string}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
{DEFAULT_KEY rabbit_number s_unsigned 6}
|
||||
{DEFAULT_KEY rabbit_enemy_distance s_unsigned 3}
|
||||
{SIMPLE_KEY rabbit_hole_img string}
|
||||
[/case]
|
||||
[case]
|
||||
value=herding
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_second" unit min=1}
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{REQUIRED_KEYS_LOC_OR_XY herd string s_unsigned}
|
||||
{DEFAULT_KEY attention_distance s_unsigned 8}
|
||||
{DEFAULT_KEY attack_distance s_unsigned 4}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
[/case]
|
||||
[case]
|
||||
value=hunter
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY home string s_unsigned}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
{DEFAULT_KEY rest_turns s_unsigned 3}
|
||||
{DEFAULT_KEY show_messages s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=swarm
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY enemy_distance s_unsigned 5}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{DEFAULT_KEY scatter_distance s_unsigned 3}
|
||||
{DEFAULT_KEY vision_distance s_unsigned 12}
|
||||
[/case]
|
||||
[case]
|
||||
value=assassin
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_second" unit min=1}
|
||||
{FILTER_TAG "prefer" location ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=bottleneck_defense
|
||||
[if]
|
||||
[not]
|
||||
glob_on_location_id=*
|
||||
[/not]
|
||||
[then]
|
||||
{REQUIRED_KEY x s_range_list}
|
||||
{REQUIRED_KEY y s_range_list}
|
||||
[/then]
|
||||
[else]
|
||||
{REQUIRED_KEY location_id string_list}
|
||||
[/else]
|
||||
[/if]
|
||||
{REQUIRED_KEYS_LOC_OR_XY enemy string_list s_range_list}
|
||||
{DEFAULT_KEY active_side_leader s_bool no}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{SIMPLE_KEY healer_x s_range_list}
|
||||
{SIMPLE_KEY healer_y s_range_list}
|
||||
{SIMPLE_KEY healer_loc string_list}
|
||||
{SIMPLE_KEY leadership_x s_range_list}
|
||||
{SIMPLE_KEY leadership_y s_range_list}
|
||||
{SIMPLE_KEY leadership_loc string_list}
|
||||
[/case]
|
||||
[case]
|
||||
value=fast_ai
|
||||
{DEFAULT_KEY attack_hidden_enemies s_bool no}
|
||||
{DEFAULT_KEY dungeon_mode s_bool no}
|
||||
{DEFAULT_KEY include_occupied_attack_hexes s_bool no}
|
||||
{DEFAULT_KEY leader_weight s_unsigned 2}
|
||||
{DEFAULT_KEY leader_additional_threat s_unsigned 1}
|
||||
{DEFAULT_KEY leader_attack_max_units s_unsigned 3}
|
||||
{DEFAULT_KEY move_cost_factor s_real 2}
|
||||
{DEFAULT_KEY weak_units_first s_bool no}
|
||||
{DEFAULT_KEY skip_combat_ca s_bool no}
|
||||
{DEFAULT_KEY skip_move_ca s_bool no}
|
||||
{DEFAULT_KEY threatened_leader_fights s_bool no}
|
||||
{FILTER_TAG "avoid" location ()}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_secont" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=goto
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{DEFAULT_KEY avoid_enemies s_unsigned 0}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY ignore_enemy_at_goal s_bool no}
|
||||
{DEFAULT_KEY ignore_units s_bool no}
|
||||
{DEFAULT_KEY release_unit_at_goal s_bool no}
|
||||
{DEFAULT_KEY release_all_units_at_goal s_bool no}
|
||||
{DEFAULT_KEY unique_goals s_bool no}
|
||||
{DEFAULT_KEY use_straight_line s_bool no}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=return_guardian
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{SIMPLE_KEY return_x s_unsigned}
|
||||
{SIMPLE_KEY return_y s_unsigned}
|
||||
{SIMPLE_KEY return_loc string}
|
||||
{DEFAULT_KEY ca_score s_unsigned 100100}
|
||||
[/case]
|
||||
[case]
|
||||
value=stationed_guardian
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEY distance s_unsigned}
|
||||
{REQUIRED_KEYS_LOC_OR_XY station string s_unsigned}
|
||||
{REQUIRED_KEYS_LOC_OR_XY guard string s_unsigned}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
[/case]
|
||||
[case]
|
||||
value=coward
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEY distance s_unsigned}
|
||||
{DEFAULT_KEY attack_if_trapped s_bool no}
|
||||
{SIMPLE_KEY avoid_x s_unsigned}
|
||||
{SIMPLE_KEY avoid_y s_unsigned}
|
||||
{SIMPLE_KEY avoid_loc string}
|
||||
{SIMPLE_KEY seek_x s_unsigned}
|
||||
{SIMPLE_KEY seek_y s_unsigned}
|
||||
{SIMPLE_KEY seek_loc string}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=zone_guardian
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{SIMPLE_KEY station_x s_unsigned}
|
||||
{SIMPLE_KEY station_y s_unsigned}
|
||||
{SIMPLE_KEY station_loc string}
|
||||
{FILTER_TAG "filter_location_enemy" location ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=hang_out
|
||||
{DEFAULT_KEY ca_score s_unsigned 170000}
|
||||
{SIMPLE_KEY mobilize_on_gold_less_than s_unsigned}
|
||||
{FILTER_TAG "avoid" location ()}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_location" location ()}
|
||||
[tag]
|
||||
name="mobilize_condition"
|
||||
super="$conditional_wml"
|
||||
[/tag]
|
||||
[/case]
|
||||
[case]
|
||||
value=healer_support
|
||||
{DEFAULT_KEY aggression s_real 1.0}
|
||||
{DEFAULT_KEY injured_units_only s_bool no}
|
||||
{DEFAULT_KEY max_threats s_unsigned 9999}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=lurkers
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{FILTER_TAG "filter_location" location min=1}
|
||||
{FILTER_TAG "filter_location_wander" location ()}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY stationary s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=messenger_escort
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY waypoint string_list s_range_list}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY enemy_death_chance s_real 0.67}
|
||||
{DEFAULT_KEY messenger_death_chance s_bool 0.0}
|
||||
{DEFAULT_KEY invert_order s_bool no}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[case]
|
||||
value=patrol
|
||||
{FILTER_TAG "filter" unit min=1}
|
||||
{DEPRECATED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY waypoint string_list s_range_list}
|
||||
{SIMPLE_KEY attack string_list}
|
||||
{DEFAULT_KEY attack_range s_int 1}
|
||||
{DEFAULT_KEY attack_invisible_enemies s_bool no}
|
||||
{DEFAULT_KEY ca_score s_unsigned 300000}
|
||||
{DEFAULT_KEY one_time_only s_bool no}
|
||||
{DEFAULT_KEY out_and_back s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=protect_unit
|
||||
[tag]
|
||||
name="unit"
|
||||
min=1
|
||||
max=infinite
|
||||
{REQUIRED_KEY id string}
|
||||
{REQUIRED_KEYS_LOC_OR_XY goal string s_unsigned}
|
||||
[/tag]
|
||||
{DEFAULT_KEY disable_move_leader_to_keep s_bool no}
|
||||
[/case]
|
||||
[case]
|
||||
value=recruit_random
|
||||
{DEFAULT_KEY ca_score s_unsigned 180000}
|
||||
{DEFAULT_KEY skip_low_gold_recruiting s_bool no}
|
||||
[tag]
|
||||
name="probability"
|
||||
max=infinite
|
||||
{REQUIRED_KEY type string_list}
|
||||
{REQUIRED_KEY probability s_real}
|
||||
[/tag]
|
||||
[/case]
|
||||
[case]
|
||||
value=recruit_rushers
|
||||
{DEFAULT_KEY ca_score s_unsigned 180000}
|
||||
{DEFAULT_KEY randomness s_real 0.1}
|
||||
[/case]
|
||||
[case]
|
||||
value=simple_attack
|
||||
{DEFAULT_KEY ca_score s_unsigned 110000}
|
||||
{DEFAULT_KEY weapon s_int -1}
|
||||
{FILTER_TAG "filter" unit ()}
|
||||
{FILTER_TAG "filter_second" unit ()}
|
||||
[/case]
|
||||
[else]
|
||||
# For unknown ai_type, accept anything
|
||||
any_tag=yes
|
||||
{ANY_KEY any}
|
||||
[/else]
|
||||
[/switch]
|
||||
super="$ai/micro_ai"
|
||||
[/then]
|
||||
[/if]
|
||||
[/tag]
|
||||
|
|
|
@ -275,7 +275,7 @@ bool configuration::parse_side_config(side_number side, const config& original_c
|
|||
}
|
||||
|
||||
static const std::set<std::string> non_aspect_attributes {"turns", "time_of_day", "engine", "ai_algorithm", "id", "description", "hidden", "mp_rank"};
|
||||
static const std::set<std::string> just_copy_tags {"engine", "stage", "aspect", "goal", "modify_ai"};
|
||||
static const std::set<std::string> just_copy_tags {"engine", "stage", "aspect", "goal", "modify_ai", "micro_ai"};
|
||||
static const std::set<std::string> old_goal_tags {"target", "target_location", "protect_unit", "protect_location"};
|
||||
|
||||
void configuration::expand_simplified_aspects(side_number side, config &cfg) {
|
||||
|
|
|
@ -952,6 +952,13 @@ static size_t generate_and_push_ai_state(lua_State* L, ai::engine_lua* engine)
|
|||
return length_ai + 1;
|
||||
}
|
||||
|
||||
void lua_ai_context::apply_micro_ai(const config &cfg)
|
||||
{
|
||||
luaW_getglobal(L, "wesnoth", "wml_actions", "micro_ai");
|
||||
luaW_pushconfig(L, cfg);
|
||||
luaW_pcall(L, 1, 0);
|
||||
}
|
||||
|
||||
lua_ai_context* lua_ai_context::create(lua_State *L, char const *code, ai::engine_lua *engine)
|
||||
{
|
||||
int res_ai = luaL_loadbufferx(L, code, strlen(code), /*name*/ code, "t"); // [-1: AI code]
|
||||
|
|
|
@ -48,6 +48,7 @@ public:
|
|||
void get_arguments(config &) const;
|
||||
void set_arguments(const config &);
|
||||
void push_ai_table();
|
||||
void apply_micro_ai(const config& cfg);
|
||||
static void init(lua_State *L);
|
||||
friend class ::game_lua_kernel;
|
||||
friend class lua_ai_load;
|
||||
|
|
|
@ -385,6 +385,11 @@ std::string engine_lua::evaluate(const std::string &/*str*/)
|
|||
return "";
|
||||
}
|
||||
|
||||
void engine_lua::apply_micro_ai(const config &cfg)
|
||||
{
|
||||
lua_ai_context_->apply_micro_ai(cfg);
|
||||
}
|
||||
|
||||
config engine_lua::to_config() const
|
||||
{
|
||||
config cfg = engine::to_config();
|
||||
|
|
|
@ -57,6 +57,8 @@ public:
|
|||
|
||||
virtual std::string evaluate(const std::string &str);
|
||||
|
||||
void apply_micro_ai(const config& cfg);
|
||||
|
||||
/**
|
||||
* Method that pushes the AI table of the lua_context on the stack
|
||||
* for debugging purposes
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
#include "game_config.hpp" // for debug
|
||||
#include "ai/lua/aspect_advancements.hpp"
|
||||
#include "ai/registry.hpp" // for init
|
||||
#include "ai/lua/engine_lua.hpp"
|
||||
|
||||
#include <algorithm> // for min
|
||||
#include <cassert> // for assert
|
||||
|
@ -107,7 +108,12 @@ void holder::init( side_number side )
|
|||
}
|
||||
modify_ai(mod_ai);
|
||||
}
|
||||
cfg_.clear_children("modify_ai");
|
||||
for(config& micro : cfg_.child_range("micro_ai")) {
|
||||
micro["side"] = side;
|
||||
micro["action"] = "add";
|
||||
micro_ai(micro);
|
||||
}
|
||||
cfg_.clear_children("modify_ai", "micro_ai");
|
||||
|
||||
std::vector<engine_ptr> engines = ai_->get_engines();
|
||||
for (std::vector<engine_ptr>::iterator it = engines.begin(); it != engines.end(); ++it)
|
||||
|
@ -140,6 +146,19 @@ ai_composite& holder::get_ai_ref()
|
|||
return *this->ai_;
|
||||
}
|
||||
|
||||
void holder::micro_ai(const config& cfg)
|
||||
{
|
||||
if (!this->ai_) {
|
||||
this->init(this->side_);
|
||||
}
|
||||
assert(this->ai_);
|
||||
|
||||
auto engine = this->ai_->get_engine_by_cfg(config{"engine", "lua"});
|
||||
if(auto lua = std::dynamic_pointer_cast<engine_lua>(engine)) {
|
||||
lua->apply_micro_ai(cfg);
|
||||
}
|
||||
}
|
||||
|
||||
void holder::modify_ai(const config &cfg)
|
||||
{
|
||||
if (!this->ai_) {
|
||||
|
|
|
@ -63,6 +63,7 @@ public:
|
|||
config to_config() const;
|
||||
|
||||
void modify_ai(const config& cfg);
|
||||
void micro_ai(const config& cfg);
|
||||
|
||||
void append_ai(const config& cfg);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue