Apply Micro AI to all sides?

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
Kharn
Posts: 82
Joined: December 12th, 2005, 7:50 pm
Location: Dallas, Tx

Apply Micro AI to all sides?

Post by Kharn » December 31st, 2014, 4:09 am

I want to apply a micro AI in multiplayer to all AI controlled sides. However, [micro_ai] tag requires a single numeric side and even refuses lists.
Ultimately I have a list of 15 or so units that should always be a lurker when controlled by the AI in multiplayer.

I am implementing this improperly currently by
leader1unit.cfg>>Prestart event>>micro_ai>>side=1>>type=
  • leader1unit.cfg>>Prestart event>>micro_ai>>side=2>>type=
    • leader1unit.cfg>>Prestart event>>micro_ai>>side=3>>type=
      • leader1unit.cfg>>Prestart event>>micro_ai>>side=4>>type=
        • leader1unit.cfg>>Prestart event>>micro_ai>>side=5>>type=
          • leader1unit.cfg>>Prestart event>>micro_ai>>side=6>>type=
            • leader2unit.cfg>>Prestart event>>micro_ai>>side=1>>type=
              • leader2unit.cfg>>Prestart event>>micro_ai>>side=2>>type=
                • leader2unit.cfg>>Prestart event>>micro_ai>>side=3>>type=
                  • leader2unit.cfg>>Prestart event>>micro_ai>>side=4>>type=
                    • leader2unit.cfg>>Prestart event>>micro_ai>>side=5>>type=[list of 15 units that should have lurker ai]
                      leader2unit.cfg>>Prestart event>>micro_ai>>side=6>>type=[list of 15 units that should have lurker ai]

                      Problem is, for every side a map has less than 6, a long error message appears in game. (Wesnoth 1.12.0\data\ai/micro_ais/micro_ai_helper.lua:29: attempt to index field '?' (a nil value)) which references this line of lua code (for ai_tag in H.child_range(wesnoth.sides[side].__cfg, 'ai') do)

                      Is there a more proper way to implement a Micro AI for a unit?

                      If not, can I get some advise on how to filter prestart events such that they dont activate unless side=X exists? This would at least stop the game from trying to activate a micro AI for a side that does not exist.

                      Many thanks!
Creator of 120+ units Lord of the Rings era and campaign now outdated & lost.
Creator of WWII Battleground Europe mod with 120+ units most with custom wml and animations. Every variable is mathematically derived based on WWII stats such as historical cost & mm armour.

User avatar
zookeeper
WML Wizard
Posts: 9740
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Apply Micro AI to all sides?

Post by zookeeper » December 31st, 2014, 6:37 am

Kharn wrote:If not, can I get some advise on how to filter prestart events such that they dont activate unless side=X exists? This would at least stop the game from trying to activate a micro AI for a side that does not exist.
Well, this would do it, assuming that every existing side actually has a unit on the map at the time (so it might or might not be safer to make it a start event instead):

Code: Select all

[event]
    name=prestart

    [filter_condition]
        [have_unit]
            side=5
        [/have_unit]
    [/filter_condition]

    ...
[/event]

Post Reply