Contolling Attack Stikes with lua?

Discussion of Lua and LuaWML support, development, and ideas.

Moderator: Forum Moderators

Post Reply
jmh
Posts: 20
Joined: May 2nd, 2015, 12:54 am

Contolling Attack Stikes with lua?

Post by jmh »

I thought I'd ask if it's even possible before attempting to figure it out as learning exercise.

What's I was thinking about was a way to control the attack of a stronger unit when pairing strong and weak units to help the weak unit advance. If the strong unit stopped striking when that target still had X hit points left, where that X was less than or equal to the damage the unit inflicts that leaves a easy target for the weak unit to finish off. I'm wondering if that level of control is possible with lau during the game. Then I started wondering if the general attack event was part of some engine which probably is all in the C/C++ code.

Anyone one know?

Thanks!
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Contolling Attack Stikes with lua?

Post by Elvish_Hunter »

jmh wrote:If the strong unit stopped striking when that target still had X hit points left, where that X was less than or equal to the damage the unit inflicts that leaves a easy target for the weak unit to finish off. I'm wondering if that level of control is possible with lau during the game.
Not directly. However, if I remember correctly (a long time passed since I had to do something like that), if you store a unit, kill it and then unstore it again where it was, the attack ceases.
This can be combined with [filter] lua_function= to check if the unit has less than the wanted amount of HP. You can do the same with the formula= key and FormulaAI language.
Current maintainer of these add-ons, all on 1.16:
The Sojournings of Grog, Children of Dragons, A Rough Life, Wesnoth Lua Pack, The White Troll (co-author)
jmh
Posts: 20
Joined: May 2nd, 2015, 12:54 am

Re: Contolling Attack Stikes with lua?

Post by jmh »

Slow getting back to the forum but Thanks! That's a good starting place to work from.
Post Reply