Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Code:
#Parties made into ships
  (0.1, 0, 0.0, [],
  [(try_for_parties, ":cur_party"),
  (party_get_current_terrain, ":terrain", ":cur_party"),
  (eq, ":terrain", 15),
  (party_get_template_id, ":cur_template", ":cur_party"),        
 (this_or_next|eq, ":cur_template", "pt_center_reinforcements_e"),
 (eq, ":cur_template", "pt_sea_raiders_e"),
  (party_set_icon, ":cur_party", "icon_ship"),
 (else_try),
 (eq, ":terrain", 15),
 (eq, ":cur_template", "pt_kingdom_hero_party"),
  (party_set_icon, ":cur_party", "icon_ship_lord"),
 (else_try),
 (eq, ":terrain", 15),
 (eq, ":cur_template", "pt_kingdom_hero_party"),
(party_set_icon, ":cur_party", "icon_ship_overlord"),
 (else_try),

Say I wanted to differentiate between the ship icons for different factions. I want faction 1 to have icon_ship_lord and faction 4 to have icon_ship_overlord when travelling on terrain_15.

What would be the component to differentiate based on faction?
 
Cozur said:
What would be the component to differentiate based on faction?

Code:
store_faction_of_party                = 2204  # (store_faction_of_party, <destination>, <party_id>),
                                              # Retrieves current faction allegiance of the party.
 
Good evening, it's me, again  :oops:

I'm making progress over my mod. Still, I want to learn how to make quests. I found out an old tutorial (https://forums.taleworlds.com/index.php/topic,53259.0.html) here in The Forge but that wasnt as thorough as I thought, and I need some more explanations for that.

Can someone help me showing me another tutorial here on TW Forum, or a video, or something else? What can I do?
I'm planning to base my mod on a lot of quests, if possible.
 
Heinrik von Waiblingen said:
What can I do?

I don't recall any newer tutorial. But what you can do right now: choose a few Native quests and learn how they work in detail

1) Merchant quest (good to learn how to use special scenes, mission template conditions, etc)
2) Random quests from a mayor (good to learn how to use the script that setups random quests)
3) A few more quests (learn how to use dialogs, game menus and the quests script: start_quest, etc)

You can start by choosing a quest on module_quests.py and doing a full search on its ID (qst_collect_men). Use Sublime Text or Notepad++ with Explorer plugin for the search.

Remember you should use the scripts, not the operations, when they are available.
 
I learned how to make quests from Cozur's resource here. It is not really a tutorial, it is more of a template, but if you study carefully how he did it, you'll be making unique quests in no time :smile:

(it's actually what got me started into modding, cause I wanted to understand Cozur's template).
 
Khamukkamu said:
I learned how to make quests from Cozur's resource here. It is not really a tutorial, it is more of a template, but if you study carefully how he did it, you'll be making unique quests in no time :smile:

(it's actually what got me started into modding, cause I wanted to understand Cozur's template).

I'm taking a look at it, sounds great as template, but I really needed a tutorial more, I'm still learning how to mod. I hope to be as smart as you were, learning from this template, I'll try :razz:

Thx in anycase for this, it will be surely useful in my mod.
 
kalarhan said:
Khamukkamu said:
Specifically, if a combination of a modifier (e.g Masterwork) and a specific item (e.g Bastard Sword) is present, name it differently (e.g "The Bastard Slayer")?

this may help: script that controls the pre-text

Code:
# script_get_item_modifier_effects moto chief
  # Input: itp_*, imod_*
  # Output: reg0 damage effect
  #         reg1 speed effect
  #         reg2 armor effect
  #         reg3 hit points effect
  #         reg4 difficulty effect
  #         reg5 price factor
  #         s0 descriptor string
  ("get_item_modifier_effects",

Code:
(str_store_string, s0, "@Balanced"),

You could use it for some special names, but you can't change the normal part of it. In your example, "Something from script" + " Bastard Sword".

A alternative is to use another item (a copy) with the special name, and replace them using a trigger/event from the player's inventory. In this case you can add a exception to the script above so no other extra texts will be included, like "" + " The Bastard Slayer". Or make the named sword plain (no imodbits allowed)

I studied this script and, unless I misunderstood, it seems that it stores the name to s0, which then is called through dialogue. So I can call it something from script ("The Slayer of"), and through dialog someone would say, "Here you go, The Slayer of Bastard Sword,' but when I take a look at my inventory, won't it still say, "Masterwork Bastard Sword?"

 
Khamukkamu said:
but when I take a look at my inventory, won't it still say, "Masterwork Bastard Sword?"

not sure how you intend to limit access to the special weapons. Can you upgrade weapons using a blacksmith? Are they quest reward? Random luck for the shop inventory?

Consider this (the second suggestion)

1) Create normal item "Bastard Sword". Add imodbits as usual, but not the imodbit_masterwork. This way this sword will never be "Masterwork Bastard Sword"
2) Create a clone of the weapon. Apply the extra stats manually (dmg, speeed, requirement). Don't give it imodbits (so this sword cant be upgraded or downgraded, it will always be imod_plain). Name it "Slayer Sword of the First Age" or something
Code:
imod_masterwork  = 17 # +5 damage, ................. +1 speed, +4 prerequisite
^ you could use special textures for the blade....

Add both to merchants, control rarity, and that takes care of stores.
Don't add the clone to merchants, and reserve it to quests or the blacksmith special option.
And so on.

Remember imods are just a hardcoded way to give bonus/penalties to your items. The definitions for price/name are defined on /Data/item_modifiers.txt . The effects are hardcoded. You add the possibility of a imod be used/present on a item with the imodbit variable on module_items.py. And you can always add custom effects on your mission template.
 
Thanks for the reply.

I'm trying not to add new items (i.e create a clone) but use existing ones in order to keep the mod compatible with M&B 1.011 (which has an item limit) :smile: I'm just looking for a way to hack a new item in (by using imodbits + new mesh combo).

As for where items will appear, at this stage of the mod, it will  be on a troop and can't be purchasable or a quest reward. In both cases, they won't appear in shops.

2 follow-up questions:

1) Can I rename an imod / imod? I believe I can use the language files to do so. Therefore, what I can do is just rename one imod to something like (Artifact), so in our example, it will show up as Bastard Sword (Artifact).

2) The VC script we were talking about show that it can set damage, speed, price, etc and store them into reg0,reg1,reg2 etc. How would I add those effects in? By adding it to mission templates?

Thanks!

PS: I know some people would rather ask us to stop supporting M&B 1.011 in order to push through these limitations, but based on our download stats, there is still a significant amount of people playing TLD on M&B 1.011, and we can't just ignore them :smile:
 
Does anyone know why the operation "troop_is_mounted" doesn't work on dedicated servers? We're trying to create a class based AI system for our multiplayer bots, that currently works as intended on non-dedicated servers. However, the cavalry related parts fail because of "troop_is_mounted".
We know that "troop_is_guarantee_horse" exists, and that works perfectly fine, but other troops default to "tf_guarantee_all" when made, which means that we have a lot of background changes to make if troop_is_mounted doesn't work.
Does anyone know of another way around this?
 
Hi!

I have problem with understanding the code I have modiefied. (Yes, I know how it sounds).

First, from game_menu I wrote small code that sets player slot to 0,1,2,3,etc.

Then I want modified code from simple trigger to read this player slot and react accordingly.

From module_game_menus (however it isn't to important):
Code:
#####################################   MAP ICON THEME  #########################################
  
  ("icon_theme",mnf_disable_all_keys,
    "You can change player map icon here. This action will change party icon, when you are on horse, or on foot. To unlock more icon themes gain more renown, choose relevant faction culture or earn them by gaining or loosing honour. There are many ways of unlocking icon them, some of them are secret. Changing icon theme 'costs' 1 Doomsday Clock 'click'. ^^^ Current icon theme: {s7}",
    "none",
    [(str_store_troop_name_plural, s7, "trp_subculture_name"),],
	
    [
    
	
	#default	
      ("icon_set_1",[(troop_slot_ge, "trp_player", slot_troop_renown, 25)  ],"Default Theme",
      [  		
		(str_clear, s10),
		(str_store_string, s10, "@Default Theme"),
		(troop_set_plural_name, "trp_subculture_name", s10),
		(troop_set_slot, "trp_player", slot_player_unlocked_icon, 1), #default
		(val_add,"$doomsday_clock",1),
        
		(display_message, "@Map icon set: {s10}", 0x005aff),
		(display_message, "@Doomsday clock +1 day", 0x6600ff),
		(play_sound,"snd_quest_completed"),
		
		(jump_to_menu, "mnu_icon_theme"),         
       ]),       
	
	#Dwarf People	
      ("icon_set_2",[(troop_slot_ge, "trp_player", slot_troop_renown, 50)  ],"Dwarf People",
      [  		
		(str_clear, s10),
		(str_store_string, s10, "@Dwarf People"),
		(troop_set_plural_name, "trp_subculture_name", s10),
		(troop_set_slot, "trp_player", slot_player_unlocked_icon, 2), #Dwarf People      #######_CLICK ICON_###### reference: s-triggers # Updating player icon in every frame
		(val_add,"$doomsday_clock",1),
        
		(display_message, "@Map icon set: {s10}", 0x005aff),
		(display_message, "@Doomsday clock +1 day", 0x6600ff),
		(play_sound,"snd_quest_completed"),
		
		(jump_to_menu, "mnu_icon_theme"),         
       ]),    
	 
	#brigands and rangers	
      ("icon_set_3",[(troop_slot_ge, "trp_player", slot_troop_renown, 50)  ],"Brigands & Rangers",
      [  		
		(str_clear, s10),
		(str_store_string, s10, "@Brigands & Rangers"),
		(troop_set_plural_name, "trp_subculture_name", s10),
		(troop_set_slot, "trp_player", slot_player_unlocked_icon, 3), #Brigands & Rangers      #######_CLICK ICON_###### reference: s-triggers # Updating player icon in every frame
		(val_add,"$doomsday_clock",1),
        
		(display_message, "@Map icon set: {s10}", 0x005aff),
		(display_message, "@Doomsday clock +1 day", 0x6600ff),
		(play_sound,"snd_quest_completed"),
		
		(jump_to_menu, "mnu_icon_theme"),         
       ]),    
	
	#brigands and rangers	 EVIL UNLOCKER
      ("icon_set_4",[(le, "$player_honor", -25),  ],"Brigands & Rangers",
      [  		
		(str_clear, s10),
		(str_store_string, s10, "@Brigands & Rangers"),
		(troop_set_plural_name, "trp_subculture_name", s10),
		(troop_set_slot, "trp_player", slot_player_unlocked_icon, 4), #Brigands & Rangers      #######_CLICK ICON_###### reference: s-triggers # Updating player icon in every frame
		(val_add,"$doomsday_clock",1),
        
		
		
		(display_message, "@Map icon set: {s10}", 0x005aff),
		(display_message, "@Doomsday clock +1 day", 0x6600ff),
		(play_sound,"snd_quest_completed"),
		
		(jump_to_menu, "mnu_icon_theme"),         
       ]),
	   
	   
	   
      ("continue",[],"Go Back",
       [         
         (jump_to_menu, "mnu_internal_affairs"),         
       ]),       
    ]
  ),
  
  #####################################   MAP ICON THEME  #########################################

The problem is here, in simple_triggers.

First, the code:

Code:
(1,
   [
  (troop_get_slot, ":icon_no", "trp_player", slot_player_unlocked_icon),
  (assign, reg10, ":icon_no"),
  (display_message, "@Map icon set: {reg10}", 0x005aff),
    ]),
 
  # Updating player icon in every frame
  (0,
   [(troop_get_inventory_slot, ":cur_horse", "trp_player", 8), #horse slot
   (assign, ":new_icon", -1), 
	
	
	
	(troop_get_slot, ":icon_no", "trp_player", slot_player_unlocked_icon),
	
	
	(try_begin), #################default
	(eq, ":icon_no", 1),             
	(ge, ":cur_horse", 0),
                (assign, ":new_icon", "icon_player_horseman"),
    (else_try),
	(eq, ":icon_no", 1),
                (assign, ":new_icon", "icon_player"),
    (try_end),
	
	
	
	
	(try_begin), #################dwarf_people
	(eq, ":icon_no", 2),             
	(ge, ":cur_horse", 0),
                (assign, ":icon_horseman", "icon_dwarf"),
    (else_try),
	(eq, ":icon_no", 2),
                (assign, ":icon_inf", "icon_dwarf_x3"),
    (try_end),
	
	
	(try_begin), #################brigands and rangers
	(eq, ":icon_no", 3),             
	(ge, ":cur_horse", 0),
                (assign, ":icon_horseman", "icon_brigand"),
    (else_try),
	(eq, ":icon_no", 3),
                (assign, ":icon_inf", "icon_ithilien_ranger"),
    (try_end),
	
	
	(try_begin), #################dunlader infrantry
	(eq, ":icon_no", 4),             
	(ge, ":cur_horse", 0),
                (assign, ":icon_horseman", "icon_dunlander"),
    (else_try),
	(eq, ":icon_no", 4),
                (assign, ":icon_inf", "icon_dunlander_x3"),
    (try_end),
	
	
    (try_begin),
      (eq, "$g_player_icon_state", pis_normal),
	      (try_begin),
        (ge, ":cur_horse", 0),
		
        (assign, ":new_icon", ":icon_horseman"),
      (else_try),
        (assign, ":new_icon", ":icon_inf"),
      (try_end),
    (else_try),
      (eq, "$g_player_icon_state", pis_camping),
      (assign, ":new_icon", "icon_camp"),
    (else_try),
      (eq, "$g_player_icon_state", pis_ship),
      (assign, ":new_icon", "icon_ship"),
    (try_end),
    
	(neq, ":new_icon", "$g_player_party_icon"),
    (assign, "$g_player_party_icon", ":new_icon"),
    (party_set_icon, "p_main_party", ":new_icon"),
    ]),

So first small piece of code is just for debug, to be sure that slot works.

When I set slot to 2 or 3 or 4 everything works.

The problem is when I set from menu player_slot :
Code:
(troop_get_slot, ":icon_no", "trp_player", slot_player_unlocked_icon),
to default, that means 1 from ingame I got message:

INVALID MAP ICON ID: -1 - when I play with horse and when I change to unequip horse the message is: INVALID MAP ICON ID 51700968. Pffff. What the hell?

I suppose that has to do something with the code at the start:
Code:
 (assign, ":new_icon", -1),
and at the end
Code:
(neq, ":new_icon", "$g_player_party_icon"),
    (assign, "$g_player_party_icon", ":new_icon"),
    (party_set_icon, "p_main_party", ":new_icon"),
Code:
bit I don't understand what does it do?


Ok, I just found that whole problem is just with default setting ie:
(try_begin), #################default
(eq, ":icon_no", 1),           
(ge, ":cur_horse", 0),
                (assign, ":new_icon", "icon_player_horseman"),
    (else_try),
(eq, ":icon_no", 1),
                (assign, ":new_icon", "icon_player"),
    (try_end),
 
I've added this code to game_menus:
Code:
("get_current_position",[],"Get current position",
       [
		 (party_get_position, reg0, "p_main_party"),
         (display_message, "@{reg0}", 0x80223167),
        ]
       ),

Why that isn't work? It shows 0. Or maybe there is a faster way to get current position?
 
Khamukkamu said:
1) Can I rename an imod / imod?

2) The VC script we were talking about show that it can set damage, speed, price, etc and store them into reg0,reg1,reg2 etc. How would I add those effects in? By adding it to mission templates?
1) copy "game folder/Data/item_modifiers.txt" to your "game folder/module/mymod/Data". You can rename the imods on that file, and also change the price factor (how many times a masterwork is more expensive than plain)

example:
Code:
imod_plain Plain_%s 1.000000 1.000000
...
imod_masterwork Masterwork_%s 4.000000 0.000000
imod_heavy Heavy_%s 1.200000 0.500000
...

2) The script in VC is used to control those variables. As the system is hardcoded and we don't have operations to access it, the VC team duplicated the values on the script so they could call it on modsys for special situations (like to use on a mission template). Examples of features: weapons breaking and losing quality; blacksmith that can upgrade a weapon; economy balance; and so on.
it is a workaround, it doesn't replace the hardcoded system, so for VC case you need to manually sync the .txt file and the script.



Tintai said:
(party_get_position, reg0, "p_main_party"),
Why that isn't work? It shows 0. Or maybe there is a faster way to get current position?

positions have their own type. It is not a single number, it is a vector (x, y, z). So you need to use a posX to carry it, then you can use operations to extract each position
Code:
position_get_x                              =  726  # (position_get_x, <destination_fixed_point>, <position>),
                                                    # Return position X coordinate (to the east, or to the right). Base unit is meters. Use (set_fixed_point_multiplier) to set another measurement unit (100 will get you centimeters, 1000 will get you millimeters, etc).
position_get_y                              =  727  # (position_get_y, <destination_fixed_point>, <position>),
                                                    # Return position Y coordinate (to the north, or forward). Base unit is meters. Use (set_fixed_point_multiplier) to set another measurement unit (100 will get you centimeters, 1000 will get you millimeters, etc).
position_get_z                              =  728  # (position_get_z, <destination_fixed_point>, <position>),
                                                    # Return position Z coordinate (to the top). Base unit is meters. Use (set_fixed_point_multiplier) to set another measurement unit (100 will get you centimeters, 1000 will get you millimeters, etc).

those operations will return a single number, which you can save in a register like reg0, and use on your test message



MongolFromForest said:
How many custom races
Try it  :mrgreen:
Add fake races (skins), compile your code, and see if you crash the game upon launch or when creating a new campaign.

That is the basic way to explore engine limitations (try and error)



MadGuarang said:
First, from game_menu I wrote small code that sets player slot to 0,1,2,3,etc.
not sure what your question is  :mrgreen:, but remember to check your slot number (ID). If you use something that is already used by other features (or the engine), the value will change outside your control. Should be clear if you read the comments on module_constants.py
 
Khamukkamu said:
Thanks again kalarhan. Exactly what we needed. Finally we are able to add more items to ye olde TLD.

np, just remember to test on MB, as my tests were only done on WB hehe

and that you can use a /modules/mymod/languages/xxx/item_modifiers.csv   to add translations
 
Thanks again.

A different question: how is that 'fade-in' effect when entering scenes done? Is it through presentations?

I think Floris had that, I have the source but I don't know where to look. A Clash Of Kings definitely has it, and I think PoP has that to.

Thanks in advance
 
Khamukkamu said:
Thanks again.

A different question: how is that 'fade-in' effect when entering scenes done? Is it through presentations?

I think Floris had that, I have the source but I don't know where to look. A Clash Of Kings definitely has it, and I think PoP has that to.

Thanks in advance

I seem to remember VC has it, you can look at the source for that. I think the player refuge scenes have it (might be fade out actually, can't remember now, probably similar operations anyway).
 
kraggrim said:
I seem to remember VC has it

Code:
      (ti_tab_pressed, 0, 0, [],
        [
          (mission_cam_animate_to_screen_color, 0xFF000000, 3000),
          (finish_mission,4),
        ]
      ),
?

Code:
mission_cam_set_screen_color                 = 2008  # (mission_cam_set_screen_color, <value>),
                                                     # Not documented. Paints the screen with solid color. Parameter <value> contains color code with alpha component. Can be used to block screen entirely, add tint etc.
mission_cam_animate_to_screen_color          = 2009  #(mission_cam_animate_to_screen_color, <value>, <duration-in-1/1000-seconds>),
                                                     # Not documented. Same as above, but color change is gradual. Used in Native to fill the screen with white before the end of marriage scene.



Khamukkamu said:
how is that 'fade-in' effect when entering scenes done?

Code:
  (0, 0, 0.5, [(neq, "$vc_menu_active", 0),],
    [
      (set_fixed_point_multiplier, 100),
      (try_begin),
        (eq, "$hide_cam_move_with_black_screen", 1),
        (assign, "$hide_cam_move_with_black_screen", 2),
        (mission_cam_set_screen_color, 0xFF000000),
      (else_try),
        (eq, "$hide_cam_move_with_black_screen", 2),
        (assign, "$hide_cam_move_with_black_screen", 0),
        (mission_cam_animate_to_screen_color, 0x00000000, 500),
      (try_end),

(all snippets are from VC code)
 
Status
Not open for further replies.
Back
Top Bottom