Real Ranged Attacks (Modification for 1.18.x)
Moderator: Forum Moderators
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)

No, wesnoth doesn't require two adjacent units to perform an attack.
- Atreides
- Posts: 1243
- Joined: March 30th, 2019, 10:38 pm
- Location: On the 2nd story of the centre village in Merwuerdigliebe turning the lights on and off
Re: Real Ranged Attacks (Modification for 1.18.x)
Heh, re-reading the thread I see that teleporting was just a suggestion. I've downloaded and tried it now and as the others say: wow this is neat.
I peeked inside and I see it is 100% lua (which I'm only starting to learn hehe) and that even the ai appears to have been customized to deal with it. Impressive stuff.
I've only played one quick game so far. Contrary to what one might expect melee units don't lose their value here at all. The close lock option ensures that. In fact if you can get two melee units to surround a unit with only ranged (e.g. DA) things turn around quite a bit. The tactical changes of course mirror those most old wargamers (like me) are accustomed to when using artillery. Keep it away from the front line! ; )
I peeked inside and I see it is 100% lua (which I'm only starting to learn hehe) and that even the ai appears to have been customized to deal with it. Impressive stuff.
I've only played one quick game so far. Contrary to what one might expect melee units don't lose their value here at all. The close lock option ensures that. In fact if you can get two melee units to surround a unit with only ranged (e.g. DA) things turn around quite a bit. The tactical changes of course mirror those most old wargamers (like me) are accustomed to when using artillery. Keep it away from the front line! ; )
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
Glad to hear that. ^^
- Spannerbag
- Posts: 759
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Real Ranged Attacks (Modification for 1.18.x)
Please do!ZombieKnight wrote: ↑August 17th, 2024, 3:20 pmYou can do this actually using specials and formulas that count distance and -5% damage per tile, for example. Or any other function.
I will include an example in the next update.

Could the close lock be implemented as a special too?
Well, off the top of my head, making longer range attacks "less attractive" in some way would seem appropriate.ZombieKnight wrote: ↑August 17th, 2024, 3:20 pmI tried to add the close lock to make it weaker, if you have any ideas on how to balance it, I'd like to hear them ^^.Spannerbag wrote: ↑August 17th, 2024, 11:46 am IMHO, it does significantly change the game, and some mechanism might be desirable to maybe balance the added advantage enjoyed by ranged attacks...
I've no idea how difficult these might be to implement and I'm spouting rubbish giving thoughts that come to mind which haven't been thought through yet.
However some random thoughts:
- Ranged attacks against non-adjacent targets become less accurate (even magical/marksman?).
- Target defence increases with range, or
- Have a flat chance to miss, e.g. ?% per extra hex up to ??% chance of missing, if attack doesn't miss resolve as normal attack (so could still miss)?
And/or - Increasing chance of hitting nearby units other than intended target (increases with range)
Alternatively... - Attacker is paying more attention to what's happening further away so is to some extent distracted regarding adjacent attacks so they suffer the converse of the above, i.e. attacker defense/chance to hit (in retaliation) reduced if attacked by adjacent unit whilst targetting more distant opponent?
This could be tricky because the attacker would attack on their turn then be subject to these penalties on the enemy turn(s)...maybe use unit variables to track state?
- Damage reduces as range increases (as mentioned previously).
- Non-adjacent ranged attacks not allowed if unit is zone-locked at start of turn?
(No real in-game logic to this I guess, but it offers the player a tactic to neutralise enemy long range attacks.)
Not sure whether skirmishers should be affected or not as they can still move normally... - Cannot fire further than visual range (even if unit visible on map) - tho' this generally won't be a meaningful limtiation IMHO.
- Long range attacks use extra movement so an attacker cannot target an enemy 3 hexes away unless attacker has 3+ movement remaining.
(No real in-game logic to this I guess, but it offers the player a way to estimate which units will be in enemy range on enemy turn after movement.)
- Cannot fire at targets if attacker does not have direct line of sight to target that is 2 hexes wide?
In the DM screen grab the northern spearman was able to throw a spear at the wolf rider which whizzed past the Mage.
Don't think this would make sense to players.
Hope these give you some ideas/starting points.
If anything else comes to mind will let you know.
Cheers!
-- Spannerbag
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
It's a special (has two parts tho, becouse Lua van't filter if special is active in pre-attack)Spannerbag wrote: ↑August 17th, 2024, 9:47 pm Please do!
Could the close lock be implemented as a special too?
YesWell, off the top of my head, making longer range attacks "less attractive" in some way would seem appropriate.
I've no idea how difficult these might be to implement and I'm spouting rubbish giving thoughts that come to mind which haven't been thought through yet.

It's an option, but becouse I plan to use it on like 2-3 hex ranges it won't be so effective (I can add it into the add-on tho[*]Target defence increases with range

This feels very similar to previous idea:).[*]Have a flat chance to miss, e.g. ?% per extra hex up to ??% chance of missing, if attack doesn't miss resolve as normal attack (so could still miss)?
I actually plan it, mostly for really ranged units like cannons in my campaing (20 tiles range), I can definitely add it into add-on too.[*]Increasing chance of hitting nearby units other than intended target (increases with range)
I see the point of this and I like it.[*]Attacker is paying more attention to what's happening further away so is to some extent distracted regarding adjacent attacks so they suffer the converse of the above, i.e. attacker defense/chance to hit (in retaliation) reduced if attacked by adjacent unit whilst targetting more distant opponent?
This could be tricky because the attacker would attack on their turn then be subject to these penalties on the enemy turn(s)...maybe use unit variables to track state?[/list]
I would rather go with chance to hit actually.[*]Damage reduces as range increases (as mentioned previously).
I like this one, stronger close lock, but I fear that each skirmisher could block 1-3 archers, which would be really strong, any idea how to balance this?[*]Non-adjacent ranged attacks not allowed if unit is zone-locked at start of turn?
(No real in-game logic to this I guess, but it offers the player a tactic to neutralise enemy long range attacks.)
Not sure whether skirmishers should be affected or not as they can still move normally...
IYHO you're right I guess, the max-min range has a purpose.[*]Cannot fire further than visual range (even if unit visible on map) - tho' this generally won't be a meaningful limtiation IMHO.
It makes archers slower... which I'm nit sure about those full three hexes (units with 4-5 moves would be messed) and current AI won't be aible to work with it :/. I maybe can add it for testing it out?[*]Long range attacks use extra movement so an attacker cannot target an enemy 3 hexes away unless attacker has 3+ movement remaining.
(No real in-game logic to this I guess, but it offers the player a way to estimate which units will be in enemy range on enemy turn after movement.)
I have a line of sight in progress, maybe it's what you meant.[*]Cannot fire at targets if attacker does not have direct line of sight to target that is 2 hexes wide?
In the DM screen grab the northern spearman was able to throw a spear at the wolf rider which whizzed past the Mage.
Don't think this would make sense to players.[/s]
Thanks for those ideas

- Spannerbag
- Posts: 759
- Joined: December 18th, 2016, 6:14 pm
- Location: Yes
Re: Real Ranged Attacks (Modification for 1.18.x)
Yeah, just thought this alternative might be easier to implement?ZombieKnight wrote: ↑August 18th, 2024, 5:18 amThis feels very similar to previous idea:).Spannerbag wrote: ↑August 17th, 2024, 9:47 pm ...Have a flat chance to miss, e.g. ?% per extra hex up to ??% chance of missing, if attack doesn't miss resolve as normal attack (so could still miss)?
Not saying you're wrong, but I can't (from my admittedly quick scribblings) see how to get a 1-3 ratio of zone lockers vs locked?ZombieKnight wrote: ↑August 18th, 2024, 5:18 amI like this one, stronger close lock, but I fear that each skirmisher could block 1-3 archers, which would be really strong, any idea how to balance this?Spannerbag wrote: ↑August 17th, 2024, 9:47 pm ...Non-adjacent ranged attacks not allowed if unit is zone-locked at start of turn?
(No real in-game logic to this I guess, but it offers the player a tactic to neutralise enemy long range attacks.)
Not sure whether skirmishers should be affected or not as they can still move normally...
Here's a quick sketch of Skirmishers and Enemies.
I think numerically, even with a favourable start (below, the skirmisher in the middle of the highlighted area was encircled at start of skirmisher turn) each skirmisher on average can block about 2 enemy units? But I could well be wrong!
Even so, close lock permitting, zone locked units can still attack adjacent enemies with ranged attacks.

I suspect in real life situations the skirmishers will not get near a 2-1 ratio very often but yes, you make a fair point.
Will have a think when I get chance.
Well, it would only make archers slower if making long range attacks, they could still make "normal" attacks on adjacent units (subject to close lock of course).ZombieKnight wrote: ↑August 18th, 2024, 5:18 amIt makes archers slower... which I'm nit sure about those full three hexes (units with 4-5 moves would be messed) and current AI won't be aible to work with it :/. I maybe can add it for testing it out?
I can see this would be tricky, after each unit moves the "personal maximum range" for ranged attacks would have to be set based on remaining movement?
I.e unit max. range = min(modification maximum range, unit current moves) but after movement. Then there's "undo"...
No worries, if it doesn't work, it doesn't work.

Probably: it seemed the spearman attack "swerved" round the friendly unit (Mage), but that could be a manifestation of the hex layout.ZombieKnight wrote: ↑August 18th, 2024, 5:18 amI have a line of sight in progress, maybe it's what you meant.Spannerbag wrote: ↑August 17th, 2024, 9:47 pm ...Cannot fire at targets if attacker does not have direct line of sight to target that is 2 hexes wide?
In the DM screen grab the northern spearman was able to throw a spear at the wolf rider which whizzed past the Mage.
Don't think this would make sense to players.
I was paying more attention to the animation issue to be fair.
It's no big deal.

Glad you found some of my "brain dump" ideas helpful.

Not had chance to consider things further (and am sadly unlikely to do so for a few days

Cheers!
-- Spannerbag
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
I'm not sure if you got me 100% right, I meant that sibgle melee skirmisher can keep blocking two enemy archers.Spannerbag wrote: ↑August 18th, 2024, 12:02 pm Not saying you're wrong, but I can't (from my admittedly quick scribblings) see how to get a 1-3 ratio of zone lockers vs locked?
Here's a quick sketch of Skirmishers and Enemies.
I think numerically, even with a favourable start (below, the skirmisher in the middle of the highlighted area was encircled at start of skirmisher turn) each skirmisher on average can block about 2 enemy units? But I could well be wrong!
Even so, close lock permitting, zone locked units can still attack adjacent enemies with ranged attacks.
I suspect in real life situations the skirmishers will not get near a 2-1 ratio very often but yes, you make a fair point.
Will have a think when I get chance.

I like it actuallyWell, it would only make archers slower if making long range attacks, they could still make "normal" attacks on adjacent units (subject to close lock of course).
I can see this would be tricky, after each unit moves the "personal maximum range" for ranged attacks would have to be set based on remaining movement?
I.e unit max. range = min(modification maximum range, unit current moves) but after movement. Then there's "undo"...
No worries, if it doesn't work, it doesn't work.![]()

But thinking about it, I would have to have a dynamic max_range, which isn't currently possible :/ (but will be if Ravanas pull request get accepted in 1.20).
For the proper animation, it would require soneone to do the animations, and mainline support would help a lot... which isn't too realistic, and it's not a highest priority now :/.Probably: it seemed the spearman attack "swerved" round the friendly unit (Mage), but that could be a manifestation of the hex layout.
I was paying more attention to the animation issue to be fair.
It's no big deal.![]()
Yeah some of you "brain dump" was rather helpful.Glad you found some of my "brain dump" ideas helpful.
Not had chance to consider things further (and am sadly unlikely to do so for a few days).
Get better, enjoy holidays or get over it soon ;-P .
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
I'm sorry, but reading it again, I'm not sure what have you meant :/.
If you could spell it out loud for me?
Re: Real Ranged Attacks (Modification for 1.18.x)
It will not be accepted unless someone tests that it works.But thinking about it, I would have to have a dynamic max_range, which isn't currently possible :/ (but will be if Ravanas pull request get accepted in 1.20).
0) ranged attacker stands outside attack range, but can see target
1) user selects ranged attacker
2) user hovers target
3) attack arrow is visible
4) user clicks, gets attack selection
5) ranged attacker moves towards target
6) as soon as target is in attack range, move is interrupted
7) if possible attack target automatically, otherwise

- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
I'm unable to do that right now, but I'm working on compiling my own Wesnoth

Thanks for the clearance0) ranged attacker stands outside attack range, but can see target
1) user selects ranged attacker
2) user hovers target
3) attack arrow is visible
4) user clicks, gets attack selection
5) ranged attacker moves towards target
6) as soon as target is in attack range, move is interrupted
7) if possible attack target automatically, otherwiseuser clicks like now

0,1,2,5,6,7 - is easy/already implemented.
3 - is impossoble without change in engine.
For the same reason there is no graphic pre-showing regular real-ranged attack.
4 - possible. Any idea how to choose the attacking hex?
I would choose the closest move-vise, or should I choose a hex based on the way mouse moved onto the enemy?
What would be better?
+ 9 make it work even when the move is interupted (by event/ambush)
The 9 will be cared about once I get the move+attack working.
Ps.: should it be

Re: Real Ranged Attacks (Modification for 1.18.x)
I was thinking of teleport for 3), but not sure if it will work.
I was thinking of closest hex. If user is not happy with closest he can move manually.
I was thinking of closest hex. If user is not happy with closest he can move manually.
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
I don't know how should that work.
Will be easiest probably.I was thinking of closest hex. If user is not happy with closest he can move manually.
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
1.1.0 is out, featuring move&attack UI.
(Due to the fact specials and abilities cannot be pre-evaluated in Lua now it can show not-true information in case of some custom abilities)
Am I missing something?
(Due to the fact specials and abilities cannot be pre-evaluated in Lua now it can show not-true information in case of some custom abilities)
Is it what you expected?Ravana wrote:
Am I missing something?
Re: Real Ranged Attacks (Modification for 1.18.x)
I tried it out, I think it should be possible to do attack move in case unit distance is movement+range. Looks like currently it tries only within movement.
- ZombieKnight
- Posts: 371
- Joined: June 27th, 2022, 2:26 pm
- Location: Czech Republic
Re: Real Ranged Attacks (Modification for 1.18.x)
Can You send the save-file?
Worked well on my testing.