Jump to content

Photo

Modding def files


  • Please log in to reply
15 replies to this topic

#1
darkyy

darkyy

    Newbie

  • Supporter
  • 12 posts
there are no need to modify the actual original .def files themselves, you can create your own .def files, and the game will load those as well.
this applies to CSVs also.
or you can make use of the appdata saves/Mods folder
 
example from AvailableUnit.def
 
def EuropeanUnitSet : AvailableUnits
{
  Militia_CE
  AdvancedMilitia_CE
  Light_Infantry_CE
  Light_Spearman_CE
  Light_Archer_CE
  Light_Cavalry_CE
  Heavy_Swordman_CE
  Heavy_Spearman_CE
  Heavy_Archer_CE
  Heavy_Cavalry_CE
  town_guards
  {
    TownGuard_CE
    EliteGuard_CE
    RoyalGuard_CE
  }
  marshals
  {
    marshal = Marshal_CE
    marshal_guard = Marshal_Guard_CE
    rebel_marshal = Marshal_Rebel_CE
    rebel_marshal_guard = Marshal_Guard_Rebel_CE
  }
}
 
then you create ModAvailableUnit.def

to overwrite the entire unit set you do
def EuropeanUnitSet : AvailableUnits
{
   //add your own list
}

 

to add to the list(I haven't looked into how the game orders the unit in the recruiting lists, but RoyalGuard will be at the top while light infantry gets pushed down one) as the list order shown in AvailableUnits.def seems to have nothing to do with it

extend EuropeanUnitSet
{
    YourCustomSoldier_CE
}
extend EuropeanUnitSet.town_guards
{
    YourCustomGuard_CE
}
extend EuropeanUnitSet.marshals
{
    YourCustomMarshal_CE
}

for buildings

def CropFarming : Building
{
  name = "Crop Farming"
  flavor = "Extensive agricultural development of the province, focused on rye, barley, buckwheat, millet and oats."
  upgrades
  {
    buildings
    {
      CropsRotation
      ManurePits = 1,2 { prerequisites { CropsRotation } }
      HeavyPloughsWorkshop = 1,3 { prerequisites { ManurePits } }
      CropsRotationModern = 2,1
    }
  }
  icon = "Assets/UI/Elements/Buildings/Icons/UI_Structure_Icon_CropFarming.tga:UI_Structure_Icon_CropFarming#2" //GUID:98eaabeeb876bd34081eaa7f33e9cb45
  illustration = "Assets/UI/Elements/Buildings/Illustrations/UI_Structure_Illustration_CropFarming.tga:UI_Structure_Illustration_CropFarming#2" //GUID:4544016cedace27478b15abfda6dcdda
}

modupgrades.def
def CropsRotationModern : Upgrade
{
   name = "Crops Rotation Modern"
   flavor = "Modernized crop planting of different crops sequentially on the same plot of land to preserve the soil's health and fertility."
   icon = "Assets/UI/Elements/Buildings/Icons/UI_Structure_Icon_CropsRotation.tga:UI_Structure_Icon_CropsRotation#2" //GUID:26052cdcb856f594782b362358f759c9
}

then a copy of buildings.csv table as modbuildings.csv, where you delete all other entries and add your own upgrade

Edit:

Updated to fix some mistakes in my understanding of the files and some additional info, still looking into possibilities.

Edit2:

So, I found the command extend instead of def, how to use it properly however seems like a pain in the rear-end, wanted to do it properly in regards to extending buildings list of upgrades etc, but can't for the life of me make it work even by debugging it with engine console to reload_defs so that I can get the error messages.

Edited by darkyy, 13 December 2022 - 05:13 pm.


#2
darkyy

darkyy

    Newbie

  • Supporter
  • 12 posts

So, I found a variable kingdom.is_ai which should be able to be used to identify if it is player that ai controlled or not

Edit: 

so I found that you can do in buildings.def

add into def buildings

go to the conditions bracket

conditions
{
IsAI=(kingdom.is_ai)
{


}
IsPlayer=(!kingdom.is_ai)
{


}//rest of the conditionals here
}

then in the .csv files do

100 Food in Town if IsPlayer
50 Food in Farm if IsAI

in the bonuses
but it won't work for requirements

Edit:

utilizing the extend command, now you can do 
modbuildings.def, this way even if the developer updates the .def files you might not have to change everything all over again or use a full copy of the def.
extend Building.conditions
{
   IsAI=(kingdom.is_ai)
   {
   }
   IsPlayer=(!kingdom.is_ai)
   {
   }
}

Edited by darkyy, 13 December 2022 - 04:07 pm.


#3
VampiresZombiesLiches

VampiresZombiesLiches

    Faithful poster

  • Supporter
  • 1,291 posts

I've tweaked a bit with the available units a bit also. Made Byzantium have all units but because of the very limited UI the box grows extremely large to the point you cant really see the top or bottom and then you cant leave the UI screen unless you press escape. The same happens with trying to add more family beyond 4 the UI gets kind of blocked out. And if I tried tweaking with increasing the 9 knight limit nothing seems to work BUT the king gets disabled and cant get recruited if you change the number beyond 9. Tried expanding the building capacity also it kind of works with 12 buildings but the last 4 buildings are almost completely pushed down and cant be seen. Any more beyond 12 and you cant really build anymore because of the expansion click to buy feature. All in all there is still much to learn. Thank you for all the info you have shared with me. 

 

I would assume this would be better if the devs added a simple scroll bar to their UI. Unless a modder in the future finds out a way and creates a brand new UI for more extensions


Edited by VampiresZombiesLiches, 13 December 2022 - 09:57 am.


#4
darkyy

darkyy

    Newbie

  • Supporter
  • 12 posts

I've tweaked a bit with the available units a bit also. Made Byzantium have all units but because of the very limited UI the box grows extremely large to the point you cant really see the top or bottom and then you cant leave the UI screen unless you press escape. The same happens with trying to add more family beyond 4 the UI gets kind of blocked out. And if I tried tweaking with increasing the 9 knight limit nothing seems to work BUT the king gets disabled and cant get recruited if you change the number beyond 9. Tried expanding the building capacity also it kind of works with 12 buildings but the last 4 buildings are almost completely pushed down and cant be seen. Any more beyond 12 and you cant really build anymore because of the expansion click to buy feature. All in all there is still much to learn. Thank you for all the info you have shared with me. 

 

I would assume this would be better if the devs added a simple scroll bar to their UI. Unless a modder in the future finds out a way and creates a brand new UI for more extensions

Indeed, looking into the asset file directly, the court limit is hardcoded into the UIasset and in the code, seems in some ways, the devs planned to have all this moddable, so who knows what they will change in this regard later on through patches.
as we can see in plenty of the defs a ton of different 'resources' etc are commented out, atleast 30 or so.
some of the defs have prefabs related to arrows(up/down/left/right) so they must also still be working on the UI for this exact reason. 
and the fact that there is still no modding manual etc, seeing as they have def/extend/based_on type logics and variable declaration, it makes me think they are still working on that part, that includes the folder where Mods are actually supposed to be. :wink:


Edited by darkyy, 13 December 2022 - 05:15 pm.


#5
VampiresZombiesLiches

VampiresZombiesLiches

    Faithful poster

  • Supporter
  • 1,291 posts

Adding the mods section into the save game folder is probably the worst thing the devs have done lol. Cloud save keeps downloading stuff i delete lol



#6
VampiresZombiesLiches

VampiresZombiesLiches

    Faithful poster

  • Supporter
  • 1,291 posts

I've tried changing all my mods to your setup you mentioned. But I am unable to make it work. I got the mod option to appear in the options but it doesnt take effect despite me using units.csv or modunits.csv via the saves mod folder.

 

With the other way. I created units.csv made changes and made a new one as modunits.csv and added into the defs folder but the game also doesnt acknowledge the changes.


Edited by VampiresZombiesLiches, 13 December 2022 - 06:09 pm.


#7
darkyy

darkyy

    Newbie

  • Supporter
  • 12 posts

I've tried changing all my mods to your setup you mentioned. But I am unable to make it work. I got the mod option to appear in the options but it doesnt take effect despite me using units.csv or modunits.csv via the saves mod folder.

 

With the other way. I created units.csv made changes and made a new one as modunits.csv and added into the defs folder but the game also doesnt acknowledge the changes.

I don't really use the Mods folder, I'd rather just deal with one location personally, it seems iffy at best currently, having the console open trying to load a mod shows alot of errors even if the mod is empty and even with an empty mod enabled the game refuses to boot.
forcing me to edit the CloudSaveSettings and remove the active mod all the way at the bottom of the file replacing it with ""
also for anyone curios, you can use --ForceEnableConsole in launch options to enable console, open it with ~ or tilde key
to use cheat commands you type
cl 3

a few console commands examples are

  • income_mul x                - select a kingdoms town selected and they get x multiplier to their gold incomes
  • expense_mul x              - select a kingdoms town selected and they get x multiplier to their gold expenses
  • give_gold x                    - select a kingdoms town selected and they get x amount of gold, if you have 10 and type 10 you now have 20
  • give_books x                 - select a kingdoms town selected and they get x amount of books, if you have 10 and type 10 you now have 20
  • give_piety x                   - select a kingdoms town selected and they get x amount of piety , if you have 10 and type 10 you now have 20
  • gold x                             - sets your gold to a specific amount, if you have 1000 and type 10 you now have 10 gold
  • books x                          - sets your books to a specific amount, if you have 1000 and type 10 you now have 10 books
  • piety x                            - sets your piety to a specific amount, if you have 1000 and type 10 you now have 10 piety
  • import resourcename    - gives your kingdom the resource as if it gets gained through trade, names on resources are found in resources.def
  • conquer                         - select a kingdoms town, this will conquer all the towns of that kingdom(you will still have to adopt the population or use the marshal ability
  • conquer_rest                 - conquers all kingdoms except the selected one
  • build name                    - Building name found in buildings.def, building gets constructed in selected town
  • build name castlename - Building gets built in specified province, example build CropFarming Rennes
  • upgrade name               - upgrade name is found in upgrades.def, this command completes the upgrade
  • apf name                        - names are found in resources.def, gives a selected province the given resource feature, example Amber

for modders wanting to rapidly test changes without restarting the game, there is 

  • reload_defs

 

regarding the csvs, I am using modbuildings.def and modbuildings.csv where I only 'new' upgrades etc as an example with no problems, game loads it just fine, the way I use the csvs specifically is to make new buildings etc not to edit the old ones.

also, I think you will like this inregards to your talents/tradition mods

under Skills like Others.def etc as an example with the tag King
 
you can add something like
 
Default
{
//action UnExcommunicateAction
mod cs_squad_size_perc = 300
{
condition = (!kingdom.is_ai)
}
}
 
in traditions.def you can also use conditionals
lets say under archerytradition
instead of just the ks_ranged_squad_size you can do
you can do
 

skills
{
skill GodSkill
{
tag king
{
kingdom_mod ks_ranged_squad_size=50 { condition= (!kingdom.is_ai) }
}
}
}
 
the same applies for the changes for specific classes like Marshal under ArcheryTradition
mod cs_salvo_capacity_bonus_perc = 50

can be

mod cs_salvo_capacity_bonus_perc = 50
{
  condition= (!kingdom.is_ai)
}

Edited by darkyy, 17 December 2022 - 07:24 pm.


#8
VampiresZombiesLiches

VampiresZombiesLiches

    Faithful poster

  • Supporter
  • 1,291 posts

Well I kind of found another way. I did the command line csv : units.csv {"my modded stuff""} at the bottom of the vanilla strings/command lines. It overwrote the vanilla settings without me actually touching the vanilla lines other than me still using "units.csv" and modifying it. I tried making a brand new one using "modunits.csv" but the game does not recognize it



#9
VampiresZombiesLiches

VampiresZombiesLiches

    Faithful poster

  • Supporter
  • 1,291 posts

Adding it via again using the mods folder in the appdata saves folder. Mods\Knights of Honor II\Defs\units.csv The game loads but in mod settings there appears 2 options under the mod. Base and Knights of Honor II. Choosing Knights of Honor II just causes endless "applying changes." Doing Mods\Defs\units.csv just straight up CTD. Just adding the modified file one time as units.csv and another as modunits.csv makes no difference. As the game does nothing with it. But add a folder of the mod name makes the game recognize it but the changes and modified stuff are not implemented in game. My findings so far.


Edited by VampiresZombiesLiches, 13 December 2022 - 07:06 pm.


#10
darkyy

darkyy

    Newbie

  • Supporter
  • 12 posts

Adding it via again using the mods folder in the appdata saves folder. Mods\Knights of Honor II\Defs\units.csv The game loads but in mod settings there appears 2 options under the mod. Base and Knights of Honor II. Choosing Knights of Honor II just causes endless "applying changes." Doing Mods\Defs\units.csv just straight up CTD. Just adding the modified file one time as units.csv and another as modunits.csv makes no difference. As the game does nothing with it. But add a folder of the mod name makes the game recognize it but the changes and modified stuff are not implemented in game. My findings so far.

as I mentioned, I do not currently use the Saves/Mods/Modname/Defs approach at all, I have nothing but problems with it regardless of what I do. :(






IPB skins by Skinbox
Page loaded in: 0.287 seconds