Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
TheVideoGameInn said:
module_items and they are the same (obviously module_items has many more items, though siege_supply is identical and marked as a quest item in both). I really don't see the problem?

they are not the same if your version has more stuff in it  :mrgreen:

you most likely made a mistake in that file, but by not reading Lumos guide on syntax you are not seeing it for what it is. @the_dragon idea on WRECK may help you, as that compiler is better at pointing out the syntax (basic) errors
 
The place that 'itm_siege_supply' should be defined is in ID_items, but since it says it is undefined, then there was an error during the compilation of items (one time). So not all items ids were generated in ID_items, so all the uses of 'itm_siege_supply' generates errors.
To fix this you should normally delete all references to 'itm_siege_supply', then compile, then add back the references.
WRECK fixes this automatically by first generating the ids and later use them (the normal compiler generates the ids and uses them at the next compilation, not at the current compilation (so the compilation depends on how the last compilation ended)).
 
Hello. I wrote a code, which should count how many empty inventory slots for weapons i have.
Code:
(assign, ":empty_slots", 0), #number of empty slots
#If the agent has 2 empty weapon slots
(try_for_range, ":slot_no", 0, 4),
  (troop_get_inventory_slot, ":cur_slot", ":cur_agent", ":slot_no"),
  (eq, ":cur_slot", -1),  #if it's an empty slot
  (val_add, ":empty_slots", 1), #increment the number of empty slots
(try_end),
But it does not work in the game. Maybe it is incorrect?
 
vitali-attila said:
Hello. I wrote a code, which should count how many empty inventory slots for weapons i have.
Code:
(assign, ":empty_slots", 0), #number of empty slots
#If the agent has 2 empty weapon slots
(try_for_range, ":slot_no", 0, 4),
  (troop_get_inventory_slot, ":cur_slot", ":cur_agent", ":slot_no"),
  (eq, ":cur_slot", -1),  #if it's an empty slot
  (val_add, ":empty_slots", 1), #increment the number of empty slots
(try_end),
But it does not work in the game. Maybe it is incorrect?

instead of that, try by using the 4 predefined weapons slots : ek_item_0, ek_item_1 , ek_item_2 and ek_item_3
 
WRECK says
Error in module_constants.py file:

Traceback (most recent call last):
  File "C:\Users\Samuel\Downloads\mb_warband_module_system_1153\Module_system 1.
153\integrated_ms\compiler.py", line 1748, in <module>
    from module_constants import *
  File "C:\Users\Samuel\Downloads\mb_warband_module_system_1153\Module_system 1.
153\integrated_ms\module_constants.py", line 469, in <module>
    num_trade_goods = itm_siege_supply - itm_spice
NameError: name 'itm_siege_supply' is not defined

Press any key to continue . . .
 
Cozur said:
fladin said:
are you sure you put it in a ti_before_mission_start ?
Yeap.

ok, here is my code :

Code:
#----------------------------------------------------------------
#mission templates before this point are hardwired into the game.
#-----------------------------------------------------------------

  (
    "town_center",0,-1,
    "Default town visit",
     ...
     ...
    ...
      (ti_before_mission_start, 0, 0, [],
      [
        (assign, "$g_main_attacker_agent", 0),
		(store_current_scene, ":cur_scene"),
		(try_begin),
			(eq, ":cur_scene", "scn_town_16_center"),
                        (store_random_in_range, ":rain_power", 50, 100),
                        (set_rain,2,":rain_power"),
		(try_end),
	  ]),
the result :
s2QW1ld.jpg
 
vitali-attila said:
Hello. I wrote a code, which should count how many empty inventory slots for weapons i have.
Code:
(assign, ":empty_slots", 0), #number of empty slots
#If the agent has 2 empty weapon slots
(try_for_range, ":slot_no", 0, 4),
  (troop_get_inventory_slot, ":cur_slot", ":cur_agent", ":slot_no"),
  (eq, ":cur_slot", -1),  #if it's an empty slot
  (val_add, ":empty_slots", 1), #increment the number of empty slots
(try_end),
But it does not work in the game. Maybe it is incorrect?

if you are checking the weapons your agent has (in a mission), you need to use agent_ operations, and not the troop_ operations

Code:
agent_get_wielded_item                   = 1726  # (agent_get_wielded_item, <destination>, <agent_id>, <hand_no>),
                                                 # Retrieves the item reference that the agent is currently wielding in his right hand (hand_no = 0) or left hand (hand_no = 1). Note that weapons are always wielded in right hand, and shield in left hand. When wielding a two-handed weapon (including bows and crossbows), this operation will return -1 for left hand.

agent_get_item_slot                      = 1804  # (agent_get_item_slot, <destination>, <agent_id>, <value>),
                                                 # Retrieves item_id for specified agent's slot Possible slot values range in 0..7, order is weapon1, weapon2, weapon3, weapon4, head_armor, body_armor, leg_armor, hand_armor.



Caba`drin said:
Troops refer to the entries in module_troops by the name assigned to them there. "trp_player" is the player, "trp_npc##" for the various companions, "trp_knight_#_##" for lords, and "trp_swadian_footman" etc, etc. With more generic soldiers, the entry in module_troops is used as a "template" to create multiple instances of them in each party, etc.

Alternatively, agents refer to the specific actors, by number, in a scene (whether that scene is a battle, a tavern or what have you). Agents are created from the templates in module_troops...for the player, companions, NPC lords, they are still unique, but with generic soldiers multiple agents can be created from a single troop template. Each agent has a unique number for that scene, but when the scene ends, the agent doesn't exist any more so its agent id is meaningless.
 
fladin said:
Cozur said:
fladin said:
are you sure you put it in a ti_before_mission_start ?
Yeap.

ok, here is my code :

Code:
#----------------------------------------------------------------
#mission templates before this point are hardwired into the game.
#-----------------------------------------------------------------

  (
    "town_center",0,-1,
    "Default town visit",
     ...
     ...
    ...
      (ti_before_mission_start, 0, 0, [],
      [
        (assign, "$g_main_attacker_agent", 0),
		(store_current_scene, ":cur_scene"),
		(try_begin),
			(eq, ":cur_scene", "scn_town_16_center"),
                        (store_random_in_range, ":rain_power", 50, 100),
                        (set_rain,2,":rain_power"),
		(try_end),
	  ]),
the result :
s2QW1ld.jpg

Thanks, I'll try it out.
 
litdum said:
I think I have a "slot" problem. I am trying to add second scenes for the courts. Original court scenes use slot, slot_town_castle, so I ve looked for it in module_scripts, I found it and i added a new one for the second scenes I made:
to module_scripts:
# Towns (loop)
      (try_for_range, ":town_no", towns_begin, towns_end),
        (store_sub, ":eek:ffset", ":town_no", towns_begin),
        (party_set_slot,":town_no", slot_party_type, spt_town),
        #(store_add, ":cur_object_no", "trp_town_1_seneschal", ":eek:ffset"),
        #(party_set_slot,":town_no", slot_town_seneschal, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_center", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_center, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_castle", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_castle, ":cur_object_no"),

        (store_add, ":cur_object_no", "scn_town_1_castlea", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_castlea, ":cur_object_no"),


        (store_add, ":cur_object_no", "scn_town_1_prison", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_prison, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_walls", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_walls, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_tavern", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_tavern, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_store", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_store, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_arena", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_arena, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_alley", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_alley, ":cur_object_no"),
        (store_add, ":cur_object_no", "trp_town_1_mayor", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_elder, ":cur_object_no"),
        (store_add, ":cur_object_no", "trp_town_1_tavernkeeper", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_tavernkeeper, ":cur_object_no"),
        (store_add, ":cur_object_no", "trp_town_1_weaponsmith", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_weaponsmith, ":cur_object_no"),
        (store_add, ":cur_object_no", "trp_town_1_armorer", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_armorer, ":cur_object_no"),
        (store_add, ":cur_object_no", "trp_town_1_merchant", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_merchant, ":cur_object_no"),
        (store_add, ":cur_object_no", "trp_town_1_horse_merchant", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_horse_merchant, ":cur_object_no"),
        (store_add, ":cur_object_no", "scn_town_1_center", ":eek:ffset"),
        (party_set_slot,":town_no", slot_town_center, ":cur_object_no"),
        (party_set_slot,":town_no", slot_town_reinforcement_party_template, "pt_center_reinforcements"),
      (try_end),

# Castles
      (try_for_range, ":castle_no", castles_begin, castles_end),
        (store_sub, ":eek:ffset", ":castle_no", castles_begin),
        (val_mul, ":eek:ffset", 3),

#        (store_add, ":senechal_troop_no", "trp_castle_1_seneschal", ":eek:ffset"),
#        (party_set_slot,":castle_no", slot_town_seneschal, ":senechal_troop_no"),
        (store_add, ":exterior_scene_no", "scn_castle_1_exterior", ":eek:ffset"),
        (party_set_slot,":castle_no", slot_castle_exterior, ":exterior_scene_no"),
        (store_add, ":interior_scene_no", "scn_castle_1_interior", ":eek:ffset"),
        (party_set_slot,":castle_no", slot_town_castle, ":interior_scene_no"),

        (store_add, ":interior_scene_no", "scn_castle_1_interiora", ":eek:ffset"),
        (party_set_slot,":castle_no", slot_town_castlea, ":interior_scene_no"),


        (store_add, ":interior_scene_no", "scn_castle_1_prison", ":eek:ffset"),
        (party_set_slot,":castle_no", slot_town_prison, ":interior_scene_no"),

        (party_set_slot,":castle_no", slot_town_reinforcement_party_template, "pt_center_reinforcements"),
        (party_set_slot,":castle_no", slot_party_type, spt_castle),
        (party_set_slot,":castle_no", slot_center_is_besieged_by, -1),
      (try_end),
to module_constans:
slot_town_center        = 10
slot_town_castle        = 11
slot_town_prison        = 12
slot_town_tavern        = 13
slot_town_store        = 14
slot_town_arena        = 16
slot_town_alley        = 17
slot_town_walls        = 18
slot_center_culture    = 19

slot_town_tavernkeeper  = 20
slot_town_weaponsmith  = 21
slot_town_armorer      = 22
slot_town_merchant      = 23
slot_town_horse_merchant= 24
slot_town_elder        = 25
slot_center_player_relation = 26
##diplomacy start+ This range doesn't need to be exhaustive (e.g. the seneschal isn't included), but it should be continuous
dplmc_slot_town_merchants_begin = slot_town_tavernkeeper
dplmc_slot_town_merchants_end = slot_town_elder + 1
##diplomacy end+

slot_center_siege_with_belfry = 27
slot_center_last_taken_by_troop = 28
slot_town_castlea = 29
and of course added the new scenes to module_scenes:
  ("castle_1_interiora",sf_indoors, "dungeon_entry_a", "bo_dungeon_entry_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_1_seneschal"]),
    ("castle_2_interiora",sf_indoors, "interior_castle_u", "bo_interior_castle_u", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_2_seneschal"]),
...
...
  ("castle_48_interiora",sf_indoors, "arabian_interior_keep_b", "bo_arabian_interior_keep_b", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_37_seneschal"]),
and
  ("town_1_castlea",sf_indoors,"viking_interior_keep_a", "bo_viking_interior_keep_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["town_1_seneschal"]),
  ("town_2_castlea",sf_indoors,"viking_interior_keep_a", "bo_viking_interior_keep_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["town_2_seneschal"]),
  ("town_3_castlea",sf_indoors,"castle_h_interior_b", "bo_castle_h_interior_b", (-100,-100),(100,100),-100,"0",
    ["exit"],["town_3_seneschal"]),
...
...
  ("town_22_castlea",sf_indoors, "arabian_interior_keep_a", "bo_arabian_interior_keep_a", (-100,-100),(100,100),-100,"0x00000007300005000002308c00004a840000624700004fda",
    ["exit"],["town_22_seneschal"]),
When I used this slot_town_castlea it works for towns but for castles it doesn't. Random castle scenes turn up. For example when I tried to enter to Malayurg castle, I spawn in a sarranid prison. How can I solve it? I ve done exactly same as original slot_town_castle. Why does it not work  :sad:  ? I could not find where the mistake is.
I changed the slot number to other various numbers, checked the castlea scenes in module_scenes:
("castle_1_exterior",sf_generate,"none", "none", (0,0),(100,100),-100,"0x30054da28004050000005a76800022aa00002e3b",
    [],[],"outer_terrain_steppe"),
  ("castle_1_interior",sf_indoors, "dungeon_entry_a", "bo_dungeon_entry_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_1_seneschal"]),
  ("castle_1_interiora",sf_indoors, "dungeon_entry_a", "bo_dungeon_entry_a", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_1_seneschal"]),

  ("castle_1_prison",sf_indoors,"interior_prison_a", "bo_interior_prison_a", (-100,-100),(100,100),-100,"0",
    [],[]),
#      2 Plain
  ("castle_2_exterior",sf_generate,"none", "none", (0,0),(100,100),-100,"0xa00363638005c16d00003c82000037e000002303",
    [],[],"outer_terrain_plain"),
  ("castle_2_interior",sf_indoors, "interior_castle_u", "bo_interior_castle_u", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_2_seneschal"]),
  ("castle_2_interiora",sf_indoors, "interior_castle_u", "bo_interior_castle_u", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_2_seneschal"]),

  ("castle_2_prison",sf_indoors,"interior_prison_d", "bo_interior_prison_d", (-100,-100),(100,100),-100,"0",#### B bkullanilmayacak
    [],[]),
#      3 Plain
  ("castle_3_exterior",sf_generate,"none", "none", (0,0),(100,100),-100,"0x0000000030044e900003dd02000077b20000400100005697",
    [],[],"outer_terrain_plain"),
  ("castle_3_interior",sf_indoors, "interior_castle_m", "bo_interior_castle_m", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_3_seneschal"]),
  ("castle_3_interiora",sf_indoors, "interior_castle_m", "bo_interior_castle_m", (-100,-100),(100,100),-100,"0",
    ["exit"],["castle_3_seneschal"]),

  ("castle_3_prison",sf_indoors,"interior_prison_e", "bo_interior_prison_e", (-100,-100),(100,100),-100,"0",
    [],[]),
...
... rest of them ...
But this slot_town_castlea which is I made still does not work for castles. I must find how to create a new "slot_town_castle". Otherwise a lot of scenes I made will be useless  :sad: . Most modders add castles to their mod and I think there should be someone who know how to create a new slot for castle interior scenes. I could not create it. This one (slot_town_castlea) works for only towns. What should I do to this slot work for castles as well?

Edit: I made it!
 
TheVideoGameInn said:
I've tried every single suggestion, and nothing works.
As others have stated before - please dont spam your particular issue. If someone knows the answer, they ll get around to helping you. If they do not, you bumps are wasted regardless. If you are worried that somebody didnt see your inquiry - ask again the next day... not the next hour (unless ofc you have new information).

I would suggest that you upload the potential culprits, i.e. module_ items, constants, map_icons and hope that somebody will glance it over. (Or post them in code[])
 
Has anyone by small chance happen to have a copy of diplomacy that they modded to have bodyguards? I tried following the tutorial at http://forums.taleworlds.com/index.php?topic=151908.0    but it didn't work. thanks if you do happen to be that small chances, miracle really.
 
themanwhocrys2 said:
Has anyone by small chance happen to have a copy of diplomacy that they modded to have bodyguards? I tried following the tutorial at http://forums.taleworlds.com/index.php?topic=151908.0    but it didn't work. thanks if you do happen to be that small chances, miracle really.

I had a extra comma all good now
 
kalarhan said:
if you are checking the weapons your agent has (in a mission), you need to use agent_ operations, and not the troop_ operations

Code:
agent_get_wielded_item                   = 1726  # (agent_get_wielded_item, <destination>, <agent_id>, <hand_no>),
                                                 # Retrieves the item reference that the agent is currently wielding in his right hand (hand_no = 0) or left hand (hand_no = 1). Note that weapons are always wielded in right hand, and shield in left hand. When wielding a two-handed weapon (including bows and crossbows), this operation will return -1 for left hand.

agent_get_item_slot                      = 1804  # (agent_get_item_slot, <destination>, <agent_id>, <value>),
                                                 # Retrieves item_id for specified agent's slot Possible slot values range in 0..7, order is weapon1, weapon2, weapon3, weapon4, head_armor, body_armor, leg_armor, hand_armor.



Caba`drin said:
Troops refer to the entries in module_troops by the name assigned to them there. "trp_player" is the player, "trp_npc##" for the various companions, "trp_knight_#_##" for lords, and "trp_swadian_footman" etc, etc. With more generic soldiers, the entry in module_troops is used as a "template" to create multiple instances of them in each party, etc.

Alternatively, agents refer to the specific actors, by number, in a scene (whether that scene is a battle, a tavern or what have you). Agents are created from the templates in module_troops...for the player, companions, NPC lords, they are still unique, but with generic soldiers multiple agents can be created from a single troop template. Each agent has a unique number for that scene, but when the scene ends, the agent doesn't exist any more so its agent id is meaningless.

Hello. Thank you, kalarhan and fladin, for the help.
I did what kalarhan said and it worked! Thank you very much again. :smile:

There is another thing I can't solve. If the ":cur_agent" is the player, the code should remove the ":cur_item"(which he has in one of his weapon slots) from the inventory, of course, forever.
The code below is what I tried to do. But it does not work...
Code:
(try_begin),
  (eq, ":cur_agent", ":player_agent"), 
  (assign, ":break", 0),
  (try_for_range, ":slot_no", 0, 4),
    (eq, ":break", 0),
    (agent_get_item_slot, ":cur_slot", ":player_agent", ":slot_no"),
    (eq, ":cur_slot", ":cur_item"), 
    #(troop_remove_item, "trp_player", ":cur_item"), #TEST -> does not work 
    (troop_set_inventory_slot, "trp_player", ":slot_no", -1), #does not work either
  (assign,":break", 1),
(try_end),
(try_end),
Could you please tell me what is wrong and how to fix it?
 
vitali-attila said:
There is another thing I can't solve. If the ":cur_agent" is the player, the code should remove the ":cur_item"(which he has in one of his weapon slots) from the inventory, of course, forever.
The code below is what I tried to do. But it does not work...
Code:
(try_begin),
  (eq, ":cur_agent", ":player_agent"), 
  (assign, ":break", 0),
  (try_for_range, ":slot_no", 0, 4),
    (eq, ":break", 0),
    (agent_get_item_slot, ":cur_slot", ":player_agent", ":slot_no"),
    (eq, ":cur_slot", ":cur_item"), 
    #(troop_remove_item, "trp_player", ":cur_item"), #TEST -> does not work 
    (troop_set_inventory_slot, "trp_player", ":slot_no", -1), #does not work either
  (assign,":break", 1),
(try_end),
(try_end),
Could you please tell me what is wrong and how to fix it?

did you read Caba's text about troops X agents?

about your snippet: you are not showing how you are getting the id's for the agent and the player_agent, so no way to know if they are correct.
If you want to remove the item for the mission duration, use a agent_ operation
If you want to also remove the item forever, then add a extra line for your troop.

Code:
troop_remove_item                        = 1531  # (troop_remove_item, <troop_id>, <item_id>),
                                                 # Removes an item from the troop equipment or inventory. Operation will remove first matching item it finds.

keep in mind that operation does not take into account the IMOD of a item, and if you have duplicates it will have some weird results :XD
you should get the current item IMOD and look for it on the troop inventory.

You should never assume the agents slots are the same as the troop, not even for weapons. You can drop and pick new gear in a mission, and that will break your script.
 
Status
Not open for further replies.
Back
Top Bottom