Hitboxes for short weapons

Everything about development and the OpenMW source code.
Post Reply
User avatar
akortunov
Posts: 279
Joined: 13 Mar 2017, 13:49
Location: Samara, Russian Federation
Github profile: https://github.com/akortunov

Hitboxes for short weapons

Post by akortunov » 09 May 2018, 10:27

Currently, OpenMW has issues with Morrowind Rebirth and some other mods which use MCP feature to make weapons with Reach < 1.0 (2 yards with fCombatDistance = 128).
Some testing shows that with MCP both NPC's and player can use weapons with Reach near 0.25 (0.5 yard) without problems, in OpenMW both player and NPC's can not hit small or flying creatures.

Some observations about vanilla game behaviour:
1. Looks like Morrowind uses a center of attacker's collision box height as origin of hitbox.
OpenMW uses the 0.75 of of attacker's collision box height as origin of hitbox, what can lead to problems with small creatures.
2. Hitbox is a cone, Morrowind determines an intersection plane between hitbox and target's collision box and spawns blood particles in a random point on this plane.
OpenMW spawns blood particles somewhere on the cone basement, inside target collision box, what is a quite weird.
3. For player OpenMW uses a head position as origin of hitbox (near top of collision box), but looks like Morrowind does not treat player differently from other actors.
Even more, for NPC's OpenMW adds a half extents of attacker to distance (use the front of attacker's collision box), but does not add it for player, so player has shorter attack range than NPC's.
4. Looks like vanilla game uses hitboxes for touch spells instead of simple raycasting (bug #3374).
5. Vanilla game treats flying actors differently (some observations are here).

What we can do:
1. Use the half of attacker's height as an origin of hitbox. Fixes short weapons for NPC's.
2. We can use the raycast first and cone as fallback. This approach should fix blood particles.
3. For player we should add half extents for distance too. If we did not hit anything, we can try to do not treat player differently from other actors. This approach allows player to hit small creatures with short weapons.
4. For touch spells use focused object for player (if available), use cone-shape hitboxes for actors in other cases.

The code is here.

I do not know what to do with flying actors (5), so any suggestions would be welcome.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests