Jump to content

How does one make a mod that uses the gams 'MODS'-menu?


Graesholt

Recommended Posts

I was recently provided help making a mod that increased the durability of items without removing the feature, and therefore made two separate mods, one that increases weapon durability and one for armor.

However, what I thought would not be an issue with the game went and was one anyway, as the two mods alter the same script, and are thus incompatible with each other.

This sucks tremendously.

 

I was thinking now that instead I'd make a mod that uses the ingame MODS-menu, so players could be able to with sliders determine how much more durability their items have, armor and weapons separate.

There is just one hitch with that plan:

I can find NO DOCUMENTATION WHATSOEVER online of how one makes a mod that uses that damn menu.

NONE

 

I have googled for most of a day now and am getting sort of frustrated with it. I can find no forum posts, no questions asked, no tutorials, no pictures of vague explanations scribbled hastily onto napkins. Nothing.

 

Does anyone have any idea how one interacts with the ingame MODS menu through mods?
Thank you.

Link to comment
Share on other sites

You should start with some mods that have menu entries, like Friendly HUD, More Quick Slots, Sort Everything etc...

 

Also see the w3strings encoder / decoder tool. See this forum for more details.

 

The short version:

 

1. Create an XML file describing the menu. Few examples are included in the game, you can find others in existing mods. The XMLs are located in bin\config\r4game\user_config_matrix\pc folder. Let's say you'll have 3 entries, all sliders (see audio.xml for examples, also you'll find few others in other menus):

  • a slider for armor durability reduction, with valid values between 0.0 and 1.0; variable named armorLoseValue
  • a slider for weapons durability reduction when the difficulty is not hardcore, with valid values between 0.0 and 0.4; variable named weaponLoseValue
  • a slider for weapons durrability when hardcore mod is used, with valid values between 0.0 and 0.4; variable named weaponLoseValueHardcore

2. Create the w3strings files with the strings used by your menu. Probably you'll spend some time here until you'll figure the required keys :smile:

3. Add the variables specified in menu file to user.settings file, with their default values. For example something like this:

 

[modEquipmentDurability]

armorLoseValue = 0.6

weaponLoseValue = 0.26

weaponLoseValueHardcore = 0.1

 

No scripting required so far. If the menu works then you'll have to use the variables configured in menu.

 

There are many examples in existing scripts for getting the value of a variable. Search game's script files for GetInGameConfigWrapper.

 

For your mod(s), you don't have to change anymore the DURABILITY_ARMOR_LOSE_VALUE, DURABILITY_WEAPON_LOSE_VALUE and DURABILITY_WEAPON_LOSE_VALUE_HARDCORE constants. Instead you should change only the ReduceItemDurability function from inventoryComponent.ws script file. Something like this:

if(IsItemWeapon(itemId))
{ 
    chance = theGame.params.DURABILITY_WEAPON_LOSE_CHANCE;
    if(theGame.GetDifficultyMode() == EDM_Hardcore) {
        value = StringToFloat(theGame.GetInGameConfigWrapper().GetVarValue('modEquipmentDurability', 'weaponLoseValueHardcore'));
    } else {
        value = StringToFloat(theGame.GetInGameConfigWrapper().GetVarValue('modEquipmentDurability', 'weaponLoseValue'));
   }
}
else if(IsItemAnyArmor(itemId))
{
    chance = theGame.params.DURABILITY_ARMOR_LOSE_CHANCE;
    value = StringToFloat(theGame.GetInGameConfigWrapper().GetVarValue('modEquipmentDurability', 'armorLoseValue'));
}

where modEquipmentDurability is the group for your variables (defined in XML files, added to user.settings) and weaponLoseValue, weaponLoseValueHardcore and armorLoseValue are the names of the variables defined in the XML files.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...