aliens

Author Topic: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?  (Read 11576 times)

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
if you try to create a close-combat weapon by taking a ranged weapon using maxRange=1, you get a very weird attack pattern where you can't attack diagonally, even though those tiles should be considered "directly adjacent".

Code: [Select]
.....
..X..
.XSX.
..X..
.....

S = Soldier
X = can be attacked
. = can not be attacked

I think it would make sense to allow attacking those adjacent tiles. Maybe add an option that allows "maxRange=1.5", creating this attack pattern (which would be similar to true melee weapons):

Code: [Select]
.....
.XXX.
.XSX.
.XXX.
.....

S = Soldier
X = can be attacked
. = can not be attacked

niculinux

  • Guest
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #1 on: August 22, 2015, 09:43:16 pm »
+1 but low priority :) i think

Offline kikimoristan

  • Commander
  • *****
  • Posts: 647
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #2 on: August 23, 2015, 01:43:36 am »
it's not a bug. based on how range is calculated you're not supposed to attack diagonally with max range = 1

for grid

a1 a2 a3
b1 b2 b3
c1 c2 c3

and your guy is at a1 and is attacking c3

diagonal range is calculated like a1 a2 b2 b3 c3 NOT a1 b2 c3

range 1.5 is same thing as range 1 since the value has to be whole number


Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #3 on: August 23, 2015, 02:58:03 am »
Yes it's not a bug, but modders want the ability to define a non-integer maxRange. 1.5 is superior to √2 but inferior to 2, so it is an adequate number to describe a range of "all 8 neighboring tiles".

Offline kikimoristan

  • Commander
  • *****
  • Posts: 647
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #4 on: August 23, 2015, 07:16:08 am »
ask yankes he may include it in extended version but might not be 1.5 ..might end up being something else like squareRange=true rather than default round range

i doubt this will ever be included in openxcom as warboy and supsuper want  it to be   as close to original game as possible + UI/visual enhancements .

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
@tollworkout: of course it's not a bug. But it is a weird and artificial-feeling effect of a completely correct use of mathematics, introduced by adding a feature that never existed in the original game in the first place ;)

Offline kikimoristan

  • Commander
  • *****
  • Posts: 647
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #6 on: August 23, 2015, 10:04:59 am »
what you need is square range . not sure if that would be useful for anything other than range 1. i mean you could make it so range is square at 1 then becomes circular > 1 that way you don't need anything special.


you could do this

range 0 = default range 1 behaviour
range 1 = square range (what you want)
range 2+ = normal range behaviour

Offline Solarius Scorch

  • Global Moderator
  • Commander
  • *****
  • Posts: 11730
  • WE MUST DISSENT
    • View Profile
    • Nocturmal Productions modding studio website
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #7 on: August 23, 2015, 12:21:13 pm »
Yeah, that would fix stuff without breaking stuff. Of course only for the 1 tile distance diagonally.

Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #8 on: August 23, 2015, 12:47:00 pm »
Well to be honest... while I like things how they are now, being unable to attack diagonally is a questionable use of mathematics - √2 is ~1.4 which rounds down to 1, not 2, so a diagonal attack should be possible with range = 1. Rounding 1.4 up to 2 is not correct.

I have a feeling this problem affects all ranged weapons, the diagonal range seems to be always overcalculated. Ex. attacking 5 tiles diagonally counts as range 8, even if √50 = 7.07.

This is based, I think, on how the original game calculated blast radii, so it's "X-Com mathematics" and I can live with that.

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #9 on: August 23, 2015, 02:13:09 pm »
Quote
the diagonal range seems to be always overcalculated. Ex. attacking 5 tiles diagonally counts as range 8, even if √50 = 7.07.
I see no rounding here. maxRange 7 is too short to hit a target at 7.07, because 7.07 is strictly superior to 7.
Allowing floating numbers for maxRange would give people more choice about the edge cases, for example with maxRange=7.10 :
+7, +0 : can hit
+8, +0 : cannot hit
+5, +5 : can hit

Offline kikimoristan

  • Commander
  • *****
  • Posts: 647
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #10 on: August 23, 2015, 04:39:35 pm »
i HIGHLY doubt this will ever be part of openxcom.

this visual "error" is not really an error but is a side effect of openxcom being an abstraction of reality as chessboard tile based system with it's own set of physics. using same math yields this visual artefact inconsistent with sprite's ability to be diagonal.

here's another odd one. why can't the character attack above and below (lets say flying suit) with a melee weapon but can do so with range 1 weapon.

only solution is adaptive math that is special for range 0 and range 1 and is normal for > 1

but this may in fact open a whole new can of worms.

im okay with vanilla style

Offline Dioxine

  • Commander
  • *****
  • Posts: 5458
  • punk not dead
    • View Profile
    • Nocturnal Productions
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #11 on: August 23, 2015, 05:02:20 pm »
I see no rounding here. maxRange 7 is too short to hit a target at 7.07, because 7.07 is strictly superior to 7.
Allowing floating numbers for maxRange would give people more choice about the edge cases, for example with maxRange=7.10 :
+7, +0 : can hit
+8, +0 : cannot hit
+5, +5 : can hit

This is isn't the only true way of looking at this. The same engine works for calculating accuracy, if a weapon loses 10% acc per tile, why 7.07 distance should incur -80% accuracy? The "too short" argument doesn't work here unless we assume distance is quantative, not continuous... and allowing float for max range would only make the quantative accuracy drop problem more glaring... otoh if we assume distance is continuous, we should use mathematical rounding, in my opinion.

But this is purely academical, I see no problem with how it works now.

Offline Warboy1982

  • Administrator
  • Commander
  • *****
  • Posts: 2333
  • Developer
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #12 on: August 24, 2015, 11:52:27 am »
probably easier just to allow range: 1 to work diagonally.

Offline moriarty

  • Commander
  • *****
  • Posts: 1421
    • View Profile
    • Luke's OX mod site
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #13 on: August 25, 2015, 08:20:00 pm »
probably easier just to allow range: 1 to work diagonally.

that would be really nice. I don't see a reason not to - I just can't come up with any explanation why a weapon wouldn't work on diagonally adjacent enemies. Except maybe for large swords when the enemy is diagonally "behind" another object or wall. then again, a sword would be "melee", and that works diagonally anyway. oh well.  ::)

Offline yrizoud

  • Commander
  • *****
  • Posts: 1014
    • View Profile
Re: weapon maxRange "1" extended to diagonals / allow maxRange=1.5 ?
« Reply #14 on: August 25, 2015, 09:05:15 pm »
From memory of HeroQuest, in that game most weapons allow attack in 4 neighboring tiles, the only weapon which allows attack in diagonal (spear) has some definite advantages :
1) The wielder often requires one less step to get in melee range (only needs to reach a diagonal, no extra move to get contiguous).
2) More people can gang up on a single opponent, since spear-wielders can attack between two teammates
3) In that pattern, the spear wielder is safe from counter-attack because 2 teammates occupy his side tiles, no enemy can enter them to attack him. (Unless the enemy is using a spear too)
edit: The point is, having both ways of counting "range 1" in the same game can give rich gameplay.
« Last Edit: August 25, 2015, 09:29:31 pm by yrizoud »