Avareee said:
Silverc said:
kalarhan said:
(ti_on_agent_killed_or_wounded, 0, 0, [],
[
(store_trigger_param_1, ":dead_agent_no"),
(store_trigger_param_2, ":killer_agent_no"),
(store_trigger_param_3, ":is_wounded"),
(try_begin),
(ge, ":dead_agent_no", 0),
(neg|agent_is_ally, ":dead_agent_no"),
(agent_is_human, ":dead_agent_no"),
(agent_get_troop_id, ":dead_agent_troop_id", ":dead_agent_no"),
## (str_store_troop_name, s6, ":dead_agent_troop_id"),
## (assign, reg0, ":dead_agent_no"),
## (assign, reg1, ":killer_agent_no"),
## (assign, reg2, ":is_wounded"),
## (agent_get_team, reg3, ":dead_agent_no"),
#(display_message, "@{!}dead agent no : {reg0} ; killer agent no : {reg1} ; is_wounded : {reg2} ; dead agent team : {reg3} ; {s6} is added"),
(party_add_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1), #addition_to_p_total_enemy_casualties
(eq, ":is_wounded", 1),
(party_wound_members, "p_total_enemy_casualties", ":dead_agent_troop_id", 1),
(try_end),
(call_script, "script_apply_death_effect_on_courage_scores", ":dead_agent_no", ":killer_agent_no"),
]),
#Individual lord political calculations
#Check for lords without fiefs, auto-defections, etc
(0.5,
[
##diplomacy start+
#This is fairly complicated, and it was getting nearly unreadable so I reformatted it.
#The old version is visible in version control.
(assign, ":save_reg0", reg0),
(val_add, "$g_lord_long_term_count", 1),
(try_begin),
(neg|is_between, "$g_lord_long_term_count", active_npcs_including_player_begin, active_npcs_end),
(assign, "$g_lord_long_term_count", active_npcs_including_player_begin),
(try_end),
##Add political calculations for kingdom ladies. Just extending the range would
##slow down the political calculations cycle, which would have possibly-unforeseen results.
##Instead, add a second iteration to deal with extensions.
(try_for_range, ":iteration", 0, 2),
(assign, ":troop_no", "$g_lord_long_term_count"),
(try_begin),
(eq, ":iteration", 1),
(val_sub, ":troop_no", active_npcs_including_player_begin),
(val_add, ":troop_no", active_npcs_end),
(try_end),
#Crude check to make sure that a careless modder (i.e. me) didn't decide it
#would be a good idea to redefine active_npcs to include kingdom_ladies,
#which would make the second iteration run off the end of the heroes list.
(is_between, ":troop_no", active_npcs_including_player_begin, heroes_end),
#Special handling for trp_player, and get the troop's faction
(try_begin),
(eq, ":troop_no", "trp_kingdom_heroes_including_player_begin"),
(assign, ":troop_no", "trp_player"),
(assign, ":faction", "$players_kingdom"),
(else_try),
(store_faction_of_troop, ":faction", ":troop_no"),
(try_end),
(try_begin),
(eq, "$cheat_mode", 1),
(str_store_troop_name, s9, ":troop_no"),
(display_message, "@{!}DEBUG -- Doing political calculations for {s9}"),
(try_end),
#Tally the fiefs owned by the hero, and cache the value in slot.
#If a lord owns no fiefs, his relations with his liege may deteriorate.
(try_begin),
(assign, reg0, 1),#Center points + 1
(try_for_range, ":center", centers_begin, centers_end),
(party_slot_eq, ":center", slot_town_lord, ":troop_no"),
(try_begin),
(is_between, ":center", towns_begin, towns_end),
(val_add, reg0, 3),#3 points per town
(else_try),
(is_between, ":center", walled_centers_begin, walled_centers_end),
(val_add, reg0, 2),#2 points per castle
(else_try),
(val_add, reg0, 1),#1 point per village
(try_end),
(try_end),
#Update cached total
(troop_set_slot, ":troop_no", dplmc_slot_troop_center_points_plus_one, reg0),
#If a lord has no fiefs, relation loss potentially results.
#Do not apply this to the player.
(eq, reg0, 1),
(troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
(neq, ":troop_no", "trp_player"),
#Don't apply this to the leader
(faction_get_slot, ":faction_leader", ":faction", slot_faction_leader),
(gt, ":faction_leader", -1),
(neq, ":faction_leader", ":troop_no"),
(neg|troop_slot_eq, ":faction_leader", slot_troop_spouse, ":troop_no"),
(neg|troop_slot_eq, ":troop_no", slot_troop_spouse, ":faction_leader"),
(troop_get_slot, ":troop_reputation", ":troop_no", slot_lord_reputation_type),
(try_begin),
(this_or_next|eq, ":troop_reputation", lrep_quarrelsome),
(this_or_next|eq, ":troop_reputation", lrep_selfrighteous),
(this_or_next|eq, ":troop_reputation", lrep_cunning),
(eq, ":troop_reputation", lrep_debauched),
(call_script, "script_troop_change_relation_with_troop", ":troop_no", ":faction_leader", -4),
(val_add, "$total_no_fief_changes", -4),
(else_try),
(this_or_next|eq, ":troop_reputation", lrep_ambitious),#add support for lady personalities
(eq, ":troop_reputation", lrep_martial),
(call_script, "script_troop_change_relation_with_troop", ":troop_no", ":faction_leader", -2),
(val_add, "$total_no_fief_changes", -2),
(try_end),
(try_end),
(call_script, "script_troop_change_relation_with_troop", ":feast_host", ":troop_no", ":relation_booster"),
# 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),
]),
Yes, I ended up doing this instead. Worked like a charm, I guess.[Bcw]Btm_Earendil said:
JuJu70 said:
(troop_clear_inventory, ":cur_merchant"),
(troop_add_merchandise, ":cur_merchant", itp_type_goods, ":number_of_items_in_town"),
(neq, ":cur_merchant", "trp_town_1_seneschal"),
SupaNinjaMan said:
("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),
]),
# Chests
["zendar_chest","{!}Zendar Chest","{!}Zendar Chest",tf_hero|tf_inactive, 0,reserved, fac_neutral,
[],def_attrib|level(18),wp(60),knows_common, 0],
["tutorial_chest_1","{!}Melee Weapons Chest","{!}Melee Weapons Chest",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_tutorial_sword, itm_tutorial_axe, itm_tutorial_spear, itm_tutorial_club, itm_tutorial_battle_axe],def_attrib|level(18),wp(60),knows_common, 0],
["tutorial_chest_2","{!}Ranged Weapons Chest","{!}Ranged Weapons Chest",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_tutorial_short_bow, itm_tutorial_arrows, itm_tutorial_crossbow, itm_tutorial_bolts, itm_tutorial_throwing_daggers],def_attrib|level(18),wp(60),knows_common, 0],
["bonus_chest_1","{!}Bonus Chest","{!}Bonus Chest",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_strange_armor,itm_strange_short_sword],def_attrib|level(18),wp(60),knows_common, 0],
["bonus_chest_2","{!}Bonus Chest","{!}Bonus Chest",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_strange_boots,itm_strange_sword],def_attrib|level(18),wp(60),knows_common, 0],
["bonus_chest_3","{!}Bonus Chest","{!}Bonus Chest",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_strange_helmet,itm_strange_great_sword],def_attrib|level(18),wp(60),knows_common, 0],
["household_possessions","{!}household_possessions","{!}household_possessions",tf_hero|tf_inactive|tf_is_merchant, 0,reserved, fac_neutral,[],def_attrib|level(18),wp(60),knows_inventory_management_10, 0],