Commit graph

390 commits

Author SHA1 Message Date
mattsc
24881edfb3 Micro AIs: use AI id instead of CA id as identifier
… for determining whether AI/CA ids are unique.  Also pass AI id to
eval/exec functions, instead of CA id.  This is also a step toward
fixing the bug with MAI variables remaining stored in units after an
MAI is removed.
In principle, the ca_id= key in the [micro_ai] tag should now be
renamed to ai_id, but that would break backward compatibility without
any benefit to the user, so we deal with it internally behind the
scenes instead.
2014-03-31 08:12:33 -07:00
mattsc
96e84f24c5 MAIs: add utility functions for storing information in unit variables
These provide a simple and consistent way of storing variables inside
[micro_ai] tags in unit variables.  This is needed for fixing a bug
with variables stored in units from a previous MAI causing problems
with a subsequent MAI.
2014-03-31 07:54:52 -07:00
mattsc
7c3d9093fb Micro AIs: fix bug requiring unnecessary keys for MAI removal
MAIs which take either [filter] or id= used to throw an error message
if neither was given even for MAI removal.
2014-03-31 07:49:56 -07:00
mattsc
84b1234835 [micro_ai] tag: move CA_path definition to beginning of file
To make it more visible for UMC authors who want to include their own
(modified) AIs.
2014-03-31 07:46:21 -07:00
mattsc
0fd45763a9 MAIs: test for unit equality directly, not via coordinates 2014-03-29 17:19:56 -07:00
mattsc
f03c6052d0 Return guardian MAI: remove unnecessary condition
We can never get to this point in the code if the unit does not have
moves.
2014-03-29 17:19:56 -07:00
mattsc
a017e584f2 Coward MAI: remove unnecessary condition
ai_helper.movefull_stopunit takes care of this internally.
2014-03-29 17:19:56 -07:00
mattsc
187f1c489b Patrol MAI: fix bug with save/load persistent data storage
WML values may not be used as keys, this can make savegames invalid.
Store information in the units now rather than in self.data. (Note:
storing in self.data would also be possible if the syntax were changed.)
2014-03-28 07:49:09 -07:00
mattsc
244ad22ce2 MAIs: minor code simplification in AIs that take both [filter] and id=
These are the AIs that used to use Behavior Candidate Actions (BCA).
2014-03-28 07:00:59 -07:00
mattsc
c72c8e7ff2 Messenger MAI: add optional invert_order= key
In the default configuration, the AI moves the messenger which has
advanced the furthest through the waypoints first.  If this key is set,
the rearmost messenger is moved first.
2014-03-27 14:36:32 -07:00
mattsc
62f709aaa3 Messenger MAI: allow several messengers to be controlled by AI
For two of the CAs this mostly just means reading the [filter] tag and
picking one of the messengers.  However, for the CA moving the escort
units, it means a complete rewrite, as the AI now needs to figure out
which escort unit should be moved toward which messenger.
2014-03-27 13:36:29 -07:00
mattsc
2d458b642a Messenger MAI: fix bug with escort units blocking the messenger
When there were lots of escort units, they previously quite frequently
blocked the messenger’s way, preventing him from making progress even
when it was possible.  Escort units now specifically move out of the
way if they do not need to attack enemy units in the messenger’s way.
2014-03-26 18:06:36 -07:00
mattsc
f417faa2d5 Move path to Micro AI candidate actions files into variable
The purpose of this commit (and the previous) is to make it easier for
UMC authors to add functionality to the Micro AIs.
2014-03-25 08:09:49 -07:00
mattsc
5df117161a Move Micro AI auxiliary functions into their own file 2014-03-25 07:59:29 -07:00
mattsc
76bcdae73c Messenger MAI: add optional [filter_second] tag
This allows selection of the escort units.
2014-03-25 06:32:58 -07:00
mattsc
64b41270e7 Messenger MAI: fix rare bug in attacks by messenger
This previously resulted in an error message when the messenger had
moves left but had no attacks left, a condition that was not checked
for.
2014-03-19 10:36:46 -07:00
mattsc
e5ea7824d1 Patrol Micro AI: fix bug in the attack part of this MAI
This was an oversight dating back to the introduction of the [filter]
tag as a possible parameter to this Micro AI.  A part of the attack
code still relied on the id= key being given, although that key is not
required any more now.
2014-03-17 18:30:30 -07:00
Nils Kneuper
0be71a9276 made string translateable and match pofix.py replacement 2014-03-02 10:21:45 +01:00
mattsc
95212970b8 Micro AIs: fix errors caused when WML events interfere with AI actions
If a WML event takes a unit off the map, many of the AIs would
previously have run into problems by trying to access a unit that is
then not there any more.  Thus, the existence of the unit needs to be
verified before continuing in cases when this would cause errors.
2014-02-27 17:06:20 -08:00
mattsc
947cbb2a45 Forest Animals MAI: remove incorrect wesnoth.put_unit
This needs to be in a synchronized event, which was added right below,
but apparently I forgot to remove this line.
2014-02-27 17:06:19 -08:00
mattsc
d3e9cb3957 Micro AIs: add check for valid recruiting and error message
This now checks whether the recruiting intended to be done with
ai.recruit is possible and displays an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
835194eee4 Micro AIs: add check for valid stopunit execution and error message
This now checks whether the stopunit execution intended to be done with
ai.stopunit_all, ai.stopunit_attacks or ai.stopunit_moves is possible
and displays an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
f0506b2d31 Micro AIs: add check for valid move and error message
This now checks whether the move intended to be done with ai.move is
possible and display an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
c06529aa18 Micro AIs: add check for valid full move and error message
This now checks whether the move intended to be done with ai.move_full
is possible and display an error message if it is not.
2014-02-27 17:06:19 -08:00
mattsc
70e3fc58bd Micro AIs: add check for valid attacks and error message
This will now check whether the attack intended to be done with
ai.attack is possible and display an error message if it is not.
2014-02-27 17:06:18 -08:00
mattsc
47e78471b9 Simple Attack MAI test scenario: move Lua filter function into preload event
… so that it is available after a reload as well.
2014-02-21 12:23:35 -08:00
mattsc
ac5acf69af Forest Animals MAI: make the rabbit-type animals replay safe
They need to be put on the map and taken off using ai.synced_command(),
otherwise it causes OOS errors.
2014-02-20 21:04:24 -08:00
mattsc
a66a87dad6 Healer support MAI test scenario: change event from die to last breath 2014-02-20 20:14:00 -08:00
mattsc
e78462c395 Remove function ai_helper.random()
This was using the synced RNG which is exactly the wrong thing to do
within the AI evaluation/execution functions.
2014-02-20 11:33:05 -08:00
mattsc
77d258474e Hang Out MAI: use [ai][avoid] if [micro_ai][avoid] is not given
The scenario author now has the option to use either the default AI
[avoid] tag or a specialized [avoid] tag inside the [micro_ai] tag.  If
neither is given, the default remains all castle terrain.
2014-02-11 14:00:21 -08:00
mattsc
ed4fe91b44 Wolves MAI: add optional parameter attack_only_prey=
By default, the wolves attack any enemy unit they can reach.  If this
key is set, only prey units are attacked.
2014-01-19 12:06:20 -08:00
mattsc
f856cadff6 Coward Micro AI: add optional tag [filter_second]
This tag determines from which units the coward flees.  It defaults to
all enemy units, but can be set to enemy and/or allied units if
specified.
2014-01-03 19:03:06 -08:00
mattsc
c65d8d4ae1 Wolves MAI: fix bug that sometimes kept predators from attacking
The attacks aspect may only be modified if the avoid_type= key is set
in the [micro_ai] tag, otherwise all attacks get disabled.
2013-12-20 09:00:01 -08:00
Ignacio R. Morelle
cc7afb5d67 Fix a typo in a translatable string
("handle" -> "handled")
2013-12-06 06:03:11 -03:00
mattsc
ffbf2c2891 Simple Attack MAI: add optional parameter 'weapon' 2013-11-25 19:37:20 -08:00
mattsc
c6db6cd8d5 Lua AIs: Remove unnecessary arguments in call to wesnoth.put_unit() 2013-11-14 20:04:52 -08:00
mattsc
9976eac873 Micro AI CA files: replace tabs by spaces
I had not realized that TextWrangler changes spaces to tabs when
shifting blocks of text to the left, which had been done for all CA
files when converting the engine files.
2013-11-14 10:54:14 -08:00
mattsc
c0ee2c8e87 Add wmllint spelling exceptions for files in data/ai/ 2013-11-02 20:20:10 -07:00
mattsc
b340188038 Hunter MAI [micro_ai] tag: add optional [filter] tag 2013-11-01 17:13:06 -07:00
mattsc
08a722e248 All Guardian MAI [micro_ai] tags: add optional [filter] tag 2013-11-01 17:13:05 -07:00
mattsc
0670630ff9 Patrol MAI [micro_ai] tag: add optional [filter] tag 2013-11-01 17:13:05 -07:00
mattsc
1d488a2c35 Rename ai/micro_ais/ais/ to ai/micro_ais/engines/
... in order to distinguish between AI files containing full engines
and those containing individual CA eval/exec functions
2013-10-30 12:55:08 -07:00
mattsc
e469df1d50 Move and rename [micro_ai] tag setup file
... to a more logical location given the recent reorganization.
2013-10-30 12:55:08 -07:00
mattsc
4e68b4eaa2 Recruiting MAI test scenario: add Rush Recruitment MAI for Side 2 2013-10-30 09:47:41 -07:00
mattsc
b826e5ead5 Micro AIs: make recruit_rushers work with new external CA method
The previous code did not allow to get the ai table to the execution
function.
2013-10-30 09:42:41 -07:00
mattsc
3a30675d2f Micro AIs: remove all references to AI-demos add-on 2013-10-28 17:27:14 -07:00
mattsc
6ad899cbf5 [micro_ai] tag: remove now unneeded code and comment 2013-10-26 18:33:26 -07:00
mattsc
ed10e8e8a8 [micro_ai] tag: remove code for old-style CA syntax
All Micro AIs have now been converted to using external CAs.
2013-10-26 18:31:11 -07:00
mattsc
436f36c80a Recruiting MAIs: get rid of recruiting_type= key
The previous value of recruiting_type= now goes directly into ai_type=.
 Also add syntax translation and deprecation message.
2013-10-26 18:23:55 -07:00
mattsc
6fb7c46dbe Both Recruiting MAIs: switch to using external CAs
This includes disabling the rush recruiter for the time being, as the
engine files it uses do not yet use the external CAs.  It will be
re-enabled once those have been converted as well.
2013-10-26 17:26:37 -07:00