Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
k0nr@d said:
"player_has_item" checks player inventory AND 9 equipment slots?

equipment slots are part of the inventory. Some operations will check only part of it (gear slots, the first 10, or baggage slots), as it is the case for this one.

player_has_item is used for baggage items (usually for quest checks like if you have the ale you need to deliver, etc)

Code:
#equipment slots
ek_item_0 = 0
ek_item_1 = 1
ek_item_2 = 2
ek_item_3 = 3
ek_head   = 4
ek_body   = 5
ek_foot   = 6
ek_gloves = 7
ek_horse  = 8
ek_food   = 9

max_inventory_items = 96
num_equipment_kinds = ek_food + 1
 
I have got another question. Lets say that my troops file has 100 merchants (trp_x1, trp_x2, ...) and I am looking for a specific item in trp_x1, trp_x2, trp_x3, trp_ 4 inventories. Initial code could look like this:

(try_for_range, ":merchant", trp_x1, trp_x5),
        do something
(try_end),

How to do above in an elegant way, if troops are not one after another (e.g. trp_x1, trp_x42, trp_x76, trp_ 8:cool:?

Thank you.
 
k0nr@d said:
(try_for_range, ":merchant", trp_x1, trp_x5),
        do something
(try_end),

How to do above in an elegant way, if troops are not one after another (e.g. trp_x1, trp_x42, trp_x76, trp_ 8:cool:?

if the troops are grouped on module_troops.py it is easier. Open your ID_troops.py and you will see each troop get a number (ID), so the loop for:

(try_for_troops, :troop, trp_first_one, trp_last_one) really translates to
(try_for_troops, :troop, 55, 100), # from ID 55 to 99 (not 100)

If you can't have this then the next alternative is to use some kind of flag to filter then out.

(try_for_troops, :troop, trp_first_one, trp_last_one),
  is this troop a merchant? If so continue, else try the next one
(try_end),

filter can be a slot check, a stat check, etc, something that makes then unique in some way. You may create a new slot, as a example, and set it to 0/1 as the merchant flag, and so on.
 
All right, I really need some help.

People are having massive issues with the latest version of BF.
Apparently, most of the people are taking 10+ minutes to load, which is crazy. Frequent crashes while loading, even loading times of 30+ minutes.
I can't figure out what it could be connected to, they get stuck on 'Loading Textures', but in the update no particulary big textures were added and only 30-40 were added in terms of quantity, nothing in comparison to hundreds in already.

Anyone got any ideas?
 
kalarhan said:
k0nr@d said:
(try_for_range, ":merchant", trp_x1, trp_x5),
        do something
(try_end),

How to do above in an elegant way, if troops are not one after another (e.g. trp_x1, trp_x42, trp_x76, trp_ 8:cool:?

if the troops are grouped on module_troops.py it is easier. Open your ID_troops.py and you will see each troop get a number (ID), so the loop for:

(try_for_troops, :troop, trp_first_one, trp_last_one) really translates to
(try_for_troops, :troop, 55, 100), # from ID 55 to 99 (not 100)

If you can't have this then the next alternative is to use some kind of flag to filter then out.

(try_for_troops, :troop, trp_first_one, trp_last_one),
  is this troop a merchant? If so continue, else try the next one
(try_end),

filter can be a slot check, a stat check, etc, something that makes then unique in some way. You may create a new slot, as a example, and set it to 0/1 as the merchant flag, and so on.
In the " normal" programming language I would create array like:
merchant_array() = array(trp_x1, trp_x56, trp_x67, trp_x89)
then just index through it. There is no simple way to create temporary array in Warband scripting language?
 
BNS Marko said:
All right, I really need some help.

People are having massive issues with the latest version of BF.
Apparently, most of the people are taking 10+ minutes to load, which is crazy. Frequent crashes while loading, even loading times of 30+ minutes.
I can't figure out what it could be connected to, they get stuck on 'Loading Textures', but in the update no particulary big textures were added and only 30-40 were added in terms of quantity, nothing in comparison to hundreds in already.

Anyone got any ideas?
They need to use Load Textures On Demand. Iirc theres a module.ini option to generate simplified textures for loading which might help as well.

It still takes a long time to load a lot of the big scenes for me (death star for example) but the admin option to reset scores without resetting the map basically eliminates the issue. But when I tried without on demand textures I got stuck as well (and this was a few patches ago) So hopefully load textures on demand will solve the issue for everyone.
 
k0nr@d said:
In the " normal" programming language I would create array like:
merchant_array() = array(trp_x1, trp_x56, trp_x67, trp_x89)
then just index through it. There is no simple way to create temporary array in Warband scripting language?

MBScript is normal programming. It is a scripting language that is based on C++. Python is just used for basic grammar and the compiler.

Yes you can create a temporary array. A dynamic one (runtime) can be built using slots. A static one (compile time) can be built using pure Python.

For arrays as slots you can even add a OSP like WARP (https://forums.taleworlds.com/index.php/topic,335511.msg7953775.html#msg7953775), or just do it with a troop or party operations.
 
Ruthven said:
BNS Marko said:
All right, I really need some help.

People are having massive issues with the latest version of BF.
Apparently, most of the people are taking 10+ minutes to load, which is crazy. Frequent crashes while loading, even loading times of 30+ minutes.
I can't figure out what it could be connected to, they get stuck on 'Loading Textures', but in the update no particulary big textures were added and only 30-40 were added in terms of quantity, nothing in comparison to hundreds in already.

Anyone got any ideas?
They need to use Load Textures On Demand. Iirc theres a module.ini option to generate simplified textures for loading which might help as well.

It still takes a long time to load a lot of the big scenes for me (death star for example) but the admin option to reset scores without resetting the map basically eliminates the issue. But when I tried without on demand textures I got stuck as well (and this was a few patches ago) So hopefully load textures on demand will solve the issue for everyone.
Tried loading textures on demand as a solution, no option. I tried re-uploading the mod as a .rar, if maybe something got corrupted. Still nothing  :???:
I don't experience the problem and can't recreate it myself, but it appears on low-high end PCs alike, which makes it all the more mysterious.
 
BNS Marko said:
All right, I really need some help.

People are having massive issues with the latest version of BF.
Apparently, most of the people are taking 10+ minutes to load, which is crazy. Frequent crashes while loading, even loading times of 30+ minutes.
I can't figure out what it could be connected to, they get stuck on 'Loading Textures', but in the update no particulary big textures were added and only 30-40 were added in terms of quantity, nothing in comparison to hundreds in already.

Anyone got any ideas?

I had that issue but I solved it to an extent by resizing a few textures which had non-regular resolutions (i.e. powers of 2)
 
jacobhinds said:
BNS Marko said:
All right, I really need some help.

People are having massive issues with the latest version of BF.
Apparently, most of the people are taking 10+ minutes to load, which is crazy. Frequent crashes while loading, even loading times of 30+ minutes.
I can't figure out what it could be connected to, they get stuck on 'Loading Textures', but in the update no particulary big textures were added and only 30-40 were added in terms of quantity, nothing in comparison to hundreds in already.

Anyone got any ideas?

I had that issue but I solved it to an extent by resizing a few textures which had non-regular resolutions (i.e. powers of 2)

As in, exponents of 2? 2^n?

7caa64e6ab.png
The new bigg-ish textures to be added now are the ones with RPIT_

 
Actual dds dimensions (e.g. 1024^2), not file size, although that bottomless_pit one could be scaled down drastically. As long as it uses dxt1/3/5 compression it should be fine when the game reads it.
 
Oh crap, resolution, not file size. Got it. Although the botomless pit worked so far until now fine, I don't think that's an issue(Doesn't mean we can't scale it down though).
 
I'm using the Floris Dev Suite as a base to create my own mod, and have implemented a new char race. Everything is going dandy, but I wanted to alter some of the dialogue for the intro quest based off being human (tf's 0,1) or the new race (tf 2). I tried to accomplish this by having it check the gender, then assign the dialogue from the string file based off the result:

  [anyone, "start_up_quest_1_next",
  [
  (try_begin),
    (eq,"$character_gender",2), #ALTERNATE QUEST LINE
(str_store_string, s11, "str_test_alt_char_race_first_chat_with_starting_merchant"),
  (else_try), #STANDARD QUEST LINE
    (eq,"$character_gender",1), #FEMALE (SPLIT FOR DEBUGGING PURPOSES)
(str_store_string, s11, "str_test_female_first_chat_with_starting_merchant"),
  (else_try), #STANDARD QUEST LINE
    (eq,"$character_gender",0), #MALE (SPLIT FOR DEBUGGING PURPOSES)
(str_store_string, s11, "str_test_male_first_chat_with_starting_merchant"),
  (try_end),
  ],
 
  "{s11}", "close_window",
 
  [   
    (assign, "$talked_with_merchant", 1),
    (mission_disable_talk),
  ]],

This code triggers in the module_dialogs file when the merchant talks to you after killing the intro bandit. However it keeps assigning the male dialogue for the alternate char race. Starting as a female maintains its correct gender. If I use the EXACT try_begin code in the module_game_menus area that triggers the initial fight scene, it is able to correctly identify the alt char race's 'gender' as being 2. So for some reason in the dialogs file the alt char race's "$character_gender" is reading as 0 instead of 2. What am I doing wrong? Thanks!

EDIT: Solved it! Apparently diplomacy (integrated into Floris) has a script that reassigns gender post-char creation (in both ("setup_talk_info", and ("setup_talk_info_companions", in the module_scripts file). Does anyone know if anything bad will happen if I just comment out the gender code 'fix' there? Thanks.
 
Syke said:
EDIT: Solved it! Apparently diplomacy (integrated into Floris) has a script that reassigns gender post-char creation

if you are unsure about changing code you can always use the normal operation to check type (skins)
Code:
troop_set_type                           = 1505  # (troop_set_type, <troop_id>, <gender>),
                                                 # Changes the troop skin. There are two skins in Native: male and female, so in effect this operation sets troop gender. However mods may declare other skins.
troop_get_type                           = 1506  # (troop_get_type, <destination>, <troop_id>),
                                                 # Returns troop current skin (i.e. gender).
 
Good day!
I am working on the server and scripting it.
And... I have a small problem. Question: "How to give item to the player when he spawns?"

My code not working, but compiling without errors.

Code:
 ("multiplayer_server_on_agent_spawn_common",
   [
     (store_script_param, ":agent_no", 1),
	 
	 (store_script_param_2, ":player_no", 1),
	 
	  (store_trigger_param_1, ":agent_id"),
	  
	   (agent_is_active,":agent_id"),
      (agent_is_alive,":agent_id"),
	  
	  (try_begin),
        (agent_get_item_slot, ":item_id", ":agent_id", 4), #ek_head
        (gt,":item_id",-1), # even have a item there?
        (agent_unequip_item, ":agent_id", ":item_id", 4), #ek_head
      (try_end),
	  
	  	 (player_get_unique_id, ":player_unique_id", ":player_no"),
	 
(eq, ":player_unique_id", 656345),

  (agent_equip_item,":agent_id","itm_pirate_hat"),
  
  (try_for_range, ":player_no", 1, multiplayer_player_loops_end), #0 is server so starting from 1
        (player_is_active, ":player_no"),
        (multiplayer_send_3_int_to_player, ":player_no", multiplayer_event_return_agent_set_item, ":agent_id", "itm_pirate_hat", 4),
      (try_end),

When im spawning, its only removing my hat and on the console I see error:
Code:
Input: SCRIPT ERROR ON OPCODE 22: Invalid Script Parameter ID: 1; LINE NO: 1:
 At script: script_49. SCRIPT WARNING ON OPCODE 441: Invalid Player ID: 15; LINE NO: 10:
 At script: script_49.
 
Cray-Z said:
My code not working, but compiling without errors.

start by fixing your indentation. It is hard to read the code otherwise.

then check your syntax. This one, as a example, is invalid
Code:
store_script_param_2, ":player_no", 1),

review your parameters (you did not show us the script call), and if in doubt add logging messages to test it
 
Is it possible to make ex-king of a destroyed faction to join player's faction as a lord? Does it require lots of modding, or may be done easily?
 
Ansiktslos said:
Is it possible to make ex-king of a destroyed faction to join player's faction as a lord?

sure, you can even see this done in VC as a example (start a new royal game)

Ansiktslos said:
Does it require lots of modding, or may be done easily?

you will have to review some code (depends on your own mod base - Native, Floris, etc). The hard/easy part depends on your experience really, so you will only know once you try (shouldn't be hard at all)
 
Status
Not open for further replies.
Back
Top Bottom