Contolling Attack Stikes with lua?

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

Moderators: Forum Moderators, Developers

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

Contolling Attack Stikes with lua?

Post by jmh » July 18th, 2015, 3:16 pm

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
Developer
Posts: 1375
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Contolling Attack Stikes with lua?

Post by Elvish_Hunter » July 21st, 2015, 9:15 am

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:
1.14: The Sojournings of Grog, A Rough Life, The White Troll (co-author), Wesnoth Lua Pack
1.12: Children of Dragons
Active again until mid-October

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

Re: Contolling Attack Stikes with lua?

Post by jmh » August 5th, 2015, 9:22 pm

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

Post Reply