Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Hello. I want to add more maps and unit types to the Custom Battle. Maps can be from the single-player campaign battles. I want to make this for "With Fire and Sword", but I assume it is done the same way for "Warband" as well.
Could you tell me how to implement this?
 
vitali-attila said:
Hello. I want to add more maps and unit types to the Custom Battle. Maps can be from the single-player campaign battles. I want to make this for "With Fire and Sword", but I assume it is done the same way for "Warband" as well.
Could you tell me how to implement this?

For making a map, enter a scene and edit it with the Edit Mod. Then rename that scene's sco file which is in a folder called Resource in the directory of Warband (or WFaS) according to which custom battle map you want to replace.
 
That's just replacing them, though. Here's how to go about it:

Find quick_battle_battle_scenes_end in module_constants.py, then look up the scene it's "equal" to in module_scenes.py. Add a scene just before that line by copying one of the others -- you'll have to change the name though. Use http://mbcommands.ollclan.eu/terrain/ to generate a scene code (which should go in the same place as in the other scenes).

You might also want to create an icon and name for the scene, but it's not essential.
 
fladin said:
Nameless Warrior said:
Does anyone know which code deals with where and when lords reappear after being defeated in battle. I have looked through scripts, simple triggers and game menus using key words but can't find anything.

I think it's that trigger, in simple_triggers, but I'm not sure
Code:
  # Respawn hero party after kingdom hero is released from captivity.
  (48, 
   [
       (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
         (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),

         (str_store_troop_name, s1, ":troop_no"),
       
         (neg|troop_slot_ge, ":troop_no", slot_troop_prisoner_of_party, 0),
         (neg|troop_slot_ge, ":troop_no", slot_troop_leaded_party, 1),

         (store_troop_faction, ":cur_faction", ":troop_no"),
         (try_begin),
           (eq, ":cur_faction", "fac_outlaws"), #Do nothing
         (else_try),         
           (try_begin),
             (eq, "$cheat_mode", 2),
             (str_store_troop_name, s4, ":troop_no"),
             (display_message, "str_debug__attempting_to_spawn_s4"),
           (try_end),
           
           (call_script, "script_cf_select_random_walled_center_with_faction_and_owner_priority_no_siege", ":cur_faction", ":troop_no"),#Can fail
           (assign, ":center_no", reg0),

           (try_begin),
             (eq, "$cheat_mode", 2),             
             (str_store_party_name, s7, ":center_no"),
			 (str_store_troop_name, s0, ":troop_no"),
             (display_message, "str_debug__s0_is_spawning_around_party__s7"),
           (try_end),
       
           (call_script, "script_create_kingdom_hero_party", ":troop_no", ":center_no"),

		   (try_begin),
		     (eq, "$g_there_is_no_avaliable_centers", 0),
             (party_attach_to_party, "$pout_party", ":center_no"),
           (try_end),
           
           #new
           #(troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
		   #(call_script, "script_npc_decision_checklist_party_ai", ":troop_no"), #This handles AI for both marshal and other parties		
		   #(call_script, "script_party_set_ai_state", ":party_no", reg0, reg1),
		   #new end

           (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
           (call_script, "script_party_set_ai_state", ":party_no", spai_holding_center, ":center_no"),           
           
         (else_try),
           (neg|faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active),
           (try_begin),
             (is_between, ":troop_no", kings_begin, kings_end),
             (troop_set_slot, ":troop_no", slot_troop_change_to_faction, "fac_commoners"),
           (else_try),
             (store_random_in_range, ":random_no", 0, 100),
             (lt, ":random_no", 10),
             (call_script, "script_cf_get_random_active_faction_except_player_faction_and_faction", ":cur_faction"),
             (troop_set_slot, ":troop_no", slot_troop_change_to_faction, reg0),
           (try_end),
         (try_end),
       (try_end),
    ]),

Thanks for that. I think my notepad ++ "find" function" is going haywire. I posted so many combinations of code from that and it never found anything yet when I found it by scrolling it was there.
 
jacobhinds said:
That's just replacing them, though. Here's how to go about it:

Find quick_battle_battle_scenes_end in module_constants.py, then look up the scene it's "equal" to in module_scenes.py. Add a scene just before that line by copying one of the others -- you'll have to change the name though. Use http://mbcommands.ollclan.eu/terrain/ to generate a scene code (which should go in the same place as in the other scenes).

You might also want to create an icon and name for the scene, but it's not essential.

Thank you both, Dragos and jacobhinds, for the help. I preferred to do what jacobhinds wrote. And it worked nice)), though with some bugs: because there is no icon and name for the new map, the game takes them from the next map and thus icons represent the wrong scenes. So could you tell me how to add icons and names?
 
Hello , I am kind of new and lost in these forums but in either case my questions : Does anyone knows which file is responsible for village improvement/building values? If someone could point it for me in Native module I would really appreciate it, because I want to see the structure of the code and replicate it and add more build able buildings for villages......Also by the way how do you add new build-able buildings in game?
 
vitali-attila said:
So could you tell me how to add icons and names?

To add names, go to module_strings.py and find the strings named quick_battle_scene_1 etc. Add a name in the same position you added the scene. So for example, if you added a scene between quick_battle_scene_3 and quick_battle_scene_4, You'll need to add a name there. It doesn't have to have the same name, it's only the order that matters.

To add icons, go to module_meshes.py and look for cb_ui_maps_scene_01 etc. You'll do the same thing here; add a mesh between the scenes icons you just used.
The difference here is that you'll have to create a texture, material and mesh using openbrf. Use the meshes and textures in user_interface_c.brf as a template.



commanderx said:
Hello , I am kind of new and lost in these forums but in either case my questions : Does anyone knows which file is responsible for village improvement/building values? If someone could point it for me in Native module I would really appreciate it, because I want to see the structure of the code and replicate it and add more build able buildings for villages......Also by the way how do you add new build-able buildings in game?

The code for buildings is sort of all over the place. Improvements are set via "slots", which are packets of data (specifically, integers) assigned to an entity, be it a village, troop, scene prop or whatever. For improvements, these slots are either 0 (not built) or 1 (built). The effects are then applied in various scripts, or via timed triggers. You'll need some understanding as to how slots work if you want to make your own improvement, but here's the general gist:
Code:
slot_center_has_manor            = 130 #village
slot_center_has_fish_pond        = 131 #village
slot_center_has_watch_tower      = 132 #village
slot_center_has_school           = 133 #village
slot_center_has_messenger_post   = 134 #town, castle, village
slot_center_has_prisoner_tower   = 135 #town, castle
These lines can be found in module_constants.py, which is where all slots are defined. Anything with slot_center on the beginning is a "settlement" slot. Every settlement slot has to have a different number otherwise you'll cause problems with overlap. The numbers themselves don't really matter much, as long as you aren't adding thousands of them.

Find an unused number (there are some empty slots before slot_center_has_manor, i.e. 127, 128 and 129). Then add your own slot, e.g. slot_center_has_irrigation = 129.

You will then have to go to module_game_menus.py and search for "center_manage" (with the quotes). Scroll down a bit and you'll see options for things like "center_build_manor". Just paste one of these somewhere in the list, and it will add it as an option for building.
      ("center_build_irrigation",[(eq, reg6, 0),
                            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
                            (party_slot_eq, "$g_encountered_party", slot_center_has_irrigation, 0),
                                  ],
      "Build farmland irrigation.",[(assign, "$g_improvement_type", slot_center_has_irrigation),
                        (jump_to_menu, "mnu_center_improve"),]),
Change the bits in bold. This bit:
Code:
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
determines which settlements you're allowed to build in. Remove this line entirely if you want to allow the player to build anywhere.

Then go to module_scripts.py and find get_improvement_details. Copy one of these:
      (eq, ":improvement_no", slot_center_has_irrigation),
      (str_store_string, s0, "@Irrigation"),
      (str_store_string, s1, "@Irrigating the village's fields will provide a 1% boost to prosperity every week."),
      (assign, reg0, 15000),
    (else_try),
Once again, replace the bits in bold. The number at the bottom is the price, and also determines the time it takes to build.

Getting the building to actually do something is up to you. However, here's an example based on the above, which goes in module_simple_triggers.py.

Code:
	(7 * 24,
   [(try_for_range, ":center_no", villages_begin, villages_end),
      (party_slot_eq, ":center_no", slot_center_has_watch_irrigation, 1),
        (call_script, "script_change_center_prosperity", ":center_no", 1),
    (try_end),
   ]),

Every week (7 times 24 hours), it cycles through all the villages, checks if they have irrigation, and changes prosperity by 1 if the above is true.

Hope this helps.
 
Can I add a video to the game? For example, I will add a button and whenever I click it, the video will start. Then whenever I click anywhere in the screen, the screen will return. Is it possible?
 
buz said:
spawn_around_party = 1100 # ID of spawned party is put into reg(0)

I know that operation but is there another way to get party id from a party template?

show us your user case. A template is a generic representation -> many parties have the same template, so it is a many to one relation




Another topic: I was checking a bug earlier and decided to add a logger for my source code. It works like this:

1) Insert this on your .py file
Code:
import inspect

def lineno():
    return str(inspect.currentframe().f_back.f_lineno)

2) Now you can add a
Code:
(display_message, "@error on line: " + lineno()),

and it will add to your logs the position on your source file (like line 12345).

Cheers
 
how to add ?
module_scripts.py
from module_items import *

def v():
  item_bodyarmor = []
  for i_item in xrange(len(items)):
    item_bodyarmor.append((item_set_slot, i_item, slot_item_body_armor, get_body_armor(items[i_item][6])))
  return item_bodyarmor[:]
 
def get_item_leg_armor():
  item_legarmor = []
  for i_item in xrange(len(items)):
    item_legarmor.append((item_set_slot, i_item, slot_item_leg_armor, get_leg_armor(items[i_item][6])))
  return item_legarmor[:] 
 
def get_item_head_armor():
  item_headarmor = []
  for i_item in xrange(len(items)):
    item_headarmor.append((item_set_slot, i_item, slot_item_head_armor, get_head_armor(items[i_item][6])))
  return item_headarmor[:] 
 
# def get_item_hit_points():  ###cannot set item hitpoints
  # item_hitpoints = []
  # for i_item in xrange(len(items)):
    # item_hitpoints.append((item_set_slot, i_item, slot_item_hit_points, get_hit_points(items[i_item][6])))
  # return item_hitpoints[:]

def get_item_shield_height():
  item_shield_height = []
  for i_item in xrange(len(items)):
    item_shield_height.append((item_set_slot, i_item, slot_item_shield_height, shield_height(items[i_item][6])))
  return item_shield_height[:]   
 
def get_item_shield_width():
  item_shield_width = []
  for i_item in xrange(len(items)):
    item_shield_width.append((item_set_slot, i_item, slot_item_shield_width, shield_width(items[i_item][6])))
  return item_shield_width[:] 
:???: :???:
[/quote]
 
Dragos said:
Can I add a video to the game? For example, I will add a button and whenever I click it, the video will start. Then whenever I click anywhere in the screen, the screen will return. Is it possible?
it is possible with WSE, you should check here. it's being ported to the newer versions so I don't know if the play_video command is already done.
 
kalarhan said:
A template is a generic representation -> many parties have the same template, so it is a many to one relation

I thought every party with same party template have same party id but you say not so I don't have any question now, 'spawn_around_party' operation is enough for single party to get party id.

Thanks.
 
Ikaguia said:
Dragos said:
Can I add a video to the game? For example, I will add a button and whenever I click it, the video will start. Then whenever I click anywhere in the screen, the screen will return. Is it possible?
it is possible with WSE, you should check here. it's being ported to the newer versions so I don't know if the play_video command is already done.

There is a play_bink_video operation that I may use. Is there any way to add only play_bink_video operation?
 
jacobhinds said:
To add names, go to module_strings.py and find the strings named quick_battle_scene_1 etc. Add a name in the same position you added the scene. So for example, if you added a scene between quick_battle_scene_3 and quick_battle_scene_4, You'll need to add a name there. It doesn't have to have the same name, it's only the order that matters.

To add icons, go to module_meshes.py and look for cb_ui_maps_scene_01 etc. You'll do the same thing here; add a mesh between the scenes icons you just used.
The difference here is that you'll have to create a texture, material and mesh using openbrf. Use the meshes and textures in user_interface_c.brf as a template.

Thank you. I didn't get how to add an icon but that's not a problem now - int the battle the units from both sides spawn together in one place instead of spawning on different ends of the map as usual. I tried using sf_auto_entry_points, but it moved only the player. Do you know how to fix this?

Both sides spawn in one place:
52405f4c900fb1f826dd45ad998a957d.jpg
42673aa19aabf15dea0f9d895db20961.jpg
 
Hello m'a lords. I have a little problem with animations in my mod. I have not changed anything on the animations files, but when changing the castle guard troops, sometime I see on them some animations, and sometimes others.

In three of the six factions, the castle guards look like this (warband cool animations)

zuLlX.jpg

And in the other three factions, the castle guards look like this (terrible M&B animations, I think)

yqw2E.jpg

--------

I don't know what causes this but I think it's something related to the armors they have. Do anyone know what can I do to make them all use the same animations?

Cheers and thank you.
 
mike56 said:
Hello m'a lords. I have a little problem with animations in my mod. I have not changed anything on the animations files, but when changing the castle guard troops, sometime I see on them some animations, and sometimes others.

In three of the six factions, the castle guards look like this (warband cool animations)

zuLlX.jpg

And in the other three factions, the castle guards look like this (terrible M&B animations, I think)

yqw2E.jpg

--------

I don't know what causes this but I think it's something related to the armors they have. Do anyone know what can I do to make them all use the same animations?

Cheers and thank you.

The animations in the lower screenshot are only used for standing women in warband, and not ladies either, just townswomen, female NPCs and merchants. The engine's somehow assuming that they're not men, which osunlikely since the default gender for new races is male (assumong you've added now genders).

It's much more likely that the scripts that determine NPC animations are making exceptions for your new guard troops, which might mean they're outside a certain range. Search all your files for agent_set_animation (there aren't too many instances in native), and you'll find the relevant script.
 
Status
Not open for further replies.
Back
Top Bottom