Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
Totenkopf900 said:
Now I just need to figure how to limit the number of merc companies the player can recruit, right now you can recruit them infinite times, any insight on this?

you can use a global variable to keep a counter, among other ideas.
 
3Xu9xZH.jpg
Why does the game randomly switches to a new line in displayed message in places where it's not supposed to do it?
Is it some engine bug or I'm missing something?

Code:
Code:
	  (str_clear, s0),
	  (store_faction_of_party, ":party_faction", ":party_no"),
	  (try_for_range, ":kingdom", "fac_commoners", "fac_neutralbutnotrly"),
			(neq, ":kingdom", ":party_faction"),
			(neg|is_between, ":kingdom", "fac_innocents", "fac_player_faction"),
			(neg|is_between, ":kingdom", "fac_kingdoms_end", "fac_peasant_rebels"),
			(neg|is_between, ":kingdom", "fac_outlaws_ks", "fac_imperial_scouts"),
			(neg|is_between, ":kingdom", "fac_undeads", "fac_mosoru"),
			(str_store_faction_name, s1, ":kingdom"),
			(store_relation, reg0, ":party_faction", ":kingdom"),
			(str_store_string, s0, "@{s0}{s1}: {reg0}^"),
	  (try_end),
	  (display_message, s0),
Thanks in advance.
 
Leonion said:
(str_clear, s0),
  (store_faction_of_party, ":party_faction", ":party_no"),
  (try_for_range, ":kingdom", "fac_commoners", "fac_neutralbutnotrly"),
(neq, ":kingdom", ":party_faction"),
(neg|is_between, ":kingdom", "fac_innocents", "fac_player_faction"),
(neg|is_between, ":kingdom", "fac_kingdoms_end", "fac_peasant_rebels"),
(neg|is_between, ":kingdom", "fac_outlaws_ks", "fac_imperial_scouts"),
(neg|is_between, ":kingdom", "fac_undeads", "fac_mosoru"),
(str_store_faction_name, s1, ":kingdom"),
(store_relation, reg0, ":party_faction", ":kingdom"),
(str_store_string, s0, "@{s0}{s1}: {reg0}^"),
  (try_end),
  (display_message, s0),
I don't know if it cause the problem but the blue s0 seems very unnecessary. :grin:



How can i change the flag which appearing while holding down "F1"(the one being used for setting an order position by releasing)? It is tutorial_flag_yellow in object_meshes.brf but i wonder from which script can i change that flag? Any idea?
 
Could anyone help with a problem I have ran into when trying out my mod.

I have been making a mod for multiplayer and when I access the new items on the equipment menu they are running off the screen to the right. How do I stop this from happening and instead have them go onto the next line.
 
Does the game save the inventory of hero troops like lords? If i add a item to a lord through a script and then save the game, will he continue to have that item when i restart the game and load the save?

kalarhan said:
KratosMKII said:
How do i make the presentation display more items slots? I modified the part in red but it didn't change anything.

see example from VC "script_troop_detail_inventory"
Thank you.
 
KratosMKII said:
Does the game save the inventory of hero troops like lords?

game can save inventory of any troop. You can disable that feature for non-heroes on module.ini.

Code:
dont_load_regular_troop_inventories = 1

player is just another hero troop. Companions too. There is no difference between them for the engine. It is up to you to create specific rules using modsys.
 
kalarhan said:
KratosMKII said:
Does the game save the inventory of hero troops like lords?

game can save inventory of any troop. You can disable that feature for non-heroes on module.ini.

Code:
dont_load_regular_troop_inventories = 1

player is just another hero troop. Companions too. There is no difference between them for the engine. It is up to you to create specific rules using modsys.
Thanks again.
 
Now i'm getting issues when trying to spawn a new lord

(assign, ":break_loop", 0),

(try_for_range, ":cur_lord", lords_begin, lords_end),
    (eq, ":break_loop", 0),
    (troop_get_slot, ":is_alive", ":cur_lord", slot_troop_is_alive), 
    (lt, ":is_alive", 1),  ### dead or inactive
      (assign, ":break_loop", 1),  ### breaks loop
  (call_script, "script_recycle_lord", ":cur_lord", ":faction_no"), ## recycle the mofo

      (try_begin),  ### CULTURE
        (call_script, "script_get_random_culture_for_lord", ":faction_no"), ## gets a random culture based on proximity
        (assign, ":cur_lord_culture", reg0), 
        (assign, ":cur_lord_culture", reg0), 
    (troop_set_slot, ":cur_lord", slot_troop_cur_culture, ":cur_lord_culture"),  ## applies the culture to lord
    (troop_set_faction, ":cur_lord", ":faction_no"),  ## applies the faction

        (str_store_troop_name, s6, ":cur_lord"), 
        (str_store_faction_name, s7, ":cur_lord_culture"), 
    (display_message, "@{s6} culture is {s7}."),
      (try_end),

      (try_begin),  ### NAME
    (call_script, "script_get_random_name_for_lord", ":faction_no", ":cur_lord_culture"), ## gets a random name based on culture
        (str_clear, s4), 
        (str_store_string, s4, reg0), 
        (troop_set_name, ":cur_lord", s4),
      (try_end),



      (try_begin), ### CREATE PARTY
        (assign, ":break_loop", 0),
        (try_for_range, ":center_no", walled_centers_begin, walled_centers_end),
  (eq, ":break_loop", 0),
            (store_faction_of_party, ":cur_center_faction", ":center_no"),
            (eq, ":faction_no", ":cur_center_faction"),
              (assign, ":break_loop", 1), ### breaks loop
              (call_script, "script_create_kingdom_hero_party", ":cur_lord", ":center_no"),
              (assign, ":lords_party", "$pout_party"),
              (party_attach_to_party, ":lords_party", ":center_no"),
              (str_store_troop_name, s5, ":cur_lord"), 
              (party_set_name, "$pout_party", "str_s5_s_party"),  ### sets the party name
              (troop_set_slot, ":cur_lord", slot_troop_cur_center, ":center_no"),
  (party_set_faction, ":cur_lord", ":faction_no"),  ## applies the faction
 
              (str_store_troop_name, s6, ":cur_lord"), 
              (str_store_faction_name, s7, ":center_no"), 
          (display_message, "@{s6} party created at {s7}."),
        (try_end),
      (try_end),

      (troop_set_slot, ":cur_lord", slot_troop_is_alive, 1),  ### he's active now

script_get_random_name_for_lord said:
  (store_random_in_range, reg20, "str_enhanced_name_english_1", "str_enhanced_surname_english_1"),
  (store_random_in_range, reg21, "str_enhanced_surname_english_1", "str_enhanced_names_end"),
      (str_store_string, s1, reg20), 
      (str_store_string, s2, reg21), 
      (str_store_string, s3, "str_enhanced_name_surname"),  ### combines name and surname


  (try_end),

  (assign, reg0, s3),
Whenever i try to spawn him, he doesn't get a name (he's always named "No." in the debug messages i added), no center of the faction is selected (it always selects p_player_castle according to debug messages which is the last walled center) so he doesn't spawn.

 
Leonion said:
  (str_clear, s0),
  (store_faction_of_party, ":party_faction", ":party_no"),
  (try_for_range, ":kingdom", "fac_commoners", "fac_neutralbutnotrly"),
(neq, ":kingdom", ":party_faction"),
(neg|is_between, ":kingdom", "fac_innocents", "fac_player_faction"),
(neg|is_between, ":kingdom", "fac_kingdoms_end", "fac_peasant_rebels"),
(neg|is_between, ":kingdom", "fac_outlaws_ks", "fac_imperial_scouts"),
(neg|is_between, ":kingdom", "fac_undeads", "fac_mosoru"),
(str_store_faction_name, s1, ":kingdom"),
(store_relation, reg0, ":party_faction", ":kingdom"),
(str_store_string, s0, "@{s0}{s1}: {reg0}^"),
  (try_end),
  (display_message, s0),

Have you tried it without this?
 
kalarhan said:
KratosMKII said:
(assign, reg0, s3),

what are you trying to do above?

strings like s0, s1, ... are global

and you cant mix register (numbers) with strings (text) without converting them with concatenation (number to string).

 
  (str_clear, s1), 
  (str_clear, s2), 
  (str_clear, s3), 
  (try_begin),
    (eq, ":faction_no", "fac_kingdom_9"),
  (store_random_in_range, reg20, "str_enhanced_name_english_1", "str_enhanced_surname_english_1"),
  (store_random_in_range, reg21, "str_enhanced_surname_english_1", "str_enhanced_names_end"),

      (str_store_string, s1, reg20), 
      (str_store_string, s2, reg21), 
      (str_store_string, s3, "str_enhanced_name_surname"),  ### combines name and surname
  # (else_try),
  (try_end),
 
  (troop_set_name, ":cur_lord", s3),
Thank you. I fixed the last part but is that in red the correct way of getting a random string?
 
KratosMKII said:
Thank you. I fixed the last part but is that in red the correct way of getting a random string?

in that what you are doing is not messing with strings, but their ID, which is a number. So that works just fine.

same as when you use a range of strings IDs to select a string value (text) - a example is

Code:
  ("town_prosperity_0",   "^The poverty of the town of {s60} is unbearable"),
  ("town_prosperity_10",   "^The town of {s60} is all but deserted to its squalor."),
  ("town_prosperity_20",   "^The town of {s60} looks a wretched, desolate place."),
  ("town_prosperity_30",   "^The town of {s60} looks poor and neglected."),
  ("town_prosperity_40",   "^The town of {s60} appears to be struggling."),
  ("town_prosperity_50",   "^The town of {s60} seems unremarkable."),
  ("town_prosperity_60",   "^The town of {s60} seems to be flourishing."),
  ("town_prosperity_70",   "^The prosperous town of {s60} is bustling with activity."),
  ("town_prosperity_80",   "^The town of {s60} looks rich and well maintained."),
  ("town_prosperity_90",   "^The town of {s60} is opulent and crowded with well-to-do people."),
  ("town_prosperity_100",  "^The glittering town of {s60} openly flaunts its great wealth."),

so keep in mind what type of value is used on each parameter of a operation (read the header_operations doc for that). Is it a position ? A string? A numeric value? And so on.
 
Masterancza said:
Have you tried it without this?
Without this it's just wall of text.
3XuXKMR.jpg
It seems like the game messages have certain maximum width, but the engine just ignores the fact that my concatenated (now I know 1 more smart word :grin:) string has multiple line breaks and none of the lines exceeds this width.
It still treats this whole string as 1 line and adds its own breaks. Bad game. :evil:
I was wondering if there is a workaround or some fix for this...
 
Leonion said:
I was wondering if there is a workaround or some fix for this...

why, how and when are  you printing the messages? The snippet you showed us could drop the concatenation and just print each name at time (unless you have some other process breaking the log).

you can also use more than one variable to store it, or even use a generic troop name to store it (as troops have two strings for name and plural). VC, as a example, used troop name to store debug texts without any issues.
 
Is it possible to get a random helmet from a troop's inventory using a script?

kalarhan said:
KratosMKII said:
Thank you. I fixed the last part but is that in red the correct way of getting a random string?

in that what you are doing is not messing with strings, but their ID, which is a number. So that works just fine.

same as when you use a range of strings IDs to select a string value (text) - a example is

Code:
  ("town_prosperity_0",   "^The poverty of the town of {s60} is unbearable"),
  ("town_prosperity_10",   "^The town of {s60} is all but deserted to its squalor."),
  ("town_prosperity_20",   "^The town of {s60} looks a wretched, desolate place."),
  ("town_prosperity_30",   "^The town of {s60} looks poor and neglected."),
  ("town_prosperity_40",   "^The town of {s60} appears to be struggling."),
  ("town_prosperity_50",   "^The town of {s60} seems unremarkable."),
  ("town_prosperity_60",   "^The town of {s60} seems to be flourishing."),
  ("town_prosperity_70",   "^The prosperous town of {s60} is bustling with activity."),
  ("town_prosperity_80",   "^The town of {s60} looks rich and well maintained."),
  ("town_prosperity_90",   "^The town of {s60} is opulent and crowded with well-to-do people."),
  ("town_prosperity_100",  "^The glittering town of {s60} openly flaunts its great wealth."),

so keep in mind what type of value is used on each parameter of a operation (read the header_operations doc for that). Is it a position ? A string? A numeric value? And so on.
Thanks.
 
kalarhan said:
why, how and when are  you printing the messages?
The message is printed when the player clicks on a special option in the context menu (I'm not sure it's the correct name) for a party on the global map.
You know, for example, when you RMB-click a lord and there is an option "follow", so this is another one, to learn about this party's faction's relations with [most] other factions.

kalarhan said:
you can also use more than one variable to store it, or even use a generic troop name to store it (as troops have two strings for name and plural). VC, as a example, used troop name to store debug texts without any issues.
You mean like... storing the full string as a troop's name and then converting it back to string and printing the string?
Like
Code:
	  (troop_set_plural_name, "trp_zann_invasion_troop", s0),
	  (str_store_troop_name_plural, s30, "trp_zann_invasion_troop"),
	  (display_message, s30),
?
if so, I tried doing this, but the game still adds its own breaks.

KratosMKII said:
Is it possible to get a random helmet from a troop's inventory using a script?
Do a scan of the troop's inventory (troop_get_inventory_capacity => try_for_range => troop_get_inventory_slot).
Add all the discovered helmets to a certain list (e.g. slots 1, 2, 3 etc. of a fake troop).
Generate random number from 1 to last_slot+1.
troop_get_slot => and you have a random helmet.
 
Leonion said:
You mean like... storing the full string as a troop's name and then converting it back to string and printing the string?

nope. Instead of doing concatenation and storage on the same variable {s0} you can use the troop name/plural as the storage. That way the string variable will only have a short text (kingdom and value), while the storage can have hundreds of lines worth of content.

and when I asked about the printing I was talking about this

Code:
     (store_faction_of_party, ":party_faction", ":party_no"),
     (try_for_range, ":kingdom", "fac_commoners", "fac_neutralbutnotrly"),
         ... stuff to filter it out
         (str_store_faction_name, s1, ":kingdom"),
         (store_relation, reg0, ":party_faction", ":kingdom"),
         (display_message,  "@{!}{s1}: {reg0}"),
     (try_end),


 
Status
Not open for further replies.
Back
Top Bottom