bisthebis25
Knight
A simple script who changes the caravans destination : A caravan will calculate benefits with 2 towns, not one. Before, caravan choosed the best town. Now, they will choose a town for this AND potential tariffs from this town to another.
Repalce the old script_cf_select_most_profitable_town_at_peace_with_faction_in_trade_route by this.
In module_simple_triggers, change this (line 2016 on native 1.153 MS :
By
create this constant
In dialogs, change this ;
by this :
In conditions of this line, add this :
I will add screenshots this evening.
PS : i know i can improves the script
Repalce the old script_cf_select_most_profitable_town_at_peace_with_faction_in_trade_route by this.
Code:
("cf_select_most_profitable_town_at_peace_with_faction_in_trade_route",
[
(store_script_param, ":town_no", 1),
(store_script_param, ":faction_no", 2),
(assign, ":result", -1),
(assign, ":best_town_score", 0),
(store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
(try_for_range, ":cur_slot", slot_town_trade_routes_begin, slot_town_trade_routes_end),
(party_get_slot, ":cur_town", ":town_no", ":cur_slot"),
(gt, ":cur_town", 0),
(store_faction_of_party, ":cur_faction", ":cur_town"),
(store_relation, ":reln", ":cur_faction", ":faction_no"),
(ge, ":reln", 0),
(assign, ":cur_town_score", 0),
(try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
(neq, ":cur_goods", "itm_butter"), #Don't count perishables
(neq, ":cur_goods", "itm_cattle_meat"),
(neq, ":cur_goods", "itm_chicken"),
(neq, ":cur_goods", "itm_pork"),
(store_add, ":cur_goods_price_slot", ":cur_goods", ":item_to_price_slot"),
(party_get_slot, ":origin_price", ":town_no", ":cur_goods_price_slot"),
(party_get_slot, ":destination_price", ":cur_town", ":cur_goods_price_slot"),
(gt, ":destination_price", ":origin_price"),
(store_sub, ":price_dif", ":destination_price", ":origin_price"),
(try_begin), #weight luxury goods double
(this_or_next|eq, ":cur_goods", "itm_spice"),
(eq, ":cur_goods", "itm_velvet"),
(val_mul, ":price_dif", 2),
(try_end),
(val_add, ":cur_town_score", ":price_dif"),
(try_end),
## (try_begin),
## (eq, "$cheat_mode", 1),
## (str_store_party_name, s10, ":town_no"),
## (str_store_party_name, s11, ":cur_town"),
## (assign, reg3, ":cur_town_score"),
## (display_message, "str_caravan_in_s10_considers_s11_total_price_dif_=_reg3"),
## (try_end),
(gt, ":cur_town_score", ":best_town_score"),
(assign, ":best_town_score", ":cur_town_score"),
(assign, ":result", ":cur_town"),
#------------------------------#
#------------------------------#
#----Script 2nd town begins----#
#------------------------------#
#------------------------------#
#town_no : origin of caravan
#cur_town : first potential step
#cur_town2 : second potential step
(assign, ":town_2_best", 0),
(assign, ":town_2_best_score", 0),
(try_for_range, ":cur_slot", slot_town_trade_routes_begin, slot_town_trade_routes_end),
#(party_get_slot, ":cur_town2", ":town_no", ":cur_slot"),
(party_get_slot, ":cur_town2", ":result", ":cur_slot"),
(gt, ":cur_town2", 0),
(store_faction_of_party, ":cur_faction", ":cur_town2"),
(store_relation, ":reln", ":cur_faction", ":faction_no"),
(ge, ":reln", 0),
(assign, ":cur_town2_score", 0),
(try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
(neq, ":cur_goods", "itm_butter"), #Don't count perishables
(neq, ":cur_goods", "itm_cattle_meat"),
(neq, ":cur_goods", "itm_chicken"),
(neq, ":cur_goods", "itm_pork"),
(store_add, ":cur_goods_price_slot", ":cur_goods", ":item_to_price_slot"),
(party_get_slot, ":origin_price", ":cur_town", ":cur_goods_price_slot"),
(party_get_slot, ":destination_price", ":cur_town2", ":cur_goods_price_slot"),
(gt, ":destination_price", ":origin_price"),
(store_sub, ":price_dif", ":destination_price", ":origin_price"),
(try_begin), #weight luxury goods double
(this_or_next|eq, ":cur_goods", "itm_spice"),
(eq, ":cur_goods", "itm_velvet"),
(val_mul, ":price_dif", 2),
(try_end),
(val_add, ":cur_town2_score", ":price_dif"),
(try_end),
(gt, ":cur_town2_score" ,":town_2_best_score"),
(assign, ":town_2_best_score", ":cur_town2_score"),
(assign, ":best_town2", ":cur_town2"),
(assign, reg1, ":cur_town2"),
(try_end),
(val_add, ":cur_town_score", ":best_town2"),
(gt, ":cur_town_score", ":best_town_score"),
(assign, ":best_town_score", ":cur_town_score"),
(assign, ":result", ":cur_town"),
#------------------------------#
#------------------------------#
#-----Script 2nd town ends-----#
#------------------------------#
#------------------------------#
In module_simple_triggers, change this (line 2016 on native 1.153 MS :
Code:
(call_script, "script_cf_select_most_profitable_town_at_peace_with_faction_in_trade_route", ":cur_center", ":merchant_faction"),
(assign, ":target_center", reg0),
By
Code:
(call_script, "script_cf_select_most_profitable_town_at_peace_with_faction_in_trade_route", ":cur_center", ":merchant_faction"),
(assign, ":target_center", reg0),
(party_set_slot, ":party_no", slot_caravan_future_destination, reg1),
create this constant
Code:
slot_caravan_future_destination = 900,
In dialogs, change this ;
Code:
We are coming from {s11} and heading to {s12}.{s14}
Code:
We are coming from {s11} and heading to {s12}.{s14} ^^ After, we think we will go to {s17}
In conditions of this line, add this :
(party_get_slot, "rigin", "$g_encountered_party", slot_party_last_traded_center),
(party_get_slot, ":destination", "$g_encountered_party", slot_party_ai_object),
(str_store_party_name, s11, "rigin"),
(str_store_party_name, s12, ":destination"),
(str_store_string, s14, "str___we_believe_that_there_is_money_to_be_made_selling_"),
(store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
(assign, ":at_least_one_item_found", 0),
(try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
(store_add, ":cur_goods_price_slot", ":cur_goods", ":item_to_price_slot"),
(party_get_slot, "rigin_price", "rigin", ":cur_goods_price_slot"),
(party_get_slot, ":destination_price", ":destination", ":cur_goods_price_slot"),
(gt, ":destination_price", "rigin_price"),
(store_sub, ":price_dif", ":destination_price", "rigin_price"),
(gt, ":price_dif", 200),
(str_store_item_name, s15, ":cur_goods"),
(str_store_string, s14, "str_s14s15_"),
(assign, ":at_least_one_item_found", 1),
(try_end),
(try_begin),
(eq, ":at_least_one_item_found", 0),
(str_store_string, s14, "str__we_carry_a_selection_of_goods_although_the_difference_in_prices_for_each_is_not_so_great_we_hope_to_make_a_profit_off_of_the_whole"),
(else_try),
(str_store_string, s14, "str_s14and_other_goods"),
(party_get_slot, ":future_destination","$g_encountered_party", slot_caravan_future_destination),
(str_store_party_name, s17, ":future_destination"),
(try_end),
I will add screenshots this evening.
PS : i know i can improves the script