Commit graph

1012 commits

Author SHA1 Message Date
mattsc
f260dd3be5 Micro AIs: one more wesnoth.dofile -> wesnoth.require 2014-04-07 14:36:36 -07:00
mattsc
bb5ed2e5a2 Micro AIs: clean up loading of Lua files
Consistently use wesnoth.require, avoid wesnoth.dofile. Move commands
as close to beginning of file as possible in order to facilitate custom
modifications of MAIs.
2014-04-07 14:23:42 -07:00
mattsc
1dfd79c3a5 Micro AIs: use the new functions for storing information in self.data
… so that it is done in a consistent way and conflicts can be avoided
when setting up a subsequent MAI.
2014-03-31 20:04:18 -07:00
mattsc
73a11634f7 Micro AIs: check for existence of [micro_ai] tags in self.data when...
… setting up an MAI. Ideally, we would delete such previous occurrences
of [micro_ai] tags in the AI's self.data variable. However, the MAI can
be changed while it is not the AI's turn, when this is not possible. So
instead, we check for the existence of such tags and make sure we are
using a different ai_id.
2014-03-31 20:02:16 -07:00
mattsc
6cfe5fa351 MAIs: add utility functions for storing information in AI's self.data
These provide a simple and consistent method of storing variables
inside [micro_ai] tags in the AI's persistent self.data variable. This
is needed for fixing a bug with variables stored there from a previous
MAI causing problems with a subsequent MAI
2014-03-31 19:58:58 -07:00
mattsc
6bd3bae330 Fix typos in comments 2014-03-31 19:55:24 -07:00
mattsc
d69d4e9858 Goto MAI: store whether unit is released in the unit, not self.data
This is unit specific information, and therefore should go into the
unit.  By contrast, information whether all units of the side have been
released needs to remain in self.data.
2014-03-31 18:18:51 -07:00
mattsc
c24ddb71b2 Micro AIs bug fix: remove MAI unit variables on MAI removal
Previously this information remained in units and could alter the
behavior of subsequent MAIs, or even entirely disable them.
2014-03-31 08:21:50 -07:00
mattsc
49cc3bc7f9 Micro AIs: use the new functions for storing information in units
… such that it is done in a consistent way and this information can be
removed on MAI deletion.
2014-03-31 08:19:31 -07:00
mattsc
a4ee966d06 Fix comments 2014-03-31 08:16:14 -07:00
mattsc
bfb3315153 Micro AIs: another bug fix for required keys for MAI removal
The random recruiters MAI also required unnecessary keys to be provided
for MAI removal.
2014-03-31 08:15:12 -07:00
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
9e6b780306 ai_helper.get_closest_location(): fix bug with tags in SLF
The way how the Standard Location Filter was dealt with only worked
with keys, not tags.
2014-03-26 18:03:50 -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
496a58d343 Experimental AI: use checked versions of the AI actions
So that only valid actions are executed and useful error messages are
produced if something goes wrong.
2014-02-28 07:04:54 -08:00
mattsc
0b6fa7ed19 Experimental AI: remove potential of causing errors through WML events
Events taking units off the map after the move could previously have
caused errors, and thus disabled the AI for the rest of the turn.
2014-02-28 07:03:02 -08: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
b7bc394f95 Micro AIs: improve error reporting
Use error() instead of wesnoth.message(), as this also produces a stack
traceback.
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
62273f51b3 RCA AI: revert gold saving default back to 'off'
This was discussed both on the wesnoth-dev mailing list and on the
forums and the overall consensus was that it should be off, although
some scenarios will benefit from it.  It should be enabled specifically
in such scenarios as they are identified.
Reference:
https://mail.gna.org/public/wesnoth-dev/2014-01/msg00001.html
and links therein
2014-01-22 06:51:19 -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