from header_game_menus import *
from header_parties import *
from header_items import *
from header_mission_templates import *
from header_music import *
from header_terrain_types import *
from header_sounds import sf_2d

from module_constants import *
# "123456789012345678901234567890123456789012345678901234567890"
####################################################################################################################
#  (menu-id, menu-flags, menu_text, mesh-name, [<operations>], [<options>]),
#
#   Each game menu is a tuple that contains the following fields:
#
#  1) Game-menu id (string): used for referencing game-menus in other files.
#     The prefix menu_ is automatically added before each game-menu-id
#
#  2) Game-menu flags (int). See header_game_menus.py for a list of available flags.
#     You can also specify menu text color here, with the menu_text_color macro
#  3) Game-menu text (string).
#  4) mesh-name (string). Not currently used. Must be the string "none"
#  5) Operations block (list). A list of operations. See header_operations.py for reference.
#     The operations block is executed when the game menu is activated.
#  6) List of Menu options (List).
#     Each menu-option record is a tuple containing the following fields:
#   6.1) Menu-option-id (string) used for referencing game-menus in other files.
#        The prefix mno_ is automatically added before each menu-option.
#   6.2) Conditions block (list). This must be a valid operation block. See header_operations.py for reference.
#        The conditions are executed for each menu option to decide whether the option will be shown to the player or not.
#   6.3) Menu-option text (string).
#   6.4) Consequences block (list). This must be a valid operation block. See header_operations.py for reference.
#        The consequences are executed for the menu option that has been selected by the player.
#
#
# Note: The first Menu is the initial character creation menu.
# 'Nother Note: The first five menus are hard-wired.#moto chief note
####################################################################################################################

game_menus = [
  ("start_game_0",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Welcome to Viking Conquest.",
    "none",
    [
      (try_begin),
        (assign, reg0, 0),
        (get_operation_set_version, reg0),
        (ge, reg0, warband_version),
        (assign, "$campaign_type", camp_storyline),
        (assign, "$difficulty_type", camp_d1),
        (assign, reg60, 1),
        (start_presentation, "prsnt_vc_options"),
      (else_try),
        (change_screen_quit),
      (try_end),
    ],
    [
      ##     ("continue",[],"Continue...",
      ##       [(jump_to_menu, "mnu_start_game_1"),
      ##        ]
      ##       ),
      ##      ("go_back",[],"Go back",
      ##       [
      ##         (change_screen_quit),
      ##       ]),
    ]
  ),
  
  #scene chief intro1 empieza barco
  (
    "start_phase_2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "{!}{s1}",
    "none",
    [
      
      (str_clear, s1),
      (assign, ":continue", 1),
      (assign, ":radius", 70),
      
      (call_script,"script_check_if_playername_is_correct"),
      (try_begin),
        (eq, "$campaign_type", camp_sandbox),
        (try_begin),
          (eq, "$nacionalidad_type", cb7_anglesaxon),
          (party_get_position, pos0, "p_castle_20"),  #Grantebrycge
          (assign, ":radius", 93),
        (else_try),
          (eq, "$nacionalidad_type", cb7_norseman),
          (store_random_in_range, reg0, 0, 2),
          (try_begin),
            (eq, reg0, 0),
            (party_get_position, pos0, "p_castle_49"),  #Skyfa
            (assign, ":radius", 20),	# to quickly fix reopened VC-1211
          (else_try),
            (party_get_position, pos0, "p_village_53"),  #Skiringssalr By
          (try_end),
        (else_try),
          (eq, "$nacionalidad_type", cb7_frisian),
          (party_get_position, pos0, "p_town_11"),  #Dorestad
          (assign, ":radius", 20),
        (else_try),
          (eq, "$nacionalidad_type", cb7_irish),
          (party_get_position, pos0, "p_castle_73"),  #Ath Mor
          (assign, ":radius", 100),
        (else_try),
          (eq, "$nacionalidad_type", cb7_briton),
          (party_get_position, pos0, "p_castle_44"),  #Din Erth
        (else_try),
          (eq, "$nacionalidad_type", cb7_scotopict),
          (party_get_position, pos0, "p_monasterio6"),  #Petrus
        (else_try),
          (eq, "$nacionalidad_type", cb7_foreigner),
          (party_get_position, pos0, "p_castle_30"),  #Din Tagell
          (assign, ":radius", 50),
        (try_end),
        
        (call_script, "script_recurse_party_around_pos0", "p_main_party", ":radius", 0),
        (change_screen_map),
        (assign, ":continue", 0),
      (else_try),
        (eq, "$campaign_type", camp_storyline),
        (play_sound, "snd_ship_static_loop", sf_2d),
        (str_store_string, s1, "@You can't sleep. You can hear the constant crunch of the boat hull, smell sea brine, and feel the breeze caressing your face, but your eyes are closed and refuse to open. And your mind keeps dreaming, remembering other times, a past life that feels far away and that you remember less every day, even though not many months have passed since your departure.^^" +
          "Now, the future is uncertain. Your journey has brought you to the Frisian Sea hoping to find news about an old sorcerer who takes care of all ills, because your mother is sick. For her you left everything behind, a world you knew like the back of your hand, and paid for passage on a north boat, a paunchy merchantman. It's slow and clumsy, but its captain has promised to take you to the remote part of Friese where the sorcerer lives.^^" +
          "Your mother travels with you; nobody else has joined you. Her illness progresses, and there are days when she no longer recognizes you, but she appears to be completely sound at other times. Every morning you wake up not knowing which day it will be: will you be able to converse with her or will you have to tie her to a post so she does not fall overboard?^^" +
          "You need to wake up, though your eyes oppose you and your mind boils with fever...^^" +
        "One more effort. Your eyelids obey..."),
        
        #party already placed
      (else_try),
        (change_screen_map),
        (assign, ":continue", 0),
      (try_end),
      
      (set_background_mesh, "mesh_pic_extra_barco"),
      
      
      ##      (try_begin),
      ##        (eq, "$current_startup_mainquest_phase", 1),
      ##        (jump_to_menu, "mnu_start_phase_22"),
      ##        (assign, ":continue", 0),
      ##      (try_end),
      (eq, ":continue", 1),
      
    ],
    [
      
      ("continue_i",[],"Continue...",
        [
          (modify_visitors_at_site,"scn_mainquest_1ship"),
          (reset_visitors, 0),
          
          # (try_for_range, ":visiterator", 22, 27),	#Phaiak	(Sorry, have to reduce entry points because there are to much...)
          # (set_visitor, ":visiterator", "trp_sailors",),
          # (try_end),
          
          # Making mother look like player
          (str_store_troop_face_keys, s1, "trp_player"),
          (str_store_troop_face_keys, s2, "trp_your_tutorialwife"),
          (face_keys_get_hair_color, ":hair_color", s1),
          (face_keys_set_hair_color, s2, ":hair_color"),
          (try_for_range, ":key_no", 0, 8),
            (face_keys_get_morph_key, ":morph_key", s1, ":key_no"),
            (face_keys_set_morph_key, s2, ":key_no", ":morph_key"),
          (end_try),
          (troop_set_face_keys, "trp_your_tutorialwife", s2),
          
          
          #(set_visitor, 32,"trp_sailors"),
          (set_visitor, 31,"trp_sailors"),
          (set_visitor, 29,"trp_sailors"),
          (set_visitor, 26,"trp_sailors"),
          #(set_visitor, 23,"trp_sailors"),
          
          (set_visitor,0,"trp_player"),
          
          (set_visitor,33,"trp_trainer_1"),
          
          (set_visitor,1,"trp_frisianship_merchant"),
          
          (set_visitor,10,"trp_mercenary_arqueros"),
          (set_visitor,11,"trp_mercenary_arqueros"),
          
          (set_visitor,35,"trp_bodo_falso"), #futuro companero viaja en el barco.
          
          ##      (try_begin),
          ##         (eq,"$character_gender",tf_male),
          (set_visitor,2,"trp_your_tutorialwife"),
          ##	  (else_try),
          ##         (eq,"$character_gender",tf_female),
          ##        (set_visitor,3,"trp_your_tutorialhusband"),
          ##      (try_end),
          (assign, "$mainquest_barco", 1), #hace viable trainer en barco para esta quest
          #cero para empezar chief
          (assign, "$hablo_bodo", 0),
          (assign, "$first_encuentro", 0),
          (assign, "$mainquestbarco_5_state", 0),
          
          ##        (set_visitor,60,"trp_tutorial_master_horseman"),
          ##        (set_visitor,61,"trp_tutorial_rider_1"),
          ##        (set_visitor,62,"trp_tutorial_rider_1"),
          ##        (set_visitor,63,"trp_tutorial_rider_2"),
          ##        (set_visitor,64,"trp_tutorial_rider_2"),
          
          (set_jump_mission,"mt_mainquest_1mt"),
          (jump_to_scene,"scn_mainquest_1ship"),
          (change_screen_mission),
      ]),
      
      
      ("continue_cheat",[(eq, "$cheat_mode", 1)],"Bypass the tutorial.",
        [
          (modify_visitors_at_site,"scn_mainquest_1ship"),
          (reset_visitors, 0),
          
          # (try_for_range, ":visiterator", 22, 27),	#Phaiak	(Sorry, have to reduce entry points because there are to much...)
          # (set_visitor, ":visiterator", "trp_sailors",),
          # (try_end),
          #(set_visitor, 32,"trp_sailors"),
          (set_visitor, 31,"trp_sailors"),
          (set_visitor, 29,"trp_sailors"),
          (set_visitor, 26,"trp_sailors"),
          #(set_visitor, 23,"trp_sailors"),
          
          (set_visitor,0,"trp_player"),
          
          (set_visitor,33,"trp_trainer_1"),
          
          (set_visitor,1,"trp_frisianship_merchant"),
          
          (set_visitor,10,"trp_mercenary_arqueros"),
          (set_visitor,11,"trp_mercenary_arqueros"),
          
          (set_visitor,35,"trp_bodo_falso"), #futuro companero viaja en el barco.
          
          # (try_begin),
          # (eq,"$character_gender",tf_male),
          (set_visitor,2,"trp_your_tutorialwife"),
          # (else_try),
          # (eq,"$character_gender",tf_female),
          # (set_visitor,3,"trp_your_tutorialhusband"),
          # (try_end),
          (assign, "$mainquest_barco", 1), #hace viable trainer en barco para esta quest
          #cero para empezar chief
          (assign, "$hablo_bodo", 0),
          # (assign, "$first_encuentro", 2),
          (assign, "$first_encuentro", 5),	#Phaiak
          (assign, "$mainquestbarco_5_state", 0),
          
          (set_jump_mission,"mt_mainquest_1mt"),
          (jump_to_scene,"scn_mainquest_1ship"),
          (change_screen_mission),
      ]),
      
      ("go_back_dot",
        [],
        "Go back.",
        [
          (change_screen_quit),
      ]),
    ]
  ),
  
  (
    "start_game_3",mnf_disable_all_keys,
    "Choose your scenario:",
    "none",
    [
      (assign, "$g_custom_battle_scenario", 0),
      (assign, "$g_custom_battle_scenario", "$g_custom_battle_scenario"),
      ##      #Default banners
      ##      (troop_set_slot, "trp_banner_background_color_array", 126, 0xFF212221),
      ##      (troop_set_slot, "trp_banner_background_color_array", 127, 0xFF212221),
      ##      (troop_set_slot, "trp_banner_background_color_array", 128, 0xFF2E3B10),
      ##      (troop_set_slot, "trp_banner_background_color_array", 129, 0xFF425D7B),
      ##      (troop_set_slot, "trp_banner_background_color_array", 130, 0xFF394608),
    ],
    [
      ##      ("custom_battle_scenario_1",[], "Skirmish 1",
      ##       [
      ##           (assign, "$g_custom_battle_scenario", 0),
      ##           (jump_to_menu, "mnu_custom_battle_2"),
      ##
      ##        ]
      ##       ),
      ####      ("custom_battle_scenario_2",[],"Siege Attack 1",
      ####       [
      ####           (assign, "$g_custom_battle_scenario", 1),
      ####           (jump_to_menu, "mnu_custom_battle_2"),
      ####
      ####        ]
      ####       ),
      ##      ("custom_battle_scenario_3",[],"Skirmish 2",
      ##       [
      ##           (assign, "$g_custom_battle_scenario", 1),
      ##           (jump_to_menu, "mnu_custom_battle_2"),
      ##
      ##        ]
      ##       ),
      ##       ("custom_battle_scenario_4",[],"Siege Defense",
      ##       [
      ##           (assign, "$g_custom_battle_scenario", 2),
      ##           (jump_to_menu, "mnu_custom_battle_2"),
      ##        ]
      ##       ),
      ##       ("custom_battle_scenario_5",[],"Skirmish 3",
      ##       [
      ##           (assign, "$g_custom_battle_scenario", 3),
      ##           (jump_to_menu, "mnu_custom_battle_2"),
      ##        ]
      ##       ),
      ##      ("custom_battle_scenario_6",[],"Siege Attack",
      ##       [
      ##           (assign, "$g_custom_battle_scenario", 4),
      ##           (jump_to_menu, "mnu_custom_battle_2"),
      ##
      ##        ]
      ##       ),
      ("go_back",[],"Go back",
        [(change_screen_quit),
        ]
      ),
    ]
  ),
  
  ##  ("start_game_3",mnf_disable_all_keys,
  ##    "Choose your scenario:",
  ##    "none",
  ##    [
  ##      (assign, "$g_custom_battle_scenario", 0),
  ##      (assign, "$g_custom_battle_scenario", "$g_custom_battle_scenario"),
  ####      #Default banners
  ####      (troop_set_slot, "trp_banner_background_color_array", 126, 0xFF212221),
  ####      (troop_set_slot, "trp_banner_background_color_array", 127, 0xFF212221),
  ####      (troop_set_slot, "trp_banner_background_color_array", 128, 0xFF2E3B10),
  ####      (troop_set_slot, "trp_banner_background_color_array", 129, 0xFF425D7B),
  ####      (troop_set_slot, "trp_banner_background_color_array", 130, 0xFF394608),
  ##      ],
  ##    [
  ####      ("custom_battle_scenario_1",[], "Skirmish 1",
  ####       [
  ####           (assign, "$g_custom_battle_scenario", 0),
  ####           (jump_to_menu, "mnu_custom_battle_2"),
  ####
  ####        ]
  ####       ),
  ######      ("custom_battle_scenario_2",[],"Siege Attack 1",
  ######       [
  ######           (assign, "$g_custom_battle_scenario", 1),
  ######           (jump_to_menu, "mnu_custom_battle_2"),
  ######
  ######        ]
  ######       ),
  ####      ("custom_battle_scenario_3",[],"Skirmish 2",
  ####       [
  ####           (assign, "$g_custom_battle_scenario", 1),
  ####           (jump_to_menu, "mnu_custom_battle_2"),
  ####
  ####        ]
  ####       ),
  ####       ("custom_battle_scenario_4",[],"Siege Defense",
  ####       [
  ####           (assign, "$g_custom_battle_scenario", 2),
  ####           (jump_to_menu, "mnu_custom_battle_2"),
  ####        ]
  ####       ),
  ####       ("custom_battle_scenario_5",[],"Skirmish 3",
  ####       [
  ####           (assign, "$g_custom_battle_scenario", 3),
  ####           (jump_to_menu, "mnu_custom_battle_2"),
  ####        ]
  ####       ),
  ####      ("custom_battle_scenario_6",[],"Siege Attack",
  ####       [
  ####           (assign, "$g_custom_battle_scenario", 4),
  ####           (jump_to_menu, "mnu_custom_battle_2"),
  ####
  ####        ]
  ####       ),
  ##      ("go_back",[],"Go back",
  ##       [(change_screen_quit),
  ##        ]
  ##       ),
  ##    ]
  ##  ),
  
  (
    "tutorial",mnf_disable_all_keys,
    "You approach a field where the locals are practicing with weapons. You can practice here to improve your combat skills.",
    "none",
    [
      (try_begin),
        (eq, "$g_tutorial_entered", 1),
        (change_screen_quit),
      (else_try),
        (set_passage_menu, "mnu_tutorial"),
        ##        (try_begin),
        ##          (eq, "$tutorial_1_finished", 1),
        ##          (str_store_string, s1, "str_finished"),
        ##        (else_try),
        ##          (str_store_string, s1, "str_empty_string"),
        ##        (try_end),
        ##        (try_begin),
        ##          (eq, "$tutorial_2_finished", 1),
        ##          (str_store_string, s2, "str_finished"),
        ##        (else_try),
        ##          (str_store_string, s2, "str_empty_string"),
        ##        (try_end),
        ##        (try_begin),
        ##          (eq, "$tutorial_3_finished", 1),
        ##          (str_store_string, s3, "str_finished"),
        ##        (else_try),
        ##          (str_store_string, s3, "str_empty_string"),
        ##        (try_end),
        ##        (try_begin),
        ##          (eq, "$tutorial_4_finished", 1),
        ##          (str_store_string, s4, "str_finished"),
        ##        (else_try),
        ##          (str_store_string, s4, "str_empty_string"),
        ##        (try_end),
        ##        (try_begin),
        ##          (eq, "$tutorial_5_finished", 1),
        ##          (str_store_string, s5, "str_finished"),
        ##        (else_try),
        ##          (str_store_string, s5, "str_empty_string"),
        ##        (try_end),
        (assign, "$g_tutorial_entered", 1),
      (try_end),
    ],
    [
      ##      ("tutorial_1",
      ##      [(eq,1,0),],
      ##      "Tutorial #1: Basic movement and weapon selection. {s1}",
      ##      [
      ##        #(modify_visitors_at_site,"scn_tutorial_1"),(reset_visitors,0),
      ####           (set_jump_mission,"mt_tutorial_1"),
      ####           (jump_to_scene,"scn_tutorial_1"),(change_screen_mission)]),
      ##      ]),
      ##
      ##      ("tutorial_2",[(eq,1,0),],"Tutorial #2: Fighting with a shield. {s2}",[
      ####           (modify_visitors_at_site,"scn_tutorial_2"),(reset_visitors,0),
      ####           (set_visitor,1,"trp_tutorial_maceman"),
      ####           (set_visitor,2,"trp_tutorial_archer"),
      ####           (set_jump_mission,"mt_tutorial_2"),
      ####           (jump_to_scene,"scn_tutorial_2"),(change_screen_mission)]),
      ##           (modify_visitors_at_site,"scn_tutorial_training_ground"),
      ##           (reset_visitors, 0),
      ##           (set_player_troop, "trp_player"),
      ##           (set_visitor,0,"trp_player"),
      ##           (set_jump_mission,"mt_ai_training"),
      ##           (jump_to_scene,"scn_tutorial_training_ground"),
      ##           (change_screen_mission)]),
      ##
      ##      ("tutorial_3",[(eq,1,0),],"Tutorial #3: Fighting without a shield. {s3}",[
      ##           (modify_visitors_at_site,"scn_tutorial_3"),(reset_visitors,0),
      ##           (set_visitor,1,"trp_tutorial_maceman"),
      ##           (set_visitor,2,"trp_tutorial_swordsman"),
      ##           (set_jump_mission,"mt_tutorial_3"),
      ##           (jump_to_scene,"scn_tutorial_3"),(change_screen_mission)]),
      ##      ("tutorial_3b",[(eq,0,1)],"Tutorial 3 b",[(try_begin),
      ##                                                  (ge, "$tutorial_3_state", 12),
      ##                                                  (modify_visitors_at_site,"scn_tutorial_3"),(reset_visitors,0),
      ##                                                  (set_visitor,1,"trp_tutorial_maceman"),
      ##                                                  (set_visitor,2,"trp_tutorial_swordsman"),
      ##                                                  (set_jump_mission,"mt_tutorial_3_2"),
      ##                                                  (jump_to_scene,"scn_tutorial_3"),
      ##                                                  (change_screen_mission),
      ##                                                (else_try),
      ##                                                  (display_message,"str_door_locked",0xFFFFAAAA),
      ##                                                (try_end)], "Next level"),
      ##      ("tutorial_4",[(eq,1,0),],"Tutorial #4: Riding a horse. {s4}",[
      ##           (modify_visitors_at_site,"scn_tutorial_training_ground"),
      ##           (reset_visitors, 0),
      ##           (set_player_troop, "trp_player"),
      ##           (assign, "$g_player_troop", "trp_player"),
      ##           (troop_raise_attribute, "$g_player_troop", ca_strength, 12),
      ##           (troop_raise_attribute, "$g_player_troop", ca_agility, 9),
      ##           (troop_raise_attribute, "$g_player_troop", ca_charisma, 5),
      ##           (troop_raise_skill, "$g_player_troop", skl_shield, 3),
      ##           (troop_raise_skill, "$g_player_troop", skl_athletics, 2),
      ##           (troop_raise_skill, "$g_player_troop", skl_riding, 3),
      ##           (troop_raise_skill, "$g_player_troop", skl_power_strike, 1),
      ##           (troop_raise_skill, "$g_player_troop", skl_power_draw, 5),
      ##           (troop_raise_skill, "$g_player_troop", skl_weapon_master, 4),
      ##           (troop_raise_skill, "$g_player_troop", skl_ironflesh, 1),
      ##           (troop_raise_skill, "$g_player_troop", skl_horse_archery, 6),
      ##           (troop_raise_proficiency_linear, "$g_player_troop", wpt_one_handed_weapon, 70),
      ##           (troop_raise_proficiency_linear, "$g_player_troop", wpt_two_handed_weapon, 70),
      ##           (troop_raise_proficiency_linear, "$g_player_troop", wpt_polearm, 70),
      ##           (troop_raise_proficiency_linear, "$g_player_troop", wpt_crossbow, 70),
      ##           (troop_raise_proficiency_linear, "$g_player_troop", wpt_throwing, 70),
      ##
      ##        (troop_clear_inventory, "$g_player_troop"),
      ##        (troop_add_item, "$g_player_troop","itm_bl_tunic01",0),
      ##        (troop_add_item, "$g_player_troop","itm_leather_boots",0),
      ##        (troop_add_item, "$g_player_troop","itm_practice_sword",0),
      ##        (troop_add_item, "$g_player_troop","itm_quarter_staff",0),
      ##        (troop_equip_items, "$g_player_troop"),
      ##        (set_visitor,0,"trp_player"),
      ##        (set_visitor,32,"trp_tutorial_fighter_1"),
      ##        (set_visitor,33,"trp_tutorial_fighter_2"),
      ##        (set_visitor,34,"trp_tutorial_fighter_3"),
      ##        (set_visitor,35,"trp_tutorial_fighter_4"),
      ##        (set_visitor,40,"trp_tutorial_master_archer"),
      ##        (set_visitor,41,"trp_tutorial_archer_1"),
      ##        (set_visitor,42,"trp_tutorial_archer_1"),
      ##        (set_visitor,60,"trp_tutorial_master_horseman"),
      ##        (set_visitor,61,"trp_tutorial_rider_1"),
      ##        (set_visitor,62,"trp_tutorial_rider_1"),
      ##        (set_visitor,63,"trp_tutorial_rider_2"),
      ##        (set_visitor,64,"trp_tutorial_rider_2"),
      ##        (set_jump_mission,"mt_tutorial_training_ground"),
      ##        (jump_to_scene,"scn_tutorial_training_ground"),
      ##        (change_screen_mission),
      ##      ]),
      ##
      ##      ("tutorial_5",
      ##      [
      ##        (eq,1,0),
      ##      ],
      ##      "Tutorial #5: Commanding a band of soldiers. {s5}",
      ##      [
      ##        (modify_visitors_at_site,"scn_tutorial_5"),(reset_visitors,0),
      ##        (set_visitor,0,"trp_player"),
      ##        (set_visitor,1,"trp_saxon_level1_landed"),
      ##        (set_visitor,2,"trp_saxon_level1_landed"),
      ##        (set_visitor,3,"trp_saxon_level1_landed"),
      ##        (set_visitor,4,"trp_saxon_level1_landed"),
      ##        (set_jump_mission,"mt_tutorial_5"),
      ##        (jump_to_scene,"scn_tutorial_5"),
      ##        (change_screen_mission),
      ##      ]),
      ##
      ##      ("tutorial_edit_custom_battle_scenes",
      ##      [(eq,1,0),],
      ##      "(NO TRANSLATE) tutorial_edit_custom_battle_scenes",
      ##      [
      ##        (jump_to_menu,"mnu_custom_battle_scene"),
      ##      ]),
      
      ("continue",[],"Continue...",
        [
          (modify_visitors_at_site,"scn_tutorial_training_ground"),
          # (modify_visitors_at_site,"scn_village_150"), #chief quita previa y pone doccinga
          (reset_visitors, 0),
          (set_player_troop, "trp_player"),
          (assign, "$g_player_troop", "trp_player"),
          (troop_raise_attribute, "$g_player_troop", ca_strength, 12),
          (troop_raise_attribute, "$g_player_troop", ca_agility, 9),
          (troop_raise_attribute, "$g_player_troop", ca_charisma, 5),
          (troop_raise_skill, "$g_player_troop", skl_shield, 3),
          (troop_raise_skill, "$g_player_troop", skl_athletics, 2),
          (troop_raise_skill, "$g_player_troop", skl_riding, 3),
          (troop_raise_skill, "$g_player_troop", skl_power_strike, 1),
          (troop_raise_skill, "$g_player_troop", skl_power_draw, 5),
          (troop_raise_skill, "$g_player_troop", skl_weapon_master, 4),
          (troop_raise_skill, "$g_player_troop", skl_ironflesh, 1),
          (troop_raise_skill, "$g_player_troop", skl_horse_archery, 6),
          (troop_raise_proficiency_linear, "$g_player_troop", wpt_one_handed_weapon, 70),
          (troop_raise_proficiency_linear, "$g_player_troop", wpt_two_handed_weapon, 70),
          (troop_raise_proficiency_linear, "$g_player_troop", wpt_polearm, 70),
          (troop_raise_proficiency_linear, "$g_player_troop", wpt_crossbow, 70),
          (troop_raise_proficiency_linear, "$g_player_troop", wpt_throwing, 70),
          
          (troop_clear_inventory, "$g_player_troop"),
          (troop_add_item, "$g_player_troop","itm_bl_tunic01",0),
          (troop_add_item, "$g_player_troop","itm_carbatinae_1v",0),
          (troop_add_item, "$g_player_troop","itm_practice_sword",0),
          (troop_add_item, "$g_player_troop","itm_quarter_staff",0),
          (troop_equip_items, "$g_player_troop"),
          (set_visitor,0,"trp_player"),
          (set_visitor,32,"trp_tutorial_fighter_1"),
          (set_visitor,33,"trp_tutorial_fighter_2"),
          (set_visitor,34,"trp_tutorial_fighter_3"),
          (set_visitor,35,"trp_tutorial_fighter_4"),
          (set_visitor,40,"trp_tutorial_master_archer"),
          (set_visitor,41,"trp_tutorial_archer_1"),
          (set_visitor,42,"trp_tutorial_archer_1"),
          (set_visitor,60,"trp_tutorial_master_horseman"),
          (set_visitor,61,"trp_tutorial_rider_1"),
          (set_visitor,62,"trp_tutorial_rider_1"),
          (set_visitor,63,"trp_tutorial_rider_2"),
          (set_visitor,64,"trp_tutorial_rider_2"),
          (set_jump_mission,"mt_tutorial_training_ground"),
          (jump_to_scene,"scn_tutorial_training_ground"),
          #(set_jump_mission,"mt_village_doccinga"),
          #(jump_to_scene,"scn_village_150"), #chief quita previa y pone doccinga
          (change_screen_mission),
      ]),
      
      ("go_back_dot",
        [],
        "Go back.",
        [
          (change_screen_quit),
      ]),
    ]
  ),
  
  ("reports",0,
    "Character Renown: {reg5}^Honor Rating: {reg6}^Party Morale: {reg8}^Party Size Limit: {reg7}^",
    "none",
    [
      
      (try_begin),
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),	#only allowed on land
        (change_screen_return),
      (else_try),
        (neg|party_is_active, "p_troop_camp_1"),
        (enable_party, "p_troop_camp_1"),
        (party_relocate_near_party, "p_troop_camp_1", "p_main_party", 1),
        (assign, "$auto_enter_town", "p_troop_camp_1"),
        (presentation_set_duration, 0),
        (change_screen_return),
      (else_try),
        (neg|party_is_active, "p_troop_camp_2"),
        (enable_party, "p_troop_camp_2"),
        (party_relocate_near_party, "p_troop_camp_2", "p_main_party", 1),
        (assign, "$auto_enter_town", "p_troop_camp_2"),
        (presentation_set_duration, 0),
        (change_screen_return),
      (else_try),
        (display_message, "@You can't have more than two active troop quarters."),
        (change_screen_return),
      (end_try),
      
      ##   (try_begin),
      ##      (eq,"$temp",3),
      ##      (assign,"$temp",0),
      ##      (change_screen_return),
      ##    (else_try),
      ##      (str_clear,s1),
      ##      (str_clear,s2),
      ##      (str_clear,s3),
      ##      (str_clear,s4),
      ##      (str_clear,s5),
      ##      (str_clear,s6),
      ##      (str_clear,s7),
      ##      (str_clear,s8),
      ##      (str_clear,s9),
      ##      (str_clear,s10),
      ##      (str_clear,s11),
      ##      (str_clear,s12),
      ##      (str_clear,s13),
      ##      (str_clear,s14),
      ##      (str_clear,s15),
      ##      (str_clear,s16),
      ##      (str_clear,s17),
      ##      (str_clear,s18),
      ##         (start_presentation, "prsnt_character_screen_main"),
      ##      (try_end),
      
      ##    (call_script, "script_game_get_party_companion_limit"),
      ##    (assign, ":party_size_limit", reg0),
      ##    (troop_get_slot, ":renown", "trp_player", slot_troop_renown),
      ##    (assign, reg5, ":renown"),
      ##    (assign, reg6, "$player_honor"),
      ##    (assign, reg7, ":party_size_limit"),
      ##    #(call_script, "script_get_player_party_morale_values"),
      ##    #(party_set_morale, "p_main_party", reg0),
      ##    (party_get_morale, reg8, "p_main_party"),
    ],
    [
      ##      ("cheat_faction_orders",[(ge,"$cheat_mode",1)],"{!}Cheat: Faction orders.",
      ##       [(jump_to_menu, "mnu_faction_orders"),
      ##        ]
      ##       ),
      ##
      ##      ("view_character_report",[],"View character report.",
      ##       [(jump_to_menu, "mnu_character_report"),
      ##        ]
      ##       ),
      ##      ("view_party_size_report",[],"View party size report.",
      ##       [(jump_to_menu, "mnu_party_size_report"),
      ##        ]
      ##       ),
      ##
      ##      ("view_npc_mission_report",[],"View companion mission report.",
      ##       [(jump_to_menu, "mnu_companion_report"),
      ##        ]
      ##       ),
      ##
      ##      ("view_weekly_budget_report",[],"View weekly budget report.",
      ##       [
      ##         (assign, "$g_apply_budget_report_to_gold", 0),
      ##         (start_presentation, "prsnt_budget_report"),
      ##        ]
      ##       ),
      ##
      ##      ("view_weekly_budget_report",[],"Character sheet test.", #
      ##       [
      ##      (str_clear,s1),
      ##      (str_clear,s2),
      ##      (str_clear,s3),
      ##      (str_clear,s4),
      ##      (str_clear,s5),
      ##      (str_clear,s6),
      ##      (str_clear,s7),
      ##      (str_clear,s8),
      ##      (str_clear,s9),
      ##      (str_clear,s10),
      ##      (str_clear,s11),
      ##      (str_clear,s12),
      ##      (str_clear,s13),
      ##      (str_clear,s14),
      ##      (str_clear,s15),
      ##      (str_clear,s16),
      ##      (str_clear,s17),
      ##      (str_clear,s18),
      ##         (start_presentation, "prsnt_character_screen_main"),
      ##        ]
      ##       ),
      ##
      ##      ("view_morale_report",[],"View party morale report.",
      ##       [(jump_to_menu, "mnu_morale_report"),
      ##        ]
      ##       ),
      ##
      ###NPC companion changes begin
      ##      ("lord_relations",[],"View list of known lords by relation.",
      ##       [
      ##		(jump_to_menu, "mnu_lord_relations"),
      ##        ]
      ##       ),
      ##
      ##      ("courtship_relations",[],"View courtship relations.",
      ##       [
      ##		(jump_to_menu, "mnu_courtship_relations"),
      ##        ]
      ##       ),
      ##
      ##      ("status_check",[(eq,"$cheat_mode",1)],"{!}NPC status check.",
      ##       [
      ##        (try_for_range, ":npc", companions_begin, companions_end),
      ##            (main_party_has_troop, ":npc"),
      ##            (str_store_troop_name, 4, ":npc"),
      ##            (troop_get_slot, reg3, ":npc", slot_troop_morality_state),
      ##            (troop_get_slot, reg4, ":npc", slot_troop_2ary_morality_state),
      ##            (troop_get_slot, reg5, ":npc", slot_troop_personalityclash_state),
      ##            (troop_get_slot, reg6, ":npc", slot_troop_personalityclash2_state),
      ##            (troop_get_slot, reg7, ":npc", slot_troop_personalitymatch_state),
      ##            (display_message, "@{!}{s4}: M{reg3}, 2M{reg4}, PC{reg5}, 2PC{reg6}, PM{reg7}"),
      ##        (try_end),
      ##        ]
      ##       ),
      ##
      ###NPC companion changes end
      ##
      ##      ("view_faction_relations_report",[],"View faction relations report.",
      ##       [(jump_to_menu, "mnu_faction_relations_report"),
      ##        ]
      ##       ),
      ("resume_travelling",[],"Resume travelling.",
        [(change_screen_return),
        ]
      ),
    ]
  ),
  
  ## Menus before this point are hard-wired ##
  
  #regreso al barco tras tutorial
  (
    "start_phase_2x",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Back",
    "none",
    [
      (modify_visitors_at_site,"scn_mainquest_1ship"),
      (reset_visitors, 0),
      
      # (try_for_range, ":visiterator", 22, 27),
      # (set_visitor, ":visiterator", "trp_sailors",),
      # (try_end),
      #(set_visitor, 32,"trp_sailors"),
      (set_visitor, 31,"trp_sailors"),
      (set_visitor, 29,"trp_sailors"),
      (set_visitor, 26,"trp_sailors"),
      #(set_visitor, 23,"trp_sailors"),
      
      (set_visitor,0,"trp_player"),
      
      (set_visitor,33,"trp_trainer_1"),
      
      (set_visitor,1,"trp_frisianship_merchant"),
      
      (set_visitor,10,"trp_mercenary_arqueros"),
      (set_visitor,11,"trp_mercenary_arqueros"),
      
      (set_visitor,35,"trp_bodo_falso"), #futuro companero viaja en el barco.
      
      # (try_begin),
      # (eq,"$character_gender",tf_male),
      (set_visitor,2,"trp_your_tutorialwife"),
      # (else_try),
      # (eq,"$character_gender",tf_female),
      # (set_visitor,3,"trp_your_tutorialhusband"),
      # (try_end),
      (assign, "$mainquest_barco", 1), #hace viable trainer en barco para esta quest
      
      
      (set_jump_mission,"mt_mainquest_1mt"),
      (jump_to_scene,"scn_mainquest_1ship"),
      (change_screen_mission),
      
    ],
    [
      ("go_back_dot",
        [],
        "Go back.",
        [
          (change_screen_quit),
      ]),
    ]
  ),
  
  ##########scene barco chief intro1 end
  
  ("start_phase_22",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "{!}{s1}",
    "none",
    [
      (str_clear, s1),
      (str_store_string, s1, "@The night falls while the ship, the Woden Ric, crosses the ocean. There is a good wind and the Woden Ric enjoys good sailing away from the site of the battle where it stopped in the morning. The Frisian coast is near by the time you fall asleep.^" +
        "The ship sails during the night while the shift rotates at the rudder. If all goes well, landfall will occur the next day, and you'll be a little closer to your destination.^" +
        "If all goes well... if only your nights were not filled with nightmares of ships consumed by fire and drowned men floating on bloody water. You are trapped in this way, costing you escape even to the world of dreams, when a hand shakes you, and a voice calls loudly near your ear.^" +
      "You open your eyes and see the taciturn face of the captain illuminated by the light of dawn.  You see his lips moving frantically and gradually begin to understand his words...^^"),
      (assign, "$mainquest_barco", 0), #hace inviable trainer en barco para que los trainers trabajen normalmente en el juego
      #todo cero de nuevo chief
      (assign, "$hablo_bodo", 0),
      (assign, "$first_encuentro", 4), #para dialogo nuevo con capitan
      (assign, "$mainquestbarco_5_state", 0),
      #todo cero acaba
      (play_sound, "snd_ship_sailing_loop", sf_2d),
      (set_background_mesh, "mesh_pic_knorr"),
    ],
    [
      
      ("town_4",[(eq, "$current_startup_quest_phase", 0),],"Continue.",
        [
          #por native
          # (assign, "$current_town", "p_town_1"), #doccinga
          (assign, "$current_town", "p_village_150"), #doccinga
          (assign, "$g_starting_town", "$current_town"),
          #   (assign, "$g_journey_string", "str_journey_to_sargoth"),
          #
          (modify_visitors_at_site,"scn_sea_battle_mainquest"),
          (reset_visitors),
          
          (assign, ":num_sailors", 6),
          (set_visitors, 0, "trp_sailors", ":num_sailors"),
          (set_visitor,0,"trp_mercenary_arqueros"),
          (set_visitor,0,"trp_trainer_1"),
          (set_visitor,0,"trp_mercenary_arqueros"),
          (set_visitor,0,"trp_bodo_falso"), #futuro companero viaja en el barco.
          (set_visitor,0,"trp_player"),
          (set_visitor,0,"trp_your_tutorialwife"),
          (set_visitor,0,"trp_frisianship_merchant"),
          
          (assign, ":num_pirates", 20),
          (set_visitors, 2, "trp_elite_viking", ":num_pirates"),
          (set_visitor,2,"trp_sea_raider_leader2"),
          ##
          (set_party_battle_mode),
          (set_battle_advantage, 0),
          ##        (assign, "$g_battle_result", 0),
          ##
          # (set_jump_mission,"mt_mainquest_seabattle"),
          (jump_to_scene,"scn_sea_battle_mainquest"),
          (change_screen_mission),
      ]),
      
      # ("tutorial_cheat",[(eq,1,0)],"{!}CHEAT!",
        # [
          # (change_screen_return),
          # (assign, "$cheat_mode", 1),
          # (set_show_messages, 0),
          # (add_xp_to_troop, 15000, "trp_player"),
          # (troop_raise_skill, "trp_player", skl_leadership, 7),
          # (troop_raise_skill, "trp_player", skl_prisoner_management, 5),
          # (troop_raise_skill, "trp_player", skl_inventory_management, 10),
          # (party_add_members, "p_main_party", "trp_briton_level2_companion", 10),
          # (party_add_members, "p_main_party", "trp_saxon_level3_landed", 10),
          # (party_add_members, "p_main_party", "trp_saxon_level1_companion", 10),
          # (party_add_members, "p_main_party", "trp_briton_marksman", 10),
          # (troop_add_item, "trp_player","itm_mail_shirt_1",0),
          # (troop_add_item, "trp_player","itm_spangenhelm_11",0),
          
          # (troop_add_item, "trp_player","itm_tutorial_spear",0),
          # (troop_add_item, "trp_player","itm_tutorial_staff",0),
          # (troop_add_item, "trp_player","itm_tutorial_staff_no_attack",0),
          # (troop_add_item, "trp_player","itm_arena_lance",0),
          # (troop_add_item, "trp_player","itm_practice_staff",0),
          # (troop_add_item, "trp_player","itm_practice_lance",0),
          # (troop_add_item, "trp_player","itm_practice_javelin",0),
          # (troop_add_item, "trp_player","itm_long_light_spear2",0),
          # (troop_add_item, "trp_player","itm_pitch_fork",0),
          # (troop_add_item, "trp_player","itm_long_light_spear2",0),
          # (troop_add_item, "trp_player","itm_battle_fork",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_staff",0),
          # (troop_add_item, "trp_player","itm_quarter_staff",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_light_spear1",0),
          # (troop_add_item, "trp_player","itm_long_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_war_spear2",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_long_light_spear2",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_heavy_spear1",0),
          # (troop_add_item, "trp_player","itm_throwing_spears",0),
          # (troop_add_item, "trp_player","itm_javelin",0),
          
          # (troop_add_item, "trp_player","itm_long_axe_b",0),
          
          # (set_show_messages, 1),
          
          # (try_for_range, ":cur_place", scenes_begin, scenes_end),
            # (scene_set_slot, ":cur_place", slot_scene_visited, 1),
          # (try_end),
          
          # (call_script, "script_get_player_party_morale_values"),
          # (party_set_morale, "p_main_party", reg0),
        # ]
      # ),
    ]
  ),
  ###chief intro VC
  # (
    # "custom_battle_scene",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    # "(NO_TRANS)",
    
    # "none",
    # [],
    # [
      
      # ("quick_battle_scene_1",[],"{!}quick_battle_scene_1",
        # [
          # (set_jump_mission,"mt_ai_training"),
          # (jump_to_scene,"scn_quick_battle_scene_1"),(change_screen_mission)
        # ]
      # ),
      # ("quick_battle_scene_2",[],"{!}quick_battle_scene_2",
        # [
          # (set_jump_mission,"mt_ai_training"),
          # (jump_to_scene,"scn_quick_battle_village_141"),(change_screen_mission)
        # ]
      # ),
      # ("quick_battle_scene_3",[],"{!}quick_battle_scene_3",
        # [
          # (set_jump_mission,"mt_ai_training"),
          # (jump_to_scene,"scn_quick_battle_scene_3"),(change_screen_mission)
        # ]
      # ),
      # ("quick_battle_scene_4",[],"{!}quick_battle_scene_4",
        # [
          # (set_jump_mission,"mt_ai_training"),
          # (jump_to_scene,"scn_quick_battle_scene_4"),(change_screen_mission)
        # ]
      # ),
      
      # ("go_back",[],"{!}Go back",
        # [(change_screen_quit),
        # ]
      # ),
    # ]
  # ),
  
  #depreciated
  ##  (
  ##    "custom_battle_2",mnf_disable_all_keys,
  ##    "{!}{s16}",
  ##    "none",
  ##    [
  ##     (assign, "$g_battle_result", 0),
  ##     (set_show_messages, 0),
  ##
  ##     (troop_clear_inventory, "trp_player"),
  ##     (troop_raise_attribute, "trp_player", ca_strength, -1000),
  ##     (troop_raise_attribute, "trp_player", ca_agility, -1000),
  ##     (troop_raise_attribute, "trp_player", ca_charisma, -1000),
  ##     (troop_raise_attribute, "trp_player", ca_intelligence, -1000),
  ##     (troop_raise_skill, "trp_player", skl_shield, -1000),
  ##     (troop_raise_skill, "trp_player", skl_athletics, -1000),
  ##     (troop_raise_skill, "trp_player", skl_riding, -1000),
  ##     (troop_raise_skill, "trp_player", skl_power_strike, -1000),
  ##     (troop_raise_skill, "trp_player", skl_power_throw, -1000),
  ##     (troop_raise_skill, "trp_player", skl_weapon_master, -1000),
  ##     (troop_raise_skill, "trp_player", skl_horse_archery, -1000),
  ##     (troop_raise_skill, "trp_player", skl_ironflesh, -1000),
  ##     (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, -10000),
  ##     (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, -10000),
  ##     (troop_raise_proficiency_linear, "trp_player", wpt_polearm, -10000),
  ##     (troop_raise_proficiency_linear, "trp_player", wpt_archery, -10000),
  ##     (troop_raise_proficiency_linear, "trp_player", wpt_crossbow, -10000),
  ##     (troop_raise_proficiency_linear, "trp_player", wpt_throwing, -10000),
  ##
  ##     (reset_visitors),
  ####   Scene 1 Start "Shalow Lake War"
  ##     (try_begin),
  ##       (eq, "$g_custom_battle_scenario", 0),
  ##       (assign, "$g_player_troop", "trp_knight_1_15"),
  ##       (set_player_troop, "$g_player_troop"),
  ##
  ##       (assign, "$g_custom_battle_scene", "scn_quick_battle_1"),
  ##       (modify_visitors_at_site, "$g_custom_battle_scene"),
  ##       (set_visitor, 0, "$g_player_troop"),
  ##
  ###       (troop_add_item, "trp_player","itm_bascinet",0),
  ###       (troop_add_item, "trp_player","itm_mail_with_surcoat",0),
  ###       (troop_add_item, "trp_player","itm_bastard_sword_a",0),
  ###       (troop_add_item, "trp_player","itm_war_bow",0),
  ###       (troop_add_item, "trp_player","itm_khergit_arrows",0),
  ###       (troop_add_item, "trp_player","itm_kite_shield",0),
  ###       (troop_add_item, "trp_player","itm_hunter",0),
  ###       (troop_add_item, "trp_player","itm_mail_chausses",0),
  ###       (troop_equip_items, "trp_player"),
  ##
  ##       (set_visitors, 1, "trp_farmer", 13),
  ##       (set_visitors, 2, "trp_briton_level1_companion", 5),
  ##       (set_visitors, 3, "trp_briton_marksman", 4),
  ##       (set_visitors, 4, "trp_briton_horseman", 8),
  ##       (set_visitors, 5, "trp_briton_level2_companion", 3),
  ##       (set_visitors, 6, "trp_peasant_woman", 7),
  ##
  ####     Enemy
  ##       (set_visitors, 16, "trp_saxon_level1_landed", 6),
  ##       (set_visitors, 17, "trp_saxon_level1_companion", 6),
  ##       (set_visitors, 18, "trp_saxon_horseman", 4),
  ##       (set_visitors, 19, "trp_saxon_level3_landed", 10),
  ##       (set_visitors, 20, "trp_saxon_level2_landed", 6),
  ##       (str_store_string, s16, "str_custom_battle_1"),
  ##
  ####   SCENE 3 Start "Mountain Bandit Hunt"
  ##     (else_try),
  ##       (eq, "$g_custom_battle_scenario", 1),
  ##       (assign, "$g_player_troop", "trp_knight_2_5"),
  ##       (set_player_troop, "$g_player_troop"),
  ##
  ##       (assign, "$g_custom_battle_scene", "scn_quick_battle_3"),
  ##       (modify_visitors_at_site, "$g_custom_battle_scene"),
  ##       (set_visitor, 0, "$g_player_troop"),
  ##
  ##       (set_visitors, 1, "trp_saxon_level1_companion", 4),
  ##       (set_visitors, 2, "trp_saxon_level1_companion", 5),
  ##       (set_visitors, 3, "trp_saxon_level0_companion", 4),
  ##       (set_visitors, 4, "trp_saxon_horseman", 4),
  ##       (set_visitors, 5, "trp_saxon_level0_landed", 2),
  ##       (set_visitors, 6, "trp_saxon_level3_landed", 4),
  #### ENEMY
  ##
  ##       (set_visitors, 16, "trp_mountain_bandit", 4),
  ##       (set_visitors, 17, "trp_bandit", 8),
  ##       (set_visitors, 18, "trp_mountain_bandit", 8),
  ##       (set_visitors, 19, "trp_mountain_bandit", 6),
  ##       (set_visitors, 20, "trp_sea_raider", 5),
  ##       (set_visitors, 21, "trp_mountain_bandit", 4),
  ##       (set_visitors, 22, "trp_brigand", 6),
  ##       (set_visitors, 23, "trp_sea_raider", 8),
  ##       (set_visitors, 25, "trp_brigand", 10),
  ##       (str_store_string, s16, "str_custom_battle_2"),
  ##
  ####   SCENE 4 Start "Grand Stand"
  ##     (else_try),
  ##       (eq, "$g_custom_battle_scenario", 2),
  ##       (assign, "$g_player_troop", "trp_kingdom_5_lady_1"),
  ##       (set_player_troop, "$g_player_troop"),
  ##
  ##       (troop_raise_attribute, "$g_player_troop", ca_strength, 12),
  ##       (troop_raise_attribute, "$g_player_troop", ca_agility, 9),
  ##       (troop_raise_attribute, "$g_player_troop", ca_charisma, 5),
  ##       (troop_raise_attribute, "$g_player_troop", ca_intelligence, 5),
  ##       (troop_raise_skill, "$g_player_troop", skl_shield, 3),
  ##       (troop_raise_skill, "$g_player_troop", skl_athletics, 2),
  ##       (troop_raise_skill, "$g_player_troop", skl_riding, 3),
  ##       (troop_raise_skill, "$g_player_troop", skl_power_strike, 4),
  ##       (troop_raise_skill, "$g_player_troop", skl_power_draw, 5),
  ##       (troop_raise_skill, "$g_player_troop", skl_weapon_master, 4),
  ##       (troop_raise_skill, "$g_player_troop", skl_ironflesh, 6),
  ##       (troop_raise_proficiency_linear, "$g_player_troop", wpt_one_handed_weapon, 100),
  ##       (troop_raise_proficiency_linear, "$g_player_troop", wpt_two_handed_weapon, 30),
  ##       (troop_raise_proficiency_linear, "$g_player_troop", wpt_polearm, 20),
  ##       (troop_raise_proficiency_linear, "$g_player_troop", wpt_crossbow, 110),
  ##       (troop_raise_proficiency_linear, "$g_player_troop", wpt_throwing, 10),
  ##
  ##       (assign, "$g_custom_battle_scene", "scn_quick_battle_4"),
  ##       (modify_visitors_at_site, "$g_custom_battle_scene"),
  ##       (set_visitor, 0, "$g_player_troop"),
  ##
  ##       (troop_clear_inventory, "$g_player_troop"),
  ##       (troop_add_item, "$g_player_troop","itm_helmet_with_neckguard",0),
  ##       (troop_add_item, "$g_player_troop","itm_plate_armor",0),
  ##       (troop_add_item, "$g_player_troop","itm_carbatinae_6",0),
  ##       (troop_add_item, "$g_player_troop","itm_mail_chausses",0),
  ##       (troop_add_item, "$g_player_troop","itm_tab_shield_small_round_c",0),
  ##       (troop_add_item, "$g_player_troop","itm_heavy_crossbow",0),
  ##       (troop_add_item, "$g_player_troop","itm_bolts",0),
  ##       (troop_add_item, "$g_player_troop","itm_sword_medieval_b_small",0),
  ##       (troop_equip_items, "$g_player_troop"),
  #### US
  ##       (set_visitors, 1, "trp_saxon_level1_landed", 4),
  ##       (set_visitors, 2, "trp_saxon_level1_companion", 3),
  ##       (set_visitors, 3, "trp_saxon_level1_landed", 4),
  ##       (set_visitors, 4, "trp_saxon_level1_companion", 3),
  ##       (set_visitors, 5, "trp_saxon_level1_landed", 3),
  ##       (set_visitors, 6, "trp_saxon_level0_landed", 5),
  ##       (set_visitors, 7, "trp_saxon_level0_landed", 4),
  ##       (set_visitors, 8, "trp_saxon_level1_companion", 3),
  ##
  #### ENEMY
  ##       (set_visitors, 16, "trp_briton_level1_landed", 8),
  ##       (set_visitors, 17, "trp_briton_level2_landed", 9),
  ##       (set_visitors, 18, "trp_briton_level1_companion", 7),
  ##       (set_visitors, 19, "trp_briton_marksman", 8),
  ##       (set_visitors, 20, "trp_briton_level0_landed", 13),
  ##       (str_store_string, s16, "str_custom_battle_3"),
  ##
  ####   Scene 5 START
  ##     (else_try),
  ##       (eq, "$g_custom_battle_scenario", 3),
  ##       (assign, "$g_player_troop", "trp_knight_1_10"),
  ##       (set_player_troop, "$g_player_troop"),
  ##
  ##       (assign, "$g_custom_battle_scene", "scn_quick_battle_5"),
  ##       (modify_visitors_at_site, "$g_custom_battle_scene"),
  ##       (set_visitor, 0, "$g_player_troop"),
  ##
  #### US
  ##       (set_visitors, 1, "trp_briton_level2_companion", 3),
  ##       (set_visitors, 2, "trp_briton_level1_companion", 4),
  ##       (set_visitors, 3, "trp_briton_marksman", 8),
  ##       (set_visitors, 4, "trp_briton_horseman", 8),
  ##       (set_visitors, 5, "trp_briton_level2_companion", 2),
  ##
  ####     enemy
  ##       (set_visitors, 16, "trp_saxon_level1_landed", 8),
  ##       (set_visitors, 17, "trp_saxon_level1_companion", 10),
  ##       (set_visitors, 18, "trp_saxon_horseman", 4),
  ##       (set_visitors, 19, "trp_saxon_level3_landed", 10),
  ##       (set_visitors, 20, "trp_saxon_level2_landed", 7),
  ##       (str_store_string, s16, "str_custom_battle_4"),
  ##
  ##     (else_try),
  ##       (eq, "$g_custom_battle_scenario", 4),
  ##
  ####       (assign, "$g_custom_battle_scene", "scn_quick_battle_6"),
  ##       (assign, "$g_custom_battle_scene", "scn_quick_battle_7"),
  ##
  ###   Player Wear
  ##       (assign, "$g_player_troop", "trp_knight_4_9"),
  ##       (set_player_troop, "$g_player_troop"),
  ##
  ##       (modify_visitors_at_site, "$g_custom_battle_scene"),
  ##       (set_visitor, 0, "$g_player_troop"),
  ##
  ##       (set_visitors, 1, "trp_angle_level3_landed", 4),
  ##       (set_visitors, 2, "trp_angle_level3_landed", 4),
  ##       (set_visitors, 3, "trp_angle_horseman", 4),
  ##       (set_visitors, 4, "trp_angle_level2_landed", 5),
  ##       (set_visitors, 5, "trp_angle_level1_landed", 5),
  ##       (set_visitors, 6, "trp_angle_level0_companion", 8),
  ##
  #### ENEMY
  ##       (set_visitors, 11, "trp_saxon_level3_landed", 2),
  ##       (set_visitors, 12, "trp_saxon_level2_landed", 6),
  ##       (set_visitors, 13, "trp_saxon_level1_landed", 8),
  ##       (set_visitors, 14, "trp_saxon_level0_companion", 10),
  ##       (set_visitors, 16, "trp_saxon_bowman", 5),
  ##       (set_visitors, 17, "trp_saxon_level1_companion", 4),
  ##       (set_visitors, 18, "trp_saxon_level2_companion", 2),
  ##       (set_visitors, 19, "trp_saxon_bowman", 4),
  ##       (set_visitors, 20, "trp_saxon_bowman", 3),
  ##       (set_visitors, 21, "trp_saxon_bowman", 3),
  ##       (set_visitors, 22, "trp_saxon_bowman", 3),
  ##       (set_visitors, 23, "trp_saxon_level1_companion", 2),
  ##       (str_store_string, s16, "str_custom_battle_5"),
  ##     (try_end),
  ##     (set_show_messages, 1),
  ##     ],
  ##
  ##    [
  ##      ("custom_battle_go",[],"Start.",
  ##       [(try_begin),
  ##          (eq, "$g_custom_battle_scenario", 2),
  ####          (set_jump_mission,"mt_custom_battle_siege"),
  ##        (else_try),
  ##          (eq, "$g_custom_battle_scenario", 4),
  ####          (set_jump_mission,"mt_custom_battle_5"),
  ##        (else_try),
  ####          (set_jump_mission,"mt_custom_battle"),
  ##        (try_end),
  ##        (jump_to_menu, "mnu_custom_battle_end"),
  ##        (jump_to_scene,"$g_custom_battle_scene"),
  ##        (change_screen_mission),
  ##        ]
  ##       ),
  ##      ("leave_custom_battle_2",[],"Cancel.",
  ##       [(jump_to_menu, "mnu_start_game_3"),
  ##        ]
  ##       ),
  ##    ]
  ##  ),
  
  
  (
    "custom_battle_end",mnf_disable_all_keys,
    "The battle is over. {s1} Your side killed {reg5} enemies and lost {reg6} troops during the battle. You personally slew {reg7} men in the fighting.",
    "none",
    [(stop_all_sounds, 0),	#VC-2127
      (play_sound, "snd_raven"),(set_background_mesh, "mesh_pic_defeat"),
      (music_set_situation, 0),
      (assign, reg5, "$g_custom_battle_team2_death_count"),
      (assign, reg6, "$g_custom_battle_team1_death_count"),
      (get_player_agent_kill_count, ":kill_count"),
      (get_player_agent_kill_count, ":wound_count", 1),
      (store_add, reg7, ":kill_count", ":wound_count"),
      (try_begin),
        (eq, "$g_battle_result", 1),
        (str_store_string, s1, "str_battle_won"),
      (else_try),
        (str_store_string, s1, "str_battle_lost"),
      (try_end),
      
      (try_begin),
        (ge, "$g_custom_battle_team2_death_count", 100),
        (unlock_achievement, ACHIEVEMENT_LOOK_AT_THE_BONES),
      (try_end),
    ],
    [
      ("continue",[],"Continue.",
        [(change_screen_quit),
        ]
      ),
    ]
  ),
  
  ###chief character creation, creacion de caracter menu
  ("start_game_2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Welcome to Viking Conquest.",
    "none",
    [
      (assign, "$character_gender", tf_male),
      (assign, "$character_height", cb3_normal),
      (assign, "$age_type", cb4_young),
      (assign, "$virtue_type", cb5_bold),
      (assign, "$defect_type", cb6_prudence),
      (assign, "$g_faction_selected", "fac_kingdom_5"),
      (assign, "$nacionalidad_type", cb7_anglesaxon),
      (assign, "$background_type", cb_thief),
      (assign, "$child_type", cb2_steppe_child),
      (assign, "$blife_type", cb3_landowner), #default for high level modes. See presentation.
      (assign, "$religion_type", cb3_christian),
      (start_presentation, "prsnt_player_sheet_bio"),
    ],
    [
      ##     ("continue",[],"Continue...",
      ##       [(jump_to_menu, "mnu_start_game_1"),
      ##        ]
      ##       ),
      ##      ("go_back",[],"Go back",
      ##       [
      ##         (change_screen_quit),
      ##    ]),
    ]
  ),
  
  ("start_game_1",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Welcome to Viking Conquest.",
    "none",
    [
      (start_presentation, "prsnt_intro_epic"),
    ],
    [
      ##     ("continue",[],"Continue...",
      ##       [(jump_to_menu, "mnu_start_game_1"),
      ##        ]
      ##       ),
      ##      ("go_back",[],"Go back",
      ##       [
      ##         (change_screen_quit),
      ##       ]),
    ]
  ),
  
  ("start_game_11",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Exit?",
    "none",
    [
      (change_screen_quit),
    ],
    [
      ##     ("continue",[],"Continue...",
      ##       [(jump_to_menu, "mnu_start_game_1"),
      ##        ]
      ##       ),
      ##      ("go_back",[],"Go back",
      ##       [
      ##         (change_screen_quit),
      ##       ]),
    ]
  ),
  
  ("start_game_4",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You have made some choices. You will not be able to change them later after the game starts. Would you like to keep them and continue?",
    "none",
    [
      (set_show_messages, 0),
      
      #attributes initial = 10 (4 in troops player + 5 here)
      (troop_raise_attribute, "trp_player",ca_strength,5),
      (troop_raise_attribute, "trp_player",ca_charisma,5),
      (troop_raise_attribute, "trp_player",ca_agility,5),
      (troop_raise_attribute, "trp_player",ca_intelligence,5),
      #gender change basic
      (try_begin),
        (eq,"$character_gender",tf_male),
        (troop_raise_attribute, "trp_player",ca_strength,2),
        (troop_raise_attribute, "trp_player",ca_charisma,-2),
        (troop_raise_attribute, "trp_player",ca_agility,2),
        (troop_raise_attribute, "trp_player",ca_intelligence,-2),
      (else_try),
        (troop_raise_attribute, "trp_player",ca_strength,-2),
        (troop_raise_attribute, "trp_player",ca_charisma,2),
        (troop_raise_attribute, "trp_player",ca_agility,-2),
        (troop_raise_attribute, "trp_player",ca_intelligence,2),
      (try_end),
      
      (try_begin),
        (eq, "$campaign_type", camp_storyline),
        (troop_raise_skill, "trp_player","skl_sea_king",1),
        (allow_ironman,0),
      (end_try),
      
      ##		   (try_begin), #no ironman in storyline
      ##		          (eq, "$campaign_type", camp_storyline),
      ##                         (allow_ironman,1),
      ##                  (try_end),
      #altura
      (try_begin),
        (eq,"$character_height",cb3_bajo),
        (troop_raise_attribute, "trp_player",ca_strength,-1),
        (troop_raise_attribute, "trp_player",ca_agility,1),
      (else_try),
        (eq,"$character_height",cb3_alto),
        (troop_raise_attribute, "trp_player",ca_strength,1),
        (troop_raise_attribute, "trp_player",ca_agility,-1),
      (try_end),
      #edad
      (try_begin),
        (eq,"$age_type",cb4_elder),
        (troop_raise_attribute, "trp_player",ca_strength,-2),
        (troop_raise_attribute, "trp_player",ca_agility,-2),
        (troop_raise_attribute, "trp_player",ca_intelligence,2),
        (troop_raise_attribute, "trp_player",ca_charisma,2),
      (else_try),
        (eq,"$age_type",cb4_adult),
        (troop_raise_attribute, "trp_player",ca_strength,1),
        (troop_raise_attribute, "trp_player",ca_agility,1),
        (troop_raise_attribute, "trp_player",ca_intelligence,1),
        (troop_raise_attribute, "trp_player",ca_charisma,1),
      (else_try),
        (eq,"$age_type",cb4_young),
        (troop_raise_attribute, "trp_player",ca_strength,2),
        (troop_raise_attribute, "trp_player",ca_agility,2),
        (troop_raise_attribute, "trp_player",ca_intelligence,-1),
        (troop_raise_attribute, "trp_player",ca_charisma,-1),
      (try_end),
      
      #virtue
      (try_begin),
        (eq,"$virtue_type",cb5_calm),
        (troop_raise_attribute, "trp_player",ca_charisma,-1),
        (troop_raise_attribute, "trp_player",ca_intelligence,1),
        #           (troop_raise_attribute, "trp_player",ca_agility,1),
      (else_try),
        (eq,"$virtue_type",cb5_responsible),
        (troop_raise_attribute, "trp_player",ca_intelligence,1),
      (else_try),
        (eq,"$virtue_type",cb5_extroverted),
        (troop_raise_attribute, "trp_player",ca_charisma,2),
      (else_try),
        (eq,"$virtue_type",cb5_bold),
        (troop_raise_attribute, "trp_player",ca_strength,1),
        (troop_raise_attribute, "trp_player",ca_intelligence,-1),
      (try_end),
      
      #virtue
      (try_begin),
        (eq,"$defect_type",cb6_prudence),
        (troop_raise_attribute, "trp_player",ca_intelligence,1),
      (else_try),
        (eq,"$defect_type",cb6_fortitude),
        (troop_raise_attribute, "trp_player",ca_strength,1),
        (troop_raise_attribute, "trp_player",ca_charisma,1),
        (troop_raise_attribute, "trp_player",ca_intelligence,-1),
        (troop_raise_skill, "trp_player",skl_athletics,1),
      (else_try),
        (eq,"$defect_type",cb6_temperance),
        (troop_raise_attribute, "trp_player",ca_agility,1),
        (troop_raise_skill, "trp_player",skl_ironflesh,1),
      (else_try),
        (eq,"$defect_type",cb6_justice),
        (troop_raise_attribute, "trp_player",ca_intelligence,1),
        (troop_raise_attribute, "trp_player",ca_charisma,1),
      (try_end),
      
      #Nationality
      (try_begin),
        (eq,"$nacionalidad_type",cb7_foreigner),
        (troop_raise_attribute, "trp_player",ca_intelligence,2),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_norse"),
        (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_norse"),
        (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop,"trp_norse_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop,"trp_norse_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_norse_level1_landed"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_norse_messenger"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_norse_prison_guard"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_norse_castle_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_norse_level1_landed"),
        (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_norse_messenger"),
        (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_norse_prison_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_norse_castle_guard"),
      (else_try),
        (eq,"$nacionalidad_type",cb7_scotopict),
        (troop_raise_attribute, "trp_player",ca_agility,2),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_scotch"),
        (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_scotch"),
        (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop,"trp_scotch_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop,"trp_scotch_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_scotch_level1_landed"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_scotch_messenger"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_scotch_prison_guard"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_scotch_castle_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_scotch_level1_landed"),
        (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_scotch_messenger"),
        (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_scotch_prison_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_scotch_castle_guard"),
      (else_try),
        (eq,"$nacionalidad_type",cb7_briton),
        (troop_raise_attribute, "trp_player",ca_charisma,1),
        (troop_raise_attribute, "trp_player",ca_agility,1),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_welsh"),
        (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_welsh"),
        (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop,"trp_briton_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop,"trp_briton_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_briton_level1_landed"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_messenger_troop, "trp_briton_messenger"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_prison_guard_troop, "trp_briton_prison_guard"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_castle_guard_troop, "trp_briton_castle_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_briton_level1_landed"),
        (faction_set_slot, "fac_player_faction",  slot_faction_messenger_troop, "trp_briton_messenger"),
        (faction_set_slot, "fac_player_faction",  slot_faction_prison_guard_troop, "trp_briton_prison_guard"),
        (faction_set_slot, "fac_player_faction",  slot_faction_castle_guard_troop, "trp_briton_castle_guard"),
      (else_try),
        (eq,"$nacionalidad_type",cb7_irish),
        (troop_raise_attribute, "trp_player",ca_agility,2),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_irish"),
        (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_irish"),
        (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop,"trp_irish_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop,"trp_irish_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_irish_level1_landed"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_irish_messenger"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_irish_prison_guard"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_irish_castle_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_irish_level1_landed"),
        (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_irish_messenger"),
        (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_irish_prison_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_irish_castle_guard"),
      (else_try),
        (eq,"$nacionalidad_type",cb7_frisian),
        (troop_raise_attribute, "trp_player",ca_intelligence,1),
        (troop_raise_attribute, "trp_player",ca_strength,1),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_norse"),
        (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_norse"),
        (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop,"trp_norse_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop,"trp_norse_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_norse_level1_landed"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_norse_messenger"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_norse_prison_guard"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_norse_castle_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_norse_level1_landed"),
        (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_norse_messenger"),
        (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_norse_prison_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_norse_castle_guard"),
      (else_try),
        (eq,"$nacionalidad_type",cb7_norseman),
        (troop_raise_attribute, "trp_player",ca_strength,2),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_norse"),
        (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_norse"),
        (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop,"trp_norse_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop,"trp_norse_deserter"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_norse_level1_landed"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_norse_messenger"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_norse_prison_guard"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_norse_castle_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_norse_level1_landed"),
        (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_norse_messenger"),
        (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_norse_prison_guard"),
        (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_norse_castle_guard"),
      (else_try),
        (eq,"$nacionalidad_type",cb7_anglesaxon),
        (troop_raise_attribute, "trp_player",ca_charisma,2),
        (try_begin),
          (gt, "$g_faction_selected", 0),
          (faction_get_slot, reg1, "$g_faction_selected",  slot_faction_culture),
          (try_begin),
            (eq, reg1, "fac_culture_saxon"),
            (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop, "trp_saxon_deserter"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop, "trp_saxon_deserter"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_saxon_level1_landed"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_saxon_messenger"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_saxon_prison_guard"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_saxon_castle_guard"),
            (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_saxon_level1_landed"),
            (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_saxon_messenger"),
            (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_saxon_prison_guard"),
            (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_saxon_castle_guard"),
          (else_try),
            (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop, "trp_angle_deserter"),
            (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_angle_level1_landed"),
            (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_angle_messenger"),
            (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_angle_prison_guard"),
            (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_angle_castle_guard"),
            (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop, "trp_angle_deserter"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_angle_level1_landed"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_angle_messenger"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_angle_prison_guard"),
            (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_angle_castle_guard"),
          (try_end),
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, reg1),
          (faction_set_slot, "fac_player_faction",  slot_faction_culture, reg1),
        (else_try),
          (faction_set_slot, "fac_player_supporters_faction",  slot_faction_culture, "fac_culture_saxon"),
          (faction_set_slot, "fac_player_faction",  slot_faction_culture, "fac_culture_saxon"),
          (faction_set_slot, "fac_player_faction", slot_faction_deserter_troop, "trp_saxon_deserter"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_deserter_troop, "trp_saxon_deserter"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_guard_troop, "trp_saxon_level1_landed"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_messenger_troop, "trp_saxon_messenger"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_prison_guard_troop, "trp_saxon_prison_guard"),
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_castle_guard_troop, "trp_saxon_castle_guard"),
          (faction_set_slot, "fac_player_faction", slot_faction_guard_troop, "trp_saxon_level1_landed"),
          (faction_set_slot, "fac_player_faction", slot_faction_messenger_troop, "trp_saxon_messenger"),
          (faction_set_slot, "fac_player_faction", slot_faction_prison_guard_troop, "trp_saxon_prison_guard"),
          (faction_set_slot, "fac_player_faction", slot_faction_castle_guard_troop, "trp_saxon_castle_guard"),
        (try_end),
      (try_end),
      (try_begin),
        (faction_get_slot, ":culture", "fac_player_faction", slot_faction_culture),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_1_troop),
        (faction_set_slot, "fac_player_faction",  slot_faction_tier_1_troop, ":troop"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_tier_1_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_2_troop),
        (faction_set_slot, "fac_player_faction",  slot_faction_tier_2_troop, ":troop"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_tier_2_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_3_troop),
        (faction_set_slot, "fac_player_faction",  slot_faction_tier_3_troop, ":troop"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_tier_3_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_4_troop),
        (faction_set_slot, "fac_player_faction",  slot_faction_tier_4_troop, ":troop"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_tier_4_troop, ":troop"),
        (faction_get_slot, ":troop", ":culture",  slot_faction_tier_5_troop),
        (faction_set_slot, "fac_player_faction",  slot_faction_tier_5_troop, ":troop"),
        (faction_set_slot, "fac_player_supporters_faction",  slot_faction_tier_5_troop, ":troop"),
      (try_end),
      #Total attributes (above) 10 + (10 max or -4 min) = 20 up and 6 down
      
      #skills (below): Total points initial = 40. Int can give some extra points here.
      #Moreover, player will get enter 40 and 44 extra points in his 40 levels.
      #Total skills 10 points (max) 8 to 10. In addition player will be able use troops, companions and items to add more skills points (or penalties)
      #background
      #####battle skills
      ##        (troop_raise_skill, "trp_player",skl_weapon_master,1),
      ##        (troop_raise_skill, "trp_player",skl_trainer,1),
      ##        (troop_raise_skill, "trp_player",skl_riding,1),
      ##        (troop_raise_skill, "trp_player",skl_athletics,1),
      ##        (troop_raise_skill, "trp_player",skl_power_draw,1),
      ##        (troop_raise_skill, "trp_player",skl_power_throw,1),
      ##        (troop_raise_skill, "trp_player",skl_power_strike,1),
      ##        (troop_raise_skill, "trp_player",skl_ironflesh,1),
      ###leader
      ##        (troop_raise_skill, "trp_player",skl_leadership,1),
      ##        (troop_raise_skill, "trp_player",skl_persuasion,1),
      ##        (troop_raise_skill, "trp_player",skl_engineer,1),
      ##        (troop_raise_skill, "trp_player",skl_tactics,1),
      ###sea skills
      ##        (troop_raise_skill, "trp_player",skl_sea_king,1),
      ##        (troop_raise_skill, "trp_player",skl_navigation,1),
      #####comerce
      ##        (troop_raise_skill, "trp_player",skl_trade,1),
      ##        (troop_raise_skill, "trp_player",skl_inventory_management,1),
      ####doctor
      ##        (troop_raise_skill, "trp_player",skl_first_aid,1),
      ##        (troop_raise_skill, "trp_player",skl_surgery,1),
      ##        (troop_raise_skill, "trp_player",skl_wound_treatment,1),
      ####tracker
      ##        (troop_raise_skill, "trp_player",skl_spotting,1),
      ##        (troop_raise_skill, "trp_player",skl_pathfinding,1),
      ##        (troop_raise_skill, "trp_player",skl_tracking,1),
      ##        (troop_raise_skill, "trp_player",skl_looting,1),
      ##basic skills player
      ###battle skills
      (troop_raise_skill, "trp_player",skl_prisoner_management,1),
      (troop_raise_skill, "trp_player",skl_weapon_master,1),
      (troop_raise_skill, "trp_player",skl_athletics,1),
      (troop_raise_skill, "trp_player",skl_ironflesh,1),
      (troop_raise_skill, "trp_player",skl_leadership,1),
      (troop_raise_skill, "trp_player",skl_persuasion,1),
      (troop_raise_skill, "trp_player",skl_trade,1),
      (troop_raise_skill, "trp_player",skl_inventory_management,1),
      (troop_raise_skill, "trp_player",skl_first_aid,1),
      
      #basic weapon proficiency (30 troops + 30 here
      (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
      (troop_raise_proficiency, "trp_player",wpt_two_handed_weapon,30),
      (troop_raise_proficiency, "trp_player",wpt_polearm,30),
      (troop_raise_proficiency, "trp_player",wpt_throwing,30),
      (troop_raise_proficiency, "trp_player", wpt_crossbow, 30),
      (troop_raise_proficiency, "trp_player", wpt_archery, 30),
      (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
      
      #basic gold
      (troop_add_gold, "trp_player", 100),
      
      
      (try_begin),
        (eq,"$background_type",cb_noble),
        (eq,"$character_gender",tf_male),
        (troop_raise_skill, "trp_player",skl_leadership,2),
        (troop_raise_skill, "trp_player",skl_persuasion,2),
        #       (troop_raise_skill, "trp_player",skl_engineer,2),
        (troop_raise_skill, "trp_player",skl_tactics,2),
        
        (troop_raise_skill, "trp_player",skl_weapon_master,2),
        (troop_raise_skill, "trp_player",skl_trainer,2),
        (troop_raise_skill, "trp_player",skl_riding,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        (troop_raise_skill, "trp_player",skl_maintenance,2),
        
        (val_add, "$player_right_to_rule", 4),
        
      (else_try),
        (eq,"$background_type",cb_noble),
        (eq,"$character_gender",tf_female),
        (troop_raise_skill, "trp_player",skl_leadership,2),
        (troop_raise_skill, "trp_player",skl_persuasion,2),
        
        (troop_raise_skill, "trp_player",skl_weapon_master,2),
        (troop_raise_skill, "trp_player",skl_riding,2),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        #        (troop_raise_skill, "trp_player",skl_power_draw,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        
        (troop_raise_skill, "trp_player",skl_first_aid,2),
        (troop_raise_skill, "trp_player",skl_wound_treatment,2),
        (troop_raise_skill, "trp_player",skl_inventory_management,2),
        (troop_raise_skill, "trp_player",skl_maintenance,2),
        
        (val_add, "$player_right_to_rule", 2),
        
      (else_try),
        (eq,"$background_type",cb_merchant),
        (troop_raise_skill, "trp_player",skl_trade,4),
        (troop_raise_skill, "trp_player",skl_inventory_management,2),
        
        (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        (troop_raise_skill, "trp_player",skl_power_throw,1),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        
        (troop_raise_skill, "trp_player",skl_navigation,2),
        
        (troop_raise_skill, "trp_player",skl_pathfinding,2),
        (troop_raise_skill, "trp_player",skl_looting,1),
      (else_try),
        (eq,"$background_type",cb_guard), #Craftsman
        (troop_raise_skill, "trp_player",skl_trade,2),
        (troop_raise_skill, "trp_player",skl_inventory_management,2),
        (troop_raise_skill, "trp_player",skl_looting,1),
        (troop_raise_skill, "trp_player",skl_engineer,3),
        
        (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        (troop_raise_skill, "trp_player",skl_power_throw,1),
        (troop_raise_skill, "trp_player",skl_power_strike,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        (troop_raise_skill, "trp_player",skl_maintenance,4),
        
      (else_try),
        (eq,"$background_type",cb_forester), #Priest
        (assign, "$sabe_leer", 1), #sabe leer chief? Yes
        (troop_raise_skill, "trp_player",skl_athletics,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        
        (troop_raise_skill, "trp_player",skl_persuasion,2),
        (troop_raise_skill, "trp_player",skl_trade,1),
        (troop_raise_skill, "trp_player",skl_inventory_management,2),
        (troop_raise_skill, "trp_player",skl_first_aid,4),
        (troop_raise_skill, "trp_player",skl_surgery,2),
        (troop_raise_skill, "trp_player",skl_wound_treatment,2),
      (else_try),
        (eq,"$background_type",cb_nomad), #Peasant
        (eq,"$character_gender",tf_male),
        (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_athletics,4),
        #       (troop_raise_skill, "trp_player",skl_power_draw,1),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        
        (troop_raise_skill, "trp_player",skl_trade,1),
        (troop_raise_skill, "trp_player",skl_inventory_management,1),
        (troop_raise_skill, "trp_player",skl_first_aid,2),
        (troop_raise_skill, "trp_player",skl_looting,1),
        (troop_raise_skill, "trp_player",skl_maintenance,1),
        
      (else_try),
        (eq,"$background_type",cb_nomad),#Peasant
        (eq,"$character_gender",tf_female),
        (troop_raise_skill, "trp_player",skl_first_aid,2),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        (troop_raise_skill, "trp_player",skl_wound_treatment,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,1),
        (troop_raise_skill, "trp_player",skl_ironflesh,1),
        (troop_raise_skill, "trp_player",skl_maintenance,1),
        
        (troop_raise_skill, "trp_player",skl_trade,1),
        (troop_raise_skill, "trp_player",skl_inventory_management,4),
        (troop_raise_skill, "trp_player",skl_looting,1),
      (else_try),
        (eq,"$background_type",cb_thief), #Outlaw
        (troop_raise_skill, "trp_player",skl_weapon_master,2),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        #       (troop_raise_skill, "trp_player",skl_power_draw,1),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        (troop_raise_skill, "trp_player",skl_spotting,2),
        (troop_raise_skill, "trp_player",skl_pathfinding,2),
        (troop_raise_skill, "trp_player",skl_tracking,4),
        (troop_raise_skill, "trp_player",skl_looting,3),
      (try_end),
      #child know.
      (try_begin),
        (eq,"$child_type",cb2_page), #martial
        (eq,"$character_gender",tf_male),
        (assign, "$sabe_leer", 0), #sabe leer chief?
        
        (troop_raise_skill, "trp_player",skl_leadership,2),
        (troop_raise_skill, "trp_player",skl_tactics,1),
        (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_trainer,1),
        (troop_raise_skill, "trp_player",skl_riding,1),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        #       (troop_raise_skill, "trp_player",skl_power_draw,1),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        (troop_raise_skill, "trp_player",skl_maintenance,1),
        
        (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_two_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_polearm,30),
        (troop_raise_proficiency, "trp_player",wpt_throwing,30),
        (troop_raise_proficiency, "trp_player", wpt_crossbow, 30),
        (troop_raise_proficiency, "trp_player", wpt_archery, 30),
        (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
        
        (val_add, "$player_right_to_rule", 4),
        
      (else_try),
        
        (eq,"$child_type",cb2_page), #martial
        (eq,"$character_gender",tf_female),
        (assign, "$sabe_leer", 0), #sabe leer chief?
        
        (troop_raise_skill, "trp_player",skl_persuasion,2),
        (troop_raise_skill, "trp_player",skl_spotting,2),
        (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_trainer,1),
        (troop_raise_skill, "trp_player",skl_riding,1),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        (troop_raise_skill, "trp_player",skl_power_draw,1),
        (troop_raise_skill, "trp_player",skl_power_throw,1),
        (troop_raise_skill, "trp_player",skl_power_strike,1),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        (troop_raise_skill, "trp_player",skl_maintenance,1),
        
        (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_two_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_polearm,30),
        (troop_raise_proficiency, "trp_player",wpt_throwing,30),
        (troop_raise_proficiency, "trp_player", wpt_crossbow, 30),
        (troop_raise_proficiency, "trp_player", wpt_archery, 30),
        (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
        
        (val_add, "$player_right_to_rule", 2),
        
      (else_try),
        (eq,"$child_type",cb2_apprentice), #Crafts
        (assign, "$sabe_leer", 0), #sabe leer chief?
        (troop_raise_skill, "trp_player",skl_leadership,1),
        (troop_raise_skill, "trp_player",skl_persuasion,1),
        (troop_raise_skill, "trp_player",skl_trade,1),
        (troop_raise_skill, "trp_player",skl_inventory_management,2),
        #       (troop_raise_skill, "trp_player",skl_looting,1),
        (troop_raise_skill, "trp_player",skl_engineer,1),
        (troop_raise_skill, "trp_player",skl_maintenance,2),
        
        (troop_raise_skill, "trp_player",skl_weapon_master,2),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        
        (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_polearm,30),
        (troop_raise_proficiency, "trp_player",wpt_throwing,30),
        (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
        
        (troop_add_gold, "trp_player", 180), #money compensate each point lost in proficiency
      (else_try),
        (eq,"$child_type",cb2_urchin), # Stealing
        (assign, "$sabe_leer", 0), #sabe leer chief?
        
        (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        #       (troop_raise_skill, "trp_player",skl_power_draw,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,1),
        (troop_raise_skill, "trp_player",skl_leadership,1),
        (troop_raise_skill, "trp_player",skl_persuasion,2),
        (troop_raise_skill, "trp_player",skl_spotting,2),
        (troop_raise_skill, "trp_player",skl_pathfinding,4),
        (troop_raise_skill, "trp_player",skl_tracking,3),
        
        (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_polearm,30),
        (troop_raise_proficiency, "trp_player",wpt_throwing,30),
        (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
        (troop_raise_proficiency, "trp_player", wpt_archery, 30),
        
        (troop_add_gold, "trp_player", 120), #money compensate each point lost in proficiency
      (else_try),
        (eq,"$child_type",cb2_steppe_child), #Farming
        # (eq,"$character_gender",tf_male),
        (assign, "$sabe_leer", 0), #sabe leer chief?
        #       (troop_raise_skill, "trp_player",skl_weapon_master,1),
        (troop_raise_skill, "trp_player",skl_athletics,2),
        #       (troop_raise_skill, "trp_player",skl_power_draw,1),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_power_strike,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        (troop_raise_skill, "trp_player",skl_inventory_management,1),
        (troop_raise_skill, "trp_player",skl_spotting,2),
        (troop_raise_skill, "trp_player",skl_pathfinding,2),
        (troop_raise_skill, "trp_player",skl_tracking,2),
        (troop_raise_skill, "trp_player",skl_looting,1),
        (troop_raise_skill, "trp_player",skl_maintenance,1),
        
        (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_polearm,30),
        (troop_raise_proficiency, "trp_player",wpt_throwing,30),
        (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
        
        (troop_add_gold, "trp_player", 180), #money compensate each point lost in proficiency
        
      (else_try),
        (eq,"$child_type",cb2_merchants_helper), # Oratory
        (assign, "$sabe_leer", 1), #sabe leer chief? Yes
        (troop_raise_skill, "trp_player",skl_leadership,2),
        (troop_raise_skill, "trp_player",skl_power_throw,2),
        (troop_raise_skill, "trp_player",skl_ironflesh,2),
        
        (troop_raise_skill, "trp_player",skl_persuasion,4),
        (troop_raise_skill, "trp_player",skl_trade,2),
        (troop_raise_skill, "trp_player",skl_inventory_management,2),
        (troop_raise_skill, "trp_player",skl_first_aid,2),
        (troop_raise_skill, "trp_player",skl_surgery,2),
        (troop_raise_skill, "trp_player",skl_wound_treatment,2),
        
        (troop_raise_proficiency, "trp_player",wpt_one_handed_weapon,30),
        (troop_raise_proficiency, "trp_player",wpt_polearm,30),
        (troop_raise_proficiency, "trp_player", wpt_firearm, 30), #sling
        
        (troop_add_gold, "trp_player", 240), #money compensate each point lost in proficiency
      (try_end),
      
      #blife #add items
      (try_begin),
        (neq, "$campaign_type", camp_kingc),
        (neq, "$campaign_type", camp_lordc),
        (try_begin),
          (eq,"$blife_type",cb3_landowner), #landowner
          (eq,"$character_gender",tf_male),
          (troop_add_item, player,"itm_carbatinae_1s",imod_tattered),
          (troop_add_item, player,"itm_hoodtunic_05",imod_crude),
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_light_spear1",imod_cracked),
          (troop_add_item, player,"itm_javelin",imod_bent),
          (troop_add_item, player,"itm_shield_13",imod_cracked),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_dried_meat",0),
          (troop_add_gold, "trp_player", 800), #option is easier
          (val_add, "$player_right_to_rule", 4),
        (else_try),
          (eq,"$blife_type",cb3_landowner), #landowner women
          (eq,"$character_gender",tf_female),
          (troop_add_item, player,"itm_womenshoes_1",imod_ragged), #chief cambiado
          (troop_add_item, player,"itm_ptunic_7woman",0), #chief cambiado
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_light_spear1",imod_cracked),
          (troop_add_item, player,"itm_javelin",imod_bent),
          (troop_add_item, player,"itm_shield_17",imod_cracked),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_dried_meat",0),
          (troop_add_gold, "trp_player", 800), #option is easier
          (val_add, "$player_right_to_rule", 2),
        (else_try),
          (eq,"$blife_type",cb3_roamer), #hunter
          (eq,"$character_gender",tf_male),
          (troop_add_item, player,"itm_carbatinae_1",imod_ragged), #chief cambiado
          (troop_add_item, player,"itm_hoodtunic_01",imod_crude),
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_long_bow",imod_bent),
          (troop_add_item, player,"itm_arrows",0),
          (troop_raise_skill, "trp_player",skl_power_draw,2),
          (troop_add_item, player,"itm_grain",0),
          (troop_add_item, player,"itm_vc_honey",0),
          (troop_add_gold, "trp_player", 600), #
        (else_try),
          (eq,"$blife_type",cb3_roamer), #hunter
          (eq,"$character_gender",tf_female),
          (troop_add_item, player,"itm_womenshoes_5",imod_tattered), #chief cambiado
          (troop_add_item, player,"itm_ptunic_1woman",imod_crude),
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_long_bow",imod_bent),
          (troop_add_item, player,"itm_arrows",0),
          (troop_raise_skill, "trp_player",skl_power_draw,2),
          (troop_add_item, player,"itm_grain",0),
          (troop_add_item, player,"itm_vc_honey",0),
          (troop_add_gold, "trp_player", 600), #
        (else_try),
          (eq,"$blife_type",cb3_traveler), # traveler
          (eq,"$character_gender",tf_male),
          (troop_add_item, player,"itm_carbatinae_1",imod_tattered), #chief cambiado
          (troop_add_item, player,"itm_hoodtunic_03",imod_crude),   #Long Tunic
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_hatchet",imod_rusty),
          (troop_add_item, player,"itm_sling",0),
          (troop_add_item, player,"itm_sling_rock1",0),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_grain",0),
          (troop_add_item, player,"itm_wool",0),
          (troop_add_gold, "trp_player", 600), #
        (else_try),
          (eq,"$blife_type",cb3_traveler), # traveler
          (eq,"$character_gender",tf_female),
          (troop_add_item, player,"itm_womenshoes_5",imod_tattered), #chief cambiado
          (troop_add_item, player,"itm_ptunic_2woman",imod_crude),   #Tunic
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_hatchet",imod_chipped),
          (troop_add_item, player,"itm_sling",0),
          (troop_add_item, player,"itm_sling_rock1",0),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_grain",0),
          (troop_add_item, player,"itm_wool",0),
          (troop_add_gold, "trp_player", 600), #
        (else_try),
          (eq,"$blife_type",cb3_student), #priest
          (assign, "$sabe_leer", 1), #sabe leer chief? Yes
          (troop_add_item, player,"itm_robe6",imod_ragged),
          (troop_add_item, player,"itm_stones",0),
          (troop_add_item, player,"itm_quarter_staff",imod_bent),
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_bread", 0),
          (troop_add_item, player,"itm_bread", 0),
          (troop_add_item, player,"itm_smoked_fish",0),
          (troop_add_gold, "trp_player", 500), #
        (else_try),
          (eq,"$blife_type",cb3_slave), # Slave
          (eq,"$character_gender",tf_male),
          (troop_add_item, player,"itm_just_man_boots_medium",imod_ragged),
          (troop_add_item, player,"itm_btunic_2",imod_ragged),
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_hatchet",imod_rusty),
          (troop_add_item, player,"itm_sling",0),
          (troop_add_item, player,"itm_sling_rock1",0),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_smoked_fish",0),
          (troop_add_gold, "trp_player", 300), #
        (else_try),
          (eq,"$blife_type",cb3_slave), # Slave
          (eq,"$character_gender",tf_female),
          (troop_add_item, player,"itm_just_man_boots_medium",imod_ragged),
          (troop_add_item, player,"itm_ptunic_3woman",imod_ragged),
          (troop_add_item, player,"itm_knife2",0),
          (troop_add_item, player,"itm_hatchet",imod_rusty),
          (troop_add_item, player,"itm_sling",0),
          (troop_add_item, player,"itm_sling_rock1",0),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_smoked_fish",0),
          (troop_add_gold, "trp_player", 300), #
        (try_end),
      (else_try),
        (eq, "$campaign_type", camp_lordc),
        (try_begin),
          (eq,"$character_gender",tf_male),
          (troop_add_item, player,"itm_carbatinae_vc1s"),
          (troop_add_item, player,"itm_gambeson30"),
          (troop_add_item, player,"itm_spangenhelm_11"),
          (troop_add_item, player,"itm_heavy_spear2"),
          (troop_add_item, player,"itm_throwing_spears"),
          (troop_add_item, player,"itm_tab_shield_round_06_device"),
          (try_begin),
            (eq,"$religion_type",cb3_christian),
            (troop_add_item, player,"itm_noble_swordv6"),
          (else_try),
            (troop_add_item, player,"itm_axe_4"),
          (try_end),
          (troop_add_item, player,"itm_bread", 0),
          (troop_add_item, player,"itm_bread", 0),
          (troop_add_item, player,"itm_smoked_fish",0),
        (else_try),
          (troop_add_item, player,"itm_womenshoes_5"),
          (troop_add_item, player,"itm_richwoman_saxon6"),
          (troop_add_item, player,"itm_veil_d"),
          (troop_add_item, player,"itm_long_light_spear2"),
          (troop_add_item, player,"itm_javelin_skirmishes"),
          (troop_add_item, player,"itm_tab_shield_round_06_device"),
          (try_begin),
            (eq,"$religion_type",cb3_christian),
            (troop_add_item, player,"itm_noble_swordv5"),
          (else_try),
            (troop_add_item, player,"itm_one_handed_war_axe_a"),
          (try_end),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_grain",0),
          (troop_add_item, player,"itm_vc_honey",0),
        (try_end),
      (else_try),
        (eq, "$campaign_type", camp_kingc),
        (try_begin),
          (eq,"$character_gender",tf_male),
          (troop_add_item, player,"itm_carbatinae_12q"),
          (troop_add_item, player,"itm_common_pony2"),
          (troop_add_item, player,"itm_mail_shirt_1"),
          (troop_add_item, player,"itm_crown1"),
          (troop_add_item, player,"itm_heavy_spear2"),
          (troop_add_item, player,"itm_noble_swordv7"),
          (troop_add_item, player,"itm_tab_shield_round_06_device"),
          (troop_add_item, player,"itm_javelin"),
          (troop_add_item, player,"itm_vc_honey",0),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_smoked_fish",0),
          (troop_add_item, player,"itm_wine",0),
        (else_try),
          (troop_add_item, player,"itm_womenshoes_2"),
          (troop_add_item, player,"itm_common_pony"),
          (troop_add_item, player,"itm_queenwoman_saxon"),
          (troop_add_item, player,"itm_crown1"),
          (troop_add_item, player,"itm_long_light_spear2"),
          (troop_add_item, player,"itm_noble_swordv7"),
          (troop_add_item, player,"itm_tab_shield_round_06_device"),
          (troop_add_item, player,"itm_javelin"),
          (troop_add_item, player,"itm_vc_honey",0),
          (troop_add_item, player,"itm_bread",0),
          (troop_add_item, player,"itm_dried_meat",0),
          (troop_add_item, player,"itm_jewelry",0),
        (try_end),
      (try_end),
      (try_begin),#phaiak begin (VC-188)
        (eq, "$campaign_type", camp_storyline),
        (troop_remove_item, "trp_player", "itm_sling"),
        (troop_remove_item, "trp_player", "itm_long_bow"),
        (troop_remove_item, "trp_player", "itm_stones"),
        (troop_remove_item, "trp_player", "itm_javelin"),
      (end_try),#phaiak end
      
      (try_begin),
        (eq,"$religion_type",cb3_christian),
        (assign, "$g_player_faith", 1), #religion player chief
        (troop_set_slot, "trp_player", slot_troop_religion, 1),	#christian
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_religion, cb3_christian),
      (else_try),
        (eq,"$religion_type",cb3_pagan),
        (assign, "$g_player_faith", 2), #religion player chief
        (troop_set_slot, "trp_player", slot_troop_religion, 2),	#pagan
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_religion, cb3_pagan),
      (try_end),
      
      (troop_set_slot, "trp_player", slot_troop_renown, 60), #same renown everybody, nobody knows to player
      (call_script, "script_change_player_honor", 1),
      
      (try_begin),
        (eq, "$difficulty_type", camp_d5),
        (assign, ":morale", 20),
      (else_try),
        (eq, "$difficulty_type", camp_d2),
        (assign, ":morale", 80),
      (else_try),
        (assign, ":morale", 50),
      (try_end),
      
      (options_get_campaign_ai, ":reduce_campaign_ai"),
      (try_begin), #hard
        (eq, ":reduce_campaign_ai", 0),
        (val_sub, ":morale", 10),
      (else_try), #easy
        (eq, ":reduce_campaign_ai", 2),
        (val_add, ":morale", 10),
      (try_end),
      
      (party_set_morale, "p_main_party", ":morale"),
      
      (try_begin),
        (eq, "$campaign_type", camp_lordc),
        (call_script, "script_player_join_faction", "$g_faction_selected"),
        (faction_get_slot, ":leader", "$g_faction_selected", slot_faction_leader),
        (call_script, "script_get_poorest_village_of_faction", "$g_faction_selected"),
        (assign, ":center", reg0),
        (call_script, "script_give_center_to_lord", ":center", "trp_player", 0),
        (assign, "$player_has_homage", 1),
        (assign, "$g_player_banner_granted", 1),
        (try_begin),
          (eq,"$age_type",cb4_elder),
          (troop_set_slot, "trp_player", slot_troop_renown, 800),
          (troop_set_slot, "trp_player", slot_troop_wealth, 11000),
          (troop_add_gold, "trp_player", 11000),
          (assign, ":rounds", 15),
        (else_try),
          (eq,"$age_type",cb4_adult),
          (troop_set_slot, "trp_player", slot_troop_renown, 650),
          (troop_set_slot, "trp_player", slot_troop_wealth, 9000),
          (troop_add_gold, "trp_player", 9000),
          (assign, ":rounds", 12),
        (else_try),
          (troop_set_slot, "trp_player", slot_troop_renown, 500),
          (troop_set_slot, "trp_player", slot_troop_wealth, 7000),
          (troop_add_gold, "trp_player", 7000),
          (assign, ":rounds", 9),
        (try_end),
        
        (val_or, "$first_time", first_time_load_main_party),
        (try_for_range, ":unused", 0, ":rounds"),
          (call_script, "script_hire_men_to_kingdom_hero_party", "trp_player"),
        (try_end),
        (val_sub, "$first_time", first_time_load_main_party),
        
        (val_div, ":rounds", 3),
        # (party_remove_members, "p_main_party", "trp_player", 1),
        
        (try_for_range, ":unused", 0, ":rounds"),
          (party_upgrade_with_xp, "p_main_party", 3000, 0),
        (try_end),
        # (party_add_leader, "p_main_party", "trp_player"), not working, so screw it
        (try_for_range, ":unused", 0, 4),
          (add_xp_to_troop, 11650, "trp_player"),
        (try_end),
        (party_get_position, pos0, ":center"),
        (call_script, "script_recurse_party_around_pos0", "p_main_party", 3, 0),
        
        #relations: game start makes 10-50
        (try_for_range, ":troop_id", original_kingdom_heroes_begin, active_npcs_end),
          (store_troop_faction, ":faction", ":troop_id"),
          (eq, ":faction", "$g_faction_selected"),
          
          (store_random_in_range, ":relation", -13, 13),
          (store_random_in_range, reg0, -13, 13),
          (val_add, ":relation", reg0),
          (store_random_in_range, reg0, -13, 13),
          (val_add, ":relation", reg0),
          (val_add, ":relation", 20), #average lord relation game start x2 (adult divided by 2)
          
          (try_begin),
            (eq,"$age_type",cb4_adult),
            (val_div, ":relation", 2),
          (else_try),
            (eq,"$age_type",cb4_young),
            (val_div, ":relation", 4),
          (try_end),
          
          (troop_set_slot, ":troop_id", slot_troop_met, 1),
          (call_script, "script_change_player_relation_with_troop", ":troop_id", ":relation"),
        (try_end),
        (call_script, "script_add_log_entry", logent_pledged_allegiance,   "trp_player",  -1, ":leader", "$g_faction_selected"),
        (call_script, "script_add_log_entry", logent_liege_grants_fief_to_vassal, ":leader", ":center", "trp_player", "$g_faction_selected"),
        (call_script, "script_update_all_notes"),
      (try_end),
      
      (try_begin),
        (eq, "$campaign_type", camp_kingc),
        (try_for_range, ":slot", 0, 270),
          (faction_get_slot, reg0, "$g_faction_selected", ":slot"),
          (faction_set_slot, "fac_player_supporters_faction", ":slot", reg0),
        (try_end),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_active),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_marshal, "trp_player"),
        
        (faction_get_slot, ":old_leader", "$g_faction_selected", slot_faction_leader),
        
        (try_for_parties, ":cur_party"),
          (store_faction_of_party, ":faction", ":cur_party"),
          (try_begin),
            (eq, ":faction", "$g_faction_selected"),
            (party_set_faction, ":cur_party", "fac_player_supporters_faction"),
          (try_end),
          (try_begin),
            (party_slot_eq, ":cur_party", slot_center_original_faction,  "$g_faction_selected"),
            (party_set_slot, ":cur_party", slot_center_original_faction,  "fac_player_supporters_faction"),
          (try_end),
          (try_begin),
            (party_slot_eq, ":cur_party", slot_center_ex_faction,  "$g_faction_selected"),
            (party_set_slot, ":cur_party", slot_center_ex_faction,  "fac_player_supporters_faction"),
          (try_end),
          (try_begin),
            (party_slot_eq, ":cur_party", slot_town_lord,  ":old_leader"),
            (call_script, "script_give_center_to_lord", ":cur_party", "trp_player", 0),
          (try_end),
        (try_end),
        (try_for_range, ":troop_id", kingdom_ladies_begin, kingdom_ladies_end),
          (store_troop_faction, ":faction", ":troop_id"),
          (eq, ":faction", "$g_faction_selected"),
          (troop_set_faction, ":troop_id", "fac_player_supporters_faction"),
          (troop_set_slot, ":troop_id", slot_troop_met, 1),
        (try_end),
        (assign, ":lords_count", 0),
        (try_for_range, ":troop_id", original_kingdom_heroes_begin, active_npcs_end),
          (store_troop_faction, ":faction", ":troop_id"),
          (eq, ":faction", "$g_faction_selected"),
          (val_add, ":lords_count", 1),
        (try_end),
        (convert_to_fixed_point, ":lords_count"),
        (store_sqrt, ":lords_count", ":lords_count"),
        (convert_from_fixed_point, ":lords_count"),
        (store_sub, ":extra_bias", 4, ":lords_count"),
        (val_mul, ":extra_bias", 7),  #add up to 35 relation (see other 5 below) to overcome the strongest of familial relations to throne in small factions
        (try_for_range, ":troop_id", original_kingdom_heroes_begin, active_npcs_end),
          (store_troop_faction, ":faction", ":troop_id"),
          (eq, ":faction", "$g_faction_selected"),
          (troop_set_faction, ":troop_id", "fac_player_supporters_faction"),
          #Give new title
          (call_script, "script_troop_set_title_according_to_faction", ":troop_id", "fac_player_supporters_faction"), #new title system
          #relations: game start makes 10-50
          (store_random_in_range, ":relation", -20, 20),
          (store_random_in_range, reg0, -20, 20),
          (val_add, ":relation", reg0),
          # (val_add, ":relation", 20), #average lord relation game start x2 (adult divided by 2) remove for story that this is minority faction king
          
          (try_begin),
            (eq,"$age_type",cb4_adult),
            (val_div, ":relation", 2),
          (else_try),
            (eq,"$age_type",cb4_young),
            (val_div, ":relation", 4),
          (try_end),
          
          (try_begin),
            (eq, ":troop_id", ":old_leader"),
            (val_sub, ":relation", 25),
          (else_try),
            (call_script, "script_troop_get_relation_with_troop", ":troop_id", ":old_leader"),
            (val_sub, ":relation", reg0),
            (val_add, ":relation", 10+5), #average lord relation game start plus a bit to offset bias from relatives to king
            (val_add, ":relation", ":extra_bias"),
          (try_end),
          
          (troop_set_slot, ":troop_id", slot_troop_met, 1),
          (call_script, "script_change_player_relation_with_troop", ":troop_id", ":relation"),
          
          (neq, ":troop_id", ":old_leader"),  #sow some dissent!
          (troop_set_slot, ":troop_id", slot_troop_original_faction, "fac_player_supporters_faction"),
        (try_end),
        
        (faction_set_slot, "$g_faction_selected", slot_faction_state, sfs_defeated),
        (assign, ":kingdom_pretender", -1),
        (try_for_range, ":cur_pretender", pretenders_begin, pretenders_end),
          (troop_slot_eq, ":cur_pretender", slot_troop_original_faction, "$g_faction_selected"),
          (assign, ":kingdom_pretender", ":cur_pretender"),
        (try_end),
        (try_begin),
          (is_between, ":kingdom_pretender", pretenders_begin, pretenders_end),
          (neq, ":kingdom_pretender", "$supported_pretender"),
          (troop_set_slot, ":kingdom_pretender", slot_troop_cur_center, 0), #remove pretender from the world
        (try_end),
        
        (assign, "$player_has_homage", 1),
        (assign, "$players_kingdom", fac_player_supporters_faction),
        (assign, "$g_player_banner_granted", 1),
        # (val_mul, "$player_right_to_rule", 2), as tests go only to 25, this just removes gameplay
        # (val_add, "$player_right_to_rule", 40),
        
        (try_begin),
          (eq,"$age_type",cb4_elder),
          (troop_set_slot, "trp_player", slot_troop_renown, 1100),
          (troop_set_slot, "trp_player", slot_troop_wealth, 27000),
          (troop_add_gold, "trp_player", 27000),
          (assign, ":rounds", 24),
        (else_try),
          (eq,"$age_type",cb4_adult),
          (troop_set_slot, "trp_player", slot_troop_renown, 1000),
          (troop_set_slot, "trp_player", slot_troop_wealth, 24000),
          (troop_add_gold, "trp_player", 24000),
          (assign, ":rounds", 18),
        (else_try),
          (troop_set_slot, "trp_player", slot_troop_renown, 900),
          (troop_set_slot, "trp_player", slot_troop_wealth, 21000),
          (troop_add_gold, "trp_player", 21000),
          (assign, ":rounds", 12),
        (try_end),
        
        (val_or, "$first_time", first_time_load_main_party),
        (try_for_range, reg0, 0, ":rounds"),
          (call_script, "script_hire_men_to_kingdom_hero_party", "trp_player"),
        (try_end),
        (val_sub, "$first_time", first_time_load_main_party),
        
        (val_div, ":rounds", 3),
        # (party_remove_members, "p_main_party", "trp_player", 1),
        
        (try_for_range, reg0, 0, ":rounds"),
          (party_upgrade_with_xp, "p_main_party", 4000, 0),
        (try_end),
        # (party_add_leader, "p_main_party", "trp_player"), not working, so screw it
        
        (try_begin),
          (troop_slot_eq, "trp_player", slot_troop_religion, 2),#pagan
          (party_add_members,"p_main_party","trp_npc3",1),
          (party_add_members,"p_main_party","trp_npc7",1),
          (party_add_members,"p_main_party","trp_npc11",1),
          (party_add_members,"p_main_party","trp_npc13",1),
          (troop_set_slot, "trp_npc13", slot_troop_met, 1),
          (troop_set_slot, "trp_npc11", slot_troop_met, 1),
          (troop_set_slot, "trp_npc7", slot_troop_met, 1),
          (troop_set_slot, "trp_npc3", slot_troop_met, 1),
          (troop_set_slot, "trp_npc13", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc13", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc13", 0),
          (troop_set_note_available, "trp_npc13", 1),
          (troop_set_slot, "trp_npc11", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc11", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc11", 0),
          (troop_set_note_available, "trp_npc11", 1),
          (troop_set_slot, "trp_npc3", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc3", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc3", 0),
          (troop_set_note_available, "trp_npc3", 1),
          (troop_set_slot, "trp_npc7", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc7", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc7", 0),
          (troop_set_note_available, "trp_npc7", 1),
        (else_try),
          (party_add_members,"p_main_party","trp_npc16",1),
          (party_add_members,"p_main_party","trp_npc5",1),
          (party_add_members,"p_main_party","trp_npc6",1),
          (party_add_members,"p_main_party","trp_npc10",1),
          (troop_set_slot, "trp_npc10", slot_troop_met, 1),
          (troop_set_slot, "trp_npc10", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc10", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc10", 0),
          (troop_set_note_available, "trp_npc10", 1),
          (troop_set_slot, "trp_npc6", slot_troop_met, 1),
          (troop_set_slot, "trp_npc6", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc6", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc6", 0),
          (troop_set_note_available, "trp_npc6", 1),
          (troop_set_slot, "trp_npc5", slot_troop_met, 1),
          (troop_set_slot, "trp_npc5", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc5", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc5", 0),
          (troop_set_note_available, "trp_npc1", 1),
          (troop_set_slot, "trp_npc16", slot_troop_met, 1),
          (troop_set_slot, "trp_npc16", slot_troop_occupation, slto_player_companion),
          (troop_set_slot, "trp_npc16", slot_troop_cur_center, -1),
          (troop_set_auto_equip, "trp_npc16", 0),
          (troop_set_note_available, "trp_npc16", 1),
        (try_end),
        (try_for_range, ":unused", 0, 7),
          (add_xp_to_troop, 19000, "trp_player"),
        (try_end),
        (troop_get_slot, reg0, ":old_leader", slot_troop_leaded_party),
        (party_get_attached_to, ":center", reg0),
        (assign, "$g_player_court", ":center"),
        (assign, "$g_player_minister", "trp_temporary_minister"),
        (troop_set_faction, "trp_temporary_minister", "fac_player_supporters_faction"),
        
        (party_get_position, pos0, ":center"),
        (call_script, "script_recurse_party_around_pos0", "p_main_party", 3, 0),
        (call_script, "script_update_all_notes"),
      (try_end),
      
      (try_begin),
        (eq, "$campaign_type", camp_kingc),
        # (assign, "$auto_menu", "mnu_minister_confirm"),  not working
        (jump_to_menu, "mnu_minister_confirm"),
        # (jump_to_menu, "mnu_auto_return"),
        (start_presentation, "prsnt_banner_selection"),
      (else_try),
        (this_or_next|eq, "$campaign_type", camp_lordc),
        (eq, "$background_type", cb_noble),
        (jump_to_menu, "mnu_auto_return"),
        (start_presentation, "prsnt_banner_selection"),
      (else_try),
        (change_screen_return, 0),
      (try_end),
      
      #spawn looters here now that campaign type is set
      #generally copied from script_spawn_bandits
      (call_script, "script_update_party_creation_random_limits"),
      
      #load with lairs
      (try_for_range, ":bandit_spawn_point", laired_spawn_points_begin, laired_spawn_points_end),
        (call_script, "script_spawn_lairs", ":bandit_spawn_point"),
      (try_end),
      
      #put a bandit by each lair
      (call_script, "script_spawn_bandits"),
      
      #overload with looters (easy parties to beat at start
      (options_get_campaign_ai, ":ai"),
      (try_begin),
        (neq, "$campaign_type", camp_kingc),
        (neq, "$campaign_type", camp_lordc),
        (try_begin),
          (eq, ":ai", 0), #difficult
          (set_party_creation_random_limits, 0,  4),  #for some reason, larger parties are created
        (else_try),
          (eq, ":ai", 1), #normal
          (set_party_creation_random_limits, 0,  2),
        (else_try), #easy
          (set_party_creation_random_limits, 0,  1),
        (try_end),
      (try_end),
      
      #as parties get larger, make fewer of them
      (assign, reg0, "$spawn_party_max_size"),
      (val_min, reg0, phase_out),
      (store_sub, ":proportion", phase_out, reg0),
      
      (try_begin),
        (eq, "$bandit_quantity_option", 0),  #less
        (val_mul, ":proportion", 2),
        (val_div, ":proportion", 3),
      (else_try),
        (eq, "$bandit_quantity_option", 2),  #more
        (val_mul, ":proportion", 3),
        (val_div, ":proportion", 2),
      (try_end),
      
      (store_mul, ":party_max", 90, ":proportion"),  #every 2nd of 3 villages
      (val_div, ":party_max", phase_out),
      (val_add, ":party_max", 10),  #allow two per every land mass on map
      
      (set_spawn_radius, 10),
      (store_num_parties_of_template, ":num_parties", "pt_looters"),
      (store_sub, ":num_new_parties", ":party_max", ":num_parties"),
      (try_for_range, ":unused", 0, ":num_new_parties"),
        (store_random_in_range,":spawn_point",villages_begin,villages_end),
        (spawn_around_party,":spawn_point","pt_looters"),
        (party_set_slot, reg0, slot_party_spawn_point, ":spawn_point"),
        (party_set_ai_behavior, reg0, ai_bhvr_patrol_party),
        (party_set_ai_object, reg0, ":spawn_point"),
        (call_script, "script_update_party_icon", reg0),
      (try_end),
      
      (store_div, ":min", "$spawn_party_max_size", 5),
      (set_party_creation_random_limits, ":min", "$spawn_party_max_size"),
      (set_show_messages, 1),
    ],
    
    [
      
      ("go_back",[],"Go back",
        [
          (jump_to_menu,"mnu_start_game_0"),
      ]),
    ]
  ),
  
  
  (
    "past_life_explanation",mnf_disable_all_keys,
    "{!}{s3}",
    "none",
    [
      (try_begin),
        (gt,"$current_string_reg",14),
        (assign,"$current_string_reg",10),
      (try_end),
      (str_store_string_reg,s3,"$current_string_reg"),
      (try_begin),
        (ge,"$current_string_reg",14),
        (str_store_string,s5,"@Back to the beginning..."),
      (else_try),
        (str_store_string,s5,"@View next segment..."),
      (try_end),
    ],
    [
      ("view_next",[],"{!}{s5}",[
          (val_add,"$current_string_reg",1),
          (jump_to_menu, "mnu_past_life_explanation"),
      ]),
      ("continue",[],"Continue...",
        [
      ]),
      ("go_back_dot",[],"Go back.",[
          #  (jump_to_menu, "mnu_choose_skill"),
      ]),
    ]
  ),
  
  (
    "auto_return",0,
    "{!}This menu automatically returns to caller.",
    "none",
    [(change_screen_return, 0)],
    [
    ]
  ),
  
  # ("morale_report",0,    #modified motomataru chief
    # "{!}{s1}",
    # "none",
    # [
      # (call_script, "script_get_player_party_morale_values"),
      # #(party_set_morale, "p_main_party", reg0),
      # (assign, reg6, 50),
      # (assign, ":sum_modifiers", reg6),
      
      # (assign, reg1, "$g_player_party_morale_modifier_party_size"),
      # (try_begin),
        # (gt, reg1, 0),
        # (str_store_string, s2, "@{!} -"),
      # (else_try),
        # (str_store_string, s2, "str_space"),
      # (try_end),
      # (val_sub, ":sum_modifiers", reg1),
      
      # # (assign, reg2, "$g_player_party_morale_modifier_leadership"),    included in party size modifier now
      # # (try_begin),
      # # (gt, reg2, 0),
      # # (str_store_string, s3, "@{!} +"),
      # # (else_try),
      # # (str_store_string, s3, "str_space"),
      # # (try_end),
      
      # (assign, reg2, "$g_player_party_morale_modifier_weariness"),
      # (try_begin),
        # (gt, reg2, 0),
        # (str_store_string, s3, "@{!} -"),
      # (else_try),
        # (str_store_string, s3, "str_space"),
      # (try_end),
      # (val_sub, ":sum_modifiers", reg2),
      
      # (try_begin),
        # (gt, "$g_player_party_morale_modifier_no_food", 0),
        # (assign, reg7, "$g_player_party_morale_modifier_no_food"),
        # (str_store_string, s5, "@^No food:  -{reg7}"),
        # (val_sub, ":sum_modifiers", reg7),
      # (else_try),
        # (str_store_string, s5, "str_space"),
      # (try_end),
      
      # (assign, reg3, "$g_player_party_morale_modifier_food"),
      # (try_begin),
        # (gt, reg3, 0),
        # (str_store_string, s4, "@{!} +"),
      # (else_try),
        # (str_store_string, s4, "str_space"),
      # (try_end),
      # (val_add, ":sum_modifiers", reg3),
      
      # (try_begin),
        # (gt, "$g_player_party_morale_modifier_debt", 0),
        # (assign, reg7, "$g_player_party_morale_modifier_debt"),
        # (str_store_string, s6, "@^Wage debt:  -{reg7}"),
        # (val_sub, ":sum_modifiers", reg7),
      # (else_try),
        # (str_store_string, s6, "str_space"),
      # (try_end),
      
      # (party_get_morale, reg5, "p_main_party"),
      # (store_sub, reg4, reg5, ":sum_modifiers"),
      # (try_begin),
        # (gt, reg4, 0),
        # (str_store_string, s7, "@{!} +"),
      # (else_try),
        # (str_store_string, s7, "str_space"),
      # (try_end),
      # #religion opuesta tropas chief
      # (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
      # (try_for_range, ":i_stack", 0, ":num_stacks"),
        # (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
        # (str_store_troop_name,s12,":stack_troop"),
        # (try_begin),
          # (eq, "$g_player_faith", 2), #player es pagano, problemas con tropas cristianas
          # (this_or_next|is_between, ":stack_troop", christian_troops_begin, christian_troops_end),
          # (this_or_next|is_between, ":stack_troop", christian_troops2_begin, christian_troops2_end),
          # (this_or_next|is_between, ":stack_troop", christian_troops3_begin, christian_troops3_end),
          # (is_between, ":stack_troop", christian_troops4_begin, christian_troops4_end),
          # (str_store_string, s11, "@{s11} {s12},"),
          # (str_store_string, s13, "@These Christian troops could cause some problems with party morale: {s11}"),
        # (else_try),
          # (eq, "$g_player_faith", 1), #player es cristiano
          # (this_or_next|is_between, ":stack_troop", pagan_troops_begin, pagan_troops_end),
          # (this_or_next|is_between, ":stack_troop", pagan_troops2_begin, pagan_troops2_end),
          # (is_between, ":stack_troop", pagan_troops3_begin, pagan_troops3_end),
          # (str_store_string, s11, "@{s11} {s12},"),
          # (str_store_string, s13, "@These pagan troops could cause some problems with party morale: {s11}"),
        # (else_try),
          # (str_store_string, s11, "str_space"),
        # (try_end),
      # (try_end),
      # #religion chief acaba
      
      # (str_store_string, s1, "@Current party morale is {reg5}.^Current party morale modifiers are:^^Base morale:  +{reg6}^Party size penalty: {s2}{reg1}^Lack of rest: {s3}{reg2}^Food variety: {s4}{reg3}{s5}{s6}^Recent events: {s7}{reg4}^" +
      # "{s13}^^TOTAL:  {reg5}^^^"),
      
      # (try_for_range, ":kingdom_no", npc_kingdoms_begin, npc_kingdoms_end),
        # (faction_get_slot, ":faction_morale", ":kingdom_no",  slot_faction_morale_of_player_troops),
        # (val_div, ":faction_morale", 100),
        # (neq, ":faction_morale", 0),
        # (assign, reg6, ":faction_morale"),
        # (str_store_faction_name, s9, ":kingdom_no"),
        # (str_store_string, s1, "str_s1extra_morale_for_s9_troops__reg6_"),
      # (try_end),
    # ],
    # [
      # ("continue_rep",[],"Continue...",
        # [
          # (jump_to_menu, "mnu_reports"),
      # ]),
    # ]
  # ),
  #menu moral motomataru chief acaba
  
  
  # ("courtship_relations",0,
    # "{!}{s1}",
    # "none",
    # [	(str_clear, s1),
      
      # (str_store_string, s1, "str_courtships_in_progress_"),
      # (try_for_range, ":lady", kingdom_ladies_begin, kingdom_ladies_end),
        # (troop_slot_eq, ":lady", slot_troop_met, 2),
        # (call_script, "script_troop_get_relation_with_troop", "trp_player", ":lady"),
        # (gt, reg0, 0),
        # (assign, reg3, reg0),
        
        # (str_store_troop_name, s2, ":lady"),
        
        # (store_current_hours, ":hours_since_last_visit"),
        # (troop_get_slot, ":last_visit_hour", ":lady", slot_troop_last_talk_time),
        # (val_sub, ":hours_since_last_visit", ":last_visit_hour"),
        # (store_div, ":days_since_last_visit", ":hours_since_last_visit", 24),
        # (assign, reg4, ":days_since_last_visit"),
        
        # (str_store_string, s1, "str_s1_s2_relation_reg3_last_visit_reg4_days_ago"),
      # (try_end),
      
      # (str_store_string, s1, "str_s1__poems_known"),
      # (try_begin),
        # (gt, "$allegoric_poem_recitations", 0),
        # (str_store_string, s1, "str_s1_storming_the_castle_of_love_allegoric"),
      # (try_end),
      # (try_begin),
        # (gt, "$tragic_poem_recitations", 0),
        # (str_store_string, s1, "str_s1_kais_and_layali_tragic"),
      # (try_end),
      # (try_begin),
        # (gt, "$comic_poem_recitations", 0),
        # (str_store_string, s1, "str_s1_a_conversation_in_the_garden_comic"),
      # (try_end),
      # (try_begin),
        # (gt, "$heroic_poem_recitations", 0),
        # (str_store_string, s1, "str_s1_helgered_and_kara_epic"),
      # (try_end),
      # (try_begin),
        # (gt, "$mystic_poem_recitations", 0),
        # (str_store_string, s1, "str_s1_a_hearts_desire_mystic"),
      # (try_end),
      
    # ],
    # [
      # ("continue",[],"Continue...",
        # [(jump_to_menu, "mnu_reports"),
        # ]
      # ),
    # ]
  # ),
  
  
  # ("lord_relations",0,
    # "{!}{s1}",
    # "none",
    # [
      # (str_clear, s1),
      # (try_for_range, ":active_npc", active_npcs_begin, active_npcs_end),
        # (troop_set_slot, ":active_npc", slot_troop_temp_slot, 0),
      # (try_end),
      
      # (str_clear, s1),
      # (try_for_range, ":unused", active_npcs_begin, active_npcs_end),
        # (assign, ":score_to_beat", -100),
        # (assign, ":best_relation_remaining_npc", -1),
        # (try_for_range, ":active_npc", active_npcs_begin, active_npcs_end),
          # (troop_slot_eq, ":active_npc", slot_troop_temp_slot, 0),
          # (troop_slot_eq, ":active_npc", slot_troop_occupation, slto_kingdom_hero),
          # (troop_slot_ge, ":active_npc", slot_troop_met, 1),
          
          # (call_script, "script_troop_get_player_relation", ":active_npc"),
          # (assign, ":relation_with_player", reg0),
          # (ge, ":relation_with_player", ":score_to_beat"),
          
          # (assign, ":score_to_beat", ":relation_with_player"),
          # (assign, ":best_relation_remaining_npc", ":active_npc"),
        # (try_end),
        # (gt, ":best_relation_remaining_npc", -1),
        
        # (str_store_troop_name_link, s4, ":best_relation_remaining_npc"),
        # (assign, reg4, ":score_to_beat"),
        # (str_store_string, s1, "@{!}{s4}: {reg4}"),
        # (troop_set_slot, ":best_relation_remaining_npc", slot_troop_temp_slot, 1),
      # (try_end),
      
      
    # ],
    # [
      # ("continue",[],"Continue...",
        # [(jump_to_menu, "mnu_reports"),
        # ]
      # ),
    # ]
  # ),
  
  # ("companion_report",0,
    # "{s7}{s1}",
    # "none",
    # [
      # (str_clear, s1),
      # (str_clear, s7),
      # (str_store_string, s7, "str_no_companions_in_service"),
      
      # (try_begin),
        # (troop_get_slot, ":spouse_or_betrothed", "trp_player", slot_troop_spouse),
        # (try_begin),
          # (troop_get_type, ":is_female", "trp_player"),
          # (val_mod, ":is_female", 2),
          # (eq, ":is_female", 1),
          # (str_store_string, s8, "str_husband"),
        # (else_try),
          # (str_store_string, s8, "str_wife"),
        # (try_end),
        
        # (try_begin),
          # (le, ":spouse_or_betrothed", 0),
          # (troop_get_slot, ":spouse_or_betrothed", "trp_player", slot_troop_betrothed),
          # (str_store_string, s8, "str_betrothed"),
        # (try_end),
        # (gt, ":spouse_or_betrothed", 0),
        
        # (str_store_troop_name, s4, ":spouse_or_betrothed"),
        # (troop_get_slot, ":cur_center", ":spouse_or_betrothed", slot_troop_cur_center),
        # (try_begin),
          # (is_between, ":cur_center", centers_begin, centers_end),
          # (str_store_party_name, s5, ":cur_center"),
        # (else_try),
          # (troop_slot_eq, ":spouse_or_betrothed", slot_troop_occupation, slto_kingdom_hero),
          # (str_store_string, s5, "str_leading_party"),
        # (else_try),
          # (str_store_string, s5, "str_whereabouts_unknown"),
        # (try_end),
        # (str_store_string, s3, "str_s4_s8_s5"),
        # (str_store_string, s2, s1),
        # (str_store_string, s1, "str_s2_s3"),
        
      # (try_end),
      
      
      # (try_begin),
        # (ge, "$cheat_mode", 1),
        # (ge, "$npc_to_rejoin_party", 0),
        # (str_store_troop_name, s5, "$npc_to_rejoin_party"),
        # (str_store_string, s1, "@{!}DEBUG -- {s1}^NPC in rejoin queue: {s5}^"),
      # (try_end),
      
      
      # (try_for_range, ":companion", companions_begin, companions_end),
        # (str_clear, s2),
        # (str_clear, s3),
        
        # (try_begin),
          # (troop_get_slot, ":days_left", ":companion", slot_troop_days_on_mission),
          
          # (troop_slot_eq, ":companion", slot_troop_occupation, slto_player_companion),
          
          
          # (str_store_troop_name, s4, ":companion"),
          
          # (try_begin),
            # (troop_slot_eq, ":companion", slot_troop_current_mission, npc_mission_kingsupport),
            # (str_store_string, s8, "str_gathering_support"),
            # (try_begin),
              # (eq, ":days_left", 1),
              # (str_store_string, s5, "str_expected_back_imminently"),
            # (else_try),
              # (assign, reg3, ":days_left"),
              # (str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
            # (try_end),
          # (else_try),
            # (troop_slot_eq, ":companion", slot_troop_current_mission, npc_mission_gather_intel),
            # (troop_get_slot, ":town_with_contacts", ":companion", slot_troop_town_with_contacts),
            # (str_store_party_name, s11, ":town_with_contacts"),
            
            # (str_store_string, s8, "str_gathering_intelligence"),
            # (try_begin),
              # (eq, ":days_left", 1),
              # (str_store_string, s5, "str_expected_back_imminently"),
            # (else_try),
              # (assign, reg3, ":days_left"),
              # (str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
            # (try_end),
          # (else_try),
            # (troop_slot_eq, ":companion", slot_troop_current_mission, npc_mission_improve_relations),
            # (troop_get_slot, ":mission_object", ":companion", slot_troop_mission_object),
            # (str_store_party_name, s44, ":mission_object"),
            # (try_begin),
              # (neg|troop_slot_ge, ":companion", slot_troop_prisoner_of_party, 0),
              # (str_store_string, s8, "@Trying to improve your relations with {s44}"),
              # (try_begin),
                # (eq, ":days_left", 1),
                # (str_store_string, s5, "str_expected_back_imminently"),
              # (else_try),
                # (assign, reg3, ":days_left"),
                # (str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
              # (try_end),
            # (else_try),
              # (str_store_string, s8, "@Is imprisoned in the dungeon of {s44}"),
            # (try_end),
          # (else_try),	#This covers most diplomatic missions
            
            # (troop_slot_ge, ":companion", slot_troop_current_mission, npc_mission_peace_request),
            # (neg|troop_slot_ge, ":companion", slot_troop_current_mission, 8),
            
            # (troop_get_slot, ":faction", ":companion", slot_troop_mission_object),
            # (str_store_faction_name, s9, ":faction"),
            # (str_store_string, s8, "str_diplomatic_embassy_to_s9"),
            # (try_begin),
              # (eq, ":days_left", 1),
              # (str_store_string, s5, "str_expected_back_imminently"),
            # (else_try),
              # (assign, reg3, ":days_left"),
              # (str_store_string, s5, "str_expected_back_in_approximately_reg3_days"),
            # (try_end),
          # (else_try),
            # (eq, ":companion", "$g_player_minister"),
            # (str_store_string, s8, "str_serving_as_minister"),
            # (try_begin),
              # (is_between, "$g_player_court", centers_begin, centers_end),
              # (str_store_party_name, s9, "$g_player_court"),
              # (str_store_string, s5, "str_in_your_court_at_s9"),
            # (else_try),
              # (str_store_string, s5, "str_whereabouts_unknown"),
            # (try_end),
          # (else_try),
            # (main_party_has_troop, ":companion"),
            # (str_store_string, s8, "str_under_arms"),
            # (str_store_string, s5, "str_in_your_party"),
          # (else_try),
            # (troop_slot_eq, ":companion", slot_troop_current_mission, npc_mission_rejoin_when_possible),
            # (str_store_string, s8, "str_attempting_to_rejoin_party"),
            # (str_store_string, s5, "str_whereabouts_unknown"),
          # (else_try),	#Companions who are in a center
            # (troop_slot_ge, ":companion", slot_troop_cur_center, 1),
            # (str_store_string, s8, "str_separated_from_party"),
            # (str_store_string, s5, "str_whereabouts_unknown"),
          # (else_try), #Excludes companions who have occupation = retirement
            # (try_begin),
              # (check_quest_active, "qst_lend_companion"),
              # (quest_slot_eq, "qst_lend_companion", slot_quest_target_troop, ":companion"),
              # (str_store_string, s8, "@On loan,"),
            # (else_try),
              # (check_quest_active, "qst_lend_surgeon"),
              # (quest_slot_eq, "qst_lend_surgeon", slot_quest_target_troop, ":companion"),
              # (str_store_string, s8, "@On loan,"),
            # (else_try),
              # (troop_set_slot, ":companion", slot_troop_current_mission, npc_mission_rejoin_when_possible),
              # (str_store_string, s8, "str_attempting_to_rejoin_party"),
            # (try_end),
            
            # (str_store_string, s5, "str_whereabouts_unknown"),
            # (try_begin),
              # (ge, "$cheat_mode", 1),
              # (troop_get_slot, reg2, ":companion", slot_troop_current_mission),
              # (troop_get_slot, reg3, ":companion", slot_troop_days_on_mission),
              # (troop_get_slot, reg4, ":companion", slot_troop_prisoner_of_party),
              # (troop_get_slot, reg4, ":companion", slot_troop_playerparty_history),
              
              # (display_message, "@{!}DEBUG: {s4} current mission: {reg2}, days on mission: {reg3}, prisoner: {reg4}, pphistory: {reg5}"),
            # (try_end),
          # (try_end),
          
          # (str_store_string, s3, "str_s4_s8_s5"),
          
          # (str_store_string, s2, s1),
          # (str_store_string, s1, "str_s2_s3"),
          
          # (str_clear, s7), #"no companions in service"
        # (else_try),
          # (neg|troop_slot_eq, ":companion", slot_troop_occupation, slto_kingdom_hero),
          # (troop_slot_ge, ":companion", slot_troop_prisoner_of_party, centers_begin),
          
          # (str_store_troop_name, s4, ":companion"),
          # (str_store_string, s8, "str_missing_after_battle"),
          # (str_store_string, s5, "str_whereabouts_unknown"),
          
          # (str_store_string, s3, "str_s4_s8_s5"),
          # (str_store_string, s2, s1),
          # (str_store_string, s1, "str_s2_s3"),
          # (str_clear, s7), #"no companions in service"
          
        # (try_end),
        
      # (try_end),
      
      
    # ],
    # [
      # ("continue",[],"Continue...",
        # [(jump_to_menu, "mnu_reports"),
        # ]
      # ),
    # ]
  # ),
  
  ("faction_orders",0,
    "{!}{s9}",
    "none",
    [
      (str_clear, s9),
      (store_current_hours, ":cur_hours"),
      (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end),
        (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active),
        (neq, ":faction_no", "fac_player_supporters_faction"),
        
        (faction_get_slot, ":old_faction_ai_state", ":faction_no", slot_faction_ai_state),
        
        (try_begin),
          (faction_get_slot, ":faction_marshal", ":faction_no", slot_faction_marshal),
          (gt, ":faction_marshal", -1),
          (assign, ":faction_ai_decider", ":faction_marshal"),
        (else_try),
          (faction_get_slot, ":faction_ai_decider", ":faction_no", slot_faction_leader),
        (try_end),
        
        
        #(*1) these two lines moved to here from (*2)
        (call_script, "script_npc_decision_checklist_faction_ai_alt", ":faction_ai_decider"),
        (assign, ":new_strategy", reg0),
        (str_store_string, s26, s14),
        
        #(3*) these three lines moved to here from (*4)
        (faction_get_slot, ":faction_ai_state", ":faction_no", slot_faction_ai_state),
        (faction_get_slot, ":faction_ai_object", ":faction_no", slot_faction_ai_object),
        (faction_get_slot, ":faction_marshal", ":faction_no", slot_faction_marshal),
        
        (faction_get_slot, ":faction_ai_offensive_max_followers", ":faction_no", slot_faction_ai_offensive_max_followers),
        (str_store_faction_name, s10, ":faction_no"),
        
        (try_begin),
          (faction_get_slot, ":faction_issue", ":faction_no", slot_faction_political_issue),
          
          (try_begin),
            (eq, ":faction_issue", 1),
            (str_store_string, s11, "@Appoint next marshal"),
          (else_try),
            (is_between, ":faction_issue", centers_begin, centers_end),
            (str_store_party_name, s12, ":faction_issue"),
            (str_store_string, s11, "@Award {s12} as fief"),
          (else_try),
            (eq, ":faction_issue", 0),
            (str_store_string, s11, "str_none"),
          (else_try),
            (eq, ":faction_issue", -1),
            (str_store_string, s11, "str_no"),
          (else_try),
            (assign, reg3, ":faction_issue"),
            (str_store_string, s11, "@{!}Error ({reg3})"),
          (try_end),
          
          (store_current_hours, reg4),
          (faction_get_slot, ":faction_issue_put_on_agenda", ":faction_no", slot_faction_political_issue_time),
          (val_sub, reg4, ":faction_issue_put_on_agenda"),
          
          (str_store_string, s10, "@{!}{s10}^Faction political issue: {s11}"),
          (try_begin),
            (faction_slot_ge, ":faction_no", slot_faction_political_issue, 1),
            (str_store_string, s10, "@{!}{s10} (on agenda {reg4} hours)"),
          (try_end),
        (try_end),
        
        
        (assign, reg2, ":faction_ai_offensive_max_followers"),
        (try_begin),
          (eq, ":faction_ai_state", sfai_default),
          (str_store_string, s11, "@{!}Defending"),
        (else_try),
          (eq, ":faction_ai_state", sfai_gathering_army),
          (str_store_string, s11, "@{!}Gathering army"),
        (else_try),
          (eq, ":faction_ai_state", sfai_attacking_center),
          (str_store_party_name, s11, ":faction_ai_object"),
          (str_store_string, s11, "@{!}Besieging {s11}"),
        (else_try),
          (eq, ":faction_ai_state", sfai_raiding_village),
          (str_store_party_name, s11, ":faction_ai_object"),
          (str_store_string, s11, "@{!}Raiding {s11}"),
        (else_try),
          (eq, ":faction_ai_state", sfai_attacking_enemy_army),
          (str_store_party_name, s11, ":faction_ai_object"),
          (str_store_string, s11, "str_attacking_enemy_army_near_s11"),
        (else_try),
          (eq, ":faction_ai_state", sfai_feast),
          (str_store_party_name, s11, ":faction_ai_object"),
          (str_store_string, s11, "str_holding_feast_at_s11"),
        (else_try),
          (eq, ":faction_ai_state", sfai_attacking_enemies_around_center),
          (str_store_party_name, s11, ":faction_ai_object"),
          (str_store_string, s11, "@{!}Attacking enemies around {s11}"),
        (else_try),
          (assign, reg4, ":faction_ai_state"),
          (str_store_string, s11, "str_sfai_reg4"),
        (try_end),
        
        (try_begin),
          (lt, ":faction_marshal", 0),
          (str_store_string, s12, "str_noone"),
        (else_try),
          (str_store_troop_name, s12, ":faction_marshal"),
          (troop_get_slot, reg21, ":faction_marshal", slot_troop_controversy),
          (str_store_string, s12, "@{!}{s12} (controversy: {reg21})"),
        (try_end),
        
        (try_for_parties, ":screen_party"),
          #MOTO chief use substate to represent screening properly
          # (party_slot_eq, ":screen_party", slot_party_ai_state, spai_screening_army),
          (party_slot_eq, ":screen_party", slot_party_ai_state, spai_accompanying_army),
          (party_slot_eq, ":screen_party", slot_party_ai_substate, 1),
          #MOTO end use substate to represent screening properly
          (store_faction_of_party, ":screen_party_faction", ":screen_party"),
          (eq, ":screen_party_faction", ":faction_no"),
          
          (str_store_party_name, s38, ":screen_party"),
          (str_store_string, s12, "@{!}{s12}^Screening party: {s38}"),
        (try_end),
        
        #(*2) these two lines moved to up (look *1)
        #(call_script, "script_npc_decision_checklist_faction_ai", ":faction_no"),
        #(assign, ":new_strategy", reg0),
        
        #(try_begin),
        #  (this_or_next|eq, ":new_strategy", sfai_default),
        #  (eq, ":new_strategy", sfai_feast),
        #
        #  (store_current_hours, ":hours"),
        #  (faction_set_slot, ":faction_no", slot_faction_ai_last_rest_time, ":hours"),
        #(try_end),
        (try_begin),
          #new condition to rest, (a faction's new strategy should be feast or default) and (":hours_at_current_state" > 20)
          (this_or_next|eq, ":new_strategy", sfai_default),
          (eq, ":new_strategy", sfai_feast),
          
          (store_current_hours, ":hours_at_current_state"),
          (faction_get_slot, ":current_state_started", ":faction_no", slot_faction_ai_current_state_started),
          (val_sub, ":hours_at_current_state", ":current_state_started"),
          (ge, ":hours_at_current_state", 18),
          
          (store_current_hours, ":hours"),
          (faction_set_slot, ":faction_no", slot_faction_ai_last_rest_time, ":hours"),
        (try_end),
        
        #Change of strategy
        (try_begin),
          (neq, ":new_strategy", ":old_faction_ai_state"),
          
          (store_current_hours, ":hours"),
          (faction_set_slot, ":faction_no", slot_faction_ai_current_state_started, ":hours"),
        (try_end),
        
        (call_script, "script_evaluate_realm_stability", ":faction_no"),
        (assign, ":disgruntled_lords", reg0),
        (assign, ":restless_lords", reg1),
        
        (faction_get_slot, ":last_feast_ended", ":faction_no", slot_faction_last_feast_start_time),
        (store_sub, ":hours_since_last_feast", ":cur_hours", ":last_feast_ended"),
        (val_sub, ":hours_since_last_feast", 72),
        
        (faction_get_slot, ":current_state_started", ":faction_no", slot_faction_ai_current_state_started),
        (store_sub, ":hours_at_current_state", ":cur_hours", ":current_state_started"),
        
        (faction_get_slot, ":faction_ai_last_offensive_time", ":faction_no", slot_faction_last_offensive_concluded),
        (store_sub, ":hours_since_last_offensive", ":cur_hours", ":faction_ai_last_offensive_time"),
        
        (faction_get_slot, ":faction_ai_last_rest", ":faction_no", slot_faction_ai_last_rest_time),
        (store_sub, ":hours_since_last_rest", ":cur_hours", ":faction_ai_last_rest"),
        
        (faction_get_slot, ":faction_ai_last_decisive_event", ":faction_no", slot_faction_ai_last_decisive_event),
        (store_sub, ":hours_since_last_decisive_event", ":cur_hours", ":faction_ai_last_decisive_event"),
        
        (assign, reg3, ":hours_at_current_state"),
        (assign, reg4, ":hours_since_last_offensive"),
        (assign, reg5, ":hours_since_last_feast"),
        
        (assign, reg7, ":disgruntled_lords"),
        (assign, reg8, ":restless_lords"),
        (assign, reg9, ":hours_since_last_rest"),
        (assign, reg10, ":hours_since_last_decisive_event"),
        (str_store_string, s14, s26),
        
        (str_store_string, s9, "str_s9s10_current_state_s11_hours_at_current_state_reg3_current_strategic_thinking_s14_marshal_s12_since_the_last_offensive_ended_reg4_hours_since_the_decisive_event_reg10_hours_since_the_last_rest_reg9_hours_since_the_last_feast_ended_reg5_hours_percent_disgruntled_lords_reg7_percent_restless_lords_reg8__"),
      (try_end),
      
      (try_begin),
        (neg|is_between, "$g_cheat_selected_faction", kingdoms_begin, kingdoms_end),
        (call_script, "script_get_next_active_kingdom", kingdoms_end),
        (assign, "$g_cheat_selected_faction", reg0),
      (try_end),
      (str_store_faction_name, s10, "$g_cheat_selected_faction"),
      (str_store_string, s9, "@Selected faction is: {s10}^^{s9}"),
    ],
    [
      ("faction_orders_next_faction", [],"{!}Select next faction.",
        [
          (call_script, "script_get_next_active_kingdom", "$g_cheat_selected_faction"),
          (assign, "$g_cheat_selected_faction", reg0),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      
      ("faction_orders_political_collapse", [],"{!}CHEAT - Cause all lords in faction to fall out with their liege.",
        [
          (try_for_range, ":lord", active_npcs_begin, active_npcs_end),
            (troop_slot_eq, ":lord", slot_troop_occupation, slto_kingdom_hero),
            (store_faction_of_troop, ":troop_faction", ":lord"),
            (eq, ":troop_faction", "$g_cheat_selected_faction"),
            (faction_get_slot, ":faction_liege", ":troop_faction", slot_faction_leader),
            (call_script, "script_troop_change_relation_with_troop", ":lord", ":faction_liege", -200),
          (try_end),
          
        ]
      ),
      
      ("faction_orders_defend", [],"{!}Force defend.",
        [
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_state, sfai_default),
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_object, -1),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      ("faction_orders_feast", [],"{!}Force feast.",
        [
          
          (assign, ":location_high_score", 0),
          (try_for_range, ":location", walled_centers_begin, walled_centers_end),
            (neg|party_slot_ge, ":location", slot_center_is_besieged_by, 1),
            (store_faction_of_party, ":location_faction", ":location"),
            (eq, ":location_faction", "$g_cheat_selected_faction"),
            (party_get_slot, ":location_lord", ":location", slot_town_lord),
            (troop_get_slot, ":location_score", ":location_lord", slot_troop_renown),
            (store_random_in_range, ":random", 0, 1000), #will probably be king or senior lord
            (val_add, ":location_score", ":random"),
            (gt, ":location_score", ":location_high_score"),
            (assign, ":location_high_score", ":location_score"),
            (assign, ":location_feast", ":location"),
          (try_end),
          
          (try_begin),
            (gt, ":location_feast", centers_begin),
            (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_state, sfai_feast),
            (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_object, ":location_feast"),
            (try_begin),
              (eq, "$g_player_eligible_feast_center_no", ":location_feast"),
              (assign, "$g_player_eligible_feast_center_no", -1),
            (try_end),
            
            (store_current_hours, ":hours"),
            (faction_set_slot, "$g_cheat_selected_faction", slot_faction_last_feast_start_time, ":hours"),
          (try_end),
          
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      
      
      ("faction_orders_gather", [],"{!}Force gather army.",
        [
          (store_current_hours, ":cur_hours"),
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_state, sfai_gathering_army),
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_last_offensive_concluded, ":cur_hours"),
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_offensive_max_followers, 1),
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_ai_object, -1),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      ("faction_orders_increase_time", [],"{!}Increase last offensive time by 24 hours.",
        [
          (faction_get_slot, ":faction_ai_last_offensive_time", "$g_cheat_selected_faction", slot_faction_last_offensive_concluded),
          (val_sub, ":faction_ai_last_offensive_time", 24),
          (faction_set_slot, "$g_cheat_selected_faction", slot_faction_last_offensive_concluded, ":faction_ai_last_offensive_time"),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      ("faction_orders_rethink", [],"{!}Force rethink.",
        [
          (call_script, "script_init_ai_calculation"),
          (call_script, "script_decide_faction_ai", "$g_cheat_selected_faction"),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      ("faction_orders_rethink_all", [],"{!}Force rethink for all factions.",
        [
          (assign, "$g_recalculate_ais", 0),
          (call_script, "script_init_ai_calculation"),
          
          (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end),
            (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active),
            #(neg|faction_slot_eq, ":faction_no",  slot_faction_marshal, "trp_player"),
            (call_script, "script_decide_faction_ai", ":faction_no"),
          (try_end),
          
          (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
            (store_troop_faction, ":faction_no", ":troop_no"),
            (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
            (call_script, "script_calculate_troop_ai", ":troop_no"),
          (try_end),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      
      ("enable_alt_ai",[(eq, "$g_use_alternative_ai", 2),],"{!}CHEAT! - enable alternative ai",
        [
          (assign, "$g_use_alternative_ai", 1),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      
      ("disable_alt_ai",[(eq, "$g_use_alternative_ai", 2)],"{!}CHEAT! - disable alternative ai",
        [
          (assign, "$g_use_alternative_ai", 0),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      
      ("faction_orders_init_econ", [],"{!}Initialize economic stats.",
        [
          (call_script, "script_initialize_economic_information"),
          (jump_to_menu, "mnu_faction_orders"),
        ]
      ),
      
      
      
      ("go_back_dot",[],"{!}Go back.",
        [(jump_to_menu, "mnu_reports"),
        ]
      ),
    ]
  ),
  
  
  ("character_report",0,
    "{!}{s9}",
    "none",
    [(try_begin),
        (gt, "$g_player_reading_book", 0),
        (player_has_item, "$g_player_reading_book"),
        (str_store_item_name, s8, "$g_player_reading_book"),
        (str_store_string, s9, "@You are currently reading {s8}."),
      (else_try),
        (assign, "$g_player_reading_book", 0),
        (str_store_string, s9, "@You are not reading any books."),
      (try_end),
      (assign, ":num_friends", 0),
      (assign, ":num_enemies", 0),
      (str_store_string, s6, "str_none"),
      (str_store_string, s8, "str_none"),
      (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
        (this_or_next|troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
        (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_inactive_pretender),
        (call_script, "script_troop_get_player_relation", ":troop_no"),
        (assign, ":player_relation", reg0),
        #(troop_get_slot, ":player_relation", ":troop_no", slot_troop_player_relation),
        (try_begin),
          (gt, ":player_relation", 20),
          (try_begin),
            (eq, ":num_friends", 0),
            (str_store_troop_name, s8, ":troop_no"),
          (else_try),
            (eq, ":num_friends", 1),
            (str_store_troop_name, s7, ":troop_no"),
            (str_store_string, s8, "@{s7} and {s8}"),
          (else_try),
            (str_store_troop_name, s7, ":troop_no"),
            (str_store_string, s8, "@{!}{s7}, {s8}"),
          (try_end),
          (val_add, ":num_friends", 1),
        (else_try),
          (lt, ":player_relation", -20),
          (try_begin),
            (eq, ":num_enemies", 0),
            (str_store_troop_name, s6, ":troop_no"),
          (else_try),
            (eq, ":num_enemies", 1),
            (str_store_troop_name, s5, ":troop_no"),
            (str_store_string, s6, "@{s5} and {s6}"),
          (else_try),
            (str_store_troop_name, s5, ":troop_no"),
            (str_store_string, s6, "@{!}{s5}, {s6}"),
          (try_end),
          (val_add, ":num_enemies", 1),
        (try_end),
      (try_end),
      
      #lord recruitment changes begin
      (str_clear, s12),
      (try_begin),
        (gt, "$player_right_to_rule", 0),
        (assign, reg12, "$player_right_to_rule"),
        (str_store_string, s12, "str__right_to_rule_reg12"),
      (try_end),
      
      (str_clear, s15),
      # (try_begin),
        # (this_or_next|gt, "$claim_arguments_made", 0),
        # (this_or_next|gt, "$ruler_arguments_made", 0),
        # (this_or_next|gt, "$victory_arguments_made", 0),
        # (this_or_next|gt, "$lords_arguments_made", 0),
        # (eq, 1, 0),
        
        # (assign, reg3, "$claim_arguments_made"),
        # (assign, reg4, "$ruler_arguments_made"),
        # (assign, reg5, "$victory_arguments_made"),
        # (assign, reg6, "$lords_arguments_made"),
        # (assign, reg7, "$benefit_arguments_made"),
        
        # (str_store_string, s15, "str_political_arguments_made_legality_reg3_rights_of_lords_reg4_unificationpeace_reg5_rights_of_commons_reg6_fief_pledges_reg7"),
      # (try_end),
      
      #lord recruitment changes begin
      
      (assign, reg3, "$player_honor"),
      (troop_get_slot, reg2, "trp_player", slot_troop_renown),
      
      (str_store_string, s9, "str_renown_reg2_honour_rating_reg3s12_friends_s8_enemies_s6_s9"),
      
      (call_script, "script_get_number_of_hero_centers", "trp_player"),
      (assign, ":no_centers", reg0),
      (try_begin),
        (gt, ":no_centers", 0),
        (try_for_range, ":i_center", 0, ":no_centers"),
          (call_script, "script_troop_get_leaded_center_with_index", "trp_player", ":i_center"),
          (assign, ":cur_center", reg0),
          (try_begin),
            (eq, ":i_center", 0),
            (str_store_party_name, s8, ":cur_center"),
          (else_try),
            (eq, ":i_center", 1),
            (str_store_party_name, s7, ":cur_center"),
            (str_store_string, s8, "@{s7} and {s8}"),
          (else_try),
            (str_store_party_name, s7, ":cur_center"),
            (str_store_string, s8, "@{!}{s7}, {s8}"),
          (try_end),
        (try_end),
        (str_store_string, s9, "@Your estates are: {s8}.^{s9}"),
      (try_end),
      (try_begin),
        (gt, "$players_kingdom", 0),
        
        (str_store_faction_name, s8, "$players_kingdom"),
        (try_begin),
          (this_or_next|is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
          (neg|faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
          #(str_store_string, s9, "@You are a lord of {s8}.^{s9}"),
          (str_store_string, s9, "str_you_are_a_lord_lady_of_s8_s9"),
        (else_try),
          (str_store_string, s9, "str_you_are_king_queen_of_s8_s9"),
        (try_end),
        
      (try_end),
    ],
    [
      
      #lord recruitment changes begin
      
      ("continue",[(eq,"$cheat_mode",1)],"{!}CHEAT! - increase Right to Rule",
        [
          (val_add, "$player_right_to_rule", 10),
          (jump_to_menu, "mnu_character_report"),
        ]
      ),
      
      
      ("continue",[(eq,"$cheat_mode",1),
          (str_store_troop_name, s14, "$g_talk_troop"),
        ],"{!}CHEAT! - increase your relation with {s14}",
        [
          (call_script, "script_change_player_relation_with_troop", "$g_talk_troop", 10),
          (jump_to_menu, "mnu_character_report"),
        ]
      ),
      
      
      ("continue",[(eq,"$cheat_mode",1)],"{!}CHEAT! - increase Reputation",
        [
          (val_add, "$player_honor", 10),
          (jump_to_menu, "mnu_character_report"),
        ]
      ),
      
      ("continue",[(eq,"$cheat_mode",1)],"{!}CHEAT! - increase renown",
        [
          (troop_get_slot, ":renown", "trp_player", slot_troop_renown),
          (val_add, ":renown", 50),
          (troop_set_slot, "trp_player", slot_troop_renown, ":renown"),
          
          (jump_to_menu, "mnu_character_report"),
        ]
      ),
      
      ("continue",[(eq,"$cheat_mode",1)],"{!}CHEAT! - increase persuasion",
        [
          (troop_raise_skill, "trp_player", "skl_persuasion", 1),
          
          (jump_to_menu, "mnu_character_report"),
        ]
      ),
      
      ("back",[],"Back.",
        [(jump_to_menu, "mnu_cheat_testing_cheats1"),
        ]
      ),
      
      #lord recruitment changes end
      
    ]
  ),
  
  # ("party_size_report", 0, "{!}{s1}", "none", [    #motomataru update 9/29/10 to use same numbers as the function that generates it
      # (call_script, "script_game_get_party_companion_limit"),
      # (try_begin),    #base
        # (gt, reg31, 0),
        # (str_store_string, s5, "@{!} +"),
      # (else_try),
        # (str_store_string, s5, "str_space"),
      # (try_end),
      # (try_begin),    #leadership
        # (gt, reg32, 0),
        # (str_store_string, s2, "@{!} +"),
      # (else_try),
        # (str_store_string, s2, "str_space"),
      # (try_end),
      # (try_begin),    #charisma
        # (gt, reg33, 0),
        # (str_store_string, s3, "@{!} +"),
      # (else_try),
        # (str_store_string, s3, "str_space"),
      # (try_end),
      # (try_begin),    #renown
        # (gt, reg34, 0),
        # (str_store_string, s4, "@{!} +"),
      # (else_try),
        # (str_store_string, s4, "str_space"),
      # (try_end),
      # (str_store_string, s1, "@Current party size limit is {reg0}.^Current party size modifiers are:^^Base size: {s5}{reg31}^Combined leadership: {s2}{reg32}^Charisma: {s3}{reg33}^Renown: {s4}{reg34}^TOTAL:  {reg0}"),
    # ],
    # [
      # ("continue",[],"Continue...",
        # [(jump_to_menu, "mnu_reports"),
        # ]
      # ),
    # ]
  # ),
  
  # ("faction_relations_report",0,
    # "{!}{s1}",
    # "none",
    # [(str_clear, s2),
      # (try_for_range, ":cur_kingdom", kingdoms_begin, kingdoms_end),
        # (faction_slot_eq, ":cur_kingdom", slot_faction_state, sfs_active),
        # (neq, ":cur_kingdom", "fac_player_supporters_faction"),
        # (store_relation, ":cur_relation", "fac_player_faction", ":cur_kingdom"),
        # (try_begin),
          # (ge, ":cur_relation", 90),
          # (str_store_string, s3, "@Loyal"),
        # (else_try),
          # (ge, ":cur_relation", 80),
          # (str_store_string, s3, "@Devoted"),
        # (else_try),
          # (ge, ":cur_relation", 70),
          # (str_store_string, s3, "@Fond"),
        # (else_try),
          # (ge, ":cur_relation", 60),
          # (str_store_string, s3, "@Gracious"),
        # (else_try),
          # (ge, ":cur_relation", 50),
          # (str_store_string, s3, "@Friendly"),
        # (else_try),
          # (ge, ":cur_relation", 40),
          # (str_store_string, s3, "@Supportive"),
        # (else_try),
          # (ge, ":cur_relation", 30),
          # (str_store_string, s3, "@Favorable"),
        # (else_try),
          # (ge, ":cur_relation", 20),
          # (str_store_string, s3, "@Cooperative"),
        # (else_try),
          # (ge, ":cur_relation", 10),
          # (str_store_string, s3, "@Accepting"),
        # (else_try),
          # (ge, ":cur_relation", 0),
          # (str_store_string, s3, "@Indifferent"),
        # (else_try),
          # (ge, ":cur_relation", -10),
          # (str_store_string, s3, "@Suspicious"),
        # (else_try),
          # (ge, ":cur_relation", -20),
          # (str_store_string, s3, "@Unhappy"),
        # (else_try),
          # (ge, ":cur_relation", -30),
          # (str_store_string, s3, "@Resentful"),
        # (else_try),
          # (ge, ":cur_relation", -40),
          # (str_store_string, s3, "@Angry"),
        # (else_try),
          # (ge, ":cur_relation", -50),
          # (str_store_string, s3, "@Hostile"),
        # (else_try),
          # (ge, ":cur_relation", -60),
          # (str_store_string, s3, "@Hateful"),
        # (else_try),
          # (ge, ":cur_relation", -70),
          # (str_store_string, s3, "@Vengeful"),
        # (else_try),
          # (str_store_string, s3, "@Sworn Enmity"),
        # (try_end),
        # (str_store_faction_name, s4, ":cur_kingdom"),
        # (assign, reg1, ":cur_relation"),
        # (str_store_string, s2, "@{!}{s2}^{s4}: {reg1} ({s3})"),
      # (try_end),
      # (str_store_string, s1, "@Your relations with the kingdoms are:^{s2}"),
      
      
      
    # ],
    # [
      # ("continue",[],"Continue...",
        # [(jump_to_menu, "mnu_reports"),
        # ]
      # ),
    # ]
  # ),
  
  
  ("camp",0,
    "You set up camp. What do you want to do?",
    "none",
    [(set_background_mesh, "mesh_pic_camp"),
      ##    # Phaiak begin
      ##	(try_begin),
      ##	  (party_get_current_terrain, ":cur_terrain", "p_main_party"),
      ##	  (this_or_next|eq,":cur_terrain",rt_water),
      ##      (this_or_next|eq,":cur_terrain",rt_bridge),
      ##      (eq,":cur_terrain",rt_river),
      ##	  (jump_to_menu, "mnu_camp_on_sea"),
      ##	(else_try),
      ##	  (assign, "$g_player_icon_state", pis_normal),	#native
      ##      (set_background_mesh, "mesh_pic_camp"),		#native
      ##	(end_try),
      ##	# Phaiak end
      
      (try_begin),
        (eq,"$temp",6), #waiting, building, exit
        (assign,"$temp",0), #waiting, building, exit
        (change_screen_return),
      (try_end),
      
      (try_begin),
        (party_get_current_terrain, ":cur_terrain", "p_main_party"),
        (this_or_next|eq,":cur_terrain",rt_water),
        (this_or_next|eq,":cur_terrain",rt_bridge),
        (eq,":cur_terrain",rt_river),
        #(eq,"$temp",0), #waiting, building, exit	#out commented to fix VC-2245
        (start_presentation,"prsnt_camp_screen_sea"),
      (else_try),
        #  (eq,"$temp",0), #waiting, building, exit
        # (assign, "$g_player_icon_state", pis_normal),	#native
        (start_presentation,"prsnt_camp_screen_main"),
        #phaiak begin fixing wrong icon while camping on sea
        (party_slot_eq, "p_main_party", slot_party_on_water, 0),
        (assign, "$g_player_icon_state", pis_normal),
      (try_end),
      
      
      
    ],
    [
      
      ##	   ("wounds",	#Phaiak for testing...
      ##	   [
      ##		  (this_or_next|quest_slot_ge, "qst_vc_wounds", slot_quest_int_penalty_left_days, 1),
      ##		  (this_or_next|quest_slot_ge, "qst_vc_wounds", slot_quest_cha_penalty_left_days, 1),
      ##		  (this_or_next|quest_slot_ge, "qst_vc_wounds", slot_quest_str_penalty_left_days, 1),
      ##		  (				quest_slot_ge, "qst_vc_wounds", slot_quest_agi_penalty_left_days, 1),
      ##	   ],"Take a look at your heavy wounds.",
      ##       [
      ##          (jump_to_menu, "mnu_wound_report"),
      ##        ]
      ##       ),
      
      ("camp_action",[],"Take an action.",
        [(jump_to_menu, "mnu_camp_action"),
        ]
      ),
      
      ("camp_wait_here",[],"Wait here for some time.",
        [
          (assign,"$g_camp_mode", 1),
          (assign, "$g_infinite_camping", 0),
          (assign, "$g_player_icon_state", pis_camping),
          
          (try_begin),
            (party_is_active, "p_main_party"),
            (party_get_current_terrain, ":cur_terrain", "p_main_party"),
            (try_begin),
              (eq, ":cur_terrain", rt_desert),
              (unlock_achievement, ACHIEVEMENT_SARRANIDIAN_NIGHTS),
            (try_end),
          (try_end),
          
          (rest_for_hours_interactive, 24 * 365, 5, 1), #rest while attackable
          
          (change_screen_return),
        ]
      ),
      
      ##      ("check_troop_tree",[],"Consult Troop Tree.",[
      ##        (assign, "$g_presentation_obj_sliders_1_val", 0),
      ##        (start_presentation, "prsnt_troop_tree"),
      ##      ]),
      
      #    ("formation_mod_option",[],"Formations mod options.", [(start_presentation, "prsnt_formation_mod_option")]),	#MOTO chief
      ("resume_travelling",[],"Resume travelling.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  #######camp wait
  ("camp_action_rest",0,
    "Camping allows your men to rest for a while and recover from the hard life of travels. It also allows you to forage, increasing your food supplies. This is particularly helpful when campaigning in enemy territory, where it is difficult to buy supplies.",
    "none",
    [(set_background_mesh, "mesh_pic_camp"),
    ],
    [
      ("camp_wait_here",[],"Wait here for some time.",
        [
          (str_clear,s1),
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (eq, "$fortified_camp", 1), #payment
            (ge, ":gold", 200), #foragers ok
            (troop_remove_gold, "trp_player", 200),
          (else_try),
            (eq, "$fortified_camp", 1), #payment no
            (display_message, "@You don't have the money to pay your men to fortify the camp. They do the job, but angrily.", color_terrible_news),
            (call_script, "script_change_player_party_morale", -8),
          (else_try),
          (try_end),
          
          (assign,"$g_presentations_next_presentation",-1),
          (presentation_set_duration,0),
          
          (assign,"$g_camp_mode", 1),
          (assign, "$g_infinite_camping", 0),
          (assign, "$g_player_icon_state", pis_camping),
          
          (try_begin),
            (party_is_active, "p_main_party"),
            (party_get_current_terrain, ":cur_terrain", "p_main_party"),
            (try_begin),
              (eq, ":cur_terrain", rt_desert),
              (unlock_achievement, ACHIEVEMENT_SARRANIDIAN_NIGHTS),
            (try_end),
          (try_end),
          
          (rest_for_hours_interactive, 24 * 365, 5, 1), #rest while attackable
          
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
      
      ("back",[],"Back.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  ################
  ###build refuge
  ("build_refuge_new",0,
    "Your men await your orders to start building the refuge. There is enough material collected so far, and what may be missing can be purchased in nearby villages.^^" +
    "Total Cost: 1000 peningas.^" +
    "Time need: 6 hours.",
    "none",
    [(set_background_mesh, "mesh_pic_camp"),
    ],
    [
      ("refuge_here",[(eq, "$lair_on", 0),],"So order.",
        [
          (str_clear,s1),
          
          (troop_remove_gold, "trp_player", 1000),
          (call_script, "script_make_lair"),
          (display_message, "@After you buy the materials, your men build a permanent shelter for you."),
          
          #tiempo de construccion
          (assign,"$g_presentations_next_presentation",-1),
          (presentation_set_duration,0),
          (assign,"$g_camp_mode", 1),
          (assign, "$g_infinite_camping", 0),
          (assign, "$g_player_icon_state", pis_camping),
          
          (rest_for_hours, 6, 5, 1), #rest while no attackable
          (assign,"$temp",6), #Obliga descanso al salir
          (change_screen_return),
          ##
          ##                 (leave_encounter),
          ##                 #(change_screen_map),
          ##		 (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
      
      ("back",[],"Back.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  ######################
  ("camp_cheat",0,
    "Select a cheat:",
    "none",
    [],
    [
      ("camp_cheat_find_item",[], "Find an item...",
        [
          (jump_to_menu, "mnu_cheat_find_item"),
        ]
      ),
      
      ("testing_cheats",[], "Cheats fast use.",
        [
          (jump_to_menu, "mnu_cheat_testing_cheats1"),
        ]
      ),
      
      ("camp_cheat_1",[],"{!}Increase player renown.",
        [
          (str_store_string, s1, "@Player renown is increased by 100."),
          (call_script, "script_change_troop_renown", "trp_player", 100),
          (jump_to_menu, "mnu_camp_cheat"),
        ]
      ),
      
      ("camp_cheat_2",[],"{!}Increase player Reputation.",
        [
          (assign, reg7, "$player_honor"),
          (val_add, reg7, 1),
          (display_message, "@Player reputation is increased by 1, and it is now {reg7}."),
          (val_add, "$player_honor", 1),
          (jump_to_menu, "mnu_camp_cheat"),
        ]
      ),
      ("camp_cheat_2b",[],"{!}Decrease player Reputation.",
        [
          (assign, reg7, "$player_honor"),
          (val_sub, reg7, 5),
          (display_message, "@Player reputation is decreased by 5, and it is now {reg7}."),
          (val_sub, "$player_honor", 5),
          (jump_to_menu, "mnu_camp_cheat"),
        ]
      ),
      
      ("action_modify_banner",[(eq, "$cheat_mode", 1)],"{!}Cheat: Modify your banner.",
        [
          (start_presentation, "prsnt_banner_selection"),
          #(start_presentation, "prsnt_custom_banner"),
        ]
      ),
      
      ("camp_cheat_3",[],"{!}Update political notes.",
        [
          (try_for_range, ":hero", active_npcs_begin, active_npcs_end),
            (troop_slot_eq, ":hero", slot_troop_occupation, slto_kingdom_hero),
            (call_script, "script_update_troop_political_notes", ":hero"),
          (try_end),
          
          (try_for_range, ":kingdom", kingdoms_begin, kingdoms_end),
            (call_script, "script_update_faction_political_notes", ":kingdom"),
          (try_end),
        ]
      ),
      
      ("camp_cheat_4",[],"{!}Update troop notes.",
        [
          (try_for_range, ":hero", active_npcs_begin, active_npcs_end),
            (troop_slot_eq, ":hero", slot_troop_occupation, slto_kingdom_hero),
            (call_script, "script_update_troop_notes", ":hero"),
          (try_end),
          
          (try_for_range, ":lady", kingdom_ladies_begin, kingdom_ladies_end),
            (call_script, "script_update_troop_notes", ":lady"),
            (call_script, "script_update_troop_political_notes", ":lady"),
            (call_script, "script_update_troop_location_notes", ":lady", 0),
          (try_end),
        ]
      ),
      
      # ("camp_cheat_5",[],"{!}Make peace.",
        # [
            # (try_for_range, ":cur_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
                # (call_script, "script_diplomacy_faction_get_diplomatic_status_with_faction", ":cur_kingdom", "fac_player_supporters_faction"),
                # (le, reg0, -2),
                # (call_script, "script_diplomacy_start_peace_between_kingdoms", ":cur_kingdom", "fac_player_supporters_faction", 1),
                # (call_script, "script_update_all_notes"),
            # (try_end),
        # ]
      # ),
  
      ("camp_cheat_6",[],"{!}Infinite camp",
        [
          (assign,"$g_camp_mode", 1),
          (assign, "$g_infinite_camping", 1),
          (assign, "$g_player_icon_state", pis_camping),
          (rest_for_hours_interactive, 10 * 24 * 365, 20), #10 year rest while not attackable with 20x speed
          (change_screen_return),
        ]
      ),
      
      ("cheat_faction_orders",[(ge,"$cheat_mode",1)],
        "{!}Cheat: Set Debug messages to All.",
        [(assign,"$cheat_mode",1),
          (jump_to_menu, "mnu_camp_cheat"),
        ]
      ),
      ("cheat_faction_orders",[
          (ge, "$cheat_mode", 1),
          (neq,"$cheat_mode",3)],"{!}Cheat: Set Debug messages to Econ Only.",
        [(assign,"$cheat_mode",3),
          (jump_to_menu, "mnu_camp_cheat"),
        ]
      ),
      ("cheat_faction_orders",[
          (ge, "$cheat_mode", 1),
          (neq,"$cheat_mode",4)],"{!}Cheat: Set Debug messages to Political Only.",
        [(assign,"$cheat_mode",4),
          (jump_to_menu, "mnu_camp_cheat"),
        ]
      ),
      
      ("back_to_camp_menu",[],"Back to camp menu.",
        [
          (jump_to_menu, "mnu_camp_action"),
          #(jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  ("cheat_testing_cheats1",0,
    "Select a cheat:",
    "none",
    [
    ],
    [
      ("continue1",[(eq,"$cheat_mode",1)],"{!}CHEAT! - increase Right to Rule",
        [
          (val_add, "$player_right_to_rule", 10),
          (jump_to_menu, "mnu_character_report"),
        ]
      ),
      
      ("update_danmork4",[],"{!}Add renown, money and troops.", #chief
        [
          (call_script, "script_troop_add_gold", "trp_player", 20000),
          (call_script, "script_change_troop_renown", "trp_player", 200),
          (party_add_members, "p_main_party", "trp_mercenary_swordsman", 15),
          (party_add_members, "p_main_party", "trp_norse_slave", 10),
          (party_add_members, "p_main_party", "trp_mercenary_crossbowman", 5),
          (party_add_members, "p_main_party", "trp_saxon_priest", 2),
          
        ]
      ),
      ("update_women",[],"{!}Testing: Women Army.", #chief
        [
          (party_add_members, "p_main_party", "trp_follower_woman", 10),
          (party_add_members, "p_main_party", "trp_hunter_woman", 10),
          (party_add_members, "p_main_party", "trp_fighter_woman", 10),
          (party_add_members, "p_main_party", "trp_sword_sister", 5),
        ]
      ),
      ("update_berserk",[],"{!}Testing: Berserker Army.", #chief
        [
          (party_add_members, "p_main_party", "trp_sea_raider_leader", 5),
          (party_add_members, "p_main_party", "trp_looter_leader", 5),
        ]
      ),
       ("cheat_testing_cheats1l",[(eq,"$cheat_mode",1)],"{!}Test: Add Companions and 100 relation to them.",
         [
           (try_for_range, ":companion", companions_begin, companions_end),
             (try_begin),
               (troop_slot_eq, ":companion", slot_troop_occupation, slto_inactive),   #VC-3910 limit game breaking
               (call_script, "script_recruit_troop_as_companion", ":companion"),
               (call_script, "script_change_player_relation_with_troop", ":companion", 100),
             (else_try),
               (troop_slot_eq, ":companion", slot_troop_occupation, slto_player_companion),
               (call_script, "script_change_player_relation_with_troop", ":companion", 100),
             (else_try),
               (troop_slot_eq, ":companion", slot_troop_occupation, slto_kingdom_hero),
               (str_store_troop_name, s11, ":companion"),
               (store_troop_faction, ":troop_faction", ":companion"),
               (str_store_faction_name, s3, ":troop_faction"),
               (display_log_message, "@{!}{s11} has joined the {s3}."),
             (else_try),
               (troop_slot_eq, ":companion", slot_troop_occupation, slto_retirement),
               (str_store_troop_name, s11, ":companion"),
               (display_log_message, "@{!}{s11} has retired from adventuring."),
             (else_try),
               (troop_slot_eq, ":companion", slot_troop_occupation, slto_dead),
               (str_store_troop_name, s11, ":companion"),
               (display_log_message, "@{!}{s11} is dead."),
             (try_end),
           (try_end),
         ]
       ),
      
      ("reset_messenger_system",[(eq,"$cheat_mode",1)],"{!}Reset Messenger System.",
        [
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (display_message, "@Reseted."),
        ]
      ),
      
      ("back",[],"Back.",
        [
          #(jump_to_menu, "mnu_camp_action"),
          (jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  #storyline cheats
  ("storyline_cheat",0,
    "Select a cheat:",
    "none",
    [
    ],
    [
      
      #cheat mainquest para ir mas rapido.
      ("hide_lords",[(eq,"$cheat_mode",1)],"{!}After The Messenger Quest: spawn lords in Snotingaham.",
        [
          (assign, "$g_lord_hide", -1), #lords back to world hide lords
        ]
      ),
      
      ("douar_1s",[(eq,"$cheat_mode",1)],"{!}Access to Douar-an-Enez (danish side). Before Boar Grove.",
        [
          (str_store_party_name_link, s3, "p_town_27"),
          (str_store_troop_name, s11, "trp_knight_8_2"),
          (assign, "$player_side", 2), #danish
          (str_store_string, s2, "@The time to meet with the troops from the Kingdom of Asturias has arrived. Bodo's letter indicates that they will dock at {s3}, and {s11} wants you go there and meet with them. " +
            "There is a traitor named Silo. Use him to gain favor with the Asturian troops and bring them to the side of the sons of Ragnar. If you fail to convince them, {s11} wants them destroyed.^^" +
          "But before you leave Englaland, you must go to {s3} and talk to the old captain at the port, as {s11} has gathered men and ships to help you in Douar-an-Enez."),
          (call_script, "script_start_quest", "qst_douar_an_enez", "trp_knight_8_2"),
          (quest_set_slot,"qst_douar_an_enez",slot_quest_current_state, 1),
          (change_screen_notes, 4),
        ]
      ),
      ("douar_2s",[(eq,"$cheat_mode",1)],"{!}Access to Douar-an-Enez (wessex side). Before Boar Grove.",
        [
          (str_store_party_name_link, s3, "p_town_12"),
          (str_store_troop_name, s11, "trp_knight_5_1"),
          (assign, "$player_side", 1), #wessex
          (str_store_string, s2, "@The time to meet with the troops from the Kingdom of Asturias has arrived. Bodo's letter indicates that they will dock at {s3}, and {s11} wants you go there and meet with them. " +
            "There is a traitor named Silo. You have to expose him and destroy him diplomatically, without breaking relations with the Asturians.^^" +
          "{s11} has gathered men and ships to help you in Douar-an-Enez. You must go to {s3} and talk to the old captain at the port."),
          (call_script, "script_start_quest", "qst_douar_an_enez", "trp_knight_5_1"),
          (quest_set_slot,"qst_douar_an_enez",slot_quest_current_state, 1),
          (change_screen_notes, 4),
        ]
      ),
      ("douar_2sbeda",[(eq,"$cheat_mode",1)],"{!}Access to Douar-an-Enez (You need to Beda in party - go to talk to Old Captain)",
        [
          (quest_set_slot,"qst_douar_an_enez",slot_quest_current_state, 7), #status 6 acaba
          (display_message, "@Go to Old Captain."),
        ]
      ),
      ("update_danmork21",[(eq,"$cheat_mode",1)],"{!}Darmakr part: Ulf's quest before the Assembly.", #puntual testing
        [
          (str_store_string, s2, "@The king of Danmark suggested that you talk to Ulf at his farmstead to convince him not to testify against you at the Assembly. " +
            "In addition, {s10} said it would be a good idea to have good relations (more than 15 relation points) with the jarls of Danmark, so they speak favorably about you at the Assembly."),
          (call_script, "script_start_quest", "qst_ulf_testigo", "$g_talk_troop"),
          (quest_set_slot,"qst_ulf_testigo",slot_quest_current_state, 1),
          (enable_party, "p_farmland"), #farm para emboscada, Sven meeting chief
          (change_screen_notes, 4),
        ]
      ),
      ("douar_back",[(eq,"$cheat_mode",1)],"{!}Final part: Back from Douar-an-Enez (before cattle quest).", #puntual testing
        [
          
          (str_clear, s3),
          (str_clear, s11),
          (call_script, "script_end_quest", "qst_douar_an_enez"),
          (str_store_party_name_link, s3, "p_town_12"),
          
          (try_begin),
            (eq, "$player_side", 2), #danish
            (str_store_troop_name_link, s11, "trp_kingdom_8_lord"),
            (str_store_string, s2, "@You have recently returned to the islands. It seems the world has gone mad. The Danish have advanced on West Seaxe and have fortified a camp at Readingum, where they have managed to defeat an attack by the Saxons. " +
              "Now, West Seaxe is gathering the fyrd in Aescesdun, calling all possible men to finish off the Danish. West Seaxe is fighting desperately for its survival. The Danish, in turn, are hastening to march against them. It seems a large battle is in the future, and Sven will be in it. " +
            "You must meet with {s11} as soon as possible in Readingum, near {s3}."),
            (call_script, "script_start_quest", "qst_aescesdun", "trp_kingdom_8_lord"),
          (else_try),
            (eq, "$player_side", 1), #wessex
            (str_store_troop_name_link, s11, "trp_knight_5_1"),
            (str_store_string, s2, "@You have recently returned to the islands. It seems the world has gone mad. The Danish have advanced on West Seaxe and have fortified a camp at Readingum, where they have managed to defeat an attack by the Saxons. " +
              "Now, West Seaxe is gathering the fyrd in Aescesdun, calling all possible men to finish off the Danish. West Seaxe is fighting desperately for its survival. The Danish, in turn, are hastening to march against them. It seems a large battle is in the future, and Sven will be in it. " +
            "You must meet with {s11} as soon as possible in Aescesdun, near {s3}."),
            (call_script, "script_start_quest", "qst_aescesdun", "trp_knight_5_1"),
          (try_end),
          (enable_party, "p_readingum"),
          (enable_party, "p_aescesdun"),
          (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 1),
          (display_message, "@Go to your lord."),
        ]
      ),
      ("oath_mission",[(eq,"$cheat_mode",1)],"{!}Back The Alliance quest to stage previus Join Kingdom Mission.",
        [
          (quest_set_slot,"qst_the_alliance",slot_quest_current_state, 9), #status 6 acaba
          (display_message, "@Go to talk to Aelfred (Wessex side) or Halfdan (Danish side)."),
        ]
      ),
      ("spawn_wessex_foragers",[(eq,"$cheat_mode",1)],"{!}Spawn Wessex Foragers.",
        [
          (spawn_around_party,"p_bjorn_camp","pt_wessex_foragers"), #bjorn camp
        ]
      ),
      ("mission_test_1",[],"{!}Test funeral mission.",
        [(set_jump_mission, "mt_funeral"),
          (jump_to_scene, "scn_mainquest_funeral"),
          (modify_visitors_at_site,"scn_mainquest_funeral"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (try_for_range, ":counter", 1, 41),
            (store_random_in_range, ":troop", "trp_town_walker_1", "trp_nino_varon"),
            (set_visitor, ":counter", ":troop"),
          (end_try),
          (set_visitor, 41, "trp_pagano"),
          (set_visitor, 42, "trp_village_walker_1"),
          (set_visitor, 43, "trp_village_walker_2"),
          (music_set_situation, mtf_sit_killed),
          (change_screen_mission),
        ]
      ),
      ("mission_test_2",[],"{!}Test svenattack_thefleet.",
        [
          (select_enemy, 0),
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_svenattack_thefleet"),
          (jump_to_scene,"scn_sea_battle_mainquest_fleet"),
          (change_screen_mission),
        ]
      ),
      ("mission_test_4",[],"{!}First ship mission",
        [
          (modify_visitors_at_site,"scn_frisa_beach"),
          (reset_visitors),
          (set_visitor, 41, "trp_npc3"), #Brunhild
          (set_visitor, 42, "trp_town_11_shipwright"), #le da el barco
          (set_visitor, 43, "trp_regular_sailors"),
          (set_visitor, 44, "trp_regular_sailors"),
          (set_visitor, 45, "trp_regular_sailors"),
          (set_visitor, 46, "trp_regular_sailors"),
          (set_visitor, 47, "trp_regular_sailors"),
          (set_jump_entry, 0),
          
          (set_jump_mission, "mt_frisa_beach"),
          (jump_to_scene,"scn_frisa_beach"),
          (change_screen_mission),
        ]
      ),
      #
      ("mission_test_5",[],"{!}douaranenez landing (wessex side)",
        [
          (assign, "$player_side", 1), #wessex
          (jump_to_menu, "mnu_way_to_douaranenez4"),
        ]
      ),
      #
      ("mission_test_6",[],"{!}douaranenez landing (danish side)",
        [
          (assign, "$player_side", 2), #danish
          (jump_to_menu, "mnu_way_to_douaranenez4"),
        ]
      ),
      
      #
      ("mission_test_7",[],"{!}Holmgang (Reginhard)",
        [
          (quest_set_slot,"qst_the_holmgang",slot_quest_current_state, 1),
          (jump_to_menu, "mnu_the_holmgang2"),
        ]
      ),
      #
      ("mission_test_8",[],"{!}Holmgang (Egil)",
        [
          (quest_set_slot,"qst_the_holmgang",slot_quest_current_state, 2),
          (jump_to_menu, "mnu_the_holmgang2"),
        ]
      ),
      ### phaiak end
      
      ("back_to_camp_menu",[],"Back to camp menu.",
        [
          (jump_to_menu, "mnu_camp_action"),
        ]
      ),
    ]
  ),
  ####
  
  ### phaiak begin
  ("phaiak_cheats",0,
    "{!}For Testing only:",
    "none",
    [
      (assign, reg5, "$cheat_find_item_range_begin"),
      (store_add, reg6, "$cheat_find_item_range_begin", max_inventory_items),
      (val_min, reg6, "itm_items_end"),
      (val_sub, reg6, 1),
    ],
    [
      
      ("vc_menu",	#Phaiak for testing...
        [
          (assign, reg1, "$g_vc_menu_turned_off"),
        ],"{!}vc_menu_turned_off: {reg1}",
        [
          (try_begin),
            (eq, "$g_vc_menu_turned_off", 1),
            (assign, "$g_vc_menu_turned_off", 0),
          (else_try),
            (assign, "$g_vc_menu_turned_off", 1),
          (end_try),
          (jump_to_menu, "mnu_phaiak_cheats"),
        ]
      ),
      #
      ("season",
        [
          (assign, reg1, "$shader_season"),
        ],"{!}season: {reg1}",
        [
          (try_begin),
            (lt, "$shader_season", 3),
            (val_add,  "$shader_season", 1),
          (else_try),
            (assign, "$shader_season", 0),
          (end_try),
          (jump_to_menu, "mnu_phaiak_cheats"),
        ]
      ),
      #
      ("beaufort",
        [
          (assign, reg1, "$beaufort"),
        ],"{!}beaufort: {reg1}",
        [
          (try_begin),
            (lt, "$beaufort", 12),
            (val_add, "$beaufort", 1),
          (else_try),
            (assign, "$beaufort", 0),
          (end_try),
          (jump_to_menu, "mnu_phaiak_cheats"),
        ]
      ),
      #
      ("crew",
        [
          (try_begin),
            (eq, "$percent_crew", 0),
            (assign, reg1, 100),
          (else_try),
            (assign, reg1, "$percent_crew"),
          (end_try),
        ],"{!}A. Choose percentage of crew. Current: {reg1} %%",
        [
          (try_begin),
            (lt, "$percent_crew", 80),
            (val_add, "$percent_crew", 10),
          (else_try),
            (assign, "$percent_crew", 0),
          (end_try),
          (jump_to_menu, "mnu_phaiak_cheats"),
        ]
      ),
      #
      ("testdrive",[],"{!}Testdrive",
        [
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_ship_test"),
          (jump_to_scene,"scn_sea_battle"),
          (change_screen_mission),
        ]
      ),
      ("testdrive2",[],"{!}sea_battle_douaranenez wessex",
        [
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_sea_battle_douaranenez"),
          (jump_to_scene,"scn_sea_battle_douaranenez"),
          (select_enemy, 1),
          (set_jump_entry, 1),
          (change_screen_mission),
        ]
      ),
      ("testdrive3",[],"{!}sea_battle_douaranenez danish",
        [
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_sea_battle_douaranenez"),
          (jump_to_scene,"scn_sea_battle_douaranenez"),
          (select_enemy, 0),
          (set_jump_entry, 0),
          (change_screen_mission),
        ]
      ),
      ("mission_test_3",[],"{!}D-day (100 ships)",
        [
          #(play_track, "track_epic_music", 2),
          (assign, "$d_day_ships", 100),
          (select_enemy, 0),
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_d_day"),
          (jump_to_scene,"scn_d_day"),
          (change_screen_mission),
        ]
      ),
      ("back",[],"Back.",
        [(jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  ### phaiak end
  
  ("cheat_find_item",0,
    "{!}Current item range: {reg5} to {reg6}",
    "none",
    [
      (assign, reg5, "$cheat_find_item_range_begin"),
      (store_add, reg6, "$cheat_find_item_range_begin", max_inventory_items),
      (val_min, reg6, "itm_items_end"),
      (val_sub, reg6, 1),
    ],
    [
      ("cheat_find_item_next_range",[], "{!}Move to next item range.",
        [
          (val_add, "$cheat_find_item_range_begin", max_inventory_items),
          (try_begin),
            (ge, "$cheat_find_item_range_begin", "itm_items_end"),
            (assign, "$cheat_find_item_range_begin", 0),
          (try_end),
          (jump_to_menu, "mnu_cheat_find_item"),
        ]
      ),
      
      ("cheat_find_item_choose_this",[], "{!}Choose from this range.",
        [
          (troop_clear_inventory, "trp_find_item_cheat"),
          (store_add, ":max_item", "$cheat_find_item_range_begin", max_inventory_items),
          (val_min, ":max_item", "itm_items_end"),
          (store_sub, ":num_items_to_add", ":max_item", "$cheat_find_item_range_begin"),
          (try_for_range, ":i_slot", 0, ":num_items_to_add"),
            (store_add, ":item_id", "$cheat_find_item_range_begin", ":i_slot"),
            (troop_add_items, "trp_find_item_cheat", ":item_id", 1),
          (try_end),
          (change_screen_trade, "trp_find_item_cheat"),
        ]
      ),
      
      ("back_to_camp_menu",[],"{!}Back to camp menu.",
        [(jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  ("cheat_change_weather",0,
    "{!}Current cloud amount: {reg5}^Current Fog Strength: {reg6}",
    "none",
    [
      (get_global_cloud_amount, reg5),
      (get_global_haze_amount, reg6),
    ],
    [
      ("cheat_increase_cloud",[], "{!}Increase Cloud Amount.",
        [
          (get_global_cloud_amount, ":cur_cloud_amount"),
          (val_add, ":cur_cloud_amount", 5),
          (val_min, ":cur_cloud_amount", 100),
          (set_global_cloud_amount, ":cur_cloud_amount"),
        ]
      ),
      ("cheat_decrease_cloud",[], "{!}Decrease Cloud Amount.",
        [
          (get_global_cloud_amount, ":cur_cloud_amount"),
          (val_sub, ":cur_cloud_amount", 5),
          (val_max, ":cur_cloud_amount", 0),
          (set_global_cloud_amount, ":cur_cloud_amount"),
        ]
      ),
      ("cheat_increase_fog",[], "{!}Increase Fog Amount.",
        [
          (get_global_haze_amount, ":cur_fog_amount"),
          (val_add, ":cur_fog_amount", 5),
          (val_min, ":cur_fog_amount", 100),
          (set_global_haze_amount, ":cur_fog_amount"),
        ]
      ),
      ("cheat_decrease_fog",[], "{!}Decrease Fog Amount.",
        [
          (get_global_haze_amount, ":cur_fog_amount"),
          (val_sub, ":cur_fog_amount", 5),
          (val_max, ":cur_fog_amount", 0),
          (set_global_haze_amount, ":cur_fog_amount"),
        ]
      ),
      
      ("camp_action_4",[],"{!}Back.",
        [(jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  
  ("camp_action",0,
    "Choose an action:",
    "none",
    [
    ],
    [
      
      # ("formation",
      # [], "Formation options.",
      # [
      # (start_presentation,"prsnt_formation_mod_option"),
      # ],
      # ),
      # ("global_options",
      # [], "Global options.",
      # [
      # (start_presentation,"prsnt_campmenu_choice_campaign"),
      # ],
      # ),
      
      ###Cheats
      ("camp_cheat",
        [(ge, "$cheat_mode", 1)
        ], "{!}CHEAT MENU!",
        [(jump_to_menu, "mnu_camp_cheat"),
        ],
      ),
      
      ("debug",
        [  (ge, "$cheat_mode", 1),
          (try_begin),
            (eq, "$vc_debug_mode", 0),
            (str_store_string, s8, "@off"),
          (else_try),
            (assign, reg2, "$vc_debug_mode"),
            (str_store_string, s8, "@{reg2}"),
          (end_try),
          
        ], "{!}VC DEBUG MODE: {s8}",
        [
          (try_begin),
            (ge, "$vc_debug_mode", 2),
            (assign, "$vc_debug_mode", 0),
          (else_try),
            (val_add, "$vc_debug_mode", 1),
          (end_try),
        ],
      ),
      
      ("sea_stuck_cheat",
        [(ge, "$cheat_mode", 1)
          ], "{!}Reset position to land (save game before using!)",
        [(call_script, "script_switch_to_land_consequences"),
        ],
      ),
      
      ("savegame_check_cheat",#VC-3134
        [(ge, "$cheat_mode", 1)
        ], "{!}CHEAT: Check savegame for errors.",
        [
          (assign, ":errors_found", 0),
          #
          (try_begin),
            (call_script, "script_cf_party_is_valid", "p_the_fleet"),
          (else_try),
            (val_add, ":errors_found", 1),
            (display_message, "@{!}Error: Party 'p_the_fleet' was deleted. In case you are playing the story mode you are maybe unable to proceed in the story."),
          (end_try),
          #
          (try_begin),
            (le, ":errors_found", 0),
            (display_message, "@{!}No errors found."),
          (end_try),
        ],
      ),
      
      ###Cheats storyline
      ("storyline_cheat",
        [(ge, "$cheat_mode", 1)
        ], "{!}Storyline Cheats!",
        [(jump_to_menu, "mnu_storyline_cheat"),
        ],
      ),
      
      ##########testing
      
      ###
      ("camp_action_1testing",[        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
          (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
        ],"{!}Faction testing.",
        [
          (assign, "$factionorders_type", factionorders_no),
          (start_presentation,"prsnt_faction_screen_main"),
        ]
      ),
      ######
      ("camp_action_1",[(eq,"$cheat_mode",1)],"{!}Cheat: Walk around.",
        [(set_jump_mission,"mt_ai_training"),
          (call_script, "script_setup_random_scene"),
          (change_screen_mission),
        ]
      ),
      ("camp_conversation",[(eq,"$cheat_mode",1)],"{!}Cheat: Conversation Scene.",
        [(set_jump_mission,"mt_ai_training"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_mission),
        ]
      ),
      ##      ("update_danmork1",[(eq,"$cheat_mode",1)],"Testing: Updated quest danmork.",
      ##       [
      ##        (str_store_troop_name, s11, "trp_player"),
      ##
      ##            (str_store_string, s2, "@You have offered your services to {s11}, in exchange for allowing you to join the hunt for Sven Bull Neck. {s1} has asked you to prove your worth."),
      ##    (call_script, "script_start_quest", "qst_kennemer_jarl_missions", "trp_player"),
      ##(str_store_string, s2, "@Thonkrik told you that the jarl of Kennemer may be allied with Sven Neck Bull in his attempt to capture the throne of Friese."),
      ##		(add_quest_note_from_sreg, "qst_kennemer_jarl_missions", 4, s2, 0),
      ##                (str_store_string, s2, "@All plans of the jarl of Kennemer to become the king have been ruined by your intervention. His ally, the Danish Lord, Sigurd 'Snake in the Eye,' will not send more troops because he is recruiting reinforcements for Englaland. It seems Friese will be free from Viking attacks for some time, thanks to your effort. However,  you now have to run away from the land that you have just helped to save."),
      ##		(add_quest_note_from_sreg, "qst_kennemer_jarl_missions", 6, s2, 0),
      ##      (quest_set_slot,"qst_kennemer_jarl_missions",slot_quest_current_state, 2), #Jarl enemigo
      ##
      ##     (str_store_string, s2, "@Go to the port master at Ribe."),
      ##     (call_script, "script_start_quest", "qst_the_fleet", "$g_talk_troop"),
      ##         (quest_set_slot,"qst_the_fleet",slot_quest_current_state, 3),
      ##
      ##   (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_frisa", "trp_player"),
      ##(str_store_string, s2, "@Note 3: You chose to become an enemy of the jarl of Kennemer for his betrayal and alliance with Sigurd, Sven Bull Neck's patron. You know he will send assassins after your head."),
      ##		(add_quest_note_from_sreg, "qst_notes_frisa", 6, s2, 0),
      ##
      ##
      ##    (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_global", "trp_player"),
      ##
      ##    (str_store_string, s2, "@Note 1: Doccinga fishermen rescued you from the sea. Sven attacked your ship. Looks like you're the only survivor."),
      ##		(add_quest_note_from_sreg, "qst_notes_global", 4, s2, 0),
      ##        (str_store_string, s2, "@Note 2: The Viking prisoner in Doccinga told you there were other survivors of the attack on the Woden Ric. They seem to have been taken to a hideout that Sven Bull Neck has in Danmark."),
      ##		(add_quest_note_from_sreg, "qst_notes_global", 5, s2, 0),
      ##                 (str_store_string, s2, "@Note: You returned 'The Cathach of Colum Cille' to Gleann_Da_Loch."),
      ##		(add_quest_note_from_sreg, "qst_notes_global", 6, s2, 0),
      ##
      ##    (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_companions", "trp_player"),
      ##               (str_store_string, s2, "@Note Bodo: Bodo feels indirectly responsible for the death of the people of the Woden Ric."),
      ##		(add_quest_note_from_sreg, "qst_notes_companions", 4, s2, 0),
      ##               (str_store_string, s2, "@Note Bodo: you chose to be loyal to Bodo and not deliver him to Sigurd at the exchange at the farm."),
      ##		(add_quest_note_from_sreg, "qst_notes_companions", 5, s2, 0),
      ##
      ##    (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_danmork", "trp_player"),
      ##                (str_store_string, s2, "@Note 1: Ragnar Lodbrok, a Viking who is now dead, had three wives, Skjaldmo, Lathgertha and Aslaug, and many children, some of their names are: Ivar the Boneless, Bjorn Ironside, Halfdan, Sigurd 'Snake in the Eye,' and Hubbi. Ragnar's sons are attacking Englaland in revenge for the execution of their father by the king Aelle of Northhymbre, who is also dead."),
      ##		(add_quest_note_from_sreg, "qst_notes_danmork", 4, s2, 0),
      ##                                           (change_screen_notes, 4),
      ##        ]
      ##       ),
      ##            ("testingcaesar",[(eq,"$cheat_mode",1)],"Testing: Updated quest leave Danmark: Fleet.",
      ##       [
      ##        (str_store_troop_name, s11, "trp_player"),
      ##
      ##            (str_store_string, s2, "@You have offered your services to {s11}, in exchange for allowing you to join the hunt for Sven Bull Neck. {s1} has asked you to prove your worth."),
      ##    (call_script, "script_start_quest", "qst_kennemer_jarl_missions", "trp_player"),
      ##(str_store_string, s2, "@Thonkrik told you that the jarl of Kennemer may be allied with Sven Neck Bull in his attempt to capture the throne of Friese."),
      ##		(add_quest_note_from_sreg, "qst_kennemer_jarl_missions", 4, s2, 0),
      ##                (str_store_string, s2, "@All plans of the jarl of Kennemer to become the king have been ruined by your intervention. His ally, the Danish Lord, Sigurd 'Snake in the Eye,' will not send more troops because he is recruiting reinforcements for Englaland. It seems Friese will be free from Viking attacks for some time, thanks to your effort. However,  you now have to run away from the land that you have just helped to save."),
      ##		(add_quest_note_from_sreg, "qst_kennemer_jarl_missions", 6, s2, 0),
      ##      (quest_set_slot,"qst_kennemer_jarl_missions",slot_quest_current_state, 2), #Jarl enemigo
      ##
      ##     (str_store_string, s2, "@Go to the port master at Ribe."),
      ##     (call_script, "script_start_quest", "qst_the_fleet", "$g_talk_troop"),
      ##         (quest_set_slot,"qst_the_fleet",slot_quest_current_state, 3),
      ##
      ##   (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_frisa", "trp_player"),
      ##(str_store_string, s2, "@Note 3: You chose to become an enemy of the jarl of Kennemer for his betrayal and alliance with Sigurd, Sven Bull Neck's patron. You know he will send assassins after your head."),
      ##		(add_quest_note_from_sreg, "qst_notes_frisa", 6, s2, 0),
      ##
      ##
      ##    (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_global", "trp_player"),
      ##
      ##    (str_store_string, s2, "@Note 1: Doccinga fishermen rescued you from the sea. Sven attacked your ship. Looks like you're the only survivor."),
      ##		(add_quest_note_from_sreg, "qst_notes_global", 4, s2, 0),
      ##        (str_store_string, s2, "@Note 2: The Viking prisoner in Doccinga told you there were other survivors of the attack on the Woden Ric. They seem to have been taken to a hideout that Sven Bull Neck has in Danmark."),
      ##		(add_quest_note_from_sreg, "qst_notes_global", 5, s2, 0),
      ##                 (str_store_string, s2, "@Note: You returned 'The Cathach of Colum Cille' to Gleann_Da_Loch."),
      ##		(add_quest_note_from_sreg, "qst_notes_global", 6, s2, 0),
      ##
      ##    (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_companions", "trp_player"),
      ##               (str_store_string, s2, "@Note Bodo: Bodo feels indirectly responsible for the death of the people of the Woden Ric."),
      ##		(add_quest_note_from_sreg, "qst_notes_companions", 4, s2, 0),
      ##               (str_store_string, s2, "@Note Bodo: you chose to be loyal to Bodo and not deliver him to Sigurd at the exchange at the farm."),
      ##		(add_quest_note_from_sreg, "qst_notes_companions", 5, s2, 0),
      ##
      ##    (str_store_string, s2, "@Info:"),
      ##    (call_script, "script_start_quest", "qst_notes_danmork", "trp_player"),
      ##                (str_store_string, s2, "@Note 1: Ragnar Lodbrok, a Viking who is now dead, had three wives, Skjaldmo, Lathgertha and Aslaug, and many children, some of their names are: Ivar the Boneless, Bjorn Ironside, Halfdan, Sigurd 'Snake in the Eye,' and Hubbi. Ragnar's sons are attacking Englaland in revenge for the execution of their father by the king Aelle of Northhymbre, who is also dead."),
      ##		(add_quest_note_from_sreg, "qst_notes_danmork", 4, s2, 0),
      ###companions Brunhild Bodo Egil Agathinos Asbjorn, solveig
      ##      (party_add_members, "p_main_party", "trp_npc2", 1),#join hero
      ##      (party_add_members, "p_main_party", "trp_npc3", 1),#join hero
      ##      (party_add_members, "p_main_party", "trp_npc6", 1),#join hero
      ##      (party_add_members, "p_main_party", "trp_npc11", 1),#join hero
      ##      (party_add_members, "p_main_party", "trp_npc12", 1),#join hero
      ##      (party_add_members, "p_main_party", "trp_npc15", 1),#join hero
      ###tropas
      ##      (party_add_members, "p_main_party", "trp_frisian_basic", 13),#join hero
      ##      (party_add_members, "p_main_party", "trp_norse_level0_landed", 8),#join hero
      ##                                           (change_screen_notes, 4),
      ##        ]
      ##       ),
      
      ######################
      ##      ("camp_recruit_prisoners",
      ##       [(troops_can_join, 1),
      ##        (store_current_hours, ":cur_time"),
      ##        (val_sub, ":cur_time", 24),
      ##        (gt, ":cur_time", "$g_prisoner_recruit_last_time"),
      ##        (try_begin),
      ##          (gt, "$g_prisoner_recruit_last_time", 0),
      ##          (assign, "$g_prisoner_recruit_troop_id", 0),
      ##          (assign, "$g_prisoner_recruit_size", 0),
      ##          (assign, "$g_prisoner_recruit_last_time", 0),
      ##        (try_end),
      ##        ], "Recruit some of your prisoners to your party.",
      ##       [(jump_to_menu, "mnu_camp_recruit_prisoners"),
      ##        ],
      ##       ),
      
      ##      ("action_read_book",[],"Select a book to read.",
      ##       [  (try_begin), #chief anadido
      ##             (eq, "$sabe_leer", 1),
      ##             (jump_to_menu, "mnu_camp_action_read_book"),
      ##		   (else_try), #chief anadido
      ##             (display_message,"@You cannot read. You should learn it at a monastery.",0xFFFFAAAA), #chief anadido
      ##           (try_end), #chief anadido
      ##        ]
      ##       ),
      
      ##      ("action_rename_kingdom",
      ##       [
      ##         (eq, "$players_kingdom_name_set", 1),
      ##         (faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
      ##         (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
      ##         ],"Rename your kingdom.",
      ##       [(start_presentation, "prsnt_name_kingdom"),
      ##        ]
      ##       ),
      
      ##      ("action_modify_banner",[(eq, "$cheat_mode", 1)],"{!}Cheat: Modify your banner.",
      ##       [
      ##           (start_presentation, "prsnt_banner_selection"),
      ##           #(start_presentation, "prsnt_custom_banner"),
      ##        ]
      ##       ),
      ##      ("action_retire",[],"Retire from adventuring.",
      ##       [(jump_to_menu, "mnu_retirement_verify"),
      ##        ]
      ##       ),
      #chief anade
      ("jump_to_scene",[(eq,"$cheat_mode",1)],"{!}debug: test scene menu",
        [
          (jump_to_menu,"mnu_test_scene"),
        ]
      ),
      ("toggle_cheat_on",[(eq, "$cheat_mode", 0)],"_Toggle cheat menu on.",
        [
          (assign,"$cheat_mode",1),
        ]
      ),
      
      ("toggle_cheat_off",[(eq, "$cheat_mode",1)],"_Toggle cheat menu off.",
        [
          (assign,"$cheat_mode",0),
        ]
      ),
      #chief anade acaba
      ("back_to_camp_menu",[],"Back to camp menu.",
        [(jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  ("camp_recruit_prisoners",0,
    "You offer your prisoners freedom if they agree to join you as soldiers. {s18}",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_guerreros"), #pic book
      
      (assign, ":num_regular_prisoner_slots", 0),
      (party_get_num_prisoner_stacks, ":num_stacks", "p_main_party"),
      (try_for_range, ":cur_stack", 0, ":num_stacks"),
        (party_prisoner_stack_get_troop_id, ":cur_troop_id", "p_main_party", ":cur_stack"),
        (neg|troop_is_hero, ":cur_troop_id"),
        (val_add, ":num_regular_prisoner_slots", 1),
      (try_end),
      (try_begin),
        (eq, ":num_regular_prisoner_slots", 0),
        (jump_to_menu, "mnu_camp_no_prisoners"),
      (else_try),
        (eq, "$g_prisoner_recruit_troop_id", 0),
        (store_current_hours, "$g_prisoner_recruit_last_time"),
        (store_random_in_range, ":rand", 0, 100),
        (store_skill_level, ":persuasion_level", "skl_persuasion", "trp_player"),
        (store_sub, ":reject_chance", 15, ":persuasion_level"),
        (val_mul, ":reject_chance", 6),
        (try_begin),
          (lt, ":rand", ":reject_chance"),
          (assign, "$g_prisoner_recruit_troop_id", -7),
        (else_try),
          (assign, ":num_regular_prisoner_slots", 0),
          (party_get_num_prisoner_stacks, ":num_stacks", "p_main_party"),
          (try_for_range, ":cur_stack", 0, ":num_stacks"),
            (party_prisoner_stack_get_troop_id, ":cur_troop_id", "p_main_party", ":cur_stack"),
            (neg|troop_is_hero, ":cur_troop_id"),
            (val_add, ":num_regular_prisoner_slots", 1),
          (try_end),
          (store_random_in_range, ":random_prisoner_slot", 0, ":num_regular_prisoner_slots"),
          (try_for_range, ":cur_stack", 0, ":num_stacks"),
            (party_prisoner_stack_get_troop_id, ":cur_troop_id", "p_main_party", ":cur_stack"),
            (neg|troop_is_hero, ":cur_troop_id"),
            (val_sub, ":random_prisoner_slot", 1),
            (lt, ":random_prisoner_slot", 0),
            (assign, ":num_stacks", 0),
            (assign, "$g_prisoner_recruit_troop_id", ":cur_troop_id"),
            (party_prisoner_stack_get_size, "$g_prisoner_recruit_size", "p_main_party", ":cur_stack"),
          (try_end),
        (try_end),
        
        (try_begin),
          (gt, "$g_prisoner_recruit_troop_id", 0),
          (party_get_free_companions_capacity, ":capacity", "p_main_party"),
          (val_min, "$g_prisoner_recruit_size", ":capacity"),
          #morale limit
          (party_get_morale,":cur_morale","p_main_party"),
          ## (val_mul,":cur_morale",10),
          (store_div, ":morale_limit", ":cur_morale", 4),
          (val_max, ":morale_limit", 5),
          
          (val_min, "$g_prisoner_recruit_size", ":morale_limit"),
          #
          (assign, reg1, "$g_prisoner_recruit_size"),
          (gt, "$g_prisoner_recruit_size", 0),
          (try_begin),
            (gt, "$g_prisoner_recruit_size", 1),
            (assign, reg2, 1),
          (else_try),
            (assign, reg2, 0),
          (try_end),
          (str_store_troop_name_by_count, s1, "$g_prisoner_recruit_troop_id", "$g_prisoner_recruit_size"),
          #cost
          (store_character_level, ":troop_level", "$g_prisoner_recruit_troop_id"),
          (store_mul, ":total_pay", ":troop_level", 10),
          (try_begin),
            (lt, ":troop_level", 18),
            (assign, ":total_pay", 5),
          (try_end),
          (try_begin),
            (gt, ":troop_level", 26),
            (val_mul, ":total_pay", 3),
          (try_end),
          (val_mul, ":total_pay", "$g_prisoner_recruit_size"),
          (assign, "$temp2", ":total_pay"),
          (assign, reg0, ":total_pay"),
          
          
          (str_store_string, s18, "@{reg1} {s1} {reg2?accept:accepts} the offer. Cost: {reg0} peningas."),
        (else_try),
          (str_store_string, s18, "@No one accepts the offer."),
        (try_end),
      (try_end),
    ],
    [
      ("camp_recruit_prisoners_accept",[(gt, "$g_prisoner_recruit_troop_id", 0),(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", "$temp2"),
        ],"Take them.",
        [(remove_troops_from_prisoners, "$g_prisoner_recruit_troop_id", "$g_prisoner_recruit_size"),
          (party_add_members, "p_main_party", "$g_prisoner_recruit_troop_id", "$g_prisoner_recruit_size"),
          (troop_remove_gold, "trp_player", "$temp2"),
          (assign, "$temp2", 0),
          #morale drop
          (store_character_level, ":troop_level", "$g_prisoner_recruit_troop_id"),
          (try_begin),
            (gt, ":troop_level", 26),
            (assign, ":morale_penalty", -4),
          (else_try),
            (gt, ":troop_level", 18),
            (assign, ":morale_penalty", -3),
          (else_try),
            (assign, ":morale_penalty", -2),
          (try_end),
          #
          (store_mul, ":morale_change", ":morale_penalty", "$g_prisoner_recruit_size"),
          (call_script, "script_change_player_party_morale", ":morale_change"),
          (jump_to_menu, "mnu_camp"),
        ]
      ),
      
      ("camp_recruit_prisoners_half",[(gt, "$g_prisoner_recruit_troop_id", 0),(store_troop_gold, ":gold", "trp_player"),
          (assign, ":expenses", "$temp2"),
          (val_div, ":expenses", 2),
          (ge, ":gold", ":expenses"),
          (assign, ":men_hire", "$g_prisoner_recruit_size"),
          (val_div, ":men_hire", 2),
          (ge, ":men_hire", 2),
        ],"Take half them.",
        [
          (assign, ":men_hire", "$g_prisoner_recruit_size"),
          (val_div, ":men_hire", 2),
          
          (remove_troops_from_prisoners, "$g_prisoner_recruit_troop_id", ":men_hire"),
          (party_add_members, "p_main_party", "$g_prisoner_recruit_troop_id", ":men_hire"),
          (assign, ":expenses", "$temp2"),
          (val_div, ":expenses", 2),
          (troop_remove_gold, "trp_player", ":expenses"),
          (assign, "$temp2", 0),
          #morale drop
          (store_character_level, ":troop_level", "$g_prisoner_recruit_troop_id"),
          (try_begin),
            (gt, ":troop_level", 26),
            (assign, ":morale_penalty", -4),
          (else_try),
            (gt, ":troop_level", 18),
            (assign, ":morale_penalty", -3),
          (else_try),
            (assign, ":morale_penalty", -2),
          (try_end),
          #
          (store_mul, ":morale_change", ":morale_penalty", ":men_hire"),
          (call_script, "script_change_player_party_morale", ":morale_change"),
          (jump_to_menu, "mnu_camp"),
        ]
      ),
      
      ("camp_recruit_prisoners_reject",[(gt, "$g_prisoner_recruit_troop_id", 0)],"Reject them.",
        [(jump_to_menu, "mnu_camp"),
          (assign, "$g_prisoner_recruit_troop_id", 0),
          (assign, "$g_prisoner_recruit_size", 0),
        ]
      ),
      ("go_back_dot",[(le, "$g_prisoner_recruit_troop_id", 0)],"Go back.",
        [(jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  ("camp_no_prisoners",0,
    "You have no prisoners to recruit from.",
    "none",
    [      (set_background_mesh, "mesh_pic_extra_guerreros"), #pic book
    ],
    [
      ("continue",[],"Continue...",
        [(jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  ("camp_action_read_book",0,
    "Choose a book to read:",
    "none",
    [
      (set_background_mesh, "mesh_pic_coppergate_helm"), #pic book
    ],
    [
      ("action_read_book_1",[(player_has_item, "itm_book_tactics"),
          (item_slot_eq, "itm_book_tactics", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_tactics"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_tactics"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("action_read_book_2",[(player_has_item, "itm_book_persuasion"),
          (item_slot_eq, "itm_book_persuasion", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_persuasion"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_persuasion"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("action_read_book_3",[(player_has_item, "itm_book_leadership"),
          (item_slot_eq, "itm_book_leadership", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_leadership"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_leadership"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("action_read_book_4",[(player_has_item, "itm_book_intelligence"),
          (item_slot_eq, "itm_book_intelligence", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_intelligence"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_intelligence"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("action_read_book_5",[(player_has_item, "itm_book_trade"),
          (item_slot_eq, "itm_book_trade", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_trade"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_trade"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("action_read_book_6",[(player_has_item, "itm_book_weapon_mastery"),
          (item_slot_eq, "itm_book_weapon_mastery", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_weapon_mastery"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_weapon_mastery"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("action_read_book_7",[(player_has_item, "itm_book_engineering"),
          (item_slot_eq, "itm_book_engineering", slot_item_book_read, 0),
          (str_store_item_name, s1, "itm_book_engineering"),
        ],"{!}{s1}.",
        [(assign, "$temp", "itm_book_engineering"),
          (jump_to_menu, "mnu_camp_action_read_book_start"),
        ]
      ),
      ("back_to_camp_menu",[],"Back to camp menu.",
        [(jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  ("camp_action_read_book_start",0,
    "{!}{s1}",
    "none",
    [(set_background_mesh, "mesh_pic_coppergate_helm"), #pic book
      (assign, ":new_book", "$temp"),
      (str_store_item_name, s2, ":new_book"),
      (try_begin),
        (store_attribute_level, ":int", "trp_player", ca_intelligence),
        (item_get_slot, ":int_req", ":new_book", slot_item_intelligence_requirement),
        (le, ":int_req", ":int"),
        (str_store_string, s1, "@You start reading {s2}. After a few pages, " +
        "you feel you could learn a lot from this book. You decide to keep it close by and read whenever you have the time."),
        (assign, "$g_player_reading_book", ":new_book"),
      (else_try),
        (str_store_string, s1, "@You flip through the pages of {s2}, but you find the text confusing and difficult to follow. " +
        "Try as you might, it soon gives you a headache, and you're forced to give up the attempt."),
      (try_end),],
    [
      ("continue",[],"Continue...",
        [(jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  
  ("retirement_verify",0,
    "You are at day {reg0}. Your current luck is {reg1}. Are you sure you want to retire?",
    "none",
    [(set_background_mesh, "mesh_pic_draco_single"), #pic book
      (store_current_day, reg0),
      (assign, reg1, "$g_player_luck"),
    ],
    [
      ("yes_dot",[],"Yes.",
        [
          (start_presentation, "prsnt_retirement"),
        ]
      ),
      ("no_dot",[],"No.",
        [
          (jump_to_menu, "mnu_camp"),
        ]
      ),
    ]
  ),
  
  ("end_game",0,
    "The decision is made, and you resolve to give up your adventurer's " +
    "life and settle down. You sell off your weapons and armour, gather up " +
    "all your money, and ride off into the sunset....",
    "none",
    [(set_background_mesh, "mesh_pic_draco_single"), #pic book
    ],
    [
      ("end_game_bye",[],"Farewell.",
        [
          (change_screen_quit),
        ]
      ),
    ]
  ),
  
  ("cattle_herd",0,
    "You encounter a herd of cattle.",
    "none",
    [(play_sound, "snd_cow_moo"),
      (set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("cattle_drive_away",[],"Lead the cattle onward.",
        [
          (party_set_slot, "$g_encountered_party", slot_cattle_driven_by_player, 1),
          (party_set_ai_behavior, "$g_encountered_party", ai_bhvr_escort_party),
          (party_set_ai_object,"$g_encountered_party", "p_main_party"),
          (change_screen_return),
        ]
      ),
      ("cattle_stop",[],"Bring the herd to a stop.",
        [
          (party_set_slot, "$g_encountered_party", slot_cattle_driven_by_player, 0),
          (party_set_ai_behavior, "$g_encountered_party", ai_bhvr_hold),
          (change_screen_return),
        ]
      ),
      ("cattle_kill",[(assign, ":continue", 1),
          (try_begin),
            (check_quest_active, "qst_move_cattle_herd"),
            (neg|check_quest_succeeded, "qst_move_cattle_herd"),
            (quest_slot_eq, "qst_move_cattle_herd", slot_quest_target_party, "$g_encountered_party"),
            (assign, ":continue", 0),
          (try_end),
          (eq, ":continue", 1)],"Slaughter some of the animals.",
        [(jump_to_menu, "mnu_cattle_herd_kill"),
        ]
      ),
      ("leave",[],"Leave.",
        [(change_screen_return),
        ]
      ),
    ]
  ),
  
  ("cattle_herd_kill",0,
    "How many animals do you want to slaughter?",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"),
      (party_get_num_companions, reg5, "$g_encountered_party")],
    [
      ("cattle_kill_1",[(ge, reg5, 1),],"One.",
        [(call_script, "script_kill_cattle_from_herd", "$g_encountered_party", 1),
          (jump_to_menu, "mnu_cattle_herd_kill_end"),
          (change_screen_loot, "trp_temp_troop"),
          (play_sound, "snd_cow_slaughter"),
        ]
      ),
      ("cattle_kill_2",[(ge, reg5, 2),],"Two.",
        [(call_script, "script_kill_cattle_from_herd", "$g_encountered_party", 2),
          (jump_to_menu, "mnu_cattle_herd_kill_end"),
          (change_screen_loot, "trp_temp_troop"),
          (play_sound, "snd_cow_slaughter"),
        ]
      ),
      ("cattle_kill_3",[(ge, reg5, 3),],"Three.",
        [(call_script, "script_kill_cattle_from_herd", "$g_encountered_party", 3),
          (jump_to_menu, "mnu_cattle_herd_kill_end"),
          (change_screen_loot, "trp_temp_troop"),
          (play_sound, "snd_cow_slaughter"),
        ]
      ),
      ("cattle_kill_4",[(ge, reg5, 4),],"Four.",
        [(call_script, "script_kill_cattle_from_herd", "$g_encountered_party", 4),
          (jump_to_menu, "mnu_cattle_herd_kill_end"),
          (change_screen_loot, "trp_temp_troop"),
          (play_sound, "snd_cow_slaughter"),
        ]
      ),
      ("cattle_kill_5",[(ge, reg5, 5),],"Five.",
        [(call_script, "script_kill_cattle_from_herd", "$g_encountered_party", 5),
          (jump_to_menu, "mnu_cattle_herd_kill_end"),
          (change_screen_loot, "trp_temp_troop"),
          (play_sound, "snd_cow_slaughter"),
        ]
      ),
      ("cattle_kill_20",[(ge, reg5, 20),],"Twenty.",
        [(call_script, "script_kill_cattle_from_herd", "$g_encountered_party", 20),
          (jump_to_menu, "mnu_cattle_herd_kill_end"),
          (change_screen_loot, "trp_temp_troop"),
          (play_sound, "snd_cow_slaughter"),
        ]
      ),
      ("go_back_dot",[],"Go back.",
        [(jump_to_menu, "mnu_cattle_herd"),
        ]
      ),
    ]
  ),
  
  ("cattle_herd_kill_end",0,
    "{!}You shouldn't be reading this.",
    "none",
    [(change_screen_return)],
    [
    ]
  ),
  
  
  ("arena_duel_fight",0, #chief cambia
    "A duel is a very serious thing, especially if it is to the death. Two enter the circle, but only one comes out...^^" +
    "Both mind and body react to stress and danger. You feel the cold sweat under your armpits, the kind that comes regardless of whether it's hot or not. It's the sweat of the fight, and its presence indicates that you... are ready.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_duelos"), #pic book
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
      
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$g_leave_encounter", 0),
          
          ##        (try_begin),
          ##          (is_between, "$g_encountered_party", towns_begin, towns_end),
          ##          (party_get_slot, ":duel_scene", "$g_encountered_party", slot_town_arena),
          ##        (else_try),
          ##          (eq, "$g_start_arena_fight_at_nearest_town", 1),
          ##          (assign, ":closest_town", -1),
          ##          (assign, ":minimum_dist", 10000),
          ##          (try_for_range, ":cur_town", towns_begin, towns_end),
          ##            (store_distance_to_party_from_party, ":dist", ":cur_town", "$g_encountered_party"),
          ##            (lt, ":dist", ":minimum_dist"),
          ##            (assign, ":minimum_dist", ":dist"),
          ##            (assign, ":closest_town", ":cur_town"),
          ##          (try_end),
          ##          (try_begin),
          ##            (ge, ":closest_town", 0),
          ##            (party_get_slot, ":duel_scene", ":closest_town", slot_town_arena),
          ##          (try_end),
          ##          (assign, "$g_start_arena_fight_at_nearest_town", 0),
          ##        (else_try),
          ##          (party_get_current_terrain, ":terrain", "p_main_party"),
          ##          (eq, ":terrain", 4),
          ##          (assign, ":duel_scene", "scn_training_ground_ranged_melee_3"),
          ##        (else_try),
          ##          (eq, ":terrain", 5),
          ##          (assign, ":duel_scene", "scn_training_ground_ranged_melee_4"),
          ##        (else_try),
          ##          (assign, ":duel_scene", "scn_training_ground_ranged_melee_1"),
          ##        (try_end),
          
          (set_jump_mission, "mt_duel_with_lord"),
          (call_script, "script_duel_init_system", "scn_duel_plain", "$g_duel_troop"),
          (jump_to_menu, "mnu_arena_duel_conclusion"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  
  ("arena_duel_conclusion",0,
    "{!}{s11}",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_duelos"), #pic book
      (str_store_troop_name, s10, "$temp"),
      (try_begin),
        (eq, "$g_leave_encounter", 1),
        (change_screen_return),
      (try_end),
      
      
      
      (try_begin),
        (quest_slot_eq, "qst_blank_quest_15", slot_quest_target_troop, "$temp"),
        (check_quest_failed, "qst_blank_quest_15"),
        (str_store_string, s11, "str_you_lie_stunned_for_several_minutes_then_stagger_to_your_feet_to_find_your_s10_standing_over_you_you_have_lost_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_blank_quest_15", slot_quest_target_troop, "$temp"),
        (check_quest_succeeded, "qst_blank_quest_15"),
        (str_store_string, s11, "str_s10_lies_in_the_arenas_dust_for_several_minutes_then_staggers_to_his_feet_you_have_won_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_duel_for_lady", slot_quest_target_troop, "$temp"),
        (check_quest_failed, "qst_duel_for_lady"),
        (str_store_string, s11, "str_you_lie_stunned_for_several_minutes_then_stagger_to_your_feet_to_find_your_s10_standing_over_you_you_have_lost_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_duel_for_lady", slot_quest_target_troop, "$temp"),
        (check_quest_succeeded, "qst_duel_for_lady"),
        (str_store_string, s11, "str_s10_lies_in_the_arenas_dust_for_several_minutes_then_staggers_to_his_feet_you_have_won_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_duel_courtship_rival", slot_quest_target_troop, "$temp"),
        (check_quest_failed, "qst_duel_courtship_rival"),
        (str_store_string, s11, "str_you_lie_stunned_for_several_minutes_then_stagger_to_your_feet_to_find_your_s10_standing_over_you_you_have_lost_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_duel_courtship_rival", slot_quest_target_troop, "$temp"),
        (check_quest_succeeded, "qst_duel_courtship_rival"),
        (str_store_string, s11, "str_s10_lies_in_the_arenas_dust_for_several_minutes_then_staggers_to_his_feet_you_have_won_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_duel_avenge_insult", slot_quest_target_troop, "$temp"),
        (check_quest_succeeded, "qst_duel_avenge_insult"),
        (str_store_string, s11, "str_s10_lies_in_the_arenas_dust_for_several_minutes_then_staggers_to_his_feet_you_have_won_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_duel_avenge_insult", slot_quest_target_troop, "$temp"),
        (check_quest_failed, "qst_duel_avenge_insult"),
        (str_store_string, s11, "str_you_lie_stunned_for_several_minutes_then_stagger_to_your_feet_to_find_your_s10_standing_over_you_you_have_lost_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_denounce_lord", slot_quest_target_troop, "$temp"),
        (check_quest_succeeded, "qst_denounce_lord"),
        (str_store_string, s11, "str_s10_lies_in_the_arenas_dust_for_several_minutes_then_staggers_to_his_feet_you_have_won_the_duel"),
      (else_try),
        (quest_slot_eq, "qst_denounce_lord", slot_quest_target_troop, "$temp"),
        (check_quest_failed, "qst_denounce_lord"),
        (str_store_string, s11, "str_you_lie_stunned_for_several_minutes_then_stagger_to_your_feet_to_find_your_s10_standing_over_you_you_have_lost_the_duel"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (call_script, "script_get_meeting_scene"), (assign, ":meeting_scene", reg0),
          (modify_visitors_at_site,":meeting_scene"),
          (reset_visitors),
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"$temp"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,":meeting_scene"),
          (assign, "$talk_context", tc_after_duel),
          (change_screen_map_conversation, "$temp"),
          (assign, "$g_duel_troop", -1),
      ]),
    ]
  ),
  
  
  (
    "simple_encounter",mnf_enable_hot_keys,
    "{s2} You have {reg10} troops fit for battle against their {reg11}.^^{s7}",
    "none",
    [
      (try_begin),
        (check_quest_active,"qst_aescesdun"),
        (quest_slot_eq,"qst_aescesdun",slot_quest_current_state, 14),
        (this_or_next|eq, "$g_encountered_party", "p_aescesdun"),
        (eq, "$g_encountered_party", "p_mega_danishrmy"),
        (jump_to_menu,"mnu_mega_battle_ashdown"),
      (try_end),
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (try_begin),
        (eq, "$new_encounter", 1),
        (party_get_template_id, ":template_id", "$g_enemy_party"),
        (neq, ":template_id", "pt_routed_warriors"), #chief, los que huyen no luchan
        (call_script, "script_let_nearby_parties_join_current_battle", 0, 0),
      (try_end),
      (call_script, "script_encounter_calculate_fit"),
      (try_begin),
        (eq, "$new_encounter", 1),
        # (assign, "$new_encounter", 0),	MOTO chief move to end so it can be used!
        (assign, "$g_encounter_is_in_village", 0),
        (assign, "$g_encounter_type", 0),
        (try_begin),
          (party_slot_eq, "p_main_party", slot_party_on_water, 0),#VC-3027
          (party_slot_eq, "$g_enemy_party", slot_party_ai_state, spai_raiding_around_center),
          (party_get_slot, ":village_no", "$g_enemy_party", slot_party_ai_object),
          (store_distance_to_party_from_party, ":dist", ":village_no", "$g_enemy_party"),
          (try_begin),
            (lt, ":dist", raid_distance),
            (assign, "$g_encounter_is_in_village", ":village_no"),
            (assign, "$g_encounter_type", enctype_fighting_against_village_raid),
          (try_end),
        (try_end),
        (try_begin),
          (party_slot_eq, "p_main_party", slot_party_on_water, 0),#VC-3027
          (gt, "$g_player_raiding_village", 0),
          (assign, "$g_encounter_is_in_village", "$g_player_raiding_village"),
          (assign, "$g_encounter_type", enctype_catched_during_village_raid),
          (party_quick_attach_to_current_battle, "$g_encounter_is_in_village", 1), #attach as enemy
          (str_store_string, s1, "@Villagers"),
          (display_message, "str_s1_joined_battle_enemy",color_bad_news),
        (else_try),
          (party_slot_eq, "p_main_party", slot_party_on_water, 0),#VC-3027
          (eq, "$g_encounter_type", enctype_fighting_against_village_raid),
          (party_quick_attach_to_current_battle, "$g_encounter_is_in_village", 0), #attach as friend
          (str_store_string, s1, "@Villagers"),
          (display_message, "str_s1_joined_battle_friend",color_good_news),
          # Let village party join battle at your side
        (try_end),
        ###player lair troops join to battle
        # (try_begin),
        # (eq, "$lair_on", 1),
        # (party_is_active, "p_yourlair"),
        # (store_distance_to_party_from_party, ":cur_distance", "p_yourlair", "p_main_party"),
        # (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
        # (party_quick_attach_to_current_battle, "p_yourlair", 0), #attach as friend
        # (str_store_string, s1, "@Refuge Troops"),
        # (display_message, "str_s1_joined_battle_friend",color_good_news),
        # (try_end),
        # (try_begin),
        # (try_for_range, ":center", walled_centers_begin, walled_centers_end),
        # (party_slot_eq, ":center", slot_town_lord, "trp_player"),
        # (store_distance_to_party_from_party, ":cur_distance", ":center", "p_main_party"),
        # (lt, ":cur_distance", 3),  #party is within distance
        # (party_quick_attach_to_current_battle, ":center", 0), #attach as friend
        # (str_store_string, s1, "@Garrison Troops"),
        # (display_message, "str_s1_joined_battle_friend",color_good_news),
        # (try_end),
        # (try_end),
        ##troop_camp
        # (try_begin),
        # (party_is_active, "p_troop_camp_1"),
        # (store_distance_to_party_from_party, ":cur_distance", "p_troop_camp_1", "p_main_party"),
        # (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
        # (party_quick_attach_to_current_battle, "p_troop_camp_1", 0), #attach as friend
        # (str_store_string, s1, "@Camp Troops"),
        # (display_message, "str_s1_joined_battle_friend",color_good_news),
        # (try_end),
        # (try_begin),
        # (party_is_active, "p_troop_camp_2"),
        # (store_distance_to_party_from_party, ":cur_distance", "p_troop_camp_2", "p_main_party"),
        # (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
        # (party_quick_attach_to_current_battle, "p_troop_camp_2", 0), #attach as friend
        # (str_store_string, s1, "@Camp Troops"),
        # (display_message, "str_s1_joined_battle_friend",color_good_news),
        # (try_end),
        ####ambush system
        (assign, ":ambush_ai_yes", 1), #ambush chief system
        (try_begin),
          (neq, "$g_encounter_type", enctype_fighting_against_village_raid),
          (neq, "$g_player_icon_state", pis_camping), #camp normal
          #  (neq, "$g_encounter_type", ambush_ai_yes),
          (le,"$player_ambushed",0),
          (eq, "$encountered_party_hostile", 1),
          (party_get_current_terrain, ":terrain_type", "p_main_party"),
          (neq,":terrain_type",0),	#no ambushes at sea
          (neq,":terrain_type",7),
          (neq,":terrain_type",8),
          
          #limit parties that ambush
          (neq, "$g_encountered_party",      "pt_boar_herd"),
          (neg|is_between, "$g_encountered_party",      "pt_merchant_caravan", "pt_kingdom_hero_party"),
          (neg|is_between, "$g_encountered_party",      "pt_steppe_bandit_lair", "pt_boar_herd"),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_besieging_center),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_raiding_around_center),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_accompanying_army),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_visiting_village),
          #end limit parties that ambush
          
          (try_begin),
            (eq, ":terrain_type", rt_steppe),
            (val_add, ":ambush_ai_yes", 10),
          (else_try),
            (eq, ":terrain_type", rt_plain),
            (val_add, ":ambush_ai_yes", 12),
          (else_try),
            (eq, ":terrain_type", rt_snow),
            (val_add, ":ambush_ai_yes", 14),
          (else_try),
            (eq, ":terrain_type", rt_desert),
            (val_add, ":ambush_ai_yes", 10),
          (else_try),
            (eq, ":terrain_type", rt_steppe_forest),
            (val_add, ":ambush_ai_yes", 18),
          (else_try),
            (eq, ":terrain_type", rt_forest),
            (val_add, ":ambush_ai_yes", 30),
          (else_try),
            (eq, ":terrain_type", rt_snow_forest),
            (val_add, ":ambush_ai_yes", 26),
          (else_try),
            (val_add, ":ambush_ai_yes", 10),
          (try_end),
          #big armies = more difficult to do ambush
          (store_party_size_wo_prisoners, ":enemy_strength", "$g_encountered_party"),
          (try_begin),
            (le, ":enemy_strength", 30),
            (val_add, ":ambush_ai_yes", 30),
          (else_try),
            (le, ":enemy_strength", 60),
            (val_add, ":ambush_ai_yes", 20),
          (else_try),
            (le, ":enemy_strength", 120),
            (val_add, ":ambush_ai_yes", 16),
          (else_try),
            (le, ":enemy_strength", 240),
            (val_add, ":ambush_ai_yes", 12),
          (else_try),
            (val_add, ":ambush_ai_yes", 10),
          (try_end),
          #player skills helping to avoid ambush
          (call_script, "script_get_max_skill_of_player_party", "skl_spotting"),
          (assign, ":spotting_skill", reg0),
          (val_sub,":ambush_ai_yes",":spotting_skill"),
          (val_max, ":ambush_ai_yes", 1),
          (store_random_in_range,":ambush_ratio",0,200),
          (try_begin),
            (lt,":ambush_ratio",":ambush_ai_yes"),
            (assign,"$player_ambushed",1),
            (assign, "$cant_leave_encounter", 1),
          (else_try),
            (assign,"$player_ambushed",2), #ambush check only once per battle
          (try_end),
        (try_end),
        ################
        
        (call_script, "script_encounter_init_variables"),
        (assign, "$encountered_party_hostile", 0),
        (assign, "$encountered_party_friendly", 0),
        (try_begin),
          (gt, "$g_encountered_party_relation", 10), #chief add relation, they dont join you if no good relation.
          
          #Quest bandits are never friendly
          (this_or_next|neg|check_quest_active, "qst_track_down_bandits"),
          (neg|quest_slot_eq, "qst_track_down_bandits", slot_quest_target_party, "$g_encountered_party"),
          
          (this_or_next|neg|check_quest_active, "qst_blank_quest_4"),
          (neg|quest_slot_eq, "qst_blank_quest_4", slot_quest_target_party, "$g_encountered_party"),
          
          (assign, "$encountered_party_friendly", 1),
        (try_end),
        
        (try_begin),
          (gt, "$g_encountered_party_relation", 0), #por debajo de 10 y por encima de 0 no luchan.
          (lt, "$g_encountered_party_relation", 10),
          (assign, "$encountered_party_friendly", 0),
        (try_end),
        
        (try_begin), ##chief , huidos no luchan
          (party_get_template_id, ":template_id", "$g_enemy_party"),
          (this_or_next|eq, ":template_id", "pt_routed_warriors"),
          (eq, ":template_id", "pt_troublesome_bandits"),
          (assign, "$encountered_party_friendly", 0),
        (try_end),
        
        (try_begin),
          (lt, "$g_encountered_party_relation", 0),
          (assign, "$encountered_party_hostile", 1),
        (try_end),
        (try_begin),
          (encountered_party_is_attacker),
          (assign, "$cant_leave_encounter", 1),
        (try_end),
        (assign, "$talk_context", tc_party_encounter),
        (call_script, "script_setup_party_meeting", "$g_encountered_party"),
      (else_try), #second or more turn
        #          (try_begin),
        #            (call_script, "script_encounter_calculate_morale_change"),
        #          (try_end),
        (try_begin),
          # We can leave battle only after some troops have been killed.
          (eq, "$cant_leave_encounter", 1),
          (assign, ":continue", 0),
          (try_begin),
            (check_quest_active, "qst_blank_quest_15"),
            (quest_get_slot, ":cur_lord", "qst_blank_quest_15", slot_quest_target_troop),
            (troop_slot_eq, ":cur_lord", slot_troop_leaded_party, "$g_encountered_party"),
            (assign, ":continue", 1),
          (try_end),
          (call_script, "script_party_count_members_with_full_health", "p_main_party_backup"),
          (assign, ":org_total_party_counts", reg0),
          (try_begin),
            (le, ":org_total_party_counts",0),
            (assign, ":continue", 1),
          (try_end),
          (eq, ":continue", 0),
          (call_script, "script_party_count_members_with_full_health", "p_encountered_party_backup"),
          (assign, ":orig_enemy_party_counts", reg0),
          (try_begin),
            (le, ":orig_enemy_party_counts",0),
            (assign, ":orig_enemy_party_counts",1),
          (try_end),
          #           (val_add, ":org_total_party_counts", reg0),
          
          (call_script, "script_party_count_members_with_full_health", "p_main_party"),
          (assign, ":cur_total_party_counts", reg0),
          (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
          (assign, ":cur_enemy_party_counts", reg0),
          #           (val_add, ":cur_total_party_counts", reg0),
          (store_mul, ":leave_encounter_limit", ":cur_total_party_counts", 100),
          (val_div, ":leave_encounter_limit",  ":org_total_party_counts"),
          (store_mul, ":leave_enemy_limit", ":cur_enemy_party_counts", 100),
          (val_div, ":leave_enemy_limit",  ":orig_enemy_party_counts"),
          #           (store_sub, ":leave_encounter_limit", ":org_total_party_counts", 10),
          #           (lt, ":cur_total_party_counts", ":leave_encounter_limit"),
          (this_or_next|lt,":leave_enemy_limit", 10),
          (lt, ":leave_encounter_limit", 10),
          (assign, "$cant_leave_encounter", 0),
        (try_end),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (try_end),
      
      #####Lords commander options
      #     (str_clear, s8),
      (try_begin),
        (eq, "$g_encountered_party_template", "pt_kingdom_hero_party"),
        (eq, "$encountered_party_friendly", 0),
        (neg|troop_is_wounded, "trp_player"),
        (neq, "$g_empieza_asedio", 1),#no in sieges
        (party_get_current_terrain,":terrain","p_main_party"),
        (neq,":terrain",0),
        (neq,":terrain",7),
        (neq,":terrain",8),
        (ge,"$player_ambushed",2),
        (le, "$g_empieza_campeon", 0),
        (store_random_in_range,":commander_lords",1,9),
        (assign, ":commander_effect",0),# speech, religion, skirmishes
        (try_begin),
          (eq, ":commander_lords",1),#
          (assign, ":commander_effect",1),# speech = more morale to enemy Impassion your men with a rousing speech
          (call_script, "script_change_party_morale", "$g_enemy_party", 10),
          (assign, "$g_empieza_campeon", 1),
        (else_try),
          (eq, ":commander_lords",2),#
          (assign, ":commander_effect",2),# Religion
          (call_script, "script_change_party_morale", "$g_enemy_party", 6),
          (assign, "$g_empieza_campeon", 1),
        (else_try),
          (eq, ":commander_lords",3),#
          (assign, ":commander_effect",3),# skirmishes.
          (assign, "$g_empieza_campeon", 1),
          ### muertos
          (call_script, "script_simulate_battle_with_parties", 32, "$g_enemy_party", 36, "$g_ally_party", 0),
          (call_script, "script_encounter_calculate_fit"), ### call reg10 and reg11 again
          
          ###
        (else_try),
          (assign, ":commander_effect",0),
        (try_end),
      (try_end),
      ####################
      #setup s2
      (try_begin),
        (party_is_active, "$g_encountered_party"),
        (str_store_party_name, s1,"$g_encountered_party"),
        (try_begin),
          #chief ambush begin
          (eq, "$player_ambushed",1),#Ambush Yes
          (str_store_string,s2,"@Ambush! The enemy has maneuvered to gain a good position, and you fell into an ambush.^^Being ambushed puts you in a poor and disorganized defensive position, and your men will have morale problems and reduced ability to cause damage to your enemies.^^"), #
        (else_try), #chief ambush end
          (eq, "$g_encounter_type", 0),
          (eq, ":commander_effect",1),
          (str_store_string, s2,"@You have encountered {s1}.^^The warlord encourages his men with a rousing speech. Your enemies have very high morale.^^"),
        (else_try),
          (eq, "$g_encounter_type", 0),
          (eq, ":commander_effect",2),
          (str_store_string, s2,"@You have encountered {s1}.^^The warlord gathers his men to pray and invoke the protection of their god. Your enemies have high morale.^^"),
        (else_try),
          (eq, "$g_encounter_type", 0),
          (eq, ":commander_effect",3),
          (str_store_string, s2,"@You have encountered {s1}.^^Before we were prepared, we were surprised by enemy missile troops. They caused some casualties.^^"),
        (else_try), #chief commands lords end
          (eq, "$g_encounter_type", 0),
          (str_store_string, s2,"@You have encountered {s1}."),
        (else_try),
          (eq, "$g_encounter_type", enctype_fighting_against_village_raid),
          (str_store_party_name, s3, "$g_encounter_is_in_village"),
          (str_store_string, s2,"@You have engaged {s1} while they were raiding {s3}."),
        (else_try),
          (eq, "$g_encounter_type", enctype_catched_during_village_raid),
          (str_store_party_name, s3, "$g_encounter_is_in_village"),
          (str_store_string, s2,"@You were caught by {s1} while your forces were raiding {s3}."),
        (try_end),
      (try_end),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1), #battle won
          (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
          (le, ":num_enemy_regulars_remaining",  "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          (assign, ":enemy_finished",1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (this_or_next|le, ":num_enemy_regulars_remaining", 0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          (ge, "$g_friend_fit_for_battle",1),
          (assign, ":enemy_finished",1),
        (try_end),
        (this_or_next|eq, ":enemy_finished",1),
        (eq,"$g_enemy_surrenders",1),
        (assign, "$g_next_menu", -1),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        (assign, ":friends_finished",0),
        (try_begin),
          (eq, "$g_battle_result", -1),
          
          #(eq, ":num_our_regulars_remaining", 0), #battle lost
          (le, ":num_our_regulars_remaining",  "$num_routed_us"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign,  ":friends_finished", 1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (ge, "$g_enemy_fit_for_battle",1),
          (le, "$g_friend_fit_for_battle",0),
          (assign,  ":friends_finished",1),
        (try_end),
        
        (this_or_next|eq,  ":friends_finished",1),
        (eq,"$g_player_surrenders",1),
        
        (assign, "$g_next_menu", "mnu_captivity_start_wilderness"),
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
      
      
      #chief anadidos
      (try_begin),
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),
        (set_background_mesh, "mesh_pic_extra_navegando"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_looters"),
        (set_background_mesh, "mesh_pic_forest_bandits"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_mountain_bandits"),
        (set_background_mesh, "mesh_pic_forest_bandits"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_steppe_bandits"),
        (set_background_mesh, "mesh_pic_sea_raiders"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_taiga_bandits"),
        (set_background_mesh, "mesh_pic_sea_raiders"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_sea_raiders"),
        (set_background_mesh, "mesh_pic_bandits"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_sea_raiders2"),
        (set_background_mesh, "mesh_pic_sea_raiders"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_forest_bandits"),
        (set_background_mesh, "mesh_pic_bandits"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_deserters"),
        (set_background_mesh, "mesh_pic_deserters"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_kingdom_hero_party"),
        (party_stack_get_troop_id, ":leader_troop", "$g_encountered_party", 0),
        (ge, ":leader_troop", 1),
        (troop_get_slot, ":leader_troop_faction", ":leader_troop", slot_troop_original_faction),
        (try_begin),
          (eq, ":leader_troop_faction", fac_kingdom_1),
          (set_background_mesh, "mesh_pic_nord"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_2),
          (set_background_mesh, "mesh_pic_nord"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_3),
          (set_background_mesh, "mesh_pic_nord"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_4),
          (set_background_mesh, "mesh_pic_nord"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_5),
          (set_background_mesh, "mesh_pic_vaegir"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_6), ##puestos chief de aqui hasta 32
          (set_background_mesh, "mesh_pic_sarranid_encounter"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_7),
          (set_background_mesh, "mesh_pic_sarranid_encounter"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_8),
          (set_background_mesh, "mesh_pic_nord"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_9),
          (set_background_mesh, "mesh_pic_ambush"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_10),
          (set_background_mesh, "mesh_pic_ambush"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_11),
          (set_background_mesh, "mesh_pic_ambush"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_12),
          (set_background_mesh, "mesh_pic_ambush"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_13),
          (set_background_mesh, "mesh_pic_ambush"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_14),
          (set_background_mesh, "mesh_pic_rhodock"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_15),
          (set_background_mesh, "mesh_pic_rhodock"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_16),
          (set_background_mesh, "mesh_pic_rhodock"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_17),
          (set_background_mesh, "mesh_pic_rhodock"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_18),
          (set_background_mesh, "mesh_pic_rhodock"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_19),
          (set_background_mesh, "mesh_pic_rhodock"),
        (else_try),
          (eq, ":leader_troop_faction", fac_kingdom_20),
          (set_background_mesh, "mesh_pic_khergit"),
        (else_try),
          #(eq, ":leader_troop_faction", fac_kingdom_21),
          (set_background_mesh, "mesh_pic_rhodock"),
        (try_end),
      (else_try),
        (set_background_mesh, "mesh_pic_deserters"),
      (try_end),
      
      #MOTO chief document skill requuirement
      (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),
      (party_get_num_companion_stacks, ":stacks", "p_main_party"),
      (try_begin),
        (lt, ":tactics", 1),
        (gt, ":stacks", 1),
        (eq, "$encountered_party_friendly", 0),
        (neg|troop_is_wounded, "trp_player"),
        #Chief sea battles
        (party_get_current_terrain,":terrain","p_main_party"),
        (neq,":terrain",0),
        (neq,":terrain",7),
        (neq,":terrain",8),
        #sea battles
        (str_store_string, s2, "@{s2}^^You overhear one of your more experienced men grumbling about the lack of a battle plan, and you make a mental note to find someone that can make one.^^"),
      (try_end),
      #MOTO chief end
      
      (try_begin),
        (party_is_active,"$g_enemy_party"),#fix for kidnapped girl
        #Phaiak begin "Hatred feature"
        (try_begin),
          (party_slot_eq, "$g_enemy_party", slot_party_type, spt_village_farmer),
          (assign, "$courage_influence", -300),
          (str_store_string, s7, "@Your men feel uneasy about attacking innocents."),
        (else_try),
          (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan),
          (assign, "$courage_influence", -100),
          (str_store_string, s7, "@Your men feel uneasy about attacking traders."),
        (else_try),
          #OUTLAWS
          (store_faction_of_party, ":party_faction", "$g_enemy_party"),
          (this_or_next|eq, ":party_faction", "fac_outlaws"),
          (this_or_next|eq, ":party_faction", "fac_manhunters"),
          (this_or_next|eq, ":party_faction", "fac_mountain_bandits"),
          (this_or_next|eq, ":party_faction", "fac_forest_bandits"),
          (				eq, ":party_faction", "fac_deserters"),
          (str_store_string, s7, "@Your men feel good about attacking outlaws."),
          (assign, "$courage_influence", 100),
        (else_try),
          #LORDS
          (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_hero_party),
          (party_stack_get_troop_id, ":party_leader", "$g_enemy_party", 0),
          (str_store_troop_name, s8, ":party_leader"),
          (try_begin),
            (this_or_next|troop_slot_eq, ":party_leader", slot_lord_reputation_type, lrep_goodnatured),
            (this_or_next|troop_slot_eq, ":party_leader", slot_lord_reputation_type, lrep_upstanding),
            (			  troop_slot_eq, ":party_leader", slot_lord_reputation_type, lrep_martial),
            (try_begin),
              (encountered_party_is_attacker),
              (str_store_string, s7, "@Since {s8} has a good reputation, your troops feel a bit more confident than usual when attacked."),
              (assign, "$courage_influence", 200),
            (else_try),
              (str_store_string, s7, "@Your men feel uneasy about attacking {s8}, who is loved by the people."),
              (assign, "$courage_influence", -100),
            (end_try),
          (else_try),
            (this_or_next|troop_slot_eq, ":party_leader", slot_lord_reputation_type, lrep_selfrighteous),
            (this_or_next|troop_slot_eq, ":party_leader", slot_lord_reputation_type, lrep_cunning),
            (			  troop_slot_eq, ":party_leader", slot_lord_reputation_type, lrep_debauched),
            (try_begin),
              (encountered_party_is_attacker),
              (str_store_string, s7, "@Your men feel uneasy about being attacked by {s8}, because he is feared."),
              (assign, "$courage_influence", -200),
            (else_try),
              (str_store_string, s7, "@Your men are eager to attack {s8}, because he is hated."),
              (assign, "$courage_influence", 200),
            (end_try),
          (else_try),
            #lord personally not important
            (str_clear, s7),
            (assign, "$courage_influence", 0),
          (end_try),
        (else_try),
          #NOTHING
          (str_clear, s7),
          (assign, "$courage_influence", 0),
        (try_end),
        #Phaiak end
      (try_end),#fix for kidnapped girl
      (assign, "$new_encounter", 0),	#MOTO move to end so it can be used!
    ],
    [
      
      ####ambush chief Player Player can ambush to enemies too
      ("playerambush_attack",
        [ (eq,"$player_ambushed",2),
          (eq, "$encountered_party_friendly", 0),
          (neg|troop_is_wounded, "trp_player"),
          (neq, "$g_encounter_type", enctype_fighting_against_village_raid),
          (party_get_current_terrain, ":terrain_type", "p_main_party"),
          (neq,":terrain_type",0),	#no ambushes at sea
          (neq,":terrain_type",7),
          (neq,":terrain_type",8),
          #limit parties that ambush
          (neq, "$g_encountered_party",      "pt_boar_herd"),
          (neg|is_between, "$g_encountered_party",      "pt_merchant_caravan", "pt_kingdom_hero_party"),
          (neg|is_between, "$g_encountered_party",      "pt_steppe_bandit_lair", "pt_boar_herd"),
          
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_besieging_center),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_raiding_around_center),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_accompanying_army),
          (neg|party_slot_eq, "$g_encountered_party",      slot_party_ai_state, spai_visiting_village),
          #end limit parties that ambush
          (assign, ":continue", 0), #ambush chief system
          (try_begin),
            (assign, ":ambush_ai_yes", 1), #ambush chief system
            (try_begin),
              (eq, ":terrain_type", rt_steppe),
              (val_add, ":ambush_ai_yes", 10),
            (else_try),
              (eq, ":terrain_type", rt_plain),
              (val_add, ":ambush_ai_yes", 12),
            (else_try),
              (eq, ":terrain_type", rt_snow),
              (val_add, ":ambush_ai_yes", 14),
            (else_try),
              (eq, ":terrain_type", rt_desert),
              (val_add, ":ambush_ai_yes", 10),
            (else_try),
              (eq, ":terrain_type", rt_steppe_forest),
              (val_add, ":ambush_ai_yes", 18),
            (else_try),
              (eq, ":terrain_type", rt_forest),
              (val_add, ":ambush_ai_yes", 30),
            (else_try),
              (eq, ":terrain_type", rt_snow_forest),
              (val_add, ":ambush_ai_yes", 26),
            (else_try),
              (val_add, ":ambush_ai_yes", 10),
            (try_end),
            #big armies = more difficult to do ambush
            (store_party_size_wo_prisoners, ":player_strength", "p_main_party"),
            (try_begin),
              (le, ":player_strength", 30),
              (val_add, ":ambush_ai_yes", 30),
            (else_try),
              (le, ":player_strength", 60),
              (val_add, ":ambush_ai_yes", 20),
            (else_try),
              (le, ":player_strength", 120),
              (val_add, ":ambush_ai_yes", 16),
            (else_try),
              (le, ":player_strength", 240),
              (val_add, ":ambush_ai_yes", 12),
            (else_try),
              (val_add, ":ambush_ai_yes", 10),
            (try_end),
            
            #player skills helping to avoid ambush
            (call_script, "script_get_max_skill_of_player_party", "skl_spotting"),
            (assign, ":spotting_skill", reg0),
            (val_add,":ambush_ai_yes",":spotting_skill"),
            (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),
            (val_add,":ambush_ai_yes",":tactics"),
            
            (val_max, ":ambush_ai_yes", 1),
            ###
            
            (store_random_in_range,":ambush_ratio",0,400),
            
            (try_begin),
              (lt,":ambush_ratio",":ambush_ai_yes"),
              (assign, ":continue", 1), #ambush chief system
              #   (assign,"$player_ambushed",4), #ambush effect for player enemies in battle
            (else_try),
              (assign,"$player_ambushed",3), #ambush check only once per battle
            (try_end),
          (try_end),
          (eq, ":continue", 1), #ambush chief player yes
        ],
        "Ambush attack!",
        [
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          #ambush scene
          (party_get_current_terrain, ":terrain_type", "p_main_party"),
          (party_get_position, pos4, "p_main_party"),
          (position_get_z, ":elevation", pos4),
          
          (assign, ":scene_to_use", "scn_random_scene"),
          (try_begin),
            (gt, ":elevation", 200),
            (assign, ":scene_to_use", "scn_ambush_mountains"),
          (else_try),
            (map_get_water_position_around_position, pos2, pos4, 10),
            (assign, ":scene_to_use", "scn_ambush_coast"),
          (else_try),
            (eq, ":terrain_type", rt_snow),
            (assign, ":scene_to_use", "scn_ambush_snow"),
          (else_try),
            (eq, ":terrain_type", rt_steppe_forest),
            (assign, ":scene_to_use", "scn_ambush_forest"),
          (else_try),
            (eq, ":terrain_type", rt_forest),
            (assign, ":scene_to_use", "scn_ambush_forest"),
          (else_try),
            (eq, ":terrain_type", rt_snow_forest),
            (assign, ":scene_to_use", "scn_ambush_snow"),
          (else_try),
            (assign, ":continue_bridge", 0),  #party is within distance   #more distance for kingdom messengers
            (try_for_range, ":cur_party", "p_Bridge_1", "p_ferry_1a"),
              (store_distance_to_party_from_party, ":cur_distance", ":cur_party", "p_main_party"),
              (lt, ":cur_distance", 10),  #party is within distance   #more distance for kingdom messengers
              (assign, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            (try_end),
            (eq, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_ambush_river_plain"),
          (else_try),
            
            (store_random_in_range, ":scene_a_usar", 1,4),
            (try_begin),
              (eq, ":scene_a_usar", 1),
              (assign, ":scene_to_use", "scn_ambush_farmland"),
            (else_try),
              (eq, ":scene_a_usar", 2),
              (assign, ":scene_to_use", "scn_ambush_marshland"),
            (else_try),
              (eq, ":scene_a_usar", 3),
              (assign, ":scene_to_use", "scn_ambush_hills"),
            (else_try),
              (assign, ":scene_to_use", "scn_ambush_farmland"),
            (try_end),
          (try_end),
          ###
          (set_jump_mission,"mt_lead_charge"),
          (jump_to_scene, ":scene_to_use"),
          (assign,"$player_ambushed",4), #ambush effect for player enemies in battle
          
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ####ambush chief AI
      ("ambush_attack",
        [(eq,"$player_ambushed",1),
          (eq, "$encountered_party_friendly", 0),
          (neg|troop_is_wounded, "trp_player"),
        ],
        "Ambush defense!",
        [
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          #ambush scene
          (party_get_current_terrain, ":terrain_type", "p_main_party"),
          (party_get_position, pos4, "p_main_party"),
          (position_get_z, ":elevation", pos4),
          
          (assign, ":scene_to_use", "scn_random_scene"),
          (try_begin),
            (gt, ":elevation", 200),
            (assign, ":scene_to_use", "scn_ambushed_mountains"),
          (else_try),
            (map_get_water_position_around_position, pos2, pos4, 10),
            (assign, ":scene_to_use", "scn_ambushed_coast"),
          (else_try),
            (eq, ":terrain_type", rt_snow),
            (assign, ":scene_to_use", "scn_ambushed_snow"),
          (else_try),
            (eq, ":terrain_type", rt_steppe_forest),
            (assign, ":scene_to_use", "scn_ambushed_forest"),
          (else_try),
            (eq, ":terrain_type", rt_forest),
            (assign, ":scene_to_use", "scn_ambushed_forest"),
          (else_try),
            (eq, ":terrain_type", rt_snow_forest),
            (assign, ":scene_to_use", "scn_ambushed_snow"),
          (else_try),
            (assign, ":continue_bridge", 0),  #party is within distance   #more distance for kingdom messengers
            (try_for_range, ":cur_party", "p_Bridge_1", "p_ferry_1a"),
              (store_distance_to_party_from_party, ":cur_distance", ":cur_party", "p_main_party"),
              (lt, ":cur_distance", 5),  #party is within distance   #more distance for kingdom messengers
              (assign, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            (try_end),
            (eq, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_ambushed_river_plain"),
          (else_try),
            
            (store_random_in_range, ":scene_a_usar", 1,4),
            (try_begin),
              (eq, ":scene_a_usar", 1),
              (assign, ":scene_to_use", "scn_ambushed_farmland"),
            (else_try),
              (eq, ":scene_a_usar", 2),
              (assign, ":scene_to_use", "scn_ambushed_marshland"),
            (else_try),
              (eq, ":scene_a_usar", 3),
              (assign, ":scene_to_use", "scn_ambushed_hills"),
            (else_try),
              (assign, ":scene_to_use", "scn_ambushed_farmland"),
            (try_end),
          (try_end),
          ###
          (set_jump_mission,"mt_lead_charge"),
          (jump_to_scene, ":scene_to_use"),
          (assign,"$player_ambushed",5), #ambush effect on, ambuch effec continue in next rounds but no ambush battle, as ambush battle will be first round only.
          
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ############
      
      
      ("encounter_attack",
        [
          (eq, "$encountered_party_friendly", 0),
          (neg|troop_is_wounded, "trp_player"),
          (neq, "$player_ambushed",1),#Ambush Yes
          
          (try_begin),
            (party_slot_eq, "p_main_party", slot_party_on_water, 1),
            (str_store_string, s7, "@Board"),
          (else_try),
            (str_store_string, s7, "@Charge"),
          (end_try),
          
        ],
        "{s7} the enemy.",
        [
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
          (try_begin),
            (eq, ":encountered_party_template", "pt_village_farmers"),
            (unlock_achievement, ACHIEVEMENT_HELP_HELP_IM_BEING_REPRESSED),
          (try_end),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (try_begin),
            (eq, "$g_encounter_type", enctype_fighting_against_village_raid),
            (assign, "$g_village_raid_evil", 0),
            (set_jump_mission,"mt_village_raid"),
            (party_get_slot, ":scene_to_use", "$g_encounter_is_in_village", slot_castle_exterior),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (eq, "$g_encounter_type", enctype_catched_during_village_raid),
            (assign, "$g_village_raid_evil", 0),
            (set_jump_mission,"mt_village_raid"),
            (party_get_slot, ":scene_to_use", "$g_encounter_is_in_village", slot_castle_exterior),
            (jump_to_scene, ":scene_to_use"),
            # phaiak chief begin
          (else_try),
            (party_slot_eq, "p_main_party", slot_party_on_water, 1),	# = sea battle
            #(party_get_num_companions, ":num_enemy", "$g_encountered_party"),
            #new begin
            (try_begin),
              (store_faction_of_party, ":party_faction", "$g_encountered_party"),
              (this_or_next|eq, ":party_faction", "fac_outlaws"),
              (this_or_next|eq, ":party_faction", "fac_manhunters"),
              (this_or_next|eq, ":party_faction", "fac_mountain_bandits"),
              (this_or_next|eq, ":party_faction", "fac_forest_bandits"),
              (this_or_next|eq, ":party_faction", "fac_deserters"),
              (party_slot_eq, "$g_encountered_party", slot_party_type, spt_kingdom_hero_party),
              (assign, ":prepare_party_ships_for_team_script", "script_randomize_ships_for_team_war_party"),
            (else_try),
              (assign, ":prepare_party_ships_for_team_script", "script_randomize_ships_for_team_civilian"),
            (end_try),
            #new end
            (call_script, "script_party_count_members_with_full_health", "$g_encountered_party"),
            (assign, ":num_enemy", reg0),
            (call_script, "script_party_count_members_with_full_health", "p_main_party"),
            (store_add, "$startup_battle_size", ":num_enemy", reg0),
            (try_begin),
              (encountered_party_is_attacker),
              (select_enemy, 1),
              (assign, "$player_team_in_sea_battle", 0),
              (call_script, "script_prepare_party_ships_for_team", "p_main_party", 0),
              (call_script, ":prepare_party_ships_for_team_script", 1, ":num_enemy"),
            (else_try),
              (select_enemy, 0),
              (assign, "$player_team_in_sea_battle", 1),
              (call_script, ":prepare_party_ships_for_team_script", 0, ":num_enemy"),
              (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
            (end_try),
            (set_jump_mission,"mt_sea_battle"),
            #(jump_to_scene,"scn_sea_battle"),
            (call_script, "script_setup_random_sea_scene"),
            (assign, "$g_next_menu", "mnu_simple_encounter"),
            (jump_to_menu, "mnu_battle_debrief"),
            (change_screen_mission),
            # phaiak end
            #caravan chief anadido
          (else_try),
            (eq, ":encountered_party_template", "pt_kingdom_caravan_party"),
            (try_begin),
              (store_random_in_range, ":scene_a_usar", 1,4),
              (try_begin),
                (eq, ":scene_a_usar", 1),
                (assign, ":scene_to_use", "scn_caravanatacada"),
              (else_try),
                (eq, ":scene_a_usar", 2),
                (assign, ":scene_to_use", "scn_caravan_ambush"),
              (else_try),
                (eq, ":scene_a_usar", 3),
                (assign, ":scene_to_use", "scn_caravanatacada"),
              (else_try),
                (assign, ":scene_to_use", "scn_caravan_ambush"),
              (try_end),
            (try_end),
            #caravan terrain acaba
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            #chief escenas unicas empieza
          (else_try), #player lair
            (eq, "$lair_on", 1),
            (encountered_party_is_attacker), #only if player is deffeding, no attacking chief
            (party_is_active, "p_yourlair"),
            (store_distance_to_party_from_party, ":cur_distance", "p_yourlair", "p_main_party"),
            # (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
            (assign, ":distance_ok", 0),  #party is within distance   #more distance for kingdom messengers
            (try_begin),
              (is_currently_night),
              (lt, ":cur_distance", 2),  #party is within distance   #more distance for kingdom messengers
              (assign, ":distance_ok", 1),  #party is within distance   #more distance for kingdom messengers
            (else_try), #player lair
              (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
              (assign, ":distance_ok", 1),  #party is within distance   #more distance for kingdom messengers
            (try_end),
            (eq, ":distance_ok", 1),  #party is within distance   #more distance for kingdom messengers
            (try_begin), #player lair
              (party_slot_eq, "p_yourlair", slot_lair_improve, 4), #Refuge
              (assign, ":scene_to_use", "scn_player_hideout_5"),
            (else_try),
              (party_slot_eq, "p_yourlair", slot_lair_improve, 2), #hideout
              (assign, ":scene_to_use", "scn_player_hideout_3"),
            (else_try),
              (assign, ":scene_to_use", "scn_player_hideout_1"),#permanent camp
            (try_end),
            
            # (assign, ":scene_to_use", "scn_lair_exterior"),
            # (assign,"$battle_type",1),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            ########### Fortified camp
          (else_try),
            (eq, "$fortified_camp", 1), #fortified ok
            (assign, ":scene_to_use", "scn_player_camp_fortified"),
            (assign,"$chest_broken",1),	 #possible camp pillage
            
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            #################
          (else_try), #normal camp
            (eq, "$g_player_icon_state", pis_camping), #camp normal
            (assign,"$chest_broken",1),	 #possible camp pillage
            (assign, ":scene_to_use", "scn_player_camp"),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_battle_stones", "p_main_party"),
            (lt, ":cur_distance", 3),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_battle_stonesb"),
            (assign,"$battle_type",1),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_circle_mystic1", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_circle_mysticb"),
            (assign,"$battle_type",2),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_roman_fort", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_roman_fortb"),
            (assign,"$battle_type",3),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_hadrian_wall1", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_hadrian_wallb"),
            (assign,"$battle_type",4),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_farmland_special", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_farmlandb"),
            (assign,"$battle_type",5),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (assign, ":continue_bridge", 0),  #party is within distance   #more distance for kingdom messengers
            (try_for_range, ":cur_party", "p_Bridge_1", "p_ferry_1a"),
              (store_distance_to_party_from_party, ":cur_distance", ":cur_party", "p_main_party"),
              (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
              (assign, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            (try_end),
            (eq, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            #  (lt, ":cur_distance", 11),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_bridge_battleb"),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            ###
          (else_try),
            (set_jump_mission,"mt_lead_charge"),
            (call_script, "script_setup_random_scene"),
          (try_end),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      
      #MOTO chief -- copy from encounter_attack except for marked lines
      ("encounter_deploy",	#MOTO
        [
          (neq, "$player_ambushed",1),#Ambush Yes
          (eq, "$encountered_party_friendly", 0),
          (neg|troop_is_wounded, "trp_player"),
          #Chief sea battles
          (party_get_current_terrain,":terrain","p_main_party"),
          (neq,":terrain",0),
          (neq,":terrain",7),
          (neq,":terrain",8),
          #sea battles
          (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),	#MOTO
          (ge, ":tactics", 1),	#MOTO
        ],
        "Start battle holding position.",	#MOTO
        [
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
          (try_begin),
            (eq, ":encountered_party_template", "pt_village_farmers"),
            (unlock_achievement, ACHIEVEMENT_HELP_HELP_IM_BEING_REPRESSED),
          (try_end),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (try_begin),
            (eq, "$g_encounter_type", enctype_fighting_against_village_raid),
            (assign, "$g_village_raid_evil", 0),
            (set_jump_mission,"mt_village_raid"),
            (party_get_slot, ":scene_to_use", "$g_encounter_is_in_village", slot_castle_exterior),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (eq, "$g_encounter_type", enctype_catched_during_village_raid),
            (assign, "$g_village_raid_evil", 0),
            (set_jump_mission,"mt_village_raid"),
            (party_get_slot, ":scene_to_use", "$g_encounter_is_in_village", slot_castle_exterior),
            (jump_to_scene, ":scene_to_use"),
            #caravan chief anadido
          (else_try),
            (eq, ":encountered_party_template", "pt_kingdom_caravan_party"),
            (try_begin),
              (store_random_in_range, ":scene_a_usar", 1,4),
              (try_begin),
                (eq, ":scene_a_usar", 1),
                (assign, ":scene_to_use", "scn_caravanatacada"),
              (else_try),
                (eq, ":scene_a_usar", 2),
                (assign, ":scene_to_use", "scn_caravan_ambush"),
              (else_try),
                (eq, ":scene_a_usar", 3),
                (assign, ":scene_to_use", "scn_caravanatacada"),
              (else_try),
                (assign, ":scene_to_use", "scn_caravan_ambush"),
              (try_end),
            (try_end),
            #caravan terrain acaba
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            #chief escenas unicas empieza
          (else_try), #player lair
            (eq, "$lair_on", 1),
            (encountered_party_is_attacker), #only if player is deffeding, no attacking chief
            (party_is_active, "p_yourlair"),
            (store_distance_to_party_from_party, ":cur_distance", "p_yourlair", "p_main_party"),
            (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
            (try_begin), #player lair
              (party_slot_eq, "p_yourlair", slot_lair_improve, 4), #Refuge
              (assign, ":scene_to_use", "scn_player_hideout_5"),
            (else_try),
              (party_slot_eq, "p_yourlair", slot_lair_improve, 2), #hideout
              (assign, ":scene_to_use", "scn_player_hideout_3"),
            (else_try),
              (assign, ":scene_to_use", "scn_player_hideout_1"),#permanent camp
            (try_end),
            
            # (assign, ":scene_to_use", "scn_lair_exterior"),
            # (assign,"$battle_type",1),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            ########### Fortified camp
          (else_try),
            (eq, "$fortified_camp", 1), #fortified ok
            (assign, ":scene_to_use", "scn_player_camp_fortified"),
            (assign,"$chest_broken",1),	 #possible camp pillage
            
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            #################
          (else_try), #normal camp
            (eq, "$g_player_icon_state", pis_camping), #camp normal
            (assign,"$chest_broken",1),	 #possible camp pillage
            (assign, ":scene_to_use", "scn_player_camp"),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_battle_stones", "p_main_party"),
            (lt, ":cur_distance", 3),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_battle_stonesb"),
            (assign,"$battle_type",1),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_circle_mystic1", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_circle_mysticb"),
            (assign,"$battle_type",2),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_roman_fort", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_roman_fortb"),
            (assign,"$battle_type",3),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_hadrian_wall1", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_hadrian_wallb"),
            (assign,"$battle_type",4),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (store_distance_to_party_from_party, ":cur_distance", "p_farmland_special", "p_main_party"),
            (lt, ":cur_distance", 6),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_farmlandb"),
            (assign,"$battle_type",5),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
          (else_try),
            (assign, ":continue_bridge", 0),  #party is within distance   #more distance for kingdom messengers
            (try_for_range, ":cur_party", "p_Bridge_1", "p_ferry_1a"),
              (store_distance_to_party_from_party, ":cur_distance", ":cur_party", "p_main_party"),
              (lt, ":cur_distance", 4),  #party is within distance   #more distance for kingdom messengers
              (assign, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            (try_end),
            (eq, ":continue_bridge", 1),  #party is within distance   #more distance for kingdom messengers
            #  (lt, ":cur_distance", 11),  #party is within distance   #more distance for kingdom messengers
            (assign, ":scene_to_use", "scn_bridge_battleb"),
            (set_jump_mission,"mt_lead_charge"),
            (jump_to_scene, ":scene_to_use"),
            ###
          (else_try),
            (set_jump_mission,"mt_lead_charge"),
            (call_script, "script_setup_random_scene"),
          (try_end),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
          
          (assign, "$player_deploy_troops", 1),	#MOTO
      ]),
      #MOTO chief end
      
      # #chief sea battles empieza
      # ("encounter_sea_attack",[
      # (eq, "$encountered_party_friendly", 0),
      # (neg|troop_is_wounded, "trp_player"),
      # (party_get_current_terrain,":terrain","p_main_party"),
      # (this_or_next|eq,":terrain",0),
      # (this_or_next|eq,":terrain",7),
      # (eq,":terrain",8),
      # ],"Board the enemy.",[
      # (assign, "$g_battle_result", 0),
      # (assign, "$g_engaged_enemy", 1),
      
      # (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
      # (try_begin),
      # (eq, ":encountered_party_template", "pt_village_farmers"),
      # (unlock_achievement, ACHIEVEMENT_HELP_HELP_IM_BEING_REPRESSED),
      # (try_end),
      
      # (call_script, "script_calculate_renown_value"),
      # (call_script, "script_calculate_battle_advantage"),
      # (set_battle_advantage, reg0),
      # (set_party_battle_mode),
      # (store_random_in_range, ":scene_a_sea", 1,3),
      
      # #phaiak sea battle chief
      # (try_begin),
      # (eq, ":scene_a_sea", 1),
      # (display_message, "@mno_encounter_sea_attack: dynamic scene"),
      # (set_jump_mission,"mt_sea_battle"),
      # (jump_to_scene, "scn_sea_battle"),
      # #phaiak acaba
      
      # #Adorno
      # (else_try),
      # (display_message, "@mno_encounter_sea_attack: static scene"),
      # (set_jump_mission,"mt_ship_battle2"),
      # (val_add,reg10,reg11),
      # (try_begin),
      # (gt,reg10,60),
      # (jump_to_scene, "scn_sea_4"),
      # (else_try),
      # (gt,reg10,30),
      # (jump_to_scene, "scn_sea_3"),
      # (else_try),
      # (jump_to_scene, "scn_sea_1"),
      # (try_end),
      # (try_end),
      # #Adorno end
      
      # (assign, "$g_next_menu", "mnu_simple_encounter"),
      # (jump_to_menu, "mnu_battle_debrief"),
      # (change_screen_mission),
      # ]),
      # #chief sea battles acaba
      
      ("encounter_order_attack",
        [      # (neq, "$player_ambushed",1),#Ambush Yes
          
          (eq, "$encountered_party_friendly", 0),
          (call_script, "script_party_count_members_with_full_health", "p_main_party"),(ge, reg0, 4),
        ],
        "Order your troops to attack without you.",
        [
          (jump_to_menu, "mnu_order_attack_begin"),
          #(simulate_battle,3),
      ]),
      
      ###chief tacticas, discursos, combate campeones etc...
      ("tactical_nuevo",[        (neq, "$player_ambushed",1),#Ambush Yes
          (neq, "$g_empieza_asedio", 1),#no in sieges
          (eq, "$encountered_party_friendly", 0),
          (neg|troop_is_wounded, "trp_player"),
          (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),
          (ge, ":tactics", 4),
          (party_get_current_terrain,":terrain","p_main_party"),
          (neq,":terrain",0),
          (neq,":terrain",7),
          (neq,":terrain",8),
        ],"Commander's Options.",
        [
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (try_begin),
            (ge, ":num_men", 50), # deja pasar si el player tiene por lo menos 50 hombres
            #(assign,"$emboscada_time", 1), #antes de 48 horas no puede haber otra emboscada ambush chief
            (jump_to_menu,"mnu_panel_comandante"),
          (else_try),
            (display_message,"@You need to have 50 or more men in order to use the commander panel."),
          (try_end),
      ]),
      #tactical chief acaba
      
      ("leave",[        (neq, "$player_ambushed",1),#Ambush Yes
          
          (eq,"$cant_leave_encounter", 0),
          ],"Leave.",[
          
          ###NPC companion changes begin
          (try_begin),
            (eq, "$encountered_party_friendly", 0),
            (encountered_party_is_attacker),
            (call_script, "script_objectionable_action", tmt_aristocratic, "str_flee_battle"),
          (try_end),
          ###NPC companion changes end
          #Troop commentary changes begin
          (try_begin),
            (eq, "$encountered_party_friendly", 0),
            #                  (encountered_party_is_attacker),
            (party_get_num_companion_stacks, ":num_stacks", "p_encountered_party_backup"),
            (try_for_range, ":stack_no", 0, ":num_stacks"),
              (party_stack_get_troop_id,   ":stack_troop","p_encountered_party_backup",":stack_no"),
              (is_between, ":stack_troop", active_npcs_begin, active_npcs_end),
              (troop_slot_eq, ":stack_troop", slot_troop_occupation, slto_kingdom_hero),
              (store_troop_faction, ":victorious_faction", ":stack_troop"),
              #					(store_relation, ":relation_with_stack_troop", ":victorious_faction", "fac_player_faction"),
              #					(lt, ":relation_with_stack_troop", 0),
              (call_script, "script_add_log_entry", logent_player_retreated_from_lord, "trp_player",  -1, ":stack_troop", ":victorious_faction"),
            (try_end),
          (try_end),
          (try_begin),
            (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
            (eq,":player_renown", "$temp3"),
            (store_character_level, ":player_level", "trp_player"), #depend on level, more level more penalty
            (assign, ":renown_change", ":player_level"),
            (val_mul, ":renown_change", "$temp2"),
            (val_div, ":renown_change", "$temp_2"),
            (val_mul, ":renown_change", -1),
            (store_mul, ":renown_limit", ":player_level", -1),
            (val_add, ":renown_limit", -1),
            (options_get_campaign_ai, ":reduce_campaign_ai"), #moto chief
            (try_begin),
              (eq, ":reduce_campaign_ai", 0), #hard
              (assign, ":renown_mod", 150),
            (else_try),
              (eq, ":reduce_campaign_ai", 1), #medium
              (assign, ":renown_mod", 100),
            (else_try),
              (eq, ":reduce_campaign_ai", 2), #easy
              (assign, ":renown_mod", 50),
            (try_end),
            (val_mul, ":renown_limit", ":renown_mod"),
            (val_div, ":renown_limit", 100),
            (val_max, ":renown_change", ":renown_limit"),
            (val_min, ":renown_change", -1),
            (call_script,"script_change_troop_renown", "trp_player", ":renown_change"),
          (try_end),
          #Troop commentary changes end
          (leave_encounter),
          (change_screen_return),
      ]),
      ("encounter_retreat",[       # (neq, "$player_ambushed",1),#Ambush Yes
          
          (eq,"$cant_leave_encounter", 1),
          (neg|party_slot_eq, "p_main_party", slot_party_on_water, 1),	#no retreat on sea VC-2133
          (assign, ":continue", 0),
          (try_begin),
            (check_quest_active, "qst_blank_quest_15"),
            (quest_get_slot, ":cur_lord", "qst_blank_quest_15", slot_quest_target_troop),
            (eq, ":cur_lord", "$g_talk_troop"),
            (assign, ":continue", 1),
          (try_end),
          (eq, ":continue", 0),
          (call_script, "script_get_max_skill_of_player_party", "skl_tactics"),
          (assign, ":max_skill", reg0),
          (val_add, ":max_skill", 4),
          
          (call_script, "script_party_count_members_with_full_health", "p_collective_enemy", 0),
          (assign, ":enemy_party_strength", reg0),
          (val_div, ":enemy_party_strength", 2),
          
          (val_div, ":enemy_party_strength", ":max_skill"),
          (val_max, ":enemy_party_strength", 1),
          
          (call_script, "script_party_count_fit_regulars", "p_main_party"),
          (assign, ":player_count", reg0),
          (ge, ":player_count", ":enemy_party_strength"),
          (gt, ":player_count", 20),
          ],"Pull back, leaving some soldiers behind to cover your retreat.",[(jump_to_menu, "mnu_encounter_retreat_confirm"),]),
      
      ("encounter_surrender",[
          (this_or_next|eq, "$player_ambushed",1),#Ambush Yes
          (eq,"$cant_leave_encounter", 1),
          ],"Surrender.",[(assign,"$g_player_surrenders",1)]),
      #####chief acceso a tropas cercanas
      ##      ("fuerzas_enliza",[
      ##	(eq, "$encountered_party_friendly", 0),
      ##								(eq,"$force_presentation_shown",0),
      ##							],"Assess nearby forces.",
      ##							[(start_presentation,"prsnt_force_composition"),]),
      
    ]
  ),
  (
    "encounter_retreat_confirm",0,
    "As the party member with the highest tactics skill, " +
    "({reg2}), {reg3?you devise:{s3} devises} a plan that will allow you and your men to escape unscathed, " +
    "but you'll have to leave {reg4} soldiers behind to prevent the enemy from giving chase.",
    "none",
    [(play_sound, "snd_raven"),
      (set_background_mesh, "mesh_pic_raven"), #pic book
      (call_script, "script_get_max_skill_of_player_party", "skl_tactics"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      (assign, reg2, ":max_skill"),
      (val_add, ":max_skill", 4),
      
      (call_script, "script_party_count_members_with_full_health", "p_collective_enemy", 0),
      (assign, ":enemy_party_strength", reg0),
      (val_div, ":enemy_party_strength", 2),
      
      (store_div, reg4, ":enemy_party_strength", ":max_skill"),
      (val_max, reg4, 1),
      
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s3, ":max_skill_owner"),
      (try_end),
      (assign, "$temp", reg4),
    ],
    [
      ("leave_behind",[],"Go on. The sacrifice of these men will save the rest.",
        [
          (assign, ":num_casualties", "$temp"),
          (assign, reg45, "$temp"),
          (display_message, "@{reg45} will be lost."),
          (try_for_range, ":unused", 0, ":num_casualties"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
            (assign, ":lost_troop", reg0),
            (store_random_in_range, ":random_no", 0, 100),
            (ge, ":random_no", 30),
            (party_add_prisoners, "$g_encountered_party", ":lost_troop", 1),
          (try_end),
          (call_script, "script_change_player_party_morale", -10),
          (jump_to_menu, "mnu_encounter_retreat"),
      ]),
      ("dont_leave_behind",[],"No. We leave no one behind.",[(jump_to_menu, "mnu_simple_encounter"),]),
    ]
  ),
  (
    "encounter_retreat",0,
    "You tell {reg4} of your troops to hold the enemy while you retreat with the rest of your party.",
    "none",
    [ (set_background_mesh, "mesh_pic_steppe_bandits"), #pic book
    ],
    [
      ("continue",[],"Continue...",
        [
          ###Troop commentary changes begin
          (call_script, "script_objectionable_action", tmt_aristocratic, "str_flee_battle"),
          (party_get_num_companion_stacks, ":num_stacks", "p_encountered_party_backup"),
          (try_for_range, ":stack_no", 0, ":num_stacks"),
            (party_stack_get_troop_id,   ":stack_troop","p_encountered_party_backup",":stack_no"),
            (is_between, ":stack_troop", active_npcs_begin, active_npcs_end),
            (troop_slot_eq, ":stack_troop", slot_troop_occupation, slto_kingdom_hero),
            (store_troop_faction, ":victorious_faction", ":stack_troop"),
            (call_script, "script_add_log_entry", logent_player_retreated_from_lord_cowardly, "trp_player",  -1, ":stack_troop", ":victorious_faction"),
          (try_end),
          ###Troop commentary changes end
          (party_ignore_player, "$g_encountered_party", 1),
          (leave_encounter),
          (change_screen_return)
      ]),
    ]
  ),
  (
    "order_attack_begin",0,
    "Your troops prepare to attack the enemy.",
    "none",
    [
      (set_background_mesh, "mesh_pic_charge"), #pic book
    ],
    [
      ("order_attack_begin",[],"Order the attack.",
        [
          (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
          (try_begin),
            (eq, ":encountered_party_template", "pt_village_farmers"),
            (unlock_achievement, ACHIEVEMENT_HELP_HELP_IM_BEING_REPRESSED),
          (try_end),
          
          (assign, "$g_engaged_enemy", 1),
          (jump_to_menu,"mnu_order_attack_2"),
      ]),
      ("call_back",[],"Call them back.",[(jump_to_menu,"mnu_simple_encounter")]),
    ]
  ),
  (
    "order_attack_2",mnf_disable_all_keys,
    "{s4}^^Your casualties: {s8}^^Enemy casualties: {s9}",
    "none",
    [
      (set_background_mesh, "mesh_pic_charge"),
      
      (call_script, "script_party_calculate_strength", "p_main_party", 1), #exclude player
      (assign, ":player_party_strength", reg0),
      
      (call_script, "script_party_calculate_strength", "p_collective_enemy", 0),
      (assign, ":enemy_party_strength", reg0),
      
      (party_collect_attachments_to_party, "p_main_party", "p_collective_ally"),
      (call_script, "script_party_calculate_strength", "p_collective_ally", 1), #exclude player
      (assign, ":total_player_and_followers_strength", reg0),
      
      (try_begin),
        (le, ":total_player_and_followers_strength", ":enemy_party_strength"),
        (assign, ":minimum_power", ":total_player_and_followers_strength"),
      (else_try),
        (assign, ":minimum_power", ":enemy_party_strength"),
      (try_end),
      
      (try_begin),
        (le, ":minimum_power", 25),
        (assign, ":division_constant", 1),
      (else_try),
        (le, ":minimum_power", 50),
        (assign, ":division_constant", 2),
      (else_try),
        (le, ":minimum_power", 75),
        (assign, ":division_constant", 3),
      (else_try),
        (le, ":minimum_power", 125),
        (assign, ":division_constant", 4),
      (else_try),
        (le, ":minimum_power", 200),
        (assign, ":division_constant", 5),
      (else_try),
        (le, ":minimum_power", 400),
        (assign, ":division_constant", 6),
      (else_try),
        (le, ":minimum_power", 800),
        (assign, ":division_constant", 7),
      (else_try),
        (le, ":minimum_power", 1600),
        (assign, ":division_constant", 8),
      (else_try),
        (le, ":minimum_power", 3200),
        (assign, ":division_constant", 9),
      (else_try),
        (le, ":minimum_power", 6400),
        (assign, ":division_constant", 10),
      (else_try),
        (le, ":minimum_power", 12800),
        (assign, ":division_constant", 11),
      (else_try),
        (le, ":minimum_power", 25600),
        (assign, ":division_constant", 12),
      (else_try),
        (le, ":minimum_power", 51200),
        (assign, ":division_constant", 13),
      (else_try),
        (le, ":minimum_power", 102400),
        (assign, ":division_constant", 14),
      (else_try),
        (assign, ":division_constant", 15),
      (try_end),
      
      (val_div, ":player_party_strength", ":division_constant"), #1.126, ":division_constant" was 5 before
      (val_max, ":player_party_strength", 1), #1.126
      (val_div, ":enemy_party_strength", ":division_constant"), #1.126, ":division_constant" was 5 before
      (val_max, ":enemy_party_strength", 1), #1.126
      (val_div, ":total_player_and_followers_strength", ":division_constant"), #1.126, ":division_constant" was 5 before
      (val_max, ":total_player_and_followers_strength", 1), #1.126
      
      (store_mul, "$g_strength_contribution_of_player", ":player_party_strength", 100),
      (val_div, "$g_strength_contribution_of_player", ":total_player_and_followers_strength"),
      
      (inflict_casualties_to_party_group, "p_main_party", ":enemy_party_strength", "p_temp_casualties"),
      (call_script, "script_print_casualties_to_s0", "p_temp_casualties", 0),
      (str_store_string_reg, s8, s0),
      
      (try_begin),
        (ge, "$g_ally_party", 0),
        (inflict_casualties_to_party_group, "$g_ally_party", ":enemy_party_strength", "p_temp_casualties"),
        (str_store_string_reg, s8, s0),
      (try_end),
      
      (inflict_casualties_to_party_group, "$g_encountered_party", ":total_player_and_followers_strength", "p_temp_casualties"),
      
      #ozan begin
      (party_get_num_companion_stacks, ":num_stacks", "p_temp_casualties"),
      (try_for_range, ":stack_no", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":stack_troop", "p_temp_casualties", ":stack_no"),
        (try_begin),
          (party_stack_get_size, ":stack_size", "p_temp_casualties", ":stack_no"),
          (gt, ":stack_size", 0),
          (party_add_members, "p_total_enemy_casualties", ":stack_troop", ":stack_size"), #addition_to_p_total_enemy_casualties
          (party_stack_get_num_wounded, ":stack_wounded_size", "p_temp_casualties", ":stack_no"),
          (gt, ":stack_wounded_size", 0),
          (party_wound_members, "p_total_enemy_casualties", ":stack_troop", ":stack_wounded_size"),
        (try_end),
      (try_end),
      #ozan end
      
      (call_script, "script_print_casualties_to_s0", "p_temp_casualties", 0),
      (str_store_string_reg, s9, s0),
      
      (party_collect_attachments_to_party, "$g_encountered_party", "p_collective_enemy"),
      (assign, "$no_soldiers_left", 0),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        (store_add, ":num_routed_us_plus_one", "$num_routed_us", 1),
        (le, ":num_our_regulars_remaining", ":num_routed_us_plus_one"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_order_attack_failure"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (this_or_next|le, ":num_enemy_regulars_remaining", 0),
        (le, ":num_enemy_regulars_remaining", "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
        (assign, ":continue", 0),
        (party_get_num_companion_stacks, ":party_num_stacks", "p_collective_enemy"),
        (try_begin),
          (eq, ":party_num_stacks", 0),
          (assign, ":continue", 1),
        (else_try),
          (party_stack_get_troop_id, ":party_leader", "p_collective_enemy", 0),
          (try_begin),
            (neg|troop_is_hero, ":party_leader"),
            (assign, ":continue", 1),
          (else_try),
            (troop_is_wounded, ":party_leader"),
            (assign, ":continue", 1),
          (try_end),
        (try_end),
        (eq, ":continue", 1),
        (assign, "$g_battle_result", 1),
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_order_attack_success"),
      (else_try),
        (str_store_string, s4, "str_order_attack_continue"),
      (try_end),
    ],
    [
      ("order_attack_continue",[(eq, "$no_soldiers_left", 0)],"Order your soldiers to continue the attack.",[
          (jump_to_menu,"mnu_order_attack_2"),
      ]),
      ("order_retreat",[(eq, "$no_soldiers_left", 0)],"Call your soldiers back.",[
          (jump_to_menu,"mnu_simple_encounter"),
      ]),
      ("continue",[(eq, "$no_soldiers_left", 1)],"Continue...",[
          (jump_to_menu,"mnu_simple_encounter"),
      ]),
    ]
  ),
  
  (
    "battle_debrief",mnf_disable_all_keys,
    "{s11}^^Your casualties: {s8}{s10}^^Enemy Casualties:{s9}^^{s3}",	#s3=injuries
    "none",
    [
      (try_begin),
        (eq, "$g_battle_result", 1),
        (call_script, "script_change_troop_renown", "trp_player", "$battle_renown_value"),
        
        (try_begin),
          (ge, "$g_encountered_party", 0),
          (party_is_active, "$g_encountered_party"),
          (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
          (eq, ":encountered_party_template", "pt_kingdom_caravan_party"),
          
          (get_achievement_stat, ":number_of_village_raids", ACHIEVEMENT_THE_BANDIT, 0),
          (get_achievement_stat, ":number_of_caravan_raids", ACHIEVEMENT_THE_BANDIT, 1),
          (val_add, ":number_of_caravan_raids", 1),
          (set_achievement_stat, ACHIEVEMENT_THE_BANDIT, 1, ":number_of_caravan_raids"),
          
          (try_begin),
            (ge, ":number_of_village_raids", 3),
            (ge, ":number_of_caravan_raids", 3),
            (unlock_achievement, ACHIEVEMENT_THE_BANDIT),
          (try_end),
        (try_end),
        
        (try_begin),
          (party_get_current_terrain, ":cur_terrain", "p_main_party"),
          (eq, ":cur_terrain", rt_snow),
          (get_achievement_stat, ":number_of_victories_at_snowy_lands", ACHIEVEMENT_BEST_SERVED_COLD, 0),
          (val_add, ":number_of_victories_at_snowy_lands", 1),
          (set_achievement_stat, ACHIEVEMENT_BEST_SERVED_COLD, 0, ":number_of_victories_at_snowy_lands"),
          
          (try_begin),
            (eq, ":number_of_victories_at_snowy_lands", 10),
            (unlock_achievement, ACHIEVEMENT_BEST_SERVED_COLD),
          (try_end),
        (try_end),
        
        (try_begin),
          (ge, "$g_enemy_party", 0),
          (party_is_active, "$g_enemy_party"),
          (party_stack_get_troop_id, ":stack_troop", "$g_enemy_party", 0),
          (eq, ":stack_troop", "trp_mountain_bandit"),
          
          (get_achievement_stat, ":number_of_victories_aganist_mountain_bandits", ACHIEVEMENT_MOUNTAIN_BLADE, 0),
          (val_add, ":number_of_victories_aganist_mountain_bandits", 1),
          (set_achievement_stat, ACHIEVEMENT_MOUNTAIN_BLADE, 0, ":number_of_victories_aganist_mountain_bandits"),
          
          (try_begin),
            (eq, ":number_of_victories_aganist_mountain_bandits", 10),
            (unlock_achievement, ACHIEVEMENT_MOUNTAIN_BLADE),
          (try_end),
        (try_end),
        
        (try_begin),
          (is_between, "$g_ally_party", walled_centers_begin, walled_centers_end),
          (unlock_achievement, ACHIEVEMENT_NONE_SHALL_PASS),
        (try_end),
        
        (try_begin),
          (eq, "$g_joined_battle_to_help", 1),
          (unlock_achievement, ACHIEVEMENT_GOOD_SAMARITAN),
        (try_end),
      (try_end),
      
      (assign, "$g_joined_battle_to_help", 0),
      (call_script, "script_count_casualties_and_adjust_morale"),#new
      (call_script, "script_encounter_calculate_fit"),
      
      (call_script, "script_party_count_fit_regulars", "p_main_party"),
      (assign, "$playerparty_postbattle_regulars", reg0),
      
      (try_begin),
        (eq, "$g_battle_result", 1),
        (eq, "$g_enemy_fit_for_battle", 0),
        (str_store_string, s11, "@You were victorious!"),
        #       (play_track, "track_bogus"), #clear current track.
        #       (call_script, "script_music_set_situation_with_culture", mtf_sit_victorious),
        (try_begin),
          (gt, "$g_friend_fit_for_battle", 1),
          (set_background_mesh, "mesh_pic_victory"),
        (try_end),
      (else_try),
        (eq, "$g_battle_result", -1),
        (ge, "$g_enemy_fit_for_battle",1),
        (this_or_next|le, "$g_friend_fit_for_battle",0),
        (le, "$playerparty_postbattle_regulars", 0),
        (str_store_string, s11, "@The battle was lost. Your forces were utterly crushed."),
        (play_sound, "snd_raven"),
        (set_background_mesh, "mesh_pic_defeat"),
      (else_try),
        (eq, "$g_battle_result", -1),
        (str_store_string, s11, "@Your companions carry you away from the fighting."),
        (troop_get_type, ":is_female", "trp_player"),
        (val_mod, ":is_female", 2),
        (try_begin),
          (eq, ":is_female", 1),
          (set_background_mesh, "mesh_pic_raven"),
        (else_try),
          (set_background_mesh, "mesh_pic_raven"),
        (try_end),
      (else_try),
        (eq, "$g_battle_result", 1),
        (str_store_string, s11, "@You have defeated the enemy."),
        (try_begin),
          (gt, "$g_friend_fit_for_battle", 1),
          (set_background_mesh, "mesh_pic_victory"),
        (try_end),
      (else_try),
        (eq, "$g_battle_result", 0),
        (str_store_string, s11, "@You have retreated from the fight."),
        (set_background_mesh, "mesh_pic_defeat"),
      (try_end),
      #NPC companion changes begin
      ##check for excessive casualties, more forgiving if battle result is good
      (try_begin),
        (gt, "$playerparty_prebattle_regulars", 9),
        (store_add, ":divisor", 3, "$g_battle_result"),
        (store_div, ":half_of_prebattle_regulars", "$playerparty_prebattle_regulars", ":divisor"),
        (lt, "$playerparty_postbattle_regulars", ":half_of_prebattle_regulars"),
        (call_script, "script_objectionable_action", tmt_egalitarian, "str_excessive_casualties"),
      (try_end),
      #NPC companion changes end
      
      (call_script, "script_print_casualties_to_s0", "p_player_casualties", 0),
      (str_store_string_reg, s8, s0),
      (call_script, "script_print_casualties_to_s0", "p_enemy_casualties", 0),
      (str_store_string_reg, s9, s0),
      (str_clear, s10),
      (try_begin),
        (eq, "$any_allies_at_the_last_battle", 1),
        (call_script, "script_print_casualties_to_s0", "p_ally_casualties", 0),
        (str_store_string, s10, "@^^Ally Casualties:{s0}"),
      (try_end),
      # wound report
      (call_script, "script_store_wound_report"),
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu, "$g_next_menu"),]),
    ]
  ),
  
  
  
  (
    "total_victory", 0,
    "You shouldn't be reading this... {s9}",
    "none",
    [
      (assign, ":warband_updated", 0),
      (try_begin),
        (assign, reg0, 0),
        (get_operation_set_version, reg0),
        (ge, reg0, warband_version),
        (assign, ":warband_updated", 1),
      (else_try),
        (change_screen_quit),
      (try_end),
      (eq, ":warband_updated", 1),
      
      # We exploit the menu condition system below.
      # The conditions should make sure that always another screen or menu is called.
      (assign, ":break", 0),
      (try_begin),
        (eq, "$routed_party_added", 0), #new
        (assign, "$routed_party_added", 1),
        
        #add new party to map (routed_warriors)
        (call_script, "script_add_routed_party"),
      (end_try),
      
      (try_begin),
        (check_quest_active, "qst_track_down_bandits"),
        (neg|check_quest_succeeded, "qst_track_down_bandits"),
        (neg|check_quest_failed, "qst_track_down_bandits"),
        (quest_get_slot, ":quest_party", "qst_track_down_bandits", slot_quest_target_party),
        (party_is_active, ":quest_party"),
        (party_get_attached_to, ":quest_party_attached",":quest_party"),
        (this_or_next|eq, ":quest_party", "$g_enemy_party"),
        (eq, ":quest_party_attached", "$g_enemy_party"),
        (call_script, "script_succeed_quest", "qst_track_down_bandits"),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_cause_provocation"),
        (neg|check_quest_succeeded,"qst_cause_provocation"),
        (neg|check_quest_failed, "qst_cause_provocation"),
        (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
        (eq, "$g_encountered_party_type", spt_kingdom_caravan),
        (quest_slot_eq, "qst_cause_provocation", slot_quest_target_faction, ":defender_faction"),
        (call_script, "script_succeed_quest", "qst_cause_provocation"),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_blank_quest_4"),
        (neg|check_quest_succeeded, "qst_blank_quest_4"),
        (neg|check_quest_failed, "qst_blank_quest_4"),
        (quest_get_slot, ":quest_party", "qst_blank_quest_4", slot_quest_target_party),
        (party_is_active, ":quest_party"),
        (party_get_attached_to, ":quest_party_attached",":quest_party"),
        (this_or_next|eq, ":quest_party", "$g_enemy_party"),
        (eq, ":quest_party_attached", "$g_enemy_party"),
        (call_script, "script_succeed_quest", "qst_blank_quest_4"),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_blank_quest_15"),
        (neg|check_quest_succeeded, "qst_blank_quest_15"),
        (neg|check_quest_failed, "qst_blank_quest_15"),
        (party_stack_get_troop_id, ":enemy_lord", "$g_encountered_party", 0),
        (quest_slot_eq, "qst_blank_quest_15", slot_quest_target_troop,":enemy_lord"),
        (call_script, "script_succeed_quest", "qst_blank_quest_15"),
        (set_show_messages, 0),
        (call_script, "script_end_quest", "qst_blank_quest_15"),
        (set_show_messages, 1),
      (try_end),
      (try_begin),
        (gt, "$g_private_battle_with_troop", 0),
        (troop_slot_eq, "$g_private_battle_with_troop", slot_troop_leaded_party, "$g_encountered_party"),
        (assign, "$g_private_battle_with_troop", 0),
        (assign, "$g_disable_condescending_comments", 1),
      (try_end),
      
      #new - begin
      (party_get_num_companion_stacks, ":num_stacks", "p_collective_enemy"),
      (try_for_range, ":i_stack", 0, ":num_stacks"),
        (party_stack_get_troop_id, ":stack_troop", "p_collective_enemy", ":i_stack"),
        (is_between, ":stack_troop", lords_begin, lords_end),
        (troop_is_wounded, ":stack_troop"),
        (party_add_members, "p_total_enemy_casualties", ":stack_troop", 1),
      (try_end),
      #new - end
      
      (try_begin),
        # Talk to ally leader
        (eq, "$thanked_by_ally_leader", 0),
        (assign, "$thanked_by_ally_leader", 1),
        (gt, "$g_ally_party", 0),
        (party_get_template_id,":ally_party_template","$g_ally_party"),
        #(store_add, ":total_str_without_player", "$g_starting_strength_ally_party", "$g_starting_strength_enemy_party"),
        
        (store_add, ":total_str_without_player", "$g_starting_strength_friends", "$g_starting_strength_enemy_party"),
        (val_sub, ":total_str_without_player", "$g_starting_strength_main_party"),
        
        (store_sub, ":ally_strength_without_player", "$g_starting_strength_friends", "$g_starting_strength_main_party"),
        
        (store_mul, ":ally_advantage", ":ally_strength_without_player", 100),
        (val_add, ":total_str_without_player", 1),
        (val_div, ":ally_advantage", ":total_str_without_player"),
        #Ally advantage=50  means battle was evenly matched
        
        (store_sub, ":enemy_advantage", 100, ":ally_advantage"),
        
        (store_mul, ":faction_reln_boost", ":enemy_advantage", "$g_starting_strength_enemy_party"),
        (val_div, ":faction_reln_boost", 3000),
        (val_clamp, ":faction_reln_boost", 0, 5),
        
        (store_mul, "$g_relation_boost", ":enemy_advantage", ":enemy_advantage"),
        (val_div, "$g_relation_boost", 700),
        (val_clamp, "$g_relation_boost", 0, 20),
        
        (party_get_num_companion_stacks, ":num_ally_stacks", "$g_ally_party"),
        (gt, ":num_ally_stacks", 0),
        (store_faction_of_party, ":ally_faction","$g_ally_party"),
        (try_begin),
          (eq,":ally_party_template","pt_village_elder"),
          (assign, "$g_relation_boost", 0),
          (assign,":faction_reln_boost", 0),
        (try_end),
        (call_script, "script_change_player_relation_with_faction", ":ally_faction", ":faction_reln_boost"),
        (try_begin), #Increase relation with village helping farmers
          (eq,":ally_party_template","pt_village_farmers"),
          (party_get_slot, ":village_no", "$g_ally_party", slot_party_home_center),
          (gt,"$g_relation_boost",0),
          (store_div,":bonus","$g_relation_boost",2),
          (val_max,":bonus",2),
          (call_script, "script_change_player_relation_with_center", ":village_no", ":bonus"),
        (try_end),
        (party_stack_get_troop_id, ":ally_leader", "$g_ally_party"),
        (party_stack_get_troop_dna, ":ally_leader_dna", "$g_ally_party", 0),
        (try_begin),
          (troop_is_hero, ":ally_leader"),
          (neg|is_between, ":ally_leader", village_elders_begin, village_elders_end),
          (call_script, "script_troop_get_player_relation",  ":ally_leader"),
          (assign, ":hero_relation", reg0),
          #           (troop_get_slot, ":hero_relation", ":ally_leader", slot_troop_player_relation),
          (assign, ":rel_boost", "$g_relation_boost"),
          (try_begin),
            (lt, ":hero_relation", -5),
            (val_div, ":rel_boost", 3),
          (try_end),
          (call_script,"script_change_player_relation_with_troop", ":ally_leader", ":rel_boost"),
        (try_end),
        (assign, "$talk_context", tc_ally_thanks),
        (call_script, "script_setup_troop_meeting", ":ally_leader", ":ally_leader_dna"),
      (else_try),
        # Talk to enemy leaders
        (assign, ":break", 0),
        
        (party_get_num_companion_stacks, ":num_stacks", "p_total_enemy_casualties"), #p_encountered changed to total_enemy_casualties
        (try_for_range, ":stack_no", "$last_defeated_hero", ":num_stacks"), #May 31 bug note -- this now returns some heroes in victorious party as well as in the other party
          (eq, ":break", 0),
          (party_stack_get_troop_id, ":stack_troop", "p_total_enemy_casualties", ":stack_no"),
          (party_stack_get_troop_dna, ":stack_troop_dna", "p_total_enemy_casualties", ":stack_no"),
          
          (troop_is_hero, ":stack_troop"),
          
          (store_troop_faction, ":defeated_faction", ":stack_troop"),
          #steve post 0912 changes begin - removed, this is duplicated elsewhere in game menus
          #(call_script, "script_add_log_entry", logent_lord_defeated_by_player, "trp_player",  -1, ":stack_troop", ":defeated_faction"),
          (try_begin),
            (store_relation, ":relation", ":defeated_faction", "fac_player_faction"),
            (ge, ":relation", 0),
            (str_store_troop_name, s4, ":stack_troop"),
            
            (try_begin),
              (eq, "$cheat_mode", 1),
              (display_message, "@{!}{s4} skipped in p_total_enemy_casualties capture queue because is friendly"),
            (try_end),
          (else_try),
            (try_begin),
              (party_stack_get_troop_id, ":party_leader", "$g_encountered_party", 0),
              (is_between, ":party_leader", active_npcs_begin, active_npcs_end),
              (troop_slot_eq, ":party_leader", slot_troop_occupation, slto_kingdom_hero),
              (store_sub, ":kingdom_hero_id", ":party_leader", active_npcs_begin),
              (get_achievement_stat, ":was_he_defeated_player_before", ACHIEVEMENT_BARON_GOT_BACK, ":kingdom_hero_id"),
              (eq, ":was_he_defeated_player_before", 1),
              
              (unlock_achievement, ACHIEVEMENT_BARON_GOT_BACK),
            (try_end),
            
            ###
            (try_begin), #trophies chief
              (party_stack_get_troop_id, ":party_leader", "$g_encountered_party", 0),
              (is_between, ":party_leader", active_npcs_begin, active_npcs_end),
              (troop_slot_eq, ":party_leader", slot_troop_occupation, slto_kingdom_hero),
              (store_random_in_range, ":rand", 1, 100),
              (try_begin), #trophies chief
                (ge, ":rand", 80),
                (troop_add_item,"trp_player","itm_trophy_c",0),
              (else_try),
                (troop_add_item,"trp_player","itm_trophy_b",0),
              (try_end),
            (try_end),
            ###
            (store_add, "$last_defeated_hero", ":stack_no", 1),
            (call_script, "script_remove_troop_from_prison", ":stack_troop"),
            (troop_set_slot, ":stack_troop", slot_troop_leaded_party, -1),
            
            (call_script, "script_cf_check_hero_can_escape_from_player", ":stack_troop"),
            
            (str_store_troop_name, s1, ":stack_troop"),
            (str_store_faction_name, s3, ":defeated_faction"),
            (str_store_string, s17, "@{s1} of the {s3} managed to escape."),
            (display_log_message, "@{!}{s17}"),
            (jump_to_menu, "mnu_enemy_slipped_away"),
            (assign, ":break", 1),
          (else_try),
            (store_add, "$last_defeated_hero", ":stack_no", 1),
            (call_script, "script_remove_troop_from_prison", ":stack_troop"),
            (troop_set_slot, ":stack_troop", slot_troop_leaded_party, -1),
            
            (assign, "$talk_context", tc_hero_defeated),
            
            (call_script, "script_setup_troop_meeting", ":stack_troop", ":stack_troop_dna"),
            (assign, ":break", 1),
          (try_end),
        (try_end),
        
        (eq, ":break", 1),
      (else_try),
        # Talk to freed heroes
        (assign, ":break", 0),
        (party_get_num_prisoner_stacks, ":num_prisoner_stacks", "p_collective_enemy"),
        (try_for_range, ":stack_no", "$last_freed_hero", ":num_prisoner_stacks"),
          (eq, ":break", 0),
          (party_prisoner_stack_get_troop_id, ":stack_troop", "p_collective_enemy", ":stack_no"),
          (troop_is_hero, ":stack_troop"),
          (party_prisoner_stack_get_troop_dna, ":stack_troop_dna", "p_collective_enemy", ":stack_no"),
          (store_add, "$last_freed_hero", ":stack_no", 1),
          (assign, "$talk_context", tc_hero_freed),
          (call_script, "script_setup_troop_meeting", ":stack_troop", ":stack_troop_dna"),
          (assign, ":break", 1),
        (try_end),
        (eq, ":break", 1),
        #vc ship capture begin
      (else_try),
        (eq, "$ship_capture_shown", 0),
        (assign, "$ship_capture_shown", 1),
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),
        (jump_to_menu, "mnu_ship_capture"),
        #vc ship capture end
      (else_try),
        (eq, "$capture_screen_shown", 0),
        (assign, "$capture_screen_shown", 1),
        (party_clear, "p_temp_party"),
        (assign, "$g_move_heroes", 0),
        #(call_script, "script_party_prisoners_add_party_companions", "p_temp_party", "p_collective_enemy"),
        
        #p_total_enemy_casualties deki yarali askerler p_temp_party'e prisoner olarak eklenecek.
        (call_script, "script_party_add_wounded_members_as_prisoners", "p_temp_party", "p_total_enemy_casualties"),
        
        (call_script, "script_party_add_party_prisoners", "p_temp_party", "p_collective_enemy"),
        (try_begin),
          (call_script, "script_party_calculate_strength", "p_collective_friends_backup",0),
          (assign,":total_initial_strength", reg(0)),
          (gt, ":total_initial_strength", 0),
          #(gt, "$g_ally_party", 0),
          (call_script, "script_party_calculate_strength", "p_main_party_backup",0),
          (assign,":player_party_initial_strength", reg(0)),
          # move ally_party_initial_strength/(player_party_initial_strength + ally_party_initial_strength) prisoners to ally party.
          # First we collect the share of prisoners of the ally party and distribute those among the allies.
          (store_sub, ":ally_party_initial_strength", ":total_initial_strength", ":player_party_initial_strength"),
          
          #(call_script, "script_party_calculate_strength", "p_ally_party_backup"),
          #(assign,":ally_party_initial_strength", reg(0)),
          #(store_add, ":total_initial_strength", ":player_party_initial_strength", ":ally_party_initial_strength"),
          (store_mul, ":ally_share", ":ally_party_initial_strength", 1000),
          (val_div, ":ally_share", ":total_initial_strength"),
          (assign, "$pin_number", ":ally_share"), #we send this as a parameter to the script.
          (party_clear, "p_temp_party_2"),
          (call_script, "script_move_members_with_ratio", "p_temp_party", "p_temp_party_2"),
          
          #TODO: This doesn't handle prisoners if our allies joined battle after us.
          (try_begin),
            (gt, "$g_ally_party", 0),
            (neq,":ally_party_template","pt_village_elder"),
            (neq, ":ally_party_template","pt_merchant_caravan"),
            (neq, ":ally_party_template", "pt_kingdom_caravan_party"),
            (distribute_party_among_party_group, "p_temp_party_2", "$g_ally_party"),
          (try_end),
          #next if there's anything left, we'll open up the party exchange screen and offer them to the player.
        (try_end),
        (party_get_num_companions, ":num_rescued_prisoners", "p_temp_party"),
        (party_get_num_prisoners,  ":num_captured_enemies", "p_temp_party"),
        
        (store_add, ":total_capture_size", ":num_rescued_prisoners", ":num_captured_enemies"),
        
        (gt, ":total_capture_size", 0),
        (change_screen_exchange_with_party, "p_temp_party"),
        # vc loot options begin
      (else_try),
        (eq, "$loot_options_shown", 0),
        (assign, "$loot_options_shown", 1),
        #moved to fix VC-1688 (don't show loot options if there is no loot)
        (troop_clear_inventory, "trp_temp_troop"),
        (assign, "$loot_option", 0),
        (call_script, "script_party_calculate_loot", "p_total_enemy_casualties"), #p_encountered_party_backup changed to total_enemy_casualties	#in VC this will set "$loot_value_before"
        (gt, reg0, 0),
        #fix VC-1688 ends
        (jump_to_menu, "mnu_loot_options"),
        # vc loot options end
      (else_try),
        (eq, "$loot_screen_shown", 0),
        (assign, "$loot_screen_shown", 1),
        #          (try_begin),
        #            (gt, "$g_ally_party", 0),
        #            (call_script, "script_party_add_party", "$g_ally_party", "p_temp_party"), #Add remaining prisoners to ally TODO: FIX it.
        #          (else_try),
        #            (party_get_num_attached_parties, ":num_quick_attachments", "p_main_party"),
        #            (gt, ":num_quick_attachments", 0),
        #            (party_get_attached_party_with_rank, ":helper_party", "p_main_party", 0),
        #            (call_script, "script_party_add_party", ":helper_party", "p_temp_party"), #Add remaining prisoners to our reinforcements
        #          (try_end),
        
        # (!)moved: #edit: Yes, it was moved but we need it here again, because otherwise "$loot_option" isnt reflected in the shown loot
        (troop_clear_inventory, "trp_temp_troop"),
        (call_script, "script_party_calculate_loot", "p_total_enemy_casualties"), #p_encountered_party_backup changed to total_enemy_casualties
        (gt, reg0, 0),
        (gt, "$loot_value_before", 0), #new
        
        (troop_sort_inventory, "trp_temp_troop"),
        #vc loot changes begin
        (try_begin),
          (eq, "$loot_option", 0),
          (change_screen_loot, "trp_temp_troop"),
        (else_try),
          (eq, "$loot_option", 1),
          (call_script, "script_change_party_morale", "p_main_party", -2),
          (display_message, "@Your party lost {reg1} morale.", color_bad_news),
          (change_screen_loot, "trp_temp_troop"),
        (else_try),
          (eq, "$loot_option", 2),
          (call_script, "script_change_party_morale", "p_main_party", 1),
          (display_message, "@Your party gained {reg1} morale.", color_good_news),
          #(play_sound, "snd_man_yell"),(play_sound, "snd_man_yell"),(play_sound, "snd_man_yell"),	#fixing VC-913
          #			(call_script, "script_change_troop_renown", "trp_player", 2), #JuJu70 another exploit, fight thieves and gain renown by letting your men keep their rags
          (jump_to_menu, "mnu_total_victory"),
        (else_try),
          (jump_to_menu, "mnu_total_victory"),
        (end_try),
        #
      (else_try),
        (gt, "$loot_value_before", 0),
        
        (assign, ":loot_value_after", 0),
        (troop_sort_inventory, "trp_temp_troop"),
        (troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop"),
        (try_for_range, ":i_slot", 0, ":inv_cap"),
          (troop_get_inventory_slot, ":item_id", "trp_temp_troop", ":i_slot"),
          (gt, ":item_id", 0),
          (troop_get_inventory_slot_modifier, ":item_mod" , "trp_temp_troop", ":i_slot"),
          (call_script, "script_store_item_price", ":item_id", ":item_mod"),
          (val_add, ":loot_value_after", reg0),
        (try_end),
        
        (try_begin),
          (eq, "$cheat_mode", 1),
          (assign, reg1, "$loot_value_before"),
          (assign, reg2, ":loot_value_after"),
          (display_message, "@{!}TEST: Loot value before: {reg1} and after: {reg2}"),
        (end_try),
        
        (assign, reg1, 0),
        (try_begin),
          (this_or_next|eq, "$loot_option", 0),	#share like common
          (eq, "$loot_option", 2),				#all to troops
          (store_div, ":morale_bonus", ":loot_value_after", 230), # compare: quastuosa takes 115 coins for 1 morale; here we have 230 coins for 1 morale
          (val_min, ":morale_bonus", 5),
          (gt, ":morale_bonus", 0),
          (call_script, "script_change_party_morale", "p_main_party", ":morale_bonus"),
          (gt, reg1, 0),
          (display_message, "@Your party gained {reg1} morale for the loot you shared.", color_good_news),
        (else_try),
          (eq, "$loot_option", 1),				#player wants to see all loot
          (store_div, ":accepted_player_share", "$loot_value_before", 6), # ~ 16% for player is accepted
          (store_sub, ":accepted_troop_share", "$loot_value_before", ":accepted_player_share"),
          (store_sub, ":value_diff", ":loot_value_after", ":accepted_troop_share"),
          (try_begin),
            (gt, ":value_diff", 0),
            (store_div, ":morale_bonus", ":value_diff", 230),
            (gt, ":morale_bonus", 0),
            (val_min, ":morale_bonus", 5),
            (call_script, "script_change_party_morale", "p_main_party", ":morale_bonus"),
            (gt, reg1, 0),
            (display_message, "@Your party gained {reg1} morale for the loot you shared.", color_good_news),
          (else_try),
            (le, ":value_diff", 0),
            (store_div, ":morale_penalty", ":value_diff", 200),
            (lt, ":morale_penalty", 0),
            (val_max, ":morale_penalty", -40),
            (call_script, "script_change_party_morale", "p_main_party", ":morale_penalty"),
            (gt, reg1, 0),
            (display_message, "@Your party lost {reg1} morale, because your troops think you keep too much loot for yourself.", color_bad_news),
          (end_try),
        (else_try),
          (eq, "$loot_option", 3),
          # JuJu70 modified
          # This needs to be toned down - renown generator especially early on - fight looters 20 times, renown at 160
          (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
          (val_mul, ":player_renown", 10),
          (store_div, ":renown_bonus", ":loot_value_after", ":player_renown"),
          (gt, ":renown_bonus", 0),
          (val_min, ":renown_bonus", 3),
          (store_sub, ":honor_bonus", ":renown_bonus", 2),
          (val_max, ":honor_bonus", 1),
          (try_begin),
            (gt, ":renown_bonus", 0),
            (call_script, "script_change_troop_renown", "trp_player", ":renown_bonus"),
          (try_end),
          (try_begin),
            (gt, ":honor_bonus", 0),
            (call_script, "script_change_player_honor", ":honor_bonus"),
          (try_end),
        (end_try),
        
        (assign, "$loot_value_before", 0),
        (jump_to_menu, "mnu_total_victory"),
        #vc loot changes end
      (else_try),
        #finished all
        (try_begin),
          (le, "$g_ally_party", 0),
          (end_current_battle),
        (try_end),
        (call_script, "script_party_give_xp_and_gold", "p_total_enemy_casualties"), #p_encountered_party_backup changed to total_enemy_casualties
        (try_begin),
          (eq, "$g_enemy_party", 0),
          (display_message,"str_error_string"),
        (try_end),
        
        (try_begin),
          (party_is_active, "$g_ally_party"),
          (neq,":ally_party_template","pt_village_elder"),
          (call_script, "script_battle_political_consequences", "$g_enemy_party", "$g_ally_party"),
        (else_try),
          (call_script, "script_battle_political_consequences", "$g_enemy_party", "p_main_party"),
        (try_end),
        
        (call_script, "script_event_player_defeated_enemy_party", "$g_enemy_party"),
        (call_script, "script_clear_party_group", "$g_enemy_party"),
        (try_begin),
          (eq, "$g_next_menu", -1),
          
          #NPC companion changes begin
          (call_script, "script_post_battle_personality_clash_check"),
          #NPC companion changes end
          
          #Post 0907 changes begin
          (party_stack_get_troop_id, ":enemy_leader", "p_encountered_party_backup",0),
          (try_begin),
            (is_between, ":enemy_leader", active_npcs_begin, active_npcs_end),
            (neg|is_between, "$g_encountered_party", centers_begin, centers_end),
            (store_troop_faction, ":enemy_leader_faction", ":enemy_leader"),
            
            (try_begin),
              (eq, "$g_ally_party", 0),
              (call_script, "script_add_log_entry", logent_lord_defeated_by_player, "trp_player",  -1, ":enemy_leader", ":enemy_leader_faction"),
              (try_begin),
                (eq, "$cheat_mode", 1),
                (display_message, "@{!}Victory comment. Player was alone"),
              (try_end),
            (else_try),
              (ge, "$g_strength_contribution_of_player", 40),
              (call_script, "script_add_log_entry", logent_lord_defeated_by_player, "trp_player",  -1, ":enemy_leader", ":enemy_leader_faction"),
              (try_begin),
                (eq, "$cheat_mode", 1),
                (display_message, "@{!}Ordinary victory comment. The player provided at least 40 percent forces."),
              (try_end),
            (else_try),
              (gt, "$g_starting_strength_enemy_party", 1000),
              (call_script, "script_get_closest_center", "p_main_party"),
              (assign, ":battle_of_where", reg0),
              (call_script, "script_add_log_entry", logent_player_participated_in_major_battle, "trp_player",  ":battle_of_where", -1, ":enemy_leader_faction"),
              (try_begin),
                (eq, "$cheat_mode", 1),
                (display_message, "@{!}Player participation comment. The enemy had at least 1k starting strength."),
              (try_end),
            (else_try),
              (eq, "$cheat_mode", 1),
              (display_message, "@{!}No victory comment. The battle was small, and the player provided less than 40 percent of allied strength"),
            (try_end),
          (try_end),
          #Post 0907 changes end
          (val_add, "$g_total_victories", 1),
          (leave_encounter),
          (change_screen_return),
        (else_try),
          (try_begin), #my kingdom
            #(change_screen_return),
            (eq, "$g_next_menu", "mnu_castle_taken"),
            
            (assign, "$loot_option", -1),	#new for VC
            
            (call_script, "script_add_log_entry", logent_castle_captured_by_player, "trp_player", "$g_encountered_party", -1, "$g_encountered_party_faction"),
            (store_current_hours, ":hours"),
            (faction_set_slot, "$players_kingdom", slot_faction_ai_last_decisive_event, ":hours"),
            
            (try_begin), #player took a walled center while he is a vassal of npc kingdom.
              (is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
              (jump_to_menu, "$g_next_menu"),
            (else_try), #player took a walled center while he is a vassal of rebels.
              (eq, "$players_kingdom", "fac_player_supporters_faction"),
              (assign, "$g_center_taken_by_player_faction", "$g_encountered_party"),
              (neg|faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
              (faction_get_slot, ":faction_leader", "fac_player_supporters_faction", slot_faction_leader),
              (change_screen_return),
              (start_map_conversation, ":faction_leader", -1),
            (else_try), #player took a walled center for player's kingdom
              (neg|is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
              (assign, "$g_center_taken_by_player_faction", "$g_encountered_party"),
              (assign, "$talk_context", tc_give_center_to_fief),
              (change_screen_return),
              
              (assign, ":best_troop", "trp_briton_marksman"),
              (assign, ":maximum_troop_score", 0),
              
              (party_get_num_companion_stacks, ":num_stacks", "p_main_party"),
              (try_for_range, ":stack_no", 0, ":num_stacks"),
                (party_stack_get_troop_id, ":stack_troop", "p_main_party", ":stack_no"),
                (neq, ":stack_troop", "trp_player"),
                
                (party_stack_get_size, ":stack_size", "p_main_party", ":stack_no"),
                (party_stack_get_num_wounded, ":num_wounded", "p_main_party", ":stack_no"),
                (troop_get_slot, ":num_routed", "p_main_party", slot_troop_player_routed_agents),
                
                (assign, ":continue", 0),
                (try_begin),
                  (neg|troop_is_hero, ":stack_troop"),
                  (store_add, ":agents_which_cannot_speak", ":num_wounded", ":num_routed"),
                  (gt, ":stack_size", ":agents_which_cannot_speak"),
                  (assign, ":continue", 1),
                (else_try),
                  (troop_is_hero, ":stack_troop"),
                  (neg|troop_is_wounded, ":stack_troop"),
                  (assign, ":continue", 1),
                (try_end),
                (eq, ":continue", 1),
                
                (try_begin),
                  (troop_is_hero, ":stack_troop"),
                  (troop_get_slot, ":troop_renown", ":stack_troop", slot_troop_renown),
                  (store_mul, ":troop_score", ":troop_renown", 100),
                  (val_add, ":troop_score", 1000),
                (else_try),
                  (store_character_level, ":troop_level", ":stack_troop"),
                  (assign, ":troop_score", ":troop_level"),
                (try_end),
                
                (try_begin),
                  (gt, ":troop_score", ":maximum_troop_score"),
                  (assign, ":maximum_troop_score", ":troop_score"),
                  (assign, ":best_troop", ":stack_troop"),
                  (party_stack_get_troop_dna, ":best_troop_dna", "p_main_party", ":stack_no"),
                (try_end),
              (try_end),
              (start_map_conversation, ":best_troop", ":best_troop_dna"),
            (try_end),
          (try_end),
        (try_end),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[]),
    ]
  ),
  
  (
    "enemy_slipped_away",0,
    "{!}{s17}",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),],
    [
      ("continue",[],"Continue...",[(jump_to_menu,"mnu_total_victory")]),
    ]
  ),
  
  (
    "total_defeat",0,
    "{!}You shouldn't be reading this...",
    "none",
    [
      (play_track, "track_captured", 1),
      # Free prisoners
      (party_get_num_prisoner_stacks, ":num_prisoner_stacks","p_main_party"),
      (try_for_range, ":stack_no", 0, ":num_prisoner_stacks"),
        (party_prisoner_stack_get_troop_id, ":stack_troop","p_main_party",":stack_no"),
        (troop_is_hero, ":stack_troop"),
        (call_script, "script_remove_troop_from_prison", ":stack_troop"),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_blank_quest_15"),
        (neg|check_quest_succeeded, "qst_blank_quest_15"),
        (neg|check_quest_failed, "qst_blank_quest_15"),
        (party_stack_get_troop_id, ":enemy_lord", "$g_encountered_party", 0),
        (quest_slot_eq, "qst_blank_quest_15", slot_quest_target_troop,":enemy_lord"),
        (call_script, "script_fail_quest", "qst_blank_quest_15"),
        (set_show_messages, 0),
        (call_script, "script_end_quest", "qst_blank_quest_15"),
        (set_show_messages, 1),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_cause_provocation"),
        (neg|check_quest_succeeded,"qst_cause_provocation"),
        (neg|check_quest_failed, "qst_cause_provocation"),
        (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
        (eq, "$g_encountered_party_type", spt_kingdom_caravan),
        (quest_slot_eq, "qst_cause_provocation", slot_quest_target_faction, ":defender_faction"),
        (call_script, "script_fail_quest", "qst_cause_provocation"),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_blank_quest_4"),
        (neg|check_quest_succeeded, "qst_blank_quest_4"),
        (neg|check_quest_failed, "qst_blank_quest_4"),
        (quest_get_slot, ":target_party", "qst_blank_quest_4", slot_quest_target_party),
        (eq, ":target_party", "$g_encountered_party"),
        (call_script, "script_fail_quest", "qst_blank_quest_4"),
      (try_end),
      (try_begin),
        (party_is_active, "$g_ally_party"),
        (party_get_template_id,":ally_party_template","$g_ally_party"),
        (neq,":ally_party_template","pt_village_elder"),
        (call_script, "script_battle_political_consequences", "$g_ally_party", "$g_enemy_party"),
      (else_try),
        (call_script, "script_battle_political_consequences", "p_main_party", "$g_enemy_party"),
      (try_end),
      
      (call_script, "script_loot_player_items", "$g_enemy_party"),
      
      (assign, "$g_move_heroes", 0),
      (party_clear, "p_temp_party"),
      (call_script, "script_party_add_party_prisoners", "p_temp_party", "p_main_party"),
      (call_script, "script_party_prisoners_add_party_companions", "p_temp_party", "p_main_party"),
      (distribute_party_among_party_group, "p_temp_party", "$g_enemy_party"),
      
      (assign, "$g_prison_heroes", 1),
      (call_script, "script_party_remove_all_companions", "p_main_party"),
      (assign, "$g_prison_heroes", 0),
      (assign, "$g_move_heroes", 1),
      (call_script, "script_party_remove_all_prisoners", "p_main_party"),
      
      (val_add, "$g_total_defeats", 1),
      
      (try_begin),
        (neq, "$g_player_surrenders", 1),
        (store_random_in_range, ":random_no", 0, 100),
        (ge, ":random_no", "$g_player_luck"),
        (jump_to_menu, "mnu_permanent_damage"),
      (else_try),
        (try_begin),
          (eq, "$g_next_menu", -1),
          (leave_encounter),
          (change_screen_return),
        (else_try),
          (jump_to_menu, "$g_next_menu"),
        (try_end),
      (try_end),
      (try_begin),
        (gt, "$g_ally_party", 0),
        (call_script, "script_party_wound_all_members", "$g_ally_party"),
        (try_begin),
          (party_get_template_id,":ally_party_template","$g_ally_party"),
          (eq,":ally_party_template","pt_village_elder"),
          (party_stack_get_troop_id, ":ally_leader", "$g_ally_party",0),
          (try_for_range, ":cur_village", villages_begin, villages_end),
            (party_get_slot, ":village_elder", ":cur_village", slot_town_elder),
            (eq, ":village_elder", ":ally_leader"),
            (party_set_slot, ":cur_village", slot_party_levy_on, 0),
          (try_end),
        (try_end),
      (try_end),
      
      #Troop commentary changes begin
      (party_get_num_companion_stacks, ":num_stacks", "p_encountered_party_backup"),
      (try_for_range, ":stack_no", 0, ":num_stacks"),
        (party_stack_get_troop_id,   ":stack_troop","p_encountered_party_backup",":stack_no"),
        (is_between, ":stack_troop", active_npcs_begin, active_npcs_end),
        (troop_slot_eq, ":stack_troop", slot_troop_occupation, slto_kingdom_hero),
        (store_troop_faction, ":victorious_faction", ":stack_troop"),
        (call_script, "script_add_log_entry", logent_player_defeated_by_lord, "trp_player",  -1, ":stack_troop", ":victorious_faction"),
      (try_end),
      #Troop commentary changes end
      
    ],
    []
  ),
  
  (
    "permanent_damage",mnf_disable_all_keys,
    "{!}{s0}",
    "none",
    [
      (set_background_mesh, "mesh_pic_raven"),
      (assign, ":end_cond", 1),
      (try_for_range, ":unused", 0, ":end_cond"),
        (store_random_in_range, ":random_attribute", 0, 4),
        (store_attribute_level, ":attr_level", "trp_player", ":random_attribute"),
        (try_begin),
          (gt, ":attr_level", 3),
          (neq, ":random_attribute", ca_charisma),
          (try_begin),
            (eq, ":random_attribute", ca_strength),
            (str_store_string, s0, "@Some of your tendons have been damaged in the battle. You lose 1 strength."),
          (else_try),
            (eq, ":random_attribute", ca_agility),
            (str_store_string, s0, "@The wound you took was pretty nasty and will cause you to limp slightly even after it heals. You lose 1 agility."),
            ##          (else_try),
            ##            (eq, ":random_attribute", ca_charisma),
            ##            (str_store_string, s0, "@After the battle you are aghast to find that one of the terrible blows you suffered has left a deep, disfiguring scar on your face, horrifying those around you. Your charisma is reduced by 1."),
          (else_try),
            ##            (eq, ":random_attribute", ca_intelligence),
            (str_store_string, s0, "@You have trouble thinking straight after the battle, perhaps from a particularly hard hit to your head, and frequent headaches now plague your existence. Your intelligence is reduced by 1."),
          (try_end),
        (else_try),
          (lt, ":end_cond", 200),
          (val_add, ":end_cond", 1),
        (try_end),
      (try_end),
      (try_begin),
        (eq, ":end_cond", 200),
        (try_begin),
          (eq, "$g_next_menu", -1),
          (leave_encounter),
          (change_screen_return),
        (else_try),
          (jump_to_menu, "$g_next_menu"),
        (try_end),
      (else_try),
        (troop_raise_attribute, "trp_player", ":random_attribute", -1),
      (try_end),
    ],
    [
      ("s0",
        [
          (store_random_in_range, ":random_no", 0, 4),
          (try_begin),
            (eq, ":random_no", 0),
            (str_store_string, s0, "@Perhaps I'm getting unlucky..."),
          (else_try),
            (eq, ":random_no", 1),
            (str_store_string, s0, "@Retirement is starting to sound better and better."),
          (else_try),
            (eq, ":random_no", 2),
            (str_store_string, s0, "@No matter! I will persevere!"),
          (else_try),
            (eq, ":random_no", 3),
            (troop_get_type, ":is_female", "trp_player"),
            (val_mod, ":is_female", 2),
            (try_begin),
              (eq, ":is_female", 1),
              (str_store_string, s0, "@What did I do to deserve this?"),
            (else_try),
              (str_store_string, s0, "@I suppose it'll make for a good story, at least..."),
            (try_end),
          (try_end),
        ],
        "{!}{s0}",
        [
          (try_begin),
            (eq, "$g_next_menu", -1),
            (leave_encounter),
            (change_screen_return),
          (else_try),
            (jump_to_menu, "$g_next_menu"),
          (try_end),
      ]),
    ]
  ),
  
  (
    "pre_join",0,
    "You come across a battle between {s2} and {s1}. You decide to...",
    "none",
    [
      (str_store_party_name, 1,"$g_encountered_party"),
      (str_store_party_name, 2,"$g_encountered_party_2"),
      
      (set_background_mesh, "mesh_pic_duel_warriors"), #pic book
    ],
    [
      ("pre_join_help_attackers",[
          (store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
          (store_relation, ":attacker_relation", ":attacker_faction", "fac_player_faction"),
          (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
          (store_relation, ":defender_relation", ":defender_faction", "fac_player_faction"),
          (ge, ":attacker_relation", 0),
          (lt, ":defender_relation", 0),
          ##         (ge, ":attacker_relation", ":defender_relation"), #chief
        ],
        "Move in to help the {s2}.",[
          (select_enemy,0),
          (assign,"$g_enemy_party","$g_encountered_party"),
          (assign,"$g_ally_party","$g_encountered_party_2"),
          (jump_to_menu,"mnu_join_battle")]),
      ("pre_join_help_defenders",[
          (store_faction_of_party, ":attacker_faction", "$g_encountered_party_2"),
          (store_relation, ":attacker_relation", ":attacker_faction", "fac_player_faction"),
          (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
          (store_relation, ":defender_relation", ":defender_faction", "fac_player_faction"),
          (ge, ":defender_relation", 0),
          (lt, ":attacker_relation", 0),
          ##          (ge, ":defender_relation", ":attacker_relation"), #same here
        ],
        "Rush to the aid of the {s1}.",[
          (select_enemy,1),
          (assign,"$g_enemy_party","$g_encountered_party_2"),
          (assign,"$g_ally_party","$g_encountered_party"),
          (jump_to_menu,"mnu_join_battle")]),
      ("pre_join_leave",[],"Don't get involved.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  
  (
    "join_battle",0,
    "You are helping the {s2} against the {s1}. You have {reg10} troops fit for battle against the enemy's {reg11}.",
    "none",
    [
      (str_store_party_name, 1,"$g_enemy_party"),
      (str_store_party_name, 2,"$g_ally_party"),
      (set_background_mesh, "mesh_pic_duel_warriors"), #pic book
      (call_script, "script_encounter_calculate_fit"),
      
      (try_begin),
        (eq, "$new_encounter", 1),
        (assign, "$new_encounter", 0),
        (call_script, "script_encounter_init_variables"),
      (else_try), #second or more turn
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (try_end),
      
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (assign, ":enemy_finished",0),
        (try_begin),
          (eq, "$g_battle_result", 1),
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
          (le, ":num_enemy_regulars_remaining", "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign, ":enemy_finished",1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (le, "$g_enemy_fit_for_battle",0),
          (ge, "$g_friend_fit_for_battle",1),
          (assign, ":enemy_finished",1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished",1),
        (eq,"$g_enemy_surrenders",1),
        (assign, "$g_next_menu", -1),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_collective_friends"),
        (assign, ":num_ally_regulars_remaining", reg0),
        (assign, ":battle_lost", 0),
        (try_begin),
          (eq, "$g_battle_result", -1),
          
          #(eq, ":num_ally_regulars_remaining", 0), #battle lost
          (le, ":num_ally_regulars_remaining",  "$num_routed_allies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign, ":battle_lost",1),
        (try_end),
        
        (this_or_next|eq, ":battle_lost",1),
        (eq,"$g_player_surrenders",1),
        (leave_encounter),
        (change_screen_return),
      (try_end),
    ],
    [
      ("join_attack",
        [
          (neg|troop_is_wounded, "trp_player"),
          
          (try_begin),
            (party_slot_eq, "p_main_party", slot_party_on_water, 1),
            (str_store_string, s7, "@Board"),
          (else_try),
            (str_store_string, s7, "@Charge"),
          (end_try),
        ],
        "{s7} the enemy.",
        [
          (assign, "$g_joined_battle_to_help", 1),
          (party_set_next_battle_simulation_time, "$g_encountered_party", -1),
          (assign, "$g_battle_result", 0),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          # phaiak chief begin
          (try_begin),
            (party_slot_eq, "p_main_party", slot_party_on_water, 1),	# = sea battle
            #(party_get_num_companions, ":num_enemy", "$g_enemy_party"),
            #new begin
            (try_begin),
              (store_faction_of_party, ":party_faction", "$g_enemy_party"),
              (this_or_next|eq, ":party_faction", "fac_outlaws"),
              (this_or_next|eq, ":party_faction", "fac_manhunters"),
              (this_or_next|eq, ":party_faction", "fac_mountain_bandits"),
              (this_or_next|eq, ":party_faction", "fac_forest_bandits"),
              (this_or_next|eq, ":party_faction", "fac_deserters"),
              (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_hero_party),
              (assign, ":prepare_party_ships_for_team_script", "script_randomize_ships_for_team_war_party"),
            (else_try),
              (assign, ":prepare_party_ships_for_team_script", "script_randomize_ships_for_team_civilian"),
            (end_try),
            #new end
            (call_script, "script_party_count_members_with_full_health", "$g_enemy_party"),
            (assign, ":num_enemy", reg0),
            (call_script, "script_party_count_members_with_full_health", "p_main_party"),
            (store_add, "$startup_battle_size", ":num_enemy", reg0),
            (call_script, "script_party_count_members_with_full_health", "$g_ally_party"),
            (val_add, "$startup_battle_size", reg0),
            (try_begin),
              (eq,"$g_enemy_party","$g_encountered_party"),
              (eq,"$g_ally_party","$g_encountered_party_2"),
              (assign, "$player_team_in_sea_battle", 1),
              (call_script, ":prepare_party_ships_for_team_script", 0, ":num_enemy"),
              (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
            (else_try),
              (assign, "$player_team_in_sea_battle", 0),
              (call_script, "script_prepare_party_ships_for_team", "p_main_party", 0),
              (call_script, ":prepare_party_ships_for_team_script", 1, ":num_enemy"),
            (end_try),
            (set_jump_mission,"mt_sea_battle"),					#Somebody had outcommented this. Why????
            (call_script, "script_setup_random_sea_scene"),
          (else_try),
            (set_jump_mission,"mt_lead_charge"),			# native
            (call_script, "script_setup_random_scene"),	# native
          (end_try),
          # phaiak end
          (assign, "$g_next_menu", "mnu_join_battle"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      
      
      ("join_order_attack",
        [
          (call_script, "script_party_count_members_with_full_health", "p_main_party"),
          (ge, reg0, 3),
        ],
        "Order your troops to join your allies while you stay back.",
        [
          (assign, "$g_joined_battle_to_help", 1),
          (party_set_next_battle_simulation_time, "$g_encountered_party", -1),
          (jump_to_menu,"mnu_join_order_attack"),
      ]),
      
      ("leave",[],"Leave.",
        [
          (try_begin),
            (neg|troop_is_wounded, "trp_player"),
            (call_script, "script_objectionable_action", tmt_aristocratic, "str_flee_battle"),
            (party_stack_get_troop_id, ":enemy_leader","$g_enemy_party",0),
            (is_between, ":enemy_leader", active_npcs_begin, active_npcs_end),
            (call_script, "script_add_log_entry", logent_player_retreated_from_lord, "trp_player",  -1, ":enemy_leader", -1),
            (display_message, "@Player retreats from battle."), #chief anadido
          (try_end),
          
          (leave_encounter),(change_screen_return)]),
  ]),
  
  (
    "join_order_attack",mnf_disable_all_keys,
    "{s4}^^Your casualties: {s8}^^Allies' casualties: {s9}^^Enemy casualties: {s10}",
    "none",
    [(set_background_mesh, "mesh_pic_charge"), #pic book
      (call_script, "script_simulate_battle_with_parties", 2, "$g_enemy_party", 2, "$g_ally_party", 0),
      #(assign, "$cant_leave_encounter", 0),
      (assign, "$no_soldiers_left", 0),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health","p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        
        #(le, ":num_our_regulars_remaining", 0),
        (le, ":num_our_regulars_remaining", "$num_routed_us"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
        
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_join_order_attack_failure"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health","p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        
        (this_or_next|le, ":num_enemy_regulars_remaining", 0),
        (le, ":num_enemy_regulars_remaining", "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
        
        (assign, "$g_battle_result", 1),
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_join_order_attack_success"),
      (else_try),
        (str_store_string, s4, "str_join_order_attack_continue"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (jump_to_menu,"mnu_join_battle"),
      ]),
    ]
  ),
  
  
  # Towns
  (
    "zendar",mnf_auto_enter,
    "You enter the town of Zendar.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_tools",70),(set_price_rate_for_item,"itm_salt",140)],
    [
      ("zendar_enter",[],"_",[(set_jump_mission,"mt_town_default"),(jump_to_scene,"scn_zendar_center"),(change_screen_mission)],"Door to the town center."),
      ("zendar_tavern",[],"_",[(set_jump_mission,"mt_town_default"),
          (jump_to_scene,"scn_the_happy_boar"),
          (change_screen_mission)],"Door to the tavern."),
      ("zendar_merchant",[],"_",[(set_jump_mission,"mt_town_default"),
          (jump_to_scene,"scn_zendar_merchant"),
          (change_screen_mission)],"Door to the merchant."),
      ("zendar_arena",[],"_",[(set_jump_mission,"mt_town_default"),
          (jump_to_scene,"scn_zendar_arena"),
          (change_screen_mission)],"Door to the arena."),
      #      ("zendar_leave",[],"Leave town.",[[leave_encounter],[change_screen_return]]),
      ("town_1_leave",[],"_",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  (
    "salt_mine",mnf_auto_enter,
    "You enter the salt mine.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55)],
    [
      ("enter",[],"Enter.",[(set_jump_mission,"mt_town_center"),(jump_to_scene,"scn_salt_mine"),(change_screen_mission)]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  (
    "four_ways_inn",mnf_auto_enter,
    "You arrive at the Four Ways Inn.",
    "none",
    [],
    [
      
      #      ("enter",[],"Enter.",[[set_jump_mission,"mt_town_default"],[jump_to_scene,"scn_conversation_scene"],[change_screen_mission]]),
      ("enter",[],"Enter.",[(set_jump_mission,"mt_ai_training"),(jump_to_scene,"scn_four_ways_inn"),(change_screen_mission)]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  (
    "test_scene",0,
    "You enter the test scene.",
    "none",
    [],
    [
      
      ("enter",[],"{!}Enter 1.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_1"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 2.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_2"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 3.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_3"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 4.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_4"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 5.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_5"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 6.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_6"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 7.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_test2"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 8.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_test3"],[change_screen_mission]]),
      ("enter",[],"{!}Enter 9.",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_multi_scene_13"],[change_screen_mission]]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  #scene quarry chief
  (
    "quarry1",0,
    "You arrive at a quarry. The sounds of carts and picks fill the air as several free men work.",
    "none",
    [(set_background_mesh, "mesh_pic_bandits_lair"), #pic book
      
      (try_begin),
        (eq, "$player_is_working", 1),
        (assign, "$player_is_working", 0),
        (jump_to_menu, "mnu_work_start"),
      (end_try),
      
      #	 (set_price_rate_for_item,"itm_iron",304),(set_price_rate_for_item,"itm_stone",104),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enter",[],"Enter.",[
          (set_jump_mission,"mt_quarry_place"),
          (modify_visitors_at_site,"scn_quarry"),
          (reset_visitors),
          (try_begin),
            (gt,"trp_quarry_trabajador", 0),
            (assign,reg(0),"trp_quarry_trabajador"),
            (assign,reg(1),"trp_quarry_trabajador"),
            (assign,reg(2),"trp_quarry_trabajador"),
            (assign,reg(3),"trp_quarry_trabajador"),
          (else_try),
            (assign,reg(0),"trp_quarry_trabajador"),
            (assign,reg(1),"trp_quarry_trabajador"),
            (assign,reg(2),"trp_quarry_trabajador"),
            (assign,reg(3),"trp_quarry_trabajador"),
          (try_end),
          (shuffle_range,0,4),
          (set_visitor,1,reg(3)),
          (set_visitor,2,reg(1)),
          (set_visitor,3,reg(2)),
          (set_visitor,4,reg(3)),
          (set_visitor,5,reg(0)),
          (set_visitor,6,"trp_quarry_trabajador"),
          (set_visitor,7,"trp_quarry_trabajador"),
          (set_visitor,13,"trp_quarry_trabajador"),
          (set_visitor,14,"trp_quarry_trabajador"),
          (set_visitor,15,reg(2)),
          (set_visitor,16,"trp_quarry_trabajador"),
          (set_visitor,17,"trp_quarry_capataz"), #boss
          (set_visitor,18,"trp_quarry_trabajador"),
          (set_visitor,23,"trp_quarry_trabajador"),
          (set_visitor,24,reg(0)),
          (set_visitor,25,"trp_quarry_trabajador"),
          (set_visitor,26,"trp_quarry_trabajador"),
          (set_visitor,27,"trp_quarry_trabajador"),
          (set_visitor,28,"trp_quarry_trabajador"),
          (set_visitor,29,"trp_quarry_trabajador"),
          (set_visitor,30,"trp_quarry_trabajador"),
          (set_visitor,33,"trp_quarry_trabajador"),
          (set_visitor,34,reg(2)),
          (set_visitor,35,reg(2)),
          (set_visitor,36,"trp_quarry_trabajador"),
          (set_visitor,40,reg(1)),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_quarry", slot_scene_visited, 1),
          (jump_to_scene,"scn_quarry"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #Salt mine
  (
    "salt_mine_vc",0,
    "You arrive at a salt mine. The sound of carts and shovels fills the air as several free men work.",
    "none",
    [(set_background_mesh, "mesh_pic_bandits_lair"), #pic book
      
      (try_begin),
        (eq, "$player_is_working", 1),
        (assign, "$player_is_working", 0),
        (jump_to_menu, "mnu_work_start"),
      (end_try),
      #     (reset_price_rates,0),
      #	 (set_price_rate_for_item,"itm_salt",305),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enter",[],"Enter.",[
          (set_jump_mission,"mt_saltminevc_place"),
          (modify_visitors_at_site,"scn_salt_mine_vc"),
          (reset_visitors),
          (try_begin),
            (gt,"trp_quarry_trabajador", 0),
            (assign,reg(0),"trp_quarry_trabajador"),
            (assign,reg(1),"trp_quarry_trabajador"),
            (assign,reg(2),"trp_quarry_trabajador"),
            (assign,reg(3),"trp_quarry_trabajador"),
          (else_try),
            (assign,reg(0),"trp_quarry_trabajador"),
            (assign,reg(1),"trp_quarry_trabajador"),
            (assign,reg(2),"trp_quarry_trabajador"),
            (assign,reg(3),"trp_quarry_trabajador"),
          (try_end),
          (shuffle_range,0,4),
          (set_visitor,1,reg(3)),
          (set_visitor,2,reg(1)),
          (set_visitor,3,reg(2)),
          (set_visitor,4,reg(3)),
          (set_visitor,5,reg(0)),
          (set_visitor,6,"trp_quarry_trabajador"),
          (set_visitor,7,"trp_quarry_trabajador"),
          (set_visitor,13,"trp_quarry_trabajador"),
          (set_visitor,14,"trp_quarry_trabajador"),
          (set_visitor,15,reg(2)),
          (set_visitor,16,"trp_quarry_trabajador"),
          (set_visitor,17,"trp_saltmine_capataz"), #boss
          (set_visitor,18,"trp_quarry_trabajador"),
          (set_visitor,23,"trp_quarry_trabajador"),
          (set_visitor,24,reg(0)),
          (set_visitor,25,"trp_quarry_trabajador"),
          (set_visitor,26,"trp_quarry_trabajador"),
          (set_visitor,27,"trp_quarry_trabajador"),
          (set_visitor,28,"trp_quarry_trabajador"),
          (set_visitor,29,"trp_quarry_trabajador"),
          (set_visitor,30,"trp_quarry_trabajador"),
          (set_visitor,33,"trp_quarry_trabajador"),
          (set_visitor,34,reg(2)),
          (set_visitor,35,reg(2)),
          (set_visitor,36,"trp_quarry_trabajador"),
          (set_visitor,40,reg(1)),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_salt_mine_vc", slot_scene_visited, 1),
          (jump_to_scene,"scn_salt_mine_vc"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #salt mine finish chief
  #Lumber Camp
  (
    "lumber_camp",0,
    "You arrive at a lumber camp. The sounds of axes and saws fill the air as a few free men work.",
    "none",
    [
      
      (try_begin),
        (eq, "$player_is_working", 1),
        (assign, "$player_is_working", 0),
        (jump_to_menu, "mnu_work_start"),
      (else_try),
        (set_background_mesh, "mesh_pic_forest"), #pic book
        #		(reset_price_rates,0),
        (try_begin), #no batalla de noche
          (store_time_of_day, ":cur_hour"),
          (ge, ":cur_hour", 5),
          (lt, ":cur_hour", 21),
          (assign, "$town_nighttime", 0),
        (else_try),
          (assign, "$town_nighttime", 1),
        (try_end),
        (try_begin), #no batalla de noche
          (eq, "$town_nighttime", 1),
          (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
        (try_end),
      (try_end),
    ],
    [
      ("enter",[],"Enter.",[
          (set_jump_mission,"mt_lumbercamp_place"),
          (modify_visitors_at_site,"scn_lumber_camp"),
          (reset_visitors),
          (try_begin),
            (gt,"trp_quarry_trabajador", 0),
            (assign,reg(0),"trp_quarry_trabajador"),
            (assign,reg(1),"trp_quarry_trabajador"),
            (assign,reg(2),"trp_quarry_trabajador"),
            (assign,reg(3),"trp_quarry_trabajador"),
          (else_try),
            (assign,reg(0),"trp_quarry_trabajador"),
            (assign,reg(1),"trp_quarry_trabajador"),
            (assign,reg(2),"trp_quarry_trabajador"),
            (assign,reg(3),"trp_quarry_trabajador"),
          (try_end),
          (shuffle_range,0,4),
          (set_visitor,1,reg(3)),
          (set_visitor,2,reg(1)),
          (set_visitor,3,reg(2)),
          (set_visitor,4,reg(3)),
          (set_visitor,5,reg(0)),
          (set_visitor,6,"trp_quarry_trabajador"),
          (set_visitor,7,"trp_quarry_trabajador"),
          (set_visitor,13,"trp_quarry_trabajador"),
          (set_visitor,14,"trp_quarry_trabajador"),
          (set_visitor,15,reg(2)),
          (set_visitor,16,"trp_quarry_trabajador"),
          (set_visitor,17,"trp_lumbercamp_capataz"), #boss
          (set_visitor,18,"trp_quarry_trabajador"),
          (set_visitor,23,"trp_quarry_trabajador"),
          (set_visitor,24,reg(0)),
          (set_visitor,25,"trp_quarry_trabajador"),
          (set_visitor,26,"trp_quarry_trabajador"),
          (set_visitor,27,"trp_quarry_trabajador"),
          (set_visitor,28,"trp_quarry_trabajador"),
          (set_visitor,29,"trp_quarry_trabajador"),
          (set_visitor,30,"trp_quarry_trabajador"),
          (set_visitor,33,"trp_quarry_trabajador"),
          (set_visitor,34,reg(2)),
          (set_visitor,35,reg(2)),
          (set_visitor,36,"trp_quarry_trabajador"),
          (set_visitor,40,reg(1)),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_lumber_camp", slot_scene_visited, 1),
          (jump_to_scene,"scn_lumber_camp"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###lumber camp end
  ###farmstead
  (
    "farmstead_special",0,
    "You arrive at a farmstead. Farmsteads are the source of produce and foodstuffs, so those things are cheaper here.^^{s10}",
    "none",
    [(set_background_mesh, "mesh_pic_farmstead"), #pic book
      
      (try_begin),
        (eq, "$player_is_working", 1),
        (assign, "$player_is_working", 0),
        (jump_to_menu, "mnu_work_start"),
      (end_try),
      
      (str_clear, s10),
      (party_get_slot, reg22, "$g_encountered_party", slot_center_player_cattle),
      (try_begin),
        (gt, reg22, 0),
        (str_store_string, s10, "@You have {reg22} head of cattle grazing here."),
      (try_end),
      #	 (set_price_rate_for_item,"itm_cow1",1800),(set_price_rate_for_item,"itm_cow2",1800),
      #    (set_price_rate_for_item,"itm_vc_honey",220),(set_price_rate_for_item,"itm_wool",230),(set_price_rate_for_item,"itm_ale",280),
      #    (set_price_rate_for_item,"itm_cattle_meat",120),(set_price_rate_for_item,"itm_chicken",65),(set_price_rate_for_item,"itm_vc_furs",391),(set_price_rate_for_item,"itm_dried_meat",150),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("take_cattlefs",[
          (party_get_slot, reg22, "$g_encountered_party", slot_center_player_cattle),
          (gt, reg22, 0),
      ],"Take some of your cattle.",[
          (start_presentation,"prsnt_take_cattle"),
      ]),
      
      ("enter",[],"Enter.",[
          (set_jump_mission,"mt_farmstead_place"),
          (modify_visitors_at_site,"scn_farmstead_special"),
          (reset_visitors),
          (try_begin),
            (assign,reg(0),"trp_farmer"),
            (assign,reg(1),"trp_farmer"),
            (assign,reg(2),"trp_farmer"),
            (assign,reg(3),"trp_farmer"),
          (try_end),
          (shuffle_range,0,4),
          (set_visitor,1,reg(3)),
          (set_visitor,2,reg(1)),
          (set_visitor,3,reg(2)),
          (set_visitor,4,reg(3)),
          (set_visitor,5,reg(0)),
          (set_visitor,6,"trp_peasant_woman"),
          (set_visitor,7,"trp_peasant_woman"),
          (set_visitor,13,"trp_peasant_woman"),
          (set_visitor,14,"trp_manhunterdruid"),
          (set_visitor,15,reg(2)),
          (set_visitor,16,"trp_manhunterdruid"),
          (set_visitor,17,"trp_farmstead_boss"), #boss
          (set_visitor,18,"trp_manhunterdruid"),
          (set_visitor,23,"trp_manhunterdruid"),
          (set_visitor,24,reg(0)),
          (set_visitor,25,"trp_farmer"),
          (set_visitor,26,"trp_farmer"),
          (set_visitor,27,"trp_farmer"),
          (set_visitor,28,"trp_farmer"),
          (set_visitor,29,"trp_farmer"),
          (set_visitor,30,"trp_peasant_woman"),
          (set_visitor,33,"trp_peasant_woman"),
          (set_visitor,34,reg(2)),
          (set_visitor,35,reg(2)),
          (set_visitor,36,"trp_peasant_woman"),
          (set_visitor,40,reg(1)),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_farmstead_special", slot_scene_visited, 1),
          (jump_to_scene,"scn_farmstead_special"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #####
  (
    "hadrian_wall1",0,
    "You arrive at remains of what once was Hadrian's Wall.",
    "none",
    [ (set_background_mesh, "mesh_pic_road_with_grove"), #pic book
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      
      ("enter",[(eq, "$g_hadrianwall_visited", 0),],"Enter.",[
          (set_jump_mission,"mt_hadrian_place"),
          (modify_visitors_at_site,"scn_hadrian_wall1"),
          (reset_visitors),
          (set_visitor,16,"trp_refugeedruid"), #old roman chief
          (set_visitor,17,"trp_old_roman"), #old roman chief
          (set_visitor,18,"trp_farmerdruid"), #old roman chief
          (set_visitor,19,"trp_farmerdruid"), #old roman chief
          (set_visitor,20,"trp_refugeedruid"), #old roman chief
          (set_jump_entry, 0),
          (scene_set_slot, "scn_hadrian_wall1", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_hadrian_wall1"),
          (change_screen_mission),
      ]),
      ("enter",[(ge, "$g_hadrianwall_visited", 2),],"Enter.",[
          (set_jump_mission,"mt_hadrian_place"),
          (modify_visitors_at_site,"scn_hadrian_wall1"),
          (reset_visitors),
          (set_jump_entry, 0),
          (try_begin), #britona,
            (neg|main_party_has_troop,"trp_npc1"),
            (troop_slot_eq, "trp_npc1", slot_troop_occupation, 0),
            (neg|troop_slot_ge, "trp_npc1", slot_troop_prisoner_of_party, centers_begin),
            (set_visitor,17,"trp_npc1"), #Caio
          (try_end),
          (scene_set_slot, "scn_hadrian_wall1", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_hadrian_wall1"),
          (change_screen_mission),
      ]),
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###sacred grove
  (
    "celidon_forest",0,
    "Before you lies a strange place that seems to emanate a mystical energy from the past.",
    "none",
    [(set_background_mesh, "mesh_pic_forest"), #pic book
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enter",[(neq, "$druid_on", 2),],"Enter.",[
          (set_jump_mission,"mt_stone_circle"),
          (modify_visitors_at_site,"scn_celidon_forest"),
          (reset_visitors),
          (assign,reg(0),"trp_farmerdruid"),
          (assign,reg(1),"trp_manhunterdruid"),
          (assign,reg(2),"trp_peasant_womandruid"),
          (assign,reg(3),"trp_refugeedruid"),
          (set_visitor,1,reg(3)),
          (set_visitor,2,reg(1)),
          (set_visitor,3,reg(2)),
          (set_visitor,4,reg(3)),
          (set_visitor,5,reg(0)),
          (set_visitor,6,"trp_farmerdruid"),
          (set_visitor,7,"trp_farmerdruid"),
          (set_visitor,8,reg(3)),
          (set_visitor,9,reg(0)),
          (set_visitor,10,reg(1)),
          (set_visitor,11,reg(2)),
          (set_visitor,12,reg(3)),
          (set_visitor,13,"trp_peasant_womandruid"),
          (set_visitor,14,"trp_farmerdruid"),
          (set_visitor,15,reg(2)),
          (set_visitor,16,"trp_farmerdruid"),
          (set_visitor,17,"trp_last_druid"), #druida chief
          (set_visitor,18,"trp_prisionerdruid"),
          (set_visitor,19,reg(0)),
          (set_visitor,20,reg(1)),
          (set_visitor,21,reg(2)),
          (set_visitor,22,reg(3)),
          (set_visitor,23,"trp_farmerdruid"),
          (set_visitor,24,reg(0)),
          
          (try_begin), #britona,
            (neg|main_party_has_troop,"trp_npc7"),
            (troop_slot_eq, "trp_npc7", slot_troop_occupation, 0),
            (neg|troop_slot_ge, "trp_npc7", slot_troop_prisoner_of_party, centers_begin),
            (set_visitor,25,"trp_npc7"), #Dwywei
          (try_end),
          
          (set_visitor,26,"trp_refugeedruid"),
          (set_visitor,27,"trp_farmerdruid"),
          (set_visitor,28,"trp_manhunterdruid"),
          (set_visitor,29,"trp_peasant_womandruid"),
          (set_visitor,30,"trp_peasant_womandruid"),
          (set_visitor,31,reg(2)),
          (set_visitor,32,reg(3)),
          (set_visitor,33,"trp_manhunterdruid"),
          (set_visitor,34,reg(2)),
          (set_visitor,35,reg(2)),
          (set_visitor,36,"trp_manhunterdruid"),
          (set_visitor,37,reg(2)),
          (set_visitor,38,reg(3)),
          (set_visitor,39,reg(0)),
          (set_visitor,40,reg(1)),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_celidon_forest", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_celidon_forest"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ############################ last druid end
  
  ###roman ruins
  (
    "hidden_valley",0,
    "You arrive at a strange place that looks like Roman ruins. Your men set up camp behind you as you start to explore...",
    "none",
    [(set_background_mesh, "mesh_pic_forest"), #pic book
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter_hv",[(eq, "$g_roman_ruins_visited", 0),],"Investigate.",
        [
          (set_jump_mission,"mt_dungeon_romanbath"),
          (modify_visitors_at_site,"scn_hidden_valley"),
          (reset_visitors),
          (assign,reg(0),"trp_slave_driver"),
          (assign,reg(1),"trp_slave_hunter"),
          (assign,reg(2),"trp_slave_crusher"),
          (assign,reg(3),"trp_slave_driver"),
          (shuffle_range,0,4),
          (set_visitor,5,reg(0)),
          (set_visitor,6,"trp_slave_crusher"),
          (set_visitor,7,"trp_slave_crusher"),
          (set_visitor,8,reg(3)),
          (set_visitor,9,reg(0)),
          (set_visitor,10,reg(1)),
          (set_visitor,11,reg(2)),
          (set_visitor,12,reg(3)),
          (set_visitor,13,"trp_slave_crusher"),
          (set_visitor,14,"trp_sea_raider"),
          (set_visitor,15,reg(2)),
          (set_visitor,16,"trp_slaver_chief"),
          (set_visitor,17,reg(2)),
          (set_visitor,18,reg(3)),
          (set_visitor,19,reg(0)),
          (set_visitor,20,reg(1)),
          (set_visitor,21,reg(2)),
          (set_visitor,22,reg(3)),
          (set_visitor,23,"trp_desert_bandit_hero"),
          (set_visitor,24,reg(0)),
          (set_visitor,25,"trp_slave_hunter"),
          (set_visitor,26,"trp_slave_hunter"),
          (set_visitor,27,"trp_slave_hunter"),
          (set_visitor,28,"trp_slave_hunter"),
          (set_visitor,29,"trp_slave_hunter"),
          (set_visitor,30,"trp_slave_hunter"),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_hidden_valley", slot_scene_visited, 1),
          (assign,"$g_odin1",0),
          (assign,"$g_odin2",0),
          (jump_to_scene,"scn_hidden_valley"),
          (change_screen_mission),
      ]),
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ##############
  
  (
    "battlefields",0,
    "{!}Select a field...",
    "none",
    [],
    [
      
      ("enter_f1",[],"{!}Field 1",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_field_1"],[change_screen_mission]]),
      ("enter_f2",[],"{!}Field 2",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_field_2"],[change_screen_mission]]),
      ("enter_f3",[],"{!}Field 3",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_field_3"],[change_screen_mission]]),
      ("enter_f4",[],"{!}Field 4",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_field_4"],[change_screen_mission]]),
      ("enter_f5",[],"{!}Field 5",[[set_jump_mission,"mt_ai_training"],[jump_to_scene,"scn_field_5"],[change_screen_mission]]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  
  ##  (
  ##    "center_under_attack_while_resting",0,
  ##    "{s1} has been besieged by {s2}, and the enemy seems to be preparing for an assault!\
  ## What will you do?",
  ##    "none",
  ##    [
  ##        (party_get_battle_opponent, ":besieger_party", "$auto_enter_town"),
  ##        (str_store_party_name, s1, "$auto_enter_town"),
  ##        (str_store_party_name, s2, ":besieger_party"),
  ##    ],
  ##    [
  ##      ("defend_against_siege", [],"Help the defenders of {s1}!",
  ##       [
  ##           (assign, "$g_last_player_do_nothing_against_siege_next_check", 0),
  ##           (rest_for_hours, 0, 0, 0),
  ##           (change_screen_return),
  ##           (start_encounter, "$auto_enter_town"),
  ##           ]),
  ##      ("do_not_defend_against_siege",[],"Find a secure place and wait there.",
  ##       [
  ##           (change_screen_return),
  ##           ]),
  ##    ]
  ##  ),
  
  (
    "join_siege_outside",0,
    "{s1} has come under siege by {s2}.",
    "none",
    [
      (str_store_party_name, s1, "$g_encountered_party"),
      (str_store_party_name, s2, "$g_encountered_party_2"),
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_siege_sighted_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_siege_sighted"),
      (try_end),
    ],
    [
      ("approach_besiegers",[(store_faction_of_party, ":faction_no", "$g_encountered_party_2"),
          (store_relation, ":relation", ":faction_no", "fac_player_faction"),
          (ge, ":relation", 0),
          (store_faction_of_party, ":faction_no", "$g_encountered_party"),
          (store_relation, ":relation", ":faction_no", "fac_player_faction"),
          (lt, ":relation", 0),
          ],"Approach the siege camp.",[
          (jump_to_menu, "mnu_besiegers_camp_with_allies"),
      ]),
      ("pass_through_siege",[(store_faction_of_party, ":faction_no", "$g_encountered_party"),
          (store_relation, ":relation", ":faction_no", "fac_player_faction"),
          (ge, ":relation", 0),
        ],"Pass through the siege lines and enter {s1}.",
        [
          (jump_to_menu,"mnu_cut_siege_without_fight"),
      ]),
      ("leave",[],"Leave.",[(leave_encounter),
          (change_screen_return)]),
    ]
  ),
  (
    "cut_siege_without_fight",0,
    "The besiegers let you approach the gates without challenge.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_sighted"),
    ],
    [
      ("continue",[],"Continue...",[(try_begin),
            (this_or_next|eq, "$g_encountered_party_faction", "fac_player_supporters_faction"),
            (eq, "$g_encountered_party_faction", "$players_kingdom"),
            (jump_to_menu, "mnu_town"),
          (else_try),
            (jump_to_menu, "mnu_castle_outside"),
          (try_end)]),
    ]
  ),
  #
  (
    "besiegers_camp_with_allies",0,
    "{s1} remains under siege. The banners of {s2} fly above the camp of the besiegers, " +
    "where you and your men are welcomed.",
    "none",
    [       (set_background_mesh, "mesh_pic_swad"), #pic book
      
      (str_store_party_name, s1, "$g_encountered_party"),
      (str_store_party_name, s2, "$g_encountered_party_2"),
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", "$g_encountered_party_2"),
      (select_enemy, 0),
      (call_script, "script_encounter_calculate_fit"),
      (try_begin),
        (eq, "$new_encounter", 1),
        (assign, "$new_encounter", 0),
        (call_script, "script_encounter_init_variables"),
      (try_end),
      
      (try_begin),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (else_try),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1),
          (assign, ":enemy_finished", 1),
        (else_try),
          (this_or_next|le, "$g_enemy_fit_for_battle",0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          (ge, "$g_friend_fit_for_battle", 1),
          (assign, ":enemy_finished", 1),
        (try_end),
        (this_or_next|eq, ":enemy_finished", 1),
        (eq, "$g_enemy_surrenders", 1),
        ##          (assign, "$g_next_menu", -1),#"mnu_castle_taken_by_friends"),
        ##          (jump_to_menu, "mnu_total_victory"),
        (call_script, "script_party_wound_all_members", "$g_enemy_party"),
        
        ##                  #Center captured Innecesary code, this works on script game_event_simulate_battle
        ##          (try_begin),
        ##            (assign, "$g_recalculate_ais", 1),
        ##            (assign, ":root_winner_party", "$g_ally_party"),
        (assign, ":root_defeated_party", "$g_enemy_party"),
        ##            (store_faction_of_party, ":winner_faction", ":root_winner_party"),
        ##            (try_begin),
        ##              (eq, ":winner_faction", "fac_player_supporters_faction"),
        ##              (assign, ":winner_faction", "$players_kingdom"),
        ##            (try_end),
        ##            (store_faction_of_party, ":defeated_faction", ":root_defeated_party"),
        ##
        ##            (str_store_party_name, s1, ":root_defeated_party"),
        ##            (str_store_faction_name, s2, ":winner_faction"),
        ##            (str_store_faction_name, s3, ":defeated_faction"),
        ##            (display_log_message, "str_center_captured"),
        ##
        ##            (try_begin),
        ##                 (eq, "$g_encountered_party", ":root_defeated_party"),
        ##                 (call_script, "script_add_log_entry", logent_player_participated_in_siege, "trp_player",  "$g_encountered_party", 0, "$g_encountered_party_faction"),
        ##            (try_end),
        ##
        ##            (try_begin),
        ##              (party_get_num_companion_stacks, ":num_stacks", ":root_winner_party"),
        ##              (gt, ":num_stacks", 0),
        ##              (party_stack_get_troop_id, ":leader_troop_no", ":root_winner_party", 0),
        ##              (is_between, ":leader_troop_no", companions_begin, kingdom_heroes_end),
        ##              (party_set_slot, ":root_defeated_party", slot_center_last_taken_by_troop, ":leader_troop_no"),
        ##            (else_try),
        ##              (party_set_slot, ":root_defeated_party", slot_center_last_taken_by_troop, -1),
        ##            (try_end),
        ##
        (call_script, "script_lift_siege", ":root_defeated_party", 0),
        ##            (call_script, "script_give_center_to_faction", ":root_defeated_party", ":winner_faction"),
        ##            #Reduce prosperity of the center by 5
        ##            (call_script, "script_change_center_prosperity", ":root_defeated_party", -5),
        ##            (call_script, "script_order_best_besieger_party_to_guard_center", ":root_defeated_party", ":winner_faction"),
        ##            (try_begin),
        ##              (eq, ":winner_faction", "fac_player_supporters_faction"),
        ##              (jump_to_menu, "mnu_castle_taken"),
        ##            (else_try),
        ##				(call_script, "script_cf_reinforce_party", ":root_defeated_party"),
        ##				(call_script, "script_center_get_food_store_limit", ":root_defeated_party"),
        ##				(val_div, reg0, 2),
        ##				(party_set_slot, ":root_defeated_party", slot_party_food_store, reg0),
        ##            (try_end),
        ##          (try_end),
        ######
        
        
        (leave_encounter),
        (change_screen_return),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_collective_friends"),
        (assign, ":ally_num_soldiers", reg0),
        (eq, "$g_battle_result", -1),
        (this_or_next|eq, ":ally_num_soldiers", 0), #battle lost (TODO : also compare this with routed allies too like in other parts)
        (le, ":ally_num_soldiers",  "$num_routed_allies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
        (leave_encounter),
        (change_screen_return),
      (try_end),
    ],
    [
      ("talk_to_siege_commander",[],"Request a meeting with the commander.",[
          (call_script, "script_get_meeting_scene"), (assign, ":meeting_scene", reg0),
          (modify_visitors_at_site,":meeting_scene"),(reset_visitors),
          (set_visitor,0,"trp_player"),
          (party_stack_get_troop_id, ":siege_leader_id","$g_encountered_party_2",0),
          (party_stack_get_troop_dna,":siege_leader_dna","$g_encountered_party_2",0),
          (set_visitor,17,":siege_leader_id",":siege_leader_dna"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,":meeting_scene"),
          (assign, "$talk_context", tc_siege_commander),
          (change_screen_map_conversation, ":siege_leader_id")]),
      ("join_siege_with_allies",[(neg|troop_is_wounded, "trp_player")], "Join the next assault.",
        [
          (assign, "$g_joined_battle_to_help", 1),
          (party_set_next_battle_simulation_time, "$g_encountered_party", -1),
          (try_begin),
            (check_quest_active, "qst_join_siege_with_army"),
            (quest_slot_eq, "qst_join_siege_with_army", slot_quest_target_center, "$g_encountered_party"),
            (add_xp_as_reward, 250),
            (call_script, "script_succeed_quest", "qst_join_siege_with_army"),
            (set_show_messages, 0),
            (call_script, "script_end_quest", "qst_join_siege_with_army"),
            (set_show_messages, 1),
            #Reactivating follow army quest
            (faction_get_slot, ":faction_marshal", "$players_kingdom", slot_faction_marshal),
            (str_store_troop_name_link, s9, ":faction_marshal"),
            (setup_quest_text, "qst_follow_army"),
            (str_store_string, s2, "@{s9} wants you to follow his army until further notice."),
            (call_script, "script_start_quest", "qst_follow_army", ":faction_marshal"),
            (assign, "$g_player_follow_army_warnings", 0),
          (try_end),
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_walls),
          (else_try),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
          (try_end),
          (call_script, "script_calculate_battle_advantage"),
          (val_mul, reg0, 2),
          (val_div, reg0, 3), #scale down the advantage a bit in sieges.
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_center_siege_with_belfry, 1),
            (set_jump_mission,"mt_castle_attack_walls_belfry"),
          (else_try),
            (set_jump_mission,"mt_castle_attack_walls_ladder"),
          (try_end),
          (jump_to_scene,":battle_scene"),
          (assign, "$g_siege_final_menu", "mnu_besiegers_camp_with_allies"),
          (assign, "$g_siege_battle_state", 1),
          (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ("join_siege_stay_back", [(call_script, "script_party_count_members_with_full_health", "p_main_party"),
          (ge, reg0, 3),
        ],
        "Order your soldiers to join the next assault without you.",
        [
          (assign, "$g_joined_battle_to_help", 1),
          (party_set_next_battle_simulation_time, "$g_encountered_party", -1),
          (try_begin),
            (check_quest_active, "qst_join_siege_with_army"),
            (quest_slot_eq, "qst_join_siege_with_army", slot_quest_target_center, "$g_encountered_party"),
            (add_xp_as_reward, 100),
            (call_script, "script_succeed_quest", "qst_join_siege_with_army"),
            (set_show_messages, 0),
            (call_script, "script_end_quest", "qst_join_siege_with_army"),
            (set_show_messages, 1),
            #Reactivating follow army quest
            (faction_get_slot, ":faction_marshal", "$players_kingdom", slot_faction_marshal),
            (str_store_troop_name_link, s9, ":faction_marshal"),
            (setup_quest_text, "qst_follow_army"),
            (str_store_string, s2, "@{s9} wants you to follow his army until further notice."),
            (call_script, "script_start_quest", "qst_follow_army", ":faction_marshal"),
            (assign, "$g_player_follow_army_warnings", 0),
          (try_end),
          (jump_to_menu,"mnu_castle_attack_walls_with_allies_simulate")]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  
  (
    "castle_outside",0,
    "You are outside {s2}.{s11} {s3} {s4}",
    "none",
    [
      #chief anade saqueo Siege Warfare
      (try_begin),
        (party_slot_ge, "$g_encountered_party", slot_party_looted_left_days, 1),
        (store_faction_of_party, ":faction", "$g_encountered_party"),
        (neq, ":faction", "$players_kingdom"),
        (jump_to_menu, "mnu_saqueo_loot_continue"),
      (else_try),
        #chief saqueo acaba
        
        (assign, "$g_enemy_party", "$g_encountered_party"),
        (assign, "$g_ally_party", -1),
        (str_store_party_name, s2,"$g_encountered_party"),
        (try_begin),
          (eq, "$new_encounter", 1),
          (party_get_template_id, ":template_id", "$g_enemy_party"),
          (neq, ":template_id", "pt_routed_warriors"), #chief, los que huyen no luchan
          (call_script, "script_let_nearby_parties_join_current_battle", 1, 0),
        (try_end),
        (call_script, "script_encounter_calculate_fit"),
        (assign,"$all_doors_locked",1),
        (assign, "$current_town","$g_encountered_party"),
        
        (try_begin), #mainquest chief
          (eq, "$current_town", "p_castle_9"),
          (check_quest_active,"qst_sven_traitor"),
          (jump_to_menu, "mnu_nothingam_siege"),
        (try_end),
        ###
        (try_begin),
          (eq, "$new_encounter", 1),
          (assign, "$new_encounter", 0),
          (call_script, "script_encounter_init_variables"),
          (assign, "$entry_to_town_forbidden",0),
          (assign, "$sneaked_into_town",0),
          (assign, "$town_entered", 0),
          #          (assign, "$waiting_for_arena_fight_result", 0),
          (assign, "$encountered_party_hostile", 0),
          (assign, "$encountered_party_friendly", 0),
          (try_begin),
            (gt, "$g_player_besiege_town", 0),
            (neq,"$g_player_besiege_town","$g_encountered_party"),
            (party_slot_eq, "$g_player_besiege_town", slot_center_is_besieged_by, "p_main_party"),
            (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
            (assign,"$g_player_besiege_town",-1),
          (try_end),
          (try_begin),
            (lt, "$g_encountered_party_relation", 0),
            (assign, "$encountered_party_hostile", 1),
            (assign,"$entry_to_town_forbidden",1),
          (try_end),
          
          (assign,"$cant_sneak_into_town",0),
          (try_begin),
            (eq,"$current_town","$last_sneak_attempt_town"),
            (store_current_hours,reg(2)),
            (val_sub,reg(2),"$last_sneak_attempt_time"),
            (lt,reg(2),12),
            (assign,"$cant_sneak_into_town",1),
          (try_end),
        (else_try), #second or more turn
          (eq, "$g_leave_encounter",1),
          (change_screen_return),
        (try_end),
        
        (str_clear,s4),
        (try_begin),
          (eq,"$entry_to_town_forbidden",1),
          (try_begin),
            (eq,"$cant_sneak_into_town",1),
            (str_store_string,s4,"str_sneaking_to_town_impossible"),
          (else_try),
            (str_store_string,s4,"str_entrance_to_town_forbidden"),
          (try_end),
        (try_end),
        
        (party_get_slot, ":center_lord", "$current_town", slot_town_lord),
        (store_faction_of_party, ":center_faction", "$current_town"),
        (str_store_faction_name,s9,":center_faction"),
        (try_begin),
          (ge, ":center_lord", 0),
          (str_store_troop_name,s8,":center_lord"),
          (str_store_string,s7,"@{s8} of the {s9}"),
        (try_end),
        
        (try_begin), # same mnu_town
          (party_slot_eq,"$current_town",slot_party_type, spt_castle),
          (try_begin),
            (eq, ":center_lord", "trp_player"),
            (str_store_string,s11,"@ As you reach the settlement, you are greeted by your men."),
          (else_try),
            (ge, ":center_lord", 0),
            (str_store_string,s11,"@ As you reach the settlement, you are greeted by men loyal to {s7}."),
          (else_try),
            (is_between, ":center_faction", kingdoms_begin, kingdoms_end),
            (str_store_string,s11,"str__this_castle_is_temporarily_under_royal_control"),
          (else_try),
            (str_store_string,s11,"str__this_castle_does_not_seem_to_be_under_anyones_control"),
          (try_end),
        (else_try),
          (try_begin),
            (eq, ":center_lord", "trp_player"),
            (str_store_string,s11,"@ You are greeted by men loyal to you."),
          (else_try),
            (ge, ":center_lord", 0),
            (str_store_string,s11,"@ You are greeted by men loyal to {s7}."),
          (else_try),
            (is_between, ":center_faction", kingdoms_begin, kingdoms_end),
            (str_store_string,s11,"str__this_town_is_temporarily_under_royal_control"),
          (else_try),
            (str_store_string,s11,"str__the_townspeople_seem_to_have_declared_their_independence"),
          (try_end),
        (try_end),
        
        (party_get_num_companions, reg(7),"p_collective_enemy"),
        (assign,"$castle_undefended",0),
        (str_clear, s3),
        (try_begin),
          (eq,reg(7),0),
          (assign,"$castle_undefended",1),
          #          (party_set_faction,"$g_encountered_party","fac_neutral"),
          #          (party_set_slot, "$g_encountered_party", slot_town_lord, stl_unassigned),
          (str_store_string, s3, "str_castle_is_abondened"),
        (else_try),
          (eq,"$g_encountered_party_faction","fac_player_supporters_faction"),
          (str_store_string, s3, "str_place_is_occupied_by_player"),
        (else_try),
          (lt, "$g_encountered_party_relation", 0),
          (str_store_string, s3, "str_place_is_occupied_by_enemy"),
        (else_try),
          #          (str_store_string, s3, "str_place_is_occupied_by_friendly"),
        (try_end),
        
        (try_begin),
          (eq, "$g_leave_town_outside",1),
          (assign, "$g_leave_town_outside",0),
          (assign, "$g_permitted_to_center", 0),
          (change_screen_return),
        (else_try),
          (check_quest_active, "qst_escort_lady"),
          (quest_slot_eq, "qst_escort_lady", slot_quest_target_center, "$g_encountered_party"),
          (quest_get_slot, ":quest_object_troop", "qst_escort_lady", slot_quest_object_troop),
          (call_script, "script_get_meeting_scene"), (assign, ":meeting_scene", reg0),
          (modify_visitors_at_site,":meeting_scene"),
          (reset_visitors),
          (set_visitor,0, "trp_player"),
          (set_visitor,17, ":quest_object_troop"),
          (set_jump_mission, "mt_conversation_encounter"),
          (jump_to_scene, ":meeting_scene"),
          (assign, "$talk_context", tc_entering_center_quest_talk),
          (change_screen_map_conversation, ":quest_object_troop"),
        (else_try),
          (check_quest_active, "qst_kidnapped_girl"),
          (quest_slot_eq, "qst_kidnapped_girl", slot_quest_giver_center, "$g_encountered_party"),
          (quest_slot_eq, "qst_kidnapped_girl", slot_quest_current_state, 3),
          (call_script, "script_get_meeting_scene"), (assign, ":meeting_scene", reg0),
          (modify_visitors_at_site,":meeting_scene"),
          (reset_visitors),
          (set_visitor,0, "trp_player"),
          (set_visitor,17, "trp_kidnapped_girl"),
          (set_jump_mission, "mt_conversation_encounter"),
          (jump_to_scene, ":meeting_scene"),
          (assign, "$talk_context", tc_entering_center_quest_talk),
          (change_screen_map_conversation, "trp_kidnapped_girl"),
          ##        (else_try),
          ##          (gt, "$lord_requested_to_talk_to", 0),
          ##          (store_current_hours, ":cur_hours"),
          ##          (neq, ":cur_hours", "$quest_given_time"),
          ##          (modify_visitors_at_site,"scn_conversation_scene"),
          ##          (reset_visitors),
          ##          (assign, ":cur_lord", "$lord_requested_to_talk_to"),
          ##          (assign, "$lord_requested_to_talk_to", 0),
          ##          (set_visitor,0,"trp_player"),
          ##          (set_visitor,17,":cur_lord"),
          ##          (set_jump_mission,"mt_conversation_encounter"),
          ##          (jump_to_scene,"scn_conversation_scene"),
          ##          (assign, "$talk_context", tc_castle_gate_lord),
          ##          (change_screen_map_conversation, ":cur_lord"),
        (else_try),
          (eq, "$g_town_visit_after_rest", 1),
          (assign, "$g_town_visit_after_rest", 0),
          (jump_to_menu,"mnu_town"),
        (else_try),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
          (this_or_next|party_slot_eq, "$g_encountered_party", slot_town_lord, "trp_player"),
          (faction_slot_eq, "$g_encountered_party_faction", slot_faction_leader, "trp_player"),
          (jump_to_menu, "mnu_enter_your_own_castle"),
        (else_try),
          (party_slot_eq,"$g_encountered_party", slot_party_type,spt_castle),
          (ge, "$g_encountered_party_relation", 0),
          (this_or_next|eq,"$castle_undefended", 1),
          (this_or_next|eq, "$g_permitted_to_center", 1),
          (eq, "$g_encountered_party_faction", "$players_kingdom"),
          (jump_to_menu, "mnu_town"),
        (else_try),
          ### following line out commented to avoid castle menu for vc (phaiak)
          #(party_slot_eq,"$g_encountered_party", slot_party_type,spt_town),
          (ge, "$g_encountered_party_relation", 0),
          (jump_to_menu, "mnu_town"),
          #vc coastal conquest begin
        (else_try),
          (eq, "$g_next_menu", "mnu_port_attack"),
          (assign, "$g_next_menu", 0),
          (jump_to_menu, "mnu_port_attack"),
          #vc coastal conquest end
        (else_try),
          (eq, "$g_player_besiege_town", "$g_encountered_party"),
          (jump_to_menu, "mnu_castle_besiege"),
        (try_end),
        
        (call_script, "script_set_town_picture"),
      (try_end),
    ],
    [
      #        ("talk_to_castle_commander",[
      #            (party_get_num_companions, ":no_companions", "$g_encountered_party"),
      #            (ge, ":no_companions", 1),
      #            (eq,"$ruler_meeting_denied",0), #this variable is removed
      #            ],
      #         "Request a meeting with the lord of the castle.",[
      #             (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
      #             (set_visitor,0,"trp_player"),
      #             (party_stack_get_troop_id, reg(6),"$g_encountered_party",0),
      #             (party_stack_get_troop_dna,reg(7),"$g_encountered_party",0),
      #             (set_visitor,17,reg(6),reg(7)),
      #             (set_jump_mission,"mt_conversation_encounter"),
      #             (jump_to_scene,"scn_conversation_scene"),
      #             (assign, "$talk_context", tc_castle_commander),
      #             (change_screen_map_conversation, reg(6))
      #             ]),
      ("approach_gates",[(this_or_next|eq,"$entry_to_town_forbidden",1),
          (party_slot_eq,"$g_encountered_party", slot_party_type,spt_castle)],
        "Approach the gates and hail the guard.",[ (str_clear, s10),
          (jump_to_menu, "mnu_castle_guard"),
          ##                                                   (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
          ##                                                   (set_visitor,0,"trp_player"),
          ##                                                   (store_faction_of_party, ":cur_faction", "$g_encountered_party"),
          ##                                                   (faction_get_slot, ":cur_guard", ":cur_faction", slot_faction_guard_troop),
          ##                                                   (set_visitor,17,":cur_guard"),
          ##                                                   (set_jump_mission,"mt_conversation_encounter"),
          ##                                                   (jump_to_scene,"scn_conversation_scene"),
          ##                                                   (assign, "$talk_context", tc_castle_gate),
          ##                                                   (change_screen_map_conversation, ":cur_guard")
      ]),
      
      ("town_sneak",
        [
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type,spt_town),
            (str_store_string, s7, "str_town"),
          (else_try),
            (str_store_string, s7, "str_castle"),
          (try_end),
          
          (eq, "$entry_to_town_forbidden", 1),
          (eq, "$cant_sneak_into_town", 0)
        ],
        "Disguise yourself and try to sneak into {s7}",
        [
          (faction_get_slot, ":player_alarm", "$g_encountered_party_faction", slot_faction_player_alarm),
          (party_get_num_companions, ":num_men", "p_main_party"),
          (party_get_num_prisoners, ":num_prisoners", "p_main_party"),
          (val_add, ":num_men", ":num_prisoners"),
          (val_mul, ":num_men", 2),
          (val_div, ":num_men", 3),
          (store_add, ":get_caught_chance", ":player_alarm", ":num_men"),
          (store_random_in_range, ":random_chance", 0, 100),
          (try_begin),
            (this_or_next|ge, ":random_chance", ":get_caught_chance"),
            (eq, "$g_last_defeated_bandits_town", "$g_encountered_party"),
            (assign, "$g_last_defeated_bandits_town", 0),
            (assign, "$sneaked_into_town",1),
            (assign, "$town_entered", 1),
            (jump_to_menu,"mnu_sneak_into_town_suceeded"),
            (assign, "$g_mt_mode", tcm_disguised),
          (else_try),
            (jump_to_menu,"mnu_sneak_into_town_caught"),
          (try_end),
      ]),
      
      ("castle_start_siege",
        [
          (this_or_next|party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, -1),
          (             party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, "p_main_party"),
          #MOTO chief add consequences as vassal
          # (store_relation, ":reln", "$g_encountered_party_faction", "fac_player_faction"),
          ##           (try_begin),
          ##             (gt, "$players_kingdom", 0),
          ##             (neq, "$players_kingdom", "fac_player_supporters_faction"),
          ##             (store_relation, ":reln", "$g_encountered_party_faction", "$players_kingdom"),
          ##           (else_try),
          ##             (store_relation, ":reln", "$g_encountered_party_faction", "fac_player_faction"),
          ##           (try_end),
          #MOTO end add consequences as vassal
          #  (lt, ":reln", 1),#chief changed from 0 to allow attacking neutral castles
          # (lt, ":reln", 0),
          (lt, "$g_encountered_party_2", 1),
          (call_script, "script_party_count_fit_for_battle","p_main_party"),
          (gt, reg(0), 20),
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (assign, reg6, 1),
          (else_try),
            (assign, reg6, 0),
          (try_end),
        ],
        "Besiege the {reg6?town:castle}.",
        [
          (assign,"$g_player_besiege_town","$g_encountered_party"),
          
          #MOTO chief add consequences as vassal
          (try_begin),
            (gt, "$players_kingdom", 0),
            (faction_slot_eq, "$players_kingdom", slot_faction_state, sfs_active),
            (store_relation, ":enemy_relation", "$g_encountered_party_faction", "$players_kingdom"),
            (ge,":enemy_relation",0),    #not yet at war?
            (call_script, "script_diplomacy_start_war_between_kingdoms", "$players_kingdom", "$g_encountered_party_faction", logent_player_faction_declares_war),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -4),
            (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord),
            (call_script, "script_change_player_relation_with_troop", ":town_lord", -30),
            
            #player is vassal
            (try_begin),
              (neq, "$players_kingdom", "fac_player_supporters_faction"),
              (store_add, ":slot_provocation_days", "$players_kingdom", slot_faction_provocation_days_with_factions_begin),
              (val_sub, ":slot_provocation_days", kingdoms_begin),
              
              #there was provocation
              (try_begin),
                (faction_slot_ge, "$g_encountered_party_faction", ":slot_provocation_days", 1),
                (faction_get_slot,":faction_leader","$players_kingdom",slot_faction_leader),
                (try_begin),
                  (ge, ":faction_leader", 0),
                  (call_script,"script_change_player_relation_with_troop",":faction_leader",-10),
                (try_end),
                
                #unprovoked attack
              (else_try),
                (troop_get_slot, ":controversy", "trp_player", slot_troop_controversy),
                (val_add, ":controversy", 40), #two of these will get player fired as marshal script_decide_faction_ai
                (troop_set_slot, "trp_player", slot_troop_controversy, ":controversy"),
                (display_message, "@The rulers of the realms are troubled by your offense against the majesty of your lord."),
                (try_for_range, ":kingdom", npc_kingdoms_begin, npc_kingdoms_end),
                  (faction_get_slot,":faction_leader", ":kingdom", slot_faction_leader),
                  (ge, ":faction_leader", 0),
                  (try_begin),
                    (eq, ":kingdom", "$players_kingdom"),
                    (call_script,"script_change_player_relation_with_troop",":faction_leader",-20),
                  (else_try),
                    (call_script,"script_change_player_relation_with_troop",":faction_leader",-5),  #this effectively prevents player from becoming vassal of other kings to cause wars lord_ask_enter_service
                  (try_end),
                (try_end),
              (try_end),
            (try_end),
            
            #no kingdom or at war
          (else_try),
            (call_script, "script_make_kingdom_hostile_to_player", "$g_encountered_party_faction", -40),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -2),
            (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord),
            (call_script, "script_change_player_relation_with_troop", ":town_lord", -30),
          (try_end),
          #MOTO end add consequences as vassal
          (call_script, "script_update_all_notes"),
          #siege warfare chief We repit this here for advoid issues.
          (assign, "$g_empieza_asedio", 1), #variable to begin siege
          (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
          (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
          (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
          (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
          (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          
          (assign, "$g_siege_saneamiento", 0),
          (assign, "$g_traicion_interna", 0),
          (assign, "$g_infiltracion_interna", 0),
          (assign, "$g_campos_cercanos", 0),
          (assign, "$g_listos_para_asalto", 0),
          (assign, "$g_mantlets_1", 0),
          (assign, "$g_cabezas_dentro", 0), #event
          (assign, "$g_siege_method", 0),
          (assign, "$g_siege_sallied_out_once", 0),
          (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
          (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
          #siege warfare acaba
          (jump_to_menu, "mnu_castle_besiege"),
      ]),
      
      ("cheat_castle_start_siege",
        [
          (eq, "$cheat_mode", 1),
          (this_or_next|party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, -1),
          (             party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, "p_main_party"),
          (store_relation, ":reln", "$g_encountered_party_faction", "fac_player_faction"),
          (ge, ":reln", 0),
          (lt, "$g_encountered_party_2", 1),
          (call_script, "script_party_count_fit_for_battle","p_main_party"),
          (gt, reg(0), 1),
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (assign, reg6, 1),
          (else_try),
            (assign, reg6, 0),
          (try_end),
        ],
        "{!}CHEAT: Besiege the {reg6?town:castle}...",
        [
          (assign,"$g_player_besiege_town","$g_encountered_party"),
          (jump_to_menu, "mnu_castle_besiege"),
      ]),
      
      ("leave",[],"Leave.",[(change_screen_return,0)]),
      ("castle_cheat_interior",[(eq, "$cheat_mode", 1)], "{!}CHEAT! Interior.",[(set_jump_mission,"mt_ai_training"),
          (party_get_slot, ":castle_scene", "$current_town", slot_town_castle),
          (jump_to_scene,":castle_scene"),
          (change_screen_mission)]),
      ("castle_cheat_exterior",[(eq, "$cheat_mode", 1)], "{!}CHEAT! Exterior.",[
          #                                                       (set_jump_mission,"mt_town_default"),
          (set_jump_mission,"mt_ai_training"),
          (party_get_slot, ":castle_scene", "$current_town", slot_castle_exterior),
          (jump_to_scene,":castle_scene"),
          (change_screen_mission)]),
      ("castle_cheat_town_walls",[(eq, "$cheat_mode", 1),(party_slot_eq,"$current_town",slot_party_type, spt_town),], "{!}CHEAT! Town Walls.",
        [
          (party_get_slot, ":scene", "$current_town", slot_town_walls),
          (set_jump_mission,"mt_ai_training"),
          (jump_to_scene,":scene"),
          (change_screen_mission)]),
      
    ]
  ),
  (
    "castle_guard",0,
    "You approach the gate. The men on the walls watch you closely.^^{s10}",
    "none",
    [
      ##prisoner lord chief Siege Warfare
      (try_begin),
        (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord),
        (gt, ":town_lord", 0),
        (is_between, ":town_lord", companions_begin, kingdom_heroes_end),
        (str_store_troop_name, s11, ":town_lord"),
        (try_begin),
          (party_count_prisoners_of_type, ":party_has_prisoner", "p_main_party", ":town_lord"),
          (gt, ":party_has_prisoner", 0),
          (str_store_string, s10, "@You make sure they see that their lord, {s11}, is held prisoner by your army."),
        (try_end),
      (try_end),
      ###chief acaba
      
      (call_script, "script_set_town_picture"),
    ],
    [
      ("request_shelter",[(party_slot_eq, "$g_encountered_party",slot_party_type, spt_castle),
          (ge, "$g_encountered_party_relation", 0)],
        "Request entry to the castle.",
        [(party_get_slot, ":castle_lord", "$g_encountered_party", slot_town_lord),
          (try_begin),
            (lt, ":castle_lord", 0),
            (jump_to_menu, "mnu_castle_entry_granted"),
          (else_try),
            (call_script, "script_troop_get_player_relation", ":castle_lord"),
            (assign, ":castle_lord_relation", reg0),
            #(troop_get_slot, ":castle_lord_relation", ":castle_lord", slot_troop_player_relation),
            (try_begin),
              (gt, ":castle_lord_relation", -15),
              (jump_to_menu, "mnu_castle_entry_granted"),
            (else_try),
              (jump_to_menu, "mnu_castle_entry_denied"),
            (try_end),
          (try_end),
      ]),
      ("request_meeting_commander",[],
        "Request a meeting with someone.",
        [
          (jump_to_menu, "mnu_castle_meeting"),
      ]),
      ("leave",[],
        "Leave.",
        [(change_screen_return,0)]),
    ]
  ),
  (
    "castle_entry_granted",0,
    "After a brief wait, the guards open the gates for you and allow your party inside.",
    "none",
    [
      (call_script, "script_set_town_picture"),
    ],
    [
      ("continue",[],
        "Continue...",
        [(jump_to_menu,"mnu_town")]),
    ]
  ),
  (
    "castle_entry_denied",0,
    "The lord of this castle has forbidden you from coming inside these walls, " +
    "and the guard sergeant informs you that his men will fire if you attempt to come any closer.",
    "none",
    [
      (call_script, "script_set_town_picture"),
    ],
    [
      ("continue",[],
        "Continue...",
        [(str_clear, s10),(jump_to_menu,"mnu_castle_guard")]),
    ]
  ),
  (
    "castle_meeting",0,
    "Who do you want to meet with?",
    "none",
    [
      (assign, "$num_castle_meeting_troops", 0),
      (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
        (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
        (call_script, "script_get_troop_attached_party", ":troop_no"),
        (eq, "$g_encountered_party", reg0),
        (troop_set_slot, "trp_temp_array_a", "$num_castle_meeting_troops", ":troop_no"),
        (val_add, "$num_castle_meeting_troops", 1),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 0),(troop_get_slot, ":troop_no", "trp_temp_array_a", 0),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 0),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 1),(troop_get_slot, ":troop_no", "trp_temp_array_a", 1),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 1),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 2),(troop_get_slot, ":troop_no", "trp_temp_array_a", 2),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 2),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 3),(troop_get_slot, ":troop_no", "trp_temp_array_a", 3),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 3),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 4),(troop_get_slot, ":troop_no", "trp_temp_array_a", 4),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 4),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 5),(troop_get_slot, ":troop_no", "trp_temp_array_a", 5),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 5),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 6),(troop_get_slot, ":troop_no", "trp_temp_array_a", 6),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 6),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 7),(troop_get_slot, ":troop_no", "trp_temp_array_a", 7),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 7),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 8),(troop_get_slot, ":troop_no", "trp_temp_array_a", 8),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 8),(jump_to_menu,"mnu_castle_meeting_selected")]),
      ("guard_meet_s5",[(gt, "$num_castle_meeting_troops", 9),(troop_get_slot, ":troop_no", "trp_temp_array_a", 9),(str_store_troop_name, s5, ":troop_no")],
        "{!}{s5}.",[(troop_get_slot, "$castle_meeting_selected_troop", "trp_temp_array_a", 9),(jump_to_menu,"mnu_castle_meeting_selected")]),
      
      ("forget_it",[],
        "Forget it.",
        [(str_clear, s10),(jump_to_menu,"mnu_castle_guard")]),
    ]
  ),
  (
    "castle_meeting_selected",0,
    "Your request for a meeting is relayed inside, and finally {s6} appears in the courtyard to speak with you.",
    "none",
    [
      (set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (str_store_troop_name, s6, "$castle_meeting_selected_troop")],
    [
      ("continue",[],
        "Continue...",
        [(jump_to_menu, "mnu_castle_outside"),
          
          # Phaiak begin
          (party_get_slot, ":castle_scene", "$current_town", slot_town_castle),
          (set_jump_mission,"mt_conversation_encounter"),
          (modify_visitors_at_site,":castle_scene"),
          (reset_visitors),
          (mission_tpl_entry_set_override_flags, "mt_conversation_encounter", 18, af_override_horse),
          (mission_tpl_entry_set_override_flags, "mt_conversation_encounter", 16, af_override_horse),
          (set_visitor,18,"trp_player"),
          (set_visitor,16,"$castle_meeting_selected_troop"),
          (jump_to_scene,":castle_scene"),
          # Phaiak end
          (assign, "$talk_context", tc_castle_gate),
          (change_screen_map_conversation, "$castle_meeting_selected_troop"),
      ]),
    ]
  ),
  
  ######
  (
    "port_attack",mnf_enable_hot_keys,
    "You are attacking the port of {s1}. You have {reg10} troops fit for battle against the enemy's {reg11}.",
    "none",
    [
      
      (set_background_mesh, "mesh_pic_fleet"),
      
      (try_begin),
        (party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, -1),
        (party_set_slot, "$g_encountered_party", slot_center_is_besieged_by, "p_main_party"),
        (store_current_hours, ":cur_hours"),
        (party_set_slot, "$g_encountered_party", slot_center_siege_begin_hours, ":cur_hours"),
        (assign, "$g_siege_method", 0),
        (assign, "$g_siege_sallied_out_once", 0),
      (try_end),
      
      #Check if enemy leaves the castle to us...
      # (try_begin),
      # (eq, "$g_castle_left_to_player",1), #we come here after dialog. Empty the castle and send parties away.
      # (assign, "$g_castle_left_to_player",0),
      # (store_faction_of_party, ":castle_faction", "$g_encountered_party"),
      # (party_set_faction,"$g_encountered_party","fac_neutral"), #temporarily erase faction so that it is not the closest town
      # (party_get_num_attached_parties, ":num_attached_parties_to_castle","$g_encountered_party"),
      # (try_for_range_backwards, ":iap", 0, ":num_attached_parties_to_castle"),
      # (party_get_attached_party_with_rank, ":attached_party", "$g_encountered_party", ":iap"),
      # (party_detach, ":attached_party"),
      # (party_get_slot, ":attached_party_type", ":attached_party", slot_party_type),
      # (eq, ":attached_party_type", spt_kingdom_hero_party),
      # (store_faction_of_party, ":attached_party_faction", ":attached_party"),
      # (call_script, "script_get_closest_walled_center_of_faction", ":attached_party", ":attached_party_faction"),
      # (try_begin),
      # (gt, reg0, 0),
      # (call_script, "script_party_set_ai_state", ":attached_party", spai_holding_center, reg0),
      # (else_try),
      # (call_script, "script_party_set_ai_state", ":attached_party", spai_patrolling_around_center, "$g_encountered_party"),
      # (try_end),
      # (try_end),
      # (call_script, "script_party_remove_all_companions", "$g_encountered_party"),
      # (change_screen_return),
      # (party_collect_attachments_to_party, "$g_encountered_party", "p_collective_enemy"), #recalculate so that
      # (call_script, "script_party_copy", "p_encountered_party_backup", "p_collective_enemy"), #leaving troops will not be considered as captured
      # (party_set_faction,"$g_encountered_party",":castle_faction"),
      # (try_end),
      
      #Check for victory or defeat....
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (str_store_party_name, 1,"$g_encountered_party"),
      (call_script, "script_encounter_calculate_fit"),
      
      (assign, reg11, "$g_enemy_fit_for_battle"),
      (assign, reg10, "$g_friend_fit_for_battle"),
      
      
      (try_begin),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (else_try),
        (call_script, "script_party_count_fit_regulars","p_collective_enemy"),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1),
          (assign, ":enemy_finished", 1),
        (else_try),
          (le, "$g_enemy_fit_for_battle",0),
          (ge, "$g_friend_fit_for_battle", 1),
          (assign, ":enemy_finished", 1),
        (try_end),
        (eq, ":enemy_finished", 1),
        #(eq, 0, 1),
        
        (assign, "$g_next_menu", "mnu_castle_taken"),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":main_party_fit_regulars", reg0),
        (eq, "$g_battle_result", -1),
        (eq, ":main_party_fit_regulars", 0), #all lost (TODO : )
        (assign, "$g_next_menu", "mnu_captivity_start_castle_defeat"),
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
    ],
    [
      # ("siege_request_meeting",[(eq, "$cant_talk_to_enemy", 0)],"Call for a meeting with the castle commander.", [
      # (assign, "$cant_talk_to_enemy", 1),
      # (assign, "$g_enemy_surrenders",0),
      # (assign, "$g_castle_left_to_player",0),
      # (assign, "$talk_context", tc_castle_commander),
      # (party_get_num_attached_parties, ":num_attached_parties_to_castle","$g_encountered_party"),
      # (try_begin),
      # (gt, ":num_attached_parties_to_castle", 0),
      # (party_get_attached_party_with_rank, ":leader_attached_party", "$g_encountered_party", 0),
      # (call_script, "script_setup_party_meeting", ":leader_attached_party"),
      # (else_try),
      # (call_script, "script_setup_party_meeting", "$g_encountered_party"),
      # (try_end),
      # ]),
      
      
      # ("wait_24_hours",[],"Wait until tomorrow.", [
      # (assign,"$auto_besiege_town","$g_encountered_party"),
      # (assign, "$g_siege_force_wait", 1),
      # (store_time_of_day,":cur_time_of_day"),
      # (val_add, ":cur_time_of_day", 1),
      # (assign, ":time_to_wait", 31),
      # (val_sub,":time_to_wait",":cur_time_of_day"),
      # (val_mod,":time_to_wait",24),
      # (val_add, ":time_to_wait", 1),
      # (rest_for_hours_interactive, ":time_to_wait", 10, 1), #rest while attackable x10 speed should save time to player.
      # (assign, "$cant_talk_to_enemy", 0),
      # (change_screen_return),
      # ]),
      
      
      ("lead_attack",
        [
          (neg|troop_is_wounded, "trp_player"),
          #(ge, "$g_siege_method", 1),
          (gt, "$g_friend_fit_for_battle", 3),
          #(store_current_hours, ":cur_hours"),
          #(ge, ":cur_hours", "$g_siege_method_finish_hours"),
        ],
        "Lead your soldiers in a coastal assault.",
        [
          (call_script, "script_prepare_party_ships_for_team", "$g_encountered_party", 1),	#because player ships are in port
          
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_party_coastal_assault_scene),
          (else_try),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
          (try_end),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (assign, ":battle_advantage", reg0),
          (val_mul, ":battle_advantage", 2),
          (val_div, ":battle_advantage", 3), #scale down the advantage a bit in sieges.
          (set_battle_advantage, ":battle_advantage"),
          (set_party_battle_mode),
          (assign, "$g_siege_battle_state", 1),
          # (assign, ":siege_sally", 0),
          # (try_begin),
          # (le, ":battle_advantage", -4), #we are outnumbered, defenders sally out
          # (eq, "$g_siege_sallied_out_once", 0),
          # (set_jump_mission,"mt_castle_attack_walls_defenders_sally"),
          # (assign, "$g_siege_battle_state", 0),
          # (assign, ":siege_sally", 1),
          # (else_try),
          # (party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),
          # (set_jump_mission,"mt_castle_attack_walls_belfry"),
          # (else_try),
          # (set_jump_mission,"mt_castle_attack_walls_ladder"),
          # (try_end),
          
          (set_jump_mission,"mt_ships_attack_port"),
          
          (assign, "$cant_talk_to_enemy", 0),
          (assign, "$g_siege_final_menu", "mnu_port_attack"),
          (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
          (assign, "$g_siege_method", 0), #reset siege timer
          (jump_to_scene,":battle_scene"),
          (try_begin),
            # (eq, ":siege_sally", 1),
            # (jump_to_menu, "mnu_siege_attack_meets_sally"),
            # (else_try),
            (jump_to_menu, "mnu_battle_debrief"),
            (change_screen_mission),
          (try_end),
      ]),
      ("attack_stay_back",
        [
          (ge, "$g_siege_method", 1),
          (gt, "$g_friend_fit_for_battle", 3),
          (store_current_hours, ":cur_hours"),
          (ge, ":cur_hours",  "$g_siege_method_finish_hours"),
        ],
        "Order your soldiers to attack while you stay back...", [(assign, "$cant_talk_to_enemy", 0),(jump_to_menu,"mnu_castle_attack_walls_simulate")]),
      ##
      ##      ("build_ladders",[(party_slot_eq, "$current_town", slot_center_siege_with_belfry, 0),(eq, "$g_siege_method", 0)],
      ##       "Prepare ladders to attack the walls.", [(jump_to_menu,"mnu_construct_ladders")]),
      ##
      ##      ("build_siege_tower",[(party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),(eq, "$g_siege_method", 0)],
      ##       "Build a siege tower.", [(jump_to_menu,"mnu_construct_siege_tower")]),
      
      
      ("cheat_conquer_castle",[(eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT: Instant conquer castle.",
        [
          (assign, "$g_next_menu", "mnu_castle_taken"),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ("abandon_attack",[],"Abandon the attack.",
        [
          (call_script, "script_lift_siege", "$g_encountered_party", 0),
          (assign,"$g_player_besiege_town", -1),
          
          #(party_slot_ge, "$current_town", slot_party_1_ship_type, 1),
          (leave_encounter),
          (call_script, "script_give_player_ships_from_party_to_party", "$g_encountered_party", "p_main_party"),
          (party_get_slot, ":curr_port", "$g_encountered_party", slot_party_port_party),
          (party_get_position, pos2, ":curr_port"),
          (party_set_position, "p_main_party", pos2),
          (call_script, "script_switch_to_water_consequences"),
          (change_screen_map),
          
      ]),
      
      
    ]
  ),
  
  ######
  (
    "castle_besiege",mnf_enable_hot_keys,
    "You are laying siege to {s4}. {s2} " +
    "^^{s15} {s16} {s17} {s18} {s19} {s20} {s21} {s22}",
    "none",
    [
      (str_clear, s1),
      (str_clear, s2),
      (str_clear, s4),
      (str_clear, s15),
      (str_clear, s16),
      (str_clear, s17),
      (str_clear, s18),
      (str_clear, s19),
      (str_clear, s20),
      (str_clear, s21),
      (str_clear, s22),
      
      (str_store_party_name,s4,"$current_town"),
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_siege_sighted_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_siege_sighted"),
      (try_end),
      (assign, "$g_siege_force_wait", 0),
      (try_begin),
        (party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, -1),
        (party_set_slot, "$g_encountered_party", slot_center_is_besieged_by, "p_main_party"),
        (store_current_hours, ":cur_hours"),
        (party_set_slot, "$g_encountered_party", slot_center_siege_begin_hours, ":cur_hours"),
        (assign, "$g_siege_method", 0),
        (assign, "$g_siege_sallied_out_once", 0),
        # Chief siege camp around town Siege warfare icono de asedio
        #phaiak begin
        (party_get_icon, ":icon", "$g_encountered_party"),
        (try_begin),
          (eq, ":icon", "icon_town_port"),
          (party_set_extra_icon, "$g_encountered_party", "icon_siege_camp_ports", 0, 0, 0, 0),
        (else_try),
          (eq, ":icon", "icon_town_walled"),
          (party_set_extra_icon, "$g_encountered_party", "icon_siege_camp_town", 0, 0, 0, 0),
        (else_try),
          (eq, ":icon", "icon_fort1"),
          (party_set_extra_icon, "$g_encountered_party", "icon_siege_camp_fort", 0, 0, 0, 0),
        (else_try),
          (eq, ":icon", "icon_fort2"),
          (party_set_extra_icon, "$g_encountered_party", "icon_siege_camp_fort", 0, 0, 0, 0),
        (end_try),
        #phaiak end
        # chief siege camp acaba
        (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
        (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
      (try_end),
      
      (party_get_slot, ":town_food_store", "$g_encountered_party", slot_party_food_store),
      (call_script, "script_center_get_food_consumption", "$g_encountered_party"),
      (assign, ":food_consumption", reg0),
      (assign, reg7, ":food_consumption"),
      (assign, reg8, ":town_food_store"),
      (store_div, reg3, ":town_food_store", ":food_consumption"),
      
      (try_begin),
        (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
        (assign, reg6, 1),
      (else_try),
        (assign, reg6, 0),
      (try_end),
      
      (try_begin),
        (gt, reg3, 0),
        (str_store_string, s2, "@The {reg6?town's:fort's} food stores should last for {reg3} more days."),
      (else_try),
        (str_store_string, s2, "@The {reg6?town's:fort's} food stores have run out and the defenders are starving."),
        
        #siege warfare chief##############
        (try_begin),
          (gt, "$g_days_spent_starving", 6), #6 days left, deffenders tired siege.
          (jump_to_menu, "mnu_surrender_siege_defenders_starved"),
        (else_try), #defenders desesperate = sally out to break the siege
          (gt, "$g_days_spent_starving", 1), #6 days left, deffenders tired siege
          
          ###add days each 24 h
          (try_begin),
            (party_get_slot, ":last_starving_time", "$g_encountered_party", slot_center_starvation_time),
            (store_current_hours, ":cur_hours"),
            (store_add, ":add_starving", ":last_starving_time", 24), #x min hours enter sallys
            (ge, ":cur_hours", ":add_starving"),
            (val_add, "$g_days_spent_starving", 1), #8 days left, deffenders tired siege
            (party_set_slot, "$g_encountered_party", slot_center_starvation_time, ":cur_hours"),
            #(display_message, "@added 1 day to sally2"),
          (try_end),
          #
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_walls),
          (else_try),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
          (try_end),
          (call_script, "script_calculate_battle_advantage"),
          (assign, ":battle_advantage", reg0),
          (val_mul, ":battle_advantage", 2),
          (val_div, ":battle_advantage", 3), #scale down the advantage a bit in sieges.
          (set_battle_advantage, ":battle_advantage"),
          
          (try_begin),
            (store_current_hours, "$g_sally_timer"),
            (ge, "$g_sally_timer", "$g_next_sally_at"),
            (store_random_in_range, ":hours", 22,44),
            (store_add, "$g_next_sally_at", "$g_sally_timer", ":hours"), #x min hours enter sallys
            (ge, ":hours", 28), #60% chance to deffenders sally out
            
            (set_party_battle_mode),
            (assign, "$g_siege_battle_state", 1),
            (try_begin),
              (set_jump_mission,"mt_castle_attack_walls_defenders_sally"),
              (assign, "$g_siege_battle_state", 0),
            (try_end),
            (assign, "$cant_talk_to_enemy", 0),
            (assign, "$g_siege_final_menu", "mnu_castle_besiege"),
            (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
            (assign, "$g_siege_method", 0), #reset siege timer
            (jump_to_scene,":battle_scene"),
            (jump_to_menu, "mnu_nofood_siege_defenders_sally"),
          (try_end),
        (else_try), #defenders desesperate = sally out to break the siege
          ###add days each 24 h
          (try_begin),
            (party_get_slot, ":last_starving_time", "$g_encountered_party", slot_center_starvation_time),
            (store_current_hours, ":cur_hours"),
            (store_add, ":add_starving", ":last_starving_time", 24), #x min hours enter sallys
            (ge, ":cur_hours", ":add_starving"),
            (val_add, "$g_days_spent_starving", 1), #8 days left, deffenders tired siege
            (party_set_slot, "$g_encountered_party", slot_center_starvation_time, ":cur_hours"),
            #(display_message, "@added 1 day to sally"),
          (else_try),
            (val_add, "$g_days_spent_starving", 0), #8 days left, deffenders tired siege
          (try_end),
          #
        (try_end),
        ###siege warfare end
      (try_end),
      
      ##        (str_store_string, s3, "str_empty_string"),
      ##        (try_begin),
      ##          (ge, "$g_siege_method", 1),
      ##          (store_current_hours, ":cur_hours"),
      ##          (try_begin),
      ##            (lt, ":cur_hours",  "$g_siege_method_finish_hours"),
      ##            (store_sub, reg9, "$g_siege_method_finish_hours", ":cur_hours"),
      ##            (try_begin),
      ##              (eq, "$g_siege_method", 1),
      ##              (str_store_string, s3, "@You're preparing to attack the walls, the work should finish in {reg9} hours."),
      ##            (else_try),
      ##              (eq, "$g_siege_method", 2),
      ##              (str_store_string, s3, "@Your forces are building a siege tower and preparing to attack the walls. They estimate another {reg9} hours to complete the build."),
      ##            (try_end),
      ##          (else_try),
      ##            (try_begin),
      ##              (eq, "$g_siege_method", 1),
      ##              (str_store_string, s3, "@You are ready to attack the walls at any time."),
      ##            (else_try),
      ##              (eq, "$g_siege_method", 2),
      ##              (str_store_string, s3, "@The siege tower is built and ready to make an assault."),
      ##            (try_end),
      ##          (try_end),
      ##        (try_end),
      
      ####siege warfare chief
      
      #string para circunvalacion
      (str_store_string,s15,"str_circunvalation_none"),
      (try_begin),
        (party_slot_eq,"$g_encountered_party",slot_center_blockaded,1),
        (str_store_string, s15, "@>>Your men are building checkpoints and small camps around {s4} to prevent anyone from going in or out.^^"),
      (else_try),
        (party_slot_eq,"$g_encountered_party",slot_center_blockaded,2), #final
        (str_store_string, s15, "@>>Your perimeter control is ready. You have set a perimeter for surveillance around {s4}. No one can enter or leave without the knowledge of your men.^" +
        "This will be beneficial especially when you have to negotiate the surrender of the castle with its commander.^^"),
      (try_end),
      
      (str_store_string,s16,"str_empty_string"),
      (try_begin),
        (ge, "$g_listos_para_asalto", 1),
        (str_store_string,s16,"@>>Your men are ready for assault.^^"),
      (try_end),
      
      ####saneamiento chief
      (str_store_string,s17,"str_empty_string"),
      (try_begin),
        (eq, "$g_siege_saneamiento", 2),
        (str_store_string,s17,"@>>As a disciplined army, your men have made latrines, pipelines, and a pond for their weekly bath. A healthy camp prevents disease.^^"),
      (try_end),
      
      (str_store_string,s18,"str_empty_string"),
      (try_begin),
        (eq, "$g_mantlets_1", 2),
        (str_store_string,s18,"@>>Your men have finished building mantlets. Now you can use them to protect your soldiers in the vanguard attack, and your main force for the final charge.^^"),
      (try_end),
      
      (str_store_string,s19,"str_empty_string"),
      (try_begin),
        (ge, "$g_siege_method", 2),
        (str_store_string,s19,"@>>Your men have finished making scaling equipment.^^"),
      (try_end),
      
      (str_store_string,s20,"str_empty_string"),
      (try_begin),
        (eq, "$g_traicion_interna", 3),
        (str_store_string,s20,"@>>Your attempt to find a traitor in the settlement has failed.^^"),
      (else_try),
        (eq, "$g_traicion_interna", 4),
        (str_store_string,s20,"@>>You have found a traitor within {s7} that has supported your efforts to conquer it. This will make it more receptive to surrendering.^^"),
      (try_end),
      
      ####strings infiltrado
      (str_store_string,s21,"str_empty_string"),
      (try_begin),
        (eq, "$g_infiltracion_interna", 3),
        (str_store_string,s21,"@>>Your attempt to have your men infiltrate {s4} has failed.^^"),
      (else_try),
        (eq, "$g_infiltracion_interna", 4),
        (str_store_string,s21,"@>>Your men have succeeded in infiltrating {s4} and damaging the enemy.^^"),
      (try_end),
      
      #####strings quemar campos cercanos
      (str_store_string,s22,"str_empty_string"),
      (try_begin),
        (eq, "$g_campos_cercanos", 3),
        (str_store_string,s22,"@>>You've managed to pillage the crops and farms nearby.^^"),
      (try_end),
      #siege warfare chief
      
      #Check if enemy leaves the castle to us...
      (try_begin),
        (eq, "$g_castle_left_to_player",1), #we come here after dialog. Empty the castle and send parties away.
        (assign, "$g_castle_left_to_player",0),
        (store_faction_of_party, ":castle_faction", "$g_encountered_party"),
        (party_set_faction,"$g_encountered_party","fac_neutral"), #temporarily erase faction so that it is not the closest town
        (party_get_num_attached_parties, ":num_attached_parties_to_castle","$g_encountered_party"),
        (try_for_range_backwards, ":iap", 0, ":num_attached_parties_to_castle"),
          (party_get_attached_party_with_rank, ":attached_party", "$g_encountered_party", ":iap"),
          (party_detach, ":attached_party"),
          (party_get_slot, ":attached_party_type", ":attached_party", slot_party_type),
          (eq, ":attached_party_type", spt_kingdom_hero_party),
          (store_faction_of_party, ":attached_party_faction", ":attached_party"),
          (call_script, "script_get_closest_walled_center_of_faction", ":attached_party", ":attached_party_faction"),
          (try_begin),
            (gt, reg0, 0),
            (call_script, "script_party_set_ai_state", ":attached_party", spai_holding_center, reg0),
          (else_try),
            (call_script, "script_party_set_ai_state", ":attached_party", spai_patrolling_around_center, "$g_encountered_party"),
          (try_end),
        (try_end),
        (call_script, "script_party_remove_all_companions", "$g_encountered_party"),
        (change_screen_return),
        (party_collect_attachments_to_party, "$g_encountered_party", "p_collective_enemy"), #recalculate so that
        (call_script, "script_party_copy", "p_encountered_party_backup", "p_collective_enemy"), #leaving troops will not be considered as captured
        (party_set_faction,"$g_encountered_party",":castle_faction"),
      (try_end),
      
      #Check for victory or defeat....
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (str_store_party_name, 1,"$g_encountered_party"),
      (call_script, "script_encounter_calculate_fit"),
      
      (assign, reg11, "$g_enemy_fit_for_battle"),
      (assign, reg10, "$g_friend_fit_for_battle"),
      
      
      (try_begin),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (else_try),
        (call_script, "script_party_count_fit_regulars","p_collective_enemy"),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1),
          (assign, ":enemy_finished", 1),
        (else_try),
          (this_or_next|le, "$g_enemy_fit_for_battle",0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #we do not want routed agents to spawn again in next turn of battle.
          (ge, "$g_friend_fit_for_battle", 1),
          (assign, ":enemy_finished", 1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished", 1),
        (eq, "$g_enemy_surrenders", 1),
        #siege warfare chief
        (assign, "$g_empieza_asedio", 0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
        (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
        (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
        (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
        (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
        
        (assign, "$g_siege_saneamiento", 0),
        (assign, "$g_traicion_interna", 0),
        (assign, "$g_infiltracion_interna", 0),
        (assign, "$g_campos_cercanos", 0),
        (assign, "$g_listos_para_asalto", 0),
        (assign, "$g_mantlets_1", 0),
        (assign, "$g_cabezas_dentro", 0), #event
        (assign, "$g_siege_method", 0),
        (assign, "$g_siege_sallied_out_once", 0),
        (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
        (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
        #siege warfare acaba
        
        (assign, "$g_next_menu", "mnu_castle_taken"),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":main_party_fit_regulars", reg0),
        (eq, "$g_battle_result", -1),
        (this_or_next|eq, ":main_party_fit_regulars", 0), #all lost (TODO : )
        (le, ":main_party_fit_regulars",  "$num_routed_allies"), #we do not want routed agents to spawn again in next turn of battle.
        (assign, "$g_next_menu", "mnu_captivity_start_castle_defeat"),
        #siege warfare chief
        (assign, "$g_empieza_asedio", 0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
        (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
        (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
        (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
        (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
        
        (assign, "$g_siege_saneamiento", 0),
        (assign, "$g_traicion_interna", 0),
        (assign, "$g_infiltracion_interna", 0),
        (assign, "$g_campos_cercanos", 0),
        (assign, "$g_listos_para_asalto", 0),
        (assign, "$g_mantlets_1", 0),
        (assign, "$g_cabezas_dentro", 0), #event
        (assign, "$g_siege_method", 0),
        (assign, "$g_siege_sallied_out_once", 0),
        (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
        (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
        #siege warfare acaba
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
    ],
    [
      ("siege_request_meeting",[(eq, "$cant_talk_to_enemy", 0)],"Call for a meeting with the castle commander.", [
          (assign, "$cant_talk_to_enemy", 1),
          (assign, "$g_enemy_surrenders",0),
          (assign, "$g_castle_left_to_player",0),
          (assign, "$talk_context", tc_castle_commander),
          (party_get_num_attached_parties, ":num_attached_parties_to_castle","$g_encountered_party"),
          (try_begin),
            (gt, ":num_attached_parties_to_castle", 0),
            (party_get_attached_party_with_rank, ":leader_attached_party", "$g_encountered_party", 0),
            (call_script, "script_setup_party_meeting", ":leader_attached_party"),
          (else_try),
            (call_script, "script_setup_party_meeting", "$g_encountered_party"),
          (try_end),
      ]),
      
      #########Siege Warfare chief
      ("siege_warfare_p",[],
        "Siege Warfare (Planning Siege).", [(jump_to_menu,"mnu_siege_plan"),]),
      ("siege_assault_p",[],
        "Siege Warfare (Preparing Assault).", [(jump_to_menu,"mnu_siege_assault")]),
      ("siege_assault_camp",[],
        "Your Siege Camp.", [			(start_presentation,"prsnt_camp_screen_siege"),
      ]),
      #########Siege warfare acaba
      
      ("wait_24_hours",[],"Wait until tomorrow.", [
          (assign,"$auto_besiege_town","$g_encountered_party"),
          (assign, "$g_siege_force_wait", 1),
          (store_time_of_day,":cur_time_of_day"),
          (val_add, ":cur_time_of_day", 1),
          (assign, ":time_to_wait", 31),
          (val_sub,":time_to_wait",":cur_time_of_day"),
          (val_mod,":time_to_wait",24),
          (val_add, ":time_to_wait", 1),
          (rest_for_hours_interactive, ":time_to_wait", 10, 1), #rest while attackable x10 speed should save time to player.
          (assign, "$cant_talk_to_enemy", 0),
          (change_screen_return),
      ]),
      
      
      ##      ("castle_lead_attack",
      ##       [
      ##         (neg|troop_is_wounded, "trp_player"),
      ##         (ge, "$g_siege_method", 1),
      ##         (gt, "$g_friend_fit_for_battle", 3),
      ##         (store_current_hours, ":cur_hours"),
      ##         (ge, ":cur_hours", "$g_siege_method_finish_hours"),
      ##       ],
      ##       "Lead your soldiers in an assault.",
      ##       [
      ##           (try_begin),
      ##             (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
      ##             (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_walls),
      ##           (else_try),
      ##             (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
      ##           (try_end),
      ##
      ##           (call_script, "script_calculate_renown_value"),
      ##           (call_script, "script_calculate_battle_advantage"),
      ##           (assign, ":battle_advantage", reg0),
      ##           (val_mul, ":battle_advantage", 2),
      ##           (val_div, ":battle_advantage", 3), #scale down the advantage a bit in sieges.
      ##           (set_battle_advantage, ":battle_advantage"),
      ##           (set_party_battle_mode),
      ##           (assign, "$g_siege_battle_state", 1),
      ##           (assign, ":siege_sally", 0),
      ##           (try_begin),
      ##             (le, ":battle_advantage", -4), #we are outnumbered, defenders sally out
      ##             (eq, "$g_siege_sallied_out_once", 0),
      ##             (set_jump_mission,"mt_castle_attack_walls_defenders_sally"),
      ##             (assign, "$g_siege_battle_state", 0),
      ##             (assign, ":siege_sally", 1),
      ##           (else_try),
      ##             (party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),
      ##             (set_jump_mission,"mt_castle_attack_walls_belfry"),
      ##           (else_try),
      ##             (set_jump_mission,"mt_castle_attack_walls_ladder"),
      ##           (try_end),
      ##           (assign, "$cant_talk_to_enemy", 0),
      ##           (assign, "$g_siege_final_menu", "mnu_castle_besiege"),
      ##           (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
      ##           (assign, "$g_siege_method", 0), #reset siege timer
      ##           (jump_to_scene,":battle_scene"),
      ##           (try_begin),
      ##             (eq, ":siege_sally", 1),
      ##             (jump_to_menu, "mnu_siege_attack_meets_sally"),
      ##           (else_try),
      ##             (jump_to_menu, "mnu_battle_debrief"),
      ##             (change_screen_mission),
      ##           (try_end),
      ##       ]),
      ##      ("attack_stay_back",
      ##       [
      ##         (ge, "$g_siege_method", 1),
      ##         (gt, "$g_friend_fit_for_battle", 3),
      ##         (store_current_hours, ":cur_hours"),
      ##         (ge, ":cur_hours",  "$g_siege_method_finish_hours"),
      ##         ],
      ##       "Order your soldiers to attack while you stay back...", [(assign, "$cant_talk_to_enemy", 0),(jump_to_menu,"mnu_castle_attack_walls_simulate")]),
      ##
      ##      ("build_ladders",[(party_slot_eq, "$current_town", slot_center_siege_with_belfry, 0),(eq, "$g_siege_method", 0)],
      ##       "Prepare ladders to attack the walls.", [(jump_to_menu,"mnu_construct_ladders")]),
      ##
      ##      ("build_siege_tower",[(party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),(eq, "$g_siege_method", 0)],
      ##       "Build a siege tower.", [(jump_to_menu,"mnu_construct_siege_tower")]),
      
      ("cheat_castle_lead_attack",[(eq, "$cheat_mode", 1),
          (eq, "$g_siege_method", 0)],
        "{!}CHEAT: Instant build equipment.",
        [
          (assign, "$g_siege_method", 1),
          (assign, "$g_siege_method_finish_hours", 0),
          (jump_to_menu, "mnu_castle_besiege"),
      ]),
      
      ("cheat_conquer_castle",[(eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT: Instant conquer castle.",
        [
          (assign, "$g_next_menu", "mnu_castle_taken"),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ##      ("lift_siege",[],"Abandon the siege.",
      ##       [
      ##         (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
      ##         (assign,"$g_player_besiege_town", -1),
      ##         (change_screen_return)]),
      
      ("lift_siege",[],"Abandon the siege.",
        [
          (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
          (assign,"$g_player_besiege_town", -1),
          #siege warfare chief
          (assign, "$g_empieza_asedio", 0),
          (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
          (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
          (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
          (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
          (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          
          (assign, "$g_siege_saneamiento", 0),
          (assign, "$g_traicion_interna", 0),
          (assign, "$g_infiltracion_interna", 0),
          (assign, "$g_campos_cercanos", 0),
          (assign, "$g_listos_para_asalto", 0),
          (assign, "$g_mantlets_1", 0),
          (assign, "$g_cabezas_dentro", 0), #event
          (assign, "$g_siege_method", 0),
          (assign, "$g_siege_sallied_out_once", 0),
          (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
          (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
          #siege warfare acaba
          (change_screen_return)]),
      
      
    ]
  ),
  
  
  ######Siege warfare Chief
  (
    "siege_plan",0,
    "You meet with your advisers to plan the siege and try to conquer {s4} with the least possible casualties. Your strategy could be to reduce the place by famine and demoralization.^^{s15} {s17} {s18} {s19} {s20}",
    "none",
    [
      
      (str_store_party_name,s4,"$current_town"),
      
      (str_clear, s7),
      (str_clear, s15),
      (str_clear, s16),
      (str_clear, s17),
      (str_clear, s18),
      (str_clear, s19),
      (str_clear, s20),
      
      #string para circunvalacion
      (str_store_string,s15,"str_circunvalation_none"),
      (try_begin),
        (party_slot_eq,"$g_encountered_party",slot_center_blockaded,1),
        (str_store_string, s15, "@>>Your men are building checkpoints and small camps around {s4} to prevent anyone from going in or out.^^"),
      (else_try),
        (party_slot_eq,"$g_encountered_party",slot_center_blockaded,2), #final
        (str_store_string, s15, "@>>Your perimeter control is ready. You have set a perimeter for surveillance around {s4}. No one can enter or leave without the knowledge of your men.^" +
        "This will be beneficial especially when you have to negotiate the surrender of the castle with its commander.^^"),
      (try_end),
      #
      ####strings traicion
      (str_store_string,s17,"str_empty_string"),
      (try_begin),
        (ge, "$g_traicion_interna", 1),
        (le, "$g_traicion_interna", 2),
        (str_store_string,s17,"@>>You have sent men to find a traitor in {s4}.^^"),
      (else_try),
        (eq, "$g_traicion_interna", 3),
        (str_store_string,s17,"@>>Your attempt to find a traitor in the settlement has failed.^^"),
      (else_try),
        (eq, "$g_traicion_interna", 4),
        (str_store_string,s17,"@>>You have found a traitor within {s4} that has supported your efforts to conquer it. This will render it more receptive to surrendering.^^"),
      (try_end),
      
      #####strings quemar campos cercanos
      (str_store_string,s18,"str_empty_string"),
      (try_begin),
        (eq, "$g_campos_cercanos", 3),
        (str_store_string,s18,"@>>You've managed to pillage the crops and farms nearby.^^"),
      (else_try),
        (ge, "$g_campos_cercanos", 1),
        (str_store_string,s18,"@>>Your men are taking crops and ransacking farms close to {s4} on your orders. This will render it more receptive to surrendering.^^"),
      (try_end),
      ####strings infiltrado
      (str_store_string,s19,"str_empty_string"),
      (try_begin),
        (ge, "$g_infiltracion_interna", 1),
        (le, "$g_infiltracion_interna", 2),
        (str_store_string,s19,"@>>You have sent men to infiltrate {s4}.^^"),
      (else_try),
        (eq, "$g_infiltracion_interna", 3),
        (str_store_string,s19,"@>>Your attempt to have your men infiltrate {s4} has failed.^^"),
      (else_try),
        (eq, "$g_infiltracion_interna", 4),
        (str_store_string,s19,"@>>Your men have succeeded in infiltrating {s4} and damaging the enemy.^^"),
      (try_end),
      ####saneamiento chief
      (str_store_string,s20,"str_empty_string"),
      (try_begin),
        (eq, "$g_siege_saneamiento", 0),
        (str_store_string,s20,"@>>Your camp smells horrible. The ground is muddy, your men defecate between tents, and you see rats running here and there.^^"),
      (else_try),
        (ge, "$g_siege_saneamiento", 1),
        (party_get_slot, ":last_saneamiento_time", "$g_encountered_party", slot_center_latrines),
        (store_current_hours, ":cur_hours"),
        (store_add, ":ok_time", ":last_saneamiento_time", 4),
        (gt, ":cur_hours", ":ok_time"),
        (str_store_string,s20,"@>>As a disciplined army, your men have made latrines, pipelines and a pond for their weekly bath. A healthy camp prevents disease.^^"),
        (assign, "$g_siege_saneamiento", 2), #final
      (else_try),
        (eq, "$g_siege_saneamiento", 1),
        (str_store_string,s20,"@>>Your men are digging holes for latrines and taking other measures to prevent disease.^^"),
      (try_end),
      
      (call_script, "script_set_town_picture"),
      
    ],
    [
      
      ###siege perimeter control(party_set_slot,"p_main_party",slot_center_blockaded,0),
      ("build_circunvalation",[
          (party_slot_eq,"$g_encountered_party",slot_center_blockaded,0),],
        "Blockade: build checkpoints around {s4}.", [
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (try_begin),
            (gt, ":num_men", 250), # se muestra si el player tiene por lo menos 250 hombres
            (jump_to_menu,"mnu_construct_circunvalation"),
          (else_try),
            (display_message,"@You need to have more than 250 men for this job."),
          (try_end),
      ]),
      
      ("close_circunvalation",[
          (party_slot_eq,"$g_encountered_party",slot_center_blockaded,1),
          (party_get_slot, ":last_blockplace_time", "$g_encountered_party", slot_center_blockaded_time),
          (store_current_hours, ":cur_hours"),
          
          (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
          (assign, ":max_skill", reg0),
          (store_sub, reg4, 16, ":max_skill"),
          (val_mul, reg4, 4),#between 24 and 64 hours
          
          #      (store_random_in_range,":random_check",80,100),
          (store_add, ":ok_time", ":last_blockplace_time", reg4), #between 60 and 160 hours
          (gt, ":cur_hours", ":ok_time"),
        ],
        "Checkpoints are finished. Now order active watching.", [
          #Reduce prosperity of the center by 10
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -10),
          (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
          (party_set_slot,"$g_encountered_party",slot_center_blockaded, 2),
          (jump_to_menu,"mnu_siege_plan"),]),
      #####circunvalacion acaba
      #####disfrazarte para entrar en la ciudad e investigar sus defensas
      ("town_investigar",
        [
        ],
        "Investigate the defenses: try to sneak inside. (Tracking)",
        [
          (faction_get_slot, ":player_alarm", "$g_encountered_party_faction", slot_faction_player_alarm),
          (party_get_num_companions, ":num_men", "p_main_party"),
          (party_get_num_prisoners, ":num_prisoners", "p_main_party"),
          (val_add, ":num_men", ":num_prisoners"),
          (val_mul, ":num_men", 2),
          (val_div, ":num_men", 10),
          (store_add, ":get_caught_chance", ":player_alarm", ":num_men"),
          (store_random_in_range, ":random_chance", 0, 100),
          (store_skill_level, ":tracking", "skl_tracking", "trp_player"), #skill help to infiltrate
          (val_mul, ":tracking", 2),
          (val_add, ":random_chance", ":tracking"),
          (try_begin),
            (this_or_next|ge, ":random_chance", ":get_caught_chance"),
            (eq, "$g_last_defeated_bandits_town", "$g_encountered_party"),
            (assign, "$g_last_defeated_bandits_town", 0),
            (assign, "$sneaked_into_town",1),
            (assign, "$town_entered", 1),
            (jump_to_menu,"mnu_sneak_into_town_suceeded2"),
            (assign, "$g_mt_mode", tcm_disguised),
          (else_try),
            (jump_to_menu,"mnu_sneak_into_town_caught"),
          (try_end),
      ]),
      
      #traicion interna
      ("traicion_interna",
        [
          (party_get_slot, ":blockplace_place", "$g_encountered_party", slot_center_blockaded),
          (ge, ":blockplace_place", 1),
          (eq, "$g_traicion_interna", 0),
          (neq, "$g_infiltracion_interna", 1),
        ],
        "Find a traitor within the defenses of {s4}.",
        [
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (try_begin),
            (gt, ":num_men", 40), # se muestra si el player tiene por lo menos 40 hombres
            (jump_to_menu,"mnu_traicion_interna2"),
          (else_try),
            (display_message,"@You need to have at least 40 men in order to assign some of them to finding a traitor."),
          (try_end),
      ]),
      
      ("traicion_interna3",[           (eq, "$g_traicion_interna", 2),
        ],
        "Any news from the men sent in search of a traitor?", [
          (store_random_in_range, ":rand", 0, 6),
          (try_begin),
            (eq, ":rand", 0),
            (jump_to_menu,"mnu_traicion_resultado5"),
          (else_try),
            (eq, ":rand", 1),
            (jump_to_menu,"mnu_traicion_resultado2"),
          (else_try),
            (eq, ":rand", 2),
            (jump_to_menu,"mnu_traicion_resultado3"),
          (else_try),
            (eq, ":rand", 3),
            (jump_to_menu,"mnu_traicion_resultado4"),
          (else_try),
            (jump_to_menu,"mnu_traicion_resultado1"),
          (try_end),
      ]),
      
      ####maniobras de infiltracion chief
      ("infiltracion_interna",
        [
          (party_get_slot, ":blockplace_place", "$g_encountered_party", slot_center_blockaded),
          (ge, ":blockplace_place", 1),
          (eq, "$g_infiltracion_interna", 0),
          (neq, "$g_traicion_interna", 1),
        ],
        "Send some men to infiltrate the place.",
        [
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (try_begin),
            (gt, ":num_men", 30), # se muestra si el player tiene por lo menos 30 hombres
            (start_presentation,"prsnt_infiltrationandsabotage"),
            # (jump_to_menu,"mnu_infiltracion_interna2"),
          (else_try),
            (display_message,"@You need more than 30 men, or sending some will leave your camp somewhat unprotected."),
          (try_end),
      ]),
      
      ("infiltracion_interna3",[           (eq, "$g_infiltracion_interna", 2),
        ],
        "Any news from the men sent to infiltrate?", [
          (store_random_in_range, ":rand", 0, 4),
          (try_begin),
            (le, ":rand", 1),
            (try_begin),
              (party_slot_eq,"$g_encountered_party",slot_center_infiltration_type,1), #water
              (jump_to_menu,"mnu_infiltracion_resultado4_c"),
            (else_try),
              (party_slot_eq,"$g_encountered_party",slot_center_infiltration_type,2), #cattle
              (jump_to_menu,"mnu_infiltracion_resultado3_c"),
            (else_try),
              (party_slot_eq,"$g_encountered_party",slot_center_infiltration_type,3), #food
              (jump_to_menu,"mnu_infiltracion_resultado3"),
            (else_try),
              (party_slot_eq,"$g_encountered_party",slot_center_infiltration_type,4), #morale
              (jump_to_menu,"mnu_infiltracion_resultado4"),
            (else_try),
              (jump_to_menu,"mnu_infiltracion_resultado1"),
            (try_end),
          (else_try),
            (eq, ":rand", 2),
            (jump_to_menu,"mnu_infiltracion_resultado2"),
          (else_try),
            (eq, ":rand", 3),
            (jump_to_menu,"mnu_infiltracion_resultado5"),
          (else_try),
            (jump_to_menu,"mnu_infiltracion_resultado1"),
          (try_end),
      ]),
      ####maniobras de infiltracion chief acaba
      
      #####construir letrinas, canalizaciones para evitar acumulacion de barro con la lluvia, cavar pozos para suministro de agua
      ("build_varios",[
          #obtiene numero de hombres de el ejercito del player
          (eq, "$g_siege_saneamiento", 0),],
        "Order the construction of sanitation to prevent disease.", [
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (try_begin),
            (gt, ":num_men", 10), # se muestra si el player tiene por lo menos 10 hombres
            ##                (store_current_hours, ":cur_hours"),
            ##                (party_set_slot, "$g_encountered_party", slot_center_latrines, ":cur_hours"),
            (jump_to_menu,"mnu_construct_saneamiento"),
          (else_try),
            (display_message,"@You need to have more than 10 men in order to do this job."),
          (try_end),
      ]),
      ####construir chief letrinas, canalizaciones y pozos acaba
      #destruir campos cercanos para obtener comida y empobrecer a la ciudad
      ("destruir_campos_a",[
          (eq, "$g_campos_cercanos", 0),],
        "Pillage farms to replenish your stocks and harm the enemy.", [
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (try_begin),
            (gt, ":num_men", 80), # se muestra si el player tiene por lo menos 80 hombres
            (assign, "$g_campos_cercanos", 1),
          (else_try),
            (display_message,"@You need to have more than 80 men in order to do this."),
          (try_end),
      ]),
      
      ("destruir_campos_b",[
          (eq, "$g_campos_cercanos", 2),],
        "Any news from the men I sent to pillage farms?", [
          #          (store_current_month, ":cur_month"),
          (store_random_in_range, ":rand", 0, 3),
          (try_begin),
            (le, ":rand", 2),
            (try_begin),
              (this_or_next|eq, "$g_cur_month", 3),
              (this_or_next|eq, "$g_cur_month", 4),
              (eq, "$g_cur_month", 5),
              (jump_to_menu,"mnu_campos_cercanos1"),
            (else_try),
              (this_or_next|eq, "$g_cur_month", 9),
              (this_or_next|eq, "$g_cur_month", 10),
              (eq, "$g_cur_month", 11),
              (jump_to_menu,"mnu_campos_cercanos2"),
            (else_try),
              (this_or_next|eq, "$g_cur_month", 12),
              (this_or_next|eq, "$g_cur_month", 1),
              (eq, "$g_cur_month", 2),
              (jump_to_menu,"mnu_campos_cercanos3"),
            (else_try),
              (this_or_next|eq, "$g_cur_month", 6),
              (this_or_next|eq, "$g_cur_month", 7),
              (eq, "$g_cur_month", 8),
              (jump_to_menu,"mnu_campos_cercanos2_c"),
            (else_try),
              (jump_to_menu,"mnu_campos_cercanos4"),
            (try_end),
          (else_try),
            (jump_to_menu,"mnu_campos_cercanos4"),
          (try_end),
      ]),
      
      
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_castle_besiege")]),
    ]
  ),
  
  ###############assault
  (
    "siege_assault",0,
    "Time is of essence, and you fear the arrival of support force for the place. Assaulting will mean heavy casualties, but you have made up your mind.^^{s17} {s18} {s19}",
    "none",
    [
      
      (str_store_party_name,s4,"$current_town"),
      
      (str_clear, s17),
      (str_clear, s18),
      (str_clear, s19),
      ####listos para asalto
      (str_store_string,s17,"str_empty_string"),
      (try_begin),
        (neq, "$g_listos_para_asalto", 1),
        (eq, "$g_siege_method", 2),
        (str_store_string,s17,"@>>The assault equipment is ready. The troops await your orders.^^"),
      (else_try),
        (eq, "$g_listos_para_asalto", 1),
        (this_or_next|eq, "$g_cur_month", 3),
        (this_or_next|eq, "$g_cur_month", 4),
        (eq, "$g_cur_month", 5),
        (str_store_string,s17,"@>>You look at {s4}. Your men are silent while they await your order to attack. Your muscles are tense, hot for battle, but your mind is cold and adrenaline fills your veins^" +
        "A man breathes deeply. 'Do you smell that?' he asks, 'That is the scent of glory.' 'Are you ready to seize it?'^^"),
      (else_try),
        (ge, "$g_listos_para_asalto", 1),
        (this_or_next|eq, "$g_cur_month", 9),
        (this_or_next|eq, "$g_cur_month", 10),
        (eq, "$g_cur_month", 11),
        (str_store_string,s17,"@>>The steel of the weapons glitters, banners sway in the wind and horns sound. The men whisper, many pray, ingratiate themselves with their god before facing the end of their lives. Up ahead there are only two things: victory or death.^" +
        "War ... war never changes.^^"),
      (else_try),
        (ge, "$g_listos_para_asalto", 1),
        (this_or_next|eq, "$g_cur_month", 12),
        (this_or_next|eq, "$g_cur_month", 1),
        (eq, "$g_cur_month", 2),
        (str_store_string,s17,"@>>Winter is the worst time to fight, but there you are in the cold months, ready to undertake the conquest of {s4}. Many people think you're a daredevil, others a madman. But no one knows that someday you will be Brytenwalda.^^"),
      (else_try),
        (ge, "$g_listos_para_asalto", 1),
        (this_or_next|eq, "$g_cur_month", 6),
        (this_or_next|eq, "$g_cur_month", 7),
        (eq, "$g_cur_month", 8),
        (str_store_string,s17,"@>>It's summer and hot -- maybe too hot -- but, at that moment, you do not feel anything. As always before a battle, you set aside time for a few inevitable memories of the past... Then you close your mind and ready it for battle, preparing for even the worst case -- death.^^"),
      (else_try),
        (ge, "$g_listos_para_asalto", 1),
        (str_store_string,s17,"@>>You look at {s4}. Your men are silent while waiting for your order to charge towards death. Your muscles are tense, hot for battle, your mind cold and adrenaline fills your veins^" +
        "A man breathes deeply. 'Do you smell that?' he asks, 'That is the scent of glory.' 'Are you ready to seize it?'^^"),
      (try_end),
      
      (str_store_string,s18,"str_empty_string"),
      (try_begin),
        (ge, "$g_mantlets_1", 1),
        (party_get_slot, ":last_mantles_time", "$g_encountered_party", slot_center_mantlets_placed),
        (store_current_hours, ":cur_hours"),
        (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
        (assign, ":max_skill", reg0),
        (store_sub, reg4, 16, ":max_skill"),
        (val_mul, reg4, 2),
        (store_add, ":ok_time", ":last_mantles_time", reg4),#between 12 and 32 hours
        (gt, ":cur_hours", ":ok_time"),
        (str_store_string,s18,"@>>Your men have finished building the mantlets. Now you can use them to protect your soldiers in the vanguard attack, and your main force for the final charge.^^"),
        (assign, "$g_mantlets_1", 2), #final
      (else_try),
        (eq, "$g_mantlets_1", 1),
        (str_store_string,s18,"@>>Your men are building mantlets.^^"),
      (try_end),
      
      (str_store_string,s19,"str_empty_string"),
      (try_begin),
        (ge, "$g_siege_method", 1),
        
        (party_get_slot, ":last_ladders_time", "$g_encountered_party", slot_center_ladder_time),
        (store_current_hours, ":cur_hours"),
        (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
        (assign, ":max_skill", reg0),
        (store_sub, reg4, 16, ":max_skill"),
        (val_mul, reg4, 2),
        
        (store_add, ":ok_time", ":last_ladders_time", reg4), #between 24 and 64 hours
        (gt, ":cur_hours", ":ok_time"),
        (str_store_string,s19,"@>>Your men have finished building the ladders.^^"),
        (assign, "$g_siege_method", 2), #final
      (else_try),
        (eq, "$g_siege_method", 1),
        (str_store_string,s19,"@>>Your men are building assault ladders.^^"),
      (try_end),
      
      (call_script, "script_set_town_picture"),
      
      #Check for victory or defeat....
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (str_store_party_name, 1,"$g_encountered_party"),
      (call_script, "script_encounter_calculate_fit"),
      
      (assign, reg11, "$g_enemy_fit_for_battle"),
      (assign, reg10, "$g_friend_fit_for_battle"),
      
      
      (try_begin),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (else_try),
        (call_script, "script_party_count_fit_regulars","p_collective_enemy"),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1),
          (assign, ":enemy_finished", 1),
        (else_try),
          (this_or_next|le, "$g_enemy_fit_for_battle",0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #we do not want routed agents to spawn again in next turn of battle.
          (ge, "$g_friend_fit_for_battle", 1),
          (assign, ":enemy_finished", 1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished", 1),
        (eq, "$g_enemy_surrenders", 1),
        #siege warfare chief
        (assign, "$g_empieza_asedio", 0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
        (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
        (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
        (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
        (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
        
        (assign, "$g_siege_saneamiento", 0),
        (assign, "$g_traicion_interna", 0),
        (assign, "$g_infiltracion_interna", 0),
        (assign, "$g_campos_cercanos", 0),
        (assign, "$g_listos_para_asalto", 0),
        (assign, "$g_mantlets_1", 0),
        (assign, "$g_cabezas_dentro", 0), #event
        (assign, "$g_siege_method", 0),
        (assign, "$g_siege_sallied_out_once", 0),
        (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
        (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
        #siege warfare acaba
        
        (assign, "$g_next_menu", "mnu_castle_taken"),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":main_party_fit_regulars", reg0),
        (eq, "$g_battle_result", -1),
        (this_or_next|eq, ":main_party_fit_regulars", 0), #all lost (TODO : )
        (le, ":main_party_fit_regulars",  "$num_routed_allies"), #we do not want routed agents to spawn again in next turn of battle.
        (assign, "$g_next_menu", "mnu_captivity_start_castle_defeat"),
        #siege warfare chief
        (assign, "$g_empieza_asedio", 0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
        (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
        (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
        (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
        (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
        (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
        
        (assign, "$g_siege_saneamiento", 0),
        (assign, "$g_traicion_interna", 0),
        (assign, "$g_infiltracion_interna", 0),
        (assign, "$g_campos_cercanos", 0),
        (assign, "$g_listos_para_asalto", 0),
        (assign, "$g_mantlets_1", 0),
        (assign, "$g_cabezas_dentro", 0), #event
        (assign, "$g_siege_method", 0),
        (assign, "$g_siege_sallied_out_once", 0),
        (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
        (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
        #siege warfare acaba
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
    ],
    [
      #####scout da pinceladas
      ("scout_investigar",
        [
        ],
        "Call the scouts for a report on {s4}.",
        [
          (jump_to_menu,"mnu_informacion_ciudad"),
      ]),
      
      ("poniendo_elementos_mantles",
        [(eq, "$g_mantlets_1", 2),
          (neq, "$g_listos_para_asalto", 1),
          (ge, "$g_siege_method", 2),
          (gt, "$g_friend_fit_for_battle", 3),
          ##         (store_current_hours, ":cur_hours"),
          ##         (ge, ":cur_hours",  "$g_siege_method_finish_hours"),
        ],
        "Order the vanguard to place the mantlets.", [(assign, "$cant_talk_to_enemy", 0),(jump_to_menu,"mnu_poner_escaleras_mantlets")]),
      
      ("poniendo_elementos",
        [(neq, "$g_mantlets_1", 2),
          (neq, "$g_listos_para_asalto", 1),
          (ge, "$g_siege_method", 2),
          (gt, "$g_friend_fit_for_battle", 3),
          ##         (store_current_hours, ":cur_hours"),
          ##         (ge, ":cur_hours",  "$g_siege_method_finish_hours"),
        ],
        "Order the vanguard to prepare the assault.", [(assign, "$cant_talk_to_enemy", 0),(jump_to_menu,"mnu_poner_escaleras")]),
      
      ("castle_lead_attack",
        [
          (neg|troop_is_wounded, "trp_player"),
          (eq, "$g_listos_para_asalto", 1),
          (ge, "$g_siege_method", 2),
          (gt, "$g_friend_fit_for_battle", 3),
        ],
        "The hour has arrived. Lead your soldiers in assault!",
        [
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_walls),
          (else_try),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
          (try_end),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (assign, ":battle_advantage", reg0),
          (val_mul, ":battle_advantage", 2),
          (val_div, ":battle_advantage", 3), #scale down the advantage a bit in sieges.
          (set_battle_advantage, ":battle_advantage"),
          (set_party_battle_mode),
          (assign, "$g_siege_battle_state", 1),
          (assign, ":siege_sally", 0),
          (try_begin),
            (le, ":battle_advantage", -6), #we are outnumbered, defenders sally out
            (eq, "$g_siege_sallied_out_once", 0),
            (set_jump_mission,"mt_castle_attack_walls_defenders_sally"),
            (assign, "$g_siege_battle_state", 0),
            (assign, ":siege_sally", 1),
          (else_try),
            (party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),
            (set_jump_mission,"mt_castle_attack_walls_belfry"),
          (else_try),
            (set_jump_mission,"mt_castle_attack_walls_ladder"),
          (try_end),
          (assign, "$cant_talk_to_enemy", 0),
          (assign, "$g_siege_final_menu", "mnu_castle_besiege"),
          (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
          (assign, "$g_siege_method", 0), #reset siege timer
          (jump_to_scene,":battle_scene"),
          (try_begin),
            (eq, ":siege_sally", 1),
            (jump_to_menu, "mnu_siege_attack_meets_sally"),
          (else_try),
            (jump_to_menu, "mnu_battle_debrief"),
            (change_screen_mission),
          (try_end),
      ]),
      ("attack_stay_back",
        [
          (eq, "$g_listos_para_asalto", 1),
          (ge, "$g_siege_method", 2),
          (gt, "$g_friend_fit_for_battle", 3),
        ],
        "Order your soldiers to attack while you stay back...", [(assign, "$cant_talk_to_enemy", 0),(jump_to_menu,"mnu_castle_attack_walls_simulate2")]),
      
      ("build_mantlet",
        [           (eq, "$g_mantlets_1", 0),
          (neq, "$g_siege_method", 1),
        ],
        "Build mantlets.",
        [
          (jump_to_menu,"mnu_build_mantles2"),
          ##                        (assign, "$g_mantlets_1", 1),
          ##                (store_current_hours, ":cur_hours"),
          ##                (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, ":cur_hours"),
      ]),
      #siege warfare ram
      ("build_ladders",[(party_slot_eq, "$current_town", slot_center_siege_with_belfry, 0),
          #(party_slot_eq, "$current_town", slot_center_siege_with_ram, 0),
          (eq, "$g_siege_method", 0),
          (neq, "$g_mantlets_1", 1),],
        "Build equipment and clear the ground for assault.", [(jump_to_menu,"mnu_construct_ladders")]),
      
      ##no siege towers in dark ages
      ("build_siege_tower",[(party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),(eq, "$g_siege_method", 0)],
        "Build a siege tower and other equipment to assault the fortress. Assaults may result in many casualties.", [(jump_to_menu,"mnu_construct_siege_tower")]),
      ###siege warfare ram chief
      ##                   ("build_battering_ram", [(party_slot_eq, "$current_town", slot_center_siege_with_ram, 1),
      ##	                           (eq, "$g_siege_method", 0)],
      ##       "Build a battering ram and equipment to prepare the assault on the fortress . Assaults are unpredictable, and may result in many casualties.", [(jump_to_menu,"mnu_battering_ram")]),
      ###siege warfare ram acaba
      ("cheat_castle_lead_attack",[(eq, "$cheat_mode", 1),
          (eq, "$g_siege_method", 0)],
        "{!}CHEAT: Instant build equipments.",
        [
          (assign, "$g_siege_method", 1),
          (assign, "$g_siege_method_finish_hours", 0),
          (jump_to_menu, "mnu_castle_besiege"),
      ]),
      
      ("cheat_conquer_castle",[(eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT: Instant conquer castle.",
        [
          (assign, "$g_next_menu", "mnu_castle_taken"),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_castle_besiege")]),
    ]
  ),
  
  #####Siege warfare acaba
  
  #########
  
  
  (
    "siege_attack_meets_sally",0,
    "The defenders sally out to meet your assault.",
    "none",
    [
      (set_background_mesh, "mesh_pic_sally_out"),
    ],
    [
      ("continue",[],
        "Continue...",
        [
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  #######siege warfare
  #Low food = sally out
  (
    "nofood_siege_defenders_sally",0,
    "The lack of food forces the desperate defenders of {s4} to sally out in an attempt to break the siege.",
    "none",
    [
      (set_background_mesh, "mesh_pic_sally_out"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [
      ("continue",[],
        "Continue...",
        [
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  #surrender for hunger
  (
    "surrender_siege_defenders_starved",0,
    "The defenders of {s4} can hold out no longer. Lack of food has debilitated them. Already the weakest have died of starvation, and in some cases, the need has led to cannibalism.^" +
    "{s4} is ready to surrender...",
    "none",
    [
      (set_background_mesh, "mesh_pic_siege_victory"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [
      ("continue",[],
        "Continue...",
        [
          (assign, "$g_enemy_surrenders",1),
          (jump_to_menu, "mnu_castle_besiege"), #
      ]),
    ]
  ),
  ############
  ####SIEGE WARFARE CHIEF menus extras
  (
    "castle_attack_walls_simulate2",mnf_disable_all_keys, #vanguardia
    "{s4}^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (try_begin),
        (set_background_mesh, "mesh_laddersassault"),
      (try_end),
      
      (try_begin), ###siege warfare
        (eq, "$g_mantlets_1", 2),
        (call_script, "script_simulate_battle_with_parties", 2, "$g_enemy_party", 5, 0, 0), ###less difficult
      (else_try),
        (call_script, "script_simulate_battle_with_parties", 2, "$g_enemy_party", 6, 0, 0),
      (try_end),
      
      (assign, "$no_soldiers_left", 0),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (le, reg0, 0), #(TODO : compare with num_routed_us)
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_attack_walls_failure"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (le, reg0, 0), #(TODO : compare with num_routed_enemies)
        (assign, "$no_soldiers_left", 1),
        (assign, "$g_battle_result", 1),
        (str_store_string, s4, "str_attack_walls_success"),
      (else_try),
        (str_store_string, s4, "str_attack_walls_continue"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu,"mnu_siege_assault")]),
    ]
  ),
  
  
  
  (
    "sneak_into_town_suceeded2",0,
    "Disguised and under the cover of darkness, you infiltrate {s4}. It's time to scout out their defenses.",
    "none",
    [
      (set_background_mesh, "mesh_sneak_into_town"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$sneaked_into_town",1),
          (jump_to_menu,"mnu_town"),
      ]),
    ]
  ),
  
  #labores de saneamiento chief
  (
    "construct_saneamiento",0,
    "Sanitation is important for preventing rats and disease. It is possible to construct latrines and pipelines to prevent the accumulation of mud and filth from the rain, and dig a reservoir to have an available water supply. Do you want to do it?^" +
    "It will take 4 hours.",
    "none",
    [
      (set_background_mesh, "mesh_siegeplan"),
    ],
    [
      ("build_saneamiento",[],
        "Do it.", [
          (assign, "$g_siege_saneamiento", 1),
          (store_current_hours, ":cur_hours"),
          (party_set_slot, "$g_encountered_party", slot_center_latrines, ":cur_hours"),
          (call_script, "script_change_player_party_morale", -3),
          (assign, "$g_siege_saneamiento", 2), #fix problem with saneamiento.
          (jump_to_menu,"mnu_siege_plan")
      ]),
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_siege_plan")]),
    ],
  ),
  #saneamiento acaba
  ###block place
  (
    "construct_circunvalation",0,
    "Blockading a place protects your troops during the siege, helps to avoid some enemy skirmishers, and prevents the entry of food and reinforcements. " +
    "It also lowers enemy's morale and helps you negotiate the surrender of the place.^^" +
    "As the party member with the highest Engineer skill, ({reg2}), {reg3?you estimate:{s3} estimates} that building the blockade around the place will take {reg4} hours.",
    "none",
    [
      (set_background_mesh, "mesh_circunvalacion"),
      
      (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      (assign, reg2, ":max_skill"),
      
      (store_sub, reg4, 16, ":max_skill"),
      (val_mul, reg4, 4),#between 24 and 64 hours
      
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s3, ":max_skill_owner"),
      (try_end),
    ],
    [
      ("build_circun_cont",[],
        "Do it.", [
          (party_set_slot,"$g_encountered_party",slot_center_blockaded,1),
          (store_current_hours, ":cur_hours"),
          (party_set_slot, "$g_encountered_party", slot_center_blockaded_time, ":cur_hours"),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_siege_plan")]),
    ],
  ),
  
  ##########
  ("traicion_interna2",0,
    "Your siege works begin to demoralize the defenders. Some of your soldiers are willing to contact the garrison or the inhabitants at {s4} and probe if someone would be willing to commit treason and facilitate the conquest. They need 500 peningas for the job.",
    "none",
    [(set_background_mesh, "mesh_sneak_into_town"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [
      ("intentar_traicion",[],
        "Allow these men to seek out a traitor.", [
          (store_troop_gold,":money","trp_player"),
          (try_begin),
            (gt,":money",499),
            (troop_remove_gold, "trp_player", 500),
            (assign, "$g_traicion_interna", 1),
            (jump_to_menu,"mnu_siege_plan"),
          (else_try),
            (display_message,"str_no_money"),
          (try_end),
      ]),
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_siege_plan")]),
    ],
  ),
  
  ####traicion interna
  ("traicion_resultado1",0,
    "They returned without news. No one is willing to become a traitor.",
    "none", [ (set_background_mesh, "mesh_sneak_into_town"),
    ],
    [
      ("back_behind",[],"Well, bad luck.",
        [
          (assign, "$g_traicion_interna", 3),#failed
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("traicion_resultado2",0,
    "Sir! Our men have been discovered near the wall. They are fighting their way out of {s4}. Look over there at the sally port. They are trying to flee, but are surrounded...",
    "none",
    [
      (set_background_mesh, "mesh_sneak_into_town"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [
      ("ayudar_infiltrados",[],"Order: send an additional group of men to their aid.",
        [
          (jump_to_menu,"mnu_traicion_lucha"),
      ]),
      ("leave_men",[],"Leave the men to their fate. They knew what was coming.",
        [
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_party_morale", -6),
          (assign, "$g_traicion_interna", 3), #failed
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("traicion_resultado3",0,
    "Your men have returned. A traitor within the place has set barns ablaze and will soon flee {s4} and join your army. The enemy will lose much of their food stock because of that.",
    "none", [ (set_background_mesh, "mesh_sneak_into_town"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [("back_to_siege",[],"Well done.",
        [
          (party_get_slot,":cur_food","$g_encountered_party",slot_party_food_store),
          (try_begin),
            (ge,":cur_food",4),
            (store_random_in_range,":burned",40,50),
            (val_mul,":cur_food",100),
            (val_add,":burned",100),
            (val_div,":cur_food",":burned"),
            (party_set_slot,"$g_encountered_party",slot_party_food_store,":cur_food"),
            (str_store_party_name,s4,"$g_encountered_party"),
            (display_message, "@{s4} lost between 40 and 50% of its food reserves.", 0xFF0000),
          (try_end),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -5),
          (party_add_members, "p_main_party", "trp_townsman", 1),
          (assign, "$g_traicion_interna", 4), #success
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("traicion_resultado4",0,
    "Your men have returned. They report there is a traitor who knows the routines of the garrison, and he is willing to lead a small force to ambush the enemy when they come to the water supplies, a nearby stream outside the walls...",
    "none", [ (set_background_mesh, "mesh_sneak_into_town"),],
    [
      ("atacar_emboscada_player",[],"Go yourself with your closest companions.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          
          (store_random_in_range, ":scene_a_usar", 0,3),
          (try_begin),
            (eq, ":scene_a_usar", 1),
            (assign, ":scene_to_use", "scn_river_ambush_1"),
          (else_try),
            (eq, ":scene_a_usar", 2),
            (assign, ":scene_to_use", "scn_river_ambush_2"),
          (else_try),
            (assign, ":scene_to_use", "scn_river_ambush_3"),
          (try_end),
          
          (set_jump_mission,"mt_ambush_riversw"),
          (modify_visitors_at_site,":scene_to_use"),
          #### tropas cambiar por las del asentamiento
          (assign, "$g_traicion_interna", 4), #success
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"), #player
          (assign, ":cur_entry", 1),
          (try_for_range, ":companion", companions_begin, companions_end),
            (main_party_has_troop,":companion"),
            (set_visitor, ":cur_entry", ":companion"),
            (val_add, ":cur_entry", 1),
          (try_end),
          
          (assign, ":num_troops", 8),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
            (assign, ":lost_troop", reg0),
            #(try_for_range, ":visiterator", 17, 18), #possible 17 and 31, but this add 8 enemies each 1 entry point
            (assign, ":visiterator", 17),
            (set_visitor, ":visiterator", ":lost_troop"),
            #  (try_end),
          (try_end),
          (jump_to_scene,":scene_to_use"),
          (change_screen_mission),
      ]),
      
      ("atacar_emboscada",[],"Order: send a group of men with the traitor to carry out the ambush.",
        [
          (store_random_in_range, ":rand", 0, 3),
          (try_begin),
            (eq, ":rand", 0),
            (jump_to_menu,"mnu_emboscada_victory"),
          (else_try),
            (eq, ":rand", 1),
            (jump_to_menu,"mnu_emboscada_lose"),
          (else_try),
            (jump_to_menu,"mnu_emboscada_nada"),
          (try_end),
      ]),
      ("leave_men1",[],"It makes me uneasy. Forget about it.",
        [
          # (assign, "$g_traicion_interna", 0),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  #resultado
  ("emboscada_player",0,
    "Moving through the vegetation, you have taken your enemies by surprise and have given a good account of yourselves. Now the garrison will think twice before sending men out.",
    "none", [ (set_background_mesh, "mesh_pic_ambush"),
    ],
    [
      ("victory_bang",[],"Victory!",
        [
          (leave_encounter),
          (change_screen_map),
      ]),
    ],
  ),
  #
  ("emboscada_nada",0,
    "Your men move under the cover of the vegetation, away from the watchful eyes on the wall, but when they come to the meeting point, there is nobody. The alleged traitor has been discovered or has repented. Your men return disappointed.",
    "none", [ (set_background_mesh, "mesh_pic_ambush"),
    ],
    [
      ("emboscada_nanai",[],"Do not worry. There will be another chance.",
        [
          (assign, "$g_traicion_interna", 3), #failed
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  #
  ("emboscada_lose",0,
    "Alarm! Treason! The alleged traitor led your men into an ambush. They are fighting desperately, leaving many men on the field.",
    "none", [ (set_background_mesh, "mesh_pic_ambush"),
      (store_random_in_range, ":p_leave", 8, 12),
      (assign, ":num_troops", ":p_leave"),
      (try_for_range, ":unused", 0, ":num_troops"),
        (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
      (try_end),
    ],
    [("regreso_lucha",[],"Your worst fears have come true.",
        [
          (assign, "$g_traicion_interna", 3), #failed
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("emboscada_victory",0,
    "The traitor leads your men through the night to a hill that controls the path to a well. Your men take up positions in the vegetation, in silence, their faces stained black. At daybreak, your men spot a large group of enemies by the water.^^A battle cry fills the valley as your soldiers fall like a tide of death on the enemy... killing many.",
    "none", [ (set_background_mesh, "mesh_pic_ambush"),
      
      (store_random_in_range, ":p_leave", 8, 12),
      (assign, ":num_troops", ":p_leave"),
      (try_for_range, ":unused", 0, ":num_troops"),
        (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
      (try_end),
    ],
    
    [("victory_bang",[],"Victory!",
        [
          (call_script, "script_change_player_party_morale", 3),
          (assign, "$g_traicion_interna", 4), #success
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  #
  ("traicion_resultado5",0,
    "When your men come back, they tell you they have contacted a man who is in control of rations, and he has promised to raise the price of food to his fellow citizens to sow discontent, making them more likely to abandon the fortress.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),
    ],
    
    [("traicion_moral",[],"Perfect!",
        [
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -5),
          
          (store_random_in_range, ":p_leave", 8, 22),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
          (try_end),
          (assign, "$g_traicion_interna", 4), #success
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  #traicion interna
  ("traicion_lucha",0,
    "Your men and the enemy fight to the death at the foot of the wall, where everything is unfavorable to your troops. You watch them fighting and retreating towards you. Many bodies are left behind. " +
    "^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none", [ (set_background_mesh, "mesh_siegeplan"),
      (call_script, "script_simulate_battle_with_parties", 15, "$g_enemy_party", 75, 0, 0),
    ],
    
    [("regreso_luchar",[],"Well, no one gets left behind.",
        [
          (call_script, "script_change_player_honor", 5),
          (call_script, "script_change_player_party_morale", 5),
          (assign, "$g_traicion_interna", 3), #failed
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  ####infiltracion interna chief
  ("infiltracion_resultado1",0,
    "They returned without news. They were unable to enter the settlement.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),
    ],
    [
      ("back_behindi",[],"Just bad luck, I guess.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 3),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("infiltracion_resultado2",0,
    "Sir! Our men have been discovered in {s4}. Unfortunately, none have returned. They were all killed or captured.",
    "none",
    [
      (set_background_mesh, "mesh_siegeplan"),
      (str_store_party_name,s4,"$current_town"),
    ],
    [
      ("muertos_infiltrado",[],"Terrible news.",
        [
          (call_script, "script_change_player_party_morale", -5),
          
          (store_random_in_range, ":p_leave", 18, 22),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
            (assign, ":lost_troop", reg0),
            (store_random_in_range, ":random_no", 0, 100),
            (ge, ":random_no", 50),
            (party_add_prisoners, "$g_encountered_party", ":lost_troop", 1),
          (try_end),
          
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 3),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("infiltracion_resultado3",0,
    "Victory! They have managed to burn several food stores. The enemy is demoralized. Perhaps it is time to request their surrender.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),],
    
    [("back_to_siegei",[],"Well, give them a barrel of mead.",
        [
          (party_get_slot,":cur_food","$g_encountered_party",slot_party_food_store),
          (try_begin),
            (ge,":cur_food",4),
            (store_random_in_range,":burned",50,60),
            (val_mul,":cur_food",100),
            (val_add,":burned",100),
            (val_div,":cur_food",":burned"),
            (party_set_slot,"$g_encountered_party",slot_party_food_store,":cur_food"),
            (str_store_party_name,s4,"$g_encountered_party"),
            (display_message, "@{s4} lost between 50 and 60% of its food reserves.", 0xFF0000),
          (try_end),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -5),
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 4),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("infiltracion_resultado3_c",0,
    "Victory! They killed many cattle and contaminated the water reserves. The enemy is demoralized and their lord has lost some renown. Perhaps it is time to request their surrender.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),],
    
    [("back_to_siegein",[],"Well, give them a barrel of mead.",
        [
          (party_get_slot,":cur_food","$g_encountered_party",slot_party_food_store),
          (try_begin),
            (ge,":cur_food",4),
            (store_random_in_range,":burned",30,40),
            (val_mul,":cur_food",100),
            (val_add,":burned",100),
            (val_div,":cur_food",":burned"),
            (party_set_slot,"$g_encountered_party",slot_party_food_store,":cur_food"),
            (str_store_party_name,s4,"$g_encountered_party"),
            (display_message, "@{s4} lost between 30 and 40% of its food reserves.", 0xFF0000),
          (try_end),
          (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord),
          (call_script, "script_change_troop_renown", ":town_lord", -15),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -10),
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 4),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  
  ("infiltracion_resultado4",0,
    "Your men have returned. They said that some warriors are dissatisfied, and some were persuaded to switch to your side. If you agree, they will leave the city at night and join your army. Before they leave, they promise to cause unrest to facilitate the surrender of the place.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),],
    
    [("aceptar_si",[],"They are welcome.",
        [
          (store_random_in_range, ":p_leave", 4, 12),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
            (assign, ":lost_troop", reg0),
            (party_add_members, "p_main_party", ":lost_troop", 1),
          (try_end),
          
          (party_get_slot,":cur_food","$g_encountered_party",slot_party_food_store),
          (try_begin),
            (ge,":cur_food",4),
            (store_random_in_range,":burned",10,20),
            (val_mul,":cur_food",100),
            (val_add,":burned",100),
            (val_div,":cur_food",":burned"),
            (party_set_slot,"$g_encountered_party",slot_party_food_store,":cur_food"),
            (str_store_party_name,s4,"$g_encountered_party"),
            (display_message, "@{s4} lost between 10 and 20% of its food reserves.", 0xFF0000),
          (try_end),
          
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 4),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
      ("leave_men1",[],"It makes me uneasy. Forget about it.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 0),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("infiltracion_resultado4_c",0,
    "Your men have returned. They said that they poisoned the water of some wells and nearby streams. This should sicken many in the garrison.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),],
    
    [("aceptar_oki",[],"That's good news. It will leave fewer men to defend the wall.",
        [
          
          (assign,":party_no","$g_encountered_party"),
          (party_get_num_companion_stacks, ":num_stacks",":party_no"),
          (party_get_slot,":party_type",":party_no",slot_party_type),
          # (assign,":max_no",60),
          (assign,":start_troop",0),
          (try_begin),
            (eq,":party_type",3), #town
            (assign,":max_no",30), #30%
            (call_script, "script_change_center_prosperity", ":party_no", -5),
          (else_try),
            #(eq,":party_type",2), #fort
            (assign,":max_no",20), #20%
            (call_script, "script_change_center_prosperity", ":party_no", -3),
          (try_end),
          (party_get_slot, ":food_stores", ":party_no", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", ":party_no"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, ":party_no", slot_party_food_store, ":food_stores"),
          (try_for_range, ":stack_no", ":start_troop", ":num_stacks"),
            (party_stack_get_troop_id,":cur_troop_id",":party_no",":stack_no"),
            (party_stack_get_size,":num_troops",":party_no",":stack_no"),
            (val_mul,":num_troops",100),
            (store_random_in_range,":wounds",10,":max_no"), #10% wounds - 10 to 20 0 30 depend on center type
            (val_add,":wounds",100),
            (store_div,":damage",":num_troops",":wounds"),
            (party_wound_members,":party_no",":cur_troop_id",":damage"),
            (str_store_party_name,s4,"$g_encountered_party"),
            (display_message, "@{s4} have between 10 and 30% of its garrison sick for a few days.", 0xFF0000),
          (try_end),
          
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 4),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
      ##        ("leave_men",[],"It makes me uneasy. Forget about it.",
      ##       [
      ##                          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
      ##                        (assign, "$g_infiltracion_interna", 0),
      ##                        (jump_to_menu,"mnu_siege_plan"),
      ##        ]),
    ],
  ),
  
  ("infiltracion_resultado5",0,
    "Oh, sir. The enemy has sent a bag with the heads of your men. Some of our soldiers have seen it, and fear runs through the camp.",
    "none", [ (set_background_mesh, "mesh_siegeplan"),
    ],
    
    [
      ("infiltracion_morali",[],"Cowards! How can a couple of heads sink the morale of an army? Are they cattle or men?",
        [
          (call_script, "script_change_player_party_morale", -10),
          
          (store_random_in_range, ":p_leave", 18, 22),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 0),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
      ("infiltracion_morali2",[],"Avenge the insult to us!",
        [
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_troop_renown", "trp_player", -10),
          
          (store_random_in_range, ":p_leave", 18, 22),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          
          (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
          (assign, "$g_infiltracion_interna", 3),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  ###infiltracion interna acaba
  
  
  ###recogida y siembra de cosechas
  ("campos_cercanos1",0,
    "{reg59?Lady:Sir}, crops and farms were burned, but since this is not the harvest season, it wasn't possible to get food.",
    "none", [ (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("back_behind_d",[],"Well done, do not worry.",
        [
          (assign, "$g_campos_cercanos", 3),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -3),
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  ("campos_cercanos2",0,
    "{reg59?Lady:Sir}, crops and farms were burned, and as it is the harvest season, we found an abundance of food.",
    "none", [ (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("back_behind_c",[],"Well done, food is always welcome.",
        [
          (assign, "$g_campos_cercanos", 3),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -20),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  ("campos_cercanos2_c",0,
    "{reg59?Lady:Sir}, crops and farms were burned. The grain is still green, but edible. We found an abundance of food.",
    "none", [ (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("back_behind_cc",[],"Well done, food always is welcome.",
        [
          (assign, "$g_campos_cercanos", 3),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -10),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_grain",0),
          (troop_add_item, "trp_player","itm_grain",0),
          (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  ("campos_cercanos3",0,
    "{reg59?Lady:Sir}, we burned the fields, but as it is after the harvest time, there was no grain left. However, the farmers have left some of their cattle behind.",
    "none", [ (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("back_behind_bc",[],"Food is always welcome.",
        [
          (assign, "$g_campos_cercanos", 3),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", -10),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          (troop_add_item, "trp_player","itm_pork",0),
          (troop_add_item, "trp_player","itm_pork",0),
          (troop_add_item, "trp_player","itm_pork",0),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (troop_add_item, "trp_player","itm_chicken",0),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("campos_cercanos4",0,
    "We have encountered problems. The fields were burned, but the farmers struck back with support from some members of the garrison.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none", [
      (set_background_mesh, "mesh_pic_messenger"),
      (call_script, "script_simulate_battle_with_parties", 30, "$g_enemy_party", 90, 0, 0),
    ],
    [
      ("back_behind_ac",[],"Terrible news!",
        [
          (assign, "$g_campos_cercanos", 3),
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (jump_to_menu,"mnu_siege_plan"),
      ]),
    ],
  ),
  
  ("poner_escaleras",0, #no mantles
    "Your vanguard advances, bringing ladders, shovels and other useful siege equipment... A display of men armed with ranged weapons goes forth, attracting the enemy's missiles. Your heart races in its bony cage. Somehow, all battles seem to be the first.^" +
    "The thrill, terror and sweat are there, always. Your men make a shield formation to protect themselves...^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none", [ (set_background_mesh, "mesh_laddersassault"),
      (call_script, "script_simulate_battle_with_parties", 15, "$g_enemy_party", 45, 0, 0),
    ],
    [
      ("back_behind_esc1",[],"Your men have met the enemy. It is your turn...",
        [
          (assign, "$g_listos_para_asalto", 1),
          (jump_to_menu,"mnu_siege_assault"),
      ]),
    ],
  ),
  
  ("poner_escaleras_mantlets",0, #mantles
    "Your vanguard advances, bringing ladders, mantlets, shovels and other useful siege equipment... A display of men armed with ranged weapons goes forth, guarded by mantlets, attracting the enemy's missiles. Your heart races in its bony cage. Somehow, all battles seem to be the first.^" +
    "The thrill, terror and sweat are there, always. Your men make a shield formation to protect themselves, and using the mantlets saves still more lives. " +
    "^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none", [ (set_background_mesh, "mesh_laddersassault"),
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 50, 0, 0),
    ],
    [
      ("back_behind_esc2",[],"Your men have met the enemy. It is your time...",
        [
          (assign, "$g_listos_para_asalto", 1),
          (jump_to_menu,"mnu_siege_assault"),
      ]),
    ],
  ),
  
  ####
  #####scout reporta datos de ciudad
  (
    "informacion_ciudad",0,#{s10} belongs to {s21}
    "A scout appears before you: '{s11}^{s12}{s1}{s5}{s17}'",
    "none",
    [
      (str_clear, s10),
      (str_clear, s21),
      (str_clear, s11),
      (str_clear, s12),
      (str_clear, s3),
      (str_clear, s16),
      (set_background_mesh, "mesh_pic_messenger"),
      #string descripcion
      ##	 (party_get_slot,":town_lord","$current_town",slot_town_lord),
      ##	 (str_store_troop_name,s21,":town_lord"),
      ##        #
      ##        (str_store_party_name, s10, "$current_town"),
      
      (call_script, "script_game_get_center_note", "$current_town", 0),
      (str_store_string, s11, "@{!}{s0}"),
      ##    (try_begin),
      ##      (this_or_next|is_between, "$current_town", towns_begin, towns_end),
      ##      (is_between, "$current_town", castles_begin, castles_end),
      ##    (try_end),
      
      (party_get_slot, ":center_food_store", "$current_town", slot_party_food_store),
      (call_script, "script_center_get_food_consumption", "$current_town"),
      (assign, ":food_consumption", reg0),
      (store_div, reg6, ":center_food_store", ":food_consumption"),
      (store_party_size_wo_prisoners,reg5, "$current_town"),
      #(store_party_size, reg5, "$current_town"),
      (str_store_string, s12, "@It should have food stocks for {reg6} days.^The garrison has {reg5} men."),
      
      (party_get_num_attached_parties, ":num_attached_parties", "$current_town"),
      (try_begin),
        (eq, ":num_attached_parties", 0),
        (str_clear, s1),
        (str_clear, s5),
        
      (else_try),
        (str_store_string, s1, "@^^The following armies are currently inside:"),
        (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"),
          (party_get_attached_party_with_rank, ":attached_party", "$current_town", ":attached_party_rank"),
          (str_store_party_name, s3, ":attached_party"),
          (store_party_size, reg1, ":attached_party"),
          (str_store_string, s5, "@^{s3} with {reg1} troops."),
        (try_end),
      (try_end),
      
      ##     (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
      ##     (val_div, ":prosperity", 20),
      ##    (try_begin),
      ##     (eq, ":prosperity", 0),
      ##       (str_store_string, s16, "@{s10} is a very poor place that"),
      ##     (else_try),
      ##       (eq, ":prosperity", 1),
      ##       (str_store_string, s16, "@{s10} is poor place that"),
      ##     (else_try),
      ##       (eq, ":prosperity", 2),
      ##       (str_store_string, s16, "@{s10} is good place that"),
      ##     (else_try),
      ##       (eq, ":prosperity", 3),
      ##       (str_store_string, s16, "@{s10} is rich place that"),
      ##     (else_try),
      ##       (str_store_string, s16, "@{s10} is very rich place that"),
      ##     (try_end),
      ##
      ##    (call_script, "script_update_center_recon_notes", "$current_town"),
      
      #informacion asedio
      (str_store_string,s17,"str_empty_string"),
      (try_begin),
        (eq, "$current_town", "p_town_27"),
        (str_store_string,s17,"@^^Commander, this town is one big rock. Many before us have fled the place before a single blow was exchanged, so we must keep morale up among the men. " +
          "The path to the main gate is formidably narrow and steep, but if we set up the camp and build a battering ram, we can break down the wall at the back entrance of the town. " +
        "When the wall is down, we can charge in without losing breath. The steps up to the town center are fewer there."),
      (else_try),
        (eq, "$current_town", "p_town_6"),
        (str_store_string,s17,"@^^Alt Clut, the rock high over the Clyde. This is the mightiest fortress of the northern Britons. Nobody has ever taken it by siege in your day. " +
        "Controlling the mouth of the Clyde, it was where King Riderch Hael fought the Bernicians and the Picts."),
      (else_try),
        (eq, "$current_town", "p_castle_30"),
        (str_store_string,s17,"@^^This formidable stronghold is the jewel of the Dumnonian kingdom. Here many ships from Mediterannea arrive full of wine and luxuries. Legend says the warlord, Arthur, was born here."),
      (else_try),
        (eq, "$current_town", "p_castle_37"),
        (str_store_string,s17,"@^^Dun Taruo, the fortress of the bull. This place seems like the work of giants, and for centuries, the Picts have known its reputation."),
      (else_try),
        (eq, "$current_town", "p_town_3"),
        (str_store_string,s17,"@^^The seat of the brave Goutodin warriors. From here, they launched their attacks against the Bernicians, and their heroic end will never be forgotten. You can almost smell their courage from here, " +
        "even though Goutodin disappeared long ago."),
      (else_try),
        (str_store_string,s17,"@^^This place is just waiting for you to conquer it."),
      (try_end),
      #
    ],
    [("regreso_luchain",[],"Thank you. Your information is important!",
        [
          (jump_to_menu,"mnu_siege_assault"),
      ]),
    ],
  ),
  
  
  
  #################menus extras acaba chief Siege Warfare
  (
    "castle_besiege_inner_battle",0,
    "{!}{s1}",
    "none",
    [
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_siege_sighted_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_siege_sighted"),
      (try_end),
      (assign, ":result", "$g_battle_result"),#will be reset at script_encounter_calculate_fit
      (call_script, "script_encounter_calculate_fit"),
      
      # TODO: To use for the future:
      (str_store_string, s1, "@As a last defensive effort, you retreat to the main hall of the keep. " +
      "You and your remaining soldiers will put up a desperate fight here. If you are defeated, there's no other place to fall back to."),
      (str_store_string, s1, "@You've been driven away from the walls. " +
      "Now the attackers are pouring into the streets. If you can defeat them, you can perhaps turn the tide and save the day."),
      (try_begin),
        (this_or_next|neq, ":result", 1),
        (this_or_next|le, "$g_friend_fit_for_battle", 0),
        (le, "$g_enemy_fit_for_battle", 0),
        (jump_to_menu, "$g_siege_final_menu"),
      (else_try),
        (call_script, "script_encounter_calculate_fit"),
        (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
        (try_begin),
          (eq, "$g_siege_battle_state", 0),
          (eq, ":result", 1),
          (assign, "$g_battle_result", 0),
          (jump_to_menu, "$g_siege_final_menu"),
        (else_try),
          (eq, "$g_siege_battle_state", 1),
          (eq, ":result", 1),
          (str_store_string, s1, "@You've breached the town walls, " +
            "but the stubborn defenders continue to resist you in the streets! " +
          "You'll have to deal with them before you can attack the keep at the heart of the town."),
        (else_try),
          (eq, "$g_siege_battle_state", 2),
          (eq, ":result", 1),
          (str_store_string, s1, "@The town centre is yours, " +
            "but the remaining defenders have retreated to the castle. " +
          "It must fall before you can complete your victory."),
        (else_try),
          (jump_to_menu, "$g_siege_final_menu"),
        (try_end),
      (else_try),
        (try_begin),
          (eq, "$g_siege_battle_state", 0),
          (eq, ":result", 1),
          (assign, "$g_battle_result", 0),
          (jump_to_menu, "$g_siege_final_menu"),
        (else_try),
          (eq, "$g_siege_battle_state", 1),
          (eq, ":result", 1),
          (str_store_string, s1, "@The remaining defenders have retreated to the castle as a last defense. You must go in and crush any remaining resistance."),
        (else_try),
          (jump_to_menu, "$g_siege_final_menu"),
        (try_end),
      (try_end),
    ],
    [
      ("continue",[],
        "Continue...",
        [
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (try_begin),
              (eq, "$g_siege_battle_state", 1),
              (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_center),
              (set_jump_mission, "mt_besiege_inner_battle_town_center"),
            (else_try),
              (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_castle),
              (set_jump_mission, "mt_besiege_inner_battle_castle"),
            (try_end),
          (else_try),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_castle),
            (set_jump_mission, "mt_besiege_inner_battle_castle"),
          (try_end),
          ##           (call_script, "script_calculate_battle_advantage"),
          ##           (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (jump_to_scene, ":battle_scene"),
          (val_add, "$g_siege_battle_state", 1),
          (assign, "$g_next_menu", "mnu_castle_besiege_inner_battle"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  
  ####siege warfare
  (
    "build_mantles2",0,
    "The mantlets help protect your men when they have to use assault equipment. They save many lives. " +
    "As the party member with the highest Engineer skill, ({reg2}), {reg3?you estimate:{s3} estimates} that it will take " +
    "{reg4} hours to build mantlets.",
    "none",
    [(call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      (assign, reg2, ":max_skill"),
      
      (store_sub, reg4, 16, ":max_skill"),
      (val_mul, reg4, 2),#between 12 and 32 hours
      
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s3, ":max_skill_owner"),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("build_mantles",[],
        "Do it.", [
          #(assign, "$g_siege_method", 1),
          (assign, "$g_mantlets_1", 1),
          (store_current_hours, ":cur_hours"),
          (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, ":cur_hours"),
          (jump_to_menu,"mnu_siege_assault"),
      ]),
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_siege_assault")]),
    ],
  ),
  
  (
    "construct_ladders",0,
    "As the party member with the highest Engineer skill ({reg2}), {reg3?you estimate:{s3} estimates} that it will take " +
    "{reg4} hours to build enough equipment for the assault.",
    "none",
    [(call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      (assign, reg2, ":max_skill"),
      
      (store_sub, reg4, 16, ":max_skill"),
      (val_mul, reg4, 2),#between 12 and 32 hours
      
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s3, ":max_skill_owner"),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("build_ladders_cont",[],
        "Do it.", [
          (assign, "$g_siege_method", 1),
          (store_current_hours, ":cur_hours"),
          (party_set_slot, "$g_encountered_party", slot_center_ladder_time, ":cur_hours"),
          (jump_to_menu,"mnu_siege_assault"),
          ##           (store_current_hours, ":cur_hours"),
          ##           (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
          ##           (store_sub, ":hours_takes", 14, reg0),
          ##           (val_mul, ":hours_takes", 2),
          ##           (val_div, ":hours_takes", 3),
          ##           (store_add, "$g_siege_method_finish_hours",":cur_hours", ":hours_takes"),
          ##           (assign,"$auto_besiege_town","$current_town"),
          ##           (rest_for_hours_interactive, 96, 5, 1), #rest while attackable. A trigger will divert control when attack is ready.
          ##           (change_screen_return),
      ]),
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_castle_besiege")]),
    ],
  ),
  
  
  (
    "construct_siege_tower",0,
    "As the party member with the highest Engineer skill, ({reg2}), {reg3?you estimate:{s3} estimates} that building a siege tower and other equipment for assault will take " +
    "{reg4} hours.",
    "none",
    [(call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      (assign, reg2, ":max_skill"),
      
      (store_sub, reg4, 15, ":max_skill"),
      (val_mul, reg4, 6),
      
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s3, ":max_skill_owner"),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("build_siege_tower_cont",[],
        "Start building.", [
          (assign, "$g_siege_method", 2),
          (store_current_hours, ":cur_hours"),
          (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
          (store_sub, ":hours_takes", 15, reg0),
          (val_mul, ":hours_takes", 6),
          (store_add, "$g_siege_method_finish_hours",":cur_hours", ":hours_takes"),
          (assign,"$auto_besiege_town","$current_town"),
          (rest_for_hours_interactive, 240, 5, 1), #rest while attackable. A trigger will divert control when attack is ready.
          (change_screen_return),
      ]),
      ("go_back_dot",[],
        "Go back.", [(jump_to_menu,"mnu_castle_besiege")]),
    ],
  ),
  
  
  (
    "castle_attack_walls_simulate",mnf_disable_all_keys,
    "{s4}^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (try_begin),
        (set_background_mesh, "mesh_pic_siege_attack"),
      (try_end),
      
      (call_script, "script_simulate_battle_with_parties", 2, "$g_enemy_party", 6, 0, 0),
      
      (assign, "$no_soldiers_left", 0),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (le, reg0, 0), #(TODO : compare with num_routed_us)
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_attack_walls_failure"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (le, reg0, 0), #(TODO : compare with num_routed_enemies)
        (assign, "$no_soldiers_left", 1),
        (assign, "$g_battle_result", 1),
        (str_store_string, s4, "str_attack_walls_success"),
      (else_try),
        (str_store_string, s4, "str_attack_walls_continue"),
      (try_end),
    ],
    [
      ##      ("lead_next_wave",[(eq, "$no_soldiers_left", 0)],"Lead the next wave of attack personally.", [
      ##           (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
      ##           (set_party_battle_mode),
      ##           (set_jump_mission,"mt_castle_attack_walls"),
      ##           (jump_to_scene,":battle_scene"),
      ##           (jump_to_menu,"mnu_castle_outside"),
      ##           (change_screen_mission),
      ##       ]),
      ##      ("continue_attacking",[(eq, "$no_soldiers_left", 0)],"Order your soldiers to keep attacking...", [
      ##                                    (jump_to_menu,"mnu_castle_attack_walls_3"),
      ##                                    ]),
      ##      ("call_soldiers_back",[(eq, "$no_soldiers_left", 0)],"Call your soldiers back.",[(jump_to_menu,"mnu_castle_outside")]),
      ("continue",[],"Continue...",[(jump_to_menu,"mnu_castle_besiege")]),
    ]
  ),
  
  (
    "castle_attack_walls_with_allies_simulate",mnf_disable_all_keys,
    "{s4}^^Your casualties: {s8}^^Allies' casualties: {s9}^^Enemy casualties: {s10}",
    "none",
    [
      (try_begin),
        (set_background_mesh, "mesh_pic_siege_attack"),
      (try_end),
      
      (call_script, "script_simulate_battle_with_parties", 2, "$g_enemy_party", 6, "$g_ally_party", 0),
      
      (assign, "$no_soldiers_left", 0),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (le, reg0, 0), #(TODO : compare with num_routed_us)
        (assign, "$no_soldiers_left", 1),
        (str_store_string, s4, "str_attack_walls_failure"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (le, reg0, 0), #(TODO : compare with num_routed_enemies)
        (assign, "$no_soldiers_left", 1),
        (assign, "$g_battle_result", 1),
        (str_store_string, s4, "str_attack_walls_success"),
      (else_try),
        (str_store_string, s4, "str_attack_walls_continue"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu,"mnu_besiegers_camp_with_allies")]),
    ]
  ),
  
  # (
    # "castle_taken_by_friends",0,
    # "Nothing to see here.",
    # "none",
    # [
      # (party_clear, "$g_encountered_party"),
      # (party_stack_get_troop_id, ":leader", "$g_encountered_party_2", 0),
      # (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, ":leader"),
      # (store_troop_faction, ":faction_no", ":leader"),
      # #Reduce prosperity of the center by 5
      # (call_script, "script_change_center_prosperity", "$g_encountered_party", -5),
      # (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
      # (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
      # (val_min, ":food_stores", reg0),
      # (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
      # (try_begin),
        # (assign, ":damage", 20),
        # (is_between, "$g_encountered_party", towns_begin, towns_end),
        # (assign, ":damage", 40),
      # (try_end),
      # (try_begin),
        # (neq, ":faction_no", "$g_encountered_party_faction"),
        # (call_script, "script_faction_inflict_war_damage_on_faction", ":faction_no", "$g_encountered_party_faction", ":damage"),
      # (try_end),
      
      # (call_script, "script_give_center_to_faction", "$g_encountered_party", ":faction_no"),
      # (call_script, "script_add_log_entry", logent_player_participated_in_siege, "trp_player",  "$g_encountered_party", 0, "$g_encountered_party_faction"),
      # ##        (call_script, "script_change_troop_renown", "trp_player", 1),
      # (change_screen_return),
    # ],
    # [
    # ],
  # ),
  
  ###siege warfare chief cambia
  (
    "castle_taken",mnf_disable_all_keys,
    "The battle for {s60} is almost over. Your troops are eager to start plundering the {reg2?town:fort}. {s10}" +
    "You may want to just fill your purse a bit and leave the plundered place for the enemy. " +
    "Finally, you could also decide to devastate the place completely in order to gain as much loot as possible, " +
    "enslave the inhabitants, and make it worthless for its owner.",
    "none",
    [
      #siege warfare chief
      (assign, "$g_empieza_asedio", 0),
      (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
      (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
      (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
      (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
      (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
      (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
      
      (assign, "$g_siege_saneamiento", 0),
      (assign, "$g_traicion_interna", 0),
      (assign, "$g_infiltracion_interna", 0),
      (assign, "$g_campos_cercanos", 0),
      (assign, "$g_listos_para_asalto", 0),
      (assign, "$g_mantlets_1", 0),
      (assign, "$g_cabezas_dentro", 0), #event
      (assign, "$g_siege_method", 0),
      (assign, "$g_siege_sallied_out_once", 0),
      (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
      (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
      #siege warfare acaba
      
      #new:
      (assign, "$plunder_battle_shown", 0),
      (assign, "$capture_screen_shown", 0),
      (assign, "$loot_screen_shown", 0),
      # SETUP MORALE IMPACT
      # JuJu70
      (try_begin),
        (assign, ":num_bmen", 0),
        (assign, ":num_cmen", 0),
        (assign, ":num_pmen", 0),
        (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
        (try_for_range, ":i_stack", 0, ":num_stacks"),
          (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
          (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
          (try_begin),
            (this_or_next|is_between, ":stack_troop", "trp_farmer", "trp_watchman"),
            (this_or_next|is_between, ":stack_troop", "trp_briton_slave", "trp_todos_cuerno"),
            (this_or_next|is_between, ":stack_troop", "trp_frisian_basic", "trp_briton_messenger"),
            (is_between, ":stack_troop", "trp_manhunter", "trp_refugeeromanruins"),
            (val_add, ":num_cmen", ":stack_size"),
          (else_try),
            (this_or_next|is_between, ":stack_troop", "trp_norse_slave", "trp_briton_slave"),
            (is_between, ":stack_troop", "trp_watchman", "trp_mercenaries_end"),
            (val_add, ":num_pmen", ":stack_size"),
          (else_try),
            (is_between, ":stack_troop", "trp_looter", "trp_manhunter"),
            (val_add, ":num_bmen", ":stack_size"),
          (try_end),
        (try_end),
        (store_party_size_wo_prisoners, ":num_men", "p_main_party"),
        # depending on the situation the player come to this menu with loot_option = -1 or he has already decided in a dialogue
        (try_begin),
          (eq, "$loot_option", 0),
          (val_mul, ":num_bmen", 3),
          (val_mul, ":num_pmen", 2),
          (val_mul, ":num_cmen", -1),
          (store_add, ":weighted", ":num_bmen", ":num_pmen"),
          (val_add, ":weighted", ":num_cmen"),
          (val_mul, ":weighted", -10),
          (val_div, ":weighted", ":num_men"),
          (call_script, "script_change_player_honor", 5),
          (call_script, "script_change_player_party_morale", ":weighted"),
          (jump_to_menu, "mnu_castle_taken_native"),
        (else_try),
          (eq, "$loot_option", 1),
          (val_mul, ":num_bmen", 2),
          (val_mul, ":num_cmen", -2),
          (store_add, ":weighted", ":num_bmen", ":num_cmen"),
          (val_add, ":weighted", ":num_pmen"),
          (val_mul, ":weighted", 5),
          (val_div, ":weighted", ":num_men"),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_party_morale", ":weighted"),
          (call_script, "script_change_troop_renown", "trp_player", 2),
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -30), #center hate to player
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_loot_village"), # companion comment
          (jump_to_menu, "mnu_castle_taken_plunder"),
        (else_try),
          (eq, "$loot_option", 2),	#(Scorched earth policy)
          (val_mul, ":num_bmen", 4),
          (val_mul, ":num_pmen", 2),
          (val_mul, ":num_cmen", -4),
          (store_add, ":weighted", ":num_bmen", ":num_cmen"),
          (val_add, ":weighted", ":num_pmen"),
          (val_mul, ":weighted", 5),
          (val_div, ":weighted", ":num_men"),
          (call_script, "script_change_player_honor", -15),
          (call_script, "script_change_player_party_morale", ":weighted"),
          (call_script, "script_change_troop_renown", "trp_player", 7),
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -80), #center hate to player
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_sell_slavery"), # companion comment
          (jump_to_menu, "mnu_castle_taken_plunder"),
        (else_try),
          (eq, "$loot_option", 3),
          (val_mul, ":num_bmen", 2),
          (val_mul, ":num_cmen", -1),
          (store_add, ":weighted", ":num_bmen", ":num_cmen"),
          (val_add, ":weighted", ":num_pmen"),
          (val_mul, ":weighted", 5),
          (val_div, ":weighted", ":num_men"),
          (call_script, "script_change_player_honor", -3),
          (call_script, "script_change_player_party_morale", ":weighted"),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -20), #center hate to player
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_loot_village"), # companion comment
          (jump_to_menu, "mnu_castle_taken_keepplunder"),
        (try_end),
      (try_end),
      (play_sound, "snd_cow_moo"), #ambient sound chief
      (set_background_mesh, "mesh_pic_siege_victory"), #pic book
      (str_store_party_name, s60, "$g_encountered_party"),
      (party_get_slot, ":prosperity", "$g_encountered_party", slot_town_prosperity),
      (store_div, ":str_id", ":prosperity", 10),
      (val_min, ":str_id", 9),
      (try_begin),
        (is_between, "$g_encountered_party", towns_begin, towns_end),
        (assign, reg2, 1),
        (val_add, ":str_id", "str_town_prosperity_0"),
        (str_store_string, s10, ":str_id"),
      (else_try),
        (assign, reg2, 0),
        (val_add, ":str_id", "str_fort_prosperity_0"),
        (str_store_string, s10, ":str_id"),
      (try_end),
      (str_store_string, s10, "@{s10}^^"),
      (try_begin),
        (this_or_next|neq, "$campaign_type", camp_storyline), #storyline, mission conquest part, in order to avoid player kingdoms. Except after join to kingdom.
        (is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
        (str_store_string, s10, "@{s10}You may decide to forbid your troops from harming the {reg2?town:fort}, if you want to conquer it for your faction, but your troops may lose morale. "),
        (str_store_string, s10, "@{s10}You can allow some plundering and keep the {reg2?town:fort}. "),
      (try_end),
    ],
    [
      
      ("saqueo_noallowed",[
          (this_or_next|neq, "$campaign_type", camp_storyline),
          (is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
        ],
        "Conquer the {reg2?town:fort}, but forbid plundering.",
        [
          (assign, "$loot_option", 0),
          (jump_to_menu, "mnu_castle_taken"),
      ]),
      
      ("keep_plunder",[
          (this_or_next|neq, "$campaign_type", camp_storyline),
          (is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
        ],
        "Conquer and plunder the {reg2?town:fort}.",
        [
          (assign, "$loot_option", 3),
          (jump_to_menu, "mnu_castle_taken"),
      ]),
      
      ("saqueo_normal",[],
        "Plunder the {reg2?town:fort} and leave.",
        [
          (assign, "$loot_option", 1),
          (jump_to_menu, "mnu_castle_taken"),
      ]),
      
      ("saqueo_total",[],
        "Devastate the place and leave.",
        [
          (assign, "$loot_option", 2),
          (jump_to_menu, "mnu_castle_taken"),
      ]),
      
    ],
  ),
  
  (
    "castle_taken_plunder",mnf_disable_all_keys,
    "The {reg2?town:fort} is plundered. You have collected {reg7} peningas.",
    "none",
    [
      (set_background_mesh, "mesh_pic_siege_victory"), #pic book
      (troop_clear_inventory, "trp_temp_troop"),
      (try_begin),
        (eq, "$plunder_battle_shown", 0),
        (assign, "$plunder_battle_shown", 1),
        (party_clear, "$g_encountered_party"),
        (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
        (modify_visitors_at_site, ":exterior_scene"),
        (reset_visitors),
        (assign, ":num_townsman", 15),
        (store_character_level, ":level", "trp_player"),
        (val_add, ":num_townsman", ":level"),
        (val_div, ":num_townsman", 10),
        (try_for_range, ":entry", 1, 11),	#thats entry 30-39
          (set_visitors, ":entry", "trp_townsman", ":num_townsman"),
        (end_try),
        (set_jump_mission,"mt_center_plunder"),
        (jump_to_scene, ":exterior_scene"),
        (change_screen_mission),
      (else_try),
        (eq, "$capture_screen_shown", 0),
        (assign, "$capture_screen_shown", 1),
        (eq, "$loot_option", 2),	#new: capturing slaves only for loot option 2
        (party_clear, "p_temp_party"),
        (assign, "$g_move_heroes", 0),
        (call_script, "script_party_add_wounded_members_as_prisoners", "p_temp_party", "p_total_enemy_casualties"),
        (party_get_num_prisoners,  ":num_captured_enemies", "p_temp_party"),
        (gt, ":num_captured_enemies", 0),
        (change_screen_exchange_with_party, "p_temp_party"),
      (else_try),
        (eq, "$loot_screen_shown", 0),
        (assign, "$loot_screen_shown", 1),
        (assign, ":merchant_troop", 0),
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (party_get_slot, ":merchant_troop", "$g_encountered_party", slot_town_merchant),
        (else_try),
          # new begin (copy of mnu_village_loot_complete)
          (assign, ":bound_town", "$g_encountered_party"),
          (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
          (reset_item_probabilities,0),
          (assign, ":total_probability", 0),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_get_slot, ":cur_price", ":bound_town", ":cur_price_slot"),
            (gt, ":cur_price", 0),
            (call_script, "script_center_get_production", ":bound_town", ":cur_goods"),
            (assign, ":cur_probability", reg0),
            (call_script, "script_center_get_consumption", ":bound_town", ":cur_goods"),
            (val_div, reg0, 3),
            (val_sub, ":cur_probability", reg0),
            (val_mul, ":cur_probability", 4),
            (val_mul, ":cur_probability", average_price_factor),
            (val_div, ":cur_probability", ":cur_price"),
            (val_max,":cur_probability",0),
            #first only simulation
            #(set_item_probability_in_merchandise,":cur_goods",":cur_probability"),
            (val_add, ":total_probability", ":cur_probability"),
          (try_end),
          (reset_item_probabilities,0),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_get_slot, ":cur_price", ":bound_town", ":cur_price_slot"),
            (gt, ":cur_price", 0),
            (call_script, "script_center_get_production", ":bound_town", ":cur_goods"),
            (assign, ":cur_probability", reg0),
            (gt, ":cur_probability", 0),
            (call_script, "script_center_get_consumption", ":bound_town", ":cur_goods"),
            (val_div, reg0, 3),
            (val_sub, ":cur_probability", reg0),
            (val_mul, ":cur_probability", 4),
            (val_mul, ":cur_probability", average_price_factor),
            (val_div, ":cur_probability", ":cur_price"),
            (val_max, ":cur_probability", 0),
            (val_mul, ":cur_probability", num_merchandise_goods),
            (val_mul, ":cur_probability", 100),
            (val_div, ":cur_probability", ":total_probability"),
            (val_max, ":cur_probability", 5),
            (set_item_probability_in_merchandise,":cur_goods",":cur_probability"),
          (try_end),
          
          (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
          (val_min, ":prosperity", 40),
          (val_div, ":prosperity", 2),
          (val_max, ":prosperity", 3),
          (party_get_skill_level, ":looting_skill", "p_main_party", "skl_looting"),
          (val_add, ":prosperity", ":looting_skill"),
          
          (troop_add_merchandise,"trp_temp_troop",itp_type_goods,":prosperity"),
          (assign, ":merchant_troop", "trp_temp_troop"),
          #new end
        (end_try),
        (gt, ":merchant_troop", 0),
        (troop_sort_inventory, ":merchant_troop"),
        (change_screen_loot, ":merchant_troop"),
      (else_try),
        # All shown
        
        # 1.PLUNDER MONEY
        (party_get_slot, ":prosperity_money", "$g_encountered_party", slot_town_prosperity),
        (store_random_in_range, ":random_money", 5, 11),
        (val_mul, ":random_money", 10),
        (try_begin),
          (eq, "$loot_option", 1),
          (store_mul, ":prosperity_impact", ":prosperity_money", 8),
          (val_div, ":prosperity_impact", 10),
          (val_sub, ":prosperity_impact", ":prosperity_money"),
          (val_mul, ":random_money", 10),		# 500 - 1000 peningas
          (val_mul, ":prosperity_money", 75),		# 0 - 10000 peningas		# 100 - 6000
        (else_try),
          (eq, "$loot_option", 2),
          (store_mul, ":prosperity_impact", ":prosperity_money", 5),
          (val_div, ":prosperity_impact", 10),
          (val_sub, ":prosperity_impact", ":prosperity_money"),
          (val_mul, ":random_money", 20),		# 1000 - 2000 peningas
          (val_mul, ":prosperity_money", 125),		# 0 - 15000 peningas		# 200 - 12000
        (else_try),
          (display_message, "@{!}Error in mnu_castle_taken_plunder"),
        (end_try),
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (assign, reg2, 1),	# is town
          (call_script, "script_change_center_prosperity", "$g_encountered_party", ":prosperity_impact"),
          #more plunder in towns:
          (val_mul, ":random_money", 120),	#%
          (val_mul, ":prosperity_money", 170),	#%
          (store_add, ":plunder_money", ":prosperity_money", ":random_money"),
          (val_div, ":plunder_money", 100),	#%
        (else_try),
          (assign, reg2, 0),	# is fort
          (store_add, ":plunder_money", ":prosperity_money", ":random_money"),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", ":prosperity_impact"), #go for immediate impact, fort recovers rather than eventual impact through villages
          # (try_for_range, ":cur_village", villages_begin, villages_end),
          # (party_get_slot, ":bound_center", ":cur_village", slot_village_bound_center),
          # (eq, "$g_encountered_party", ":bound_center"),
          # (call_script, "script_change_center_prosperity", ":cur_village", ":prosperity_impact"),
          # # (party_get_slot, ":village_prosperity", ":cur_village", slot_town_prosperity),
          # # (party_set_slot, "$g_encountered_party", slot_town_prosperity, ":village_prosperity"),  #in VC castles only have one village
          # (try_end),
        (try_end),
        (party_get_skill_level, ":looting_skill", "p_main_party", "skl_looting"),
        #		(val_mul, ":looting_skill", 3),	#3% more money for each skill point
        (store_mul, ":skill_money", ":plunder_money", ":looting_skill"),
        (val_div, ":skill_money", 100),
        (val_add, ":plunder_money", ":skill_money"),
        (troop_add_gold, "trp_player", ":plunder_money"),
        (assign, reg7, ":plunder_money"),
        
        # 2.ICON
        (call_script, "script_change_party_icon_loot_state", "$g_encountered_party", 1),
        # (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire"),
        # (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire_smoke"),
        
        # 3.DEVASTATED TIME
        (party_set_slot, "$g_encountered_party", slot_party_looted_left_days, 14),
        (party_set_slot, "$g_encountered_party", slot_center_accumulated_rents, 0),
        (try_begin),
          (eq, "$loot_option", 2),
          (party_set_slot, "$g_encountered_party", slot_party_looted_left_days, 21),
        (end_try),
        
        # 4.PUSH PLAYER ON SEA IF HE HAS SHIPS
        (try_begin),
          (party_slot_ge, "$current_town", slot_party_1_ship_type, 1),
          (call_script, "script_give_player_ships_from_party_to_party", "$current_town", "p_main_party"),
          (party_get_slot, ":curr_port", "$current_town", slot_party_port_party),
          (party_get_position, pos2, ":curr_port"),
          (party_set_position, "p_main_party", pos2),
          (call_script, "script_switch_to_water_consequences"),
        (end_try),
        
        # 5. NATIVE CODE WE STILL NEED
        (try_for_range, ":unused", 0, 2),
          (call_script, "script_cf_reinforce_party", "$g_encountered_party"),
        (try_end),
        (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
        (val_div, reg0, 3),
        (party_set_slot, "$g_encountered_party", slot_party_food_store, reg0),
        (call_script, "script_lift_siege", "$g_encountered_party", 0),
        (assign, "$g_player_besiege_town", -1),
        (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, "trp_player"),
        
        (call_script, "script_change_troop_renown", "trp_player", 10),
        
        (assign, ":damage", 20),		#native: 20
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (assign, ":damage", 40),	#native: 40
        (try_end),
        (call_script, "script_faction_inflict_war_damage_on_faction", "$players_kingdom", "$g_encountered_party_faction", ":damage"),
      (end_try),
    ],
    [
      
      
      ("continue",[],"Continue...",
        [
          # (assign, "$auto_enter_town", "$g_encountered_party"),
          # (change_screen_return),
          (change_screen_map),
          #(jump_to_menu, "mnu_auto_return_to_map"),
      ]),
    ],
  ),
  
  (
    "castle_taken_native",mnf_disable_all_keys,
    "{s3} has fallen to your troops, and you now have full control of the {reg2?town:fort}. " +
    "{reg1? You may station troops here to defend it against enemies who may try to recapture it. Also, you should select now whether you will hold the {reg2?town:castle} yourself or give it to a faithful vassal...:}",# Only visible when castle is taken without being a vassal of a kingdom.
    "none",
    [
      (set_background_mesh, "mesh_pic_siege_victory"), #pic book
      (party_clear, "$g_encountered_party"),
      
      (try_begin),
        (eq, "$players_kingdom", "fac_player_supporters_faction"),
        (party_get_slot, ":new_owner", "$g_encountered_party", slot_town_lord),
        (neq, ":new_owner", "trp_player"),
        
        (try_for_range, ":unused", 0, 4),
          (call_script, "script_cf_reinforce_party", "$g_encountered_party"),
        (try_end),
      (try_end),
      (call_script, "script_lift_siege", "$g_encountered_party", 0),
      (assign, "$g_player_besiege_town", -1),
      
      (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, "trp_player"),
      #Reduce prosperity of the center by 5
      (call_script, "script_change_center_prosperity", "$g_encountered_party", -3),	#native= -5 #reduced because raid is avoided
      (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
      (val_min, reg0, 2),
      (party_set_slot, "$g_encountered_party", slot_party_food_store, reg0),
      (call_script, "script_change_troop_renown", "trp_player", 10),
      
      (assign, ":damage", 20),		#native: 20
      (try_begin),
        (is_between, "$g_encountered_party", towns_begin, towns_end),
        (assign, ":damage", 40),	#native: 40
      (try_end),
      (call_script, "script_faction_inflict_war_damage_on_faction", "$players_kingdom", "$g_encountered_party_faction", ":damage"),
      
      (try_begin),
        (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end),
        (neq, "$players_kingdom", "fac_player_supporters_faction"),
        (call_script, "script_give_center_to_faction", "$g_encountered_party", "$players_kingdom"),
        (call_script, "script_order_best_besieger_party_to_guard_center", "$g_encountered_party", "$players_kingdom"),
        (jump_to_menu, "mnu_castle_taken_2"),
      (else_try),
        (call_script, "script_give_center_to_faction", "$g_encountered_party", "fac_player_supporters_faction"),
        (call_script, "script_order_best_besieger_party_to_guard_center", "$g_encountered_party", "fac_player_supporters_faction"),
        (str_store_party_name, s3, "$g_encountered_party"),
        (assign, reg1, 0),
        (try_begin),
          (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
          (assign, reg1, 1),
        (try_end),
        #(party_set_slot, "$g_encountered_party", slot_town_lord, stl_unassigned),
      (try_end),
      (assign, reg2, 0),
      (try_begin),
        (is_between, "$g_encountered_party", towns_begin, towns_end),
        (assign, reg2, 1),
      (try_end),
    ],
    [
      
      ("continue",[],"Continue...",
        [
          (assign, "$auto_enter_town", "$g_encountered_party"),
          # (change_screen_return),
          (change_screen_map),
      ]),
    ],
  ),
  ####
  (
    "castle_taken_keepplunder",mnf_disable_all_keys,
    "{s3} has fallen to your troops, and you now have full control of the {reg2?town:fort}. Your troops run through the streets getting as much stuff as they can carry. The {reg2?town:fort} is plundered. You have collected {reg7} peningas. " +
    "{reg1? You may station troops here to defend it against enemies who may try to recapture it. Also, you should select now whether you will hold the {reg2?town:castle} yourself or give it to a faithful vassal...:}",# Only visible when castle is taken without being a vassal of a kingdom.
    "none",
    [
      (set_background_mesh, "mesh_pic_siege_victory"), #pic book
      (troop_clear_inventory, "trp_temp_troop"),
      (try_begin),
        (eq, "$plunder_battle_shown", 0),
        (assign, "$plunder_battle_shown", 1),
        (party_clear, "$g_encountered_party"),
        (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
        (modify_visitors_at_site, ":exterior_scene"),
        (reset_visitors),
        (assign, ":num_townsman", 15),
        (store_character_level, ":level", "trp_player"),
        (val_add, ":num_townsman", ":level"),
        (val_div, ":num_townsman", 10),
        (try_for_range, ":entry", 1, 11),	#thats entry 30-39
          (set_visitors, ":entry", "trp_townsman", ":num_townsman"),
        (end_try),
        (set_jump_mission,"mt_center_plunder"),
        (jump_to_scene, ":exterior_scene"),
        (change_screen_mission),
      (else_try),
        (eq, "$loot_screen_shown", 0),
        (assign, "$loot_screen_shown", 1),
        (assign, ":merchant_troop", 0),
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (party_get_slot, ":merchant_troop", "$g_encountered_party", slot_town_merchant),
        (else_try),
          # new begin (copy of mnu_village_loot_complete)
          (assign, ":bound_town", "$g_encountered_party"),
          (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
          (reset_item_probabilities,0),
          (assign, ":total_probability", 0),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_get_slot, ":cur_price", ":bound_town", ":cur_price_slot"),
            (gt, ":cur_price", 0),
            (call_script, "script_center_get_production", ":bound_town", ":cur_goods"),
            (assign, ":cur_probability", reg0),
            (call_script, "script_center_get_consumption", ":bound_town", ":cur_goods"),
            (val_div, reg0, 3),
            (val_sub, ":cur_probability", reg0),
            (val_mul, ":cur_probability", 4),
            (val_mul, ":cur_probability", average_price_factor),
            (val_div, ":cur_probability", ":cur_price"),
            (val_max,":cur_probability",0),
            #first only simulation
            #(set_item_probability_in_merchandise,":cur_goods",":cur_probability"),
            (val_add, ":total_probability", ":cur_probability"),
          (try_end),
          (reset_item_probabilities,0),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_get_slot, ":cur_price", ":bound_town", ":cur_price_slot"),
            (gt, ":cur_price", 0),
            (call_script, "script_center_get_production", ":bound_town", ":cur_goods"),
            (assign, ":cur_probability", reg0),
            (gt, ":cur_probability", 0),
            (call_script, "script_center_get_consumption", ":bound_town", ":cur_goods"),
            (val_div, reg0, 3),
            (val_sub, ":cur_probability", reg0),
            (val_mul, ":cur_probability", 4),
            (val_mul, ":cur_probability", average_price_factor),
            (val_div, ":cur_probability", ":cur_price"),
            (val_max, ":cur_probability", 0),
            (val_mul, ":cur_probability", num_merchandise_goods),
            (val_mul, ":cur_probability", 100),
            (val_div, ":cur_probability", ":total_probability"),
            (val_max, ":cur_probability", 5),
            (set_item_probability_in_merchandise,":cur_goods",":cur_probability"),
          (try_end),
          
          (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
          (val_min, ":prosperity", 30),
          (val_div, ":prosperity", 2),
          (val_max, ":prosperity", 3),
          (party_get_skill_level, ":looting_skill", "p_main_party", "skl_looting"),
          (val_add, ":prosperity", ":looting_skill"),
          (troop_add_merchandise,"trp_temp_troop",itp_type_goods,":prosperity"),
          (assign, ":merchant_troop", "trp_temp_troop"),
          #new end
        (end_try),
        (gt, ":merchant_troop", 0),
        (troop_sort_inventory, ":merchant_troop"),
        (change_screen_loot, ":merchant_troop"),
      (else_try),
        # All shown
        
        # 1.PLUNDER MONEY
        (party_get_slot, ":prosperity_money", "$g_encountered_party", slot_town_prosperity),
        (store_random_in_range, ":random_money", 3, 10),
        (val_mul, ":random_money", 8),
        (try_begin),
          (eq, "$loot_option", 3),
          (val_mul, ":random_money", 8),		# 500 - 1000 peningas
          (val_mul, ":prosperity_money", 60),		# 0 - 10000 peningas		# 100 - 6000
          (assign, ":prosperity_impact", -12),
          #(call_script, "script_change_center_prosperity", "$g_encountered_party", -12),
        (else_try),
          (display_message, "@{!}Error in mnu_castle_taken_plunder"),
        (end_try),
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (assign, reg2, 1),	# is town
          (call_script, "script_change_center_prosperity", "$g_encountered_party", ":prosperity_impact"),
          (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
          #more plunder in towns:
          (val_mul, ":random_money", 150),	#%
          (val_mul, ":prosperity_money", 120),	#%
          (store_add, ":plunder_money", ":prosperity_money", ":random_money"),
          (val_div, ":plunder_money", 100),	#%
        (else_try),
          (assign, reg2, 0),	# is fort
          (store_add, ":plunder_money", ":prosperity_money", ":random_money"),
          (store_div, ":half", ":prosperity_impact", 2),
          (call_script, "script_change_center_prosperity", "$g_encountered_party", ":half"), #go for immediate impact, fort recovers rather than eventual impact through villages
          # (try_for_range, ":cur_village", villages_begin, villages_end),
          # (party_get_slot, ":bound_center", ":cur_village", slot_village_bound_center),
          # (eq, "$g_encountered_party", ":bound_center"),
          # (store_div, ":half", ":prosperity_impact", 2),
          # (call_script, "script_change_center_prosperity", ":cur_village", ":half"),
          #				(party_get_slot, ":village_prosperity", ":cur_village", slot_town_prosperity),
          #				(party_set_slot, "$g_encountered_party", slot_town_prosperity, ":village_prosperity"),  #in VC castles only have one village
          # (try_end),
        (try_end),
        (party_get_skill_level, ":looting_skill", "p_main_party", "skl_looting"),
        #		(val_mul, ":looting_skill", 3),	#3% more money for each skill point
        (store_mul, ":skill_money", ":plunder_money", ":looting_skill"),
        (val_div, ":skill_money", 100),
        (val_add, ":plunder_money", ":skill_money"),
        (troop_add_gold, "trp_player", ":plunder_money"),
        (assign, reg7, ":plunder_money"),
        
        # 2.ICON
        (call_script, "script_change_party_icon_loot_state", "$g_encountered_party", 1),
        # (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire"),
        # (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire_smoke"),
        
        # 3.DEVASTATED TIME
        (party_set_slot, "$g_encountered_party", slot_party_looted_left_days, 7),
        (party_set_slot, "$g_encountered_party", slot_center_accumulated_rents, 0),
        
        # 4 Native part
        # 4.PUSH PLAYER ON SEA IF HE HAS SHIPS
        (try_begin),
          (party_slot_ge, "$current_town", slot_party_1_ship_type, 1),
          (call_script, "script_give_player_ships_from_party_to_party", "$current_town", "p_main_party"),
          (party_get_slot, ":curr_port", "$current_town", slot_party_port_party),
          (party_get_position, pos2, ":curr_port"),
          (party_set_position, "p_main_party", pos2),
          (call_script, "script_switch_to_water_consequences"),
        (end_try),
        (try_begin),
          (eq, "$players_kingdom", "fac_player_supporters_faction"),
          (party_get_slot, ":new_owner", "$g_encountered_party", slot_town_lord),
          (neq, ":new_owner", "trp_player"),
          
          (try_for_range, ":unused", 0, 2),
            (call_script, "script_cf_reinforce_party", "$g_encountered_party"),
          (try_end),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_div, reg0, 2),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, reg0),
        (try_end),
        
        (call_script, "script_lift_siege", "$g_encountered_party", 0),
        (assign, "$g_player_besiege_town", -1),
        
        (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, "trp_player"),
        #Reduce prosperity of the center by 5
        (call_script, "script_change_center_prosperity", "$g_encountered_party", -3),	#native= -5 #reduced because raid is avoided
        
        (call_script, "script_change_troop_renown", "trp_player", 10),
        (assign, ":damage", 20),		#native: 20
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (assign, ":damage", 40),	#native: 40
        (try_end),
        (call_script, "script_faction_inflict_war_damage_on_faction", "$players_kingdom", "$g_encountered_party_faction", ":damage"),
        
        (try_begin),
          (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end),
          (neq, "$players_kingdom", "fac_player_supporters_faction"),
          (call_script, "script_give_center_to_faction", "$g_encountered_party", "$players_kingdom"),
          (call_script, "script_order_best_besieger_party_to_guard_center", "$g_encountered_party", "$players_kingdom"),
          (jump_to_menu, "mnu_castle_taken_2"),
        (else_try),
          (call_script, "script_give_center_to_faction", "$g_encountered_party", "fac_player_supporters_faction"),
          (call_script, "script_order_best_besieger_party_to_guard_center", "$g_encountered_party", "fac_player_supporters_faction"),
          (str_store_party_name, s3, "$g_encountered_party"),
          (assign, reg1, 0),
          (try_begin),
            (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
            (assign, reg1, 1),
          (try_end),
          #(party_set_slot, "$g_encountered_party", slot_town_lord, stl_unassigned),
        (try_end),
        (assign, reg2, 0),
        (try_begin),
          (is_between, "$g_encountered_party", towns_begin, towns_end),
          (assign, reg2, 1),
        (try_end),
      (try_end),
    ],
    [
      
      ("continue",[],"Continue...",
        [
          (assign, "$auto_enter_town", "$g_encountered_party"),
          #       (change_screen_return),
          (change_screen_map),
      ]),
    ],
  ),
  
  
  (
    "castle_taken_2",mnf_disable_all_keys,
    "{s3} has fallen to your troops, and you now have full control of the fort. " +
    "It is time to send word to {s9} about your victory. {s5}",
    "none",
    [
      (set_background_mesh, "mesh_pic_siege_victory"), #pic book
      #siege warfare chief
      (assign, "$g_empieza_asedio", 0),
      (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
      (party_set_slot,"$g_encountered_party",slot_center_blockaded_time,0),
      (party_set_slot, "$g_encountered_party", slot_center_mantlets_placed, 0),
      (party_set_slot,"$g_encountered_party",slot_center_ladder_time,0),
      (party_set_slot,"$g_encountered_party",slot_center_latrines,0),
      (party_set_slot,"$g_encountered_party",slot_center_infiltration_type,0),
      
      (assign, "$g_siege_saneamiento", 0),
      (assign, "$g_traicion_interna", 0),
      (assign, "$g_infiltracion_interna", 0),
      (assign, "$g_campos_cercanos", 0),
      (assign, "$g_listos_para_asalto", 0),
      (assign, "$g_mantlets_1", 0),
      (assign, "$g_cabezas_dentro", 0), #event
      (assign, "$g_siege_method", 0),
      (assign, "$g_siege_sallied_out_once", 0),
      (assign, "$g_days_spent_starving", 0), #siege warfare, important, we use this in dialogs
      (assign, "$g_next_sally_at", 0), #sally more common siege warfare chief
      #siege warfare acaba
      
      (str_store_party_name, s3, "$g_encountered_party"),
      (str_clear, s5),
      (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s9, ":faction_leader"),
      (try_begin),
        (eq, "$player_has_homage", 0),
        (assign, reg8, 0),
        (try_begin),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (assign, reg8, 1),
        (try_end),
        (str_store_string, s5, "@However, since you are not a sworn {reg59?follower:man} of {s9}, there is no chance he would recognize you as the {reg59?lady:lord} of this {reg8?town:fort}."),
      (try_end),
    ],
    [
      ("castle_taken_claim",[(eq, "$player_has_homage", 1)],
        "Request that {s3} be awarded to you.",
        [
          (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, "trp_player"),
          (assign, "$g_castle_requested_by_player", "$current_town"),
          (assign, "$g_castle_requested_for_troop", "trp_player"),
          (assign, "$auto_enter_town", "$g_encountered_party"),
          (change_screen_return),
      ]),
      
      ("castle_taken_claim_2",[
          (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
          (is_between, ":spouse", active_npcs_begin, active_npcs_end),
          (troop_slot_eq, ":spouse", slot_troop_occupation, slto_kingdom_hero),
          (store_faction_of_troop, ":spouse_faction", ":spouse"),
          (eq, ":spouse_faction", "$players_kingdom"),
        ],
        "Request that {s3} be awarded to your {reg59?husband:wife}.",
        [
          (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, "trp_player"),
          (assign, "$g_castle_requested_by_player", "$current_town"),
          (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
          (assign, "$g_castle_requested_for_troop", ":spouse"),
          (assign, "$auto_enter_town", "$g_encountered_party"),
          (call_script, "script_cf_reinforce_party", "$g_encountered_party"),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_div, reg0, 2),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, reg0),
          (change_screen_return),
      ]),
      
      
      
      ("castle_taken_no_claim",[],"Ask for no rewards.",
        [
          (party_set_slot, "$g_encountered_party", slot_center_last_taken_by_troop, -1),
          (assign, "$auto_enter_town", "$g_encountered_party"),
          (try_for_range, ":unused", 0, 2),
            (call_script, "script_cf_reinforce_party", "$g_encountered_party"),
          (try_end),
          (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
          (val_div, reg0, 2),
          (party_set_slot, "$g_encountered_party", slot_party_food_store, reg0),
          (change_screen_return),
          #        (jump_to_menu, "mnu_town"),
      ]),
    ],
  ),
  
  ###saqueo center, usado en religion monasterios y otros.
  (
    "saqueo_loot_continue",0,
    "This settlement has not recovered from being looted by you.",
    "none",
    [
      (set_background_mesh, "mesh_pic_looted_village"),
    ],
    [
      ("continue",[],"Continue...",[(change_screen_return)]),
    ],
  ),
  ####saquear acaba chief
  
  # (
    # "requested_castle_granted_to_player",0,
    # "You receive a message from your liege, {s3}.^^" +
    # "{reg4?She:He} has decided to grant {s2}{reg3? and the nearby village of {s4}:} to you, with all due incomes and titles, to hold in {reg4?her:his} name for as long as you maintain your oath of homage.",
    # "none",
    # [
      # (set_background_mesh, "mesh_pic_messenger"),
      # (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      # (str_store_troop_name, s3, ":faction_leader"),
      # (str_store_party_name, s2, "$g_center_to_give_to_player"),
      # (try_begin),
        # (party_slot_eq, "$g_center_to_give_to_player", slot_party_type, spt_castle),
        # (assign, reg3, 1),
        # (try_for_range, ":cur_village", villages_begin, villages_end),
          # (party_slot_eq, ":cur_village", slot_village_bound_center, "$g_center_to_give_to_player"),
          # (str_store_party_name, s4, ":cur_village"),
        # (try_end),
      # (else_try),
        # (assign, reg3, 0),
      # (try_end),
      # (troop_get_type, reg4, ":faction_leader"),
      # (val_mod, reg4, 2),
      
    # ],
    # [
      # ("continue",[],"Continue.",
        # [
          # (call_script, "script_give_center_to_lord", "$g_center_to_give_to_player", "trp_player", 0),
          # (jump_to_menu, "mnu_give_center_to_player_2"),
        # ],
      # ),
    # ]
  # ),
  
  # (
    # "requested_castle_granted_to_player_husband", 0,
    # "You receive a message from your liege, {s3}.^^" +
    # "{reg4?She:He} has decided to grant {s2}{reg3? and the nearby village of {s4}:} to your husband, {s7}.",
    # "none",
    # [
      # (set_background_mesh, "mesh_pic_messenger"),
      # (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      # (str_store_troop_name, s3, ":faction_leader"),
      # (str_store_party_name, s2, "$g_center_to_give_to_player"),
      # (try_begin),
        # (party_slot_eq, "$g_center_to_give_to_player", slot_party_type, spt_castle),
        # (assign, reg3, 1),
        # (try_for_range, ":cur_village", villages_begin, villages_end),
          # (party_slot_eq, ":cur_village", slot_village_bound_center, "$g_center_to_give_to_player"),
          # (str_store_party_name, s4, ":cur_village"),
        # (try_end),
      # (else_try),
        # (assign, reg3, 0),
      # (try_end),
      # (troop_get_type, reg4, ":faction_leader"),
      # (val_mod, reg4, 2),
      
      # (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
      # (str_store_troop_name, s11, ":spouse"),
      # (str_store_string, s7, "str_to_your_husband_s11"),
    # ],
    # [
      # ("continue",[],"Continue.",
        # [
          # (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
          # (call_script, "script_give_center_to_lord", "$g_center_to_give_to_player", ":spouse", 0),
        # ],
      # ),
    # ]
  # ),
  
  (
    "requested_castle_granted_to_another",0,
    "You receive a message from your monarch, {s3}.^^" +
    "'I was most pleased to hear of your valiant efforts in the capture of {s2}. Your victory has gladdened all our hearts. " +
    "You also requested me to give you ownership of the castle, but that is a favour that I fear I cannot grant, " +
    "as you already hold significant estates in my realm. " +
    "Instead I have sent you {reg6} peningas to cover the expenses of your campaign, but {s2} I give to {s5}.' " +
    "",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s3, ":faction_leader"),
      (str_store_party_name, s2, "$g_center_to_give_to_player"),
      (party_get_slot, ":new_owner", "$g_center_to_give_to_player", slot_town_lord),
      (str_store_troop_name, s5, ":new_owner"),
      (assign, reg6, 900),
      
      (assign, "$g_castle_requested_by_player", -1),
      (assign, "$g_castle_requested_for_troop", -1),
      
    ],
    [
      ("accept_decision",[],"Accept the decision.",
        [
          (call_script, "script_troop_add_gold", "trp_player", reg6),
          (change_screen_return),
      ]),
      
      ("leave_faction",[],"You have been wronged! Renounce your oath to your liege! ",
        [
          (jump_to_menu, "mnu_leave_faction"),
          (call_script, "script_troop_add_gold", "trp_player", reg6),
      ]),
    ],
  ),
  
  
  (
    "requested_castle_granted_to_another_female",0,
    "You receive a message from your monarch, {s3}.^^" +
    "'I was most pleased to hear of your valiant efforts in the capture of {s2}. Your victory has gladdened all our hearts. " +
    "You also requested me to give ownership of the castle to your husband, but that is a favour that I fear I cannot grant, " +
    "as he already holds significant estates in my realm. " +
    "Instead I have sent you {reg6} peningas to cover the expenses of your campaign, but {s2} I give to {s5}.' " +
    "",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s3, ":faction_leader"),
      (str_store_party_name, s2, "$g_center_to_give_to_player"),
      (party_get_slot, ":new_owner", "$g_center_to_give_to_player", slot_town_lord),
      (str_store_troop_name, s5, ":new_owner"),
      (assign, reg6, 900),
      
      (assign, "$g_castle_requested_by_player", -1),
      (assign, "$g_castle_requested_for_troop", -1),
    ],
    
    [
      ("accept_decision2",[],"Accept the decision.",
        [
          (call_script, "script_troop_add_gold", "trp_player", reg6),
          (change_screen_return),
      ]),
    ],
  ),
  
  
  
  
  (
    "leave_faction",0,
    "Renouncing your oath is a grave act. Your lord may condemn you and confiscate your lands and holdings. " +
    "However, if you return them on your own free will, he may let the betrayal go unpunished.",
    "none",
    [(set_background_mesh, "mesh_pic_leave_faction"),
    ],
    [
      ("leave_faction_give_back", [], "Renounce your oath and give up your holdings.",
        [
          #Troop commentary changes begin
          #        (call_script, "script_add_log_entry", logent_renounced_allegiance,   "trp_player",  -1, "$g_talk_troop", "$g_talk_troop_faction"),
          #Troop commentary changes end
          (call_script, "script_player_leave_faction", 1), #1 means give back fiefs
          (change_screen_return),
      ]),
      ("leave_faction_hold", [
          (neq, "$campaign_type", camp_storyline),
          (str_store_party_name, s2, "$g_center_to_give_to_player"),
        ], "Renounce your oath and rule your lands, including {s2}, in your own name.",
        [
          (call_script, "script_give_center_to_lord", "$g_center_to_give_to_player", "trp_player", 0), #this should activate the player faction (it does not)
          (call_script, "script_player_leave_faction", 0), #"1" would mean give back fiefs
          (call_script, "script_activate_player_faction", "trp_player"), #Activating player faction should now work
          (change_screen_return),
      ]),
      ("leave_faction_cancel", [], "Remain loyal and accept the decision.",
        [
          (change_screen_return),
      ]),
    ],
  ),
  
  # (
    # "give_center_to_player",0,
    # "Your lord offers to extend your fiefs! " +
    # "{s1} sends the word that he is willing to grant {s2} to you in payment for your loyal service, " +
    # "adding it to your holdings. What is your answer?",
    # "none",
    # [(set_background_mesh, "mesh_pic_messenger"),
      # (store_faction_of_party, ":center_faction", "$g_center_to_give_to_player"),
      # (faction_get_slot, ":faction_leader", ":center_faction", slot_faction_leader),
      # (str_store_troop_name, s1, ":faction_leader"),
      # (str_store_party_name, s2, "$g_center_to_give_to_player"),
    # ],
    # [
      # ("give_center_to_player_accept",[],"Accept the offer.",
        # [(call_script, "script_give_center_to_lord", "$g_center_to_give_to_player", "trp_player", 0),
          # (jump_to_menu, "mnu_give_center_to_player_2"),
      # ]),
      # ("give_center_to_player_reject",[],"Reject the offer. You have no interest in holding {s2}.",
        # [(party_set_slot, "$g_center_to_give_to_player", slot_town_lord, stl_rejected_by_player),
          # (change_screen_return),
      # ]),
    # ],
  # ),
  
  (
    "give_center_to_player_2",0,
    "With a brief ceremony, you are officially confirmed as the new lord of {s2}{reg3? and its bound village {s4}:}. " +
    "{reg3?They:It} will make a fine part of your fiefdom. " +
    "You can now claim the rents and revenues from your personal estates there, draft soldiers from the populace, " +
    "and manage the lands as you see fit. " +
    "However, you are also expected to defend your fief and your people from harm, " +
    "as well as maintaining the rule of law and order.",
    "none",
    [      (set_background_mesh, "mesh_festin"), #pic book
      
      (str_store_party_name, s2, "$g_center_to_give_to_player"),
      (assign, reg3, 0),
      (try_begin),
        (party_slot_eq, "$g_center_to_give_to_player", slot_party_type, spt_castle),
        (try_for_range, ":cur_village", villages_begin, villages_end),
          (party_slot_eq, ":cur_village", slot_village_bound_center, "$g_center_to_give_to_player"),
          (str_store_party_name, s4, ":cur_village"),
          (assign, reg3, 1),
        (try_end),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ],
  ),
  
  
  (
    "oath_fulfilled",0,
    "You had a contract with {s1} to serve him for a certain duration. " +
    "Your contract has now expired. What will you do?",
    "none",
    [
      (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s1, ":faction_leader"),
      (set_background_mesh, "mesh_pic_payment1"), #pic book
    ],
    [
      ("renew_oath",[(faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
          (str_store_troop_name, s1, ":faction_leader")], "Renew your contract with {s1} for another month.",
        [
          (store_current_day, ":cur_day"),
          (store_add, "$mercenary_service_next_renew_day", ":cur_day", 30),
          (change_screen_return),
      ]),
      ("dont_renew_oath",[],"Become free of your bond.",
        [
          (call_script, "script_player_leave_faction", 1), #1 means give back fiefs
          (change_screen_return),
      ]),
    ]
  ),
  
  
  ##  (
  ##    "castle_garrison_stationed",0,
  ###    "The rest of the castle garrison recognizes that their situation is hopeless and surrenders. {s1} is at your mercy now. What do you want to do with this castle?",
  ##    "_",
  ##    "none",
  ##    [
  ##        (jump_to_menu, "mnu_town"),
  ##    ],
  ##    [],
  ##  ),
  
  ##  (
  ##    "castle_choose_captain",0,
  ##    "You will need to assign one of your companions as the castellan. Who will it be?",
  ##    "none",
  ##    [
  ##        (try_for_range, ":slot_no", 0, 20),
  ##          (troop_set_slot, "trp_temp_troop", ":slot_no", 0),
  ##        (try_end),
  ##        (assign, ":num_captains", 0),
  ##        (party_clear, "p_temp_party"),
  ##        (party_get_num_companion_stacks, ":num_stacks", "p_main_party"),
  ##        (try_for_range, ":i_s", 1,":num_stacks"),
  ##          (party_stack_get_troop_id, ":companion","p_main_party", ":i_s"),
  ##          (troop_slot_eq, ":companion", slot_troop_occupation, slto_player_companion),
  ##          (troop_set_slot, "trp_temp_troop", ":num_captains", ":companion"),
  ##        (try_end),
  ##    ],
  ##    [
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 0),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 0),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 1),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 1),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 2),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 2),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 3),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 3),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 4),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 4),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 5),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 5),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 6),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 6),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 7),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 7),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 8),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 8),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 9),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 9),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 10),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 10),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 11),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 11),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 12),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 12),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 13),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 13),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 14),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 14),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##      ("castellan_candidate",  [(troop_get_slot, ":captain", "trp_temp_troop", 15),(gt,":captain",0),(str_store_troop_name, s5,":captain")],
  ##         "{!}{s5}",    [(troop_get_slot, "$selected_castellan", "trp_temp_troop", 15),(jump_to_menu,"mnu_castle_captain_chosen")]),
  ##
  ##      ("cancel",[],
  ##         "Cancel...",
  ##         [(jump_to_menu, "mnu_town")]),
  ##    ],
  ##  ),
  ##  (
  ##    "castle_captain_chosen",0,
  ##    "h this castle?",
  ##    "none",
  ##    [
  ##        (party_add_leader, "$g_encountered_party",  "$selected_castellan"),
  ##        (party_remove_members, "p_main_party", "$selected_castellan",1),
  ##        (party_set_slot, "$g_encountered_party", slot_town_lord, "trp_player"),
  ##        (party_set_faction, "$g_encountered_party", "fac_player_supporters_faction"),
  ##        (try_for_range, ":slot_no", 0, 20), #clear temp troop slots just in case
  ##          (troop_set_slot, "trp_temp_troop", ":slot_no", 0),
  ##        (try_end),
  ##        (jump_to_menu, "mnu_town"),
  ##        (change_screen_exchange_members,0),
  ##    ],
  ##    [],
  ##  ),
  
  ##  (
  ##    "under_siege_attacked_continue",0,
  ##    "Nothing to see here.",
  ##    "none",
  ##    [
  ##        (assign, "$g_enemy_party", "$g_encountered_party_2"),
  ##        (assign, "$g_ally_party", "$g_encountered_party"),
  ##        (party_set_next_battle_simulation_time, "$g_encountered_party", 0),
  ##        (call_script, "script_encounter_calculate_fit"),
  ##        (try_begin),
  ##          (call_script, "script_party_count_fit_regulars", "p_collective_enemy"),
  ##          (assign, ":num_enemy_regulars_remaining", reg(0)),
  ##          (assign, ":enemy_finished",0),
  ##          (try_begin),
  ##            (eq, "$g_battle_result", 1),
  ##            (eq, ":num_enemy_regulars_remaining", 0), #battle won
  ##            (assign, ":enemy_finished",1),
  ##          (else_try),
  ##            (eq, "$g_engaged_enemy", 1),
  ##            (le, "$g_enemy_fit_for_battle",0),
  ##            (ge, "$g_friend_fit_for_battle",1),
  ##            (assign, ":enemy_finished",1),
  ##          (try_end),
  ##          (this_or_next|eq, ":enemy_finished",1),
  ##          (eq,"$g_enemy_surrenders",1),
  ####          (assign, "$g_center_under_siege_battle", 0),
  ##          (assign, "$g_next_menu", -1),
  ##          (jump_to_menu, "mnu_total_victory"),
  ##        (else_try),
  ##          (assign, ":battle_lost", 0),
  ##          (try_begin),
  ##            (eq, "$g_battle_result", -1),
  ##            (assign, ":battle_lost",1),
  ##          (try_end),
  ##          (this_or_next|eq, ":battle_lost",1),
  ##          (eq,"$g_player_surrenders",1),
  ####          (assign, "$g_center_under_siege_battle", 0),
  ##          (assign, "$g_next_menu", "mnu_captivity_start_under_siege_defeat"),
  ##          (jump_to_menu, "mnu_total_defeat"),
  ##        (else_try),
  ##    # Ordinary victory.
  ##          (try_begin),
  ##          #check whether enemy retreats
  ##            (eq, "$g_battle_result", 1),
  ##            (store_mul, ":min_enemy_str", "$g_enemy_fit_for_battle", 2),
  ##            (lt, ":min_enemy_str", "$g_friend_fit_for_battle"),
  ##            (party_set_slot, "$g_enemy_party", slot_party_retreat_flag, 1),
  ##
  ##            (try_for_range, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end),
  ##              (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
  ##              (troop_slot_eq, ":troop_no", slot_troop_is_prisoner, 0),
  ##              (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
  ##              (gt, ":party_no", 0),
  ##              (party_slot_eq, ":party_no", slot_party_ai_state, spai_besieging_center),
  ##              (party_slot_eq, ":party_no", slot_party_ai_object, "$g_encountered_party"),
  ##              (party_slot_eq, ":party_no", slot_party_ai_substate, 1),
  ##              (call_script, "script_party_set_ai_state", ":party_no", spai_undefined, -1),
  ##              (call_script, "script_party_set_ai_state", ":party_no", spai_besieging_center, ":center_no"),
  ##            (try_end),
  ##            (display_message, "@{!}TODO: Enemy retreated. The assault has ended, siege continues."),
  ##            (change_screen_return),
  ##          (try_end),
  ####          (assign, "$g_center_under_siege_battle", 0),
  ##        (try_end),
  ##        ],
  ##    [
  ##    ]
  ##  ),
  
  
  (
    "siege_started_defender",0,
    "{s1} is launching an assault against the walls of {s2}. You have {reg10} troops fit for battle against the enemy's {reg11}. You decide to...",
    "none",
    [
      (set_background_mesh, "mesh_siegeassault"), #pic book
      
      (select_enemy,1),
      (assign, "$g_enemy_party", "$g_encountered_party_2"),
      (assign, "$g_ally_party", "$g_encountered_party"),
      (str_store_party_name, 1,"$g_enemy_party"),
      (str_store_party_name, 2,"$g_ally_party"),
      
      (try_begin),
        (eq, "$g_siege_first_encounter", 1),
        (call_script, "script_let_nearby_parties_join_current_battle", 0, 1),
      (try_end),
      
      (call_script, "script_encounter_calculate_fit"),
      
      (try_begin),
        (eq, "$g_siege_first_encounter", 1),
        (call_script, "script_encounter_init_variables"),
      (try_end),
      
      (try_begin),
        (eq, "$g_siege_first_encounter", 0),
        (try_begin),
          (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
          (assign, ":num_enemy_regulars_remaining", reg0),
          (call_script, "script_party_count_members_with_full_health", "p_collective_friends"),
          (assign, ":num_ally_regulars_remaining", reg0),
          (assign, ":enemy_finished", 0),
          (try_begin),
            (eq, "$g_battle_result", 1),
            #              (eq, ":num_enemy_regulars_remaining", 0), #battle won (sdsd = TODO : compare with num_routed_us)
            (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
            (le, ":num_enemy_regulars_remaining",  "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
            (assign, ":enemy_finished",1),
          (else_try),
            (eq, "$g_engaged_enemy", 1),
            #              (le, "$g_enemy_fit_for_battle",0),
            (this_or_next|le, "$g_enemy_fit_for_battle", 0),
            (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
            (ge, "$g_friend_fit_for_battle",1),
            (assign, ":enemy_finished",1),
          (try_end),
          (this_or_next|eq, ":enemy_finished",1),
          (eq,"$g_enemy_surrenders",1),
          (assign, "$g_next_menu", -1),
          (jump_to_menu, "mnu_total_victory"),
        (else_try),
          (assign, ":battle_lost", 0),
          (try_begin),
            (this_or_next|eq, "$g_battle_result", -1),
            (troop_is_wounded,  "trp_player"),
            (this_or_next|eq, ":num_ally_regulars_remaining", 0), #(sdsd = TODO : compare with num_routed_allies)
            (le, ":num_ally_regulars_remaining",  "$num_routed_allies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
            (assign, ":battle_lost",1),
          (try_end),
          (this_or_next|eq, ":battle_lost",1),
          (eq,"$g_player_surrenders",1),
          (assign, "$g_next_menu", "mnu_captivity_start_under_siege_defeat"),
          (jump_to_menu, "mnu_total_defeat"),
        (else_try),
          # Ordinary victory/defeat.
          (assign, ":attackers_retreat", 0),
          (try_begin),
            #check whether enemy retreats
            (eq, "$g_battle_result", 1),
            ##            (store_mul, ":min_enemy_str", "$g_enemy_fit_for_battle", 2),
            ##            (lt, ":min_enemy_str", "$g_friend_fit_for_battle"),
            (assign, ":attackers_retreat", 1),
          (else_try),
            (eq, "$g_battle_result", 0),
            (store_div, ":min_enemy_str", "$g_enemy_fit_for_battle", 3),
            (lt, ":min_enemy_str", "$g_friend_fit_for_battle"),
            (assign, ":attackers_retreat", 1),
          (else_try),
            (store_random_in_range, ":random_no", 0, 100),
            (store_mul, ":num_ally_regulars_remaining_multiplied", ":num_ally_regulars_remaining", 13),
            (val_div, ":num_ally_regulars_remaining_multiplied", 10),
            (ge, ":num_ally_regulars_remaining_multiplied", ":num_enemy_regulars_remaining"),
            (lt, ":random_no", 10),
            (neq, "$new_encounter", 1),
            (assign, ":attackers_retreat", 1),
          (try_end),
          (try_begin),
            (eq, ":attackers_retreat", 1),
            (party_get_slot, ":siege_hardness", "$g_encountered_party", slot_center_siege_hardness),
            (val_add, ":siege_hardness", 100),
            (party_set_slot, "$g_encountered_party", slot_center_siege_hardness, ":siege_hardness"),
            (party_set_slot, "$g_enemy_party", slot_party_retreat_flag, 1),
            
            (try_for_range, ":troop_no", active_npcs_begin, active_npcs_end),
              (troop_slot_eq, ":troop_no", slot_troop_occupation, slto_kingdom_hero),
              #(troop_slot_eq, ":troop_no", slot_troop_is_prisoner, 0),
              (neg|troop_slot_ge, ":troop_no", slot_troop_prisoner_of_party, 0),
              (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party),
              (gt, ":party_no", 0),
              (party_slot_eq, ":party_no", slot_party_ai_state, spai_besieging_center),
              (party_slot_eq, ":party_no", slot_party_ai_object, "$g_encountered_party"),
              (party_slot_eq, ":party_no", slot_party_ai_substate, 1),
              (call_script, "script_party_set_ai_state", ":party_no", spai_undefined, -1),
              (call_script, "script_party_set_ai_state", ":party_no", spai_besieging_center, "$g_encountered_party"),
            (try_end),
            (display_message, "@The enemy has been forced to retreat. The assault is over, but the siege continues."),
            (assign, "$g_battle_simulation_cancel_for_party", "$g_encountered_party"),
            (leave_encounter),
            (change_screen_return),
            (assign, "$g_battle_simulation_auto_enter_town_after_battle", "$g_encountered_party"),
          (try_end),
        (try_end),
      (try_end),
      (assign, "$g_siege_first_encounter", 0),
      (assign, "$new_encounter", 0),
    ],
    [
      ("siege_defender_join_battle",
        [
          (neg|troop_is_wounded, "trp_player"),
        ],
        "Join the battle.",[
          (party_set_next_battle_simulation_time, "$g_encountered_party", -1),
          (assign, "$g_battle_result", 0),
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_town_walls),
          (else_try),
            (party_get_slot, ":battle_scene", "$g_encountered_party", slot_castle_exterior),
          (try_end),
          (call_script, "script_calculate_battle_advantage"),
          (val_mul, reg0, 2),
          (val_div, reg0, 3), #scale down the advantage a bit.
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_siege_with_belfry, 1),
            (set_jump_mission,"mt_castle_attack_walls_belfry"),
          (else_try),
            (set_jump_mission,"mt_castle_attack_walls_ladder"),
          (try_end),
          (jump_to_scene,":battle_scene"),
          (assign, "$g_next_menu", "mnu_siege_started_defender"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission)]),
      ("siege_defender_troops_join_battle",[(call_script, "script_party_count_members_with_full_health", "p_main_party"),
          (this_or_next|troop_is_wounded,  "trp_player"),
          (ge, reg0, 3)],
        "Order your men to join the battle without you.",[
          (party_set_next_battle_simulation_time, "$g_encountered_party", -1),
          (select_enemy,1),
          (assign,"$g_enemy_party","$g_encountered_party_2"),
          (assign,"$g_ally_party","$g_encountered_party"),
          (assign,"$g_siege_join", 1),
          (jump_to_menu,"mnu_siege_join_defense")]),
      
      ##       ("siege_defender_surrender",[ #siege Warfare
      ##                                    (party_slot_eq, "$g_encountered_party", slot_town_lord, "trp_player"),
      ##                                     ],
      ##                                    "Surrender the place in return they let you go out with your troops.",[(assign, "$g_player_surrenders", 1),
      ##                                    (jump_to_menu,"mnu_siege_started_defender")]),
    ]
  ),
  
  (
    "siege_join_defense",mnf_disable_all_keys,
    "{s4}^^Your casualties: {s8}^^Allies' casualties: {s9}^^Enemy casualties: {s10}",
    "none",
    [ (set_background_mesh, "mesh_siegeassault"), #pic book
      (try_begin),
        (eq, "$g_siege_join", 0),
        (call_script, "script_simulate_battle_with_parties", 6, "$g_enemy_party", 2, "$g_ally_party", 1), #player party not involved, takes no damage
      (else_try),
        (call_script, "script_simulate_battle_with_parties", 6, "$g_enemy_party", 2, "$g_ally_party", 0),
      (try_end),
      
      (try_begin),
        (call_script, "script_party_count_members_with_full_health","p_main_party"),
        (le, reg0, 0),
        (str_store_string, s4, "str_siege_defender_order_attack_failure"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health","p_collective_enemy"),
        (le, reg0, 0),
        (assign, "$g_battle_result", 1),
        (str_store_string, s4, "str_siege_defender_order_attack_success"),
      (else_try),
        (str_store_string, s4, "str_siege_defender_order_attack_continue"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[
          (jump_to_menu,"mnu_siege_started_defender"),
      ]),
    ]
  ),
  
  (
    "enter_your_own_castle",0,
    "{!}{s10}",
    "none",
    [ (call_script, "script_set_town_picture"),
      (try_begin),
        (neg|is_between, "$players_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
        (faction_get_slot, ":faction_leader", "fac_player_supporters_faction", slot_faction_leader),
        (eq, ":faction_leader", "trp_player"),
        (str_store_string, s10, "@As you approach, you are spotted by the fort guards, who welcome you and open the gates for their {reg59?queen:king}."),
      (else_try),
        (str_store_string, s10, "@As you approach, you are spotted by the fort guards, who welcome you and open the gates for their {reg59?lady:lord}."),
      (try_end),
      
      (str_store_party_name, s2, "$current_town"),
    ],
    [
      ("continue",[],"Continue...",
        [ (jump_to_menu,"mnu_town"),
      ]),
    ],
  ),
  
  (
    "village",mnf_enable_hot_keys,
    "{s10} {s12}^{s11}^{s6}{s7}^^{s15}",
    "none",
    [
      (assign, ":block_vc_menu", 0),	#vc_menu
      
      (assign, "$current_town", "$g_encountered_party"),
      (call_script, "script_update_center_recon_notes", "$current_town"),
      
      (assign, "$g_defending_against_siege", 0), #required for bandit check
      (assign, "$g_battle_result", 0),
      (assign, "$qst_collect_taxes_currently_collecting", 0),
      (assign, "$qst_train_peasants_against_bandits_currently_training", 0),
      
      (try_begin), #chief doccinga coastal assault mainquest
        (eq, "$current_town", "p_village_150"),
        (check_quest_active,"qst_doccinga_assault"),
        (quest_slot_eq,"qst_doccinga_assault",slot_quest_current_state, 0), #status 0
        (call_script, "script_village_set_state",  "$current_town", svs_looted), #loteada, danada durante un tiempo chief
        (assign, ":block_vc_menu", 1),	#vc_menu
        (jump_to_menu, "mnu_doccinga_c_assault"),
      (try_end),
      
      
      (try_begin),
        (gt, "$auto_enter_menu_in_center", 0),
        (jump_to_menu, "$auto_enter_menu_in_center"),
        (assign, ":block_vc_menu", 1),	#vc_menu
        (assign, "$auto_enter_menu_in_center", 0),
      (try_end),
      
      (try_begin),
        (neq, "$g_player_raiding_village",  "$current_town"),
        (assign, "$g_player_raiding_village", 0),
      (else_try),
        (jump_to_menu, "mnu_village_loot_continue"),
        (assign, ":block_vc_menu", 1),	#vc_menu
      (try_end),
      
      (try_begin),#Fix for collecting taxes
        (eq, "$g_town_visit_after_rest", 1),
        (assign, "$g_town_visit_after_rest", 0),
      (try_end),
      
      (str_store_party_name,s2, "$current_town"),
      (party_get_slot, ":center_lord", "$current_town", slot_town_lord),
      (store_faction_of_party, ":center_faction", "$current_town"),
      (str_store_faction_name,s9,":center_faction"),
      
      #Religion chief fe faith empieza
      #chief fe faith empieza cristianismo
      (try_begin),
        (neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
        (neg|party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
        (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
        (eq, "$g_player_faith", 1), #player es cristiano
        (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
        (try_begin),
          # (party_slot_eq, "$current_town", slot_center_religion, 2),#pagan
          # (str_store_string, s15, "@Pagan Village: Christians aren't welcome here."),
          # (else_try),
          (lt, ":faith", 30),
          (str_store_string, s15, "@^Christians aren't welcome here."),
        (else_try),
          (is_between, ":faith", 30,50),
          (str_store_string, s15, "@^Christians are accepted here."),
        (else_try),
          (is_between, ":faith", 50,65),
          (str_store_string, s15, "@^Christians are in the majority here."),
        (else_try),
          (is_between, ":faith", 65,80),
          (str_store_string, s15, "@^Christians are dominant here."),
        (else_try),
          (ge, ":faith", 80),
          (str_store_string, s15, "@^This village is a bastion of your faith."),
        (else_try),
          (str_store_string, s15, "@^Rumor has it that Christian faith is nothing more than a veil, and the population continues to worship pagan gods..."),
        (try_end),
      (try_end),
      #chief fe faith empieza paganismo
      (try_begin),
        (neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
        (neg|party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
        (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
        (eq, "$g_player_faith", 2), #player is pagan
        (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
        (store_sub, ":p_faith", 100, ":faith"),
        (try_begin),
          # (party_slot_eq, "$current_town", slot_center_religion, 1),
          # (str_store_string, s15, "@Christian Village: Pagans are hated by the population."),
          # (else_try),
          (lt, ":p_faith", 30),
          (str_store_string, s15, "@^Pagans aren't welcome here."),
        (else_try),
          (is_between, ":p_faith", 30,50),
          (str_store_string, s15, "@^Pagans are accepted here."),
        (else_try),
          (is_between, ":p_faith", 50, 65),
          (str_store_string, s15, "@^Pagans are in the majority here."),
        (else_try),
          (is_between, ":p_faith", 65, 80),
          (str_store_string, s15, "@^Pagans are dominant here."),
        (else_try),
          (ge, ":p_faith", 80),
          (str_store_string, s15, "@^This village is a bastion of your faith."),
        (else_try),
          (str_store_string, s15, "@^Rumor has it that old pagan gods are being forgotten in favour of Christendom."),
        (try_end),
      (try_end),
      #Religion end chief
      
      (try_begin),
        (ge, ":center_lord", 0),
        (str_store_troop_name,s8,":center_lord"),
        (str_store_string,s7,"@{s8} of the {s9}"),
      (try_end),
      
      (str_clear, s10),
      (str_clear, s12),
      
      (try_begin),
        (neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
        (str_store_string, s60, s2),
        
        (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
        (try_begin),
          (eq, "$cheat_mode", 1),
          (assign, reg4, ":prosperity",),
          (display_message, "@{!}Prosperity: {reg4}"),
        (try_end),
        
        #(val_add, ":prosperity", 5),
        (store_div, ":str_id", ":prosperity", 10),
        (val_min, ":str_id", 9),
        (val_add, ":str_id", "str_village_prosperity_0"),
        (str_store_string, s10, ":str_id"),
        
        
        (store_div, ":str_id", ":prosperity", 20),
        (val_min, ":str_id", 4),
        # (try_begin),
        # (is_between, "$current_town", "p_village_1", villages_end),
        # (val_add, ":str_id", "str_oasis_village_alt_prosperity_0"),
        # (else_try),
        (val_add, ":str_id", "str_village_alt_prosperity_0"),
        # (try_end),
        
        (str_store_string, s12, ":str_id"),
      (try_end),
      
      (str_clear, s11),
      (try_begin),
        (party_slot_eq, "$current_town", slot_village_state, svs_looted),
      (else_try),
        (eq, ":center_lord", "trp_player"),
        (str_store_string,s11,"@This village and the surrounding lands belong to you."),
      (else_try),
        (ge, ":center_lord", 0),
        (str_store_string,s11,"@You remember that this village and the surrounding lands belong to {s7}."),
      (else_try),
        (str_store_string,s11,"@These lands belong to no one."),
      (try_end),
      
      (str_clear, s7),
      (try_begin),
        (neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
        (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
        (call_script, "script_describe_center_relation_to_s3", ":center_relation"),
        (assign, reg9, ":center_relation"),
        (str_store_string, s7, "@{!} {s3} ({reg9})."),
      (try_end),
      (str_clear, s6),
      (try_begin),
        (party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
        (assign, ":block_vc_menu", 1),	#vc_menu
        (party_get_slot, ":bandit_troop", "$current_town", slot_village_infested_by_bandits),
        (store_character_level, ":player_level", "trp_player"),
        (store_add, "$qst_eliminate_bandits_infesting_village_num_bandits", ":player_level", 10),
        (val_mul, "$qst_eliminate_bandits_infesting_village_num_bandits", 12),
        (val_div, "$qst_eliminate_bandits_infesting_village_num_bandits", 10),
        (store_random_in_range, "$qst_eliminate_bandits_infesting_village_num_villagers", 25, 30),
        (assign, reg8, "$qst_eliminate_bandits_infesting_village_num_bandits"),
        (str_store_troop_name_by_count, s35, ":bandit_troop", "$qst_eliminate_bandits_infesting_village_num_bandits"),
        (str_store_string, s6, "@The village is infested by {reg8} {s35}."),
        (str_clear, s15),
        (assign, "$g_enemy_party", -1), #new, no known enemy party while saving village from bandits dfdf
        (assign, "$g_ally_party", -1), #new, no known enemy party while saving village from bandits dfdf
        
        (try_begin),
          (eq, ":bandit_troop", "trp_forest_bandit"),
          (set_background_mesh, "mesh_pic_forest_bandits"),
        (else_try),
          (eq, ":bandit_troop", "trp_steppe_bandit"),
          (set_background_mesh, "mesh_pic_sea_raiders"),
        (else_try),
          (eq, ":bandit_troop", "trp_taiga_bandit"),
          (set_background_mesh, "mesh_pic_sea_raiders"),
        (else_try),
          (eq, ":bandit_troop", "trp_mountain_bandit"),
          (set_background_mesh, "mesh_pic_mountain_bandits"),
        (else_try),
          (eq, ":bandit_troop", "trp_sea_raider"),
          (set_background_mesh, "mesh_pic_bandits"),
        (else_try), #puesto chief
          (eq, ":bandit_troop", "trp_elite_viking"),
          (set_background_mesh, "mesh_pic_sea_raiders"),
        (else_try),
          (set_background_mesh, "mesh_pic_bandits"),
        (try_end),
      (else_try),
        (party_slot_eq, "$current_town", slot_village_state, svs_looted),
        (assign, ":block_vc_menu", 1),	#vc_menu
        (str_store_string, s6, "@The village has been pillaged. A handful of souls scatter as you pass through the burnt out houses."),
        (try_begin),
          (neq, "$g_player_raid_complete", 1),
          (play_track, "track_empty_village", 1),
        (try_end),
        (str_clear, s15),
        (set_background_mesh, "mesh_pic_looted_village"),
      (else_try),
        (party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
        (assign, ":block_vc_menu", 1),	#vc_menu
        (str_store_string, s6, "@The village is being raided."),
        (str_clear, s15),
        (set_background_mesh, "mesh_pic_looted_village"),
      (else_try),
        (party_get_current_terrain, ":cur_terrain", "$current_town"),
        (try_begin),
          (this_or_next|eq, ":cur_terrain", rt_steppe),
          (this_or_next|eq, ":cur_terrain", rt_steppe_forest),
          (this_or_next|eq, ":cur_terrain", rt_desert),
          (             eq, ":cur_terrain", rt_desert_forest),
          (set_background_mesh, "mesh_pic_village_s"),
        (else_try),
          (this_or_next|eq, ":cur_terrain", rt_snow),
          (             eq, ":cur_terrain", rt_snow_forest),
          (set_background_mesh, "mesh_pic_village_w"),
        (else_try),
          (set_background_mesh, "mesh_pic_village_p"),
        (try_end),
      (try_end),
      
      (try_begin),
        (eq, "$g_player_raid_complete", 1),
        (assign, "$g_player_raid_complete", 0),
        (jump_to_menu, "mnu_village_loot_complete"),
        (assign, ":block_vc_menu", 1),	#vc_menu
      (else_try),
        (party_get_slot, ":raider_party", "$current_town", slot_village_raided_by),
        (gt, ":raider_party", 0),
        # Process here...
      (try_end),
      
      (try_begin),
        (eq,"$g_leave_town",1),
        (assign,"$g_leave_town",0),
        (change_screen_return),
      (try_end),
      
      (try_begin),
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      
      # Phaiak begin (vc_menu)
      (try_begin),
        # vc_menu on
        (neq, "$g_vc_menu_turned_off", 1),
        (eq, ":block_vc_menu", 0),	#vc_menu
        (try_begin),
          (gt, "$vc_menu_result", 0),
          (call_script, "script_execute_village_menu_cosequence", "$vc_menu_result"),
          (assign, "$vc_menu_result", 0),
        (else_try),
          (try_begin),
            (eq, "$vc_menu_active", 0),
            (assign, "$vc_menu_active", "prsnt_vc_menu"),
          (end_try),
          #(str_store_string, s30, "@{s10} {s12}^{s11}^{s6}{s7}^{s15}"),
          (str_store_string, s30, "@{s10} {s12}^{s11}{s6}{s7}{s15}"),
          (call_script, "script_execute_village_menu_cosequence", slot_quest_menu_village_visit),
        (end_try),
        
      (else_try),
        # vc_menu off
        (assign, "$vc_menu_active", 0),
        (call_script, "script_check_village_menu_conditions"),
        (assign, "$curr_menu_slot", 30),
      (end_try),
      
      # Phaiak end
      
      
      
      # (try_begin),
      # (gt, "$vc_menu_result", 0),
      # (call_script, "cc", "$vc_menu_result"),
      # (assign, "$vc_menu_result", 0),
      # (end_try),
      
      # (str_store_string, s30, "@{s10} {s12}^{s11}^{s6}{s7}^{s15}"),
      # (try_for_range, ":menu_slot", slot_quest_menu_begin, slot_quest_menu_end),
      # (quest_set_slot, "qst_vc_menu", ":menu_slot", 0),
      # (end_try),
      # (assign, "$curr_menu_slot", 30),
      # Phaiak end
    ],
    [
      ("village_manage",#1
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Manage this village.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_1),]),
      
      ("recruit_volunteers",#2
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Recruit Volunteers.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_2),]),
      
      ("village_center",#3
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Go to the village center.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_3),],"Door to the village center."),
      
      ("meet_leader",#3.1
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
          (party_slot_eq,"$current_town", slot_party_levy_on, 0),
        ],"Meet the leader.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_3 + 1),],"Door to the village center."),
      
      ("village_buy_food",#4
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Buy supplies from the peasants.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_4 + 1),]),
      
      ###comprar cattle chief
      ("comprar_cattle",[
          (party_slot_eq, "$current_town", slot_village_state, 0),
          (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
          (assign, ":quest_village", 0),
          (try_begin),
            (check_quest_active, "qst_deliver_cattle"),
            (quest_slot_eq, "qst_deliver_cattle", slot_quest_target_center, "$current_town"),
            (assign, ":quest_village", 1),
          (try_end),
          (eq, ":quest_village", 0),
        ],
        "I want to buy some cattle.",
        [
          (jump_to_menu, "mnu_comprar_cattle2"),
      ]),
      
      ####comprar cattle chief acaba
      ("village_attack_bandits",#5
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Attack the bandits.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_5 + 1),]),
      
      ("village_wait",#6
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Wait here for some time.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_6 + 1),]),
      
      ("collect_taxes_qst",#7
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ], "{reg5?Continue collecting taxes:Collect taxes}.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_7 + 1),]),
      
      ("train_peasants_against_bandits_qst",#8
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ], "Train the peasants.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_8 + 1),]),
      
      ("village_hostile_action",#9
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ], "Take a hostile action.",
        [(call_script, "script_execute_village_menu_cosequence", slot_quest_menu_9 + 1),]),
      
      ("village_reports",#10
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ], "{!}CHEAT! Show reports.",
        [
          (call_script, "script_execute_village_menu_cosequence", slot_quest_menu_10 + 1),
      ]),
      ("village_leave",#11
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Leave..."
        ,[
          (call_script, "script_execute_village_menu_cosequence", slot_quest_menu_11 + 1),
      ]),
      
      
    ],
  ),
  
  (
    "village_hostile_action",0,
    "What action do you have in mind?^ (You need over 20 troops.)",
    "none",
    [ (set_background_mesh, "mesh_pic_family"), #pic book
    ],
    [
      ("village_force_convert",[
          (party_slot_eq, "$current_town", slot_village_state, 0),
          (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
          (store_party_size_wo_prisoners, ":player_party_size", "p_main_party"),
          (gt, ":player_party_size", 100),
          (assign, ":num_p", 0),
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
            (try_begin),
              (troop_slot_eq, "trp_player", slot_troop_religion, 1),
              (try_begin),
                (this_or_next|eq,":stack_troop", "trp_briton_priest"),
                (this_or_next|eq,":stack_troop", "trp_saxon_priest"),
                (this_or_next|eq,":stack_troop", "trp_scotch_priest"),
                (this_or_next|eq,":stack_troop", "trp_angle_priest"),
                (eq,":stack_troop", "trp_irish_priest"),
                (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
                (val_add, ":num_p", ":stack_size"),
              (try_end),
            (else_try),
              (troop_slot_eq, "trp_player", slot_troop_religion, 2),
              (try_begin),
                (eq,":stack_troop", "trp_norse_priest"),
                (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
                (val_add, ":num_p",":stack_size"),
              (try_end),
            (try_end),
          (try_end),
          (ge, ":num_p", 10),
          (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
          (try_begin),
            (troop_slot_eq, "trp_player", slot_troop_religion, 1),#christian
            (lt, ":faith", 100),
            (store_relation,":rel","fac_christians","fac_player_faction"),
          (else_try),
            (troop_slot_eq, "trp_player", slot_troop_religion, 2),#pagan
            (store_sub, ":p_faith", 100, ":faith"),
            (lt, ":p_faith", 100),
            (store_relation,":rel","fac_pagans","fac_player_faction"),
          (try_end),
          (gt, ":rel", 40),
          (troop_slot_ge, "trp_player", slot_troop_renown, 300),
        ],"Try to convert the peasants forcefully.",
        [
          (jump_to_menu, "mnu_village_force_convert_confirm")
      ]),
      
      ("village_take_food",[
          (party_slot_eq, "$current_town", slot_village_state, 0),
          (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
          (neq, "$players_kingdom", "$g_encountered_party_faction"),    #added for VC-3396
          (store_party_size_wo_prisoners, ":player_party_size", "p_main_party"),
          (gt, ":player_party_size", 20), #20 men or more need.
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
          (assign, ":town_stores_not_empty", 0),
          (try_for_range, ":slot_no", num_equipment_kinds, max_inventory_items + num_equipment_kinds),
            (troop_get_inventory_slot, ":slot_item", ":merchant_troop", ":slot_no"),
            (ge, ":slot_item", 0),
            (assign, ":town_stores_not_empty", 1),
          (try_end),
          (eq, ":town_stores_not_empty", 1),
        ],"Force peasants to give you supplies.",
        [
          
          (jump_to_menu, "mnu_village_take_food_confirm")
      ]),
      ("village_steal_cattle",
        [
          (party_slot_eq, "$current_town", slot_village_state, 0),
          (neq, "$players_kingdom", "$g_encountered_party_faction"),    #added for VC-3396
          (party_slot_eq, "$current_town", slot_village_player_can_not_steal_cattle, 0),
          (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
          (store_party_size_wo_prisoners, ":player_party_size", "p_main_party"),
          (gt, ":player_party_size", 20), #20 men or more need.
          (party_get_slot, ":num_cattle", "$current_town", slot_village_number_of_cattle),
          (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
          (gt, ":num_cattle", 0),
        ],"Steal cattle.",
        [
          (jump_to_menu, "mnu_village_steal_cattle_confirm")
      ]),
      #enslaves
      ("enslave_villagers",
        [
          (neg|party_slot_eq, "$current_town", slot_village_state, svs_looted),
          (neg|party_slot_eq, "$current_town", slot_village_state, svs_being_raided),
          (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
          (neq, "$players_kingdom", "$g_encountered_party_faction"),    #added for VC-3396
          (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
          (store_party_size_wo_prisoners, ":player_party_size", "p_main_party"),
          (gt, ":player_party_size", 20), #20 men or more need.
          (party_slot_eq, "$current_town", slot_center_enslaved, 0),
        ]
        ,"Enslave the villagers.",
        [
          (jump_to_menu, "mnu_village_raid_villagers_toslaves"),
      ]),
      ###
      ("village_loot",[(party_slot_eq, "$current_town", slot_village_state, 0),
          (neq, "$players_kingdom", "$g_encountered_party_faction"),    #added for VC-3396
          (neg|party_slot_ge, "$current_town", slot_village_infested_by_bandits, 1),
          (store_party_size_wo_prisoners, ":player_party_size", "p_main_party"),
          (gt, ":player_party_size", 20), #20 men or more need.
          (store_faction_of_party, ":center_faction", "$current_town"),
          (store_relation, ":reln", "fac_player_faction", ":center_faction"),
          (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
          (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
          (assign, ":continue", 0),
          (try_begin),
            (gt, ":town_lord", 0),
            (troop_get_slot, ":lord_rel", ":town_lord", slot_troop_player_relation),
            (this_or_next|lt, ":lord_rel", -15),
            (le, ":reln", 0),
            (assign, ":continue", 1),
          (else_try),
            (lt, ":town_lord", 0),
            (le, ":reln", 0),
            (assign, ":continue", 1),
          (try_end),
          (eq, ":continue", 1),
        ],
        "Loot and burn this village.",
        [
          #           (party_clear, "$current_town"),
          #           (party_add_template, "$current_town", "pt_villagers_in_raid"),
          #    (jump_to_menu, "mnu_village_start_attack"),
          (call_script, "script_party_count_members_with_full_health","$current_town"),
          #(display_message, "@Villager size is {reg0}"),
          (assign, ":villagers_party_size", reg0),
          (store_random_in_range, ":rebellion", 1, 100), #rebellion or run away
          (try_begin),
            (ge, ":rebellion", 25), #yes rebelion
            (ge, ":villagers_party_size", 20),
            (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
            (jump_to_menu, "mnu_village_start_attack"),
          (else_try),
            (jump_to_menu, "mnu_village_loot_no_resist_population_flee"),
          (try_end),
          
      ]),
      ("forget_it",[],
        "Forget it.",[(jump_to_menu,"mnu_village")]),
    ],
  ),
  
  (
    "recruit_volunteers",0,
    "{!}{s18}",
    "none",
    [
      #vc_submenu_recruits begins
      (try_begin),
        (this_or_next|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),	#chief add for recruit need to permission
        (party_slot_eq, "$current_town", recruit_permission_need, 0), 				#chief add for recruit need to permission
        (assign, "$g_block_recruiting", 0),
        #vc_submenu_recruits ends
        
        (party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
        (party_get_slot, ":volunteer_amount", "$current_town", slot_center_volunteer_troop_amount),
        (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
        (store_troop_gold, ":gold", "trp_player"),
        (call_script, "script_cost_per_village_recruit"),  #MOTO variable cost
        (assign, ":basic_cost", reg0),
        (store_character_level, ":level", ":volunteer_troop"),
        (val_sub, ":level", 12),
        (val_add, ":basic_cost", ":level"),
        (store_div, ":gold_capacity", ":gold", ":basic_cost"),#10 peningas per man MOTO variable cost
        (assign, ":party_capacity", ":free_capacity"),
        (val_min, ":party_capacity", ":gold_capacity"),
        (try_begin),
          (gt, ":party_capacity", 0),
          (val_min, ":volunteer_amount", ":party_capacity"),
        (try_end),
        (assign, reg5, ":volunteer_amount"),
        (assign, reg7, 0),
        (try_begin),
          (gt, ":volunteer_amount", ":gold_capacity"),
          (assign, reg7, 1), #not enough money
        (try_end),
        (try_begin),
          (eq, ":volunteer_amount", 0),
          (str_store_string, s18, "@No one here seems to be willing to join your party."),
        (else_try),
          (store_mul, reg6, ":volunteer_amount", reg0),#10 peningas per man MOTO variable cost
          (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
          (try_begin),
            (eq, reg5, 1),
            (str_store_string, s18, "@One {s3} volunteers to follow you."),
          (else_try),
            (str_store_string, s18, "@{reg5} {s3} volunteer to follow you."),
          (try_end),
          (set_background_mesh, "mesh_pic_recruits"),
        (try_end),
        
        #vc_submenu_recruits begins
      (else_try),
        (str_store_string, s18, "@You need to get the permission of the village leader to recruit here."),
        (party_get_slot, ":volunteer_troop", "$current_town", slot_center_volunteer_troop_type),
        (assign, ":volunteer_amount", 0),
        (assign, reg7, 0),#
        (assign, reg5, 1),#
        (assign, "$g_block_recruiting", 1),
      (end_try),
      #vc_submenu_recruits ends
    ],
    [
      ("continue_not_enough_gold",
        [
          (eq, reg7, 1),
        ],
        "I don't have enough money.",
        [
          (jump_to_menu,"mnu_village"),
      ]),
      
      ("continue",
        [
          (eq, reg7, 0),
          (eq, reg5, 0),
        ], #noone willing to join
        "Continue...",
        [
          (party_set_slot, "$current_town", slot_center_volunteer_troop_amount, -1),
          (jump_to_menu,"mnu_village"),
      ]),
      
      ("recruit_them",
        [
          (eq, reg7, 0),
          (gt, reg5, 0),
          (eq, "$g_block_recruiting", 0),	#vc_submenu_recruits
        ],
        "Recruit them ({reg6} peningas).",
        [
          (call_script, "script_village_recruit_volunteers_recruit"),
          
          (jump_to_menu,"mnu_village"),
      ]),
      
      ("forget_it",
        [
          (eq, reg7, 0),
          (gt, reg5, 0),
        ],
        "Forget it.",
        [
          (jump_to_menu,"mnu_village"),
      ]),
    ],
  ),
  
  (
    "village_hunt_down_fugitive_defeated",0,
    "A heavy blow from the fugitive sends you to the ground, and your vision spins and goes dark. " +
    "Time passes. When you open your eyes again, you find yourself battered and bloody, " +
    "but luckily none of the wounds appear to be lethal.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"), #pic book
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu, "mnu_village"),]),
    ],
  ),
  (
    "village_confront_contact_defeated",0,
    "A heavy blow from the villager sends you to the ground, and your vision spins and goes dark. " +
    "Time passes. When you open your eyes again, you find yourself battered and bloody, " +
    "but luckily none of the wounds appear to be lethal.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"), #pic book
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu, "mnu_village"),]),
    ],
  ),
  (
    "village_hunt_lover_defeated",0,
    "A heavy blow from the ghost sends you to the ground, and your vision spins and goes dark. " +
    "Time passes. When you open your eyes again, you find yourself battered and bloody, " +
    "but luckily none of the wounds appear to be lethal.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"), #pic book
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu, "mnu_village"),]),
    ],
  ),
  (
    "village_hunt_music_defeated",0,
    "A heavy blow from the rogue guard sends you to the ground, and your vision spins and goes dark. " +
    "Time passes. When you open your eyes again, you find yourself battered and bloody, " +
    "but luckily none of the wounds appear to be lethal.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"), #pic book
    ],
    [
      ("continue",[],"Continue...",[(jump_to_menu, "mnu_village"),]),
    ],
  ),
  
  (
    "village_infest_bandits_result",0,
    "{!}{s9}",
    "none",
    [(try_begin),
        (eq, "$g_battle_result", 1),
        (jump_to_menu, "mnu_village_infestation_removed"),
      (else_try),
        (str_store_string, s9, "@Try as you might, you could not defeat the bandits. " +
          "Infuriated, they raze the village to the ground to punish the peasants, " +
        "and then leave the burning wasteland behind to find greener pastures to plunder."),
        (set_background_mesh, "mesh_pic_looted_village"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [(party_set_slot, "$g_encountered_party", slot_village_infested_by_bandits, 0),
          (call_script, "script_village_set_state",  "$current_town", svs_looted),
          (party_set_slot, "$current_town", slot_village_raid_progress, 0),
          (party_set_slot, "$current_town", slot_village_recover_progress, 0),
          (try_begin),
            (check_quest_active, "qst_eliminate_bandits_infesting_village"),
            (quest_slot_eq, "qst_eliminate_bandits_infesting_village", slot_quest_target_center, "$g_encountered_party"),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -10),
            (call_script, "script_fail_quest", "qst_eliminate_bandits_infesting_village"),
            (set_show_messages, 0),
            (call_script, "script_end_quest", "qst_eliminate_bandits_infesting_village"),
            (set_show_messages, 1),
          (else_try),
            (check_quest_active, "qst_deal_with_bandits_at_lords_village"),
            (quest_slot_eq, "qst_deal_with_bandits_at_lords_village", slot_quest_target_center, "$g_encountered_party"),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -8),
            (call_script, "script_fail_quest", "qst_deal_with_bandits_at_lords_village"),
            (set_show_messages, 0),
            (call_script, "script_end_quest", "qst_deal_with_bandits_at_lords_village"),
            (set_show_messages, 1),
          (else_try),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -5),
          (try_end),
          (jump_to_menu, "mnu_village"),]),
    ],
  ),
  
  
  (
    "village_infestation_removed",mnf_disable_all_keys,
    "In a battle worthy of song, you and your men drive the bandits out of the village, making it safe once more. " +
    "The villagers have little left in the way of wealth after their ordeal, " +
    "but they offer you all they can find.",
    "none",
    [ (set_background_mesh, "mesh_pic_family"), #pic book
      
      (party_get_slot, ":bandit_troop", "$g_encountered_party", slot_village_infested_by_bandits),
      (party_set_slot, "$g_encountered_party", slot_village_infested_by_bandits, 0),
      (party_clear, "p_temp_party"),
      (party_add_members, "p_temp_party", ":bandit_troop", "$qst_eliminate_bandits_infesting_village_num_bandits"),
      (assign, "$g_strength_contribution_of_player", 50),
      (call_script, "script_party_give_xp_and_gold", "p_temp_party"),
      (try_begin),
        (check_quest_active, "qst_eliminate_bandits_infesting_village"),
        (quest_slot_eq, "qst_eliminate_bandits_infesting_village", slot_quest_target_center, "$g_encountered_party"),
        (call_script, "script_succeed_quest", "qst_eliminate_bandits_infesting_village"),
        (set_show_messages, 0),
        (call_script, "script_end_quest", "qst_eliminate_bandits_infesting_village"),
        (set_show_messages, 1),
        #Add quest reward
        (call_script, "script_change_player_relation_with_center", "$g_encountered_party", 10),
      (else_try),
        (check_quest_active, "qst_deal_with_bandits_at_lords_village"),
        (quest_slot_eq, "qst_deal_with_bandits_at_lords_village", slot_quest_target_center, "$g_encountered_party"),
        (call_script, "script_succeed_quest", "qst_deal_with_bandits_at_lords_village"),
        (call_script, "script_change_player_relation_with_center", "$g_encountered_party", 3),
      (else_try),
        #Add normal reward
        (call_script, "script_change_player_relation_with_center", "$g_encountered_party", 4),
      (try_end),
      
      (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
      (try_for_range, ":slot_no", num_equipment_kinds ,max_inventory_items + num_equipment_kinds),
        (store_random_in_range, ":rand", 0, 100),
        (lt, ":rand", 70),
        (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
      (try_end),
    ],
    [
      ("village_bandits_defeated_accept",[],"Take it as your just due.",[(jump_to_menu, "mnu_village"),
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
          (troop_sort_inventory, ":merchant_troop"),
          (change_screen_loot, ":merchant_troop"),
      ]),
      
      ("village_bandits_defeated_cont",[],  "Refuse, stating that they need these items more than you do.",
        [	(call_script, "script_change_player_relation_with_center", "$g_encountered_party", 3),
          (call_script, "script_change_player_honor", 1),
          (jump_to_menu, "mnu_village")]),
    ],
  ),
  
  (
    "center_manage",0,
    "{s19}^{reg6?^^You are " +
    "currently building {s7}. The building will be completed after {reg8} day{reg9?s:}.:}",
    "none",
    [(assign, ":num_improvements", 0),
      (str_clear, s18),
      (try_begin),
        (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
        (assign, ":begin", village_improvements_begin),
        (assign, ":end", village_improvements_end),
        (str_store_string, s17, "@village"),
      (else_try),
        (assign, ":begin", walled_center_improvements_begin),
        (assign, ":end", walled_center_improvements_end),
        (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
        (str_store_string, s17, "@town"),
      (else_try),
        (str_store_string, s17, "@castle"),
      (try_end),
      
      (try_for_range, ":improvement_no", ":begin", ":end"),
        (party_slot_ge, "$g_encountered_party", ":improvement_no", 1),
        (val_add,  ":num_improvements", 1),
        (call_script, "script_get_improvement_details", ":improvement_no"),
        (try_begin),
          (eq,  ":num_improvements", 1),
          (str_store_string, s18, "@{!}{s0}"),
        (else_try),
          (str_store_string, s18, "@{!}{s18}, {s0}"),
        (try_end),
      (try_end),
      
      (try_begin),
        (eq,  ":num_improvements", 0),
        (str_store_string, s19, "@The {s17} has no improvements."),
      (else_try),
        (str_store_string, s19, "@The {s17} has the following improvements: {s18}."),
      (try_end),
      
      (assign, reg6, 0),
      (try_begin),
        (party_get_slot, ":cur_improvement", "$g_encountered_party", slot_center_current_improvement),
        (gt, ":cur_improvement", 0),
        (call_script, "script_get_improvement_details", ":cur_improvement"),
        (str_store_string, s7, s0),
        (assign, reg6, 1),
        (store_current_hours, ":cur_hours"),
        (party_get_slot, ":finish_time", "$g_encountered_party", slot_center_improvement_end_hour),
        (val_sub, ":finish_time", ":cur_hours"),
        (store_div, reg8, ":finish_time", 24),
        (val_max, reg8, 1),
        (store_sub, reg9, reg8, 1),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("center_build_manor",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
          (party_slot_eq, "$g_encountered_party", slot_center_has_manor, 0),
        ],
        "Build a mead hall.",[(assign, "$g_improvement_type", slot_center_has_manor),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_fish_pond",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
          (party_slot_eq, "$g_encountered_party", slot_center_has_fish_pond, 0),
        ],
        "Build a mill.",[(assign, "$g_improvement_type", slot_center_has_fish_pond),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_watch_tower",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
          (party_slot_eq, "$g_encountered_party", slot_center_has_watch_tower, 0),
        ],
        "Build a watchtower.",[(assign, "$g_improvement_type", slot_center_has_watch_tower),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_school",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
          (party_slot_eq, "$g_encountered_party", slot_center_has_school, 0),
        ],
        "Build a school.",[(assign, "$g_improvement_type", slot_center_has_school),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_messenger_post",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_center_has_messenger_post, 0),
        ],
        "Build a messenger post.",[(assign, "$g_improvement_type", slot_center_has_messenger_post),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_prisoner_tower",[(eq, reg6, 0),
          (this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
          (party_slot_eq, "$g_encountered_party", slot_center_has_prisoner_tower, 0),
        ],
        "Build a prisoner tower.",[(assign, "$g_improvement_type", slot_center_has_prisoner_tower),
          (jump_to_menu, "mnu_center_improve"),]),
      #religion edificios chief
      ("center_build_religion1",[(eq, reg6, 0),
          (eq, "$g_player_faith", 1), #es cristiano
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
          (party_slot_eq, "$g_encountered_party", slot_center_has_temple1, 0),
        ],
        "Build a Christian monastery (conversion factor).",[
          (assign, "$g_improvement_type", slot_center_has_temple1),
          (party_set_slot, "$g_encountered_party", slot_center_has_temple3, 0),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_religion2",[(eq, reg6, 0),
          (eq, "$g_player_faith", 2),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
          (party_slot_eq, "$g_encountered_party", slot_center_has_temple3, 0),
        ],
        "Build a temple to Odin (conversion factor).",[
          (assign, "$g_improvement_type", slot_center_has_temple3),
          (party_set_slot, "$g_encountered_party", slot_center_has_temple1, 0),
          (jump_to_menu, "mnu_center_improve"), ]),
      ("center_build_religion3",[(eq, reg6, 0),
          (eq, "$g_player_faith", 1),
          (this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
          (party_slot_eq, "$g_encountered_party", slot_center_has_monastery1, 0),
        ],
        "Build a Christian church (conversion factor).",[
          (assign, "$g_improvement_type", slot_center_has_monastery1),
          (party_set_slot, "$g_encountered_party", slot_center_has_monastery3, 0),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_religion4",[(eq, reg6, 0),
          (eq, "$g_player_faith", 2),
          (this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
          (party_slot_eq, "$g_encountered_party", slot_center_has_monastery3, 0),
        ],
        "Build a shrine to Norse gods (conversion factor).",[
          (assign, "$g_improvement_type", slot_center_has_monastery3),
          (party_set_slot, "$g_encountered_party", slot_center_has_monastery1, 0),
          (jump_to_menu, "mnu_center_improve"), ]),
      ("center_build_herreria",[(eq, reg6, 0),
          
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
          (party_slot_eq, "$g_encountered_party", slot_center_has_blacksmith, 0),
        ],
        "Build a smithy.",[(assign, "$g_improvement_type", slot_center_has_blacksmith),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_guilds",[(eq, reg6, 0),
          
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party", slot_center_has_guild, 0),
        ],
        "Build a merchants' rest hall.",[(assign, "$g_improvement_type", slot_center_has_guild),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_library",[(eq, reg6, 0),
          
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party", slot_center_has_university, 0),
        ],
        "Build a scriptorium.",[(assign, "$g_improvement_type", slot_center_has_university),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_build_slavemarket",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party",slot_town_port, 1),
          (party_slot_eq, "$g_encountered_party", slot_center_has_slavemarket, 0),
        ],
        "Build a slave market.",[(assign, "$g_improvement_type", slot_center_has_slavemarket),
          (jump_to_menu, "mnu_center_improve"),]),
      ("center_kill_slavemarket",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
          (party_slot_eq, "$g_encountered_party",slot_town_port, 1),
          (party_slot_eq, "$g_encountered_party", slot_center_has_slavemarket, 1),
        ],
        "Remove a slave market.",[
          (jump_to_menu, "mnu_remove_slaves"),]),
      ("center_build_brewery",[(eq, reg6, 0),
          (party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
          (party_slot_eq, "$g_encountered_party", slot_center_has_brewery, 0),
        ],
        "Build a brewery.",[(assign, "$g_improvement_type", slot_center_has_brewery),
          (jump_to_menu, "mnu_center_improve"),]),
      #chief edificios
      
      
      
      ("go_back_dot",[],"Go back.",[(jump_to_menu, "$g_next_menu")]),
    ],
  ),
  
  (
    "remove_slaves",0,
    "Do you wish to remove the slave traders and forbid them from conducting their ungodly business within the boundaries of your town? " +
    "Keep in mind this will reduce the tariffs of the town and its prosperity temporarily.",
    "none",
    [(call_script, "script_set_town_picture")] ,
    [
      ("remove_slaves",[],
        "Go on.", [
          (party_set_slot,"$g_encountered_party", slot_center_has_slavemarket, 0),
          (party_get_slot, ":center_prosperity", "$g_encountered_party", slot_town_prosperity),
          (val_sub, ":center_prosperity", 20),
          (val_max, ":center_prosperity", 0),
          (party_set_slot,"$g_encountered_party", slot_town_prosperity, ":center_prosperity"),
          (party_get_slot, reg2, "$g_encountered_party", slot_center_accumulated_tariffs),
          (val_div, reg2, 4),
          (party_set_slot,"$g_encountered_party", slot_center_accumulated_tariffs, reg2),
          (jump_to_menu,"mnu_center_manage"),
      ]),
      ("forget_it",[],
        "Forget it.", [(jump_to_menu,"mnu_center_manage")]),
    ],
  ),
  
  (
    "center_improve",0,
    "{s19} As the party member with the highest engineer skill ({reg2}), {reg3?you reckon:{s3} reckons} that building the {s4} will cost you " +
    "{reg5} peningas and will take {reg6} days.",
    "none",
    [(call_script, "script_get_improvement_details", "$g_improvement_type"),
      (assign, ":improvement_cost", reg0),
      (str_store_string, s4, s0),
      (str_store_string, s19, s1),
      (call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      (assign, reg2, ":max_skill"),
      
      (store_sub, ":multiplier", 20, ":max_skill"),
      (val_mul, ":improvement_cost", ":multiplier"),
      (val_div, ":improvement_cost", 20),
      
      (store_div, ":improvement_time", ":improvement_cost", 300), #chief was 100
      (val_add, ":improvement_time", 5),
      
      (assign, reg5, ":improvement_cost"),
      (assign, reg6, ":improvement_time"),
      
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s3, ":max_skill_owner"),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("improve_cont",[(store_troop_gold, ":cur_gold", "trp_player"),
          (ge, ":cur_gold", reg5),
          (assign, reg33, 0),
          (assign, "$temp", 0),
          (assign, "$temp2", 0),
          (str_clear, s15),
          (try_begin),
            (this_or_next|eq, "$g_improvement_type", slot_center_has_monastery3),
            (eq, "$g_improvement_type", slot_center_has_temple3),
            (party_get_slot, ":faith", "$g_encountered_party", slot_center_faithratio),
            (party_get_slot,":religion","$g_encountered_party",slot_center_religion),
            (try_begin),
              (eq, ":religion", 2),
              (store_sub, ":p_faith", 100, ":faith"),
              (try_begin),
                (lt, ":p_faith", 40),
                (assign, reg33, -30),
              (else_try),
                (gt, ":p_faith", 65),
                (assign, reg33, -5),
              (else_try),
                (assign, reg33, -10),
              (try_end),
            (else_try),
              (eq, ":religion", 1),
              (try_begin),
                (gt, ":faith", 45),
                (assign, reg33, -30),
              (else_try),
                (assign, reg33, -10),
              (try_end),
            (try_end),
            (assign, "$temp2", 2),
            (assign, "$temp", reg33),
            (str_store_string, s15, "@ (Christian riots could cause: {reg33} relations drop)"),
          (else_try),
            (this_or_next|eq, "$g_improvement_type", slot_center_has_monastery1),
            (eq, "$g_improvement_type", slot_center_has_temple1),
            (party_get_slot, ":faith", "$g_encountered_party", slot_center_faithratio),
            (party_get_slot,":religion","$g_encountered_party",slot_center_religion),
            (try_begin),
              (eq, ":religion", 1),
              (try_begin),
                (lt, ":faith", 40),
                (assign, reg33, -30),
              (else_try),
                (gt, ":faith", 65),
                (assign, reg33, -5),
              (else_try),
                (assign, reg33, -10),
              (try_end),
            (else_try),
              (eq, ":religion", 2),
              (store_sub, ":p_faith", 100, ":faith"),
              (try_begin),
                (gt, ":p_faith", 45),
                (assign, reg33, -30),
              (else_try),
                (assign, reg33, -10),
              (try_end),
            (try_end),
            (assign, "$temp2", 1),
            (assign, "$temp", reg33),
            (str_store_string, s15, "@ (Pagan riots could cause: {reg33} relations drop)"),
          (try_end),
        ],
        "Go on{s15}.", [(troop_remove_gold, "trp_player", reg5),
          (party_set_slot, "$g_encountered_party", slot_center_current_improvement, "$g_improvement_type"),
          (store_current_hours, ":cur_hours"),
          (store_mul, ":hours_takes", reg6, 24),
          (val_add, ":hours_takes", ":cur_hours"),
          (party_set_slot, "$g_encountered_party", slot_center_improvement_end_hour, ":hours_takes"),
          (try_begin),
            (this_or_next|eq, "$g_improvement_type", slot_center_has_monastery1),
            (this_or_next|eq, "$g_improvement_type", slot_center_has_temple1),
            (this_or_next|eq, "$g_improvement_type", slot_center_has_monastery3),
            (eq, "$g_improvement_type", slot_center_has_temple3),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", "$temp"),
            (party_set_slot,"$g_encountered_party",slot_center_religion, "$temp2"),
          (try_end),
          (jump_to_menu,"mnu_center_manage"),
          
      ]),
      ("forget_it",[(store_troop_gold, ":cur_gold", "trp_player"),
          (ge, ":cur_gold", reg5)],
        "Forget it.", [(jump_to_menu,"mnu_center_manage")]),
      ("improve_not_enough_gold",[(store_troop_gold, ":cur_gold", "trp_player"),
          (lt, ":cur_gold", reg5)],
        "I don't have enough money.", [(jump_to_menu, "mnu_center_manage"),]),
    ],
  ),
  
  (
    "town_bandits_failed",mnf_disable_all_keys,
    "{!}{s4} {s5}",
    "none",
    [ (set_background_mesh, "mesh_pic_siege_victory"), #pic book
      
      #      (call_script, "script_loot_player_items", 0),
      (store_troop_gold, ":total_gold", "trp_player"),
      (store_div, ":gold_loss", ":total_gold", 30),
      (store_random_in_range, ":random_loss", 40, 100),
      (val_add, ":gold_loss", ":random_loss"),
      (val_min, ":gold_loss", ":total_gold"),
      (party_set_slot, "$current_town", slot_center_has_bandits, 1),
      (try_begin),
        (eq, ":gold_loss", 0),
        (str_store_string, s4, "@Your enemies beat you down and leave you for dead."),
      (else_try),
        (troop_remove_gold, "trp_player",":gold_loss"),
        (str_store_string, s4, "@You have fallen. Your enemies quickly search your body for every coin they can find, " +
        "then vanish into the night. They have left you alive, if only barely."),
      (try_end),
      (party_get_num_companions, ":num_companions", "p_main_party"),
      (try_begin),
        (gt, ":num_companions", 2),
        (str_store_string, s5, "@Luckily, some of your companions come to search for you when you do not return and find you lying by the side of the road. They hurry you to safety and dress your wounds."),
      (else_try),
        (str_store_string, s5, "@Luckily, some passing townspeople find you lying by the side of the road and recognise you as something other than a simple beggar. They carry you to the nearest inn and dress your wounds."),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[(change_screen_return)]),
    ],
  ),
  
  (
    "town_bandits_succeeded",mnf_disable_all_keys,
    "The enemies fall before you as grain to a scythe! Soon you stand alone in the streets " +
    "while most of your attackers lie unconscious, dead or dying. " +
    "Searching the bodies, you find a purse, which must have belonged to a previous victim of these brutes. " +
    "Or perhaps, it was given to them by someone who wanted to arrange a suitable ending to your life. {s33}",
    "none",
    [ (set_background_mesh, "mesh_pic_battle_raid"), #pic book
      (party_set_slot, "$current_town", slot_center_has_bandits, 1),
      (assign, "$g_last_defeated_bandits_town", "$g_encountered_party"),
      (try_begin),
        (check_quest_active, "qst_deal_with_night_bandits"),
        (neg|check_quest_succeeded, "qst_deal_with_night_bandits"),
        (quest_slot_eq, "qst_deal_with_night_bandits", slot_quest_target_center, "$g_encountered_party"),
        (call_script, "script_succeed_quest", "qst_deal_with_night_bandits"),
      (try_end),
      (store_mul, ":xp_reward", "$num_center_bandits", 117),
      (add_xp_to_troop, ":xp_reward", "trp_player"),
      (store_mul, ":gold_reward", "$num_center_bandits", 50),
      (call_script, "script_troop_add_gold","trp_player",":gold_reward"),
      (str_clear, s33),
      (try_begin),
        (neg|check_quest_active, "qst_blank_quest_14"),
        (neg|check_quest_active, "qst_blank_quest_15"),
        (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
        (ge, ":player_renown", 400),
        (store_random_in_range, ":rand", 0,100),
        (assign, "$temp", 0),
        (try_begin),
          (lt, ":rand", 30),
          (store_faction_of_party, ":faction", "$current_town"),
          (call_script, "script_cf_select_random_village_with_faction", ":faction"),
          (assign, ":quest_target_center", reg0),
          (try_begin),
            (gt, ":quest_target_center", 0),
            (neq,":quest_target_center", "$current_town"),
          (else_try),
            (try_for_range,":unused", 0,5),
              (store_random_in_range, ":random_village", villages_begin, villages_end),
              (neq, ":random_village", "$current_town"),
              (assign, ":quest_target_center", ":random_village"),
            (try_end),
          (try_end),
          (gt, ":quest_target_center", 0),
          (str_store_party_name_link,s3, ":quest_target_center"),
          (assign, "$temp", ":quest_target_center"),
          (str_store_string, s33, "@Going through the bandits' purses, you discover a dirty torn piece of vellum with the word 'kill' and a portion of your name still visible. Turning the vellum over, you see the scribbles 'Meet me in {s3}.'"),
        (else_try),
          (str_clear, s33),
        (try_end),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[(change_screen_return)]),
      
      ("reveal",[(neg|check_quest_active, "qst_blank_quest_14"),
          (neg|check_quest_active, "qst_blank_quest_15"),
          (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
          (ge, ":player_renown", 400),
          (gt, "$temp", 0),
          (is_between, "$temp", centers_begin, centers_end),
        ],"Try to find out who wanted you dead.",
        [
          (assign, ":quest_expiration_days", 30),
          (assign, ":quest_target_center", "$temp"),
          (quest_set_slot, "qst_blank_quest_14", slot_quest_target_center, ":quest_target_center"),
          (quest_set_slot, "qst_blank_quest_14", slot_quest_expiration_days, ":quest_expiration_days"),
          (quest_set_slot, "qst_blank_quest_14", slot_quest_current_state, 0),
          (quest_set_slot, "qst_blank_quest_14", slot_quest_target_troop, "trp_mercenaries_end"),
          (str_store_string, s2, "str_reveal_ass"),
          (str_store_party_name_link,s3, ":quest_target_center"),
          (setup_quest_text, "qst_blank_quest_14"),
          (call_script, "script_start_quest", "qst_blank_quest_14", -1),
          (change_screen_return)]),
      
      
    ],
  ),
  #Force conversion
  (
    "village_force_convert_confirm",0,
    "It will take you 5 hours to go through the village, pull all the heretics from their holes, and force them to recant their wrongful beliefs.",
    "none",
    [(set_background_mesh, "mesh_pic_family"), #pic book
    ],
    [
      ("village_force_convert_confirm",[],"Go on.",
        [
          (rest_for_hours_interactive, 5, 5, 1), #rest while attackable
          (assign, "$auto_menu", "mnu_village_force_convert1"),
          (change_screen_return),
      ]),
      ("forget_it",[],"Forget it.",[(change_screen_return)]),
    ],
  ),
  
  (
    "village_force_convert1",mnf_disable_all_keys,
    "{!}{s1}",
    "none",
    [(set_background_mesh, "mesh_pic_family"), #pic book
      (store_skill_level, ":persuasion", "skl_persuasion", "trp_player"),
      (store_skill_level, ":power_strike", "skl_power_strike", "trp_player"),
      (store_attribute_level, ":charisma", "trp_player", ca_charisma),
      (store_attribute_level,":intelligence","trp_player",ca_intelligence),
      (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
      (store_faction_of_party, ":faction_no", "$current_town"),
      (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
      (store_add, ":mod", ":charisma",":intelligence"),
      (val_div, ":mod", 3),
      (val_div, ":persuasion", 2),
      (val_add, ":mod", ":persuasion"),
      (val_add, ":mod",":power_strike"),
      (val_sub, ":mod", 2),
      (try_begin),
        (eq, "$g_player_faith", 1),
        (val_mul, ":mod", ":faith"),
      (else_try),
        (store_sub, ":p_faith", 100, ":faith"),
        (val_mul, ":mod", ":p_faith"),
      (try_end),
      (val_div, ":mod", 100),
      (try_begin),
        (eq, "$defect_type", cb6_prudence),
        (val_add, ":mod", 2),
      (else_try),
        (eq, "$defect_type", cb6_fortitude),
        (val_add, ":mod", 4),
      (else_try),
        (eq, "$defect_type", cb6_temperance),
        (val_sub, ":mod", 2),
      (else_try),
        (eq, "$defect_type", cb6_justice),
        (val_sub, ":mod", 3),
      (try_end),
      (try_begin),
        (eq, "$virtue_type", cb5_calm),
        (val_sub, ":mod", 1),
      (else_try),
        (eq, "$virtue_type", cb5_responsible),
        (val_sub, ":mod", 2),
      (else_try),
        (eq, "$virtue_type",  cb5_extroverted),
        (val_add, ":mod", 2),
      (else_try),
        (eq, "$virtue_type",  cb5_bold),
        (val_add, ":mod", 3),
      (try_end),
      (val_div, ":center_relation", 8),
      (val_add, ":mod", ":center_relation"),
      (assign, reg44, ":mod"),
      (assign, ":conv", 0),
      (store_random_in_range, ":rand", 0,60),
      #	(assign, reg45, ":rand"),
      #	(display_message, "@Mod is {reg44} and random is {reg45}"),
      (try_begin),
        (le, ":mod", 0),
        (lt, ":rand", 3),
        (val_add, ":conv", 1),
      (else_try),
        (gt, ":mod",0),
        (lt, ":rand", ":mod"),
        (val_sub, ":mod", ":rand"),
        (val_min, ":mod", 5),
        (val_add, ":conv", ":mod"),
      (try_end),
      (try_begin),
        (gt, ":conv", 0),
        (try_begin),
          (eq, "$g_player_faith", 1),
          (val_add, ":faith", ":conv"),
        (else_try),
          (eq, "$g_player_faith", 2),
          (val_add, ":p_faith", ":conv"),
          (store_sub, ":faith", 100, ":p_faith"),
        (try_end),
        (val_clamp, ":faith", 0, 101),
        (party_set_slot, "$current_town", slot_center_faithratio, ":faith"),
        (val_mul, ":conv", -2),
        (call_script, "script_change_center_prosperity", "$current_town", ":conv"),
        (val_mul, ":conv", 5),
        (val_div, ":conv", 3),
        (call_script, "script_change_player_relation_with_center", "$current_town", ":conv"),
        (try_begin),
          (eq, "$g_player_faith", 1),
          (faction_slot_eq, ":faction_no", slot_faction_religion, cb3_pagan),
          (call_script, "script_change_player_relation_with_faction" ,":faction_no", -2),
        (else_try),
          (eq, "$g_player_faith", 2),
          (faction_slot_eq, ":faction_no", slot_faction_religion, cb3_christian),
          (call_script, "script_change_player_relation_with_faction" ,":faction_no", -2),
        (try_end),
        (str_store_string, s1, "@Your efforts prove successful, and some people have changed their beliefs."),
      (else_try),
        (call_script, "script_change_center_prosperity", "$current_town", -3),
        (call_script, "script_change_player_relation_with_center", "$current_town", -5),
        # (try_begin),
        # (eq, "$g_player_faith", 1),
        # (eq,":religionp", 1),
        # (call_script, "script_change_player_relation_with_faction" ,":faction_no", -3),
        # (else_try),
        # (eq, "$g_player_faith", 2),
        # (eq,":religion", 1),
        # (call_script, "script_change_player_relation_with_faction" ,":faction_no", -3),
        # (try_end),
        (str_store_string, s1, "@Your efforts to convert people have failed miserably."),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (change_screen_return),
      ]),
    ],
  ),
  
  (
    "village_steal_cattle_confirm",0,
    "As the party member with the highest looting skill ({reg2}), {reg3?you reckon:{s1} reckons} that you can steal as many as {reg4} head of the village's cattle.",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"), #pic book
      (call_script, "script_get_max_skill_of_player_party", "skl_looting"),
      (assign, reg2, reg0),
      (assign, ":max_skill_owner", reg1),
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s1, ":max_skill_owner"),
      (try_end),
      (call_script, "script_calculate_amount_of_cattle_can_be_stolen", "$current_town"),
      (assign, reg4, reg0),
    ],
    [
      ("village_steal_cattle_confirm",[],"Go on.",
        [
          (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
          (assign, "$auto_menu", "mnu_village_steal_cattle"),
          (change_screen_return),
      ]),
      ("forget_it",[],"Forget it.",[(change_screen_return)]),
    ],
  ),
  
  (
    "village_steal_cattle",mnf_disable_all_keys,
    "{!}{s1}",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"), #pic book
      (call_script, "script_calculate_amount_of_cattle_can_be_stolen", "$current_town"),
      (assign, ":max_value", reg0),
      #     (val_add, ":max_value", 1),
      (store_random_in_range, ":random_value", 0, ":max_value"),
      (call_script, "script_get_max_skill_of_player_party", "skl_looting"),
      (assign, ":skill", reg0),
      (val_add, ":random_value", ":skill"),
      (try_begin),
        (gt, ":random_value", ":max_value"),
        (assign, ":random_value", ":max_value"),
      (try_end),
      (party_set_slot, "$current_town", slot_village_player_can_not_steal_cattle, 1),
      (party_get_slot, ":lord", "$current_town", slot_town_lord),
      (store_faction_of_party, ":faction_no", "$current_town"), #JuJu70 wrong place so relations drop was failing
      (try_begin),
        (le, ":random_value", 0),
        (call_script, "script_change_player_relation_with_center", "$current_town", -5),
        (call_script, "script_change_player_relation_with_faction" ,":faction_no", -2), #chief
        (str_store_string, s1, "@You fail to steal any cattle."),
      (else_try),
        (assign, reg17, ":random_value"),
        # (store_sub, reg12, ":random_value", 1),
        (try_begin),
          (gt, ":lord", 0),
          (call_script, "script_change_player_relation_with_troop", ":lord", -15),
          (call_script, "script_add_log_entry", logent_player_stole_cattles_from_village, "trp_player",  "$current_town", ":lord", "$g_encountered_party_faction"),
        (try_end),
        (call_script, "script_change_player_relation_with_center", "$current_town", -30), #you are steal its food!
        (call_script, "script_change_player_relation_with_faction" ,":faction_no", -7), #chief, war? -20 too much
        (call_script, "script_change_player_honor", -2),
        (str_store_string, s1, "@You drive away {reg17} head of cattle from the village's herd."),
        
        (try_begin),
          (eq, ":random_value", 3),
          (unlock_achievement, ACHIEVEMENT_GOT_MILK),
        (try_end),
        
        (call_script, "script_create_cattle_herd", "$current_town", ":random_value"),
        (party_get_slot, ":num_cattle", "$current_town", slot_village_number_of_cattle),
        (val_sub, ":num_cattle", ":random_value"),
        (party_set_slot, "$current_town", slot_village_number_of_cattle, ":num_cattle"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (change_screen_return),
      ]),
    ],
  ),
  
  
  (
    "village_take_food_confirm",0,
    "It will be difficult to force and threaten peasants into giving their precious supplies. You think you will need at least one hour.",
    #TODO: mention looting skill?
    "none",
    [(set_background_mesh, "mesh_pic_family"), #pic book
    ],
    [
      ("village_take_food_confirm",[],"Go ahead.",
        [
          (rest_for_hours_interactive, 1, 5, 0), #rest while not attackable
          (assign, "$auto_enter_town", "$current_town"),
          (assign, "$g_town_visit_after_rest", 1),
          (assign, "$auto_enter_menu_in_center", "mnu_village_take_food"),
          (change_screen_return),
      ]),
      ("forget_it",[],"Forget it.",[(jump_to_menu, "mnu_village_hostile_action")]),
    ],
  ),
  
  (
    "village_take_food",0,
    "The villagers grudgingly bring out what they have for you.",
    "none",
    [(set_background_mesh, "mesh_pic_family"), #pic book
      #     (call_script, "script_party_count_members_with_full_health","p_main_party"),
      #      (assign, ":player_party_size", reg0),
      (call_script, "script_party_count_members_with_full_health","$current_town"),
      (assign, ":villagers_party_size", reg0),
      (try_begin),
        #        (lt, ":player_party_size", 20),
        (ge, ":villagers_party_size", 30),
        (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
        (jump_to_menu, "mnu_village_start_attack"),
      (try_end),
    ],
    [
      ("take_supplies",[],"Take the supplies.",
        [(store_faction_of_party, ":faction_no", "$current_town"),
          (try_begin),
            (party_slot_ge, "$current_town", slot_center_player_relation, -60),
            (try_begin),
              (party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
              (call_script, "script_change_player_relation_with_center", "$current_town", -5), #chief cambia
              (call_script, "script_change_player_relation_with_faction" ,":faction_no", -10), #chief
            (else_try),
              (call_script, "script_change_player_relation_with_center", "$current_town", -10), #chief cambia
              (call_script, "script_change_player_relation_with_faction" ,":faction_no", -20), #chief
            (try_end),
          (try_end),
          (party_get_slot, ":village_lord", "$current_town", slot_town_lord),
          (try_begin),
            (gt,  ":village_lord", 1),
            (call_script, "script_change_player_relation_with_troop", ":village_lord", -15), #chief cambia
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -15), #
          (try_end),
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
          (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
          (val_mul, ":player_party_looting", 3),
          (store_sub, ":random_chance", 60, ":player_party_looting"), #Increases the chance of looting by 3% per skill level
          (try_for_range, ":slot_no", num_equipment_kinds ,max_inventory_items + num_equipment_kinds),
            (troop_get_inventory_slot, ":slot_item", ":merchant_troop", ":slot_no"),
            (try_begin),
              (neg|is_between,":slot_item", food_begin, food_end),
              (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
            (else_try),
              (store_random_in_range, ":rand", 0, 100),
              (lt, ":rand", ":random_chance"),
              (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
            (try_end),
          (try_end),
          
          ###NPC companion changes begin
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_steal_from_villagers"),
          #NPC companion changes end
          #Troop commentary changes begin
          (call_script, "script_add_log_entry", logent_village_extorted, "trp_player",  "$current_town", -1, -1),
          (store_faction_of_party,":village_faction",  "$current_town"),
          (call_script, "script_faction_inflict_war_damage_on_faction", "$players_kingdom", ":village_faction", 5),
          #Troop commentary changes end
          
          (jump_to_menu, "mnu_village"),
          (troop_sort_inventory, ":merchant_troop"),
          (change_screen_loot, ":merchant_troop"),
      ]),
      ("let_them_keep_it_2",[],"Let them keep it.",[(jump_to_menu, "mnu_village")]),
    ],
  ),
  
  
  (
    "village_start_attack",mnf_disable_all_keys,
    "Some of the angry villagers grab their tools and prepare to resist you. " +
    "It looks like you'll have a fight on your hands if you continue.",
    "none",
    [
      (set_background_mesh, "mesh_pic_villageriot"),
      #       (call_script, "script_party_count_members_with_full_health","p_main_party"),
      #       (assign, ":player_party_size", reg0),
      (call_script, "script_party_count_members_with_full_health","$current_town"),
      (assign, ":villagers_party_size", reg0),
      (store_faction_of_party, ":faction_no", "$current_town"), #
      (try_begin),
        #	     (store_random_in_range, ":random_no", 45, 800), #
        #         (gt, ":player_party_size", ":random_no"), #
        #        (jump_to_menu, "mnu_village_loot_no_resist"),
        #       (else_try),
        (this_or_next|eq, ":villagers_party_size", 0),
        (eq, "$g_battle_result", 1),
        (try_begin),
          (eq, "$g_battle_result", 1),
          (store_random_in_range, ":enmity", -30, -15),
          (call_script, "script_change_player_relation_with_center", "$current_town", ":enmity"),
          (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
          (try_begin),
            (gt, ":town_lord", 0),
            (call_script, "script_change_player_relation_with_troop", ":town_lord", -3),
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -3), #
          (try_end),
        (try_end),
        (jump_to_menu, "mnu_village_loot_no_resist"),
      (else_try),
        (eq, "$g_battle_result", -1),
        (jump_to_menu, "mnu_village_loot_defeat"),
      (try_end),
    ],
    [
      ("village_raid_attack",[],"Charge them.",[
          (store_random_in_range, ":enmity", -15, -10), #chief cambiado
          (store_faction_of_party, ":faction_no", "$current_town"), #
          (call_script, "script_change_player_relation_with_center", "$current_town", ":enmity"),
          (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
          (try_begin),
            (gt, ":town_lord", 0),
            (call_script, "script_change_player_relation_with_troop", ":town_lord", -15), #chief cambiado
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (neq, ":faction_leader","trp_player"),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -15), #chief cambiado
          (try_end),
          (call_script, "script_change_player_relation_with_faction" ,":faction_no", -10), #
          (call_script, "script_encounter_calculate_fit"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (assign, "$g_battle_result", 0),
          (assign, "$g_village_raid_evil", 1),
          (set_jump_mission,"mt_village_raid"),
          (party_get_slot, ":scene_to_use", "$current_town", slot_castle_exterior),
          (jump_to_scene, ":scene_to_use"),
          (assign, "$g_next_menu", "mnu_village_start_attack"),
          
          (call_script, "script_diplomacy_party_attacks_neutral", "p_main_party", "$g_encountered_party"),
          ###NPC companion changes begin
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_loot_village"),
          #NPC companion changes end
          
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ("village_raid_leave",[],"Leave this village alone.",[(change_screen_return)]),
    ],
  ),
  ###enslave villagers
  (
    "village_raid_villagers_toslaves",0,
    "Do you want to hunt the villagers down like animals and make them slaves?",
    "none",
    [(set_background_mesh, "mesh_pic_family"), #pic book
      (party_slot_eq, "$current_town", slot_center_enslaved, 0),
      (call_script, "script_party_count_members_with_full_health","$current_town"),
      #(display_message, "@Villager size is {reg0}"),
      (assign, ":villagers_party_size", reg0),
      (store_random_in_range, ":rebellion", 1, 100), #rebellion or run away
      (try_begin),
        (ge, ":rebellion", 40), #yes rebelion
        (ge, ":villagers_party_size", 40),
        (neg|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
        (jump_to_menu, "mnu_village_start_attack"),
      (else_try),
        (lt, ":rebellion", 40), #no rebelion
        (ge, ":villagers_party_size", 40),
        (party_clear, "p_temp_party"),
        (assign, "$g_move_heroes", 0),
        # JuJu70 less prisoners
        (store_random_in_range, ":rand1", 1, 6), #little prisoners, people run away
        (store_random_in_range, ":rand2", 1, 2),
        (party_add_prisoners, "p_temp_party", "trp_farmer", ":rand2"),
        (party_add_prisoners, "p_temp_party", "trp_peasant_woman", ":rand1"),
        (party_get_num_companions, ":num_rescued_prisoners", "p_temp_party"),
        (party_get_num_prisoners,  ":num_captured_enemies", "p_temp_party"),
        (store_add, ":total_capture_size", ":num_rescued_prisoners", ":num_captured_enemies"),
        (assign, reg44, ":total_capture_size"),
        #(display_message, "@total size is {reg44}"),
        (assign, "$temp", ":total_capture_size"),
        (eq, ":total_capture_size", 0),
        (jump_to_menu, "mnu_village_loot_no_resist_population_flee"),
      (else_try),
        (party_clear, "p_temp_party"),
        (assign, "$g_move_heroes", 0),
        # JuJu70 less prisoners
        (store_random_in_range, ":rand1", 6, 20),
        (store_random_in_range, ":rand2", 4, 12),
        (party_add_prisoners, "p_temp_party", "trp_farmer", ":rand2"),
        (party_add_prisoners, "p_temp_party", "trp_peasant_woman", ":rand1"),
        (party_get_num_companions, ":num_rescued_prisoners", "p_temp_party"),
        (party_get_num_prisoners,  ":num_captured_enemies", "p_temp_party"),
        (store_add, ":total_capture_size", ":num_rescued_prisoners", ":num_captured_enemies"),
        (assign, reg44, ":total_capture_size"),
        #(display_message, "@total size is {reg44}"),
        (assign, "$temp", ":total_capture_size"),
        (eq, ":total_capture_size", 0),
        (jump_to_menu, "mnu_village_loot_no_resist"),
      (try_end),
    ],
    [
      ("villagers_slaves",[(gt,"$temp", 0)],"Take all villagers prisoner!",
        [
          (store_random_in_range, ":enmity", -15, -10), #chief cambiado
          (store_faction_of_party, ":faction_no", "$current_town"), #
          (call_script, "script_change_player_relation_with_center", "$current_town", ":enmity"),
          (try_begin),
            (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
            (gt, ":town_lord", 0),
            (call_script, "script_change_player_relation_with_troop", ":town_lord", -10), #chief cambiado
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -10), #
          (try_end),
          (try_begin),
            (store_relation, ":relation", ":faction_no",  "$players_kingdom"),
            (ge, ":relation", 0),
            (call_script, "script_change_player_relation_with_faction" ,":faction_no", -5),
          (try_end),
          (party_set_slot, "$current_town", slot_center_enslaved, 1),
          (jump_to_menu, "mnu_village"),
          (change_screen_exchange_with_party, "p_temp_party"),
          (party_clear, "$current_town"),
      ]),
      ("no_cancel",[],"No. Cancel the order!",[		   (store_faction_of_party, ":faction_no", "$current_town"), #
          (call_script, "script_change_player_relation_with_center", "$current_town", -2),
          (try_begin),
            (store_relation, ":relation", ":faction_no",  "$players_kingdom"),
            (ge, ":relation", 0),
            (call_script, "script_change_player_relation_with_faction" ,":faction_no", -1),
          (try_end),
          
          (jump_to_menu, "mnu_village_loot_no_resist")]),
    ],
  ),
  
  (
    "village_loot_no_resist",0,
    "The villagers here are few and frightened, and they quickly scatter and run before you, but your men manage to catch some of them. " +
    "The village is at your mercy.",
    "none",
    [(set_background_mesh, "mesh_pic_villageriot"), #pic book
      (try_begin),
        (check_quest_active, "qst_cause_provocation"),
        (neg|check_quest_succeeded,"qst_cause_provocation"),
        (neg|check_quest_failed, "qst_cause_provocation"),
        (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
        (quest_slot_eq, "qst_cause_provocation", slot_quest_target_faction, ":defender_faction"),
        (call_script, "script_succeed_quest", "qst_cause_provocation"),
      (try_end),
    ],
    [
      ("village_plunder",[], "Plunder the village, then raze it.",
        [
          (call_script, "script_village_set_state", "$current_town", svs_being_raided),
          (party_set_slot, "$current_town", slot_village_raided_by, "p_main_party"),
          (assign,"$g_player_raiding_village","$current_town"),
          
          (try_begin),
            (store_faction_of_party, ":village_faction", "$current_town"),
            (store_relation, ":relation", "$players_kingdom", ":village_faction"),
            (ge, ":relation", 0),
            (call_script, "script_diplomacy_party_attacks_neutral", "p_main_party", "$current_town"),
          (try_end),
          
          (rest_for_hours, 3, 5, 1), #rest while attackable (3 hours will be extended by the trigger) #no attackable, native bug
          (change_screen_return),
      ]),
      #JuJu70 - continue with enslaving
      ("village_enslave",[(party_slot_eq, "$current_town", slot_center_enslaved, 0),],"Enslave the villagers.",
        [
          (party_clear, "p_temp_party"),
          (assign, "$g_move_heroes", 0),
          (store_random_in_range, ":rand1", 4, 30),
          (store_random_in_range, ":rand2", 4, 22),
          (party_add_prisoners, "p_temp_party", "trp_farmer", ":rand2"),
          (party_add_prisoners, "p_temp_party", "trp_peasant_woman", ":rand1"),
          (store_random_in_range, ":enmity", -15, -10), #chief cambiado
          (call_script, "script_change_player_relation_with_center", "$current_town", ":enmity"),
          (store_faction_of_party, ":faction_no", "$current_town"), #
          (party_get_slot, ":town_lord", "$current_town", slot_town_lord),
          (try_begin),
            (gt, ":town_lord", 0),
            (call_script, "script_change_player_relation_with_troop", ":town_lord", -10), #chief cambiado
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -10), #chief cambiado
          (try_end),
          (try_begin),
            (store_relation, ":relation", ":faction_no",  "$players_kingdom"),
            (ge, ":relation", 0),
            (call_script, "script_change_player_relation_with_faction" ,":faction_no", -10),
          (try_end),
          (party_set_slot, "$current_town", slot_center_enslaved, 1),
          (jump_to_menu, "mnu_village"),
          (change_screen_exchange_with_party, "p_temp_party"),
          (party_clear, "$current_town"),
      ]),
      # Continue with taking supplies
      ("take_supplies1",[],"Take the supplies.",
        [ (store_faction_of_party, ":faction_no", "$current_town"),
          (try_begin),
            (party_slot_ge, "$current_town", slot_center_player_relation, -60),
            (try_begin),
              (party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
              (call_script, "script_change_player_relation_with_center", "$current_town", -15), #chief cambia
              #(call_script, "script_change_player_relation_with_faction" ,":faction_no", -10), #chief
            (else_try),
              (call_script, "script_change_player_relation_with_center", "$current_town", -10), #chief cambia
              (call_script, "script_change_player_relation_with_faction" ,":faction_no", -20), #chief
            (try_end),
          (try_end),
          (party_get_slot, ":village_lord", "$current_town", slot_town_lord),
          (try_begin),
            (gt,  ":village_lord", 0),
            (call_script, "script_change_player_relation_with_troop", ":village_lord", -15), #chief cambia
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (neq, ":faction_leader","trp_player"),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -15), #chief cambiado
          (try_end),
          
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
          (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
          (val_mul, ":player_party_looting", 3),
          (store_sub, ":random_chance", 70, ":player_party_looting"), #Increases the chance of looting by 3% per skill level
          (try_for_range, ":slot_no", num_equipment_kinds ,max_inventory_items + num_equipment_kinds),
            (troop_get_inventory_slot, ":slot_item", ":merchant_troop", ":slot_no"),
            (try_begin),
              (neg|is_between,":slot_item", food_begin, food_end),
              (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
            (else_try),
              (store_random_in_range, ":rand", 0, 100),
              (lt, ":rand", ":random_chance"),
              (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
            (try_end),
          (try_end),
          
          ###NPC companion changes begin
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_steal_from_villagers"),
          #NPC companion changes end
          #Troop commentary changes begin
          (call_script, "script_add_log_entry", logent_village_extorted, "trp_player",  "$current_town", -1, -1),
          (store_faction_of_party,":village_faction",  "$current_town"),
          (call_script, "script_faction_inflict_war_damage_on_faction", "$players_kingdom", ":village_faction", 5),
          #Troop commentary changes end
          
          (jump_to_menu, "mnu_village"),
          (troop_sort_inventory, ":merchant_troop"),
          (change_screen_loot, ":merchant_troop"),
      ]),
      
      ("village_raid_leave",[],"Leave this village alone.",[(change_screen_return)]),
    ],
  ),
  ###looting when villagers run away
  (
    "village_loot_no_resist_population_flee",0,
    "Most villagers ran away when they saw your army. " +
    "The village is at your mercy.",
    "none",
    [(set_background_mesh, "mesh_pic_villageriot"), #pic book
      (try_begin),
        (check_quest_active, "qst_cause_provocation"),
        (neg|check_quest_succeeded,"qst_cause_provocation"),
        (neg|check_quest_failed, "qst_cause_provocation"),
        (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
        (quest_slot_eq, "qst_cause_provocation", slot_quest_target_faction, ":defender_faction"),
        (call_script, "script_succeed_quest", "qst_cause_provocation"),
      (try_end),
    ],
    [
      ("village_lootflee",[], "Plunder the village, then raze it.",
        [
          (call_script, "script_village_set_state", "$current_town", svs_being_raided),
          (party_set_slot, "$current_town", slot_village_raided_by, "p_main_party"),
          (assign,"$g_player_raiding_village","$current_town"),
          
          (try_begin),
            (store_faction_of_party, ":village_faction", "$current_town"),
            (store_relation, ":relation", "$players_kingdom", ":village_faction"),
            (ge, ":relation", 0),
            (call_script, "script_diplomacy_party_attacks_neutral", "p_main_party", "$current_town"),
          (try_end),
          
          (rest_for_hours, 3, 5, 1), #rest while attackable (3 hours will be extended by the trigger) #no attackable, native bug
          (change_screen_return),
      ]),
      # Continue with taking supplies
      ("take_supplies1flee",[],"Take the supplies.",
        [ (store_faction_of_party, ":faction_no", "$current_town"),
          (try_begin),
            (party_slot_ge, "$current_town", slot_center_player_relation, -60),
            (try_begin),
              (party_slot_eq, "$current_town", slot_town_lord, "trp_player"),
              (call_script, "script_change_player_relation_with_center", "$current_town", -15), #chief cambia
              #(call_script, "script_change_player_relation_with_faction" ,":faction_no", -10), #chief
            (else_try),
              (call_script, "script_change_player_relation_with_center", "$current_town", -10), #chief cambia
              (call_script, "script_change_player_relation_with_faction" ,":faction_no", -20), #chief
            (try_end),
          (try_end),
          (party_get_slot, ":village_lord", "$current_town", slot_town_lord),
          (try_begin),
            (gt,  ":village_lord", 0),
            (call_script, "script_change_player_relation_with_troop", ":village_lord", -15), #chief cambia
          (else_try),
            (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
            (neq, ":faction_leader","trp_player"),
            (call_script, "script_change_player_relation_with_troop", ":faction_leader", -15), #chief cambiado
          (try_end),
          
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
          (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
          (val_mul, ":player_party_looting", 3),
          (store_sub, ":random_chance", 70, ":player_party_looting"), #Increases the chance of looting by 3% per skill level
          (try_for_range, ":slot_no", num_equipment_kinds ,max_inventory_items + num_equipment_kinds),
            (troop_get_inventory_slot, ":slot_item", ":merchant_troop", ":slot_no"),
            (try_begin),
              (neg|is_between,":slot_item", food_begin, food_end),
              (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
            (else_try),
              (store_random_in_range, ":rand", 0, 100),
              (lt, ":rand", ":random_chance"),
              (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
            (try_end),
          (try_end),
          
          ###NPC companion changes begin
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_steal_from_villagers"),
          #NPC companion changes end
          #Troop commentary changes begin
          (call_script, "script_add_log_entry", logent_village_extorted, "trp_player",  "$current_town", -1, -1),
          (store_faction_of_party,":village_faction",  "$current_town"),
          (call_script, "script_faction_inflict_war_damage_on_faction", "$players_kingdom", ":village_faction", 5),
          #Troop commentary changes end
          
          (jump_to_menu, "mnu_village"),
          (troop_sort_inventory, ":merchant_troop"),
          (change_screen_loot, ":merchant_troop"),
      ]),
      
      ("village_raid_leaveflee",[],"Leave this village alone.",[(change_screen_return)]),
    ],
  ),
  #####################
  (
    "village_loot_complete",mnf_disable_all_keys,
    "On your orders, your troops sack the village, pillaging everything of any value, " +
    "and then put the buildings to the torch. From the coins and valuables that are found, you get your share of {reg1} peningas.",
    "none",
    [(set_background_mesh, "mesh_pic_vc_plundering_monastery"), #pic book
      (get_achievement_stat, ":number_of_village_raids", ACHIEVEMENT_THE_BANDIT, 0),
      (get_achievement_stat, ":number_of_caravan_raids", ACHIEVEMENT_THE_BANDIT, 1),
      (val_add, ":number_of_village_raids", 1),
      (set_achievement_stat, ACHIEVEMENT_THE_BANDIT, 0, ":number_of_village_raids"),
      
      (try_begin),
        (ge, ":number_of_village_raids", 3),
        (ge, ":number_of_caravan_raids", 3),
        (unlock_achievement, ACHIEVEMENT_THE_BANDIT),
      (try_end),
      
      (party_get_slot, ":village_lord", "$current_town", slot_town_lord),
      (store_faction_of_party, ":faction_no", "$current_town"),
      (try_begin),
        (gt,  ":village_lord", 0),
        (call_script, "script_change_player_relation_with_troop", ":village_lord", -10),
      (else_try),
        (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader),
        (neq, ":faction_leader","trp_player"),
        (call_script, "script_change_player_relation_with_troop", ":faction_leader", -10), #chief cambiado
      (try_end),
      (store_random_in_range, ":enmity", -35, -25),
      (call_script, "script_change_player_relation_with_center", "$current_town", ":enmity"),
      
      #       (store_relation, ":relation", ":faction_no", "fac_player_faction"),
      (call_script, "script_change_player_relation_with_faction", ":faction_no", -5),
      
      
      (assign, ":money_gained", 20),
      (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
      (store_mul, ":prosperity_of_village_mul_5", ":prosperity", 5),
      (val_add, ":money_gained", ":prosperity_of_village_mul_5"),
      (call_script, "script_troop_add_gold", "trp_player", ":money_gained"),
      
      (assign, ":morale_increase", 3),
      (store_div, ":money_gained_div_100", ":money_gained", 100),
      (val_add, ":morale_increase", ":money_gained_div_100"),
      (call_script, "script_change_player_party_morale", ":morale_increase"),
      
      
      (faction_get_slot, ":faction_morale", ":faction_no",  slot_faction_morale_of_player_troops),
      (store_mul, ":morale_increase_mul_2", ":morale_increase", 200),
      (val_sub, ":faction_morale", ":morale_increase_mul_2"),
      (faction_set_slot, ":faction_no",  slot_faction_morale_of_player_troops, ":faction_morale"),
      (try_begin),
        (check_quest_active, "qst_cause_provocation"),
        (neg|check_quest_succeeded,"qst_cause_provocation"),
        (neg|check_quest_failed, "qst_cause_provocation"),
        (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
        (quest_slot_eq, "qst_cause_provocation", slot_quest_target_faction, ":defender_faction"),
        (call_script, "script_succeed_quest", "qst_cause_provocation"),
      (try_end),
      #NPC companion changes begin
      (call_script, "script_objectionable_action", tmt_humanitarian, "str_loot_village"),
      #NPC companion changes end
      (assign, reg1, ":money_gained"),
    ],
    [
      ("continue",[], "Continue...",
        [
          (jump_to_menu, "mnu_close"),
          (call_script, "script_calculate_amount_of_cattle_can_be_stolen", "$current_town"),
          (assign, ":max_cattle", reg0),
          (val_mul, ":max_cattle", 3),
          (val_div, ":max_cattle", 2),
          (party_get_slot, ":num_cattle", "$current_town", slot_village_number_of_cattle),
          (val_min, ":max_cattle", ":num_cattle"),
          #         (val_add, ":max_cattle", 1),
          (store_random_in_range, ":random_value", 0, ":max_cattle"),
          (try_begin),
            (gt, ":random_value", 0),
            (call_script, "script_create_cattle_herd", "$current_town", ":random_value"),
            (val_sub, ":num_cattle", ":random_value"),
            (party_set_slot, "$current_town", slot_village_number_of_cattle, ":num_cattle"),
          (try_end),
          (troop_clear_inventory, "trp_temp_troop"),
          
          #below line changed with below lines to make plunder result more realistic. Now only items produced in bound town can be stolen after raid.
          #(reset_item_probabilities,100),
          
          #begin of changes
          (party_get_slot, ":bound_town", "$current_town", slot_village_bound_center),
          (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin),
          (reset_item_probabilities,0),
          (assign, ":total_probability", 0),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_get_slot, ":cur_price", ":bound_town", ":cur_price_slot"),
            (gt, ":cur_price", 0),
            (call_script, "script_center_get_production", ":bound_town", ":cur_goods"),
            (assign, ":cur_probability", reg0),
            (call_script, "script_center_get_consumption", ":bound_town", ":cur_goods"),
            (val_div, reg0, 3),
            (val_sub, ":cur_probability", reg0),
            (val_mul, ":cur_probability", 4),
            (val_mul, ":cur_probability", average_price_factor),
            (val_div, ":cur_probability", ":cur_price"),
            (val_max, ":cur_probability", 0),
            #first only simulation
            #(set_item_probability_in_merchandise,":cur_goods",":cur_probability"),
            (val_add, ":total_probability", ":cur_probability"),
          (try_end),
          
          (reset_item_probabilities,0),
          (try_for_range, ":cur_goods", trade_goods_begin, trade_goods_end),
            (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"),
            (party_get_slot, ":cur_price", ":bound_town", ":cur_price_slot"),
            (gt, ":cur_price", 0),
            (call_script, "script_center_get_production", ":bound_town", ":cur_goods"),
            (assign, ":cur_probability", reg0),
            (gt, ":cur_probability", 0),
            (call_script, "script_center_get_consumption", ":bound_town", ":cur_goods"),
            (val_div, reg0, 3),
            (val_sub, ":cur_probability", reg0),
            (val_mul, ":cur_probability", 4),
            (val_mul, ":cur_probability", average_price_factor),
            (val_div, ":cur_probability", ":cur_price"),
            (val_max, ":cur_probability", 0),
            (val_mul, ":cur_probability", num_merchandise_goods),
            (val_mul, ":cur_probability", 100),
            (val_div, ":cur_probability", ":total_probability"),
            (val_max, ":cur_probability", 5),
            # Limiting to food and agriculturl items
            (try_begin),
              (this_or_next|eq, ":cur_goods", "itm_raw_flax"),
              (this_or_next|eq, ":cur_goods", "itm_wool"),
              (this_or_next|eq, ":cur_goods", "itm_vc_raw_leather"),
              (this_or_next|eq, ":cur_goods", "itm_timber"),
              (this_or_next|eq, ":cur_goods", "itm_vc_furs"),
              (is_between, ":cur_goods", food_begin, food_end),
              (set_item_probability_in_merchandise,":cur_goods",":cur_probability"),
            (else_try),
              (set_item_probability_in_merchandise,":cur_goods",0),
            (try_end),
            # End of limiting
          (try_end),
          (set_item_probability_in_merchandise,"itm_jewelry",0),
          #end of changes
          (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
          (try_begin),
            (ge, ":prosperity", 40),
            (troop_add_merchandise,"trp_temp_troop",itp_type_goods,22),
          (else_try),
            (is_between, ":prosperity", 20, 40),
            (troop_add_merchandise,"trp_temp_troop",itp_type_goods,17),
          (else_try),
            (is_between, ":prosperity", 0, 20),
            (troop_add_merchandise,"trp_temp_troop",itp_type_goods,11),
          (else_try),
            (troop_add_merchandise,"trp_temp_troop",itp_type_goods,5),
          (try_end),
          (troop_sort_inventory, "trp_temp_troop"),
          (change_screen_loot, "trp_temp_troop"),
      ]),
    ],
  ),
  (
    "village_loot_defeat",0,
    "Fighting with courage and determination, the villagers manage to hold together and drive off your forces.",
    "none",
    [
      (set_background_mesh, "mesh_pic_villageriot"),
      (try_begin),
        (check_quest_active, "qst_cause_provocation"),
        (neg|check_quest_succeeded,"qst_cause_provocation"),
        (neg|check_quest_failed, "qst_cause_provocation"),
        (store_faction_of_party, ":defender_faction", "$g_encountered_party"),
        (quest_slot_eq, "qst_cause_provocation", slot_quest_target_faction, ":defender_faction"),
        (call_script, "script_fail_quest", "qst_cause_provocation"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",[(change_screen_return)]),
    ],
  ),
  
  (
    "village_loot_continue",0,
    "Do you wish to continue looting this village?",
    "none",
    [(set_background_mesh, "mesh_pic_vc_plundering_monastery"), #pic book
    ],
    [
      ("yes_dot",[],"Yes.",[ (rest_for_hours, 3, 5, 1), #rest while attackable (3 hours will be extended by the trigger)
          (change_screen_return),
      ]),
      ("no_dot",[],"No.",[(call_script, "script_village_set_state", "$current_town", svs_normal),
          (assign, "$g_player_raiding_village", 0),
          (change_screen_return)]),
    ],
  ),
  
  (
    "close",0,
    "Nothing.",
    "none",
    [
      (change_screen_return),
    ],
    [],
  ),
  
  (
    "town",mnf_enable_hot_keys,
    "{!}{s30}",
    "none",
    [
      (assign, ":block_vc_menu", 0),	#vc_menu
      
      (try_begin),
        (eq, "$sneaked_into_town", 1),
        (call_script, "script_music_set_situation_with_culture", mtf_sit_town_infiltrate),
      (else_try),
        (call_script, "script_music_set_situation_with_culture", mtf_sit_travel),
      (try_end),
      (store_encountered_party, "$current_town"),
      ###storyline
      (try_begin), #mainquest chief
        (eq, "$current_town", "p_castle_9"),
        (check_quest_active,"qst_sven_traitor"),
        (jump_to_menu, "mnu_nothingam_siege"),
      (try_end),
      ######
      
      #chief lord player anadido
      (party_get_slot, ":lord", "$current_town", slot_town_lord),
      (try_begin),
        (eq, ":lord", "trp_player"),
        ####random events when player is lord - juices chief, riots, etc...
        (neg|is_currently_night),
        (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting)
        (party_slot_eq, "$current_town", slot_center_is_besieged_by, -1),
        (store_party_size_wo_prisoners, ":num_men", "p_main_party"),
        (try_begin),
          (gt, ":num_men", 40), #40 men necesary for events.
          (eq, "$lord_event_possible", 0),
          (assign, "$lord_event_possible", 1), #possible each 90 hours. Only possible once when player enter to town, no while move around menus. VC-3447
          (store_random_in_range, ":ratio_event", 0, 100),
          (try_begin),
            (lt, ":ratio_event", 15), #15%
            (eq, "$sneaked_into_town", 0),#Skip if sneaked
            
            (try_begin),
              (eq, "$event_oneuse", 0),
              (assign, ":event_juice", "mnu_event_05_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 1),
              (assign, ":event_juice", "mnu_event_02_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 2),
              (assign, ":event_juice", "mnu_event_09_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 3),
              (assign, ":event_juice", "mnu_event_04_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 4),
              (assign, ":event_juice", "mnu_event_01_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 5),
              (assign, ":event_juice", "mnu_event_06_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 6),
              (assign, ":event_juice", "mnu_event_14_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 7),
              (assign, ":event_juice", "mnu_event_08_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 8),
              (assign, ":event_juice", "mnu_event_03_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 9),
              (assign, ":event_juice", "mnu_event_10_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 10),
              (assign, ":event_juice", "mnu_event_17_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 11),
              (assign, ":event_juice", "mnu_event_12_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 12),
              (assign, ":event_juice", "mnu_event_13_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 13),
              (assign, ":event_juice", "mnu_event_07_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 14),
              (assign, ":event_juice", "mnu_event_18_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 15),
              (assign, ":event_juice", "mnu_event_16_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 16),
              (assign, ":event_juice", "mnu_event_11_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 17),
              (assign, ":event_juice", "mnu_event_15_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 18),
              (assign, ":event_juice", "mnu_event_19_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 19),
              (assign, ":event_juice", "mnu_event_22_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 20),
              (assign, ":event_juice", "mnu_event_21_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              (eq, "$event_oneuse", 21),
              (assign, ":event_juice", "mnu_event_20_juicio"),
              (val_add, "$event_oneuse", 1),
            (else_try),
              #(ge, "$event_oneuse", 21),
              (store_random_in_range, ":event_juice", "mnu_event_16_juicio", "mnu_event_22_juicio"),
            (try_end),
            
            (jump_to_menu, ":event_juice"),
            (assign, ":block_vc_menu", 1),	#vc_menu
            # (assign, "$lord_event_possible", 1), #possible each 90 hours
          (try_end),
        (try_end),
        
        (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
        (try_begin),
          (gt, ":num_men", 40), #40 men necesary for events.
          (lt, ":center_relation", -30), #negative relations = possible riots
          (eq, "$lord_event_possible", 0),
          #(assign, ":continue", 1),
          
          (store_random_in_range, ":ratio_event", 0, 100),
          (try_begin),
            (lt, ":ratio_event", 5), #5%, people fear fight againts his lord, break laws
            (jump_to_menu, "mnu_riots_01"),
            (assign, ":block_vc_menu", 1),	#vc_menu
            (assign, "$lord_event_possible", 1), #possible each 90 hours
          (else_try),
            (lt, ":ratio_event", 15), #7%, people fear fight againts his lord, break laws
            (jump_to_menu, "mnu_riots_02"),
            (assign, ":block_vc_menu", 1),	#vc_menu
            (assign, "$lord_event_possible", 1), #possible each 90 hours
          (else_try),
            (display_message,"@People aren't very happy with your presence in their home."),
          (try_end),
        (try_end),
      (try_end),
      #chief anadido acaba
      (call_script, "script_update_center_recon_notes", "$current_town"),
      (assign, "$g_defending_against_siege", 0),
      (str_clear, s3),
      (party_get_battle_opponent, ":besieger_party", "$current_town"),
      (store_faction_of_party, ":encountered_faction", "$g_encountered_party"),
      (store_relation, ":faction_relation", ":encountered_faction", "fac_player_faction"),
      (try_begin),
        (gt, ":besieger_party", 0),
        (ge, ":faction_relation", 0),
        (store_faction_of_party, ":besieger_party_faction", ":besieger_party"),
        (store_relation, ":besieger_party_relation", ":besieger_party_faction", "fac_player_faction"),
        (lt, ":besieger_party_relation", 0),
        (assign, "$g_defending_against_siege", 1),
        (assign, "$g_siege_first_encounter", 1),
        (jump_to_menu, "mnu_siege_started_defender"),
        (assign, ":block_vc_menu", 1),	#vc_menu
      (try_end),
      
      (try_begin),
        (is_between, "$g_encountered_party", towns_begin, towns_end),
        (store_sub, ":encountered_town_no", "$g_encountered_party", towns_begin),
        (set_achievement_stat, ACHIEVEMENT_MIGRATING_COCONUTS, ":encountered_town_no", 1),
        
        (assign, ":there_are_villages_not_visited", 0),
        (try_for_range, ":cur_town", towns_begin, towns_end),
          (store_sub, ":encountered_town_no", ":cur_town", towns_begin),
          (get_achievement_stat, ":town_is_visited", ACHIEVEMENT_MIGRATING_COCONUTS, ":encountered_town_no"),
          (eq, ":town_is_visited", 0),
          (assign, ":there_are_villages_not_visited", 1),
        (try_end),
        
        (try_begin),
          (eq, ":there_are_villages_not_visited", 0),
          (unlock_achievement, ACHIEVEMENT_MIGRATING_COCONUTS),
        (try_end),
      (try_end),
      
      #Quest menus
      
      (assign, "$qst_collect_taxes_currently_collecting", 0),
      
      (try_begin),
        (gt, "$quest_auto_menu", 0),
        (jump_to_menu, "$quest_auto_menu"),
        (assign, ":block_vc_menu", 1),	#vc_menu
        (assign, "$quest_auto_menu", 0),
      (try_end),
      
      (try_begin),
        ##          (eq, "$g_center_under_siege_battle", 1),
        ##          (jump_to_menu,"mnu_siege_started_defender"),
        ##        (else_try),
        (eq, "$g_town_assess_trade_goods_after_rest", 1),
        (assign, "$g_town_assess_trade_goods_after_rest", 0),
        (jump_to_menu,"mnu_town_trade_assessment"),
        (assign, ":block_vc_menu", 1),	#vc_menu
      (try_end),
      
      (assign, "$talk_context", 0),
      (assign,"$all_doors_locked",0),
      
      (try_begin),
        (eq, "$g_town_visit_after_rest", 1),
        (assign, "$g_town_visit_after_rest", 0),
        (assign, "$town_entered", 1),
      (try_end),
      
      (try_begin),
        (eq,"$g_leave_town",1),
        (assign,"$g_leave_town",0),
        (assign,"$g_permitted_to_center",0),
        (leave_encounter),
        (change_screen_return),
      (try_end),
      
      (str_store_party_name, s2, "$current_town"),
      (party_get_slot, ":center_lord", "$current_town", slot_town_lord),
      (store_faction_of_party, ":center_faction", "$current_town"),
      (str_store_faction_name, s9, ":center_faction"),
      
      #Religion chief fe faith empieza
      #chief fe faith empieza cristianismo
      (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
      (try_begin),
        (eq, "$g_player_faith", 1), #player es cristiano
        (try_begin),
          (lt, ":faith", 30),
          (str_store_string, s15, "@^Christians aren't welcome here."),
        (else_try),
          (lt, ":faith", 50),
          (str_store_string, s15, "@^Christians are accepted here."),
        (else_try),
          (lt, ":faith", 65),
          (str_store_string, s15, "@^Christians are in the majority here."),
        (else_try),
          (lt, ":faith", 80),
          (str_store_string, s15, "@^Christians are dominant here."),
        (else_try),
          (lt, ":faith", 101),
          (str_store_string, s15, "@^This town is a bastion of your faith."),
        (else_try),
          (str_store_string, s15, "@^Rumor has it that Christian faith is nothing more than a veil, and the population continues to worship pagan gods..."),
        (try_end),
      (try_end),
      #chief fe faith empieza paganismo
      (try_begin),
        (eq, "$g_player_faith", 2), #player is pagan
        (store_sub, ":p_faith", 100, ":faith"),
        (try_begin),
          (lt, ":p_faith", 30),
          (str_store_string, s15, "@^Pagans aren't welcome here."),
        (else_try),
          (lt, ":p_faith", 50),
          (str_store_string, s15, "@^Pagans are accepted here."),
        (else_try),
          (lt, ":p_faith", 65),
          (str_store_string, s15, "@^Pagans are in the majority here."),
        (else_try),
          (lt, ":p_faith", 80),
          (str_store_string, s15, "@^Pagans are dominant here."),
        (else_try),
          (lt, ":p_faith", 101),
          (str_store_string, s15, "@^This town is a bastion of your faith."),
        (else_try),
          (str_store_string, s15, "@^Rumor has it that old pagan gods are being forgotten in favour of Christendom."),
        (try_end),
      (try_end),
      #Religion end chief
      
      (try_begin),
        (ge, ":center_lord", 0),
        (str_store_troop_name,s8,":center_lord"),
        (str_store_string,s7,"@{s8} of the {s9}"),
      (try_end),
      
      (try_begin),
        (party_slot_eq,"$current_town",slot_party_type, spt_town),
        (str_store_string, s60, s2),
        (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
        (try_begin),
          (ge, "$cheat_mode", 1),
          (assign, reg4, ":prosperity",),
          (display_message, "@{!}DEBUG -- Prosperity: {reg4}"),
        (try_end),
        (store_div, ":str_id", ":prosperity", 10),
        (val_min, ":str_id", 9),
        (val_add, ":str_id", "str_town_prosperity_0"),
        (str_store_string, s10, ":str_id"),
        (store_div, ":str_id", ":prosperity", 20),
        (val_min, ":str_id", 4),
        (val_add, ":str_id", "str_town_alt_prosperity_0"),
        (str_store_string, s14, ":str_id"),
      (else_try),
        #phaiak begin
        (str_store_string, s60, s2),
        (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
        (store_div, ":str_id", ":prosperity", 10),
        (val_min, ":str_id", 9),
        (val_add, ":str_id", "str_fort_prosperity_0"),
        (str_store_string, s10, ":str_id"),
        #phaiak end
        (str_clear, s14),
        #(str_store_string,s10,"@You are at {s2}."),
      (try_end),
      
      (try_begin),
        (party_slot_eq,"$current_town",slot_party_type, spt_castle),
        (try_begin),
          (eq, ":center_lord", "trp_player"),
          (str_store_string,s11,"@ As you reach the settlement, you are greeted by your men.^{s15}"),
        (else_try),
          (gt, ":center_lord", -1),
          (troop_slot_eq, ":center_lord", slot_troop_spouse, "trp_player"),
          (str_store_string,s11,"str__you_see_the_banner_of_your_wifehusband_s7_over_the_castle_gate"),
          (str_store_string, s11, "@{s11}^{s15}"),
        (else_try),
          (ge, ":center_lord", 0),
          (str_store_string,s11,"@ As you reach the settlement, you are greeted by men loyal to {s7}.^{s15}"),
        (else_try),
          ##            (str_store_string,s11,"@ This castle seems to belong to no one."),
          # (str_store_string,s11,"@ This castle has no garrison."),		# "No owner" doesn't mean "no garrison"!
          (str_store_string,s11,"@ This fort seems to belong to no one.^{s15}"), #VC-1938
        (try_end),
      (else_try),
        (try_begin),
          (eq, ":center_lord", "trp_player"),
          (str_store_string,s11,"@You are greeted by men loyal to you.^{s15}"),
        (else_try),
          (gt, ":center_lord", -1),
          (troop_slot_eq, ":center_lord", slot_troop_spouse, "trp_player"),
          (str_store_string,s11,"str__the_banner_of_your_wifehusband_s7_flies_over_the_town_gates"),
          (str_store_string, s11, "@{s11}^{s15}"),
        (else_try),
          (ge, ":center_lord", 0),
          (str_store_string,s11,"@You are greeted by men loyal to {s7}.^{s15}"),
        (else_try),
          ##            (str_store_string,s11,"@ The townsfolk here have declared their independence."),
          # (str_store_string,s11,"@This town has no garrison.^{s15}"),	# "No owner" doesn't mean "no garrison"!
          (str_store_string,s11,"@ This town seems to belong to no one.^{s15}"), #VC-1938
        (try_end),
      (try_end),
      
      (str_clear, s12),
      (try_begin),
        #         (party_slot_eq,"$current_town",slot_party_type, spt_town),
        (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
        (call_script, "script_describe_center_relation_to_s3", ":center_relation"),
        (assign, reg9, ":center_relation"),
        (str_store_string, s12, "@{!} {s3} ({reg9})."),
      (try_end),
      
      (str_clear, s13),
      (try_begin),
        (gt,"$entry_to_town_forbidden",0),
        (str_store_string, s13, "@ You have successfully sneaked in."),
      (else_try),
        (faction_slot_eq, ":center_faction", slot_faction_ai_state, sfai_feast),
        (faction_slot_eq, ":center_faction", slot_faction_ai_object, "$current_town"),
        
        (str_store_string, s13, "str__the_lord_is_currently_holding_a_feast_in_his_hall"),
      (try_end),
      
      #version check
      (try_begin),
        (assign, reg0, 0),
        (get_operation_set_version, reg0),
        (gt, reg0, warband_version-3),
        
        #forbidden to enter?
        (try_begin),
          (store_time_of_day,reg(12)),
          (ge,reg(12),5),
          (lt,reg(12),21),
          (assign,"$town_nighttime",0),
        (else_try),
          (assign,"$town_nighttime",1),
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
          (str_store_string, s13, "str_town_nighttime"),
        (try_end),
        
        (try_begin),
          (party_slot_ge, "$current_town", slot_town_has_tournament, 1),
          (neg|party_slot_ge, "$current_town", slot_party_looted_left_days, 1),
          (neg|is_currently_night),
          (party_set_slot, "$current_town", slot_town_has_tournament, 1),
          (str_store_string, s13, "@{s13} A tournament will be held here soon."),
        (try_end),
        
        (assign,"$castle_undefended",0),
        (party_get_num_companions, ":castle_garrison_size", "p_collective_enemy"),
        (try_begin),
          (eq,":castle_garrison_size",0),
          (assign,"$castle_undefended",1),
        (try_end),
        
        # Phaiak begin (new menu)
        (str_store_string, s30, "@{s10} {s14}^{s11}{s12}{s13}"),
        (try_begin),
          # vc_menu on
          (neq, "$g_vc_menu_turned_off", 1),
          (eq, ":block_vc_menu", 0),	#vc_menu
          (try_begin),
            (gt, "$vc_menu_result", 0),
            (call_script, "script_execute_town_menu_cosequence", "$vc_menu_result"),
            (assign, "$vc_menu_result", 0),
          (else_try),
            (try_begin),
              (eq, "$vc_menu_active", 0),
              (assign, "$vc_menu_active", "prsnt_vc_menu"),
            (end_try),
            #(str_store_string, s30, "@{s10} {s14}^{s11}{s12}{s13}"),
            (try_begin),
              (party_slot_eq,"$current_town",slot_party_type, spt_castle),
              (call_script, "script_execute_town_menu_cosequence", slot_quest_menu_castle_visit),#castle
            (else_try),
              (call_script, "script_execute_town_menu_cosequence", slot_quest_menu_town_visit),#town
            (end_try),
          (end_try),
          
        (else_try),
          # vc_menu off
          (assign, "$vc_menu_active", 0),
          (call_script, "script_set_town_picture"),
          ## lord show chief
          (try_begin),
            (party_get_slot, ":center_lord", "$current_town", slot_town_lord),
            (ge, ":center_lord", 0),
            (set_fixed_point_multiplier, 100),
            (position_set_x, pos0, 70),
            (position_set_y, pos0, 5),
            (position_set_z, pos0, 75),
            (set_game_menu_tableau_mesh, "tableau_troop_note_mesh", ":center_lord", pos0),
          (try_end),
          ## chief acaba
          (call_script, "script_check_town_menu_conditions"),
          (assign, "$curr_menu_slot", 30),
        (end_try),
        # Phaiak end
      (try_end),  #version check
      
      #		(str_clear, s5), #alert player that there are new rumors
      #		(try_begin),
      #			(eq, 1, 0),
      #			(neg|is_currently_night),
      #			(str_store_string, s5, "@^The buzz of excited voices as you come near the gate suggests to you that news of some import is circulating among the townsfolk."),
      #			(lt, "$last_town_log_entry_checked", "$num_log_entries"),
      #			(assign, "$g_town_rumor_log_entry", 0),
      #			(try_for_range, ":log_entry", "$last_town_log_entry_checked", "$num_log_entries"),
      #				(eq, ":log_entry", 4123), #placeholder to avoid having unused variable error message
      #			(try_end),
      #			(assign, "$last_town_log_entry_checked", "$num_log_entries"),
      #		(try_end),
    ],
    [
      ("castle_castle",#1
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Visit the lord's hall.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_1),], "To the Meduseld."),
      
      ("join_tournament",#2
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Join the Competition.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_2),]),
      
      ("town_castle",#3
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Visit the lord's hall.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_3),], "To the Meduseld."),
      
      ("town_center",#4
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Stroll through town.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_4),],"To the center of town."),
      
      # ("town_mayor",#4.1#disabled(VC-2663)
      # [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
      # ],"Meet the mayor.",
      # [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_4 + 1),]),
      
      ("town_tavern",#5
        [(val_add, "$curr_menu_slot", 2),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),#we need to add 2 to curr_menu_slot here because of VC-2663
        ],"Visit the mead hall.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_5 + 1),],"To the mead hall."),
      
      ("town_merchant",#6
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Speak with the merchant.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_6 + 1),],"To the merchant."),
      
      ("town_arena",#7
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Visit the training grounds.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_7 + 1),],"To the training grounds."),
      
      ("town_dungeon",#8
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Never: Enter the prison.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_8 + 1),],"To the prison."),
      
      ("castle_inspect", #9
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Tour the grounds.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_9 + 1),], "Leave."),
      
      ("town_enterprise",#10
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Visit your farmstead.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_10 + 1),],"To your enterprise."),
      
      ("visit_lady",#11
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Attempt to visit a lady.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_11 + 1),], "To the garden."),
      
      ("trade_with_merchants",#12
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Trade with locals.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_12 + 1),]),
      
      ("travel",  #13 Needs work
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Travel to another port.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_13 + 1),],"Outfit your party."),
      
      ("walled_center_manage",#14
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Manage this {reg0?town:castle}.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_14 + 1),]),
      
      ("walled_center_move_court",#15
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Move your court here.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_15 + 1),]),
      
      ("castle_station_troops",#16
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Manage the garrison.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_16 + 1),]),
      
      ("castle_wait",#17
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Wait here for some time.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_17 + 1),],"Bed."),
      
      ("town_alley",#18
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Ask for potential recruits.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_18 + 1),]),
      
      ("town_visit_port",#19
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"See the ships.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_19 + 1),]),
      
      ("collect_taxes_qst",#20
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"{reg5?Continue collecting taxes:Collect taxes}.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_20 + 1),]),
      
      ("banquete_mead",#21
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"My men deserve a symbel. Buy mead and food.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_21 + 1),],"Set sail."),
      
      ("set_sail",#22
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Sail from port.",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_22 + 1),],"Set sail."),
      
      ("town_leave",#23
        [(val_add, "$curr_menu_slot", 1),(quest_slot_ge, "qst_vc_menu", "$curr_menu_slot", 1),
        ],"Leave...",
        [(call_script, "script_execute_town_menu_cosequence", slot_quest_menu_23 + 1),],"Leave Area."),
      
      #### following mno's are not included into vc menu yet...
      
      ("castle_cheat_alley",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT! Alley.",
        [
          (party_get_slot, reg11, "$current_town", slot_town_alley),
          (set_jump_mission, "mt_ai_training"),
          (jump_to_scene, reg11),
          (change_screen_mission),
      ]),
      
      
      ("castle_cheat_interior",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT! Interior.",
        [
          (set_jump_mission,"mt_ai_training"),
          (party_get_slot, ":castle_scene", "$current_town", slot_town_castle),
          (jump_to_scene,":castle_scene"),
          (change_screen_mission),
      ]),
      
      ("castle_cheat_town_exterior",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT! Exterior.",
        [
          (try_begin),
            (party_slot_eq, "$current_town",slot_party_type, spt_castle),
            (party_get_slot, ":scene", "$current_town", slot_castle_exterior),
          (else_try),
            (party_get_slot, ":scene", "$current_town", slot_town_center),
          (try_end),
          (set_jump_mission,"mt_ai_training"),
          (jump_to_scene,":scene"),
          (change_screen_mission),
      ]),
      
      ("castle_cheat_dungeon",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT! Prison.",
        [
          (set_jump_mission,"mt_ai_training"),
          (party_get_slot, ":castle_scene", "$current_town", slot_town_prison),
          (jump_to_scene,":castle_scene"),
          (change_screen_mission),
      ]),
      
      ("castle_cheat_town_walls",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
        ],
        "{!}CHEAT! Town Walls.",
        [
          (party_get_slot, ":scene", "$current_town", slot_town_walls),
          (set_jump_mission,"mt_ai_training"),
          (jump_to_scene,":scene"),
          (change_screen_mission),
      ]),
      
      ("castle_cheat_town_coastal",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          (party_slot_eq, "$current_town",slot_town_port, 1),
          (eq, "$cheat_mode", 1),
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
        ],
        "{!}CHEAT! Town Coastal Assault.",
        [
          (party_get_slot, ":scene", "$current_town", slot_party_coastal_assault_scene),
          (set_jump_mission,"mt_ai_training"),
          (jump_to_scene,":scene"),
          (change_screen_mission),
      ]),
      
      ("cheat_town_start_siege",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
          (party_slot_eq, "$g_encountered_party", slot_center_is_besieged_by, -1),
          (lt, "$g_encountered_party_2", 1),
          (call_script, "script_party_count_fit_for_battle","p_main_party"),
          (gt, reg(0), 1),
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
            (assign, reg6, 1),
          (else_try),
            (assign, reg6, 0),
          (try_end),
        ],
        "{!}CHEAT: Besiege the {reg6?town:castle}...",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (assign,"$g_player_besiege_town","$g_encountered_party"),
          (jump_to_menu, "mnu_castle_besiege"),
      ]),
      
      ("center_reports",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (eq, "$cheat_mode", 1),
        ],
        "{!}CHEAT! Show reports.",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (jump_to_menu,"mnu_center_reports"),
      ]),
      
      ("sail_from_port",
        [
          (val_add, "$curr_menu_slot", 1),										#Phaiak
          
          (party_slot_eq,"$current_town",slot_party_type, spt_town),
          (eq, "$cheat_mode", 1),
          #(party_slot_eq,"$current_town",slot_town_near_shore, 1),
        ],
        "{!}CHEAT: Sail from port.",
        [
          (assign, "$g_player_icon_state", pis_ship),
          (party_set_flags, "p_main_party", pf_is_ship, 1),
          (party_get_position, pos1, "p_main_party"),
          (map_get_water_position_around_position, pos2, pos1, 6),
          (party_set_position, "p_main_party", pos2),
          # (assign, "$g_main_ship_party", -1),
          (change_screen_return),
      ]),
      
    ]
  ),
  
  
  
  (
    "cannot_enter_court",0,
    "There is a feast in progress in the lord's hall, but you are not of sufficient status to be invited inside. Perhaps increasing your renown would win you admittance -- or you might also try distinguishing yourself at a tournament while the feast is in progress...",
    "none",
    [(set_background_mesh, "mesh_festin"), #pic book
    ],
    [
      ("continue", [],"Continue",
        [
          (jump_to_menu, "mnu_town"),
      ]),
  ]),
  
  
  (
    "lady_visit",0,
    "Who do you wish to visit?",
    "none",
    [(set_background_mesh, "mesh_festin"), #pic book
    ],
    [
      
      ("visit_lady_1", [
          (gt, "$love_interest_in_town", 0),
          (str_store_troop_name, s12, "$love_interest_in_town"),
        ],
        "Visit {s12}",
        [
          (assign, "$love_interest_in_town", "$love_interest_in_town"),
          (jump_to_menu, "mnu_garden"),
      ]),
      
      
      
      ("visit_lady_2", [
          (gt, "$love_interest_in_town_2", 0),
          (str_store_troop_name, s12, "$love_interest_in_town_2"),
        ],
        "Visit {s12}",
        [
          (assign, "$love_interest_in_town", "$love_interest_in_town_2"),
          (jump_to_menu, "mnu_garden"),
      ]),
      
      ("visit_lady_3", [
          (gt, "$love_interest_in_town_3", 0),
          (str_store_troop_name, s12, "$love_interest_in_town_3"),
        ],
        "Visit {s12}",
        [
          (assign, "$love_interest_in_town", "$love_interest_in_town_3"),
          (jump_to_menu, "mnu_garden")], "Door to the garden."),
      
      
      ("visit_lady_4", [(gt, "$love_interest_in_town_4", 0),(str_store_troop_name, s12, "$love_interest_in_town_4"),],
        "Visit {s12}",[(assign, "$love_interest_in_town", "$love_interest_in_town_4"),(jump_to_menu, "mnu_garden"),]),
      
      ("visit_lady_5", [(gt, "$love_interest_in_town_5", 0),(str_store_troop_name, s12, "$love_interest_in_town_5"),],
        "Visit {s12}",[(assign, "$love_interest_in_town", "$love_interest_in_town_5"),(jump_to_menu, "mnu_garden"),]),
      
      ("visit_lady_6",[(gt, "$love_interest_in_town_6", 0),(str_store_troop_name, s12, "$love_interest_in_town_6"),],
        "Visit {s12}",[(assign, "$love_interest_in_town", "$love_interest_in_town_6"),(jump_to_menu, "mnu_garden"),]),
      
      ("visit_lady_7",[(gt, "$love_interest_in_town_7", 0),(str_store_troop_name, s12, "$love_interest_in_town_7"),],
        "Visit {s12}",[(assign, "$love_interest_in_town", "$love_interest_in_town_7"),(jump_to_menu, "mnu_garden"),]),
      
      ("visit_lady_8",[(gt, "$love_interest_in_town_8", 0),(str_store_troop_name, s12, "$love_interest_in_town_8"),],
        "Visit {s12}",[(assign, "$love_interest_in_town", "$love_interest_in_town_8"),(jump_to_menu, "mnu_garden"),]),
      
      
      ("leave",[], "Leave",[(jump_to_menu, "mnu_town")]),
      
    ]
  ),
  
  
  (
    "town_tournament_lost",0,
    "You have been eliminated from the tournament.{s8}",
    "none",
    [      (set_background_mesh, "mesh_pic_irish_veterans"), #pic book
      
      (str_clear, s8),
      (try_begin),
        (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
        (neg|troop_slot_ge, "trp_player", slot_troop_renown, 50),
        (neg|troop_slot_ge, "trp_player", slot_troop_renown, 125),
        (gt, "$g_player_tournament_placement", 4),
        (faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_state, sfai_feast),
        (faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_object, "$g_encountered_party"),
        (str_store_string, s8, "str__however_you_have_sufficiently_distinguished_yourself_to_be_invited_to_attend_the_ongoing_feast_in_the_lords_castle"),
      (try_end),
      
    ],
    [
      ("continue", [], "Continue...",
        [(jump_to_menu, "mnu_town_tournament_won_by_another"),
      ]),
    ]
  ),
  
  (
    "town_tournament_won",mnf_disable_all_keys,
    "You have won the tournament of {s3}! You are filled with pride as the crowd cheers your name. " +
    "In addition to honour, fame and glory, you earn a prize of {reg9} peningas. {s8}",
    "none",
    [ (set_background_mesh, "mesh_pic_victory"), #pic book
      ##        (try_begin),
      ##          (set_fixed_point_multiplier, 100),
      ##          (position_set_x, pos0, 70),
      ##          (position_set_y, pos0, 30),
      ##          (position_set_z, pos0, 75),
      ##          (set_game_menu_tableau_mesh, "tableau_troop_note_mesh", "trp_player", pos0),
      ##        (try_end),
      
      (str_store_party_name, s3, "$current_town"),
      (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
      (try_begin),
        (lt, ":player_renown", 200),
        (call_script, "script_change_troop_renown", "trp_player", 10),
      (else_try),
        (store_mul, ":boost", 200, 10),
        (val_div, ":boost", ":player_renown"),
        (call_script, "script_change_troop_renown", "trp_player", ":boost"),
      (try_end),
      (store_random_in_range, ":rand", 0, 20),
      (try_begin),
        (eq, ":rand", 0),
        (troop_add_item, "trp_player", "itm_common_horse", 0), #chief da objeto al ganar torneo
        (display_message, "@An expensive horse is awarded to you for your victory.", 0xFF0000),
      (else_try),
        (eq, ":rand", 1),
        (troop_add_item, "trp_player", "itm_cow1", 0), #chief da objeto al ganar torneo
        (display_message, "@A fat cow is awarded to you for your victory.", 0xFF0000),
      (else_try),
        (eq, ":rand", 2),
        (troop_add_item, "trp_player", "itm_byrnie34", 0), #chief da objeto al ganar torneo
        (display_message, "@You are given a beautiful shirt of mail adorned with a pelt, as befits a mighty warlord.", 0xFF0000),
      (else_try),
        (eq, ":rand", 3),
        (troop_add_item, "trp_player", "itm_noble_sword", 0), #chief da objeto al ganar torneo
        (display_message, "@They give you a fine sword, worthy of a noble.", 0xFF0000),
      (else_try),
        (display_message, "@They appreciate your participation in the competition and place a wreath of laurel on your head.", 0xFF0000),
      (try_end),
      (try_begin),
        (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
        (lt, ":center_relation", 30),
        (call_script, "script_change_player_relation_with_center", "$current_town", 6),
      (try_end),
      
      (assign, reg9, 200),
      (add_xp_to_troop, 250, "trp_player"),
      (troop_add_gold, "trp_player", reg9),
      (str_clear, s8),
      (store_add, ":total_win", "$g_tournament_bet_placed", "$g_tournament_bet_win_amount"),
      (try_begin),
        (gt, "$g_tournament_bet_win_amount", 0),
        (assign, reg8, ":total_win"),
        (str_store_string, s8, "@Moreover, you earn {reg8} peningas from the clever bets you placed on yourself..."),
      (try_end),
      (try_begin),
        (this_or_next|neq, "$players_kingdom", "$g_encountered_party_faction"),
        (neg|troop_slot_ge, "trp_player", slot_troop_renown, 70),
        (neg|troop_slot_ge, "trp_player", slot_troop_renown, 145),
        
        (faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_state, sfai_feast),
        (faction_slot_eq, "$g_encountered_party_faction", slot_faction_ai_object, "$g_encountered_party"),
        (str_store_string, s8, "str_s8_you_are_also_invited_to_attend_the_ongoing_feast_in_the_castle"),
      (try_end),
      (troop_add_gold, "trp_player", ":total_win"),
      (assign, ":player_odds_sub", 0),
      (store_div, ":player_odds_sub", "$g_tournament_bet_win_amount", 5),
      (party_get_slot, ":player_odds", "$current_town", slot_town_player_odds),
      (val_sub, ":player_odds", ":player_odds_sub"),
      (val_max, ":player_odds", 250),
      (party_set_slot, "$current_town", slot_town_player_odds, ":player_odds"),
      (call_script, "script_play_victorious_sound"),
      
      (unlock_achievement, ACHIEVEMENT_MEDIEVAL_TIMES),
    ],
    [
      ("continue", [], "Continue...",
        [(jump_to_menu, "mnu_town"),
      ]),
    ]
  ),
  
  (
    "town_tournament_won_by_another",mnf_disable_all_keys,
    "As the only {reg3?fighter:man} to remain undefeated this day, {s1} wins the lists and the glory of this tournament.",
    "none",
    [ (set_background_mesh, "mesh_pic_irish_veterans"), #pic book
      (call_script, "script_get_num_tournament_participants"),
      (store_sub, ":needed_to_remove_randomly", reg0, 1),
      (try_begin),
        (troop_slot_eq, "trp_tournament_participants", 0, 0), #delete player from the participants
        (troop_set_slot, "trp_tournament_participants", 0, -1),
        (val_sub, ":needed_to_remove_randomly", 1),
      (try_end),
      (call_script, "script_remove_tournament_participants_randomly", ":needed_to_remove_randomly"),
      (call_script, "script_sort_tournament_participant_troops"),
      (troop_get_slot, ":winner_troop", "trp_tournament_participants", 0),
      (str_store_troop_name, s1, ":winner_troop"),
      (try_begin),
        (troop_is_hero, ":winner_troop"),
        (call_script, "script_change_troop_renown", ":winner_troop", 20),
      (try_end),
      (troop_get_type, reg3, ":winner_troop"),
      (val_mod, reg3, 2),
      ##        (try_begin),
      ##          (set_fixed_point_multiplier, 100),
      ##          (position_set_x, pos0, 70),
      ##          (position_set_y, pos0, 30),
      ##          (position_set_z, pos0, 75),
      ##          (set_game_menu_tableau_mesh, "tableau_troop_note_mesh", ":winner_troop", pos0),
      ##        (try_end),
    ],
    [
      ("continue", [], "Continue...",
        [(jump_to_menu, "mnu_town"),
      ]),
    ]
  ),
  
  (
    "town_tournament",mnf_disable_all_keys,
    "{s1}You are at tier {reg0} of the competition, with {reg1} participants remaining. In the next round, there will be {reg2} teams with {reg3} {reg4?fighters:fighter} each.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_duelos"), #pic book
      (party_set_slot, "$current_town", slot_town_has_tournament, 0), #No way to return back if this menu is left
      (call_script, "script_sort_tournament_participant_troops"),#Moving trp_player to the top of the list
      (call_script, "script_get_num_tournament_participants"),
      (assign, ":num_participants", reg0),
      (try_begin),
        (neg|troop_slot_eq, "trp_tournament_participants", 0, 0),#Player is defeated
        
        (assign, ":player_odds_add", 0),
        (store_div, ":player_odds_add", "$g_tournament_bet_placed", 5),
        (party_get_slot, ":player_odds", "$current_town", slot_town_player_odds),
        (val_add, ":player_odds", ":player_odds_add"),
        (val_min, ":player_odds", 4000),
        (party_set_slot, "$current_town", slot_town_player_odds, ":player_odds"),
        
        (jump_to_menu, "mnu_town_tournament_lost"),
      (else_try),
        (eq, ":num_participants", 1),#Tournament won
        (jump_to_menu, "mnu_town_tournament_won"),
      (else_try),
        (try_begin),
          (le, "$g_tournament_next_num_teams", 0),
          (call_script, "script_get_random_tournament_team_amount_and_size"),
          (assign, "$g_tournament_next_num_teams", reg0),
          (assign, "$g_tournament_next_team_size", reg1),
        (try_end),
        (assign, reg2, "$g_tournament_next_num_teams"),
        (assign, reg3, "$g_tournament_next_team_size"),
        (store_sub, reg4, reg3, 1),
        (str_clear, s1),
        (try_begin),
          (eq, "$g_tournament_player_team_won", 1),
          (str_store_string, s1, "@Victory is yours! You have won this melee, but now you must prepare yourself for the next round. "),
        (else_try),
          (eq, "$g_tournament_player_team_won", 0),
          (str_store_string, s1, "@You have been bested in this melee, but the master of ceremonies gives special recognition to your skill and bravery, allowing you to take part in the next round. "),
        (try_end),
        (assign, reg1, ":num_participants"),
        (store_add, reg0, "$g_tournament_cur_tier", 1),
      (try_end),
    ],
    [
      ("tournament_view_participants", [], "View participants.",
        [(jump_to_menu, "mnu_tournament_participants"),
      ]),
      ("tournament_bet", [(neq, "$g_tournament_cur_tier", "$g_tournament_last_bet_tier")], "Place a bet on yourself.",
        [(jump_to_menu, "mnu_tournament_bet"),
      ]),
      ("tournament_join_next_fight", [], "Fight in the next round.",
        [
          (party_get_slot, ":arena_scene", "$current_town", slot_town_arena),
          (modify_visitors_at_site, ":arena_scene"),
          (reset_visitors),
          #Assuming that there are enough participants for the teams
          (assign, "$g_player_tournament_placement", "$g_tournament_cur_tier"),
          (try_begin),
            (gt, "$g_player_tournament_placement", 4),
            (assign, "$g_player_eligible_feast_center_no", "$current_town"),
          (try_end),
          (val_add, "$g_tournament_cur_tier", 1),
          
          (store_mul, "$g_tournament_num_participants_for_fight", "$g_tournament_next_num_teams", "$g_tournament_next_team_size"),
          (troop_set_slot, "trp_tournament_participants", 0, -1),#Removing trp_player from the list
          (troop_set_slot, "trp_temp_array_a", 0, "trp_player"),
          (try_for_range, ":slot_no", 1, "$g_tournament_num_participants_for_fight"),
            (call_script, "script_get_random_tournament_participant"),
            (troop_set_slot, "trp_temp_array_a", ":slot_no", reg0),
          (try_end),
          (call_script, "script_shuffle_troop_slots", "trp_temp_array_a", 0, "$g_tournament_num_participants_for_fight"),
          
          
          (try_for_range, ":slot_no", 0, 4),#shuffle teams
            (troop_set_slot, "trp_temp_array_b", ":slot_no", ":slot_no"),
          (try_end),
          (call_script, "script_shuffle_troop_slots", "trp_temp_array_b", 0, 4),
          
          (assign, ":cur_slot", 0),
          (try_for_range, ":cur_team_offset", 0, "$g_tournament_next_num_teams"),
            (troop_get_slot, ":cur_team", "trp_temp_array_b", ":cur_team_offset"),
            
            (try_for_range, ":slot_no", 0, 8),#shuffle entry_points
              (troop_set_slot, "trp_temp_array_c", ":slot_no", ":slot_no"),
            (try_end),
            (call_script, "script_shuffle_troop_slots", "trp_temp_array_c", 0, 8),
            
            (try_for_range, ":cur_index", 0, "$g_tournament_next_team_size"),
              (store_mul, ":cur_entry_point", ":cur_team", 8),
              (troop_get_slot, ":entry_offset", "trp_temp_array_c", ":cur_index"),
              (val_add, ":cur_entry_point", ":entry_offset"),
              (troop_get_slot, ":troop_no", "trp_temp_array_a", ":cur_slot"),
              (set_visitor, ":cur_entry_point", ":troop_no"),
              (val_add, ":cur_slot", 1),
            (try_end),
          (try_end),
          
          (assign, "$g_tournament_next_num_teams", 0),
          (assign, "$g_tournament_next_team_size", 0),
          
          (assign, "$g_mt_mode", abm_tournament),
          
          (party_get_slot, ":town_original_faction", "$current_town", slot_center_original_faction),
          (assign, ":town_index_within_faction", 0),
          (assign, ":end_cond", towns_end),
          (try_for_range, ":cur_town", towns_begin, ":end_cond"),
            (try_begin),
              (eq, ":cur_town", "$current_town"),
              (assign, ":end_cond", 0), #break
            (else_try),
              (party_slot_eq, ":cur_town", slot_center_original_faction, ":town_original_faction"),
              (val_add, ":town_index_within_faction", 1),
            (try_end),
          (try_end),
          
          (set_jump_mission, "mt_arena_melee_fight"),
          (call_script,"script_set_items_for_tournament_by_factions",":town_original_faction"),
          (jump_to_scene, ":arena_scene"),
          (change_screen_mission),
      ]),
      ("leave_tournament",[],"Withdraw from the tournament.",
        [
          (jump_to_menu, "mnu_tournament_withdraw_verify"),
      ]),
    ]
  ),
  
  (
    "tournament_withdraw_verify",0,
    "Are you sure you want to withdraw from the tournament?",
    "none",
    [(set_background_mesh, "mesh_pic_extra_duelos"), #pic book
    ],
    [
      ("tournament_withdraw_yes", [], "Yes. This is a pointless affectation.",
        [(jump_to_menu, "mnu_town_tournament_won_by_another"),
      ]),
      ("tournament_withdraw_no", [], "No, not as long as there is a chance of victory!",
        [(jump_to_menu, "mnu_town_tournament"),
      ]),
    ]
  ),
  
  (
    "tournament_bet",0,
    "The odds against you are {reg5} to {reg6}.{reg1? You have already bet {reg1} peningas on yourself, and if you win, you will earn {reg2} peningas.:} How much do you want to bet?",
    "none",
    [(set_background_mesh, "mesh_pic_payment"), #pic book
      (assign, reg1, "$g_tournament_bet_placed"),
      (store_add, reg2, "$g_tournament_bet_win_amount", "$g_tournament_bet_placed"),
      (call_script, "script_get_win_amount_for_tournament_bet"),
      (assign, ":player_odds", reg0),
      (assign, ":min_dif", 100000),
      (assign, ":min_dif_divisor", 1),
      (assign, ":min_dif_multiplier", 1),
      (try_for_range, ":cur_multiplier", 1, 50),
        (try_for_range, ":cur_divisor", 1, 50),
          (store_mul, ":result", 100, ":cur_multiplier"),
          (val_div, ":result", ":cur_divisor"),
          (store_sub, ":difference", ":player_odds", ":result"),
          (val_abs, ":difference"),
          (lt, ":difference", ":min_dif"),
          (assign, ":min_dif", ":difference"),
          (assign, ":min_dif_divisor", ":cur_divisor"),
          (assign, ":min_dif_multiplier", ":cur_multiplier"),
        (try_end),
      (try_end),
      (assign, reg5, ":min_dif_multiplier"),
      (assign, reg6, ":min_dif_divisor"),
    ],
    [
      ("bet_100_denars", [(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 100)
        ],
        "100 peningas.",
        [
          (assign, "$temp", 100),
          (jump_to_menu, "mnu_tournament_bet_confirm"),
      ]),
      ("bet_50_denars", [(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 50)
        ],
        "50 peningas.",
        [
          (assign, "$temp", 50),
          (jump_to_menu, "mnu_tournament_bet_confirm"),
      ]),
      ("bet_20_denars", [(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 20)
        ],
        "20 peningas.",
        [
          (assign, "$temp", 20),
          (jump_to_menu, "mnu_tournament_bet_confirm"),
      ]),
      ("bet_10_denars", [(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 10)
        ],
        "10 peningas.",
        [
          (assign, "$temp", 10),
          (jump_to_menu, "mnu_tournament_bet_confirm"),
      ]),
      ("bet_5_denars", [(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 5)
        ],
        "5 peningas.",
        [
          (assign, "$temp", 5),
          (jump_to_menu, "mnu_tournament_bet_confirm"),
      ]),
      ("go_back_dot", [], "Go back.",
        [
          (jump_to_menu, "mnu_town_tournament"),
      ]),
    ]
  ),
  
  (
    "tournament_bet_confirm",0,
    "If you bet {reg1} peningas, you will earn {reg2} peningas if you win the tournament. Is that all right?",
    "none",
    [(set_background_mesh, "mesh_pic_payment"), #pic book
      (call_script, "script_get_win_amount_for_tournament_bet"),
      (assign, ":win_amount", reg0),
      (val_mul, ":win_amount", "$temp"),
      (val_div, ":win_amount", 100),
      (assign, reg1, "$temp"),
      (assign, reg2, ":win_amount"),
    ],
    [
      ("tournament_bet_accept", [],
        "Go ahead.",
        [
          (call_script, "script_tournament_place_bet", "$temp"),
          (jump_to_menu, "mnu_town_tournament"),
      ]),
      ("tournament_bet_cancel", [],
        "Forget it.",
        [
          (jump_to_menu, "mnu_tournament_bet"),
      ]),
    ]
  ),
  
  (
    "tournament_participants",0,
    "You ask one of the criers for the names of the tournament participants. They are:^{s11}",
    "none",
    [(set_background_mesh, "mesh_pic_payment"), #pic book
      (str_clear, s11),
      (call_script, "script_sort_tournament_participant_troops"),
      (call_script, "script_get_num_tournament_participants"),
      (assign, ":num_participants", reg0),
      (try_for_range, ":cur_slot", 0, ":num_participants"),
        (troop_get_slot, ":troop_no", "trp_tournament_participants", ":cur_slot"),
        (str_store_troop_name, s12, ":troop_no"),
        (str_store_string, s11, "@{!}{s11}^{s12}"),
      (try_end),
    ],
    [
      ("go_back_dot", [], "Go back.",
        [(jump_to_menu, "mnu_town_tournament"),
      ]),
    ]
  ),
  
  
  (
    "collect_taxes",mnf_disable_all_keys,
    "As the party member with the highest trade skill ({reg2}), {reg3?you expect:{s1} expects} that collecting taxes from here will take {reg4} days...",
    "none",
    [(set_background_mesh, "mesh_pic_payment"), #pic book
      (call_script, "script_get_max_skill_of_player_party", "skl_trade"),
      (assign, ":max_skill", reg0),
      (assign, reg2, reg0),
      (assign, ":max_skill_owner", reg1),
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s1, ":max_skill_owner"),
      (try_end),
      (assign, ":tax_quest_expected_revenue", 3000),
      (try_begin),
        (party_slot_eq, "$current_town", slot_party_type, spt_town),
        (assign, ":tax_quest_expected_revenue", 6000),
      (try_end),
      
      (try_begin),
        (quest_slot_eq, "qst_collect_taxes", slot_quest_current_state, 0),
        (store_add, ":max_skill_plus_thirty", ":max_skill", 30),
        (try_begin),
          (party_slot_eq, "$current_town", slot_party_type, spt_town),
          (store_div, "$qst_collect_taxes_total_hours", 24* 7 * 30, ":max_skill_plus_thirty"),
        (else_try),
          #Village
          (store_div, "$qst_collect_taxes_total_hours", 24 * 3 * 30, ":max_skill_plus_thirty"),
        (try_end),
        
        (call_script, "script_party_count_fit_for_battle", "p_main_party"),
        (val_add, reg0, 20),
        (val_mul, "$qst_collect_taxes_total_hours", 20),
        (val_div, "$qst_collect_taxes_total_hours", reg0),
        
        
        (quest_set_slot, "qst_collect_taxes", slot_quest_target_amount, "$qst_collect_taxes_total_hours"),
        (store_div, ":menu_begin_time", "$qst_collect_taxes_total_hours", 20),#between %5-%25
        (store_div, ":menu_end_time", "$qst_collect_taxes_total_hours", 4),
        (assign, ":unrest_begin_time", ":menu_end_time"),#between %25-%75
        (store_mul, ":unrest_end_time", "$qst_collect_taxes_total_hours", 3),
        (val_div, ":unrest_end_time", 4),
        
        (val_mul, ":tax_quest_expected_revenue", 2),
        (store_div, "$qst_collect_taxes_hourly_income", ":tax_quest_expected_revenue", "$qst_collect_taxes_total_hours"),
        
        (store_random_in_range, "$qst_collect_taxes_menu_counter", ":menu_begin_time", ":menu_end_time"),
        (store_random_in_range, "$qst_collect_taxes_unrest_counter", ":unrest_begin_time", ":unrest_end_time"),
        (assign, "$qst_collect_taxes_halve_taxes", 0),
      (try_end),
      (quest_get_slot, ":target_hours", "qst_collect_taxes", slot_quest_target_amount),
      (store_div, ":target_days", ":target_hours", 24),
      (val_mul, ":target_days", 24),
      (try_begin),
        (lt, ":target_days", ":target_hours"),
        (val_add, ":target_days", 24),
      (try_end),
      (val_div, ":target_days", 24),
      (assign, reg4, ":target_days"),
    ],
    [
      ("start_collecting", [], "Start collecting.",
        [(assign, "$qst_collect_taxes_currently_collecting", 1),
          (try_begin),
            (quest_slot_eq, "qst_collect_taxes", slot_quest_current_state, 0),
            (quest_set_slot, "qst_collect_taxes", slot_quest_current_state, 1),
          (try_end),
          (rest_for_hours_interactive, 1000, 5, 0), #rest while not attackable
          (assign,"$auto_enter_town","$current_town"),
          (assign, "$g_town_visit_after_rest", 1),
          (change_screen_return),
      ]),
      ("collect_later", [], "Put it off until later.",
        [(try_begin),
            (party_slot_eq, "$current_town", slot_party_type, spt_town),
            (jump_to_menu, "mnu_town"),
          (else_try),
            (jump_to_menu, "mnu_village"),
          (try_end),
      ]),
    ]
  ),
  
  (
    "collect_taxes_complete",mnf_disable_all_keys,
    "You've collected {reg3} peningas in taxes from {s3}. {s19} will be expecting you to take the money to him.",
    "none",
    [(set_background_mesh, "mesh_pic_payment"), #pic book
      (str_store_party_name, s3, "$current_town"),
      (quest_get_slot, ":quest_giver", "qst_collect_taxes", slot_quest_giver_troop),
      (str_store_troop_name, s19, ":quest_giver"),
      (quest_get_slot, reg3, "qst_collect_taxes", slot_quest_gold_reward),
      (try_begin),
        (eq, "$qst_collect_taxes_halve_taxes", 0),
        (call_script, "script_change_player_relation_with_center", "$current_town", -2),
      (try_end),
      (call_script, "script_succeed_quest", "qst_collect_taxes"),
    ],
    [
      ("continue", [], "Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "collect_taxes_rebels_killed",0,
    "Your quick action and strong arm have successfully put down the revolt. " +
    "Surely, anyone with a mind to rebel against you will think better of it after this.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"), #pic book
    ],
    [
      ("continue", [], "Continue...",
        [(change_screen_map),
      ]),
    ]
  ),
  
  (
    "collect_taxes_failed",mnf_disable_all_keys,
    "You could collect only {reg3} peningas as tax from {s3} before the revolt broke out. " +
    "{s1} won't be happy, but some silver will placate him better than nothing at all...",
    "none",
    [(set_background_mesh, "mesh_pic_payment"), #pic book
      (str_store_party_name, s3, "$current_town"),
      (quest_get_slot, ":quest_giver", "qst_collect_taxes", slot_quest_giver_troop),
      (str_store_troop_name, s1, ":quest_giver"),
      (quest_get_slot, reg3, "qst_collect_taxes", slot_quest_gold_reward),
      (call_script, "script_fail_quest", "qst_collect_taxes"),
      (quest_set_slot, "qst_collect_taxes", slot_quest_current_state, 4),
      (rest_for_hours, 0, 0, 0), #stop resting
    ],
    [
      ("continue", [], "Continue...",
        [(change_screen_map),
      ]),
    ]
  ),
  
  (
    "collect_taxes_revolt_warning",0,
    "The people of {s3} are outraged at your demands and decry it as nothing more than extortion. " +
    "They're getting very restless, and they may react badly if you keep pressing them.",
    "none",
    [
      (set_background_mesh, "mesh_pic_townriot"), #pic book
      (str_store_party_name, s3, "$current_town"),
    ],
    [
      ("continue_collecting_taxes", [], "Ignore them and continue.",
        [(change_screen_return),]),
      ("halve_taxes", [(quest_get_slot, ":quest_giver_troop", "qst_collect_taxes", slot_quest_giver_troop),
          (str_store_troop_name, s1, ":quest_giver_troop"),],
        "Agree to reduce your collection by half. ({s1} may be upset)",
        [(assign, "$qst_collect_taxes_halve_taxes", 1),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "collect_taxes_revolt",0,
    "You are interrupted while collecting the taxes at {s3}. A large band of angry {reg9?peasants:townsmen} is marching nearer, " +
    "shouting about the exorbitant taxes and waving torches and weapons. It looks like they aim to fight you!",
    "none",
    [(set_background_mesh, "mesh_pic_townriot"), #pic book
      (str_store_party_name, s3, "$current_town"),
      (assign, reg9, 0),
      (try_begin),
        (party_slot_eq, "$current_town", slot_party_type, spt_village),
        (assign, reg9, 1),
      (try_end),
    ],
    [
      ("continue", [], "Continue...",
        [(set_jump_mission,"mt_back_alley_revolt"),
          (quest_get_slot, ":target_center", "qst_collect_taxes", slot_quest_target_center),
          (try_begin),
            (party_slot_eq, ":target_center", slot_party_type, spt_town),
            (party_get_slot, ":town_alley", ":target_center", slot_town_alley),
          (else_try),
            (party_get_slot, ":town_alley", ":target_center", slot_castle_exterior),
          (try_end),
          (modify_visitors_at_site,":town_alley"),
          (reset_visitors),
          (assign, ":num_rebels", 6),
          (store_character_level, ":level", "trp_player"),
          (val_div, ":level", 6),
          (val_add, ":num_rebels", ":level"),
          (val_sub, ":num_rebels", "$temp2"),
          (val_max, ":num_rebels", 4),
          (set_visitors, 1, "trp_tax_rebel", ":num_rebels"),
          (jump_to_scene,":town_alley"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  # They must learn field discipline and the steadiness to follow orders in combat before they can be thought to use arms.",
  (
    "train_peasants_against_bandits",0,
    "As the party member with the highest training skill ({reg2}), {reg3?you expect:{s1} expects} that getting some peasants ready for practice will take {reg4} hours.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_combate"), #pic book
      (call_script, "script_get_max_skill_of_player_party", "skl_trainer"),
      (assign, ":max_skill", reg0),
      (assign, reg2, reg0),
      (assign, ":max_skill_owner", reg1),
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s1, ":max_skill_owner"),
      (try_end),
      (store_sub, ":needed_hours", 20, ":max_skill"),
      (val_mul, ":needed_hours", 3),
      (val_div, ":needed_hours", 5),
      (store_sub, reg4, ":needed_hours", "$qst_train_peasants_against_bandits_num_hours_trained"),
    ],
    [
      ("make_preparation", [], "Train them.",
        [
          (assign, "$qst_train_peasants_against_bandits_currently_training", 1),
          (rest_for_hours_interactive, 1000, 5, 0), #rest while not attackable
          (assign, "$auto_enter_town", "$current_town"),
          (assign, "$g_town_visit_after_rest", 1),
          (change_screen_return),
      ]),
      ("train_later", [], "Put it off until later.",
        [
          (jump_to_menu, "mnu_village"),
      ]),
    ]
  ),
  
  (
    "train_peasants_against_bandits_ready",0,
    "You put the peasants through the basics of soldiering, discipline and obedience. " +
    "You think {reg0} of them {reg1?have:has} fully grasped the training and {reg1?are:is} ready for some practice.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_combate"), #pic book
      (store_character_level, ":level", "trp_player"),
      (val_div, ":level", 10),
      (val_add, ":level", 1),
      (quest_get_slot, ":quest_target_amount", "qst_train_peasants_against_bandits", slot_quest_target_amount),
      (quest_get_slot, ":quest_current_state", "qst_train_peasants_against_bandits", slot_quest_current_state),
      (val_sub, ":quest_target_amount", ":quest_current_state"),
      (assign, ":max_random", ":level"),
      (val_min, ":max_random", ":quest_target_amount"),
      (val_max, ":max_random", 0),
      (val_add, ":max_random", 1),
      (store_random_in_range, ":random_number", 1, ":max_random"),
      (assign, "$g_train_peasants_against_bandits_num_peasants", ":random_number"),
      (assign, reg0, ":random_number"),
      (store_sub, reg1, ":random_number", 1),
      (str_store_troop_name_by_count, s0, "trp_trainee_peasant", ":random_number"),
    ],
    [
      ("peasant_start_practice", [], "Start the practice fight.",
        [
          (set_jump_mission,"mt_village_training"),
          (quest_get_slot, ":target_center", "qst_train_peasants_against_bandits", slot_quest_target_center),
          (party_get_slot, ":village_scene", ":target_center", slot_castle_exterior),
          (modify_visitors_at_site, ":village_scene"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (set_visitors, 1, "trp_trainee_peasant", "$g_train_peasants_against_bandits_num_peasants"),
          (set_jump_entry, 11),
          (jump_to_scene, ":village_scene"),
          (jump_to_menu, "mnu_train_peasants_against_bandits_training_result"),
          (music_set_situation, 0),
          (change_screen_mission),
      ]),
    ]
  ),
  
  (
    "train_peasants_against_bandits_training_result",mnf_disable_all_keys,
    "{!}{s0}",
    "none",
    [(set_background_mesh, "mesh_pic_extra_combate"), #pic book
      (assign, reg5, "$g_train_peasants_against_bandits_num_peasants"),
      (str_store_troop_name_by_count, s0, "trp_trainee_peasant", "$g_train_peasants_against_bandits_num_peasants"),
      (try_begin),
        (eq, "$g_train_peasants_against_bandits_training_succeeded", 0),
        (str_store_string, s0, "@You were beaten. The peasants are heartened by their success, but the lesson you wanted to teach them probably didn't get through..."),
      (else_try),
        (str_store_string, s0, "@After beating your last opponent, you explain to the peasants how to defend themselves better against such an attack. You hope that they will take the experience to heart and be better prepared next time."),
        (quest_get_slot, ":quest_current_state", "qst_train_peasants_against_bandits", slot_quest_current_state),
        (val_add, ":quest_current_state", "$g_train_peasants_against_bandits_num_peasants"),
        (quest_set_slot, "qst_train_peasants_against_bandits", slot_quest_current_state, ":quest_current_state"),
      (try_end),
    ],
    [
      ("continue", [], "Continue...",
        [
          (try_begin),
            (quest_get_slot, ":quest_current_state", "qst_train_peasants_against_bandits", slot_quest_current_state),
            (quest_get_slot, ":quest_target_amount", "qst_train_peasants_against_bandits", slot_quest_target_amount),
            (eq, ":quest_target_amount",":quest_current_state"),
            #          (quest_slot_eq, "qst_train_peasants_against_bandits", slot_quest_target_amount, ":quest_current_state"),
            (jump_to_menu, "mnu_train_peasants_against_bandits_attack"),
          (else_try),
            (change_screen_map),
          (try_end),
      ]),
    ]
  ),
  
  (
    "train_peasants_against_bandits_attack",0,
    "As you get ready to continue the training, a sentry from the village runs up to you, shouting alarms. " +
    "The bandits have been spotted on the horizon, riding hard for {s3}. " +
    "The local leader begs that you organize your newly trained militia and face them.",
    "none",
    [(set_background_mesh, "mesh_pic_going_to_war"), #pic book
      (str_store_party_name, s3, "$current_town"),
    ],
    [
      ("peasants_against_bandits_attack_resist", [], "Prepare for a fight!",
        [
          (store_random_in_range, ":random_no", 0, 3),
          (try_begin),
            (eq, ":random_no", 0),
            (assign, ":bandit_troop", "trp_bandit"),
          (else_try),
            (eq, ":random_no", 1),
            (assign, ":bandit_troop", "trp_mountain_bandit"),
          (else_try),
            (assign, ":bandit_troop", "trp_forest_bandit"),
          (try_end),
          (party_get_slot, ":scene_to_use", "$g_encountered_party", slot_castle_exterior),
          (modify_visitors_at_site, ":scene_to_use"),
          (reset_visitors),
          (store_character_level, ":level", "trp_player"),
          (val_div, ":level", 2),
          (store_add, ":min_bandits", ":level", 16),
          (store_add, ":max_bandits", ":min_bandits", 6),
          (store_random_in_range, ":random_no", ":min_bandits", ":max_bandits"),
          (set_visitors, 0, ":bandit_troop", ":random_no"),
          (assign, ":num_villagers", ":max_bandits"),
          (set_visitors, 2, "trp_trainee_peasant", ":num_villagers"),
          (set_party_battle_mode),
          (set_battle_advantage, 0),
          (assign, "$g_battle_result", 0),
          (set_jump_mission,"mt_village_attack_bandits"),
          (jump_to_scene, ":scene_to_use"),
          (assign, "$g_next_menu", "mnu_train_peasants_against_bandits_attack_result"),
          (jump_to_menu, "mnu_battle_debrief"),
          (assign, "$g_mt_mode", vba_after_training),
          (change_screen_mission),
      ]),
    ]
  ),
  
  (
    "train_peasants_against_bandits_attack_result",mnf_disable_all_keys,
    "{!}{s9}",
    "none",
    [
      (try_begin),
        (eq, "$g_battle_result", 1),
        (str_store_string, s9, "@The bandits are broken! " +
          "Those few who remain alive and conscious run off with their tails between their legs, " +
        "terrified of the peasants and their new champion."),
        (call_script, "script_succeed_quest", "qst_train_peasants_against_bandits"),
        (jump_to_menu, "mnu_train_peasants_against_bandits_success"),
      (else_try),
        (call_script, "script_fail_quest", "qst_train_peasants_against_bandits"),
        (str_store_string, s9, "@Try as you might, you could not defeat the bandits. " +
          "Infuriated, they raze the village to the ground to punish the peasants, " +
        "and then leave the burning wasteland behind to find greener pastures to plunder."),
        (set_background_mesh, "mesh_pic_looted_village"),
      (try_end),
    ],
    [
      ("continue", [], "Continue...",
        [(try_begin),
            (call_script, "script_village_set_state",  "$current_town", svs_looted),
            (party_set_slot, "$current_town", slot_village_raid_progress, 0),
            (party_set_slot, "$current_town", slot_village_recover_progress, 0),
            (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -15),
            (call_script, "script_end_quest", "qst_train_peasants_against_bandits"),
          (try_end),
          (change_screen_map),
      ]),
    ]
  ),
  
  (
    "train_peasants_against_bandits_success",mnf_disable_all_keys,
    "The bandits are broken! " +
    "Those few who remain run off with their tails between their legs, " +
    "terrified of the peasants and their new champion. " +
    "The villagers have little left in the way of wealth after their ordeal, " +
    "but they offer you all they can find to show their gratitude.",
    "none",
    [(set_background_mesh, "mesh_pic_family"), #pic book
      (party_clear, "p_temp_party"),
      (call_script, "script_end_quest", "qst_train_peasants_against_bandits"),
      (call_script, "script_change_player_relation_with_center", "$g_encountered_party", 8),
      
      (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
      (try_for_range, ":slot_no", num_equipment_kinds ,max_inventory_items + num_equipment_kinds),
        (store_random_in_range, ":rand", 0, 100),
        (lt, ":rand", 50),
        (troop_set_inventory_slot, ":merchant_troop", ":slot_no", -1),
      (try_end),
      (call_script, "script_add_log_entry", logent_helped_peasants, "trp_player",  "$current_town", -1, -1),
    ],
    [
      ("village_bandits_defeated_accept",[],"Take it as your just due.",[(jump_to_menu, "mnu_auto_return_to_map"),
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_elder),
          (troop_sort_inventory, ":merchant_troop"),
          (change_screen_loot, ":merchant_troop"),
      ]),
      ("village_bandits_defeated_cont",[],  "Refuse, stating that they need these items more than you do.",[
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", 3),
          (call_script, "script_change_player_honor", 1),
          (change_screen_map)]),
    ],
  ),
  
  ### loot options (Phaiak)
  
  (
    "loot_options",0,
    "The battle is over. What do you want to do with the loot?",
    "none",
    [
      (set_background_mesh, "mesh_pic_chest"), #pic book
      #(set_background_mesh, "mesh_pic_extra_navegando"),
      (assign, "$loot_option", 0),
      
      (try_begin),
        (party_get_num_companions, ":party_members", "p_main_party"),
        (le, ":party_members", 3),
        (jump_to_menu, "mnu_total_victory"),	# No loot option for very small party
      (end_try),
      
    ],
    [
      ("loot_0", [], "Share the loot, as is common.",
        [
          (assign, "$loot_option", 0),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ("loot_1", [], "Take first claim on all the loot.",
        [
          (assign, "$loot_option", 1),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ("loot_2", [], "Leave all the loot for your men.",
        [
          (assign, "$loot_option", 2),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ("loot_3", [], "Leave the loot, but use the time to bury the dead.",
        [
          (assign, "$loot_option", 3),
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
    ]
  ),
  
  ### map sea travel menus begin (Phaiak)
  
  (
    "landing_point_encounter",0,
    "Do you wish to disembark?",
    "none",
    [
      
      (try_begin),
        (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end),
        (faction_slot_eq,  "$players_kingdom", slot_faction_marshal, "trp_player"),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_ai_state, sfai_default),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_ai_state, sfai_feast),
        (jump_to_menu, "mnu_landing_point_encounter_as_marshal"),
      (else_try),
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),
        (party_get_position, pos1, "p_landing_point"),
        (call_script, "script_get_next_land_position", 1),
        (set_spawn_radius, 0),
        (spawn_around_party, "p_main_party", "pt_landet_ships"),
        (assign, ":landet_ship_party", reg0),
        (str_store_troop_name, s1, "trp_player"),
        (party_set_name, ":landet_ship_party", "@{s1}'s Ships"),
        (party_set_slot, ":landet_ship_party", slot_party_type, spt_ship),
        (party_set_position, ":landet_ship_party", pos2),
        (call_script, "script_give_player_ships_from_party_to_party", "p_main_party", ":landet_ship_party"),
        (party_set_position, "p_main_party", pos2),
        (call_script, "script_switch_to_land_consequences"),
        (change_screen_return),
      (else_try),
        (set_background_mesh, "mesh_hacerbarco"),
      (end_try),
      
    ],
    [
      ("no_dot", [], "No.",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "landet_ships_encounter",0,
    "Do you wish to embark?",
    "none",
    [
      (set_background_mesh, "mesh_hacerbarco"),
      (try_begin),
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),
        (try_begin),
          (party_slot_ge, "$g_encountered_party", slot_party_1_ship_type, 1),
          (call_script, "script_condition_check_merging_ships", "$g_encountered_party"),
          (try_begin),
            # skill to low
            (eq, reg0, 1),
            (display_message, "@Can't merge both fleets because your sea-king skill isn't high enough."),
          (else_try),
            # more then 7 ships (player shouldn't see this in theory)
            (eq, reg0, 2),
            (display_message, "@Can't merge both fleets because this would exceed the fleet limit of seven ships."),
          (else_try),
            # merging possible
            (call_script, "script_merge_ships_from_party_to_party", "$g_encountered_party", "p_main_party"),
            (remove_party, "$g_encountered_party"), #changeing from "disable_party" to "remove_party" for VC-3855
            (display_message, "@Fleets merged."),
          (end_try),
        (end_try),
        (change_screen_return),
      (else_try),
        (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end),
        (faction_slot_eq,  "$players_kingdom", slot_faction_marshal, "trp_player"),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_ai_state, sfai_default),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_ai_state, sfai_feast),
        (jump_to_menu, "mnu_landet_ships_encounter_as_marshal"),
      (else_try),
        (call_script, "script_cf_crew_fit_in_ships", "$g_encountered_party"),
        (call_script, "script_give_player_ships_from_party_to_party", "$g_encountered_party", "p_main_party"),
        (party_get_position, pos1, "$g_encountered_party"),
        (call_script, "script_get_next_water_position", 1),
        (party_set_position, "p_main_party", pos2),
        (call_script, "script_switch_to_water_consequences"),
        (remove_party, "$g_encountered_party"), #changeing from "disable_party" to "remove_party" for VC-3855
        (change_screen_return),
      (else_try),
        (display_message, "str_cant_set_sail"),
        (change_screen_return),
      (end_try),
      
    ],
    [
      ("no_dot", [], "No.",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "ferry_encounter",0,
    "The ferry captain will carry you to the other side for {reg7} peningas.",
    "none",
    [
      (set_background_mesh, "mesh_hacerbarco"),
      
      (party_get_num_companions, "$current_dialog_cost", "p_main_party"),
      
      (try_begin),
        #VC-1803
        (check_quest_active, "qst_escort_merchant_caravan"),
        (quest_get_slot, ":quest_target_party", "qst_escort_merchant_caravan", slot_quest_target_party),
        (party_is_active, ":quest_target_party"),
        (eq, "$escort_merchant_caravan_mode", 0),
        (display_message, "@The trader you are escorting does not want to use a ferry.", color_bad_news),
        (change_screen_return),
      (else_try),
        #VC-2874
        (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end),
        (faction_slot_eq,  "$players_kingdom", slot_faction_marshal, "trp_player"),
        (display_message, "@The ferry station is too small and can't transport a marshal and his whole army.", color_bad_news),
        (change_screen_return),
      (else_try),
        (le, "$current_dialog_cost", 3),
        (store_troop_gold, reg8, "trp_player"),
        (ge, reg8, 1),
        (troop_remove_gold, "trp_player", 1),
        
        (try_begin),
          (is_between, "$g_encountered_party", "p_ferry_1a", "p_ferry_1b"),
          (store_add, ":target_ferry_station", "$g_encountered_party", 4),
        (else_try),
          (store_sub, ":target_ferry_station", "$g_encountered_party", 4),
        (end_try),
        (assign, "$travel_town", ":target_ferry_station"),
        (party_get_slot, ":target_ferry_port", ":target_ferry_station", slot_party_port_party),
        (enable_party, "p_transporter"),
        (party_get_slot, ":curr_ferry_port", "$g_encountered_party", slot_party_port_party),
        (party_get_position, pos1, ":curr_ferry_port"),
        #(party_get_position, pos1, "p_main_party"),
        #(call_script, "script_get_next_water_position", 1),
        (party_set_slot, "p_transporter", slot_party_on_water, 1),
        (party_set_flags, "p_transporter", pf_is_ship, 1),
        (party_set_position, "p_transporter", pos1),
        (party_get_position, pos2, ":target_ferry_port"),
        (party_set_ai_behavior, "p_transporter", ai_bhvr_travel_to_point),
        (party_set_ai_target_position, "p_transporter", pos2),
        
        # SEA TRAVEL
        (assign, "$auto_menu", -1),	# Have to create menu ...
        (rest_for_hours, 10 * 24, 1, 0),
        (set_camera_follow_party, "p_transporter"),
        (assign, "$g_player_is_captive", 1),
        (change_screen_return),
      (else_try),
        (assign, reg7, "$current_dialog_cost"),
        (set_background_mesh,"mesh_pic_extra_barco"),
      (end_try),
      
    ],
    [
      
      ("continue",
        [
          (store_troop_gold, reg8, "trp_player"),
          (ge, reg8, "$current_dialog_cost"),
          
        ],"Continue.",
        [
          (troop_remove_gold, "trp_player", "$current_dialog_cost"),
          (change_screen_return),
          (try_begin),
            (is_between, "$g_encountered_party", "p_ferry_1a", "p_ferry_1b"),
            (store_add, ":target_ferry_station", "$g_encountered_party", 4),
          (else_try),
            (store_sub, ":target_ferry_station", "$g_encountered_party", 4),
          (end_try),
          (assign, "$travel_town", ":target_ferry_station"),
          (party_get_slot, ":target_ferry_port", ":target_ferry_station", slot_party_port_party),
          (enable_party, "p_transporter"),
          (party_get_slot, ":curr_ferry_port", "$g_encountered_party", slot_party_port_party),
          (party_get_position, pos1, ":curr_ferry_port"),
          (party_set_slot, "p_transporter", slot_party_on_water, 1),
          (party_set_flags, "p_transporter", pf_is_ship, 1),
          (party_set_position, "p_transporter", pos1),
          (party_get_position, pos2, ":target_ferry_port"),
          (party_set_ai_behavior, "p_transporter", ai_bhvr_travel_to_point),
          (party_set_ai_target_position, "p_transporter", pos2),
          
          # SEA TRAVEL
          (assign, "$auto_menu", -1),	# Have to create menu ...
          (rest_for_hours, 10 * 24, 1, 0),
          (set_camera_follow_party, "p_transporter"),
          (assign, "$g_player_is_captive", 1),
          (change_screen_return),
        ]
      ),
      
      ("back",[],"Back.",
        [
          (change_screen_return),
        ]
      ),
      
  ]),
  
  (
    "port_encounter",0,
    "You encounter the port of {s2}. {s3}",
    "none",
    [
      (party_get_slot, ":curr_town", "$g_encountered_party", slot_party_port_party),
      (str_store_party_name, s2, ":curr_town"),
      (assign, "$temp", 0),
      
      #(party_get_slot, reg7, ":curr_town", slot_party_1_ship_type),
      
      (try_begin),
        #town is looted
        (party_slot_ge, ":curr_town", slot_party_looted_left_days, 1),
        (jump_to_menu, "mnu_saqueo_loot_continue"),
      (else_try),
        #town is enemy
        (lt, "$g_encountered_party_relation", 0),
        # (assign, "$auto_port_attack", ":curr_town"),
        # (assign, "$auto_enter_town", ":curr_town"),
        (str_store_string, s3, "@You can't enter the port because you are not welcome in this town."),
        (assign, "$temp", 1),
        (try_begin),
          #(this_or_next|eq, ":curr_town", "p_town_11"),	#Dorestad
          (eq, ":curr_town", "p_town_27"),	#Bebbanburh
          (str_store_string, s3, "@You can't enter the port because you are not welcome in this town. Moreover, this town can't be attacked from its sea side."),
          (assign, "$temp", 0),
        (end_try),
      (else_try),
        #already ships in port
        (party_slot_ge, ":curr_town", slot_party_1_ship_type, 1),
        (set_background_mesh,"mesh_pic_extra_barco"),
        
        (call_script, "script_condition_check_merging_ships", ":curr_town"),
        (try_begin),
          # skill to low
          (eq, reg0, 1),
          (str_store_string, s3, "@You can't enter the port. You already have a fleet in the port and your sea-king skill isn't high enough to merge both fleets."),
        (else_try),
          # more then 7 ships (player shouldn't see this in theory)
          (eq, reg0, 2),
          (str_store_string, s3, "@You can't enter the port. You already have a fleet in the port and you can't merge both fleets because this would exceed the fleet limit of seven ships."),
        (else_try),
          # merging possible
          (str_store_string, s3, "@You already have a fleet in the port. Do you want to merge both fleets?"),
          (assign, "$temp", 2),
        (end_try),
        
      (else_try),
        #all ok - enter port
        (call_script, "script_give_player_ships_from_party_to_party", "p_main_party", ":curr_town"),
        (party_get_position, pos2, ":curr_town"),
        (party_set_position, "p_main_party", pos2),
        (call_script, "script_switch_to_land_consequences"),
        (assign, "$auto_enter_town", ":curr_town"),
        (change_screen_return),
      (end_try),
      (call_script, "script_set_town_picture"),
    ],
    [
      
      ("attack",
        [
          (eq, "$temp", 1),
          
          (party_get_slot, ":curr_town", "$g_encountered_party", slot_party_port_party),
          (this_or_next|party_slot_eq, ":curr_town", slot_center_is_besieged_by, -1),
          (             party_slot_eq, ":curr_town", slot_center_is_besieged_by, "p_main_party"),
          (store_relation, ":reln", "$g_encountered_party_faction", "fac_player_faction"),
          (lt, ":reln", 0),
          (lt, "$g_encountered_party_2", 1),
          (call_script, "script_party_count_fit_for_battle","p_main_party"),
          (gt, reg(0), 5),
          
        ],"Attack.",
        [
          (party_get_slot, ":curr_town", "$g_encountered_party", slot_party_port_party),
          (call_script, "script_give_player_ships_from_party_to_party", "p_main_party", ":curr_town"),
          (party_get_position, pos2, ":curr_town"),
          (party_set_position, "p_main_party", pos2),
          (call_script, "script_switch_to_land_consequences"),
          (assign, "$auto_enter_town", ":curr_town"),
          
          (assign,"$g_player_besiege_town","$g_encountered_party"),
          (call_script, "script_make_kingdom_hostile_to_player", "$g_encountered_party_faction", -40),
          (call_script, "script_update_all_notes"),
          
          (assign, "$g_battle_result", 0),
          (assign, "$g_castle_left_to_player",0),
          #(jump_to_menu, "mnu_port_attack"),
          (assign, "$g_next_menu", "mnu_port_attack"),
          (change_screen_return),
        ]
      ),
      
      ("merge",
        [
          (eq, "$temp", 2),
          
        ],"Merge the fleets.",
        [
          
          (party_get_slot, ":curr_town", "$g_encountered_party", slot_party_port_party),
          (call_script, "script_merge_ships_from_party_to_party", ":curr_town", "p_main_party"),
          (jump_to_menu, "mnu_port_encounter"),
        ]
      ),
      
      ("leave",[],"Leave.",
        [
          (change_screen_return),
        ]
      ),
      
  ]),
  
  # (
    # "camp_on_sea",0,
    # "You stop your ships in the sea. What do you want to do?^^" +
    # "{!}{s1}",
    # "none",
    # [
      # (set_background_mesh,"mesh_pic_knorr"),
      
      # (str_clear,s1),
      # (party_get_num_companion_stacks, ":num", "p_main_party"),
      # (try_for_range, ":stack_no", 0, ":num"),
        # (party_stack_get_troop_id, ":party_troop", "p_main_party", ":stack_no"),
        # (eq, ":party_troop", "trp_regular_sailors"),
        # (assign, ":num", 0), #loop breaker
        # (party_stack_get_size, ":size", "p_main_party", ":stack_no"),
        # (party_stack_get_num_wounded, ":wounded", "p_main_party", ":stack_no"),
        # (val_sub, ":size", ":wounded"),
        # (ge, ":size", 1),
        # (assign, reg5, ":size"),
        # (store_div, ":total_movement", ":size", 10),
        # (try_begin),
          # (ge, ":total_movement", 20),
          # (assign, ":total_movement", 20), 	# max speed. Phaiak maybe you want read this to balance.
        # (try_end),
        # (assign, reg6, ":total_movement"),
        # (str_store_string, s1, "@Number of Sailors: {reg5}^Speed from Sailors: {reg6}"),
      # (try_end),
    # ],
    # [
      
      # ("epic_sea_battle",[],"B. Epic sea battle!",
        # [
          # ###(options_set_battle_size, 500),
          # (call_script, "script_troop_add_gold", "trp_player", 20000),
          # (call_script, "script_change_troop_renown", "trp_player", 2000),
          
          # (party_force_add_members, "p_main_party" , "trp_taiga_bandit", 90),
          # (party_force_add_members, "p_main_party" , "trp_elite_viking", 90),
          # (party_add_members, "p_main_party", "trp_mercenary_swordsman", 30),
          # (party_add_members, "p_main_party", "trp_hired_blade", 30),
          # (party_add_members, "p_main_party", "trp_mercenary_crossbowman", 30),
          
          # (party_set_slot, "p_main_party", slot_party_1_ship_type, 2), 	#
          # (party_set_slot, "p_main_party", slot_party_1_ship_quality, 100), #
          # (party_set_slot, "p_main_party", slot_party_2_ship_type, 4), 	#
          # (party_set_slot, "p_main_party", slot_party_2_ship_quality, 80), #
          # (party_set_slot, "p_main_party", slot_party_3_ship_type, 6), 	#
          # (party_set_slot, "p_main_party", slot_party_3_ship_quality, 100), #
          # (party_set_slot, "p_main_party", slot_party_4_ship_type, 3), 	#
          # (party_set_slot, "p_main_party", slot_party_4_ship_quality, 90), #
          # (party_set_slot, "p_main_party", slot_party_5_ship_type, 4), 	#
          # (party_set_slot, "p_main_party", slot_party_5_ship_quality, 80),
          # (party_set_slot, "p_main_party", slot_party_6_ship_type, 6), 	#
          # (party_set_slot, "p_main_party", slot_party_6_ship_quality, 100),
          # (party_set_slot, "p_main_party", slot_party_7_ship_type, 6), 	#
          # (party_set_slot, "p_main_party", slot_party_7_ship_quality, 90),
          
          # (spawn_around_party, "p_main_party", "pt_epic_fleet"),
          # (party_set_ai_object, "p_main_party", reg0),
          
          # (party_set_slot, reg0, slot_party_1_ship_type, 3), 	#
          # (party_set_slot, reg0, slot_party_1_ship_quality, 100), #
          # (party_set_slot, reg0, slot_party_2_ship_type, 2), 	#
          # (party_set_slot, reg0, slot_party_2_ship_quality, 80), #
          # (party_set_slot, reg0, slot_party_3_ship_type, 4), 	#
          # (party_set_slot, reg0, slot_party_3_ship_quality, 100), #
          # (party_set_slot, reg0, slot_party_4_ship_type, 3), 	#
          # (party_set_slot, reg0, slot_party_4_ship_quality, 90), #
          # (party_set_slot, reg0, slot_party_5_ship_type, 6), 	#
          # (party_set_slot, reg0, slot_party_5_ship_quality, 80),
          # (party_set_slot, reg0, slot_party_6_ship_type, 3), 	#
          # (party_set_slot, reg0, slot_party_6_ship_quality, 100),
          # (party_set_slot, reg0, slot_party_7_ship_type, 3), 	#
          # (party_set_slot, reg0, slot_party_7_ship_quality, 90),
          
          # (change_screen_return),
        # ]
      # ),
      
      # ("d_day1",[],"C. D-day! (200 ships)",
        # [
          # #(play_track, "track_epic_music", 2),
          # (assign, "$d_day_ships", 200),
          # (select_enemy, 0),
          # (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          # (set_jump_mission,"mt_d_day"),
          # (jump_to_scene,"scn_d_day"),
          # (change_screen_mission),(gt, "$percent_crew", 0),
        # ]
      # ),
      
      
      # ("testdrive2",[],"mega sea battle... select_enemy 0",
        # [
          # (set_jump_mission,"mt_sea_battle_player_party_and_2_visitor_partys"),
          # (select_enemy, 0),
          # #team 0
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop1_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop1_count, 3),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop2_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop2_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop3_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop3_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop4_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop4_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop5_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop5_count, 0),
          # #team 1
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop1_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop1_count, 7),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop2_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop2_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop3_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop3_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop4_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop4_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop5_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop5_count, 0),
          
          # (jump_to_scene,"scn_mega_sea_battle"),
          
          # (change_screen_mission),
        # ]
      # ),
      
      # ("testdrive2",[],"mega sea battle... select_enemy 1",
        # [
          # (set_jump_mission,"mt_sea_battle_player_party_and_2_visitor_partys"),
          # (select_enemy, 1),
          # #team 0
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop1_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop1_count, 3),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop2_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop2_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop3_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop3_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop4_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop4_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop5_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_0_spawn_troop5_count, 0),
          # #team 1
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop1_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop1_count, 7),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop2_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop2_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop3_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop3_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop4_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop4_count, 0),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop5_type, "trp_sailors"),
          # (quest_set_slot, "qst_sea_battle_spawn", slot_quest_team_1_spawn_troop5_count, 0),
          
          # (jump_to_scene,"scn_mega_sea_battle"),
          
          # (change_screen_mission),
        # ]
      # ),
      
      
      # ("see_ships",[],"Take a look at your ships. (WIP)",
        # [
          # (assign, "$vc_menu_active", "prsnt_vc_submenu_ships"),
          # (assign, "$current_town", "p_main_party"),	# maybe dangerous...
          # (set_jump_mission,"mt_camp_on_sea"),
          # (jump_to_scene,"scn_camp_on_sea"),
          # (change_screen_mission),
        # ]
      # ),
      
      # ("camp_action_1",[(eq,"$cheat_mode",1)],"{!}Cheat: Walk around.",
        # [
          # (set_jump_mission,"mt_sea_battle"),
          # (jump_to_scene,"scn_sea_battle"),
          # (change_screen_mission),
        # ]
      # ),
      
      # ("camp_wait_here",[],"Wait here for some time.",
        # [
          # (assign,"$g_camp_mode", 1),
          # (assign, "$g_infinite_camping", 0),
          # (rest_for_hours_interactive, 24 * 365, 5, 1), #rest while attackable
          # (change_screen_return),
        # ]
      # ),
      
      # ("resume_travelling",[],"Resume travelling.",
        # [
          # (change_screen_return),
        # ]
      # ),
      
  # ]),
  
  ### map sea travel menus end
  ##  ( ###off add in character presentation
  ##   "wound_report",0,
  ##    "{!}{s0}",
  ##    "none",
  ##    [
  ##	  (set_background_mesh,"mesh_pic_wounded"),
  ##
  ##	  (call_script, "script_store_wound_report_to_s0"),
  ##     ],
  ##[
  ##
  ##      ("back",[],"Back.",
  ##       [
  ##           (jump_to_menu, "mnu_camp"),
  ##        ]
  ##       ),
  ##
  ##  ]),
  
  (
    "center_reports",0,
    "Town Name: {s1}^Rent Income: {reg1} peningas^Tariff Income: {reg2} peningas^Food Stocks: for {reg3} days",
    "none",
    [(party_get_slot, ":town_food_store", "$g_encountered_party", slot_party_food_store),
      (call_script, "script_center_get_food_consumption", "$g_encountered_party"),
      (assign, ":food_consumption", reg0),
      (try_begin),
        (gt, ":food_consumption", 0),
        (store_div, reg3, ":town_food_store", ":food_consumption"),
      (else_try),
        (assign, reg3, 9999),
      (try_end),
      (str_store_party_name, s1, "$g_encountered_party"),
      (party_get_slot, reg1, "$g_encountered_party", slot_center_accumulated_rents),
      (party_get_slot, reg2, "$g_encountered_party", slot_center_accumulated_tariffs),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("to_price_and_productions", [], "Show prices and production.",
        [(jump_to_menu, "mnu_price_and_production"),
      ]),
      
      ("go_back_dot",[],"Go back.",
        [(try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
            (jump_to_menu, "mnu_village"),
          (else_try),
            (jump_to_menu, "mnu_town"),
          (try_end),
      ]),
    ]
  ),
  
  (
    "price_and_production",0,
    "Goods produced are:^(Note: base/modified by raw materials/modified by materials plus prosperity)^{s1}^^Price factors are:^{s2}",
    "none",
    [
      
      (assign, ":calradian_average_urban_hardship", 0),
      (assign, ":calradian_average_rural_hardship", 0),
      
      (try_for_range, ":center", towns_begin, towns_end),
        (call_script, "script_center_get_goods_availability", ":center"),
        (val_add, ":calradian_average_urban_hardship", reg0),
      (try_end),
      
      (try_for_range, ":center", villages_begin, villages_end),
        (call_script, "script_center_get_goods_availability", ":center"),
        (val_add, ":calradian_average_rural_hardship", reg0),
      (try_end),
      
      # MOTO replace hard-coded The Northlands values chief
      # (val_div, ":calradian_average_rural_hardship", 110),
      # (val_div, ":calradian_average_urban_hardship", 22),
      (store_sub, reg0, villages_end, villages_begin),
      (val_div, ":calradian_average_rural_hardship", reg0),
      (store_sub, reg0, towns_end, towns_begin),
      (val_div, ":calradian_average_urban_hardship", reg0),
      # MOTO replace hard-coded The Northlands values end
      
      
      (call_script, "script_center_get_goods_availability", "$g_encountered_party"),
      
      (assign, reg1, ":calradian_average_urban_hardship"),
      (assign, reg2, ":calradian_average_rural_hardship"),
      
      (try_begin),
        (ge, "$cheat_mode", 1),
        (str_store_string, s1, "str___hardship_index_reg0_avg_towns_reg1_avg_villages_reg2__"),
        (display_message, "@{!}DEBUG - {s1}"),
      (try_end),
      
      
      (try_for_range, ":cur_good", trade_goods_begin, trade_goods_end),
        (neq, ":cur_good", "itm_pork"), #tied to price of grain
        (neq, ":cur_good", "itm_chicken"), #tied to price of grain
        (neq, ":cur_good", "itm_butter"), #tied to price of cheese
        (neq, ":cur_good", "itm_cattle_meat"),
        (neq, ":cur_good", "itm_cabbages"), #possibly include later
        
        (call_script, "script_center_get_production", "$g_encountered_party", ":cur_good"),
        (assign, ":production", reg0),
        (assign, ":base_production", reg2),
        (assign, ":base_production_modded_by_raw_materials", reg1),
        
        (call_script, "script_center_get_consumption", "$g_encountered_party", ":cur_good"),
        (assign, ":consumer_consumption", reg2),
        (assign, ":raw_material_consumption", reg1),
        (assign, ":consumption", reg0),
        
        (store_sub, ":cur_good_price_slot", ":cur_good", trade_goods_begin),
        (val_add, ":cur_good_price_slot", slot_town_trade_good_prices_begin),
        (party_get_slot, ":price", "$g_encountered_party", ":cur_good_price_slot"),
        
        (assign, ":total_centers", 0),
        (assign, ":calradian_average_price", 0),
        (assign, ":calradian_average_production", 0),
        (assign, ":calradian_average_consumption", 0),
        
        (try_for_range, ":center", centers_begin, centers_end),
          (neg|is_between, ":center", castles_begin, castles_end),
          (val_add, ":total_centers", 1),
          (call_script, "script_center_get_production", ":center", ":cur_good"),
          (assign, ":center_production", reg2),
          (call_script, "script_center_get_consumption", ":center", ":cur_good"),
          (store_add, ":center_consumption", reg1, reg2),
          
          (party_get_slot, ":center_price", ":center", ":cur_good_price_slot"),
          (val_add, ":calradian_average_price", ":center_price"),
          (val_add, ":calradian_average_production", ":center_production"),
          (val_add, ":calradian_average_consumption", ":center_consumption"),
        (try_end),
        
        (assign, ":calradian_total_production", ":calradian_average_production"),
        (assign, ":calradian_total_consumption", ":calradian_average_consumption"),
        
        (val_div, ":calradian_average_price", ":total_centers"),
        (val_div, ":calradian_average_production", ":total_centers"),
        (val_div, ":calradian_average_consumption", ":total_centers"),
        
        
        (str_store_item_name, s3, ":cur_good"),
        
        (assign, reg1, ":base_production"),
        (assign, reg2, ":base_production_modded_by_raw_materials"),
        (assign, reg3, ":production"),
        (assign, reg4, ":price"),
        
        (assign, reg5, ":calradian_average_production"),
        (assign, reg6, ":calradian_average_price"),
        
        (assign, reg7, ":consumer_consumption"),
        (assign, reg8, ":raw_material_consumption"),
        (assign, reg9, ":consumption"),
        
        (assign, reg10, ":calradian_average_consumption"),
        
        (item_get_slot, ":production_slot", ":cur_good", slot_item_production_slot),
        (party_get_slot, ":production_number", "$g_encountered_party", ":production_slot"),
        (assign, reg11, ":production_number"),
        (assign, reg12, ":calradian_total_production"),
        (assign, reg13, ":calradian_total_consumption"),
        
        (item_get_slot, ":production_string", ":cur_good", slot_item_production_string),
        (str_store_string, s4, ":production_string"),
        
        (str_store_string, s1, "str___s3_price_=_reg4_calradian_average_reg6_capital_reg11_s4_base_reg1modified_by_raw_material_reg2modified_by_prosperity_reg3_calradian_average_production_base_reg5_total_reg12_consumed_reg7used_as_raw_material_reg8modified_total_reg9_calradian_consumption_base_reg10_total_reg13s1_"),
      (try_end),
      
      (call_script, "script_set_town_picture"),
    ],
    [
      ("go_back_dot",[],"Go back.",
        [(try_begin),
            (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
            (jump_to_menu, "mnu_village"),
          (else_try),
            (jump_to_menu, "mnu_town"),
          (try_end),
      ]),
    ]
  ),
  
  (
    "town_trade",0,
    "You head towards the marketplace.",
    "none",
    [ (call_script, "script_set_town_picture"),
    ],
    [
      ("assess_prices",
        [
          (store_faction_of_party, ":current_town_faction", "$current_town"),
          (store_relation, ":reln", ":current_town_faction", "fac_player_faction"),
          (ge, ":reln", 0),
        ],
        "Assess the local prices.",
        [
          (jump_to_menu,"mnu_town_trade_assessment_begin"),
      ]),
      ("trophies",[(this_or_next|player_has_item,"itm_trophy_a"),
          (this_or_next|player_has_item,"itm_trophy_b"),
          (player_has_item,"itm_trophy_c"),
        ],
        "Redeem your battle trophies.",
        [
          (jump_to_menu,"mnu_trophy_premium"),
      ]),
      ("highking_trophies",[(this_or_next|player_has_item,"itm_trophy_norse"),
          (this_or_next|player_has_item,"itm_trophy_cymry"),
          (this_or_next|player_has_item,"itm_trophy_irish"),
          (player_has_item,"itm_trophy_saxon"),
        ],
        "Redeem your High King trophies.",
        [
          (jump_to_menu,"mnu_trophy_hihgking_premium"),
      ]),
      
      ("trade_with_arms_merchant",[(party_slot_ge, "$current_town", slot_town_weaponsmith, 1)],
        "Trade with the weaponsmith.",
        [
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_weaponsmith),
          (assign, "$g_talk_troop", ":merchant_troop"),
          (change_screen_trade, ":merchant_troop"),
      ]),
      ("trade_with_armor_merchant",[(party_slot_ge, "$current_town", slot_town_armorer, 1)],
        "Trade with the armorer.",
        [
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_armorer),
          (assign, "$g_talk_troop", ":merchant_troop"),
          (change_screen_trade, ":merchant_troop"),
      ]),
      ("trade_with_horse_merchant",[(party_slot_ge, "$current_town", slot_town_horse_merchant, 1)],
        "Trade with the horse merchant.",
        [
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_horse_merchant),
          (assign, "$g_talk_troop", ":merchant_troop"),
          (change_screen_trade, ":merchant_troop"),
      ]),
      ("trade_with_goods_merchant",[(party_slot_ge, "$current_town", slot_town_merchant, 1)],
        "Trade with the goods merchant.",
        [
          (party_get_slot, ":merchant_troop", "$current_town", slot_town_merchant),
          (assign, "$g_talk_troop", ":merchant_troop"),
          (troop_set_auto_equip, ":merchant_troop",0),
          (change_screen_trade, ":merchant_troop"),
      ]),
      ("back_to_town_menu",[],"Head back.",
        [
          (jump_to_menu,"mnu_town"),
      ]),
    ]
  ),
  ########premium for trophy battle chief
  ("trophy_premium",0,
    "The battle trophies are coveted goods. Exchange them for money and experience.",
    "none",
    [       (set_background_mesh, "mesh_pic_chest"), #pic book
    ],
    [
      ("premium_a",[(player_has_item,"itm_trophy_a")],
        "Exchange battle trophy.",
        [
          (add_xp_to_troop,300,"trp_player"),
          (party_add_xp, "p_main_party", 500),
          #(call_script, "script_upgrade_hero_party", "p_main_party", 2000),
          (troop_remove_item,"trp_player","itm_trophy_a"),
          (call_script, "script_troop_add_gold", "trp_player", 500),
          (jump_to_menu,"mnu_trophy_premium"),
      ]),
      ("premium_b",[(player_has_item,"itm_trophy_b")],
        "Exchange war trophy.",
        [
          
          (add_xp_to_troop,600,"trp_player"),
          (party_add_xp, "p_main_party", 1500),
          (call_script, "script_change_player_relation_with_center", "$current_town", 1),
          #         (call_script, "script_upgrade_hero_party", "p_main_party", 4000),
          (call_script,"script_change_troop_renown", "trp_player" ,1),
          (troop_remove_item,"trp_player","itm_trophy_b"),
          (call_script, "script_troop_add_gold", "trp_player", 1000),
          (jump_to_menu,"mnu_trophy_premium"),
      ]),
      ("premium_c",[(player_has_item,"itm_trophy_c")],
        "Exchange epic trophy",
        [
          (add_xp_to_troop,900,"trp_player"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 2),
          (party_add_xp, "p_main_party", 2500),
          #  (call_script, "script_upgrade_hero_party", "p_main_party", 6000),
          (call_script,"script_change_troop_renown", "trp_player" ,3),
          (call_script, "script_troop_add_gold", "trp_player", 2000),
          (troop_remove_item,"trp_player","itm_trophy_c"),
          (jump_to_menu,"mnu_trophy_premium"),
      ]),
      
      ("back",[],"Back.",
        [
          (jump_to_menu,"mnu_town_trade"),
      ]),
    ]
  ),
  ###high king add-ons trophy
  ("trophy_hihgking_premium",0,
    "The High King trophies are coveted goods, as they are only obtained by powerful warlords who are able to unite under their banner many territories. Exchange them for a lot of money and experience.",
    "none",
    [       (set_background_mesh, "mesh_pic_chest"), #pic book
    ],
    [
      ("premium_norse",[(player_has_item,"itm_trophy_norse")],
        "Exchange Norse Konungr trophy.",
        [
          # (add_xp_to_troop,3500,"trp_player"),
          (party_add_xp, "p_main_party", 30000),
          #         (call_script, "script_upgrade_hero_party", "p_main_party", 10000),
          (troop_remove_item,"trp_player","itm_trophy_norse"),
          (call_script, "script_troop_add_gold", "trp_player", 8000),
          (jump_to_menu,"mnu_trophy_hihgking_premium"),
      ]),
      ("premium_cymry",[(player_has_item,"itm_trophy_cymry")],
        "Exchange Vrenhin Lloegr trophy.",
        [
          #  (add_xp_to_troop,3500,"trp_player"),
          (party_add_xp, "p_main_party", 30000),
          #         (call_script, "script_upgrade_hero_party", "p_main_party", 10000),
          (troop_remove_item,"trp_player","itm_trophy_cymry"),
          (call_script, "script_troop_add_gold", "trp_player", 8000),
          (jump_to_menu,"mnu_trophy_hihgking_premium"),
      ]),
      ("premium_irish",[(player_has_item,"itm_trophy_irish")],
        "Exchange Ard Ruire trophy.",
        [
          # (add_xp_to_troop,3500,"trp_player"),
          (party_add_xp, "p_main_party", 30000),
          #         (call_script, "script_upgrade_hero_party", "p_main_party", 10000),
          (troop_remove_item,"trp_player","itm_trophy_irish"),
          (call_script, "script_troop_add_gold", "trp_player", 8000),
          (jump_to_menu,"mnu_trophy_hihgking_premium"),
      ]),
      ("premium_saxon",[(player_has_item,"itm_trophy_saxon")],
        "Exchange Brytenwalda trophy.",
        [
          # (add_xp_to_troop,3500,"trp_player"),
          (party_add_xp, "p_main_party", 30000),
          #         (call_script, "script_upgrade_hero_party", "p_main_party", 10000),
          (troop_remove_item,"trp_player","itm_trophy_saxon"),
          (call_script, "script_troop_add_gold", "trp_player", 8000),
          (jump_to_menu,"mnu_trophy_hihgking_premium"),
      ]),
      
      ("back",[],"Back.",
        [
          (jump_to_menu,"mnu_town_trade"),
      ]),
    ]
  ),
  ##########
  (
    "town_trade_assessment_begin",0,
    #"You overhear the following details about the roads out of town :^(experimental feature -- this may go into dialogs)^{s42}^You also overhear several discussions about the price of trade goods across the local area.^You listen closely, trying to work out the best deals around.",
    "You overhear several discussions about the price of trade goods across the local area.^You listen closely, trying to work out the best deals around.",
    "none",
    [
      (str_clear, s42),
      ##	(call_script, "script_merchant_road_info_to_s42", "$g_encountered_party"),
      (call_script, "script_set_town_picture"),
    ],
    
    [
      ("continue",[],"Continue...",
        [
          (assign,"$auto_enter_town", "$current_town"),
          (assign, "$g_town_assess_trade_goods_after_rest", 1),
          (call_script, "script_get_max_skill_of_player_party", "skl_trade"),
          (val_div, reg0, 2),
          (store_sub, ":num_hours", 6, reg0),
          (assign, "$g_last_rest_center", "$current_town"),
          (assign, "$g_last_rest_payment_until", -1),
          (rest_for_hours, ":num_hours", 5, 0), #rest while not attackable
          (change_screen_return),
      ]),
      ("go_back_dot",[],"Go back.",
        [
          (jump_to_menu,"mnu_town_trade"),
      ]),
    ]
  ),
  
  (
    "town_trade_assessment",mnf_disable_all_keys,
    "As the party member with the highest trade skill ({reg2}), {reg3?you try to figure out:{s1} tries to figure out} the best goods to trade in. {s2}",
    "none",
    [
      
      (call_script, "script_get_max_skill_of_player_party", "skl_trade"),
      (assign, ":max_skill", reg0),
      (assign, ":max_skill_owner", reg1),
      
      (assign, ":num_best_results", 0),
      (assign, ":best_result_1_item", -1),
      (assign, ":best_result_1_town", -1),
      (assign, ":best_result_1_profit", 0),
      (assign, ":best_result_2_item", -1),
      (assign, ":best_result_2_town", -1),
      (assign, ":best_result_2_profit", 0),
      (assign, ":best_result_3_item", -1),
      (assign, ":best_result_3_town", -1),
      (assign, ":best_result_3_profit", 0),
      (assign, ":best_result_4_item", -1),
      (assign, ":best_result_4_town", -1),
      (assign, ":best_result_4_profit", 0),
      (assign, ":best_result_5_item", -1),
      (assign, ":best_result_5_town", -1),
      (assign, ":best_result_5_profit", 0),
      
      (store_sub, ":num_towns", walled_centers_end, walled_centers_begin),
      (store_sub, ":num_goods", trade_goods_end, trade_goods_begin),
      (store_mul, ":max_iteration", ":num_towns", ":num_goods"),
      (val_mul, ":max_iteration", ":max_skill"),
      (val_div, ":max_iteration", 20),
      
      (assign, ":org_encountered_party", "$g_encountered_party"),
      
      (try_for_range, ":unused", 0, ":max_iteration"),
        (store_random_in_range, ":random_trade_good", trade_goods_begin, trade_goods_end),
        
        (store_random_in_range, ":random_town", towns_begin, towns_end),
        
        (party_get_slot, ":cur_merchant", ":org_encountered_party", slot_town_merchant),
        (assign, ":num_items_in_town_inventory", 0),
        (try_for_range, ":i_slot", num_equipment_kinds, max_inventory_items + num_equipment_kinds),
          (troop_get_inventory_slot, ":slot_item", ":cur_merchant", ":i_slot"),
          (try_begin),
            (eq, ":slot_item", ":random_trade_good"),
            (val_add, ":num_items_in_town_inventory", 1),
          (try_end),
        (try_end),
        
        (ge, ":num_items_in_town_inventory", 1),
        
        (assign, ":already_best", 0),
        
        (try_begin),
          (eq, ":random_trade_good", ":best_result_1_item"),
          (eq, ":random_town", ":best_result_1_town"),
          (val_add, ":already_best", 1),
        (try_end),
        
        (try_begin),
          (eq, ":random_trade_good", ":best_result_2_item"),
          (eq, ":random_town", ":best_result_2_town"),
          (val_add, ":already_best", 1),
        (try_end),
        
        (try_begin),
          (eq, ":random_trade_good", ":best_result_3_item"),
          (eq, ":random_town", ":best_result_3_town"),
          (val_add, ":already_best", 1),
        (try_end),
        
        (try_begin),
          (eq, ":random_trade_good", ":best_result_4_item"),
          (eq, ":random_town", ":best_result_4_town"),
          (val_add, ":already_best", 1),
        (try_end),
        
        (try_begin),
          (eq, ":random_trade_good", ":best_result_5_item"),
          (eq, ":random_town", ":best_result_5_town"),
          (val_add, ":already_best", 1),
        (try_end),
        
        (le, ":already_best", 1),
        
        (store_item_value, ":random_trade_good_price", ":random_trade_good"),
        (assign, "$g_encountered_party", ":org_encountered_party"),
        (call_script, "script_game_get_item_buy_price_factor", ":random_trade_good"),
        (store_mul, ":random_trade_good_buy_price", ":random_trade_good_price", reg0),
        (val_div, ":random_trade_good_buy_price", 100),
        (val_max, ":random_trade_good_buy_price", 1),
        (assign, "$g_encountered_party", ":random_town"),
        (call_script, "script_game_get_item_sell_price_factor", ":random_trade_good"),
        (store_mul, ":random_trade_good_sell_price", ":random_trade_good_price", reg0),
        (val_div, ":random_trade_good_sell_price", 100),
        (val_max, ":random_trade_good_sell_price", 1),
        (store_sub, ":difference", ":random_trade_good_sell_price", ":random_trade_good_buy_price"),
        
        (try_begin),
          (this_or_next|eq, ":best_result_1_item", ":random_trade_good"),
          (this_or_next|eq, ":best_result_2_item", ":random_trade_good"),
          (this_or_next|eq, ":best_result_3_item", ":random_trade_good"),
          (this_or_next|eq, ":best_result_4_item", ":random_trade_good"),
          (eq, ":best_result_5_item", ":random_trade_good"),
          
          (try_begin),
            (eq, ":best_result_1_item", ":random_trade_good"),
            (gt, ":difference", ":best_result_1_profit"),
            (assign, ":best_result_1_item", ":random_trade_good"),
            (assign, ":best_result_1_town", ":random_town"),
            (assign, ":best_result_1_profit", ":difference"),
          (else_try),
            (eq, ":best_result_2_item", ":random_trade_good"),
            (gt, ":difference", ":best_result_2_profit"),
            (assign, ":best_result_2_item", ":random_trade_good"),
            (assign, ":best_result_2_town", ":random_town"),
            (assign, ":best_result_2_profit", ":difference"),
          (else_try),
            (eq, ":best_result_3_item", ":random_trade_good"),
            (gt, ":difference", ":best_result_3_profit"),
            (assign, ":best_result_3_item", ":random_trade_good"),
            (assign, ":best_result_3_town", ":random_town"),
            (assign, ":best_result_3_profit", ":difference"),
          (else_try),
            (eq, ":best_result_4_item", ":random_trade_good"),
            (gt, ":difference", ":best_result_4_profit"),
            (assign, ":best_result_4_item", ":random_trade_good"),
            (assign, ":best_result_4_town", ":random_town"),
            (assign, ":best_result_4_profit", ":difference"),
          (else_try),
            (eq, ":best_result_5_item", ":random_trade_good"),
            (gt, ":difference", ":best_result_5_profit"),
            (assign, ":best_result_5_item", ":random_trade_good"),
            (assign, ":best_result_5_town", ":random_town"),
            (assign, ":best_result_5_profit", ":difference"),
          (try_end),
        (else_try),
          (try_begin),
            (gt, ":difference", ":best_result_1_profit"),
            (val_add, ":num_best_results", 1),
            (val_min, ":num_best_results", 5),
            (assign, ":best_result_5_item", ":best_result_4_item"),
            (assign, ":best_result_5_town", ":best_result_4_town"),
            (assign, ":best_result_5_profit", ":best_result_4_profit"),
            (assign, ":best_result_4_item", ":best_result_3_item"),
            (assign, ":best_result_4_town", ":best_result_3_town"),
            (assign, ":best_result_4_profit", ":best_result_3_profit"),
            (assign, ":best_result_3_item", ":best_result_2_item"),
            (assign, ":best_result_3_town", ":best_result_2_town"),
            (assign, ":best_result_3_profit", ":best_result_2_profit"),
            (assign, ":best_result_2_item", ":best_result_1_item"),
            (assign, ":best_result_2_town", ":best_result_1_town"),
            (assign, ":best_result_2_profit", ":best_result_1_profit"),
            (assign, ":best_result_1_item", ":random_trade_good"),
            (assign, ":best_result_1_town", ":random_town"),
            (assign, ":best_result_1_profit", ":difference"),
          (else_try),
            (gt, ":difference", ":best_result_2_profit"),
            (val_add, ":num_best_results", 1),
            (val_min, ":num_best_results", 5),
            (assign, ":best_result_5_item", ":best_result_4_item"),
            (assign, ":best_result_5_town", ":best_result_4_town"),
            (assign, ":best_result_5_profit", ":best_result_4_profit"),
            (assign, ":best_result_4_item", ":best_result_3_item"),
            (assign, ":best_result_4_town", ":best_result_3_town"),
            (assign, ":best_result_4_profit", ":best_result_3_profit"),
            (assign, ":best_result_3_item", ":best_result_2_item"),
            (assign, ":best_result_3_town", ":best_result_2_town"),
            (assign, ":best_result_3_profit", ":best_result_2_profit"),
            (assign, ":best_result_2_item", ":random_trade_good"),
            (assign, ":best_result_2_town", ":random_town"),
            (assign, ":best_result_2_profit", ":difference"),
          (else_try),
            (gt, ":difference", ":best_result_3_profit"),
            (val_add, ":num_best_results", 1),
            (val_min, ":num_best_results", 5),
            (assign, ":best_result_5_item", ":best_result_4_item"),
            (assign, ":best_result_5_town", ":best_result_4_town"),
            (assign, ":best_result_5_profit", ":best_result_4_profit"),
            (assign, ":best_result_4_item", ":best_result_3_item"),
            (assign, ":best_result_4_town", ":best_result_3_town"),
            (assign, ":best_result_4_profit", ":best_result_3_profit"),
            (assign, ":best_result_3_item", ":random_trade_good"),
            (assign, ":best_result_3_town", ":random_town"),
            (assign, ":best_result_3_profit", ":difference"),
          (else_try),
            (gt, ":difference", ":best_result_4_profit"),
            (val_add, ":num_best_results", 1),
            (val_min, ":num_best_results", 5),
            (assign, ":best_result_5_item", ":best_result_4_item"),
            (assign, ":best_result_5_town", ":best_result_4_town"),
            (assign, ":best_result_5_profit", ":best_result_4_profit"),
            (assign, ":best_result_4_item", ":random_trade_good"),
            (assign, ":best_result_4_town", ":random_town"),
            (assign, ":best_result_4_profit", ":difference"),
          (else_try),
            (gt, ":difference", ":best_result_5_profit"),
            (val_add, ":num_best_results", 1),
            (val_min, ":num_best_results", 5),
            (assign, ":best_result_5_item", ":best_result_4_item"),
            (assign, ":best_result_5_town", ":best_result_4_town"),
            (assign, ":best_result_5_profit", ":best_result_4_profit"),
          (try_end),
        (try_end),
      (try_end),
      
      (assign, "$g_encountered_party", ":org_encountered_party"),
      
      (str_clear, s3),
      
      (assign, reg2, ":max_skill"),
      (try_begin),
        (eq, ":max_skill_owner", "trp_player"),
        (assign, reg3, 1),
      (else_try),
        (assign, reg3, 0),
        (str_store_troop_name, s1, ":max_skill_owner"),
      (try_end),
      (try_begin),
        (le, ":num_best_results", 0),
        (str_store_string, s2, "@Unfortunately, {reg3?You are:{s1} is} unable to find any trade goods that would bring a profit."),
      (else_try),
        (try_begin),
          (ge, ":best_result_5_item", 0),
          (assign, reg6, ":best_result_5_profit"),
          (str_store_item_name, s4, ":best_result_5_item"),
          (str_store_party_name, s5, ":best_result_5_town"),
          (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} peningas per item.{s3}"),
        (try_end),
        (try_begin),
          (ge, ":best_result_4_item", 0),
          (assign, reg6, ":best_result_4_profit"),
          (str_store_item_name, s4, ":best_result_4_item"),
          (str_store_party_name, s5, ":best_result_4_town"),
          (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} peningas per item.{s3}"),
        (try_end),
        (try_begin),
          (ge, ":best_result_3_item", 0),
          (assign, reg6, ":best_result_3_profit"),
          (str_store_item_name, s4, ":best_result_3_item"),
          (str_store_party_name, s5, ":best_result_3_town"),
          (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} peningas per item.{s3}"),
        (try_end),
        (try_begin),
          (ge, ":best_result_2_item", 0),
          (assign, reg6, ":best_result_2_profit"),
          (str_store_item_name, s4, ":best_result_2_item"),
          (str_store_party_name, s5, ":best_result_2_town"),
          (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} peningas per item.{s3}"),
        (try_end),
        (try_begin),
          (ge, ":best_result_1_item", 0),
          (assign, reg6, ":best_result_1_profit"),
          (str_store_item_name, s4, ":best_result_1_item"),
          (str_store_party_name, s5, ":best_result_1_town"),
          (str_store_string, s3, "@^Buying {s4} here and selling it at {s5} would bring a profit of {reg6} peningas per item.{s3}"),
        (try_end),
        (str_store_string, s2, "@{reg3?You find:{s1} finds} out the following:^{s3}"),
      (try_end),
      (call_script, "script_set_town_picture"),
    ],
    [
      ("continue",[],"Continue...",
        [
          (jump_to_menu,"mnu_town_trade"),
      ]),
    ]
  ),
  
  
  
  
  (
    "sneak_into_town_suceeded",0,
    "Disguised in the garments of a poor pilgrim, you fool the guards and make your way into the town.",
    "none",
    [     (set_background_mesh, "mesh_sneak_into_town"), #pic book
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$sneaked_into_town",1),
          (jump_to_menu,"mnu_town"),
      ]),
    ]
  ),
  (
    "sneak_into_town_caught",0,
    "As you try to sneak in, one of the guards recognizes you and raises the alarm! " +
    "You must flee back through the gates before all the guards in the town come down on you!",
    "none",
    [
      (assign,"$auto_menu","mnu_captivity_start_castle_surrender"),
      (set_background_mesh, "mesh_pic_irish_veterans"), #pic book
    ],
    [
      ("sneak_caught_fight",[],"Try to fight your way out!",
        [
          (assign,"$all_doors_locked",1),
          (party_get_slot, ":sneak_scene", "$current_town", slot_town_center), # slot_town_gate),
          (modify_visitors_at_site,":sneak_scene"),
          (reset_visitors),
          
          (try_begin),
            (this_or_next|eq, "$talk_context", tc_escape),
            (eq, "$talk_context", tc_prison_break),
            (set_jump_entry, 7),
          (else_try),
            (party_slot_eq, "$current_town", slot_party_type, spt_town),
            #(set_visitor,0,"trp_player"),
            (set_jump_entry, 0),
          (else_try),
            #(set_visitor,1,"trp_player"),
            (set_jump_entry, 1),
          (try_end),
          
          #(store_faction_of_party, ":town_faction","$current_town"),
          #(faction_get_slot, ":tier_2_troop", ":town_faction", slot_faction_tier_2_troop),
          #(faction_get_slot, ":tier_3_troop", ":town_faction", slot_faction_tier_3_troop),
          #(try_begin),
          #  (gt, ":tier_2_troop", 0),
          #  (gt, ":tier_3_troop", 0),
          #  (assign,reg0,":tier_3_troop"),
          #  (assign,reg1,":tier_3_troop"),
          #  (assign,reg2,":tier_2_troop"),
          #  (assign,reg3,":tier_2_troop"),
          #(else_try),
          #  (assign,reg0,"trp_briton_bowman"),
          #  (assign,reg1,"trp_briton_level2_landed"),
          #  (assign,reg2,"trp_briton_level0_companion"),
          #  (assign,reg3,"trp_briton_level2_landed"),
          #(try_end),
          #(assign,reg4,-1),
          #(shuffle_range,0,5),
          #(set_visitor,2,reg0),
          #(set_visitor,3,reg1),
          #(set_visitor,4,reg2),
          #(set_visitor,5,reg3),
          
          (set_jump_mission,"mt_sneak_caught_fight"),
          (set_passage_menu,"mnu_town"),
          (jump_to_scene,":sneak_scene"),
          (change_screen_mission),
      ]),
      ("sneak_caught_surrender",[],"Surrender.",
        [
          (jump_to_menu,"mnu_captivity_start_castle_surrender"),
      ]),
    ]
  ),
  (
    "sneak_into_town_caught_dispersed_guards",0,
    "You drive off the guards and cover your trail before running off, easily losing your pursuers in the maze of streets.",
    "none",
    [(set_background_mesh, "mesh_sneak_into_town"), #pic book
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$sneaked_into_town",1),
          (assign, "$town_entered", 1),
          (jump_to_menu,"mnu_town"),
      ]),
    ]
  ),
  
  (
    "sneak_into_town_caught_ran_away",0,
    "You make your way back through the gates and quickly retreat to the safety of the countryside.{s11}",
    "none",
    [
      
      (str_clear, s11),
      (assign, ":at_least_one_escaper_caught", 0),
      
      (assign, ":end_cond", kingdom_ladies_end),
      (try_for_range, ":prisoner", active_npcs_begin, ":end_cond"),
        (try_begin),
          (troop_slot_eq, ":prisoner", slot_troop_mission_participation, mp_prison_break_escaped),
          (assign, "$talk_context", tc_hero_freed),
          (assign, reg14, ":prisoner"),
          (call_script, "script_setup_troop_meeting", ":prisoner", -1),
          (troop_set_slot, ":prisoner", slot_troop_mission_participation, -1),
          
          (troop_get_slot, ":prison_center", ":prisoner", slot_troop_prisoner_of_party),
          (party_remove_prisoners, ":prison_center", ":prisoner", 1),
          (troop_set_slot, ":prisoner", slot_troop_prisoner_of_party, -1),
          
          (assign, ":end_cond", -1),
        (else_try),
          (troop_slot_eq, ":prisoner", slot_troop_mission_participation, mp_prison_break_caught),
          (str_store_troop_name, s12, ":prisoner"),
          (try_begin),
            (eq, ":at_least_one_escaper_caught", 0),
            (str_store_string, s11, "str_s11_unfortunately_s12_was_wounded_and_had_to_be_left_behind"),
          (else_try),
            (str_store_string, s11, "str_s11_also_s12_was_wounded_and_had_to_be_left_behind"),
          (try_end),
          (assign, ":at_least_one_escaper_caught", 1),
        (try_end),
        
        (troop_set_slot, ":prisoner", slot_troop_mission_participation, 0), #new
      (try_end),
      (set_background_mesh, "mesh_sneak_into_town"), #pic book
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign,"$auto_menu",-1),
          (store_encountered_party,"$last_sneak_attempt_town"),
          (store_current_hours,"$last_sneak_attempt_time"),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "enemy_offer_ransom_for_prisoner",0,
    "The {s2} offers you a sum of {reg12} peningas for {s1}.",
    "none",
    [(call_script, "script_calculate_ransom_amount_for_troop", "$g_ransom_offer_troop"),
      (assign, reg12, reg0),
      (assign, reg13, reg1),
      (str_store_troop_name, s1, "$g_ransom_offer_troop"),
      (store_troop_faction, ":faction_no", "$g_ransom_offer_troop"),
      (str_store_faction_name, s2, ":faction_no"),
      (set_background_mesh, "mesh_pic_chest"), #pic book
    ],
    [
      ("ransom_accept",[],"Accept the offer.",
        [(troop_add_gold, "trp_player", reg12),
          (try_begin),
            (troop_slot_eq, "$g_ransom_offer_troop", slot_troop_occupation, slto_kingdom_hero),
            (troop_get_slot, ":wealth", "$g_ransom_offer_troop", slot_troop_wealth),
            (val_sub, ":wealth", reg12),
            (val_max, ":wealth", 0),
            (troop_set_slot, "$g_ransom_offer_troop", slot_troop_wealth, ":wealth"),
          (else_try),
            (troop_slot_eq, "$g_ransom_offer_troop", slot_troop_occupation, slto_kingdom_lady),
            (assign, ":relative", reg13),
            (troop_get_slot, ":wealth", ":relative", slot_troop_wealth),
            (val_sub, ":wealth", reg12),
            (val_max, ":wealth", 0),
            (troop_set_slot, ":relative", slot_troop_wealth, ":wealth"),
          (try_end),
          (party_remove_prisoners, "$g_ransom_offer_party", "$g_ransom_offer_troop", 1),
          (call_script, "script_remove_troop_from_prison", "$g_ransom_offer_troop"),
          (try_begin),
            (troop_get_type, ":is_female", "trp_player"),
            (val_mod, ":is_female", 2),
            (eq, ":is_female", 1),
            
            (get_achievement_stat, ":number_of_lords_sold", ACHIEVEMENT_MAN_HANDLER, 0),
            (val_add, ":number_of_lords_sold", 1),
            (set_achievement_stat, ACHIEVEMENT_MAN_HANDLER, 0, ":number_of_lords_sold"),
            
            (eq, ":number_of_lords_sold", 3),
            (unlock_achievement, ACHIEVEMENT_MAN_HANDLER),
          (try_end),
          
          (change_screen_return),
      ]),
      ("ransom_reject",[],"Reject the offer.",
        [
          (call_script, "script_change_player_relation_with_troop", "$g_ransom_offer_troop", -4),
          (call_script, "script_change_player_honor", -1),
          (assign, "$g_ransom_offer_rejected", 1),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "training_ground",0,
    "You approach a training field where you can practice your martial skills. What kind of training do you want to do?",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
      (store_add, "$g_training_ground_melee_training_scene", "scn_training_ground_ranged_melee_1", "$g_encountered_party"),
      (val_sub, "$g_training_ground_melee_training_scene", training_grounds_begin),
      (try_begin),
        (ge, "$g_training_ground_training_count", 3),
        (assign, "$g_training_ground_training_count", 0),
        (rest_for_hours, 1, 5, 1), #rest while attackable
        (assign, "$auto_enter_town", "$g_encountered_party"),
        (change_screen_return),
      (try_end),
    ],
    [
      ("camp_trainer",
        [], "Speak with the trainer.",
        [
          (set_jump_mission, "mt_training_ground_trainer_talk"),
          (modify_visitors_at_site, "$g_training_ground_melee_training_scene"),
          (reset_visitors),
          (set_jump_entry, 5),
          (jump_to_scene, "$g_training_ground_melee_training_scene"),
          (change_screen_mission),
          (music_set_situation, 0),
      ]),
      ("camp_train_melee",
        [
          (neg|troop_is_wounded, "trp_player"),
          (call_script, "script_party_count_fit_for_battle", "p_main_party"),
          (gt, reg0, 1),
        ], "Sparring practice.",
        [
          (assign, "$g_mt_mode", ctm_melee),
          (jump_to_menu, "mnu_training_ground_selection_details_melee_1"),
          (music_set_situation, 0),
      ]),
      ("camp_train_archery",[], "Ranged weapon practice.",
        [
          (jump_to_menu, "mnu_training_ground_selection_details_ranged_1"),
          (music_set_situation, 0),
      ]),
      ("camp_train_mounted",[], "Horseback practice.",
        [
          (assign, "$g_mt_mode", ctm_mounted),
          (jump_to_menu, "mnu_training_ground_selection_details_mounted"),
          (music_set_situation, 0),
      ]),
      
      ("go_to_track",[(eq, "$cheat_mode", 1)],"{!}Cheat: Go to track.",
        [
          (set_jump_mission, "mt_ai_training"),
          (store_add, ":scene_no", "scn_training_ground_horse_track_1", "$g_encountered_party"),
          (val_sub, ":scene_no", training_grounds_begin),
          (jump_to_scene, ":scene_no"),
          (change_screen_mission),
        ]
      ),
      ("go_to_range",[(eq, "$cheat_mode", 1)],"{!}Cheat: Go to range.",
        [
          (set_jump_mission, "mt_ai_training"),
          (jump_to_scene, "$g_training_ground_melee_training_scene"),
          (change_screen_mission),
        ]
      ),
      ("leave",[],"Leave.",
        [(change_screen_return),
      ]),
    ]
  ),
  
  ("training_ground_selection_details_melee_1",0,
    "How many opponents will you go against?",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
      (call_script, "script_write_fit_party_members_to_stack_selection", "p_main_party", 1),
      (troop_get_slot, "$temp", "trp_stack_selection_amounts", 1), #number of men fit
      (assign, "$temp_2", 1),
    ],
    [
      ("camp_train_melee_num_men_1",[(ge, "$temp", 1)], "One.",
        [
          (assign, "$temp", 1),
          (jump_to_menu, "mnu_training_ground_selection_details_melee_2"),
      ]),
      ("camp_train_melee_num_men_2",[(ge, "$temp", 2)], "Two.",
        [
          (assign, "$temp", 2),
          (jump_to_menu, "mnu_training_ground_selection_details_melee_2"),
      ]),
      ("camp_train_melee_num_men_3",[(ge, "$temp", 3)], "Three.",
        [
          (assign, "$temp", 3),
          (jump_to_menu, "mnu_training_ground_selection_details_melee_2"),
      ]),
      ("camp_train_melee_num_men_4",[(ge, "$temp", 4)], "Four.",
        [
          (assign, "$temp", 4),
          (jump_to_menu, "mnu_training_ground_selection_details_melee_2"),
      ]),
      ("cancel_dot",[],"Cancel.",
        [
          (jump_to_menu, "mnu_training_ground"),
      ]),
    ]
  ),
  
  ("training_ground_selection_details_melee_2",0,
    "Choose your opponent #{reg1}:",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
      (assign, reg1, "$temp_2"),
      (troop_get_slot, "$temp_3", "trp_stack_selection_amounts", 0), #number of slots
    ],
    [
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 1),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 1),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 2),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 2),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 3),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 3),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 4),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 4),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 5),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 5),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 6),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 6),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 7),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 7),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 8),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 8),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 9),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 9),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 10),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 10),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 11),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 11),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 12),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 12),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 13),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 13),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 14),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 14),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 15),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 15),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 16),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 16),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 17),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 17),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 18),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 18),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 19),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 19),]),
      ("s0", [(call_script, "script_cf_training_ground_sub_routine_1_for_melee_details", 20),], "{!}{s0}",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", 20),]),
      ("training_ground_selection_details_melee_random", [], "Choose randomly.",
        [(call_script, "script_training_ground_sub_routine_2_for_melee_details", -1),]),
      ("go_back_dot",[],"Go back.",
        [(jump_to_menu, "mnu_training_ground"),
        ]
      ),
    ]
  ),
  
  
  ("training_ground_selection_details_mounted",0,
    "What kind of weapon do you want to train with?",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
    ],
    [
      ("camp_train_mounted_details_1",[], "One-handed weapon.",
        [
          (call_script, "script_start_training_at_training_ground", itp_type_one_handed_wpn, 0),
      ]),
      ("camp_train_mounted_details_2",[], "Polearm.",
        [
          (call_script, "script_start_training_at_training_ground", itp_type_polearm, 0),
      ]),
      ("camp_train_mounted_details_3",[], "Bow.",
        [
          (call_script, "script_start_training_at_training_ground", itp_type_bow, 0),
      ]),
      ("camp_train_mounted_details_4",[], "Thrown weapon.",
        [
          (call_script, "script_start_training_at_training_ground", itp_type_thrown, 0),
      ]),
      ("go_back_dot",[],"Go back.",
        [(jump_to_menu, "mnu_training_ground"),
        ]
      ),
    ]
  ),
  
  
  ("training_ground_selection_details_ranged_1",0,
    "What kind of ranged weapon do you want to train with?",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
    ],
    [
      ("camp_train_ranged_weapon_bow",[], "Bow and arrows.",
        [
          (assign, "$g_mt_mode", ctm_ranged),
          (assign, "$temp", itp_type_bow),
          (jump_to_menu, "mnu_training_ground_selection_details_ranged_2"),
      ]),
      ("camp_train_ranged_weapon_crossbow",[], "Javelins.",
        [
          (assign, "$g_mt_mode", ctm_ranged),
          (assign, "$temp", itp_type_crossbow),
          (jump_to_menu, "mnu_training_ground_selection_details_ranged_2"),
      ]),
      ("camp_train_ranged_weapon_thrown",[], "Throwing Knives.",
        [
          (assign, "$g_mt_mode", ctm_ranged),
          (assign, "$temp", itp_type_thrown),
          (jump_to_menu, "mnu_training_ground_selection_details_ranged_2"),
      ]),
      ("go_back_dot",[],"Go back.",
        [(jump_to_menu, "mnu_training_ground"),
        ]
      ),
    ]
  ),
  
  
  ("training_ground_selection_details_ranged_2",0,
    "What range do you want to practice at?",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
    ],
    [
      ("camp_train_ranged_details_1",[], "10 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 10),
      ]),
      ("camp_train_ranged_details_2",[], "20 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 20),
      ]),
      ("camp_train_ranged_details_3",[], "30 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 30),
      ]),
      ("camp_train_ranged_details_4",[], "40 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 40),
      ]),
      ("camp_train_ranged_details_5",[(eq, "$g_mt_mode", ctm_ranged),], "50 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 50),
      ]),
      ("camp_train_ranged_details_6",[(eq, "$g_mt_mode", ctm_ranged),], "60 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 60),
      ]),
      ("camp_train_ranged_details_7",[(eq, "$g_mt_mode", ctm_ranged),], "70 yards.",
        [
          (call_script, "script_start_training_at_training_ground", "$temp", 70),
      ]),
      ("go_back_dot",[],"Go back.",
        [(jump_to_menu, "mnu_training_ground"),
        ]
      ),
    ]
  ),
  
  
  ("training_ground_description",0,
    "{!}{s0}",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
    ],
    [
      ("continue", [], "Continue...",
        [
          (jump_to_scene, "$g_training_ground_training_scene"),
          (change_screen_mission),
        ]
      ),
    ]
  ),
  
  ("training_ground_training_result",mnf_disable_all_keys,
    "{s7}{s2}",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"), #pic book
      (store_skill_level, ":trainer_skill", "skl_trainer", "trp_player"),
      (store_add, ":trainer_skill_multiplier", 5, ":trainer_skill"),
      (call_script, "script_write_fit_party_members_to_stack_selection", "p_main_party", 1),
      (str_clear, s2),
      (troop_get_slot, ":num_fit", "trp_stack_selection_amounts", 1),
      (troop_get_slot, ":num_slots", "trp_stack_selection_amounts", 0),
      (try_begin),
        (gt, "$g_training_ground_training_success_ratio", 0),
        (store_mul, ":xp_ratio_to_add", "$g_training_ground_training_success_ratio", "$g_training_ground_training_success_ratio"),
        (try_begin),
          (eq, "$g_training_ground_training_success_ratio", 100),
          (val_mul, ":xp_ratio_to_add", 2), #2x when perfect
        (try_end),
        (try_begin),
          (eq, "$g_mt_mode", ctm_melee),
          (val_div, ":xp_ratio_to_add", 2),
        (try_end),
        (val_div, ":xp_ratio_to_add", 10), # value over 1000
        (try_begin),
          (gt, ":num_fit", 8),
          (val_mul, ":xp_ratio_to_add", 3),
          (assign, ":divisor", ":num_fit"),
          (convert_to_fixed_point, ":divisor"),
          (store_sqrt, ":divisor", ":divisor"),
          (convert_to_fixed_point, ":xp_ratio_to_add"),
          (val_div, ":xp_ratio_to_add", ":divisor"),
        (try_end),
        ##       (assign, reg0, ":xp_ratio_to_add"),
        ##       (display_message, "@xp earn ratio: {reg0}/1000"),
        (store_mul, ":xp_ratio_to_add_with_trainer_skill", ":xp_ratio_to_add", ":trainer_skill_multiplier"),
        (val_div, ":xp_ratio_to_add_with_trainer_skill", 10),
        (party_get_num_companion_stacks, ":num_stacks", "p_main_party"),
        (store_add, ":end_cond", ":num_slots", 2),
        (try_for_range, ":i_slot", 2, ":end_cond"),
          (troop_get_slot, ":amount", "trp_stack_selection_amounts", ":i_slot"),
          (troop_get_slot, ":troop_id", "trp_stack_selection_ids", ":i_slot"),
          (assign, ":end_cond_2", ":num_stacks"),
          (try_for_range, ":stack_no", 0, ":end_cond_2"),
            (party_stack_get_troop_id, ":stack_troop", "p_main_party", ":stack_no"),
            (eq, ":stack_troop", ":troop_id"),
            (assign, ":end_cond_2", 0), #break
            (call_script, "script_cf_training_ground_sub_routine_for_training_result", ":troop_id", ":stack_no", ":amount", ":xp_ratio_to_add_with_trainer_skill"),
            (str_store_troop_name_by_count, s1, ":troop_id", ":amount"),
            (assign, reg1, ":amount"),
            (str_store_string, s2, "@{s2}^{reg1} {s1} earned {reg0} experience."),
          (try_end),
        (try_end),
        (try_begin),
          (eq, "$g_mt_mode", ctm_melee),
          (store_mul, ":special_xp_ratio_to_add", ":xp_ratio_to_add", 3),
          (val_div, ":special_xp_ratio_to_add", 2),
          (try_for_range, ":enemy_index", 0, "$g_training_ground_training_num_enemies"),
            (troop_get_slot, ":troop_id", "trp_temp_array_a", ":enemy_index"),
            (assign, ":end_cond_2", ":num_stacks"),
            (try_for_range, ":stack_no", 0, ":end_cond_2"),
              (party_stack_get_troop_id, ":stack_troop", "p_main_party", ":stack_no"),
              (eq, ":stack_troop", ":troop_id"),
              (assign, ":end_cond_2", 0), #break
              (call_script, "script_cf_training_ground_sub_routine_for_training_result", ":troop_id", ":stack_no", 1, ":special_xp_ratio_to_add"),
              (str_store_troop_name, s1, ":troop_id"),
              (str_store_string, s2, "@{s2}^{s1} earned an additional {reg0} experience."),
            (try_end),
          (try_end),
        (try_end),
        (try_begin),
          (call_script, "script_cf_training_ground_sub_routine_for_training_result", "trp_player", -1, 1, ":xp_ratio_to_add"),
          (str_store_string, s2, "@^You earned {reg0} experience.{s2}"),
        (try_end),
      (try_end),
      (try_begin),
        (eq, "$g_training_ground_training_success_ratio", 0),
        (str_store_string, s7, "@The training didn't go well at all."),
      (else_try),
        (lt, "$g_training_ground_training_success_ratio", 25),
        (str_store_string, s7, "@The training didn't go well at all."),
      (else_try),
        (lt, "$g_training_ground_training_success_ratio", 50),
        (str_store_string, s7, "@The training didn't go very well."),
      (else_try),
        (lt, "$g_training_ground_training_success_ratio", 75),
        (str_store_string, s7, "@The training went quite well."),
      (else_try),
        (lt, "$g_training_ground_training_success_ratio", 99),
        (str_store_string, s7, "@The training went very well."),
      (else_try),
        (str_store_string, s7, "@The training went perfectly."),
      (try_end),
      
    ],
    [
      ("continue",[],"Continue...",
        [(jump_to_menu, "mnu_training_ground"),
        ]
      ),
    ]
  ),
  
  ("marshal_selection_candidate_ask",0,
    "{s15} will soon select a new marshal for the {s23}. Some of the lords have suggested your name as a likely candidate.",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"), #pic book
      (try_begin),
        (eq, "$g_presentation_marshal_selection_ended", 1),
        (change_screen_return),
      (try_end),
      (faction_get_slot, ":king", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s15, ":king"),
      (str_store_faction_name, s23, "$players_kingdom"),
    ],
    [
      ("marshal_candidate_accept", [], "Let {s15} know that you are willing to serve as marshal.",
        [
          (start_presentation, "prsnt_marshal_selection"),
        ]
      ),
      ("marshal_candidate_reject", [], "Tell everyone that you are too busy these days.",
        [
          (try_begin),
            (eq, "$g_presentation_marshal_selection_max_renown_1_troop", "trp_player"),
            (assign, "$g_presentation_marshal_selection_max_renown_1", "$g_presentation_marshal_selection_max_renown_2"),
            (assign, "$g_presentation_marshal_selection_max_renown_1_troop", "$g_presentation_marshal_selection_max_renown_2_troop"),
          (try_end),
          
          (assign, "$g_presentation_marshal_selection_max_renown_2", "$g_presentation_marshal_selection_max_renown_3"),
          (assign, "$g_presentation_marshal_selection_max_renown_2_troop", "$g_presentation_marshal_selection_max_renown_3_troop"),
          (start_presentation, "prsnt_marshal_selection"),
        ]
      ),
    ]
  ),
  
  
  
  
  ##    [
  ##      ("renew_oath",[],"Renew your oath to {s1} for another month.",[
  ##          (store_current_day, ":cur_day"),
  ##          (store_add, "$g_oath_end_day", ":cur_day", 30),
  ##          (change_screen_return)]),
  ##      ("dont_renew_oath",[],"Become free of your bond.",[
  ##          (assign, "$players_kingdom",0),
  ##          (assign, "$g_player_permitted_castles", 0),
  ##          (change_screen_return)]),
  ##    ]
  ##  ),
  
  
  #####################################################################
  ## Captivity....
  #####################################################################
  #####################################################################
  #####################################################################
  #####################################################################
  # (
    # "captivity_avoid_wilderness",0,
    # "Suddenly, all the world goes black around you. " +
    # "Many hours later, you regain your consciousness and find yourself at the spot where you fell. " +
    # "Your enemies must have left you for dead and left you there. " +
    # "However, it seems that none of your wounds was lethal, " +
    # "and, although you feel awful, you find out that can still walk. " +
    # "You get up and look for any other survivors from your party.",
    # "none",
    # [
    # ],
    # []
  # ),
  
  (
    "captivity_start_wilderness",0,
    "Stub",
    "none",
    [
      (assign, "$g_player_is_captive", 1),
      (try_begin), #siege warfare
        (eq, "$g_empieza_asedio", 1),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
      (try_end),
      (try_begin),
        (eq,"$g_player_surrenders",1),
        (jump_to_menu, "mnu_captivity_start_wilderness_surrender"),
      (else_try),
        (jump_to_menu, "mnu_captivity_start_wilderness_defeat"),
      (try_end),
    ],
    []
  ),
  
  (
    "captivity_start_wilderness_surrender",0,
    "Stub",
    "none",
    [
      (assign, "$g_player_is_captive", 1),
      (assign,"$auto_menu",-1), #We need this since we may come here by something other than auto_menu
      (assign, "$capturer_party", "$g_encountered_party"),
      (try_begin), #siege warfare
        (eq, "$g_empieza_asedio", 1),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
      (try_end),
      (jump_to_menu, "mnu_captivity_wilderness_taken_prisoner"),
    ],
    []
  ),
  
  (
    "captivity_start_wilderness_defeat",0,
    "Your enemies take you prisoner.",
    "none",
    [
      (assign, "$g_player_is_captive", 1),
      (assign,"$auto_menu",-1),
      (assign, "$capturer_party", "$g_encountered_party"),
      
      (try_begin),
        (party_stack_get_troop_id, ":party_leader", "$g_encountered_party", 0),
        (is_between, ":party_leader", active_npcs_begin, active_npcs_end),
        (troop_slot_eq, ":party_leader", slot_troop_occupation, slto_kingdom_hero),
        (store_sub, ":kingdom_hero_id", ":party_leader", active_npcs_begin),
        (set_achievement_stat, ACHIEVEMENT_BARON_GOT_BACK, ":kingdom_hero_id", 1),
      (try_end),
      (try_begin), #siege warfare
        (eq, "$g_empieza_asedio", 1),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
      (try_end),
      
      (jump_to_menu, "mnu_captivity_wilderness_taken_prisoner"),
    ],
    []
  ),
  (
    "captivity_start_castle_surrender",0,
    "Stub",
    "none",
    [
      (assign, "$g_player_is_captive", 1),
      (assign,"$auto_menu",-1),
      (assign, "$capturer_party", "$g_encountered_party"),
      (try_begin), #siege warfare
        (eq, "$g_empieza_asedio", 1),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
      (try_end),
      (jump_to_menu, "mnu_captivity_castle_taken_prisoner"),
    ],
    []
  ),
  (
    "captivity_start_castle_defeat",0,
    "Stub",
    "none",
    [
      (assign, "$g_player_is_captive", 1),
      (assign,"$auto_menu",-1),
      (assign, "$capturer_party", "$g_encountered_party"),
      (try_begin), #siege warfare
        (eq, "$g_empieza_asedio", 1),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
      (try_end),
      (jump_to_menu, "mnu_captivity_castle_taken_prisoner"),
    ],
    []
  ),
  (
    "captivity_start_under_siege_defeat",0,
    "Your enemies take you prisoner.",
    "none",
    [
      (assign, "$g_player_is_captive", 1),
      (assign,"$auto_menu",-1),
      (assign, "$capturer_party", "$g_encountered_party"),
      (try_begin), #siege warfare
        (eq, "$g_empieza_asedio", 1),
        (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
        (assign, "$g_player_besiege_town", -1),
      (try_end),
      (jump_to_menu, "mnu_captivity_castle_taken_prisoner"),
    ],
    []
  ),
  (
    "captivity_wilderness_taken_prisoner",0,  #chief cambia completamently, permadeath added.
    "{!}{s2}",
    "none",
    [
      (assign, "$g_player_dead_yn", 0),
      (try_begin),
        (eq, "$g_campaign_death", 1),
        (str_store_string, s2, "@You fall on the ground with multiple injuries. Each time your heart beats more slowly and your vision fades away... This battle was too much for you, and death rides to meet you.^^" +
        "While life escapes, you hope that someone will just remember that there was once someone special called {playername}."),
        (assign,"$g_player_dead_yn",1),
        (set_background_mesh, "mesh_pic_raven"),
      (else_try),
        # Battle loose on water...
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),
        (assign, "$g_player_is_captive", 0),
        #(str_store_string, s2, "@After losing the sea battle, you cling to floating debris. Passing fishermen bring you to a nearby town. You have lost all your crew and all your ships."),
        (str_store_string, s2, "@After losing the sea battle, you manage to escape with one of your ships."),
        (set_background_mesh, "mesh_pic_raven"),
      (else_try),
        (str_store_string, s2, "@Your enemies take you prisoner."),
        (set_background_mesh, "mesh_pic_prisoner_wilderness"),
        
      (try_end),
    ],
    [
      ("continue1", [(eq, "$g_player_dead_yn", 1),], "Continue...", #death chief here
        [
          (str_clear,s2),
          (assign, "$g_campaign_death", 0),
          (change_screen_quit),
      ]),
      
      ("continue",[(eq, "$g_player_dead_yn", 0),],"Continue...",
        [
          (str_clear,s2), #chief
          # Explanation of removing below code : heros are already being removed with 50% (was 75%, I decreased it) probability in mnu_total_defeat, why here there is additionally 30% removing of heros?
          # See codes linked to "mnu_captivity_start_wilderness_surrender" and "mnu_captivity_start_wilderness_defeat" which is connected with here they all also enter
          # "mnu_total_defeat" and inside the "mnu_total_defeat" there is script_party_remove_all_companions which removes 50% (was 75%, I decreased it) of compainons from player party.
          
          #(try_for_range, ":npc", companions_begin, companions_end),
          #  (main_party_has_troop, ":npc"),
          #  (store_random_in_range, ":rand", 0, 100),
          #  (lt, ":rand", 30),
          #  (remove_member_from_party, ":npc", "p_main_party"),
          #  (troop_set_slot, ":npc", slot_troop_occupation, 0),
          #  (troop_set_slot, ":npc", slot_troop_playerparty_history, pp_history_scattered),
          #  (assign, "$last_lost_companion", ":npc"),
          #  (store_faction_of_party, ":victorious_faction", "$g_encountered_party"),
          #  (troop_set_slot, ":npc", slot_troop_playerparty_history_string, ":victorious_faction"),
          #  (troop_set_health, ":npc", 100),
          #  (store_random_in_range, ":rand_town", towns_begin, towns_end),
          #  (troop_set_slot, ":npc", slot_troop_cur_center, ":rand_town"),
          #  (assign, ":nearest_town_dist", 1000),
          #  (try_for_range, ":town_no", towns_begin, towns_end),
          #    (store_faction_of_party, ":town_fac", ":town_no"),
          #    (store_relation, ":reln", ":town_fac", "fac_player_faction"),
          #    (ge, ":reln", 0),
          #    (store_distance_to_party_from_party, ":dist", ":town_no", "p_main_party"),
          #    (lt, ":dist", ":nearest_town_dist"),
          #    (assign, ":nearest_town_dist", ":dist"),
          #    (troop_set_slot, ":npc", slot_troop_cur_center, ":town_no"),
          #  (try_end),
          #(try_end),
          
          # Phaiak begin
          (try_begin),
            # (eq, 1, 0),	#old (disabled)
            # (party_slot_eq, "p_main_party", slot_party_on_water, 1),
            # (try_for_range, ":current_ship_type_slot", slot_party_player_ships_type_begin, slot_party_player_ships_type_end),	# delete all ships
              # (party_set_slot, "p_main_party", ":current_ship_type_slot", 0),
            # (end_try),
            # (assign, ":closest_town", -1),
            # (assign, ":score_to_beat", 99999),
            # (try_for_range, ":town_no", towns_begin, towns_end),
              # (store_distance_to_party_from_party, ":distance", "p_main_party", ":town_no"),
              # (lt, ":distance", ":score_to_beat"),
              # (assign, ":closest_town", ":town_no"),
              # (assign, ":score_to_beat", ":distance"),
            # (try_end),
            # (party_relocate_near_party, "p_main_party", ":closest_town", 1),
            # (call_script, "script_switch_to_land_consequences"),
            
          # (else_try),
            #new:
            (party_slot_eq, "p_main_party", slot_party_on_water, 1),
            (try_for_range, ":current_ship_type_slot", slot_party_2_ship_type, slot_party_player_ships_type_end),	# delete all ships
              (party_set_slot, "p_main_party", ":current_ship_type_slot", 0),
            (end_try),
            (call_script, "script_set_parties_around_player_ignore_player", 8, 12),
            
          (else_try),
            # Phaiak end
            (set_camera_follow_party, "$capturer_party"),
            (assign, "$g_player_is_captive", 1),
            (store_random_in_range, ":random_hours", 18, 30),
            (call_script, "script_event_player_captured_as_prisoner"),
            (call_script, "script_stay_captive_for_hours", ":random_hours"),
            (assign,"$auto_menu","mnu_captivity_wilderness_check"),
          (end_try),
          (change_screen_return),
      ]),
    ]
  ),
  (
    "captivity_wilderness_check",0,
    "stub",
    "none",
    [(jump_to_menu,"mnu_captivity_end_wilderness_escape")],
    []
  ),
  (
    "captivity_end_wilderness_escape", 0,
    "After painful days of being dragged about as a prisoner, you find a chance and escape from your captors!",
    "none",
    [
      (play_cue_track, "track_escape"),
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_escape_1_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_escape_1"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$g_player_is_captive", 0),
          (try_begin),
            (party_is_active, "$capturer_party"),
            (party_relocate_near_party, "p_main_party", "$capturer_party", 2),
          (try_end),
          (call_script, "script_set_parties_around_player_ignore_player", 8, 12), #it was radius:2 and hours:4, but players make lots of complains about consequent battle losses after releases from captivity then I changed this.
          (assign, "$g_player_icon_state", pis_normal),
          (set_camera_follow_party, "p_main_party"),
          (rest_for_hours, 0, 0, 0), #stop resting
          (change_screen_return),
      ]),
    ]
  ),
  (
    "captivity_castle_taken_prisoner",0,
    "You are quickly surrounded by guards, who take away your weapons. With curses and insults, they throw you into the dungeon where you must wait away the miserable days of your captivity.",
    "none",
    [
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_prisoner_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_prisoner_man"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$g_player_is_captive", 1),
          (store_random_in_range, ":random_hours", 25, 50), #chief LENGTHENED TIME cambiado
          (call_script, "script_event_player_captured_as_prisoner"),
          (call_script, "script_stay_captive_for_hours", ":random_hours"),
          (assign,"$auto_menu", "mnu_captivity_castle_check"),
          (change_screen_return)
      ]),
    ]
  ),
  (
    "captivity_rescue_lord_taken_prisoner",0,
    "You remain in disguise for as long as possible before revealing yourself. " +
    "The guards are outraged and beat you savagely before throwing you back into the cell for God knows how long...",
    "none",
    [
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_prisoner_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_prisoner_man"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$g_player_is_captive", 1),
          (store_random_in_range, ":random_hours", 16, 22),
          (call_script, "script_event_player_captured_as_prisoner"),
          (call_script, "script_stay_captive_for_hours", ":random_hours"),
          (assign,"$auto_menu", "mnu_captivity_castle_check"),
          (change_screen_return),
      ]),
    ]
  ),
  (
    "captivity_castle_check",0,
    "stub",
    "none",
    [
      (store_random_in_range, reg(7), 0, 10),
      (try_begin),
        (party_is_active, "$capturer_party"),
        (store_faction_of_party, ":capturer_faction", "$capturer_party"),
        (is_between, ":capturer_faction", kingdoms_begin, kingdoms_end),
        (store_relation, ":relation_w_player_faction", ":capturer_faction", "fac_player_faction"),
        (ge, ":relation_w_player_faction", 0),
        (jump_to_menu,"mnu_captivity_end_exchanged_with_prisoner"),
      (else_try),
        (lt, reg(7), 4),
        
        (store_character_level, ":player_level", "trp_player"),
        (store_mul, "$player_ransom_amount", ":player_level", 50),
        (val_add, "$player_ransom_amount", 100),
        (store_troop_gold, reg3, "trp_player"),
        (store_div, ":player_gold_div_20", reg3, 20),
        (val_add, "$player_ransom_amount", ":player_gold_div_20"),
        
        (gt, reg3, "$player_ransom_amount"),
        (jump_to_menu,"mnu_captivity_end_propose_ransom"),
      (else_try),
        (lt, reg7, 7),
        (jump_to_menu,"mnu_captivity_end_exchanged_with_prisoner"),
      (else_try),
        (jump_to_menu,"mnu_captivity_castle_remain"),
      (try_end),
    ],
    []
  ),
  (
    "captivity_end_exchanged_with_prisoner",0,
    "After days of imprisonment, you are finally set free when your captors exchange you for another prisoner.",
    "none",
    [
      
      (set_background_mesh, "mesh_pic_leave_faction"), #pic book
      
      (play_cue_track, "track_escape"),
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$g_player_is_captive", 0),
          (try_begin),
            (party_is_active, "$capturer_party"),
            (party_relocate_near_party, "p_main_party", "$capturer_party", 2),
          (try_end),
          (call_script, "script_set_parties_around_player_ignore_player", 8, 12), #it was radius:2 and hours:12, but players make lots of complains about consequent battle losses after releases from captivity then I changed this.
          (assign, "$g_player_icon_state", pis_normal),
          (set_camera_follow_party, "p_main_party"),
          (rest_for_hours, 0, 0, 0), #stop resting
          (change_screen_return),
      ]),
    ]
  ),
  (
    "captivity_end_propose_ransom",0,
    "You spend long hours in the sunless dank of the dungeon, more than you can count. " +
    "Suddenly one of your captors enters your cell with an offer; " +
    "he proposes to free you in return for {reg5} peningas of your hidden wealth. You decide to...",
    "none",
    [(set_background_mesh, "mesh_pic_coppergate_helm"), #pic book
      (assign, reg5, "$player_ransom_amount"),
    ],
    [
      ("captivity_end_ransom_accept",
        [
          (store_troop_gold,":player_gold", "trp_player"),
          (ge, ":player_gold","$player_ransom_amount")
        ],"Accept the offer.",
        [
          (play_cue_track, "track_escape"),
          (assign, "$g_player_is_captive", 0),
          (troop_remove_gold, "trp_player", "$player_ransom_amount"),
          (try_begin),
            (party_is_active, "$capturer_party"),
            (party_relocate_near_party, "p_main_party", "$capturer_party", 1),
          (try_end),
          (call_script, "script_set_parties_around_player_ignore_player", 8, 12), #it was radius:2 and hours:6, but players make lots of complains about consequent battle losses after releases from captivity then I changed this.
          (assign, "$g_player_icon_state", pis_normal),
          (set_camera_follow_party, "p_main_party"),
          (rest_for_hours, 0, 0, 0), #stop resting
          (change_screen_return),
      ]),
      ("captivity_end_ransom_deny",
        [
        ],"Refuse him and wait for something better.",
        [
          (assign, "$g_player_is_captive", 1),
          (store_random_in_range, reg(8), 16, 22),
          (call_script, "script_stay_captive_for_hours", reg8),
          (assign,"$auto_menu", "mnu_captivity_castle_check"),
          (change_screen_return),
      ]),
    ]
  ),
  (
    "captivity_castle_remain",mnf_disable_all_keys,
    "More days pass in the darkness of your cell. You get through them as best you can, " +
    "enduring the kicks and curses of the guards, watching your underfed body waste away more and more...",
    "none",
    [
      (troop_get_type, ":is_female", "trp_player"),
      (val_mod, ":is_female", 2),
      (try_begin),
        (eq, ":is_female", 1),
        (set_background_mesh, "mesh_pic_prisoner_fem"),
      (else_try),
        (set_background_mesh, "mesh_pic_prisoner_man"),
      (try_end),
      (store_random_in_range, ":random_hours", 16, 22),
      (call_script, "script_stay_captive_for_hours", ":random_hours"),
      (assign,"$auto_menu", "mnu_captivity_castle_check"),
      
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$g_player_is_captive", 1),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "kingdom_army_quest_report_to_army",0,
    "{s8} sends word that he wishes you to join {reg4?her:his} new military campaign. " +
    "You need to bring at least {reg13} troops to the army, " +
    "and are instructed to raise more men with all due haste if you do not have enough.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (quest_get_slot, ":quest_target_troop", "qst_report_to_army", slot_quest_target_troop),
      (quest_get_slot, ":quest_target_amount", "qst_report_to_army", slot_quest_target_amount),
      (call_script, "script_get_information_about_troops_position", ":quest_target_troop", 0),
      (str_clear, s9),
      (try_begin),
        (eq, reg0, 1), #troop is found and text is correct
        (str_store_string, s9, s1),
      (try_end),
      (str_store_troop_name, s8, ":quest_target_troop"),
      (assign, reg13, ":quest_target_amount"),
      (troop_get_type, reg4, ":quest_target_troop"),
      (val_mod, reg4, 2),
    ],
    [
      ("continue",[],"Continue...",
        [
          (quest_get_slot, ":quest_target_troop", "qst_report_to_army", slot_quest_target_troop),
          (quest_get_slot, ":quest_target_amount", "qst_report_to_army", slot_quest_target_amount),
          (str_store_troop_name_link, s13, ":quest_target_troop"),
          (assign, reg13, ":quest_target_amount"),
          (setup_quest_text, "qst_report_to_army"),
          (str_store_string, s2, "@{s13} asked you to report to him with at least {reg13} troops."),
          (call_script, "script_start_quest", "qst_report_to_army", ":quest_target_troop"),
          (call_script, "script_report_quest_troop_positions", "qst_report_to_army", ":quest_target_troop", 3),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "kingdom_army_quest_messenger",0,
    "{s8} sends word that he wishes to speak with you about a task he needs performed. " +
    "He requests you to come and see him as soon as possible.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, ":faction_marshal", "$players_kingdom", slot_faction_marshal),
      (str_store_troop_name, s8, ":faction_marshal"),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "kingdom_army_quest_join_siege_order",0,
    "{s8} sends word that you are to join the siege of {s9} in preparation for a full assault. " +
    "Your troops are to take {s9} at all costs.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, ":faction_marshal", "$players_kingdom", slot_faction_marshal),
      (quest_get_slot, ":quest_target_center", "qst_join_siege_with_army", slot_quest_target_center),
      (str_store_troop_name, s8, ":faction_marshal"),
      (str_store_party_name, s9, ":quest_target_center"),
    ],
    [
      ("continue",[],"Continue...",
        [
          (call_script, "script_conclude_quest", "qst_follow_army"),
          (set_show_messages, 0),
          (call_script, "script_end_quest", "qst_follow_army"),
          (set_show_messages, 1),
          (quest_get_slot, ":quest_target_center", "qst_join_siege_with_army", slot_quest_target_center),
          (faction_get_slot, ":faction_marshal", "$players_kingdom", slot_faction_marshal),
          (str_store_troop_name_link, s13, ":faction_marshal"),
          (str_store_party_name_link, s14, ":quest_target_center"),
          (setup_quest_text, "qst_join_siege_with_army"),
          (str_store_string, s2, "@{s13} ordered you to join the assault against {s14}."),
          (call_script, "script_start_quest", "qst_join_siege_with_army", ":faction_marshal"),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "kingdom_army_follow_failed",0,
    "You have failed to follow {s8}. The marshal assumes that you were otherwise engaged, but would have appreciated your support.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, ":faction_marshal", "$players_kingdom", slot_faction_marshal),
      (str_store_troop_name, s8, ":faction_marshal"),
      (call_script, "script_abort_quest", "qst_follow_army", 1),
      #        (call_script, "script_change_player_relation_with_troop", ":faction_marshal", -3),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "invite_player_to_faction_without_center",0,
    "You receive an offer of vassalage!^^" +
    "{s8} of the {s9} has sent a royal herald to bring you an invitation in his own hand. " +
    "You would be granted the honour of becoming a vassal {reg59?lady:lord} of the {s9}, " +
    "and in return {s8} asks you to swear an oath of homage to him and fight in his military campaigns, " +
    "although he offers you no lands or titles. " +
    "He will surely be offended if you do not take the offer...",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, "$g_invite_faction_lord", "$g_invite_faction", slot_faction_leader),
      (str_store_troop_name, s8, "$g_invite_faction_lord"),
      (str_store_faction_name, s9, "$g_invite_faction"),
    ],
    [
      ("faction_accept",[],"Accept!",
        [(str_store_troop_name,s1,"$g_invite_faction_lord"),
          (setup_quest_text,"qst_join_faction"),
          
          (str_store_troop_name_link, s3, "$g_invite_faction_lord"),
          (str_store_faction_name_link, s4, "$g_invite_faction"),
          (quest_set_slot, "qst_join_faction", slot_quest_giver_troop, "$g_invite_faction_lord"),
          (quest_set_slot, "qst_join_faction", slot_quest_expiration_days, 30),
          (quest_set_slot, "qst_join_faction", slot_quest_failure_consequence, 0),
          
          (str_store_string, s2, "@Find and speak with {s3} of the {s4} to give him your oath of homage."),
          (call_script, "script_start_quest", "qst_join_faction", "$g_invite_faction_lord"),
          (call_script, "script_report_quest_troop_positions", "qst_join_faction", "$g_invite_faction_lord", 3),
          (jump_to_menu, "mnu_invite_player_to_faction_accepted"),
      ]),
      ("faction_reject",[],"Decline the invitation.",
        [(call_script, "script_change_player_relation_with_troop", "$g_invite_faction_lord", -3),
          (call_script, "script_change_player_relation_with_faction", "$g_invite_faction", -10),
          (assign, "$g_invite_faction", 0),
          (assign, "$g_invite_faction_lord", 0),
          (assign, "$g_invite_offered_center", 0),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "invite_player_to_faction",0,
    "You receive an offer of vassalage!^^" +
    "{s8} of the {s9} has sent a royal herald to bring you an invitation in his own hand. " +
    "You would be granted the honour of becoming a vassal {reg59?lady:lord} of the {s9}, " +
    "and in return {s8} asks you to swear an oath of homage to him and fight in his military campaigns, " +
    "offering you the fief of {s2} for your loyal service. " +
    "He will surely be offended if you do not take the offer...",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (faction_get_slot, "$g_invite_faction_lord", "$g_invite_faction", slot_faction_leader),
      (str_store_troop_name, s8, "$g_invite_faction_lord"),
      (str_store_faction_name, s9, "$g_invite_faction"),
      (str_store_party_name, s2, "$g_invite_offered_center"),
    ],
    [
      ("faction_accept",[],"Accept!",
        [(str_store_troop_name,s1,"$g_invite_faction_lord"),
          (setup_quest_text,"qst_join_faction"),
          
          (str_store_troop_name_link, s3, "$g_invite_faction_lord"),
          (str_store_faction_name_link, s4, "$g_invite_faction"),
          (quest_set_slot, "qst_join_faction", slot_quest_giver_troop, "$g_invite_faction_lord"),
          (quest_set_slot, "qst_join_faction", slot_quest_expiration_days, 30),
          (str_store_string, s2, "@Find and speak with {s3} of the {s4} to give him your oath of homage."),
          (call_script, "script_start_quest", "qst_join_faction", "$g_invite_faction_lord"),
          (call_script, "script_report_quest_troop_positions", "qst_join_faction", "$g_invite_faction_lord", 3),
          (jump_to_menu, "mnu_invite_player_to_faction_accepted"),
      ]),
      ("faction_reject",[],"Decline the invitation.",
        [(call_script, "script_change_player_relation_with_troop", "$g_invite_faction_lord", -3),
          (assign, "$g_invite_faction", 0),
          (assign, "$g_invite_faction_lord", 0),
          (assign, "$g_invite_offered_center", 0),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "invite_player_to_faction_accepted",0,
    "In order to become a vassal, you must swear an oath of homage to {s3}. " +
    "You shall have to find him and give him your oath in person. {s5}",
    "none",
    [(set_background_mesh, "mesh_pic_coppergate_helm"), #pic book
      (call_script, "script_get_information_about_troops_position", "$g_invite_faction_lord", 0),
      (str_store_troop_name, s3, "$g_invite_faction_lord"),
      (str_store_string, s5, "@{!}{s1}"),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "question_peace_offer",0,
    "Truce^^The {s1} offers you a peace agreement. What is your answer?",
    "none",
    [
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
      (store_relation,  ":relation", "fac_player_supporters_faction", "$g_notification_menu_var1"),
      (try_begin),
        (ge, ":relation", 0),
        (change_screen_return),
      (try_end),
    ],
    [
      ("peace_offer_accept",[],"Accept",
        [
          (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_player_supporters_faction", "$g_notification_menu_var1", 1),
          (change_screen_return),
      ]),
      ("peace_offer_reject",[],"Reject",
        [
          (call_script, "script_change_player_relation_with_faction", "$g_notification_menu_var1", -5),
          (change_screen_return),
      ]),
    ]
  ),
  
  # (
    # "notification_truce_expired",0,
    # "Truce Has Expired^^The truce between the {s1} and the {s2} has expired.",
    # "none",
    # [
      # (str_store_faction_name, s1, "$g_notification_menu_var1"),
      # (str_store_faction_name, s2, "$g_notification_menu_var2"),
      
      # (set_fixed_point_multiplier, 100),
      # (position_set_x, pos0, 65),
      # (position_set_y, pos0, 30),
      # (position_set_z, pos0, 170),
      # (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
    # ],
    # [
      # ("continue",[],"Continue",
        # [
          # (change_screen_return),
      # ]),
    # ]
  # ),
  
  (
    "notification_feast_quest_expired",0,
    "{!}{s10}",
    "none",
    [
      (str_store_string, s10, "str_feast_quest_expired"),
    ],
    [
      ("continue",[],"Continue",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_sortie_possible",0,
    "Enemy Sighted: Enemies have been sighted outside the walls of {s4}, and {s5} and others are preparing for a sortie. You may join them if you wish.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (str_store_party_name, s4, "$g_notification_menu_var1"),
      (party_stack_get_troop_id, ":leader", "$g_notification_menu_var2", 0),
      (str_store_troop_name, s5, ":leader"),
    ],
    [
      ("continue",[],"Continue",
        [
          #stop auto-clock
          
          (change_screen_return),
      ]),
    ]
  ),
  
  
  
  
  (
    "notification_casus_belli_expired",0,
    "Kingdom Fails to Respond^^The {s1} has not responded to the {s2}'s provocations, and {s3} suffers a loss of face among {reg4?her:his} more bellicose subjects...^",
    "none",
    [
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$g_notification_menu_var2"),
      (faction_get_slot, ":faction_leader", "$g_notification_menu_var1", slot_faction_leader),
      (str_store_troop_name, s3, ":faction_leader"),
      (troop_get_type, reg4, ":faction_leader"),
      (val_mod, reg4, 2),
      
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
      ###no menu v-2646
      (display_message,"@Kingdom Fails to Respond: The {s1} has not responded to the {s2}'s provocations, and {s3} suffers a loss of face among {reg4?her:his} more bellicose subjects..."),
      (call_script, "script_faction_follows_controversial_policy", "$g_notification_menu_var1", logent_policy_ruler_ignores_provocation),
      (leave_encounter),
      (jump_to_menu, "mnu_auto_return_to_map"),
      
      
    ],
    [
      ("continue",[],"Continue",
        [
          (call_script, "script_faction_follows_controversial_policy", "$g_notification_menu_var1", logent_policy_ruler_ignores_provocation),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_lord_defects",0,
    "Defection: {s4} has abandoned the {s5} and joined the {s7}, taking {reg4?her:his} his fiefs with him",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (assign, ":defecting_lord", "$g_notification_menu_var1"),
      (assign, ":old_faction", "$g_notification_menu_var2"),
      (str_store_troop_name, s4, ":defecting_lord"),
      (str_store_faction_name, s5, ":old_faction"),
      (store_faction_of_troop, ":new_faction", ":defecting_lord"),
      (str_store_faction_name, s7, ":new_faction"),
      (troop_get_type, reg4, ":defecting_lord"),
      (val_mod, reg4, 2),
      
    ],
    [
      ("continue",[],"Continue",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "notification_treason_indictment",0,
    "Treason Indictment^^{s9}",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (assign, ":indicted_lord", "$g_notification_menu_var1"),
      (assign, ":former_faction", "$g_notification_menu_var2"),
      (faction_get_slot, ":former_faction_leader", ":former_faction", slot_faction_leader),
      
      #Set up string
      (try_begin),
        (eq, ":indicted_lord", "trp_player"),
        (str_store_troop_name, s7, ":former_faction_leader"),
        (str_store_string, s9, "str_you_have_been_indicted_for_treason_to_s7_your_properties_have_been_confiscated_and_you_would_be_well_advised_to_flee_for_your_life"),
      (else_try),
        (str_store_troop_name, s4, ":indicted_lord"),
        (str_store_faction_name, s5, ":former_faction"),
        (str_store_troop_name, s6, ":former_faction_leader"),
        
        (troop_get_type, reg4, ":indicted_lord"),
        (val_mod, reg4, 2),
        (store_faction_of_troop, ":new_faction", ":indicted_lord"),
        (try_begin),
          (is_between, ":new_faction", kingdoms_begin, kingdoms_end),
          (str_store_faction_name, s10, ":new_faction"),
          (str_store_string, s11, "str_with_the_s10"),
        (else_try),
          (str_store_string, s11, "str_outside_calradia"),
        (try_end),
        (str_store_string, s9, "str_by_order_of_s6_s4_of_the_s5_has_been_indicted_for_treason_the_lord_has_been_stripped_of_all_reg4herhis_properties_and_has_fled_for_reg4herhis_life_he_is_rumored_to_have_gone_into_exile_s11"),
      (try_end),
      
      
    ],
    [
      ("continue",[],"Continue",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  #motomataru chief cambia
  (
    "notification_border_incident",0,
    # "Border incident^^Word reaches you that {s9}. Though you don't know whether or not the rumors are true, you do know one thing -- this seemingly minor incident has raised passions among the {s4}, making it easier for them to go to war against the {s3}, if they want it...",
    "Border incident^^Word reaches you that {s9}. Though you don't know whether or not the rumors are true, you do know one thing -- this seemingly minor incident has raised passions among the people of the {s4}, making it easier for them to go to war against the {s3}...",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (assign, ":acting_village", "$g_notification_menu_var1"),
      (assign, ":target_village", "$g_notification_menu_var2"),
      (store_faction_of_party, ":acting_faction", ":acting_village"),
      
      (try_begin),
        (eq, ":target_village", -1),
        (party_get_slot, ":target_faction", ":acting_village", slot_center_original_faction),
        (try_begin),
          (this_or_next|eq, ":target_faction", ":acting_faction"),
          (neg|faction_slot_eq, ":target_faction", slot_faction_state, sfs_active),
          (party_get_slot, ":target_faction", ":acting_village", slot_center_ex_faction),
        (try_end),
        
        (str_store_party_name, s1, ":acting_village"),
        (str_store_faction_name, s3, ":acting_faction"),
        (str_store_faction_name, s4, ":target_faction"),
        (faction_get_slot, ":target_leader", ":target_faction", slot_faction_leader),
        (str_store_troop_name, s5, ":target_leader"),
        
        (str_store_string, s9, "str_local_notables_from_s1_a_village_claimed_by_the_s4_have_been_mistreated_by_their_overlords_from_the_s3_and_petition_s5_for_protection"),
        (display_log_message, "@There has been an alleged border incident: {s9}"),
        
        (call_script, "script_add_log_entry", logent_border_incident_subjects_mistreated, ":acting_village", -1, -1, ":acting_faction"),
        
        
      (else_try),
        (store_faction_of_party, ":target_faction", ":target_village"),
        
        (str_store_party_name, s1, ":acting_village"),
        (str_store_party_name, s2, ":target_village"),
        (str_store_faction_name, s3, ":acting_faction"),	#MOTO chief move up from below
        (str_store_faction_name, s4, ":target_faction"),	#MOTO chief move up from below
        
        (store_random_in_range, ":random", 0, 3),
        (try_begin),
          (eq, ":random", 0),
          
          (str_store_string, s9, "str_villagers_from_s1_stole_some_cattle_from_s2"),
          # (display_log_message, "@There has been an alleged border incident: {s9}"), #moto chief
          (display_log_message, "@There has been an alleged border incident: the people of the {s4} are considering war against the {s3}."),	#MOTO make more helpful
          
          (call_script, "script_add_log_entry", logent_border_incident_cattle_stolen, ":acting_village", ":target_village", -1,":acting_faction"),
          
        (else_try),
          (eq, ":random", 1),
          
          (str_store_string, s9, "str_villagers_from_s1_abducted_a_woman_from_a_prominent_family_in_s2_to_marry_one_of_their_boys"),
          # (display_log_message, "@There has been an alleged border incident: {s9}"), #moto chief
          (display_log_message, "@There has been an alleged border incident: the people of the {s4} are considering war against the {s3}."),	#MOTO make more helpful
          
          (call_script, "script_add_log_entry", logent_border_incident_bride_abducted, ":acting_village", ":target_village", -1, ":acting_faction"),
        (else_try),
          (eq, ":random", 2),
          
          (str_store_string, s9, "str_villagers_from_s1_killed_some_farmers_from_s2_in_a_fight_over_the_diversion_of_a_stream"),
          # (display_log_message, "@There has been an alleged border incident: {s9}"), #moto chief
          (display_log_message, "@There has been an alleged border incident: the people of the {s4} are considering war against the {s3}."),	#MOTO make more helpful
          
          (call_script, "script_add_log_entry", logent_border_incident_villagers_killed, ":acting_village", ":target_village", -1,":acting_faction"),
        (try_end),
        
      (try_end),
      
      # (str_store_faction_name, s3, ":acting_faction"),	MOTO chief pointless here
      # (str_store_faction_name, s4, ":target_faction"),
      
      (store_add, ":slot_provocation_days", ":acting_faction", slot_faction_provocation_days_with_factions_begin),
      (val_sub, ":slot_provocation_days", kingdoms_begin),
      (faction_set_slot, ":target_faction", ":slot_provocation_days", 30),
      ###no menu v-2646
      (try_begin),
        (neq, ":target_faction", "$players_kingdom"),
        (neq, ":acting_faction", "$players_kingdom"),
        (display_message,"@Border incident: Word reaches you that {s9}. Though you don't know whether or not the rumors are true, you do know one thing -- this seemingly minor incident has raised passions among the people of the {s4}, making it easier for them to go to war against the {s3}..."),
        (leave_encounter),
        (jump_to_menu, "mnu_auto_return_to_map"),
      (try_end),
    ],
    [
      ("continue",[],"Continue",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  
  
  
  (
    "notification_player_faction_active",0,
    "You now possess land in your name, without being tied to any kingdom. This makes you a monarch in your own right, with your court temporarily located at {s12}. However, the other kings in the Northlands will at first consider you a threat, for if any upstart warlord can grab a throne, then their own legitimacy is called into question.^^You may find it desirable at this time to pledge yourself to an existing kingdom. If you want to continue as a sovereign monarch, then your first priority should be to establish an independent right to rule. You can establish your right to rule through several means -- marrying into a high-born family, recruiting new lords, governing your lands, treating with other kings, or dispatching your companions on missions.^^At any rate, your first step should be to appoint a chief minister from among your companions, to handle affairs of state. Different companions have different capabilities.^You may appoint new ministers from time to time. You may also change the location of your court, by speaking to the minister.",
    "none",
    [
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "fac_player_supporters_faction", pos0),
      
      (unlock_achievement, ACHIEVEMENT_CALRADIAN_TEA_PARTY),
      (play_track, "track_coronation"),
      (troop_add_item, "trp_player", "itm_crown1", 0), #chief corona al nuevo rey
      
      (try_for_range, ":walled_center", walled_centers_begin, walled_centers_end),
        (lt, "$g_player_court", walled_centers_begin),
        (store_faction_of_party, ":walled_center_faction", ":walled_center"),
        (eq, ":walled_center_faction", "fac_player_supporters_faction"),
        (assign, "$g_player_court", ":walled_center"),
        
        (try_begin),
          (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
          (is_between, ":spouse", kingdom_ladies_begin, kingdom_ladies_end),
          (troop_set_slot, ":spouse", slot_troop_cur_center, "$g_player_court"),
        (try_end),
        
        (str_store_party_name, s12, "$g_player_court"),
      (try_end),
      
    ],
    [
      ("appoint_spouse",[
          (troop_slot_ge, "trp_player", slot_troop_spouse, 1),
          (troop_get_slot, ":player_spouse", "trp_player", slot_troop_spouse),
          (neg|troop_slot_eq, ":player_spouse", slot_troop_occupation, slto_kingdom_hero),
          (str_store_troop_name, s10, ":player_spouse"),
        ],"Appoint your wife, {s10}...",
        [
          (troop_get_slot, ":player_spouse", "trp_player", slot_troop_spouse),
          (assign, "$g_player_minister", ":player_spouse"),
          (jump_to_menu, "mnu_minister_confirm"),
      ]),
      
      ("appoint_npc1",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc1"),
          (str_store_troop_name, s10, "trp_npc1"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc1"),
          (jump_to_menu, "mnu_minister_confirm"),
      ]),
      
      ("appoint_npc2",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc2"),
          (str_store_troop_name, s10, "trp_npc2"),],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc2"),
          (jump_to_menu, "mnu_minister_confirm"),]),
      
      ("appoint_npc3",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc3"),
          (str_store_troop_name, s10, "trp_npc3"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc3"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc4",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc4"),
          (str_store_troop_name, s10, "trp_npc4"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc4"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc5",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc5"),
          (str_store_troop_name, s10, "trp_npc5"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc5"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc6",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc6"),
          (str_store_troop_name, s10, "trp_npc6"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc6"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc7",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc7"),
          (str_store_troop_name, s10, "trp_npc7"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc7"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc8",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc8"),
          (str_store_troop_name, s10, "trp_npc8"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc8"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc9",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc9"),
          (str_store_troop_name, s10, "trp_npc9"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc9"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc10",[ (neq, "$campaign_type", camp_storyline),#was npc9
          (main_party_has_troop, "trp_npc10"),
          (str_store_troop_name, s10, "trp_npc10"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc10"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc11",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc11"),
          (str_store_troop_name, s10, "trp_npc11"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc11"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc12",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc12"),
          (str_store_troop_name, s10, "trp_npc12"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc12"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc13",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc13"),
          (str_store_troop_name, s10, "trp_npc13"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc13"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc14",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc14"),
          (str_store_troop_name, s10, "trp_npc14"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc14"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc15",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc15"),
          (str_store_troop_name, s10, "trp_npc15"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc15"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_npc16",[(neq, "$campaign_type", camp_storyline),
          (main_party_has_troop, "trp_npc16"),
          (str_store_troop_name, s10, "trp_npc16"),
        ],"Appoint {s10}",
        [
          (assign, "$g_player_minister", "trp_npc16"),
          (jump_to_menu, "mnu_minister_confirm"), ]),
      
      ("appoint_default",[],"Appoint a prominent citizen from the area...",
        [
          (assign, "$g_player_minister", "trp_temporary_minister"),
          (troop_set_faction, "trp_temporary_minister", "fac_player_supporters_faction"),
          (jump_to_menu, "mnu_minister_confirm"),
      ]),
    ]
  ),
  
  (
    "minister_confirm",0,
    "{s9}can be found at your court in {s12}. You should consult your minister periodically to avoid the accumulation of unresolved issues that may sap your authority...",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (try_begin),
        (eq, "$players_kingdom_name_set", 1),
        (change_screen_return),
      (try_end),
      
      (str_store_party_name, s12, "$g_player_court"),
      
      (try_begin),
        (eq, "$g_player_minister", "trp_temporary_minister"),
        (str_store_string, s9, "str_your_new_minister_"),
      (else_try),
        (str_store_troop_name, s10, "$g_player_minister"),
        (str_store_string, s9, "str_s10_is_your_new_minister_and_"),
      (try_end),
      
      (try_begin),
        (main_party_has_troop, "$g_player_minister"),
        (remove_member_from_party, "$g_player_minister", "p_main_party"),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (start_presentation, "prsnt_name_kingdom"),
      ]),
    ]
  ),
  
  
  
  (
    "notification_court_lost",0,
    "{!}{s12}",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (try_begin),
        (is_between, "$g_player_court", centers_begin, centers_end),
        (str_store_party_name, s10, "$g_player_court"),
        (str_store_party_name, s11, "$g_player_court"),
      (else_try),
        (str_store_string, s10, "str_your_previous_court_some_time_ago"),
        (str_store_string, s11, "str_your_previous_court_some_time_ago"),
      (try_end),
      
      (assign, "$g_player_court", -1),
      (assign, "$g_trainerlair_training_center2", -1),
      (assign, "$g_trainerlair_training_type2", 0),
      (str_store_string, s14, "str_after_to_the_fall_of_s11_your_court_has_nowhere_to_go"),
      (try_begin),
        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
        (str_store_string, s14, "str_as_you_no_longer_maintain_an_independent_kingdom_you_no_longer_maintain_a_court"),
      
      (else_try),
        (try_for_range, ":walled_center", walled_centers_begin, walled_centers_end),
          (eq, "$g_player_court", -1),
          (store_faction_of_party, ":walled_center_faction", ":walled_center"),
          (eq, ":walled_center_faction", "fac_player_supporters_faction"),
          (neg|party_slot_ge, ":walled_center", slot_town_lord, active_npcs_begin),
          (assign, "$g_player_court", ":walled_center"),
        (try_end),
        
        (gt, "$g_player_court", -1),
        (try_begin),
          (is_between, "$g_player_minister", companions_begin, companions_end),
          (troop_set_slot, "$g_player_minister", slot_troop_cur_center, "$g_player_court"),
        (try_end),
        (try_begin),
          (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
          (is_between, ":spouse", kingdom_ladies_begin, kingdom_ladies_end),
          (troop_set_slot, ":spouse", slot_troop_cur_center, "$g_player_court"),
          (str_store_party_name, s11, "$g_player_court"),
        (try_end),
        (str_store_string, s14, "str_due_to_the_loss_of_s10_your_court_has_been_relocated_to_s11"),
      
      (else_try),
        (try_for_range, ":walled_center", walled_centers_begin, walled_centers_end),
          (eq, "$g_player_court", -1),
          (store_faction_of_party, ":walled_center_faction", ":walled_center"),
          (eq, ":walled_center_faction", "fac_player_supporters_faction"),
          (assign, "$g_player_court", ":walled_center"),
        (try_end),
        
        (gt, "$g_player_court", -1),
        (try_begin),
          (is_between, "$g_player_minister", companions_begin, companions_end),
          (troop_set_slot, "$g_player_minister", slot_troop_cur_center, "$g_player_court"),
        (try_end),
        (try_begin),
          (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
          (is_between, ":spouse", kingdom_ladies_begin, kingdom_ladies_end),
          (troop_set_slot, ":spouse", slot_troop_cur_center, "$g_player_court"),
        (try_end),
        (party_get_slot, ":town_lord", "$g_player_court", slot_town_lord),
        (str_store_party_name, s11, "$g_player_court"),
        (str_store_troop_name, s9, ":town_lord"),
        (str_store_string, s14, "str_after_to_the_fall_of_s10_your_faithful_vassal_s9_has_invited_your_court_to_s11_"),
      (try_end),
      
      (str_store_string, s12, s14),
    ],
    [
      ("continue",[],"Continue...",[
          (change_screen_return),
      ]),
    ],
  ),
  
  
  
  (
    "notification_player_faction_deactive",0,
    "Your kingdom no longer holds any land.",
    "none",
    [
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "fac_player_supporters_faction", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [
          
          (try_begin),
            
            
          (try_end),
          (assign, "$g_player_minister", -1),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  
  
  
  
  (
    "notification_player_wedding_day",0,
    "{s8} wishes to inform you that preparations for your wedding at {s10} have been completed and that your presence is expected imminently.",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (set_background_mesh, "mesh_pic_messenger"),
      (str_store_troop_name, s8, "$g_notification_menu_var1"),
      (str_store_party_name, s10, "$g_notification_menu_var2"),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "notification_player_kingdom_holds_feast",0,
    "{!}{s11}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      
      (str_store_troop_name, s8, "$g_notification_menu_var1"),
      (store_faction_of_troop, ":host_faction", "$g_notification_menu_var1"),
      (str_store_faction_name, s9, ":host_faction"),
      
      #		(str_store_faction_name, s9, "$players_kingdom"),
      (str_store_party_name, s10, "$g_notification_menu_var2"),
      
      (str_clear, s12),
      (try_begin),
        (check_quest_active, "qst_wed_betrothed"),
        (quest_get_slot, ":giver_troop", "qst_wed_betrothed", slot_quest_giver_troop),
        (store_faction_of_troop, ":giver_troop_faction", ":giver_troop"),
        (eq, ":giver_troop_faction", "$players_kingdom"),
        (str_store_string, s12, "str_feast_wedding_opportunity"),
      (try_end),
      
      
      
      (str_store_string, s11, "str_s8_wishes_to_inform_you_that_the_lords_of_s9_will_be_gathering_for_a_feast_at_his_great_hall_in_s10_and_invites_you_to_be_part_of_this_august_assembly"),
      (try_begin),
        (eq, "$g_notification_menu_var1", 0),
        (party_slot_eq, "$g_notification_menu_var2", slot_town_lord, "trp_player"),
        (str_store_string, s11, "str_the_great_lords_of_your_kingdom_plan_to_gather_at_your_hall_in_s10_for_a_feast"),
      (else_try),
        (eq, "$g_notification_menu_var1", 0),
        (neg|party_slot_eq, "$g_notification_menu_var2", slot_town_lord, "trp_player"),
        (party_get_slot, ":owner", "$g_notification_menu_var2", slot_town_lord),
        (store_faction_of_troop, ":faction", ":owner"),
        (eq, ":faction", "$players_kingdom"),
        (str_store_troop_name, s15, ":owner"),
        (str_store_string, s11, "@The great lords of your kingdom plan to gather at the great hall of {s15} in {s10} for a feast"),
      (try_end),
      (str_store_string, s11, "@{!}{s11}{s12}"),
      
      (try_begin),
        (ge, "$cheat_mode", 1),
        (store_current_hours, ":hours_since_last_feast"),
        (faction_get_slot, ":last_feast_start_time", "$players_kingdom", slot_faction_last_feast_start_time),
        (val_sub, ":hours_since_last_feast", ":last_feast_start_time"),
        (assign, reg4, ":hours_since_last_feast"),
        (display_message, "@{!}DEBUG -- Hours since last feast started: {reg4}"),
      (try_end),
      
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "notification_center_under_siege",0,
    "{s1} has been besieged by {s2} of the {s3}! " +
    "^^The settlement is surrounded and besieged, its warriors have stocked weapons and stones, and they hope to resist the enemy.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (str_store_party_name, s1, "$g_notification_menu_var1"),
      (str_store_troop_name, s2, "$g_notification_menu_var2"),
      (store_troop_faction, ":troop_faction", "$g_notification_menu_var2"),
      (str_store_faction_name, s3, ":troop_faction"),
      ##      (set_fixed_point_multiplier, 100),
      ##      (position_set_x, pos0, 62),
      ##      (position_set_y, pos0, 30),
      ##      (position_set_z, pos0, 170),
      ##      (set_game_menu_tableau_mesh, "tableau_center_note_mesh", "$g_notification_menu_var1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_village_raided",0,
    "Enemies have Laid Waste to a Fief^^{s1} has been raided by {s2} of the {s3}!",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (str_store_party_name, s1, "$g_notification_menu_var1"),
      (str_store_troop_name, s2, "$g_notification_menu_var2"),
      (store_troop_faction, ":troop_faction", "$g_notification_menu_var2"),
      (str_store_faction_name, s3, ":troop_faction"),
      ##      (set_fixed_point_multiplier, 100),
      ##      (position_set_x, pos0, 62),
      ##      (position_set_y, pos0, 30),
      ##      (position_set_z, pos0, 170),
      ##      (set_game_menu_tableau_mesh, "tableau_center_note_mesh", "$g_notification_menu_var1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_village_raid_started",0,
    "Your Village is under Attack!^^{s2} of the {s3} is laying waste to {s1}.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      (str_store_party_name, s1, "$g_notification_menu_var1"),
      (str_store_troop_name, s2, "$g_notification_menu_var2"),
      (store_troop_faction, ":troop_faction", "$g_notification_menu_var2"),
      (str_store_faction_name, s3, ":troop_faction"),
      ##      (set_fixed_point_multiplier, 100),
      ##      (position_set_x, pos0, 62),
      ##      (position_set_y, pos0, 30),
      ##      (position_set_z, pos0, 170),
      ##      (set_game_menu_tableau_mesh, "tableau_center_note_mesh", "$g_notification_menu_var1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_one_faction_left",0,
    "The Northlands Conquered by One Kingdom^^The {s1} has defeated all rivals and stands as the sole kingdom.^^" +
    "You are BRYTENWALDA!",
    "none",
    [#(set_background_mesh, "mesh_pic_post_battle_menu"), #pic book
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (try_begin),
        (is_between, "$g_notification_menu_var1", "fac_kingdom_1", kingdoms_end), #Excluding player kingdom
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_for_menu", "$g_notification_menu_var1", pos0),
      (else_try),
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
      (try_end),
      (try_begin),
        (faction_slot_eq, "$g_notification_menu_var1", slot_faction_leader, "trp_player"),
        (unlock_achievement, ACHIEVEMENT_THE_GOLDEN_THRONE),
      (else_try),
        (unlock_achievement, ACHIEVEMENT_MANIFEST_DESTINY),
      (try_end),
      
      (try_begin),
        (troop_get_type, ":is_female", "trp_player"),
        (val_mod, ":is_female", 2),
        (eq, ":is_female", 1),
        (unlock_achievement, ACHIEVEMENT_EMPRESS),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_oath_renounced_faction_defeated",0,
    "Your Old Faction was Defeated^^You won the battle against the {s1}! This ends your struggle, which started after you renounced your oath to them.",
    "none",
    [
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (try_begin),
        (is_between, "$g_notification_menu_var1", "fac_kingdom_1", kingdoms_end), #Excluding player kingdom
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_for_menu", "$g_notification_menu_var1", pos0),
      (else_try),
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_center_lost",0,
    "An Estate was Lost^^You have lost {s1} to the {s2}.",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (str_store_party_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$g_notification_menu_var2"),
      ##      (set_fixed_point_multiplier, 100),
      ##      (position_set_x, pos0, 62),
      ##      (position_set_y, pos0, 30),
      ##      (position_set_z, pos0, 170),
      ##      (set_game_menu_tableau_mesh, "tableau_center_note_mesh", "$g_notification_menu_var1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "notification_troop_left_players_faction",0,
    "Betrayal!^^{s1} has left the {s2} and joined the {s3}.",
    "none",
    [
      (str_store_troop_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$players_kingdom"),
      (str_store_faction_name, s3, "$g_notification_menu_var2"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 55),
      (position_set_y, pos0, 20),
      (position_set_z, pos0, 100),
      (set_game_menu_tableau_mesh, "tableau_troop_note_mesh", "$g_notification_menu_var1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_troop_joined_players_faction",0,
    "Good news!^^{s1} has left the {s2} and joined the {s3}.",
    "none",
    [
      (str_store_troop_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$g_notification_menu_var2"),
      (str_store_faction_name, s3, "$players_kingdom"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 55),
      (position_set_y, pos0, 20),
      (position_set_z, pos0, 100),
      (set_game_menu_tableau_mesh, "tableau_troop_note_mesh", "$g_notification_menu_var1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  #MOTO salvage explanation (when multiple explanations needed, only last one valid)
  (
    "notification_war_declared",0,
    "Declaration of War^^The {s1} has declared war against the {s2}!^{s57}^^Blacksmiths have stopped manufacturing plows to forge swords and spears. War has been declared!",
    "none",
    [
      (try_begin),
        (eq, "$g_last_acting_faction", "$g_notification_menu_var1"),
        (eq, "$g_last_target_faction", "$g_notification_menu_var2"),
        (str_store_string, s57, "@^{s64}^"),
        (assign, "$g_last_acting_faction", -1),
        (assign, "$g_last_target_faction", -1),
      (else_try),
        (str_clear, s57),
      (try_end),
      #MOTO salvage explanation end
      
      
      #to do the reason, have war_damage = 0 yield pre-war reasons
      # (try_begin),
      #        (eq, "$g_notification_menu_var1", "fac_player_supporters_faction"),
      #        (str_store_faction_name, s1, "$g_notification_menu_var2"),
      #        (str_store_string, s2, "@you"),
      #      (else_try),
      #        (eq, "$g_notification_menu_var2", "fac_player_supporters_faction"),
      #        (str_store_faction_name, s1, "$g_notification_menu_var1"),
      #        (str_store_string, s2, "@you"),
      #      (else_try),
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$g_notification_menu_var2"),
      # (try_end),
      
      
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (store_sub, ":faction_1", "$g_notification_menu_var1", kingdoms_begin),
      (store_sub, ":faction_2", "$g_notification_menu_var2", kingdoms_begin),
      (val_mul, ":faction_1", 128),
      (val_add, ":faction_1", ":faction_2"),
      (set_game_menu_tableau_mesh, "tableau_2_factions_mesh", ":faction_1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_peace_declared",0,
    "Peace Agreement^^The {s1} and the {s2} have made peace!^{s57}^^These two peoples have stopped fighting. It may only be a temporary truce that some of them take to prepare for another war, or perhaps peace is sincere and lasting.",
    "none",
    [
      (try_begin),
        #MOTO salvage explanation (when multiple explanations needed, only last one valid)
        (eq, "$g_last_acting_faction", "$g_notification_menu_var1"),
        (eq, "$g_last_target_faction", "$g_notification_menu_var2"),
        (str_store_string, s57, "@^{s64}^"),
        (assign, "$g_last_acting_faction", -1),
        (assign, "$g_last_target_faction", -1),
        #MOTO salvage explanation end
      (else_try),
        (str_clear, s57),
      (try_end),
      
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$g_notification_menu_var2"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (store_sub, ":faction_1", "$g_notification_menu_var1", kingdoms_begin),
      (store_sub, ":faction_2", "$g_notification_menu_var2", kingdoms_begin),
      (val_mul, ":faction_1", 128),
      (val_add, ":faction_1", ":faction_2"),
      (set_game_menu_tableau_mesh, "tableau_2_factions_mesh", ":faction_1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  ###alliance notification chief
  (
    "notification_alliance_declared",0,
    "Alliance Agreement^^The {s1} and the {s2} have entered into an alliance!^{s57}^^Both kingdoms have joined their fate and are certainly stronger now.",
    "none",
    [
      (try_begin),
        #MOTO salvage explanation (when multiple explanations needed, only last one valid)
        (eq, "$g_last_acting_faction", "$g_notification_menu_var1"),
        (eq, "$g_last_target_faction", "$g_notification_menu_var2"),
        (str_store_string, s57, "@^{s64}^"),
        (assign, "$g_last_acting_faction", -1),
        (assign, "$g_last_target_faction", -1),
        #MOTO salvage explanation end
      (else_try),
        (str_clear, s57),
      (try_end),
      
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (str_store_faction_name, s2, "$g_notification_menu_var2"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (store_sub, ":faction_1", "$g_notification_menu_var1", kingdoms_begin),
      (store_sub, ":faction_2", "$g_notification_menu_var2", kingdoms_begin),
      (val_mul, ":faction_1", 128),
      (val_add, ":faction_1", ":faction_2"),
      (set_game_menu_tableau_mesh, "tableau_2_factions_mesh", ":faction_1", pos0),
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "notification_alliance_offer",0,
    "The {s1} offers to enter into an alliance with you. What is your answer?",
    "none",
    [
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
    ],
    [
      ("offer_accept",[],"Accept",
        [
          (call_script, "script_diplomacy_start_alliance_between_kingdoms", "fac_player_supporters_faction", "$g_notification_menu_var1", 1),
          (change_screen_return),
      ]),
      ("offer_reject",[],"Reject",
        [
          (call_script, "script_change_player_relation_with_faction", "$g_notification_menu_var1", -5),
          (change_screen_return),
      ]),
    ]
  ),
  
  ###restore faction, restaurar faccion
  (
    "notification_kingdom_reborn",0,
    "Rebellion!^^The people of the defeated {s13} have taken up their weapons, and {s14} has taken a fief from the {s12}. The {s13} has been restored! Long live the King!",
    "none",
    [
      (troop_get_slot, ":original_faction", "$g_notification_menu_var1", slot_troop_original_faction),
      (faction_get_slot, ":original_king", ":original_faction", slot_faction_leader),
      # (str_store_troop_name, s11, "$g_notification_menu_var1"),
      (str_store_faction_name, s12, "$g_notification_menu_var2"),
      (str_store_faction_name, s13, ":original_faction"),
      (str_store_troop_name, s14, ":original_king"),
      
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (try_begin),
        (is_between, ":original_faction", npc_kingdoms_begin, npc_kingdoms_end), #Excluding player kingdom
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_for_menu", ":original_faction", pos0),
      (else_try),
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", ":original_faction", pos0),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (troop_get_slot, ":original_faction", "$g_notification_menu_var1", slot_troop_original_faction),
          
          ## start peace with all third party kingdoms
          (try_for_range, ":cur_kingdom", npc_kingdoms_begin, npc_kingdoms_end),
            (neq, ":cur_kingdom", ":original_faction"),
            (neq, ":cur_kingdom", "$g_notification_menu_var2"),
            (call_script, "script_diplomacy_start_peace_between_kingdoms", ":cur_kingdom", ":original_faction", 0),
          (try_end),
          
          ## faction rebelled against
          (faction_get_slot, ":opposing_king", "$g_notification_menu_var2", slot_faction_leader),
          (try_begin),
            (eq, ":opposing_king", "trp_player"),
            (call_script, "script_diplomacy_start_peace_between_kingdoms", "$g_notification_menu_var2", ":original_faction", 0),  #let player start his/her own wars
          (else_try),
            (call_script, "script_diplomacy_start_war_between_kingdoms", "$g_notification_menu_var2", ":original_faction", logent_faction_declares_war_to_regain_territory),	#MOTO chief pass log entries
          (try_end),
          
          (call_script, "script_update_all_notes"),
          (change_screen_return),
      ]),
    ]
  ),
  #storyline center back to faction
  (
    "notification_center_restoration",0,
    "Local rebellion!^^The people of the {s12} have taken up their weapons and have recovered {s11}.",
    "none",
    [
      (str_store_party_name, s11, "$g_notification_menu_var1"),
      (str_store_faction_name, s12, "$g_notification_menu_var2"),
      (set_background_mesh, "mesh_pic_messenger"), #pic book          ],
    ],
    [
      ("continue",[],"Continue...",
        [
          # (change_screen_return),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###########
  
  (
    "notification_faction_defeated",0,
    "Faction Eliminated^^The {s1} is no more!",
    "none",
    [
      (str_store_faction_name, s1, "$g_notification_menu_var1"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (try_begin),
        (is_between, "$g_notification_menu_var1", "fac_kingdom_1", kingdoms_end), #Excluding player kingdom
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_for_menu", "$g_notification_menu_var1", pos0),
      (else_try),
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (try_begin),
            (is_between, "$supported_pretender", pretenders_begin, pretenders_end),
            (troop_slot_eq, "$supported_pretender", slot_troop_original_faction, "$g_notification_menu_var1"),
            
            (call_script, "script_check_concilio_calradi_achievement"),
            (faction_get_slot, ":old_leader", "$g_notification_menu_var1", slot_faction_leader),
            
            #All rebels switch to kingdom
            (try_for_range, ":cur_troop", active_npcs_begin, active_npcs_end),
              (troop_slot_eq, ":cur_troop", slot_troop_occupation, slto_kingdom_hero),
              (store_troop_faction, ":cur_faction", ":cur_troop"),
              
              (try_begin),
                (eq, ":cur_faction", "fac_player_supporters_faction"),
                (troop_set_faction, ":cur_troop", "$g_notification_menu_var1"),
                (call_script, "script_troop_set_title_according_to_faction", ":cur_troop", "$g_notification_menu_var1"),
              (else_try), #lords of faction react
                (eq, ":cur_faction", "$g_notification_menu_var1"),
                (try_begin),
                  (eq, ":old_leader", ":cur_troop"),
                  (call_script, "script_change_player_relation_with_troop", ":old_leader", -100),
                  (call_script, "script_troop_change_relation_with_troop", ":old_leader", "$supported_pretender", -100),
                (else_try),
                  (call_script, "script_troop_get_relation_with_troop", ":cur_troop", ":old_leader"),
                  (val_div, reg0, -2),
                  (call_script, "script_change_player_relation_with_troop", ":cur_troop", reg0),
                  (call_script, "script_troop_change_relation_with_troop", ":cur_troop", "$supported_pretender", reg0),
                (try_end),
              (try_end),
            (try_end),
            
            (try_for_parties, ":cur_party"),
              (store_faction_of_party, ":cur_faction", ":cur_party"),
              (eq, ":cur_faction", "fac_player_supporters_faction"),
              (party_set_faction, ":cur_party", "$g_notification_menu_var1"),
            (try_end),
            
            (call_script, "script_deactivate_player_faction", 0),
            (assign, "$players_kingdom", "$g_notification_menu_var1"),
            
            (try_begin),
              (troop_get_slot, ":spouse", "trp_player", slot_troop_spouse),
              (is_between, ":spouse", kingdom_ladies_begin, kingdom_ladies_end),
              (troop_set_faction, ":spouse", "$g_notification_menu_var1"),
            (try_end),
            
            (call_script, "script_add_notification_menu", "mnu_notification_rebels_switched_to_faction", "$g_notification_menu_var1", "$supported_pretender"),
            
            (faction_set_slot, "$g_notification_menu_var1", slot_faction_state, sfs_active),
            
            (troop_set_slot, ":old_leader", slot_troop_change_to_faction, "fac_adventurers"),
            
            (faction_set_slot, "$g_notification_menu_var1", slot_faction_leader, "$supported_pretender"),
            (troop_set_faction, "$supported_pretender", "$g_notification_menu_var1"),
            
            (faction_get_slot, ":old_marshal", "$g_notification_menu_var1", slot_faction_marshal),
            (try_begin),
              (ge, ":old_marshal", 0),
              (troop_get_slot, ":old_marshal_party", ":old_marshal", slot_troop_leaded_party),
              (party_is_active, ":old_marshal_party"),
              (party_set_marshal, ":old_marshal_party", 0),
            (try_end),
            
            (faction_set_slot, "$g_notification_menu_var1", slot_faction_marshal, "trp_player"),
            (faction_set_slot, "$g_notification_menu_var1", slot_faction_ai_state, sfai_default),
            (faction_set_slot, "$g_notification_menu_var1", slot_faction_ai_object, -1),
            (troop_set_slot, "$supported_pretender", slot_troop_occupation, slto_kingdom_hero),
            (troop_set_slot, "$supported_pretender", slot_troop_renown, 1000),
            
            (party_remove_members, "p_main_party", "$supported_pretender", 1),
            (call_script, "script_set_player_relation_with_faction", "$g_notification_menu_var1", 0),
            (try_for_range, ":cur_kingdom", kingdoms_begin, kingdoms_end),
              (faction_slot_eq, ":cur_kingdom", slot_faction_state, sfs_active),
              (neq, ":cur_kingdom", "$g_notification_menu_var1"),
              (store_relation, ":reln", ":cur_kingdom", "fac_player_supporters_faction"),
              (set_relation, ":cur_kingdom", "$g_notification_menu_var1", ":reln"),
            (try_end),
            (assign, "$supported_pretender", 0),
            (assign, "$supported_pretender_old_faction", 0),
            (assign, "$g_recalculate_ais", 1),
            (call_script, "script_update_all_notes"),
          (try_end),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "notification_rebels_switched_to_faction",0,
    "Rebellion Success^^Your rebellion is victorious! Your faction now has the sole claim to the title of the {s11}, with {s12} as the single ruler.",
    "none",
    [
      (str_store_faction_name, s11, "$g_notification_menu_var1"),
      (str_store_troop_name, s12, "$g_notification_menu_var2"),
      (set_fixed_point_multiplier, 100),
      (position_set_x, pos0, 65),
      (position_set_y, pos0, 30),
      (position_set_z, pos0, 170),
      (try_begin),
        (is_between, "$g_notification_menu_var1", "fac_kingdom_1", kingdoms_end), #Excluding player kingdom
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_for_menu", "$g_notification_menu_var1", pos0),
      (else_try),
        (set_game_menu_tableau_mesh, "tableau_faction_note_mesh_banner", "$g_notification_menu_var1", pos0),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$talk_context", tc_rebel_thanks),
          (start_map_conversation, "$g_notification_menu_var2", -1),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  (
    "notification_player_should_consult",0,
    "Your minister sends word that there are problems brewing in the realm that, if left untreated, could sap your authority. You should consult with him at your earliest convenience.",
    "none",
    [
    ],
    [
      ("continue",[],"Continue...",
        [
          (setup_quest_text, "qst_consult_with_minister"),
          
          (str_store_troop_name, s11, "$g_player_minister"),
          (str_store_party_name, s12, "$g_player_court"),
          
          (str_store_string, s2, "str_consult_with_s11_at_your_court_in_s12"),
          (call_script, "script_start_quest", "qst_consult_with_minister", -1),
          
          
          (quest_set_slot, "qst_consult_with_minister", slot_quest_expiration_days, 30),
          (quest_set_slot, "qst_consult_with_minister", slot_quest_giver_troop, "$g_player_minister"),
          
          
          (change_screen_return),
      ]),
    ]
  ),
  
  
  
  ####banquete moral mead chief
  (
    "banquete_moral",0,
    "Order your men to leave their weapons outside and invite them to your Great Hall, to sit at your table by rank. The nearest and dearest sit close to you.^" +
    "Some girls serve meat and mead in large quantities. You've spent a lot of money on this feast because your men deserve it.^" +
    "They are the ones who bleed with you, who have helped you conquer your domains. They are your faithful followers.^" +
    "The evening progresses. Many men, drunk as vats, shout and sing. Some run off to vomit and others fight like gamecocks to attract the attention of a girl.^" +
    "Behind you, a bard sings of your power and deeds. You act like a lord. You are a lord, a 'shepherd of men.'",
    "none",
    [
      (set_background_mesh, "mesh_festin"),
    ],
    [
      ("banquete_ok",[],"You drink, laugh and shout as they come.",
        [
          (call_script, "script_change_player_party_morale", 10),
          (call_script, "script_change_troop_renown", "trp_player", -3),
          (call_script, "script_change_player_honor", 1),
          (try_begin),
            (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
            (lt, ":center_relation", 60),
            (call_script, "script_change_player_relation_with_center", "$current_town", 1),
          (try_end),
          (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
          (change_screen_return),
      ]),
      ("banquete_ok2",[],"You stay sober, taste the drink, but no more than necessary.",[
          (call_script, "script_change_player_party_morale", 6),
          (call_script, "script_change_player_honor", -1),
          (try_begin),
            (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
            (lt, ":center_relation", 60),
            (call_script, "script_change_player_relation_with_center", "$current_town", 1),
          (try_end),
          (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
          (change_screen_return)]),
    ],
  ),
  ####banquete moral chief acaba
  #comprar cattle chief
  (
    "comprar_cattle2",0,
    "There are {reg5} head of cattle, each for {reg6} peningas. How many do you want to buy?",
    "none",
    [
      (set_background_mesh, "mesh_pic_cattle"),
      (party_get_slot, reg5, "$g_encountered_party", slot_village_number_of_cattle),
      (gt, reg5, 0),
      (store_item_value, ":cattle_cost", "itm_cattle_meat"),
      (call_script, "script_game_get_item_buy_price_factor", "itm_cattle_meat"),
      (val_mul, ":cattle_cost", reg0),
      #Multiplied by 2 and divided by 100
      (val_div, ":cattle_cost", 50),
      (assign, "$temp", ":cattle_cost"),
      (assign, reg6, ":cattle_cost"),
    ],
    [
      ("cattle_okc",[
          (party_get_slot, ":num_cattle", "$g_encountered_party", slot_village_number_of_cattle),
          (ge, ":num_cattle", 1),
          (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", "$temp"),
        ],"One.",
        [
          (call_script, "script_buy_cattle_from_village", "$g_encountered_party", 1, "$temp"),
      ]),
      ("cattle_ok2c",[(party_get_slot, ":num_cattle", "$g_encountered_party", slot_village_number_of_cattle),
          (ge, ":num_cattle", 5),
          (store_troop_gold, ":gold", "trp_player"),
          (store_mul, ":cost", "$temp", 5),
          (ge, ":gold", ":cost"),
          ],"Five.",[
          (call_script, "script_buy_cattle_from_village", "$g_encountered_party", 5, "$temp"),
      ]),
      ("cattle_ok3c",[
        ],"Forget it.",
        [
          (jump_to_menu,"mnu_village"),
      ]),
    ],
  ),
  #cattle acaba chief
  
  
  
  # (
    # "notification_player_feast_in_progress",0,
    # "Feast in Preparation^^Your wife has started preparations for a feast in your hall in {s11}.",
    # "none",
    # [(set_background_mesh, "mesh_pic_messenger"), #pic book
      # (str_store_party_name, s11, "$g_notification_menu_var1"),
    # ],
    # [
      # ("continue",[],"Continue...",
        # [(change_screen_return),
      # ]),
    # ]
  # ),
  
  
  (
    "notification_lady_requests_visit",0, #add this once around seven days after the last visit, or three weeks, or three months
    "An elderly woman approaches your party and passes one of your men a letter, sealed in plain wax. It is addressed to you. When you break the seal, you see it is from {s15}. It reads, 'I so enjoyed your last visit. {s14} I am currently in {s10}.{s12}'",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"), #pic book
      
      (assign, ":lady_no", "$g_notification_menu_var1"),
      (assign, ":center_no", "$g_notification_menu_var2"),
      
      (str_store_troop_name, s15, ":lady_no"),
      (str_store_party_name, s10, ":center_no"),
      
      (store_current_hours, ":hours_since_last_visit"),
      (troop_get_slot, ":last_visit_hours", ":lady_no", slot_troop_last_talk_time),
      (val_sub, ":hours_since_last_visit", ":last_visit_hours"),
      
      (call_script, "script_get_kingdom_lady_social_determinants", ":lady_no"),
      (assign, ":lady_guardian", reg0),
      
      (str_store_troop_name, s16, ":lady_guardian"),
      (call_script, "script_troop_get_family_relation_to_troop", ":lady_guardian", ":lady_no"),
      
      (str_clear, s14),
      (try_begin),
        (lt, ":hours_since_last_visit", 336),
        (try_begin),
          (troop_slot_eq, ":lady_no", slot_lord_reputation_type, lrep_otherworldly),
          (str_store_string, s14, "str_as_brief_as_our_separation_has_been_the_longing_in_my_heart_to_see_you_has_made_it_seem_as_many_years"),
        (else_try),
          (str_store_string, s14, "str_although_it_has_only_been_a_short_time_since_your_departure_but_i_would_be_most_pleased_to_see_you_again"),
        (try_end),
      (else_try),
        (ge, ":hours_since_last_visit", 336),
        (try_begin),
          (troop_slot_eq, ":lady_no", slot_lord_reputation_type, lrep_ambitious),
          (str_store_string, s14, "str_although_i_have_received_no_word_from_you_for_quite_some_time_i_am_sure_that_you_must_have_been_very_busy_and_that_your_failure_to_come_see_me_in_no_way_indicates_that_your_attentions_to_me_were_insincere_"),
        (else_try),
          (troop_slot_eq, ":lady_no", slot_lord_reputation_type, lrep_moralist),
          (str_store_string, s14, "str_i_trust_that_you_have_comported_yourself_in_a_manner_becoming_a_gentleman_during_our_long_separation_"),
        (else_try),
          (str_store_string, s14, "str_it_has_been_many_days_since_you_came_and_i_would_very_much_like_to_see_you_again"),
        (try_end),
      (try_end),
      
      
      (str_clear, s12),
      (str_clear, s18),
      (try_begin),
        (neg|troop_slot_eq, ":lady_guardian", slot_troop_spouse, ":lady_no"),
        (troop_slot_eq, ":lady_guardian", slot_lord_granted_courtship_permission, 0),
        (str_store_string, s12, "str__you_should_ask_my_s11_s16s_permission_but_i_have_no_reason_to_believe_that_he_will_prevent_you_from_coming_to_see_me"),
        (str_store_string, s18, "str__you_should_first_ask_her_s11_s16s_permission"),
      (else_try),
        (this_or_next|troop_slot_eq, ":lady_guardian", slot_troop_spouse, ":lady_no"),
        (troop_slot_eq, ":lady_guardian", slot_lord_granted_courtship_permission, -1),
        (str_store_string, s12, "str__alas_as_we_know_my_s11_s16_will_not_permit_me_to_see_you_however_i_believe_that_i_can_arrange_away_for_you_to_enter_undetected"),
      (else_try),
        (troop_slot_eq, ":lady_guardian", slot_lord_granted_courtship_permission, 1),
        (str_store_string, s12, "str__as_my_s11_s16_has_already_granted_permission_for_you_to_see_me_i_shall_expect_your_imminent_arrival"),
      (try_end),
      
    ],
    [
      
      ("continuewo",[],"Tell the woman to inform her mistress that you will come shortly.",
        [
          
          (assign, ":lady_to_visit", "$g_notification_menu_var1"),
          (str_store_troop_name_link, s3, ":lady_to_visit"),
          (str_store_party_name_link, s4, "$g_notification_menu_var2"),
          
          (str_store_string, s2, "str_visit_s3_who_was_last_at_s4s18"),
          (call_script, "script_start_quest", "qst_visit_lady", ":lady_to_visit"),
          (quest_set_slot, "qst_visit_lady", slot_quest_giver_troop, ":lady_to_visit"), #don't know why this is necessary
          
          (try_begin),
            (eq, "$cheat_mode", 1),
            (quest_get_slot, ":giver_troop", "qst_visit_lady", slot_quest_giver_troop),
            (str_store_troop_name, s2, ":giver_troop"),
            (display_message, "str_giver_troop_=_s2"),
          (try_end),
          
          (quest_set_slot, "qst_visit_lady", slot_quest_expiration_days, 30),
          (change_screen_return),
      ]),
      
      ("continuewo2",[],"Tell the woman to inform her mistress that you are indisposed.",
        [
          (troop_set_slot, "$g_notification_menu_var1", slot_lady_no_messages, 1),
          (change_screen_return),
      ]),
    ]
  ),
  
  
  
  ( #pre lady visit
    "garden",0,
    "{!}{s12}",
    "none",
    [(set_background_mesh, "mesh_festin"), #pic book
      
      (call_script, "script_get_kingdom_lady_social_determinants", "$love_interest_in_town"),
      (assign, ":guardian_lord", reg0),
      (str_store_troop_name, s11, "$love_interest_in_town"),
      
      (try_begin),
        (neg|troop_slot_eq, ":guardian_lord", slot_lord_granted_courtship_permission, 1),
        (call_script, "script_npc_decision_checklist_male_guardian_assess_suitor", ":guardian_lord", "trp_player"),
        (lt, reg0, 0),
        (troop_set_slot, ":guardian_lord", slot_lord_granted_courtship_permission, -1),
      (try_end),
      
      (assign, "$nurse_assists_entry", 0),
      (try_begin),
        (troop_slot_eq, ":guardian_lord", slot_lord_granted_courtship_permission, 1),
        (str_store_string, s12, "str_the_guards_at_the_gate_have_been_ordered_to_allow_you_through_you_might_be_imagining_things_but_you_think_one_of_them_may_have_given_you_a_wink"),
      (else_try), #the circumstances under which the lady arranges for a surreptitious entry
        (call_script, "script_troop_get_relation_with_troop", "trp_player", "$love_interest_in_town"),
        (this_or_next|check_quest_active, "qst_blank_quest_16"),
        (this_or_next|check_quest_active, "qst_blank_quest_17"),
        (gt, reg0, 0),
        
        (assign, ":player_completed_quest", 0),
        (try_begin),
          (check_quest_active, "qst_visit_lady"),
          (quest_slot_eq, "qst_visit_lady", slot_quest_giver_troop, "$love_interest_in_town"),
          (assign, ":player_completed_quest", 1),
        (else_try),
          (check_quest_active, "qst_formal_marriage_proposal"),
          (quest_slot_eq, "qst_formal_marriage_proposal", slot_quest_giver_troop, "$love_interest_in_town"),
          (this_or_next|check_quest_succeeded, "qst_formal_marriage_proposal"),
          (check_quest_failed, "qst_formal_marriage_proposal"),
          (assign, ":player_completed_quest", 1),
        (else_try),
          (check_quest_active, "qst_duel_courtship_rival"),
          (quest_slot_eq, "qst_duel_courtship_rival", slot_quest_giver_troop, "$love_interest_in_town"),
          (this_or_next|check_quest_succeeded, "qst_duel_courtship_rival"),
          (check_quest_failed, "qst_duel_courtship_rival"),
          (assign, ":player_completed_quest", 1),
        (else_try),
          (check_quest_active, "qst_blank_quest_16"),
          (quest_slot_eq, "qst_blank_quest_16", slot_quest_giver_troop, "$love_interest_in_town"),
          (this_or_next|check_quest_succeeded, "qst_blank_quest_16"),
          (check_quest_failed, "qst_blank_quest_16"),
          (assign, ":player_completed_quest", 1),
        (else_try),
          (check_quest_active, "qst_blank_quest_17"),
          (quest_slot_eq, "qst_blank_quest_17", slot_quest_giver_troop, "$love_interest_in_town"),
          (this_or_next|check_quest_succeeded, "qst_blank_quest_17"),
          (check_quest_failed, "qst_blank_quest_17"),
          (assign, ":player_completed_quest", 1),
        (try_end),
        
        (try_begin),
          (store_current_hours, ":hours_since_last_visit"),
          (troop_get_slot, ":last_visit_time", "$love_interest_in_town", slot_troop_last_talk_time),
          (val_sub, ":hours_since_last_visit", ":last_visit_time"),
          (this_or_next|ge, ":hours_since_last_visit", 96), #at least four days
          (eq, ":player_completed_quest", 1),
          
          (try_begin),
            (is_between, "$g_encountered_party", towns_begin, towns_end),
            (str_store_string, s12, "str_the_guards_glare_at_you_and_you_know_better_than_to_ask_permission_to_enter_however_as_you_walk_back_towards_your_lodgings_an_elderly_lady_dressed_in_black_approaches_you_i_am_s11s_nurse_she_whispers_urgently_don_this_dress_and_throw_the_hood_over_your_face_i_will_smuggle_you_inside_the_castle_to_meet_her_in_the_guise_of_a_skullery_maid__the_guards_will_not_look_too_carefully_but_i_beg_you_for_all_of_our_sakes_be_discrete"),
            (assign, "$nurse_assists_entry", 1),
          (else_try),
            (str_store_string, s12, "str_the_guards_glare_at_you_and_you_know_better_than_to_ask_permission_to_enter_however_as_you_walk_back_towards_your_lodgings_an_elderly_lady_dressed_in_black_approaches_you_i_am_s11s_nurse_she_whispers_urgently_wait_for_a_while_by_the_spring_outside_the_walls_i_will_smuggle_her_ladyship_out_to_meet_you_dressed_in_the_guise_of_a_shepherdess_but_i_beg_you_for_all_of_our_sakes_be_discrete"),
            (assign, "$nurse_assists_entry", 2),
          (try_end),
        (else_try),
          (str_store_string, s12, "str_the_guards_glare_at_you_and_you_know_better_than_to_ask_permission_to_enter_however_as_you_walk_back_towards_your_lodgings_an_elderly_lady_dressed_in_black_approaches_you_i_am_s11s_nurse_she_whispers_urgently_her_ladyship_asks_me_to_say_that_yearns_to_see_you_but_that_you_should_bide_your_time_a_bit_her_ladyship_says_that_to_arrange_a_clandestine_meeting_so_soon_after_your_last_encounter_would_be_too_dangerous"),
        (try_end),
      (else_try),
        (str_store_string, s12, "str_the_guards_glare_at_you_and_you_know_better_than_to_ask_permission_to_enter"),
      (try_end),
      
    ],
    [
      
      ("enter",
        [
          (call_script, "script_get_kingdom_lady_social_determinants", "$love_interest_in_town"),
          (troop_slot_eq, reg0, slot_lord_granted_courtship_permission, 1)
        ], "Enter",
        [
          (jump_to_menu, "mnu_town"),
          (call_script, "script_setup_meet_lady", "$love_interest_in_town", "$g_encountered_party"),
        ]
      ),
      
      ("nurse",
        [
          (eq, "$nurse_assists_entry", 1),
        ], "Go with the nurse",
        [
          (jump_to_menu, "mnu_town"),
          (call_script, "script_setup_meet_lady", "$love_interest_in_town", "$g_encountered_party"),
        ]
      ),
      
      
      ("nurse2",
        [
          (eq, "$nurse_assists_entry", 2),
        ], "Wait by the spring",
        [
          (jump_to_menu, "mnu_town"),
          (call_script, "script_setup_meet_lady", "$love_interest_in_town", "$g_encountered_party"),
        ]
      ),
      
      ("leave",
        [],
        "Leave",
        [(jump_to_menu, "mnu_town")]),
      
    ]
    
    
  ),
  
  
  (
    "kill_local_merchant_begin",0,
    "You spot your victim and follow him, observing as he turns a corner into a dark alley. " +
    "This will surely be your best opportunity to attack him.",
    "none",
    [(set_background_mesh, "mesh_pic_battle_raid"), #pic book
    ],
    [
      ("continue",[],"Continue...",
        [(set_jump_mission,"mt_back_alley_kill_local_merchant"),
          (party_get_slot, ":town_alley", "$qst_kill_local_merchant_center", slot_town_alley),
          (modify_visitors_at_site,":town_alley"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (set_visitor, 1, "trp_local_merchant"),
          (jump_to_menu, "mnu_town"),
          (jump_to_scene,":town_alley"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  
  (
    "debug_alert_from_s65",0,
    "DEBUG ALERT: {s65}",
    "none",
    [
    ],
    [
      ("continue",[],"Continue...",
        [
          (assign, "$debug_message_in_queue", 0),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "auto_return_to_map",0,
    "stub",
    "none",
    [(change_screen_map)],
    []
  ),
  
  (
    "bandit_lair",0,
    "{!}{s3}",
    "none",
    [(set_background_mesh, "mesh_pic_bandits_lair"), #pic book
      (try_begin),
        (eq, "$loot_screen_shown", 1),
        
        (try_begin),
          (ge, "$g_encountered_party", 0),
          (party_is_active, "$g_encountered_party"),
          (party_get_template_id, ":template", "$g_encountered_party"),
          (neq, ":template", "pt_looter_lair"),
          (call_script, "script_remove_lair", "$g_encountered_party"),
          (assign, "$g_encountered_party", -1),
        (try_end),
        
        (assign, "$g_leave_encounter", 0),
        (change_screen_return),
        
      (else_try),
        (party_stack_get_troop_id, ":bandit_type", "$g_encountered_party", 0),
        (str_store_troop_name_plural, s4, ":bandit_type"),
        (str_store_string, s5, "str_bandit_approach_defile"),
        
        (try_begin),
          (eq, ":bandit_type", "trp_desert_bandit"),
          (str_store_string, s5, "str_bandit_approach_defile"),
        (else_try),
          (eq, ":bandit_type", "trp_mountain_bandit"),
          (str_store_string, s5, "str_bandit_approach_cliffs"),
        (else_try),
          (eq, ":bandit_type", "trp_forest_bandit"),
          (str_store_string, s5, "str_bandit_approach_swamp"),
        (else_try),
          (eq, ":bandit_type", "trp_taiga_bandit"),
          # (str_store_string, s5, "str_bandit_approach_swamp"),
          (str_store_string, s5, "str_bandit_approach_cove"),
        (else_try),
          (eq, ":bandit_type", "trp_steppe_bandit"),
          # (str_store_string, s5, "str_bandit_approach_thickets"),
          (str_store_string, s5, "str_bandit_approach_cove"),
        (else_try),
          (eq, ":bandit_type", "trp_sea_raider"),
          # (str_store_string, s5, "str_bandit_approach_cove"),
          (str_store_string, s5, "str_bandit_approach_thickets"),
        (else_try), #chief anadido
          (eq, ":bandit_type", "trp_elite_viking"),
          (str_store_string, s5, "str_bandit_approach_cove"),
        (try_end),
        
        (try_begin),
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 0), #used in place of global variable
          (str_store_string, s3, "str_bandit_hideout_preattack"),
        (else_try),
          (party_get_template_id, ":template", "$g_encountered_party"),
          (eq, ":template", "pt_looter_lair"),
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 1), #used in place of global variable
          (str_store_string, s3, "str_lost_startup_hideout_attack"),
        (else_try),
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 1), #used in place of global variable
          (str_store_string, s3, "str_bandit_hideout_failure"),
        (else_try),
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 2), #used in place of global variable
          (str_store_string, s3, "str_bandit_hideout_success"),
        (try_end),
      (try_end),
    ],
    [
      ("continue_1l",
        [
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 0), #used in place of global variable
        ],
        "Attack the hideout...",
        
        [
          (party_set_slot, "$g_encountered_party", slot_party_ai_substate, 1),
          (party_get_template_id, ":template", "$g_encountered_party"),
          (assign, "$g_enemy_party", "$g_encountered_party"),
          
          (try_begin),
            (eq, ":template", "pt_sea_raider_lair"),
            (assign, ":bandit_troop", "trp_sea_raider"),
            # (assign, ":scene_to_use", "scn_lair_sea_raiders"),
            (assign, ":scene_to_use", "scn_lair_steppe_bandits"),
          (else_try),	#chief puesto
            (eq, ":template", "pt_sea_raider_lair2"),
            (assign, ":bandit_troop", "trp_elite_viking"),
            (assign, ":scene_to_use", "scn_lair_sea_raiders"),
          (else_try),
            (eq, ":template", "pt_forest_bandit_lair"),
            (assign, ":bandit_troop", "trp_forest_bandit"),
            (assign, ":scene_to_use", "scn_lair_forest_bandits"),
          (else_try),
            (eq, ":template", "pt_desert_bandit_lair"),
            (assign, ":bandit_troop", "trp_desert_bandit"),
            (assign, ":scene_to_use", "scn_lair_desert_bandits"),
          (else_try),
            (eq, ":template", "pt_mountain_bandit_lair"),
            (assign, ":bandit_troop", "trp_mountain_bandit"),
            (assign, ":scene_to_use", "scn_lair_mountain_bandits"),
          (else_try),
            (eq, ":template", "pt_taiga_bandit_lair"),
            (assign, ":bandit_troop", "trp_taiga_bandit"),
            # (assign, ":scene_to_use", "scn_lair_taiga_bandits"),
            (assign, ":scene_to_use", "scn_lair_sea_raiders"),
          (else_try),
            (eq, ":template", "pt_steppe_bandit_lair"),
            (assign, ":bandit_troop", "trp_steppe_bandit"),
            # (assign, ":scene_to_use", "scn_lair_steppe_bandits"),
            (assign, ":scene_to_use", "scn_lair_sea_raiders"),
          (else_try),
            #(eq, ":template", "pt_looter_lair"),
            (assign, ":bandit_troop", "trp_looter"),
            
            # (store_faction_of_party, ":starting_town_faction", "$g_starting_town"),
            
            # (try_begin),
            # (eq, ":starting_town_faction", "fac_kingdom_1"), #player selected swadian city as starting town.
            # (assign, ":scene_to_use", "scn_lair_forest_bandits"),
            # (else_try),
            # (eq, ":starting_town_faction", "fac_kingdom_2"), #player selected Vaegir city as starting town.
            # (assign, ":scene_to_use", "scn_lair_taiga_bandits"),
            # (else_try),
            # (eq, ":starting_town_faction", "fac_kingdom_3"), #player selected Khergit city as starting town.
            # (assign, ":scene_to_use", "scn_lair_steppe_bandits"),
            # (else_try),
            # (eq, ":starting_town_faction", "fac_kingdom_4"), #player selected Nord city as starting town.
            # (assign, ":scene_to_use", "scn_lair_sea_raiders"),
            # (else_try),
            # (eq, ":starting_town_faction", "fac_kingdom_5"), #player selected Rhodok city as starting town.
            # (assign, ":scene_to_use", "scn_lair_mountain_bandits"),
            # (else_try),
            # (eq, ":starting_town_faction", "fac_kingdom_6"), #player selected Sarranid city as starting town.
            (assign, ":scene_to_use", "scn_lair_desert_bandits"),
            # (try_end),
          (try_end),
          
          (modify_visitors_at_site,":scene_to_use"),
          (reset_visitors),
          
          (store_character_level, ":player_level", "trp_player"),
          (store_add, ":number_of_bandits_will_be_spawned_at_each_period", 5, ":player_level"),
          (val_div, ":number_of_bandits_will_be_spawned_at_each_period", 3),
          
          (try_for_range, ":unused", 0, ":number_of_bandits_will_be_spawned_at_each_period"),
            (store_random_in_range, ":random_entry_point", 2, 11),
            (set_visitor, ":random_entry_point", ":bandit_troop", 1),
          (try_end),
          
          (party_clear, "p_temp_casualties"),
          
          (set_party_battle_mode),
          (set_battle_advantage, 0),
          (assign, "$g_battle_result", 0),
          (set_jump_mission,"mt_bandit_lair"),
          
          (jump_to_scene, ":scene_to_use"),
          (change_screen_mission),
      ]),
      
      ("trade_withbanditsl",
        [
          (lt,"$player_honor",-20),
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 0),
        ],
        "Sell spoils to bandits.",
        [
          (troop_clear_inventory, "trp_bandit_lairmerchant"),
          (try_begin),
            (store_troop_gold, ":cur_gold","trp_bandit_lairmerchant"),
            (troop_slot_eq,"trp_bandit_lairmerchant",slot_troop_days_on_mission,0),
            (lt,":cur_gold",8000),
            (store_random_in_range,":new_gold",2000,10000),
            (call_script, "script_troop_add_gold", "trp_bandit_lairmerchant", ":new_gold"),
            (troop_set_slot,"trp_bandit_lairmerchant",slot_troop_days_on_mission,4),#hours
          (try_end),
          (change_screen_trade,"trp_bandit_lairmerchant"),
      ]),
      
      ("leave_no_attackl",
        [
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 0),
        ],
        "Leave...",
        [
          (change_screen_return),
      ]),
      
      ("leave_victoryl",
        [
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 2),
        ],
        "Continue...",
        [
          (party_get_template_id, ":template", "$g_encountered_party"),
          (try_begin),
            (neq, ":template", "pt_looter_lair"),
            (check_quest_active, "qst_destroy_bandit_lair"),
            (quest_slot_eq, "qst_destroy_bandit_lair", slot_quest_target_party, "$g_encountered_party"),
            (call_script, "script_succeed_quest", "qst_destroy_bandit_lair"),
          (try_end),
          
          (assign, "$g_leave_encounter", 0),
          
          (try_begin),
            (eq, "$loot_screen_shown", 0),
            #          (try_begin),
            #            (gt, "$g_ally_party", 0),
            #            (call_script, "script_party_add_party", "$g_ally_party", "p_temp_party"), #Add remaining prisoners to ally TODO: FIX it.
            #          (else_try),
            #            (party_get_num_attached_parties, ":num_quick_attachments", "p_main_party"),
            #            (gt, ":num_quick_attachments", 0),
            #            (party_get_attached_party_with_rank, ":helper_party", "p_main_party", 0),
            #            (call_script, "script_party_add_party", ":helper_party", "p_temp_party"), #Add remaining prisoners to our reinforcements
            #          (try_end),
            (troop_clear_inventory, "trp_temp_troop"),
            
            (party_get_num_companion_stacks, ":num_stacks", "p_temp_casualties"),
            (try_for_range, ":stack_no", 0, ":num_stacks"),
              (party_stack_get_troop_id, ":stack_troop", "p_temp_casualties", ":stack_no"),
              (try_begin),
                (party_stack_get_size, ":stack_size", "p_temp_casualties", ":stack_no"),
                (party_stack_get_troop_id, ":stack_troop", "p_temp_casualties", ":stack_no"),
                (gt, ":stack_size", 0),
                (party_add_members, "p_total_enemy_casualties", ":stack_troop", ":stack_size"), #addition_to_p_total_enemy_casualties
                (party_stack_get_num_wounded, ":stack_wounded_size", "p_temp_casualties", ":stack_no"),
                (gt, ":stack_wounded_size", 0),
                (party_wound_members, "p_total_enemy_casualties", ":stack_troop", ":stack_wounded_size"),
              (try_end),
            (try_end),
            
            (call_script, "script_party_calculate_loot", "p_total_enemy_casualties"), #p_encountered_party_backup changed to total_enemy_casualties
            (gt, reg0, 0),
            (troop_sort_inventory, "trp_temp_troop"),
            (change_screen_loot, "trp_temp_troop"),
            (assign, "$loot_screen_shown", 1),
            
            (try_begin),
              (party_get_template_id, ":template", "$g_encountered_party"),
              (eq, ":template", "pt_looter_lair"),
              (call_script, "script_remove_lair", "$g_encountered_party"),
              (assign, "$g_encountered_party", -1),
            (try_end),
            
          (else_try),
            (change_screen_return),
            (call_script, "script_remove_lair", "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
      ]),
      
      ("leave_defeatl",
        [
          (party_slot_eq, "$g_encountered_party", slot_party_ai_substate, 1),
        ],
        "Continue...",
        [
          (try_begin),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (neq, ":template", "pt_looter_lair"),
            (check_quest_active, "qst_destroy_bandit_lair"),
            (quest_slot_eq, "qst_destroy_bandit_lair", slot_quest_target_party, "$g_encountered_party"),
            (call_script, "script_fail_quest", "qst_destroy_bandit_lair"),
          (try_end),
          
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (neq, ":template", "pt_looter_lair"),
            (call_script, "script_remove_lair", "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
          
          (assign, "$g_leave_encounter", 0),
          
          (try_begin),
            (party_is_active, "$g_encountered_party"),
            (party_set_slot, "$g_encountered_party", slot_party_ai_substate, 0),
          (try_end),
          
          (change_screen_return),
      ]),
      
    ]
  ),
  
  
  (
    "notification_player_faction_political_issue_resolved",0,
    "After consulting with the peers of the realm, {s10} has decided to confer {s11} on {s12}.",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      
      (assign, ":faction_issue_resolved", "$g_notification_menu_var1"),
      (assign, ":faction_decision", "$g_notification_menu_var2"),
      (faction_get_slot, ":leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s10, ":leader"),
      (try_begin),
        (eq, ":faction_issue_resolved", 1),
        (str_store_string, s11, "str_the_marshalship"),
      (else_try),
        (str_store_party_name, s11, ":faction_issue_resolved"),
      (try_end),
      (str_store_troop_name, s12, ":faction_decision"),
      
    ],
    [
      ("continue",
        [],"Continue...",
        [
          (change_screen_return),
      ]),
      
      
    ]
  ),
  
  (
    "notification_player_faction_political_issue_resolved_for_player",0,
    "After consulting with the peers of the realm, {s10} has decided to confer {s11} on you. You may decline the honor, but it will probably mean that you will not receive other awards for a little while.{s12}",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (faction_get_slot, ":leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s10, ":leader"),
      (faction_get_slot, ":issue", "$players_kingdom", slot_faction_political_issue),
      (try_begin),
        (eq, ":issue", 1),
        (str_store_string, s11, "str_the_marshalship"),
        (str_store_string, s12, "@^^Note that as long as you remain marshal, the lords of the realm will be expecting you to lead them on campaign. So, if you are awaiting a feast, either for a wedding or for other purposes, you may wish to resign the marshalship by speaking to your liege."),
      (else_try),
        (str_clear, s12),
        (str_store_party_name, s11, ":issue"),
      (try_end),
    ],
    [
      ("accept",
        [],"Accept the honor",
        [
          (faction_get_slot, ":issue", "$players_kingdom", slot_faction_political_issue),
          
          (try_begin),
            (eq, ":issue", 1),
            (call_script, "script_check_and_finish_active_army_quests_for_faction", "$players_kingdom"),
            (call_script, "script_appoint_faction_marshal", "$players_kingdom", "trp_player"),
            (unlock_achievement, ACHIEVEMENT_AUTONOMOUS_COLLECTIVE),
          (else_try),
            (call_script, "script_give_center_to_lord", ":issue", "trp_player", 0), #Zero means don't add garrison
            (party_set_slot,":issue",recruit_permission_need, 0), # no permission to recruit
          (try_end),
          
          (faction_set_slot, "$players_kingdom", slot_faction_political_issue, 0),
          (try_for_range, ":active_npc", active_npcs_begin, active_npcs_end),
            (store_faction_of_troop, ":active_npc_faction", ":active_npc"),
            (eq, ":active_npc_faction", "$players_kingdom"),
            (troop_set_slot, ":active_npc", slot_troop_stance_on_faction_issue, -1),
          (try_end),
          (change_screen_return),
      ]),
      
      ("decline",
        [],"Decline the honor",
        [
          (faction_get_slot, ":issue", "$players_kingdom", slot_faction_political_issue),
          (try_begin),
            (is_between, ":issue", centers_begin, centers_end),
            (assign, "$g_dont_give_fief_to_player_days", 30),
          (else_try),
            (assign, "$g_dont_give_marshalship_to_player_days", 30),
          (try_end),
          
          (try_for_range, ":active_npc", active_npcs_begin, active_npcs_end),
            (store_faction_of_troop, ":active_npc_faction", ":active_npc"),
            (eq, ":active_npc_faction", "$players_kingdom"),
            (troop_set_slot, ":active_npc", slot_troop_stance_on_faction_issue, -1),
          (try_end),
          (change_screen_return),
      ]),
    ]
  ),
  
  ##  ("start_phase_2_5",mnf_disable_all_keys,
  ##    "{!}{s16}",
  ##    "none",
  ##    [
  ##      (str_store_party_name, s1, "$g_starting_town"),
  ##      (str_store_string, s16, "$g_journey_string"),
  ##    ],
  ##    [
  ##      ("continue",[], "Continue...",
  ##       [
  ##		 (jump_to_menu, "mnu_start_phase_3"),
  ##       ]),
  ##    ]
  ##  ),
  
  ###chief cambia para intro nueva
  ("start_phase_3",mnf_disable_all_keys,
    "{!}{s1}",
    "none",
    [
      (str_clear, s1),
      (str_store_string, s1, "@Strange... You've been asleep, but you can't remember any nightmares. What you remember clearly are Viking warriors boarding the Woden Ric, plunging their weapons into the bodies of the captain and sailors, and Bodo, the Cantabrian, defending himself like a lion until cornered. You hear his words in your consciousness, '{playername}! Fight! I am yet with you!'^^" +
        "You remember the death -- your death -- when your enemies fell upon you. You still feel the wooden floor of the boat smash into your cheek before you could hardly breathe a goodbye to the world. Your eyes met your mother's, just before the end, as a huge Viking, dressed in iron -- could he be Sven? -- cracked her head with his spear and threw her body to the side.^^" +
        "You crawled, leaving a trail of blood, preferring to give your body to the fish, but you remember no more.^^Are you dead? " +
        "But if you're dead, why do you feel the sore muscles of your body, or the heat from a nearby fire? How is it that you can clench your hands, open your eyes and distinguish the beams of a roof over you?^^" +
      "And if you're alive, who has saved you, why and how?"),
      (set_background_mesh, "mesh_pic_extra_navegando"),
    ],
    [
      ("continue",[(eq, "$current_startup_quest_phase", 1)], "Continue...",
        [
          (assign, "$current_town", "p_village_150"), #doccinga
          (assign, "$g_starting_town", "$current_town"),
          # (party_set_morale, "p_main_party", 100),
          (set_encountered_party, "$current_town"),
          # (call_script, "script_prepare_alley_to_fight"),
          (assign, "$town_entered", 1),
          
          (assign, ":town_merchant", "trp_nord_merchant"),
          (assign, ":town_room_scene", "scn_town_1_room"),
          #quitamos items to player chief
          (troop_get_inventory_capacity, ":capacity", "trp_player"), #chief limpia inventario
          (try_for_range, ":i", 0, ":capacity"),
            (troop_set_inventory_slot, "trp_player", ":i", -1),
          (try_end),
          
          (assign, "$g_player_troop", "trp_player"),
          #(troop_clear_inventory, "$g_player_troop"),
          (set_show_messages, 0),
          #
          (troop_add_item, "$g_player_troop","itm_ptunic_1",0),
          (troop_add_item, "$g_player_troop","itm_carbatinae_1",0),
          (troop_add_item, "$g_player_troop","itm_bread",0), #food
          (troop_add_item, "$g_player_troop","itm_seax_1",0), #importante para quest en doccinga de lucha con los melee
          (troop_equip_items, "$g_player_troop"),
          
          (store_troop_gold,":money","trp_player"),
          (troop_remove_gold,"trp_player",":money"),
          (call_script, "script_troop_add_gold", "trp_player", 80),
          #
          (set_show_messages, 1),
          
          (modify_visitors_at_site, ":town_room_scene"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (set_visitor, 9, ":town_merchant"),
          
          (assign, "$talk_context", tc_merchants_house),
          
          (assign, "$dialog_with_merchant_ended", 0),
          
          (set_jump_mission, "mt_meeting_merchant"),
          
          (jump_to_scene, ":town_room_scene"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  ("start_phase_4",mnf_disable_all_keys,
    "{!}{s11}",
    "none",
    [
      (assign, ":continue", 1),
      (try_begin),
        (eq, "$current_startup_quest_phase", 2),
        (change_screen_return),
        (assign, ":continue", 0),
      (else_try),
        (eq, "$current_startup_quest_phase", 3),
        (str_store_string, s11, "str_merchant_and_you_call_some_townsmen_and_guards_to_get_ready_and_you_get_out_from_tavern"),
      (else_try),
        (eq, "$current_startup_quest_phase", 4),
        (try_begin),
          (eq, "$g_killed_first_bandit", 1),
          (str_store_string, s11, "str_town_fight_ended_you_and_citizens_cleaned_town_from_bandits"),
        (else_try),
          (str_store_string, s11, "str_town_fight_ended_you_and_citizens_cleaned_town_from_bandits_you_wounded"),
        (try_end),
      (try_end),
      
      (eq, ":continue", 1),
    ],
    [
      ("continue",
        [
          (this_or_next|eq, "$current_startup_quest_phase", 1),
          (eq, "$current_startup_quest_phase", 4),
        ],
        "Continue...",
        [
          (assign, "$town_entered", 1),
          
          (try_begin),
            (eq, "$current_town", "p_town_1"),
            (assign, ":town_merchant", "trp_nord_merchant"),
            (assign, ":town_room_scene", "scn_town_1_room"),
          (else_try),
            (eq, "$current_town", "p_town_5"),
            (assign, ":town_merchant", "trp_rhodok_merchant"),
            (assign, ":town_room_scene", "scn_town_5_room"),
          (else_try),
            (eq, "$current_town", "p_town_6"),
            (assign, ":town_merchant", "trp_swadian_merchant"),
            (assign, ":town_room_scene", "scn_town_6_room"),
          (else_try),
            (eq, "$current_town", "p_town_8"),
            (assign, ":town_merchant", "trp_vaegir_merchant"),
            (assign, ":town_room_scene", "scn_town_8_room"),
          (else_try),
            (eq, "$current_town", "p_town_10"),
            (assign, ":town_merchant", "trp_khergit_merchant"),
            (assign, ":town_room_scene", "scn_town_10_room"),
          (else_try),
            (eq, "$current_town", "p_town_19"),
            (assign, ":town_merchant", "trp_sarranid_merchant"),
            (assign, ":town_room_scene", "scn_town_19_room"),
          (try_end),
          
          (modify_visitors_at_site, ":town_room_scene"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (set_visitor, 9, ":town_merchant"),
          
          (assign, "$talk_context", tc_merchants_house),
          
          (assign, "$dialog_with_merchant_ended", 0),
          
          (set_jump_mission, "mt_meeting_merchant"),
          
          (jump_to_scene, ":town_room_scene"),
          (change_screen_mission),
      ]),
      
      ("continue",
        [
          (eq, "$current_startup_quest_phase", 3),
        ],
        "Continue...",
        [
          (call_script, "script_prepare_town_to_fight"),
      ]),
    ]
  ),
  
  
  ("lost_tavern_duel",mnf_disable_all_keys,
    "{!}{s11}",
    "none",
    [(set_background_mesh, "mesh_pic_battle_raid"), #pic book
      (try_begin),
        (agent_get_troop_id, ":type", "$g_main_attacker_agent"),
        (eq, ":type", "trp_belligerent_drunk"),
        (str_store_string, s11, "str_lost_tavern_duel_ordinary"),
      (else_try),
        (agent_get_troop_id, ":type", "$g_main_attacker_agent"),
        (eq, ":type", "trp_hired_assassin"),
        (str_store_string, s11, "str_lost_tavern_duel_assassin"),
      (try_end),
      (troop_set_slot, "trp_hired_assassin", slot_troop_cur_center, -1),
    ],
    [
      ("continue",[],"Continue...",
        [
          (jump_to_menu, "mnu_town"),
      ]),
    ]
  ),
  
  
  ("establish_court",mnf_disable_all_keys,
    "Establishing {s4} as your court will require a small refurbishment. In particular, you will need a set of tools and some silver. It may also take a short while for some of your followers to relocate here. Do you wish to proceed?",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (str_store_party_name, s4, "$g_encountered_party"),
    ],
    
    [
      ("establish",[
          (player_has_item, "itm_tools"),
          (player_has_item, "itm_silver"),
        ],"Establish {s4} as your court",
        [
          (assign, "$g_player_court", "$current_town"),
          (assign, "$g_trainerlair_training_center2", -1),
          (assign, "$g_trainerlair_training_type2", 0),
          (troop_remove_item, "trp_player", "itm_tools"),
          (troop_remove_item, "trp_player", "itm_silver"),
          (jump_to_menu, "mnu_town"),
      ]),
      
      
      ("hold_off",[],"Hold off...",
        [
          (jump_to_menu, "mnu_town"),
      ]),
    ]
  ),
  
  ("notification_relieved_as_marshal", mnf_disable_all_keys,
    "{s4} wishes to inform you that your services as marshal are no longer required. In honor of valiant efforts on behalf of the realm over the last {reg4} days, however, {reg8?she:he} offers you a purse of {reg5} peningas.",
    "none",
    [(set_background_mesh, "mesh_pic_diplomatic"), #pic book
      (assign, reg4, "$g_player_days_as_marshal"),
      
      
      
      (store_div, ":renown_gain", "$g_player_days_as_marshal",4),
      (val_min, ":renown_gain", 20),
      (store_mul, ":denar_gain", "$g_player_days_as_marshal", 50),
      (val_max, ":denar_gain", 200),
      (val_min, ":denar_gain", 4000),
      (troop_add_gold, "trp_player", ":denar_gain"),
      (call_script, "script_change_troop_renown", "trp_player", ":renown_gain"),
      (assign, "$g_player_days_as_marshal", 0),
      (assign, "$g_dont_give_marshalship_to_player_days", 15),
      (assign, reg5, ":denar_gain"),
      
      (faction_get_slot, ":faction_leader", "$players_kingdom", slot_faction_leader),
      (str_store_troop_name, s4, ":faction_leader"),
      (troop_get_type, reg8, ":faction_leader"),
      (val_mod, reg8, 2),
    ],
    
    [
      ("continue",[],"Continue",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  ####monasterios religion chief empieza
  
  ("monasterio_visit",0,
    "You arrive at a monastery. The place stretches out wide, with a church, rooms for the monks and their servants, and large gardens with livestock pens. This place certainly treasures wealth!^^{s13}",
    "none",
    [
      (try_begin),
        (party_slot_ge, "$g_encountered_party", slot_party_looted_left_days, 1),
        (jump_to_menu, "mnu_saqueo_loot_continue"),
      (try_end),
      (set_background_mesh, "mesh_pic_extra_monasterio"),
      (try_begin),
        (check_quest_active, "qst_blank_quest_2"),
        (quest_slot_eq, "qst_blank_quest_2", slot_quest_target_center, "$g_encountered_party"),
        (call_script, "script_get_meeting_scene"), (assign, ":meeting_scene", reg0),
        (modify_visitors_at_site,":meeting_scene"),
        (reset_visitors),
        (set_visitor,0, "trp_player"),
        (set_visitor,17, "trp_sacerdote_1"),
        (set_jump_mission, "mt_conversation_encounter"),
        (jump_to_scene, ":meeting_scene"),
        (assign, "$talk_context", tc_entering_center_quest_talk),
        (change_screen_map_conversation, "trp_sacerdote_1"),
      (try_end),
      (try_begin),  #forbidden to enter?
        (store_time_of_day, reg12),
        (is_between, reg12, 5, 21),
        (assign, "$all_doors_locked", 0),
        (str_clear, s13),
      (else_try),
        (assign, "$all_doors_locked", 1),
        (str_store_string, s13, "@It is night, and the monastery seems quiet."),
      (try_end),
    ],
    [
      
      ("enter_interiorm",
        [
          #(eq, 1, 0),	#disabled in menu
          (eq, "$all_doors_locked",0),
        ],
        "Visit the abbot.",
        [
          (eq, "$all_doors_locked",0),
          (set_jump_mission, "mt_monasterio_interior"),
          (set_passage_menu,"mnu_monasterio_visit"),
          (party_get_slot, ":interior_scene", "$g_encountered_party", slot_town_castle),
          (modify_visitors_at_site, ":interior_scene"),
          (reset_visitors),
          (set_visitor, 43, "trp_abad"),
          (set_jump_entry, 0),
          (jump_to_scene, ":interior_scene"),
          (change_screen_mission),
          
      ],"To the Abbot."),
      
      ("entermo",
        [
        ],"Visit the monastery.",
        [
          (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
          (modify_visitors_at_site, ":exterior_scene"),
          (reset_visitors),
          # Setup monk walkers
          (try_begin),
            (eq, "$all_doors_locked",0),
            (try_for_range, ":visiterator", 1, 20),
              (set_visitor, ":visiterator", "trp_monjes",),
            (try_end),
            (try_for_range, ":visiterator", 20, 40),
              (set_visitor, ":visiterator", "trp_monk_walker",),
            (try_end),
            (call_script, "script_init_town_walkers"),
          (try_end),
          
          (set_jump_mission,"mt_monasterio"),
          (set_passage_menu,"mnu_monasterio_visit"),# new phaiak
          
          (jump_to_scene, ":exterior_scene"),
          (change_screen_mission),
          
      ],"Leave."),
      
      ("monasterio_recruitm",
        [
          (eq, "$g_player_faith", 1),
          #(eq, "$reclutar_puede_refuges", 0),
          (party_slot_eq,"$g_encountered_party",slot_center_volunteer_troop_type,0),#can recruit
          (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
          (ge, ":free_capacity", 4),
        ],
        "Ask if somebody wants to join you.",
        [
          (store_random_in_range, ":rand", 0, 8),
          (try_begin),
            (eq, ":rand", 0),
            (jump_to_menu,"mnu_refugee_recruit_troops12"),
          (else_try),
            (eq, ":rand", 1),
            (jump_to_menu,"mnu_refugee_recruit_troops32"),
          (else_try),
            (eq, ":rand", 2),
            (jump_to_menu,"mnu_refugee_recruit_troops12"),
          (else_try),
            (eq, ":rand", 3),
            (jump_to_menu,"mnu_refugee_recruit_troops22"),
          (else_try),
            (eq, ":rand", 4),
            (jump_to_menu,"mnu_refugee_recruit_troops22"),
          (else_try),
            (eq, ":rand", 5),
            (jump_to_menu,"mnu_refugee_recruit_troops22"),
          (else_try),
            (eq, ":rand", 6),
            (jump_to_menu,"mnu_refugee_recruit_troops42"),
          (else_try),
            (eq, ":rand", 7),
            (jump_to_menu,"mnu_refugee_recruit_troops32"),
          (try_end),
        ]
      ),
      
      ("donatemo",[
          (eq, "$g_player_faith", 1),
          (eq, "$g_rezar_monasterio", 0),
          ],"Make a donation to the monastery (500 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 500),
            (troop_remove_gold, "trp_player", 500),
            (display_message, "@The monks bless you, and you continue on your way."),
            (call_script, "script_change_player_relation_with_faction", "fac_christians", 2), #la q designemos
            (call_script, "script_change_troop_renown", "trp_player", 1),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -1),
          (try_end),
          (assign, "$g_rezar_monasterio", 1),
          (change_screen_return),
        ]
      ),
      
      ("aprender_leermo",[
          (eq, "$sabe_leer", 0),
          ],"Learn how to read (4000 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 3999),
            #		     (troop_remove_gold, "trp_player", 4000),
            (start_presentation, "prsnt_read_yesorno"),
            ##                   (rest_for_hours, 24 * 3, 20, 0), #rest while no attackable x20 speed
            ##                  (assign, "$sabe_leer", 1),
            #   (display_message, "@On several occasions throughout your life, you have seen the strange Latin letters, and therefore quickly learn how to read. Perhaps in time you will also learn how to write!"),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -1),
          (try_end),
          #(change_screen_map),
        ]
      ),
      
      ("convertirmo",[
          (eq, "$g_player_faith", 2),
        ],"Convert to Christianity.",
        [
          (assign, "$g_player_faith", 1),
          (troop_set_slot, "trp_player", slot_troop_religion, 1), # christian
          (faction_set_slot, "fac_player_supporters_faction", slot_faction_religion, cb3_christian),
          (display_message, "@You are now a Christian."),
          (try_begin),
            (lt, "$g_player_conversions", 3),
            (store_relation,":rel","fac_christians","fac_player_faction"),
            (try_begin),
              (lt,":rel",-5),
              (call_script, "script_set_player_relation_with_faction", "fac_christians", 1),
            (else_try),
              (call_script, "script_change_player_relation_with_faction", "fac_christians", 5), #la q designemos
            (try_end),
          (else_try),
            (call_script, "script_change_player_relation_with_faction", "fac_christians", 5), #la q designemos
          (try_end),
          
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", -10), #la q designemos
          (troop_get_slot, ":controversy", "trp_player", slot_troop_controversy),
          (val_add, ":controversy", 5),
          (troop_set_slot, "trp_player", slot_troop_controversy, ":controversy"),
          (val_add, "$g_player_conversions", 1),
          (change_screen_return),
        ]
      ),
      
      ("camp_wait_heremo",[
        (neq, "$read_game_no", -1),  #VC-3570 fix learn read exploit
      ],"Wait here for some time.",
        [
          (assign,"$g_camp_mode", 1),
          (assign, "$g_infinite_camping", 0),
          (assign, "$g_player_icon_state", pis_camping),
          (rest_for_hours_interactive, 24 * 365, 5, 0), #rest while no attackable
          (change_screen_return),
        ]
      ),
      
      ("pillage_monasterymo",
        [
          (neq, "$read_game_no", -1),  #VC-3570 fix learn read exploit
          #(eq, "$g_player_faith", 2), #player es pagano, problemas con tropas cristianas CH players can too, important to monastery quest.
        ],"Pillage the monastery.",
        [
          
          (try_begin),
            (call_script, "script_party_count_members_with_full_health", "p_main_party"),
            (gt, reg0, 15), # se muestra si el player tiene por lo menos 15 hombres
            (party_clear, "$g_encountered_party"),
            (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
            (modify_visitors_at_site, ":exterior_scene"),
            (reset_visitors),
            (assign, ":num_monks", 15),
            (store_character_level, ":level", "trp_player"),
            (val_div, ":level", 5),
            (val_add, ":num_monks", ":level"),
            (set_visitors, 1, "trp_monjes", ":num_monks"),
            #(set_visitors, 1, "trp_abad", 1),
            (set_jump_mission,"mt_monasterio_atacado"),
            (jump_to_scene, ":exterior_scene"),
            (change_screen_mission),
            #
            (party_clear, "p_total_enemy_casualties"),
            (assign, "$capture_screen_shown", 0),
            (assign, "$loot_screen_shown", 0),
            (assign, "$all_doors_locked", 1),
          (else_try),
            (display_message,"@You need to have more men for this."),
          (try_end),
        ]
      ),
      
      #     ("choice_monasterio",[],"Save progress.", #save
      #       [
      #               (start_presentation, "prsnt_auto_save"),
      #        ]),
      
      ("leave",[],"Leave.",[
          (leave_encounter),
          (assign, "$read_game_no", 0),  #unsignal learning
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ####monasterios chief acaba
  ###Pagan holy sites
  ("paganholysites_visit",0,
    "You arrive at a hof. In these places, the old gods of the Norse are worshipped. This place certainly treasures wealth!^^{s13}",
    "none",
    [
      (try_begin),
        (party_slot_ge, "$g_encountered_party", slot_party_looted_left_days, 1),
        (jump_to_menu, "mnu_saqueo_loot_continue"),
      (try_end),
      (set_background_mesh, "mesh_pic_road_with_grove"),
      ##	  (try_begin),
      ##           (check_quest_active, "qst_blank_quest_2"),
      ##           (quest_slot_eq, "qst_blank_quest_2", slot_quest_target_center, "$g_encountered_party"),
      ##           (call_script, "script_get_meeting_scene"), (assign, ":meeting_scene", reg0),
      ##           (modify_visitors_at_site,":meeting_scene"),
      ##           (reset_visitors),
      ##           (set_visitor,0, "trp_player"),
      ##           (set_visitor,17, "trp_sacerdote_1"),
      ##           (set_jump_mission, "mt_conversation_encounter"),
      ##           (jump_to_scene, ":meeting_scene"),
      ##           (assign, "$talk_context", tc_entering_center_quest_talk),
      ##           (change_screen_map_conversation, "trp_sacerdote_1"),
      ##	 (try_end),
      (try_begin),  #forbidden to enter?
        (store_time_of_day, reg12),
        (is_between, reg12, 5, 21),
        (assign, "$all_doors_locked", 0),
        (str_clear, s13),
      (else_try),
        (assign, "$all_doors_locked", 1),
        (str_store_string, s13, "@It is night, and the hof seems quiet."),
      (try_end),
    ],
    [
      
      ##      ("enter_interior",
      ##       [
      ##        #(eq, 1, 0),	#disabled in menu
      ##		(eq, "$all_doors_locked",0),
      ##       ],
      ##       "Visit the abbot.",
      ##       [
      ##          (set_jump_mission, "mt_monasterio_interior"),
      ##		  (set_passage_menu,"mnu_monasterio_visit"),
      ##		  (party_get_slot, ":interior_scene", "$g_encountered_party", slot_town_castle),
      ##          (modify_visitors_at_site, ":interior_scene"),
      ##		  (reset_visitors),
      ##          (set_visitor, 43, "trp_abad"),
      ##          (set_jump_entry, 0),
      ##		  (jump_to_scene, ":interior_scene"),
      ##          (change_screen_mission),
      ##
      ##        ],"To the Abbot."),
      
      ("enter_hofho",
        [
        ],"Visit the hof.",
        [
          (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
          (modify_visitors_at_site, ":exterior_scene"),
          (reset_visitors),
          # Setup priest walkers
          (try_begin),
            (eq, "$all_doors_locked",0),
            (try_for_range, ":visiterator", 1, 8),
              (set_visitor, ":visiterator", "trp_norse_priest",), #
            (try_end),
            (try_for_range, ":visiterator", 11, 12),
              (set_visitor, ":visiterator", "trp_sea_raider_leader",),
            (try_end),
            (try_for_range, ":visiterator", 13, 14),
              (set_visitor, ":visiterator", "trp_looter_leader",),
            (try_end),
            (try_for_range, ":visiterator", 10, 18),
              (set_visitor, ":visiterator", "trp_norse_priest",),
            (try_end),
            (try_for_range, ":visiterator", 19, 25),
              (set_visitor, ":visiterator", "trp_manhunterdruid",),
            (try_end),
            (try_for_range, ":visiterator", 26, 32),
              (set_visitor, ":visiterator", "trp_refugee",),
            (try_end),
            # (call_script, "script_init_town_walkers"),
          (try_end),
          
          (set_jump_mission,"mt_paganholysite"),
          #(set_passage_menu,"mnu_monasterio_visit"),# new phaiak
          
          (jump_to_scene, ":exterior_scene"),
          (change_screen_mission),
          
      ],"Leave."),
      
      ("hof_recruitho",
        [
          (eq, "$g_player_faith", 2), #pagan
          (party_slot_eq,"$g_encountered_party",slot_center_volunteer_troop_type,0),#can recruit
          (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
          (ge, ":free_capacity", 2),
        ],
        "Try to recruit a berserker.",
        [
          (store_random_in_range, ":rand", 1, 8),
          (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
          (try_begin),
            (le, ":player_renown", 150), # you have to be someone
            (jump_to_menu,"mnu_nonberserker_renown_low"),
          (else_try),
            (ge, ":rand", 7),
            (jump_to_menu,"mnu_berserker_recruit_2troop"),
          (else_try),
            (ge, ":rand", 4),
            (jump_to_menu,"mnu_berserker_recruit_troop"),
          (else_try),
            (jump_to_menu,"mnu_nonberserker_avaiable_troop"),
          (try_end),
      ]),
      
      ("donate_hofho",[
          (eq, "$g_player_faith", 2),
          (eq, "$g_rezar_monasterio", 0),
          ],"Make a donation to the hof (500 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 500),
            (troop_remove_gold, "trp_player", 500),
            (display_message, "@The gothi has sacrificed animals to appease the gods on your behalf."),
            (call_script, "script_change_player_relation_with_faction", "fac_pagans", 2), #la q designemos
            (call_script, "script_change_troop_renown", "trp_player", 1),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -2),
          (try_end),
          (assign, "$g_rezar_monasterio", 1),
          (change_screen_return),
        ]
      ),
      
      ("convertir_norsegho",[
          (eq, "$g_player_faith", 1),
        ],"Convert to follow Norse gods.",
        [
          (assign, "$g_player_faith", 2),
          (troop_set_slot, "trp_player", slot_troop_religion, 2), # pagan
        (faction_set_slot, "fac_player_supporters_faction", slot_faction_religion, cb3_pagan),
          (display_message, "@You are now a pagan, a follower of Odin and the other Norse gods."),
          (try_begin),
            (lt, "$g_player_conversions", 3),
            (store_relation,":rel","fac_pagans","fac_player_faction"),
            (try_begin),
              (lt,":rel",-5),
              (call_script, "script_set_player_relation_with_faction", "fac_pagans", 1),
            (else_try),
              (call_script, "script_change_player_relation_with_faction", "fac_pagans", 5), #la q designemos
            (try_end),
          (else_try),
            (call_script, "script_change_player_relation_with_faction", "fac_pagans", 5), #la q designemos
          (try_end),
          
          (troop_get_slot, ":controversy", "trp_player", slot_troop_controversy),
          (val_add, ":controversy", 5),
          (troop_set_slot, "trp_player", slot_troop_controversy, ":controversy"),
          (val_add, "$g_player_conversions", 1),
          
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -10), #la q designemos
          (change_screen_return),
        ]
      ),
      
      ("camp_wait_hereho",[],"Wait here for some time.",
        [
          (assign,"$g_camp_mode", 1),
          (assign, "$g_infinite_camping", 0),
          (assign, "$g_player_icon_state", pis_camping),
          (rest_for_hours_interactive, 24 * 365, 5, 0), #rest while no attackable
          (change_screen_return),
        ]
      ),
      
      ("pillage_hofho",
        [
          #(eq, "$g_player_faith", 2), #player es pagano, problemas con tropas cristianas CH players can too, important to monastery quest.
        ],"Pillage the Hof.",
        [
          
          (try_begin),
            (call_script, "script_party_count_members_with_full_health", "p_main_party"),
            (gt, reg0, 15), # se muestra si el player tiene por lo menos 15 hombres
            (party_clear, "$g_encountered_party"),
            (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
            (modify_visitors_at_site, ":exterior_scene"),
            (reset_visitors),
            (assign, ":num_priest", 10),
            (store_character_level, ":level", "trp_player"),
            (val_div, ":level", 5),
            (val_max, ":level", 1),
            (val_add, ":num_priest", ":level"),
            (set_visitors, 1, "trp_norse_priest", ":num_priest"),
            (set_visitors, 1, "trp_manhunterdruid", ":level"),
            (set_visitors, 1, "trp_looter_leader", ":level"), #berserkers defend monastery
            (set_jump_mission,"mt_paganholysites_atacado"),
            (jump_to_scene, ":exterior_scene"),
            (change_screen_mission),
            #
            (party_clear, "p_total_enemy_casualties"),
            (assign, "$capture_screen_shown", 0),
            (assign, "$loot_screen_shown", 0),
          (else_try),
            (display_message,"@You need to have more men for this."),
          (try_end),
        ]
      ),
      
      #     ("choice_monasterio",[],"Save progress.", #save
      #       [
      #               (start_presentation, "prsnt_auto_save"),
      #        ]),
      
      ("leave",[],"Leave.",[(leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  ################ pagan holy sites end
  ###saquear monasterio Religion
  (
    "saquear_monasterio",mnf_disable_all_keys,
    "Blood and treasure. Those of your men with fewer scruples proceed towards {s3}, killing anyone in their path and plundering its riches. The fire and death sweeping the place are rampant. You plunder spoils of war worth {reg3} peningas.^^" +
    "{!}{s4}." +
    "",
    # These Christian troops aren't happy with your action: {s5}^\
    # These pagan troops are happy with your action: {s6}\
    # With unusual fury, your pagan warriors plunder the monastery and kill all the monks. Blood covers the ground, and greed shines in the eyes of the fiercest men.\
    # Blood and death are everywhere. The monks do not resist, and you take possession of their valuables. Your Christian followers do not look very happy.\
    
    "none",
    [
      (try_begin),
        (eq, "$capture_screen_shown", 0),
        (assign, "$capture_screen_shown", 1),
        (party_clear, "p_temp_party"),
        (assign, "$g_move_heroes", 0),
        (call_script, "script_party_add_wounded_members_as_prisoners", "p_temp_party", "p_total_enemy_casualties"),
        (party_get_num_prisoners,  ":num_captured_enemies", "p_temp_party"),
        (try_begin),
          (gt, ":num_captured_enemies", 0),
          (change_screen_exchange_with_party, "p_temp_party"),
        (try_end),
      (else_try),
        (eq, "$loot_screen_shown", 0),
        (assign, "$loot_screen_shown", 1),
        (troop_clear_inventory, "trp_temp_troop"),
        #creating loot
        (try_for_range, ":curr_item" , "itm_mead", "itm_siege_supply"),
          (set_item_probability_in_merchandise, ":curr_item", 0),
        (try_end),
        (set_item_probability_in_merchandise, "itm_wine", 15),
        (set_item_probability_in_merchandise, "itm_ale", 20),
        (set_item_probability_in_merchandise, "itm_jewelry", 5),	#was 12 #/2,25
        (set_item_probability_in_merchandise, "itm_amber", 9),		#was 40 #/4,5
        (set_item_probability_in_merchandise, "itm_silver", 7),		#was 20 #/3
        (try_for_range, ":curr_item", "itm_smoked_fish", "itm_siege_supply"),
          (store_random_in_range, ":rand", 0, 4),
          (val_mul, ":rand", 10),
          (set_item_probability_in_merchandise, ":curr_item", ":rand"),
        (end_try),
        (store_random_in_range, ":loot_amount", 1, 4),
        (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
        (val_add, ":loot_amount", ":player_party_looting"),
        (try_begin),
          (eq, "$easy_wage", 1),# VC-2450
          (val_mul, ":loot_amount", 140),
          (val_div, ":loot_amount", 100),
        (try_end),
        (val_max,":loot_amount",2),
        (troop_add_merchandise,"trp_temp_troop", itp_type_goods, ":loot_amount"),
        (troop_sort_inventory, "trp_temp_troop"),
        (change_screen_loot, "trp_temp_troop"),
      (else_try),
        # All shown
        
        # 1.PLUNDER MONEY
        (party_get_skill_level, ":max_loot", "p_main_party", "skl_looting"),
        (val_mul, ":max_loot", 65),	# 0 -650
        (val_add, ":max_loot", 100),	# 100 - 750
        (store_random_in_range, ":random", 100, ":max_loot"),
        (val_div, ":random", 10),
        (val_mul, ":random", 10),
        (try_begin),
          (check_quest_active, "qst_blank_quest_3"),
          (neg|check_quest_succeeded,"qst_blank_quest_3"),
          (neg|check_quest_failed,"qst_blank_quest_3"),
          (quest_slot_eq, "qst_blank_quest_3", slot_quest_target_center, "$g_encountered_party"),
          (quest_get_slot, ":quest_target_amount", "qst_blank_quest_3",slot_quest_target_amount),
          (val_mul, ":quest_target_amount", 3),
          (val_div, ":quest_target_amount", 2),
          (val_add, ":random", ":quest_target_amount"),
          (call_script, "script_succeed_quest", "qst_blank_quest_3"),
        (try_end),
        (call_script, "script_troop_add_gold", "trp_player", ":random"),
        (assign, reg3, ":random"),
        
        # 2.ICON
        (call_script, "script_change_party_icon_loot_state", "$g_encountered_party", 1),
        (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire"),
        (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire_smoke"),
        (party_set_slot, "$g_encountered_party", slot_village_smoke_added, 1),
        
        # 3.DEVASTATED TIME
        (party_set_slot,"$g_encountered_party", slot_party_looted_left_days, 14), #ciudad saqueda	#changed to 2 weeks
        
        # 4.PARTY MORALE 		#pierde moral cristianos Cristianos descontentos con player chief
        (try_begin),
          (assign, ":num_bmen", 0),
          (assign, ":num_cmen", 0),
          (assign, ":num_pmen", 0),
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
            (try_begin),
              (this_or_next|is_between, ":stack_troop", "trp_farmer", "trp_watchman"),# they are cantabrian christians
              (this_or_next|is_between, ":stack_troop", "trp_briton_slave", "trp_todos_cuerno"),
              (this_or_next|is_between, ":stack_troop", "trp_frisian_basic", "trp_briton_messenger"),
              (is_between, ":stack_troop", "trp_manhunter", "trp_refugeeromanruins"),
              (val_add, ":num_cmen", ":stack_size"),
            (else_try),
              (this_or_next|is_between, ":stack_troop", "trp_norse_slave", "trp_briton_slave"),
              (is_between, ":stack_troop", "trp_watchman", "trp_mercenaries_end"),
              (val_add, ":num_pmen", ":stack_size"),
            (else_try),
              (is_between, ":stack_troop", "trp_looter", "trp_manhunter"),
              (val_add, ":num_bmen", ":stack_size"),
            (try_end),
          (try_end),
          (store_party_size_wo_prisoners, ":num_men", "p_main_party"),
          (val_mul, ":num_bmen", 3),
          (val_mul, ":num_pmen", 2),
          (val_mul, ":num_cmen", -5),
          (store_add, ":weighted", ":num_bmen", ":num_cmen"),
          (val_add, ":weighted", ":num_pmen"),
          (val_mul, ":weighted", 5),
          (val_div, ":weighted", ":num_men"),
          (assign, ":total_morale_p", ":weighted"),
          (val_clamp, ":total_morale_p", -100,101),
          (try_begin),
            (gt, ":total_morale_p", 2),
            (str_clear, s4),
            (str_store_string, s4, "@The majority of your troops is Pagan and supports your action."),
          (else_try),
            (lt, ":total_morale_p", -2),
            (str_clear, s4),
            (str_store_string, s4, "@The majority of your troops is Christian and hates your action."),
          (else_try),
            (str_clear, s4),
          (try_end),
          (call_script, "script_change_player_party_morale", ":total_morale_p"),
        (end_try),
        
        # 5. BOOK QUEST
        (try_begin),
          (check_quest_active,"qst_cathach_colum"),
          (eq, "$g_encountered_party", "p_monasterio29"), #JuJu70- just to make sure we're at the right place
          (neg|quest_slot_eq,"qst_cathach_colum",slot_quest_current_state, 4),
          (troop_add_item, "trp_player","itm_relic",0),
          (str_store_string, s7, "@In the arms of the dead abbot, your men find 'The Cathach of Colum Cille.'"),
          # (call_script, "script_change_player_relation_with_faction", "fac_kingdom_18", -50),
          # (call_script, "script_change_player_relation_with_faction", "fac_kingdom_19", -50),
          # (call_script, "script_change_player_relation_with_faction", "fac_christians", -50),
          # (call_script, "script_change_player_honor", -10),
          (call_script, "script_succeed_quest", "qst_cathach_colum"),
          (quest_set_slot,"qst_cathach_colum",slot_quest_current_state, 4),
          (call_script, "script_objectionable_action", tmt_humanitarian, "str_loot_village"),
        (else_try),
          (str_clear, s7),
        (try_end),
        
        # 6. Reduce relations with nearby faction - JuJu70
        (assign, ":min_dist", 100),
        (assign, ":min_dist_village", -1),
        (try_for_range, ":cur_village", villages_begin, villages_end),
          (store_distance_to_party_from_party, ":cur_dist", ":cur_village", "$g_encountered_party"),
          (lt, ":cur_dist", ":min_dist"),
          (assign, ":min_dist", ":cur_dist"),
          (assign, ":min_dist_village", ":cur_village"),
        (try_end),
        (try_begin), # we need a try here. Otherwise the rest of the code maybe not addressed
          (gt, ":min_dist_village", -1),
          (store_faction_of_party, ":village_faction", ":min_dist_village"),
          (is_between, ":village_faction", "fac_kingdom_1", kingdoms_end),
          (faction_slot_eq, ":village_faction", slot_faction_religion, cb3_christian),
          (call_script, "script_change_player_relation_with_faction", ":village_faction", -5),
        (end_try),
        
        # 7. PENALTYS (moved from the mno)
        (call_script, "script_change_player_honor", -5),	#fixing VC-1308 #seems too low now
        (call_script, "script_change_troop_renown", "trp_player", 5),
        (call_script, "script_change_player_relation_with_faction", "fac_christians", -10), #la q designemos
        (call_script, "script_change_player_relation_with_faction", "fac_pagans", 1), #la q designemos
        (set_fixed_point_multiplier, 100),
        (try_for_range, ":center", centers_begin, centers_end),#reduce relacion con cada centro chief
          (store_distance_to_party_from_party, ":cur_distance", "p_main_party", ":center"),
          (lt,":cur_distance", 40), #2500 way too far
          #(store_random_in_range, ":penalty", -7, -1),
          (party_get_slot, ":faith", ":center", slot_center_faithratio),
          (val_div, ":faith", -13),		#-7 ... 0
          (call_script, "script_change_player_relation_with_center", ":center", ":faith"),
        (try_end),
        
        # 8. REST
        (set_background_mesh, "mesh_pic_vc_plundering_monastery"),
        (play_sound, "snd_cow_moo"), #anadido chief
        (party_clear, "$g_encountered_party"),
        (str_store_party_name, s3, "$g_encountered_party"),
        
      (end_try),
      
      
    ],
    [
      
      ("backho",[],"Leave the place.",
        [  (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
          (change_screen_return),
        ]
      ),
      
      # ("spoils_woden",[(eq, 0, 1), (eq, "$g_player_faith", 2),],"Sacrifice some monks in honor of Odin and keep the booty.",
      # [
      # (call_script, "script_change_player_relation_with_faction", "fac_christians", -12), #la q designemos
      # (call_script, "script_change_player_relation_with_faction", "fac_pagans", 4), #la q designemos
      # #reduce relacion con cada centro cercano chief
      # (try_for_range, ":center", centers_begin, centers_end),
      # (neg|party_slot_ge, ":center", slot_center_religion, 2),
      # (store_distance_to_party_from_party, ":cur_distance", "p_main_party", ":center"),
      # (lt,":cur_distance",90),
      # (call_script, "script_change_player_relation_with_center", ":center", -6),
      # (try_end),
      # (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
      # (change_screen_return),
      # ]),
      # ("spoils_alls",
      # [(eq, 0, 1),
      # ],"Sacrifice some monks and keep the booty.",
      # [
      # (call_script, "script_change_player_relation_with_faction", "fac_christians", -10), #la q designemos
      # #reduce relacion con cada centro chief
      # (try_for_range, ":center", centers_begin, centers_end),
      # (neg|party_slot_ge, ":center", slot_center_religion, 2),
      # (store_distance_to_party_from_party, ":cur_distance", "p_main_party", ":center"),
      # (lt,":cur_distance",90),
      # (call_script, "script_change_player_relation_with_center", ":center", -6),
      # (try_end),
      # (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
      # (change_screen_return),
      # ]),
      # ("spois_share",[  (eq, 0, 1),
      # ],"I want to participate in the looting.",
      # [
      # (call_script, "script_change_player_relation_with_faction", "fac_christians", -10), #la q designemos
      # #reduce relacion con cada centro chief
      # (try_for_range, ":center", centers_begin, centers_end),
      # (neg|party_slot_ge, ":center", slot_center_religion, 2),
      # (store_distance_to_party_from_party, ":cur_distance", "p_main_party", ":center"),
      # (lt,":cur_distance",90),
      # (call_script, "script_change_player_relation_with_center", ":center", -6),
      # (try_end),
      # (party_get_slot, ":exterior_scene", "$g_encountered_party", slot_castle_exterior),
      # (modify_visitors_at_site, ":exterior_scene"),
      # (reset_visitors),
      # (assign, ":num_monks", 15),
      # (store_character_level, ":level", "trp_player"),
      # (val_div, ":level", 5),
      # (val_add, ":num_monks", ":level"),
      # (set_visitors, 1, "trp_monjes", ":num_monks"),
      # (change_screen_mission),
      # ]),
      
    ],
  ),
  ####saquear monasterio acaba chief
  #saquear pagan holy sites
  (
    "saquear_paganholysite",mnf_disable_all_keys,
    "Blood and treasure. Those of your men with fewer scruples proceed towards {s3}, killing anyone in their path and plundering its riches. The fire and death sweeping the place are rampant. You plunder spoils of war are worth {reg3} peningas.^^" +
    "{s7}^^" +
    "{!}{s4}." +
    "",
    # These pagan troops aren't happy with your action: {s5}^\
    # These Crhistian troops are happy with your action: {s6}\
    "none",
    [
      (try_begin),
        (eq, "$capture_screen_shown", 0),
        (assign, "$capture_screen_shown", 1),
        (party_clear, "p_temp_party"),
        (assign, "$g_move_heroes", 0),
        (call_script, "script_party_add_wounded_members_as_prisoners", "p_temp_party", "p_total_enemy_casualties"),
        (party_get_num_prisoners,  ":num_captured_enemies", "p_temp_party"),
        (gt, ":num_captured_enemies", 0),
        (change_screen_exchange_with_party, "p_temp_party"),
      (else_try),
        (eq, "$loot_screen_shown", 0),
        (assign, "$loot_screen_shown", 1),
        (troop_clear_inventory, "trp_temp_troop"),
        #creating loot
        (try_for_range, ":curr_item" , "itm_mead", "itm_siege_supply"),
          (set_item_probability_in_merchandise, ":curr_item", 0),
        (try_end),
        (set_item_probability_in_merchandise, "itm_amber", 9), #was 40 #/4,5
        (set_item_probability_in_merchandise, "itm_silver", 5),	#was 15 #/3
        (set_item_probability_in_merchandise, "itm_vc_furs", 10),
        (set_item_probability_in_merchandise, "itm_ale", 20),
        (try_for_range, ":curr_item", "itm_smoked_fish", "itm_siege_supply"),
          (store_random_in_range, ":rand", 0, 4),
          (val_mul, ":rand", 10),
          (set_item_probability_in_merchandise, ":curr_item", ":rand"),
        (end_try),
        (store_random_in_range, ":loot_amount", 1, 4),
        (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
        (val_add, ":loot_amount", ":player_party_looting"),
        (val_max, ":loot_amount", 2),
        (troop_add_merchandise,"trp_temp_troop", itp_type_goods, ":loot_amount"),
        (troop_sort_inventory, "trp_temp_troop"),
        (change_screen_loot, "trp_temp_troop"),
      (else_try),
        # All shown
        
        # 1.PLUNDER MONEY
        (party_get_skill_level, ":max_loot", "p_main_party", "skl_looting"),
        (val_mul, ":max_loot", 65),	# 0 -650
        (val_add, ":max_loot", 100),	# 100 - 750
        (store_random_in_range, ":random", 100, ":max_loot"),
        (val_div, ":random", 10),
        (val_mul, ":random", 10),
        ##		(try_begin),
        ##			(check_quest_active, "qst_blank_quest_3"),
        ##			(neg|check_quest_succeeded,"qst_blank_quest_3"),
        ##			(neg|check_quest_failed,"qst_blank_quest_3"),
        ##            (quest_slot_eq, "qst_blank_quest_3", slot_quest_target_center, "$g_encountered_party"),
        ##			(quest_get_slot, ":quest_target_amount", "qst_blank_quest_3",slot_quest_target_amount),
        ##			(val_mul, ":quest_target_amount", 3),
        ##			(val_div, ":quest_target_amount", 2),
        ##			(val_add, ":random", ":quest_target_amount"),
        ##			(call_script, "script_succeed_quest", "qst_blank_quest_3"),
        ##		(try_end),
        (call_script, "script_troop_add_gold", "trp_player", ":random"),
        (assign, reg3, ":random"),
        
        # 2.ICON
        #(call_script, "script_change_party_icon_loot_state", "$g_encountered_party", 1),
        (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire"),
        (party_add_particle_system, "$g_encountered_party", "psys_map_village_fire_smoke"),
        (party_set_slot, "$g_encountered_party", slot_village_smoke_added, 1),
        
        # 3.DEVASTATED TIME
        (party_set_slot,"$g_encountered_party", slot_party_looted_left_days, 14), #ciudad saqueda	#changed to 2 weeks
        
        # 4.PARTY MORALE 		#pierde moral pagans descontentos con player chief
        (try_begin),
          (assign, ":num_bmen", 0),
          (assign, ":num_cmen", 0),
          (assign, ":num_pmen", 0),
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"),
            (try_begin),
              (this_or_next|is_between, ":stack_troop", "trp_farmer", "trp_watchman"),# they are cantabrian christians
              (this_or_next|is_between, ":stack_troop", "trp_briton_slave", "trp_todos_cuerno"),
              (this_or_next|is_between, ":stack_troop", "trp_frisian_basic", "trp_briton_messenger"),
              (is_between, ":stack_troop", "trp_manhunter", "trp_refugeeromanruins"),
              (val_add, ":num_cmen", ":stack_size"),
            (else_try),
              (this_or_next|is_between, ":stack_troop", "trp_norse_slave", "trp_briton_slave"),
              (is_between, ":stack_troop", "trp_watchman", "trp_mercenaries_end"),
              (val_add, ":num_pmen", ":stack_size"),
            (else_try),
              (is_between, ":stack_troop", "trp_looter", "trp_manhunter"),
              (val_add, ":num_bmen", ":stack_size"),
            (try_end),
          (try_end),
          (store_party_size_wo_prisoners, ":num_men", "p_main_party"),
          (val_mul, ":num_bmen", 3),
          (val_mul, ":num_pmen", -5),
          (val_mul, ":num_cmen", 2),
          (store_add, ":weighted", ":num_bmen", ":num_cmen"),
          (val_add, ":weighted", ":num_pmen"),
          (val_mul, ":weighted", 5),
          (val_div, ":weighted", ":num_men"),
          (assign, ":total_morale_p", ":weighted"),
          (val_clamp, ":total_morale_p", -100, 101),
          (try_begin),
            (gt, ":total_morale_p", 2),
            (str_store_string, s4, "@The majority of your troops are Christian and support your action."),
          (else_try),
            (lt, ":total_morale_p", -2),
            (str_store_string, s4, "@The majority of your troops are pagan and hate your action."),
          (else_try),
            (str_clear, s4),
          (try_end),
          (call_script, "script_change_player_party_morale", ":total_morale_p"),
        (end_try),
        
        # 6. Reduce relations with nearby faction - JuJu70
        (assign, ":min_dist", 100),
        (assign, ":min_dist_village", -1),
        (try_for_range, ":cur_village", villages_begin, villages_end),
          (store_distance_to_party_from_party, ":cur_dist", ":cur_village", "$g_encountered_party"),
          (lt, ":cur_dist", ":min_dist"),
          (assign, ":min_dist", ":cur_dist"),
          (assign, ":min_dist_village", ":cur_village"),
        (try_end),
        (try_begin), # we need a try here. Otherwise the rest of the code maybe not addressed
          (gt, ":min_dist_village", -1),
          (store_faction_of_party, ":village_faction", ":min_dist_village"),
          (is_between, ":village_faction", "fac_kingdom_1", kingdoms_end),
          (faction_slot_eq, ":village_faction", slot_faction_religion, cb3_pagan),
          (call_script, "script_change_player_relation_with_faction", ":village_faction", -5),
        (end_try),
        
        # 7. PENALTYS (moved from the mno)
        (call_script, "script_change_player_honor", -5),	#fixing VC-1308 #seems too low now
        (call_script, "script_change_troop_renown", "trp_player", 5),
        (call_script, "script_change_player_relation_with_faction", "fac_pagans", -10), #la q designemos
        (call_script, "script_change_player_relation_with_faction", "fac_christians", 1), #la q designemos
        (set_fixed_point_multiplier, 100),
        (try_for_range, ":center", centers_begin, centers_end),#reduce relacion con cada centro chief
          (store_distance_to_party_from_party, ":cur_distance", "p_main_party", ":center"),
          (lt,":cur_distance", 40), #2500 way too far
          #(store_random_in_range, ":penalty", -7, -1),
          (party_get_slot, ":faith", ":center", slot_center_faithratio),
          (val_div, ":faith", -13),		#-7 ... 0
          (call_script, "script_change_player_relation_with_center", ":center", ":faith"),
        (try_end),
        
        # 8. REST
        (set_background_mesh, "mesh_pic_raven"),
        (play_sound, "snd_cow_moo"), #anadido chief
        (party_clear, "$g_encountered_party"),
        (str_store_party_name, s3, "$g_encountered_party"),
        
      (end_try),
      
      
    ],
    [
      
      ("backpa",[],"Leave the place.",
        [  (rest_for_hours_interactive, 3, 5, 1), #rest while attackable
          (change_screen_return),
        ]
      ),
    ],
  ),
  #############
  #monasterio reclutas religion
  ####saquear monasterio acaba chief
  #monasterio reclutas religion
  ("refugee_recruit_troops12",0,
    "There are some widows and orphans interested in joining and trying to find a new life with your soldiers.",
    "none", [ (set_background_mesh, "mesh_pic_payment"),
    ],
    [("acept_themmo",[(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 20),], "Hire them. (20 peningas)",
        [
          (party_add_members,"p_main_party","trp_refugee",2),
          (party_add_members,"p_main_party","trp_peasant_woman",2),
          (troop_remove_gold,"trp_player", 20),
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
      ("back_to_town_menu",[],"Head back.",
        [
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
    ]
  ),
  
  ("refugee_recruit_troops22",0,
    "Nobody wants to join you.",
    "none", [ (set_background_mesh, "mesh_pic_payment"),
    ],
    [("back_to_town_menu",[],"Head back.",
        [
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
    ]
  ),
  
  ("refugee_recruit_troops32",0,
    "There are some shepherds and farmers interested in joining your army.",
    "none", [ (set_background_mesh, "mesh_pic_payment"),
      
    ],
    [("acept_themmo2",[ (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 60),], "Hire them. (60 peningas)",
        [
          (party_add_members,"p_main_party","trp_farmer",5),
          (troop_remove_gold,"trp_player", 60),
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
      ("back_to_town_menu",[],"Head back.",
        [
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
    ]
  ),
  
  ("refugee_recruit_troops42",0,
    "There are a cleric and some young warriors interested in joining your army.",
    "none", [ (set_background_mesh, "mesh_pic_payment"),
    ],
    [("acept_themmo3",[(store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 400),], "Hire them. (400 peningas)",
        [
          (party_add_members,"p_main_party","trp_scotch_priest",1),
          (party_add_members,"p_main_party","trp_manhunter",4),
          (troop_remove_gold,"trp_player", 400),
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
      ("back_to_town_menu",[],"Head back.",
        [
          #(assign, "$reclutar_puede_refuges", 1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_monasterio_visit"),
      ]),
    ]
  ),
  #monasterio reclutas chief acaba
  
  ###Holy pagan sites berkerser recruits
  #monasterio reclutas religion
  ("berserker_recruit_2troop",0,
    "There are two ulfhednar who could join to you.",
    "none", [ (set_background_mesh, "mesh_pic_extra_guerreroelite"),
    ],
    [("acept_thempa",[], "They are welcome!",
        [
          (party_add_members,"p_main_party","trp_looter_leader",2),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_paganholysites_visit"),
      ]),
      ("back_to_town_menu",[],"Head back.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_paganholysites_visit"),
      ]),
    ]
  ),
  ("berserker_recruit_troop",0,
    "There is a berserker who could join to you.",
    "none", [ (set_background_mesh, "mesh_pic_extra_guerreroelite"),
    ],
    [("acept_thempa2",[], "He is welcome!",
        [
          (party_add_members,"p_main_party","trp_sea_raider_leader",1),
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_paganholysites_visit"),
      ]),
      ("back_to_town_menu",[],"Head back.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_paganholysites_visit"),
      ]),
    ]
  ),
  ("nonberserker_avaiable_troop",0,
    "The berserkers don't want to join you.",
    "none", [ (set_background_mesh, "mesh_pic_extra_guerreros"),
    ],
    [("back_to_town_menu",[],"Head back.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_paganholysites_visit"),
      ]),
    ]
  ),
  ("nonberserker_renown_low",0,
    "You look like a beggar, hardly a leader worth following. You need more renown (>150) for berserkers to join your party.",
    "none", [ (set_background_mesh, "mesh_pic_extra_guerreros"),
    ],
    [("back_to_town_menu",[],"Head back.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_volunteer_troop_type,5),#5 days cooldown
          (jump_to_menu,"mnu_paganholysites_visit"),
      ]),
    ]
  ),
  #####
  #panel comandante chief
  (
    "panel_comandante",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Before the battle begins...",
    "none",
    [
      (set_background_mesh, "mesh_pic_post_battle_menu"),
      
    ],
    [
      ("choice_1comm",[
          
          (eq, "$g_empieza_discurso", 0),
        ],"Impassion your men with a rousing speech.",
        [
          (store_random_in_range, ":rand", 0, 16),
          (party_get_skill_level, ":lider", "p_main_party", skl_leadership),
          (try_begin),
            (eq, ":rand", 0),
            (ge, ":lider", 8),
            (jump_to_menu,"mnu_discurso_1"),
          (else_try),
            (eq, ":rand", 1),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_2"),
          (else_try),
            (eq, ":rand", 2),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_3"),
          (else_try),
            (eq, ":rand", 3),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_4"),
          (else_try),
            (eq, ":rand", 4),
            (jump_to_menu,"mnu_discurso_5"),
          (else_try),
            (eq, ":rand", 5),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_6"),
          (else_try),
            (eq, ":rand", 6),
            (jump_to_menu,"mnu_discurso_7"),
          (else_try),
            (eq, ":rand", 7),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_8"),
          (else_try),
            (eq, ":rand", 8),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_9"),
          (else_try),
            (eq, ":rand", 9),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_discurso_10"),
          (else_try),
            (eq, ":rand", 10),
            (jump_to_menu,"mnu_discurso_11"),
          (else_try),
            (eq, ":rand", 11),
            (jump_to_menu,"mnu_discurso_12"),
          (else_try),
            (jump_to_menu,"mnu_discurso_off"),
          (try_end),
        ]
      ),
      ("choice_2comm",[
          (eq, "$g_empieza_campeon", 0),
          (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_hero_party),
        ],"Call your enemy forward for a duel of honour.",
        [
          (store_random_in_range, ":rand", 0, 5),
          (party_get_skill_level, ":lider", "p_main_party", skl_leadership),
          (try_begin),
            (eq, ":rand", 0),
            (ge, ":lider", 2),
            (jump_to_menu,"mnu_lucha_1_p"),
          (else_try),
            (eq, ":rand", 1),
            (ge, ":lider", 2),
            (jump_to_menu,"mnu_lucha_1_d"),
          (else_try),
            (eq, ":rand", 2),
            (ge, ":lider", 2),
            (jump_to_menu,"mnu_lucha_2_v"),
          (else_try),
            (jump_to_menu,"mnu_lucha_2_no"),
          (try_end),
        ]
      ),
      ("choice_3comm",[
          (eq, "$g_empieza_campeon", 0),
          (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),
          (ge, ":tactics", 6),
        ],"Skirmishers: Send your men to hinder the enemy's advance.",
        [
          (assign, ":g_escaramuza_result2", 0),    #MOTO chief rewrite
          (try_begin),
            (troop_is_hero, "$g_talk_troop"),
            
            (party_get_skill_level, ":lider", "p_main_party",      skl_tactics),
            (store_skill_level, ":lider2", skl_tactics,      "$g_talk_troop"),
            (store_sub, reg0, ":lider", ":lider2"),
            
            (try_begin),
              (lt, reg0, -1),    #AI better than player?
              (assign, ":g_escaramuza_result2", 1),
            (else_try),
              (gt, reg0, 1),    #player better than AI?
              (assign, ":g_escaramuza_result2", 2),
            (try_end),
          (try_end),
          #MOTO rewrite end
          
          (store_random_in_range, ":rand", 0, 3),
          (try_begin),
            (eq, ":rand", 0),
            (eq, ":g_escaramuza_result2", 1),    #MOTO chief rewrite
            (jump_to_menu,"mnu_escaramuza_1"),
          (else_try),
            (eq, ":rand", 1),
            (eq, ":g_escaramuza_result2", 2),    #MOTO rewrite
            (jump_to_menu,"mnu_escaramuza_2"),
          (else_try),
            (eq, ":rand", 2),
            (jump_to_menu,"mnu_escaramuza_2"),
          (else_try),
            (jump_to_menu,"mnu_escaramuza_3"),
          (try_end),
        ]
      ),
      ("choice_4comm",[(le, "$g_empieza_discurso", 0),
          (eq, "$g_player_faith", 2),
        ],"Make a sacrifice to the gods.",
        [
          (store_random_in_range, ":rand", 0, 5),
          (party_get_skill_level, ":lider", "p_main_party", skl_leadership),
          (try_begin),
            (eq, ":rand", 0),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_sacrificio_1"),
          (else_try),
            (eq, ":rand", 1),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_sacrificio_2"),
          (else_try),
            (eq, ":rand", 2),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_sacrificio_3"),
          (else_try),
            (eq, ":rand", 3),
            (ge, ":lider", 4),
            (jump_to_menu,"mnu_sacrificio_4"),
          (else_try),
            (jump_to_menu,"mnu_sacrificio_off"),
          (try_end),
        ]
      ),
      ("choice_5comm",[],"Do nothing.",
        [
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  
  ###escaramuza chief
  (
    "escaramuza_1",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "{reg59?Lady:Sir}, the enemy commander overcame your tactical skills. Before we were prepared, we were surprised by enemy missile troops. They caused numerous casualties.^^Your casualties: {s8}",
    "none",
    [
      (set_background_mesh, "mesh_pic_charge"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 2),
      (call_script, "script_collect_friendly_parties"),
    ],
    [
      ("damn",[],"Damn!",
        [
          (assign, "$g_empieza_campeon", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "escaramuza_2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Our men were deployed in time and closed with the enemy, causing them heavy casualties, before returning.^^Enemy casualties: {s8}",
    "none",
    [
      (set_background_mesh, "mesh_pic_charge"),
      (call_script, "script_inflict_casualties_to_party", "$g_enemy_party", 2),
      (party_collect_attachments_to_party, "$g_enemy_party", "p_collective_enemy"),
    ],
    [
      ("defendiendo_2e",[],"Well done.",
        [
          (assign, "$g_empieza_campeon", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "escaramuza_3",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Upon approaching the enemy, our men found the enemy commander had deployed missile troops to protect his army's advance. To avoid losing men, your soldiers did not attack and returned.",
    "none",
    [(set_background_mesh, "mesh_pic_charge"),
    ],
    [
      ("defendiendo_3e",[],"Right.",
        [
          (assign, "$g_empieza_campeon", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  #lucha de campeones
  (
    "lucha_2_no",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "There seems to be no one willing to duel.",
    "none",
    [(set_background_mesh, "mesh_pic_duel_warriors"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_campeon", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "lucha_1_d",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "An enemy warrior moves towards your army and stops a stone's throw away. He takes a lamb skin filled with mead from around his neck and throws it to the ground. You see him jump to warm up his muscles. He casts aside his cloak, removes his robe and boots and stands naked, equipped only with spear and shield. " +
    "He is their champion, and he points to your army challenging your men to face him.^^" +
    "Before you can speak, a boy runs out from the ranks. He isn't a veteran or the most capable of your troops, but he's certainly brave.^^" +
    "Your warrior, your champion, advances to the enemy. They circle each other, studying each other's moves. Your warrior's nerves fail, and he gives a jab with his spear, lowering his shield. The enemy champion seizes the opportunity and swiftly plunges the blade of his spear into the heart of your warrior...^^" +
    "You have lost the duel.",
    "none",
    [
      (set_background_mesh, "mesh_pic_duel_warriors"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_campeon", 1),
          (call_script, "script_change_player_party_morale", -4),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "lucha_2_v",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One of your men breaks away from the ranks and saunters towards the enemy, then turns, pulls his coat halfway up, and shows his ass. An enemy champion runs towards him, enraged, and tosses a javelin. It is a wild shot that falls a few feet from your warrior. The enemy then draws his sword and charges with a cry.^^" +
    "Your man quickly prepares himself and stands his ground, waiting with a spear rocking in his hand. " +
    "Each champion batters the other's shield in an effort to hit home.^^" +
    "Watching closely, you observe the first blood spilled, and then the last as your champion thrusts his spear through the mouth of his opponent. After catching his breath, your champion turns around and shouts to your men: 'I was too big a mouthful!'^^" +
    "You have won the duel.",
    "none",
    [
      (set_background_mesh, "mesh_pic_duel_warriors"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_campeon", 1),
          (call_script, "script_change_player_party_morale", 4),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "lucha_1_p",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The chief of your enemies stands out in front of his army and points towards you, inviting you to a duel.",
    "none",
    [
      (set_background_mesh, "mesh_pic_duel_warriors"),
    ],
    [
      ("defendiendo_7e",[],"Accept.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (assign, "$g_empieza_campeon", 1),
          (call_script, "script_change_player_party_morale", 1),
          
          (set_jump_mission,"mt_viking_duel_normal"),
          (party_get_current_terrain, ":terrain_type", "p_main_party"),
          (try_begin),
            (this_or_next|eq, ":terrain_type", rt_steppe),
            (eq, ":terrain_type", rt_plain),
            (assign, ":scene_to_use", "scn_duel_steppe"),
          (else_try),
            (eq, ":terrain_type", rt_snow),
            (assign, ":scene_to_use", "scn_duel_snow"),
          (else_try),
            (eq, ":terrain_type", rt_forest),
            (assign, ":scene_to_use", "scn_duel_plain_forest"),
          (else_try),
            (eq, ":terrain_type", rt_snow_forest),
            (assign, ":scene_to_use", "scn_duel_snow_forest"),
          (else_try),
            #(eq, ":terrain_type", rt_desert_forest),
            (assign, ":scene_to_use", "scn_duel_steppe"),
          (try_end),

          (call_script, "script_duel_init_system", ":scene_to_use", "$g_talk_troop"),
          (assign, "$g_next_menu", -1),
          (change_screen_mission),
        ]
      ),
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_campeon", 1),
          (call_script, "script_change_player_party_morale", -10),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  #sacrificios
  (
    "sacrificio_off",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The gods remain mute to your prayers and sacrifices.",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "sacrificio_1",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The viscera of the slaughtered animals are full of worms: a bad omen.^^Maybe you should not fight today.",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", -5),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "sacrificio_2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "As you look down at the blood of the slaughtered animal, one of your men points to the horizon where an eagle takes flight with a snake in its claws. A good omen indeed.^^The time is ripe to attack the enemy.",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 10),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "sacrificio_3",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "As you thrust the sacrificial knife into the neck of the animal, it escapes from your hands and runs a few yards before collapsing, facing the enemy. It can only be a bad omen.^^Maybe you should not fight today.",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", -5),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "sacrificio_4",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Digging into the intestines of the slaughtered animal, you discover a silver pendant ring. It can only be a good omen.^^You're ready for battle.",
    "none",
    [(set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 10),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  #sacrificios acaba
  
  #discursos
  
  (
    "discurso_off",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You also step forward and try to make condescending remarks, but it's not convincing. Your nerves betray you, and you are unable to articulate a single word.",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", -4),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "discurso_1",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'When the young men and beautiful women of your village ask you where you got your battle scars, you can tell them, 'under arms in the greatest army, with the greatest general that Britannia and Hibernia have ever seen!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_cd",[],"Excelent speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 4),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'When the young men and beautiful women of your village ask you where you got your battle scars, you can tell them, 'under arms in the greatest army, with the greatest general that Britannia and Hibernia have ever seen!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_dd",[],"Normal speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_3",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'And to think that right now, across Bryten, cowards and old men are herding their goats, tending their crops, toiling and sweating for nothing! Yet here we freemen stand. Our own toil is about to begin. Our own sweat and blood are poised to run. For what? For honor! For glory! For wealth!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_ed",[],"Good speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 2),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_4",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'From all across this land we have travelled to meet our destinies on this field of battle, at this moment in time. Long after we have all expired, men will sing our names in their songs. They will sing of the greatness we shall find here in these fields!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_fd",[],"Good speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 2),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "discurso_5",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Brothers! Once you were born; later, you grew into men. Yesterday we marched; today we fight! Today we spill the blood of the host of our enemies and bring them to ruin. Today we smash their shields. All the days of your lives have led to this. Today we conquer together as brothers. Tonight we feast at the table of the enemy!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_gd",[],"Good speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 2),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "discurso_6",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Men! My brothers! Lo, we have marched these many days. Your prize yet waits! The prize, glory, comes from the groans of your enemy! Now go! Go to your destiny! Take your prize! Fight! Fight! Fight!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_7",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Friends! Hear me! Now is the day when the songs of our hearths are written with the blood of our foes! You are free men! None can assault our lands and stand to tell the tale. The host before us is great. They do not fight to defend their homes but to plunder yours. They will fall! Ready your spears! Hold fast, and never yield! No man will yield his land or his glory to the cowards in the rabble before us. Fight! Die, but never yield! Never, never, never!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_id",[],"Good speech. Back.",
        [
          (call_script, "script_change_player_party_morale", 2),
          (assign, "$g_empieza_discurso", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_8",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Men, we stand before our enemy, ready for battle. Draw your sword! Take hold of your spear! This shield wall is our home, so let us welcome our enemy! Let him come! Let the shield walls strive one against the other! All that is needed is your own arm and your own heart. Within this shield wall you shall stand, my brothers. I know that within the breast of each man here is a fire so bright that I say these walls protect our foes and not us! Our fate is glory! No man can take that unless you give it to him.'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_jd",[],"Good speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 2),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_9",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Come, men! Let us go forth and face our foe on the field of battle! With men like you, our shield wall will never break or fall to those craven dogs who come against us here! Like the heroes of old, let us go and make a slaughter, every man a hero, every man a true man! This day, we will make gluttons of the ravens!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_kd",[],"Good speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 2),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_10",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Remember your children and your wives. Remember your homes and your ancestors. Remember your gods and everything for which we fight today. We are here to build a better world! These men facing us know it, and fear our determination. They are so afraid, they piss their pants and shake like leaves, unable to hold their spears.  Men! I am with you, with my sword and my shield, bleeding and sweating, proud to stand shoulder to shoulder with such titans. Men, our fate awaits us. It's time for us to seize it!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("defendiendo_1_l",[],"Good speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 2),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  (
    "discurso_11",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them.  While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'Let us go out from this burning place into the open and stand up to our enemies. He who dies shall be with our god. He who dies not, his name will be honoured. I go first, and what I do, you do. May God be my witness, I will never leave you, my brothers and fellow knights!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
    ],
    [
      ("back",[],"Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  (
    "discurso_12",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You inspect the troops and move among them. While speaking to them, you look each man in the eye, seeking to convey the significance of the moment:^^'The sun will set on our enemy this evening, but we shall shine as the rays of the sun on a spring day. You may be nervous and trembling now, but your shaking hands are nothing compared to theirs. They are but autumn leaves in the wind; we are the howling storm that will scatter them across the meadows, never to be seen again. Brandish your spears. Be the thunder that topples their tree. This land is ours -- these woods, these hills, these fields -- and so shall it be season after season, year after year, forever and ever!'",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),	],
    [
      ("defendiendo_1_m",[],"Excellent speech. Back.",
        [
          (assign, "$g_empieza_discurso", 1),
          (call_script, "script_change_player_party_morale", 4),
          (jump_to_menu,"mnu_simple_encounter"),
        ]
      ),
    ]
  ),
  
  
  #mainquest chief menus
  (
    "doccinga_messenger",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A farmer approaches, beating a squalid mule. He stops in front of you, takes a breath and shouts,^^" +
    "'Sven Bull Neck is advancing on Doccinga with three ships! Thonkrik sent me to warn you. {s4} won't come; he has left us to luck! " +
    "I will give the news to the other jarls, but they are Danish and do not worry about Frisians. Please, we need your help. Save our people!'^^" +
    "The farmer kicks his mule and rides away from you. His desperate words, 'Save our people,' remain in your mind, an echo of distress.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (party_get_slot, ":town_lord", "p_castle_63", slot_town_lord),
      (str_store_troop_name,s4,":town_lord"),
    ],
    [
      ("choice_01mess_1",[],"Continue",
        [
          #(str_store_troop_name,s1,"trp_village_150_elder"),
          
          #     (setup_quest_text,"qst_join_faction"),
          
          ##        (str_store_troop_name_link, s3, "$g_invite_faction_lord"),
          ##        (str_store_faction_name_link, s4, "$g_invite_faction"),
          ##        (quest_set_slot, "qst_join_faction", slot_quest_giver_troop, "$g_invite_faction_lord"),
          
          (str_store_party_name_link, s3, "p_village_150"),
          (str_store_string, s2, "@{s3} is in danger. Save the village from Sven Bull Neck's assault, before the village is destroyed! You will need a good number of troops to repel the Viking attack!"),
          (call_script, "script_start_quest", "qst_doccinga_assault", "trp_village_150_elder"),
          (quest_set_slot,"qst_doccinga_assault",slot_quest_current_state, 0), #status 0
          (quest_set_slot,"qst_kennemer_mission_3",slot_quest_current_state, 3), #update
          
          (assign, "$option_switches", 0), #prepare for coming lord dialogs
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "doccinga_messenger2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
    "'Thonkrik seeks your presence in Doccinga, {playername}. He has captured a prisoner from Sven Bull Neck's Viking raiders in the recent battle.^" +
    "He thinks you'll be interested in interrogating him and requests that you go to see him as soon as you can. " +
    "Thonkrik does not know how long he can hold the prisoner before the king or jarl claims him.'",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_01mess2_1",[],"Tell Thonkrik that the message has been received.",
        [
          
          (str_store_party_name_link, s3, "p_village_150"),
          (str_store_string, s2, "@Return to {s3} and interrogate the prisoner."),
          (call_script, "script_start_quest", "qst_doccinga_interrogation", "trp_village_150_elder"),
          (quest_set_slot,"qst_doccinga_interrogation",slot_quest_current_state, 0), #status 0
          (quest_set_slot,"qst_revenge_sigurd",slot_quest_current_state, 3),
          (call_script, "script_village_set_state", "p_village_150", svs_normal), #clear raid flag
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  
  (
    "doccinga_c_assault",menu_text_color(0xFF000000)|mnf_disable_all_keys, #doccinga coastal assault
    "From a hill near Doccinga, you can see that the townspeople are fleeing. Some of the braver ones and a few of the king's men are trying to form a shield wall at the beach, ready to defend their possessions or, in the worst case, to protect their loved ones' escape.^^" +
    "Far off, in the sea, you distinguish three Viking warships. You cannot see them well from this far, but it isn't hard to imagine that they are full of warriors.^^" +
    "Your mind cannot help but return to memories of that naval battle where Sven Bull Neck attacked your ship. Now, finally, the big Viking is again within reach.^^" +
    "From Doccinga, you notice that a man leaves, running. He looks like a warrior. Noticing you, he heads towards you...",
    "none",
    [
      (set_background_mesh, "mesh_pic_escape_1"),
      
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("choice_01ass_1d",[
          #(neg|troop_is_wounded, "trp_player"),
          (assign, ":continue", 0),
          (try_begin),
            (store_party_size_wo_prisoners, ":party_size", "p_main_party"),
            (gt, ":party_size", 55),
            (assign, ":continue", 1),
            (display_message, "@Return when you have fifty-five or fewer men in your party."),
            (jump_to_menu, "mnu_noaccessallowed"),
          (try_end),
          (eq, ":continue", 0),
          
        ],"Advance to help Doccinga and meet the warrior.",
        [
          (set_spawn_radius, 0),
          #(spawn_around_party,"p_village_150","pt_doccinga_deffend"),
          (spawn_around_party,"p_main_party","pt_sven_doccinga_ca"),
          #(assign, "$sven_doccinga_ca", reg0),
          ### Phaiak begin
          # Info: giving party of Sven fitting ships
          #(assign, ":party_sven", reg0),
          (quest_set_slot, "qst_team_1_ships", slot_quest_1_ship_type, 4),
          (quest_set_slot, "qst_team_1_ships", slot_quest_1_ship_cond, 100),
          (store_random_in_range, ":sail", 0, 10),
          (call_script, "script_encode_values_to_reg0", 1, ":sail", 1, 0, 0),
          (quest_set_slot, "qst_team_1_ships", slot_quest_1_ship_prop, reg0),
          
          (quest_set_slot, "qst_team_1_ships", slot_quest_2_ship_type, 4),
          (quest_set_slot, "qst_team_1_ships", slot_quest_2_ship_cond, 90),
          (store_random_in_range, ":sail", 0, 10),
          (call_script, "script_encode_values_to_reg0", 3, ":sail", 0, 0, 0),	#Thats exactly the ship the player will get
          (quest_set_slot, "qst_team_1_ships", slot_quest_2_ship_prop, reg0),
          
          (quest_set_slot, "qst_team_1_ships", slot_quest_3_ship_type, 4),
          (quest_set_slot, "qst_team_1_ships", slot_quest_3_ship_cond, 90),
          (store_random_in_range, ":sail", 0, 10),
          (call_script, "script_encode_values_to_reg0", 2, ":sail", 0, 0, 0),
          (quest_set_slot, "qst_team_1_ships", slot_quest_3_ship_prop, reg0),
          
          (quest_set_slot, "qst_team_1_ships", slot_quest_4_ship_type, 3),
          (quest_set_slot, "qst_team_1_ships", slot_quest_4_ship_cond, 100),
          (quest_set_slot, "qst_team_1_ships", slot_quest_4_ship_prop, 1),
          ### Phaiak end
          #(change_screen_map),
          #  (jump_to_menu,"mnu_doccinga_c_assault2"),
          (party_set_ai_behavior, "pt_sven_doccinga_ca", ai_bhvr_attack_party),
          (party_set_ai_object,"pt_sven_doccinga_ca","p_main_party"),
          (change_screen_return),
          (rest_for_hours_interactive, 1, 1, 1),
          
          (quest_set_slot,"qst_doccinga_assault",slot_quest_current_state, 1), #status 1
          
      ]),
      ("choice_doccinga",[],"I need to recruit more men.", #save
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #  (start_presentation, "prsnt_auto_save")
      ]),
      
      ("encounter_save",[
        ],"I will return later. Doccinga can wait.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "doccinga_c_assaultnoche",menu_text_color(0xFF000000)|mnf_disable_all_keys, #no night quest
    "It's late at night, and your men need some rest. Come back in the morning.",
    "none",
    [ (set_background_mesh, "mesh_pic_beach"),
    ],
    [
      ("choice_01assault_3d",[],"Continue.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "noaccessallowed",menu_text_color(0xFF000000)|mnf_disable_all_keys, #no night quest
    "Having too many men in your party will cause people to fear that you plan to attack. You may wish to put some men in camp quarters for now.",
    "none",
    [ (set_background_mesh, "mesh_pic_town1"),
    ],
    [
      ("choice_01nall_3d",[],"Continue.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "doccinga_c_assault2",menu_text_color(0xFF000000)|mnf_disable_all_keys, #doccinga coastal assault
    "As you approach the village, you see the queue of refugees fleeing Doccinga. They walk loaded with all their belongings and pull heavy wagons, so they move very slowly. If you don't stop the Vikings on the beach, all the refugees will die at their swords.",
    "none",
    [
      (set_background_mesh, "mesh_pic_draco_single"),
      
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (call_script, "script_encounter_calculate_fit"),
      (try_begin),
        (eq, "$new_encounter", 1),
        # (assign, "$new_encounter", 0),	MOTO chief move to end so it can be used!
        (assign, "$g_encounter_type", 0),
        
        # (call_script, "script_let_nearby_parties_join_current_battle", 1, 0),
        #(party_quick_attach_to_current_battle, "p_hadrian_wall", 0), #attach as friend
        (party_quick_attach_to_current_battle, "p_village_150", 0), #attach as ally
        (call_script, "script_encounter_init_variables"),
        (assign, "$encountered_party_hostile", 0),
        (assign, "$encountered_party_friendly", 0),
        (try_begin),
          (gt, "$g_encountered_party_relation", 0), #chief add relation, they dont join you if no good relation.
          (assign, "$encountered_party_friendly", 1),
        (try_end),
        
        (try_begin),
          (lt, "$g_encountered_party_relation", 0),
          (assign, "$encountered_party_hostile", 1),
          (try_begin),
            (encountered_party_is_attacker),
            (assign, "$cant_leave_encounter", 1),
          (try_end),
        (try_end),
        (assign, "$talk_context", tc_party_encounter),
        (call_script, "script_setup_party_meeting", "$g_encountered_party"),
      (else_try), #second or more turn
        (try_begin),
          # We can leave battle only after some troops have been killed.
          (eq, "$cant_leave_encounter", 1),
          (call_script, "script_party_count_members_with_full_health", "p_main_party_backup"),
          (assign, ":org_total_party_counts", reg0),
          (call_script, "script_party_count_members_with_full_health", "p_encountered_party_backup"),
          (val_add, ":org_total_party_counts", reg0),
          
          (call_script, "script_party_count_members_with_full_health", "p_main_party"),
          (assign, ":cur_total_party_counts", reg0),
          (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
          (val_add, ":cur_total_party_counts", reg0),
          
          (store_sub, ":leave_encounter_limit", ":org_total_party_counts", 10),
          (lt, ":cur_total_party_counts", ":leave_encounter_limit"),
          (assign, "$cant_leave_encounter", 0),
        (try_end),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (try_end),
      
      #setup s2
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1), #battle won
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
          (le, ":num_enemy_regulars_remaining",  "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign, ":enemy_finished",1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (ge, "$g_friend_fit_for_battle",1),
          (assign, ":enemy_finished",1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished",1),
        (eq,"$g_enemy_surrenders",1),
        (assign, "$g_next_menu", -1),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        (assign, ":friends_finished",0),
        (try_begin),
          (eq, "$g_battle_result", -1),
          
          (this_or_next|eq, ":num_our_regulars_remaining", 0), #battle lost
          (le, ":num_our_regulars_remaining",  "$num_routed_us"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign,  ":friends_finished", 1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (ge, "$g_enemy_fit_for_battle",1),
          (le, "$g_friend_fit_for_battle",0),
          (assign,  ":friends_finished",1),
        (try_end),
        
        (this_or_next|eq,  ":friends_finished",1),
        (eq,"$g_player_surrenders",1),
        
        (assign, "$g_next_menu", "mnu_captivity_start_wilderness"),
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
      
      
      #chief anadidos
      #MOTO chief end
      (assign, "$new_encounter", 0),	#MOTO move to end so it can be used!
    ],
    [
      ("choice_01ent_1e",[
        ],"Enter Doccinga.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          ###chief acaba
          (set_party_battle_mode),
          (select_enemy, 1),
          (set_jump_mission,"mt_doccinga_ca"),
          (jump_to_scene, "scn_doccinga_ca"),
          (change_screen_mission),
      ]),
    ]
  ),
  
  (
    "doccinga_victory",menu_text_color(0xFF000000)|mnf_disable_all_keys, #coastal assault victory
    "Blood drips from your hand to your elbow. Around you, there is only death, and your ears are filled with the groans of the dying.^^" +
    "The Vikings, defeated, have returned to the sea, leaving behind many dead and wounded, but the cost has been very high.^^" +
    "Sven Bull Neck was not among the assailants, and that surprises you, as the boats were his. Where then is your hated enemy?^^" +
    "Thonkrik's words resonate in your mind. Perhaps it is time to pay a visit to the jarl of Kennemer. He has some explanations to give.",
    "none",
    [(play_sound, "snd_raven"),(set_background_mesh, "mesh_pic_raven"),
    ],
    [
      ("choice_01vic_1",[],"Continue",
        [
          
          (str_clear, s2),
          (str_clear, s3),
          (str_clear, s9),
          (str_store_troop_name_link, s9, "trp_knight_4_3"),
          (str_store_party_name_link, s3, "p_village_150"),
          
          (str_store_string, s2, "@You have saved {s3}. Perhaps now is a good time to ask {s9} about his involvement with Sven."),
          (add_quest_note_from_sreg, "qst_doccinga_assault", 4, s2, 0),
          (call_script, "script_troop_add_gold", "trp_player", 500),
          
          (add_xp_as_reward,500),
          (call_script, "script_change_troop_renown", "trp_player", 12),
          (call_script, "script_change_player_honor", 6),
          (call_script, "script_change_player_relation_with_faction", "fac_kingdom_4", 2),
          (call_script, "script_change_player_relation_with_center", "p_village_150", 10),
          # (call_script, "script_succeed_quest", "qst_collect_men"),
          # (quest_set_slot,"qst_doccinga_assault",slot_quest_current_state, 7), #status 1
          (call_script, "script_succeed_quest", "qst_doccinga_assault"),
          (set_show_messages, 0),
          (call_script, "script_end_quest", "qst_doccinga_assault"),
          (set_show_messages, 1),
          
          (str_clear, s2),
          (str_store_string, s2, "@{s9} did not come to the aid of {s3}. Thonkrik suspects that the jarl is in an alliance with Sven Bull Neck. Maybe it's time to talk to him, or you can go directly to the king to tell him about {s9}'s betrayal."),
          (add_quest_note_from_sreg, "qst_kennemer_mission_3", 6, s2, 0),
          (quest_set_slot,"qst_kennemer_mission_3",slot_quest_current_state, 4), #update mission kill a king Final stage
          ##        (try_begin),
          ##          (eq, "$g_encountered_party", "$sven_doccinga_ca"),
          ##          (remove_party, "$g_encountered_party"),
          ##        (try_end),
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (eq, ":template", "pt_sven_doccinga_ca"),
            (remove_party, "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "frisa_proscrito",menu_text_color(0xFF000000)|mnf_disable_all_keys, #coastal assault victory
    "The time given by the jarl of Kennemer to leave Doccinga is over. Now you are an outlaw in Friese.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_01poc_1a",[],"Continue",
        [
          (quest_set_slot,"qst_revenge_sigurd",slot_quest_current_state, 4),
          (change_screen_return),
      ]),
    ]
  ),
  ####Thiaderd mission chief
  (
    "thiaderd_muerto",menu_text_color(0xFF000000)|mnf_disable_all_keys, #
    "The fight was tough. Thiaderd's men fought like lions, but your troops managed to finish them off.^^" +
    "Thiaderd's corpse is among the bodies of his warriors. You have done your part; all that's left is to loot Thiaderd's camp, located just ahead.",
    "none",
    [(set_background_mesh, "mesh_pic_looted_village"),
    ],
    [
      ("choice_01_1ath",[],"Continue",
        [
          (quest_set_slot,"qst_kennemer_mission_2",slot_quest_current_state, 41),
          (str_store_string, s2, "@Loot Thiaderd's camp."),
          (add_quest_note_from_sreg, "qst_kennemer_mission_2", 5, s2, 0),
          (jump_to_menu, "mnu_camp_thiaderd"),
          ##                 (leave_encounter),
          ##	   (change_screen_return),
          ##                 (leave_encounter),
          ##                 (change_screen_map),
      ]),
    ]
  ),
  
  (
    "thiaderd_battle",menu_text_color(0xFF000000)|mnf_disable_all_keys, #doccinga coastal assault
    "The battle is inevitable. Thiaderd is furious upon seeing Reginhard and orders his men to attack.",
    "none",
    [
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
      (set_background_mesh, "mesh_pic_nord"),
      (assign, "$g_enemy_party", "p_thiaderd_lair"),
      (assign, "$g_ally_party", -1),
      (call_script, "script_encounter_calculate_fit"),
    ],
    [
      ("choice_01_thiaderd",[
        ],"To battle!",
        [
          
          (set_party_battle_mode),
          (set_battle_advantage, 0),
          (assign, "$g_battle_result", 0),
          (jump_to_scene, "scn_boar_grove"),
          (set_jump_mission,"mt_thiaderd_battle"),
          (assign, "$g_next_menu", "mnu_thiaderd_muerto"),
          # (jump_to_menu, "mnu_thiaderd_muerto"),
          #  (assign, "$g_mt_mode", vba_normal),
          (change_screen_mission),
          
      ]),
      ##      ("encounter_save",[
      ##          ],"Give me time to save my game.",
      ##      [
      ##        (leave_encounter),
      ##        (change_screen_return),
      ##      ]),
    ]
  ),
  
  ##########thiaderd mission chief
  (
    "camp_thiaderd",0,
    "{!}{s5}",
    "none",
    [(set_background_mesh, "mesh_pic_bandits_lair"),
      (try_begin),
        (quest_slot_eq,"qst_kennemer_mission_2",slot_quest_current_state, 41),
        (str_store_string,s5,"@Ahead, in a small camp, there are some women and children, the families of the rebels. They look scared, not knowing where to flee.^^" +
        "Among these people are the wife and son of Thiaderd. It is a difficult choice. Maybe they will seek revenge in the future, but they aren't warriors."),
      (else_try),
        (str_store_string,s5,"@A small camp stands next to a river. You see women and children between the cottages, watching warily. " +
        "A number of men, few in number but with an aggressive demeanor, come to meet you. A very tall man leads them."),
      (try_end),
    ],
    [
      ("talk_to_thiaderd",[ (check_quest_active,"qst_kennemer_mission_2"),(quest_slot_eq,"qst_kennemer_mission_2",slot_quest_current_state, 4),
        ],
        "Talk to the men.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc8"), #reginhard
          (set_visitor,17,"trp_thiaderd"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_thiaderd"),
      ]),
      
      ("kill_thiader_fam",[ (check_quest_active,"qst_kennemer_mission_2"),(quest_slot_eq,"qst_kennemer_mission_2",slot_quest_current_state, 41),
        ],
        "Kill them all and pillage and burn the camp.",[
          (quest_set_slot,"qst_kennemer_mission_2",slot_quest_current_state, 5),
          (call_script, "script_troop_add_gold", "trp_player", 800),
          (call_script, "script_change_troop_renown", "trp_player", 6),
          (call_script, "script_change_player_honor", -6),
          (call_script, "script_change_player_party_morale", -2),
          (str_store_string, s2, "@Note 2: You chose to kill Thiaderd's wife and son."),
          (add_quest_note_from_sreg, "qst_notes_frisa", 5, s2, 0),
          (assign, "$thiader_family", 1), #everybody kill
          
          ##                  (try_begin),
          ##                        (eq, "$g_encountered_party", "$thiaderd_lair"),
          ##                          (remove_party, "$g_encountered_party"),
          (disable_party, "p_thiaderd_lair"),
          (enable_party, "p_destroy1"),
          ##                (try_end),
          (str_store_string, s2, "@Thiaderd is dead. You've accomplished your mission."),
          (add_quest_note_from_sreg, "qst_kennemer_mission_2", 5, s2, 0),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("loot_thiader_fam",[ (check_quest_active,"qst_kennemer_mission_2"),(quest_slot_eq,"qst_kennemer_mission_2",slot_quest_current_state, 41),
        ],
        "Loot the lair, but spare the inhabitants.",[
          (quest_set_slot,"qst_kennemer_mission_2",slot_quest_current_state, 5),
          (call_script, "script_troop_add_gold", "trp_player", 400),
          (call_script, "script_change_troop_renown", "trp_player", 3),
          (call_script, "script_change_player_honor", -3),
          (call_script, "script_change_player_party_morale", 1),
          (str_store_string, s2, "@Note 2: You chose to respect the life of Thiaderd's wife and son."),
          (add_quest_note_from_sreg, "qst_notes_frisa", 5, s2, 0),
          
          (assign, "$thiader_family", 2), #everybody live
          
          ##                  (try_begin),
          ##                        (eq, "$g_encountered_party", "$thiaderd_lair"),
          ##                          (remove_party, "$g_encountered_party"),
          (disable_party, "p_thiaderd_lair"),
          (enable_party, "p_destroy1"),
          ##                (try_end),
          (str_store_string, s2, "@Thiaderd is dead. You've accomplished your mission."),
          (add_quest_note_from_sreg, "qst_kennemer_mission_2", 5, s2, 0),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("no_kill_thiader_f",[ (check_quest_active,"qst_kennemer_mission_2"),(quest_slot_eq,"qst_kennemer_mission_2",slot_quest_current_state, 41),
        ],
        "We are not murderers! Let them live in peace.",[
          (quest_set_slot,"qst_kennemer_mission_2",slot_quest_current_state, 5),
          (call_script, "script_change_player_honor", 6),
          
          (str_store_string, s2, "@Note 2: You chose to leave Thiaderd's wife and son alive."),
          (add_quest_note_from_sreg, "qst_notes_frisa", 5, s2, 0),
          
          ##             (assign, "$thiader_family", 2), #everybody live
          ##                 (try_begin),
          ##                     (eq, "$g_encountered_party", "$thiaderd_lair"),
          (disable_party, "p_thiaderd_lair"),
          ##                     (remove_party, "$g_encountered_party"),
          ##                 (try_end),
          (str_store_string, s2, "@Thiaderd is dead. You've accomplished your mission."),
          (add_quest_note_from_sreg, "qst_kennemer_mission_2", 5, s2, 0),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      
      ("choice_farmth",[],"I need to recruit more men.", #save
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #  (start_presentation, "prsnt_auto_save")
      ]),
      
      ("leave",[(check_quest_active,"qst_kennemer_mission_2"),(quest_slot_eq,"qst_kennemer_mission_2",slot_quest_current_state, 4),
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_return),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  ####
  
  (
    "frisa_beach",0,
    "The sea breeze caresses your face. You hear the seagulls over your head, and the smell of salt is getting stronger. In the distance, you distinguish the silhouette of a boat on a hidden beach. It is the ship that Thonkrik told you about... your ship.",
    "none",
    [(set_background_mesh, "mesh_pic_beach"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enterbea",[],"Walk down to the beach.",[
          
          (try_begin),
            (hero_can_join, "p_main_party"),
            (modify_visitors_at_site,"scn_frisa_beach"),
            (reset_visitors),
            (set_visitor, 41, "trp_npc3"), #Brunhild
            (set_visitor, 42, "trp_town_11_shipwright"), #le da el barco
            (set_visitor, 43, "trp_regular_sailors"),
            (set_visitor, 44, "trp_regular_sailors"),
            (set_visitor, 45, "trp_regular_sailors"),
            (set_visitor, 46, "trp_regular_sailors"),
            (set_visitor, 47, "trp_regular_sailors"),
            (set_jump_entry, 0),
            (set_jump_mission, "mt_frisa_beach"),
            (jump_to_scene,"scn_frisa_beach"),
            (change_screen_mission),
          (else_try),
            (display_message, "@You need room for at least one more member in your army to continue!"),
          (end_try),
      ]),
      
      ("leavebea",[],"Come back later.",[
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "sven_lair",0,
    "On the banks of a river, you distinguish a Viking fort. You've found the hideout of Sven!^" +
    "It is a good place with a small port for ships, easy to defend. Behind the wall, between the houses, you can see some warriors. You cannot count them all without being seen, but it seems there a few dozen of them in there." +
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_camp"),
      (str_clear, s4),
      (try_begin),
        (check_quest_active,"qst_sven_lair"),
        (str_store_string, s4, "@^^In the middle of the fort, you see some prisoners prepared for sale. Could your mother be among them?"),
      (try_end),
      
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
      
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (call_script, "script_encounter_calculate_fit"),
    ],
    [
      
      ("talk_to_fort_leader",[(neg|troop_is_wounded, "trp_player"),(quest_slot_eq,"qst_sven_lair",slot_quest_current_state, 2),
        ],
        "Request a meeting with the leader of the fort.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc3"),
          (set_visitor,17,"trp_leader_svenlair"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_leader_svenlair")
      ]),
      
      ("enter_to_buy_prisoners",[(neg|troop_is_wounded, "trp_player"),(quest_slot_eq,"qst_sven_lair",slot_quest_current_state, 3),
        ],
        "Enter the fort and buy the prisoners.",[
          ##           (assign, "$talk_context", tc_town_talk),
          ##           (assign, "$g_mt_mode", tcm_default),
          (modify_visitors_at_site,"scn_sven_lair_player_exterior"),
          (reset_visitors, 0),
          # (reset_visitors),
          
          (try_for_range, ":visiterator", 20, 30),
            (set_visitor, ":visiterator", "trp_taiga_bandit",),
          (try_end),
          
          (set_visitor,0,"trp_player"),
          
          (set_visitor,33,"trp_elite_viking"),
          
          (set_visitor,1,"trp_leader_svenlair"),
          
          (set_visitor,10,"trp_elite_viking"),
          (set_visitor,6,"trp_elite_viking"),
          #prisoners
          (set_visitor,16,"trp_peasant_woman"), #.
          (set_visitor,17,"trp_peasant_woman"), #.
          (set_visitor,18,"trp_bodo_falso"), #futuro companero viaja en el barco.
          
          (set_jump_mission,"mt_sven_lair_comprar"),
          (jump_to_scene,"scn_sven_lair_player_exterior"),
          (change_screen_mission),
      ]),
      ("initial_attack",[(neg|troop_is_wounded, "trp_player"),(quest_slot_eq,"qst_sven_lair",slot_quest_current_state, 2),],"Surprise attack.",[
          
          (try_begin),
            #  (encountered_party_is_attacker),
            (select_enemy, 1),
          (else_try),
            (select_enemy, 0),
          (end_try),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (set_jump_mission,"mt_sven_lair_surprise"),
          (jump_to_scene,"scn_sven_lair_land_assault"),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ("nosurprise_attack",[(neg|troop_is_wounded, "trp_player"),(check_quest_active,"qst_sven_lair"),
          (quest_get_slot, ":quest_current_state", "qst_sven_lair", slot_quest_current_state),
          (neq, ":quest_current_state", 5),
          ],"Total Assault!",[
          (try_begin),
            #  (encountered_party_is_attacker),
            (select_enemy, 1),
          (else_try),
            (select_enemy, 0),
          (end_try),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (set_jump_mission,"mt_sven_lair_normal"),
          (jump_to_scene,"scn_sven_lair_land_assault"),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ("conquestsl_attack0",[(neg|troop_is_wounded, "trp_player"),(check_quest_active,"qst_sven_lair"),
          (quest_get_slot, ":quest_current_state", "qst_sven_lair", slot_quest_current_state),
          (eq, ":quest_current_state", 5),],"Sven's men watch my army. I must return later.",[
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("conquestsl_attack",[(neg|troop_is_wounded, "trp_player"),(neg|check_quest_active,"qst_sven_lair"),],"Conquer Sven's hideout!",[
          (try_begin),
            #  (encountered_party_is_attacker),
            (select_enemy, 1),
          (else_try),
            (select_enemy, 0),
          (end_try),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (set_jump_mission,"mt_sven_lair_normal"), #diferente mission template
          (jump_to_scene,"scn_sven_lair_land_assault"),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      ("choice_fort",[],"I need to recruit more men.", #save
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #  (start_presentation, "prsnt_auto_save")
      ]),
      ##     ("choice_fort",[],"Save.", #save
      ##        [
      ##                (start_presentation, "prsnt_auto_save")
      ##        ]),
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      # ("leavesl",[],"Come back later.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  
  (
    "sven_lair_comprado",0,
    "You leave behind Sven Bull Neck's hideout. You've decided to achieve your goals through diplomacy, to prevent casualties among your men.^^" +
    "Now there's a new man in your party, an old friend, the Cantabrian, Bodo. Just outside Sven's hideout, he asks you to walk away with him. He wants to tell you what happened after Sven's attack on the Woden Ric.",
    "none",
    [(set_background_mesh, "mesh_pic_camp"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_sven_lair"),
        (quest_slot_eq,"qst_sven_lair",slot_quest_current_state, 5), #status 0
        (jump_to_menu, "mnu_sven_lair_final"),
      (try_end),
      
    ],
    [
      ("talk_to_bodo",[
        ],
        "Talk to Bodo.",[
          (add_xp_as_reward,100),
          (call_script, "script_change_player_relation_with_troop", "trp_npc6", 10),
          (call_script, "script_change_troop_renown", "trp_player", 9),
          (call_script, "script_change_player_party_morale", 2),
          (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc6"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation_scene"),
          (change_screen_map_conversation, "trp_npc6")
      ]),
    ]
  ),
  (
    "svenlair_victory",0,
    "After a tough battle, your men have defeated the Vikings protecting the hideout. In one of the houses, you find three prisoners: two women and one man. The women are unknown to you, perhaps prisoners from other Viking raids, but the man is Bodo, the Cantabrian who traveled with you aboard the Woden Ric.^^" +
    "Bodo joins your party. An old friend is back. He asks you to walk away with him. He wants to tell you what happened after Sven Bull Neck's attack on the Woden Ric. " +
    "But first, you need to decide what to do with Sven's hideout.",
    "none",
    [(set_background_mesh, "mesh_pic_duel_warriors"),
      (try_begin), #chief doccinga coastal assault mainquest
        (main_party_has_troop,"trp_npc6"),
        ##             (check_quest_active,"qst_sven_lair"),
        ##             (quest_slot_eq,"qst_sven_lair",slot_quest_current_state, 5), #status 0
        (jump_to_menu, "mnu_sven_lair_final"),
      (try_end),
    ],
    [
      ("take_itv",[(eq, "$lair_on", 0), #player dont have lair
        ],
        "It is a good place. I order my men to clean it up for me.",[
          #give lair to player
          (add_xp_as_reward,150),
          (call_script, "script_change_player_party_morale", 3),
          (call_script, "script_change_troop_renown", "trp_player", 14),
          (call_script, "script_troop_add_gold", "trp_player", 300),
          ##           (try_begin),
          ##          (eq, "$g_encountered_party", "$sven_lair_deffense"),
          ##          (remove_party, "$g_encountered_party"),
          ##        (try_end),
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (eq, ":template", "pt_sven_lair_deffense"),
            (remove_party, "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
          
          (call_script, "script_make_lair"),
          
          (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc6"),
          (troop_set_slot, "trp_npc6", slot_troop_met, 0),#bugfix to reset conversation if dialog was tabbed-out
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation_scene"),
          (change_screen_map_conversation, "trp_npc6")
      ]),
      ("destroy_itv",[
        ],
        "Bah. I order my men to pillage and destroy it.",[
          (add_xp_as_reward,200),
          (call_script, "script_change_player_party_morale", 10),
          (call_script, "script_change_troop_renown", "trp_player", 14),
          (call_script, "script_troop_add_gold", "trp_player", 3000),
          ##         (try_begin),
          ##          (eq, "$g_encountered_party", "$sven_lair_deffense"),
          ##		  (party_is_active, "$g_encountered_party"),
          ##          (remove_party, "$g_encountered_party"),
          ##        (try_end),
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (eq, ":template", "pt_sven_lair_deffense"),
            (remove_party, "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
          (enable_party, "p_destroy2"), #activa incendiada
          
          (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors),
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc6"),
          (troop_set_slot, "trp_npc6", slot_troop_met, 0),#bugfix to reset conversation if dialog was tabbed-out
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation_scene"),
          (change_screen_map_conversation, "trp_npc6")
      ]),
    ]
  ),
  
  (
    "sven_lair_final",0,
    "Fate is playing with you. First, everything was pointing to your mother's death. You were driven partly by the need to survive, but mainly by revenge: find Sven Bull Neck and kill him. But, now that your mother is still alive and in the hands of your enemies, your priority is to find and rescue her.",
    "none",
    [(play_sound, "snd_raven"),(set_background_mesh, "mesh_pic_raven"),
    ],
    [
      ("travel_sv",[
        ],
        "Go.",[
          (str_store_string, s2, "@Note 2: In Sven's hideout, you found Bodo, one of the travelers from the Woden Ric. Thanks to Bodo, you learn the fate of Woden Ric after the Viking attack. " +
          "Your mother is still alive, thanks to the item Bodo gave her, but the item made her very valuable to the Vikings."),
          (add_quest_note_from_sreg, "qst_notes_danmork", 5, s2, 0),
          (call_script, "script_change_player_party_morale", 2),
          (party_add_members, "p_main_party", "trp_peasant_woman", 2),#women viking prisoners
          #    (change_screen_notes, 4),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "svenlair_victory_conquista",0, #when taken not as part of story quest
    "After a tough battle, your men have defeated the Vikings protecting the hideout. You need to decide what to do with it.",
    "none",
    [(set_background_mesh, "mesh_pic_duel_warriors"),
    ],
    [
      ("take_itsl",[(eq, "$lair_on", 0),
        ],
        "It is a good place. I order my men to clean it up for me.",[
          #give lair to player
          (add_xp_as_reward,150),
          (call_script, "script_change_player_party_morale", 3),
          (call_script, "script_change_troop_renown", "trp_player", 14),
          (call_script, "script_troop_add_gold", "trp_player", 300),
          ##        (try_begin),
          ##          (eq, "$g_encountered_party", "$sven_lair_deffense"),
          ##          (remove_party, "$g_encountered_party"),
          ##        (try_end),
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (eq, ":template", "pt_sven_lair_deffense"),
            (remove_party, "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
          
          (call_script, "script_make_lair"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("destroy_itsl",[
        ],
        "Bah. I order my men to pillage and destroy it.",[
          (add_xp_as_reward,200),
          (call_script, "script_change_player_party_morale", 10),
          (call_script, "script_change_troop_renown", "trp_player", 14),
          (call_script, "script_troop_add_gold", "trp_player", 3000),
          ##        (try_begin),
          ##          (eq, "$g_encountered_party", "$sven_lair_deffense"),
          ##          (remove_party, "$g_encountered_party"),
          ##			    (enable_party, "p_destroy2"),
          ##        (try_end),
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (eq, ":template", "pt_sven_lair_deffense"),
            (remove_party, "$g_encountered_party"),
          (try_end),
          (enable_party, "p_destroy2"), #activa incendiada
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  
  ####prisoner exchange mision chief
  (
    "farmstead_sigurd",0,
    "A dirt road leads to a large fence, beyond which several houses have been built. It seems like a prosperous place, home to a rich man.^" +
    "From where you are, you can see some men moving around. Everything seems quiet.",
    "none", #primer menu
    [(set_background_mesh, "mesh_pic_farmstead"),
      
      (try_begin), #
        (quest_slot_eq,"qst_danmork_protection",slot_quest_current_state, 5),
        (assign, "$beda_story_1", 22),
        (jump_to_menu, "mnu_farmstead_sigurd2"),
      (try_end),
      (try_begin), #
        (quest_slot_eq,"qst_revenge_exchange",slot_quest_current_state, 4),
        (assign, "$beda_story_1", 22),
        (jump_to_menu, "mnu_farmstead_sigurd3"),
      (try_end),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enter_to_farmstead",[
          (assign, ":continue", 0),
          (try_begin),
            (store_party_size_wo_prisoners, ":party_size", "p_main_party"),
            (gt, ":party_size", 30),
            (assign, ":continue", 1),
            (display_message, "@Return when you have thirty or fewer men in your party."),
            (jump_to_menu, "mnu_noaccessallowed"),
          (try_end),
          (eq, ":continue", 0),
          #(neg|troop_is_wounded, "trp_player"),#(check_quest_active,"qst_revenge_exchange"),
          #(quest_get_slot, ":quest_current_state", "qst_sven_lair", slot_quest_current_state),
          #(neq, ":quest_current_state", 5),
        ],
        "Enter the farmstead.",[
          (modify_visitors_at_site,"scn_danish_farmstead"),
          (reset_visitors, 0),
          
          (try_for_range, ":visiterator", 30, 35),
            (set_visitor, ":visiterator", "trp_norse_slave",),
          (try_end),
          
          (set_visitor,0,"trp_player"),
          (try_begin), #
            (main_party_has_troop, "trp_npc2"),
            (set_visitor,1,"trp_npc2"),
          (try_end),
          
          (try_begin), #
            (main_party_has_troop, "trp_npc8"),
            (set_visitor,2,"trp_npc8"),
          (try_end),
          (try_begin), #
            (main_party_has_troop, "trp_npc3"),
            (set_visitor,3,"trp_npc3"),
          (try_end),
          
          (set_visitor,21,"trp_ulf_thefarmer"),
          (set_visitor,10,"trp_hija_granja"),
          
          (try_begin), #
            (eq,"$orm_the_black",1),
            (set_visitor,36,"trp_orm_robagranjas"),
          (try_end),
          (try_begin), #
            (check_quest_active, "qst_ulf_testigo"),(quest_slot_eq,"qst_ulf_testigo",slot_quest_current_state, 1),
            (set_visitor,36,"trp_orm_robagranjas"),
            (assign,"$orm_the_black",0),
          (try_end),
          # (set_visitor,16,"trp_peasant_woman"), #
          #  (set_visitor,17,"trp_peasant_woman"), #
          #  (set_visitor,18,"trp_bodo_falso"), #


          (try_begin), #finish sigurd's quest
               (check_quest_active,"qst_collect_smen"),
               (call_script, "script_end_quest", "qst_collect_smen"),
          (try_end),
 
          (set_jump_mission,"mt_farmstead_exchange"),
          (jump_to_scene,"scn_danish_farmstead"),
          (change_screen_mission),
      ]),
      ##     ("choice_farm2",[],"Save.", #save
      ##        [
      ##                (start_presentation, "prsnt_auto_save")
      ##        ]),
      ##     ("choice_farm2",[],"I need to recruit more men.", #save
      ##        [
      ##                 (leave_encounter),
      ##                 #(change_screen_map),
      ##		 (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ##             #  (start_presentation, "prsnt_auto_save")
      ##        ]),
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "farmstead_sigurd2",0,
    "It is not long before your lookouts warn you that a party of men is approaching. The tension is thick on the farm, but Egil, positioned on a hill, sends a word not to worry, because the visitors carry the banners of the king.^^" +
    "King Horik is sending reinforcements!",
    "none", #tropas del rey llegan
    [(set_background_mesh, "mesh_pic_nord"),
      (try_begin), #
        (quest_slot_eq,"qst_revenge_exchange",slot_quest_current_state, 4),
        (jump_to_menu, "mnu_farmstead_sigurd3"),
      (try_end),
    ],
    [
      ("talk_kingleader",[
        ],
        "Talk to the man who leads them.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc2"),
          (set_visitor,17,"trp_leader_svenlair"),
          (set_visitor,18,"trp_npc3"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_leader_svenlair")
      ]),
    ]
  ),
  (
    "farmstead_sigurd3",0,
    "You discover that the farm is a good place to spend a day away from the dangers and difficult decisions of the road. For a moment, you dream that the farm is yours. You cultivate the fields, direct the slaves, and have each day bettered by the following. " +
    "{s2}. You see yourself sitting on a bench at the door, watching the sunset or the dawn... Is this what you want? Or would it be too much of the same for you? " +
    "No matter, you still have many things to do before thinking of a quiet life.^" +
    "On the second day, one of your lookouts alerts you about armed men approaching. They are numerous and carry the banner of Sigurd 'Snake in the Eye.' Without having to give orders, your men pick up their weapons, put on their armor, and they run to the farm entrance to form their shield wall.",
    "none", #hay tropas del rey?
    [(set_background_mesh, "mesh_pic_nord"),
      
      (try_begin), #
        (eq, "$beda_story_1", 22),
        (assign, "$beda_story_1", 0),
        (assign, "$auto_menu", "mnu_farmstead_sigurd3"),
        (rest_for_hours, 3 * 24, 100, 0), #7 days rest while not attackable with 100x speed
        (change_screen_return),
      (try_end),
      
      (try_begin),
        (eq, "$thora_hijo", 1), #player romance and hijo
        (str_store_string, s2, "@You think of Thora, who visits you every night, a beautiful woman who could give you many children."),
      (else_try),
        (eq, "$thora_hijo", 2), #Egil y thora romance
        (str_store_string, s2, "@You think of Thora, who visits Egil every night. She is a beautiful woman protected by her father. She does not have to worry about anything other than being happy."),
      (else_try), #no romance
        (str_store_string, s2, "@You think of Thora, a beautiful woman protected by her father. She does not have to worry about anything other than being happy."),
      (try_end),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter_to_battlefs",[
        ],
        "Begin the exchange.",[
          (set_spawn_radius, 0),
          #(spawn_around_party,"p_village_150","pt_doccinga_deffend"),
          (spawn_around_party,"p_main_party","pt_sigurd_farm_men"),
          #(assign, "$sigurd_farm_men", reg0),
          (party_set_ai_behavior, "pt_sigurd_farm_men", ai_bhvr_attack_party),
          (party_set_ai_object,"pt_sigurd_farm_men","p_main_party"),
          (rest_for_hours, 1, 1, 1),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "farmstead_sigurd4",menu_text_color(0xFF000000)|mnf_disable_all_keys, #doccinga coastal assault
    "You look at the men who came. They are many, maybe more than sixty, and they're well armed. A prisoner is pushed ahead with his head covered with a sack...",
    "none",
    [
      (set_background_mesh, "mesh_pic_nord"),
      
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (call_script, "script_encounter_calculate_fit"),
      (try_begin),
        (eq, "$new_encounter", 1),
        (assign, "$g_encounter_type", 0),
        
        (call_script, "script_encounter_init_variables"),
        (assign, "$encountered_party_hostile", 0),
        (assign, "$encountered_party_friendly", 0),
        (try_begin),
          (gt, "$g_encountered_party_relation", 0), #chief add relation, they dont join you if no good relation.
          (assign, "$encountered_party_friendly", 1),
        (try_end),
        
        (try_begin),
          (lt, "$g_encountered_party_relation", 0),
          (assign, "$encountered_party_hostile", 1),
          (try_begin),
            (encountered_party_is_attacker),
            (assign, "$cant_leave_encounter", 1),
          (try_end),
        (try_end),
        (assign, "$talk_context", tc_party_encounter),
        (call_script, "script_setup_party_meeting", "$g_encountered_party"),
      (else_try), #second or more turn
        (try_begin),
          # We can leave battle only after some troops have been killed.
          (eq, "$cant_leave_encounter", 1),
          (call_script, "script_party_count_members_with_full_health", "p_main_party_backup"),
          (assign, ":org_total_party_counts", reg0),
          (call_script, "script_party_count_members_with_full_health", "p_encountered_party_backup"),
          (val_add, ":org_total_party_counts", reg0),
          
          (call_script, "script_party_count_members_with_full_health", "p_main_party"),
          (assign, ":cur_total_party_counts", reg0),
          (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
          (val_add, ":cur_total_party_counts", reg0),
          
          (store_sub, ":leave_encounter_limit", ":org_total_party_counts", 10),
          (lt, ":cur_total_party_counts", ":leave_encounter_limit"),
          (assign, "$cant_leave_encounter", 0),
        (try_end),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (try_end),
      
      #setup s2
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1), #battle won
          
          #     (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
          #    (le, ":num_enemy_regulars_remaining",  "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign, ":enemy_finished",1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (ge, "$g_friend_fit_for_battle",1),
          (assign, ":enemy_finished",1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished",1),
        (eq,"$g_enemy_surrenders",1),
        (assign, "$g_next_menu", "mnu_hablar_olvir"),
        #(assign, "$g_next_menu", -1),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        (assign, ":friends_finished",0),
        (try_begin),
          (eq, "$g_battle_result", -1),
          
          (this_or_next|eq, ":num_our_regulars_remaining", 0), #battle lost
          (le, ":num_our_regulars_remaining",  "$num_routed_us"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign,  ":friends_finished", 1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (ge, "$g_enemy_fit_for_battle",1),
          (le, "$g_friend_fit_for_battle",0),
          (assign,  ":friends_finished",1),
        (try_end),
        
        (this_or_next|eq,  ":friends_finished",1),
        (eq,"$g_player_surrenders",1),
        
        (assign, "$g_next_menu", "mnu_captivity_start_wilderness"),
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
      
      
      #chief anadidos
      #MOTO chief end
      (assign, "$new_encounter", 0),	#MOTO move to end so it can be used!
    ],
    [
      ("enter",[
        ],"Enter.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          ###chief acaba
          (set_party_battle_mode),
          (select_enemy, 1),
          (set_jump_mission,"mt_farmstead_ca"),
          (jump_to_scene, "scn_danish_farmstead"),
          #  (change_screen_mission),
          #  (assign, "$g_next_menu", "mnu_simple_encounter"),
          #(jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
          (assign, "$player_deploy_troops", 1),	#MOTO
      ]),
    ]
  ),
  (
    "hablar_olvir",0,
    "After a brutal combat, Ulf's farm is covered with corpses. Your men roam between the bodies, finishing off the wounded and taking everything that is of value. " +
    "You look at Egil, who's cutting off the finger of a dying warrior to take a golden ring; then at Brunhild, who's watching with horror all the carnage; then at Reginhard, who's laughing sitting on a corpse. " +
    "You, yourself do not know how you feel. Somebody said once that war changes people, that it is a voracious demon that devours your soul. Have you changed? Are you different?^^" +
    "Your thoughts are broken when two of your soldiers bring before you Olvir. He's still alive, but not for long. The blood gushes from his side... unstoppable.",
    "none",
    [(set_background_mesh, "mesh_pic_prisoner_wilderness"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_danmork_protection"),
        (quest_slot_eq,"qst_danmork_protection",slot_quest_current_state, 14),
        (leave_encounter),
        (change_screen_map),
      (try_end),
    ],
    [
      ("talk_to_olvir",[
        ],
        "Talk to Olvir.",[
          ##         (try_begin),
          ##          (eq, "$g_encountered_party", "$sigurd_farm_men"),
          ##          (remove_party, "$g_encountered_party"),
          ##          (try_end),
          (try_begin),
            (ge, "$g_encountered_party", 0),
            (party_is_active, "$g_encountered_party"),
            (party_get_template_id, ":template", "$g_encountered_party"),
            (eq, ":template", "pt_sigurd_farm_men"),
            (remove_party, "$g_encountered_party"),
            (assign, "$g_encountered_party", -1),
          (try_end),
          
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc8"),
          (set_visitor,17,"trp_sven_brother"),
          (set_visitor,18,"trp_npc2"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_sven_brother"),
      ]),
      
    ]
  ),
  
  ##########
  
  #### doccinga prisoner join to player chief
  (
    "doccinga_prisonerjoined",0,
    "While you travel, a man comes to your army. A few yards away, he puts down his weapons and shows his bare hands. You barely recognize him. It is the same man whom you interrogated in Doccinga, the Viking captain that you had let live.",
    "none",
    [(set_background_mesh, "mesh_pic_steppe_bandits"),
      (try_begin),
        (eq,"$doccinga_prisoner",3),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_captain",[
        ],
        "Hear what he has to say.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc8"),
          (set_visitor,17,"trp_sea_raider_leader2"),
          (set_visitor,18,"trp_npc2"),
          (assign,"$doccinga_prisoner",2),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_sea_raider_leader2"),
      ]),
      
    ]
  ),
  ########
  
  #### menu conversaciones globales directas y simples chief
  (
    "entregar_bodo",0,
    "Two of Sigurd's men follow you to Bodo, who offers no resistance when you explain the situation. While Sigurd's men lead him away, he stops before you, looking at you with teary eyes. " +
    "Brunhild and Reginhard don't seem happy with your choice.",
    "none",
    [(set_background_mesh, "mesh_pic_swad"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_revenge_exchange"),
        (quest_slot_eq,"qst_revenge_exchange",slot_quest_current_state, 3),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_bodoentregado",[
        ],
        "Talk to Bodo.",[
          
          (call_script, "script_change_player_relation_with_troop", "trp_npc3", -10),
          (call_script, "script_change_player_relation_with_troop", "trp_npc8", -10),
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"trp_npc6"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc6")
      ]),
      
    ]
  ),
  (
    "arboleda_conrey",0,
    "You follow the king to a nearby grove, away from prying eyes and ears.",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_danmork_protection"),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      
      ("talk_to_reyhorik",[
        ],
        "Talk to King Horik.",[
          (quest_set_slot,"qst_revenge_sigurd",slot_quest_current_state, 6),
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc3"),
          (set_visitor,17,"trp_kingdom_1_lord"),
          (set_visitor,18,"trp_npc6"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_kingdom_1_lord")
      ]),
      
    ]
  ),
  
  (
    "arboleda_conrey2",0,
    "You follow the king to a nearby grove, away from prying eyes and ears.",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_bodo_letter"),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      
      ("talk_to_reyhorik2",[
        ],
        "Talk to King Horik.",[
          (assign, "$arboleda_conrey", 1),
          (quest_set_slot,"qst_danmork_protection",slot_quest_current_state, 15),
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc2"),
          (set_visitor,17,"trp_kingdom_1_lord"),
          (set_visitor,18,"trp_npc3"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_kingdom_1_lord")
      ]),
      
    ]
  ),
  #encuentro hijos de Ragnar en Siege in Nothingam chief
  (
    "meeting_ragnarssons",0,
    "Several men come to meet you at the gates of Snotingaham. Though armed, they do not threaten but seem happy to see you.",
    "none",
    [(set_background_mesh, "mesh_pic_nord"),
      (try_begin),
        (check_quest_active,"qst_the_messengersn"),
        (quest_slot_eq, "qst_the_messengersn", slot_quest_current_state, 4), #active menu in siege
        (jump_to_menu, "mnu_nothingam_siege2"),
      (try_end),
    ],
    [
      
      ("talk_to_siegemen",[
        ],
        "Talk to them.",[
          (quest_set_slot, "qst_the_messengersn", slot_quest_current_state, 3), #active menu in siege
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_knight_8_13"), #Ivarr
          (set_visitor,17,"trp_kingdom_8_lord"),
          (set_visitor,18,"trp_norse_level0_companion"), #halfdan
          (set_visitor,19,"trp_knight_8_14"), #hubbi
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_kingdom_8_lord")
      ]),
      
    ]
  ),
  #####
  
  ####
  (
    "primer_barco",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You have obtained your first ship. A ship doesn't simply make it feasible for you to cross the sea. It makes you rich if you engage in trade across the sea. It makes you a feared man if you make quick raids on settlements on the coast. It makes you a ruler if you conquer foreign lands. The Norsemen say it will even bring you to the after-life.^^" +
    "However, traveling on a ship is also dangerous. The sea is like an open grave beneath the hull, awaiting you and your men. The storms of winter will harm your ships, but calm weather isn't much better, because it forces your men to row. To avoid overtaxing the crew, it is customary to stop traveling at night and to rest on land.^^" +
    "A ship is also a valuable possession. The owner should always keep an eye on it.^^Come back to this place as soon as you want to sail...",
    "none",
    [(set_background_mesh, "mesh_hacerbarco"),
    ],
    [
      ("choice_01_1bar",[],"Continue.",
        [
          #(quest_set_slot,"qst_getting_ship",slot_quest_current_state, 4),
          (call_script, "script_succeed_quest", "qst_getting_ship"),
          (set_show_messages, 0),
          (call_script, "script_end_quest", "qst_getting_ship"),
          (set_show_messages, 1),
          
          #(party_get_position, pos2, "p_frisa_beach"),
          (disable_party, "p_frisa_beach"),
          (set_spawn_radius, 0),
          (spawn_around_party, "p_main_party", "pt_landet_ships"),
          (assign, ":landet_ship_party", reg0),
          (str_store_troop_name, s1, "trp_player"),
          (party_set_name, ":landet_ship_party", "@{s1}'s Ships"),
          (party_set_slot, ":landet_ship_party", slot_party_type, spt_ship),
          #(party_set_position, ":landet_ship_party", pos2),
          (party_set_slot, ":landet_ship_party", slot_party_1_ship_type, 4), # = small warship
          (party_set_slot, ":landet_ship_party", slot_party_1_ship_quality, 80), # = bad quality
          (party_set_slot, ":landet_ship_party", slot_party_1_ship_name, "str_ship_name_1"), # = "Tranann"
          (change_screen_return),
      ]),
    ]
  ),
  ###destroy parties
  (
    "lugar_destruido",0,
    "{!}{s4}.",
    "none",
    [(set_background_mesh, "mesh_pic_looted_village"),
      (str_clear, s4),
      (try_begin),
        (eq, "$g_encountered_party", "p_destroy3"),
        (str_store_string, s4, "@One of the greatest battles known between West Seaxe and the Danes was fought here. You have memories of that day, because you took part in it."),
      (else_try),
        (str_store_string, s4, "@This place, destroyed by your men, is nothing but ash and rubble."),
      (try_end),
      
    ],
    [
      ("lugar_des",[
        ],
        "Go.",[
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  ####player lair menus chief
  ####banquete moral mead chief player lair
  (
    "banquete_moral_refuge",0,
    "Order your men to leave their weapons outside and invite them to your great hall, to sit at your table by rank. The nearest and dearest sit closest to you. " +
    "Some girls serve meat and mead in large quantities.^^You've spent a small fortune on this feast because your men deserve it. " +
    "They are the ones who bleed with you, who have helped you conquer your domains. They are your faithful followers.^^" +
    "The evening progresses. Many men are as drunk as vats. They shout and sing. Some run off to vomit and others fight like gamecocks to attract the attention of a girl. " +
    "Behind you, a bard sings of your power and deeds.^^You act like a warlord. You are a warlord... a 'shepherd of men.'",
    "none",
    [
      (set_background_mesh, "mesh_festin"),
    ],
    [
      ("banquete_okr",[],"You drink, laugh and shout as they come.",
        [
          (call_script, "script_change_player_party_morale", 10),
          (call_script, "script_change_player_honor", -3),
          (rest_for_hours, 3, 5, 0),
          (change_screen_return),
      ]),
      ("banquete_ok2r",[],"You stay sober, taste the drink, but no more than necessary.",[
          (call_script, "script_change_player_party_morale", 5),
          (rest_for_hours, 3, 5, 0),
          (change_screen_return),]),
      ("banquete_ok3r",[(store_troop_gold,":money","trp_player"),(ge,":money",2000),],"You call your men and give them rings and bracelets (2000 peningas).",[
          (call_script, "script_change_player_party_morale", 18),
          (troop_remove_gold, "trp_player", 2000),
          (rest_for_hours, 5, 5, 0), #rest while no attackable
          (change_screen_return),]),
    ],
  ),
  ####banquete moral chief acaba
  
  
  
  (
    "player_lair_menus",mnf_enable_hot_keys,
    "You are at {s10}, your very own refuge, a hidden retreat free from enemies, where you can hide when things go badly, rest from your travels, or save your most personal of treasures. " +
    "^^{s11}^^{s13}",
    "none",
    [
      (str_clear, s10),
      (str_clear, s11),
      (str_clear, s13),
      (store_encountered_party, "$current_town"),
      # ## player photo
      # (try_begin),
        # (set_fixed_point_multiplier, 100),
        # (position_set_x, pos0, 70),
        # (position_set_y, pos0, 5),
        # (position_set_z, pos0, 75),
        # (set_game_menu_tableau_mesh, "tableau_troop_note_mesh", "trp_player", pos0),
      # (try_end),
      # ## player photo
      (str_store_party_name, s10, "$current_town"),
      (party_get_num_companions, reg5 , "$g_encountered_party"),
      (call_script,"script_game_get_lair_garrison_limit","$g_encountered_party"),
      (str_store_string,s11,"@Garrison: {reg5} (limit: {reg0})^^ Having your men garrison the refuge, like for castles and cities, allows them to rest away from the dangers of road and battle and reduces their maintenance cost."),
      (set_background_mesh, "mesh_pic_thing"),
      (assign, "$talk_context", 0),
    ],
    [
      
      ("banquete_refugemead",
        [(eq, "$banquete_refuge", 0),
          (party_slot_eq, "$g_encountered_party", slot_lair_improve, 4), #max improvement need to
        ],
        "My men deserve a banquet in my refuge.",
        [
          (try_begin),
            (eq, "$hire_cook1", hire_cook1),
            (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
            (reset_visitors), #entry points
            (set_visitor,0,"trp_player"),
            (set_visitor,17,"trp_cook_lair"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation3people_scene"),
            (change_screen_map_conversation, "trp_cook_lair"),
          (else_try),
            (display_message,"@You need to hire a cook first."),
          (try_end),
        ]
      ),
      
      ("guarida_rename", [],
        "Rename your refuge.",
        [
          (start_presentation, "prsnt_set_playerlair_name")
      ]),
      
      ("lair_interior",
        [
          (party_get_slot, ":stage", "$g_encountered_party", slot_lair_improve),
          (ge, ":stage", 2),
        ],"Go to the refuge's hall.", #chief
        [
          (set_jump_mission, "mt_lair_interior"),
          
          (modify_visitors_at_site,"scn_player_hideout_house"),
          
          (reset_visitors),
          (try_begin),
            (eq, "$hire_barber1", hire_barber1),
            (set_visitor, 39, "trp_lair_barber1"),
          (try_end),
          (try_begin),
            (eq, "$hire_barber1", hire_barber2),
            (set_visitor, 39, "trp_lair_barber2"),
          (try_end),
          (try_begin),
            (eq, "$hire_barber1", hire_barber3),
            (set_visitor, 39, "trp_lair_barber3"),
          (try_end),
          (try_begin),
            (eq, "$hire_barber1", hire_barber4),
            (set_visitor, 39, "trp_lair_barber4"),
          (try_end),
          
          (try_begin),
            (eq, "$hire_cook1", hire_cook1),
            (set_visitor, 40, "trp_cook_lair"),
          (try_end),
          
          (try_begin),
            (eq, "$hire_priest1", hire_priest2),
            (set_visitor, 41, "trp_pagano_lair"),
          (try_end),
          (try_begin),
            (eq, "$hire_priest1", hire_priest1),
            (set_visitor, 41, "trp_sacerdote_lair"),
          (try_end),
          
          (try_begin),
            (eq, "$bard_type", hire_bard1),
            (set_visitor, 42, "trp_skald_lair"),
          (try_end),
          (try_begin),
            (eq, "$bard_type", hire_bard2),
            (set_visitor, 42, "trp_bardo_lair"),
          (try_end),
          
          (assign, ":cur_entry", 10),
          (try_for_range, ":companion_candidate", companions_begin, companions_end),
            
            (party_get_num_companion_stacks, ":num_stacks", "$g_encountered_party"),
            (try_for_range, ":troop_iterator", 0, ":num_stacks"),
              
              (party_stack_get_troop_id, ":cur_troop_id", "$g_encountered_party", ":troop_iterator"),
              (eq, ":companion_candidate", ":cur_troop_id"),
              #(troop_is_hero, ":cur_troop_id"),
              (set_visitor, ":companion_candidate", ":cur_entry"),
              
              (val_add, ":cur_entry", 1),
            (try_end),
          (try_end),
          
          (set_jump_entry, 0),
          #  (scene_set_slot, "scn_lair_exterior", slot_scene_visited, 1),
          (jump_to_scene,"scn_player_hideout_house"),
          (change_screen_mission),
      ], "Gate to your refuge."),
      
      ("visit_tavern_lair",
        [
          (party_get_slot, ":stage", "$g_encountered_party", slot_lair_improve),
          (ge, ":stage", 2),
        ],"Go to the mead hall.", #chief
        [
          (set_jump_mission, "mt_lair_interior"),
          (assign, "$talk_context", tc_tavern_talk),
          
          (modify_visitors_at_site,"scn_player_hideout_tavern"),
          (reset_visitors),
          (try_begin),
            (eq, "$hire_whore1", hire_whore1),
            (set_visitor, 21, "trp_quastuosa_lair1"),
          (try_end),
          (try_begin),
            (eq, "$hire_whore1", hire_whore2),
            (set_visitor, 21, "trp_quastuosa_lair2"),
          (try_end),
          (try_begin),
            (eq, "$hire_whore1", hire_whore3),
            (set_visitor, 21, "trp_quastuosa_lair3"),
          (try_end),
          (try_begin),
            (eq, "$hire_whore1", hire_whore4),
            (set_visitor, 21, "trp_quastuosa_lair4"),
          (try_end),
          
          (try_begin),
            (eq, "$hire_tavernkeeper1", hire_tavernkeeper1),
            (set_visitor, 20, "trp_town_30_tavernkeeper"),
          (try_end),
          
          (set_jump_entry, 0),
          #  (scene_set_slot, "scn_lair_exterior", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_player_hideout_tavern"),
          (change_screen_mission),
      ], "Door to the mead hall."),
      
      ("lair_buildings_improve",
        [  (eq, "$captain_ok", hire_captainok),
        ],"Talk to your captain.", #chief
        [
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"trp_lair_captain"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_lair_captain")
      ], "Gate to your refuge."),
      
      
      ("hirelair_staff",
        [
          ##		(party_get_slot, ":stage", "$g_encountered_party", slot_lair_improve),
          ##		(ge, ":stage", 1),
        ],
        "Hire staff.",
        [
          (start_presentation, "prsnt_lair_hire_staff"),
          #(jump_to_menu, "mnu_contratar_personal")
      ]),
      
      
      ("lair_inspect", [
          (try_begin),  #forbidden to enter?
            (store_time_of_day,reg(12)),
            (ge,reg(12),5),
            (lt,reg(12),21),
            (assign,":lair_nighttime",0),
          (else_try),
            (assign,":lair_nighttime",1),
            (str_store_string, s13, "@It is night, and your refuge seems quiet, with some men watching while others are asleep."),
          (try_end),
          (eq,":lair_nighttime",0),
        ],
        "Take a walk around your refuge.",
        [
          (try_begin),
            (party_slot_eq, "$g_encountered_party", slot_lair_improve, 4), #Refuge
            (assign, ":lair_scene", "scn_player_hideout_5"),
          (else_try),
            (party_slot_eq, "$g_encountered_party", slot_lair_improve, 3), #Refuge
            (assign, ":lair_scene", "scn_player_hideout_4"),
          (else_try),
            (party_slot_eq, "$g_encountered_party", slot_lair_improve, 2), #hideout
            (assign, ":lair_scene", "scn_player_hideout_3"),
          (else_try),
            (party_slot_eq, "$g_encountered_party", slot_lair_improve, 1), #hideout
            (assign, ":lair_scene", "scn_player_hideout_2"),
          (else_try),
            (assign, ":lair_scene", "scn_player_hideout_1"),#permanent camp
          (try_end),
          
          (modify_visitors_at_site,":lair_scene"),
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"),
          
          (try_begin),
            (eq, "$captain_ok", hire_captainok),
            (set_visitor, 11, "trp_lair_captain"),
          (try_end),
          
          (try_begin),
            (eq, "$hire_smith1", hire_smith1),
            (set_visitor, 12, "trp_town_30_weaponsmith"),
          (try_end),
          (try_begin),
            (eq, "$hire_armorer1", hire_armorer1),
            (set_visitor, 13, "trp_town_30_armorer"),
          (try_end),
          (try_begin),
            (eq, "$hire_trainer1", hire_trainer1),
            (set_visitor, 9, "trp_trainer_2"),
          (try_end),
          ###garrison troops
          (assign, ":party", "p_yourlair"),
          (assign,":count",18),
          
          ##           (assign, ":archer_no", 17),
          ##           (assign, ":cavalry_no", 26),
          ##          (assign, ":infantry_no", 30),
          
          (party_get_num_companion_stacks, ":num_stacks", ":party"), #1 man each troop type
          (try_for_range, ":troop_iterator", 0, ":num_stacks"),
            (party_stack_get_troop_id, ":cur_troop_id", ":party", ":troop_iterator"),
            (neg|troop_is_hero, ":cur_troop_id"),##
            (assign, ":total_valor", 0),
            (call_script, "script_count_troops_inparty", ":party", ":cur_troop_id"),
            (val_add, ":total_valor", reg0),
            
            (try_begin),
              (party_slot_eq, "$g_encountered_party", slot_lair_improve, 4), #Refuge
              (ge,":total_valor",2),
              (assign,":total_valor",2),
            (else_try),
              (party_slot_eq, "$g_encountered_party", slot_lair_improve, 3), #Refuge
              (ge,":total_valor",2),
              (assign,":total_valor",2),
            (else_try),
              (party_slot_eq, "$g_encountered_party", slot_lair_improve, 2), #hideout
              (ge,":total_valor",1),
              (assign,":total_valor",1),
            (else_try),
              (party_slot_eq, "$g_encountered_party", slot_lair_improve, 1), #hideout
              (ge,":total_valor",1),
              (assign,":total_valor",1),
            (else_try),
              (ge,":total_valor",1),
              (assign,":total_valor",1),
            (try_end),
            
            
            (try_begin),
              (le,":count",56),
              (set_visitors,":count",":cur_troop_id", ":total_valor"),
              (store_random_in_range, ":esposas", 0, 100),
              (try_begin),
                (ge,":esposas",80),
                (set_visitor, ":count", "trp_fighter_woman",1),
              (else_try),
                (ge,":esposas",30),
                (set_visitor, ":count", "trp_follower_woman",1),
              (else_try),
                (ge, ":esposas", 15),
                (set_visitor, ":count", "trp_nino_varon",1),
              (else_try),
                (set_visitor, ":count", "trp_nina_chica",1),
              (try_end),
            (try_end),
            (val_add,":count",1),
          (try_end),
          
          ##
          
          (set_jump_mission,"mt_lair_visit"),
          ##             (try_begin),
          ##               (eq, "$town_entered", 0),
          ##               (assign, "$town_entered", 1),
          ##               (eq, "$town_nighttime", 0),
          ##             (try_end),
          (set_jump_entry, 1),
          (jump_to_scene, ":lair_scene"),
          (change_screen_mission),
      ], "Go to the square."),
      
      ("mylair_station_troops",
        [
        ],
        "Manage the garrison.",
        [
          (party_get_num_companions,":companions", "$g_encountered_party"),
          (call_script,"script_game_get_lair_garrison_limit","$g_encountered_party"),
          (assign, ":limit", reg0),
          (try_begin),
            (gt, ":companions", ":limit"),
            (display_message,"@Your garrison size exceeds the maximum allowed number of soldiers that can be stationed at your refuge. This will produce discontent among men and desertions!",0xFFFF0000),
          (try_end),
          (change_screen_exchange_members,1),
          (display_message,"@Garrison limit: {reg0}",0xFFFF0000),
          (display_message,"@The ramshackle prison at your refuge is not very secure. Your captain suggests not to keep lords here!",0xFFFF0000),
          ##	     (else_try),
          ## 		(display_message,"@It is impossible to garrison more men here. All spots are occupied!",0xFFFF0000),
          ##            (try_end),
      ]),
      
      ("demoler_lair", [(eq, "$lair_on", 1),], "Demolish your personal refuge.",
        [
          (jump_to_menu, "mnu_demoler_lairm")
      ]),
      
      ("lair_wait",[],
        "Wait here for some time.",
        [
          (assign, "$auto_enter_town", "p_yourlair"),
          (assign,"$g_camp_mode", 1),
          (assign, "$g_player_icon_state", pis_camping),
          (assign, "$g_infinite_camping", 0),
          #(assign, "$g_town_visit_after_rest", 1),
          (assign, "$g_last_rest_center", "$current_town"),
          
          #(assign, "$auto_enter_town", "p_yourlair"),
          #(assign, "$g_town_visit_after_rest", 1),
          # (assign, "$g_last_rest_center", "$current_town"),
          
          (rest_for_hours_interactive, 24 * 365, 5, 1), #rest while attackable, batalla lair. Player deffend his lair.
          
          #(rest_for_hours_interactive, 24 * 365, 5, 0), #rest while not attackable
          (change_screen_return),
      ]),
      
      #VC-1878 begins
      
      ("see_ships",
        [
          (party_slot_eq, "$current_town", slot_town_port, 1),
          (party_slot_ge, "$current_town", slot_party_1_ship_type, 1),
        ],
        "See the ships.",
        [
          # (assign, "$vc_menu_active", "prsnt_vc_submenu_ships"),
          # (assign, "$ship_menu_state", 1),
          # (assign, "$current_landed_ships_party", -1),
          # (set_jump_mission,"mt_camp_on_sea"),
          # (jump_to_scene,"scn_camp_on_sea"),
          # (change_screen_mission),
          
          (assign, "$vc_menu_active", "prsnt_vc_submenu_ships"),
          (assign, "$ship_menu_state", 1),
          (set_jump_mission,"mt_town_center"),
          #(set_jump_mission,"mt_camp_on_sea"),
          (set_jump_entry, 1),
          # (party_get_slot, ":town_scene", "$current_town", slot_town_center),
          # (jump_to_scene,":town_scene"),
          (jump_to_scene, "scn_port"),
          (change_screen_mission,0),
      ]),
      
      ("embarkre",
        [
          (party_slot_eq, "$current_town", slot_town_port, 1),
          (party_slot_ge, "$current_town", slot_party_1_ship_type, 1),
        ],
        "Embark.",
        [
          (try_begin),
            (call_script, "script_cf_crew_fit_in_ships", "$current_town"),
            (assign, "$vc_menu_active", 0),
            #(assign,"$g_leave_town",1),	#?
            (call_script, "script_give_player_ships_from_party_to_party", "$current_town", "p_main_party"),
            (party_get_slot, ":curr_port", "$current_town", slot_party_port_party),
            (party_get_position, pos2, ":curr_port"),
            (party_set_position, "p_main_party", pos2),
            (call_script, "script_switch_to_water_consequences"),
            (change_screen_map),
          (else_try),
            (display_message, "str_cant_set_sail"),
          (try_end),
          
      ]),
      #VC-1878 ends
      
      ("lair_leave",[],"Leave...",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ],"Leave Area."),
  ]),
  #demoler
  ("demoler_lairm", 0, "Are you sure you want to demolish your refuge?", "none", [(set_background_mesh, "mesh_pic_thing"),],
    [
      ("demoler_yes", [
        (party_get_slot, ":stage", "$g_encountered_party", slot_lair_improve),
        (try_begin),
          (ge, ":stage", 3),
          (assign, reg1, 1000),
        (else_try),
          (assign, reg1, 500),
        (try_end),
      ], "Yes ({reg1} peningas).", [
          (store_troop_gold, ":gold_amount", "trp_player"),
          (try_begin),
            (lt, ":gold_amount", reg1),
            (display_message, "@You do not have enough money to pay men to demolish your refuge."),
          (else_try),
            (troop_remove_gold, "trp_player", reg1),
            (assign, "$g_move_heroes", 1),
            (call_script, "script_party_add_party", "p_main_party", "p_yourlair"),
            (party_clear, "p_yourlair"),
            
            #VC-3245, VC-3630
            (party_get_slot, ":port_party", "p_yourlair", slot_party_port_party),
            (try_begin),
              (gt, ":port_party", "p_spawn_points_end"),
              (party_set_flags, ":port_party", pf_no_label, 0),
              (remove_party, ":port_party"),
              (party_set_slot, "p_yourlair", slot_party_port_party, 0),
              (party_set_slot, "p_yourlair", slot_town_port, 0),
              (val_sub, "$g_number_of_map_ports", 1),
            (try_end),
            
            (try_begin),
              (neg|party_slot_eq, "p_yourlair", slot_party_player_ships_type_begin, 0),
              (party_get_position, pos1, "p_landing_point"),
              (call_script, "script_get_next_land_position", 1),
              (set_spawn_radius, 0),
              (spawn_around_party, "p_landing_point", "pt_landet_ships"),
              (assign, ":landet_ship_party", reg0),
              (str_store_troop_name, s1, "trp_player"),
              (party_set_name, ":landet_ship_party", "@{s1}'s Ships"),
              (party_set_slot, ":landet_ship_party", slot_party_type, spt_ship),
              (party_set_position, ":landet_ship_party", pos2),
              (call_script, "script_give_player_ships_from_party_to_party", "p_yourlair", ":landet_ship_party"),
            (try_end),
            
            (disable_party, "p_yourlair"),
            (display_message, "@Refuge demolished!"),
            (assign, "$lair_on", 0),
            (party_set_slot, "$g_encountered_party", slot_lair_improve, 0),
            (party_set_slot, "$current_town", slot_town_port, 0),	#VC-1878
            
            (assign, "$captain_ok", hire_captainno),
            (assign, "$hire_priest1", hire_priest3),
            (assign, "$bard_type", hire_bard3),
            (assign, "$hire_tavernkeeper1", hire_tavernkeeper2),
            (assign, "$hire_whore1", hire_whore5),
            (assign, "$hire_trainer1", hire_trainer2),
            (assign, "$hire_barber1", hire_barber5),
            (assign, "$hire_smith1", hire_smith2),
            (assign, "$hire_armorer1", hire_armorer2),
            (assign, "$hire_cook1", hire_cook2),
            ###no hired
            (assign, "$captain_hired_on", 0), # no contratado chief, hired
            (assign, "$priest_hired_on", 0), #contratado chief, hired
            (assign, "$bard_hired_on", 0), # no contratado chief, hired
            (assign, "$tavernkeeper_hired_on", 0), # no contratado chief, hired
            (assign, "$whore_hired_on", 0), #contratado chief, hired
            (assign, "$trainer_hired_on", 0), #contratado chief, hired
            
            (assign, "$smith_hired_on", 0), #contratado chief, hired
            (assign, "$armorer_hired_on", 0), #contratado chief, hired
            (assign, "$barber_hired_on", 0), #contratado chief, hired
            (assign, "$cook_hired_on", 0), #contratado chief, hired
            ###
            
            (leave_encounter),
            #(change_screen_map),
            (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          (try_end),
      ]),
      
      ("demoler_no", [], "Return.",
        [(jump_to_menu, "mnu_player_lair_menus"),
      ]),
  ]),
  ### player lair acaba chief
  ####menus open conversations con companions
  (
    "conversacion_companions1",0,
    "As you stop to rest on the way, your companions approach you, led by Brunhild. She has something to say.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin), #chief doccinga coastal assault mainquest
        (eq, "$tem", 1),
        (assign, "$tem", 0),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_brunhild",[
        ],
        "Listen to Brunhild.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc8"),
          (set_visitor,17,"trp_npc3"),
          (set_visitor,18,"trp_npc6"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc3")
      ]),
    ]
  ),
  #
  (
    "conversacion_companions2",0,
    "As you stop to rest on the way, your companions approach you. Their faces show concern.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin), #chief doccinga coastal assault mainquest
        (neg|check_quest_active,"qst_the_holmgang"),
        #  (quest_slot_eq,"qst_the_holmgang",slot_quest_current_state, 4), #status 0
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_companions2",[
        ],
        "Listen to them.",[
          (assign, "$g_encountered_party", -2),#fix for Brunhild endless loop
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19, 20,21,22,23 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc15"),
          (set_visitor,17,"trp_npc3"),
          (set_visitor,18,"trp_npc6"),
          (try_begin),
            (main_party_has_troop,"trp_npc8"),
            (troop_set_slot, "trp_npc2", slot_troop_occupation, slto_dead),
            (set_visitor,19,"trp_npc8"),
          (try_end),
          (try_begin),
            (main_party_has_troop,"trp_npc2"),
            (troop_set_slot, "trp_npc8", slot_troop_occupation, slto_dead),
            (set_visitor,20,"trp_npc2"),
          (try_end),
          
          # (set_visitor,18,"trp_npc2"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc3")
      ]),
    ]
  ),
  ###bodo choice player elige bando
  (
    "conversacion_companionsbodo_choice",0,
    "As you stop to rest on the way, your companions approach you, led by Bodo. He has something to say.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_the_alliance"),
        (assign, "$g_lord_hide", -1), #lords back to world hide lords
        (disable_party, "p_bjorn_camp"),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_bodochoice",[
        ],
        "Listen to Bodo.",[
          (assign, "$g_lord_hide", -1),
          (party_set_flags,"p_castle_9",pf_hide_defenders,0), #unhide deffenders in Snothingaham.
          
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19, 20, 21, 22, 23 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          
          (set_visitor,16,"trp_npc12"),
          (set_visitor,17,"trp_npc3"),
          
          (set_visitor,18,"trp_npc6"),
          (set_visitor,19,"trp_npc11"),
          (set_visitor,20,"trp_npc15"),
          
          (try_begin), #reginhard
            (main_party_has_troop, "trp_npc8"),
            (set_visitor,21,"trp_npc8"),
          (try_end),
          (try_begin), #egil
            (main_party_has_troop, "trp_npc2"),
            (set_visitor,22,"trp_npc2"),
          (try_end),
          
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc6")
      ]),
    ]
  ),
  ####
  #caio old roman quest
  (
    "caio_entry",0,
    "Your men have notified you that someone is here to visit you. It is a lanky boy, looking happy. Surely it is the son of the Old Roman.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin),
        (this_or_next|eq,"$g_hadrianwall_visited",2),
        (main_party_has_troop,"trp_npc1"), #Caio
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_caio",[
        ],
        "Continue.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"trp_npc1"),
          (assign, "$g_hadrianwall_visited", 2), #no more caio menu
          (troop_set_slot, "trp_npc1", slot_troop_met, 0),#bugfix to reset conversation if dialog was tabbed-out
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc1")
      ]),
    ]
  ),
  
  #egil
  (
    "egil_conversacion",0,
    "Your men have notified you that someone is coming towards you. It is a single figure, who advances without hiding and with full confidence. He is a tall man, robust and of proud bearing. When he arrives before your men, he shows open hands, so all can see that he is not armed. " +
    "He seeks you with his eyes and walks towards you. One of your men stops him with his spear...",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin), #chief doccinga coastal assault mainquest
        (main_party_has_troop,"trp_npc2"), #egil
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_egil",[
        ],
        "Continue.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc8"),
          (set_visitor,17,"trp_npc2"),
          (set_visitor,18,"trp_npc6"),
          (set_jump_mission,"mt_conversation_encounter"),
          (troop_set_slot, "trp_npc2", slot_troop_met, 0),#bugfix to reset conversation if dialog was tabbed-out
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc2")
      ]),
    ]
  ),
  #aghatinos
  (
    "aghatinos_conversacion",0,
    "On one side of the road, a man is awaiting sitting on a big rock. He is thin, tall, and is dressed in poor clothing. He seems harmless enough. " +
    "Calmly, the stranger waits until you come close to him. His eyes are searching through the faces of your men until they stop on you, then he gets up and walks to you.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin),
        (main_party_has_troop,"trp_npc15"), #aghatinos
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_aghatinos",[
        ],
        "Talk to him.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"trp_npc15"),
          (troop_set_slot, "trp_npc15", slot_troop_met, 0),#bugfix to reset conversation if dialog was tabbed-out
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc15")
      ]),
    ]
  ),
  #
  #Egil rebelion mainquest
  (
    "egil_rebelion",0,
    "It seems that something is wrong. You hear screaming and see that Egil is heading your way.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_the_alliance"),
        (quest_slot_eq,"qst_the_alliance",slot_quest_current_state, 3),
        (jump_to_menu,"mnu_egil_rebelion2"),
        (try_begin),
          (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
          (lt, ":health", 30),
          (val_add, ":health", 35),               #add to it the 5%
          (troop_set_health,   "trp_player", ":health"),   #set it
        (try_end),
      (try_end),
    ],
    [
      ("talk_to_egilreb",[
        ],
        "Listen to Egil.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19, 20, 21, 22, 23 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          
          (set_visitor,17,"trp_npc2"),
          (set_visitor,18,"trp_npc6"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_npc2")
      ]),
    ]
  ),
  (
    "egil_rebelion2",0,
    "Egil's body lies at your feet, delivered to eternal sleep. Some of your followers take his body away for burial. Egil was a beloved member of your party, and his death weighs heavily among your warriors.",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"),
          (troop_set_slot, "trp_npc2", slot_troop_occupation, slto_dead),
          (remove_member_from_party, "trp_npc2"),
          (add_xp_as_reward,100),
          (quest_set_slot,"qst_the_alliance",slot_quest_current_state, 4),
    ],
    [
      ("permitir1",[(store_troop_gold,":money","trp_player"),(ge,":money",2000),
        ],
        "Join the men who bury Egil and pay the costs of his burial.",[
          (troop_remove_gold,"trp_player",2000),
          (call_script, "script_change_player_honor", 5),
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (display_message,"@Your men think you've done an honorable thing by paying for Egil's funeral expenses, despite that he turned against you."),
          
          (str_store_string, s2, "@Note Egil: Egil turned against you when you decided to give the letter to West Seaxe. He attacked you, and you had to kill him. As he was loved by all, you decided to pay for and attend his funeral."),
          (add_quest_note_from_sreg, "qst_notes_companions", 8, s2, 0),
          (dialog_box,"@Your men think you've done an honorable thing by paying for Egil's funeral expenses, despite how he turned against you.", "@Message"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("permitir2",[
        ],
        "Allow them to bury Egil.",[
          (call_script, "script_change_player_party_morale", -15),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (dialog_box,"@Your men cry for Egil's betrayal, and they mourn his death. Many of them liked him; some would have liked him as a leader."),
          
          (str_store_string, s2, "@Note Egil: Egil turned against you when you decided to give the letter to West Seaxe. He attacked you, and you had to kill him. You let your men bury him."),
          (add_quest_note_from_sreg, "qst_notes_companions", 8, s2, 0),
          (dialog_box,"@Your men cry for Egil's betrayal, and they mourn his death. Many of them liked him; some would have liked him as a leader.", "@Message"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("permitir3",[
        ],
        "Do not allow your men to bury Egil. Leave his corpse to the crows!",[
          (call_script, "script_change_player_party_morale", -20),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_troop_renown", "trp_player", 10),
          (display_message,"@Your men cry for Egil's death, but they obey your orders. Now they think you're a tough leader who does not forgive traitors."),
          
          (str_store_string, s2, "@Note Egil: Egil turned against you when you decided to give the letter to West Seaxe. He attacked you, and you had to kill him. You didn't even let your men bury him."),
          (add_quest_note_from_sreg, "qst_notes_companions", 8, s2, 0),
          (dialog_box,"@Your men cry for Egil's death, but they obey your orders. Now they think you're a tough leader who does not forgive traitors.", "@Message"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "egil_duel",0,
    "Egil moves toward you. The men close around the two of you. It's you or him...",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_duelos"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_the_alliance"),
        (quest_slot_eq,"qst_the_alliance",slot_quest_current_state, 3),
        (jump_to_menu,"mnu_egil_rebelion2"),
      (try_end),
    ],
    [
      ("fight_egilrebdu",[
        ],
        "Fight.",[
          (quest_set_slot,"qst_the_alliance",slot_quest_current_state, 2),
          (set_jump_mission,"mt_egil_duel_death"),
          (call_script, "script_duel_init_system", "scn_duel_plain", "trp_npc2"),
          (assign, "$g_next_menu",-1),
          (change_screen_mission),
      ]),
    ]
  ),
  ########mainquest chief egil
  ####chief back from Frankia qst_douar_an_enez
  (
    "backfrom_frankia",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "{!}{s4}",
    "none",
    [
      (str_clear, s4),
      (set_background_mesh, "mesh_pic_messenger"),
      
      (str_store_string, s4, "@Shortly after landing, as if he had been watching you, a messenger appears riding towards you. You notice the dark circles under his eyes, as if he went days without sleeping, and his horse seems to be on the verge of exhaustion. " +
      "Finally, he takes a breath and exclaims:^^"),
      (try_begin),
        (eq, "$player_side", 2), #danish
        (str_store_string, s4, "@{s4}'{playername}, my jarl, Rathbarth Ragnarsson, has dispatched messengers to find you after merchants brought news that you had left Frankia for Englaland. He wants you to join his brother Halfdan in Readingum, as he is leading a final assault on West Seaxe. " +
          "We advanced from East Engle with a great army and set up a fortified camp at Readingum. We plundered the area, but Aethelred and Aelfred gathered the fyrd in Witan Ceaster and attacked us. Luckily, they were repelled.^^" +
          "Now the king of West Seaxe, assisted by his brother Aelfred, has retreated west, to Aescesdun, where they gather a huge army to fight us. Your help is needed, as Halfdan wants to go against them before they get more men. We fear that this will be the mother of all battles! If we win, West Seaxe will be ours!^^" +
        "Jarl Rathbarth told me especially to mention that Sven Bull Neck is with Aelfred and fights in his army.'"),
      (else_try),
        (eq, "$player_side", 1), #wessex
        (str_store_string, s4, "@{s4}'{playername}, my ealdorman, Aelfred Aethelwulfing, has dispatched messengers to find you after merchants brought news that you had left Frankia for Englaland. He wants you to join him as soon as possible. He is moving around the kingdom to gather an army as the Danish advance against West Seaxe.^^" +
          "They advanced from East Engle with a great army and set up a fortified camp at Readingum, from where they plundered the area. Our king, Aethelred, and Aelfred gathered the Fyrd in Witan Ceaster and attacked the Danish in Readingum, but they were repelled. " +
          "Now they are in Aescesdun gathering men and preparing to face the Danish again! God protect us, we will go against the Danish with the entire fyrd! If this fails, West Seaxe will be lost with the rest of Englaland!^^" +
        "Ealdorman Aelfred told me especially to mention that Sven Bull Neck is with Halfdan and fights in his army.'"),
      (try_end),
    ],
    [
      ("choice_01_1frankia",[],"Continue",
        [
          (str_clear, s3),
          (str_clear, s11),
          (add_xp_as_reward,200),
          (call_script, "script_end_quest", "qst_douar_an_enez"),
          
          (str_store_party_name_link, s3, "p_town_12"),
          
          (try_begin),
            (eq, "$player_side", 2), #danish
            #(str_store_party_name_link, s3, "p_town_12"),
            (str_store_troop_name_link, s11, "trp_kingdom_8_lord"),
            (str_store_string, s2, "@You have recently returned to the islands. It seems the world has gone mad. The Danish have advanced on West Seaxe and have fortified a camp at Readingum, where they have managed to defeat an attack by the Saxons. " +
              "Now, West Seaxe is gathering the fyrd in Aescesdun, calling all possible men to finish off the Danish. West Seaxe is fighting desperately for its survival. The Danish, in turn, are hastening to march against them. It seems a large battle is in the future, and Sven will be in it. " +
            "You must meet with {s11} as soon as possible in Readingum, near {s3}."),
            (call_script, "script_start_quest", "qst_aescesdun", "trp_kingdom_8_lord"),
          (else_try),
            (eq, "$player_side", 1), #wessex
            #(str_store_party_name, s3, "p_aescesdun"),
            (str_store_troop_name_link, s11, "trp_knight_5_1"),
            (str_store_string, s2, "@You have recently returned to the islands. It seems the world has gone mad. The Danish have advanced on West Seaxe and have fortified a camp at Readingum, where they have managed to defeat an attack by the Saxons. " +
              "Now, West Seaxe is gathering the fyrd in Aescesdun, calling all possible men to finish off the Danish. West Seaxe is fighting desperately for its survival. The Danish, in turn, are hastening to march against them. It seems a large battle is in the future, and Sven will be in it. " +
            "You must meet with {s11} as soon as possible in Aescesdun, near {s3}."),
            (call_script, "script_start_quest", "qst_aescesdun", "trp_knight_5_1"),
          (try_end),
          (enable_party, "p_readingum"),
          (enable_party, "p_aescesdun"),
          (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 1),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ######################
  
  ###cueva odin
  (
    "cueva_odin",0,
    "The smell of the sea is pervasive in this area, and the rumble of the waves crashing against the cliffs resonates in your head like thunder. " +
    "There is a path, very narrow at the end of a beach, where you distinguish traces of men. It is a difficult way that you can only follow on your own, so you order your people to wait behind while you investigate.",
    "none",
    [(set_background_mesh, "mesh_pic_cave"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_bodo_letter"),
        (quest_slot_eq,"qst_bodo_letter",slot_quest_current_state, 4),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
      (try_begin),
        (check_quest_active,"qst_bodo_letter"),
        (quest_slot_eq,"qst_bodo_letter",slot_quest_current_state, 3),
        (quest_set_slot,"qst_bodo_letter",slot_quest_current_state, 2),
      (try_end),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enterod",[(quest_slot_eq,"qst_bodo_letter",slot_quest_current_state, 2),
        ],"Approach.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_cueva_odin"),
          (modify_visitors_at_site,"scn_odin_cave"),
          (reset_visitors),
          (store_character_level, ":num_enemy", "trp_player"),
          
          #balance for attributes
          (store_attribute_level, reg1, "trp_player", ca_strength),
          (val_add, ":num_enemy", reg1),
          (store_attribute_level, reg1, "trp_player", ca_agility),
          (val_add, ":num_enemy", reg1),
          
          #balance for skills
          (store_skill_level, reg1, "skl_athletics", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_weapon_master", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_power_draw", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_power_throw", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_power_strike", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_ironflesh", "trp_player"),
          (val_add, ":num_enemy", reg1),
          
          (val_div, ":num_enemy", 9),
          
          (try_begin),
            (main_party_has_troop,"trp_npc6"),
            (set_visitor,1,"trp_npc6"),
            (val_add, ":num_enemy", 4),
          (try_end),
          (try_begin),
            (main_party_has_troop,"trp_npc2"),
            (troop_get_slot, ":relation", "trp_npc2", slot_troop_player_relation),
            (ge, ":relation", 1),
            (set_visitor,2,"trp_npc2"),
            (val_add, ":num_enemy", 4),
          (try_end),
          (try_begin),
            (main_party_has_troop,"trp_npc3"),
            (troop_get_slot, ":relation", "trp_npc3", slot_troop_player_relation),
            (ge, ":relation", 1),
            (set_visitor,3,"trp_npc3"),
            (val_add, ":num_enemy", 2),
          (try_end),
          (try_begin),
            (main_party_has_troop,"trp_npc8"),
            (troop_get_slot, ":relation", "trp_npc8", slot_troop_player_relation),
            (ge, ":relation", 1),
            (set_visitor,4,"trp_npc8"),
            (val_add, ":num_enemy", 4),
          (try_end),
          
          (set_visitor,6,"trp_norse_level0_landed"),
          (set_visitor,11,"trp_norse_bowman"),
          (set_visitor,14,"trp_norse_priest"),
          (set_visitor,16,"trp_atli_eiriksson"),
          
          (try_begin),
            (gt, ":num_enemy", 4),
            (set_visitor,12,"trp_norse_level0_companion"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 5),
            (set_visitor,7,"trp_norse_level0_landed"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 6),
            (set_visitor,19,"trp_norse_level1_companion"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 7),
            (set_visitor,15,"trp_norse_level1_landed"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 8),
            (set_visitor,17,"trp_norse_level2_companion"),
          (try_end),
          
          (try_begin),
            (neg|main_party_has_troop,"trp_npc6"),
            (set_visitor,21,"trp_npc6"),
          (try_end),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_odin_cave", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_odin_cave"),
          (change_screen_mission),
      ]),
      
      ("enterod2",[(neg|quest_slot_eq,"qst_bodo_letter",slot_quest_current_state, 2),(eq, "$g_odin_cave_visited", 0),
        ],"It looks like someone's den. Investigate.",
        [
          (set_jump_mission,"mt_cueva_odin"),
          (modify_visitors_at_site,"scn_odin_cave"),
          (reset_visitors),
          (store_character_level, ":num_enemy", "trp_player"),
          
          #balance for attributes
          (store_attribute_level, reg1, "trp_player", ca_strength),
          (val_add, ":num_enemy", reg1),
          (store_attribute_level, reg1, "trp_player", ca_agility),
          (val_add, ":num_enemy", reg1),
          
          #balance for skills
          (store_skill_level, reg1, "skl_athletics", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_weapon_master", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_power_draw", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_power_throw", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_power_strike", "trp_player"),
          (val_add, ":num_enemy", reg1),
          (store_skill_level, reg1, "skl_ironflesh", "trp_player"),
          (val_add, ":num_enemy", reg1),
          
          (val_div, ":num_enemy", 9),
          
          (try_begin),
            (gt,"trp_manhunter", 0),
            (assign,reg(0),"trp_slave_hunter"),
            (assign,reg(1),"trp_slave_crusher"),
            (assign,reg(2),"trp_taiga_bandit"),
            (assign,reg(3),"trp_manhunter"),
          (else_try),
            (assign,reg(0),"trp_irish_deserter"),
            (assign,reg(1),"trp_taiga_bandit"),
            (assign,reg(2),"trp_manhunter"),
            (assign,reg(3),"trp_norse_level0_companion"),
          (try_end),
          (shuffle_range,0,4),
          
          (set_visitor,17,"trp_desert_bandit_hero"),
          
          (try_begin),
            (gt, ":num_enemy", 1),
            (set_visitor,7,"trp_norse_level1_companion"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 2),
            (set_visitor,6,"trp_scotch_level1_skirmisher"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 3),
            (set_visitor,5,reg(0)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 4),
            (set_visitor,13,"trp_norse_level0_companion"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 5),
            (set_visitor,8,reg(3)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 6),
            (set_visitor,14,"trp_sea_raider"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 7),
            (set_visitor,9,reg(0)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 8),
            (set_visitor,16,"trp_sea_raider_leader2"),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 9),
            (set_visitor,10,reg(1)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 10),
            (set_visitor,18,reg(3)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 11),
            (set_visitor,11,reg(2)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 12),
            (set_visitor,19,reg(0)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 13),
            (set_visitor,12,reg(3)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 14),
            (set_visitor,20,reg(1)),
          (try_end),
          (try_begin),
            (gt, ":num_enemy", 15),
            (set_visitor,15,reg(2)),
          (try_end),
          
          (set_visitor,21,"trp_refugeeromanruins"),
          (set_visitor,22,"trp_refugeeromanruins"),
          (set_visitor,23,"trp_peasant_womanromanruins"),
          (set_visitor,24,"trp_peasant_womanromanruins"),
          (set_jump_entry, 0),
          (scene_set_slot, "scn_odin_cave", slot_scene_visited, 1),
          (assign,"$g_odin1",0),
          (assign,"$g_odin2",0),
          
          (jump_to_scene,"scn_odin_cave"),
          (change_screen_mission),
      ]),
      
      ("choice_od",[
        (neq, "$g_odin_cave_visited", 0),
        (neg|quest_slot_eq,"qst_bodo_letter",slot_quest_current_state, 2)
      ],"No one has reoccupied the cave. You shudder at the memory.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
      ("encounter_savefarmod",[
        (this_or_next|eq, "$g_odin_cave_visited", 0),
        (quest_slot_eq,"qst_bodo_letter",slot_quest_current_state, 2)
        ],"You believe you need to prepare more. Leave.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ##cueva odin acaba chief
  #duelo with Orm the black chief
  (
    "orm_duel",0,
    "You move from the farm to a clearing, where Ulf's thralls are preparing a ritual circle of stones that mark the boundary of the dueling area. Around you, all the men from the farm and your men form another circle to cheer you on.^^" +
    "In front of you, Orm the Black warms his oversized muscles. He seems confident. Perhaps, given his spotless record of wins, he can't be said to be too confident. Your companions give you pats on the back, advice and wishes for good luck. All but Reginhard, who is pessimistic and says he will record the runes on your gravestone. Suddenly, Egil points toward Orm. " +
    "The berserker has ceased to warm up his muscles. His body convulses uncontrollably, and his mouth foams white. Suddenly, he lifts his head and, looking at you with bloodshot eyes, shouts something unintelligible. He launches himself towards you like a viper, much more quickly than one would expect from such a large man...",
    "none",
    [(set_background_mesh, "mesh_pic_extra_guerreroelite"),
      ##        (try_begin), #chief doccinga coastal assault mainquest
      ##             (check_quest_active,"qst_ulf_testigo"),
      ##        (quest_slot_eq,"qst_ulf_testigo",slot_quest_current_state, 4), #status 0
      ##        (leave_encounter),
      ##                    (change_screen_map),
      ##        (try_end),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("duel_orm",[
        ],
        "Jump to the fray.",[
          
          (set_jump_mission,"mt_viking_duel_normal"),
          (call_script, "script_duel_init_system", "scn_duel_steppe", "trp_orm_robagranjas"),
          (assign, "$g_next_menu",-1),
          (change_screen_mission),
      ]),
    ]
  ),
  (
    "orm_duel_win",mnf_disable_all_keys,
    "Orm the Black's corpse lies at your feet. Your arms are sore from blocking the brutality of his attacks, and your mind keeps replaying the more desperate moments of the duel. You wonder at the fury of Orm and his apparent immunity to pain. " +
    "There's no doubt you're lucky, for you have just survived a fight with a berserker!",
    "none",
    [
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_ulf_testigo"),
        (quest_slot_eq,"qst_ulf_testigo",slot_quest_current_state, 4), #status 0
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
      (set_background_mesh, "mesh_pic_victory"),
      (call_script,"script_change_troop_renown","trp_player",25),
      (str_store_string,s2,"@You met Orm the Black in single combat and killed him."),
      (add_troop_note_from_sreg,"trp_orm_robagranjas",3,s2, 1),
    ],
    [
      ("continue",[],"Continue...",
        [
          (party_get_morale,":cur_morale","p_main_party"),
          (val_add,":cur_morale",10),
          (try_begin),
            (gt,":cur_morale",99),
            (assign,":cur_morale",99),
          (try_end),
          (party_set_morale,"p_main_party",":cur_morale"),
          (display_message,"@Your party has gained morale."),
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_npc2"),
          (set_visitor,17,"trp_ulf_thefarmer"),
          (set_visitor,18,"trp_hija_granja"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_ulf_thefarmer")
      ]),
    ]
  ),
  
  
  ####duel menus
  (
    "viking_duel_win",mnf_disable_all_keys,
    "The duel is over, and you have defeated {s1}. The skalds will talk about your victory, and the fame of your feat will spread by the word of mouth.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_guerreroelite"),
      (str_clear, s1),
      (try_begin),
        (troop_is_hero, "$g_talk_troop"),
        (str_store_troop_name,s1,"$g_talk_troop"),
        (set_background_mesh, "mesh_pic_victory"),
        (call_script,"script_change_troop_renown","$g_talk_troop",-5),
        (call_script,"script_change_troop_renown","trp_player",5),
        (call_script,"script_change_player_relation_with_troop","$g_talk_troop",-10),
        #(assign,"$duel_encounter",-1), #activar si anadimos duelos
        (str_store_string,s2,"@You met {s1} in single combat and won."),
        (add_troop_note_from_sreg,"$g_talk_troop",3,s2, 1),
      (else_try),
        (str_store_string,s1,"@This warrior"),
        (call_script,"script_change_troop_renown","trp_player",-5),
      (try_end),
    ],
    [
      ("continue",[],"Continue...",
        [
          ##           (store_current_hours,":protected_until"),
          ##			(val_add, ":protected_until", 24),
          ##			(party_set_slot,"$g_encountered_party",slot_party_ignore_player_until,":protected_until"),
          ##			(party_ignore_player, "$g_encountered_party", ":protected_until"),
          ##			(store_faction_of_party,":faction_no","$g_encountered_party"),
          ##			(call_script,"script_get_closest_walled_center_of_faction","$g_encountered_party",":faction_no"),
          ##			(assign,":ai_object",reg0),
          ##			(call_script,"script_party_set_ai_state","$g_encountered_party",spai_retreating_to_center,":ai_object"),
          (party_get_morale,":cur_morale","$g_encountered_party"),
          (val_sub,":cur_morale",20),
          (try_begin),
            (gt,":cur_morale",99),
            (assign,":cur_morale",99),
          (try_end),
          (party_set_morale,"$g_encountered_party",":cur_morale"),
          (display_message,"@The enemy party has lost morale."),
          
          
          (party_get_morale,":cur_morale","p_main_party"),
          (val_add,":cur_morale",20),
          (try_begin),
            (gt,":cur_morale",99),
            (assign,":cur_morale",99),
          (try_end),
          (party_set_morale,"p_main_party",":cur_morale"),
          (display_message,"@Your party has gained morale."),
          (str_clear,s1),
          (str_clear,s2),
          (change_screen_return),
      ]),
    ]
  ),
  (
    "viking_duel_lose",mnf_disable_all_keys,
    "{s1} was an opponent too skilled for you. You have been defeated. While {s1}'s fame will grow from the victory, thanks to the songs of the skalds, men will remember your name only as that of the beaten.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_guerreroelite"),
      (str_clear, s1),
      (try_begin),
        (troop_is_hero, "$g_talk_troop"),
        (str_store_troop_name,s1,"$g_talk_troop"),
        (troop_get_type, ":is_female", "trp_player"),
        (val_mod, ":is_female", 2),	#gender fix chief moto
        (try_begin),
          (eq, ":is_female", 1),
          (set_background_mesh, "mesh_pic_wounded_fem"),
        (else_try),
          (set_background_mesh, "mesh_pic_wounded"),
        (try_end),
        (call_script,"script_change_troop_renown","trp_player",-5),
        (call_script,"script_change_troop_renown","$g_talk_troop",5),
        (call_script,"script_change_player_relation_with_troop","$g_talk_troop",1),
        #(assign,"$duel_encounter",-1), #activar si anadimos duelos
        (str_store_string,s2,"@You met {s1} in single combat and lost."),
        (add_troop_note_from_sreg,"$g_talk_troop",3,s2, 1),
      (else_try),
        (str_store_string,s1,"@This warrior"),
        (call_script,"script_change_troop_renown","trp_player",-5),
      (try_end),
      
    ],
    [
      ("continue",[],"Continue...",
        [
          ##           (store_current_hours,":protected_until"),
          ##			(val_add, ":protected_until", 24),
          ##			(party_set_slot,"$g_encountered_party",slot_party_ignore_player_until,":protected_until"),
          ##			(party_ignore_player, "$g_encountered_party", ":protected_until"),
          ##			(store_faction_of_party,":faction_no","$g_encountered_party"),
          ##			(call_script,"script_get_closest_walled_center_of_faction","$g_encountered_party",":faction_no"),
          ##			(assign,":ai_object",reg0),
          ##			(call_script,"script_party_set_ai_state","$g_encountered_party",spai_retreating_to_center,":ai_object"),
          (party_get_morale,":cur_morale","p_main_party"),
          (val_sub,":cur_morale",20),
          (try_begin),
            (gt,":cur_morale",99),
            (assign,":cur_morale",99),
          (try_end),
          (party_set_morale,"p_main_party",":cur_morale"),
          (display_message,"@Your party has lost morale."),
          (str_clear,s1),
          (str_clear,s2),
          (change_screen_return),
      ]),
    ]
  ),
  
  ####party rebelion duel chief troop rebelion
  (
    "duel_troop_rebelion",0,
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_extra_duelos"),
      (str_clear, s4),
      (store_random_in_range, ":random_chance", 0, 100), #differents options
      (try_begin),
        (ge, ":random_chance", 70),
        (str_store_string, s4, "@The low morale of your army has led some men to conspire against you. One of your warriors committed the imprudence of talking too much while you could hear him. Feeling exposed, the warrior has insulted you publicly and has challenged you to a duel for leadership... A duel to the death."),
      (else_try),
        (ge, ":random_chance", 30),
        (str_store_string, s4, "@The problems of morale of your army have moved one of your warriors to propose himself a candidate to replace you. He has challenged you to a duel to the death..."),
      (else_try),
        (str_store_string, s4, "@Morale is so low, a warrior insults you when you go near him, accusing you of being a bad leader. Then he challenges you to a duel. The victor occupies your post."),
      (try_end),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("duel_rebelion",[
        ],
        "Accept the challenge.",[
          (party_get_current_terrain, ":terrain_type", "p_main_party"),
          (try_begin),
            (this_or_next|eq, ":terrain_type", rt_steppe),
            (eq, ":terrain_type", rt_plain),
            (assign, ":scene_to_use", "scn_duel_steppe"),
          (else_try),
            (eq, ":terrain_type", rt_snow),
            (assign, ":scene_to_use", "scn_duel_snow"),
          (else_try),
            (eq, ":terrain_type", rt_forest),
            (assign, ":scene_to_use", "scn_duel_plain_forest"),
          (else_try),
            (eq, ":terrain_type", rt_snow_forest),
            (assign, ":scene_to_use", "scn_duel_snow_forest"),
          (else_try),
            #(eq, ":terrain_type", rt_desert_forest),
            (assign, ":scene_to_use", "scn_duel_steppe"),
          (try_end),
          (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (assign, "$choose_duel_troop", reg0),
          
          (try_begin),
            (eq, reg0, -1),
            (jump_to_menu, "mnu_duel_rebelion_enemyback"),
          (else_try),
            (set_jump_mission, "mt_viking_duel_rebelion"),
            (call_script, "script_duel_init_system", ":scene_to_use", "$choose_duel_troop"),
            (assign, "$g_next_menu", -1),
            (change_screen_mission),
          (try_end),
      ]),
    ]
  ),
  
  (
    "duel_rebelion_enemyback",mnf_disable_all_keys,
    "Frightened by your fierceness, your opponent in the end refuses to face you in duel. He withdraws while your troops tease him for his cowardice.",
    "none",
    [
      (stop_all_sounds, 1),
      (set_background_mesh, "mesh_pic_victory"),
    ],
    [
      ("continue",[],"Continue...",
        [
          (call_script, "script_change_player_party_morale", 5),
          
          (assign, "$choose_duel_troop", 0),
          (str_clear,s1),
          (str_clear,s2),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "duel_rebelion_win",mnf_disable_all_keys,
    "The duel is over. Your enemy lies on the ground, defeated by your skill with weapons. You hope that this serves as a warning to other potential rivals. Now your mission is to restore confidence and improve your army's morale.",
    "none",
    [
      (stop_all_sounds, 1),	#VC-2127
      (set_background_mesh, "mesh_pic_victory"),
      (call_script,"script_change_troop_renown","trp_player",2),
      #(assign,"$duel_encounter",-1), #activar si anadimos duelos
    ],
    [
      ("continue",[],"Continue...",
        [
          (call_script, "script_change_player_party_morale", 5),
          
          (assign, "$choose_duel_troop", 0),
          (str_clear,s1),
          (str_clear,s2),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ####
  ####The thing
  (
    "thething_messenger",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A messenger approaches, beating his horse. He stops in front of you, takes a breath and shouts,^^" +
    "'My King, Horik of Danmark, invites you to the Assembly being held near Ribe. Since it is going to be about your complaint with Sven Bull Neck and Sigurd Ragnarsson, you must go soon, or the judgment of the Assembly will go against you.'^^" +
    "The messenger then kicks his mount and rides away.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_01_1thing",[],"Continue",
        [
          (str_store_party_name_link, s3, "p_town_4"),
          (str_store_string, s2, "@The Assembly has taken up your case. You must quickly go to the assembly near {s3}, lest they decide against you."),
          (add_quest_note_from_sreg, "qst_the_thing", 5, s2, 0),
          (quest_set_slot,"qst_the_thing",slot_quest_current_state, 2),
          (enable_party, "p_the_thing"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###
  ###duelo
  (
    "the_holmgang",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A group of heavily armed men approaches you. It is led by Harald Haraldsson, king's right hand, who reminds you of your promise at the Assembly. " +
    "It is the hour of the holmgang and your opponent is already on Short Island. They surround your party and lead you to a nearby beach, where a gaunt old man waits in a small boat. " +
    "You get in the boat, and two of Harald's men push it into the water. The old man, without a word to you, begins paddling toward an island on the horizon.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_01_1duelhom",[],"Continue.",
        [
          (jump_to_menu, "mnu_the_holmgang2"),
      ]),
    ]
  ),
  (
    "the_holmgang2",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The water is gentle. The only sound you hear is that of the oars on the water, striking in a slow and deliberate rhythm. The old man is not so old, but wrinkles of a hard life at sea make him look like an elder. " +
    "He wears a worn and salt-bleached tunic, and the skin of his hands look like hard leather. His eyes are blue and crystal clear and do not look directly at you even for a moment, but remain focused on the island. " +
    "Up ahead awaits an opponent who once was a companion. The Assembly has decided that two go to Short Island, but only one return. " +
    "The boat stops near a small beach, and after you get off, the old man paddles it a few tens of meters back into the ocean, where he stops and waits.",
    "none",
    [
      (set_background_mesh, "mesh_pic_small_island"),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("choice_01_2duelhom",[],"Duel.",
        [
          (set_jump_mission,"mt_the_holmgang"),
          (assign, ":scene_to_use", "scn_holmgang"),
          (modify_visitors_at_site,":scene_to_use"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (try_begin),
            (quest_slot_eq,"qst_the_holmgang",slot_quest_current_state, 1), #Reginhard enemy
            (set_visitor, 4, "trp_npc8"),
          (try_end),
          (try_begin),
            (quest_slot_eq,"qst_the_holmgang",slot_quest_current_state, 2), #Egil enemy
            (set_visitor, 4, "trp_npc2"),
          (try_end),
          
          
          (jump_to_scene,":scene_to_use"),
          #(assign, "$g_next_menu",-1),
          (change_screen_mission),
      ]),
    ]
  ),
  (
    "the_holmgang3",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "'Two went to the island, but only one returns.'^^You have been victorious, but at the cost of killing an old companion. In your mind, you remember the phrase that you heard so often from Reginhard: Gaed a wyrd swa hio scel! Fate always goes as she must!^^" +
    "The old man takes the boat back to where your warriors await in Danmark. When you arrive, they pick up their things and say nothing, aware of the gravity of the moment. Soon they are ready to go. " +
    "Harald and his men have already left. It's time to look for the Assembly judge called Asbjorn in the mead hall of Ribe.",
    "none",
    [
      (set_background_mesh, "mesh_pic_small_island"),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("choice_01_3duelhom",[],"Travel.",
        [
          
          (try_begin),
            (quest_slot_eq,"qst_the_holmgang",slot_quest_current_state, 1), #Reginhard enemy
            (str_store_string, s2, "@Note Reginhard: Reginhard betrayed you before the Assembly, and you had to kill him in a holmgang decreed by the Assembly."),
            (add_quest_note_from_sreg, "qst_notes_companions", 7, s2, 0),
          (try_end),
          (try_begin),
            (quest_slot_eq,"qst_the_holmgang",slot_quest_current_state, 2), #Egil enemy
            (str_store_string, s2, "@Note Egil: Reginhard betrayed you before the Assembly, but you forgave him. However, Egil did not accept your decision, and you had to kill him in a holmgang by the laws of the Assembly."),
            (add_quest_note_from_sreg, "qst_notes_companions", 7, s2, 0),
          (try_end),
          (str_store_party_name_link, s3, "p_town_4"),
          (str_store_string, s2, "@The holmgang is over. It's time to meet Asbjorn in {s3}."),
          (add_quest_note_from_sreg, "qst_the_fleet", 4, s2, 0),
          (quest_set_slot,"qst_the_fleet",slot_quest_current_state, 2), # asbjorn  esta en taberna
          
          (quest_set_slot,"qst_the_holmgang",slot_quest_current_state, 3),
          (add_xp_as_reward,100),
          (call_script, "script_succeed_quest", "qst_the_holmgang"),
          #   (call_script, "script_end_quest", "qst_the_holmgang"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###
  (
    "the_thing",0,
    "In a setting reminiscent of times past, when men lifted huge rocks to venerate their dead or glorify their gods, meets the Assembly. " +
    "As you approach, you hear more clearly hundreds of voices, distinguish the tents, and smell the food from the merchant stands. The Assembly, or the Thing, is not just a meeting where issues are discussed and judgments are made but also an event where people around go to exchange news or sell their products.",
    "none",
    [(set_background_mesh, "mesh_pic_thing"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("enter_thing",[(check_quest_active,"qst_the_thing"),(quest_slot_eq,"qst_the_thing",slot_quest_current_state, 2), #puede entrar al thing. Ha sido invitado.
        ],"Approach.",
        [
          (set_jump_mission,"mt_the_thing"),
          (modify_visitors_at_site,"scn_the_thing"),
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"),
          #sven, sigurd y bodyguards
          (set_visitor,38,"trp_sven_bull_neck"), #sven
          (set_visitor,7,"trp_knight_1_5"), #sigurd
          (set_visitor,8,"trp_knight_1_1"),
          (set_visitor,9,"trp_norse_priest"),
          
          #king horik, Egil, player, portaestandarte
          (set_visitor,22,"trp_norse_standard_bearer"),
          (set_visitor,23,"trp_npc2"), #Egil, hace de intermediario ante el rey y camina hacia player y luego le lleva ante el rey
          #cuando este cerca de rey le pregunta por que llega tarde
          (set_visitor,24,"trp_kingdom_1_lord"),
          (set_visitor,25,"trp_leader_svenlair"),
          #jueces
          (set_visitor,1,"trp_paganop_1"),
          (set_visitor,2,"trp_town_4_mayor"),
          (set_visitor,3,"trp_village_98_elder"),
          (set_visitor,4,"trp_village_99_elder"),
          (set_visitor,5,"trp_npc12"), #asbjorn, medico, juez
          
          (set_visitor,10,"trp_knight_1_2"),
          (set_visitor,11,"trp_norse_level2_companion"),
          (set_visitor,12,"trp_norse_level2_companion"),
          (set_visitor,13,"trp_knight_1_4"),
          (set_visitor,14,"trp_town_4_armorer"), #mercader
          (set_visitor,15,"trp_town_4_weaponsmith"), #mercader
          (set_visitor,16,"trp_npc8"), #Reginhard
          (set_visitor,17,"trp_village_walker_1"), #caminante
          (set_visitor,18,"trp_village_walker_1"), #caminante
          (set_visitor,19,"trp_village_walker_1"), #caminante
          (set_visitor,20,"trp_norse_level2_companion"),
          (set_visitor,21,"trp_norse_level0_landed"),
          (set_visitor,26,"trp_knight_1_6"),
          (set_visitor,27,"trp_norse_level0_landed"),
          (set_visitor,28,"trp_knight_1_3"),
          (set_visitor,29,"trp_town_4_tavernkeeper"), #mercader
          (set_visitor,30,"trp_town_4_merchant"), #mercader
          (set_visitor,31,"trp_village_walker_1"), #caminante
          (set_visitor,32,"trp_norse_level0_landed"),
          (set_visitor,33,"trp_norse_level2_companion"),
          (set_visitor,34,"trp_norse_level2_companion"),
          (set_visitor,35,"trp_norse_level2_companion"),
          (set_visitor,36,"trp_npc6"), #bodo
          
          #(set_jump_entry, 0),
          (scene_set_slot, "scn_the_thing", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_the_thing"),
          (change_screen_mission),
      ]),
      
      ##            ("enter_thething2",[(neg|check_quest_active,"qst_the_thing"),
      ##                ],"Investigate.",
      ##             [
      ##                  (set_jump_mission,"mt_the_thing"),
      ##                  (modify_visitors_at_site,"scn_the_thing"),
      ##                 (reset_visitors, 0),
      ##                 (set_visitor,0,"trp_player"),
      ##	  (set_visitor,14,"trp_town_4_armorer"), #mercader
      ##	  (set_visitor,15,"trp_town_4_weaponsmith"), #mercader
      ##	  (set_visitor,17,"trp_village_walker_1"), #caminante
      ##	  (set_visitor,18,"trp_village_walker_1"), #caminante
      ##	  (set_visitor,19,"trp_village_walker_1"), #caminante
      ##	  (set_visitor,29,"trp_town_4_tavernkeeper"), #mercader
      ##	  (set_visitor,30,"trp_town_4_merchant"), #mercader
      ##	  (set_visitor,31,"trp_village_walker_1"), #caminante
      ##	  (scene_set_slot, "scn_the_thing", slot_scene_visited, 1),
      ##
      ##                 (jump_to_scene,"scn_the_thing"),
      ##               (change_screen_mission),
      ##               ]),
      
      ##     ("choice_thing",[],"Save.", #save
      ##        [
      ##                (start_presentation, "prsnt_auto_save")
      ##        ]),
      ("leave",[#(neg|check_quest_active,"qst_the_thing"),
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  #######
  ###partida fleet chief
  (
    "partida_ribe_fleet",menu_text_color(0xFF000000)|mnf_disable_all_keys, #wait until beda presentation chief
    "Since your arrival, there has been a great hubbub in the port of Ribe. Eight hundred Vikings and their captains have been boarding their ships in order of arrival, while slaves load baggage, supplies, and even animals. Most of the ships are the Knorr type, cargo ships, but there are also a good two dozen warships.^^" +
    "You spend nights on your ship, while during the day you help as you can. Your warriors kill time enjoying the hospitality of the neighbors and happy widows. " +
    "You have had no chance to get close to Sven Bull Neck or, rather, to his ship, but you hear that he and Harald, the two people in charge of the fleet, have been arguing over all types of stupid things. " +
    "Some of Harald's men have even been stabbed in the streets.^^" +
    "Finally, after everyone has prepared for the long journey, the fleet rows out of Ribe to follow the Whale Route, leaving Danmark behind.",
    "none",
    [(set_background_mesh, "mesh_pic_fleet"),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
      
      (assign, "$g_leave_encounter",1),
    ],
    [
      ("choice_01_3dfl",[],"Join the expedition.",
        [
          
          #(quest_set_slot,"qst_the_fleet",slot_quest_current_state, 41),
          #(assign, "$beda_story_1", 19), #beda story will take 5 or 6 cap only, np here
          
          (assign, "$phaiak_quest_helper", 1),
          (jump_to_menu, "mnu_partida_ribe_fleet2"),
          (play_track, "track_epic_music", 2), # Now d-day scene
          (assign, "$d_day_ships", 70),
          (select_enemy, 0),
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_d_day"),
          (jump_to_scene,"scn_d_day"),
          (change_screen_mission),
      ]),
    ]
  ),
  (
    "partida_ribe_fleet2",menu_text_color(0xFF000000)|mnf_disable_all_keys, #wait until beda presentation chief
    "By now, the differences between Sven Bull Neck, protected by Jarl Sigurd, and Harald Haraldsson, protected by King Horik, are so clear that the fleet progresses divided in two, depending on who supports which commander.^^" +
    "But it's not the time for worry. The sea brings wind and the freedom of the waves, and your ship is heading for Englaland where rivers carry silver and men get fame. And now you're closer than ever to Sven Bull Neck. You just wait for your chance to kill him and rescue your mother... " +
    "Fate always rewards the patient.",
    "none",
    [(set_background_mesh, "mesh_pic_fleet"),
      
      (try_begin),
        (eq, "$phaiak_quest_helper", 1),
        (assign, "$phaiak_quest_helper", 2),
        # prepare sea travel
        (party_get_position, pos1, "p_monasterio11"),
        (call_script, "script_get_next_water_position", 10),
        (party_set_slot, "p_the_fleet", slot_party_on_water, 1),
        (party_set_flags, "p_the_fleet", pf_is_static, 0),
        (party_set_ai_behavior, "p_the_fleet", ai_bhvr_travel_to_point),
        (party_set_ai_target_position, "p_the_fleet", pos2),
        # SEA TRAVEL (Day 1)
        (assign, "$auto_menu", "mnu_partida_ribe_fleet2"),
        (party_get_position, pos1, "p_the_fleet"),
        (party_set_position, "p_main_party", pos1),
        (rest_for_hours, 1 * 24, 0, 0),
        (set_camera_follow_party, "p_the_fleet"),
        (assign, "$g_player_is_captive", 1),
        (change_screen_return),
      (else_try),
        (eq, "$phaiak_quest_helper", 2),
        (assign, "$phaiak_quest_helper", 3),
        (start_presentation, "prsnt_beda_story_3"),
        # So after presentation next day of travel starts...
      (else_try),
        (eq, "$phaiak_quest_helper", 3),
        (assign, "$phaiak_quest_helper", 4),
        # SEA TRAVEL (Day 2)
        (assign, "$auto_menu", "mnu_partida_ribe_fleet2"),
        (party_get_position, pos1, "p_the_fleet"),
        (party_set_position, "p_main_party", pos1),
        (rest_for_hours, 1 * 24, 0, 0),
        (set_camera_follow_party, "p_the_fleet"),
        (assign, "$g_player_is_captive", 1),
        (change_screen_return),
      (end_try),
      
      
      # (try_begin),#no batalla de noche
      # (eq, "$beda_story_1", 19),
      # (assign, "$beda_story_1", 0),
      # (assign, "$auto_menu", "mnu_partida_ribe_fleet2"),
      # (rest_for_hours, 7 * 24, 100, 0), #7 days rest while not attackable with 100x speed
      # (try_end),
      
      # (try_begin), #no batalla de noche
      # (eq, "$beda_story_1", 20),
      # (assign, "$beda_story_1", 0),
      # (jump_to_menu, "mnu_sven_attack_fleet"),
      # (try_end),
      
      # (try_begin), #no batalla de noche
      # (eq, "$beda_story_1", 3),
      # (assign, "$beda_story_1", 20),
      
      # (start_presentation, "prsnt_beda_story_3"),
      # (try_end),
    ],
    [
      ("choice_02_3dfl",[],"Continue to Englaland.",
        [
          # SEA TRAVEL (Day 3)
          (assign, "$auto_menu", "mnu_sven_attack_fleet"),
          (party_get_position, pos1, "p_the_fleet"),
          (party_set_position, "p_main_party", pos1),
          (rest_for_hours, 1 * 24, 0, 0),
          (set_camera_follow_party, "p_the_fleet"),
          (assign, "$g_player_is_captive", 1),
          (change_screen_return),
      ]),
    ]
  ),
  (
    "sven_attack_fleet",menu_text_color(0xFF000000)|mnf_disable_all_keys, #wait until beda presentation chief
    "The journey from Ribe to Eoferwic or, as the Danish call it, Jorvik is three days with good weather, but with the slower knorrs, the trip will take a day or two more. The ships have spread out, but this is usual. When traveling with sail, the winds govern at will. The ships will reunite at their destination.^^" +
    "A long trip like this requires a routine. Men take turns in the work of the boat, even at night, because the fleet never stops offshore. The smell of the crowded men is horrible, the water you drink and food you eat taste terrible, and it is always uncomfortable having to peer over the stern when you want to relieve yourself.^^" +
    "Eventually, the rift between Harald and Sven becomes open. Each now meets separately with the captains who are faithful to him. Each part of the fleet proceeds separately. Harald has called you and the other captains to his boat for an emergency meeting. Apparently, one of the captains faithful to Sven Bull Neck has changed his allegiance to Harald and brings news.^^" +
    "You look forward to the meeting as well. Maybe there is finally news of your mother.",
    "none",
    [(set_background_mesh, "mesh_pic_fleet"),
      (set_camera_follow_party, "p_main_party"),
      (assign, "$g_player_is_captive", 0),
      
      (try_begin),
        (quest_slot_eq,"qst_sven_traitor",slot_quest_current_state, 1),
        (quest_slot_eq,"qst_the_fleet",slot_quest_current_state, 5),
        (party_clear, "$g_encountered_party"),
        (select_enemy, 0),
        (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
        (set_jump_mission,"mt_svenattack_thefleet"),
        (jump_to_scene,"scn_sea_battle_mainquest_fleet"),
        (change_screen_mission),
      (end_try),
    ],
    [
      ("choice_mettingcap",[],"Captains' meeting.",
        [
          #saltar a escena reunion con capitanes, ataque de svene. PLayer preguntara por su madre y descubrira que es la esposa de sven y su seird. Player debe huir ante ataque.
          
          (modify_visitors_at_site,"scn_mainquest_fleet"),
          (reset_visitors),
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_leader_svenlair"),		 #harald
          (set_visitor,17,"trp_sea_raider_leader2"),
          (set_visitor,18,"trp_norse_level3_landed"),
          (set_visitor,19,"trp_port_crew"), 			#sven traidor
          (set_visitor, 23,"trp_norse_level0_companion"),
          (set_visitor, 26,"trp_norse_level0_companion"),
          (set_visitor, 29,"trp_norse_level0_companion"),
          (set_visitor, 31,"trp_norse_standard_bearer"),
          (set_visitor, 32,"trp_norse_priest"),
          
          (assign, "$g_lord_hide", 1), #hide lords, lord to st helena
          
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_mainquest_fleet"),
          (change_screen_map_conversation, "trp_leader_svenlair"),
          (assign, "$auto_menu", "mnu_sven_attack_fleet"),#VC-3196
          
          # (modify_visitors_at_site,"scn_mainquest_fleet"),
          # (reset_visitors, 0),
          # (set_visitor, 32,"trp_norse_priest"),
          # (set_visitor, 31,"trp_norse_standard_bearer"),
          # (set_visitor, 29,"trp_norse_level0_companion"),
          # (set_visitor, 26,"trp_norse_level0_companion"),
          # (set_visitor, 23,"trp_norse_level0_companion"),
          # (set_visitor,0,"trp_player"),
          # (set_visitor,33,"trp_sea_raider_leader2"),
          # (set_visitor,1,"trp_leader_svenlair"), #harald
          # (set_visitor,10,"trp_norse_level3_landed"),
          # (set_visitor,6,"trp_sea_raider_leader2"),
          # (set_visitor,35,"trp_port_crew"), #sven traidor
          # (set_jump_mission,"mt_svenattack_thefleet"),
          # (jump_to_scene,"scn_mainquest_fleet"),
          # (change_screen_mission),
      ]),
    ]
  ),
  (
    "playerflee_svenattack",menu_text_color(0xFF000000)|mnf_disable_all_keys, #wait until beda presentation chief
    "Behind you fades the battle, the pitiful cries of the wounded, and the clash of swords. You leave behind Harald Haraldsson's army while Sven Bull Neck's men massacre them. " +
    "Your mission now is to go to Englaland to find Rathbarth Ragnarsson and tell him what happened and how Sven Bull Neck betrayed the king's men.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_navegando"),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("choice_flee1",[],"Flee.",
        [
          
          (quest_set_slot,"qst_the_fleet",slot_quest_current_state, 10),
          (call_script, "script_conclude_quest", "qst_the_fleet"),
          (set_show_messages, 0),
          (call_script, "script_end_quest", "qst_the_fleet"),
          (set_show_messages, 1),
          ###Snotingaham for Mercia
          (try_begin),
            (assign, ":center", "p_castle_9"),
            (party_set_flags,":center",pf_hide_defenders,1), #hide deffenders in Snothingaham temporally.
            (store_faction_of_party, ":old_faction", ":center"),
            (neq, ":old_faction", "fac_kingdom_7"),
            (party_clear, ":center"),
            (party_add_members, ":center", "trp_saxon_bowman", 12),
            (party_add_members, ":center", "trp_saxon_level2_landed", 52),
            (call_script, "script_give_center_to_faction", ":center", "fac_kingdom_7"),
            (call_script, "script_give_center_to_lord", "p_town_17", "trp_kingdom_7_lord", 0),
          (try_end),
          #####
          
          ###peace mercia and wessex
          (try_begin),
            (store_relation, ":cur_relation", "fac_kingdom_7", "fac_kingdom_5"),
            (lt, ":cur_relation", 0), #AT WAR
            (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_kingdom_7", "fac_kingdom_5", 1), #peace
          (try_end),
          (try_for_range, ":faction_no", "fac_kingdom_9", kingdoms_end), #factions 9 and ahead = peace
            (store_relation, ":cur_relation", "fac_kingdom_7", ":faction_no"),
            (lt, ":cur_relation", 0), #AT WAR
            (call_script, "script_diplomacy_start_peace_between_kingdoms", "fac_kingdom_7", ":faction_no", 1), #peace
          (try_end),
          #####
          
          #enable disable Snotingaham normal and Snotingaham in sieges menu
          (party_set_extra_icon, "p_castle_9", "icon_snotingaham_siege_camps", 0, 0, 0, 0),
          
          # phaiak begin
          (set_camera_follow_party, "p_main_party"),
          (assign, "$g_player_is_captive", 0),
          (party_set_flags, "p_the_fleet", pf_is_static, 1),
          (disable_party, "p_the_fleet"),
          # phaiak end
          
          (add_xp_as_reward,200),
          
          #(party_relocate_near_party, "p_main_party", "p_monasterio11", 2), #Phaiak, you want to add ship here or we save it in some port before expedition?
          # phaiak begin
          (party_get_position, pos1, "p_monasterio11"),
          (call_script, "script_get_next_water_position", 10),
          (party_set_position, "p_main_party", pos2),
          # (enable_party, "p_main_party"),	# test to make player party visible #also does not work
          # (party_set_position, "p_temp_party", pos2),
          # (party_relocate_near_party, "p_main_party", "p_temp_party", 0),
          # phaiak end
          
          ##    (troop_set_slot, "$g_talk_troop", slot_troop_prisoner_of_party, "p_main_party"),
          ##    (party_force_add_prisoners, "p_main_party", "$g_talk_troop", 1),
          ###
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###
  ##################
  ##
  (
    "way_to_douaranenez",menu_text_color(0xFF000000)|mnf_disable_all_keys, #
    "You join the fleet, and immediately the sailors unlash the boats and pull the halyards to raise the sails. " +
    "The breeze stirs the cloth, and the ships begin to move. The captains shout orders to their crews, which start to row. Moved by sail and oars, the fleet leaves the harbor and heads for open water.",
    "none",
    [(set_background_mesh, "mesh_pic_fleet"),
      (try_begin), #
        (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 10),
        (jump_to_menu, "mnu_way_to_douaranenez2"),
      (try_end),
      #  (music_set_situation, 0),
    ],
    [
      ("choice_01_3ddouar",[],"To Douar-an-Enez.",
        [
          (quest_set_slot,"qst_douar_an_enez",slot_quest_current_state, 9),
          (play_track, "track_epic_music", 1), 		#phaiak
          (assign, "$d_day_ships", 30),
          #(set_party_battle_mode),
          (select_enemy, 0),
          (set_jump_mission,"mt_d_day_douara"),
          (jump_to_scene,"scn_d_day_douara"),
          (change_screen_mission),
      ]),
    ]
  ),
  ######################
  (
    "way_to_douaranenez2",menu_text_color(0xFF000000)|mnf_disable_all_keys, #
    "You spend days at sea, uncomfortable on a boat with so many men. There is no space for privacy and tranquillity. The smell of stale sweat, urine and sebum fills the air, even above the salty scent of the sea.^" +
    "The climate is mild: no storms, no wind, despite the early appearance of fog. In fact, with so little wind, the fleet advances slowly, making the trip longer.^^" +
    "Finally, from a nearby ship, one of the lookouts points to the horizon, and you can see Douar-an-Enez. In the bay of the village, there are more than 40 boats, many of them in the sea, lashed together in battle formation. One ship leaves the group and heads towards you...",
    "none",
    [(set_background_mesh, "mesh_pic_fleet"),
      (try_begin), #
        (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 13),
        (jump_to_menu, "mnu_way_to_douaranenez3"),
      (try_end),
      
      (try_begin), #
        (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 12),
        (set_jump_mission,"mt_douaranenez_meeting"),
        (modify_visitors_at_site,"scn_douar_an_enez"),
        (reset_visitors, 0),
        (set_visitor,0,"trp_player"),
        
        (try_begin), #bodo spawn his he is in party - wessex option
          (main_party_has_troop, "trp_npc6"),
          (set_visitor,6,"trp_npc6"), #bodo
        (try_end),
        (try_begin), #bodo spawn his he is in party - wessex option
          #(eq, "$player_side", 2), #danish
          (neg|main_party_has_troop, "trp_npc6"),
          (set_visitor,1,"trp_npc6"), #bodo
        (try_end),
        
        #Asturian leaders
        (set_visitor,2,"trp_silo_gallaecia"),
        (set_visitor,3,"trp_petrus_didaz"),
        (set_visitor,4,"trp_gundinsalvo_cantabrian"),
        
        #  (set_visitor,10,"trp_knight_8_7"), #
        #static guards
        #walkers
        (set_visitor,23,"trp_gallaecia_warrior"),
        (set_visitor,24,"trp_gallaecia_warrior"),
        (set_visitor,25,"trp_gallaecia_warrior"),
        (set_visitor,26,"trp_peasant_woman"),
        (set_visitor,27,"trp_peasant_woman"),
        (set_visitor,28,"trp_cantaber_iuventus"),
        (set_visitor,29,"trp_cantaber_iuventus"),
        (set_visitor,30,"trp_cantaber_iuventus"),
        (set_visitor,31,"trp_cantaber_iuventus"),
        (set_visitor,32,"trp_cantaber_iuventus"),
        (set_visitor,33,"trp_cantaber_iuventus"),
        (set_visitor,34,"trp_cantaber_iuventus"),
        (set_visitor,35,"trp_gallaecia_warrior"),
        (set_visitor,36,"trp_peasant_woman"),
        (set_visitor,37,"trp_peasant_woman"),
        (set_visitor,38,"trp_farmerdruid"),
        (set_visitor,39,"trp_farmerdruid"),
        (set_visitor,40,"trp_gallaecia_warrior"),
        (set_visitor,41,"trp_gallaecia_warrior"),
        (set_visitor,42,"trp_gallaecia_warrior"),
        (set_visitor,43,"trp_gallaecia_warrior"),
        (set_visitor,44,"trp_gallaecia_warrior"),
        (set_visitor,45,"trp_asturias_veteran"),
        (set_visitor,46,"trp_asturias_veteran"),
        (set_visitor,47,"trp_cantaber_iuventus"),
        (set_visitor,48,"trp_cantaber_iuventus"),
        (set_visitor,49,"trp_cantaber_iuventus"),
        #static guards
        (set_visitor,75,"trp_gallaecia_warrior"),
        (set_visitor,76,"trp_gallaecia_warrior"),
        (set_visitor,77,"trp_gallaecia_warrior"),
        (set_visitor,78,"trp_cantaber_iuventus"),
        (set_visitor,79,"trp_peasant_woman"),
        (set_visitor,80,"trp_cantaber_iuventus"),
        (set_visitor,81,"trp_cantaber_iuventus"),
        (set_visitor,82,"trp_farmerdruid"),
        (set_visitor,83,"trp_cantaber_iuventus"),
        (set_visitor,84,"trp_cantaber_iuventus"),
        (set_visitor,85,"trp_cantaber_iuventus"),
        (set_visitor,86,"trp_cantaber_iuventus"),
        (set_visitor,87,"trp_cantaber_iuventus"),
        (set_visitor,88,"trp_farmerdruid"),
        (set_visitor,89,"trp_asturias_veteran"),
        (set_visitor,90,"trp_asturias_veteran"),
        (set_visitor,91,"trp_asturias_veteran"),
        (set_visitor,92,"trp_asturias_veteran"),
        (set_visitor,93,"trp_cantaber_iuventus"),
        (set_visitor,94,"trp_asturias_veteran"),
        (set_visitor,95,"trp_asturias_veteran"),
        (set_visitor,96,"trp_gallaecia_warrior"),
        (set_visitor,97,"trp_asturias_veteran"),
        (set_visitor,98,"trp_peasant_woman"),
        (set_visitor,99,"trp_peasant_woman"),
        (set_visitor,100,"trp_asturias_veteran"),
        ###
        #(set_jump_entry, 0),
        (scene_set_slot, "scn_douar_an_enez", slot_scene_visited, 1),
        
        (jump_to_scene,"scn_douar_an_enez"),
        (change_screen_mission),
      (try_end),
    ],
    [
      ("choice_d1douar2",[],"Join the parley.",
        [
          (modify_visitors_at_site,"scn_meeting_scene_water"),	#phaiak edited	#player entry point 31, and then 32, 33, testing conversation in sea...
          (reset_visitors), #
          (set_visitor,0,"trp_player"),					#phaiak edited
          (set_visitor,17,"trp_relative_of_merchant"),	#phaiak edited
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_meeting_scene_water"),		#phaiak edited		# @Idibil: I made a scene for map conversations on water: "scn_meeting_scene_water" (Well... but in the moment player is in water... I need to fix this).
          #Ok Phaiak, I used mainquest scene as I need here only, but you are free to change
          (change_screen_map_conversation, "trp_relative_of_merchant")
      ]),
    ]
  ),
  
  (
    "way_to_douaranenez3",menu_text_color(0xFF000000)|mnf_disable_all_keys, #
    "Behind you, you hear discussion in the village. There seems to be dissension in the camp of the Astures. You hear swords and shouting.^^" +
    "But none of that matters to you at the moment. In full sail, a Cantabrian ship takes you to where your boat awaits. You see, in the distance, your fleet maneuvering to confront their attackers. " +
    "Gundinsalvo travels with you. He is serious, very serious, despite the buffoonery at the meeting. He looks to where the two fleets jockey for position with their oars. His face is fierce, that of a seasoned warrior who does not fear death. " +
    "As soon as you board your boat again, you direct it toward your fleet. It's time to take control...",
    "none",
    [(set_background_mesh, "mesh_pic_fleet"),
      (try_begin), #
        (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 14),
        (jump_to_menu, "mnu_way_to_douaranenez4"),
      (try_end),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("choice_douarbdouar3",[],"To battle.",
        [
          #phaiak begin
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1),
          (set_jump_mission,"mt_sea_battle_douaranenez"),
          (jump_to_scene,"scn_sea_battle_douaranenez"),
          (party_clear, "$g_encountered_party"),
          (try_begin),
            (eq, "$player_side", 1), #wessex
            (select_enemy, 1),
            (set_jump_entry, 1),
          (else_try),
            #(eq, "$player_side", 2), #danish
            (select_enemy, 0),
            (set_jump_entry, 0),
          (end_try),
          #phaiak end
          (change_screen_mission),
      ]),
    ]
  ),
  ###desembarco
  (
    "way_to_douaranenez4",menu_text_color(0xFF000000)|mnf_disable_all_keys, #
    "The sea has become a hell of fire, blood and death. Victory is yours, but many have been left behind, overcome by the edge of the sword, including the Cantabrian, Gundinsalvo.^^" +
    "The naval battle was pure delirium of madness, but now your enemies flee. They are seeking to take refuge in Douar-an-Enez, but your warriors have pursued them, sparking a new battle in the little village. " +
    "It is where you left Bodo, who attempts to bring together the Asturians and coordinate their efforts.^^" +
    "It's your turn to join the fight...",
    "none",
    [(set_background_mesh, "mesh_pic_extra_navegando"),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
      ##        (try_begin), #
      ##                  (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 14),
      ##                 #(jump_to_menu, "mnu_way_to_douaranenez2"),
      ##         (try_end),
    ],
    [
      ("choice_douard4",[],"Disembark.",
        [
          (party_add_members,"p_main_party","trp_cantaber_iuventus",12),
          (assign, "$g_encountered_party", "p_village_63"),
          #(assign, "$g_current_town", "p_village_63"),
          (party_clear, "$g_encountered_party"),
          (try_begin), #bodo spawn his he is in party - wessex option
            (eq, "$player_side", 1), #wessex
            #player enemy
            (party_add_members, "$g_encountered_party", "trp_gallaecia_warrior" , 15),
            (party_add_members, "$g_encountered_party", "trp_norse_level0_companion" , 35),
            (party_add_members, "$g_encountered_party", "trp_norse_level1_landed" , 25),
            (party_add_members, "$g_encountered_party", "trp_norse_level2_landed" , 15),
            (party_add_members, "$g_encountered_party", "trp_norse_bowman" , 20),
            #player friendly
            (party_add_members, "$g_encountered_party", "trp_asturias_veteran" , 12),
            (party_add_members, "$g_encountered_party", "trp_cantaber_iuventus" , 20),
          (try_end),
          (try_begin), #bodo spawn his he is in party - wessex option
            (eq, "$player_side", 2), #danish ###Bodo enemy
            #player enemy
            (party_add_members, "$g_encountered_party", "trp_asturias_veteran" , 15),
            (party_add_members, "$g_encountered_party", "trp_saxon_bowman" , 20),
            (party_add_members, "$g_encountered_party", "trp_saxon_level0_companion" , 35),
            (party_add_members, "$g_encountered_party", "trp_saxon_level1_landed" , 25),
            (party_add_members, "$g_encountered_party", "trp_saxon_level2_landed" , 15),
            #player friendly
            (party_add_members, "$g_encountered_party", "trp_gallaecia_warrior" , 12),
            (party_add_members, "$g_encountered_party", "trp_cantaber_iuventus" , 20),
          (try_end),
          
          # (store_random_in_range, ":enmity", -10, -5),
          # (call_script, "script_change_player_relation_with_center", "$g_encountered_party", ":enmity"),
          
          (select_enemy, 0),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 1), #phaiak (give player his ship)
          (set_jump_mission,"mt_coastal_battle_douar"),
          (jump_to_scene,"scn_douar_an_enez_attack"),
          ##        (assign, "$g_next_menu", "mnu_simple_encounter"),
          ##        (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
    ]
  ),
  ###final batalla
  (
    "way_to_douaranenez5",menu_text_color(0xFF000000)|mnf_disable_all_keys, #
    "Douar-an-Enez is not the place it was when you first arrived. Now there are only fire and death... Its inhabitants have been turned over to torment, and you doubt that someday someone would dare repopulate this cursed place.^^" +
    "You hear the plaintive cry of your own injured people, and men wander past you staring into the distance, still shocked by the battle. You remember how Bodo died in the fight and last time you shared with him. His mission failed with persistent inevitability. There is no longer a fleet from the Kingdom of Asturias, only a few Cantabrians who have joined your cause after losing their own leader, Gundinsalvo. Now you are their leader. " +
    "Some of your men dedicate themselves to finishing off the enemy and seizing their possessions.",
    "none",
    [(set_background_mesh, "mesh_pic_duel_warriors"),
      (try_begin), #
        (check_quest_succeeded, "qst_douar_an_enez"),
        
        (disable_party, "p_the_fleet"),
        (party_get_position, pos1, "p_bight_spawn_point"),
        (call_script, "script_get_next_water_position", 2),
        (party_set_position, "p_main_party", pos2),
        (assign, "$g_lord_hide", 1),
        (troop_set_slot, "trp_npc6", slot_troop_occupation, slto_dead),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("choice_douarb15",[],"Claim your share of the spoils.",
        [
          (assign, "$g_lord_hide", 1),
          (add_xp_as_reward,1000),
          (call_script, "script_troop_add_gold", "trp_player", 10000),
          (call_script, "script_change_troop_renown", "trp_player", 15),
          (call_script, "script_change_player_party_morale", 5),
          (call_script, "script_succeed_quest", "qst_douar_an_enez"),
          (party_add_members,"p_main_party","trp_cantaber_iuventus",12),
          (party_add_members,"p_main_party","trp_asturias_veteran",6),
          (party_add_members,"p_main_party","trp_gallaecia_warrior",2),
          (troop_add_item, "trp_player","itm_mail_shirt_4",0),
          (troop_add_item, "trp_player","itm_spangenhelm_12",0),
          (troop_add_item, "trp_player","itm_one_handed_war_axe_c",0),
          (start_presentation, "prsnt_beda_story_4"),
          ##flota regreso disable
      ]),
      ("choice_douarb26",[],"Let your men keep all the loot.",
        [
          (assign, "$g_lord_hide", 1),
          (call_script, "script_troop_add_gold", "trp_player", 2000),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (call_script, "script_change_player_party_morale", 90),
          (call_script, "script_succeed_quest", "qst_douar_an_enez"),
          (party_add_members,"p_main_party","trp_cantaber_iuventus",12),
          (party_add_members,"p_main_party","trp_asturias_veteran",6),
          (party_add_members,"p_main_party","trp_gallaecia_warrior",2),
          (start_presentation, "prsnt_beda_story_4"),
      ]),
    ]
  ),
  ############
  
  
  
  ###bjorn's camp mainquest
  (
    "bjorn_camp",0,
    "On a hill, the Danish have built a small camp. Counting the number of tents that you can see, you figure that there are between 250 and 300 men. " +
    "On one of the tents waves the banner of Bjorn, one of the most famous sons of Ragnar.^^" +
    "A couple of men stop you, but they let you pass as soon as you identify yourself, as if they were advised of your arrival.",
    "none",
    [(set_background_mesh, "mesh_pic_camp"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      ##
      ##        (try_begin), #chief doccinga coastal assault mainquest
      ##                   (check_quest_active,"qst_the_messengersn"),
      ##                   (quest_slot_eq,"qst_the_messengersn",slot_quest_current_state, 4),
      ####                   (leave_encounter),
      ####                   (change_screen_map),
      ##              (jump_to_menu,"mnu_bjorn_camp2"),
      ##        (try_end),
    ],
    [
      ("enter_bjorncamp",[(check_quest_active,"qst_sven_traitor"),
        ],"Enter the camp.",
        [
          (set_jump_mission,"mt_bjorn_camp"),
          (modify_visitors_at_site,"scn_viking_camp"),
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"),
          
          (try_begin), #bodo spawn once
            (check_quest_active,"qst_sven_traitor"),
            (quest_slot_eq,"qst_sven_traitor",slot_quest_current_state, 2),
            (set_visitor,1,"trp_npc6"), #bodo
          (try_end),
          
          #merchants
          (set_visitor,2,"trp_town_10_horse_merchant"),
          (set_visitor,3,"trp_town_10_weaponsmith"),
          (set_visitor,4,"trp_town_10_merchant"),
          (set_visitor,5,"trp_town_10_armorer"), #
          
          (set_visitor,10,"trp_knight_8_7"), #bjorn
          #  (set_visitor,10,"trp_knight_8_7fake"), #bjorn fake
          #static guards
          (set_visitor,11,"trp_norse_bowman"),
          (set_visitor,12,"trp_norse_bowman"),
          (set_visitor,13,"trp_norse_bowman"),
          (set_visitor,14,"trp_norse_bowman"),
          (set_visitor,15,"trp_norse_level1_landed"),
          (set_visitor,16,"trp_norse_level1_landed"),
          (set_visitor,17,"trp_norse_level1_landed"),
          (set_visitor,18,"trp_norse_level1_landed"),
          (set_visitor,19,"trp_norse_bowman"),
          (set_visitor,20,"trp_norse_bowman"),
          (set_visitor,21,"trp_norse_bowman"),
          (set_visitor,22,"trp_norse_bowman"),
          #walkers
          (set_visitor,23,"trp_norse_slave"),
          (set_visitor,24,"trp_norse_slave"),
          (set_visitor,25,"trp_norse_slave"),
          (set_visitor,26,"trp_norse_slave"),
          (set_visitor,27,"trp_norse_level0_landed"),
          (set_visitor,28,"trp_norse_level0_landed"),
          (set_visitor,29,"trp_norse_standard_bearer"),
          (set_visitor,30,"trp_norse_elitearcher"),
          (set_visitor,31,"trp_norse_priest"),
          (set_visitor,32,"trp_norse_level1_companion"),
          (set_visitor,33,"trp_norse_level2_companion"),
          (set_visitor,34,"trp_norse_level2_companion"),
          (set_visitor,35,"trp_norse_level2_companion"),
          (set_visitor,36,"trp_norse_level1_companion"),
          (set_visitor,37,"trp_norse_level3_landed"),
          (set_visitor,38,"trp_norse_level3_landed"),
          (set_visitor,39,"trp_norse_level3_landed"),
          (set_visitor,40,"trp_norse_level3_landed"),
          (set_visitor,41,"trp_norse_level2_landed"),
          (set_visitor,42,"trp_norse_level2_landed"),
          (set_visitor,43,"trp_norse_level2_landed"),
          (set_visitor,44,"trp_norse_level2_landed"),
          (set_visitor,45,"trp_norse_level2_landed"),
          (set_visitor,46,"trp_norse_level2_landed"),
          (set_visitor,47,"trp_norse_level2_landed"),
          (set_visitor,48,"trp_norse_elitearcher"),
          (set_visitor,49,"trp_norse_elitearcher"),
          
          #(set_jump_entry, 0),
          (scene_set_slot, "scn_viking_camp", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_viking_camp"),
          (change_screen_mission),
      ]),
      
      ("enter_bjorncamp2",[(neg|check_quest_active,"qst_sven_traitor"),
        ],"Investigate.",
        [
          #merchants
          (set_visitor,2,"trp_town_10_horse_merchant"),
          (set_visitor,3,"trp_town_10_weaponsmith"),
          (set_visitor,4,"trp_town_10_merchant"),
          (set_visitor,5,"trp_town_10_armorer"), #
          
          #static guards
          (set_visitor,13,"trp_norse_bowman"),
          (set_visitor,14,"trp_norse_bowman"),
          (set_visitor,17,"trp_norse_level1_landed"),
          (set_visitor,18,"trp_norse_level1_landed"),
          (set_visitor,19,"trp_norse_bowman"),
          (set_visitor,20,"trp_norse_bowman"),
          (set_visitor,21,"trp_norse_bowman"),
          (set_visitor,22,"trp_norse_bowman"),
          (set_visitor,46,"trp_norse_level2_landed"),
          (set_visitor,47,"trp_norse_level2_landed"),
          (set_visitor,48,"trp_norse_elitearcher"),
          (set_visitor,49,"trp_norse_elitearcher"),
          
          #(set_jump_entry, 0),
          (scene_set_slot, "scn_viking_camp", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_viking_camp"),
          (change_screen_mission),
      ]),
      ##      ("encounter_savefarm",[	(check_quest_active,"qst_sven_traitor"),
      ##          ],"Give me time to save my game.",
      ##      [
      ##        (leave_encounter),
      ##        (change_screen_return),
      ##      ]),
      
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ######
  ####mission infiltration in siege mainquest
  (
    "nothingam_siege",0,
    "Down in the distance, you see two Saxon and Angle camps surrounding Snotingaham. The camps are large, capable of holding thousands of men, and there are also patrols of warriors around the perimeter of the city, making sure that no one goes in or out. " +
    "From this far away, you can just distinguish the silhouettes of Danish warriors as they patrol around the walls of the fortress. They are certainly in a compromising situation in terms of numbers, and the food is running out every day.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (try_begin),
        (check_quest_active,"qst_the_messengersn"),(quest_slot_eq, "qst_the_messengersn", slot_quest_current_state, 6),
        (jump_to_menu,"mnu_nothingam_siege_al"),
      (else_try),
        (quest_get_slot,":stage","qst_the_messengersn",slot_quest_current_state),
        (neq, ":stage", 5),
        (quest_set_slot, "qst_the_messengersn", slot_quest_current_state, 1), #re-try quest
      (try_end),
      # (try_begin),
        # (check_quest_active,"qst_the_messengersn"),(quest_slot_eq, "qst_the_messengersn", slot_quest_current_state, 1),
        # (display_message,"@You remember that you need to bring Ragnar's seax for this mission.",0xFFFFAAAA),#ragnar's seax need
      # (try_end),
    ],
    [
      ("mierce_patrols",[(check_quest_active,"qst_the_messengersn"),(quest_slot_eq, "qst_the_messengersn", slot_quest_current_state, 1), #active menu in siege
          # (this_or_next|troop_has_item_equipped,"$g_player_troop","itm_ragnar_seax"),#check if item is equiped
          # (player_has_item,"itm_ragnar_seax"), #ragnar's seax
        ],"Go to Snotingaham, passing between Mierce patrols.",
        [
          (quest_set_slot, "qst_the_messengersn", slot_quest_current_state, 2), #end menu
          
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_mercian_lines"),
          (modify_visitors_at_site,"scn_forest_infiltration"),
          
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"), #player
          #mercians
          #  (set_visitor,15,"trp_angle_horseman"),
          # (set_visitor,16,"trp_angle_level2_landed"),
          #  (set_visitor,17,"trp_angle_level2_landed"),
          #  (set_visitor,18,"trp_angle_level1_landed"),
          (set_visitor,19,"trp_angle_level1_landed"),
          (set_visitor,20,"trp_angle_level0_landed"),
          (set_visitor,21,"trp_angle_level1_landed"),
          (set_visitor,22,"trp_angle_level0_landed"),
          (set_visitor,23,"trp_angle_bowman"),
          (set_visitor,24,"trp_angle_bowman"),
          (set_visitor,25,"trp_angle_bowman"),
          (set_visitor,26,"trp_angle_level0_companion"),
          (set_visitor,27,"trp_angle_bowman"),
          (set_visitor,28,"trp_angle_bowman"),
          (set_visitor,29,"trp_angle_bowman"),
          (jump_to_scene,"scn_forest_infiltration"),
          
          (change_screen_mission),
      ]),
      
      ##      ("encounter_savefarm",[	(check_quest_active,"qst_the_messengersn"),
      ##          ],"Give me time to save my game.",
      ##      [
      ##        (leave_encounter),
      ##        (change_screen_return),
      ##      ]),
      
      ("choice_snott",[],"I need to recruit more men.", #save
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          # (start_presentation, "prsnt_auto_save")
      ]),
      ("leave",[#(neg|check_quest_active,"qst_the_messengersn"),
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  (
    "nothingam_siege2",0,
    "You leave behind Snotingaham and return to the forest...",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_the_messengersn"),
        (quest_slot_eq,"qst_the_messengersn",slot_quest_current_state, 5),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("mierce_patrols2",[
        ],"Go to Snotingaham, passing between Mierce patrols.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_mercian_lines"),
          (modify_visitors_at_site,"scn_forest_infiltration2"),
          
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"), #player
          #mercians
          (set_visitor,9,"trp_angle_level3_landed"), #static
          (set_visitor,10,"trp_angle_level2_landed"), #static
          #  (set_visitor,11,"trp_angle_horseman"), #static
          # (set_visitor,12,"trp_angle_level2_landed"), #static
          #  (set_visitor,13,"trp_angle_level3_landed"), #static
          (set_visitor,14,"trp_angle_level2_landed"), #static
          (set_visitor,15,"trp_angle_horseman"), #static
          (set_visitor,16,"trp_angle_horseman"), #static
          (set_visitor,17,"trp_angle_level2_landed"), #static
          (set_visitor,18,"trp_angle_level1_landed"), #static
          (set_visitor,19,"trp_angle_level1_landed"), #static
          (set_visitor,20,"trp_angle_level0_landed"), #patrol
          (set_visitor,21,"trp_norse_level0_landed"), #patrol
          (set_visitor,22,"trp_angle_level0_landed"), #patrol
          (set_visitor,23,"trp_angle_bowman"), #patrol
          (set_visitor,24,"trp_angle_bowman"), #patrol
          (set_visitor,25,"trp_angle_bowman"), #patrol
          (jump_to_scene,"scn_forest_infiltration2"),
          
          (change_screen_mission),
      ]),
      
    ],
  ),
  (
    "nothingam_siege_al",0,
    "As you approach Snotingaham, Saxon patrols surround you but do not attack, respecting your emissary flag. " +
    "They make you wait for about an hour while they look for Aelfred.^^" +
    "Finally, a group of riders reaches where you are, dismounts and walks up to you.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (try_begin),
        (check_quest_active,"qst_the_messengersn"),
        (check_quest_succeeded, "qst_the_messengersn"),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_alfred",[
        ],
        "Continue.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_saxon_level2_landed"),
          (set_visitor,17,"trp_knight_5_1"),
          (set_visitor,18,"trp_saxon_level3_landed"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_knight_5_1")
      ]),
    ]
  ),
  ###############
  (
    "ambush_kennemer",0,
    "While your party rests to recover from the fatigue of the road, you take advantage to get away a bit from the camp and to have some privacy, as you have an upset stomach.^^" +
    "But your relaxation, hidden among some rocks, is disturbed by a noise to your right...",
    "none",
    [(set_background_mesh, "mesh_pic_ambush"),
      (try_begin),
        (check_quest_active,"qst_kennemer_jarl_missions"),
        (quest_slot_eq,"qst_kennemer_jarl_missions",slot_quest_current_state, 8),
        (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
        (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
        (set_visitor,0,"trp_player"),
        (set_visitor,17,"trp_npc11"),
        (set_visitor,18,"trp_npc3"),
        (assign, "$g_encountered_party", "p_town_4"),
        (set_jump_mission,"mt_conversation_encounter"),
        (jump_to_scene,"scn_conversation3people_scene"),
        #  (quest_set_slot,"qst_kennemer_jarl_missions",slot_quest_current_state, 9), #en solveig dialog
        (change_screen_map_conversation, "trp_npc11"),
      (try_end),
      
      (try_begin),
        (check_quest_active,"qst_kennemer_jarl_missions"),
        (quest_slot_eq,"qst_kennemer_jarl_missions",slot_quest_current_state, 9),
        (call_script, "script_conclude_quest", "qst_kennemer_jarl_missions"),
        (set_show_messages, 0),
        (call_script, "script_end_quest", "qst_kennemer_jarl_missions"),
        (set_show_messages, 1),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("relax_broken",[
        ],"Quickly dress and take up your weapon.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_ambush_assassins"),
          (modify_visitors_at_site,"scn_stonemonumento"),
          
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"), #player
          (set_visitor,2,"trp_npc11"), #static
          #enemies
          (set_visitor,9,"trp_hired_blade"),
          # (set_visitor,10,"trp_hired_blade"),
          (set_visitor,11,"trp_mercenary_crossbowman"),
          (set_visitor,12,"trp_hired_assassin"),
          #  (set_visitor,13,"trp_mercenary_crossbowman"),
          # (set_visitor,14,"trp_mercenary_crossbowman"),
          # (set_visitor,16,"trp_hired_blade"),
          # (set_visitor,17,"trp_hired_blade"),
          (jump_to_scene,"scn_stonemonumento"),
          (quest_set_slot,"qst_kennemer_jarl_missions",slot_quest_current_state, 4),
          
          (change_screen_mission),
      ]),
      
    ],
  ),
  ##
  #####mainquest conquista castillo chief
  (
    "welsh_and_pictish_complete",mnf_disable_all_keys,
    "It has been twenty days, and you've managed to keep {s3}. It is time to return for news of Sven Bull Neck and the decision regarding the letter of Bodo.",
    "none",
    [(set_background_mesh, "mesh_pic_village_w"),
      (try_begin),
        (eq, "$player_side", 2), #danish
        (str_store_party_name, s3, "p_castle_37"),
      (else_try),
        (eq, "$player_side", 1), #wessex
        (str_store_party_name, s3, "p_castle_41"),
      (try_end),
      (call_script, "script_succeed_quest", "qst_welsh_and_pictish"),
    ],
    [
      ("continue", [], "Continue...",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #####
  ##### quest the douar_an_enez contacto madre
  (
    "messeger_mothernews",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A messenger approaches, beating a squalid horse. He stops in front of you, takes a breath and shouts,^^" +
    "'This message is for somebody called {playername}. If you want news of your mother, go to Boar Grove near Dommoc and look for the lumberjack's house.'^^" +
    "The messenger kicks his mount until it starts moving again and rides off.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_01_newsm",[],"Continue",
        [
          (str_store_party_name_link, s3, "p_town_14"),
          (str_store_string, s2, "@Before you left for your trip to Frankia, someone sent a messenger to inform you that someone will meet you at a place called Boar Grove, near {s3}. There you must find the house of the lumberjack."),
          (add_quest_note_from_sreg, "qst_douar_an_enez", 4, s2, 0),
          (quest_set_slot,"qst_douar_an_enez",slot_quest_current_state, 2),
          (enable_party, "p_boar_grove"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #######
  
  (
    "circle_mystic",0,
    "Your eyes distinguish a special place, which looks like it was raised by the ancients. Perhaps it is a good time to visit and enjoy the art of another time.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter_quest",[ (eq,"$circle_mystic",0),
        ],"Go.",
        [
          (modify_visitors_at_site,"scn_circle_mystic1"),
          (reset_visitors,0),
          (set_visitors,1,"trp_mountain_bandit_leader",1),
          (set_jump_mission,"mt_circle_mystic1"),
          (jump_to_scene,"scn_circle_mystic1"),
          (change_screen_mission),
      ]),
      
      ("enter_mystic",[(eq,"$circle_mystic",5),],"Approach.",
        [    (modify_visitors_at_site,"scn_circle_mystic1"),
          (reset_visitors,0),
          (set_visitors,8,"trp_sea_raider_hero2",1),
          (set_jump_mission,"mt_circle_mystic1"),
          (jump_to_scene,"scn_circle_mystic1"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",
        [                  (try_begin),
            (eq,"$circle_mystic",4), #now captain hero
            (assign,"$circle_mystic",5), #now captain hero
          (try_end),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  ####troll bridge
  (
    "troll_bridge",0,
    "Not far away there is a bridge over a stream. The stream itself is unnamed, but the bridge is widely known as The Troll's Bridge.",
    "none",
    [(set_background_mesh, "mesh_pic_small_island"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter_troll",[ (eq,"$troll_bridge",0),
        ],"Move towards the bridge.",
        [
          
          (modify_visitors_at_site,"scn_bridge_troll"),
          (reset_visitors,0),
          (set_visitors,1,"trp_troll_bridge",1),
          (set_jump_mission,"mt_bridge_troll"),
          (jump_to_scene,"scn_bridge_troll"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  ###battle stones
  (
    "battle_stones",0, #ambush
    "Nearby you see a house surrounded by a row of stones on the ground. It seems an idyllic place to live, surrounded by peace and tranquillity, with nary a concern but to get up and take care of the livestock or crops... It is therefore impossibly distant from your hectic itinerant life on the road.",
    "none",
    [(set_background_mesh, "mesh_pic_bandits_lair"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter",[ (eq,"$battle_stones",0),
        ],"Enter.",
        [
          
          (modify_visitors_at_site,"scn_battle_stones"),
          (reset_visitors,0),
          (set_visitors,1,"trp_sea_raider_leader2",1),
          (set_visitors,2,"trp_hired_blade",1),
          (set_visitors,3,"trp_hired_blade",1),
          (set_visitors,4,"trp_hired_blade",1),
          (set_visitors,5,"trp_hired_blade",1),
          (set_visitors,6,"trp_hired_blade",1),
          (set_visitors,7,"trp_hired_blade",1),
          (set_visitors,8,"trp_hired_blade",1),
          (set_visitors,9,"trp_taiga_bandit",4),
          (set_visitors,10,"trp_taiga_bandit",4),
          (set_visitors,11,"trp_taiga_bandit",4),
          (set_visitors,12,"trp_peasant_woman",2),
          (set_visitors,13,"trp_peasant_woman",3),
          (set_visitors,14,"trp_farmerdruid",2),
          (set_jump_mission,"mt_battle_stones"),
          (jump_to_scene,"scn_battle_stones"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ####roman fort
  (
    "roman_fort",0,
    "Following the path, you can see ruins of some ancient Roman fort, similar to those found in other parts of old Britannia.",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter_romanfort",[ (eq,"$roman_fort_riddles",0),
        ],"Investigate.",
        [
          
          (modify_visitors_at_site,"scn_roman_fort"),
          (reset_visitors,0),
          (set_visitors,1,"trp_elf_riddles",1),
          (set_jump_mission,"mt_elf_riddles"),
          (jump_to_scene,"scn_roman_fort"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  (
    "farmland_menu",0,
    "You arrive at a small hamlet along the way. Smoke rises from a chimney, but you do not see anyone outside.", #ambush
    "none",
    [(set_background_mesh, "mesh_pic_farmstead"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("enter_ambush",[ (eq,"$farmland_ambush",0),
        ],"Visit the hamlet.",
        [
          
          (modify_visitors_at_site,"scn_farmland"),
          (reset_visitors,0),
          (set_visitors,1,"trp_steppe_bandit",1),
          (set_jump_mission,"mt_farmland_ambush"),
          (jump_to_scene,"scn_farmland"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  #########beda recruit
  (
    "boar_grove",0,
    "You arrive at a deep grove of woods. {s4}",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      (str_clear, s4),
      (try_begin),
        (check_quest_active,"qst_douar_an_enez"),
        (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 6),
        (quest_set_slot,"qst_douar_an_enez",slot_quest_current_state, 7), #status 6 acaba
      (try_end),
      
      (try_begin),
        (check_quest_active,"qst_douar_an_enez"),
        (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 2),
        (str_store_string, s4, "@Through the trees, you can barely see a hut. The trees sough gently in the wind, and some birds sing, but you see no one."),
      (else_try),
        (quest_slot_ge,"qst_douar_an_enez",slot_quest_current_state, 3),
        (str_store_string, s4, "@Through the trees, you can barely see the hut, now empty, where you met Beda."),
      (else_try),
        (eq,"$g_hero_result",0),
        (str_store_string, s4, "@You arrive at a deep forest."),
      (else_try),
        (str_store_string, s4, "@Through the trees, you can barely see the hut, now abandoned since you killed the old hero who once lived in it."),
      (try_end),
    ],
    [
      ("enter_hut",[
          (check_quest_active,"qst_douar_an_enez"),
          (quest_slot_eq,"qst_douar_an_enez",slot_quest_current_state, 2),
          (neg|main_party_has_troop,"trp_npc16"),
        ],"Approach the hut.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          
          (modify_visitors_at_site,"scn_boar_grove"),
          (reset_visitors,0),
          (troop_set_slot, "trp_npc16", slot_troop_met_previously, 0),
          (set_visitors,1,"trp_npc16",1),
          (set_jump_mission,"mt_boar_grove"),
          (jump_to_scene,"scn_boar_grove"),
          (change_screen_mission),
      ]),
      
      ("enter_hut2",[
          (eq,"$g_hero_result",0),
          (neg|check_quest_active,"qst_douar_an_enez"),
        ],"Approach the hut.",
        [    (modify_visitors_at_site,"scn_boar_grove"),
          (reset_visitors,0),
          (set_visitors,1,"trp_old_hero_boargrove",1),
          (set_jump_mission,"mt_boar_grove"),
          (jump_to_scene,"scn_boar_grove"),
          (change_screen_mission),
      ]),
      
      ("leave",[],"Leave...",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ###############
  #####Danish invasion quest
  ###saxon's camp mainquest
  (
    "aescesdun_camp",0,
    "The Saxon army has retreated to this position to regroup after the defeat at Readingum. They have set up camp on a hill, where they are reinforced with men who arrive every day. " +
    "It's a good position to recover and to intercept the Danish army in their westward advance before they can penetrate into West Seaxe.^^" +
    "The site is called Aescesdun.^^" +
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_castlesnow"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      
      (str_clear, s4),
      (try_begin),
        (eq, "$player_side", 2), #Danish
        (str_store_string, s4, "@You stay hidden, watching the camp from afar and avoiding Saxon lookouts and patrols."),
      (try_end),
      
    ],
    [
      ("enter_aescendun",[(eq, "$player_side", 1), #wessex
        ],"Enter the camp.",
        [
          (set_jump_mission,"mt_aescendun_camp"),
          (modify_visitors_at_site,"scn_aescendun_camp"),
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"),
          
          #merchants
          (set_visitor,2,"trp_town_16_horse_merchant"),
          (set_visitor,3,"trp_town_16_weaponsmith"),
          (set_visitor,4,"trp_town_16_merchant"),
          (set_visitor,5,"trp_town_16_armorer"), #
          
          (set_visitor,10,"trp_knight_5_1"), #Halfdan
          #static guards
          (set_visitor,11,"trp_saxon_bowman"),
          (set_visitor,12,"trp_saxon_bowman"),
          (set_visitor,13,"trp_saxon_bowman"),
          (set_visitor,14,"trp_saxon_bowman"),
          (set_visitor,15,"trp_saxon_level0_landed"),
          (set_visitor,16,"trp_saxon_level0_landed"),
          (set_visitor,17,"trp_norse_level1_landed"),
          (set_visitor,18,"trp_norse_level1_landed"),
          (set_visitor,19,"trp_saxon_bowman"),
          (set_visitor,20,"trp_saxon_bowman"),
          (set_visitor,21,"trp_saxon_bowman"),
          (set_visitor,22,"trp_saxon_bowman"),
          #walkers
          (set_visitor,23,"trp_saxon_level0_landed"),
          (set_visitor,24,"trp_saxon_level0_landed"),
          (set_visitor,25,"trp_saxon_slave"),
          (set_visitor,26,"trp_saxon_slave"),
          (set_visitor,27,"trp_saxon_level0_companion"),
          (set_visitor,28,"trp_saxon_level0_companion"),
          (set_visitor,29,"trp_saxon_standard_bearer"),
          (set_visitor,30,"trp_saxon_level1_landed"),
          (set_visitor,31,"trp_saxon_priest"),
          (set_visitor,32,"trp_saxon_level1_landed"),
          (set_visitor,33,"trp_saxon_level1_landed"),
          (set_visitor,34,"trp_saxon_level2_landed"),
          (set_visitor,35,"trp_saxon_level2_landed"),
          (set_visitor,36,"trp_saxon_level3_landed"),
          (set_visitor,37,"trp_saxon_level3_landed"),
          (set_visitor,38,"trp_saxon_level3_landed"),
          (set_visitor,39,"trp_saxon_slave"),
          (set_visitor,40,"trp_saxon_slave"),
          (set_visitor,41,"trp_saxon_level3_landed"),
          (set_visitor,42,"trp_saxon_level2_landed"),
          (set_visitor,43,"trp_saxon_level2_landed"),
          (set_visitor,44,"trp_saxon_level3_landed"),
          (set_visitor,45,"trp_saxon_level0_companion"),
          (set_visitor,46,"trp_saxon_level0_companion"),
          (set_visitor,47,"trp_saxon_level0_companion"),
          (set_visitor,48,"trp_saxon_level0_landed"),
          (set_visitor,49,"trp_saxon_level0_landed"),
          
          #(set_jump_entry, 0),
          (scene_set_slot, "scn_aescendun_camp", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_aescendun_camp"),
          (change_screen_mission),
      ]),
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  ################
  (
    "aescesdun_empty",0,
    "The camp has been almost empty, with very few people left after the advance of the great army into battle.",
    "none",
    [(set_background_mesh, "mesh_pic_castlesnow"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
    ],
    [
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ######
  (
    "readingum_camp",0,
    "Ragnar's sons have built a fortified camp in a Saxon village called Readingum. The site has good defenses and a moat, and there are still remnants of the earlier battle in which the Saxons tried to expel the Danish. " +
    "It is a good position from which to defend and protect the surroundings.^^" +
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_castlesnow"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      ##        (try_begin), #Sven final
      ##                   (check_quest_active,"qst_svenbn_final"),
      ##		   (jump_to_menu, "mnu_sven_bullneck_readingum"),
      ##         (try_end),
      (str_clear, s4),
      (try_begin),
        (eq, "$player_side", 1), #Saxon side
        (str_store_string, s4, "@You stay hidden, watching the camp from afar and avoiding Danish lookouts and patrols."),
      (try_end),
    ],
    [
      ("enter_readingum",[(eq, "$player_side", 2), #danish
        ],"Enter the camp.",
        [
          (set_jump_mission,"mt_readingum_camp"),
          (modify_visitors_at_site,"scn_redingum_camp"),
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"),
          
          #merchants
          (set_visitor,6,"trp_town_12_horse_merchant"),
          (set_visitor,7,"trp_town_12_weaponsmith"),
          (set_visitor,8,"trp_town_12_merchant"),
          (set_visitor,5,"trp_town_12_armorer"), #
          
          (set_visitor,10,"trp_kingdom_8_lord"), #Halfdan
          #static guards
          (set_visitor,11,"trp_norse_bowman"),
          (set_visitor,12,"trp_norse_bowman"),
          (set_visitor,13,"trp_norse_bowman"),
          (set_visitor,14,"trp_norse_bowman"),
          (set_visitor,15,"trp_norse_level1_landed"),
          (set_visitor,16,"trp_norse_level1_landed"),
          (set_visitor,17,"trp_norse_level1_landed"),
          (set_visitor,18,"trp_norse_level1_landed"),
          (set_visitor,19,"trp_norse_bowman"),
          (set_visitor,20,"trp_norse_bowman"),
          (set_visitor,21,"trp_norse_bowman"),
          (set_visitor,22,"trp_norse_bowman"),
          #walkers
          (set_visitor,23,"trp_norse_slave"),
          (set_visitor,24,"trp_norse_slave"),
          (set_visitor,25,"trp_norse_slave"),
          (set_visitor,26,"trp_norse_slave"),
          (set_visitor,27,"trp_norse_level0_landed"),
          (set_visitor,28,"trp_norse_level0_landed"),
          (set_visitor,29,"trp_norse_standard_bearer"),
          (set_visitor,30,"trp_norse_elitearcher"),
          (set_visitor,31,"trp_norse_priest"),
          (set_visitor,32,"trp_norse_level1_companion"),
          (set_visitor,33,"trp_norse_level2_companion"),
          (set_visitor,34,"trp_norse_level2_companion"),
          (set_visitor,35,"trp_norse_level2_companion"),
          (set_visitor,36,"trp_norse_level1_companion"),
          (set_visitor,37,"trp_norse_level3_landed"),
          (set_visitor,38,"trp_norse_level3_landed"),
          (set_visitor,39,"trp_norse_level3_landed"),
          (set_visitor,40,"trp_norse_level3_landed"),
          (set_visitor,41,"trp_norse_level2_landed"),
          (set_visitor,42,"trp_norse_level2_landed"),
          (set_visitor,43,"trp_norse_level2_landed"),
          (set_visitor,44,"trp_norse_level2_landed"),
          (set_visitor,45,"trp_norse_level2_landed"),
          (set_visitor,46,"trp_norse_level2_landed"),
          (set_visitor,47,"trp_norse_level2_landed"),
          (set_visitor,48,"trp_norse_elitearcher"),
          (set_visitor,49,"trp_norse_elitearcher"),
          
          #(set_jump_entry, 0),
          (scene_set_slot, "scn_redingum_camp", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_redingum_camp"),
          (change_screen_mission),
      ]),
      
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  #####
  (
    "the_speech_l",0,
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_post_battle_menu"),
      
      (str_clear, s4),
      (try_begin),
        (eq, "$player_side", 1), #West Seaxe
        (str_store_string, s4, "@Aelfred gives the order, and horns call men outside the camp. You follow the brother of the king of West Seaxe outside, where his men have formed the ranks. They are led by officers and waiting.^^" +
        "There is a tense silence filled with nerves and worry. The Saxon warriors know that the fate of West Seaxe hangs by a thread. If they fall defeated, nothing will keep the Danish from plundering their houses and enslaving their families."),
        # phaiak begin
        (try_begin),
          (quest_slot_ge,"qst_aescesdun",slot_quest_current_state, 9),
          (jump_to_menu, "mnu_thetravel_danisharmy_l"),
        (end_try),
        # phaiak end
        
      (else_try),
        (eq, "$player_side", 2), #Danish
        (str_store_string, s4, "@Halfdan gives the order, and horns call men outside the camp. You follow Ragnar's son outside, where his men have formed ranks. They are led by officers and waiting.^^" +
        "The Danish warriors are animated and some even joke, motivated by the recent victory over their enemies, but all voices fall silent when Halfdan arrives before them."),
        # phaiak begin
        (try_begin),
          (quest_slot_ge,"qst_aescesdun",slot_quest_current_state, 9),
          (jump_to_menu, "mnu_thetravel_danisharmy_l"),
        (end_try),
        # phaiak end
        
      (try_end),
    ],
    [
      ("the_speech",[
        ],"Join them.",
        [
          (try_begin),
            (eq, "$player_side", 1), #West Seaxe
            (set_jump_mission,"mt_speechad_camp"),
            (modify_visitors_at_site,"scn_redingum_camp_speech"),
            (reset_visitors, 0),
            (set_visitor,0,"trp_player"),
            
            (set_visitor,10,"trp_knight_5_1"), #Halfdan
            #static guards
            (set_visitor,11,"trp_saxon_bowman"),
            (set_visitor,12,"trp_saxon_bowman"),
            (set_visitor,13,"trp_saxon_bowman"),
            (set_visitor,14,"trp_saxon_bowman"),
            (set_visitor,15,"trp_saxon_level0_landed"),
            (set_visitor,16,"trp_saxon_level0_landed"),
            (set_visitor,17,"trp_norse_level1_landed"),
            (set_visitor,18,"trp_norse_level1_landed"),
            (set_visitor,19,"trp_saxon_bowman"),
            (set_visitor,20,"trp_saxon_bowman"),
            (set_visitor,21,"trp_saxon_bowman"),
            (set_visitor,22,"trp_saxon_bowman"),
            #walkers
            (set_visitor,23,"trp_saxon_level0_landed"),
            (set_visitor,24,"trp_saxon_level0_landed"),
            (set_visitor,25,"trp_saxon_slave"),
            (set_visitor,26,"trp_saxon_slave"),
            (set_visitor,27,"trp_saxon_level0_companion"),
            (set_visitor,28,"trp_saxon_level0_companion"),
            (set_visitor,29,"trp_saxon_standard_bearer"),
            (set_visitor,30,"trp_saxon_level1_landed"),
            (set_visitor,31,"trp_saxon_priest"),
            (set_visitor,32,"trp_saxon_level1_landed"),
            (set_visitor,33,"trp_saxon_level1_landed"),
            (set_visitor,34,"trp_saxon_level2_landed"),
            (set_visitor,35,"trp_saxon_level2_landed"),
            (set_visitor,36,"trp_saxon_level3_landed"),
            (set_visitor,37,"trp_saxon_level3_landed"),
            (set_visitor,38,"trp_saxon_level3_landed"),
            (set_visitor,39,"trp_saxon_slave"),
            (set_visitor,40,"trp_saxon_slave"),
            (set_visitor,41,"trp_saxon_level3_landed"),
            (set_visitor,42,"trp_saxon_level2_landed"),
            (set_visitor,43,"trp_saxon_level2_landed"),
            (set_visitor,44,"trp_saxon_level3_landed"),
            (set_visitor,45,"trp_saxon_level0_companion"),
            (set_visitor,46,"trp_saxon_level0_companion"),
            (set_visitor,47,"trp_saxon_level0_companion"),
            (set_visitor,48,"trp_saxon_level0_landed"),
            (set_visitor,49,"trp_saxon_level0_landed"),
            
            #(set_jump_entry, 0),
            (scene_set_slot, "scn_redingum_camp_speech", slot_scene_visited, 1),
            (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 4),
            
            (jump_to_scene,"scn_redingum_camp_speech"),
          (else_try),
            (eq, "$player_side", 2), #Danish
            (set_jump_mission,"mt_speechad_camp"),
            (modify_visitors_at_site,"scn_redingum_camp_speech"),
            (reset_visitors, 0),
            (set_visitor,0,"trp_player"),
            
            (set_visitor,10,"trp_kingdom_8_lord"), #Halfdan
            #static guards
            (set_visitor,11,"trp_norse_bowman"),
            (set_visitor,12,"trp_norse_bowman"),
            (set_visitor,13,"trp_norse_bowman"),
            (set_visitor,14,"trp_norse_bowman"),
            (set_visitor,15,"trp_norse_level1_landed"),
            (set_visitor,16,"trp_norse_level1_landed"),
            (set_visitor,17,"trp_norse_level1_landed"),
            (set_visitor,18,"trp_norse_level1_landed"),
            (set_visitor,19,"trp_norse_bowman"),
            (set_visitor,20,"trp_norse_bowman"),
            (set_visitor,21,"trp_norse_bowman"),
            (set_visitor,22,"trp_norse_bowman"),
            #walkers
            (set_visitor,23,"trp_norse_slave"),
            (set_visitor,24,"trp_norse_slave"),
            (set_visitor,25,"trp_norse_slave"),
            (set_visitor,26,"trp_norse_slave"),
            (set_visitor,27,"trp_norse_level0_landed"),
            (set_visitor,28,"trp_norse_level0_landed"),
            (set_visitor,29,"trp_norse_standard_bearer"),
            (set_visitor,30,"trp_norse_elitearcher"),
            (set_visitor,31,"trp_norse_priest"),
            (set_visitor,32,"trp_norse_level1_companion"),
            (set_visitor,33,"trp_norse_level2_companion"),
            (set_visitor,34,"trp_norse_level2_companion"),
            (set_visitor,35,"trp_norse_level2_companion"),
            (set_visitor,36,"trp_norse_level1_companion"),
            (set_visitor,37,"trp_norse_level3_landed"),
            (set_visitor,38,"trp_norse_level3_landed"),
            (set_visitor,39,"trp_norse_level3_landed"),
            (set_visitor,40,"trp_norse_level3_landed"),
            (set_visitor,41,"trp_norse_level2_landed"),
            (set_visitor,42,"trp_norse_level2_landed"),
            (set_visitor,43,"trp_norse_level2_landed"),
            (set_visitor,44,"trp_norse_level2_landed"),
            (set_visitor,45,"trp_norse_level2_landed"),
            (set_visitor,46,"trp_norse_level2_landed"),
            (set_visitor,47,"trp_norse_level2_landed"),
            (set_visitor,48,"trp_norse_elitearcher"),
            (set_visitor,49,"trp_norse_elitearcher"),
            
            #(set_jump_entry, 0),
            (scene_set_slot, "scn_redingum_camp_speech", slot_scene_visited, 1),
            (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 4),
            
            (jump_to_scene,"scn_redingum_camp_speech"),
          (try_end),
          (play_track, "track_mount_and_blade_title_screen", 2), #music
          (change_screen_mission),
      ]),
    ],
  ),
  ################
  
  ##the travel to aescendun
  (
    "thetravel_danisharmy_l",0,
    "The Danish army, the Great Summer Army, has reached Aescendun.^^" +
    "King Aethelred has divided his army in two: one led by himself and the other in the hands of his brother, young Aelfred. Each division takes one side of the ancient road, the Ridgeway.^^" +
    "While the Vikings deploy, Aethelred decides that he must pray before the battle and refuses to budge until the service is complete. " +
    "But the Danish approach quickly, their army also split in two...",
    "none",
    [(set_background_mesh, "mesh_pic_charge"),
      
      (try_begin),
        (check_quest_active,"qst_aescesdun"),
        (quest_slot_eq,"qst_aescesdun",slot_quest_current_state, 12),
        (party_get_position, pos2, "p_aescesdun"),
        (party_set_flags, "p_mega_danishrmy", pf_is_static, 0),
        # phaiak begin
        (party_get_position, pos3, "p_readingum"),
        (party_set_position, "p_mega_danishrmy", pos3),
        # phaiak end
        (party_set_ai_behavior, "p_mega_danishrmy", ai_bhvr_travel_to_point),
        (party_set_ai_target_position, "p_mega_danishrmy", pos2),
        (assign, "$auto_menu", "mnu_thetravel_danisharmy_l"),
        ##		(party_get_position, pos1, "p_mega_danishrmy"),
        ##		(party_set_position, "p_main_party", pos1),
        (rest_for_hours, 1 * 24, 0, 0),
        (set_camera_follow_party, "p_mega_danishrmy"),
        (assign, "$g_player_is_captive", 1),
        (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 13),
        (change_screen_map),
      (try_end),
      (try_begin),
        (check_quest_active,"qst_aescesdun"),
        (quest_slot_eq,"qst_aescesdun",slot_quest_current_state, 13),
        (party_get_position, pos1, "p_mega_danishrmy"),
        (party_set_position, "p_main_party", pos1),
      (try_end),
    ],
    [
      ("choice_01_3ddarm",[],"The Battle of Aescesdun.",
        [
          (set_camera_follow_party, "p_main_party"),
          (assign, "$g_player_is_captive", 0),
          #        (change_screen_map),
          (try_begin),
            (eq, "$player_side", 1), #West Seaxe
            (party_get_position, pos2, "p_main_party"),
            (party_set_flags, "p_mega_danishrmy", pf_default_behavior, 1),
            (party_set_ai_behavior, "p_mega_danishrmy", ai_bhvr_attack_party),
            (party_set_ai_object,"p_mega_danishrmy","p_main_party"),
          (else_try),
            (eq, "$player_side", 2), #Danish
            (party_get_position, pos2, "p_main_party"),
            (party_set_flags, "p_aescesdun", pf_is_static, 0),
            (party_set_flags, "p_aescesdun", pf_default_behavior, 1),
            (party_set_ai_behavior, "p_aescesdun", ai_bhvr_attack_party),
            (party_set_ai_object,"p_aescesdun","p_main_party"),
          (try_end),
          #  (auto_save), ###autosavegame
          (rest_for_hours, 3, 5, 1),
          #(rest_for_hours_interactive, 1, 1, 1),
          (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 14),
          (change_screen_map),
      ]),
    ]
  ),
  ####Aescesdun battle
  (
    "mega_battle_ashdown",mnf_enable_hot_keys,
    "The Saxon army has taken a vantage point on two hills, split in two. One of the hills is dominated by the troops of King Aethelred and the other by those of Aelfred. " +
    "The Danish move quickly, more than expected, not stopping to rest or form up. This is something that Aethelred did not anticipate. He is still immersed in his prayers and has ordered not to be disturbed until finished. " +
    "The Danish don't wait. They divide their own army into two in their advance. One division under the army leaders, Jarl Halfdan and King Bagsecg, heads straight for the hosts of Aethelred. The other, under five other jarls, moves in the direction of Aelfred. They start to seize the high ground on a hill above the Saxon positions. If they finish deploying, they will have the height advantage over their enemies...^^" +
    "{s2} You have {reg10} troops fit for battle against their {reg11}.",
    "none",
    [      (set_background_mesh, "mesh_pic_charge"),
      
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (try_begin),
        (eq, "$new_encounter", 1),
        (party_get_template_id, ":template_id", "$g_enemy_party"),
        (neq, ":template_id", "pt_routed_warriors"), #chief, los que huyen no luchan
        (call_script, "script_let_nearby_parties_join_current_battle", 0, 0),
      (try_end),
      (call_script, "script_encounter_calculate_fit"),
      (try_begin),
        (eq, "$new_encounter", 1),
        # (assign, "$new_encounter", 0),	MOTO chief move to end so it can be used!
        (assign, "$g_encounter_is_ally", 0),
        (assign, "$g_encounter_type", 0),
        # allies join battle at your side
        (try_begin),
          (eq, "$player_side", 1), #West Seaxe
          (assign, "$g_encounter_is_ally", "p_aescesdun"),
          (party_quick_attach_to_current_battle, "$g_encounter_is_ally", 0), #attach as friend
          (str_store_string, s1, "@West Seaxe"),
          (display_message, "str_s1_joined_battle_friend",color_good_news),
        (else_try),
          (eq, "$player_side", 2), #Danish
          (assign, "$g_encounter_is_ally", "p_mega_danishrmy"),
          (party_quick_attach_to_current_battle, "$g_encounter_is_ally", 0), #attach as friend
          (str_store_string, s1, "@Danish"),
          (display_message, "str_s1_joined_battle_friend",color_good_news),
        (try_end),
        
        (call_script, "script_encounter_init_variables"),
        (assign, "$encountered_party_hostile", 0),
        (assign, "$encountered_party_friendly", 0),
        (try_begin),
          (gt, "$g_encountered_party_relation", 10), #chief add relation, they dont join you if no good relation.
          (assign, "$encountered_party_friendly", 1),
        (try_end),
        
        (try_begin),
          (gt, "$g_encountered_party_relation", 0), #por debajo de 10 y por encima de 0 no luchan.
          (lt, "$g_encountered_party_relation", 10),
          (assign, "$encountered_party_friendly", 0),
        (try_end),
        
        (try_begin), ##chief , huidos no luchan
          (party_get_template_id, ":template_id", "$g_enemy_party"),
          (eq, ":template_id", "pt_routed_warriors"),
          (assign, "$encountered_party_friendly", 0),
        (try_end),
        
        (try_begin),
          (lt, "$g_encountered_party_relation", 0),
          (assign, "$encountered_party_hostile", 1),
          (try_begin),
            (encountered_party_is_attacker),
            (assign, "$cant_leave_encounter", 1),
          (try_end),
        (try_end),
        (assign, "$talk_context", tc_party_encounter),
        (call_script, "script_setup_party_meeting", "$g_encountered_party"),
      (else_try), #second or more turn
        #          (try_begin),
        #            (call_script, "script_encounter_calculate_morale_change"),
        #          (try_end),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (try_end),
      
      #setup s2
      (try_begin),
        (party_is_active, "$g_encountered_party"),
        (str_store_party_name, s1,"$g_encountered_party"),
        (str_store_string, s2,"@You have encountered {s1}."),
      (try_end),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1), #battle won
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
          (le, ":num_enemy_regulars_remaining",  "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign, ":enemy_finished",1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (ge, "$g_friend_fit_for_battle",1),
          (assign, ":enemy_finished",1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished",1),
        (eq,"$g_enemy_surrenders",1),
        (assign, "$g_next_menu", -1),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        (assign, ":friends_finished",0),
        (try_begin),
          (eq, "$g_battle_result", -1),
          
          (this_or_next|eq, ":num_our_regulars_remaining", 0), #battle lost
          (le, ":num_our_regulars_remaining",  "$num_routed_us"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign,  ":friends_finished", 1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (ge, "$g_enemy_fit_for_battle",1),
          (le, "$g_friend_fit_for_battle",0),
          (assign,  ":friends_finished",1),
        (try_end),
        
        (this_or_next|eq,  ":friends_finished",1),
        (eq,"$g_player_surrenders",1),
        
        (assign, "$g_next_menu", "mnu_captivity_start_wilderness"),
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
      
      (set_background_mesh, "mesh_pic_bandits"),
      
      #MOTO chief document skill requuirement
      (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),
      (party_get_num_companion_stacks, ":stacks", "p_main_party"),
      (try_begin),
        (lt, ":tactics", 1),
        (gt, ":stacks", 1),
        (eq, "$encountered_party_friendly", 0),
        (neg|troop_is_wounded, "trp_player"),
        #Chief sea battles
        (party_get_current_terrain,":terrain","p_main_party"),
        (neq,":terrain",0),
        (neq,":terrain",7),
        (neq,":terrain",8),
        #sea battles
        (str_store_string, s2, "@{s2}^^You overhear one of your more experienced men grumbling about the lack of a battle plan, and you make a mental note to find someone that can make one.^^"),
      (try_end),
      #MOTO chief end
      (assign, "$new_encounter", 0),	#MOTO move to end so it can be used!
    ],
    [
      ("encounter_attackasc",
        [
          #(eq, "$encountered_party_friendly", 0),
          #(neg|troop_is_wounded, "trp_player"),
        ],
        "Battle of Aescesdun.",
        [
          # (neg|troop_is_wounded, "trp_player"),
          
          (call_script, "script_set_parties_around_player_ignore_player", 15, 5), #Add 90 to 100 hours without bandits attacks
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          # (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (try_begin),
            (encountered_party_is_attacker),
            (select_enemy, 1),
          (else_try),
            (select_enemy, 0),
          (try_end),
          (assign, ":scene_to_use", "scn_ashdown_battle"),
          (jump_to_scene, ":scene_to_use"),
          (set_jump_mission,"mt_ashdown_battle"),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
          (assign, "$player_deploy_troops", 1),	#MOTO
      ]),
    ]
  ),
  ###################
  (
    "svenbn_hunting",0,
    "On the way from the battlefield, all you see are broken weapons, corpses, wounded men, looters, and priests giving final unction to the dying. You feel a mix of the euphoria of remaining alive with a strong sense of desolation. " +
    "But mostly, you ask one recurring question: why? Why am I alive when so many others died?^^" +
    "But your thoughts and fate walk in different directions. {s4}",
    "none",
    [(play_sound, "snd_raven"),(set_background_mesh, "mesh_pic_raven"),
      (str_clear, s4),
      (try_begin),
        (eq, "$player_side", 1), #West Seaxe
        (str_store_string, s4, "@You notice that Aelfred is coming towards you. It was he who saved the day with his charge when the Danish tried to gain the hill. " +
        "Without that improvisation, probably you would all be dead now..."),
      (else_try),
        (eq, "$player_side", 2), #Danish
        (str_store_string, s4, "@Halfdan walks towards you. You see him covered in blood, but he is smiling. He knows that without you and your army, he would have lost that battle."),
      (try_end),
      (try_begin),
        (check_quest_active, "qst_svenbn_final"),
        (leave_encounter),
        #(change_screen_map),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("talk_to_leader",[
        ],
        "Talk to him.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19, 20, 21, 22, 23 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points The 3 entry points for prisoners in scene 1 is: 16, 17 & 18.
          (set_visitor,0,"trp_player"),
          
          (disable_party, "p_aescesdun"), #esconde la playa
          (disable_party, "p_mega_danishrmy"), #esconde la playa
          (enable_party, "p_destroy3"), #esconde la playa
          (assign, "$g_lord_hide", -1), #back lords #unhide lords
          
          
          (try_begin),
            (eq, "$player_side", 1), #West Seaxe
            (set_visitor,17,"trp_knight_5_1"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation3people_scene"),
            (change_screen_map_conversation, "trp_knight_5_1"),
          (else_try),
            (eq, "$player_side", 2), #Danish
            (set_visitor,17,"trp_kingdom_8_lord"),
            (set_jump_mission,"mt_conversation_encounter"),
            (jump_to_scene,"scn_conversation3people_scene"),
            (change_screen_map_conversation, "trp_kingdom_8_lord"),
          (try_end),
      ]),
    ]
  ),
  ("ashdown_battle_over",0,
    "The battle is over, but the thunder of shields and swords, screams of men, and the cries of the wounded still ring in your ears. Your stiff hand is squeezing your weapon. You can still feel the tension of the battle, and your senses remain on high alert. " +
    "You've survived carnage, just as you have many times before, by always living on the edge, always relying on your trusty sword. You've won today, but you know that your luck will end one day. Then, your life will be over, giving glory and fame to the one who kills you.^^" +
    "Aescesdun has not been just any battle. It brought together hundreds of men, and most of them are now lying dead in the grass. The story of Aescesdun will surely be retold by bards and storytellers for many years to come.",
    "none",
    [(set_background_mesh, "mesh_pic_raven"),
    ],
    [
      ("aescesdun_no",[],"Continue.",
        [
          ##                 (leave_encounter),
          ##				(rest_for_hours, 2, 5, 0),
          ##		 (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          (quest_set_slot,"qst_aescesdun",slot_quest_current_state, 20),
          (jump_to_menu,"mnu_svenbn_hunting"),
        ]
      ),
    ]
  ),
  #################
  #Followers camp chief
  ("followers_camp_begin",0,
    "Attracted by the growth of your army, some priests and women have joined you lately. Now, even some merchants seek permission to follow you.^^" +
    "Although they would give your army easy access to many services that will improve the morale of your men, they will slow your army.^^" +
    "Followers' services are accessible in your camp area.",
    "none",
    [(set_background_mesh, "mesh_pic_smith"),
    ],
    [
      ("followers_yes",[],"Sure. They are welcome.",
        [
          (try_begin),
            (eq, "$g_player_faith", 2), #player pagano
            (party_add_members, "p_followers_camp", "trp_norse_priest", 1),
          (else_try),
            (party_add_members, "p_followers_camp", "trp_saxon_priest", 1),
          (try_end),
          (party_add_members, "p_followers_camp", "trp_town_31_weaponsmith", 1),
          (party_add_members, "p_followers_camp", "trp_town_30_healer", 1),
          (party_add_members, "p_followers_camp", "trp_ransom_broker_20", 1),
          (party_add_members, "p_followers_camp", "trp_hunter_woman", 12),
          (party_add_members, "p_followers_camp", "trp_fighter_woman", 6),
          (assign,"$followers_on",1), #on
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
      ("followers_no",[],"No. This is an army, not a puppet show.",
        [
          (assign,"$followers_on",2), #no offer option until 24*14
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  
  ("followers_camp_leave",0,
    "Recent events and the drastic reduction in the number of your men have caused your camp followers disperse...",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
    ],
    [
      ("damn",[],"Damn.",
        [
          ##		(party_get_num_companion_stacks, ":num_stacks","p_followers_camp"),
          ##		(try_for_range, ":stack_no", 0, ":num_stacks"),
          ##			(party_stack_get_troop_id, ":stack_troop","p_followers_camp",":stack_no"),
          ##			(party_stack_get_size, ":stack_size","p_followers_camp",":stack_no"),
          ##			(party_remove_members,"p_followers_camp",":stack_troop",":stack_size"),
          ##		(try_end),
          (party_clear, "p_followers_camp"), #
          (troop_clear_inventory, "trp_household_possessions2"), #player lose mules
          (assign,"$followers_on",2), #no offer option until 24*14
          (call_script, "script_change_player_party_morale", -10),
          (display_message,"@Your followers decided to leave you."),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  
  ("followers_remove",0,
    "Are you sure you want to disperse your followers? This will make your followers stop accompanying your army. " +
    "This may mean a strong negative impact on the morale of your men.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
    ],
    [
      ("yes_dot",[],"Yes.",
        [
          (party_clear, "p_followers_camp"), #
          
          (troop_clear_inventory, "trp_household_possessions2"), #player lose mules
          (assign,"$followers_on",2), #no offer option until 24*14
          (call_script, "script_change_player_party_morale", -15),
          (display_message,"@You chose to disperse your followers."),
          (jump_to_menu, "mnu_camp"),
        ]
      ),
      ("no_dot",[],"No.",
        [
          (start_presentation, "prsnt_followers_screen_camp"),
        ]
      ),
    ]
  ),
  
  ####################
  
  (
    "sven_bullneck_readingum",0,
    "The site has good defenses and moat, and there are still remnants of the previous battle, when the Saxons tried to expel the Danish. " +
    "It is a good position to defend.^^" +
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_castledes"),
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      (str_clear, s4),
      (try_begin),
        (check_quest_active,"qst_svenbn_final"),
        (quest_slot_eq,"qst_svenbn_final",slot_quest_current_state, 1),
        (try_begin),
          (eq, "$player_side", 1), #West Seaxe
          (str_store_string, s4, "@You notice that a group of men approaching you. It is led by a tall man. This must be Eadric, the man mentioned by Aelfred."),
        (else_try),
          (eq, "$player_side", 2), #Danish
          (str_store_string, s4, "@You notice that a group of men approaching you. It is led by a tall man. This must be Arnvid, the man mentioned by Halfdan."),
        (try_end),
      (try_end),
      
      (assign, "$g_enemy_party", "$g_encountered_party"),
      (assign, "$g_ally_party", -1),
      (try_begin),
        (eq, "$new_encounter", 1),
        (party_get_template_id, ":template_id", "$g_enemy_party"),
        (neq, ":template_id", "pt_routed_warriors"), #chief, los que huyen no luchan
        (call_script, "script_let_nearby_parties_join_current_battle", 0, 0),
      (try_end),
      (call_script, "script_encounter_calculate_fit"),
      (try_begin),
        (eq, "$new_encounter", 1),
        # (assign, "$new_encounter", 0),	MOTO chief move to end so it can be used!
        (assign, "$g_encounter_is_ally", 0),
        (assign, "$g_encounter_type", 0),
        (call_script, "script_encounter_init_variables"),
        (assign, "$encountered_party_hostile", 0),
        (assign, "$encountered_party_friendly", 0),
        (try_begin),
          (gt, "$g_encountered_party_relation", 10), #chief add relation, they dont join you if no good relation.
          (assign, "$encountered_party_friendly", 1),
        (try_end),
        
        (try_begin),
          (gt, "$g_encountered_party_relation", 0), #por debajo de 10 y por encima de 0 no luchan.
          (lt, "$g_encountered_party_relation", 10),
          (assign, "$encountered_party_friendly", 0),
        (try_end),
        
        (try_begin), ##chief , huidos no luchan
          (party_get_template_id, ":template_id", "$g_enemy_party"),
          (eq, ":template_id", "pt_routed_warriors"),
          (assign, "$encountered_party_friendly", 0),
        (try_end),
        
        (try_begin),
          (lt, "$g_encountered_party_relation", 0),
          (assign, "$encountered_party_hostile", 1),
          (try_begin),
            (encountered_party_is_attacker),
            (assign, "$cant_leave_encounter", 1),
          (try_end),
        (try_end),
        (assign, "$talk_context", tc_party_encounter),
        (call_script, "script_setup_party_meeting", "$g_encountered_party"),
      (else_try), #second or more turn
        #          (try_begin),
        #            (call_script, "script_encounter_calculate_morale_change"),
        #          (try_end),
        (eq, "$g_leave_encounter",1),
        (change_screen_return),
      (try_end),
      
      #setup s2
      (try_begin),
        (party_is_active, "$g_encountered_party"),
        (str_store_party_name, s1,"$g_encountered_party"),
        (str_store_string, s2,"@You have encountered {s1}."),
      (try_end),
      (try_begin),
        (call_script, "script_party_count_members_with_full_health", "p_collective_enemy"),
        (assign, ":num_enemy_regulars_remaining", reg0),
        (assign, ":enemy_finished", 0),
        (try_begin),
          (eq, "$g_battle_result", 1), #battle won
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0), #battle won
          (le, ":num_enemy_regulars_remaining",  "$num_routed_enemies"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign, ":enemy_finished",1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          
          (this_or_next|le, ":num_enemy_regulars_remaining", 0),
          (le, "$g_enemy_fit_for_battle", "$num_routed_enemies"),  #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (ge, "$g_friend_fit_for_battle",1),
          (assign, ":enemy_finished",1),
        (try_end),
        
        (this_or_next|eq, ":enemy_finished",1),
        (eq,"$g_enemy_surrenders",1),
        (assign, "$g_next_menu", -1),
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        (call_script, "script_party_count_members_with_full_health", "p_main_party"),
        (assign, ":num_our_regulars_remaining", reg0),
        (assign, ":friends_finished",0),
        (try_begin),
          (eq, "$g_battle_result", -1),
          
          (this_or_next|eq, ":num_our_regulars_remaining", 0), #battle lost
          (le, ":num_our_regulars_remaining",  "$num_routed_us"), #replaced for above line because we do not want routed agents to spawn again in next turn of battle.
          
          (assign,  ":friends_finished", 1),
        (else_try),
          (eq, "$g_engaged_enemy", 1),
          (ge, "$g_enemy_fit_for_battle",1),
          (le, "$g_friend_fit_for_battle",0),
          (assign,  ":friends_finished",1),
        (try_end),
        
        (this_or_next|eq,  ":friends_finished",1),
        (eq,"$g_player_surrenders",1),
        
        (assign, "$g_next_menu", "mnu_captivity_start_wilderness"),
        (jump_to_menu, "mnu_total_defeat"),
      (try_end),
      
      (set_background_mesh, "mesh_pic_bandits"),
      
      #MOTO chief document skill requuirement
      (party_get_skill_level, ":tactics", "p_main_party", skl_tactics),
      (party_get_num_companion_stacks, ":stacks", "p_main_party"),
      (try_begin),
        (lt, ":tactics", 1),
        (gt, ":stacks", 1),
        (eq, "$encountered_party_friendly", 0),
        (neg|troop_is_wounded, "trp_player"),
        #Chief sea battles
        (party_get_current_terrain,":terrain","p_main_party"),
        (neq,":terrain",0),
        (neq,":terrain",7),
        (neq,":terrain",8),
        #sea battles
        (str_store_string, s2, "@{s2}^^You overhear one of your more experienced men grumbling about the lack of a battle plan, and you make a mental note to find someone that can make one.^^"),
      (try_end),
      #MOTO chief end
      (try_begin), #VC-3838
        (quest_slot_ge,"qst_svenbn_final",slot_quest_current_state, 3), #battle scene was entered...
        (neg|quest_slot_ge,"qst_svenbn_final",slot_quest_current_state, 8), #but convo not completed?
        (quest_set_slot,"qst_svenbn_final",slot_quest_current_state, 2),
      (try_end),
      
      (assign, "$new_encounter", 0),	#MOTO move to end so it can be used!
    ],
    [
      
      ("talk_to_leadermen",[               (check_quest_active,"qst_svenbn_final"),
          (quest_slot_eq,"qst_svenbn_final",slot_quest_current_state, 1),
          
        ],
        "Talk to him.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points
          (set_visitor,0,"trp_player"),
          (set_visitor,16,"trp_leader_playerrf"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_leader_playerrf")
      ]),
      
      ("enter_to_talk_sven",[(check_quest_active,"qst_svenbn_final"),
          (quest_slot_eq,"qst_svenbn_final",slot_quest_current_state, 2),
        ],
        "Get closer to Readingum.",[
          (modify_visitors_at_site,"scn_redingum"),
          (reset_visitors, 0),
          # (reset_visitors),
          
          (try_for_range, ":visiterator", 20, 30),
            (set_visitor, ":visiterator", "trp_taiga_bandit",),
          (try_end),
          
          (set_visitor,0,"trp_player"),
          
          (set_visitor,41,"trp_elite_viking"),
          
          (set_visitor,40,"trp_sven_bull_neck"),
          
          (set_visitor,10,"trp_your_motherold"),
          (set_visitor,42,"trp_elite_viking"),
          
          (set_jump_mission,"mt_readingum_svenbn"),
          (jump_to_scene,"scn_redingum"),
          (change_screen_mission),
      ]),
      ####
      ("svenreadingum_attack",[#(neg|troop_is_wounded, "trp_player"),
          (check_quest_active,"qst_svenbn_final"),
          (quest_slot_eq,"qst_svenbn_final",slot_quest_current_state, 8),
          
          (assign, ":continue", 0),
          (try_begin),
            (store_party_size_wo_prisoners, ":party_size", "p_main_party"),
            (lt, ":party_size", 100),
            (assign, ":continue", 1),
            (display_message, "@You aren't ready to face Sven. Return when you have over one hundred men in your shield wall."),
            # (jump_to_menu, "mnu_noaccessallowed"),
          (try_end),
          (eq, ":continue", 0),
          
          ],"Total Assault!",[
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          
          # (party_get_template_id, ":encountered_party_template", "$g_encountered_party"),
          
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (try_begin),
            (encountered_party_is_attacker),
            (select_enemy, 1),
          (else_try),
            (select_enemy, 0),
          (try_end),
          (assign, ":scene_to_use", "scn_redingum"),
          (jump_to_scene, ":scene_to_use"),
          (set_jump_mission,"mt_readingum_svenbattle"),
          (assign, "$g_next_menu", "mnu_simple_encounter"),
          (jump_to_menu, "mnu_battle_debrief"),
          (change_screen_mission),
      ]),
      
      ("choice_doccingatsvf",[
          (check_quest_active,"qst_svenbn_final"),
          (quest_slot_eq,"qst_svenbn_final",slot_quest_current_state, 8),
          
          (assign, ":continue", 0),
          (try_begin),
            (store_party_size_wo_prisoners, ":party_size", "p_main_party"),
            (ge, ":party_size", 100),
            (assign, ":continue", 1),
          (try_end),
          (eq, ":continue", 0),
          
        ],"I need to recruit more men.",
        [
          (display_message, "@You aren't ready to face Sven. Return when you have over one hundred men in your shield wall."),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          # (start_presentation, "prsnt_auto_save")
      ]),
      ##    ("choice_doccinga",[],"Save.", #save
      ##        [
      ##                (start_presentation, "prsnt_auto_save")
      ##        ]),
      ("leave",[
        ],"Leave.",
        [
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ################### sven final
  (
    "sven_halllatest",0,
    "The slaughter continues in Readingum, your men still fighting against the remnants of Sven's troops, but that is not the battle you seek. " +
    "Sven Bull Neck has barricaded himself in the mead hall of Readingum, taking your mother and a few men with him. It's time to end this party...",
    "none",
    [(set_background_mesh, "mesh_pic_castledes"),
      
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
      
    ],
    [
      ("fight_svhall",[
        ],"Enter the mead hall.",
        [
          (set_jump_mission,"mt_kill_to_sven"),
          (modify_visitors_at_site,"scn_reading_camp_hall"),
          
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"), #player
          (assign, ":cur_entry", 1), #no companions, more difficult?
          (try_for_range, ":companion", companions_begin, companions_end),
            (main_party_has_troop,":companion"),
            (set_visitor, ":cur_entry", ":companion"),
            (val_add, ":cur_entry", 1),
          (try_end),
          #enemies
          (set_visitor,9,"trp_sven_bull_neck"),
          (set_visitor,10,"trp_taiga_bandit"),
          (set_visitor,11,"trp_taiga_bandit"),
          (set_visitor,12,"trp_taiga_bandit"),
          (set_visitor,13,"trp_elite_viking"),
          (set_visitor,14,"trp_elite_viking"),
          (set_visitor,16,"trp_sea_raider_leader2"),
          (set_visitor,17,"trp_your_motherold"),
          (jump_to_scene,"scn_reading_camp_hall"),
          (change_screen_mission),
      ]),
      
    ],
  ),
  ####################
  (
    "mother_death",0,
    "Sven Bull Neck finally lies dead. You have accomplished your revenge, but you are left with a bitter taste in your mouth, because your mother's dead body is lying not far from Sven's. The woman who raised you. For her, you left everything behind to seek a healer in Friese. " +
    "Her last words of love resonate in your mind, like a distant echo.^^" +
    "Sven Bull Neck and your mother have been the energy that has driven you so far, but both are now dead. You feel a void, as if part of you went with them.^^" +
    "After everything that happened, all you have left are memories...",
    "none",
    [(set_background_mesh, "mesh_pic_siege_victory"),
      
      ##        (try_begin),
      ##            (check_quest_active,"qst_kennemer_jarl_missions"),
      ##            (quest_slot_eq,"qst_kennemer_jarl_missions",slot_quest_current_state, 9),
      ##            (call_script, "script_end_quest", "qst_kennemer_jarl_missions"),
      ##                   (leave_encounter),
      ##                   (change_screen_map),
      ##        (try_end),
    ],
    [
      ("mother_funeral",[
        ],"Hold a funeral.",
        [
          ###funeral mt (fire for pagan or no fire for christian) + Beda talk about player leave world, kingdoms, companions, and finally himself + Credits. Then option to leave or quest be Brytenwalda.
          # (leave_encounter),
          # #(change_screen_map),
          # (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          (play_track, "track_outdoor_beautiful_land", 1), #funeral song
          
          (set_jump_mission, "mt_funeral"),
          (jump_to_scene, "scn_mainquest_funeral"),
          (modify_visitors_at_site,"scn_mainquest_funeral"),
          (reset_visitors),
          (set_visitor, 0, "trp_player"),
          (try_for_range, ":counter", 1, 41),
            (store_random_in_range, ":troop", "trp_town_walker_1", "trp_nino_varon"),
            (set_visitor, ":counter", ":troop"),
          (end_try),
          (set_visitor, 41, "trp_pagano"),
          (set_visitor, 42, "trp_village_walker_1"),
          (set_visitor, 43, "trp_village_walker_2"),
          (music_set_situation, mtf_sit_killed),
          (change_screen_mission),
      ]),
    ],
  ),
  
  
  ###add-ons story menus
  #add-ons messenger, starting story
  (
    "addons_messenger",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
    "'To the {reg59?woman:man}, named {playername}: my master, the abbot of Finian has sent me. He has heard of you and wants to talk about an important mission. " +
    "He asks you to visit him at his monastery, Finian, near Bal Eachadha. He will pay you 1000 peningas just to come and listen to him.'",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("morrigan_1",[],"Tell the abbot that the message has been received.",
        [
          
          (str_store_party_name_link, s3, "p_village_74"),
          (str_store_string, s2, "@The abbot of Finian, near {s3} in Eriu, has asked for your presence. Apparently, he has an important mission to offer. " +
          "He is offering 1000 peningas just for you to appear in front of him."),
          (call_script, "script_start_quest", "qst_blank_quest_23", "trp_abad"),
          (quest_set_slot,"qst_blank_quest_23",slot_quest_current_state, 0), #status 0
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "addons_messenger_morriganlair",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
    "'To the {reg59?woman:man} named {playername}: my warlord, Olchobar mac Cinaeda and his companion, Aed mac Ainmerech, have sent me. They have found Morrigan's lair in the west, and they are waiting for you before attacking.'",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("morriganlair_1",[],"Tell your warlord that I am coming.",
        [
          
          (str_store_party_name_link, s3, "p_village_74"),
          (str_store_string, s2, "@The other two champions have followed Morrigan to her lair and sent a messenger to inform you where they are. They await your arrival before attacking. The moment is here to go to Morrigan's lair."),
          (add_quest_note_from_sreg, "qst_blank_quest_23", 8, s2, 0),
          (quest_set_slot,"qst_blank_quest_23",slot_quest_current_state, 5), #status 0
          (enable_party, "p_morrigan_lair"),
          (leave_encounter),
          #(change_screen_map),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "first_attack_morrigan",0,
    "You know, from the directions given by Caliacas, that the old man's burned hut isn't far from the village, but you're unable to see it. " +
    "Deep, cold and unnatural fog has blown over everything and lets you see only what is maybe a pace in front of you. " +
    "As if this were not enough, you hear wolves howling in the distance... each time closer and closer.^^" +
    "Next... your ears are flooded with a melody. Morrigan has found you.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      
      (play_track, "track_morrigan_song", 1),
      (try_begin),
        (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
        (lt, ":health", 30),
        (val_add, ":health", 35),               #add to it the 5%
        (troop_set_health,   "trp_player", ":health"),   #set it
      (try_end),
    ],
    [
      ("morrigan_ambush",[
          ],"Fight!",[
          (assign, "$g_encountered_party", "p_oldpagan_hut"),
          (party_clear, "$g_encountered_party"),
          (party_add_members, "$g_encountered_party", "trp_sea_raider_leader" , 15), #Berserkr
          (party_add_members, "$g_encountered_party", "trp_looter_leader" , 35), #Ulfhedinn
          (select_enemy, 0),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (set_jump_mission,"mt_morrigan_ambush"),
          (jump_to_scene,"scn_ambush_farmland"),
          (change_screen_mission),
      ]),
      # ("leavesl",[],"Come back later.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  ######
  (
    "morrigan_leave",0,
    "Your enemies run at the sound of the horns. The fog around you seems to fade, or maybe, now that you are calmer, your eyes simply see better through it. " +
    "Your enemy is gone, but strangely left no corpses. The swords of your men had not caused them any casualties.^^" +
    "The horns sound nearer, and in the place where you find yourselves, men begin to enter. They are just are few, certainly less than the sound of their horns led you to believe. " +
    "One of your men brings their leaders to you.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      
      (try_begin),
        (check_quest_active, "qst_blank_quest_23"),
        (quest_slot_eq,"qst_blank_quest_23",slot_quest_current_state,3),
        (disable_party, "p_oldpagan_hut"),
        (leave_encounter),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
      
    ],
    [
      ("campeones_primerencuentro",[
        ],"Talk to them.",
        [
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"trp_campeon_1"),
          (set_visitor,18,"trp_campeon_2"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_campeon_1")
          ##                 (leave_encounter),
          ##                 #(change_screen_map),
          ##		 (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  ### Morrigan's lair
  (
    "morrigan_lair_attack",0,
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_cave"),
      (str_clear, s4),
      (try_begin),
        (check_quest_active, "qst_blank_quest_23"),
        (quest_slot_eq,"qst_blank_quest_23",slot_quest_current_state,5),
        (str_store_string, s4, "@Near the end of the world, where the waves beat the cliffs and the albatrosses nest, there is a little rough valley, barely visible from a distance. A cave is hidden there. " +
          "You cannot control it; Morrigan song resonates in your head, and you feel your lips move to it. It breathes magic...^^" +
          "Far from the cave, half hidden by rocks, you can distinguish the two champions with a few men. " +
          "They seem to have left the bulk of their army hidden elsewhere to avoid attracting attention. They wait.^^" +
        "But when you take a step toward them, the song intensifies. This time, it is not in your mind... Morrigan's beasts attack you!"),
        (play_track, "track_morrigan_song", 1),
      (else_try),
        (check_quest_active, "qst_blank_quest_23"),
        (quest_get_slot,":stage","qst_blank_quest_23",slot_quest_current_state),
        (ge,":stage",6),
        (le,":stage",7),
        #(quest_slot_eq,"qst_blank_quest_23",slot_quest_current_state,6),
        (str_store_string, s4, "@The battle was tough and pushed you near the valley. Your men stayed behind, protecting the rear, because they realized numbers are useless in the narrow valley. " +
        "It is time to seek the support of the other champions and move towards Morrigan before her forces reorganize."),
      (else_try), #morrigan finish, exit place
        (str_store_string, s4, "@The mystery of Morrigan having been solved, it seems that the fog dissipates and the world regains its colors. You leave behind the cave and the terror."),
      (try_end),
      
      #           (play_track, "track_morrigan_song", 1),
    ],
    [
      ("morrigan_ambush2n",[(check_quest_active, "qst_blank_quest_23"),
          (quest_slot_eq,"qst_blank_quest_23",slot_quest_current_state,5),
          ],"Fight!",[
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          (assign, "$g_encountered_party", "p_morrigan_lair"),
          (party_clear, "$g_encountered_party"),
          (party_add_members, "$g_encountered_party", "trp_sea_raider_leader" , 15), #Berserkr
          (party_add_members, "$g_encountered_party", "trp_looter_leader" , 35), #Ulfhedinn
          (quest_set_slot,"qst_blank_quest_23",slot_quest_current_state, 6), #status 0
          (select_enemy, 0),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (set_jump_mission,"mt_morrigan_ambush_2"),
          (jump_to_scene,"scn_ambush_coast"),
          (change_screen_mission),
      ]),
      ("enter_morriganlairch",[(check_quest_active,"qst_blank_quest_23"),
          (quest_get_slot,":stage","qst_blank_quest_23",slot_quest_current_state),
          (ge,":stage",6),
          (le,":stage",7),
          #(quest_slot_eq,"qst_blank_quest_23",slot_quest_current_state, 6),
        ],"Approach the champions.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_morrigan_lair_final"),
          (modify_visitors_at_site,"scn_morrigan_lair"),
          (reset_visitors),
          (assign, ":cur_entry", 1), #entry points 1 to 10
          (try_for_range, ":companion", companions_begin, companions_end),
            (le, ":cur_entry", 10),
            (main_party_has_troop,":companion"),
            (set_visitor, ":cur_entry", ":companion"),
            (val_add, ":cur_entry", 1),
          (try_end),
          #entry points 21-24 for champions
          (set_visitor,21,"trp_campeon_1"),
          (set_visitor,22,"trp_campeon_2"),
          (set_visitor,23,"trp_mercenary_swordsman"),
          (set_visitor,24,"trp_mercenary_swordsman"),
          
          #enemy basic entry points 11 to 20
          (set_visitor,11,"trp_fake_berserker"),
          (set_visitor,12,"trp_fake_berserker"),
          #  (set_visitor,13,"trp_fake_berserker"),
          (set_visitor,14,"trp_fake_berserker"),
          # (set_visitor,15,"trp_fake_berserker"),
          (set_visitor,16,"trp_fake_berserker"),
          (set_visitor,17,"trp_fake_berserker"),
          # (set_visitor,18,"trp_fake_berserker"),
          (set_visitor,19,"trp_looter_leader"),
          (set_visitor,20,"trp_looter_leader"),
          
          #entry points 25-29 for elite guards
          (set_visitor,25,"trp_sea_raider_leader"),
          #  (set_visitor,26,"trp_sea_raider_leader"),
          (set_visitor,27,"trp_sea_raider_leader"),
          #  (set_visitor,28,"trp_sea_raider_leader"),
          (set_visitor,29,"trp_looter_leader"),
          
          #entry point 40 for morrigan
          (set_visitor,30,"trp_morrigan_npc"), #morrigan
          
          (set_jump_entry, 0),
          (scene_set_slot, "scn_morrigan_lair", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_morrigan_lair"),
          (change_screen_mission),
      ]),
      ("leave",[(neg|quest_slot_eq,"qst_blank_quest_23",slot_quest_current_state,6),
          ],"Leave.",[
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "bresail_farm_visit",0,
    "{!}{s4}",
    "none",
    [
      (str_clear, s4),
      (try_begin),
        (check_quest_active, "qst_blank_quest_26"),
        (quest_get_slot, ":quest_current_state", "qst_blank_quest_26", slot_quest_current_state),
        (le, ":quest_current_state", 2),
        (str_store_string, s4, "@Mael Bresail's farm is the typical Irish farmhouse -- a large main house with smaller buildings about it, all surrounded by a palisade."),
        (set_background_mesh, "mesh_pic_farmstead"),
      (else_try),
        (check_quest_active, "qst_blank_quest_26"),
        (quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,3),
        (str_store_string, s4, "@You settle into the seat of honor in the great hall of the house. The best mead and wine brought from Frankia are at your disposal. The tastiest dishes fill the room with their aroma and delight your palate. " +
          "It is one of the best symbels you've ever enjoyed. Your men have fun, looking happy. " +
          "The hours pass without you noticing.^^Suddenly, you realize that all the women have left the room. What is happening? A burning smell irritates your nostrils. When you investigate its origin, you see fire in the walls of the house. " +
          "Someone yells, 'Fire!' The alarm is raised, but when one of your men rushes to the entrance, he finds the door barred from outside.^^" +
        "Mael Bresail has betrayed you and tries to burn you inside. If you do not hurry to find a way out, everyone will die soon, suffocated by smoke and burned by fire."),
        (set_background_mesh, "mesh_festin"),
      (else_try),
        (check_quest_active, "qst_blank_quest_26"),
        (quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,4),
        (str_store_string, s4, "@You have managed to escape the fire trap set by Mael Bresail to kill you, but it seems that you're not safe yet..."),
        (set_background_mesh, "mesh_pic_extra_guerreros"),
      (else_try),
        (str_store_string, s4, "@Mael Bresail had betrayed you, but you escaped from the flames of his hall and defeated the men who had wanted to kill you. Now, this site only brings bad memories to mind."),
        (set_background_mesh, "mesh_pic_farmstead"),
      (try_end),
    ],
    [
      ("enter",[(check_quest_active,"qst_blank_quest_26"),		(quest_get_slot, ":quest_current_state", "qst_blank_quest_26", slot_quest_current_state),
          (le, ":quest_current_state", 2),
        ],"Enter.",
        [
          (set_jump_mission,"mt_mael_bresail_farmmeeting"),
          (modify_visitors_at_site,"scn_mael_bresail_farm_meeting"),
          (reset_visitors),
          
          #mael bresail's man
          (set_visitor,11,"trp_maelbresail_man"),
          
          (set_visitor,13,"trp_farmer"),
          (set_visitor,14,"trp_farmer"),
          (set_visitor,15,"trp_farmer"),
          (set_visitor,16,"trp_farmer"),
          (set_visitor,17,"trp_farmer"),
          
          (set_jump_entry, 0),
          (scene_set_slot, "scn_mael_bresail_farm_meeting", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_mael_bresail_farm_meeting"),
          (change_screen_mission),
      ]),
      
      ("enter_maelbresailhall",[(check_quest_active,"qst_blank_quest_26"),(quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state, 3),
        ],"Run!",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_mael_bresail_hallfired"),
          (modify_visitors_at_site,"scn_mael_bresail_farm_hall"),
          (reset_visitors),
          (assign, ":cur_entry", 1), #entry points 1 to 10
          (try_for_range, ":companion", companions_begin, companions_end),
            (le, ":cur_entry", 10),
            (main_party_has_troop,":companion"),
            (set_visitor, ":cur_entry", ":companion"),
            (val_add, ":cur_entry", 1),
          (try_end),
          #entry points some elite troops
          (assign, ":party", "p_main_party"),
          (assign,":count",11),
          
          (party_get_num_companion_stacks, ":num_stacks", ":party"), #1 man each troop type
          (try_for_range, ":troop_iterator", 0, ":num_stacks"),
            (party_stack_get_troop_id, ":cur_troop_id", ":party", ":troop_iterator"),
            (neg|troop_is_hero, ":cur_troop_id"),##
            ##			(assign, ":total_valor", 0),
            ##			(call_script, "script_count_troops_inparty", ":party", ":cur_troop_id"),
            ##			(val_add, ":total_valor", reg0),
            
            ##                    (try_begin),
            ##		        (ge,":total_valor",2),
            ##		        (assign,":total_valor",2),
            ##		    (else_try),
            ##		        (ge,":total_valor",1),
            ##		        (assign,":total_valor",1),
            ##		    (try_end),
            
            (try_begin),
              (le,":count",17),
              (set_visitors,":count",":cur_troop_id", 1),
              
              (val_add,":count",1),
            (try_end),
          (try_end),
          
          (set_jump_entry, 0),
          
          (jump_to_scene,"scn_mael_bresail_farm_hall"),
          (change_screen_mission),
      ]),
      
      ("mailbresail_attack",[(check_quest_active,"qst_blank_quest_26"),(quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state, 4),
          ],"Fight!",[
          (assign, "$g_encountered_party", "p_bresail_farm"),
          (party_clear, "$g_encountered_party"),
          (party_add_members, "$g_encountered_party", "trp_maelbresail_man" , 1),
          (party_add_members, "$g_encountered_party", "trp_irish_standard_bearer" , 1),
          (party_add_members, "$g_encountered_party", "trp_todos_cuerno" , 1),
          (party_add_members, "$g_encountered_party", "trp_irish_bowman" , 7),
          (party_add_members, "$g_encountered_party", "trp_irish_level0_skirmisher" , 10),
          (party_add_members, "$g_encountered_party", "trp_irish_level0_landed" , 9),
          (party_add_members, "$g_encountered_party", "trp_irish_level0_companion" , 5),
          (party_add_members, "$g_encountered_party", "trp_irish_knight" , 3),
          (select_enemy, 0),
          (assign, "$g_battle_result", 0),
          (assign, "$g_engaged_enemy", 1),
          (call_script, "script_calculate_renown_value"),
          (call_script, "script_calculate_battle_advantage"),
          (set_battle_advantage, reg0),
          (set_party_battle_mode),
          (set_jump_mission,"mt_maelbresailfarm_battle"),
          (jump_to_scene,"scn_mael_bresail_farm_symbel"),
          (change_screen_mission),
      ]),
      
      ("leave",[(neg|quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,3),(neg|quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,4),],"Leave.",[
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###
  (
    "bresail_fort_visit",0,
    "On the far side of a river, there are some scattered houses and, in the background, a small fort built in the style of the area. The peasants have fled at the approach of your armed warriors.",
    "none",
    [
      (try_begin), #no batalla de noche
        (store_time_of_day, ":cur_hour"),
        (ge, ":cur_hour", 5),
        (lt, ":cur_hour", 21),
        (assign, "$town_nighttime", 0),
      (else_try),
        (assign, "$town_nighttime", 1),
      (try_end),
      (try_begin), #no batalla de noche
        (eq, "$town_nighttime", 1),
        (jump_to_menu,"mnu_doccinga_c_assaultnoche"),
      (try_end),
      
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_blank_quest_26"),(quest_get_slot, ":quest_current_state", "qst_blank_quest_26", slot_quest_current_state),
        (eq, ":quest_current_state", 11),
        (start_presentation, "prsnt_addon_final_text"),
      (try_end),
      (set_background_mesh, "mesh_pic_farmstead"),
    ],
    [
      ("enter_mbfort",[ (check_quest_active,"qst_blank_quest_26"),(quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,6),
        ],"Go.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (set_jump_mission,"mt_mael_bresail_fortfinal"),
          (modify_visitors_at_site,"scn_mael_bresail_end"),
          (reset_visitors),
          (try_begin),
            (main_party_has_troop,"trp_morrigan_npc"),
            (set_visitor, 1, "trp_morrigan_npc"),
          (try_end),
          (assign, ":cur_entry", 2), #entry points 2 to 6
          (try_for_range, ":companion", companions_begin, companions_end),
            (le, ":cur_entry", 6),
            (main_party_has_troop,":companion"),
            (set_visitor, ":cur_entry", ":companion"),
            (val_add, ":cur_entry", 1),
          (try_end),
          
          (set_visitor,9,"trp_town_25_seneschal"), #mael bresail
          (set_visitor,15,"trp_maelbressail_nother"), #mael bresail's mother
          
          (set_visitor,10,"trp_irish_knight"),
          (set_visitor,11,"trp_irish_level0_landed"),
          (set_visitor,8,"trp_irish_level1_landed"),
          (set_visitor,12,"trp_irish_level0_skirmisher"),
          (set_visitor,14,"trp_irish_level1_skirmisher"),
          
          (set_jump_entry, 0),
          (scene_set_slot, "scn_mael_bresail_end", slot_scene_visited, 1),
          
          (jump_to_scene,"scn_mael_bresail_end"),
          (change_screen_mission),
      ]),
      
      
      ("leave",[(neg|quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,9),(neg|quest_slot_eq,"qst_blank_quest_26",slot_quest_current_state,10),],"Leave.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),
      ]),
      #final
      
      ("leave",[ (check_quest_active,"qst_blank_quest_26"),(quest_get_slot, ":quest_current_state", "qst_blank_quest_26", slot_quest_current_state),
          (this_or_next|eq, ":quest_current_state", 9),(eq, ":quest_current_state", 10),],"Leave.",
        [
          (try_begin),
            (main_party_has_troop,"trp_morrigan_npc"),
            (jump_to_menu, "mnu_morrigan_dialog_final"),
          (else_try),
            (start_presentation, "prsnt_addon_final_text"),
          (try_end),
      ]),
    ],
  ),
  
  (
    "morrigan_dialog_final",0,
    "As you leave Mael Bresail's fort, Morrigan approaches you and asks you a few moments to talk.",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      (try_begin), #chief doccinga coastal assault mainquest
        (check_quest_active,"qst_blank_quest_26"),(quest_get_slot, ":quest_current_state", "qst_blank_quest_26", slot_quest_current_state),
        (eq, ":quest_current_state", 11),
        (start_presentation, "prsnt_addon_final_text"),
      (try_end),
    ],
    [
      
      ("talk_to_morrigan",[(check_quest_active,"qst_blank_quest_26"),(quest_get_slot, ":quest_current_state", "qst_blank_quest_26", slot_quest_current_state),
          (ge, ":quest_current_state", 9),
        ],
        "Talk to Morrigan.",[
          (modify_visitors_at_site,"scn_conversation3people_scene"),#player entry point 16, and then 17, 18, 19 for NPC's, opposite the player. 17 must be g_talk troop
          (reset_visitors), #entry points #reparar para que funcione conversacion a varios
          (set_visitor,0,"trp_player"),
          (set_visitor,17,"trp_morrigan_npc"),
          (set_jump_mission,"mt_conversation_encounter"),
          (jump_to_scene,"scn_conversation3people_scene"),
          (change_screen_map_conversation, "trp_morrigan_npc")
      ]),
      
    ]
  ),
  
  ##################
  #####################SIEGE WARFARE RANDOM EVENTS
  ####siege warfare random event chief
  
  #si no tiene hecho letrinas y saneamiento
  (
    "event_siege_01",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One of your advisers tells you that he has found rats in the provisions that your men are eating. This could have been prevented with sanitation!",
    "none",
    [(set_background_mesh, "mesh_pic_coppergate_helm"),
      
    ],
    [
      ("choice_01_1a",[],"That is terrible! Destroy the contaminated supplies.",
        [
          (assign, ":number_of_foods_player_has", 0),
          (try_for_range, ":cur_edible", food_begin, food_end),
            
            (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten),
            (val_add, ":number_of_foods_player_has", 1),
            (store_random_in_range, ":food_lose", 0, 2),
            (try_begin),
              (gt, ":number_of_foods_player_has", 0),
              (try_begin),
                (eq, ":food_lose", 0), #35%
                (troop_remove_item, "trp_player", ":cur_edible"),
              (else_try),
              (try_end),
            (else_try),
              (eq, ":number_of_foods_player_has", 0),
              (display_message, "@Your men have nothing to eat!", 0xFF0000),
              (call_script, "script_change_player_party_morale", -8),
              (assign, ":number_of_foods_player_has", 1),
              #NPC companion changes begin
              (try_begin),
                (call_script, "script_party_count_fit_regulars", "p_main_party"),
                (gt, reg0, 0),
                (call_script, "script_objectionable_action", tmt_egalitarian, "str_men_hungry"),
              (try_end),
              #NPC companion changes end
            (try_end),
          (try_end),
          (display_message, "@Part of your food was destroyed.", 0xFF0000),
          (change_screen_return),
        ]
      ),
      ("choice_01_2a",[],"My men must eat. Kill as many rats as you can.",
        [
          (jump_to_menu,"mnu_ratas_siege"),
        ]
      ),
    ]
  ),
  
  ###matar ratas submenu
  ("ratas_siege",0,
    "Before all the rats are exterminated, many of your men fall sick and die.^^Your casualties: {s8}",
    "none", [  (set_background_mesh, "mesh_pic_coppergate_helm"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 8),
      (call_script, "script_collect_friendly_parties"),
    ],
    
    [("back_to_siegea",[],"Done.",
        [
          (call_script, "script_change_player_party_morale", -5),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  #matar ratas acaba
  #bajas enfermedad
  (
    "event_siege_02",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Poor hygiene in your camp has led to dysentery. The men start dying all around you. This could have been prevented with sanitation!",
    "none",
    [(set_background_mesh, "mesh_pic_coppergate_helm"),
      
    ],
    [
      ("choice_02_1b",[],"Hire a physician to try to help the sick (1000 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 1000),
            (troop_remove_gold, "trp_player", 1000),
            (jump_to_menu,"mnu_enfermedad2_siege"),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (jump_to_menu,"mnu_enfermedad_siege"),
          (try_end),
        ]
      ),
      ("choice_02_2b",[],"There is nothing I can do.",
        [
          (jump_to_menu,"mnu_enfermedad_siege"),
        ]
      ),
      ("choice_02_3b",[],"Pray to your god.",
        [
          (jump_to_menu,"mnu_enfermedad3_siege"),
        ]
      ),
      ("choice_02_4b",[
          (party_get_skill_level, ":heal", "p_main_party", skl_wound_treatment),
          (ge, ":heal", 5),
        ],"I or my companions can cure them.",
        [
          (jump_to_menu,"mnu_enfermedad4_siege"),
        ]
      ),
    ]
  ),
  
  ("enfermedad_siege",0,
    "Death governs your camp. Many of your men are sick and dying.^^Your casualties: {s8}",
    "none", [  (set_background_mesh, "mesh_pic_coppergate_helm"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 10),
      (call_script, "script_collect_friendly_parties"),
    ],
    
    [("damn",[],"Damn.",
        [
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_change_troop_renown", "trp_player", -10),
          (call_script, "script_change_player_honor", -5),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ("enfermedad2_siege",0,
    "Some men die from the disease, but most manage to recover thanks to the physician you hired.^^Your casualties: {s8}",
    "none", [  (set_background_mesh, "mesh_pic_coppergate_helm"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 2),
      (call_script, "script_collect_friendly_parties"),
    ],
    
    [("back_to_siegeb",[],"Back to siege.",
        [
          (call_script, "script_change_player_party_morale", 5),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (call_script, "script_change_player_honor", 1),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ("enfermedad3_siege",0,
    "Death governs your camp. Many of your men are sick and dying. Perhaps your god has saved some lives.^^Your casualties: {s8}",
    "none", [  (set_background_mesh, "mesh_pic_coppergate_helm"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 9),
      (call_script, "script_collect_friendly_parties"),
    ],
    
    [("back_to_sieged",[],"Done.",
        [
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_troop_renown", "trp_player", -15),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  
  ("enfermedad4_siege",0,
    "Thanks to your healing abilities, you manage to save many men, but some still die.^^Your casualties: {s8}",
    "none", [  (set_background_mesh, "mesh_pic_coppergate_helm"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 2),
      (call_script, "script_collect_friendly_parties"),
    ],
    
    [("back_to_siegees",[],"Back to siege.",
        [
          (call_script, "script_change_player_honor", 1),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ###bajas enfermedad acaba
  
  (
    "event_siege_03",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "There is so much garbage, vermin and other nasty things that your camp seems to be more of a pigsty. Your men are unhappy. This could have been prevented with sanitation!",
    "none",
    [	(set_background_mesh, "mesh_pic_coppergate_helm"),
    ],
    [
      ("choice_03_4c",[
          (party_get_skill_level, ":leadership", "p_main_party", skl_leadership),
          (ge, ":leadership", 6),
        ],"I will give an inspiring speech to gain time.",
        [
          (call_script, "script_change_player_party_morale", -1),
          (change_screen_return),
        ]
      ),
      ("choice_03_2c",[],"I will see what I can do.",
        [
          (call_script, "script_change_player_party_morale", -6),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  ###acaba enfermedades chief
  #seguir
  #eventos incursion, infiltracion y emboscadas
  (
    "event_siege_04",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Some enemies have managed to infiltrate at night and burn some of your supplies. Part of your food was destroyed.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (assign, ":number_of_foods_player_has", 0),
      (try_for_range, ":cur_edible", food_begin, food_end),
        
        (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten),
        (val_add, ":number_of_foods_player_has", 1),
        (store_random_in_range, ":food_lose", 0, 3),
        (try_begin),
          (gt, ":number_of_foods_player_has", 0),
          (try_begin),
            (eq, ":food_lose", 0), #25%
            (troop_remove_item, "trp_player", ":cur_edible"),
          (else_try),
          (try_end),
        (else_try),
          (eq, ":number_of_foods_player_has", 0),
          (display_message, "@Your men have nothing to eat!", 0xFF0000),
          (call_script, "script_change_player_party_morale", -8),
          (assign, ":number_of_foods_player_has", 1),
          #NPC companion changes begin
          (try_begin),
            (call_script, "script_party_count_fit_regulars", "p_main_party"),
            (gt, reg0, 0),
            (call_script, "script_objectionable_action", tmt_egalitarian, "str_men_hungry"),
          (try_end),
          #NPC companion changes end
        (else_try),
        (try_end),
      (try_end),
      (display_message, "@Part of your food was destroyed.", 0xFF0000),
    ],
    [
      ("choice_04_1d",[],"Punish the men who were on duty that night.",
        [
          (call_script, "script_change_player_party_morale", -4), #discipline concept need.
          (call_script, "script_change_troop_renown", "trp_player", 5), #JuJu70- must be a renown change and not duplicate morale malus
          (display_message,"@Your men think that you are a strong leader."),
          (change_screen_return),
        ]
      ),
      ("choice_04_2d",[],"No, do nothing!",
        [
          (call_script, "script_change_troop_renown", "trp_player", -15),
          (display_message,"@Your men think that you are a weak leader."),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_05",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "During the night, your men captured and executed a group of enemies who tried to infiltrate and burn supplies.^^Enemy casualties: {s8}",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (call_script, "script_inflict_casualties_to_party", "$g_enemy_party", 4),
      (party_collect_attachments_to_party, "$g_enemy_party", "p_collective_enemy"),
    ],
    [
      ("choice_05_1e",[],"Congratulate them for doing their job well.",
        [
          # (call_script, "script_change_player_party_morale", 5),
          (change_screen_return),
        ]
      ),
      ("choice_05_2e",[],"Reward each with a warrior bracelet (300 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 300),
            (call_script, "script_change_troop_renown", "trp_player", 5),
            (call_script, "script_change_player_party_morale", 5),
            (troop_remove_gold, "trp_player", 300),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -5),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_05_3e",[],"Reward them with a night off with pay (200 peningas).",
        [(set_background_mesh, "mesh_pic_coppergate_helm"),
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 200),
            (troop_remove_gold, "trp_player", 200),
            (call_script, "script_change_player_party_morale", 5),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -5),
            (call_script, "script_change_player_party_morale", -2),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_05_4e",[],"Do nothing. You are a stern leader.",
        [
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_player_honor", -5),
          (display_message,"@Your men think that you are a strong leader."),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  
  (
    "event_siege_06",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "{reg59?Lady:Sir}, our food supply routes may be in danger. Our scouts have discovered enemy raiders behind our lines.^^" +
    "We could avoid such problems by blockading the place.^^Do you want to send men to protect the routes and pursue the enemy?",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_06_1f",[],"Send men.",
        [
          (jump_to_menu,"mnu_encuentro_avituallamiento"),
        ]
      ),
      ("choice_06_2f",[ (store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 500),],"Send messengers to pay them off (500 peningas).",
        [
          (troop_remove_gold, "trp_player", 500),
          (jump_to_menu,"mnu_encuentro_avituallamiento2"),
        ]
      ),
      ("choice_06_3f",[],"Do nothing.",
        [
          (assign, ":number_of_foods_player_has", 0),
          (try_for_range, ":cur_edible", food_begin, food_end),
            
            (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten),
            (val_add, ":number_of_foods_player_has", 1),
            (store_random_in_range, ":food_lose", 0, 3),
            (try_begin),
              (gt, ":number_of_foods_player_has", 0),
              (try_begin),
                (eq, ":food_lose", 0), #25%
                (troop_remove_item, "trp_player", ":cur_edible"),
              (else_try),
              (try_end),
            (else_try),
              (eq, ":number_of_foods_player_has", 0),
              (display_message, "@Your men have nothing to eat!", 0xFF0000),
              (call_script, "script_change_player_party_morale", -8),
              (assign, ":number_of_foods_player_has", 1),
              #NPC companion changes begin
              (try_begin),
                (call_script, "script_party_count_fit_regulars", "p_main_party"),
                (gt, reg0, 0),
                (call_script, "script_objectionable_action", tmt_egalitarian, "str_men_hungry"),
              (try_end),
              #NPC companion changes end
            (try_end),
          (try_end),
          (display_message, "@Part of your food was destroyed.", 0xFF0000),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  #submenu encuentro avituallamiento
  ("encuentro_avituallamiento",0,
    "You dispatch a group of men to protect and pursue the enemies that plague your supply routes. Your men attempt to corner the enemy to force him to fight until death. There are some losses, but your men manage to win the battle and secure the supply routes.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none", [
      (set_background_mesh, "mesh_pic_extra_encuentro"),
      (call_script, "script_simulate_battle_with_parties", 40, "$g_enemy_party", 40, 0, 0),
    ],
    
    [("back_to_siegeg2",[],"Well done.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ("encuentro_avituallamiento2",0,
    "{!}{s4}",
    "none", [
      
      (str_clear, s4),
      (set_background_mesh, "mesh_pic_messenger"),
      (store_random_in_range, ":options", 0,5),
      (try_begin),
        (le, ":options", 1),
        (call_script, "script_simulate_battle_with_parties", 50, "$g_enemy_party", 50, 0, 0),
        (str_store_string, s4, "@While your messengers try to negotiate with the enemy raiders, a squad of your men appears by chance, and a battle begins. " +
        "Your men manage to destroy the looters and fix the problem, but at the cost of some lives.^^Your casualties: {s8}^^Enemy casualties: {s10}"),
        (set_background_mesh, "mesh_pic_extra_encuentro"),
      (else_try),
        (le, ":options", 3),
        (str_store_string, s4, "@The enemy raiders accept the deal, take the money, and promise not to attack your supplies for some weeks."),
        (set_background_mesh, "mesh_pic_messenger"),
      (else_try),
        (str_store_string, s4, "@The raiders take the money, kill the messengers, and continue to damage your supply routes."),
        (set_background_mesh, "mesh_pic_messenger"),
        
        #comida
        (assign, ":number_of_foods_player_has", 0),
        (try_for_range, ":cur_edible", food_begin, food_end),
          
          (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten),
          (val_add, ":number_of_foods_player_has", 1),
          (store_random_in_range, ":food_lose", 0, 3),
          (try_begin),
            (gt, ":number_of_foods_player_has", 0),
            (try_begin),
              (eq, ":food_lose", 0), #25%
              (troop_remove_item, "trp_player", ":cur_edible"),
            (else_try),
            (try_end),
          (else_try),
            (eq, ":number_of_foods_player_has", 0),
            (display_message, "@Your men have nothing to eat!", 0xFF0000),
            (call_script, "script_change_player_party_morale", -8),
            (assign, ":number_of_foods_player_has", 1),
            #NPC companion changes begin
            (try_begin),
              (call_script, "script_party_count_fit_regulars", "p_main_party"),
              (gt, reg0, 0),
              (call_script, "script_objectionable_action", tmt_egalitarian, "str_men_hungry"),
            (try_end),
            #NPC companion changes end
          (try_end),
        (try_end),
        (display_message, "@Part of your food was destroyed.", 0xFF0000),
        ###messengers
        (store_random_in_range, ":p_leave", 4, 8),
        (assign, ":num_troops", ":p_leave"),
        (try_for_range, ":unused", 0, ":num_troops"),
          (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
        (try_end),
      (try_end),
      
    ],
    
    [("back_to_siegeg3",[],"Very well.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ####encuentro avituallamiento acaba
  
  
  (
    "event_siege_07",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Our scouts have found that the defenders have poisoned the water with dead animals. Do you want to buy water and ask the merchants to bring it via our supply route?",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_07_1g",[],"Yes (600 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 600),
            (troop_remove_gold, "trp_player", 600),
            (change_screen_return),
          (else_try),
            (display_message, "@You don't have enough silver. You order water to be rationed and wells to be dug."),
            (call_script, "script_change_troop_renown", "trp_player", -10),
            (jump_to_menu,"mnu_sed_siege"),
          (try_end),
        ]
      ),
      ("choice_07_2g",[],"No. Ration water and dig wells.",
        [
          (jump_to_menu,"mnu_sed_siege"),
        ]
      ),
      ("choice_07_3g",[],"Without water, we cannot continue. Abandon the siege.",
        [
          (call_script, "script_lift_siege", "$g_player_besiege_town", 0),
          (assign, "$g_player_besiege_town", -1),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  ###perdidas por sed mientras cavan pozos
  ("sed_siege",0,
    "Water is running out, and your men weaken. Driven by the madness of thirst, some of them drink poisoned water and die. Finally, a well is completed and you get water for the time being. You can continue the siege.^^Your casualties from poisoned water:{s8}",
    "none", [  (set_background_mesh, "mesh_pic_messenger"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 4),
      (call_script, "script_collect_friendly_parties"),
    ],
    
    [("back_to_siegeh",[],"Fate is inexorable.",
        [
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_troop_renown", "trp_player", -15),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ],
  ),
  ####sed acaba
  
  (
    "event_siege_08",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Bad news: one of our men has deserted to the enemy. It may be because of his low morale or because they have offered him money. Whatever it is, the enemy may know our plans.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_08_1h",[],"Offer 400 peningas. I don't want more desertions.",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 400),
            (call_script, "script_change_player_party_morale", 5),
            (troop_remove_gold, "trp_player", 400),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_player_party_morale", -5),
            (call_script, "script_change_troop_renown", "trp_player", -15),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_08_2h",[],"Offer 800 peningas to minimize temptation.",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 800),
            (call_script, "script_change_player_party_morale", 4),
            (troop_remove_gold, "trp_player", 800),
            (call_script, "script_change_player_party_morale", 10),
            (call_script, "script_change_troop_renown", "trp_player", 5),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_player_party_morale", -5),
            (call_script, "script_change_troop_renown", "trp_player", -15),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_08_3h",[],"Do not worry. I can always change plans.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  (
    "event_siege_09",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A deserter from the enemy has joined our ranks. He has informed us that {s2}.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (store_random_in_range, ":rand_no", 1, 10),
      (try_begin),
        (ge, ":rand_no", 8),
        (str_store_string , s2, "@the enemy thinks reinforcements will soon arrive."),
      (else_try),
        (ge, ":rand_no", 5),
        (str_store_string , s2, "@fear and discontent are spreading inside."),
      (else_try),
        (ge, ":rand_no", 3),
        (str_store_string , s2, "@he likes the wife of his former master, and he will fight by your side if you give her to him after the conquest."),
      (else_try),
        (ge, ":rand_no", 0),
        (str_store_string , s2, "@the enemy's morale is low, and we should attack."),
      (try_end),
    ],
    [
      ("choice_09_1i",[],"He is welcome to our ranks.",
        [
          (party_add_members, "p_main_party", "trp_watchman", 1),
          (call_script, "script_change_player_party_morale", -5),
          (change_screen_return),
        ]
      ),
      ("choice_09_2i",[],"I do not want deserters among my men. Kill him.",
        [
          (call_script, "script_change_player_honor", -5),
          (change_screen_return),
        ]
      ),
      ("choice_09_3i",[],"I'm sure he's a spy. Return him to the enemy.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_10",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Our men and the enemy do not insult each other as much any more, and sometimes talk to each other. This can affect their fighting spirit when we attack. What shall we do?",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_10_1j",[],"Allow it. The enemy's fighting spirit is also affected.",
        [
          (call_script, "script_change_player_honor", 5),
          (call_script, "script_change_troop_renown", "trp_player", -15),
          (change_screen_return),
        ]
      ),
      ("choice_10_2j",[],"What? Forbid it and punish the offenders.",
        [
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_party_morale", -5),
          (change_screen_return),
        ]
      ),
    ]
  ),
  ###frio invierno bajas
  (
    "event_siege_11",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The cold of winter always takes its toll when it comes. Some men have died of cold, flu and other minor illnesses.^^Your casualties: {s8}",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 4),
      (call_script, "script_collect_friendly_parties"),
    ],
    [
      ("choice_11_1j",[],"Requiescat in pace.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_12",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A farmer comes to you and says that one of your men has raped his daughter, who lives in a village near your siege camp. The farmer desires wergild (compensation) of 100 peningas. What do you do?",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_12_1j",[],"Pay the wergild.",
        [   (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 100),
            (troop_remove_gold, "trp_player", 100),
            (display_message, "@wergild is paid."),
            (call_script, "script_change_player_honor", 1),
            (call_script, "script_change_troop_renown", "trp_player", -5),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -15),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_12_2j",[],"Pay the wergild and punish your warrior.",
        [   (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 100),
            (troop_remove_gold, "trp_player", 100),
            (display_message, "@The wergild is paid and your warrior whipped."),
            (call_script, "script_change_player_honor", 1),
            (call_script, "script_change_player_party_morale", -5),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -15),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_12_3j",[],"Refuse to pay for damage done to the Enemy.",
        [
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_party_morale", 5),
          (change_screen_return),
        ]
      ),
      ("choice_12_4j",[],"Kill the farmer and his daughter.",
        [
          (call_script, "script_change_player_honor", -10),
          (jump_to_menu,"mnu_no_paymentandkill"),
        ]
      ),
    ]
  ),
  
  (
    "no_paymentandkill",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "In revenge, the men of the nearby villages joined together and attacked your foraging parties.^^Your casualties: {s8}",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (call_script, "script_inflict_casualties_to_party", "p_main_party", 3),
      (call_script, "script_collect_friendly_parties"),
    ],
    [
      ("damn",[],"Damn!",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  
  #escaramuza pequena
  (
    "event_siege_13",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A group of enemies attacked our men by surprise and then quickly withdrew.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 80, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_13_1b",[],"Be more cautious (Solution: blockade the place).",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_14",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "While foraging, a group of enemies encountered a group of our men.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 30, "$g_enemy_party", 30, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_14_1b",[],"Be more cautious (Solution: blockade the place).",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_15",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "We were attacked by an enemy force while raiding neighboring villages. The villagers joined the enemy, causing us many casualties.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 30, "$g_enemy_party", 90, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_15_1b",[],"Be more cautious (Solution: blockade the place).",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_16",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The enemy and our men came upon each other near a river, and the fight for water caused numerous casualties on both sides.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 30, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_16_1b",[],"Be more cautious (Solution: blockade the place).",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_17",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The enemy sallied out through a secret passage, attacking us before swiftly retreating back to the protection of their walls.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 100, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_17_1b",[],"Be more cautious (Solution: blockade the place).",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_18",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Some of your men have abducted women from the surrounding villages and brought them to the siege camp for fun.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("choice_18_1b",[],"You allow it and ask for the most beautiful woman.",
        [
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_party_morale", 5),
          (party_add_members, "p_main_party", "trp_refugee", 6),
          (jump_to_menu,"mnu_no_paymentandkill"),
        ]
      ),
      ("choice_18_2b",[],"Order the release of the women and punish the kidnappers.",
        [
          (call_script, "script_change_player_party_morale", -10),
          (call_script, "script_change_player_honor", 5),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_19",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The enemy is trying to break our blockade, and our men are trying to contain them.^^Your casualties: {s8}^^Enemy casualties: {s10}", #enemy desesperate, player adventage
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 25, "$g_enemy_party", 75, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_19_1b",[],"Send some men while I take others to force them to withdraw.",
        [
          (store_random_in_range, ":rand", 0, 7),
          (try_begin),
            (le, ":rand", 3),
            (jump_to_menu,"mnu_no_defendiendo"),
          (else_try),
            (jump_to_menu,"mnu_defendiendo_circunvallation"),
          (try_end),
        ]
      ),
      ("choice_19_2b",[],"Send all the men to protect that part of the circumvallation.",
        [
          (store_random_in_range, ":rand", 0, 7),
          (try_begin),
            (le, ":rand", 3),
            (jump_to_menu,"mnu_defendiendo_mal"),
          (else_try),
            (jump_to_menu,"mnu_defendiendo_circunvallation"),
          (try_end),
        ]
      ),
      ("choice_19_3b",[],"Do not worry. Our wall is strong.",
        [
          (jump_to_menu,"mnu_no_defendiendo"),
        ]
      ),
    ]
  ),
  
  ###ataque a circunvallation por defensores
  (
    "no_defendiendo",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The enemy has overcome our defenses and burned our small camps and checkpoints, breaking our blockade.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 80, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1bnd",[],"We must build the blockade again.",
        [
          (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  (
    "defendiendo_circunvallation",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "We have managed to repel the enemy, who returned to the protection of his walls...^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 40, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1dcir",[],"Well done.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  (
    "defendiendo_mal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Another group of enemies took advantage of our troops being here and set fire to another part of our blockade.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 30, "$g_enemy_party", 90, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("damn",[],"Damn!",
        [
          (party_set_slot,"$g_encountered_party",slot_center_blockaded,0),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  #####ataque a circunvallation acaba
  
  ###ataque a maquinas de asedio
  (
    "event_siege_20",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The enemy is trying to burn our assault equipment.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 40, "$g_enemy_party", 120, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("choice_20_1b",[],"Send some men while I take others to force them to withdraw.",
        [
          (store_random_in_range, ":rand", 0, 8),
          (try_begin),
            (le, ":rand", 3),
            (jump_to_menu,"mnu_defendiendo_mal_equip"),
          (else_try),
            (le, ":rand", 5),
            (jump_to_menu,"mnu_no_defendiendo_equip"),
          (else_try),
            (jump_to_menu,"mnu_defendiendo_equip"),
          (try_end),
        ]
      ),
      ("choice_20_2b",[],"Quickly. Send all men to protect the equipment.",
        [
          (store_random_in_range, ":rand", 0, 8),
          (try_begin),
            (le, ":rand", 3),
            (jump_to_menu,"mnu_defendiendo_mal_equip"),
          (else_try),
            (jump_to_menu,"mnu_defendiendo_equip"),
          (try_end),
        ]
      ),
      ("choice_20_3b",[],"Do not worry. Our men will guard it.",
        [
          (jump_to_menu,"mnu_no_defendiendo_equip"),
        ]
      ),
    ]
  ),
  ###ataque a equipamiento de asedio
  (
    "no_defendiendo_equip",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The enemy has overcome our defenses and burned down our equipment.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 25, "$g_enemy_party", 100, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1bnde",[],"We must begin construction again.",
        [
          (assign, "$g_siege_method", 0),
          (assign, "$g_mantlets_1", 0),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  (
    "defendiendo_equip",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "We have managed to repel the enemy, who returned to the protection of his walls.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 25, "$g_enemy_party", 50, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1heq",[],"Well done.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  (
    "defendiendo_mal_equip",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Another group of enemies has surrounded our positions and burned down our siege equipment on the other side.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 30, "$g_enemy_party", 90, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("damn",[],"Damn!",
        [
          (assign, "$g_siege_method", 0),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  #####ataque a equipamiento acaba
  
  
  #continuamos aqui
  (
    "event_siege_21",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your guards discovered several men trying to sneak out at night to escape your blockade.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("choice_21_1b",[],"Allow them to escape.",
        [
          (call_script, "script_change_player_party_morale", -5),
          (store_random_in_range, ":p_leave", 8, 12),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
          (try_end),
          
          (change_screen_return),
        ]
      ),
      ("choice_21_2b",[],"Kill them.",
        [
          (call_script, "script_change_player_honor", -5),
          (store_random_in_range, ":p_leave", 8, 12),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
          (try_end),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_22",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "At night, your guards report that they observed a group of enemies dressed in sheepskins heading to a nearby stream. Right now, they are filling leather sacks with water to bring back to the settlement.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("atacar_emboscada_player2",[],"Go there with any companions who want to join.",
        [
          (try_begin),
            (store_troop_health, ":health", "trp_player", 0), #get relative health in 1-100 range and put it into the ":health" variable
            (lt, ":health", 30),
            (val_add, ":health", 35),               #add to it the 5%
            (troop_set_health,   "trp_player", ":health"),   #set it
          (try_end),
          
          (store_random_in_range, ":scene_a_usar", 0,3),
          (try_begin),
            (eq, ":scene_a_usar", 1),
            (assign, ":scene_to_use", "scn_river_ambush_1"),
          (else_try),
            (eq, ":scene_a_usar", 2),
            (assign, ":scene_to_use", "scn_river_ambush_2"),
          (else_try),
            (assign, ":scene_to_use", "scn_river_ambush_3"),
          (try_end),
          
          (set_jump_mission,"mt_ambush_riversw"),
          (modify_visitors_at_site,":scene_to_use"),
          #### tropas cambiar por las del asentamiento
          (reset_visitors, 0),
          (set_visitor,0,"trp_player"), #player
          (assign, ":cur_entry", 1),
          (try_for_range, ":companion", companions_begin, companions_end),
            (main_party_has_troop,":companion"),
            (set_visitor, ":cur_entry", ":companion"),
            (val_add, ":cur_entry", 1),
          (try_end),
          
          (assign, ":num_troops", 8),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "$g_encountered_party"),
            (assign, ":lost_troop", reg0),
            #(try_for_range, ":visiterator", 17, 18), #possible 17 and 31, but this add 8 enemies each 1 entry point
            (assign, ":visiterator", 17),
            (set_visitor, ":visiterator", ":lost_troop"),
            #  (try_end),
          (try_end),
          (jump_to_scene,":scene_to_use"),
          (change_screen_mission),
      ]),
      
      ("choice_22_1b",[],"Send men to ambush the enemy in sheepskins.",
        [
          (store_random_in_range, ":rand", 0, 3),
          (try_begin),
            (eq, ":rand", 0),
            (jump_to_menu,"mnu_victoria_ovejas"),
          (else_try),
            (eq, ":rand", 1),
            (jump_to_menu,"mnu_derrota_ovejas"),
          (else_try),
            (jump_to_menu,"mnu_tablas_ovejas"),
          (try_end),
        ]
      ),
      ("choice_22_2b",[],"Do nothing.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  #####atacar ovejas chief
  (
    "victoria_ovejas",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your soldiers surrounded the enemy in sheepskins and fell upon them by surprise, spreading death.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 50, "$g_enemy_party", 30, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1lovej",[],"Perfect!",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  (
    "derrota_ovejas",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "It's a trap! {reg59?Lady:Sir}, the men dressed in sheepskins were a decoy to bring out our men and ambush them. Many were killed before returning to the protection of our circumvallation.^^Your casualties: {s8}^^Enemy casualties: {s10}",
    "none",
    [
      (call_script, "script_simulate_battle_with_parties", 20, "$g_enemy_party", 100, 0, 0),
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1poveja",[],"That is terrible.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  (
    "tablas_ovejas",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your soldiers were deployed to surround the enemy, but they were too slow and noisy. The men in sheepskins sensed the threat and returned to the settlement quickly.",
    "none",
    [	(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("defendiendo_1oveja2",[],"Well, next time.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  ###atacar ovejas acaba
  
  (
    "event_siege_23",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Today a mercenary who wants to join our ranks came to our camp. He says he is an exile from the place that we are besieging, and he wants revenge.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_guerreroelite"),
    ],
    [
      ("choice_23_1b",[],"Accept him.",
        [
          (party_add_members, "p_main_party", "trp_mercenary_horseman", 1),
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -20),
          
          (change_screen_return),
        ]
      ),
      ("choice_23_2b",[],"I don't need more men.",
        [
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_24",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "We have accumulated the heads of enemies and dead peasants. Do you want to launch them over the walls to undermine the morale of the enemy and cause disease?",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("choice_24_1b",[],"What? You're a crazy maniac. Do not do that!",
        [
          (call_script, "script_change_player_honor", 5),
          (change_screen_return),
        ]
      ),
      ("choice_24_2b",[],"Sure, it will be useful when negotiating their surrender.",
        [
          (call_script, "script_change_player_honor", -5),
          (jump_to_menu,"mnu_cabezas_moral"),
        ]
      ),
    ]
  ),
  
  
  ###cabezas
  (
    "cabezas_moral",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The heads are launched into the settlement. From the outside, you hear the cries and tears of the citizens when they recognize a loved one. War is merciless, and you've proven you're the most terrible of foes.",
    "none",
    [	(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("defendiendo_1q",[],"This will help them give up... or die...",
        [
          (assign, "$g_cabezas_dentro", 1),
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (display_message,"@Your men think you're heartless and fear you."),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  ###cabezas acaba
  
  (
    "event_siege_25",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A merchant offers a group of dancers to entertain your men during the night.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("choice_25_1b",[],"This will just distract and tire my men.",
        [
          (call_script, "script_change_player_party_morale", -8),
          (change_screen_return),
        ]
      ),
      ("choice_25_2b",[],"Hire dancers just for yourself (100 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 100),
            (troop_remove_gold, "trp_player", 100),
            (add_xp_as_reward,100),
            (display_message, "@You feel happy."),
            (call_script, "script_change_player_party_morale", -4),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -5),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_25_3b",[],"Hire dancers for your men (500 peningas).",
        [
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (ge, ":gold", 500),
            (troop_remove_gold, "trp_player", 500),
            (display_message, "@You feel good for helping."),
            (call_script, "script_change_player_party_morale", 8),
          (else_try),
            (display_message, "@You don't have enough silver. How embarrassing!"),
            (call_script, "script_change_troop_renown", "trp_player", -5),
            (call_script, "script_change_player_party_morale", -2),
          (try_end),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_26",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A group of bandits approaches your camp. As your men reach for their arms, the bandits put down their weapons and say they come in peace. The leader of the bandits steps forward and asks if they may join you.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_guerreros"),
    ],
    [
      ("choice_26_1b",[],"Of course! Such promising men are always welcome!",
        [
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_change_player_honor", -2),
          (party_add_members, "p_main_party", "trp_mountain_bandit", 5),
          (display_message, "@New troops join your party."),
          (change_screen_return),
        ]
      ),
      ("choice_26_2b",[],"I'm sorry. We have no room for your kind!",
        [
          (display_message, "@The bandits leave, angry."),
          (change_screen_return),
        ]
      ),
      ("choice_26_3b",[],"Prove yourselves worthy by raiding a village.",
        [
          (jump_to_menu,"mnu_sanguinario_p"),
        ]
      ),
      ("choice_26_4b",[],"Kill them all!",
        [
          (call_script, "script_troop_add_gold", "trp_player", 100),
          (call_script, "script_change_player_honor", 1),
          #		(call_script, "script_change_troop_renown", "trp_player", -10),
          (display_message, "@Your men kill all the bandits."),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "sanguinario_p",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "After two hours, the bandits return with some loot and someone's head...",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_guerreros"),
      (call_script, "script_troop_add_gold", "trp_player", 500),
      (call_script, "script_change_player_honor", -10),
      #		(call_script, "script_change_troop_renown", "trp_player", -10),
      (call_script, "script_change_player_party_morale", -8),
    ],
    [
      ("choice_26_5b",[],"Well done! An officer will show you to your places.",
        [
          (party_add_members, "p_main_party", "trp_mountain_bandit", 5),
          #     (display_message, "@After tow hours the bandits return with some loot and the chiefs head..."),
          (change_screen_map),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_27",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Several merchants approach you wanting to sell goods in the camp that has formed close to yours with the wives of the soldiers, prostitutes, refugees, children and other followers of the army.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_27_1b",[],"They (and their money) are welcome.",
        [
          (call_script, "script_troop_add_gold", "trp_player", 400),
          (call_script, "script_change_player_party_morale", 5),
          
          (store_random_in_range, ":p_leave", 5, 10),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          (display_message, "@At night, some of your men make off with happy widows."),
          
          (change_screen_return), #menos disciplina
        ]
      ),
      ("choice_27_2b",[],"There are enough merchants already.",
        [
          (call_script, "script_change_player_party_morale", -5),
          (change_screen_return), #mas disciplina
        ]
      ),
      ("choice_27_3b",[],"Kill them and steal their money.",
        [
          (call_script, "script_change_player_honor", -15),
          (call_script, "script_change_player_party_morale", -10),
          #            (call_script, "script_change_troop_renown", "trp_player", -30),
          (call_script, "script_troop_add_gold", "trp_player", 1600),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_28",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "To make the food last longer, the defenders threw out their women, children and elderly. You can see them moving towards your circumvallation, begging for food.",
    "none",
    [	(set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_28_1b",[],"Send soldiers to kill the children and elderly, taking the women.",
        [
          (call_script, "script_change_player_honor", -20),
          (call_script, "script_change_player_party_morale", 5),
          #		(call_script, "script_change_troop_renown", "trp_player", -15),
          (party_add_members, "p_main_party", "trp_refugee", 8),
          (change_screen_return),
        ]
      ),
      ("choice_28_2b",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 1000),],"Buy food for them (1000 peningas). Then let them leave.",
        [
          (troop_remove_gold, "trp_player", 1000),
          (display_message, "@You feel good for helping."),
          (call_script, "script_change_player_honor", 5),
          (call_script, "script_change_player_party_morale", -5),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (display_message,"@Your men think that you are a weak leader."),
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", 10),
          (display_message,"@Your enemies appreciate your pity. Perhaps this will help you when you negotiate their surrender."),
          (change_screen_return),
        ]
      ),
      ("choice_28_3b",[],"Do not give them anything. Allow them to die of starvation.",
        [
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (display_message,"@Your men think that you are a strong leader."),
          (call_script, "script_change_player_relation_with_center", "$g_encountered_party", -10),
          (display_message, "@You know that in the coming days, dozens of children, women and elderly will die before your eyes, languishing from hunger."),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  (
    "event_siege_29",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One of your soldiers, angered by the long siege, rapes the wife of one of your officers.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_29_1b",[],"Ignore the situation.",
        [
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (display_message,"@Your officer seems upset."),
          (jump_to_menu,"mnu_lucha_oficial"),
          (change_screen_return),
        ]
      ),
      ("choice_29_2b",[],"Punish the soldier.",
        [
          (call_script, "script_change_player_party_morale", -4),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (display_message,"@Your men think that you are a strong leader."),
          (display_message,"@Your officer seems upset."),
          (jump_to_menu,"mnu_lucha_oficial"),
        ]
      ),
      ("choice_29_3b",[],"Execute the soldier.",
        [
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_change_troop_renown", "trp_player", 5),
          (display_message,"@Your men think that you are a very strong leader."),
          (display_message,"@Your officer seems happy."),
          
          (assign, ":num_troops", 1),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          (change_screen_return),
        ]
      ),
      ("choice_29_4b",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 1000),],"Pay wergild (compensation) to the officer (1000 peningas).",
        [
          (troop_remove_gold, "trp_player", 1000),
          (display_message, "@The wife is pregnant, and the officer asks for a high compensation. To avoid rumors and problems, you pay."),
          (change_screen_return),
        ]
      ),
    ]
  ),
  
  ###soldado problematico
  (
    "lucha_oficial",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your officer kills the soldier and there is a brawl between some friends of the soldier and those loyal to your officer, leaving some dead.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (store_random_in_range, ":p_leave", 6, 12),
      (assign, ":num_troops", ":p_leave"),
      (try_for_range, ":unused", 0, ":num_troops"),
        (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
      (try_end),
      
      (set_background_mesh, "mesh_pic_extra_encuentro"),
    ],
    [
      ("defendiendo_1z",[],"That is terrible.",
        [
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
        ]
      ),
    ]
  ),
  ####siege warfare acaba chief random event
  
  
  ###########messenger system
  (
    "messenger_system",0,
    "A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
    "'My masters sent me to tell you that the messenger you sent was found dead on the side of the road. We're sorry to inform you that your message never reached its destination. " +
    "We will be at your disposal for any other message that you need to send. You know where to find us.'",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (assign,":continue",0),
      #orders
      (try_begin),
        (eq, "$message_type", orders_follow),
        (jump_to_menu,"mnu_messenger_system_follow"),
        (assign,":continue",1),
      (try_end),
      (try_begin),
        (eq, "$message_type", orders_gotoplace),
        (jump_to_menu,"mnu_messenger_system_gotoplace"),
        (assign,":continue",1),
      (try_end),
      (try_begin),
        (eq, "$message_type", orders_patrolarea),
        (jump_to_menu,"mnu_messenger_system_patrolarea"),
        (assign,":continue",1),
      (try_end),
      (try_begin),
        (eq, "$message_type", orders_besiegeplace),
        (jump_to_menu,"mnu_messenger_system_besiegeplace"),
        (assign,":continue",1),
      (try_end),
      ##        (try_begin),
      ## 	     (eq, "$message_type", orders_raidarea),
      ##	     (jump_to_menu,"mnu_messenger_system_raidarea"),
      ##	(assign,":continue",1),
      ##        (try_end),
      ##        (try_begin),
      ## 	     (eq, "$message_type", orders_guardplace),
      ##	     (jump_to_menu,"mnu_messenger_system_guardplace"),
      ##        (try_end),
      #relations
      (try_begin),
        (eq, "$message_type", diplomacy_insult),
        (jump_to_menu,"mnu_messenger_system_insult"),
        (assign,":continue",1),
      (try_end),
      (try_begin),
        (eq, "$message_type", diplomacy_sendgift),
        (jump_to_menu,"mnu_messenger_system_sendgift"),
        (assign,":continue",1),
      (try_end),
      ##        (try_begin),
      ## 	     (eq, "$message_type", diplomacy_invitation),
      ##	     (jump_to_menu,"mnu_messenger_system_invitation"),
      ##        (try_end),
      #diplomacy
      (try_begin),
        (eq, "$message_type", diplomacy_sugalliance),
        (jump_to_menu,"mnu_messenger_system_sugalliance"),
        (assign,":continue",1),
      (try_end),
      (try_begin),
        (eq, "$message_type", diplomacy_suggestpeace),
        (jump_to_menu,"mnu_messenger_system_suggestpeace"),
        (assign,":continue",1),
      (try_end),
      (try_begin),
        (eq, "$message_type", diplomacy_declarewar),
        (jump_to_menu,"mnu_messenger_system_declarewar"),
        (assign,":continue",1),
      (try_end),
      ##                (assign,":troop","$message_target"),
      ## 		#(str_store_troop_name,s10,":troop"),
      ##                (troop_get_slot, ":party", ":troop", slot_troop_prisoner_of_party),
      ##                 (store_faction_of_party, ":cur_faction", ":party"),
      ##                (str_store_faction_name, s9, ":cur_faction"),
      
      #nothing
      (try_begin),
        (eq,":continue",0),
        (assign,"$message_target",-1), #lord
        (assign,"$message_type",-1), #type
        (assign,"$message_distance",-1), #distance
        (assign,"$message_place",-1), #place
        (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
        (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
        (leave_encounter),
        (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      (try_end),
    ],
    [
      ("error_1",[
        ],
        "Continue.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  (
    "messenger_system2",0,
    "A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
    "'My masters sent me to tell you that the messenger you sent to {s9} was found dead on the side of the road. We're sorry to inform you that your message never reached its destination. " +
    "We will be at your disposal for any other message that you need to send. You know where to find us.'",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (assign,":party_no","$message_target"),
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}."),
    ],
    [
      ("finish_m",[
        ],
        "Bad luck.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "messenger_system_res_failure",0,
    "A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
    "'My masters sent me to tell you that the messenger you sent was found dead on the side of the road. We're sorry to inform you that your message never reached its destination. " +
    "We will be at your disposal for any other message that you need to send. You know where to find us.'",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      
      ##                (assign,":troop","$message_target"),
      ##                 (troop_get_slot, ":party", ":troop", slot_troop_prisoner_of_party),
      ##                 (store_faction_of_party, ":cur_faction", ":party"),
      ##                (str_store_faction_name, s9, ":cur_faction"),
      
    ],
    [
      ("finish_m2",[
        ],
        "Bad luck.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ####messenger rescate
  (
    "messenger_system_res",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s1),
      (str_clear, s10),
      (str_clear, s11),
      (assign,":troop_no","$message_target"),
      (str_store_troop_name,s10,":troop_no"),
      (troop_get_slot, ":party", ":troop_no", slot_troop_prisoner_of_party),
      ##                 (store_faction_of_party, ":cur_faction", ":party"),
      ##               (str_store_faction_name, s11, ":cur_faction"),
      
      (store_random_in_range, ":random", 1, 100),
      (try_begin),
        (gt,":party",0),
        (ge, ":random", 75),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. Your proposal has been accepted and {s10} has been released from captivity.'"),
        ##        (party_remove_prisoners, ":party", ":troop", 1),
        ##        (call_script, "script_remove_troop_from_prison", ":troop"),
        (party_remove_prisoners, ":party", ":troop_no",1),
        (remove_troops_from_prisoners,  ":troop_no", 1),
        (troop_set_slot, ":troop_no", slot_troop_prisoner_of_party, -1),
        (call_script, "script_remove_troop_from_prison", ":troop_no"),
        (call_script, "script_change_player_relation_with_troop", ":troop_no", 15),
        (call_script, "script_change_player_honor", 2),
      (else_try),
        (gt,":party",0),
        (ge, ":random", 50),
        (gt, "$message_cost", 7999),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. Your proposal has been accepted and {s10} has been released from captivity.'"),
        ##        (party_remove_prisoners, ":party", ":troop", 1),
        ##        (call_script, "script_remove_troop_from_prison", ":troop"),
        (party_remove_prisoners, ":party", ":troop_no",1),
        (remove_troops_from_prisoners,  ":troop_no", 1),
        (troop_set_slot, ":troop_no", slot_troop_prisoner_of_party, -1),
        (call_script, "script_remove_troop_from_prison", ":troop_no"),
        (call_script, "script_change_player_relation_with_troop", ":troop_no", 15),
        (call_script, "script_change_player_honor", 2),
      (else_try),
        (gt,":party",0),
        (ge, ":random", 25),
        (gt, "$message_cost", 14999),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. Your proposal has been accepted and {s10} has been released from captivity.'"),
        ##        (party_remove_prisoners, ":party", ":troop", 1),
        ##        (call_script, "script_remove_troop_from_prison", ":troop"),
        (party_remove_prisoners, ":party", ":troop_no",1),
        (remove_troops_from_prisoners,  ":troop_no", 1),
        (troop_set_slot, ":troop_no", slot_troop_prisoner_of_party, -1),
        (call_script, "script_remove_troop_from_prison", ":troop_no"),
        (call_script, "script_change_player_relation_with_troop", ":troop_no", 15),
        (call_script, "script_change_player_honor", 2),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. Your proposal was not accepted and {s10} will remain captive. Here you have your money back.'"),
        (troop_add_gold, "trp_player", "$message_type"),
      (try_end),
      
    ],
    [
      ("Continue_msse",[
        ],
        "Thank for your service.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###################
  (
    "messenger_system_follow",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s12),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      #(assign,":party_destino","$message_place"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (ge, ":relation", 1),
        ##                      (this_or_next|eq, ":party_faction", "$players_kingdom"),
        ##                        (eq, ":party_faction", "fac_player_supporters_faction"),
        (this_or_next|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
        
        ##                        (this_or_next|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
        ##			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} will meet you and will follow you as soon as possible.'"),
        
        (assign, "$temp", spai_accompanying_army),
        (assign, "$temp_2", "p_main_party"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
        
      (else_try), #option 2 possitive
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (ge, ":relation", 10),
        ##                     (this_or_next|eq, ":party_faction", "$players_kingdom"),
        ##                        (eq, ":party_faction", "fac_player_supporters_faction"),
        (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
        
        (store_skill_level, ":player_persuasion_level", "skl_persuasion", "trp_player"),
        (store_div, ":player_relation_div_5", ":relation", 5),
        (val_min, ":player_relation_div_5", 10),
        (store_add, ":player_persuasion_power", ":player_relation_div_5", ":player_persuasion_level"),
        
        (store_sub, ":needed_lowest_renown", 20, ":player_persuasion_power"),
        (val_mul, ":needed_lowest_renown", 800),
        (val_div, ":needed_lowest_renown", 10),
        (this_or_next|lt, ":player_renown", ":needed_lowest_renown"),
        
        ##                        (this_or_next|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
        ##			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} will meet you and will follow you as soon as possible.'"),
        
        (assign, "$temp", spai_accompanying_army),
        (assign, "$temp_2", "p_main_party"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
      (else_try),
        
        (neq, ":party_faction", "$players_kingdom"),
        (neq, ":party_faction", "fac_player_supporters_faction"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says you're not the one to give orders.'"),
      (else_try),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says that it would hardly be proper as you don't have authority for it.'"),
      (else_try),
        (le, ":relation", 1),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} has better things to do than follow your orders.'"),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} is busy and cannot follow orders at this time.'"),
      (try_end),
      
    ],
    [
      ("Continue_mess2",[
        ],
        "Well.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ########################
  (
    "messenger_system_gotoplace",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s10),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      (assign,":party_destino","$message_place"),
      (str_store_party_name, s10,":party_destino"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (ge, ":relation", 1),
        (this_or_next|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
        
        ##                        (this_or_next|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
        ##			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} will go to {s10} as soon as possible.'"),
        
        (assign, "$temp", spai_holding_center),
        (assign, "$temp_2", ":party_destino"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
        
      (else_try), #option 2 possitive
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (ge, ":relation", 10),
        (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
        
        (store_skill_level, ":player_persuasion_level", "skl_persuasion", "trp_player"),
        (store_div, ":player_relation_div_5", ":relation", 5),
        (val_min, ":player_relation_div_5", 10),
        (store_add, ":player_persuasion_power", ":player_relation_div_5", ":player_persuasion_level"),
        
        (store_sub, ":needed_lowest_renown", 20, ":player_persuasion_power"),
        (val_mul, ":needed_lowest_renown", 800),
        (val_div, ":needed_lowest_renown", 10),
        (this_or_next|lt, ":player_renown", ":needed_lowest_renown"),
        
        ##                        (this_or_next|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
        ##			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} will go to {s10} as soon as possible.'"),
        
        (assign, "$temp", spai_holding_center),
        (assign, "$temp_2", ":party_destino"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
      (else_try),
        
        (neq, ":party_faction", "$players_kingdom"),
        (neq, ":party_faction", "fac_player_supporters_faction"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says you're not the one to give orders.'"),
      (else_try),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says that it would hardly be proper as you don't have authority for it.'"),
      (else_try),
        (le, ":relation", 1),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} has better things to do than follow your orders.'"),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} is busy and cannot follow orders at this time.'"),
      (try_end),
      
    ],
    [
      ("Continue_mess3",[
        ],
        "Well.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ##########################                   (
  (
    "messenger_system_patrolarea",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s10),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      (assign,":party_destino","$message_place"),
      (str_store_party_name, s10,":party_destino"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      #    (store_faction_of_party, ":center_faction", ":party_destino"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (ge, ":relation", 1),
        (faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message.: {s9} will go patrol around {s10} as soon as possible.'"),
        
        (assign, "$temp", spai_patrolling_around_center),
        (assign, "$temp_2", ":party_destino"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
        
      (else_try), #option 2 possitive
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (ge, ":relation", 10),
        (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown),
        
        (store_skill_level, ":player_persuasion_level", "skl_persuasion", "trp_player"),
        (store_div, ":player_relation_div_5", ":relation", 5),
        (val_min, ":player_relation_div_5", 10),
        (store_add, ":player_persuasion_power", ":player_relation_div_5", ":player_persuasion_level"),
        
        (store_sub, ":needed_lowest_renown", 20, ":player_persuasion_power"),
        (val_mul, ":needed_lowest_renown", 800),
        (val_div, ":needed_lowest_renown", 10),
        (this_or_next|lt, ":player_renown", ":needed_lowest_renown"),
        
        ##                        (this_or_next|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
        ##			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} will go patrol around {s10} as soon as possible.'"),
        
        (assign, "$temp", spai_patrolling_around_center),
        (assign, "$temp_2", ":party_destino"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
      (else_try),
        
        (neq, ":party_faction", "$players_kingdom"),
        (neq, ":party_faction", "fac_player_supporters_faction"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says you're not the one to give orders.'"),
      (else_try),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says that it would hardly be proper as you don't have authority for it.'"),
      (else_try),
        (le, ":relation", 1),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} has better things to do than follow your orders.'"),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} is busy and cannot follow orders at this time.'"),
      (try_end),
      
    ],
    [
      ("Continue_mess4",[
        ],
        "Well.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #######
  (
    "messenger_system_besiegeplace",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s10),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      (assign,":party_destino","$message_place"),
      (str_store_party_name, s10,":party_destino"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      (store_faction_of_party, ":center_faction", ":party_destino"),
      (store_relation, ":relation_fac_center", ":center_faction", "fac_player_faction"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (lt, ":opponent", 0), #party is not itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (lt, ":attached_to", 0), #party is not attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (neq, ":behavior", 8),#party is not in a town/castle
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
        (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (party_slot_eq, ":party_destino", slot_center_is_besieged_by, -1),
        (neq, ":center_faction", "$players_kingdom"),
        (neq, ":center_faction", "fac_player_supporters_faction"),
        (lt, ":relation_fac_center", 0),
        
        (ge, ":relation", 0),
        (this_or_next|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (faction_slot_eq, "fac_player_supporters_faction", slot_faction_leader, "trp_player"),
        
        #       (neg|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
        ##			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} will go to besiege {s10} as soon as possible.'"),
        
        (assign, "$temp", spai_besieging_center),
        (assign, "$temp_2", ":party_destino"),
        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
      (else_try),
        
        (neq, ":party_faction", "$players_kingdom"),
        (neq, ":party_faction", "fac_player_supporters_faction"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says you're not one to give orders.'"),
      (else_try),
        (neg|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} says that would hardly be proper as you don't have authority for it.'"),
      (else_try),
        (le, ":relation", 1),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} has better things to do than follow your orders.'"),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} is busy and cannot follow orders at this time.'"),
      (try_end),
      
    ],
    [
      ("Continue_mess5",[
        ],
        "Well.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ############
  ##                  (
  ##    "messenger_system_raidarea",0,
  ##    "{!}{s4}",
  ##    "none",
  ##    [
  ##    (set_background_mesh, "mesh_pic_messenger"),
  ##                   (str_clear, s4),
  ##                         (str_clear, s10),
  ##                         (str_clear, s2),
  ##                         (str_clear, s1),
  ##                         (str_clear, s9),
  ##	(assign,":party_no","$message_target"),
  ##	(assign,":party_destino","$message_place"),
  ##          (str_store_party_name, s10,":party_destino"),
  ##
  ##		(party_stack_get_troop_id, ":leader", ":party_no", 0),
  ##	  (call_script, "script_troop_get_player_relation", ":leader"),
  ##               (assign, ":relation", reg0),
  ##                 (store_faction_of_party, ":party_faction", ":party_no"),
  ##                 (store_faction_of_party, ":center_faction", ":party_destino"),
  ##                 (store_relation, ":relation_fac_center", ":center_faction", "fac_player_faction"),
  ##
  ##		(str_store_troop_name,s1,":leader"),
  ##		(str_store_faction_name,s2,":party_faction"),
  ##		(str_store_string,s9,"@{s1} of the {s2}."),
  ##
  ##                (try_begin),
  ##			(party_get_battle_opponent, ":opponent",":party_no"),
  ##			(lt, ":opponent", 0), #party is not itself involved in a battle
  ##			(party_get_attached_to, ":attached_to",":party_no"),
  ##			(lt, ":attached_to", 0), #party is not attached to another party in battle
  ##			(get_party_ai_behavior, ":behavior", ":party_no"),
  ##			(neq, ":behavior", 8),#party is not in a town/castle
  ##                  (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
  ##                  (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
  ##                  (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_accompanying_army),
  ##                  (neg|party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
  ##                     (neq, ":center_faction", "$players_kingdom"),
  ##                     (neq, ":center_faction", "fac_player_supporters_faction"),
  ##                     (lt, ":relation_fac_center", 0),
  ##
  ##                    (ge, ":relation", 0),
  ##                      (this_or_next|eq, ":party_faction", "$players_kingdom"),
  ##                        (eq, ":party_faction", "fac_player_supporters_faction"),
  ##                         (faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
  ##
  ####                        (this_or_next|party_slot_eq, ":party_destino", slot_party_type, spt_castle),
  ####			(party_slot_eq, ":party_destino", slot_party_type, spt_town),
  ##
  ##			(str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^\
  ##'I have returned with the answer to your message. {s9} will go to raid around {s10} as soon as possible.'"),
  ##
  ##                	  (assign, "$temp", spai_raiding_around_center),
  ##                         (assign, "$temp_2", ":party_destino"),
  ##                        (call_script, "script_party_set_ai_state", ":party_no", "$temp", "$temp_2"),
  ## 	             (else_try),
  ##
  ##                       (neq, ":party_faction", "$players_kingdom"),
  ##                        (neq, ":party_faction", "fac_player_supporters_faction"),
  ##			(str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^\
  ##'I have returned with the answer to your message. {s9} says you're not one to give orders.'"),
  ##	             (else_try),
  ##                        (neg|faction_slot_eq, "$players_kingdom", slot_faction_leader, "trp_player"),
  ##			(str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^\
  ##'I have returned with the answer to your message. {s9} says that would hardly be proper as you don't have authority for it.'"),
  ##	             (else_try),
  ##                         (le, ":relation", 1),
  ##			(str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^\
  ##'I have returned with the answer to your message. {s9} has better things to do than follow your orders.'"),
  ##	             (else_try),
  ##			(str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^\
  ##'I have returned with the answer to your message. {s9} is busy and cannot follow orders at this time.'"),
  ##                      (try_end),
  ##
  ##        ],
  ##    [
  ##        ("Continue",[
  ##            ],
  ##         "Well.",[
  ##					(assign,"$message_target",-1), #lord
  ##					(assign,"$message_type",-1), #type
  ##					(assign,"$message_distance",-1), #distance
  ##					(assign,"$message_place",-1), #place
  ##                                        (party_set_slot, "p_town_1", slot_party_messenger_time, 1), #distance - time
  ##				        (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
  ##                                       (change_screen_return),
  ##            ]),
  ##     ]
  ##  ),
  #########
  (
    "messenger_system_insult",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s12),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (this_or_next|ge, ":opponent", 0), #party is itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (this_or_next|ge, ":attached_to", 0), #party is attached to another party in battle
        (get_party_ai_behavior, ":behavior", ":party_no"),
        (this_or_next|eq, ":behavior", 8),#party is not in a town/castle
        (this_or_next|party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (this_or_next|party_slot_eq, ":party_no",      slot_party_ai_state, spai_raiding_around_center),
        (party_slot_eq, ":party_no",      slot_party_ai_state, spai_visiting_village),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} was busy and did not receive me. His men threatened to kill me if I insisted.'"),
        (call_script, "script_change_player_relation_with_troop", ":leader", -1),
      (else_try),
        (ge, ":relation", 5),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} is surprised by your insult, especially when there was no enmity between you. He says that he will ignore it this time, but do not provoke him again.'"),
        (call_script, "script_change_player_relation_with_troop", ":leader", -5),
      (else_try),
        (lt, ":relation", 5),
        (store_random_in_range, ":rand", 0, 100),
        (try_begin),
          (ge, ":rand", 90),
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was greatly angered by your insult, falling fully under the provocation of your challenge. He called his men to arms, and I think he will advance against you.'"),
          (call_script, "script_party_set_ai_state", ":party_no", spai_engaging_army, "p_main_party"),
          ##		         	(party_set_ai_behavior, ":party_no", ai_bhvr_attack_party),
          ##			       (party_set_ai_object,":party_no","p_main_party"),
          ##                              (party_set_flags, ":party_no", pf_default_behavior, 1),
          (call_script, "script_change_player_relation_with_troop", ":leader", -10),
        (else_try),
          (ge, ":rand", 80),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was greatly angered by your insult, falling fully under the provocation of your challenge. He called his men to arms, and I think he will advance against you.'"),
          (call_script, "script_party_set_ai_state", ":party_no", spai_engaging_army, "p_main_party"),
          ##			      (party_set_ai_behavior, ":party_no", ai_bhvr_attack_party),
          ##			     (party_set_ai_object,":party_no","p_main_party"),
          ##                              (party_set_flags, ":party_no", pf_default_behavior, 1),
          (call_script, "script_change_player_relation_with_troop", ":leader", -10),
        (else_try),
          (ge, ":rand", 70),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_roguish), #picaro
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_selfrighteous), #autosuficiente
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_martial), #warrior
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was greatly angered by your insult, falling fully under the provocation of your challenge. He called his men to arms, and I think he will advance against you.'"),
          (call_script, "script_party_set_ai_state", ":party_no", spai_engaging_army, "p_main_party"),
          ##			      (party_set_ai_behavior, ":party_no", ai_bhvr_attack_party),
          ##			     (party_set_ai_object,":party_no","p_main_party"),
          ##                               (party_set_flags, ":party_no", pf_default_behavior, 1),
          (call_script, "script_change_player_relation_with_troop", ":leader", -10),
        (else_try),
          (ge, ":rand", 60),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_roguish), #picaro
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_selfrighteous), #autosuficiente
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_custodian), #protector
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_martial), #warrior
          
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was greatly angered by your insult, falling fully under the provocation of your challenge. He called his men to arms, and I think he will advance against you.'"),
          (call_script, "script_party_set_ai_state", ":party_no", spai_engaging_army, "p_main_party"),
          ##			       (party_set_ai_behavior, ":party_no", ai_bhvr_attack_party),
          ##			        (party_set_ai_object,":party_no","p_main_party"),
          ##                              (party_set_flags, ":party_no", pf_default_behavior, 1),
          (call_script, "script_change_player_relation_with_troop", ":leader", -10),
        (else_try),
          (ge, ":rand", 50),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_roguish), #picaro
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_selfrighteous), #autosuficiente
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_custodian), #protector
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_quarrelsome), #pendenciero
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_benefactor), #benefactor
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_martial), #warrior
          # (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_goodnatured), #buenon
          
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was greatly angered by your insult, falling fully under the provocation of your challenge. He called his men to arms, and I think he will advance against you.'"),
          ##			        (party_set_ai_behavior, ":party_no", ai_bhvr_attack_party),
          ##			         (party_set_ai_object,":party_no","p_main_party"),
          ##                               (party_set_flags, ":party_no", pf_default_behavior, 1),
          (call_script, "script_change_player_relation_with_troop", ":leader", -10),
        (else_try),
          (ge, ":rand", 40),
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} has not fallen for your provocation. He answered to not waste more of his time.'"),
          (call_script, "script_change_player_relation_with_troop", ":leader", -1),
        (else_try),
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
            "'I have returned with the answer to your message. {s9} has not fallen for your provocation, but he has retaliated with insults difficult to repeat but all very descriptive. " +
          "And he said that if you had a problem for which you had the courage to look for him, he would love to teach you some manners.'"),
          (call_script, "script_change_player_relation_with_troop", ":leader", -8),
          (call_script, "script_change_troop_renown", "trp_player", -10),
        (try_end),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} was busy and did not receive me. His men threatened to kill me if I insisted.'"),
        (call_script, "script_change_player_relation_with_troop", ":leader", -1),
      (try_end),
      
    ],
    [
      ("Continue_mess6",[
        ],
        "Thank you for your service.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ####
  (
    "messenger_system_sendgift",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s12),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      (store_random_in_range, ":rand", 0, 100),
      
      (try_begin),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (this_or_next|ge, ":opponent", 0), #party is itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (this_or_next|ge, ":attached_to", 0), #party is attached to another party in battle
        (party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} was busy and did not receive me. However, his men took the gift and divided it among themselves, threatening to kill me if I insisted on delivering your message.'"),
        (call_script, "script_change_player_relation_with_troop", ":leader", -5),
      (else_try),
        (ge, ":relation", 0),
        (ge, ":rand", 30),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} thanks you for your gift, and says he will make the next feast in your honor.'"),
        (call_script, "script_change_player_relation_with_troop", ":leader", 5),
      (else_try),
        (le, ":relation", -70),
        (this_or_next|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_selfrighteous), #autosuficiente
        (troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} took your gift and gave it to his men, saying it is the tribute of a coward. His response was that he would be your enemy forever. Nothing can change that after everything that has happened between the two of you.'"),
        (call_script, "script_change_player_relation_with_troop", ":leader", -10),
        (call_script, "script_change_troop_renown", "trp_player", -10),
      (else_try),
        (lt, ":relation", 0),
        (try_begin),
          (ge, ":rand", 85),
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} is encouraged to know you have an interest in resolving the differences and bad relations between you. Although still there are many things to resolve, this is a good start, and he accepts your gift.'"),
          (call_script, "script_change_player_relation_with_troop", ":leader", 10),
        (else_try),
          (ge, ":rand", 65),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} is encouraged to know you have an interest in resolving the differences and bad relations between you. Although still there are many things to resolve, this is a good start, and he accepts your gift.'"),
          (call_script, "script_change_player_relation_with_troop", ":leader", 10),
        (else_try),
          (ge, ":rand", 45),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_roguish), #picaro
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_selfrighteous), #autosuficiente
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_martial), #warrior
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} is encouraged to know you have an interest in resolving the differences and bad relations between you. Although still there are many things to resolve, this is a good start, and he accepts your gift.'"),
          (call_script, "script_change_player_relation_with_troop", ":leader", 10),
        (else_try),
          (ge, ":rand", 30),
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_cunning), #astuto
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_upstanding), #respetable
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_roguish), #picaro
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_selfrighteous), #autosuficiente
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_custodian), #protector
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_quarrelsome), #pendenciero
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_benefactor), #benefactor
          (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_martial), #warrior
          # (neg|troop_slot_eq, ":leader", slot_lord_reputation_type, lrep_goodnatured), #buenon
          
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} is encouraged to know you have an interest in resolving the differences and bad relations between you. Although still there are many things to resolve, this is a good start, and he accepts your gift.'"),
          (call_script, "script_change_player_relation_with_troop", ":leader", 10),
        (else_try),
          (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} did not accept the gift, but his men took me where I was going. Sorry, I lost the treasure.'"),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (call_script, "script_change_player_relation_with_troop", ":leader", -1),
        (try_end),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} was busy and did not receive me. However, his men took the gift and divided it among themselves, threatening to kill me if I insisted on delivering your message.'"),
      (try_end),
      
    ],
    [
      ("Continue_mess7",[
        ],
        "Thank you for your service.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #############
  (
    "messenger_system_sugalliance",0,
    "{!}{s4}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s4),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      (store_relation, ":relation_fac", ":party_faction", "fac_player_faction"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        ##                        (call_script, "script_diplomacy_faction_get_diplomatic_status_with_faction", "fac_player_supporters_faction", ":party_faction"),
        ##                    (eq, reg0, 1),  #player has a truce
        ## 			(str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^\
        ##'I have returned with the answer to your message. {s9} says that if this is a joke, since both are have a truce. Orders that you do not bother him more with this.'"),
        ##                                       (call_script, "script_change_player_relation_with_troop", ":leader", -5),
        #     (else_try),
        (party_get_battle_opponent, ":opponent",":party_no"),
        (this_or_next|ge, ":opponent", 0), #party is itself involved in a battle
        (party_get_attached_to, ":attached_to",":party_no"),
        (this_or_next|ge, ":attached_to", 0), #party is attached to another party in battle
        (party_slot_eq, ":party_no",      slot_party_ai_state, spai_besieging_center),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} did not want to meet me, saying he was busy and does not like to discuss these things with a lowly messenger.'"),
      (else_try),
        (le, ":relation_fac", 30), #very goods relations need
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} did not want to meet me, saying he was busy and does not like to discuss these things with a lowly messenger.'"),
      (else_try),
        (ge, ":relation", 5),
        (faction_slot_eq, ":party_faction", slot_faction_recognized_player, 1), #recognized us
        (faction_slot_eq, ":party_faction", slot_faction_state, sfs_active),
        
        (call_script, "script_npc_decision_checklist_peace_or_war", ":party_faction", "fac_player_supporters_faction", ":leader"),
        (assign, "$g_mission_result_with_player", reg0),
        (ge, "$g_mission_result_with_player", 1), #no want war
        (store_random_in_range,":random", 5, 20),
        (ge, "$player_right_to_rule", ":random"),
        (call_script, "script_diplomacy_start_alliance_between_kingdoms", ":party_faction", "$players_kingdom", 1),
        
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} accepts your alliance proposal. From now on, {s2} is your ally.'"),
        
        (call_script, "script_change_player_relation_with_faction", ":party_faction", 10),
        (call_script, "script_change_player_relation_with_troop", ":leader", 10),
      (else_try),
        (str_store_string, s4, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} did not want to meet me, saying he was busy and does not like to discuss these things with a lowly messenger.'"),
      (try_end),
      
    ],
    [
      ("Continue_messeng1",[
        ],
        "Thank you for your service.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ###########
  (
    "messenger_system_suggestpeace",0,
    "{!}{s3}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_clear, s3),
      (str_clear, s4),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (assign,":party_no","$message_target"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (call_script, "script_troop_get_player_relation", ":leader"),
      (assign, ":relation", reg0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      (store_relation, ":relation_fac", "fac_player_faction", ":party_faction"),
      
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (try_begin),
        (gt, ":relation", 5),
        (ge, ":relation_fac", -30), #only possible if factions relations arent too bad, but other methods no messenger
        (faction_slot_eq, ":party_faction", slot_faction_recognized_player, 1), #recognized us
        (faction_slot_eq, ":party_faction", slot_faction_state, sfs_active),
        (call_script, "script_npc_decision_checklist_peace_or_war", ":party_faction", "fac_player_supporters_faction", ":leader"),
        (assign, "$g_mission_result_with_player", reg0),
        (ge, "$g_mission_result_with_player", 1), #no want war
        (store_random_in_range,":random", 5, 20),
        (ge, "$player_right_to_rule", ":random"),
        (call_script, "script_diplomacy_start_peace_between_kingdoms", ":party_faction", "$players_kingdom", 1),
        
        (str_store_string, s3, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} accepts your truce proposal. From now on, {s2} and you are at peace.'"),
        
        (call_script, "script_change_player_relation_with_faction", ":party_faction", 5),
        (call_script, "script_change_player_relation_with_troop", ":leader", 5),
      (else_try),
        (str_store_string, s3, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
        "'I have returned with the answer to your message. {s9} did not want to meet me, saying he was busy and does not like to discuss these things with a lowly messenger.'"),
      (try_end),
    ],
    [
      ("Continue_messeng2",[
        ],
        "Thank you for your service.",[
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  ##############
  (
    "messenger_system_declarewar",0,
    "{!}{s3}",
    "none",
    [
      (str_clear, s3),
      (str_clear, s4),
      (str_clear, s2),
      (str_clear, s1),
      (str_clear, s9),
      (set_background_mesh, "mesh_pic_messenger"),
      (assign,":party_no","$message_target"),
      
      (party_stack_get_troop_id, ":leader", ":party_no", 0),
      (store_faction_of_party, ":party_faction", ":party_no"),
      (str_store_troop_name,s1,":leader"),
      (str_store_faction_name,s2,":party_faction"),
      (str_store_string,s9,"@{s1} of the {s2}"),
      
      (store_random_in_range, ":random", 1, 10),
      #(call_script, "script_diplomacy_faction_get_diplomatic_status_with_faction", "fac_player_supporters_faction", ":party_faction"),
      #(assign, ":current_diplomatic_status", reg0),
      (try_begin),
        #(eq, ":current_diplomatic_status", -1), #attack neutral
        (ge, ":random", 7), #
        (str_store_string, s3, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} did not appear surprised by your declaration of war because you are scum whom nobody can trust.^^" +
        "From now on, you are at war with {s2}'"),
        (call_script, "script_diplomacy_start_war_between_kingdoms",  "fac_player_supporters_faction", ":party_faction", logent_player_faction_declares_war),	#MOTO chief pass log entries
      (else_try),
        (ge, ":random", 4), #
        #(eq, ":current_diplomatic_status", 0), #attack neutral
        (str_store_string, s3, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was very offended by your desire to provoke a war and promises to send messengers everywhere to publicize your villainy.^^" +
        "From now on, you are at war with {s2}'"),
        (call_script, "script_diplomacy_start_war_between_kingdoms",  "fac_player_supporters_faction", ":party_faction", logent_player_faction_declares_war),	#MOTO chief pass log entries
      (else_try),
        (str_store_string, s3, "@A messenger approaches, galloping. He stops in front of you, takes a breath and shouts:^^" +
          "'I have returned with the answer to your message. {s9} was very offended by your war declaration. He called you treacherous rat and said you would pay dearly.^^" +
        "From now on, you are at war with {s2}'"),
        (call_script, "script_diplomacy_start_war_between_kingdoms",  "fac_player_supporters_faction", ":party_faction", logent_player_faction_declares_war),	#MOTO chief pass log entries
      (try_end),
      (call_script, "script_change_player_relation_with_troop", ":leader", -10),
      (call_script, "script_change_player_relation_with_faction", ":party_faction", -10),
    ],
    [
      ("Continue_messeng3",[
        ],
        "I have my war.",[
          ####
          
          
          (assign,"$message_target",-1), #lord
          (assign,"$message_type",-1), #type
          (assign,"$message_distance",-1), #distance
          (assign,"$message_place",-1), #place
          (party_set_slot, "p_town_1", slot_party_messenger_time, -1), #distance - time
          (assign, "$message_target_type", -1),  # 1 player's kingdom lord , 2 no player's kingdom lord , 3 King of other kingdom
          (assign,"$message_sent",0), #message sent
          (assign,"$message_cost",-1),
          (assign,"$message_lord",0), #free lord.
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #######
  
  ######################### KINGDOM Random Events and rebolts ########
  
  ####random event juicios cuando eres rey chief
  (
    "random_juice_events",0, #final menu, load presentation to consequences
    "Events",
    "none",
    [
      (start_presentation, "prsnt_random_event_solution"),
    ],
    [
      ("leave",[],"Leave.",[
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  
  
  (
    "event_01_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Two farmers, one very tall and lanky, the other low and stocky, were presented to you to discuss the ownership of a calf. " +
    "Apparently, their fields bordered each other, and the tall farmer had a bull that impregnated a cow belonging to the other. " +
    "The stocky farmer said the calf was his, because it was his cow giving birth. " +
    "The tall farmer claimed the calf to be his, being the offspring of his best bull. He said he should at least get stud fees.",
    "none",
    [
      (set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_01_1nj",[],"The owner of the cow is right. The calf is his, just like the cow is.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (str_clear,s1),
          (str_store_string,s1,"@The other man is not very happy and criticizes you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
      ("choice_01_2nj",[],"The owner of the bull is right. The bull is his and the calf too.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (str_clear,s1),
          (str_store_string,s1,"@The other man is not very happy and criticizes you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
      ("choice_01_3nj",[],"The owner of the cow keeps the calf and pays compensation to the other.",
        [
          (display_message, "@Neither man is happy or unhappy. You seem to have found a balance."),
          (change_screen_return),
        ]
      ),
      ("choice_01_4nj",[],"Neither is right. I'll slaughter the calf for its meat and give some to my men!",
        [
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (call_script, "script_change_troop_renown", "trp_player", -4),
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          (call_script, "script_change_player_party_morale", 2),
          (str_clear,s1),
          (str_store_string,s1,"@The two men are not very happy and criticize you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
      ("choice_01_5nj",[],"Neither is right. Kill the calf and give the meat to both farmers!",
        [
          (call_script, "script_change_troop_renown", "trp_player", 2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          (str_clear,s1),
          (str_store_string,s1,"@The two men are not very happy and criticize you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
    ]
  ),
  
  
  (
    "event_02_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "My {reg59?lady:lord}, we captured a murderer! This is the man who attacked one of our messengers in {s4}, who is lying seriously injured in bed. " +
    "This doesn't show us in a good light, for the messenger was under your protection. However, the attacker has an interesting story, and he wishes to talk to you before his execution.^^" +
    "The prisoner's story: 'My {reg59?lady:lord}, I would have never thought of attacking your messenger, but that man wished to sleep with my young daughter at night, and this offer was refused! " +
    "However, he did not accept our answer, entered my house with three friends, and raped my dear daughter, laughingly telling me all the while that you would never believe the word of a commoner. A father must protect his only child!'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_02_1nj",[],"He was under my protection. You and your family will be executed.",
        [
          (str_store_party_name, s4, "$current_town"),
          (troop_add_gold, "trp_player", 1000),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          (call_script, "script_change_player_party_morale", 2),
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} think that you will not guarantee their families' protection against those who abuse their power under your favor. Rumors spread that you are a bad {reg59?lady:lord}."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
      ("choice_02_2nj",[],"I will be reasonable: only you will be hanged.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_honor", -2),
          (call_script, "script_change_player_party_morale", 2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} think that you will not guarantee their families' protection because the messenger will not be punished. Rumors spread that you are unjust."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
      ("choice_02_3nj",[],"Even though he was my servant, I would have done the same. You can go.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -1),
          (call_script, "script_change_player_party_morale", -5),
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} think that you will not guarantee their families' protection because the messenger will not be punished, but at least their fellow citizen will not be punished. However, your men are not happy with your generosity to a man who attacked someone under your protection."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
      ("choice_02_4nj",[],"I order him to be hanged. No one should take advantage of their position.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_honor", 1),
          (call_script, "script_change_player_relation_with_center", "$current_town", 5),
          (call_script, "script_change_player_party_morale", -6),
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} think that you will guarantee their families' protection, and they seem happy. However, you men are not happy that you will kill their companion."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          # (start_presentation, "prsnt_random_event_solution"),
        ]
      ),
    ]
  ),
  
  (
    "event_03_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You summon two men to decide a dispute between them. One is a local leader, while the other is a farmer who rents the land of the leader.^^" +
    "The man says his harvest was poor and cannot pay the rent, so the leader took the farmer's daughter to his own bed and as a servant in his house. " +
    "The local leader is an influential figure within {s4}.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_03_1nj",[],"Punish the farmer. He must pay rent to his lord.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (call_script, "script_change_player_honor", -2),
          (jump_to_menu, "mnu_farmer_attack_lord"),
          ##				(str_store_party_name, s4, "$current_town"),
          ##		  (display_message, "@People in {s4} think that you were hard on the farmer. Rumors spread that you are unjust."),
          ##	   (change_screen_return),
        ]
      ),
      ("choice_03_2nj",[],"Punish the local leader. He has no right to take the farmer's daughter.",
        [
          (str_store_party_name, s4, "$current_town"),
          (display_message, "@The local leader is upset with you and talks bad about you to the elites of {s4}."),
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          (call_script, "script_change_player_honor", 2),
          (str_clear,s1),
          (str_store_string,s1,"@The local leader is upset with you and talks bad about you to the elites of {s4}."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_03_3nj",[],"Kill the noble and force the farmer to join your army for not paying his taxes.",
        [
          (str_store_party_name, s4, "$current_town"),
          (party_add_members, "p_main_party", "trp_farmer", 1),
          (call_script, "script_change_player_relation_with_center", "$current_town", 5),
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} are surprised by your drastic measures, and everyone seems more willing to follow your rules."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_03_4nj",[		          (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 300),
        ],"Compensate the noble yourself for the tribute and send the girl back.",
        [
          (str_store_party_name, s4, "$current_town"),
          (display_message, "@Farmers in {s4} are concerned about their daughters as you favor the powerful who take advantage of their weakness."),
          (call_script, "script_change_player_honor", -1),
          (troop_remove_gold, "trp_player", 300),
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          (str_clear,s1),
          (str_store_string,s1,"@Farmers in {s4} are concerned about their daughters as you favor the powerful who take advantage of their weakness."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_03_5nj",[		          (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 300),
        ],"Compensate the farmer by paying wergild for daughter who was raped.",
        [
          (str_store_party_name, s4, "$current_town"),
          (troop_remove_gold, "trp_player", 300),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (call_script, "script_change_player_relation_with_center", "$current_town", 4),
          (str_clear,s1),
          (str_store_string,s1,"@Farmers in {s4} are reassured when you pay, while the local leader is happy not to be punished."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
    ]
  ),
  
  ### hecho encadenado
  (
    "farmer_attack_lord",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Not satisfied with your decision, the farmer pulls out his seax and pounces on the local leader, killing him before your men can do anything. " +
    "Then he turns to you and says, 'This is justice, bastard!' Then with the same seax, he kills himself.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_03_1attackj",[],"Continue.",
        [
          (str_store_party_name, s4, "$current_town"),
          (display_message, "@The outcome of the trial has seriously shaken the people of {s4} and has called into question your authority."),
          (call_script, "script_change_player_relation_with_center", "$current_town", -12),
          (call_script, "script_change_troop_renown", "trp_player", -6),
          (str_clear,s1),
          (str_store_string,s1,"@Farmers in {s4} are reassured when you pay, while the local leader is happy not to be punished."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
    ]
  ),
  
  #### morale less than 50 condition?
  (
    "event_04_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One of your sworn men approaches you. He states his fears that, among the men, there is much dissatisfaction. " +
    "Reason being that you are too placid and that there is too little gold and honour to be won in your service.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_04_1nj",[      (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 1000),
          (store_mul, ":gold_per", 1000, 100),
          (val_div, ":gold_per", ":gold"),
          (le, ":gold_per", 10),
        ],"Pay the men and give rings to them.",
        [
          (troop_remove_gold, "trp_player", 1000),
          (call_script, "script_change_player_party_morale", 4),
          (call_script, "script_change_troop_renown", "trp_player", -10),
          (str_clear,s1),
          (str_store_string,s1,"@Your men think you're a weak leader who is easily manipulated."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_04_2nj",[],"The men are released from their oaths if they want to leave.",
        [
          (call_script, "script_change_troop_renown", "trp_player", 3),
          
          (store_random_in_range, ":p_leave", 5, 10),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          (call_script, "script_change_player_party_morale", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men seem uncomfortable, and some of them leave you. You should try to improve morale of the rest soon."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_04_3nj",[],"Kill the man who approached you and state there shall be no more talk of sedition.",
        [
          (call_script, "script_change_player_honor", -4),
          (call_script, "script_change_player_party_morale", -10),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men seem uncomfortable, but no one says a word. It looks like you got a little more respect, but should strive to improve their morale."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_04_4nj",[
          (store_skill_level, ":persuasion", "skl_persuasion", "trp_player"),
          (gt, ":persuasion", 4),
        ],"Promise to change your leadership style.",
        [
          (call_script, "script_change_player_party_morale", -1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men seem uncomfortable. You should try to improve morale of the rest soon."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  #
  (
    "event_05_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "In {s4}, a man is brought before you. Your men inform you that he refuses to pay taxes to the kingdom, and therefore to you. The man insists that he will not pay taxes until the kingdom gives him back his boys, all of them killed in recent wars.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_05_1nj",[],"This man has already lost enough. Forgive his taxes for life.",
        [
          
          (jump_to_menu, "mnu_nobody_want_paytax"),
          ## (change_screen_return),
        ]
      ),
      ("choice_05_2nj",[],"Punish this man with death if he does not pay.",
        [
          
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -15),
          (call_script, "script_change_player_honor", -3),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Eventually the man dies in torment while your soldiers try to force him to pay his taxes. His last words were, 'Boys, beyond, where you are, I am coming.' The city is shocked by his death, and many people complain about you in {s4}."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_05_3nj",[
          (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 500),
        ],"Pay the man a wergild for the death of his boys.",
        [
          (str_store_party_name, s4, "$current_town"),
          (troop_remove_gold, "trp_player", 500),
          (call_script, "script_change_player_relation_with_center", "$current_town", 6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The man seems calmed by your words. You see in his eyes an infinite sadness, but he promises to pay his taxes in the memory of his boys."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  ###event encadenado
  (
    "nobody_want_paytax",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Suddenly, the room where you exercise your legal authority is crowded with people who have lost sons to war, all demanding equal treatment.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_05_2notaxj",[
          (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 2000),
          ],"Distribute bags of money among the people as compensation (2000 peningas).",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 8),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (troop_remove_gold, "trp_player", 2000),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your renown with your warriors suffers, as does your money bag, but the people of {s4} seem happy with the money you have given them."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_05_3notaxj",[
        ],"Having no money for all these people, you order your men to disperse the crowd.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          (store_random_in_range, ":p_leave", 5, 10),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          (call_script, "script_change_player_party_morale", -6),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men push the crowd, injuring some. Suddenly, the people turn against them, causing some casualties before being dispersed."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_05_4notaxj",[
        ],"Run out, escorted by your men, away from the crowd.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", -5),
          (call_script, "script_change_troop_renown", "trp_player", -9),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@You run through the back door while the crowd calls you a coward and miser, even as they continue to beg for money."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  ################
  
  (
    "event_06_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Two men come to you. Your men say they are ready to kill each other. One of them has cut some old oaks that were blocking traffic on the way, but they were actually within the borders of the estate of the other.^^" +
    "'Those trees made the passage of my cart difficult!' exclaims the first one. 'We are only talking about trees. I do not understand this suit!'^^" +
    "'Those trees were on my land, planted by my father, recently deceased,' shouts the other.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_06_1nj",[],"The man who cut the trees must pay to the other in compensation.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", 6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@People think the measure is fair to both."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_06_2nj",[],"Trees hindered the way. They had to be cut.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The tree owner is not very happy and criticizes you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_06_3nj",[],"The man who cut the trees must give money to the other and to you as punishment.",
        [
          (call_script, "script_troop_add_gold", "trp_player", 100),
          (call_script, "script_change_player_relation_with_center", "$current_town", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The man who cut the trees is not very happy and criticizes you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_07_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The harvest this year promises to be very bad, which means starvation for the winter. What should we do?",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_07_1nj",[	    (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 1000),
          (store_mul, ":gold_per", 1000, 100),
          (val_div, ":gold_per", ":gold"),
          (le, ":gold_per", 10),
          ],"Buy some wagons of grain from other places. (1000 peningas)",
        [
          (troop_remove_gold, "trp_player", 1000),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} are happy because you responded to their needs."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_07_2nj",[
          (store_troop_gold, ":gold", "trp_player"),
          (try_begin),
            (gt, ":gold", 0),
            (store_mul, ":gold_per", 1000, 100),
            (val_div, ":gold_per", ":gold"),
          (try_end),
          (this_or_next|gt, ":gold_per", 10),
          (lt, ":gold", 1000),
        ],"I do not have enough money to buy food elsewhere.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} are unhappy with you because you don't respond to their needs."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_07_3nj",[],"Serves them right for not tending to their crops carefully enough!",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_honor", -2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} are unhappy with you because you don't respond to their needs."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_07_4nj",[  (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 500),
          ],"Buy some grain to alleviate the problem. (500 peningas)",
        [	(troop_remove_gold, "trp_player", 500),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@People in {s4} appreciate your help, but were expecting more."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_08_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One of the local leaders approaches you stating that he has an illegitimate son (whom he favours) who wishes to join your captains. You agree to meet the boy, as it would be unseemly to reject a noble outright. " +
    "When you meet the boy, however, it is clear that he is a homebody, certainly not warrior material. Faced with this plump, smiling youth do you:",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_08_1nj",[],"Allow him to join your captains.",
        [
          (str_store_party_name, s4, "$current_town"),
          (party_add_members, "p_main_party", "trp_watchman", 1),
          (call_script, "script_change_player_relation_with_center", "$current_town", 4),
          (call_script, "script_change_player_party_morale", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Although the local leader supports your position in {s4}, your men think it is a disgrace to have the boy among them."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_08_2nj",[],"Ask for payment to grease the deal.",
        [
          (party_add_members, "p_main_party", "trp_watchman", 1),
          (troop_add_gold, "trp_player", 500),
          (call_script, "script_change_player_party_morale", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Although the local leader pays you well, your men think it is a disgrace to have the boy among them."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_08_3nj",[],"Refuse. Only the best will serve as captains.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -4),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The local leader leverages his position to undermine yours in {s4} as punishment for you not accepting his son."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  #########
  (
    "event_09_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Two proposals come before you one day. One is from a scholarly young priest called Osberh, who proposes building a church in {s4}. He promises to instruct you in new knowledge that will increase your intelligence in return.^^" +
    "Another man, upon hearing this, pushes himself before you. He is a hulking, great-bearded warrior who overshadows Osberh completely. He suggests the funds would be better used on a training camp, and he promises to teach you a trick to increase your physical prowess.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_09_1nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 1000),],"Choose Osberh's idea. You need to improve your intelligence.",
        [
          (troop_remove_gold, "trp_player", 1000),
          
          (troop_raise_attribute, "trp_player",ca_intelligence,1),
          (change_screen_return, 0),
        ]
      ),
      ("choice_09_2nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 1000),],"Choose the warrior. You need improve your strength.",
        [
          (troop_remove_gold, "trp_player", 1000),
          (troop_raise_attribute, "$g_player_troop", ca_strength, 1),
          (change_screen_return),
        ]
      ),
      ("choice_09_3nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 3000),],"I have enough money to build both facilities (3000 peningas).",
        [
          (troop_remove_gold, "trp_player", 3000),
          (troop_raise_attribute, "trp_player",ca_intelligence,1),
          (troop_raise_attribute, "$g_player_troop", ca_strength, 1),
          (change_screen_return, 0),
        ]
      ),
      ("choice_9_4nj",[],"Hah! You have enough intelligence already not to fall for either one.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_10_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A searing flash crosses the night sky. There is much talk of omens the next day. The people of {s4} generally agree that some act of sacrifice must be committed, or some divine wrath will befall the kingdom. The practise of the wickerman suddenly gains impetus, as it is near harvest time. " +
    "They find an angelic girl and treat her as a living goddess. Suddenly, you realize that the whole place follows traditions supposedly lost for centuries.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_10_1nj",[],"Allow the sacrifice of the girl.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", 8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@During the night, at a fire ceremony and dance, the girl is burned as an offering to the gods."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_10_2nj",[],"Forbid the sacrifice and take the girl into your party for safety.",
        [
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          (party_add_members, "p_main_party", "trp_refugee", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@People, superstitious, are angry with you. Some time later, you find out that another girl was sacrificed."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_10_3nj",[],"This is no affair of yours.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@During the night, at a fire ceremony and dance, the girl is burned as an offering to the gods."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_11_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A runner arrives at your court, and after you allow it, starts to tell dire news. 'My {reg59?lady:lord}, a nearby village is in great danger! " +
    "The populace has some kind of strange sickness, they can hardly move, sweat and vomit, and the local wise-woman has no cure for it. The local leader doesn't let anyone out at the moment and is expecting your orders!'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_11_1nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 500),],"Quarantine the place, but send the best area physicians to help! (500 peningas)",
        [
          (troop_remove_gold, "trp_player", 300),
          (call_script, "script_change_player_honor", 1),
          (call_script, "script_change_player_relation_with_center", "$current_town", 10),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The physician you send manages to save some lives and prevent the epidemic from spreading to other areas."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_11_2nj",[],"Quarantine the place! We will examine the survivors when the epidemic is over!",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_honor", -1),
          (call_script, "script_change_player_relation_with_center", "$current_town", -12),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The epidemic wipes out the population of the village. Although your measures prevented anyone from spreading the disease beyond {s4}, many lost relatives who lived in the village. The rumor spreads that you are a murderer."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_12_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Two nuns approach you. 'My {reg59?lady:lord}, we have a childbirth that is not going well! We tried everything we could, but it seems that the young lady is simply not suited for pregnancy. The girl is the daughter of a prominent local lord. What can we do?'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_12_1nj",[],"Everybody, kneel down and start praying!",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", 2), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", -2), #la q designemos
          
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),#christian
            (call_script, "script_change_player_relation_with_center", "$current_town", 4),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a Christian settlement, and everyone obeys your orders quickly. Somehow it seems that your prayers are successful and the girl and the child survive."),
            (display_message, "@{s1}"),
          (else_try),
            (call_script, "script_change_player_relation_with_center", "$current_town", -4),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a pagan settlement, and nobody obeys your orders. It seems that your prayers weren't necessary, for the girl and the child survive."),
            (display_message, "@{s1}"),
          (try_end),
          
          #####
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_12_2nj",[],"Guards: Bring me the wise-woman from the village, NOW!",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -2), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 2), #la q designemos
          
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),#christian
            (call_script, "script_change_player_relation_with_center", "$current_town", -4),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a Christian settlement, and nobody obeys your orders. It seems that the wise-woman wasn't necessary, for the girl and the child survive."),
            (display_message, "@{s1}"),
          (else_try),
            (call_script, "script_change_player_relation_with_center", "$current_town", 4),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a pagan settlement, and everyone obeys your orders quickly. Somehow, it seems that wise-woman's support let the girl and the child survive."),
            (display_message, "@{s1}"),
          (try_end),
          #####
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_13_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One day, a loyal noble from nearby comes to you with a strange request. 'My lord, I am in a very bad situation. I spent all my money on proper equipment and troops, so that I can serve you well. However, my first daughter is about to marry, and I cannot send a proper dowry with her to the husband.'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_13_1nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 800),],"Take this bit of silver for your faithful service (800 peningas).",
        [
          (troop_remove_gold, "trp_player", 800),
          (call_script, "script_change_player_party_morale", 5),
          (call_script, "script_change_troop_renown", "trp_player", 3),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are happy that you are concerned about their welfare, especially when they make sacrifices for you."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_13_2nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 400),],"I will help you now, but this is the last time (400 peningas).",
        [
          (troop_remove_gold, "trp_player", 400),
          (call_script, "script_change_troop_renown", "trp_player", 2),
          #               (call_script, "script_change_player_party_morale", -1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The sum is enough for the local lord to fulfill his duty, but it is not munificent. The man is grateful, but not happy."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_13_3nj",[],"No, you should have saved up the money up front!",
        [
          (call_script, "script_change_player_party_morale", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are angry that you do not back a man who spent his money to serve you. They fear that your stinginess will affect them next."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_14_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One day, a Christian missionary arrives at your doorstep. He is very enthusiastic. 'My {reg59?lady:lord}, I have splendid news! There is a merchant from Jerusalem in {s4} now, and he is willing to sell us a piece of the Holy Cross! I cannot believe that we have the opportunity to own such a famous relic! " +
    "And this would help me so much to spread the word of Christ to the faithful!'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_14_1nj",[],"We don't pay for fake relics!",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -3), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 2), #la q designemos
          (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),
            (val_mul, ":faith", -8),
            (val_div, ":faith", 100),
            (val_min, ":faith", -1),
            (call_script, "script_change_player_relation_with_center", "$current_town", ":faith"),
            (str_store_string,s1,"@The rumor that you refuse to buy the relic leads the faithful to curse your name."),
          (else_try),
            (party_slot_eq, "$current_town", slot_center_religion, 2),
            (store_sub, ":p_faith", 100, ":faith"),
            (val_mul, ":p_faith", 6),
            (val_div, ":p_faith", 100),
            (val_max, ":p_faith", 1),
            (call_script, "script_change_player_relation_with_center", "$current_town", ":p_faith"),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@The monk is removed from your presence, distressed. In {s4}, the inhabitants are happy that you respect their beliefs."),
          (try_end),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_14_2nj",[(party_slot_eq, "$current_town", slot_center_religion, 2),],"Sorry, but this place worships other gods. I won't waste my money.",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -2), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 1), #la q designemos
          (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
          (store_sub, ":p_faith", 100, ":faith"),
          (val_mul, ":p_faith", 6),
          (val_div, ":p_faith", 100),
          (val_max, ":p_faith", 1),
          (call_script, "script_change_player_relation_with_center", "$current_town", ":p_faith"),
          (str_store_party_name, s4, "$current_town"),
          (str_clear,s1),
          (str_store_string,s1,"@The monk is removed from your presence, distressed. In {s4}, the inhabitants are happy that you respect their beliefs."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_14_3nj",[],"Good offer indeed, but sadly we don't have that much in our coffers.",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -1), #la q designemos
          (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),#christian
            (val_mul, ":faith", -5),
            (val_div, ":faith", 100),
            (val_min, ":faith", -1),
            (call_script, "script_change_player_relation_with_center", "$current_town", ":faith"),
            (str_store_string,s1,"@The rumor that you refuse to buy the relic leads the faithful to curse your name."),
          (else_try),
            (party_slot_eq, "$current_town", slot_center_religion, 2),
            (store_sub, ":p_faith", 100, ":faith"),
            (val_mul, ":p_faith", 3),
            (val_div, ":p_faith", 100),
            (val_max, ":p_faith", 1),
            (call_script, "script_change_player_relation_with_center", "$current_town", ":p_faith"),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@The monk is removed from your presence, distressed. In {s4}, the inhabitants are happy that you respect their beliefs."),
          (try_end),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
      ("choice_14_4nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 5000),],"We cannot let this opportunity slip! (5000 peningas)",
        [
          (troop_remove_gold, "trp_player", 5000),
          (call_script, "script_change_player_relation_with_faction", "fac_christians", 3), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", -3), #la q designemos
          (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),#christian
            (val_mul, ":faith", 15),
            (val_div, ":faith", 100),
            (val_max, ":faith",1),
            (call_script, "script_change_player_relation_with_center", "$current_town", ":faith"),
            (call_script, "script_change_center_prosperity", "$current_town", 5),
            (party_get_slot, ":food_stores", "$g_encountered_party", slot_party_food_store),
            (call_script, "script_center_get_food_store_limit", "$g_encountered_party"),
            (val_min, ":food_stores", reg0),
            (party_set_slot, "$g_encountered_party", slot_party_food_store, ":food_stores"),
            (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
            (val_add, ":faith", 2),
            (val_clamp, ":faith", 0, 101),
            (party_set_slot, "$current_town", slot_center_faithratio, ":faith"),
            (str_store_string,s1,"@The relic causes a stir among the faithful, who flock to see it and praise your name for its purchase."),
          (else_try),
            (party_slot_eq, "$current_town", slot_center_religion, 2),
            (store_sub, ":p_faith", 100, ":faith"),
            (val_mul, ":p_faith", -8),
            (val_div, ":p_faith", 100),
            (val_min, ":p_faith", -1),
            (call_script, "script_change_player_relation_with_center", "$current_town", ":p_faith"),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@The monk is happy to use the relic to evangelize the pagans of {s4}. They, on the other hand, curse your name."),
          (try_end),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
        ]
      ),
    ]
  ),
  
  (
    "event_15_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You are having a feast with your companions when a messenger comes to your attention, 'My {reg59?lady:lord}, there is a situation in {s4} that needs your counsel.' Excusing yourself, you step outside.^^" +
    "A crowd has gathered there, arguing, but when you appear, it quickly falls silent. An elder bows to you and asks permission to speak, which you give. He speaks: 'My {reg59?lady:lord}, we need your wisdom. " +
    "Two women claim to be the mother of this child. Neither will defer.'^" +
    "Two women are presented. One is in fine clothes and the other in rags.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("choice_15_1nj",[],"Give the child to the poor woman.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The rich woman's husband, who happens to be a large landowner in {s4}, becomes very angry with you and damages your reputation."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
          
        ]
      ),
      ("choice_15_2nj",[],"Give the child to the rich woman.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The poor people in {s4} get angry when you give the child to a rich woman without making a sincere determination."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_15_3nj",[],"Order to cut the child in half and give each half to one of the women.",
        [
          (jump_to_menu, "mnu_child_half_one"),
        ]
      ),
    ]
  ),
  ###event encadenado
  (
    "child_half_one",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Then the woman in rags screams and says, 'No, please my {reg59?lady:lord}, let the other women have the child then.'^^Then the elder near you exclaims, 'So you are the rightful mother and this child belongs to you!'^^" +
    "The other woman seems uneasy, 'I can give that child a better life than always living in poverty.'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_half1pj",[],"Give the child to the poor woman and punish the rich woman for lying.",
        [
          (call_script, "script_change_player_honor", 2),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 15),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Everyone in {s4} thinks you've been wise and just to find the mother of the child and return the baby, while punishing the liar without being influenced by her wealth."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
          
        ]
      ),
      ("choice_half2pj",[],"Give the child to the poor woman and the rich woman to the crowd.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -15),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The crowd kills the rich woman. The rich woman's husband, who happens to be a large landowner in {s4}, becomes very angry with you and damages your reputation."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_half3pj",[],"Give the child to the rich woman.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -15),
          (store_random_in_range, ":p_leave", 4, 8),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The poor people in {s4} get angry when you give the child to a rich woman without making a sincere determination. " +
          "Some disturbances ending in violence occur. During the fighting, many citizens die before retiring, but you also lose some men."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_half4pj",[],"Give the child to the rich woman and poor woman to your men.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -15),
          (store_random_in_range, ":p_leave", 8, 12),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          (call_script, "script_change_player_party_morale", 5),
          (party_add_members,"p_main_party","trp_refugee",1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The poor people in {s4} get angry when you give the child to a rich woman without making a sincere determination. " +
          "Some disturbances ending in violence occur. During the fighting, many citizens die before retiring, but you also lose some men."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  ###
  (
    "event_16_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your advisor, streaked with dirt and sunburned, arrives after inspecting the harvest. 'My Lord, the harvest is poor this year. If you do not reduce taxes there will be starvation this winter.'",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_16_1nj",[],"Less taxes means less soldiers. Better an empty gut than a cut throat.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The people of {s4} do not want their children to starve for your tax, and are openly against you."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
          
        ]
      ),
      ("choice_16_2nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 1000),],"Well, I will compensate them from my purse (1000 peningas).",
        [
          (troop_remove_gold, "trp_player", 1000),
          (call_script, "script_change_troop_renown", "trp_player", 3),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 8),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The people of {s4} are very happy for your help in hard times."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_17_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A peasant from a nearby village comes to you as a supplicant. He breathlessly reports that armed men have raided his farm, carrying off women, cattle and grain. He is spattered with blood and stinks of burned thatch.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_17_1nj",[                       	    (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 800),
          (store_mul, ":gold_per", 800, 100),
          (val_div, ":gold_per", ":gold"),
          (le, ":gold_per", 10),
          ],"Hire watchmen to guard the area (800 peningas).",
        [
          (troop_remove_gold, "trp_player", 800),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", 5),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The people of {s4} are very happy for your help in hard times."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_17_2nj",[],"There is nothing to be done here. Away with you, mongrel!",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -7),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The people of {s4} are angry that you don't care about their problems."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_17_3nj",[ (store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 150),],"There will be war. Take this money and rebuild your village.",
        [
          (troop_remove_gold, "trp_player", 150),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_center", "$current_town", -2),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The people of {s4} think that this is bread for today and hunger for tomorrow, but they understand that these things happen."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_18_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A happy widow is accused of witchcraft after several men sworn to your vassal report pain while relieving themselves. " +
    "Your vassal backs their claim. You suspect he has the same complaint but knows better than to air it publicly.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_18_1nj",[],"Banish the happy widow, exiling her to another place.",
        [
          (call_script, "script_change_player_honor", -1),
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -1), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 1), #la q designemos
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The witch leaves the town for an unknown destination."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_18_2nj",[],"Pay the witch to help counteract the spread of Christianity.",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -5), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 2), #la q designemos
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The witch appreciates your confidence and leaves her old job to worship the old gods openly."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_18_3nj",[],"Where there's one, there's many! Kill anyone else reported for witchcraft.",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", 8), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", -5), #la q designemos
          (call_script, "script_change_player_relation_with_center", "$current_town", -4),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The witch-hunt costs some innocent lives, causing unrest among the population."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_19_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A missionary comes upon you and tells you of one of your villages where he was introducing God's grace. When he and his followers wanted to fell an ancient tree important to the pagans, most of the inhabitants took up arms and drove them out.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
      
    ],
    [
      ("choice_19_1nj",[],"This missionary is right: cut down this heretical tree.",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", 4), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", -4), #la q designemos
          
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),#christian
            (str_store_party_name, s4, "$current_town"),
            (call_script, "script_change_player_relation_with_center", "$current_town", 2),
            (str_store_string,s1,"@{s4} is a Christian settlement, so in the end, your orders are obeyed."),
            (display_message, "@{s1}"),
          (else_try),
            (call_script, "script_change_player_relation_with_center", "$current_town", -8),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a pagan settlement, so there is much anger when the tree is felled."),
            (display_message, "@{s1}"),
          (try_end),
          
          #####
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_19_2nj",[(eq, "$g_player_faith", 2), #player is pagan
        ],"This missionary is wrong. Have him and his followers burn for the gods.",
        [
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -18), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 8), #la q designemos
          (str_clear,s1),
          (try_begin),
            (party_slot_eq, "$current_town", slot_center_religion, 1),#christian
            (call_script, "script_change_player_relation_with_center", "$current_town", -15),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a Christian settlement, and the murder of the missionary and his followers shocks the population. They are terrified of you."),
            (display_message, "@{s1}"),
          (else_try),
            (call_script, "script_change_player_relation_with_center", "$current_town", 15),
            (str_store_party_name, s4, "$current_town"),
            (str_store_string,s1,"@{s4} is a pagan settlement, and the murder of the missionary and his followers is supported. Soon after, you find out that the missionary is canonized as Saint Cuthberh."),
            (display_message, "@{s1}"),
          (try_end),
          #####
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_19_3nj",[],"This missionary is wrong. Have those Christians abandon this village in peace.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -4), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", 2), #la q designemos
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The missionary and his followers leave {s4}, escorted by your men, without much fuss."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_20_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A woman from a nearby village comes to you claiming that one of your men who died recently was her husband. She asks for assistance to take care of the remains.",
    "none",
    [	(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_20_1nj",[                      	    (store_troop_gold, ":gold", "trp_player"),
          (ge, ":gold", 500),
          (store_mul, ":gold_per", 500, 100),
          (val_div, ":gold_per", ":gold"),
          (le, ":gold_per", 10),
        ],"Give her monetary assistance and send for a priest.",
        [
          (troop_remove_gold, "trp_player", 500),
          (call_script, "script_change_player_honor", 2),
          (call_script, "script_change_player_party_morale", 4),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men appreciate your concern for their families."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_20_2nj",[],"Do nothing. This isn't my problem.",
        [
          (call_script, "script_change_player_honor", -2),
          (call_script, "script_change_player_party_morale", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are unhappy that you don't take care of their widows."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_20_3nj",[                      (store_troop_gold, ":gold", "trp_player"),
          (lt, ":gold", 500),
        ],"Unluckily, I do not have money for this.",
        [
          (call_script, "script_change_player_party_morale", -4),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are unhappy that you don't take care of their widows, but understand you are strapped at the moment."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_21_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The most important local leader comes to you with a request. 'My {reg59?lady:lord}, would it not show your great mercy and honor to provide for those who have suffered while serving under you? " +
    "We have dozens of maimed, lame and aged ex-warriors begging for coin in the streets and many families who have lost fathers and husbands in your battles. " +
    "We need to reward and protect your loyal supporters, or else men might be hesitant in the future to be in your shield wall.",
    "none",
    [(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_21_1nj",[],"It isn't my fault my men don't save their wealth for their families.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (call_script, "script_change_player_honor", -2),
          (call_script, "script_change_player_party_morale", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are upset that you won't take care of their widows if they are killed."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_21_2nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 800),],"We should support our veterans and their families (800 peningas).",
        [
          (troop_remove_gold, "trp_player", 800),
          (call_script, "script_change_player_honor", 2),
          (call_script, "script_change_player_party_morale", 2),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are happy to hear that you care about their families."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_21_3nj",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 2000),],"Open my coffers. All families shall receive support (2000 peningas).",
        [
          (troop_remove_gold, "trp_player", 2000),
          (call_script, "script_change_troop_renown", "trp_player", 6),
          (call_script, "script_change_player_honor", 5),
          (call_script, "script_change_player_party_morale", 8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are very happy that you protect their families."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_21_4nj",[ (store_troop_gold, ":gold", "trp_player"),
          (lt, ":gold", 800),
        ],"I have no money for this unexpected expense.",
        [
          (display_message, "@Your men are upset that you won't take care of their widows if they are killed."),
          (call_script, "script_change_troop_renown", "trp_player", -5),
          (call_script, "script_change_player_honor", -2),
          (call_script, "script_change_player_party_morale", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are upset that you won't take care of their widows if they are killed."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_22_juicio",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A seemingly straightforward case is brought before you. Yesterday, the accused man broke into the victim's house and removed large amounts of wealth. " +
    "Many people saw him, and the missing items were discovered in his house. The victim is an influential supporter of the previous lord, had actually served as a councillor and was known to be of doubtful loyalty. The accused, on the other hand, happens to be one of your most vocal supporters and a major donor to your cause.",
    "none",
    [	(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_22_1nj",[],"Ignoring the evidence, you settle in your man's favor.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", 2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your followers feel that you will protect them at any cost, but the people in {s4} are not very happy with your decision. They criticize you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_22_2nj",[],"The evidence is clear, and the accused is found guilty.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_change_player_relation_with_center", "$current_town", 2),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your followers feel that you do not protect them as they deserve for their services, but the people in {s4} are very happy with your decision. The rumor spreads that you are just."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_22_3nj",[],"Both parties are in the wrong. You exile them and confiscate all material.",
        [
          (troop_add_gold, "trp_player", 2000),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your followers feel that you do not protect them as they deserve for their services. The people in {s4} are not very happy with your decision. They criticize you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  ( #juicios terminan
    "event_juicio_end",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A seemingly straightforward case is brought before you. Yesterday, the accused man broke into the victim's house and removed large amounts of wealth. " +
    "Many people saw him, and the missing items were discovered in his house. But the victim is an influential supporter of the previous lord, had actually served as a councillor and was known to be of doubtful loyalties. The accused, on the other hand, happens to be one of your most vocal supporters and has donated much money to your cause.",
    "none",
    [	(set_background_mesh, "mesh_pic_towndes"),
    ],
    [
      ("choice_end_1nj",[],"Ignoring the evidence, you settle in your man's favor.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", 2),
          (call_script, "script_change_player_relation_with_center", "$current_town", -8),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your followers feel that you will protect them at any cost, but the people in {s4} are not very happy with your decision. They criticize you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_end_2nj",[],"The evidence is clear, and the accused is found guilty!",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", -6),
          (call_script, "script_change_player_relation_with_center", "$current_town", 2),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your followers feel that you do not protect them as they deserve for their services, but the people in {s4} are very happy with your decision. The rumor spreads that you are just."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("choice_end_3nj",[],"You claim both parties are in the wrong. You exile them and confiscate all material.",
        [
          (troop_add_gold, "trp_player", 2000),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your followers feel that you do not protect them as they deserve for their services. The people in {s4} are not very happy with your decision. They criticize you when you leave, generating unfavorable rumors."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  #riots
  ( #
    "riots_01",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your relation with {s4} is very bad. As you walk its streets, people look at you hatefully and make gestures behind your back. " +
    "You get beyond a corner, and you're safe -- until several people begin to emerge. Ordinary citizens are tired of your government and begin to insult you. Finally, someone becomes bold enough to pull a knife and attack you.",
    "none",
    [	(set_background_mesh, "mesh_pic_townriot"),
      (str_store_party_name, s4, "$current_town"),
    ],
    [
      ("deffend_yr",[],"Defend yourself.",
        [
          (try_begin),
            (party_slot_eq, "$current_town", slot_party_type, spt_village),
            (party_get_slot, ":cur_scene", "$current_town", slot_castle_exterior),
          (else_try),
            (party_get_slot, ":cur_scene", "$current_town", slot_town_center),
          (try_end),
          (modify_visitors_at_site, ":cur_scene"),
          (reset_visitors),
          
          (set_jump_mission, "mt_bandits_at_night"),
          
          (assign, ":spawn_amount", 4),
          (assign, "$num_center_bandits", 0),
          (val_add, "$num_center_bandits",  ":spawn_amount"),
          (try_begin),
            (party_slot_eq, "$current_town", slot_party_type, spt_village),
            (set_visitors, 4, "trp_peasant_woman", ":spawn_amount"),
          (else_try),
            (party_slot_eq, "$current_town", slot_party_type, spt_castle),
            (set_visitors, 33, "trp_peasant_woman", ":spawn_amount"),
          (else_try),
            (set_visitors, 28, "trp_peasant_woman", ":spawn_amount"),
          (try_end),
          (assign, ":spawn_amount", 16),
          # (set_visitors, 27, "trp_townsman", ":spawn_amount"),
          (try_begin),
            (party_slot_eq, "$current_town", slot_party_type, spt_village),
            (set_visitors, 32, "trp_farmer", ":spawn_amount"),
          (else_try),
            (party_slot_eq, "$current_town", slot_party_type, spt_castle),
            (set_visitors, 42, "trp_townsman", ":spawn_amount"),
          (else_try),
            (set_visitors, 11, "trp_townsman", ":spawn_amount"),
          (try_end),
          (val_add, "$num_center_bandits",  ":spawn_amount"),
          (assign, ":spawn_amount", 8),
          (try_begin),
            (party_slot_eq, "$current_town", slot_party_type, spt_village),
            (set_visitors, 34, "trp_watchman", ":spawn_amount"),
          (else_try),
            (party_slot_eq, "$current_town", slot_party_type, spt_castle),
            (set_visitors, 42, "trp_watchman", ":spawn_amount"),
          (else_try),
            (set_visitors, 11, "trp_watchman", ":spawn_amount"),
          (try_end),
          (val_add, "$num_center_bandits",  ":spawn_amount"),
          (assign, "$town_entered", 1),
          (assign, "$all_doors_locked", 1),
          
          (display_message, "@To arms! Some citizens have revolted and try to kill you!", 0xFFFF2222),
          
          (jump_to_scene, ":cur_scene"),
          (change_screen_mission),
        ]
      ),
    ]
  ),
  ( #juicios terminan
    "riots_02",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "An angry mob insulted your name, blamed a group of your warriors walking the streets for all their ills, and attacked and killed them all. " +
    "You should improve your relations with {s4} as soon as possible.",
    "none",
    [	(set_background_mesh, "mesh_pic_townriot"),
      (str_store_party_name, s4, "$current_town"),
      (store_random_in_range, ":p_leave", 4, 12),
      (assign, ":num_troops", ":p_leave"),
      (try_for_range, ":unused", 0, ":num_troops"),
        (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
      (try_end),
    ],
    [
      ("deffend_01ri",[],"Order your men to kill the perpetrators and seize their possessions.",
        [
          (troop_add_gold, "trp_player", 2000),
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_player_party_morale", 10),
          (call_script, "script_change_player_relation_with_center", "$current_town", -10),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men charge down the streets, using the sword at the slightest provocation, avenging their fallen fellows. A bloodbath ensues as the people of {s4} flee to their homes to hide."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("deffend_02ri",[],"I will not rule by fear. I have to improve relations by other means.",
        [
          (str_store_party_name, s4, "$current_town"),
          (call_script, "script_change_player_party_morale", -10),
          (call_script, "script_change_player_relation_with_center", "$current_town", 5),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men are very angry that you have taken no action against the murder of their fellows. Meanwhile, local leaders try to quell the hatred against you in {s4}."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
      ("deffend_03ri",[
          (party_get_num_companion_stacks, ":num_stacks","p_main_party"),
          (assign, ":num_men", 0),
          (try_for_range, ":i_stack", 0, ":num_stacks"),
            (party_stack_get_size, ":stack_size","p_main_party",":i_stack"),
            (val_add, ":num_men", ":stack_size"),
          (try_end),
          (gt, ":num_men", 200), #200 men necesary for events.
        ],"Exterminate the population of the entire city and repopulate it with people that are more loyal.",
        [
          (troop_add_gold, "trp_player", 4000),
          (str_store_party_name, s4, "$current_town"),
          (party_set_slot, "$current_town", slot_center_player_relation, 0), #relation to 0
          (call_script, "script_change_player_honor", -20),
          
          (party_get_slot, ":prosperity_change", "$current_town", slot_town_prosperity),
          (val_mul, ":prosperity_change", -9),
          (val_div, ":prosperity_change", 10),
          (call_script, "script_change_center_prosperity", "$current_town", ":prosperity_change"),
          
          (party_get_slot, ":food_stores", "$current_town", slot_party_food_store),
          (call_script, "script_center_get_food_store_limit", "$current_town"),
          (val_min, ":food_stores", reg0),
          (party_set_slot, "$current_town", slot_party_food_store, ":food_stores"),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Mercilessly your men kill anyone that crosses their way, then enter the houses, killing all men over 14 years of age. The fame of your cruelty travels as the wind. " +
          "Fear seizes all who talk about you. Now {s4} is pacified, but the cost has been very high."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_juice_events"),
          #########
        ]
      ),
    ]
  ),
  
  ####juicios chief acaba random events
  ###final random events
  
  #buena para general tb
  ####random event normal
  (
    "random_normal_events",0, #final menu, load presentation to consequences
    "Events",
    "none",
    [
      (start_presentation, "prsnt_random_event_normalsolution"),
    ],
    [
      ("leave",[],"Leave.",[
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  (
    "random_normal_events2",0, #final menu, load presentation to consequences
    "Events",
    "none",
    [
      (leave_encounter),
      (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
    ],
    [
      ("leave",[],"Leave.",[
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
      ]),
    ]
  ),
  #
  (
    "event_01_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "The sound of a galloping horse pierces the cold morning, and you run outside to find a watchman dismounting. " +
    "He tells you that a strange ship carrying men who speak a foreign language has been shipwrecked on the coast nearby. What do you do?",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_01_1nor",[],"Send men to search for valuables. If there are any survivors, kill them.",
        [
          (call_script, "script_change_player_honor", -1),
          (troop_add_gold, "trp_player", 800),
          (change_screen_return, 0),
        ]
      ),
      ("choice_01_2nor",[],"Send men to investigate. If there are any survivors, recruit them.",
        [
          (display_message, "@Your men return with 300 peningas and two survivors."),
          (call_script, "script_change_player_party_morale", -5),
          (troop_add_gold, "trp_player", 300),
          (party_add_members, "p_main_party", "trp_taiga_bandit", 2),
          (change_screen_return, 0),
        ]
      ),
      ("choice_01_3nor",[],"Do nothing.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  ( #evento que se puede repetir #low ratio to happen
    "event_02_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "{!}{s4}",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      (assign, ":continue", 0),
      
      (str_clear, s4),
      (store_random_in_range, ":random", 0, 9),
      (try_begin),
        (le, ":random", 5), #positive
        (store_random_in_range, ":active_npc", kingdom_heroes_begin2, kingdom_heroes_end2),
        (call_script, "script_troop_get_player_relation",  ":active_npc"),
        (assign, ":relation", reg0),
        #                       (troop_get_slot, ":relation", ":active_npc", slot_troop_player_relation),
        (gt, ":relation", 15), #good relation = send gift
        (assign, ":continue", 1),
        (str_store_troop_name, s12, ":active_npc"),
        (str_store_string, s4, "@A messenger sent from {s12} arrives and gives you a present of silver and jewelry in appreciation of your friendship."),
        (troop_add_gold, "trp_player", 1000),
      (else_try),
        (store_random_in_range, ":active_npc", kingdom_heroes_begin2, kingdom_heroes_end2),
        (call_script, "script_troop_get_player_relation",  ":active_npc"),
        (assign, ":relation", reg0),
        #                         (troop_get_slot, ":relation", ":active_npc", slot_troop_player_relation),
        (lt, ":relation", -15), #bad relation = send insult
        (assign, ":continue", 1),
        (str_store_troop_name, s12, ":active_npc"),
        (str_store_string, s4, "@A messenger sent from {s12} arrives and gives you a message with all kinds of insults and profanities, {s12} invites you to go and look for him if you have guts which {s12} believes you don't, as you're a notorious coward."),
        (call_script, "script_change_troop_renown", "trp_player", -6),
      (try_end),
      
      (try_begin),
        (eq, ":continue", 0),
        (change_screen_return),
      (try_end),
      (eq, ":continue", 1),
      
    ],
    [
      ("choice_11_msgnor",[],"Continue.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_03_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You've heard that a bard has composed a song about your noble deeds.",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
    ],
    [
      ("choice_03_1nor",[],"Excellent news!",
        [
          (call_script, "script_change_troop_renown", "trp_player", 3),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your fame grows with the bard's song, but soon he replaces your name with that of another lord who pays him."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_03_2nor",[ (store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 300),],"Reward him with 300 peningas. Let this song be played across the land.",
        [
          (troop_remove_gold, "trp_player", 300),
          (call_script, "script_change_troop_renown", "trp_player", 9),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your fame grows higher with the bard song."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  
  (
    "event_04_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Tales of your successes spread around the country. Everywhere you go, your procession is surrounded by beggars.",
    "none",
    [(set_background_mesh, "mesh_pic_cross"),
      
    ],
    [
      ("choice_04_1no",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 200),],"Allocate 200 peningas to an alms fund.",
        [
          (troop_remove_gold, "trp_player", 200),
          (call_script, "script_change_player_honor", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Beggars everywhere bless your name when you pass by and celebrate your generosity."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_04_2no",[],"Ignore them.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Beggars soon tire of following you."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_04_3no",[],"Beggars, huh? Release the hounds!",
        [
          (call_script, "script_change_player_honor", -1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@You laugh to see how sprightly these broken-down old fellows can actually run."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_05_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A young noble spreads rumors about your mother. Accusations of working in the world's oldest profession are the more delicate ones.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("choice_05_1no",[],"I challenge him to a duel!",
        [
          (call_script, "script_change_troop_renown", "trp_player", 3),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The young noble prefers to flee rather than duel with you!"),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_05_2no",[],"It's just talk.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -26),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The word spreads that it is easy to insult you and diminish your reputation!"),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  
  (
    "event_06_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You encounter one of your soldiers' wives. She begs you to release her husband from his contract. The harvest was poor this year, and his wages can't feed the whole family. " +
    "If he could come back and work on the field, they might survive.",
    "none",
    [(set_background_mesh, "mesh_pic_going_to_war"),
      
    ],
    [
      ("choice_06_1no",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 200),],"This can't be! Here, take 200 peningas.",
        [
          (troop_remove_gold, "trp_player", 200),
          
          (call_script, "script_change_player_honor", 1),
          (call_script, "script_change_player_party_morale", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The woman and her husband are happy for your generosity!"),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_06_2no",[],"You release her husband from his duties.",
        [
          (store_random_in_range, ":p_leave", 2, 6),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Other men join in and also leave to help their families."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_07_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A local naysayer is spreading false rumors about you. While most of the stories are just pure nonsense, sooner or later people will believe them.",
    "none",
    [(set_background_mesh, "mesh_pic_messenger"),
      
    ],
    [
      ("choice_07_1no",[],"Let him say what he wants. Every man has his rights.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -3),
          (call_script, "script_change_player_honor", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The rumors hurt your fame a little, but soon the merchant gets tired of your lack of interest."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_07_2no",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 100),],"Ask him to stop. One hundred peningas might help.",
        [
          (display_message, "@The man accepts the money and stops circulating rumors."),
          (change_screen_return),
        ]
      ),
      ("choice_07_3no",[],"Silence him permanently.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -12),
          (call_script, "script_change_player_honor", -2),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@A new rumor that you're a murderer and a tyrant spreads among the population after the death of the merchant!"),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_08_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You are travelling through the forest and you suddenly spot a wild hare trapped in the snare. What do you do?",
    "none",
    [(set_background_mesh, "mesh_pic_forest"),
      
    ],
    [
      ("choice_08_1nor",[],"Free the animal.",
        [
          (display_message, "@The animal runs free without looking back."),
          (change_screen_return, 0),
        ]
      ),
      ("choice_08_2nor",[],"Clench the snare and kill the animal!",
        [
          (display_message, "@You increase your meat reserves."),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (change_screen_return, 0),
        ]
      ),
      ("choice_08_3nor",[],"Pass by the animal and ignore it.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_09_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You receive news that a group of veteran warriors has heard of your fame and wishes to join you. However, they ask more pay than you typically pay for such troops.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_guerreros"),
      
    ],
    [
      ("choice_9_1nor",[],"They are welcome.",
        [
          (display_message, "@Three veterans join your army."),
          (call_script, "script_change_troop_renown", "trp_player", 9),
          (party_add_members, "p_main_party", "trp_mercenary_swordsman", 3),
          (change_screen_return, 0),
        ]
      ),
      ("choice_9_2nor",[],"I do not need more troops.",
        [
          (display_message, "@The veterans leave, defaming your name."),
          (call_script, "script_change_troop_renown", "trp_player", -3),
          (change_screen_return, 0),
        ]
      ),
      ("choice_9_3nor",[],"Kill them. Surely they will yield some good loot.",
        [
          (display_message, "@Among the bodies, your men find 1000 peningas."),
          (call_script, "script_change_player_honor", -5),
          (troop_add_gold, "trp_player", 1000),
          (call_script, "script_change_troop_renown", "trp_player", -16),
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_10_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You receive news that a number of women express interest in becoming camp followers.",
    "none",
    [(set_background_mesh, "mesh_pic_going_to_war"),
      
    ],
    [
      ("choice_10_1nor",[],"They are welcome.",
        [
          (display_message, "@A group of six women joins your army."),
          (party_add_members, "p_main_party", "trp_follower_woman", 6),
          (change_screen_return, 0),
        ]
      ),
      ("choice_10_2nor",[],"I do not need more mouths to feed.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_11_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You receive news that a group of street musicians wishes to join you as army musicians and a standard bearer.",
    "none",
    [(set_background_mesh, "mesh_pic_vaegir"),
      
    ],
    [
      ("choice_11_1no",[],"They are welcome.",
        [
          (call_script, "script_change_troop_renown", "trp_player", 9),
          (party_add_members, "p_main_party", "trp_saxon_standard_bearer", 1),
          (party_add_members, "p_main_party", "trp_todos_cuerno", 2),
          (change_screen_return, 0),
        ]
      ),
      ("choice_11_2no",[],"I do not need more troops.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_12_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You see a crane circling above your party.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      
    ],
    [
      ("choice_12_1nor",[],"Tell your men that the crane symbolizes victory!",
        [
          (call_script, "script_change_player_party_morale", 5),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The crane was a symbol of war for the ancient Celts. Your men are impressed by your knowledge and grateful that the gods are with them."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_12_2nor",[],"Ignore it.",
        [
          (display_message, "@Your men pass by the bird without noticing it."),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men pass by the bird without noticing it."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_12_3nor",[],"The cranes signify bad fortune, but you have faith in your men!",
        [
          (call_script, "script_change_player_party_morale", -5),
          
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The crane was a symbol of war for the ancient Celts. Your ignorance troubles your men, and they begin to doubt your fitness to lead."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_13_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A country farmer stands before you on the road with a weeping girl behind him. He points his finger accusingly at one of your men, saying that he raped his daughter and must be punished.",
    "none",
    [(set_background_mesh, "mesh_pic_steppe_bandits"),
      
    ],
    [
      ("choice_13_1nor",[],"Brand the man and cast him out of your party.",
        [
          (call_script, "script_change_player_party_morale", -2),
          (call_script, "script_change_troop_renown", "trp_player", 6),
          (call_script, "script_change_player_honor", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men resent the punishment, but recognize your authority. The action sets a precedent for discipline."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_13_3nor",[],"It is a hard world, and a man must take what he can.",
        [
          (call_script, "script_change_player_honor", -1),
          (call_script, "script_change_troop_renown", "trp_player", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Offended by your contempt for his request, the farmer leaves and spreads the claim of your villainy."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_14_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "After hours, while your army rests near a village, the priest's wife comes to see you (alone) while her husband is away.",
    "none",
    [(set_background_mesh, "mesh_pic_village_p"),
      
    ],
    [
      ("choice_14_1nor",[],"You agree.",
        [
          (call_script, "script_change_player_honor", -1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@You spend time with the priest's wife, and when her husband returns, you escape to the stable without being seen!"),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_14_3nor",[],"You refuse.",
        [
          (call_script, "script_change_player_honor", 1),
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_15_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your fame and popularity have attracted young Norsemen to your cause.",
    "none",
    [(set_background_mesh, "mesh_pic_nord"),
      (troop_slot_eq, "trp_player", slot_troop_religion, 2),#pagan
    ],
    [
      ("choice_15_1nor",[],"Accept them.",
        [
          (display_message, "@Three Hirdmenn join your army!"),
          (call_script, "script_change_troop_renown", "trp_player", 9),
          (party_add_members, "p_main_party", "trp_norse_level0_companion", 3),
          (change_screen_return, 0),
        ]
      ),
      ("choice_15_2nor",[],"I don't need more men.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_16_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You spot a poor man on the road. He looks tired. You send one of your men to ask him why he is in the wilderness alone. He says that men robbed him, and if he doesn't get some money soon, he will starve. He says he served in the army once, and will make a loyal warrior.",
    "none",
    [(set_background_mesh, "mesh_pic_road_with_grove"),
      
    ],
    [
      ("choice_16_1nor",[],"Life's not fair. Give him nothing.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The man's eyes sadly follow you while you go on your way."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_16_2nor",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 10),],"Give him enough money to eat for a day (10 peningas).",
        [
          (troop_remove_gold, "trp_player", 10),
          (display_message, "@You feel good for helping him."),
          (call_script, "script_change_player_honor", 1),
          (change_screen_return, 0),
        ]
      ),
      ("choice_16_4nor",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 200),],"Give him money for several days (200 peningas).",
        [
          (troop_remove_gold, "trp_player", 200),
          (display_message, "@You feel good for helping him."),
          (call_script, "script_change_player_honor", 2),
          (change_screen_return, 0),
        ]
      ),
      ("choice_16_5nor",[(store_troop_gold, ":gold", "trp_player"),(ge, ":gold", 1600),],"Pay him and suggest he join your army.",
        [
          (troop_remove_gold, "trp_player", 1600),
          (call_script, "script_change_troop_renown", "trp_player", 3),
          (party_add_members, "p_main_party", "trp_old_hero_boargrove", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@When you give him armor and food, he proves to be a mighty warrior."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_17_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "A group of bandits approaches your camp. As your men reach for their arms, the bandits put down their weapons and say they come in peace. The leader of the bandits approaches you and asks if they may join you.",
    "none",
    [(set_background_mesh, "mesh_pic_bandits"),
    ],
    [
      ("choice_17_1nor",[],"Of course! My party always welcomes bloodthirsty men!",
        [
          (call_script, "script_change_player_party_morale", -5),
          (party_add_members, "p_main_party", "trp_mountain_bandit", 6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@New troops join your party."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_17_2nor",[],"I'm sorry. We have no room for your kind!",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The bandits turn away, greatly disappointed."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_17_3nor",[],"Prove yourselves worthy by raiding a village!",
        [
          (call_script, "script_change_player_party_morale", -8),
          (call_script, "script_troop_add_gold", "trp_player", 800),
          (call_script, "script_change_player_honor", -5),
          (call_script, "script_change_troop_renown", "trp_player", -6),
          (party_add_members, "p_main_party", "trp_mountain_bandit", 6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@After two hours, the bandits return with some loot and someone's head..."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_17_4nor",[],"Kill them all!",
        [
          (call_script, "script_change_troop_renown", "trp_player", -6),
          (call_script, "script_change_player_honor", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men kill all the bandits."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_18_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You come across the grave of an old forgotten warlord.",
    "none",
    [(set_background_mesh, "mesh_pic_cross"),
      
    ],
    [
      ("choice_18_1nor",[],"Rifle it for loot!",
        [
          (call_script, "script_change_troop_renown", "trp_player", -50),
          (call_script, "script_change_player_party_morale", -12),
          (call_script, "script_change_player_relation_with_faction", "fac_christians", -5), #la q designemos
          (call_script, "script_change_player_relation_with_faction", "fac_pagans", -5), #la q designemos
          (call_script, "script_troop_add_gold", "trp_player", 100),
          (troop_add_item, "trp_player","itm_noble_sword_6",0),
          (troop_add_item, "trp_player","itm_mail_shirt_6",0),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@On the remains of a corpse are a sword and armor of a king. They turn out to be magnificent weapons, once the rust is removed to reveal their high quality. Now they are yours -- if you do not mind the bad luck that attends grave robbers."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_18_2nor",[],"Leave the place.",
        [
          (change_screen_return, 0),
        ]
      ),
      ("choice_18_3nor",[],"Tend to the grave and pay your respects.",
        [
          (call_script, "script_change_player_honor", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Someday, perhaps, you might have the honor of being buried like a king."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_19_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "You come across unguarded cattle from a nearby village",
    "none",
    [
      (set_background_mesh, "mesh_pic_cattle"),
    ],
    [
      ("choice_19_1nor",[],"Return the animals to the village and ask for no reward.",
        [
          (call_script, "script_change_player_honor", 1),
          (call_script, "script_change_troop_renown", "trp_player", 6),
          (change_screen_return, 0),
        ]
      ),
      ("choice_19_2nor",[],"I will return the animals and demand a reward.",
        [
          (call_script, "script_troop_add_gold", "trp_player", 250),
          (change_screen_return, 0),
        ]
      ),
      ("choice_19_3nor",[],"Dinner! Round up and slaughter the animals.",
        [
          (call_script, "script_change_player_honor", -1),
          (call_script, "script_change_player_party_morale", 2),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Meat is a welcome addition to the diet of your men."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  ###new random evenst addon
  (
    "event_20_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your fame and popularity have attracted two berserkir to your cause.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_guerreroelite"),
      (troop_slot_eq, "trp_player", slot_troop_religion, 2),#pagan
    ],
    [
      ("choice_20_1nor",[],"Accept them.",
        [
          (display_message, "@Two berserkir join your army!"),
          (call_script, "script_change_troop_renown", "trp_player", 9),
          (party_add_members, "p_main_party", "trp_sea_raider_leader", 2),
          (change_screen_return, 0),
        ]
      ),
      ("choice_20_2nor",[],"I don't need more men.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  (
    "event_21_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your fame and popularity have attracted two ulfhednar to your cause.",
    "none",
    [(set_background_mesh, "mesh_pic_extra_guerreroelite"),
      (troop_slot_eq, "trp_player", slot_troop_religion, 2),#pagan
    ],
    [
      ("choice_21_1nor",[],"Accept them.",
        [
          (display_message, "@Two ulfhednar join your army!"),
          (call_script, "script_change_troop_renown", "trp_player", 9),
          (party_add_members, "p_main_party", "trp_looter_leader", 2),
          (change_screen_return, 0),
        ]
      ),
      ("choice_21_2nor",[],"I don't need more men.",
        [
          (change_screen_return, 0),
        ]
      ),
    ]
  ),
  
  (
    "event_22_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "During a break, some of your men, drunk, start to fight for the last drink of mead. Both draw their weapons and appear ready to kill.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_combate"),
    ],
    [
      ("choice_22_1nor",[],"Allow them to fight for the amusement of the rest of your men.",
        [
          (call_script, "script_change_player_honor", -1),
          (call_script, "script_change_player_party_morale", 2),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men gather around, cheering and betting. The atmosphere is tense. Suddenly, the disputes around you become more widespread. Other men draw their weapons, and a fight on a larger scale ensues. Before you can impose order again, several men die."),
          (display_message, "@{s1}"),
          (store_random_in_range, ":p_leave", 4, 8),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_22_2nor",[],"You prohibit drinking while on campaign. Punish both drunks with death.",
        [
          (call_script, "script_change_player_honor", 1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your reputation increases among your men when you return to the road, leaving behind two corpses hanging from a tree."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
          (store_random_in_range, ":p_leave", 2, 4),
          (assign, ":num_troops", ":p_leave"),
          (try_for_range, ":unused", 0, ":num_troops"),
            (call_script, "script_cf_party_remove_random_regular_troop", "p_main_party"),
          (try_end),
        ]
      ),
      ("choice_22_3nor",[],"Stop the fight and punish the men with lashes.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -6),
          (call_script, "script_change_player_party_morale", -1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men complain of not being able to enjoy a good fight, seeing that drunkenness on campaign is punishable by few lashes."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  
  (
    "event_23_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "As you travel, a man dressed in long robes approaches your army. When you grant him an audience, he says he can sell you Caledfwlch, the legendary sword of King Arthur, for 8000 peningas.",
    "none",
    [
      (set_background_mesh, "mesh_pic_chest"),
    ],
    [
      ("choice_23_1nor",[(store_troop_gold,":money","trp_player"),(ge,":money",8000),],"Buy the sword.",
        [
          (troop_remove_gold, "trp_player", 8000),
          (troop_add_item, "trp_player","itm_spatha",0),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The merchant takes the money and gives you a heavy package wrapped in a long cloth. When you unwrap it and discover that he has sold you a normal sword, the merchant is already well away."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_23_2nor",[(store_troop_gold,":money","trp_player"),(lt,":money",8000),],"You have no money to pay the sword.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The merchant takes his leave and goes back the way he came."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_23_3nor",[],"I'm not interested.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The merchant takes his leave and goes back the way he came."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  (
    "event_24_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "As you travel, you come upon a farm. Instead of showing customary hospitality, the farmer bars all the entries and puts his slaves, armed, at the door. Still, you know they are no match for your men.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_guerreros"),
    ],
    [
      ("choice_24_1nor",[],"Attack and burn the farm as punishment.",
        [
          (call_script, "script_change_player_honor", -1),
          (call_script, "script_change_player_party_morale", 2),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          (troop_add_item, "trp_player","itm_cattle_meat",0),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men attack the farm, kill the farmer and his slaves, and return with a bounty of food."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_24_2nor",[],"Move on. It's not worth stopping.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -3),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Your men think you're a weak leader unable to take action against who insult him."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  (
    "event_25_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Two men stop your army. They tell you that you are surrounded by five hundred warriors, ready to attack if you don't pay them 2000 peningas.",
    "none",
    [
      (set_background_mesh, "mesh_pic_chest"),
    ],
    [
      ("choice_25_1nor",[(store_troop_gold,":money","trp_player"),(ge,":money",2000),],"Pay them.",
        [
          (troop_remove_gold, "trp_player", 2000),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The men take the money and let you go on your way."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_25_2nor",[],"Attack!",
        [
          (call_script, "script_change_player_honor", -1),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@Without warning, you order your men to attack. The two strangers try to flee but are killed by your warriors. No one comes to reinforce them."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_25_3nor",[],"Go on your way.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The two men move aside when you ignore them and continue your way. No one attacks your army. It was all a lie."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  (
    "event_26_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "One of you scouts shows up with a bag on his back. You don't want to appear suspicious, but a fight-ready soldier would never carry such a bag. It sounds like... many heavy coins. You decide to.",
    "none",
    [
      (set_background_mesh, "mesh_pic_steppe_bandits"),
    ],
    [
      ("choice_26_1nor",[],"Confiscate the bag and punish the soldier.",
        [
          (call_script, "script_troop_add_gold", "trp_player", 250),
          (call_script, "script_change_player_party_morale", -6),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The scout, who has stolen money, spreads the rumor among your men that you are greedy."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_26_2nor",[],"Allow him to keep it. He risks his life for you, so he deserves it.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The scout hides his treasure without anyone else knowing."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_26_3nor",[],"Force him to share the benefits with the whole army.",
        [
          #####
          (str_clear,s1),
          (call_script, "script_change_player_party_morale", 8),
          (str_store_string,s1,"@The distribution of the coins brings happiness to the rest of your men, and they think that you are a fair leader."),
          (display_message, "@{s1}"),
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
    ]
  ),
  (
    "event_27_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Your soldiers come with an old man. After a long conversation, he admits his group wants to join your army and leave their village. Accepting them could cause problems with their lords. You decide to:",
    "none",
    [
      (set_background_mesh, "mesh_pic_steppe_bandits"),
    ],
    [
      ("choice_27_1nor",[],"Not get involved in local rebellions.",
        [
          #####
          (display_message, "@The men head home, disappointed."),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
      ("choice_27_2nor",[],"Not help him and send his dead body to the village.",
        [
          (call_script, "script_change_player_honor", -1),
          #####
          (try_for_range, ":center_no", centers_begin, centers_end),
            # (store_faction_of_party, ":center_faction", ":center_no"),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 25), #25 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 1),
          (try_end),
          
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
      ("choice_27_3nor",[],"You could use extra men.",
        [
          (party_add_members,"p_main_party","trp_farmer",9),
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 20), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", -2),
          (try_end),
          
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
    ]
  ),
  (
    "event_28_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "While you camp, a delegation of people from nearby approach. They say they have had a bad harvest and ask you for money to feed their children.",
    "none",
    [
      (set_background_mesh, "mesh_pic_family"),
    ],
    [
      ("choice_28_1nor",[(store_troop_gold,":money","trp_player"),(ge,":money",4000),],"Give them 4000 peningas.",
        [
          (troop_remove_gold, "trp_player", 4000),
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 20), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 6),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The farmers give you thanks and promise to name the next one of their children after you."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_28_2nor",[(store_troop_gold,":money","trp_player"),(ge,":money",1000),],"Give them 1000 peningas.",
        [
          (troop_remove_gold, "trp_player", 1000),
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 20), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 3),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The farmers give you thanks. They seem relieved and very happy."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_28_3nor",[],"You tell them you do not have enough money to share.",
        [
          #####
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
      ("choice_28_4nor",[],"Ignore them.",
        [
          #####
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
    ]
  ),
  (
    "event_29_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "While you camp, a delegation of people from nearby approach. They seem to have a problem with their lord and want your advice. " +
    "Apparently, Vikings have ransacked the area, so they are poor now, but must still pay taxes to their lord. As their lord did not protect them from the Vikings, they ask whether they should not pay and prepare to fight if their lord attacks them or whether they should pay and let their families starve.",
    "none",
    [
      (set_background_mesh, "mesh_pic_family"),
    ],
    [
      ("choice_29_1nor",[(store_troop_gold,":money","trp_player"),(ge,":money",8000),],"Give them 8000 peningas for paying their taxes and buying food.",
        [
          (troop_remove_gold, "trp_player", 8000),
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 20), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 10),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The farmers give you thanks and promise to name the next one of their children after you."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_29_2nor",[(store_troop_gold,":money","trp_player"),(ge,":money",4000),],"Give them 4000 peningas for paying their taxes.",
        [
          (troop_remove_gold, "trp_player", 4000),
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 20), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 4),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The farmers give you thanks. They seem relieved and very happy."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_29_3nor",[],"You tell them they should fight rather than pay.",
        [
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 20), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 1),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The farmers thank you. Perhaps their lord will understand the situation."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_29_4nor",[],"They should pay, for their lord would kill more of them than hunger.",
        [
          #####
          (str_clear,s1),
          (str_store_string,s1,"@The farmers thank you, although they are not happy with your counsel. It will cost the lives of many of their children next winter."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_29_5nor",[],"Ignore them.",
        [
          (call_script, "script_change_troop_renown", "trp_player", -3),
          #####
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
    ]
  ),
  (
    "event_30_normal",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Along the way, you find a sick woman. Her skin has a yellow tone, and she coughs constantly. She's from a nearby village, but as no one there knows how to cure her illness, they have sent her to the roadside to see if a traveler knows a cure.",
    "none",
    [
      (set_background_mesh, "mesh_pic_family"),
    ],
    [
      ("choice_30_1nor",[(store_troop_gold,":money","trp_player"),(ge,":money",1000),],"Give her 1000 peningas to hire a good physician.",
        [
          (troop_remove_gold, "trp_player", 1000),
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 10), #20 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 1),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@She thanks you and heads for the nearest town."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_30_2nor",[(call_script, "script_get_max_skill_of_player_party", "skl_wound_treatment"),
          (assign, ":max_skill", reg0),
          (assign, ":max_skill_owner", reg1),
          (ge, ":max_skill", 4),
          (try_begin),
            (eq, ":max_skill_owner", "trp_player"),
            (assign, reg3, 1),
          (else_try),
            (assign, reg3, 0),
            (str_store_troop_name, s3, ":max_skill_owner"),
          (try_end),
        ],"As the best physician, {reg3?you order:{s3} orders} a blood-letting.",
        [
          (try_for_range, ":center_no", centers_begin, centers_end),
            (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"),
            (lt, ":dist", 10), #10 km
            (call_script, "script_change_player_relation_with_center", ":center_no", 3),
          (try_end),
          #####
          (str_clear,s1),
          (str_store_string,s1,"@She thanks you profusely and heads back to her village, a little weak from the ordeal."),
          (display_message, "@{s1}"),
          
          (jump_to_menu, "mnu_random_normal_events"),
          #########
        ]
      ),
      ("choice_30_3nor",[],"Ignore her. Her illness could be contagious.",
        [
          #####
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),#phaiak
          #########
        ]
      ),
    ]
  ),
  #################################
  
  (
    "season_change",0,
    "{!}{s1}",
    "none",
    [
      (set_fixed_point_multiplier, 1),
      (set_shader_param_float, "@vSeason", "$shader_season"),
      
      (try_begin),
        (eq, "$shader_season", shader_spring), # spring
        (str_store_string, s1, "@The days get longer and the bony grip of winter loosens. Green leaves crown the trees once more. "),
        (set_background_mesh, "mesh_pic_road_with_grove"),
      (else_try),
        (eq, "$shader_season", shader_summer), # summer
        (str_store_string, s1, "@The sun greets you early in the morning and sends you to bed at night."),
        (set_background_mesh, "mesh_pic_small_island"),
      (else_try),
        (eq, "$shader_season", shader_autumn), # autumn
        (str_store_string, s1, "@As nature becomes a plethora of colours, people replenish their stores and prepare for winter."),
        (set_background_mesh, "mesh_pic_forest"),
      (else_try),
        (str_store_string, s1, "@The night steals from the day and grows long, while the frost threatens to do away with the weak and the old."),
        (set_background_mesh, "mesh_pic_cattle"),
      (end_try),
      
    ],
    [
      ("continue",[],"Continue...",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "troop_camp",0,
    "A small camp is established for troops you want to leave in this place for the moment.^^" +
    "(Select the troops you wish to leave in this camp and press the Give button to transfer them.)",
    "none",
    [
      (set_background_mesh, "mesh_pic_thing"),
      (try_begin),
        (party_slot_eq, "p_main_party", slot_party_on_water, 1),
        (change_screen_return),
      (else_try),
        (this_or_next|eq, "$auto_enter_town", "p_troop_camp_1"),
        (			  eq, "$auto_enter_town", "p_troop_camp_2"),
        (change_screen_exchange_members,1),
        (assign, "$auto_enter_town", 0),
      (end_try),
    ],
    [
      ("station_troops",
        [
        ],
        "Take a look at the troops.",
        [
          (change_screen_exchange_members,1),
      ]),
      
      ("leave",[],"Leave.",
        [
          
          (try_begin),
            (this_or_next|eq, "$g_encountered_party", "p_troop_camp_1"),
            (			  eq, "$g_encountered_party", "p_troop_camp_2"),
            (try_begin),
              (party_get_num_prisoners, reg1, "$g_encountered_party"),
              (gt, reg1, 0),
              (assign, "$g_move_heroes", 0),
              (call_script, "script_party_remove_all_prisoners", "$g_encountered_party"),
              # (party_remove_prisoners, "$g_encountered_party",<troop_id>,<number>),
              (display_message, "@Temporary quarters are not a good place to hold prisoners. {reg1} prisoners have escaped.", color_bad_news),
            (end_try),
            (party_get_num_companions, reg1, "$g_encountered_party"),
            (le, reg1, 0),
            (call_script, "script_randomly_make_prisoner_heroes_escape_from_party", "$g_encountered_party", 2000),
            (party_clear, "$g_encountered_party"),	#fixing VC-1852
            
            (disable_party, "$g_encountered_party"),
          (end_try),
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "player_trait",0,
    "{!}{s3}",
    "none",
    [
      (set_background_mesh, "mesh_pic_victory"),
      (store_skill_level, ":power_strike", "skl_power_strike", "trp_player"),	#Berserker
      (store_skill_level, ":leadership", "skl_leadership", "trp_player"),		#Inspiring
      (store_skill_level, ":athletics", "skl_athletics", "trp_player"),			#Tough
      (store_skill_level, ":ironflesh", "skl_ironflesh", "trp_player"),			#Strong
      
      (try_begin),
        (ge, ":power_strike", ":leadership"),
        (ge, ":power_strike", ":athletics"),
        (ge, ":power_strike", ":ironflesh"),
        (assign, "$player_trait", 1),
        #(str_store_string, s3, "str_trait_1"),
        (str_store_string, s3, "@You have become a berserker. When you go berserk, you gain great speed and strength in the heat of battle, but this brutal ferocity turns your vision red. (Use key T to increase your power strike)"),
      (else_try),
        (ge, ":leadership", ":athletics"),
        (ge, ":leadership", ":ironflesh"),
        (assign, "$player_trait", 2),
        #(str_store_string, s3, "str_trait_2"),
        (str_store_string, s3, "@Your studies in poetry and rhetoric have been productive. This newly acquired skill in oratory will increase your leadership in battle as you urge on your men in combat. (Use key T to evoke a war cry)"),
      (else_try),
        (ge, ":athletics", ":ironflesh"),
        (assign, "$player_trait", 3),
        #(str_store_string, s3, "str_trait_3"),
        (str_store_string, s3, "@The exhausting athletics regimen you have applied to your troops makes them faster and more maneuverable in battle. They show their new confidence by taunting their enemies. (Use key T to evoke a shield taunt)"),
      (else_try),
        (assign, "$player_trait", 4),
        #(str_store_string, s3, "str_trait_4"),
        (str_store_string, s3, "@Your incessant concern about the maintenance of your men's shields and armors makes it harder for the enemy to wound them. They show their new confidence by beating their shields. (Use key T to evoke a shield taunt)"),
      (end_try),
      
    ],
    [
      
      ("continue",[],"Continue.",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "start_beda_final",0,
    "FINAL ",
    "none",
    [
      (try_begin),
        (eq, "$finish_game", 0),
        (assign, "$finish_game", 1),
        (start_presentation, "prsnt_beda_story_finalmainquest"),
      (else_try),
        (change_screen_quit),
      (end_try),
      
    ],
    [
      
      ("continue",[],"Continue.",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "ship_capture",0,
    "You are able to capture one of the enemy's ships. It's a {s2}, but due to the fight, the '{s1}' is in a bad condition. Do you want to add this ship to your fleet nevertheless?",
    "none",
    [
      (assign, ":blocking", 0),
      (try_begin),
        # Player only joined the battle?
        (eq, "$g_joined_battle_to_help", 1),
        (assign, ":blocking", 1),
      (else_try),
        # Player has room for another ship?
        (store_skill_level, ":cur_sea_king_skill", "skl_sea_king", "trp_player"),
        (val_mul, ":cur_sea_king_skill", 2),	#new skill adjust
        (val_min, ":cur_sea_king_skill", 7),	#new skill adjust
        (val_sub, ":cur_sea_king_skill", 1),
        (store_add, ":slot", slot_party_1_ship_type, ":cur_sea_king_skill"),
        (party_get_slot, ":ship_type", "p_main_party", ":slot"),
        (neq, ":ship_type", 0),
        (assign, ":blocking", 1),
      (else_try),
        # Player has luck?
        (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"),
        (store_add, ":chance", 10, ":player_party_looting"), # 10% is basic chance (up to 20% with looting skill)
        (try_begin),
          (eq, "$easy_wage", 1),# VC-3003
          (val_mul, ":chance", 140),	#so up to 28%
          (val_div, ":chance", 100),
        (try_end),
        (store_random_in_range, ":rand", 1, 101),
        (gt, ":rand", ":chance"), # = no luck
        (assign, ":blocking", 1),
	  (else_try),
	    # invalid ship type entry (for example caused by VC-3658)
		(try_begin),
          (eq, "$player_team_in_sea_battle", 0),
          (assign, ":quest", "qst_team_1_ships"),
        (else_try),
          (assign, ":quest", "qst_team_0_ships"),
        (end_try),
        (quest_get_slot, ":ship_type", ":quest", slot_quest_1_ship_type),
		(this_or_next|lt, ":ship_type", ship_type_busse),
		(gt, ":ship_type", ship_type_byrding),
		(assign, ":blocking", 1),
      (end_try),
      
      (try_begin),
        (neq, ":blocking", 0),	# = no ship capture
        (jump_to_menu, "mnu_total_victory"),
      (else_try),
        # all is ok:
        (try_begin),
          (eq, "$player_team_in_sea_battle", 0),
          (assign, ":quest", "qst_team_1_ships"),
        (else_try),
          (assign, ":quest", "qst_team_0_ships"),
        (end_try),
        (quest_get_slot, "$ship_menu_current_ship_type", ":quest", slot_quest_1_ship_type),
        (store_random_in_range, "$ship_menu_current_ship_name", "str_ship_name_1", "str_ship_names_end"),
        (store_random_in_range, "$ship_menu_current_ship_quality", 5, 15),
        (quest_get_slot, "$ship_menu_current_ship_propertys", ":quest", slot_quest_1_ship_prop),
        
        (set_background_mesh,"mesh_pic_extra_viejo"),
        (str_store_string, s1, "$ship_menu_current_ship_name"),
        (call_script,  "script_get_ship_properties", "$ship_menu_current_ship_type"),
        (str_store_string, s2, reg7), #type_name
      (end_try),
      
    ],
    [
      
      ("capture",[],"Add the ship to your fleet.",
        [
          
          # Give ship to destination
          (assign, ":give_ship_completed", 0),
          (try_for_range, ":current_ship_type_slot", slot_party_player_ships_type_begin, slot_party_player_ships_type_end),
            (eq, ":give_ship_completed", 0),
            (party_get_slot, ":ship_type", "p_main_party", ":current_ship_type_slot"),
            (neg|is_between, ":ship_type", 1,10),
            (party_set_slot, "p_main_party", ":current_ship_type_slot", "$ship_menu_current_ship_type"),
            (store_sub, ":slot_number", ":current_ship_type_slot", slot_party_player_ships_type_begin),
            (store_add, ":current_ship_name_slot", slot_party_player_ships_name_begin, ":slot_number"),
            (party_set_slot, "p_main_party", ":current_ship_name_slot", "$ship_menu_current_ship_name"),
            (store_add, ":current_ship_quality_slot", slot_party_player_ships_quality_begin, ":slot_number"),
            (party_set_slot, "p_main_party", ":current_ship_quality_slot", "$ship_menu_current_ship_quality"),
            (store_add, ":current_ship_propertys_slot", slot_party_player_ships_propertys_begin, ":slot_number"),
            (party_set_slot, "p_main_party", ":current_ship_propertys_slot", "$ship_menu_current_ship_propertys"),
            (assign, ":give_ship_completed", 1),
          (end_try),
          
          (jump_to_menu, "mnu_total_victory"),
      ]),
      
      ("leave_ship",[],"Leave the ship behind.",
        [
          (jump_to_menu, "mnu_total_victory"),
      ]),
    ]
  ),
  
  ####final storyline
  ("sandboxmode_ok",menu_text_color(0xFF000000)|mnf_disable_all_keys,
    "Go to Sandbox mode?",
    "none",
    [
    ],
    [
      ("yes_dot",[],"Yes.",
        [ (disable_party, "p_readingum"),
          (call_script, "script_conclude_quest", "qst_svenbn_final"),
          (set_show_messages, 0),
          (call_script, "script_conclude_quest", "qst_notes_companions"),
          (call_script, "script_conclude_quest", "qst_notes_global"),
          (call_script, "script_conclude_quest", "qst_notes_frisa"),
          (call_script, "script_conclude_quest", "qst_notes_danmork"),
          (call_script, "script_conclude_quest", "qst_notes_englaland"),
          (call_script, "script_end_quest", "qst_svenbn_final"),
          (call_script, "script_end_quest", "qst_notes_companions"),
          (call_script, "script_end_quest", "qst_notes_global"),
          (call_script, "script_end_quest", "qst_notes_frisa"),
          (call_script, "script_end_quest", "qst_notes_danmork"),
          (call_script, "script_end_quest", "qst_notes_englaland"),
          (set_show_messages, 1),
          
          (assign, "$campaign_type", camp_sandbox),
          (assign, "$g_lord_hide", -1),
          (assign, "$continue_storyline", 1),
          (leave_encounter),
          (jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
      ("no_dot",[],"No.",
        [
          (change_screen_quit),
      ]),
    ]
  ),
  # a menu for starting a sea travel
  ("start_sea_travel",0,
    "You are starting a sea travel.",
    "none",
    [
      (set_camera_follow_party, "p_transporter"),
      (assign, "$g_player_is_captive", 1),
      #(call_script, "script_stay_captive_for_hours", 10 * 24),
      (rest_for_hours, 10 * 24, 4, 0),
      (assign,"$auto_menu","mnu_auto_return"),
      (change_screen_return),
    ],
    [
      
      ("continue",[],"Continue.",
        [
          (change_screen_map),
      ]),
    ]
  ),
  
  ("mutiny_start",0,
    "The morale of some troops is low. They start a mutiny.",
    "none",
    [
      (set_background_mesh, "mesh_pic_extra_navegando"),
    ],
    [
      
      ("continue",[],"Continue.",
        [(set_jump_mission,"mt_mutiny"),
          (call_script, "script_prepare_party_ships_for_team", "p_main_party", 0),
          (call_script, "script_setup_random_sea_scene"),
          (jump_to_menu, "mnu_mutiny_end"),
          (change_screen_mission),
        ]
      ),
    ]
  ),
  
  ("mutiny_end",0,
    "After the mutiny, the situation calms down.",
    "none",
    [
      (try_begin),
        (eq, "$g_battle_won", 1),
        (leave_encounter),	#?
        (change_screen_map),
      (else_try),
        (jump_to_menu, "mnu_captivity_wilderness_taken_prisoner"),
      (end_try),
      (set_background_mesh, "mesh_pic_extra_navegando"),
    ],
    [
      
      ("continue",[],"Continue.",
        [
          (change_screen_map),
        ]
      ),
    ]
  ),
  
  ###### Addon work feature (VC-1877)
  ("work_start",0,
    "Before long, your limbs tire of the monotonous work, but, as agreed, you work for an entire day.",
    "none",
    [
      (try_begin),
        (is_between, "$g_encountered_party", "p_lumbercamp1", "p_farmsteadsp1"),
        (set_background_mesh, "mesh_pic_forest"),
      (else_try),
        (is_between, "$g_encountered_party", "p_farmsteadsp1", "p_hadrian_wall1"),
        (set_background_mesh, "mesh_pic_farmstead"),
      (else_try),
        (set_background_mesh, "mesh_pic_bandits_lair"),
      (end_try),
    ],
    [
      
      ("continue",[],"Continue.",
        [
          (assign, "$auto_menu", "mnu_work_end"),
          (rest_for_hours, 24, 0, 0),
          (change_screen_map),
        ]
      ),
    ]
  ),
  
  ("work_end",0,
    "Content, you look back on a day of honest labour, but then, looking at your wages, you think that a life of honest labour seems to be a rather meager existence.^^{s7}",
    "none",
    [
      (try_begin),
        (is_between, "$g_encountered_party", "p_quarry1", "p_saltmine1"),
        (set_background_mesh, "mesh_pic_bandits_lair"),
        (assign, ":item", "itm_stone"),
        (assign, ":money", vc_work_payment_3),
      (else_try),
        (is_between, "$g_encountered_party", "p_saltmine1", "p_lumbercamp1"),
        (set_background_mesh, "mesh_pic_bandits_lair"),
        (assign, ":item", "itm_salt"),
        (assign, ":money", vc_work_payment_3),
      (else_try),
        (is_between, "$g_encountered_party", "p_lumbercamp1", "p_farmsteadsp1"),
        (set_background_mesh, "mesh_pic_forest"),
        (assign, ":item", "itm_timber"),
        (assign, ":money", vc_work_payment_1),
      (else_try),
        #(is_between, "$g_encountered_party", "p_farmsteadsp1", "p_hadrian_wall1"),
        (set_background_mesh, "mesh_pic_farmstead"),
        (assign, ":item", "itm_pork"),
        (assign, ":money", vc_work_payment_2),
      (end_try),
      
      (try_begin),
        (eq, "$vc_work_payment", 0),
        (str_store_string, s7, "@On this day, the foreman couldn't even pay the wages, so he paid with produced goods instead."),
        (troop_add_item, "trp_player", ":item"),
      (else_try),
        (eq, "$vc_work_payment", 1),
        (str_store_string, s7, "@However, on this day you learned something from your work."),
        (add_xp_as_reward, 50),
        (call_script, "script_troop_add_gold", "trp_player", ":money"),
      (else_try),
        (eq, "$vc_work_payment", 2),
        (str_store_string, s7, "@However, on this day you achieved a lot and were paid double."),
        (val_mul, ":money", 2),
        (call_script, "script_troop_add_gold", "trp_player", ":money"),
      (else_try),
        (eq, "$vc_work_payment", 3),
        (call_script, "script_get_closest_center", "p_main_party"),
        (assign, ":closest_center", reg0),
        (call_script, "script_change_player_relation_with_center", ":closest_center", 1),
        (str_store_party_name, s2, ":closest_center"),
        (str_store_string, s7, "@However, you befriended some workers from {s2}."),
        (call_script, "script_troop_add_gold", "trp_player", ":money"),
      (else_try),
        (call_script, "script_troop_add_gold", "trp_player", ":money"),
        (str_clear, s7),
      (end_try),
    ],
    [
      
      ("continue",[],"Continue.",
        [
          (change_screen_map),
        ]
      ),
    ]
  ),
  
  ### 2 new sea travel menus
  
  (
    "landing_point_encounter_as_marshal",0,
    "You are currently marshal. You attempt to disembark. {s1} {s2}^^Do you want to disembark now or wait?",
    "none",
    [
      (set_background_mesh, "mesh_pic_fleet"),
      
      (str_clear, s1),
      (str_clear, s2),
      (assign, ":can_join", 0),
      (assign, ":cant_join", 0),
      (try_for_parties, ":cur_party"),
        (party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
        (party_is_active, ":cur_party"),
        (store_faction_of_party, ":cur_party_faction", ":cur_party"),
        (eq, ":cur_party_faction", "$players_kingdom"),
        (get_party_ai_object, ":cur_party_ai_object", ":cur_party"),
        (eq, ":cur_party_ai_object", "p_main_party"),
        (party_slot_eq, ":cur_party", slot_party_on_water, 1),
        (store_distance_to_party_from_party, ":distance", "p_main_party", ":cur_party"),
        (try_begin),
          (le, ":distance", 5),
          (val_add, ":can_join", 1),
        (else_try),
          (val_add, ":cant_join", 1),
        (end_try),
      (try_end),
      
      (try_begin),
        (eq, ":can_join", 1),
        (str_store_string, s1, "@One lord can disembark here with you."),
      (else_try),
        (gt, ":can_join", 0),
        (assign, reg1, ":can_join"),
        (str_store_string, s1, "@{reg1} lords can disembark here with you."),
      (try_end),
      (try_begin),
        (eq, ":can_join", 1),
        (str_store_string, s2, "@One lord will lose track of you. He must disembark at the next port and then come find you."),
      (else_try),
        (gt, ":cant_join", 0),
        (assign, reg1, ":cant_join"),
        (str_store_string, s2, "@{reg1} lords will lose track of you. They must disembark at the next port and then come find you."),
      (try_end),
      
    ],
    [
      ("disembark_yeslp", [], "Disembark.",
        [
          (try_begin),
            (party_slot_eq, "p_main_party", slot_party_on_water, 1),
            (party_get_position, pos1, "p_landing_point"),
            (call_script, "script_get_next_land_position", 1),
            (set_spawn_radius, 0),
            (spawn_around_party, "p_main_party", "pt_landet_ships"),
            (assign, ":landet_ship_party", reg0),
            (str_store_troop_name, s1, "trp_player"),
            (party_set_name, ":landet_ship_party", "@{s1}'s Ships"),
            (party_set_slot, ":landet_ship_party", slot_party_type, spt_ship),
            (party_set_position, ":landet_ship_party", pos2),
            (call_script, "script_give_player_ships_from_party_to_party", "p_main_party", ":landet_ship_party"),
            (party_set_position, "p_main_party", pos2),
            (call_script, "script_switch_to_land_consequences"),
            (try_for_parties, ":cur_party"),
              (party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
              (party_is_active, ":cur_party"),
              (store_faction_of_party, ":cur_party_faction", ":cur_party"),
              (eq, ":cur_party_faction", "$players_kingdom"),
              (get_party_ai_object, ":cur_party_ai_object", ":cur_party"),
              (eq, ":cur_party_ai_object", "p_main_party"),
              (party_slot_eq, ":cur_party", slot_party_on_water, 1),
              (store_distance_to_party_from_party, ":distance", "p_main_party", ":cur_party"),
              (le, ":distance", 5),
              (party_set_position, ":cur_party", pos2),
              (party_set_slot, ":cur_party", slot_party_on_water, 0),
              (party_set_flags, ":cur_party", pf_is_ship, 0),
              (call_script, "script_update_party_icon", ":cur_party"),
            (try_end),
          (end_try),
          (change_screen_return),
      ]),
      
      ("disembark_nolp", [], "Wait.",
        [
          (change_screen_return),
      ]),
    ]
  ),
  
  (
    "landet_ships_encounter_as_marshal",0,
    "You are currently marshal. You attempt to embark. {s1} {s2}^^Do you want to embark now or wait?",
    "none",
    [
      (set_background_mesh, "mesh_pic_fleet"),
      
      (str_clear, s1),
      (str_clear, s2),
      (assign, ":can_join", 0),
      (assign, ":cant_join", 0),
      (try_for_parties, ":cur_party"),
        (party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
        (party_is_active, ":cur_party"),
        (store_faction_of_party, ":cur_party_faction", ":cur_party"),
        (eq, ":cur_party_faction", "$players_kingdom"),
        (get_party_ai_object, ":cur_party_ai_object", ":cur_party"),
        (eq, ":cur_party_ai_object", "p_main_party"),
        (party_slot_eq, ":cur_party", slot_party_on_water, 0),
        (store_distance_to_party_from_party, ":distance", "p_main_party", ":cur_party"),
        (try_begin),
          (le, ":distance", 5),
          (val_add, ":can_join", 1),
        (else_try),
          (val_add, ":cant_join", 1),
        (end_try),
      (try_end),
      
      (try_begin),
        (eq, ":can_join", 1),
        (str_store_string, s1, "@One lord can embark here with you."),
      (else_try),
        (gt, ":can_join", 0),
        (assign, reg1, ":can_join"),
        (str_store_string, s1, "@{reg1} lords can embark here with you."),
      (try_end),
      (try_begin),
        (eq, ":can_join", 1),
        (str_store_string, s2, "@One lord will lose track of you. He must embark at the next port and then come find you."),
      (else_try),
        (gt, ":cant_join", 0),
        (assign, reg1, ":cant_join"),
        (str_store_string, s2, "@{reg1} lords will lose track of you. They must embark at the next port and then come find you."),
      (try_end),
      
    ],
    [
      ("reembark_yesls", [], "Embark.",
        [
          (try_begin),
            (call_script, "script_cf_crew_fit_in_ships", "$g_encountered_party"),
            (call_script, "script_give_player_ships_from_party_to_party", "$g_encountered_party", "p_main_party"),
            (party_get_position, pos1, "$g_encountered_party"),
            (call_script, "script_get_next_water_position", 1),
            (party_set_position, "p_main_party", pos2),
            (call_script, "script_switch_to_water_consequences"),
            (disable_party, "$g_encountered_party"),
            (try_for_parties, ":cur_party"),
              (party_slot_eq, ":cur_party", slot_party_type, spt_kingdom_hero_party),
              (party_is_active, ":cur_party"),
              (store_faction_of_party, ":cur_party_faction", ":cur_party"),
              (eq, ":cur_party_faction", "$players_kingdom"),
              (get_party_ai_object, ":cur_party_ai_object", ":cur_party"),
              (eq, ":cur_party_ai_object", "p_main_party"),
              (party_slot_eq, ":cur_party", slot_party_on_water, 0),
              (store_distance_to_party_from_party, ":distance", "p_main_party", ":cur_party"),
              (le, ":distance", 5),
              (party_set_position, ":cur_party", pos2),
              (party_set_slot, ":cur_party", slot_party_on_water, 1),
              (party_set_flags, ":cur_party", pf_is_ship, 1),
              (call_script, "script_update_party_icon", ":cur_party"),
            (try_end),
          (else_try),
            (display_message, "str_cant_set_sail"),
          (end_try),
          (change_screen_return),
      ]),
      ("reembark_nols", [], "Wait.",
        [(change_screen_return),
      ]),
    ]
  ),
  
  (
    "recruit_volunteers_town",0,
    "{!}{s18}",
    "none",
    [
      # JuJu70 - make it more realistic
      (troop_get_slot, ":religion","trp_player", slot_troop_religion),
      (party_get_slot, ":center_culture", "$current_town", slot_center_culture),
      (troop_get_slot, ":player_renown", "trp_player", slot_troop_renown), #renown
      (party_get_slot, ":center_relation", "$current_town", slot_center_player_relation),
      (party_get_slot, ":faith", "$current_town", slot_center_faithratio),
      ###
      (try_begin),
        (this_or_next|party_slot_eq, "$current_town", slot_town_lord, "trp_player"),	#chief add for recruit need to permission
        (party_slot_eq, "$current_town", recruit_permission_need, 0), 				#chief add for recruit need to permission
        (party_set_slot, "$current_town", recruit_permission_need, 3), #no recruit possibility x time
        (assign, "$g_block_recruiting", 0),
        
        (store_random_in_range, ":random_no", 0, 9),
        (assign, ":extra_vol", 1),
        ##renown adjustment
        (assign, ":upper_limit", 6),
        (try_begin),
          (ge, ":player_renown", 100),
          (store_sub, ":renown_bonus", ":player_renown", 100),
          (val_div, ":renown_bonus", 100),
          (val_add, ":upper_limit", ":renown_bonus"),
        (try_end),
        (try_begin),
          (party_slot_eq, "$current_town", slot_town_lord, "trp_player"), #player is lord
          (val_add, ":upper_limit", 2),
        (try_end),
        ## religious adjustment
        (try_begin),
          (eq, ":religion", 1),
          (val_mul, ":upper_limit", ":faith"),
          (val_div, ":upper_limit", 100),
          (val_add, ":upper_limit", 1),
        (else_try),
          (eq, ":religion", 2),
          (store_sub, ":p_faith", 100, ":faith"),
          (val_mul, ":upper_limit", ":p_faith"),
          (val_div, ":upper_limit", 100),
          (val_add, ":upper_limit", 1),
        (try_end),
        ## charisma adjustment
        (store_attribute_level, ":charisma", "trp_player", ca_charisma),
        (val_div, ":charisma", 10),
        (val_add, ":upper_limit", ":charisma"),
        (store_skill_level, ":leadership", "skl_leadership", "trp_player"),
        (val_div, ":leadership", 5),
        (val_add, ":upper_limit", ":leadership"),
        ## relation adjustment
        (try_begin),
          (ge, ":center_relation", 20), #chief change to 20
          (store_div, ":rec_bonus", ":center_relation", 20),
          (val_add, ":upper_limit", ":rec_bonus"),
        (else_try),
          (lt, ":center_relation", 0),
          (assign, ":upper_limit", 0),
        (try_end),
        
        
        
        
        # (try_begin),
        # (gt, ":center_relation", 60),
        # (val_add, ":extra_vol", 4),
        # (else_try),
        # (gt, ":center_relation", 30),
        # (val_add, ":extra_vol", 2),
        # (else_try),
        ##                   (gt, ":center_relation", 30),
        # (val_add, ":extra_vol", 0),
        # (try_end),
        
        (try_begin),
          (this_or_next|lt, ":center_relation", 0),
          (le, ":random_no", 1), #40% possibilites nobody want to join
          (assign, ":volunteer_amount", ":extra_vol"), #chief chage from 0 to 1 for frank request
        (else_try),
          (store_random_in_range, ":random_no2", 1, ":upper_limit"), #max 14 men, they are warband (old english werod) with a leader + standarbearer or horned + warriors
          (try_begin),
            (party_slot_eq,"$current_town",slot_party_type, spt_town),
            (party_get_slot, ":prosperity", "$current_town", slot_town_prosperity),
            (val_div, ":prosperity", 25),
            (val_add, ":random_no2", ":prosperity"),
          (try_end),
          (val_add, ":random_no2", ":extra_vol"),
          
          (assign, ":volunteer_amount", ":random_no2"),
        (try_end),
        
        (store_random_in_range, ":ram_troop", 0, 7),
        (try_begin),
          (gt, ":center_relation", 30),
          (eq, ":ram_troop", 1),
          (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_3_troop),
        (else_try),
          (gt, ":center_relation", 30),
          (eq, ":ram_troop", 2),
          (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_2_troop),
          (troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", 1),
          (try_begin),
            (le, ":upgrade_troop_no", 0),
            (troop_get_upgrade_troop, ":upgrade_troop_no", ":volunteer_troop", 0),
          (try_end),
          (gt, ":upgrade_troop_no", 0),
          (assign, ":volunteer_troop", ":upgrade_troop_no"),
        (else_try),
          (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_2_troop),
        (try_end),
      (try_end),
      
      (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
      (store_troop_gold, ":gold", "trp_player"),
      (store_character_level, ":troop_level", ":volunteer_troop"), #cost = level * 4 . Common: troop level 23 = 92 peningas, but player save time to upgrade and upgrade cost
      (val_mul, ":troop_level", 4),
      (assign, ":wage", ":troop_level"),
      #		  (call_script, "script_cost_per_village_recruit"),  #MOTO variable cost
      #		  (store_div, ":gold_capacity", ":gold", reg0),#10 peningas per man MOTO variable cost
      (store_div, ":gold_capacity", ":gold", ":wage"),
      (assign, ":party_capacity", ":free_capacity"),
      (val_min, ":party_capacity", ":gold_capacity"),
      (try_begin),
        (gt, ":party_capacity", 0),
        (val_min, ":volunteer_amount", ":party_capacity"),
      (try_end),
      (assign, reg5, ":volunteer_amount"),
      (assign, reg7, 0),
      (try_begin),
        (gt, ":volunteer_amount", ":gold_capacity"),
        (assign, reg7, 1), #not enough money
      (try_end),
      (try_begin),
        (eq, ":volunteer_amount", 0),
        (str_store_string, s18, "@No one here wants to join your party."),
        #(str_store_string, s19, "@But"),
      (else_try),
        (store_mul, reg6, ":volunteer_amount", ":wage"),
        (assign, "$temp", ":volunteer_amount"), #troop chief
        (assign, "$temp2", ":volunteer_troop"), #troop chief
        (str_store_troop_name_by_count, s3, ":volunteer_troop", ":volunteer_amount"),
        (try_begin),
          (eq, reg5, 1),
          (str_store_string, s18, "@One {s3} is willing to follow you."),
        (else_try),
          (str_store_string, s18, "@{reg5} {s3} are willing to follow you."),
        (try_end),
        #(str_store_string, s19, "@Also"),
        #(set_background_mesh, "mesh_pic_recruits"),
        # mnu_recruit_volunteers ends
      (else_try),
        (str_store_string, s18, "@You need to get the permission of the lord of this place to recruit here."),
        #(str_store_string, s19, "@But"),
        (party_get_slot, ":center_culture", "$current_town", slot_center_culture),
        (faction_get_slot, ":volunteer_troop", ":center_culture", slot_faction_tier_2_troop),
        (assign, ":volunteer_amount", 0),
        (assign, reg7, 0),#
        (assign, reg5, 1),#
        (assign, "$g_block_recruiting", 1),
      (end_try),
      
    ],
    [
      ("continue_not_enough_gold",
        [
          (eq, reg7, 1),
        ],
        "I don't have enough money.",
        [
          (jump_to_menu,"mnu_town"),
      ]),
      
      ("continue",
        [
          (eq, reg7, 0),
          (eq, reg5, 0),
        ], #noone willing to join
        "Continue...",
        [
          (jump_to_menu,"mnu_town"),
      ]),
      
      ("recruit_them",
        [
          (eq, reg7, 0),
          (gt, reg5, 0),
          (eq, "$g_block_recruiting", 0),	#vc_submenu_recruits
        ],
        "Recruit them ({reg6} peningas).",
        [
          (assign, ":volunteer_troop", "$temp2"), #troop chief
          (assign, ":volunteer_amount", "$temp"), #troop chief
          
          (party_get_free_companions_capacity, ":free_capacity", "p_main_party"),
          (val_min, ":volunteer_amount", ":free_capacity"),
          (store_troop_gold, ":gold", "trp_player"),
          (store_character_level, ":troop_level", ":volunteer_troop"), #cost = level * 4 . Common: troop level 23 = 92 peningas, but player save time to upgrade and upgrade cost
          (val_mul, ":troop_level", 4),
          (assign, ":recruit_cost", ":troop_level"),
          (store_div, ":gold_capacity", ":gold", ":recruit_cost"),#
          (val_min, ":volunteer_amount", ":gold_capacity"),
          (party_add_members, "p_main_party", ":volunteer_troop", ":volunteer_amount"),
          (store_mul, ":cost", ":volunteer_amount", ":recruit_cost"),
          (troop_remove_gold, "trp_player", ":cost"),
          
          (jump_to_menu,"mnu_town"),
      ]),
      
      ("forget_it",
        [
          (eq, reg7, 0),
          (gt, reg5, 0),
        ],
        "Forget it.",
        [
          (jump_to_menu,"mnu_town"),
      ]),
    ],
  ),
  
  ###### Addon hunting feature (VC-1877)
  ("hunting",0,
    "You have encountered {s1}. What do you want to do?",
    "none",
    [
      (set_background_mesh, "mesh_pic_road_with_grove"),
      (assign, "$hunted_today", 1),
      
      (party_get_num_companions, reg6, "$g_encountered_party"),
      (try_begin),
        (eq, "$g_encountered_party_template", "pt_boar_herd"),
        (eq, reg6, 1),
        (str_store_string, s1, "@a lone boar"),
      (else_try),
        (eq, "$g_encountered_party_template", "pt_boar_herd"),
        (str_store_string, s1, "@a herd of {reg6} boar"),
      (else_try),
        (str_store_string, s1, "@a herd of {reg6} wild animals"),
      (end_try),
      
    ],
    [
      ("hunt_go",[],"Go hunting.",
        [
          (assign, "$loot_screen_shown", 0),
          (troop_clear_inventory, "trp_temp_troop"),
          
          (set_jump_mission,"mt_hunting"),
          (set_jump_entry, 0),
          (call_script, "script_setup_random_scene"),
          (jump_to_menu, "mnu_after_hunt"),
          (change_screen_mission),
        ]
      ),
      
      ("leave",[],"Leave.",
        [
          (change_screen_map),
        ]
      ),
    ]
  ),
  
  ("after_hunt",0,
    "{!}{s1}",
    "none",
    [
      (set_background_mesh, "mesh_pic_road_with_grove"),
      
      (try_begin),
        (eq, "$loot_screen_shown", 0),
        (assign, "$loot_screen_shown", 1),
        (gt, "$hunted_animals", 0),
        (change_screen_loot, "trp_temp_troop"),
      (else_try),
        (gt, "$hunted_animals", 0),
        (eq, "$g_encountered_party_template", "pt_boar_herd"),
        (assign, reg6, "$hunted_animals"),
        (str_store_string, s1, "@You successfully hunted {reg6} boar."),
      (else_try),
        (str_store_string, s1, "@You have lost track of the animals."),
      (end_try),
      
    ],
    [
      ("continue",[],"Continue.",
        [
          (party_clear, "$g_encountered_party"),
          (change_screen_map),
        ]
      ),
      
    ]
  ),
  
  ("slave_hideout",0,
    "You have encountered a hideout. What do you want to do?",
    "none",
    [
      (try_begin),
        (check_quest_active, "qst_blank_quest_7"),
        (neg|check_quest_succeeded,"qst_blank_quest_7"),
        (neg|check_quest_failed,"qst_blank_quest_7"),
        (quest_slot_eq, "qst_blank_quest_7", slot_quest_target_party, "$g_encountered_party"),
        (quest_get_slot,":stage","qst_blank_quest_7",slot_quest_current_state),
        (is_between, ":stage", 0,3),
        #
        (quest_set_slot, "qst_blank_quest_7", slot_quest_current_state, 2),
        (set_jump_mission,"mt_slave_hideout"),
        (set_jump_entry, 0),
        (jump_to_scene, "scn_random_scene_plain_forest"),
        (change_screen_mission),
      (else_try),
        (change_screen_map),
        (remove_party, "$g_encountered_party"),
        (assign, "$g_encountered_party", -1),
      (else_try),
        (set_background_mesh, "mesh_pic_road_with_grove"),
      (end_try),
    ],
    [
      ("leave",[],"Leave.",
        [
          (change_screen_map),
          (remove_party, "$g_encountered_party"),
          (assign, "$g_encountered_party", -1),
        ]
      ),
    ]
  ),
  
  
  ("set_goal_trigger_new_game",0,
    "{!}{s1}",
    "none",
    [
      (set_background_mesh, "mesh_pic_messenger"),
      (str_store_string, s1, "str_set_goal_trigger_new_game"),
      (str_store_string, s1, "@Choose a Goal^^^^{s1}"),
      
      (try_begin),
        (eq, "$goal_type", goal_canceled),
        (jump_to_menu, "mnu_auto_return_to_map"),
      (else_try),
        (eq, "$temp", 2),
        (ge, "$goal_type", goal_custom),
        (assign, "$temp", 3),
        (call_script, "script_button_open_set_goal_prsnt"),
      (else_try),
        (eq, "$temp", 3),
        (jump_to_menu, "mnu_auto_return_to_map"),
      (else_try),
        (eq, "$temp", 1),
        (ge, "$goal_type", goal_custom),
        (jump_to_menu, "mnu_auto_return_to_map"),
      (try_end),
    ],
    [
      ("continue",[],"Continue.",
        [
          (assign, "$temp", 2),
          (call_script, "script_button_open_set_goal_prsnt"),
        ]
      ),
      ("not_now",[],"Not now.",
        [
          (jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  
  ("set_goal_message_complete_goal",0,
    "{!}{s1}",
    "none",
    [
      (set_background_mesh, "mesh_pic_victory"),
      (str_store_string, s1, "str_set_goal_complete_goal"),
      (str_store_string, s1, "@Congratulations!^^^^{s1}"),
      
      (try_begin),
        (eq, "$goal_type", goal_canceled),
        (jump_to_menu, "mnu_auto_return_to_map"),
      (else_try),
        (eq, "$temp", 2),
        (ge, "$goal_type", goal_custom),
        (assign, "$temp", 3),
        (call_script, "script_button_open_set_goal_prsnt"),
      (else_try),
        (eq, "$temp", 3),
        (jump_to_menu, "mnu_auto_return_to_map"),
      (try_end),
    ],
    [
      ("new_goal",[],"Choose a new goal.",
        [
          (assign, "$temp", 2),
          (call_script, "script_button_open_set_goal_prsnt"),
        ]
      ),
      ("not_now",[],"Not now.",
        [
          (jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  
  ("auto_start_presentation",0,
    "{!}{s1}",
    "none",
    [
      (start_presentation, "$g_presentations_next_presentation"),
    ],
    [
      ("leave",[], "{!}leave",
        [
          (jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
    ]
  ),
  
  ("reconstruct_pre2049",0,
    "This save game appears to have been ruined by the bug in v2.049. We recommend restoring the game from last_savegame_backup.sav or your computer files backup. Do you wish to try to reconstruct the game, instead?",
    "none",
    [],
    [
      ("choice_yes",[],"Yes, attempt to reconstruct save game.", [
        (party_set_faction, "p_paganholysites1", "fac_neutral"),
        (party_set_faction, "p_paganholysites2", "fac_neutral"),
        (party_set_faction, "p_oldpagan_hut", "fac_neutral"),
        (party_set_faction, "p_morrigan_lair", "fac_neutral"),
        (party_set_faction, "p_bresail_farm", "fac_neutral"),
        (party_set_faction, "p_bresail_fort", "fac_neutral"),
        (party_set_faction, "p_reserved_1", "fac_commoners"),
        (party_set_faction, "p_Bridge_18", "fac_neutral"),
        
        (party_get_slot, ":party_no", "p_yourlair", slot_party_port_party),
        (party_set_faction, ":party_no", "fac_player_faction"),
		
        (try_for_parties, ":party_no"),
          (gt, ":party_no", "p_Bridge_18"),
          (party_get_template_id, ":party_type", ":party_no"),
          
          (try_begin),
            (eq, ":party_type", "pt_landet_ships"),
            (party_set_faction, ":party_no", "fac_player_supporters_faction"),
          (else_try),
            (eq, ":party_type", "pt_kingdom_hero_party"),
            (party_stack_get_troop_id, ":leader", ":party_no", 0),
            (store_troop_faction, ":leader_faction", ":leader"),
            (party_set_faction, ":party_no", ":leader_faction"),
          (else_try),
            (this_or_next|eq, ":party_type", "pt_cattle_herd"),
            (this_or_next|eq, ":party_type", "pt_bandits_awaiting_ransom"),
            (this_or_next|eq, ":party_type", "pt_kidnapped_girl"),
            (this_or_next|is_between, ":party_type", "pt_spy_partners", "pt_scout_party"),
            (this_or_next|eq, ":party_type", "pt_wessex_foragers"),
            (this_or_next|eq, ":party_type", "pt_boar_herd"),
            (eq, ":party_type", "pt_slave_hideout"),
            (party_set_faction, ":party_no", "fac_neutral"),
          (else_try),
            (this_or_next|eq, ":party_type", "pt_village_defenders"),
            (this_or_next|eq, ":party_type", "pt_merchant_caravan"),
            (this_or_next|eq, ":party_type", "pt_scout_party"),
            (this_or_next|eq, ":party_type", "pt_messenger_party"),
            (this_or_next|eq, ":party_type", "pt_raider_captives"),
            (this_or_next|eq, ":party_type", "pt_village_elder"),
            (is_between, ":party_type", "pt_prisoner_train_party", "pt_kingdom_hero_party"),
            (party_set_faction, ":party_no", "fac_commoners"),
          (else_try),
            (this_or_next|eq, ":party_type", "pt_looters"),
            (this_or_next|eq, ":party_type", "pt_looter_lair"),
            (this_or_next|eq, ":party_type", "pt_taiga_bandits"),
            (this_or_next|eq, ":party_type", "pt_taiga_bandit_lair"),
            (this_or_next|eq, ":party_type", "pt_desert_bandits"),
            (this_or_next|eq, ":party_type", "pt_desert_bandit_lair"),
            (this_or_next|eq, ":party_type", "pt_mountain_bandits"),
            (this_or_next|eq, ":party_type", "pt_mountain_bandit_lair"),
            (this_or_next|eq, ":party_type", "pt_sea_raiders"),
            (this_or_next|eq, ":party_type", "pt_sea_raider_lair"),
            (this_or_next|eq, ":party_type", "pt_fianna"),
            (this_or_next|eq, ":party_type", "pt_frank_looters_1"),
            (this_or_next|eq, ":party_type", "pt_frank_looters_2"),
            (this_or_next|eq, ":party_type", "pt_troublesome_bandits"),
            (this_or_next|eq, ":party_type", "pt_raider_party"),
            (this_or_next|eq, ":party_type", "pt_leaded_looters"),
            (this_or_next|eq, ":party_type", "pt_sea_raiders_ships"),
            (eq, ":party_type", "pt_sea_raiders_ships6"),
            (party_set_faction, ":party_no", "fac_outlaws"),
          (else_try),
            (eq, ":party_type", "pt_manhunters"),
            (party_set_faction, ":party_no", "fac_manhunters"),
          (else_try),
            (this_or_next|eq, ":party_type", "pt_steppe_bandits"),
            (this_or_next|eq, ":party_type", "pt_steppe_bandit_lair"),
            (this_or_next|eq, ":party_type", "pt_sea_raiders2"),
            (this_or_next|eq, ":party_type", "pt_sea_raider_lair2"),
            (is_between, ":party_type", "pt_sea_raiders_ships2", "pt_sea_raiders_ships6"),
            (party_set_faction, ":party_no", "fac_mountain_bandits"),
          (else_try),
            (this_or_next|eq, ":party_type", "pt_forest_bandits"),
            (this_or_next|eq, ":party_type", "pt_forest_bandit_lair"),
            (eq, ":party_type", "pt_ambushers"),
            (party_set_faction, ":party_no", "fac_forest_bandits"),
          (else_try),
            (eq, ":party_type", "pt_deserters"),
            (party_set_faction, ":party_no", "fac_deserters"),
          (else_try),
            (eq, ":party_type", "pt_sacerdotes_party"),
            (party_set_faction, ":party_no", "fac_christians"),
          (else_try),
            (eq, ":party_type", "pt_paganos_party"),
            (party_set_faction, ":party_no", "fac_pagans"),
          (else_try),
            (this_or_next|eq, ":party_type", "pt_chimney_smoke"),
            (this_or_next|eq, ":party_type", "pt_ferry_port"),
            (eq, ":party_type", "pt_jetty_port"),
            (party_set_faction, ":party_no", "fac_no_faction"),
          (else_try),
            (is_between, ":party_type", "pt_sven_doccinga_ca", "pt_wessex_foragers"),
            (party_set_faction, ":party_no", "fac_dark_knights"),
          (else_try),
            (eq, ":party_type", "pt_wessex_patrol"),
            (party_set_faction, ":party_no", "fac_kingdom_5"),
          (else_try),
            (eq, ":party_type", "pt_adv_party"),
            (party_set_faction, ":party_no", "fac_adventurers"),
          (try_end),
        (try_end),
        (jump_to_menu, "mnu_auto_return_to_map"),
        ]
      ),
      ("choice_no",[],"No, I will look for a game saved before v2.049.", [
        (change_screen_quit),
        ]
      ),
    ]
  ),

]
