Leonion

Trade Screen Replacer

Nov 24th, 2017
111
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ("trade_screen_replacer", 0, mesh_inventory_window_b, [
  2.     (ti_on_presentation_load,
  3.       [
  4.         (presentation_set_duration, 999999),
  5.         (set_fixed_point_multiplier, 1000),
  6.        
  7.         (try_for_range, ":i_slot", 0, 110),
  8.             (troop_set_slot, "trp_temp_array_a", ":i_slot", -1), #player's selected items
  9.             (troop_set_slot, "trp_temp_array_b", ":i_slot", -1), #merchant's selected items
  10.         (try_end),
  11.         (try_for_range, ":i_slot", 0, 220), #overlay ids (0-... - player's inventory, 110-... - merchant's inventory)
  12.             (troop_set_slot, "trp_temp_array_c", ":i_slot", -1),
  13.         (try_end),
  14.         (assign, "$g_presentation_obj_15", -1), (assign, "$g_presentation_obj_16", -1),
  15.        
  16.         ## Done button
  17.         (create_game_button_overlay, "$g_presentation_obj_1", "@Return"),
  18.         (position_set_x, pos1, 500),
  19.         (position_set_y, pos1, 23),
  20.         (overlay_set_position, "$g_presentation_obj_1", pos1),
  21.        
  22.         ## Trader Switch Button
  23.         (position_set_x, pos1, 147),
  24.         (position_set_y, pos1, 695),
  25.         (create_combo_button_overlay, "$g_presentation_obj_2"),
  26.         (overlay_set_position, "$g_presentation_obj_2", pos1),
  27.         (position_set_x, pos1, 1060),
  28.         (position_set_y, pos1, 1060),
  29.         (overlay_set_size, "$g_presentation_obj_2", pos1),
  30.         (overlay_add_item, "$g_presentation_obj_2", "@General Goods Merchant"),
  31.         (overlay_add_item, "$g_presentation_obj_2", "@Horse Merchant"),
  32.         (overlay_add_item, "$g_presentation_obj_2", "@Armourer"),
  33.         (overlay_add_item, "$g_presentation_obj_2", "@Weaponsmith"),
  34.         (try_begin),
  35.             (party_slot_eq, "$current_town", slot_town_weaponsmith, "$temp_2"),
  36.             (overlay_set_val, "$g_presentation_obj_2", 3),
  37.         (else_try),
  38.             (party_slot_eq, "$current_town", slot_town_armorer, "$temp_2"),
  39.             (overlay_set_val, "$g_presentation_obj_2", 2),
  40.         (else_try),
  41.             (party_slot_eq, "$current_town", slot_town_horse_merchant, "$temp_2"),
  42.             (overlay_set_val, "$g_presentation_obj_2", 1),
  43.         (else_try),
  44.             (overlay_set_val, "$g_presentation_obj_2", 0),
  45.         (try_end),
  46.        
  47.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  48.         ## Player's equipment 0-8
  49.         (assign, ":overlay_counter", 0),
  50.         (assign, ":total_head_armor", 0),
  51.         (assign, ":total_body_armor", 0),
  52.         (assign, ":total_leg_armor", 0),
  53.         (assign, ":total_weight", 0),
  54.        
  55.         (try_for_range, ":i_slot", 0, 9),
  56.             (troop_get_inventory_slot, ":item", "trp_player", ":i_slot"),
  57.             (try_begin),
  58.                 (ge, ":item", 0),
  59.                 (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":i_slot"),
  60.                 (item_get_weight, ":cur_weight", ":item"), (val_add, ":total_weight", ":cur_weight"),
  61.                 (try_begin),
  62.                     (eq, ":i_slot", 0), (assign, ":pos_x", 596), (assign, ":pos_y", 650),
  63.                 (else_try),
  64.                     (eq, ":i_slot", 1), (assign, ":pos_x", 596), (assign, ":pos_y", 562),
  65.                 (else_try),
  66.                     (eq, ":i_slot", 2), (assign, ":pos_x", 596), (assign, ":pos_y", 474),
  67.                 (else_try),
  68.                     (eq, ":i_slot", 3), (assign, ":pos_x", 596), (assign, ":pos_y", 385),
  69.                 (else_try), #head
  70.                     (eq, ":i_slot", 4), (assign, ":pos_x", 495), (assign, ":pos_y", 650),
  71.                     (item_get_head_armor, ":cur_head_armor_value", ":item"), (item_get_body_armor, ":cur_body_armor_value", ":item"),
  72.                     (assign, ":armor_mod", 0),
  73.                     (try_begin), (eq, ":imod", imod_cracked), (assign, ":armor_mod", -4),
  74.                     (else_try), (this_or_next|eq, ":imod", imod_rusty), (eq, ":imod", imod_tattered), (assign, ":armor_mod", -3),
  75.                     (else_try), (this_or_next|eq, ":imod", imod_battered), (eq, ":imod", imod_ragged),(assign, ":armor_mod", -2),
  76.                     (else_try), (eq, ":imod", imod_crude), (assign, ":armor_mod", -1),
  77.                     (else_try), (eq, ":imod", imod_sturdy), (assign, ":armor_mod", 1),
  78.                     (else_try), (eq, ":imod", imod_thick), (assign, ":armor_mod", 2),
  79.                     (else_try), (eq, ":imod", imod_hardened), (assign, ":armor_mod", 3),
  80.                     (else_try), (eq, ":imod", imod_reinforced), (assign, ":armor_mod", 4),
  81.                     (else_try), (eq, ":imod", imod_lordly), (assign, ":armor_mod", 6),
  82.                     (try_end),
  83.                     (try_begin),
  84.                         (gt, ":cur_head_armor_value", 0), (val_add, ":cur_head_armor_value", ":armor_mod"), (val_max, ":cur_head_armor_value", 0),
  85.                     (try_end),
  86.                     (try_begin),
  87.                         (gt, ":cur_body_armor_value", 0), (val_add, ":cur_body_armor_value", ":armor_mod"), (val_max, ":cur_body_armor_value", 0),
  88.                     (try_end),
  89.                     (val_add, ":total_head_armor", ":cur_head_armor_value"), (val_add, ":total_body_armor", ":cur_body_armor_value"),
  90.                 (else_try), #body
  91.                     (eq, ":i_slot", 5), (assign, ":pos_x", 495), (assign, ":pos_y", 562),
  92.                     (item_get_head_armor, ":cur_head_armor_value", ":item"), (item_get_body_armor, ":cur_body_armor_value", ":item"), (item_get_leg_armor, ":cur_leg_armor_value", ":item"),
  93.                     (assign, ":armor_mod", 0),
  94.                     (try_begin), (eq, ":imod", imod_cracked), (assign, ":armor_mod", -4),
  95.                     (else_try), (this_or_next|eq, ":imod", imod_rusty), (eq, ":imod", imod_tattered), (assign, ":armor_mod", -3),
  96.                     (else_try), (this_or_next|eq, ":imod", imod_battered), (eq, ":imod", imod_ragged),(assign, ":armor_mod", -2),
  97.                     (else_try), (eq, ":imod", imod_crude), (assign, ":armor_mod", -1),
  98.                     (else_try), (eq, ":imod", imod_sturdy), (assign, ":armor_mod", 1),
  99.                     (else_try), (eq, ":imod", imod_thick), (assign, ":armor_mod", 2),
  100.                     (else_try), (eq, ":imod", imod_hardened), (assign, ":armor_mod", 3),
  101.                     (else_try), (eq, ":imod", imod_reinforced), (assign, ":armor_mod", 4),
  102.                     (else_try), (eq, ":imod", imod_lordly), (assign, ":armor_mod", 6),
  103.                     (try_end),
  104.                     (try_begin),
  105.                         (gt, ":cur_head_armor_value", 0), (val_add, ":cur_head_armor_value", ":armor_mod"), (val_max, ":cur_head_armor_value", 0),
  106.                     (try_end),
  107.                     (try_begin),
  108.                         (gt, ":cur_body_armor_value", 0), (val_add, ":cur_body_armor_value", ":armor_mod"), (val_max, ":cur_body_armor_value", 0),
  109.                     (try_end),
  110.                     (try_begin),
  111.                         (gt, ":cur_leg_armor_value", 0), (val_add, ":cur_leg_armor_value", ":armor_mod"), (val_max, ":cur_leg_armor_value", 0),
  112.                     (try_end),
  113.                     (val_add, ":total_head_armor", ":cur_head_armor_value"), (val_add, ":total_body_armor", ":cur_body_armor_value"), (val_add, ":total_leg_armor", ":cur_leg_armor_value"),
  114.                 (else_try), #foot
  115.                     (eq, ":i_slot", 6), (assign, ":pos_x", 495), (assign, ":pos_y", 474),
  116.                     (item_get_body_armor, ":cur_body_armor_value", ":item"), (item_get_leg_armor, ":cur_leg_armor_value", ":item"),
  117.                     (assign, ":armor_mod", 0),
  118.                     (try_begin), (eq, ":imod", imod_cracked), (assign, ":armor_mod", -4),
  119.                     (else_try), (this_or_next|eq, ":imod", imod_rusty), (eq, ":imod", imod_tattered), (assign, ":armor_mod", -3),
  120.                     (else_try), (this_or_next|eq, ":imod", imod_battered), (eq, ":imod", imod_ragged),(assign, ":armor_mod", -2),
  121.                     (else_try), (eq, ":imod", imod_crude), (assign, ":armor_mod", -1),
  122.                     (else_try), (eq, ":imod", imod_sturdy), (assign, ":armor_mod", 1),
  123.                     (else_try), (eq, ":imod", imod_thick), (assign, ":armor_mod", 2),
  124.                     (else_try), (eq, ":imod", imod_hardened), (assign, ":armor_mod", 3),
  125.                     (else_try), (eq, ":imod", imod_reinforced), (assign, ":armor_mod", 4),
  126.                     (else_try), (eq, ":imod", imod_lordly), (assign, ":armor_mod", 6),
  127.                     (try_end),
  128.                     (try_begin),
  129.                         (gt, ":cur_body_armor_value", 0), (val_add, ":cur_body_armor_value", ":armor_mod"), (val_max, ":cur_body_armor_value", 0),
  130.                     (try_end),
  131.                     (try_begin),
  132.                         (gt, ":cur_leg_armor_value", 0), (val_add, ":cur_leg_armor_value", ":armor_mod"), (val_max, ":cur_leg_armor_value", 0),
  133.                     (try_end),
  134.                     (val_add, ":total_body_armor", ":cur_body_armor_value"), (val_add, ":total_leg_armor", ":cur_leg_armor_value"),
  135.                 (else_try), #gloves
  136.                     (eq, ":i_slot", 7), (assign, ":pos_x", 408), (assign, ":pos_y", 562),
  137.                     (item_get_body_armor, ":cur_body_armor_value", ":item"),
  138.                     (assign, ":armor_mod", 0),
  139.                     (try_begin), (eq, ":imod", imod_cracked), (assign, ":armor_mod", -4),
  140.                     (else_try), (this_or_next|eq, ":imod", imod_rusty), (eq, ":imod", imod_tattered), (assign, ":armor_mod", -3),
  141.                     (else_try), (this_or_next|eq, ":imod", imod_battered), (eq, ":imod", imod_ragged),(assign, ":armor_mod", -2),
  142.                     (else_try), (eq, ":imod", imod_crude), (assign, ":armor_mod", -1),
  143.                     (else_try), (eq, ":imod", imod_sturdy), (assign, ":armor_mod", 1),
  144.                     (else_try), (eq, ":imod", imod_thick), (assign, ":armor_mod", 2),
  145.                     (else_try), (eq, ":imod", imod_hardened), (assign, ":armor_mod", 3),
  146.                     (else_try), (eq, ":imod", imod_reinforced), (assign, ":armor_mod", 4),
  147.                     (else_try), (eq, ":imod", imod_lordly), (assign, ":armor_mod", 6),
  148.                     (try_end),
  149.                     (try_begin),
  150.                         (gt, ":cur_body_armor_value", 0), (val_add, ":cur_body_armor_value", ":armor_mod"), (val_max, ":cur_body_armor_value", 0),
  151.                     (try_end),
  152.                     (val_add, ":total_body_armor", ":cur_body_armor_value"),
  153.                 (else_try), #horse
  154.                     (assign, ":pos_x", 407),    (assign, ":pos_y", 360),
  155.                 (try_end),
  156.                 (store_sub, ":pos_x_adj", ":pos_x", 41), (store_sub, ":pos_y_adj", ":pos_y", 42),
  157.                 (create_mesh_overlay, reg1, "mesh_inv_slot"),
  158.                 (position_set_x, pos1, 820), (position_set_y, pos1, 820), (overlay_set_size, reg1, pos1),
  159.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  160.                 (create_mesh_overlay_with_item_id, reg1, ":item"),
  161.                 (position_set_x, pos1, 860), (position_set_y, pos1, 860), (overlay_set_size, reg1, pos1),
  162.                 (position_set_x, pos1, ":pos_x"), (position_set_y, pos1, ":pos_y"), (overlay_set_position, reg1, pos1),
  163.                 (troop_set_slot, "trp_temp_array_c", ":overlay_counter", reg1),
  164.                 (val_add, ":overlay_counter", 1),
  165.             (else_try),
  166.                 (try_begin),
  167.                     (eq, ":i_slot", 0), (assign, ":pos_x", 596), (assign, ":pos_y", 650),
  168.                 (else_try),
  169.                     (eq, ":i_slot", 1), (assign, ":pos_x", 596), (assign, ":pos_y", 562),
  170.                 (else_try),
  171.                     (eq, ":i_slot", 2), (assign, ":pos_x", 596), (assign, ":pos_y", 474),
  172.                 (else_try),
  173.                     (eq, ":i_slot", 3), (assign, ":pos_x", 596), (assign, ":pos_y", 385),
  174.                 (else_try), #head
  175.                     (eq, ":i_slot", 4), (assign, ":pos_x", 495), (assign, ":pos_y", 650),
  176.                 (else_try), #body
  177.                     (eq, ":i_slot", 5), (assign, ":pos_x", 495), (assign, ":pos_y", 562),
  178.                 (else_try), #foot
  179.                     (eq, ":i_slot", 6), (assign, ":pos_x", 495), (assign, ":pos_y", 474),
  180.                 (else_try), #gloves
  181.                     (eq, ":i_slot", 7), (assign, ":pos_x", 408), (assign, ":pos_y", 562),
  182.                 (else_try), #horse
  183.                     (assign, ":pos_x", 407),    (assign, ":pos_y", 360),
  184.                 (try_end),
  185.                 (store_sub, ":pos_x_adj", ":pos_x", 41), (store_sub, ":pos_y_adj", ":pos_y", 42),
  186.                 (create_mesh_overlay, reg1, "mesh_inv_slot"), (overlay_set_alpha, reg1, 0x00),
  187.                 (position_set_x, pos1, 820), (position_set_y, pos1, 820), (overlay_set_size, reg1, pos1),
  188.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  189.                 (val_mul, reg1, -1), (troop_set_slot, "trp_temp_array_c", ":overlay_counter", reg1),
  190.                 (val_add, ":overlay_counter", 1),
  191.             (try_end),
  192.         (try_end),
  193.         (assign, ":store_fpm", 1), (convert_to_fixed_point, ":store_fpm"),
  194.         (set_fixed_point_multiplier, 1), (convert_from_fixed_point, ":total_weight"), (val_div, ":total_weight", 1000),
  195.         (set_fixed_point_multiplier, ":store_fpm"),
  196.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  197.        
  198.         ## General Data
  199.         (assign, reg58, ":total_head_armor"), (assign, reg59, ":total_body_armor"), (assign, reg60, ":total_leg_armor"), (assign, reg61, ":total_weight"),
  200.         (create_text_overlay, reg1, "@Head Armor: {reg58}", tf_left_align), (overlay_set_color, reg1, 0x000000),
  201.         (position_set_x, pos1, 750), (position_set_y, pos1, 850), (overlay_set_size, reg1, pos1),
  202.         (position_set_x, pos1, 86), (position_set_y, pos1, 15), (overlay_set_area_size, reg1, pos1),
  203.         (position_set_x, pos1, 358), (position_set_y, pos1, 677), (overlay_set_position, reg1, pos1),
  204.         (create_text_overlay, reg1, "@Body Armor: {reg59}", tf_left_align), (overlay_set_color, reg1, 0x000000),
  205.         (position_set_x, pos1, 750), (position_set_y, pos1, 850), (overlay_set_size, reg1, pos1),
  206.         (position_set_x, pos1, 86), (position_set_y, pos1, 15), (overlay_set_area_size, reg1, pos1),
  207.         (position_set_x, pos1, 358), (position_set_y, pos1, 657), (overlay_set_position, reg1, pos1),
  208.         (create_text_overlay, reg1, "@Leg Armor: {reg60}", tf_left_align), (overlay_set_color, reg1, 0x000000),
  209.         (position_set_x, pos1, 750), (position_set_y, pos1, 850), (overlay_set_size, reg1, pos1),
  210.         (position_set_x, pos1, 86), (position_set_y, pos1, 15), (overlay_set_area_size, reg1, pos1),
  211.         (position_set_x, pos1, 358), (position_set_y, pos1, 637), (overlay_set_position, reg1, pos1),
  212.         (create_text_overlay, reg1, "@Weight: {reg61}", tf_left_align), (overlay_set_color, reg1, 0x000000),
  213.         (position_set_x, pos1, 750), (position_set_y, pos1, 850), (overlay_set_size, reg1, pos1),
  214.         (position_set_x, pos1, 86), (position_set_y, pos1, 15), (overlay_set_area_size, reg1, pos1),
  215.         (position_set_x, pos1, 358), (position_set_y, pos1, 607), (overlay_set_position, reg1, pos1),
  216.         (create_text_overlay, reg1, "@Outfit", tf_left_align), (overlay_set_color, reg1, 0x000000),
  217.         (position_set_x, pos1, 900), (position_set_y, pos1, 1000), (overlay_set_size, reg1, pos1),
  218.         (position_set_x, pos1, 70), (position_set_y, pos1, 17), (overlay_set_area_size, reg1, pos1),
  219.         (position_set_x, pos1, 469), (position_set_y, pos1, 695), (overlay_set_position, reg1, pos1),
  220.         (create_text_overlay, reg1, "@Arms", tf_left_align), (overlay_set_color, reg1, 0x000000),
  221.         (position_set_x, pos1, 900), (position_set_y, pos1, 1000), (overlay_set_size, reg1, pos1),
  222.         (position_set_x, pos1, 70), (position_set_y, pos1, 17), (overlay_set_area_size, reg1, pos1),
  223.         (position_set_x, pos1, 572), (position_set_y, pos1, 695), (overlay_set_position, reg1, pos1),
  224.         (create_text_overlay, reg1, "@Mount", tf_left_align), (overlay_set_color, reg1, 0x000000),
  225.         (position_set_x, pos1, 900), (position_set_y, pos1, 1000), (overlay_set_size, reg1, pos1),
  226.         (position_set_x, pos1, 70), (position_set_y, pos1, 17), (overlay_set_area_size, reg1, pos1),
  227.         (position_set_x, pos1, 380), (position_set_y, pos1, 406), (overlay_set_position, reg1, pos1),
  228.         (str_store_troop_name, s1, "trp_player"),
  229.         (create_text_overlay, reg1, "@{s1}", tf_center_justify), (overlay_set_color, reg1, 0x000000),
  230.         (position_set_x, pos1, 750), (position_set_y, pos1, 850), (overlay_set_size, reg1, pos1),
  231.         (position_set_x, pos1, 200), (position_set_y, pos1, 22), (overlay_set_area_size, reg1, pos1),
  232.         (position_set_x, pos1, 823), (position_set_y, pos1, 702), (overlay_set_position, reg1, pos1),
  233.         (store_troop_gold, reg58, "$temp_2"),
  234.         (str_store_troop_name, s1, "$temp_2"),
  235.         (create_text_overlay, reg1, "@{s1}'s money: {reg58} aurums", tf_center_justify), (overlay_set_color, reg1, 0x000000),
  236.         (position_set_x, pos1, 1000), (position_set_y, pos1, 1100), (overlay_set_size, reg1, pos1),
  237.         (position_set_x, pos1, 250), (position_set_y, pos1, 30), (overlay_set_area_size, reg1, pos1),
  238.         (position_set_x, pos1, 168), (position_set_y, pos1, 31), (overlay_set_position, reg1, pos1),
  239.         (store_troop_gold, reg59, "trp_player"),
  240.         (create_text_overlay, reg1, "@Your money: {reg59} aurums", tf_center_justify), (overlay_set_color, reg1, 0x000000),
  241.         (position_set_x, pos1, 1000), (position_set_y, pos1, 1100), (overlay_set_size, reg1, pos1),
  242.         (position_set_x, pos1, 250), (position_set_y, pos1, 30), (overlay_set_area_size, reg1, pos1),
  243.         (position_set_x, pos1, 832), (position_set_y, pos1, 31), (overlay_set_position, reg1, pos1),
  244.        
  245.         (create_mesh_overlay_with_tableau_material, reg1, -1, "tableau_game_party_window", "trp_player"),
  246.         (position_set_x, pos1, 750), (position_set_y, pos1, 850), (overlay_set_size, reg1, pos1), #old 820/950
  247.         (position_set_x, pos1, 300), (position_set_y, pos1, 40), (overlay_set_position, reg1, pos1), #old 383/60
  248.        
  249.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  250.        
  251.         ## Player's inventory
  252.         (str_clear, s1),
  253.         (create_text_overlay, "$g_presentation_obj_3", s1, tf_scrollable),
  254.         (position_set_x, pos1, 688), (position_set_y, pos1, 102),
  255.         (overlay_set_position, "$g_presentation_obj_3", pos1),
  256.         (position_set_x, pos1, 269), (position_set_y, pos1, 597),
  257.         (overlay_set_area_size, "$g_presentation_obj_3", pos1),
  258.         (set_container_overlay, "$g_presentation_obj_3"),
  259.        
  260.         (assign, ":overlay_counter", 10),
  261.         (troop_get_inventory_capacity, ":pl_inv_cap", "trp_player"),
  262.         (assign, ":pos_x", 45), (store_sub, ":pos_y", ":pl_inv_cap", 9), (val_mul, ":pos_y", 90), (val_div, ":pos_y", 3), (val_sub, ":pos_y", 40),
  263.         (try_for_range, ":i_slot", 10, ":pl_inv_cap"),
  264.             (troop_get_inventory_slot, ":item", "trp_player", ":i_slot"),
  265.             (try_begin),
  266.                 (ge, ":item", 0),
  267.                 (store_sub, ":pos_x_adj", ":pos_x", 45), (store_sub, ":pos_y_adj", ":pos_y", 46),
  268.                 (create_mesh_overlay, reg1, "mesh_inv_slot"),
  269.                 (position_set_x, pos1, 870), (position_set_y, pos1, 870), (overlay_set_size, reg1, pos1),
  270.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  271.                 (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"),
  272.                 (position_set_x, pos1, 694), (position_set_y, pos1, 694), (overlay_set_size, reg1, pos1),
  273.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  274.                 (create_mesh_overlay_with_item_id, reg1, ":item"),
  275.                 (position_set_x, pos1, 922), (position_set_y, pos1, 922), (overlay_set_size, reg1, pos1),
  276.                 (position_set_x, pos1, ":pos_x"), (position_set_y, pos1, ":pos_y"), (overlay_set_position, reg1, pos1),
  277.                 (troop_set_slot, "trp_temp_array_c", ":overlay_counter", reg1),
  278.                 (val_add, ":overlay_counter", 1),
  279.             (else_try),
  280.                 (store_sub, ":pos_x_adj", ":pos_x", 45), (store_sub, ":pos_y_adj", ":pos_y", 46),
  281.                 (create_mesh_overlay, reg1, "mesh_inv_slot"),
  282.                 (position_set_x, pos1, 870), (position_set_y, pos1, 870), (overlay_set_size, reg1, pos1),
  283.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  284.                 (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"),
  285.                 (position_set_x, pos1, 694), (position_set_y, pos1, 694), (overlay_set_size, reg1, pos1),
  286.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  287.                 (val_mul, reg1, -1), (troop_set_slot, "trp_temp_array_c", ":overlay_counter", reg1),
  288.                 (val_add, ":overlay_counter", 1),
  289.             (try_end),
  290.             (val_add, ":pos_x", 90),
  291.             (try_begin),
  292.                 (ge, ":pos_x", 250),
  293.                 (assign, ":pos_x", 45),
  294.                 (val_sub, ":pos_y", 92),
  295.             (try_end),
  296.         (try_end),
  297.         (set_container_overlay, -1),
  298.        
  299.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  300.        
  301.         ## Merchant's inventory
  302.         (str_clear, s1),
  303.         (create_text_overlay, "$g_presentation_obj_4", s1, tf_scrollable),
  304.         (position_set_x, pos1, 18), (position_set_y, pos1, 102),
  305.         (overlay_set_position, "$g_presentation_obj_4", pos1),
  306.         (position_set_x, pos1, 270), (position_set_y, pos1, 595),
  307.         (overlay_set_area_size, "$g_presentation_obj_4", pos1),
  308.         (set_container_overlay, "$g_presentation_obj_4"),
  309.        
  310.         (assign, ":overlay_counter", 120),
  311.         (troop_get_inventory_capacity, ":pl_inv_cap", "$temp_2"),
  312.         (assign, ":pos_x", 45), (store_sub, ":pos_y", ":pl_inv_cap", 9), (val_mul, ":pos_y", 90), (val_div, ":pos_y", 3), (val_sub, ":pos_y", 40),
  313.         (try_for_range, ":i_slot", 10, ":pl_inv_cap"),
  314.             (troop_get_inventory_slot, ":item", "$temp_2", ":i_slot"),
  315.             (try_begin),
  316.                 (ge, ":item", 0),
  317.                 (store_sub, ":pos_x_adj", ":pos_x", 45), (store_sub, ":pos_y_adj", ":pos_y", 46),
  318.                 (create_mesh_overlay, reg1, "mesh_inv_slot"),
  319.                 (position_set_x, pos1, 870), (position_set_y, pos1, 870), (overlay_set_size, reg1, pos1),
  320.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  321.                 (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"),
  322.                 (position_set_x, pos1, 694), (position_set_y, pos1, 694), (overlay_set_size, reg1, pos1),
  323.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  324.                 (create_mesh_overlay_with_item_id, reg1, ":item"),
  325.                 (position_set_x, pos1, 922), (position_set_y, pos1, 922), (overlay_set_size, reg1, pos1),
  326.                 (position_set_x, pos1, ":pos_x"), (position_set_y, pos1, ":pos_y"), (overlay_set_position, reg1, pos1),
  327.                 (troop_set_slot, "trp_temp_array_c", ":overlay_counter", reg1),
  328.                 (val_add, ":overlay_counter", 1),
  329.             (else_try),
  330.                 (store_sub, ":pos_x_adj", ":pos_x", 45), (store_sub, ":pos_y_adj", ":pos_y", 46),
  331.                 (create_mesh_overlay, reg1, "mesh_inv_slot"),
  332.                 (position_set_x, pos1, 870), (position_set_y, pos1, 870), (overlay_set_size, reg1, pos1),
  333.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  334.                 (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"),
  335.                 (position_set_x, pos1, 694), (position_set_y, pos1, 694), (overlay_set_size, reg1, pos1),
  336.                 (position_set_x, pos1, ":pos_x_adj"), (position_set_y, pos1, ":pos_y_adj"), (overlay_set_position, reg1, pos1),
  337.                 (val_mul, reg1, -1), (troop_set_slot, "trp_temp_array_c", ":overlay_counter", reg1),
  338.                 (val_add, ":overlay_counter", 1),
  339.             (try_end),
  340.             (val_add, ":pos_x", 90),
  341.             (try_begin),
  342.                 (ge, ":pos_x", 250),
  343.                 (assign, ":pos_x", 45),
  344.                 (val_sub, ":pos_y", 92),
  345.             (try_end),
  346.         (try_end),
  347.         (set_container_overlay, -1),
  348.        
  349.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  350.        
  351.         ## Trade buttons
  352.         (create_game_button_overlay, "$g_presentation_obj_5", "@Deal!"),
  353.         (position_set_x, pos1, 522), (position_set_y, pos1, 250), (overlay_set_position, "$g_presentation_obj_5", pos1),
  354.        
  355.         (create_game_button_overlay, "$g_presentation_obj_6", "@Sell Before"),
  356.         (position_set_x, pos1, 568), (position_set_y, pos1, 164), (overlay_set_position, "$g_presentation_obj_6", pos1),
  357.        
  358.         (create_game_button_overlay, "$g_presentation_obj_7", "@Sell After"),
  359.         (position_set_x, pos1, 568), (position_set_y, pos1, 102), (overlay_set_position, "$g_presentation_obj_7", pos1),
  360.        
  361.     ]),
  362.        
  363.         ##SECONDARY TRIGGERS BEGIN
  364.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  365.    (ti_on_presentation_event_state_change,
  366.       [
  367.         (store_trigger_param_1, ":object"),
  368.         (store_trigger_param_2, ":value"),
  369.        
  370.         (try_begin), ####### DONE BUTTON #######
  371.             (eq, ":object", "$g_presentation_obj_1"),
  372.             (presentation_set_duration, 0),
  373.         (else_try), ####### TRADER SWITCH BUTTON #######
  374.             (eq, ":object", "$g_presentation_obj_2"),
  375.             (try_begin),
  376.                 (eq, ":value", 0),
  377.                 (party_get_slot, "$temp_2", "$current_town", slot_town_merchant),
  378.             (else_try),
  379.                 (eq, ":value", 1),
  380.                 (party_get_slot, "$temp_2", "$current_town", slot_town_horse_merchant),
  381.             (else_try),
  382.                 (eq, ":value", 2),
  383.                 (party_get_slot, "$temp_2", "$current_town", slot_town_armorer),
  384.             (else_try),
  385.                 (party_get_slot, "$temp_2", "$current_town", slot_town_weaponsmith),
  386.             (try_end),
  387.             (start_presentation, "prsnt_trade_screen_replacer"),
  388.         (else_try), ####### DEAL BUTTON #######
  389.             (eq, ":object", "$g_presentation_obj_5"),
  390.             (store_troop_gold, ":player_gold","trp_player"),
  391.             (store_troop_gold, ":merchant_gold","$temp_2"),
  392.             (assign, ":total_purchase_price", 0),
  393.             (assign, ":total_selling_price", 0),
  394.             (assign, ":total_items_for_sale", 0),
  395.             (assign, ":total_items_for_purchase", 0),
  396.             (store_free_inventory_capacity, ":player_free_inv_capacity", "trp_player"),
  397.             (store_free_inventory_capacity, ":merchant_free_inv_cap", "$temp_2"),
  398.             (troop_get_inventory_capacity, ":player_full_inv_capacity", "trp_player"),
  399.             (troop_get_inventory_capacity, ":merchant_full_inv_cap", "$temp_2"),
  400.             (try_for_range, ":inv_slot", 10, ":merchant_full_inv_cap"), #merchant
  401.                 (troop_slot_eq, "trp_temp_array_b", ":inv_slot", 1),
  402.                 (troop_get_inventory_slot, ":item_no", "$temp_2", ":inv_slot"),
  403.                 (troop_get_inventory_slot_modifier, ":imod", "$temp_2", ":inv_slot"),
  404.                 (call_script, "script_get_item_value_with_imod", ":item_no", ":imod"), #or script_dplmc_get_item_value_with_imod - DIPLOMACY SCRIPT
  405.                 (assign, ":price", reg0),
  406.                 (val_div, ":price", 100),
  407.                 (call_script, "script_game_get_item_buy_price_factor", ":item_no"),
  408.                 (val_mul, ":price", reg0),
  409.                 (val_div, ":price", 100),
  410.                 (try_begin),
  411.                     (is_between, ":item_no", food_begin, food_end),
  412.                     (troop_inventory_slot_get_item_amount, ":item_quantity", "$temp_2", ":inv_slot"),
  413.                     (troop_inventory_slot_get_item_max_amount, ":item_max_quantity", "$temp_2", ":inv_slot"),
  414.                     (val_mul, ":price", ":item_quantity"),
  415.                     (val_div, ":price", ":item_max_quantity"),
  416.                 (try_end),
  417.                 (val_max, ":price", 1), (val_add, ":total_purchase_price", ":price"), (val_add, ":total_items_for_purchase", 1),
  418.                 (store_add, ":price_cache_slot", ":inv_slot", 120), (troop_set_slot, "trp_temp_array_b", ":price_cache_slot", ":price"),
  419.             (try_end),
  420.             (try_for_range, ":inv_slot", 0, ":player_full_inv_capacity"), #player
  421.                 (troop_slot_eq, "trp_temp_array_a", ":inv_slot", 1),
  422.                 (troop_get_inventory_slot, ":item_no", "trp_player", ":inv_slot"),
  423.                 (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":inv_slot"),
  424.                 (call_script, "script_get_item_value_with_imod", ":item_no", ":imod"), #or script_dplmc_get_item_value_with_imod - DIPLOMACY SCRIPT
  425.                 (assign, ":price", reg0),
  426.                 (val_div, ":price", 100),
  427.                 (call_script, "script_game_get_item_sell_price_factor", ":item_no"),
  428.                 (val_mul, ":price", reg0),
  429.                 (val_div, ":price", 100),
  430.                 (try_begin),
  431.                     (is_between, ":item_no", food_begin, food_end),
  432.                     (troop_inventory_slot_get_item_amount, ":item_quantity", "trp_player", ":inv_slot"),
  433.                     (troop_inventory_slot_get_item_max_amount, ":item_max_quantity", "trp_player", ":inv_slot"),
  434.                     (val_mul, ":price", ":item_quantity"),
  435.                     (val_div, ":price", ":item_max_quantity"),
  436.                 (try_end),
  437.                 (val_max, ":price", 1), (val_add, ":total_selling_price", ":price"), (val_add, ":total_items_for_sale", 1),
  438.                 (store_add, ":price_cache_slot", ":inv_slot", 120), (troop_set_slot, "trp_temp_array_a", ":price_cache_slot", ":price"),
  439.             (try_end),
  440.             (store_add, ":player_purchasing_capacity", ":player_gold", ":total_selling_price"), (val_sub, ":player_purchasing_capacity", ":total_purchase_price"),
  441.             (store_add, ":merchant_purchasing_capacity", ":merchant_gold", ":total_purchase_price"), (val_sub, ":merchant_purchasing_capacity", ":total_selling_price"),
  442.             (try_begin),
  443.                 (lt, ":player_purchasing_capacity", 0),
  444.                 (display_message, "@You don't have enough money!", 0xFF0000),
  445.             (else_try),
  446.                 (lt, ":merchant_purchasing_capacity", 0),
  447.                 (display_message, "@The merchant doesn't have enough money!", 0xFF0000),
  448.             (else_try),
  449.                 (lt, ":merchant_free_inv_cap", ":total_items_for_sale"),
  450.                 (display_message, "@The merchant's inventory is full!", 0xFF0000),
  451.             (else_try),
  452.                 (lt, ":player_free_inv_capacity", ":total_items_for_purchase"),
  453.                 (display_message, "@Your inventory is full!", 0xFF0000),
  454.             (else_try),
  455.                 (assign, ":total_player_profit", 0),
  456.                 (assign, ":last_empty_slot", 10),
  457.                 (try_for_range, ":inv_slot", 0, ":player_full_inv_capacity"), #player
  458.                     (troop_slot_eq, "trp_temp_array_a", ":inv_slot", 1),
  459.                     (store_add, ":price_cache_slot", ":inv_slot", 120),
  460.                     (troop_get_slot, ":cur_price", "trp_temp_array_a", ":price_cache_slot"),
  461.                     (troop_get_inventory_slot, ":item_no", "trp_player", ":inv_slot"),
  462.                     (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":inv_slot"),
  463.                     (try_begin),
  464.                         (is_between, ":item_no", food_begin, food_end),
  465.                         (troop_inventory_slot_get_item_amount, ":item_quantity", "trp_player", ":inv_slot"),
  466.                     (try_end),
  467.                     (assign, ":end", ":merchant_full_inv_cap"),
  468.                     (try_for_range, ":merchant_cur_inv_slot", ":last_empty_slot", ":end"),
  469.                         (troop_get_inventory_slot, ":cur_item", "$temp_2", ":merchant_cur_inv_slot"),
  470.                         (eq, ":cur_item", -1),
  471.                         (troop_set_inventory_slot, "$temp_2", ":merchant_cur_inv_slot", ":item_no"),
  472.                         (troop_set_inventory_slot_modifier, "$temp_2", ":merchant_cur_inv_slot", ":imod"),
  473.                         (try_begin),
  474.                             (is_between, ":item_no", food_begin, food_end),
  475.                             (troop_inventory_slot_set_item_amount, "$temp_2", ":merchant_cur_inv_slot", ":item_quantity"),
  476.                         (try_end),
  477.                         (val_add, ":total_player_profit", ":cur_price"),
  478.                         (troop_set_inventory_slot, "trp_player", ":inv_slot", -1),
  479.                         (troop_set_inventory_slot_modifier, "trp_player", ":inv_slot", 0),
  480.                         (troop_inventory_slot_set_item_amount, "trp_player", ":inv_slot", 0),
  481.                         (store_add, ":last_empty_slot", ":merchant_cur_inv_slot", 1),
  482.                         (assign, ":end", 0),
  483.                     (try_end),
  484.                 (try_end), 
  485.                 (assign, ":last_empty_slot", 10),
  486.                 (try_for_range, ":inv_slot", 10, ":merchant_full_inv_cap"), #merchant
  487.                     (troop_slot_eq, "trp_temp_array_b", ":inv_slot", 1),
  488.                     (store_add, ":price_cache_slot", ":inv_slot", 120),
  489.                     (troop_get_slot, ":cur_price", "trp_temp_array_b", ":price_cache_slot"),
  490.                     (troop_get_inventory_slot, ":item_no", "$temp_2", ":inv_slot"),
  491.                     (troop_get_inventory_slot_modifier, ":imod", "$temp_2", ":inv_slot"),
  492.                     (try_begin),
  493.                         (is_between, ":item_no", food_begin, food_end),
  494.                         (troop_inventory_slot_get_item_amount, ":item_quantity", "$temp_2", ":inv_slot"),
  495.                     (try_end),
  496.                     (assign, ":end", ":player_full_inv_capacity"),
  497.                     (try_for_range, ":player_cur_inv_slot", ":last_empty_slot", ":end"),
  498.                         (troop_get_inventory_slot, ":cur_item", "trp_player", ":player_cur_inv_slot"),
  499.                         (eq, ":cur_item", -1),
  500.                         (troop_set_inventory_slot, "trp_player", ":player_cur_inv_slot", ":item_no"),
  501.                         (troop_set_inventory_slot_modifier, "trp_player", ":player_cur_inv_slot", ":imod"),
  502.                         (try_begin),
  503.                             (is_between, ":item_no", food_begin, food_end),
  504.                             (troop_inventory_slot_set_item_amount, "trp_player", ":player_cur_inv_slot", ":item_quantity"),
  505.                         (try_end),
  506.                         (val_sub, ":total_player_profit", ":cur_price"),
  507.                         (troop_set_inventory_slot, "$temp_2", ":inv_slot", -1),
  508.                         (troop_set_inventory_slot_modifier, "$temp_2", ":inv_slot", 0),
  509.                         (troop_inventory_slot_set_item_amount, "$temp_2", ":inv_slot", 0),
  510.                         (store_add, ":last_empty_slot", ":player_cur_inv_slot", 1),
  511.                         (assign, ":end", 0),
  512.                     (try_end),
  513.                 (try_end), 
  514.                 (try_begin),
  515.                     (ge, ":total_player_profit", 1),
  516.                     (troop_add_gold, "trp_player", ":total_player_profit"),
  517.                     (troop_remove_gold, "$temp_2", ":total_player_profit"),
  518.                 (else_try),
  519.                     (le, ":total_player_profit", -1),
  520.                     (val_mul, ":total_player_profit", -1),
  521.                     (troop_add_gold, "$temp_2", ":total_player_profit"),
  522.                     (troop_remove_gold, "trp_player", ":total_player_profit"),
  523.                 (try_end), 
  524.                 (start_presentation, "prsnt_trade_screen_replacer"),
  525.             (try_end),
  526.         (else_try), ####### SELL AFTER/BEFORE BUTTONS #######
  527.             (this_or_next|eq, ":object", "$g_presentation_obj_6"), (eq, ":object", "$g_presentation_obj_7"),
  528.             (store_free_inventory_capacity, ":player_free_inv_capacity", "trp_player"),
  529.             (store_free_inventory_capacity, ":merchant_free_inv_cap", "$temp_2"),
  530.             (troop_get_inventory_capacity, ":player_full_inv_capacity", "trp_player"),
  531.             (assign, ":total_items_selected", 0),
  532.             (assign, ":key_slot", -1),
  533.             (try_for_range, ":inv_slot", 10, ":player_full_inv_capacity"), #player
  534.                 (troop_slot_eq, "trp_temp_array_a", ":inv_slot", 1),
  535.                 (val_add, ":total_items_selected", 1),
  536.                 (assign, ":key_slot", ":inv_slot"),
  537.             (try_end),
  538.             (try_begin),
  539.                 (eq, ":key_slot", -1),
  540.                 (display_message, "@You have to select an item that will be the beginning/end of your selling queue!", 0xFF0000),
  541.             (else_try),
  542.                 (neq, ":total_items_selected", 1),
  543.                 (display_message, "@You have to select only 1 item that will be the beginning/end of your selling queue!", 0xFF0000),
  544.             (else_try),
  545.                 (try_begin),
  546.                     (eq, ":object", "$g_presentation_obj_6"),
  547.                     (assign, ":beginning", 10), (store_add, ":ending", ":key_slot", 1),
  548.                 (else_try),
  549.                     (eq, ":object", "$g_presentation_obj_7"),
  550.                     (assign, ":beginning", ":key_slot"), (assign, ":ending", ":player_full_inv_capacity"),
  551.                 (try_end),
  552.                 (party_get_slot, ":weaponsmith", "$current_town", slot_town_weaponsmith), (gt, ":weaponsmith", "trp_player"),
  553.                 (party_get_slot, ":armourer", "$current_town", slot_town_armorer), (gt, ":armourer", "trp_player"),
  554.                 (party_get_slot, ":horse_merch", "$current_town", slot_town_horse_merchant), (gt, ":horse_merch", "trp_player"),
  555.                 (party_get_slot, ":food_merch", "$current_town", slot_town_merchant), (gt, ":food_merch", "trp_player"),
  556.                 (assign, ":total_items_sold", 0),
  557.                 (assign, ":total_money_received", 0),
  558.                
  559.                 (try_for_range, ":i_slot", ":beginning", ":ending"),
  560.                   (troop_get_inventory_slot, ":item", "trp_player", ":i_slot"),
  561.                   (neq, ":item", -1),
  562.                   (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":i_slot"),
  563.                   (item_get_type, ":item_type", ":item"),
  564.                   (call_script, "script_get_item_value_with_imod", ":item", ":imod"), #or script_dplmc_get_item_value_with_imod
  565.                   (assign, ":score", reg0),
  566.                   (val_div, ":score", 100),
  567.                   (call_script, "script_game_get_item_sell_price_factor", ":item"),
  568.                   (val_mul, ":score", reg0),
  569.                   (val_div, ":score", 100),
  570.                   (try_begin),
  571.                         (is_between, ":item", food_begin, food_end),
  572.                         (troop_inventory_slot_get_item_amount, ":item_quantity", "trp_player", ":i_slot"),
  573.                         (troop_inventory_slot_get_item_max_amount, ":item_max_quantity", "trp_player", ":i_slot"),
  574.                         (val_mul, ":score", ":item_quantity"),
  575.                         (val_div, ":score", ":item_max_quantity"),
  576.                   (try_end),
  577.                   (val_max, ":score", 1),
  578.                   (store_troop_gold, ":wea_m_gold",":weaponsmith"),
  579.                   (store_troop_gold, ":arm_m_gold",":armourer"),
  580.                   (store_troop_gold, ":horse_m_gold",":horse_merch"),
  581.                   (store_troop_gold, ":food_m_gold",":food_merch"),
  582.                   (store_free_inventory_capacity, ":wea_m_space", ":weaponsmith"),
  583.                   (store_free_inventory_capacity, ":arm_m_space", ":armourer"),
  584.                   (store_free_inventory_capacity, ":horse_m_space", ":horse_merch"),
  585.                   (store_free_inventory_capacity, ":food_m_space", ":food_merch"),
  586.                   (try_begin),
  587.                     (this_or_next|eq, ":item_type", itp_type_head_armor),
  588.                     (this_or_next|eq, ":item_type", itp_type_body_armor),
  589.                     (this_or_next|eq, ":item_type", itp_type_foot_armor),
  590.                     (eq, ":item_type", itp_type_hand_armor),
  591.                     (assign, ":i_want_merchant", ":armourer"),
  592.                   (else_try),
  593.                     (eq, ":item_type", itp_type_horse),
  594.                     (assign, ":i_want_merchant", ":horse_merch"),
  595.                   (else_try),
  596.                     (this_or_next|eq, ":item_type", itp_type_book),
  597.                     (eq, ":item_type", itp_type_goods),
  598.                     (assign, ":i_want_merchant", ":food_merch"),
  599.                   (else_try),
  600.                     (assign, ":i_want_merchant", ":weaponsmith"),
  601.                   (try_end),
  602.                  
  603.                   (assign, ":target_merchant", -1),
  604.                   (try_begin),
  605.                     (store_troop_gold, ":iwm_gold",":i_want_merchant"), (le, ":score", ":iwm_gold"),
  606.                     (store_free_inventory_capacity, ":iwm_space", ":i_want_merchant"), (gt, ":iwm_space", 0),
  607.                     (assign, ":target_merchant", ":i_want_merchant"),
  608.                   (else_try),
  609.                     (le, ":score", ":arm_m_gold"), (gt, ":arm_m_space", 0),
  610.                     (assign, ":target_merchant", ":armourer"),
  611.                   (else_try),
  612.                     (le, ":score", ":horse_m_gold"), (gt, ":horse_m_space", 0),
  613.                     (assign, ":target_merchant", ":horse_merch"),
  614.                   (else_try),
  615.                     (le, ":score", ":wea_m_gold"), (gt, ":wea_m_space", 0),
  616.                     (assign, ":target_merchant", ":weaponsmith"),
  617.                   (else_try),
  618.                     (le, ":score", ":food_m_gold"), (gt, ":food_m_space", 0),
  619.                     (assign, ":target_merchant", ":food_merch"),
  620.                   (try_end),
  621.                   (neq, ":target_merchant", -1),
  622.                  
  623.                   (troop_remove_gold, ":target_merchant", ":score"),
  624.                   (try_begin),
  625.                     (neg|is_between, ":item", food_begin, food_end),
  626.                     (troop_add_item, ":target_merchant", ":item", ":imod"),
  627.                   (else_try),
  628.                     (troop_get_inventory_capacity, ":target_merchant_inv_capacity", ":target_merchant"),
  629.                     (assign, ":end", ":target_merchant_inv_capacity"),
  630.                     (try_for_range, ":target_merchant_cur_inv_slot", 10, ":end"),
  631.                         (troop_get_inventory_slot, ":cur_item", ":target_merchant", ":target_merchant_cur_inv_slot"),
  632.                         (eq, ":cur_item", -1),
  633.                         (troop_set_inventory_slot, ":target_merchant", ":target_merchant_cur_inv_slot", ":item"),
  634.                         (troop_set_inventory_slot_modifier, ":target_merchant", ":target_merchant_cur_inv_slot", ":imod"),
  635.                         (troop_inventory_slot_set_item_amount, ":target_merchant", ":target_merchant_cur_inv_slot", ":item_quantity"),
  636.                         (assign, ":end", 0),
  637.                     (try_end),
  638.                   (try_end),
  639.                   (troop_set_inventory_slot, "trp_player", ":i_slot", -1),
  640.                   (val_add, ":total_items_sold", 1),
  641.                   (val_add, ":total_money_received", ":score"),
  642.                   (try_begin),
  643.                     (ge, "$cheat_mode", 1),
  644.                     (str_store_troop_name, s1, ":target_merchant"),
  645.                     (str_store_item_name, s2, ":item"),
  646.                     (assign, reg0, ":score"),
  647.                     (display_message, "@{s2} was sold to {s1} for {reg0}"),
  648.                   (try_end),
  649.                 (try_end),
  650.                 (troop_add_gold, "trp_player", ":total_money_received"),
  651.                 (assign, reg0, ":total_items_sold"),
  652.                 (assign, reg1, ":total_money_received"),
  653.                 (display_message, "@A total of {reg0} items were sold for a total price of {reg1}."),
  654.                 (start_presentation, "prsnt_trade_screen_replacer"),
  655.             (try_end),
  656.         (try_end),
  657.       ]),
  658.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  659.    (ti_on_presentation_run,
  660.     [
  661.       (try_begin),
  662.           (key_clicked, key_escape),
  663.           (presentation_set_duration, 0),
  664.       (try_end),
  665.         ]),
  666.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  667.     (ti_on_presentation_mouse_enter_leave,
  668.       [
  669.       (store_trigger_param_1, ":object"),
  670.       (store_trigger_param_2, ":enter_leave"),
  671.  
  672.       (try_begin),
  673.           (eq, ":enter_leave", 0), #enters
  674.           (assign, ":end", 210),
  675.           (try_for_range, ":slot_no", 0, ":end"),
  676.             (troop_slot_eq, "trp_temp_array_c", ":slot_no", ":object"),
  677.             (assign, "$g_current_opened_item_details", ":slot_no"),
  678.             (assign, ":imod", 0),
  679.             (assign, ":quantity", 0),
  680.             (try_begin),
  681.                 (is_between, ":slot_no", 0, 110),
  682.                 (assign, ":offset", ":slot_no"),
  683.                 (troop_get_inventory_slot, ":item_no", "trp_player", ":offset"), (gt, ":item_no", 0),
  684.                 (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":offset"),
  685.                 (troop_inventory_slot_get_item_amount, ":quantity", "trp_player", ":offset"),
  686.                 (call_script, "script_game_get_item_sell_price_factor", ":item_no"),
  687.                 (assign, ":price_factor", reg0), (assign, ":self", "trp_player"),
  688.             (else_try),
  689.                 (is_between, ":slot_no", 120, 220),
  690.                 (store_sub, ":offset", ":slot_no", 110),
  691.                 (troop_get_inventory_slot, ":item_no", "$temp_2", ":offset"), (gt, ":item_no", 0),
  692.                 (troop_get_inventory_slot_modifier, ":imod", "$temp_2", ":offset"),
  693.                 (troop_inventory_slot_get_item_amount, ":quantity", "$temp_2", ":offset"),
  694.                 (call_script, "script_game_get_item_buy_price_factor", ":item_no"),
  695.                 (assign, ":price_factor", reg0), (assign, ":self", "$temp_2"),
  696.             (try_end),
  697.             (assign, ":end", 0),
  698.           (try_end),
  699.          
  700.           (try_begin),
  701.             (gt, ":item_no", 0),
  702.             (assign, reg58, -567),
  703.             (assign, reg59, ":quantity"),
  704.             (item_get_difficulty, reg60, ":item_no"),
  705.             (try_begin),
  706.                 (eq, ":imod", imod_masterwork), (val_add, reg60, 4),
  707.             (else_try),
  708.                 (neg|item_slot_eq, ":item_no", slot_item_type, itp_type_horse),
  709.                 (eq, ":imod", imod_heavy), (val_add, reg60, 1),
  710.             (else_try),
  711.                 (eq, ":imod", imod_strong), (val_add, reg60, 2),
  712.             (else_try),
  713.                 (eq, ":imod", imod_stubborn), (val_add, reg60, 1),
  714.             (else_try),
  715.                 (eq, ":imod", imod_timid), (val_add, reg60, -1), (val_max, reg60, 0),
  716.             # (else_try),
  717.                 # (eq, ":imod", imod_spirited), (val_add, reg60, 1),
  718.             (else_try),
  719.                 (eq, ":imod", imod_champion), (val_add, reg60, 2),
  720.             (try_end),
  721.             (overlay_get_position, pos0, ":object"),
  722.             (try_begin),
  723.                 (is_between, ":item_no", food_begin, food_end),
  724.                 (troop_inventory_slot_get_item_max_amount, ":item_max_quantity", ":self", ":offset"),
  725.                 (val_mul, ":price_factor", ":quantity"),
  726.                 (val_div, ":price_factor", ":item_max_quantity"),
  727.                 (assign, reg60, ":item_max_quantity"), #reg60 - difficulty for equipment, quantity for food
  728.             (try_end),
  729.             (show_item_details_with_modifier, ":item_no", ":imod", pos0, ":price_factor"),
  730.           (try_end),
  731.           (assign, reg58, 0),
  732.       (else_try),
  733.           (eq, ":enter_leave", 1), #leaves
  734.           (assign, ":end", 210),
  735.           (try_for_range, ":slot_no", 0, ":end"),
  736.             (troop_slot_eq, "trp_temp_array_c", ":slot_no", ":object"),
  737.             (assign, "$g_current_opened_item_details", ":slot_no"),
  738.             (close_item_details),
  739.             (assign, ":end", 0),
  740.           (try_end),
  741.       (try_end),
  742.     ]),
  743.         ##+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  744.     (ti_on_presentation_mouse_press,
  745.       [
  746.       (store_trigger_param_1, ":object"),
  747.       (store_trigger_param_2, ":mouse_button"), #0: left mouse button, 1 right mouse button, 2 middle mouse button
  748.       (try_begin), #LMB
  749.           (eq, ":mouse_button", 0),
  750.           (assign, ":end", 210),
  751.           (assign, ":item_no", -1),
  752.           #(assign, ":key_slot", -1),
  753.           (try_for_range, ":slot_no", 0, ":end"),
  754.             (troop_slot_eq, "trp_temp_array_c", ":slot_no", ":object"),
  755.             #(assign, ":key_slot", ":slot_no"),
  756.             (try_begin),
  757.                 (is_between, ":slot_no", 0, 110),
  758.                 (assign, ":offset", ":slot_no"),
  759.                 (troop_get_inventory_slot, ":item_no", "trp_player", ":offset"),
  760.                 (assign, ":self", "trp_player"), (assign, ":other", "$temp_2"),
  761.                 (call_script, "script_game_get_item_sell_price_factor", ":item_no"),
  762.                 (assign, ":price_factor", reg0),
  763.             (else_try),
  764.                 (is_between, ":slot_no", 120, 220),
  765.                 (store_sub, ":offset", ":slot_no", 110),
  766.                 (troop_get_inventory_slot, ":item_no", "$temp_2", ":offset"),
  767.                 (assign, ":self", "$temp_2"), (assign, ":other", "trp_player"),
  768.                 (call_script, "script_game_get_item_buy_price_factor", ":item_no"),
  769.                 (assign, ":price_factor", reg0),
  770.             (try_end),
  771.             (assign, ":inv_slot", ":offset"),
  772.             (assign, ":end", 0),
  773.           (try_end),
  774.           #(str_store_item_name, s30, ":item_no"), (assign, reg58, ":slot_no"), (display_message, "@{reg58} slot - item {s30}"),
  775.           (try_begin),
  776.             (gt, ":item_no", 0),
  777.             (try_begin), #CTRL is pressed
  778.                 (this_or_next|key_is_down, key_left_control), (key_is_down, key_right_control),
  779.                 (store_troop_gold, ":buyer_gold",":other"),
  780.                 (troop_get_inventory_slot_modifier, ":imod", ":self", ":inv_slot"),
  781.                 (call_script, "script_get_item_value_with_imod", ":item_no", ":imod"), #or script_dplmc_get_item_value_with_imod - DIPLOMACY SCRIPT
  782.                 (assign, ":price", reg0),
  783.                 (val_div, ":price", 100),
  784.                 (val_mul, ":price", ":price_factor"),
  785.                 (val_div, ":price", 100),
  786.                 (try_begin),
  787.                     (is_between, ":item_no", food_begin, food_end),
  788.                     (troop_inventory_slot_get_item_amount, ":item_quantity", ":self", ":inv_slot"),
  789.                     (troop_inventory_slot_get_item_max_amount, ":item_max_quantity", ":self", ":inv_slot"),
  790.                     (val_mul, ":price", ":item_quantity"),
  791.                     (val_div, ":price", ":item_max_quantity"),
  792.                 (try_end),
  793.                 (val_max, ":price", 1),
  794.                 (try_begin),
  795.                     (ge, ":buyer_gold",":price"),
  796.                     (troop_set_inventory_slot, ":self", ":inv_slot", -1),
  797.                     (troop_set_inventory_slot_modifier, ":self", ":inv_slot", 0),
  798.                     (troop_inventory_slot_set_item_amount, ":self", ":inv_slot", 0),
  799.                     (troop_add_gold, ":self", ":price"),
  800.                     (troop_remove_gold, ":other", ":price"),
  801.                     (troop_get_inventory_capacity, ":other_inv_cap", ":other"),
  802.                     (try_for_range, ":buyer_cur_inv_slot", 10, ":other_inv_cap"),
  803.                         (troop_get_inventory_slot, ":cur_item", ":other", ":buyer_cur_inv_slot"),
  804.                         (eq, ":cur_item", -1),
  805.                         (troop_set_inventory_slot, ":other", ":buyer_cur_inv_slot", ":item_no"),
  806.                         (troop_set_inventory_slot_modifier, ":other", ":buyer_cur_inv_slot", ":imod"),
  807.                         (try_begin),
  808.                             (is_between, ":item_no", food_begin, food_end),
  809.                             (troop_inventory_slot_set_item_amount, ":other", ":buyer_cur_inv_slot", ":item_quantity"),
  810.                         (try_end),
  811.                         (assign, ":other_inv_cap", 10),
  812.                     (try_end),
  813.                     (start_presentation, "prsnt_trade_screen_replacer"),
  814.                 (try_end),
  815.             (else_try), #CTRL isn't pressed
  816.                 (try_begin),
  817.                     (eq, ":self", "trp_player"),
  818.                     (assign, ":array_troop", "trp_temp_array_a"),
  819.                 (else_try),
  820.                     (assign, ":array_troop", "trp_temp_array_b"),
  821.                 (try_end),
  822.                 (try_begin),
  823.                     (troop_slot_eq, ":array_troop", ":inv_slot", 1),
  824.                     (troop_set_slot, ":array_troop", ":inv_slot", -1),
  825.                     (overlay_set_color, ":object", 0xFFFFFF),
  826.                 (else_try),
  827.                     (troop_set_slot, ":array_troop", ":inv_slot", 1),
  828.                     (overlay_set_color, ":object", 0x00CC00),
  829.                 (try_end),
  830.             (try_end),
  831.           (try_end),
  832.       (else_try),
  833.           (eq, ":mouse_button", 1), #RMB
  834.           (assign, ":end", 210),
  835.           (assign, ":item_no", -1),
  836.           (store_mul, ":obj_empty", ":object", -1),
  837.           (assign, ":inv_slot", -1),
  838.           (try_for_range, ":slot_no", 0, ":end"),
  839.             (try_begin),
  840.                 (troop_slot_eq, "trp_temp_array_c", ":slot_no", ":object"),
  841.                 (try_begin),
  842.                     (is_between, ":slot_no", 0, 110),
  843.                     (assign, ":offset", ":slot_no"),
  844.                     (troop_get_inventory_slot, ":item_no", "trp_player", ":offset"),
  845.                     (assign, ":self", "trp_player"), #(assign, ":other", "$temp_2"),
  846.                 (else_try),
  847.                     (is_between, ":slot_no", 120, 220),
  848.                     (store_sub, ":offset", ":slot_no", 110),
  849.                     (troop_get_inventory_slot, ":item_no", "$temp_2", ":offset"),
  850.                     (assign, ":self", "$temp_2"), #(assign, ":other", "trp_player"),
  851.                 (try_end),
  852.                 (assign, ":inv_slot", ":offset"),
  853.                 (assign, ":end", 0),
  854.             (else_try),
  855.                 (troop_slot_eq, "trp_temp_array_c", ":slot_no", ":obj_empty"),
  856.                 (try_begin),
  857.                     (is_between, ":slot_no", 0, 110),
  858.                     (assign, ":offset", ":slot_no"),
  859.                     (assign, ":item_no", -1),
  860.                     (assign, ":self", "trp_player"), #(assign, ":other", "$temp_2"),
  861.                 (else_try),
  862.                     (is_between, ":slot_no", 120, 220),
  863.                     (store_sub, ":offset", ":slot_no", 110),
  864.                     (assign, ":item_no", -1),
  865.                     (assign, ":self", "$temp_2"), #(assign, ":other", "trp_player"),
  866.                 (try_end),
  867.                 (assign, ":inv_slot", ":offset"),
  868.                 (assign, ":end", 0),
  869.             (try_end),
  870.           (try_end),
  871.           #(assign, reg58, ":inv_slot"), (assign, reg59, ":object"), (display_message, "@Slot {reg58}, object {reg59}.", 0xFF0000),
  872.           (try_begin),
  873.             (eq, "$g_presentation_obj_15", -1),
  874.             (eq, ":self", "trp_player"),
  875.             (gt, ":item_no", 0), (neq, ":inv_slot", -1),
  876.             (overlay_set_color, ":object", 0x33FFFF),
  877.             (assign, "$g_presentation_obj_15", ":object"),
  878.             (assign, "$g_presentation_obj_16", ":inv_slot"),
  879.           (else_try), #reset
  880.             (eq, "$g_presentation_obj_15", ":object"), (neq, "$g_presentation_obj_15", -1), (neq, ":inv_slot", -1),
  881.             (eq, ":self", "trp_player"),
  882.             (overlay_set_color, ":object", 0xFFFFFF),
  883.             (assign, "$g_presentation_obj_15", -1),
  884.             (assign, "$g_presentation_obj_16", -1),
  885.           (else_try),
  886.             (neq, "$g_presentation_obj_15", -1), (neq, ":inv_slot", -1),
  887.             (eq, ":self", "trp_player"),
  888.             (troop_get_inventory_slot, ":first_item", "trp_player", "$g_presentation_obj_16"),
  889.             (item_get_type, ":first_item_type", ":first_item"),
  890.             (try_begin),
  891.                 (eq, ":item_no", -1),
  892.                 (assign, ":transition_approved", 1),
  893.             (else_try),
  894.                 (item_get_type, ":second_item_type", ":item_no"),
  895.                 (assign, ":transition_approved", 1),
  896.                 (try_begin),
  897.                     (is_between, "$g_presentation_obj_16", ek_item_0, ek_head),
  898.                     (neq, ":second_item_type", itp_type_one_handed_wpn), (neq, ":second_item_type", itp_type_two_handed_wpn), (neq, ":second_item_type", itp_type_polearm), (neq, ":second_item_type", itp_type_arrows),
  899.                     (neq, ":second_item_type", itp_type_bolts), (neq, ":second_item_type", itp_type_shield), (neq, ":second_item_type", itp_type_bow), (neq, ":second_item_type", itp_type_crossbow), (neq, ":second_item_type", itp_type_thrown),
  900.                     (assign, ":transition_approved", 0),
  901.                 (else_try),
  902.                     (is_between, ":inv_slot", ek_item_0, ek_head),
  903.                     (neq, ":first_item_type", itp_type_one_handed_wpn), (neq, ":first_item_type", itp_type_two_handed_wpn), (neq, ":first_item_type", itp_type_polearm), (neq, ":first_item_type", itp_type_arrows),
  904.                     (neq, ":first_item_type", itp_type_bolts), (neq, ":first_item_type", itp_type_shield), (neq, ":first_item_type", itp_type_bow), (neq, ":first_item_type", itp_type_crossbow), (neq, ":first_item_type", itp_type_thrown),
  905.                     (assign, ":transition_approved", 0),
  906.                 (else_try),
  907.                     (eq, "$g_presentation_obj_16", ek_head), (neq, ":second_item_type", itp_type_head_armor),
  908.                     (assign, ":transition_approved", 0),
  909.                 (else_try),
  910.                     (eq, ":inv_slot", ek_head), (neq, ":first_item_type", itp_type_head_armor),
  911.                     (assign, ":transition_approved", 0),
  912.                 (else_try),
  913.                     (eq, "$g_presentation_obj_16", ek_body), (neq, ":second_item_type", itp_type_body_armor),
  914.                     (assign, ":transition_approved", 0),
  915.                 (else_try),
  916.                     (eq, ":inv_slot", ek_body), (neq, ":first_item_type", itp_type_body_armor),
  917.                     (assign, ":transition_approved", 0),
  918.                 (else_try),
  919.                     (eq, "$g_presentation_obj_16", ek_foot), (neq, ":second_item_type", itp_type_foot_armor),
  920.                     (assign, ":transition_approved", 0),
  921.                 (else_try),
  922.                     (eq, ":inv_slot", ek_foot), (neq, ":first_item_type", itp_type_foot_armor),
  923.                     (assign, ":transition_approved", 0),
  924.                 (else_try),
  925.                     (eq, "$g_presentation_obj_16", ek_gloves), (neq, ":second_item_type", itp_type_hand_armor),
  926.                     (assign, ":transition_approved", 0),
  927.                 (else_try),
  928.                     (eq, ":inv_slot", ek_gloves), (neq, ":first_item_type", itp_type_hand_armor),
  929.                     (assign, ":transition_approved", 0),
  930.                 (else_try),
  931.                     (eq, "$g_presentation_obj_16", ek_horse), (neq, ":second_item_type", itp_type_horse),
  932.                     (assign, ":transition_approved", 0),
  933.                 (else_try),
  934.                     (eq, ":inv_slot", ek_horse), (neq, ":first_item_type", itp_type_horse),
  935.                     (assign, ":transition_approved", 0),
  936.                 (try_end),
  937.             (try_end),
  938.             (eq, ":transition_approved", 1),
  939.             (assign, ":check_item_for_req_slot", -1),
  940.             (try_begin),
  941.                 (is_between, "$g_presentation_obj_16", 0, 9),
  942.                 (neq, ":item_no", -1),
  943.                 (assign, ":check_item_for_req_slot", ":inv_slot"),
  944.             (else_try),
  945.                 (is_between, ":inv_slot", 0, 9),
  946.                 (assign, ":check_item_for_req_slot", "$g_presentation_obj_16"),
  947.             (try_end),
  948.             (try_begin),
  949.                 (neq, ":check_item_for_req_slot", -1),
  950.                 (troop_get_inventory_slot, ":item_in_question", "trp_player", ":check_item_for_req_slot"),
  951.                 (troop_get_inventory_slot_modifier, ":imod", "trp_player", ":check_item_for_req_slot"),
  952.                 (item_get_difficulty, ":item_diff", ":item_in_question"),
  953.                 (try_begin),
  954.                     (eq, ":imod", imod_masterwork), (val_add, ":item_diff", 4),
  955.                 (else_try),
  956.                     (neg|item_slot_eq, ":item_in_question", slot_item_type, itp_type_horse),
  957.                     (eq, ":imod", imod_heavy), (val_add, ":item_diff", 1),
  958.                 (else_try),
  959.                     (eq, ":imod", imod_strong), (val_add, ":item_diff", 2),
  960.                 (else_try),
  961.                     (eq, ":imod", imod_stubborn), (val_add, ":item_diff", 1),
  962.                 (else_try),
  963.                     (eq, ":imod", imod_timid), (val_add, ":item_diff", -1), (val_max, reg60, 0),
  964.                 # (else_try),
  965.                     # (eq, ":imod", imod_spirited), (val_add, ":item_diff", 1),
  966.                 (else_try),
  967.                     (eq, ":imod", imod_champion), (val_add, ":item_diff", 2),
  968.                 (try_end),
  969.                 (try_begin),
  970.                     (item_slot_eq, ":item_in_question", slot_item_type, itp_type_bow),
  971.                     (store_skill_level, ":skill_level", skl_power_draw, "trp_player"),
  972.                     (lt, ":skill_level", ":item_diff"),
  973.                     (assign, ":transition_approved", 0),
  974.                 (else_try),
  975.                     (item_slot_eq, ":item_in_question", slot_item_type, itp_type_thrown),
  976.                     (store_skill_level, ":skill_level", skl_power_throw, "trp_player"),
  977.                     (lt, ":skill_level", ":item_diff"),
  978.                     (assign, ":transition_approved", 0),
  979.                 (else_try),
  980.                     (item_slot_eq, ":item_in_question", slot_item_type, itp_type_horse),
  981.                     (store_skill_level, ":skill_level", skl_riding, "trp_player"),
  982.                     (lt, ":skill_level", ":item_diff"),
  983.                     (assign, ":transition_approved", 0),
  984.                 (else_try),
  985.                     (item_slot_eq, ":item_in_question", slot_item_type, itp_type_shield),
  986.                     (store_skill_level, ":skill_level", skl_shield, "trp_player"),
  987.                     (lt, ":skill_level", ":item_diff"),
  988.                     (assign, ":transition_approved", 0),
  989.                 (else_try),
  990.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_one_handed_wpn),
  991.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_two_handed_wpn),
  992.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_polearm),
  993.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_crossbow),
  994.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_head_armor),
  995.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_body_armor),
  996.                     (this_or_next|item_slot_eq, ":item_in_question", slot_item_type, itp_type_foot_armor),
  997.                     (item_slot_eq, ":item_in_question", slot_item_type, itp_type_hand_armor),
  998.                     (store_attribute_level, ":skill_level", "trp_player", ca_strength),
  999.                     (lt, ":skill_level", ":item_diff"),
  1000.                     (assign, ":transition_approved", 0),
  1001.                 (try_end),
  1002.             (try_end),
  1003.             (eq, ":transition_approved", 1),
  1004.             (troop_get_inventory_slot_modifier, ":first_item_imod", "trp_player", "$g_presentation_obj_16"),
  1005.             (try_begin),
  1006.                 (is_between, ":first_item", food_begin, food_end), (troop_inventory_slot_get_item_amount, ":first_item_quantity", "trp_player", "$g_presentation_obj_16"),
  1007.             (try_end),
  1008.             (troop_get_inventory_slot_modifier, ":second_item_imod", "trp_player", ":inv_slot"),
  1009.             (try_begin),
  1010.                 (is_between, ":item_no", food_begin, food_end), (troop_inventory_slot_get_item_amount, ":second_item_quantity", "trp_player", ":inv_slot"),
  1011.             (try_end),
  1012.             (troop_set_inventory_slot, "trp_player", ":inv_slot", ":first_item"),
  1013.             (troop_set_inventory_slot_modifier, "trp_player", ":inv_slot", ":first_item_imod"),
  1014.             (try_begin),
  1015.                 (is_between, ":first_item", food_begin, food_end), (troop_inventory_slot_set_item_amount, "trp_player", ":inv_slot", ":first_item_quantity"),
  1016.             (try_end),
  1017.             (troop_set_inventory_slot, "trp_player", "$g_presentation_obj_16", ":item_no"),
  1018.             (troop_set_inventory_slot_modifier, "trp_player", "$g_presentation_obj_16", ":second_item_imod"),
  1019.             (try_begin),
  1020.                 (is_between, ":item_no", food_begin, food_end), (troop_inventory_slot_set_item_amount, "trp_player", "$g_presentation_obj_16", ":second_item_quantity"),
  1021.             (try_end),
  1022.             (start_presentation, "prsnt_trade_screen_replacer"),
  1023.             # (overlay_get_position, pos0, "$g_presentation_obj_15"), (overlay_get_position, pos1, ":object"),
  1024.             # (overlay_set_position, "$g_presentation_obj_15", pos1), (overlay_set_position, ":object", pos0),
  1025.             # (overlay_set_color, "$g_presentation_obj_15", 0xFFFFFF),
  1026.             # (troop_set_slot, "trp_temp_array_c", "$g_presentation_obj_16", ":object"), (troop_set_slot, "trp_temp_array_c", ":inv_slot", "$g_presentation_obj_15"),
  1027.             # (assign, "$g_presentation_obj_15", -1),
  1028.             # (assign, "$g_presentation_obj_16", -1),
  1029.           (try_end),
  1030.          
  1031.          
  1032.       (try_end),
  1033.     ]),
  1034.     ]),
RAW Paste Data