Commit graph

16 commits

Author SHA1 Message Date
newfrenchy83
7d6e2b2a10 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.
2018-09-09 18:47:56 +03:00
Iris Morelle
4e37cdc713 Don't allow [kill] animate=yes to scroll to units through fog and shroud
Restores 1.12's behaviour.
2018-06-04 16:15:37 -04: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