Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Weapon types de-hardcoding #2134

Closed
wants to merge 7 commits into from

Conversation

@akortunov
Copy link
Collaborator

akortunov commented Jan 19, 2019

Changes custom bones loading, so requires new skeleton meshes for weapon sheathing: Sheath.zip

Summary of changes:

  1. Moves most of weapontype-related logic from a lot of switches and if-s to the table.
    In theory, later we can move this table to ESM or some kind of logic. This approach will allow modders to add new weapon types with new animations (one-handed spears or magic sword which requires Destruction skill instead of Long Blades, for example) or modify existing ones (move bow to the left hand or add a separate set of animations for short blades, for example).

  2. Changes custom bones loading.
    Instead of hardcoded xbase_anim_sh.nif OpenMW will scan nifs in the Animation folder and will load any node marked with "BONE" NiStringExtraData. Optimizer will not remove such nodes.
    This approach allows to tweak new nodes differently for females, beast races, etc.
    Here I just rotated sheathing bone for beast races only (left - old behaviour, right - new behaviour):
    screenshot_20190119_171304

Related forum topic.

@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Jan 19, 2019

And if anyone is interested, here is the prototype of bow in the left hand: Left.zip

openmw.cfg:

weapon-type=9;Bow;2b;bowandarrow;Item Weapon Bow;Weapon Bone Left;Bip01 MarksmanBow;23;1;12;1

settings.cfg:

[Game]
use additional anim sources = true

Basically, ZIP-archive contains new animations for bows and meshes with the "Weapon Bone Left" bone.
screenshot_20190119_175739
screenshot_20190119_175747

@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 33761cf to 82f36fe Jan 20, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 82f36fe to 227a3da Feb 3, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 227a3da to 721b846 Feb 11, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 721b846 to b1d2470 Mar 10, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from b1d2470 to 876fed2 Mar 12, 2019
@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Mar 12, 2019

The main questions here:

  1. Should we de-hardcode the table?
  2. If yes, should we strictly change the ESM format, of we can just add settings to the openmw.cfg?
  3. Can we add an ability to define custom weapon types?
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 876fed2 to 2570f90 Mar 12, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 2570f90 to 4e1ec87 Mar 26, 2019
@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Mar 26, 2019

OK, I allow to override data via openmw.cfg now. An example for left-handed bow:

weapon-type=9;Bow;2b;bowandarrow;Item Weapon Bow;Weapon Bone Left;Bip01 MarksmanBow;23;1;12;1

No editor support yet, but in theory it is possible to create new weapon records via Enchanted Editor since it just uses an integer field for weapon types.

@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from 4e1ec87 to c7ee6fc Apr 8, 2019
@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Apr 8, 2019

Added basic weapon types support for the editor.

@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Apr 9, 2019

All right, time for review and testing, especially for new weapon types.

As about code, I do not like much the weapon types enum with negative values, also a configuration in the openmw.cfg is not very user-friendly. Any ideas how to improve them?

@akortunov akortunov changed the title [Testing needed] Weapon types refactoring [Testing needed] Weapon types de-hardcoding Apr 9, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from c7ee6fc to c15833f Apr 9, 2019
@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Apr 10, 2019

Also if we are going to move these settings to ESM files later, I can try to setup a virtual ESM::Store for weapon types, but it will not work for editor, where we setup UI widgets only once (IIRC, even before we read data from ESM).

@akortunov akortunov changed the title [Testing needed] Weapon types de-hardcoding Weapon types de-hardcoding Apr 27, 2019
@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from aedb409 to ccaa4fd May 11, 2019
apps/openmw/mwworld/inventorystore.cpp Outdated Show resolved Hide resolved
apps/openmw/mwrender/animation.cpp Outdated Show resolved Hide resolved
apps/openmw/mwmechanics/character.cpp Outdated Show resolved Hide resolved
@@ -223,6 +228,10 @@ bool parseOptions (int argc, char** argv, OMW::Engine& engine, Files::Configurat
if (!variables["skip-menu"].as<bool>() && variables["new-game"].as<bool>())
Log(Debug::Warning) << "Warning: new-game used without skip-menu -> ignoring it";

const std::vector<std::string>& weaponTypes = variables["weapon-type"].as<Files::EscapeStringVector>().toStdStringVector();

This comment has been minimized.

Copy link
@Capostrophic

Capostrophic May 11, 2019

Collaborator

Nobody is really sure if overriding weapon types via configs is the right way to dehardcode them. Before any abrupt decisions are acknowledged in the codebase and it doesn't take too much effort not to have this, I'd reconsider having a stopgap solution this intrusive.

@akortunov akortunov force-pushed the akortunov:weapon_refactoring branch from ccaa4fd to 4f22c0e May 11, 2019
@akortunov

This comment has been minimized.

Copy link
Collaborator Author

akortunov commented Jun 6, 2019

Replaced by #2413.

@akortunov akortunov closed this Jun 6, 2019
@akortunov akortunov deleted the akortunov:weapon_refactoring branch Oct 30, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.