home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 July / maximum-cd-2010-07.iso / DiscContents / wesnoth-1.8-win32.exe / data / core / macros / ai_controller.cfg < prev    next >
Encoding:
Text File  |  2010-03-08  |  44.2 KB  |  1,069 lines

  1. #textdomain wesnoth
  2.  
  3. #define AI_CONTROLLER AFFIX PLAYER_SIDES ALLY_SIDES VARIABLES_WML
  4.     # expects $order_type to be set
  5.     [event]
  6.         name=apply_ai_params
  7.         first_time_only=no
  8.  
  9.         [set_variables]
  10.             name=new_ai_params
  11.  
  12.             [insert_tag]
  13.                 name=literal
  14.                 variable=ai_controller_{AFFIX}.$order_type|.ai
  15.             [/insert_tag]
  16.         [/set_variables]
  17.  
  18.         [if]
  19.             [variable]
  20.                 name=ai_controller_{AFFIX}.$order_type|.type
  21.                 equals=behaviour
  22.             [/variable]
  23.  
  24.             [variable]
  25.                 name=ai_controller.side_$ally_side|_current_settings.current_objective
  26.                 boolean_equals=yes
  27.             [/variable]
  28.  
  29.             [then]
  30.                 [set_variables]
  31.                     name=new_ai_params
  32.                     mode=append
  33.  
  34.                     [insert_tag]
  35.                         name=literal
  36.                         variable=ai_controller_{AFFIX}.$ai_controller.side_$ally_side|_current_settings.current_objective|.ai
  37.                     [/insert_tag]
  38.                 [/set_variables]
  39.             [/then]
  40.         [/if]
  41.  
  42.         [if]
  43.             [variable]
  44.                 name=ai_controller_{AFFIX}.$order_type|.type
  45.                 equals=objective
  46.             [/variable]
  47.  
  48.             [variable]
  49.                 name=ai_controller.side_$ally_side|_current_settings.current_behaviour
  50.                 boolean_equals=yes
  51.             [/variable]
  52.  
  53.             [then]
  54.                 [set_variables]
  55.                     name=new_ai_params
  56.                     mode=append
  57.  
  58.                     [insert_tag]
  59.                         name=literal
  60.                         variable=ai_controller_{AFFIX}.$ai_controller.side_$ally_side|_current_settings.current_behaviour|.ai
  61.                     [/insert_tag]
  62.                 [/set_variables]
  63.             [/then]
  64.         [/if]
  65.  
  66.         [if]
  67.             [and]
  68.                 [variable]
  69.                     name=ai_controller_{AFFIX}.$ai_controller.side_$ally_side|_current_settings.current_behaviour|.mode
  70.                     equals=append
  71.                 [/variable]
  72.  
  73.                 [or]
  74.                     [variable]
  75.                         name=ai_controller_{AFFIX}.$ai_controller.side_$ally_side|_current_settings.current_behaviour|.mode
  76.                         equals=$empty
  77.                     [/variable]
  78.                 [/or]
  79.             [/and]
  80.  
  81.             [and]
  82.                 [variable]
  83.                     name=ai_controller_{AFFIX}.$ai_controller.side_$ally_side|_current_settings.current_objective|.mode
  84.                     equals=append
  85.                 [/variable]
  86.  
  87.                 [or]
  88.                     [variable]
  89.                         name=ai_controller_{AFFIX}.$ai_controller.side_$ally_side|_current_settings.current_objective|.mode
  90.                         equals=$empty
  91.                     [/variable]
  92.                 [/or]
  93.             [/and]
  94.  
  95.             [then]
  96.                 [set_variables]
  97.                     name=new_ai_params
  98.                     mode=append
  99.  
  100.                     [insert_tag]
  101.                         name=literal
  102.                         variable=ai_controller.side_$ally_side|_original_settings.ai_settings.ai
  103.                     [/insert_tag]
  104.                 [/set_variables]
  105.             [/then]
  106.         [/if]
  107.  
  108.         [modify_side]
  109.             side=$ally_side
  110.  
  111.             [insert_tag]
  112.                 name=ai
  113.                 variable=new_ai_params
  114.             [/insert_tag]
  115.         [/modify_side]
  116.  
  117.         {CLEAR_VARIABLE new_ai_params}
  118.     [/event]
  119.  
  120.     [event]
  121.         name=prestart
  122.  
  123.         [set_variables]
  124.             name=ai_controller_{AFFIX}
  125.  
  126.             # This block contains all the default settings and options.
  127.             [literal]
  128.                 enabled=yes
  129.                 player_side={PLAYER_SIDES}
  130.                 ally_sides={ALLY_SIDES}
  131.                 disabled_for_sides=0
  132.  
  133.                 ################
  134.  
  135.                 [aggression]
  136.                     type=behaviour
  137.  
  138.                     [ai]
  139.                         aggression=0.9
  140.                         caution=0.1
  141.                     [/ai]
  142.  
  143.                     [option]
  144.                         message= _ "Be more aggressive"
  145.  
  146.                         [show_if]
  147.                             [variable]
  148.                                 name=ai_controller_{AFFIX}.aggression.disabled
  149.                                 not_equals=yes
  150.                             [/variable]
  151.                         [/show_if]
  152.  
  153.                         [command]
  154.                             {VARIABLE order_type aggression}
  155.  
  156.                             {MODIFY_AI_ADD_SIMPLE_ASPECT $ally_side aggression set_by_ai_controller "0.9"}
  157.                             {MODIFY_AI_ADD_SIMPLE_ASPECT $ally_side caution set_by_ai_controller "0.1"}
  158.  
  159.                             {VARIABLE ai_controller.side_$ally_side|_current_settings.current_behaviour aggression}
  160.                             {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_behaviour_description _"aggressive."}
  161.                         [/command]
  162.                     [/option]
  163.                 [/aggression]
  164.  
  165.                 ################
  166.  
  167.                 [caution]
  168.                     type=behaviour
  169.  
  170.                     [ai]
  171.                         aggression=0.1
  172.                         caution=1.0
  173.                         grouping=defensive
  174.                     [/ai]
  175.  
  176.                     [option]
  177.                         message= _ "Be more defensive"
  178.  
  179.                         [show_if]
  180.                             [variable]
  181.                                 name=ai_controller_{AFFIX}.caution.disabled
  182.                                 not_equals=yes
  183.                             [/variable]
  184.                         [/show_if]
  185.  
  186.                         [command]
  187.                             {VARIABLE order_type caution}
  188.  
  189.                             {VARIABLE ai_controller.side_$ally_side|_current_settings.current_behaviour caution}
  190.                             {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_behaviour_description _"defensive."}
  191.  
  192.                             {MODIFY_AI_ADD_SIMPLE_ASPECT $ally_side aggression set_by_ai_controller "0.1"}
  193.                             {MODIFY_AI_ADD_SIMPLE_ASPECT $ally_side caution set_by_ai_controller "1.0"}
  194.                         [/command]
  195.                     [/option]
  196.                 [/caution]
  197.  
  198.                 ################
  199.  
  200.                 [focus_on_enemy]
  201.                     type=objective
  202.  
  203.                     [ai]
  204.                         [target]
  205.                             side=$temp_i
  206.                             value=20
  207.                         [/target]
  208.                     [/ai]
  209.  
  210.                     [option]
  211.                         message= _ "Focus on defeating..."
  212.  
  213.                         [show_if]
  214.                             [variable]
  215.                                 name=ai_controller_{AFFIX}.focus_on_enemy.disabled
  216.                                 not_equals=yes
  217.                             [/variable]
  218.                         [/show_if]
  219.  
  220.                         [command]
  221.                             [set_variables]
  222.                                 name=focus_on_enemy_options_message
  223.  
  224.                                 [literal]
  225.                                     caption= _"Instruct ally"
  226.                                     speaker=narrator
  227.                                     image=wesnoth-icon.png
  228.                                     message= _"Which enemy side to focus on?"
  229.                                 [/literal]
  230.                             [/set_variables]
  231.  
  232.                             [store_side]
  233.                                 side=$ally_side
  234.                                 variable=stored_ally_side
  235.                             [/store_side]
  236.  
  237.                             {VARIABLE temp_i 1}
  238.  
  239.                             [while]
  240.                                 [variable]
  241.                                     name=temp_i
  242.                                     less_than=10
  243.                                 [/variable]
  244.  
  245.                                 [do]
  246.                                     [store_side]
  247.                                         side=$temp_i
  248.                                         variable=stored_other_side
  249.                                     [/store_side]
  250.  
  251.                                     [if]
  252.                                         [variable]
  253.                                             name=stored_ally_side.team_name
  254.                                             not_equals=$stored_other_side.team_name
  255.                                         [/variable]
  256.  
  257.                                         [have_unit]
  258.                                             side=$temp_i
  259.                                         [/have_unit]
  260.  
  261.                                         [then]
  262.                                             [if]
  263.                                                 [have_unit]
  264.                                                     side=$temp_i
  265.                                                     canrecruit=yes
  266.  
  267.                                                     [filter_vision]
  268.                                                         viewing_side=$side_number
  269.                                                         visible=yes
  270.                                                     [/filter_vision]
  271.                                                 [/have_unit]
  272.  
  273.                                                 [then]
  274.                                                     [store_unit]
  275.                                                         [filter]
  276.                                                             side=$temp_i
  277.                                                             canrecruit=yes
  278.                                                         [/filter]
  279.  
  280.                                                         kill=no
  281.                                                         variable=side_i_leader
  282.                                                     [/store_unit]
  283.  
  284.                                                     {VARIABLE this_enemy_txt_img_description "&$side_i_leader.image~TC($temp_i|,$side_i_leader.flag_rgb|)=$side_i_leader.name|="+_"(side $temp_i|)"}
  285.  
  286.                                                     {VARIABLE this_enemy_description _"$side_i_leader.name (side $temp_i|)"}
  287.                                                 [/then]
  288.  
  289.                                                 [else]
  290.                                                     {VARIABLE this_enemy_txt_img_description "&misc/blank-hex.png= ="+_"(side $temp_i|)"}
  291.                                                     {VARIABLE this_enemy_description _"side $temp_i"}
  292.                                                 [/else]
  293.                                             [/if]
  294.  
  295.                                             [set_variables]
  296.                                                 name=focus_on_enemy_options_message.option
  297.                                                 mode=append
  298.  
  299.                                                 [value]
  300.                                                     message=$this_enemy_txt_img_description
  301.  
  302.                                                     [command]
  303.                                                         {VARIABLE order_type focus_on_enemy}
  304.  
  305.                                                         {VARIABLE ai_controller.side_$ally_side|_current_settings.focus_on_enemy.side $temp_i}
  306.                                                         {VARIABLE ai_controller.side_$ally_side|_current_settings.current_objective focus_on_enemy}
  307.                                                         {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_objective_description _"focusing on defeating $this_enemy_description|."}
  308.  
  309.                                                         {MODIFY_AI_ADD_GOAL $ally_side (
  310.                                                             [goal]
  311.                                                                 id=set_by_ai_controller
  312.                                                                 value=20
  313.                                                                 [criteria]
  314.                                                                     side=$temp_i
  315.                                                                 [/criteria]
  316.                                                             [/goal]
  317.                                                         )}
  318.                                                     [/command]
  319.                                                 [/value]
  320.                                             [/set_variables]
  321.                                         [/then]
  322.                                     [/if]
  323.  
  324.                                     {VARIABLE_OP temp_i add 1}
  325.                                 [/do]
  326.                             [/while]
  327.  
  328.                             [set_variables]
  329.                                 name=focus_on_enemy_options_message.option
  330.                                 mode=append
  331.  
  332.                                 [value]
  333.                                     message="<span size='larger'>"+_"Back" + "</span>"
  334.  
  335.                                     [command]
  336.                                     [/command]
  337.                                 [/value]
  338.                             [/set_variables]
  339.  
  340.                             [insert_tag]
  341.                                 name=message
  342.                                 variable=focus_on_enemy_options_message
  343.                             [/insert_tag]
  344.  
  345.                             {CLEAR_VARIABLE stored_other_side,focus_on_enemy_options_message,side_i_leader,this_enemy_description}
  346.                         [/command]
  347.                     [/option]
  348.                 [/focus_on_enemy]
  349.  
  350.                 ################
  351.  
  352.                 [protect]
  353.                     type=objective
  354.  
  355.                     [ai]
  356.                         [target]
  357.                             side=$temp_i
  358.                             value=20
  359.                         [/target]
  360.                     [/ai]
  361.  
  362.                     [option]
  363.                         message= _ "Focus on protecting..."
  364.  
  365.                         [show_if]
  366.                             [variable]
  367.                                 name=ai_controller_{AFFIX}.protect.disabled
  368.                                 not_equals=yes
  369.                             [/variable]
  370.                         [/show_if]
  371.  
  372.                         [command]
  373.                             [set_variables]
  374.                                 name=protect_options_message
  375.  
  376.                                 [literal]
  377.                                     caption= _"Instruct ally"
  378.                                     speaker=narrator
  379.                                     image=wesnoth-icon.png
  380.                                     message= _"Which friendly side to protect?"
  381.                                 [/literal]
  382.                             [/set_variables]
  383.  
  384.                             [store_side]
  385.                                 side=$ally_side
  386.                                 variable=stored_ally_side
  387.                             [/store_side]
  388.  
  389.                             {VARIABLE temp_i 1}
  390.  
  391.                             [while]
  392.                                 [variable]
  393.                                     name=temp_i
  394.                                     less_than=10
  395.                                 [/variable]
  396.  
  397.                                 [do]
  398.                                     [store_side]
  399.                                         side=$temp_i
  400.                                         variable=stored_other_side
  401.                                     [/store_side]
  402.  
  403.                                     [if]
  404.                                         [variable]
  405.                                             name=ally_side
  406.                                             not_equals=$temp_i
  407.                                         [/variable]
  408.  
  409.                                         [variable]
  410.                                             name=stored_ally_side.team_name
  411.                                             equals=$stored_other_side.team_name
  412.                                         [/variable]
  413.  
  414.                                         [have_unit]
  415.                                             side=$temp_i
  416.                                         [/have_unit]
  417.  
  418.                                         [then]
  419.                                             [if]
  420.                                                 [have_unit]
  421.                                                     side=$temp_i
  422.                                                     canrecruit=yes
  423.                                                 [/have_unit]
  424.  
  425.                                                 [then]
  426.                                                     [store_unit]
  427.                                                         [filter]
  428.                                                             side=$temp_i
  429.                                                             canrecruit=yes
  430.  
  431.                                                             [filter_vision]
  432.                                                                 viewing_side=$side_number
  433.                                                                 visible=yes
  434.                                                             [/filter_vision]
  435.                                                         [/filter]
  436.  
  437.                                                         kill=no
  438.                                                         variable=side_i_leader
  439.                                                     [/store_unit]
  440.  
  441.                                                     {VARIABLE this_ally_txt_img_description "&$side_i_leader.image~TC($temp_i|,$side_i_leader.flag_rgb|)=$side_i_leader.name|="+_"(side $temp_i|)"}
  442.                                                     {VARIABLE this_ally_description _"$side_i_leader.name (side $temp_i|)"}
  443.                                                 [/then]
  444.  
  445.                                                 [else]
  446.                                                     {VARIABLE this_ally_txt_img_description "&misc/blank-hex.png= ="+_"(side $temp_i|)"}
  447.                                                     {VARIABLE this_ally_description _"side $temp_i"}
  448.                                                 [/else]
  449.                                             [/if]
  450.  
  451.                                             [set_variables]
  452.                                                 name=protect_options_message.option
  453.                                                 mode=append
  454.  
  455.                                                 [value]
  456.                                                     message=$this_ally_txt_img_description
  457.  
  458.                                                     [command]
  459.                                                         {VARIABLE order_type protect}
  460.  
  461.                                                         {VARIABLE ai_controller.side_$ally_side|_current_settings.protect.side $temp_i}
  462.                                                         {VARIABLE ai_controller.side_$ally_side|_current_settings.current_objective protect}
  463.                                                         {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_objective_description _"focusing on protecting $this_ally_description|."}
  464.  
  465.                                                         {MODIFY_AI_ADD_GOAL $ally_side (
  466.                                                             [goal]
  467.                                                                 id=set_by_ai_controller
  468.                                                                 name=protect
  469.                                                                 value=20
  470.                                                                 [criteria]
  471.                                                                     [filter]
  472.                                                                         side=$temp_i
  473.                                                                     [/filter]
  474.                                                                 [/criteria]
  475.                                                             [/goal]
  476.                                                         )}
  477.                                                     [/command]
  478.                                                 [/value]
  479.                                             [/set_variables]
  480.                                         [/then]
  481.                                     [/if]
  482.  
  483.                                     {VARIABLE_OP temp_i add 1}
  484.                                 [/do]
  485.                             [/while]
  486.  
  487.                             [set_variables]
  488.                                 name=protect_options_message.option
  489.                                 mode=append
  490.  
  491.                                 [value]
  492.                                     message="<span size='larger'>" + _"Back" + "</span>"
  493.  
  494.                                     [command]
  495.                                     [/command]
  496.                                 [/value]
  497.                             [/set_variables]
  498.  
  499.                             [insert_tag]
  500.                                 name=message
  501.                                 variable=protect_options_message
  502.                             [/insert_tag]
  503.  
  504.                             {CLEAR_VARIABLE stored_other_side,side_i_leader,this_ally_description,protect_options_message}
  505.                         [/command]
  506.                     [/option]
  507.                 [/protect]
  508.  
  509.                 ################
  510.  
  511.                 [defend_location]
  512.                     type=objective
  513.  
  514.                     [ai]
  515.                         [protect_location]
  516.                             x=$ai_controller.side_$ally_side|_current_settings.defend_location.x
  517.                             y=$ai_controller.side_$ally_side|_current_settings.defend_location.y
  518.                             radius=6
  519.                             value=20
  520.                         [/protect_location]
  521.                     [/ai]
  522.  
  523.                     [option]
  524.                         message= _ "Defend a location..."
  525.  
  526.                         [show_if]
  527.                             [variable]
  528.                                 name=ai_controller_{AFFIX}.defend_location.disabled
  529.                                 not_equals=yes
  530.                             [/variable]
  531.                         [/show_if]
  532.  
  533.                         [command]
  534.                             {VARIABLE ai_controller_{AFFIX}.defend_location.picker_active yes}
  535.                             {VARIABLE ai_controller_{AFFIX}.defend_location.original_controller_invokation_x $x1}
  536.                             {VARIABLE ai_controller_{AFFIX}.defend_location.original_controller_invokation_y $y1}
  537.                             {VARIABLE ai_controller_finished yes}
  538.  
  539.                             [print]
  540.                                 text= _ "Right-click to select a location to defend"
  541.                                 duration=100
  542.                                 {COLOR_WHITE}
  543.                             [/print]
  544.  
  545.                             [set_menu_item]
  546.                                 id=ai_controller_defend_location_picker
  547.                                 description= _ "Defend this location"
  548.  
  549.                                 [show_if]
  550.                                     [variable]
  551.                                         name=ai_controller_{AFFIX}.defend_location.picker_active
  552.                                         boolean_equals=yes
  553.                                     [/variable]
  554.                                 [/show_if]
  555.  
  556.                                 [command]
  557.                                     {VARIABLE ai_controller.side_$ally_side|_current_settings.defend_location.x $x1}
  558.                                     {VARIABLE ai_controller.side_$ally_side|_current_settings.defend_location.y $y1}
  559.                                     {VARIABLE ai_controller_{AFFIX}.defend_location.picker_active no}
  560.  
  561.                                     {VARIABLE order_type defend_location}
  562.  
  563.                                     {VARIABLE ai_controller.side_$ally_side|_current_settings.current_objective defend_location}
  564.                                     {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_objective_description _"focusing on defending the area around $x1|,$y1|."}
  565.  
  566.                                     {MODIFY_AI_ADD_GOAL $ally_side (
  567.                                         [goal]
  568.                                             id=set_by_ai_controller
  569.                                             name=protect
  570.                                             value=20
  571.                                             [criteria]
  572.                                                 x,y=$x1,$y1
  573.                                             [/criteria]
  574.                                         [/goal]
  575.                                     )}
  576.  
  577.                                     [print]
  578.                                         text=" "    # wmllint: ignore
  579.                                         duration=1
  580.                                     [/print]
  581.  
  582.                                     [fire_event]
  583.                                         name=menu item ai_controller
  584.  
  585.                                         [primary_unit]
  586.                                             x=$ai_controller_{AFFIX}.defend_location.original_controller_invokation_x
  587.                                             y=$ai_controller_{AFFIX}.defend_location.original_controller_invokation_y
  588.                                         [/primary_unit]
  589.                                     [/fire_event]
  590.                                 [/command]
  591.                             [/set_menu_item]
  592.  
  593.                             [event]
  594.                                 name=select,recruit,recall,side turn,menu item ai_controller
  595.  
  596.                                 [if]
  597.                                     [variable]
  598.                                         name=ai_controller_{AFFIX}.defend_location.picker_active
  599.                                         boolean_equals=yes
  600.                                     [/variable]
  601.  
  602.                                     [then]
  603.                                         {VARIABLE ai_controller_{AFFIX}.defend_location.picker_active no}
  604.  
  605.                                         [print]
  606.                                             text= _ "Location selection canceled"
  607.                                             duration=100
  608.                                             {COLOR_WHITE}
  609.                                         [/print]
  610.                                     [/then]
  611.                                 [/if]
  612.                             [/event]
  613.                         [/command]
  614.                     [/option]
  615.                 [/defend_location]
  616.  
  617.                 ################
  618.  
  619.                 [revoke_objective_orders]
  620.                     [option]
  621.                         message= _ "Clear objective orders"
  622.  
  623.                         [show_if]
  624.                             [variable]
  625.                                 name=ai_controller_{AFFIX}.revoke_objective_orders.disabled
  626.                                 not_equals=yes
  627.                             [/variable]
  628.                         [/show_if]
  629.  
  630.                         [command]
  631.                             {MODIFY_AI_DELETE_GOAL $ally_side set_by_ai_controller}
  632.  
  633.                             {CLEAR_VARIABLE ai_controller.side_$ally_side|_current_settings.current_objective}
  634.                         [/command]
  635.                     [/option]
  636.                 [/revoke_objective_orders]
  637.  
  638.                 ################
  639.  
  640.                 [revoke_behaviour_orders]
  641.                     [option]
  642.                         message= _ "Clear behavior orders"
  643.  
  644.                         [show_if]
  645.                             [variable]
  646.                                 name=ai_controller_{AFFIX}.revoke_behaviour_orders.disabled
  647.                                 not_equals=yes
  648.                             [/variable]
  649.                         [/show_if]
  650.  
  651.                         [command]
  652.                             {MODIFY_AI_DELETE_ASPECT $ally_side aggression set_by_ai_controller}
  653.                             {MODIFY_AI_DELETE_ASPECT $ally_side caution set_by_ai_controller}
  654.  
  655.                             {CLEAR_VARIABLE ai_controller.side_$ally_side|_current_settings.current_behaviour}
  656.                         [/command]
  657.                     [/option]
  658.                 [/revoke_behaviour_orders]
  659.  
  660.                 ################
  661.  
  662.                 [revoke_all_orders]
  663.                     [option]
  664.                         message= _ "Clear all orders"
  665.  
  666.                         [show_if]
  667.                             [variable]
  668.                                 name=ai_controller_{AFFIX}.revoke_orders.disabled
  669.                                 not_equals=yes
  670.                             [/variable]
  671.                         [/show_if]
  672.  
  673.                         [command]
  674.                             {MODIFY_AI_DELETE_GOAL $ally_side set_by_ai_controller}
  675.                             {MODIFY_AI_DELETE_ASPECT $ally_side aggression set_by_ai_controller}
  676.                             {MODIFY_AI_DELETE_ASPECT $ally_side caution set_by_ai_controller}
  677.  
  678.                             {CLEAR_VARIABLE ai_controller.side_$ally_side|_current_settings}
  679.                         [/command]
  680.                     [/option]
  681.                 [/revoke_all_orders]
  682.             [/literal]
  683.         [/set_variables]
  684.  
  685.         [set_variables]
  686.             name=ai_controller_{AFFIX}
  687.             mode=merge
  688.  
  689.             [literal]
  690.                 {VARIABLES_WML}
  691.             [/literal]
  692.         [/set_variables]
  693.  
  694.         [set_menu_item]
  695.             id=ai_controller
  696.             description= _ "Instruct ally"
  697.  
  698.             [show_if]
  699.                 [have_unit]
  700.                     side=$ai_controller_{AFFIX}.ally_sides
  701.                     x,y=$x1,$y1
  702.  
  703.                     [not]
  704.                         side=$ai_controller_{AFFIX}.disabled_for_sides
  705.                     [/not]
  706.                 [/have_unit]
  707.  
  708.                 [variable]
  709.                     name=ai_controller_{AFFIX}.enabled
  710.                     equals=yes
  711.                 [/variable]
  712.  
  713.                 [variable]
  714.                     name=ai_controller_{AFFIX}.player_side
  715.                     contains=$side_number
  716.                 [/variable]
  717.  
  718.                 [variable]
  719.                     name=ai_controller_{AFFIX}.defend_location.picker_active
  720.                     boolean_equals=no
  721.                 [/variable]
  722.             [/show_if]
  723.  
  724.             [command]
  725.                 [store_unit]
  726.                     [filter]
  727.                         x,y=$x1,$y1
  728.                     [/filter]
  729.  
  730.                     kill=no
  731.                     variable=ally_unit
  732.                 [/store_unit]
  733.  
  734.                 [store_unit]
  735.                     [filter]
  736.                         side=$ally_unit.side
  737.                         canrecruit=yes
  738.                     [/filter]
  739.  
  740.                     kill=no
  741.                     variable=ally_leader
  742.                 [/store_unit]
  743.  
  744.                 {VARIABLE ally_side $ally_leader.side}
  745.  
  746.                 [if]
  747.                     [variable]
  748.                         name=ai_controller.side_$ally_side|_original_settings.side
  749.                         equals=$empty
  750.                     [/variable]
  751.  
  752.                     [then]
  753.                         [store_side]
  754.                             side=$ally_side
  755.                             variable=ai_controller.side_$ally_side|_original_settings
  756.                         [/store_side]
  757.  
  758.                         [set_variables]
  759.                             name=ai_controller.side_$ally_side|_original_settings.ai_settings
  760.  
  761.                             [value]
  762.                                 side=$ally_side
  763.  
  764.                                 [insert_tag]
  765.                                     name=ai
  766.                                     variable=ally_leader.ai
  767.                                 [/insert_tag]
  768.                             [/value]
  769.                         [/set_variables]
  770.                     [/then]
  771.                 [/if]
  772.  
  773.                 {CLEAR_VARIABLE ai_controller_finished}
  774.  
  775.                 [while]
  776.                     [variable]
  777.                         name=ai_controller_finished
  778.                         not_equals=yes
  779.                     [/variable]
  780.  
  781.                     [do]
  782.                         [if]
  783.                             [variable]
  784.                                 name=ai_controller.side_$ally_side|_current_settings.current_objective
  785.                                 equals=$empty
  786.                             [/variable]
  787.  
  788.                             [then]
  789.                                 {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_objective_description _"none set."}
  790.                             [/then]
  791.                         [/if]
  792.  
  793.                         [if]
  794.                             [variable]
  795.                                 name=ai_controller.side_$ally_side|_current_settings.current_behaviour
  796.                                 equals=$empty
  797.                             [/variable]
  798.  
  799.                             [then]
  800.                                 {VARIABLE ai_controller.side_$ally_side|_current_settings.currently_doing_behaviour_description _"none set."}
  801.                             [/then]
  802.                         [/if]
  803.  
  804.                         [if]
  805.                             [variable]
  806.                                 name=ai_controller.side_$ally_side|_current_settings.current_objective
  807.                                 equals=$empty
  808.                             [/variable]
  809.  
  810.                             [variable]
  811.                                 name=ai_controller.side_$ally_side|_current_settings.current_behaviour
  812.                                 equals=$empty
  813.                             [/variable]
  814.  
  815.                             [then]
  816.                                 [set_variables]
  817.                                     name=ai_controller_{AFFIX}.main_menu_message
  818.  
  819.                                     [value]
  820.                                         speaker=narrator
  821.                                         caption= _ "Instruct ally"
  822.                                         message= _ "$ally_leader.name (side $ally_side|) has not been given any instructions and is acting normally."+"
  823. <span color='black'>-</span>"+"
  824. "+_"Objective: $ai_controller.side_$ally_side|_current_settings.currently_doing_objective_description
  825. Behavior: $ai_controller.side_$ally_side|_current_settings.currently_doing_behaviour_description"+"
  826. <span color='black'>-</span>"
  827.                                         image=wesnoth-icon.png
  828.                                     [/value]
  829.                                 [/set_variables]
  830.                             [/then]
  831.  
  832.                             [else]
  833.                                 [set_variables]
  834.                                     name=ai_controller_{AFFIX}.main_menu_message
  835.  
  836.                                     [value]
  837.                                         speaker=narrator
  838.                                         caption= _ "Instruct ally"
  839.                                         message= _ "$ally_leader.name (side $ally_side|) is carrying out the following instructions:"+"
  840. <span color='black'>-</span>"+"
  841. "+_"Objective: $ai_controller.side_$ally_side|_current_settings.currently_doing_objective_description
  842. Behavior: $ai_controller.side_$ally_side|_current_settings.currently_doing_behaviour_description"+"
  843. <span color='black'>-</span>"
  844.                                         image=wesnoth-icon.png
  845.                                     [/value]
  846.                                 [/set_variables]
  847.                             [/else]
  848.                         [/if]
  849.  
  850.                         [set_variables]
  851.                             name=ai_controller_{AFFIX}.main_menu_message.option
  852.  
  853.                             [literal]
  854.                                 message= _ "Set objective..."
  855.  
  856.                                 [command]
  857.                                     [message]
  858.                                         speaker=narrator
  859.                                         caption= _ "Instruct ally"
  860.                                         message=$ai_controller_{AFFIX}.main_menu_message.message
  861.                                         image=wesnoth-icon.png
  862.  
  863.                                         [insert_tag]
  864.                                             name=option
  865.                                             variable=ai_controller_{AFFIX}.focus_on_enemy.option
  866.                                         [/insert_tag]
  867.  
  868.                                         [insert_tag]
  869.                                             name=option
  870.                                             variable=ai_controller_{AFFIX}.protect.option
  871.                                         [/insert_tag]
  872.  
  873.                                         [insert_tag]
  874.                                             name=option
  875.                                             variable=ai_controller_{AFFIX}.defend_location.option
  876.                                         [/insert_tag]
  877.  
  878.                                         [insert_tag]
  879.                                             name=option
  880.                                             variable=ai_controller_{AFFIX}.revoke_objective_orders.option
  881.                                         [/insert_tag]
  882.  
  883.                                         [option]
  884.                                             message="<span size='larger'>" + _"Back" + "</span>"
  885.  
  886.                                             [command]
  887.                                             [/command]
  888.                                         [/option]
  889.                                     [/message]
  890.                                 [/command]
  891.                             [/literal]
  892.  
  893.                             [literal]
  894.                                 message= _ "Set behavior..."
  895.  
  896.                                 [command]
  897.                                     [message]
  898.                                         speaker=narrator
  899.                                         caption= _ "Instruct ally"
  900.                                         message=$ai_controller_{AFFIX}.main_menu_message.message
  901.                                         image=wesnoth-icon.png
  902.  
  903.                                         [insert_tag]
  904.                                             name=option
  905.                                             variable=ai_controller_{AFFIX}.aggression.option
  906.                                         [/insert_tag]
  907.  
  908.                                         [insert_tag]
  909.                                             name=option
  910.                                             variable=ai_controller_{AFFIX}.caution.option
  911.                                         [/insert_tag]
  912.  
  913.                                         [insert_tag]
  914.                                             name=option
  915.                                             variable=ai_controller_{AFFIX}.revoke_behaviour_orders.option
  916.                                         [/insert_tag]
  917.  
  918.                                         [option]
  919.                                             message="<span size='larger'>" + _"Back" + "</span>"
  920.  
  921.                                             [command]
  922.                                             [/command]
  923.                                         [/option]
  924.                                     [/message]
  925.                                 [/command]
  926.                             [/literal]
  927.  
  928.                             [insert_tag]
  929.                                 name=literal
  930.                                 variable=ai_controller_{AFFIX}.revoke_all_orders.option
  931.                             [/insert_tag]
  932.  
  933.                             [literal]
  934.                                 message="<span size='larger'>" + _"Exit" + "</span>"
  935.  
  936.                                 [command]
  937.                                     {VARIABLE ai_controller_finished yes}
  938.  
  939. #ifndef MULTIPLAYER
  940.                                     [allow_undo]
  941.                                     [/allow_undo]
  942. #endif
  943.                                 [/command]
  944.                             [/literal]
  945.                         [/set_variables]
  946.  
  947.                         [insert_tag]
  948.                             name=message
  949.                             variable=ai_controller_{AFFIX}.main_menu_message
  950.                         [/insert_tag]
  951.                     [/do]
  952.                 [/while]
  953.  
  954.                 {CLEAR_VARIABLE ally_unit,ally_leader,ai_controller_{AFFIX}.main_menu_message}
  955.             [/command]
  956.         [/set_menu_item]
  957.     [/event]
  958.  
  959.     [event]
  960.         name=victory
  961.  
  962.         {CLEAR_VARIABLE ai_controller,ai_controller_{AFFIX}}
  963.     [/event]
  964. #enddef
  965.  
  966. #define DISABLE_AI_CONTROLLER AFFIX
  967.     {VARIABLE ai_controller_{AFFIX}.enabled no}
  968. #enddef
  969.  
  970. #define DISABLE_AI_CONTROLLER_FOR_SIDE AFFIX SIDE
  971.     [if]
  972.         [variable]
  973.             name=ai_controller_{AFFIX}.disabled_for_sides
  974.             equals=0
  975.         [/variable]
  976.  
  977.         [not]
  978.             [variable]
  979.                 name=ai_controller_{AFFIX}.disabled_for_sides
  980.                 contains={SIDE}
  981.             [/variable]
  982.         [/not]
  983.  
  984.         [then]
  985.             {VARIABLE ai_controller_{AFFIX}.disabled_for_sides {SIDE}}
  986.         [/then]
  987.  
  988.         [else]
  989.             [if]
  990.                 [variable]
  991.                     name=ai_controller_{AFFIX}.disabled_for_sides
  992.                     contains={SIDE}
  993.                 [/variable]
  994.  
  995.                 [else]
  996.                     {VARIABLE ai_controller_{AFFIX}.disabled_for_sides $ai_controller_{AFFIX}.disabled_for_sides|,{SIDE}}
  997.                 [/else]
  998.             [/if]
  999.         [/else]
  1000.     [/if]
  1001. #enddef
  1002.  
  1003. #define ENABLE_AI_CONTROLLER_FOR_SIDE AFFIX SIDE
  1004.     [if]
  1005.         [variable]
  1006.             name=ai_controller_{AFFIX}.disabled_for_sides
  1007.             contains={SIDE}
  1008.         [/variable]
  1009.  
  1010.         [then]
  1011.             [set_variables]
  1012.                 name=disabled_for_sides_array
  1013.  
  1014.                 [split]
  1015.                     list=ai_controller_{AFFIX}.disabled_for_sides
  1016.                     key=side
  1017.                     separator=,
  1018.                 [/split]
  1019.             [/set_variables]
  1020.  
  1021.             {FOREACH disabled_for_sides_array disabled_for_side_i}
  1022.                 [if]
  1023.                     [variable]
  1024.                         name=disabled_for_sides_array[$disabled_for_side_i].side
  1025.                         equals={SIDE}
  1026.                     [/variable]
  1027.  
  1028.                     [then]
  1029.                         {CLEAR_VARIABLE disabled_for_sides_array[$disabled_for_side_i]}
  1030.                     [/then]
  1031.                 [/if]
  1032.             {NEXT disabled_for_side_i}
  1033.  
  1034.             [set_variable]
  1035.                 name=ai_controller_{AFFIX}.disabled_for_sides
  1036.  
  1037.                 [join]
  1038.                     variable=disabled_for_sides_array
  1039.                     key=side
  1040.                     separator=,
  1041.                 [/join]
  1042.             [/set_variable]
  1043.  
  1044.             {CLEAR_VARIABLE disabled_for_sides_array}
  1045.         [/then]
  1046.  
  1047.         [else]
  1048.             {VARIABLE ai_controller_{AFFIX}.ally_sides $ai_controller_{AFFIX}.ally_sides|,{SIDE}}
  1049.         [/else]
  1050.     [/if]
  1051. #enddef
  1052.  
  1053. # A stub for scenario 7 of LoW
  1054. #define AI_LOCATION AFFIX STRING RADIUS X Y
  1055.     {SET_LABEL {X} {Y} ({STRING})}
  1056. #enddef
  1057.  
  1058. #define AI_CONTROLLER_FUTURE_STRINGS
  1059.     # These will be used for the special orders menu and the order for telling
  1060.     # the ally leader to move someplace
  1061.     future_string_1= _ "Set special orders..."    #wmllint: ignore
  1062.     future_string_2= _ "Move leader to..."    #wmllint: ignore
  1063.     future_string_3= _ "Right-click to select a location to move leader to"    #wmllint: ignore
  1064.     future_string_4= _ "Move leader here"    #wmllint: ignore
  1065.     future_string_5= _ "moving leader to $x1|,$y1|."    #wmllint: ignore
  1066.     future_string_6= _ "Clear special orders"    #wmllint: ignore
  1067.     future_string_7= _ "Special: $ai_controller.side_$ally_side|_current_settings.currently_doing_special_description"    #wmllint: ignore
  1068. #enddef
  1069.