Author Topic: Have a question about Modding? Ask Here!  (Read 309670 times)

0 Members and 1 Guest are viewing this topic.

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1740 on: November 12, 2018, 10:15:32 pm »
Item undefined error is normal when you give brand new item (item that was added to module_items but wasn't yet compiled) to troops, compiling a second time should resolve that error.
If you keep getting it then you're doing something wrong, are you sure you are putting in correct item name, with "itm_" in front of it?
« Last Edit: November 12, 2018, 10:17:50 pm by Grozni »

Wursti

  • Guest
Re: Have a question about Modding? Ask Here!
« Reply #1741 on: November 12, 2018, 10:21:47 pm »
Item undefined error is normal when you give brand new item (item that was added to module_items but wasn't yet compiled) to troops, compiling a second time should resolve that error.
If you keep getting it then you're doing something wrong, are you sure you are putting in correct item name, with "itm_" in front of it?

Yea. I copy pasted the french troops and just renamed the stuff I had to (faction, names)

Offline PelvicThrust

  • First Sergeant
  • *
  • Posts: 514
  • 32nd Regiment of Foot - Light Infantry
    • View Profile
  • Side: Union
Re: Have a question about Modding? Ask Here!
« Reply #1742 on: November 13, 2018, 11:31:27 am »
The problem is you want to change the item worn completely on client side. Servers will not allow this, cosmetic or not, otherwise everyone would be walking around with custom equipment combinations made with changes to client.
In best case server will override item you set by default one, you'll most likely be kicked upon spawning ("kicked for cheating").

Thank you very much!

Wursti

  • Guest
Re: Have a question about Modding? Ask Here!
« Reply #1743 on: November 13, 2018, 04:53:18 pm »
Could someone please explain what exactly those lines do?



I mean I think I kinda get it but not completely

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1744 on: November 13, 2018, 07:22:13 pm »
Could someone please explain what exactly those lines do?



I mean I think I kinda get it but not completely

  • At this point you should lookup some basic modding tutorials either here or on taleworlds forum.
  • Keep header_operations.py file open so you can lookup operations. Stuff like this_or_next and is_between are called operations, all of them are listed in header_operations file, and a lot of them have usage explanations as comments in same file, so when in doubt just ctrl+F on this file and type in name of operation.
  • Everything in M&B module system are just variables holding a number. I am mentioning this because it is related to your question about what those lines do. Files starting with ID_ will tell you which variable holds which number, these files are generated during module compilation. So, if you open ID_troops.py you can see that trp_british_rocket_ai = 20 , which means that trp_british_rocket_ai is a constant variable holding a number 20, and when you use trp_british_rocket_ai as a parameter to an operation which expects to receive a troop ID, you are actually sending the number 20, so you might as well replace trp_british_rocket_ai with number 20 in your code and it will still compile without errors, as trp_british_rocket_ai is nothing else but a number 20, the ID of that troop type.
  • So with that in mind, you can use is_between, which will check if a numerical value you sent to it is within a range, to check if a troop type is within a range of troop types as they are defined in module_troops.py . So is_between(3,5,10) will check if 3 is between 5 and 9 (last value isn't counted in), and since it is not the following code of block will not happen. So in your example, those lines check if ":troop_no", which is a local variable holding a troop type number, belongs to a line infantry, and not footguard or cavalry or anything else. Here footguard units are used as last value of is_between operations because the last value is not counted in. Ofc you can also perform all other mathematical operations, for example if you want to get the next troop type as defined in module_troops you would just add one to some local variable holding a troop ID.
  • In this case several different is_between operations had to be done because units in module_units are sorted by faction, so line infantry units are separated by all other unit types in module_troops file, which means separate ranges have to be checked per each faction. This is why this_or_next is used, for next block of code to happen, any of range checks has to return true, and you do that by adding this_or_next| in front of operation which performs some check. You can also use neg| to make block of code happen if check returns false. If using this_or_next| remember you shouldn't use it in your last line of checks because there is no next one.
  • In case you don't know, all the code between try_begin and try_end will happen if checks performed inside return true (or false if you use neg|), and try_else is alternative block of code which will attempt to trigger next if the one above fails.
  • Operations are hard-coded which is why you won't find module_operations.py or ID_operations.py, operation IDs are inside the header_operations.py as they are not generated during compile. When you compile modules into .txt files operations and other variables in these files will be replaced by their numerical values, which is why txt files have loads of numbers.


Offline PelvicThrust

  • First Sergeant
  • *
  • Posts: 514
  • 32nd Regiment of Foot - Light Infantry
    • View Profile
  • Side: Union
Re: Have a question about Modding? Ask Here!
« Reply #1745 on: November 17, 2018, 03:36:30 am »
Hey guys, I am running into an issue with my shako plate, In openBRF I have the following:

british_guard_shako_ranker (the hat)
Lods
british_guard_shako_ranker.1 (the plate)
Lods

However I notice with some hats they have a .lod which is the hat and the plate, all at once, which I cant seem to make? I think this is the reason that the plate is only partially visible. in the image below in OpenBRF the selected LOD is the example of what I want to create in openBRF (see below)

Spoiler
[close]
« Last Edit: November 17, 2018, 03:38:07 am by PelvicThrust »

Offline PelvicThrust

  • First Sergeant
  • *
  • Posts: 514
  • 32nd Regiment of Foot - Light Infantry
    • View Profile
  • Side: Union
Re: Have a question about Modding? Ask Here!
« Reply #1746 on: November 17, 2018, 05:22:35 am »
Hey guys, I am running into an issue with my shako plate, In openBRF I have the following:

british_guard_shako_ranker (the hat)
Lods
british_guard_shako_ranker.1 (the plate)
Lods

However I notice with some hats they have a .lod which is the hat and the plate, all at once, which I cant seem to make? I think this is the reason that the plate is only partially visible. in the image below in OpenBRF the selected LOD is the example of what I want to create in openBRF (see below)

Spoiler
[close]

The fix was apparently not the LOD, but the fact that the shako plate was clipping into the hat by literally a millimetre (it was not really showing on me, but it was on others.)

Offline Ivkolya

  • Sergeant Major
  • *
  • Posts: 333
    • View Profile
  • Nick: Ivkolya
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1747 on: November 18, 2018, 01:10:10 am »
Hello all, I have couple of questions related to scene making. I've added entry points to my scene in NW, but they don't work as intended - I've set numbers of all first team's entry points to 0 and second team's entry points to 32, but in deathmatch mode both teams spawn on entry points of team 1. After that in testing purposes I've added 32 entry points for each team without changing their numbers (so team 1 has 0-31, team 2 - 32-63), but team 2 still spawns on team 1's entry points, and in battle mode both teams spawn just in the field, not on entry points.

So my question is - how many entry points should I add to the scene and is there a limit for them?
And another question - how to disable cavalry on the scene completely (so bots will spawn as infantry units)? I guess it should be somewhere in module files, but I can't find where.


UPD I found out that scene I've changed, had flag "sf_auto_entry_points", but even after deleting it in team deathmatch mode some units spawn outside of my new entry points, and also I've noticed that not all entry points are used, but in the same time some of units spawn in the same entry point simultaneously.
« Last Edit: November 18, 2018, 01:41:35 am by Ivkolya »

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1748 on: November 18, 2018, 01:36:14 am »
Hello all, I have couple of questions related to scene making. I've added entry points to my scene in NW, but they don't work as intended - I've set numbers of all first team's entry points to 0 and second team's entry points to 32, but in deathmatch mode both teams spawn on entry points of team 1. After that in testing purposes I've added 32 entry points for each team without changing their numbers (so team 1 has 0-31, team 2 - 32-63), but team 2 still spawns on team 1's entry points, and in battle mode both teams spawn just in the field, not on entry points.

So my question is - how many entry points should I add to the scene and is there a limit for them?
And another question - how to disable cavalry on the scene completely (so bots will spawn as infantry units)? I guess it should be somewhere in module files, but I can't find where.

Your second attempt is correct, you shouldn't have entry points with duplicate numbers.

iirc all it takes for spawning to work properly is add entry point 0 for team 1 and entry point 32 for team 2, other entry points are not mandatory. These things should work well in proper game mode (not Scene Editing) so I don't know why you are having problems in battle mode, double check everything.

As for other question, look for multiplayer_find_bot_troop_and_group_for_spawn in module_scripts.py, figure out how it works, and replace store_random_in_range with your own logic.

Offline Ivkolya

  • Sergeant Major
  • *
  • Posts: 333
    • View Profile
  • Nick: Ivkolya
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1749 on: November 18, 2018, 02:01:12 am »
Thank you very much for fast answer! :)

Problem was with flag "sf_auto_entry_points" which I've deleted now.
In testing purposes I've deleted all entry points, placed them again (0-31 for team 1 and 32-63 for team 2), started team deathmatch with 25 bots only in team 1 - some entry points were not used at all, some werre used by two units at the same time, and some units were spawned on team 2 entry points, and 4 units spawned in two points on the scene where were no entry poiints at all. But maybe this is because of team deathmatch mode.
Afterwards I've started battle mode - and team 2 spawned on their entry points, but whole team 1 spawned in the field between entry points for team 1 and team 2. Can it be because I've placed entry points for team 1 and team 2 at a long distance from each other?
« Last Edit: December 18, 2018, 03:04:25 pm by Ivkolya »

Offline maka CZ

  • Sergeant
  • *
  • Posts: 26
    • View Profile
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1750 on: November 18, 2018, 04:36:16 pm »
Hello, what is wrong? I've just changed color. Same thing happend with shakos
Spoiler
[close]

Wursti

  • Guest
Re: Have a question about Modding? Ask Here!
« Reply #1751 on: November 23, 2018, 10:12:58 pm »
Hello, what is wrong? I've just changed color. Same thing happend with shakos
Spoiler
[close]

Got no clue what is wrong :S Maybe some people can answer after I bumped this :D

----------

How can I put Units into a different unit tab (Cavalry | Artillery) ?

Offline Grozni

  • Second Lieutenant
  • *
  • Posts: 308
    • View Profile
  • Nick: RRA_10thRH_SoH_Grozni
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1752 on: November 24, 2018, 11:50:18 am »
Make sure your replacement texture and/or material got same flags in openBRF as original. Make sure you use BC3DX5 compression when exporting. If that doesn't fix it maybe your image lost alpha channel somehow.

Wursti

  • Guest
Re: Have a question about Modding? Ask Here!
« Reply #1753 on: November 24, 2018, 02:55:37 pm »

----------

How can I put Units into a different unit tab (Cavalry | Artillery) ?

nvm got it :D

Offline Ivkolya

  • Sergeant Major
  • *
  • Posts: 333
    • View Profile
  • Nick: Ivkolya
  • Side: Neutral
Re: Have a question about Modding? Ask Here!
« Reply #1754 on: December 18, 2018, 03:09:42 pm »
UPD. I've finally found a solution, but if there are another, simplier thoughts - I'll be grateful :)

How to disable bots spawning as cavalry units on certain maps of team deathmatch mode?

Hello all, in siege mode in NW there is working restriction for bots spawning as cavalry, at least in defending team, but I didn't find script for that. Maybe someone can point me where it is? I think it can be a start for disabling AI cavalry in other modes

Also I've noticed that on my new scene attacking team has no horses (but all bots are of the same unit), and defending team has cavalry, which is strange

I created new topic, but maybe here someone will see and help me (and, I guess, help many other modders), so sorry for double-posting.

I made many attempts to find a solution. I was advised to look into this module_mission_templates code,

Spoiler
Code
      (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":selected_team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),

      (team_get_faction, ":team_faction", ":selected_team"),
      (assign, ":num_ai_troops", 0),
      (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
        (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
        (eq, ":ai_troop_faction", ":team_faction"),
        (val_add, ":num_ai_troops", 1),
      (try_end),
[close]

As I think, disable cavalry for certain scenes could be made by adding list of scenes as condition and excluding cavalry units from available for spawning after oriiginal line

Code
	   (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),

First of all I tried to add lines like (neg|troop_is_guarantee_horse, ":cur_ai_troop") or (neg|troop_select_type_cavalry, ":cur_ai_troop") and couple of other variants, but they didn't work, bots were dead in list of players.

In the end I changed module_constants (added infantry of all factions) after multiplayer_ai_troops_end (as this variable is referenced in original script)

Spoiler
Code
multiplayer_ai_troops_begin = "trp_british_infantry_ai"
multiplayer_ai_troops_end = multiplayer_troops_begin

multiplayer_ai_british_infantry_begin = "trp_british_infantry_ai"
multiplayer_ai_british_infantry_end = "trp_british_hussar_ai"

multiplayer_ai_french_infantry_begin = "trp_french_infantry_ai"
multiplayer_ai_french_infantry_end = "trp_french_hussar_ai"

multiplayer_ai_prussian_infantry_begin = "trp_prussian_infantry_ai"
multiplayer_ai_prussian_infantry_end = "trp_prussian_dragoon_ai"

multiplayer_ai_russian_infantry_begin = "trp_russian_foot_guard_ai"
multiplayer_ai_russian_infantry_end = "trp_russian_hussar_ai"

multiplayer_ai_austrian_infantry_begin = "trp_austrian_infantry_ai"
multiplayer_ai_austrian_infantry_end = "trp_austrian_hussar_ai"

multiplayer_ai_rhine_infantry_begin = "trp_rhine_infantry_bavaria_ai"
multiplayer_ai_rhine_infantry_end = "trp_rhine_mounted_jaeger_ai"
[close]

So my code looks like this now

Code
      (call_script, "script_multiplayer_find_bot_troop_and_group_for_spawn", ":selected_team", ":look_only_actives"),
      (assign, ":selected_troop", reg0),
      (assign, ":selected_group", reg1),

      (team_get_faction, ":team_faction", ":selected_team"),
      (assign, ":num_ai_troops", 0),
  (store_current_scene, ":cur_scene"),
      (try_begin),
   (eq, ":cur_scene", "scn_assault_on_malakoff_test"),
   (eq, "$g_multiplayer_game_type", multiplayer_game_type_team_deathmatch),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_british_infantry_begin, multiplayer_ai_british_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_french_infantry_begin, multiplayer_ai_french_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_russian_infantry_begin, multiplayer_ai_russian_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_prussian_infantry_begin, multiplayer_ai_prussian_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_austrian_infantry_begin, multiplayer_ai_austrian_infantry_end),
           (try_for_range, ":cur_ai_troop", multiplayer_ai_rhine_infantry_begin, multiplayer_ai_rhine_infantry_end),
     (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
             (eq, ":ai_troop_faction", ":team_faction"),
             (val_add, ":num_ai_troops", 1),
  (try_end),
 
      (else_try),
   (try_for_range, ":cur_ai_troop", multiplayer_ai_troops_begin, multiplayer_ai_troops_end),
             (store_troop_faction, ":ai_troop_faction", ":cur_ai_troop"),
             (eq, ":ai_troop_faction", ":team_faction"),
             (val_add, ":num_ai_troops", 1),
      (try_end),

But bots are dead when I start team deathmach with bots.
And maybe I wrote something wrong? Maybe overall it's the right way, but I just wrote something wrong?
I really hope someone will help me.

Sorry for doubleposting (I've posted this question in the Scripting thread and created new tyopic), but I've got no answer, so I hope someone here will see this question finally and help me with it. And I think such code for disabling cavalry bots on certain maps will be much needed OSP code for many modders who make mods with infantry maps.
« Last Edit: December 19, 2018, 01:44:56 pm by Ivkolya »