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
Elvish_Hunter
Forum Moderator
Posts: 1444
Joined: September 4th, 2009, 2:39 pm
Location: Lintanir Forest...

Re: Engine support for real ranged attacks

Post by Elvish_Hunter »

lipk wrote: April 17th, 2020, 1:22 pm
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?
Not quite :) What I'm saying is just that the engine should pay attention that both the range (as in melee/ranged/whatever) and the hexes (as in min_range and max_range) match to allow retaliating. BTW, from a quick grep in the source code it seems like there isn't anything really enforcing melee and ranged to be the only two allowed ranges: there's some AI code that checks for these two ranges, but there's nothing that will throw an error if an attack has a "bacon" range. :P In fact, I just tested and the game reports it in the attack dialog as "- UNTLB range_bacon -".
Besides, I'm kind of expecting UMC authors to do all sorts of crazy things when this is enabled: for example, how should a melee attack behave with max_range greater than 1? Ignore that value? Do some sort of splash damage? What else?
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
User avatar
Ravana
Forum Moderator
Posts: 2456
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Engine support for real ranged attacks

Post by Ravana »

You should register names for new ranges and types https://github.com/ProditorMagnus/Agele ... in.cfg#L12

And engine should not care whether range is called melee or something else, if it has max_range then it can be used from distance.
User avatar
Pentarctagon
Project Manager
Posts: 4532
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: Engine support for real ranged attacks

Post by Pentarctagon »

*loads throwing axes into a catapult*
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
lipk
Developer
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Re: Engine support for real ranged attacks

Post by lipk »

Elvish_Hunter wrote:Not quite :) What I'm saying is just that the engine should pay attention that both the range (as in melee/ranged/whatever) and the hexes (as in min_range and max_range) match to allow retaliating.
Ah, okay. Well, this is how things already are and I wasn't going to change that - ranged goes to ranged and bacon goes to bacon.
Elvish_Hunter wrote:Besides, I'm kind of expecting UMC authors to do all sorts of crazy things when this is enabled: for example, how should a melee attack behave with max_range greater than 1? Ignore that value? Do some sort of splash damage? What else?
I'm with Ravana on this one, a ranged melee attack sounds kind of silly, but we don't really have a reason to explicitly disallow it.

Update
PR is ready: https://github.com/wesnoth/wesnoth/pull/4859
User avatar
Celtic_Minstrel
Developer
Posts: 1689
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: Engine support for real ranged attacks

Post by Celtic_Minstrel »

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)?
lipk wrote: April 16th, 2020, 6:44 pm 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.
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)?
lipk wrote: April 16th, 2020, 6:44 pm 3. Yes. It's probably not 'realistic', but it's simpler implementation-wise and easier to track for the player.
I would say yes, the target unit should be able to retaliate if they have an attack with the required range. Regarding units you can't see (both in retaliation and initiation)… I'm leaning towards yes. To attack with a catapult for example, you just need to know where your target is. You don't necessarily need a direct line-of-sight to them. On the other hand, for some units (eg a ballista) it might make more sense to require sight, so we could consider adding this as an option in the attack.
lipk wrote: April 16th, 2020, 6:44 pm 2. Should there be some penalty with longer range? If yes, what?
4. Should we have also support a minimum range for weapons?
To both of these I would say yes, of course.
lipk wrote: April 16th, 2020, 6:44 pm 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.
Maybe the range penalty to hit chance would be applied after all other penalties? So for magical attacks, the chance could still be reduced. I'm not sure though, this is just a random thought.
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?
I'd say, if you want to attack from a specific hex, you should move and attack separately. If you try to attack a target that is not in range (either further than the max range or closer than the min range), the unit should move to the nearest hex that puts it within range, then attack.
lipk wrote: April 16th, 2020, 6:44 pm 6. Should we have animated projectiles flying over multiple hexes?
Yes. We can do without it, but ideally we should have it.
lipk wrote: April 16th, 2020, 6:44 pm 7. How to show attacks by an enemy you can't see?
Perhaps play all animations like normal, but masked out by the fog? So you can then see an arrow or whatever flying out of the fog and hitting your unit, and if your unit is also ranged, you can see it firing back into the fog.
lipk wrote: April 16th, 2020, 6:44 pm 8. Should we have a distinct attack indicator for ranged attacks?
I'm not quite sure what you mean by this.
lipk wrote: April 17th, 2020, 1:22 pm 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.
Oh, in that case, yes we should have it.
gfgtdf wrote: April 16th, 2020, 11:47 pm 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)
This is an interesting idea, making the attack depend on the hexes it passes over… but it might be too overly complex…
Kwandulin wrote: April 17th, 2020, 5:56 am I feel that true ranged should be a safe way to attack, so no retaliation. We'd have to see how it turns out.
It's safe enough - just don't attack a catapult with your catapult and you won't receive retaliation. ;)

Elvish_Hunter wrote: April 17th, 2020, 8:43 am
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.
I have a feeling the "keeping things simple" answer here is actually "yes"…
Elvish_Hunter wrote: April 17th, 2020, 8:43 am I think we should, maybe by associating it with a max_range value greater than 1.
If either min_range or max_range is specified, it should be considered a ranged attack. Specifying min without max is the same as setting them to the same value… which also gives me another idea, should we support attacks with an unlimited max range?
lipk wrote: April 17th, 2020, 1:22 pm 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?
I think all he means is that if you have two attacks with max_range=5 but one has range=ranged and the other has range=spiritual, and one attacks the other, there's no chance of retaliation. Which probably isn't any extra work since the engine already supports this.
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).
The sidebar should probably update the hit chance while the unit is selected, based on the hovered hex. I'm not sure what it should show if you have no unit selected and hover over the ranged unit, though.
Elvish_Hunter wrote: April 18th, 2020, 9:05 pm BTW, from a quick grep in the source code it seems like there isn't anything really enforcing melee and ranged to be the only two allowed ranges: there's some AI code that checks for these two ranges, but there's nothing that will throw an error if an attack has a "bacon" range. :P In fact, I just tested and the game reports it in the attack dialog as "- UNTLB range_bacon -".
The wiki also says this is supported, and you can add a key to the [language] tag that makes it show up better in the attack dialog.
lipk wrote: April 19th, 2020, 8:26 am I'm with Ravana on this one, a ranged melee attack sounds kind of silly, but we don't really have a reason to explicitly disallow it.
I think it could make sense actually - a polearm or whip type of weapon with a max_range of 2 seems perfectly reasonable to me.
Author of The Black Cross of Aleron campaign and Default++ era.
Maintainer of Steelhive.
User avatar
Iris
Site Administrator
Posts: 6724
Joined: November 14th, 2006, 5:54 pm
Location: Chile
Contact:

Re: Engine support for real ranged attacks

Post by Iris »

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. This should be consistent with all other attacks in Wesnoth.
lipk wrote: April 16th, 2020, 6:44 pm 2. Should there be some penalty with longer range? If yes, what?
And like the above, for consistency there shouldn't be a default penalty. Noting that weapon specials (charge, etc.) and WML/Lua can still impose their own penalties if so desired by the author.
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 feel that the effective attack range should be a function of the unit's movement/vision range much like in Civ 5 (where there's a separate upgrade that allows ranged units to ignore terrain costs when attacking). But this is a very subjective question right now.
lipk wrote: April 16th, 2020, 6:44 pm 4. Should we have also support a minimum range for weapons?
Yes.
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?
See 8 below.
lipk wrote: April 16th, 2020, 6:44 pm 6. Should we have animated projectiles flying over multiple hexes?
Ideally yes, but if you somehow get past the massive hurdle of dealing with our animation engine's limitations then you're basically allowed to do whatever you want anyway. IIRC (from toying around with animations for IftU and AtS) frames are assumed to not get too far away from their parent unit's location and render invalidation issues start to crop up past a certain distance. In the best case I could be misremembering or the issue has been fixed since then.
lipk wrote: April 16th, 2020, 6:44 pm 7. How to show attacks by an enemy you can't see?
I feel that the fair thing to do in this particular case is to unfog/unshroud the attacker's location. In the case of fog of war, it should remain unfogged for a single turn at least (unless the remote target attacks again, of course).
lipk wrote: April 16th, 2020, 6:44 pm 8. Should we have a distinct attack indicator for ranged attacks?
This and 5 are almost the same question, really.

If the attacker is not within range of its target yet but can see it, then there probably should be a marker along the shortest path that indicates what the closest position that enables the attacker to fire at its target from a distance is.

How this interacts with the Attack Unit dialog is another matter entirely. Right now, attempting to attack a unit from outside of the attack range (which is to say, any non-adjacent tile) brings up AU first if there's a valid path to the target, and only after the attack is confirmed the movement happens — but the attack may still be cancelled if a new obstacle comes up along the way because of abilities or WML events.

Now, if the unit had the ability to choose between 2 adjacent-tile attacks and 2 remote attacks, then representing that and the implications for the unit's movement path in the Attack Unit UI might prove rather tricky, unless you opted to make it so the unit always moves to an adjacent tile when trying to attack from a distance... which would make it harder to discover and use remote attacks effectively without some additional hand-holding from the scenario author, which isn't ideal.

As a side-note, shouldn't we already have the means to assign weapon specials that forcefully disable retaliation from units with identical attack range in the event that breaking another core game rule is desired?
Author of the unofficial UtBS sequels Invasion from the Unknown and After the Storm (now available for Wesnoth 1.14.x and 1.15.4+).
User avatar
lipk
Developer
Posts: 637
Joined: July 18th, 2011, 1:42 pm

Re: Engine support for real ranged attacks

Post by lipk »

CelticMinstrel wrote:I have a feeling the "keeping things simple" answer here is actually "yes"…
And you're correct.
CelticMinstrel wrote:If either min_range or max_range is specified, it should be considered a ranged attack. Specifying min without max is the same as setting them to the same value… which also gives me another idea, should we support attacks with an unlimited max range?
I don't think a dedicated infinity makes sense; you can just write a crazy big number and have the same effect.
CelticMinstrel wrote:The sidebar should probably update the hit chance while the unit is selected, based on the hovered hex. I'm not sure what it should show if you have no unit selected and hover over the ranged unit, though.
Good idea. The hit chance is displayed for the target unit, so no problem there - just show the base defense, like it happens now.
Iris wrote:Ideally yes, but if you somehow get past the massive hurdle of dealing with our animation engine's limitations then you're basically allowed to do whatever you want anyway. IIRC (from toying around with animations for IftU and AtS) frames are assumed to not get too far away from their parent unit's location and render invalidation issues start to crop up past a certain distance. In the best case I could be misremembering or the issue has been fixed since then.
Well that's encouraging! :D I'll have a go at it anyway, let's hope you're wrong.

As to question 5, it turns out there's something else to consider: the attack direction is chosen according to the previous hex the mouse hovered over. So the key factor is not the shortest route to the target, but the way you moved the cursor (this is probably trivial, but I didn't remember it). If we want to preserve this behaviour for ranged attacks, we'll need to keep a longer history of the cursor's movement, which opens up a whole different can of worms... so for now I'd prefer to keep things as they are: move-and-attack always moves into melee range, if you want ranged, you move into position first, then fire with a separate action. Later, we can rework this to move to the first tile along the cursor's path from where the target can be hit or something like that, but I feel that my efforts are better spent on other things right now.

I also created a project board for this, well, project: https://github.com/orgs/wesnoth/projects/1
You can track the progress there (and grab something from the TODO column, if you want to help out).
name
Posts: 423
Joined: January 6th, 2008, 3:32 am

Re: Engine support for real ranged attacks

Post by name »

Thanks for taking this task on, lipk. This has to be the most desirable game play feature that still lacks engine support. So much interesting strategy and even map design is only possible with true ranged attacks.
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)?
Probably.
lipk wrote: April 16th, 2020, 6:44 pm 2. Should there be some penalty with longer range? If yes, what?
An accuracy decrease of 10% per each tile of distance between the shooter and the target. Same for marksman and magic.

It would be good if the accuracy falloff rate was configurable but this is not necessary.
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)?
Yes.
lipk wrote: April 16th, 2020, 6:44 pm 4. Should we have also support a minimum range for weapons?
That would be a bonus. Not necessary though.
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?
Shoot from where you are if in range, otherwise get only close enough to shoot, then shoot. For higher accuracy, the player can explicitly position the unit closer to the target, if desired.
lipk wrote: April 16th, 2020, 6:44 pm 6. Should we have animated projectiles flying over multiple hexes?
It is not needed, but definitely nice to have eventually.
lipk wrote: April 16th, 2020, 6:44 pm 7. How to show attacks by an enemy you can't see?
Reveal only the shooting unit and the tile it sits on. Next turn, the fog grows back but the shroud stays revealed.

Otherwise, the shooting unit alone could be visible, but not the terrain below it.

It depends on which is easier for you to implement.
shevegen
Posts: 293
Joined: June 3rd, 2004, 4:35 pm

Re: Engine support for real ranged attacks

Post by shevegen »

Too many comments here, so I will not go into the replies, but instead focus just on a FEW points mentioned by the threadstarter, sorry.

These are just my opinions.

> 1. Should the target unit be able to retaliate (provided it has an attack with the required range)?

In principle yes. I would, however had, not allow 100% retaliation in general. Perhaps add a weaker
counter-strike, fewer attacks, lower damage etc...

Dunno if the wesnoth team wants to add fatigue, but I find it awkward if an archer unit can
retaliate against 6 enemies in the same round without a problem.

But in general, I am in favour of the POSSIBILITY to retaliation, be it a regular thing, or a
special ability by some archer units, such as marksman or similar.

> 2. Should there be some penalty with longer range? If yes, what?

Yes in general.

Perhaps only to some units, such as longbows or ballistas or "siege" type weapons like
catapults. I would assume these to be fairly slow attacks, so perhaps model it a bit
like the dwarven rifleman or whatever the name was; they had just one powerful
attack type. But I think the exact numbers are just specifics that people can think
about, my answer is more on the general principle, so yes to it.

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

Blind shooting should ALWAYS be possible. But I would make it based on random,
perhaps also reduce the damage too.

> 4. Should we have also support a minimum range for weapons?

Not sure. Perhaps in in-door rooms if a sword guy runs to an archer, who then
can not easily shoot, even less so 5 times in a row. But in outdoor rooms, I think
this is making things too complicated. By the way, perhaps implement first the
points that are less problematic, and implement those that are more problematic
at a later point.

> 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?

Just keep it simple. Ideally the way how it is. ;)

I think moving, then shooting, should be fine. You could also perhaps shoot
first, and then move away, simulating shooting at enemies while fleeing.
That should trigger some retaliation possibility at the least for other enemy
archers though.

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

That's fine. But this is mostly a detail IMO, would be more important to
first agree on the proposed feature/suggestion, before going about
details like that.

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

Just allow targeting any hex that can be hit, perhaps in another colour,
perhaps while hitting another key on the keyboard or something like
that.

By the way the old "battle isle", if anyone remembers that, allowed
for some artillery units to shoot at targets (though there were no hidden
units if I remember).

> 8. Should we have a distinct attack indicator for ranged attacks?

Perhaps just use more distinct icons, and slightly different colours or
so. Perhaps a small icon below the target, like showing an arrow
or a bolt or so. But I think the UI things are detail, the more important
part is the functionality (yes/no) first.
Shiki
Developer
Posts: 309
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Engine support for real ranged attacks

Post by Shiki »

Pentarctagon wrote: *loads throwing axes into a catapult*
lipk wrote: […] a ranged melee attack sounds kind of silly, but we don't really have a reason to explicitly disallow it.
… like a Falcon?

I know you intended this as a joke, but actually … I see a use case in mainline for it. :eng:

There's a new unit unit in 1.15, the Dune Falconer. It's an optional L2 advancement, the falcon is one of it's attacks.
It got a new ability in regards to the falcon, though it was more about having something special on that unit, than the ability itself.

I could equally well imagine to use a real ranged attack for the falcon attack.
Try out the dark board theme.
User avatar
Hejnewar
Posts: 132
Joined: September 17th, 2016, 11:01 am

Re: Engine support for real ranged attacks

Post by Hejnewar »

Pentarctagon wrote: *loads throwing axes into a catapult*
*loads goblins into a catapult*
Shiki wrote: June 11th, 2020, 7:51 pm … like a Falcon?

I know you intended this as a joke, but actually … I see a use case in mainline for it. :eng:

There's a new unit unit in 1.15, the Dune Falconer. It's an optional L2 advancement, the falcon is one of it's attacks.
It got a new ability in regards to the falcon, though it was more about having something special on that unit, than the ability itself.

I could equally well imagine to use a real ranged attack for the falcon attack.
As much as I like this idea it still has some issues.
Most of this community would like it, but some people for sure would say that its game breaking and doesn't fit wesnoth. When it comes to "game breaking" I think that it's perfectly doable in a way that will be balanced (not by itself tho, attack like that absolutely shouldn't give unit any xp so new weapon special will be needed), but does it fit? As i said I like it, I also think that new features like this one should be showcased in game in some way, but convincing others could be problematic.

Finally biggest issue is when and if this pr will be finished. I hope it will be.
Post Reply