Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions msu/hooks/config/items.nut
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,56 @@ foreach (itemType in ::Const.Items.ItemType)
throw ::MSU.Exception.KeyNotFound(_weaponType);
}

// Map WeaponTypes to relevant strings from weapon.m.Categories.
// Is used during automatic assignment of weapontypes to weapons.
// Translators should push strings to the relevant weaponType here.
// Key = WeaponType
// Value = array of strings from weapon.m.Categories that should match to this weapon type

// Translators Note: DO NOT OVERWRITE THIS TABLE, instead push your strings to each array e.g.
// ::Const.Items.WeaponTypesCategoriesStrings.Axe.push("TranslatedAxe");
Copy link
Contributor

@Suor Suor May 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This example won't work because key is not "Axe" here. Probably should be still Axe for consistency.

Also if ::Const.Items.WeaponTypeName is translated above then pushing is not needed for the most part.

::Const.Items.WeaponTypeCategoriesStrings <- {
[::Const.Items.WeaponType.None] = ["None", "No Weapon Type"]
[::Const.Items.WeaponType.Axe] = ["Axe"],
[::Const.Items.WeaponType.Bow] = ["Bow"],
[::Const.Items.WeaponType.Cleaver] = ["Cleaver"],
[::Const.Items.WeaponType.Crossbow] = ["Crossbow"],
[::Const.Items.WeaponType.Dagger] = ["Dagger"],
[::Const.Items.WeaponType.Firearm] = ["Firearm"],
[::Const.Items.WeaponType.Flail] = ["Flail"],
[::Const.Items.WeaponType.Hammer] = ["Hammer"],
[::Const.Items.WeaponType.Mace] = ["Mace"],
[::Const.Items.WeaponType.Polearm] = ["Polearm"],
[::Const.Items.WeaponType.Sling] = ["Sling"],
[::Const.Items.WeaponType.Spear] = ["Spear"],
[::Const.Items.WeaponType.Sword] = ["Sword"],
[::Const.Items.WeaponType.Staff] = ["Staff"],
[::Const.Items.WeaponType.Throwing] = ["Throwing", "Throwing Weapon"],
[::Const.Items.WeaponType.Musical] = ["Musical", "Musical Instrument"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These "Throwing Weapon" and "Musical Instrument" entries are in fact noop. Make things a little bit slower.

};
local arr = ::Const.Items.WeaponTypeCategoriesStrings;
foreach (k, w in ::Const.Items.WeaponType)
{
if (arr.find(k) == null)
arr.push(k);

local name = ::Const.Items.getWeaponTypeName(w);
if (arr.find(name) == null)
arr.push(name)
}

// Map OneHanded and TwoHanded to relevant strings from weapon.m.Categories
// Is used during weapon.buildCategoriesFromWeaponType.
// Translators should push strings to the relevant handed-ness here.
// The last index string is always used to build the categories string.

// Translators Note: DO NOT OVERWRITE THIS TABLE, instead push your strings to each array e.g.
// ::Const.Items.WeaponHandedCategoriesStrings.OneHanded.push("One-HandedTranslation");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, the guys translating mod itself not Rosetta like can just add , "..." to arrays below

::Const.Items.WeaponHandedCategoriesStrings <- {
OneHanded = ["One-Handed"],
TwoHanded = ["Two-Handed"]
};

::Const.Items.addNewWeaponType <- function( _weaponType, _weaponTypeName = "" )
{
if (_weaponType in ::Const.Items.WeaponType) throw ::MSU.Exception.DuplicateKey(_weaponType);
Expand All @@ -127,5 +177,6 @@ foreach (itemType in ::Const.Items.ItemType)
_weaponTypeName = _weaponType;
}

::Const.Items.WeaponTypeCategoriesStrings[::Const.Items.WeaponType[_weaponType]] <- [_weaponTypeName];
::Const.Items.WeaponTypeName.push(_weaponTypeName);
}
40 changes: 27 additions & 13 deletions msu/hooks/items/weapons/weapon.nut
Original file line number Diff line number Diff line change
Expand Up @@ -54,29 +54,41 @@
return;
}

foreach (k, w in ::Const.Items.WeaponType)
foreach (weaponType, strings in ::Const.Items.WeaponTypeCategoriesStrings)
{
if (categories.find(k) != null)
foreach (str in strings)
{
this.m.WeaponType = this.m.WeaponType | w;
if (categories.find(str) != null)
{
this.m.WeaponType = this.m.WeaponType | weaponType;
break;
}
}
}

if (categories.find("One-Handed") != null && !this.isItemType(::Const.Items.ItemType.OneHanded))
foreach (str in ::Const.Items.WeaponHandedCategoriesStrings.OneHanded)
{
this.m.ItemType = this.m.ItemType | ::Const.Items.ItemType.OneHanded;
if (this.isItemType(::Const.Items.ItemType.TwoHanded))
if (categories.find(str) != null && !this.isItemType(::Const.Items.ItemType.OneHanded))
{
this.m.ItemType -= ::Const.Items.ItemType.TwoHanded;
this.m.ItemType = this.m.ItemType | ::Const.Items.ItemType.OneHanded;
if (this.isItemType(::Const.Items.ItemType.TwoHanded))
{
this.m.ItemType -= ::Const.Items.ItemType.TwoHanded;
}
break;
}
}

if (categories.find("Two-Handed") != null && !this.isItemType(::Const.Items.ItemType.TwoHanded))
foreach (str in ::Const.Items.WeaponHandedCategoriesStrings.TwoHanded)
{
this.m.ItemType = this.m.ItemType | ::Const.Items.ItemType.TwoHanded;
if (this.isItemType(::Const.Items.ItemType.OneHanded))
if (categories.find(str) != null && !this.isItemType(::Const.Items.ItemType.TwoHanded))
{
this.m.ItemType -= ::Const.Items.ItemType.OneHanded;
this.m.ItemType = this.m.ItemType | ::Const.Items.ItemType.TwoHanded;
if (this.isItemType(::Const.Items.ItemType.OneHanded))
{
this.m.ItemType -= ::Const.Items.ItemType.OneHanded;
}
break;
}
}
}
Expand Down Expand Up @@ -144,13 +156,15 @@

if (this.m.Categories != "") this.m.Categories = this.m.Categories.slice(0, -1) + ", ";

// We always use the last entry that was pushed to the strings so translators just
// have to push it there and it works.
if (this.isItemType(::Const.Items.ItemType.OneHanded))
{
this.m.Categories += "One-Handed";
this.m.Categories += ::Const.Items.WeaponHandedCategoriesStrings.OneHanded.top();
}
else if (this.isItemType(::Const.Items.ItemType.TwoHanded))
{
this.m.Categories += "Two-Handed";
this.m.Categories += ::Const.Items.WeaponHandedCategoriesStrings.TwoHanded.top();
}
}

Expand Down