Modding Q&A [For Quick Questions and Answers]

Users who are viewing this thread

Status
Not open for further replies.
@aleeque,

If I recall correctly Diplomacy uses seneschals as chests, so look for an appropriate script which updates their belongings.
 
Oh, I see. Thanks!

Okay, so now I more or less understand how to do this. In the refresh_center_inventories script I need to add right before this piece of code:

Code:
(troop_clear_inventory, ":cur_merchant"),
(troop_add_merchandise, ":cur_merchant", itp_type_goods, ":number_of_items_in_town"),

A check to make sure ":cur_merchant" is not one of the 22 seneschals. How does one do this though? Can someone please help with the necessary syntax? I know of the neq operator of course, but I'm not sure how to choose a specific range of people from module_troops.py to scan. Here's the file if this helps: https://pastebin.com/M7dXdVct

Or maybe one could just do something like this:

Code:
(neq, ":cur_merchant", "trp_town_1_seneschal"),

...22 times in a row for all of them. Would that work? And if yes, would I need to enclose such a check in (try_begin)(try_end)?

Update: okay, I tried that and it didn't work, the chests still refresh. Welp, I'm out of ideas.
 
Is it possible to make certain villages recruit certain troops? I want a system where recruiting from, say, a forest region gives you archers and another region gives you cavalry but all within the same faction's territory.

I thought of maybe assigning these villages to other factions at the start of the game, and then somehow instantly giving ownership to another faction so they'll recruit the original faction's troops? I know there's a way to recruit specific troops in towns, but I don't know if you can do this with villages.
 
aleeque said:
Oh, I see. Thanks!

Okay, so now I more or less understand how to do this. In the refresh_center_inventories script I need to add right before this piece of code:

Code:
(troop_clear_inventory, ":cur_merchant"),
(troop_add_merchandise, ":cur_merchant", itp_type_goods, ":number_of_items_in_town"),

A check to make sure ":cur_merchant" is not one of the 22 seneschals. How does one do this though? Can someone please help with the necessary syntax? I know of the neq operator of course, but I'm not sure how to choose a specific range of people from module_troops.py to scan. Here's the file if this helps: https://pastebin.com/M7dXdVct

Or maybe one could just do something like this:

Code:
(neq, ":cur_merchant", "trp_town_1_seneschal"),

...22 times in a row for all of them. Would that work? And if yes, would I need to enclose such a check in (try_begin)(try_end)?

Update: okay, I tried that and it didn't work, the chests still refresh. Welp, I'm out of ideas.
look up where trp_town_x_seneshal is being used - they should have their own scripts. They are not merchants.
 
BeefBacon said:
Is it possible to make certain villages recruit certain troops?

put your logic on the recruit scripts (there are two, one for player and one for lords NPC). You set whatever you want for the slots as the troop_ID and quantity.

Code:
script_update_volunteer_troops_in_village = 391
script_update_npc_volunteer_troops_in_village = 392

as you can see in the last lines
Code:
       (party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":volunteer_troop"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_amount, ":amount"),
 
aleeque said:
JuJu70 said:
look up where trp_town_x_seneshal is being used - they should have their own scripts. They are not merchants.

Unfortunately, there are no scripts at all involving seneschals, except one about marriage.
look better  :razz:
 
These are all the refresh scripts:

Code:
  # script_refresh_center_inventories
  ("refresh_center_inventories",
  [
  (set_merchandise_modifier_quality,150),
  (reset_item_probabilities,100),

  # Add trade goods to merchant inventories
  (try_for_range,":cur_center",towns_begin,towns_end),
    (party_get_slot,":cur_merchant",":cur_center",slot_town_merchant),
    (reset_item_probabilities,100),
      (assign, ":total_production", 0),
    (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
        (call_script, "script_center_get_production", ":cur_center", ":cur_goods"),
		(assign, ":cur_production", reg0),

        (try_for_range, ":cur_village", villages_begin, villages_end),
		  (party_slot_eq, ":cur_village", slot_village_bound_center, ":cur_center"),
          (call_script, "script_center_get_production", ":cur_village", ":cur_goods"),
		  (val_div, reg0, 3),
		  (val_add, ":cur_production", reg0),
		(try_end),

		(val_max, ":cur_production", 1),
		(val_mul, ":cur_production", 4),

		(val_add, ":total_production", ":cur_production"),
      (try_end),

	  (party_get_slot, ":town_prosperity", ":cur_center", slot_town_prosperity),
	  (assign, ":number_of_items_in_town", 25),

	  (try_begin), #1.0x - 2.0x (50 - 100 prosperity)
	    (ge, ":town_prosperity", 50),
		(store_sub, ":ratio", ":town_prosperity", 50),
		(val_mul, ":ratio", 2),
		(val_add, ":ratio", 100),
		(val_mul, ":number_of_items_in_town", ":ratio"),
		(val_div, ":number_of_items_in_town", 100),
	  (else_try), #0.5x - 1.0x (0 - 50 prosperity)
		(store_sub, ":ratio", ":town_prosperity", 50),
		(val_add, ":ratio", 100),
		(val_mul, ":number_of_items_in_town", ":ratio"),
		(val_div, ":number_of_items_in_town", 100),
	  (try_end),

	  (val_clamp, ":number_of_items_in_town", 10, 40),

	  (try_begin),
	    (is_between, ":cur_center", castles_begin, castles_end),
	    (val_div, ":number_of_items_in_town", 2),
      (try_end),

      (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
	  (call_script, "script_center_get_production", ":cur_center", ":cur_goods"),
		(assign, ":cur_production", reg0),

        (try_for_range, ":cur_village", villages_begin, villages_end),
		  (party_slot_eq, ":cur_village", slot_village_bound_center, ":cur_center"),
          (call_script, "script_center_get_production", ":cur_village", ":cur_goods"),
		  (val_div, reg0, 3),
		  (val_add, ":cur_production", reg0),
		(try_end),

		(val_max, ":cur_production", 1),
		(val_mul, ":cur_production", 4),

        (val_mul, ":cur_production", ":number_of_items_in_town"),
		(val_mul, ":cur_production", 100),
		(val_div, ":cur_production", ":total_production"),
        (set_item_probability_in_merchandise, ":cur_goods", ":cur_production"),
    (try_end),

	  (troop_clear_inventory, ":cur_merchant"),
      (troop_add_merchandise, ":cur_merchant", itp_type_goods, ":number_of_items_in_town"),

      (troop_ensure_inventory_space, ":cur_merchant", 20),
    (troop_sort_inventory, ":cur_merchant"),
    (store_troop_gold, ":cur_gold",":cur_merchant"),
    ##diplomacy start+
	#Option: scaling gold additions by the prosperity of the town.
	(try_begin),
		(ge, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),#this must be explicitly enabled
	    (party_get_slot, ":prosperity_75", ":cur_center", slot_town_prosperity),
		(val_add, ":prosperity_75", 75),
		(store_mul, ":target_gold", ":prosperity_75", 1500),
		(val_add, ":target_gold", 62),
		(val_div, ":target_gold", 125),#average 1500
		(lt, ":cur_gold", ":target_gold"),
		(store_random_in_range,":new_gold",500,1000),
		(val_mul, ":new_gold", ":prosperity_75"),
		(val_add, ":new_gold", 62),
		(val_div, ":new_gold", 125),
		(call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
	(else_try),
		(lt, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),
	    #fall through to default behavior
	    ##diplomacy end+
    (lt,":cur_gold",1500),
    (store_random_in_range,":new_gold",500,1000),
    (call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
    ##diplomacy start+
    (try_end),
	##diplomacy end+
  (try_end),
  ]),

  # script_refresh_center_armories
  ("refresh_center_armories",
  [
	  (reset_item_probabilities,100),
	  (set_merchandise_modifier_quality,150),
	  (try_for_range, ":cur_merchant", armor_merchants_begin, armor_merchants_end),
		(store_sub, ":cur_town", ":cur_merchant", armor_merchants_begin),
		(val_add, ":cur_town", towns_begin),
		(troop_clear_inventory, ":cur_merchant"),
		(party_get_slot, ":cur_faction", ":cur_town", slot_center_original_faction),
		(troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_body_armor, 16),
		(troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_head_armor, 16),
		(troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_foot_armor, 8),
		(troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_hand_armor, 4),
		(troop_ensure_inventory_space, ":cur_merchant", merchant_inventory_space),
		(troop_sort_inventory, ":cur_merchant"),
		(store_troop_gold, reg6, ":cur_merchant"),

	    ##diplomacy start+
		#Option: scaling gold additions by the prosperity of the town.
		(try_begin),
			(ge, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),#this must be explicitly enabled
		    (party_get_slot, ":prosperity_75", ":cur_town", slot_town_prosperity),
			(val_add, ":prosperity_75", 75),
			(store_mul, ":target_gold", ":prosperity_75", 900),
			(val_add, ":target_gold", 62),
			(val_div, ":target_gold", 125),#average 900
			(lt, reg(6), ":target_gold"),
			(store_random_in_range,":new_gold",200,400),
			(val_mul, ":new_gold", ":prosperity_75"),
			(val_add, ":new_gold", 62),
			(val_div, ":new_gold", 125),
			(call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
		(else_try),
			(lt, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),
		    #fall through to default behavior
		    ##diplomacy end+
	    (lt,reg6,1000),
	    (store_random_in_range,":new_gold",250,500),
	    (call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
		##diplomacy start+
		(try_end),
		##diplomacy end+
	  (end_try),
  ]),

  # script_refresh_center_weaponsmiths
  ("refresh_center_weaponsmiths",
  [
	  (reset_item_probabilities,100),
	  (set_merchandise_modifier_quality,150),
    (try_for_range, ":cur_merchant", weapon_merchants_begin, weapon_merchants_end),
	  (store_sub, ":cur_town", ":cur_merchant", weapon_merchants_begin),
	    (val_add, ":cur_town", towns_begin),
	  (troop_clear_inventory, ":cur_merchant"),
	    (party_get_slot, ":cur_faction", ":cur_town", slot_center_original_faction),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_one_handed_wpn, 5),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_two_handed_wpn, 5),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_polearm, 5),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_shield, 6),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_bow, 4),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_crossbow, 3),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_thrown, 5),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_arrows, 2),
      (troop_add_merchandise_with_faction, ":cur_merchant", ":cur_faction", itp_type_bolts, 2),
      (troop_ensure_inventory_space, ":cur_merchant", merchant_inventory_space),
      (troop_sort_inventory, ":cur_merchant"),
      (store_troop_gold, reg6, ":cur_merchant"),

	    ##diplomacy start+
		#Option: scaling gold additions by the prosperity of the town.
		(try_begin),
			(ge, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),#this must be explicitly enabled
		    (party_get_slot, ":prosperity_75", ":cur_town", slot_town_prosperity),
			(val_add, ":prosperity_75", 75),
			(store_mul, ":target_gold", ":prosperity_75", 900),
			(val_add, ":target_gold", 62),
			(val_div, ":target_gold", 125),#average 900
			(lt, reg6, ":target_gold"),
			(store_random_in_range,":new_gold",200,400),
			(val_mul, ":new_gold", ":prosperity_75"),
			(val_add, ":new_gold", 62),
			(val_div, ":new_gold", 125),
			(call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
		(else_try),
			(lt, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),
		    #fall through to default behavior
		    ##diplomacy end+
	    (lt,reg6,1000),
	    (store_random_in_range,":new_gold",250,500),
	  (call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
	  ##diplomacy start+
	  (try_end),
	  ##diplomacy end+
	  (try_end),
  ]),

  # script_refresh_center_stables
  ("refresh_center_stables",
  [
      (reset_item_probabilities,100),
      (set_merchandise_modifier_quality,150),
      (try_for_range,":cur_merchant",horse_merchants_begin,horse_merchants_end),
	  (troop_clear_inventory, ":cur_merchant"),
      (store_sub, ":cur_town", ":cur_merchant", horse_merchants_begin),
      (val_add, ":cur_town", towns_begin),
      (party_get_slot, ":cur_faction", ":cur_town", slot_center_original_faction),
      (troop_add_merchandise_with_faction,":cur_merchant", ":cur_faction",itp_type_horse,5),
      (troop_ensure_inventory_space,":cur_merchant",65),
      (troop_sort_inventory, ":cur_merchant"),
      (store_troop_gold, ":cur_gold",":cur_merchant"),
	##diplomacy start+
	#Option: scaling gold additions by the prosperity of the town.
	(try_begin),
		(ge, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),#this must be explicitly enabled
	    (party_get_slot, ":prosperity_75", ":cur_town", slot_town_prosperity),
		(val_add, ":prosperity_75", 75),
		(store_mul, ":target_gold", ":prosperity_75", 600),
		(val_add, ":target_gold", 62),
		(val_div, ":target_gold", 125),#average 600
		(lt, ":cur_gold", ":target_gold"),
		(store_random_in_range,":new_gold",200,400),
		(val_mul, ":new_gold", ":prosperity_75"),
		(val_add, ":new_gold", 62),
		(val_div, ":new_gold", 125),
		(call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
	(else_try),
		(lt, "$g_dplmc_gold_changes", DPLMC_GOLD_CHANGES_LOW),
	    #fall through to default behavior
	    ##diplomacy end+
    (lt,":cur_gold",600),
    (store_random_in_range, ":new_gold", 250, 500),
    (call_script, "script_troop_add_gold", ":cur_merchant", ":new_gold"),
    ##diplomacy start+
    (try_end),
    ##diplomacy end+
  (try_end),
  ]),

I don't see any references to seneschals. I suppose they are somehow linked in an array loop.

p.s. the chests are all refilled at the exact same time the town merchants are reset. So it must be the refresh_center_inventories script. I just don't know how to exclude the damn chests from it!

[Bcw]Btm_Earendil said:
Or you could also move the chest in the scene editor to another place which the player cannot reach if you don't find the respective code snippet^^
Yes, I ended up doing this instead. Worked like a charm, I guess.
 
I am modding Diplomacy 4.2 with PBOD .92 and have a question about the behavior of enemy archers and skirmishers when they are moving away from nearby friendly forces.  I like the way that the crossbowmen slowly back away from the enemy and from time to time, take aim and fire their crossbows.  This seems like a controlled and orderly way to skirmish.  On the other hand, the archers and throwers seem to run away like idiots, then stop and turn and sometimes fire, sometimes draw their sidearm and sometimes quickly cycle between bows and side-arms.  They look like a disorganized mob and are very ineffective.

I have looked through the source code to see if there is different coding for the crossbowmen than for the archers to explain the differences in behavior but haven't had any luck finding it.  Any help will be greatly appreciated. 
 
kalarhan said:
BeefBacon said:
Is it possible to make certain villages recruit certain troops?

put your logic on the recruit scripts (there are two, one for player and one for lords NPC). You set whatever you want for the slots as the troop_ID and quantity.

Code:
script_update_volunteer_troops_in_village = 391
script_update_npc_volunteer_troops_in_village = 392

as you can see in the last lines
Code:
       (party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":volunteer_troop"),
       (party_set_slot, ":center_no", slot_center_volunteer_troop_amount, ":amount"),

I'm not really sure what you mean. Could you show me an example of, say, village 1 recruiting a bandit? I'm in module_scripts - will I have to do anything anywhere else?
 
Many thanks to:

PitchPL

[Bcw]Btm_Earendil

kalarhan


I figured that syntax error out. I removed imodbits modifiers from a multitude of items. Now I know, you need to leave imodbits_none if you want to not have any imodbits and not run into syntax errors.
Lesson learned.
 
Redleg said:
I am modding Diplomacy 4.2 with PBOD .92 and have a question about the behavior of enemy archers and skirmishers when they are moving away from nearby friendly forces.  I like the way that the crossbowmen slowly back away from the enemy and from time to time, take aim and fire their crossbows.  This seems like a controlled and orderly way to skirmish.  On the other hand, the archers and throwers seem to run away like idiots, then stop and turn and sometimes fire, sometimes draw their sidearm and sometimes quickly cycle between bows and side-arms.  They look like a disorganized mob and are very ineffective.

I have looked through the source code to see if there is different coding for the crossbowmen than for the archers to explain the differences in behavior but haven't had any luck finding it.  Any help will be greatly appreciated.

Could it be that the crossbowmen have no sidearms? It's only a guess.
 
BeefBacon said:
I'm in module_scripts - will I have to do anything anywhere else?

open those two scripts and add your new lines of code to implement your new design (ruleset)

the entry parameter is the center (village_id) as you can see on
Code:
(store_script_param, ":center_no", 1),

you can do stuff like

Code:
(try_begin),
  (eq, ":center_no", "p_village_1"),
  (assign, ":volunteer_troop", "trp_XXXXX"),
  (assign, ":amount", 999), #put some logic for the quantity
(else_try),
  ... normal code
(try_end),
(party_set_slot, ":center_no", slot_center_volunteer_troop_type, ":volunteer_troop"),
(party_set_slot, ":center_no", slot_center_volunteer_troop_amount, ":amount"),
 
[Bcw]Btm_Earendil said:
Redleg said:
I am modding Diplomacy 4.2 with PBOD .92 and have a question about the behavior of enemy archers and skirmishers when they are moving away from nearby friendly forces.  I like the way that the crossbowmen slowly back away from the enemy and from time to time, take aim and fire their crossbows.  This seems like a controlled and orderly way to skirmish.  On the other hand, the archers and throwers seem to run away like idiots, then stop and turn and sometimes fire, sometimes draw their sidearm and sometimes quickly cycle between bows and side-arms.  They look like a disorganized mob and are very ineffective.

I have looked through the source code to see if there is different coding for the crossbowmen than for the archers to explain the differences in behavior but haven't had any luck finding it.  Any help will be greatly appreciated.

Could it be that the crossbowmen have no sidearms? It's only a guess.

They do have side-arms.  It could be the longer re-load speed of crossbows changes their retrograde behavior.

 
Vetrogor said:
When I use display_message the message only shows in the notes.
Your log is probably dead after being overwhelmed with error messages (or any other messages).
Vetrogor said:
What does special characters mean @ {!}?
@ is part of necessary syntax, as far as I understand.
{!}, as I was told, means this line won't appear for translation when somebody decides to translate your mod. It's useful for things you don't want to be translated such as (cur_item_add_mesh, "@{!}kettlehat2"),
 
Vetrogor said:
How to display a message in the left corner? The cheat mode was enabled  :facepalm:

you dont need to enable cheat mode to use display_message, as it is a normal operation.

You can use EDIT MODE to print the messages on your rgl_log.txt as well tho https://forums.taleworlds.com/index.php/topic,347990.msg8335287.html#msg8335287

You can also use some sort of filter like the global $cheat_mode (dont mix EDIT MODE, CHEAT MODE, and global cheat_mode, 3 different things).

 
Leonion said:
Vetrogor said:
When I use display_message the message only shows in the notes.
Your log is probably dead after being overwhelmed with error messages (or any other messages).
Vetrogor said:
What does special characters mean @ {!}?
@ is part of necessary syntax, as far as I understand.
{!}, as I was told, means this line won't appear for translation when somebody decides to translate your mod. It's useful for things you don't want to be translated such as (cur_item_add_mesh, "@{!}kettlehat2"),
{!} Will write the message to rgl_log
 
Status
Not open for further replies.
Back
Top Bottom