Engine support for real ranged attacks

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
User avatar
lipk
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Engine support for real ranged attacks

Post by lipk »

Hello everyone,

After a long hiatus, I've recently started tinkering with Wesnoth again and I'm trying out a couple tweaks and additions that I think might allow for a different style of gameplay. One of these things is real ranged attacks, i.e. being able to hit enemies from multiple tiles away. Now I know this idea is on the FPI list, and I don't suggest introducing real ranged attacks to mainline Wesnoth, but I don't see why the engine itself shouldn't support it. Also, I'm not requesting anyone spend their time on this, I'm quite willing to do the work myself. In fact I already have a rudimentary implementation (actually the engine support is mostly there, I pretty much just had to enable it on the UI).

So what I'd like to do here is collect feedback and discuss some of the open questions regarding the feature so that I can polish the implementation and have it merged back and also decide what should go in the initial PR and what can be left for later.

These questions are:

Mechanics

1. Should the target unit be able to retaliate (provided it has an attack with the required range)?
2. Should there be some penalty with longer range? If yes, what?
3. Should a unit be able to attack an enemy it can't see (but another allied unit can)?
4. Should we have also support a minimum range for weapons?

Interface

5. How move-and-attack should work for ranged units? Stay the same? Offer the furthest away hex from which the target can still be hit?
6. Should we have animated projectiles flying over multiple hexes?
7. How to show attacks by an enemy you can't see?
8. Should we have a distinct attack indicator for ranged attacks?

My opinions:
1. I'm inclined towards 'yes', because that's how everything works. That, however, brings up the question if you should also be able to retaliate against units you can't see.
2. I think definitely yes, and probably the simplest way is to reduce chance to hit with distance. Not sure if it should be configurable, also not sure how it would mix with magic/marksman.
3. Yes. It's probably not 'realistic', but it's simpler implementation-wise and easier to track for the player.
4. Maybe later. I could imagine 'use cases' for this, like siege weapons and the like, but it's not essential and makes some stuff more complicated.
5. I don't know.
6. It would be nice, probably not required for the first PR.
7. I don't know.
8. Yes, but it's not a priority, can be done later.

I'd be interested to hear your thoughts on these issues or anything else that pops into your mind.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Engine support for real ranged attacks

Post by Ravana »

I created issue for that https://github.com/wesnoth/wesnoth/issues/4772

1) yes
2) not by engine itself, up to individual attacks balancing. For attacks with min_range != max_range there would need to be formula variable available containing range
3) yes
4) min_range key already exists

5) hard to say. But maybe prefer to move as little as possible
6) agreed not a priority
7) could be like in age of empires, so that if something attacks you that you cant see, it is visible during the attack
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Engine support for real ranged attacks

Post by gfgtdf »

More importantly (at least to me) how are the rules that decide which attacks are allowed? Will every ranged attack get their own Movetype? I mean clearly the rules differ depengi g of the type of the attack (a" throwing" stack can shoot over mountains/unpassable (lol) while a "Shooting straight" attack cannot)
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
fire-emblem
Posts: 23
Joined: April 16th, 2020, 5:59 am

it's about how the ideas are actually implemented/executed

Post by fire-emblem »

i dont understand the point of this, sounds like something that would more easily be done after the game moved to a different 'engine' -> viewtopic.php?f=5&t=52376

none of these questions make sense cos it's all about playtesting, none of this matters until it's actually playtested
that's the only way for anyone to know if something is good or bad (and that goes for anything)
testing
actually testing things

it's not about the ideas, it's about how the ideas are actually implemented/executed
User avatar
Kwandulin
Art Contributor
Posts: 362
Joined: March 30th, 2014, 7:35 am
Location: Germany

Re: Engine support for real ranged attacks

Post by Kwandulin »

Sounds interesting!

Mechanics
1. Should the target unit be able to retaliate (provided it has an attack with the required range)?
I feel that true ranged should be a safe way to attack, so no retaliation. We'd have to see how it turns out.

2. Should there be some penalty with longer range? If yes, what?
Ranged itself is a great advantage, because a single unit can be attacked by dozens of ranged ones. I think there should be a -10% damage malus for each tile that is between the attacker and the attacked. This way we can later have some trueshot ability which negates that damage malus (maybe for elves?)

3. Should a unit be able to attack an enemy it can't see (but another allied unit can)?
Yes

4. Should we have also support a minimum range for weapons?
Yes, because it would be a flavourful counter to have a fast moving unit to quickly get into melee range where the ranged units cant retaliate (except with their weak melee attack). I'd assume that this is less imminent.

Interface
5. How move-and-attack should work for ranged units? Stay the same? Offer the furthest away hex from which the target can still be hit?
Yes

6. Should we have animated projectiles flying over multiple hexes?
Yes

7. How to show attacks by an enemy you can't see?
Just show it

8. Should we have a distinct attack indicator for ranged attacks?
Yes, because ranged units can also have a melee attack
User avatar
lipk
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Re: Engine support for real ranged attacks

Post by lipk »

Ravana wrote:2) not by engine itself, up to individual attacks balancing. For attacks with min_range != max_range there would need to be formula variable available containing range
I'm generally a 'make everything configurable' type of person, but here I'm a bit concerned about the UI. How would you present this formula to the user? Print whatever whacky expression that's in the WML? Print the values at every distance (potentially a lot)? I think, at least for the first round, it would be better to impose a uniform mechanism, like Kwandulin's -10% per hex formula, or perhaps a limited set of options (damage_decrease_per_tile, chance_to_hit_decrease_per_tile, something like that).
Ravana wrote:min_range key already exists
Doesn't mean it needs to work ;)
gfgtdf wrote:More importantly (at least to me) how are the rules that decide which attacks are allowed? Will every ranged attack get their own Movetype? I mean clearly the rules differ depengi g of the type of the attack (a" throwing" stack can shoot over mountains/unpassable (lol) while a "Shooting straight" attack cannot)
I'd prefer not to have any line-of-sight rules in the initial implementation. First, especially with great ranges, it can often be difficult to predict whether you'll be able to hit someone from a specific location or not. And second, the actual implementation shouldn't rely on a movetype (it's not like you should be able to shoot around a mountain, right?) but line-of-sight calculation and elevation of terrain features, something that the engine has currently no concept of. So I think we should just ignore this for now and maybe come back to it later if there is demand/need.
fire-emblem wrote:i dont understand the point of this, sounds like something that would more easily be done after the game moved to a different 'engine' ->
It's not. This is not a difficult thing to implement. As I said, I have a working version already. It took about 1.5 hours.
fire-emblem wrote:none of these questions make sense cos it's all about playtesting, none of this matters until it's actually playtested
that's the only way for anyone to know if something is good or bad (and that goes for anything)
The final verdict comes from playing, obviously, but upfront discussion can reveal pitfalls and aspects that make certain ideas very costly to implement and/or unlikely to be viable in practice. The goal is not to determine how things should work in all cases and until the end of times, but rather to have a sane initial concept that we can later improve on.
Kwandulin wrote:I feel that true ranged should be a safe way to attack, so no retaliation. We'd have to see how it turns out.
The one issue I have with this is ranged attacks from adjacent tiles. There must be retaliation in this case so that it's compatible with current behavior. This would result in having retaliation in some cases only, which I think is kind of awkward, although I admit that gameplay-wise it might be ok or even a positive (you'd have a strong incentive to keep your archer guys out of melee range, lest they become a lot less efficient).
User avatar
lhybrideur
Posts: 357
Joined: July 9th, 2019, 1:46 pm

Re: Engine support for real ranged attacks

Post by lhybrideur »

My answers to these questions.

Mechanics

1. Should the target unit be able to retaliate (provided it has an attack with the required range)?
Yes, if it can (min/max range)

2. Should there be some penalty with longer range? If yes, what?
-10%/hex ?

3. Should a unit be able to attack an enemy it can't see (but another allied unit can)?
Yes with a malus (-50% ? /2 ?). Same for retaliation attack when you can't see the attacker.

4. Should we have also support a minimum range for weapons?
Why not. But something like a malus for using it point-blank seems better in my opinion. For example, define only one range and apply a -10% malus for each hex further/closer than this range. Or more complex, min and max range with the same -10% rule for both.

Interface

5. How move-and-attack should work for ranged units? Stay the same? Offer the furthest away hex from which the target can still be hit?
No problem for move-and-attack. Getting closer improve the precision but increase to chance of retaliation/being attacked during enemy turn.

6. Should we have animated projectiles flying over multiple hexes?
Yes

7. How to show attacks by an enemy you can't see?
Show only the projectile

8. Should we have a distinct attack indicator for ranged attacks?
I don't understand the question
User avatar
Elvish_Hunter
Posts: 1575
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Engine support for real ranged attacks

Post by Elvish_Hunter »

lipk wrote: April 16th, 2020, 6:44 pm Now I know this idea is on the FPI list, and I don't suggest introducing real ranged attacks to mainline Wesnoth, but I don't see why the engine itself shouldn't support it.
Actually, I can see why the engine should support it, that being UMCs. The typical example I used to bring up was the Cannon unit in Fate of a Princess, and in past there was a Ranged Era on the server, so there's definitely some audience for this.
lipk wrote: April 16th, 2020, 6:44 pm 1. Should the target unit be able to retaliate (provided it has an attack with the required range)?
Yes, it should. Clearly, not only the amount of hexes should match, but also the range: AFAIK, the engine already supports ranges other than melee and ranged, to the point that I remember someone using units with a "long range" attack.
lipk wrote: April 16th, 2020, 6:44 pm 2. Should there be some penalty with longer range? If yes, what?
It shouldn't be a penalty automatically computed by the engine, but auto-stored WML variables should offer a way to implement it for those UMC authors that wishes to do so, maybe by storing the effective hexes radius of that attack. What if I want to implement an attack which gets weaker the closer you are?
lipk wrote: April 16th, 2020, 6:44 pm 3. Should a unit be able to attack an enemy it can't see (but another allied unit can)?
Not sure about that. For the sake of keeping things simple in this first implementation, I'd say no.
lipk wrote: April 16th, 2020, 6:44 pm 4. Should we have also support a minimum range for weapons?
Yes, we should. For example, you might have a Glass Cannon unit, which is extremely powerful with its true ranged attacks, but once an enemy unit gets close it has no way to retaliate against it; to implement this, a min_range=2 line should be enough.
Image
Case in point.
lipk wrote: April 16th, 2020, 6:44 pm 5. How move-and-attack should work for ranged units? Stay the same? Offer the furthest away hex from which the target can still be hit?
For now, I'd say to leave it the same and think about that later.
lipk wrote: April 16th, 2020, 6:44 pm 6. Should we have animated projectiles flying over multiple hexes?
We should. What's the point in firing a Cannon if you can't even see its cannon ball going all the way to strike the enemy?
lipk wrote: April 16th, 2020, 6:44 pm 7. How to show attacks by an enemy you can't see?
Just play the sound and show the projectile only in those hexes where you have visibility.
lipk wrote: April 16th, 2020, 6:44 pm 8. Should we have a distinct attack indicator for ranged attacks?
I think we should, maybe by associating it with a max_range value greater than 1.
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)
User avatar
lhybrideur
Posts: 357
Joined: July 9th, 2019, 1:46 pm

Re: Engine support for real ranged attacks

Post by lhybrideur »

I was thinking of two problems we might encounter

- Range computation : I see three possibilities :
- "Flat" : each hex count as 1, whatever the terrain.
- "Movement" : hexes count proportionally to the movement cost of the unit
- "Range" : "flat" terrains (plain, water, sand, etc.) count as 1, terrains with obstacles (forest, village, mountain) count as 2 to 3 depending on the unit affinities.
Problem is 1 is unsatisfactory, whereas 2 and 3 pose problems with min_range. What if I'm adjacent to a mountain with a min_range = 2. Can I attack a unit on the mountain ?

- Size of hexes : this is more a "reality" problem. What is the size of Wesnoth's hexes ? First point, having a mountain so close to a plain and the way ranged attacks are adjacent-hex attack gives smth of the order of 1-10 km. Second point, 6mp in a turn (4h) gives something similar. This means however that to have real ranged attacks, one has to shrink down everything. You can't shoot arrows several km away. Terrains therefore must be modified. A village is no more one hex but 10x10 to 100x100 hexes big.
User avatar
lipk
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Re: Engine support for real ranged attacks

Post by lipk »

lhybrideur wrote:Why not. But something like a malus for using it point-blank seems better in my opinion. For example, define only one range and apply a -10% malus for each hex further/closer than this range. Or more complex, min and max range with the same -10% rule for both.
Elvish_Hunter wrote:It shouldn't be a penalty automatically computed by the engine, but auto-stored WML variables should offer a way to implement it for those UMC authors that wishes to do so, maybe by storing the effective hexes radius of that attack. What if I want to implement an attack which gets weaker the closer you are?
I admit, having an optimal range other than the closest possible is not something I really considered, but now I kinda agree it would be quite limiting not to allow it. And yes, that implies that we can't compute the penalty in a fully automatic fashion.
lhybrideur wrote:8. Should we have a distinct attack indicator for ranged attacks?
I don't understand the question
I'm talking about the red arrow that appears when you select an enemy unit to attack. The question is whether we should have something else for ranged attacks. Crosshairs, for example. It's a minor visual detail, probably not that important.
Elvish_Hunter wrote:Yes, it should. Clearly, not only the amount of hexes should match, but also the range: AFAIK, the engine already supports ranges other than melee and ranged, to the point that I remember someone using units with a "long range" attack.
I'm not entirely sure what is the suggestion here... you say the engine already supports arbitrary categories, so there's no work to be done there, I guess? So it reads as if you wanted to put every real ranged attack into a separate "long range" category. Which might or might not be be a good idea from a gameplay perspective, but surely it's not reasonable to enforce this on an engine level?
We should. What's the point in firing a Cannon if you can't even see its cannon ball going all the way to strike the enemy?
This question was not formulated very well :) Of course it would be nice to have this, the real question is the priority. It's likely a non-trivial task on its own, and the standard, single-hex animation works better than I've expected (I'll upload some visuals later).
lhybrideur wrote:- Range computation : I see three possibilities :
- "Flat" : each hex count as 1, whatever the terrain.
- "Movement" : hexes count proportionally to the movement cost of the unit
- "Range" : "flat" terrains (plain, water, sand, etc.) count as 1, terrains with obstacles (forest, village, mountain) count as 2 to 3 depending on the unit affinities.
Problem is 1 is unsatisfactory, whereas 2 and 3 pose problems with min_range. What if I'm adjacent to a mountain with a min_range = 2. Can I attack a unit on the mountain ?
Please see my answer to gfgtdf above. While I think this is a valid question, I feel rather strongly that initially we should just go "flat", as you put it, and revisit this problem later if the need arises.
- Size of hexes : this is more a "reality" problem. What is the size of Wesnoth's hexes ? First point, having a mountain so close to a plain and the way ranged attacks are adjacent-hex attack gives smth of the order of 1-10 km. Second point, 6mp in a turn (4h) gives something similar. This means however that to have real ranged attacks, one has to shrink down everything. You can't shoot arrows several km away. Terrains therefore must be modified. A village is no more one hex but 10x10 to 100x100 hexes big.
A "reality problem" is almost automatically "no problem" when talking about Wesnoth :) It's not realistic and it's supposed to be. I highly doubt shooting an arrow to three tiles away is what's going to break anyone's immersion in the game.
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Engine support for real ranged attacks

Post by Ravana »

lipk wrote: April 17th, 2020, 8:15 am I'm generally a 'make everything configurable' type of person, but here I'm a bit concerned about the UI. How would you present this formula to the user? Print whatever whacky expression that's in the WML? Print the values at every distance (potentially a lot)? I think, at least for the first round, it would be better to impose a uniform mechanism, like Kwandulin's -10% per hex formula, or perhaps a limited set of options (damage_decrease_per_tile, chance_to_hit_decrease_per_tile, something like that).
I agree with the reasoning, so keys for mechanics that game can display, and formula for other cases where author needs to explain it.
User avatar
Heindal
Posts: 1344
Joined: August 11th, 2011, 9:25 pm
Location: Germany, Karlsruhe
Contact:

Re: Engine support for real ranged attacks

Post by Heindal »

1. Yes!
2. Yes, decrease hitchance, obviously.

This could lead to some nice strategic question, such as - will i move a little closer and expose my unit, but get a higher chance to hit?

3. No, not by default.
4. No, when the increased range decreases hitchance. I can than decide to move into the melee zone to get a better shot, but risk my unit.

5. You could add an item in the helpmenu. So right click on the unit and than the attack is ranged. Outside of the specific range, this option will not be shown, showing the effective range. (my, what an idea ... if have to change some of my campaigns now :oops:)
6. No. Just show the attack animation and than do the damage. Probably cause my way to do this with dummy units is kind of cheesy.
+ With a lot of ranged units it also becomes more time consuming.
7. A projectile from above, such as an arrow or another specific animation.
8. What`s that? :D
The future belongs to those, who believe in the beauty of their dreams.
Developer of: Trapped, Five Fates, Strange Legacy, Epical, UR Epic Era
Dungeonmasters of Wesnoth, Wild Peasants vs Devouring Corpses, Dwarf Dwarfson Dwarvenminer
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

Re: Engine support for real ranged attacks

Post by gfgtdf »

lipk wrote: April 16th, 2020, 6:44 pm 1. Should the target unit be able to retaliate (provided it has an attack with the required range)?
By default yes, i dont see a reaon why not.
lipk wrote: April 16th, 2020, 6:44 pm 2. Should there be some penalty with longer range? If yes, what?
No, least not in the engine. With the current code it is already easy to make a chance_to_hit weapon special that decreases it for example by 10%, for each tile of distance, You can make a mainline chane_to_hit weapson special that you add to every mainline ranges weapon if you want. So no changes or new attributes are needed here.
lipk wrote: April 16th, 2020, 6:44 pm 3. Should a unit be able to attack an enemy it can't see (but another allied unit can)?
I'd go for yes here,
lipk wrote: April 16th, 2020, 6:44 pm 4. Should we have also support a minimum range for weapons?
Yes it already exists as some people said
lipk wrote: April 16th, 2020, 6:44 pm 5. How move-and-attack should work for ranged units? Stay the same? Offer the furthest away hex from which the target can still be hit?
nearest hex to the attackers current position woudl make the most sense.
lipk wrote: April 16th, 2020, 6:44 pm 6. Should we have animated projectiles flying over multiple hexes?
Yes definiteley.

lipk wrote: April 16th, 2020, 6:44 pm How would you present this formula to the user?
The same way as its currently done: just show the describtive wepons specials text
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
lhybrideur
Posts: 357
Joined: July 9th, 2019, 1:46 pm

Re: Engine support for real ranged attacks

Post by lhybrideur »

lipk wrote: April 17th, 2020, 1:22 pm
lhybrideur wrote:- Range computation : I see three possibilities :
- "Flat" : each hex count as 1, whatever the terrain.
- "Movement" : hexes count proportionally to the movement cost of the unit
- "Range" : "flat" terrains (plain, water, sand, etc.) count as 1, terrains with obstacles (forest, village, mountain) count as 2 to 3 depending on the unit affinities.
Problem is 1 is unsatisfactory, whereas 2 and 3 pose problems with min_range. What if I'm adjacent to a mountain with a min_range = 2. Can I attack a unit on the mountain ?
Please see my answer to gfgtdf above. While I think this is a valid question, I feel rather strongly that initially we should just go "flat", as you put it, and revisit this problem later if the need arises.
I'm totally in favor of flat too, because KISS. As you wrote further down, we don't need to care about realism.
Heindal wrote: April 17th, 2020, 4:17 pm 7. A projectile from above, such as an arrow or another specific animation.
This is a really good idea
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: Engine support for real ranged attacks

Post by MoonyDragon »

lipk wrote: April 16th, 2020, 6:44 pm Mechanics

1. Should the target unit be able to retaliate (provided it has an attack with the required range)?
2. Should there be some penalty with longer range? If yes, what?
3. Should a unit be able to attack an enemy it can't see (but another allied unit can)?
4. Should we have also support a minimum range for weapons?

Interface

5. How move-and-attack should work for ranged units? Stay the same? Offer the furthest away hex from which the target can still be hit?
6. Should we have animated projectiles flying over multiple hexes?
7. How to show attacks by an enemy you can't see?
8. Should we have a distinct attack indicator for ranged attacks?
1. Yes.
2. Either -X% CTH per hex or -X% DMG per hex.
3. Yes. By attacking, the attacker will reveal himself (shroud+fog), allowing for retaliation from the defender.
4. No. This way, a "longshot" unit can have the choice between safety and higher CTH / DMG. This way, one can even make "longshot" a weapon special for ranged attacks, which changes nothing if the attacker is next to the defender, but does add the possibility to attack from longer range at the penalty described above.

5. If the "longshot" attack is chosen, march to the hex where you can deal the most "longshot" damage to the defender.
6. Yes.
7. see answer 3. above
8. Yes and No. In addition to the darkened tiles that show movement limits, one can add a lighter darkening that shows the attack radius of the "longshot" attack. If an enemy is within this radius, the "longshot" unit can attack directly from where it stands, via the currently used attack indicator / process.
Default L0 Era - Level 1 leaders with level 0 recruits!
Post Reply