Author Topic: [DONE] Melee terrain damage  (Read 7315 times)

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
[DONE] Melee terrain damage
« on: October 08, 2020, 03:55:28 pm »
Latest OXCE nightly has a feature that allows melee weapons to destroy terrain.

Can be enabled using the following ruleset:

Code: [Select]
constants:
  extendedTerrainMelee: 4    # 0 = turned off;  1 to 11 turned on (higher number means that it only applies to taller objects/walls)

Code: [Select]
  Compass directions

         W  /\  N
           /  \
           \  /
         S  \/  E

How it works:
- if there is no unit to attack, game tries to find a wall or an object to attack (floors cannot be attacked)
- only N/W/S/E attack directions are supported; diagonal NW/SW/NE/SE directions are not supported
- only 1x1 units can perform such attack, 2x2 units are not supported 2x2 units are also supported since OXCE v6.8.3
- only the player can use it, AI is not capable of using it
- the game first tries to find a wall, if not found then tries to find an object:
1. North direction: first North wall on the same tile, then object on next tile
2. East direction: first West wall of next tile, then object on next tile
3. South direction: first North wall of the next tile, then object on the next tile
4. West direction: first West wall on the same tile, then object on the next tile
- walls that don't block movement (e.g. rubble walls) are ignored... with the exception of doors and UFO doors
- objects and walls that are not tall enough are ignored... minimum height is defined using `extendedTerrainMelee` global constant
- terrain melee never misses; and doesn't support scripting of melee accuracy
- if the attacker is on elevated terrain of height 16 voxels or more (e.g. upper part of stairs), the attack is performed as if the attacker was one tile higher
- damage to terrain is calculated using standard terrain damage formulas, see: `TileDamageMethod`, `ToTile` and `RandomTile` attributes in the ruleset reference: https://www.ufopaedia.org/index.php/Ruleset_Reference_Nightly_(OpenXcom)#Item_Damage_Types
- (if you didn't know already) terrain damage is all or nothing, terrain doesn't have any HP that could be decreased by multiple attacks

EDIT:
- for melee weapons, if primary damage type has ToTile = 0.0, terrain melee is not attempted (e.g. stun rod)
- for other weapons (e.g. rifle gunbutt), if secondary (melee) damage type has ToTile == 0.0, terrain melee is not attempted

`extendedTerrainMelee` refers to 12 LOFTemps of map tile parts, see attached picture.
(btw. each LOFTemp is 2 voxels high, for a total of 24 voxels in one tile)

Constructive feedback welcome.

Tests welcome: https://lxnt.wtf/oxem/builds//Extended/Extended-6.6.3-f7a8833c6-2020-10-11-win64.7z
« Last Edit: February 01, 2023, 07:32:09 pm by Meridian »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #1 on: October 09, 2020, 03:27:05 am »
This is a welcome feature.

If possible could you make it so that there is a variable on the weapon item that allows this feature to toggle true/false for just that piece of equipment?

I would like to see X-Com soldiers digging with specialized equipment instead of just being able to use their pocket knives to tear down nearby walls.


I've been using a range 1 arcing weapon to simulate melee range for UFO hull cutting saws, your new method is much better.

- terrain melee never misses; and doesn't support scripting of melee accuracy

100% accuracy vs terrain but not units, I like that.

A mod creator could create an item that is primarily intended for destroying terrain.

But also could be used by the player in desperation against enemy units although with a low enough accuracy rate to make any normal melee weapon a better option as a damage dealer vs units.
« Last Edit: October 09, 2020, 03:50:44 am by The Martian »

Offline Yankes

  • Global Moderator
  • Commander
  • *****
  • Posts: 3350
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #2 on: October 09, 2020, 10:54:41 pm »
You can use knives to "open" doors, this is matter of damage it do to target and this is configurable today, look for `ToTile`damage property.

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #3 on: October 10, 2020, 12:16:02 am »
You can use knives to "open" doors, this is matter of damage it do to target and this is configurable today, look for `ToTile`damage property.

That is how I've currently got the hull breaching saw items I'm using setup. They're configured to high 'ToTile' and low or no 'ToHealth'.

My thought is that if some melee weapon items can be configured to be melee only you will still get the "There is no one there!" message for swords/etc if you try to swing into a wall preventing accidental TU use when not correctly aligned with a unit as target.
« Last Edit: October 10, 2020, 12:22:05 am by The Martian »

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #4 on: October 10, 2020, 12:23:38 am »
yeah, I can add a condition that ToTile must be > 0.0

otherwise don't attempt to attack terrain... we don't need stun rods prodding walls :)
« Last Edit: October 10, 2020, 12:25:13 am by Meridian »

Offline The Martian

  • Commander
  • *****
  • Posts: 754
  • "It implores you to listen to its arguments..."
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #5 on: October 10, 2020, 01:06:21 am »
yeah, I can add a condition that ToTile must be > 0.0

otherwise don't attempt to attack terrain... we don't need stun rods prodding walls :)

That sounds great.

Thank you.

thePaleone

  • Guest
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #6 on: October 10, 2020, 02:40:55 am »
If terrain damage could affect surface tiles, provide the map is purposely design or setup to have a layer of “earth” below the normal ground tiles. Perhaps melee weapons like a shovel can dig “foxholes” and “trenches” in a battlescape fire fight?

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #7 on: October 10, 2020, 08:31:09 am »
no

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #8 on: December 13, 2020, 04:57:22 pm »
2. East direction: first West wall of next tile, then object on next tile
3. South direction: first North wall of the next tile, then object on the next tile
East should first check for east wall on same tile (object, bigwall type 6).
South should first check for south wall on same tile (object, bigwall type 7).

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #9 on: December 14, 2020, 12:32:06 am »
is there any example somewhere?

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #10 on: December 14, 2020, 12:20:36 pm »
You mean an example of eastwalls and southwalls being used? Yes, on UFO walls.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #11 on: December 14, 2020, 12:35:21 pm »
You mean an example of eastwalls and southwalls being used? Yes, on UFO walls.

UFO walls are not destroyable by design, certainly not by anything sword-like.

Is there any example where it would be relevant?

Also, what about other bigwall types (see below) and other face directions (north, west)?

Code: [Select]
* 1: regular bigWall
 * 2: allows movement in ne/sw direction
 * 3: allows movement in nw/se direction
 * 4: acts as a west wall
 * 5: acts as a north wall
 * 6: acts as an east wall
 * 7: acts as a south wall
 * 8: acts as a south and east wall.
 * 9: acts as a north and west wall.

Offline The Reaver of Darkness

  • Commander
  • *****
  • Posts: 1512
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #12 on: December 17, 2020, 08:44:45 am »
Sorry for the late reply, had to collect my thoughts on this one.

It seems to be generally done on craft, whether they are player or opponent. Usually player craft are indestructible while opponent craft are destructible. I don't see that UFO walls are not destroyable by design, if anything they are designed to be difficult to destroy, in that the player is expected to find a way to do it. I'd bet one of the modders' favorite types of terrain to destroy with melee weapons will be UFO walls, if things like the fusion torch and chainsword are any indication.

North wall and west wall bigwalls don't have any excuse for existing as far as I can tell. There is effectively no difference between them except for whether they count as a wall or object, and placing tiles in the wall or object slots can be done regardless of their type setting. However it may be used for death tiles, but as far as I can tell, rarely if ever in vanilla. They might get used in mods, but if so I haven't seen it.

There is the type 8 and 9 which are used for corner pieces. Type 9 (north and west wall) is generally not used as you can simply have two separate north and west walls in the same tile. But type 8 (south and east wall) are used often for corners in which you need both to fit into the same object slot.

Bigwall type 1 is functionally the same as object for this consideration; the only difference is whether or not units can walk diagonally across its corner. Same can be said for type 2 and 3 (diagonals), as they simply allow passing across two diagonals and not the other two. I think it also affects explosion propagation. Shouldn't affect melee weapons attacking objects, they should see it as just an object tile.

Offline Meridian

  • Global Moderator
  • Commander
  • *****
  • Posts: 9091
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #13 on: January 16, 2022, 11:26:03 am »
East should first check for east wall on same tile (object, bigwall type 6).
South should first check for south wall on same tile (object, bigwall type 7).

Added.

Additionally, East checks also for bigwall type 8 (southeast)
Aditionally, South check also for bigwall type 8 (southeast)

North checks for bigwall types 5 and 9.
West checks for bigwall types 4 and 9.

Offline kevL

  • Colonel
  • ****
  • Posts: 482
  • pitchforks and torches
    • View Profile
Re: [EXPERIMENTAL] Melee terrain damage
« Reply #14 on: January 16, 2022, 01:20:15 pm »
... placing tiles in the wall or object slots can be done regardless of their type setting.

friendly reminder to modders that placing a tilepart in a slot it wasn't designed for is risky. Engine-code may ignore characteristics of a part's MCD record if it's in an improper slot (eg?). Best to design a new tilepart for the slot you want ... imo