A small question arose. Where is it prescribed what types of trophies are obtained after the battle? And then I plan to add gold coins of different types to some types of troops and lords, I would like them to come across in trophies sometimes.
If it is not hardcoded, it should be somewhere in the ModSys. You may make a trigger after winning a battle to give some gold to the player; some mathematical operations would come in handy.A small question arose. Where is it prescribed what types of trophies are obtained after the battle? And then I plan to add gold coins of different types to some types of troops and lords, I would like them to come across in trophies sometimes.
I understand correctly that the distribution of trophies after a battle or the looting of a caravan or a bandit's lair is determined in simple_triggers?If it is not hardcoded, it should be somewhere in the ModSys. You may make a trigger after winning a battle to give some gold to the player; some mathematical operations would come in handy.
#script_party_calculate_loot:
# INPUT:
# param1: Party-id
# Returns num looted items in reg0
("party_calculate_loot",
[
(store_script_param_1, ":enemy_party"), #Enemy Party_id
(call_script, "script_calculate_main_party_shares"),
(assign, ":num_player_party_shares", reg0),
(try_for_range, ":i_loot", 0, num_party_loot_slots),
(store_add, ":cur_loot_slot", ":i_loot", slot_party_looted_item_1),
(party_get_slot, ":item_no", "$g_enemy_party", ":cur_loot_slot"),
(gt, ":item_no", 0),
(party_set_slot, "$g_enemy_party", ":cur_loot_slot", 0),
(val_sub, ":cur_loot_slot", slot_party_looted_item_1),
(val_add, ":cur_loot_slot", slot_party_looted_item_1_modifier),
(party_get_slot, ":item_modifier", "$g_enemy_party", ":cur_loot_slot"),
(troop_add_item, "trp_temp_troop", ":item_no", ":item_modifier"),
(try_end),
(party_set_slot, "$g_enemy_party", slot_party_next_looted_item_slot, 0),
(assign, ":num_looted_items",0),
(try_begin),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_merchant_caravan), ## Tocan #Floris Seafaring / Seatrade
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_village_farmer),
(store_mul, ":plunder_amount", player_loot_share, 30),
(val_mul, ":plunder_amount", "$g_strength_contribution_of_player"),
(val_div, ":plunder_amount", 100),
(val_div, ":plunder_amount", ":num_player_party_shares"),
(try_begin),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_merchant_caravan), ## Tocan
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
(reset_item_probabilities, 100),
(assign, ":range_min", trade_goods_begin),
(assign, ":range_max", trade_goods_end),
(else_try),
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(val_div, ":plunder_amount", 2),
(reset_item_probabilities, 1),
(assign, ":range_min", food_begin),
(assign, ":range_max", food_end),
(else_try),
(val_div, ":plunder_amount", 5),
(reset_item_probabilities, 1),
(assign, ":range_min", food_begin),
(assign, ":range_max", food_end),
(try_end),
(store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
(try_for_range, ":cur_goods", ":range_min", ":range_max"),
(try_begin),
(neg|party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
(party_get_slot, ":cur_price", "$g_enemy_party", ":cur_price_slot"),
(else_try),
(assign, ":cur_price", maximum_price_factor),
(val_add, ":cur_price", average_price_factor),
(val_div, ":cur_price", 3),
(try_end),
(assign, ":cur_probability", 100),
(val_mul, ":cur_probability", average_price_factor),
(val_div, ":cur_probability", ":cur_price"),
(assign, reg0, ":cur_probability"),
(set_item_probability_in_merchandise, ":cur_goods", ":cur_probability"),
(try_end),
(troop_add_merchandise, "trp_temp_troop", itp_type_goods, ":plunder_amount"),
(val_add, ":num_looted_items", ":plunder_amount"),
(try_end),
#Now loot the defeated party
(store_mul, ":loot_probability", player_loot_share, 3),
(val_mul, ":loot_probability", "$g_strength_contribution_of_player"),
(party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
(val_add, ":player_party_looting", 10),
(val_mul, ":loot_probability", ":player_party_looting"),
(val_div, ":loot_probability", 10),
(val_div, ":loot_probability", ":num_player_party_shares"),
(party_get_num_companion_stacks, ":num_stacks",":enemy_party"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":enemy_party",":i_stack"),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":enemy_party",":i_stack"),
(try_for_range, ":unused", 0, ":stack_size"),
(troop_loot_troop, "trp_temp_troop", ":stack_troop", ":loot_probability"),
(try_end),
(try_end),
#(troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop"),
#(try_for_range, ":i_slot", 0, ":inv_cap"),
# (troop_get_inventory_slot, ":item_id", "trp_temp_troop", ":i_slot"),
# (is_between, ":item_id", horses_begin, horses_end),
# (troop_set_inventory_slot, "trp_temp_troop", ":i_slot", -1),
#(try_end),
(troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop"),
(try_for_range, ":i_slot", 0, ":inv_cap"),
(troop_get_inventory_slot, ":item_id", "trp_temp_troop", ":i_slot"),
(ge, ":item_id", 0),
(val_add, ":num_looted_items", 1),
(try_end),
(assign, reg0, ":num_looted_items"),
]),
]),
common_battle_tab_press
in module_mission_templates.py.
common_battle_tab_press = (
ti_tab_pressed, 0, 0, [],
[
(try_begin),
(eq, "$g_battle_won", 1),
(call_script, "script_count_mission_casualties_from_agents"),
Yes.I understand correctly that this script is responsible for the distribution of loot?
Check out header_triggers.py to find out what suits you.I understand correctly that the distribution of trophies after a battle or the looting of a caravan or a bandit's lair is determined in simple_triggers?
Yes.
Check out header_triggers.py to find out what suits you.
That alternative solution suggested by BladeofWar's also may do the job, it is up to you.
["ducats", "10 Ducats", [("ducats",0),("inv_ducats",ixmesh_inventory)], itp_type_goods, 0, 450, weight(0.035)|abundance(30), imodbits_none,],
["50_ducats", "50 Ducats",[("50_ducats",0),("inv_50_ducats",ixmesh_inventory)], itp_type_goods, 0, 2250, weight(0.175)|abundance(15), imodbits_none,],
(try_begin),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_merchant_caravan), ## Tocan #Floris Seafaring / Seatrade
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_hero_party),
thank you very much for the advice. Unfortunately, I don't know the modular system so well, writing a script with 0 is a difficult task for meif you can't find any code, you can write a new script and you can add tocommon_battle_tab_press
in module_mission_templates.py.
common_battle_tab_press = ( ti_tab_pressed, 0, 0, [], [ (try_begin), (eq, "$g_battle_won", 1), (call_script, "script_count_mission_casualties_from_agents"),
You can add your new script just below that.
["altins", "10 Sultani", [("altins",0),("inv_altins",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 450, weight(0.035)|abundance(90), imodbits_none, [], [fac_kingdom_6,fac_kingdom_25,]],
["50_altins", "50 Sultani", [("50_altins",0),("inv_50_altins",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2250, weight(0.175)|abundance(45), imodbits_none, [], [fac_kingdom_6,fac_kingdom_25,]],
["many_altins", "100 Sultani", [("many_altins",0),("inv_many_altins",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4500, weight(0.35)|abundance(15), imodbits_none, [], [fac_kingdom_6,fac_kingdom_25,]],
["ashrafi", "10 Ashrafi", [("ashrafi",0),("inv_ashrafi",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 450, weight(0.034)|abundance(90), imodbits_none, [], [fac_kingdom_3,fac_kingdom_16,fac_kingdom_17,fac_kingdom_21,fac_kingdom_22,fac_kingdom_25,]],
["50_ashrafi", "50 Ashrafi", [("50_ashrafi",0),("inv_50_ashrafi",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2250, weight(0.17)|abundance(45), imodbits_none, [], [fac_kingdom_3,fac_kingdom_16,fac_kingdom_17,fac_kingdom_21,fac_kingdom_22,fac_kingdom_25,]],
["many_ashrafi", "100 Ashrafi", [("many_ashrafi",0),("inv_many_ashrafi",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4500, weight(0.34)|abundance(15), imodbits_none, [], [fac_kingdom_3,fac_kingdom_16,fac_kingdom_17,fac_kingdom_21,fac_kingdom_22,fac_kingdom_25,]],
["dinars", "10 Dinars", [("dinars",0),("inv_dinars",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 450, weight(0.034)|abundance(90), imodbits_none, [], [fac_kingdom_18,fac_kingdom_20,]],
["50_dinars", "50 Dinars", [("50_dinars",0),("inv_50_dinars",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2250, weight(0.17)|abundance(45), imodbits_none, [], [fac_kingdom_18,fac_kingdom_20,]],
["many_dinars", "100 Dinars", [("many_dinars",0),("inv_many_dinars",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4500, weight(0.34)|abundance(15), imodbits_none, [], [fac_kingdom_18,fac_kingdom_20,]],
["ducats", "10 Ducats", [("ducats",0),("inv_ducats",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 450, weight(0.035)|abundance(90), imodbits_none,],
["50_ducats", "50 Ducats",[("50_ducats",0),("inv_50_ducats",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2250, weight(0.175)|abundance(45), imodbits_none,],
["many_ducats", "100 Ducats", [("many_ducats",0),("inv_many_ducats",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4500, weight(0.35)|abundance(15), imodbits_none,],
["florins", "10 Florins", [("florins",0),("inv_florins",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 445, weight(0.035)|abundance(90), imodbits_none,],
["50_florins", "50 Florins", [("50_florins",0),("inv_50_florins",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2225, weight(0.175)|abundance(45), imodbits_none,],
["many_florins", "100 Florins", [("many_florins",0),("inv_many_florins",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4450, weight(0.35)|abundance(15), imodbits_none,],
["forints", "10 Forints", [("forints",0),("inv_forints",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 450, weight(0.036)|abundance(90), imodbits_none, [], [fac_kingdom_2,fac_kingdom_5,fac_kingdom_7,fac_kingdom_8,fac_kingdom_9,fac_kingdom_28,]],
["50_forints", "50 Forints", [("50_forints",0),("inv_50_forints",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2250, weight(0.179)|abundance(45), imodbits_none, [], [fac_kingdom_2,fac_kingdom_5,fac_kingdom_7,fac_kingdom_8,fac_kingdom_9,fac_kingdom_28,]],
["many_forints", "100 Forints", [("many_forints",0),("inv_many_forints",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4500, weight(0.358)|abundance(15), imodbits_none, [], [fac_kingdom_2,fac_kingdom_5,fac_kingdom_7,fac_kingdom_8,fac_kingdom_9,fac_kingdom_28,]],
["guldens", "10 Goldguldens", [("guldens",0),("inv_guldens",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 420, weight(0.027)|abundance(90), imodbits_none, [], [fac_kingdom_1,fac_kingdom_26,]],
["50_guldens", "50 Goldguldens", [("50_guldens",0),("inv_50_guldens",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2100, weight(0.14)|abundance(45), imodbits_none, [], [fac_kingdom_1,fac_kingdom_26,]],
["many_guldens", "100 Goldguldens", [("many_guldens",0),("inv_many_guldens",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4200, weight(0.28)|abundance(15), imodbits_none, [], [fac_kingdom_1,fac_kingdom_26,]],
["principados", "10 Principados", [("principados",0),("inv_principados",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 460, weight(0.035)|abundance(90), imodbits_none, [], [fac_kingdom_38,]],
["50_principados", "50 Principados", [("50_principados",0),("inv_50_principados",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2300, weight(0.175)|abundance(45), imodbits_none, [], [fac_kingdom_38,]],
["many_principados", "100 Principados", [("many_principados",0),("inv_many_principados",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4600, weight(0.35)|abundance(15), imodbits_none, [], [fac_kingdom_38,]],
["ecu", "10 Ecu", [("ecu",0),("inv_ecu",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 450, weight(0.035)|abundance(90), imodbits_none,],
["50_ecu", "50 Ecu", [("50_ecu",0),("inv_50_ecu",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 2250, weight(0.175)|abundance(45), imodbits_none,],
["many_ecu", "100 Ecu", [("many_ecu",0),("inv_many_ecu",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 4500, weight(0.35)|abundance(15), imodbits_none,],
["nobles", "10 Nobles", [("nobles",0),("inv_nobles",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 740, weight(0.078)|abundance(90), imodbits_none, [], [fac_kingdom_2,fac_kingdom_4,fac_kingdom_26,]],
["50_nobles", "50 Nobles", [("50_nobles",0),("inv_50_nobles",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 3700, weight(0.39)|abundance(42), imodbits_none, [], [fac_kingdom_2,fac_kingdom_4,fac_kingdom_26,]],
["many_nobles", "100 Nobles", [("many_nobles",0),("inv_many_nobles",ixmesh_inventory)], itp_type_goods|itp_coin, 0, 7400, weight(0.78)|abundance(17), imodbits_none, [], [fac_kingdom_2,fac_kingdom_4,fac_kingdom_26,]],
#item flags
itp_type_horse = 0x0000000000000001
itp_type_one_handed_wpn = 0x0000000000000002
itp_type_two_handed_wpn = 0x0000000000000003
itp_type_polearm = 0x0000000000000004
itp_type_arrows = 0x0000000000000005
itp_type_bolts = 0x0000000000000006
itp_type_shield = 0x0000000000000007
itp_type_bow = 0x0000000000000008
itp_type_crossbow = 0x0000000000000009
itp_type_thrown = 0x000000000000000a
itp_type_goods = 0x000000000000000b
itp_type_head_armor = 0x000000000000000c
itp_type_body_armor = 0x000000000000000d
itp_type_foot_armor = 0x000000000000000e
itp_type_hand_armor = 0x000000000000000f
itp_type_pistol = 0x0000000000000010
itp_type_musket = 0x0000000000000011
itp_type_bullets = 0x0000000000000012
itp_type_animal = 0x0000000000000013
itp_type_book = 0x0000000000000014
itp_unique = 0x0000000000001000
itp_always_loot = 0x0000000000002000
##itp_melee = 0x000002000
itp_no_parry = 0x0000000000004000
##itp_spear = 0x000008000 #obsolete
itp_default_ammo = 0x0000000000008000
itp_merchandise = 0x0000000000010000
itp_wooden_attack = 0x0000000000020000
itp_wooden_parry = 0x0000000000040000
itp_food = 0x0000000000080000
itp_coin = 0x0000000000100000
#itp_bow = 0x0000000000000010
#itp_shield = 0x0000000000000020
#itp_javelin = 0x0000000000000040
#itp_crossbow = 0x0000000000000080
trade_goods_begin = "itm_spice"
trade_goods_end = "itm_siege_supply"
food_begin = "itm_smoked_fish"
food_end = "itm_siege_supply"
coin_begin = "itm_altins"
coin_end = "itm_many_nobles"
#script_party_calculate_loot:
# INPUT:
# param1: Party-id
# Returns num looted items in reg0
("party_calculate_loot",
[
(store_script_param_1, ":enemy_party"), #Enemy Party_id
(call_script, "script_calculate_main_party_shares"),
(assign, ":num_player_party_shares", reg0),
(try_for_range, ":i_loot", 0, num_party_loot_slots),
(store_add, ":cur_loot_slot", ":i_loot", slot_party_looted_item_1),
(party_get_slot, ":item_no", "$g_enemy_party", ":cur_loot_slot"),
(gt, ":item_no", 0),
(party_set_slot, "$g_enemy_party", ":cur_loot_slot", 0),
(val_sub, ":cur_loot_slot", slot_party_looted_item_1),
(val_add, ":cur_loot_slot", slot_party_looted_item_1_modifier),
(party_get_slot, ":item_modifier", "$g_enemy_party", ":cur_loot_slot"),
(troop_add_item, "trp_temp_troop", ":item_no", ":item_modifier"),
(try_end),
(party_set_slot, "$g_enemy_party", slot_party_next_looted_item_slot, 0),
(assign, ":num_looted_items",0),
(try_begin),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_merchant_caravan), ## Tocan #Floris Seafaring / Seatrade
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_village_farmer),
(store_mul, ":plunder_amount", player_loot_share, 30),
(val_mul, ":plunder_amount", "$g_strength_contribution_of_player"),
(val_div, ":plunder_amount", 100),
(val_div, ":plunder_amount", ":num_player_party_shares"),
(try_begin),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_merchant_caravan), ## Tocan
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(reset_item_probabilities, 100),
(assign, ":range_min", trade_goods_begin),
(assign, ":range_max", trade_goods_end),
(else_try),
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(val_div, ":plunder_amount", 2),
(reset_item_probabilities, 1),
(assign, ":range_min", food_begin),
(assign, ":range_max", food_end),
(else_try),
(val_div, ":plunder_amount", 5),
(reset_item_probabilities, 1),
(assign, ":range_min", food_begin),
(assign, ":range_max", food_end),
(else_try),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_hero_party),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_merchant_caravan),
(this_or_next|party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
(party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(val_div, ":plunder_amount", 2),
(reset_item_probabilities, 1),
(assign, ":range_min", coin_begin),
(assign, ":range_max", coin_end),
(else_try),
(val_div, ":plunder_amount", 5),
(reset_item_probabilities, 1),
(assign, ":range_min", coin_begin),
(assign, ":range_max", coin_end),
(try_end), [B] [/B]
(store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
(try_for_range, ":cur_goods", ":range_min", ":range_max"),
(try_begin),
(neg|party_slot_eq, "$g_enemy_party", slot_party_type, spt_bandit_lair),
(store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
(party_get_slot, ":cur_price", "$g_enemy_party", ":cur_price_slot"),
(else_try),
(assign, ":cur_price", maximum_price_factor),
(val_add, ":cur_price", average_price_factor),
(val_div, ":cur_price", 3),
(try_end),
(assign, ":cur_probability", 100),
(val_mul, ":cur_probability", average_price_factor),
(val_div, ":cur_probability", ":cur_price"),
(assign, reg0, ":cur_probability"),
(set_item_probability_in_merchandise, ":cur_goods", ":cur_probability"),
(try_end),
(troop_add_merchandise, "trp_temp_troop", itp_type_goods, ":plunder_amount"),
(val_add, ":num_looted_items", ":plunder_amount"),
(try_end),
#Now loot the defeated party
(store_mul, ":loot_probability", player_loot_share, 3),
(val_mul, ":loot_probability", "$g_strength_contribution_of_player"),
(party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
(val_add, ":player_party_looting", 10),
(val_mul, ":loot_probability", ":player_party_looting"),
(val_div, ":loot_probability", 10),
(val_div, ":loot_probability", ":num_player_party_shares"),
(party_get_num_companion_stacks, ":num_stacks",":enemy_party"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
(party_stack_get_troop_id, ":stack_troop",":enemy_party",":i_stack"),
(neg|troop_is_hero, ":stack_troop"),
(party_stack_get_size, ":stack_size",":enemy_party",":i_stack"),
(try_for_range, ":unused", 0, ":stack_size"),
(troop_loot_troop, "trp_temp_troop", ":stack_troop", ":loot_probability"),
(try_end),
(try_end),
#(troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop"),
#(try_for_range, ":i_slot", 0, ":inv_cap"),
# (troop_get_inventory_slot, ":item_id", "trp_temp_troop", ":i_slot"),
# (is_between, ":item_id", horses_begin, horses_end),
# (troop_set_inventory_slot, "trp_temp_troop", ":i_slot", -1),
#(try_end),
(troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop"),
(try_for_range, ":i_slot", 0, ":inv_cap"),
(troop_get_inventory_slot, ":item_id", "trp_temp_troop", ":i_slot"),
(ge, ":item_id", 0),
(val_add, ":num_looted_items", 1),
(try_end),
(assign, reg0, ":num_looted_items"),
]),