Commit graph

26 commits

Author SHA1 Message Date
Toom
31658e2587
Set unit hitpoints to 0 during [kill] (#9164) 2024-08-10 09:20:12 -05:00
Toom
9f53c4fd11
fail if [kill] contains [filter], re #4316 (#7717) 2023-07-16 19:47:44 +02:00
Celtic Minstrel
7d5fa80180
WML: Adjust the weapon selection logic for [kill] (#7196)
* WML: Adjust the weapon selection logic for [kill]

The previous logic simply did not make sense, especially for the secondary weapon.
For example, it would ignore the secondary weapon specification if the primary weapon was not found on the secondary unit, which does not make any sense.

The cases that this changes are:
- There is a secondary unit and a primary attack, but no matching attack was found. Previously it would use the default, now it pretends that attack exists.
- There is a secondary attack specified, but no primary attack, either because it was unspecified or because it didn't match any attack on the secondary unit

In both these cases, the animation runs as if a matching attack exists, rather than using no attack and choosing the default animation.

Adjust the log level too.
2022-12-24 16:52:57 +01:00
Celtic Minstrel
0f3d8388df Fix deprecation warning in [kill]
Fixes #6924
2022-07-29 23:37:36 -04:00
Celtic Minstrel
4ec60b99d9 Lua: Update all mainline references to the helper module 2021-07-07 01:32:05 -04:00
Celtic Minstrel
ea5367de17 Move create_animator and create_weapon into the units module 2021-05-11 14:52:18 -04:00
Celtic Minstrel
11a57e0fa7 Move helper.find_attack -> wesnoth.units.find_attack 2019-12-02 22:39:34 -05:00
Celtic Minstrel
0ee05637d9 Lua: Replace uses of deprecated (moved) interface functions 2019-11-16 12:35:20 -05:00
Celtic Minstrel
aaa2dc4ece Rollback possibility of wesnoth.get_units matching recall list units
Now it's renamed to wesnoth.units.find_on_map.

wesnoth.units.find implements the case of finding units on either the map or a recall list.
2019-11-15 22:39:09 -05:00
Celtic Minstrel
977f05d77f Lua: Replace uses of deprecated (moved) unit functions
Also backtracked the removal of wesnoth.get_recall_units, which is now available as wesnoth.units.find_on_recall - it's just more convenient than passing x=recall to wesnoth.units.find
2019-11-15 22:39:08 -05:00
newfrenchy83
c1a70068d5 Lua API: implicitly clear animator after playing it (#3536)
This prevents the animator from holding a strong reference to the target unit, which was keeping the unit object alive and thus preventing the unit halo, if any, from disappearing.

(cherry-picked from commit 7d6e2b2a10)
2018-10-07 03:24:59 +00:00
Iris Morelle
5c04fe72d5 Don't allow [kill] animate=yes to scroll to units through fog and shroud
Restores 1.12's behaviour.

(cherry-picked from commit 4e37cdc713)
2018-10-07 03:22:15 +00:00
Charles Dang
0103959c36 Cleaned up deprecated API usage in core Lua
[ci skip]
2018-03-13 16:55:36 +11:00
vgaming
728204665c fix code problems found by luacheck (#2388)
fix code problems found by luacheck

Second iteration of the process, now handling data/lua/wml/*.lua

luacheck command used to find bugs:
  luacheck ./*.lua --globals wesnoth wml --codes --ignore 542 213
Additionally, error code 211 (unused variables) could be ignored,
as using underscore convention `_` is controversial in
wesnoth ( see https://github.com/wesnoth/wesnoth/pull/2380#discussion_r162519341 )

Actual bugs found:
* items.lua, access of global `write_name` instead of local `cfg.write_name`
* kill.lua, typo `primary_unit` -> `primary`
* bad code style: global `i` instead of local `i`
  (would conflict with 3-rd party code if it would use global `i`, too)
2018-01-23 13:35:04 -06:00
Jyrki Vesterinen
d81f230680 Clear unit death animation after killing the unit
This is another and much better way to fix the unit halo remaining.
2017-12-28 12:02:29 +02:00
Jyrki Vesterinen
f50c7d3f2a Revert "Work around unit halo not disappearing with [kill] animate=yes"
This reverts commit 70b468070b.

As I said in the commit message, the fix is not pretty, and
@CelticMinstrel said in IRC that a different fix would definitely be
better. I'll fix the problem by having an animation automatically
release the unit when done, instead (next commit).
2017-12-28 11:48:12 +02:00
Jyrki Vesterinen
70b468070b Work around unit halo not disappearing with [kill] animate=yes
The problem was that the kill animation retained a reference to the unit.
Triggering a Lua garbage collection (which destroys the animation object)
fixes it, although it's definitely not a pretty fix.

Closes pull request #2313.
2017-12-25 18:35:01 +02:00
Gregory A Lundberg
38e31aa61f Do not access non-existent unit
The [kill] tag can run animations. But it can also fire the `last breath` event, which can call [kill]. When we get back to the original [kill], the unit is gone, causing an error attempting to run the animations.

Added a check to ensure the unit is still on the map before we attempt to run the animations.

The Issue also requested that [harm_unit] pass the unit causing the harm into the [kill] tag so that `last breath` could use the secondary (killing) unit available like it does elsewhere.

Closes #2298
2017-12-19 15:05:24 -06:00
Jyrki Vesterinen
3b5880f5fb Fix #1980: [modify_unit] makes the unit disappear for a frame or two
Regression from commit d40a9e930b.

In that commit I removed a redraw after the death animation of a killed
unit has been played, but just to be safe, I then added a redraw after the
unit has been erased from the map. Turns out it's not a good idea because
[modify_unit] operates by killing and recreating the unit.

This commit simply removes the redraw after erasing. Hopefully we aren't
relying on [kill] triggering a redraw somewhere.

[ci skip]
2017-09-12 21:36:40 +03:00
Jyrki Vesterinen
d40a9e930b Fix [kill]ed units flashing briefly after death animation 2017-09-08 21:54:03 +03:00
Celtic Minstrel
fbeb6c5b09 Add helper.find_attack and clean up the [animate_unit] / [kill] hack regarding death / victory animations 2017-05-28 18:20:16 -04:00
Celtic Minstrel
686551c9f7 Fix [primary_attack] and [second_attack] not working in [kill] 2017-05-28 18:20:14 -04:00
Celtic Minstrel
c67d524ced Fix [kill] not affecting recall list units 2017-05-22 17:31:20 -04:00
Charles Dang
0e7866db2d Possible for fix #1683 2017-05-13 02:32:26 +11:00
Celtic Minstrel
a3a84076b8 Support [primary_attack] and [secondary_attack] in [kill] 2017-05-04 19:20:43 -04:00
Celtic Minstrel
e1233fd0f2 Split several of the larger WML tags into their own file 2017-05-03 02:43:22 -04:00