# -*- coding: utf-8 -*- from header_common import * from header_operations import * from module_constants import * from header_parties import * from header_skills import * from header_mission_templates import * from header_items import * from header_triggers import * from header_terrain_types import * from header_music import * from ID_animations import * from ID_troops import * from ID_factions import * from module_troops import * from module_scripts_ai import * from module_scripts_form import * from module_scripts_form_v5 import * from module_scripts_morale import * from module_scripts_common_warp import * from header_presentations import * from module_info import wb_compile_switch as is_a_wb_script from module_items import * #################################################################################################################### # scripts is a list of script records. # Each script record contns the following two fields: # 1) Script id: The prefix "script_" will be inserted when referencing scripts. # 2) Operation block: This must be a valid operation block. See header_operations.py for reference. #################################################################################################################### ### a crude code to insert an increasing number (mtarini) ___val = 0 def next_count(): global ___val ___val=___val+1 return ___val def first_count(): global ___val ___val=0 return ___val def curr_count(): global ___val return ___val ### TLD item factionization, with subfactions (mtarini, GA) # swy: note: start_game_1 calls script_set_item_faction, which embeds the thousands operations generated here at build-time, so this runs whenever we click on the new game button def set_item_faction(): command_list = [] for i_troop in xrange(trp_i1_woodmen_man, trp_end_leaders): #regular troops here # swy: (1) iterate from i1_woodmen_man (29th troop in the list, count starts at zero) to end_leaders (430), for each of these troops... # mtarini: store all flags in a slot, for later use command_list.append((troop_set_slot, i_troop, slot_troop_flags, troops[i_troop][3])) # swy: \-> mirror each troop's flags into an accessible slot, so that we can retrieve them during the game, only for the range of regular soldier troops above, not heroes or special stuff for i_troop in xrange(trp_i1_woodmen_man, trp_elder_ironhill): #all troops # swy: (2) iterate from i1_woodmen_man (29th) to trp_elder_ironhill (823th), originally probably trp_merchants_end #GA assign troops to proper subfactions acc to troops[i_troop][5] troopsub = troops[i_troop][5] # swy: \-> the 5th element of each troop is normally reserved, on TLD it may store the subfac_ number which also gets mirrored by setting a troop slot here, otherwise is zero, and no slot_troop_subfaction is set if troopsub > 0: command_list.append((troop_set_slot, i_troop, slot_troop_subfaction, troopsub)) for i_item in xrange(itm_sumpter_horse, itm_free_far_harad_shield_paint): #regular items here # swy: (3) iterate from itm_sumpter_horse (23th) to itm_free_far_harad_shield_paint (826th), for each of these items... faction = 0 sfaction = 0 for i_troop in xrange(trp_i1_woodmen_man, trp_end_leaders): # search items inside troop inventory # swy: \-> iterate from i1_woodmen_man (29th) to to end_leaders (430), for each of those troops... if i_item in troops[i_troop][7]: # swy: if a regular troop has the current item in their inventory... faction = faction | (1 << troops[i_troop][6]) # swy: a) convert the faction number into flag toggles, storing/appending all the possible factions where a normal troop uses this item in their inventory, all together in the same bitfield troopsub = troops[i_troop][5] # swy: b) grab the current troops sub-faction field (the 5th/reserved one above) if troopsub > 0: sfaction = sfaction | (1 << troops[i_troop][5]) # swy: if it has a sub-faction number, append it to the bit-field in the same way, toggling only the right bits if faction > 0: command_list.append((item_set_slot, i_item, slot_item_faction, faction)) # swy: \-> we have finished checking out the troops that may reference this item; in these two remaining lines we only generate an item_set_slot operation if we need it, setting its corresponding has slot_item_faction / slot_item_subfaction if sfaction > 0: command_list.append((item_set_slot, i_item, slot_item_subfaction, sfaction)) return command_list [:] companionPriceMult = 100 # this is used to multiply old hiring praces for companions (in res point) to new prices (in influence) - MV: nerfed down to 50, was 20 - another nerf, Glorfindel now 50, others reasonable def set_item_score(): item_score = [] for i_item in xrange(len(items)): # ## weight # item_score.append((item_set_slot, i_item, slot_item_weight, get_hrd_weight(items[i_item][6]))) # ## difficulty # item_score.append((item_set_slot, i_item, slot_item_difficulty, get_difficulty(items[i_item][6]))) # ## two hand/one hand # type = items[i_item][3] & 0x000000ff # if type == itp_type_two_handed_wpn and items[i_item][3] & itp_two_handed == 0: # item_score.append((item_set_slot, i_item, slot_item_two_hand_one_hand, 1)) ## needs two hands item_score.append((item_set_slot, i_item, slot_item_needs_two_hands, items[i_item][3] & itp_two_handed)) # ## cant on horseback # if items[i_item][3] & itp_cant_use_on_horseback == itp_cant_use_on_horseback: # item_score.append((item_set_slot, i_item, slot_item_cant_on_horseback, 1)) # ## couchable - CABA addition if items[i_item][3] & itp_couchable == itp_couchable: item_score.append((item_set_slot, i_item, slot_item_couchable, 1)) type = items[i_item][3] & 0x000000ff if type == itp_type_shield: item_score.append((item_set_slot, i_item, slot_item_length, get_weapon_length(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_body_armor, get_body_armor(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_speed, get_speed_rating(items[i_item][6]))) elif type == itp_type_bow or type == itp_type_crossbow: item_score.append((item_set_slot, i_item, slot_item_thrust_damage, get_thrust_damage(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_swing_damage, get_swing_damage(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_speed, get_speed_rating(items[i_item][6]))) elif type >= itp_type_one_handed_wpn and type <= itp_type_thrown: item_score.append((item_set_slot, i_item, slot_item_thrust_damage, get_thrust_damage(items[i_item][6])&0xff)) item_score.append((item_set_slot, i_item, slot_item_swing_damage, get_swing_damage(items[i_item][6])&0xff)) item_score.append((item_set_slot, i_item, slot_item_speed, get_speed_rating(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_length, get_weapon_length(items[i_item][6]))) elif type >= itp_type_head_armor and type <= itp_type_hand_armor: item_score.append((item_set_slot, i_item, slot_item_head_armor, get_head_armor(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_body_armor, get_body_armor(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_leg_armor, get_leg_armor(items[i_item][6]))) elif type == itp_type_horse: item_score.append((item_set_slot, i_item, slot_item_horse_speed, get_missile_speed(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_horse_armor, get_body_armor(items[i_item][6]))) item_score.append((item_set_slot, i_item, slot_item_horse_charge, get_thrust_damage(items[i_item][6]))) ## pike definition - CABA addition if type == itp_type_polearm and get_weapon_length(items[i_item][6]) >= 150 and (get_thrust_damage(items[i_item][6]) % 256) > (get_swing_damage(items[i_item][6]) % 256): item_score.append((item_set_slot, i_item, slot_item_pike, 1)) return item_score[:] scripts = [ ("troop_get_cheer_sound", [ (store_script_param_1, ":trp"), (troop_get_type, ":race",":trp"), (try_begin),(eq,":race",0x0),(assign,reg1,"snd_man_victory"), (else_try), (eq,":race",0x1),(assign,reg1,"snd_woman_yell"), # woman (else_try), (eq,":race",0x2),(assign,reg1,"snd_gondor_victory_player"), (else_try), (eq,":race",0x3),(assign,reg1,"snd_rohan_victory"), (else_try), (eq,":race",0x4),(assign,reg1,"snd_dunlender_victory"), (else_try), (eq,":race",0x5),(assign,reg1,"snd_orc_victory"), (else_try), (eq,":race",0x6),(assign,reg1,"snd_uruk_victory"), (else_try), (eq,":race",0x7),(assign,reg1,"snd_uruk_victory"), (else_try), (eq,":race",0x8),(assign,reg1,"snd_haradrim_victory"), (else_try), (eq,":race",0x9),(assign,reg1,"snd_man_victory"), # dwarf (else_try), (eq,":race",0xA),(assign,reg1,"snd_troll_victory"), (else_try), (eq,":race",0xB),(assign,reg1,"snd_dunedain_victory_player"), (else_try), (eq,":race",0xC),(assign,reg1,"snd_mirkwood_victory_player"), (else_try), (eq,":race",0xD),(assign,reg1,"snd_mirkwood_victory_player"), (else_try), (eq,":race",0xE),(assign,reg1,"snd_mirkwood_victory_player"), (else_try), (eq,":race",0xF),(assign,reg1,"snd_man_victory"), # Khand + Rhun + Easterling (else_try),(assign,reg1,"snd_man_victory"), (try_end), ]), ############################# TLD player icon (mtarini) # script_init_player_map_icons ("init_player_map_icons",[ # defaults (assign, "$g_player_icon_mounted", "icon_player_horseman"), (assign, "$g_player_icon_foot_melee", "icon_player"), (assign, "$g_player_icon_foot_archer","icon_player"), (assign, ":fac","$players_kingdom"), (troop_get_type, ":race","$g_player_troop"), (assign, ":subfac","$players_subkingdom"), (assign, ":subfac","$players_subkingdom"), (try_begin), (eq,0,1), ]+concatenate_scripts([ (else_try), (eq, ":fac", faction_player_icons[y][0]), (assign, "$g_player_icon_mounted", faction_player_icons[y][1]), (assign, "$g_player_icon_foot_melee", faction_player_icons[y][2]), (assign, "$g_player_icon_foot_archer",faction_player_icons[y][3]), ]for y in range(len(faction_player_icons)) ) +[ (try_end), # overrite choice for gondor subfaction (try_begin),(eq, ":fac", "fac_gondor"), (try_begin), (eq,0,1), ]+concatenate_scripts([ (else_try), (eq, ":subfac", subfaction_gondor_player_icons[y][0]), (assign, "$g_player_icon_mounted", subfaction_gondor_player_icons[y][1]), (assign, "$g_player_icon_foot_melee", subfaction_gondor_player_icons[y][2]), (assign, "$g_player_icon_foot_archer",subfaction_gondor_player_icons[y][3]), ]for y in range(len(subfaction_gondor_player_icons)) ) +[ (try_end), (try_end), # fix mordor and isengard NON orcs (try_begin), (neg|is_between, ":race", tf_orc_begin, tf_orc_end), (try_begin), (this_or_next|eq, ":fac", "fac_mordor"), (eq, ":fac", "fac_guldur"), (assign, "$g_player_icon_mounted", "icon_mordor_captain"), (assign, "$g_player_icon_foot_melee", "icon_player"), (assign, "$g_player_icon_foot_archer","icon_player"), (try_end), (try_begin), (eq, ":fac", "fac_isengard"), (assign, "$g_player_icon_mounted", "icon_isengard_captain"), (assign, "$g_player_icon_foot_melee", "icon_player"), (assign, "$g_player_icon_foot_archer","icon_player"), (try_end), (try_end), # fix mordor and isengard orcs NON uruk (non mounted only) (try_begin), (eq, ":race", tf_orc), (try_begin), (eq, ":fac", "fac_mordor"), (assign, "$g_player_icon_foot_melee", "icon_orc"), (assign, "$g_player_icon_foot_archer","icon_orc"), (try_end), (try_begin), (eq, ":fac", "fac_isengard"), (assign, "$g_player_icon_foot_melee", "icon_orc_isengard"), (assign, "$g_player_icon_foot_archer","icon_orc_isengard"), (try_end), (try_end), ]), # script_determine_what_player_looks_like # no input. Call me when player can have changed look (mtarini) ("determine_what_player_looks_like", [ (troop_get_type, ":race","$g_player_troop"), (try_begin), (is_between, ":race", tf_orc_begin, tf_orc_end), (assign, "$player_looks_like_an_orc",1), (else_try), (assign, "$player_looks_like_an_orc",0), (try_end), ] + (is_a_wb_script==1 and [ # swy-- at this point should be safe to set the correct good/evil UI skin on Warband; keep in mind that $players_kingdom # gets first set when script_player_join_faction gets called by script_start_as_one in one of the previous menus. (call_script, "script_tld_internal_set_good_or_evil_ui"), ] or []) + [ ]), ############################# TLD PLAYER REWARD SYSTEM --- SCRIPTS (mtarini) #############################?# # script_player_meets_party # PlayerRewardSystem: call this when enetring a city, or meeting a party, so that player's "gold" will update (mtarini) # param1: encountered party ("player_meets_party",[ #MV: old code: didn't work too well, should have detected "territory", not opposing party faction # (try_begin), # (store_script_param_1, ":party"), # (store_faction_of_party, ":fac", ":party"), # (is_between, ":fac", kingdoms_begin, kingdoms_end), # (neq, "$ambient_faction", ":fac"), # no need to swap anything, already right # (store_relation, reg0, "fac_player_faction", ":fac"), # (ge, reg0, 0), # only with non-enemies # (call_script, "script_set_ambient_faction", ":fac"), # (try_end), (store_script_param_1, ":party"), (assign, ":closest_faction", -1), (try_begin), # check if visiting a friendly town, to optimize code (is_between, ":party", centers_begin, centers_end), (store_faction_of_party, ":center_faction", ":party"), (store_relation, ":relation", ":center_faction", "$players_kingdom"), (ge, ":relation", 0), (assign, ":closest_faction", ":center_faction"), (else_try), # find closest friendly active center to determine in whose "territory" is the main party (assign, ":mindist", 100000), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), (party_slot_eq, ":center_no", slot_center_destroyed, 0), #TLD - not destroyed (store_faction_of_party, ":center_faction", ":center_no"), (store_relation, ":relation", ":center_faction", "$players_kingdom"), (ge, ":relation", 0), # friendly center found (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"), (lt, ":dist", ":mindist"), (assign, ":mindist", ":dist"), (assign, ":closest_faction", ":center_faction"), (try_end), (try_begin), (eq, ":closest_faction", -1), #all friendly factions defeated, the player is his own faction :) (assign, ":closest_faction", "$players_kingdom"), (try_end), (try_end), (try_begin), (neq, "$ambient_faction", ":closest_faction"), # no need to swap anything, already right (call_script, "script_set_ambient_faction", ":closest_faction"), (try_end), ]), # script_add_faction_rps # PlayerRewardSystem: adds / removes (if neg) some respoints (parameter2) to a given faction (parameter1) (mtarini) # messes up s0, reg0 ("add_faction_rps",[ (store_script_param_1, ":fac"), (store_script_param_2, ":diff"), (store_mul, ":diff_neg", ":diff", -1), # diff = - diff (try_begin), (eq, "$ambient_faction", ":fac"), # just rise player gold (set_show_messages, 0), (try_begin), (gt, ":diff", 0), (troop_add_gold, "$g_player_troop", ":diff"), (else_try), (troop_remove_gold, "$g_player_troop", ":diff_neg"), (try_end), (set_show_messages, 1), (try_end), # rise res. points of that faction (faction_get_slot, ":rp", ":fac", slot_faction_respoint), (store_add,":rp",":rp",":diff"), (faction_set_slot, ":fac", slot_faction_respoint, ":rp"), # mordor and guldur common currency (try_begin), (eq, ":fac", "fac_mordor"), (faction_set_slot, "fac_guldur", slot_faction_respoint, ":rp"), (try_end), (try_begin), (eq, ":fac", "fac_guldur"), (faction_set_slot, "fac_mordor", slot_faction_respoint, ":rp"), (try_end), (str_store_faction_name, s0, ":fac"), (try_begin),(gt, ":diff", 0), (assign, reg0, ":diff"), (display_message, "@You gained {reg0} Resource Points of {s0}."), (else_try),(gt, ":diff_neg", 0), (assign, reg0, ":diff_neg"), (display_message, "@You lost {reg0} Resource Points of {s0}."), (try_end), ]), # script_update_respoint # PlayerRewardSystem, update_respoint script: makes sure that respoints of active faction reflect current "gold"(no params) (mtarini) ("update_respoint",[ (store_troop_gold, ":cur_gold", "$g_player_troop"), (faction_set_slot, "$ambient_faction", slot_faction_respoint, ":cur_gold"), (try_begin),(eq, "$ambient_faction", "fac_mordor"), (faction_set_slot, "fac_guldur", slot_faction_respoint, ":cur_gold"),(try_end), # mordor and guldur common currency (try_begin),(eq, "$ambient_faction", "fac_guldur"), (faction_set_slot, "fac_mordor", slot_faction_respoint, ":cur_gold"),(try_end), ]), # script_reward_system_init # PlayerRewardSystem: init (mtarini) ("reward_system_init",[ (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (try_begin), (eq,"$players_kingdom", ":fac"), (store_troop_gold, ":gold_player", "$g_player_troop"), (faction_set_slot, ":fac", slot_faction_influence, 1), (faction_set_slot, ":fac", slot_faction_rank , 50), (faction_set_slot, ":fac", slot_faction_respoint , ":gold_player"), (assign, "$ambient_faction", ":fac"), (else_try), (faction_set_slot, ":fac", slot_faction_influence, 0), (faction_set_slot, ":fac", slot_faction_rank , 0), (faction_set_slot, ":fac", slot_faction_respoint , 0), (try_end), (try_end), #(str_store_faction_name,s3,"$players_kingdom"),(store_troop_gold, reg3, "$g_player_troop"), #(display_message, "@debug: player has faction '{s3}' and {reg3} gold"), #]+concatenate_scripts([ # (store_set_slot, faction_init[y][0], slot_faction_influence, 0), # (store_set_slot, faction_init[y][0], slot_faction_rank, 0), # (store_set_slot, faction_init[y][0], slot_faction_respoint, 0), #]for y in range(len(faction_init)) ) +[ ]), # script_set_ambient_faction # PlayerRewardSystem, script: stores current gold to appropriate faction's respoint, and resoruce point of a parameter faction to current gold (mtarini) # param1: new current faction ("set_ambient_faction",[ (try_begin), (store_script_param_1, ":fac"), (store_troop_gold, ":old_gold", "$g_player_troop"), (faction_get_slot, ":new_gold", ":fac", slot_faction_respoint), (faction_set_slot, "$ambient_faction", slot_faction_respoint, ":old_gold"), (neq, "$ambient_faction", ":fac"), # no need to swap, already right (assign, "$ambient_faction", ":fac"), (set_show_messages, 0), (try_begin), (gt, ":old_gold", ":new_gold"), (store_sub, ":diff", ":old_gold", ":new_gold"), (troop_remove_gold, "$g_player_troop", ":diff"), (else_try), (store_sub, ":diff", ":new_gold", ":old_gold"), (troop_add_gold, "$g_player_troop", ":diff"), (try_end), (set_show_messages, 1), #(str_store_faction_name, s10, "$ambient_faction"), #(display_message, "@info: now using Resource Pts. of {s10}." ), (try_end), ]), # script_rank_income_to_player # PlayerRewardSystem: rank_income (mtarini) # gives to player the income of his rank # messes up s24 ("rank_income_to_player",[ (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":fac", slot_faction_state, sfs_active), #MV fix: dead factions don't pay you # Allows us modders to cap the resource points income. (CppCoder) (faction_get_slot, ":total_rp", ":fac", slot_faction_respoint), (this_or_next|eq, tld_rp_cap, -1), (lt, ":total_rp", tld_rp_cap), (call_script, "script_get_faction_rank", ":fac"), (assign, ":rank", reg0), (gt, ":rank", 0), (call_script, "script_get_rank_title_to_s24", ":fac"), (neq, "$g_fast_mode", 1), #InVain: no income during fast mode (display_message, "@{s24}:"), (store_mul, ":income", ":rank", ":rank"), (store_mul, ":rank10", ":rank", 10), (val_mul, ":income", 5), # ( rank^2 *5 +rank * 10) = 0, 15 , 30, 55, 90 , 135, 190, 255, ... per day. (val_add, ":income", ":rank10"), (call_script, "script_add_faction_rps", ":fac", ":income"), (try_end), ]), # script_get_own_rank_title_to_s24 # PlayerRewardSystem, script: stores in s24 title of home faction rank # param1: faction # param2: rank # param3: career variant (e.g. ranger vs knight) TODO # output: string 24 ("get_own_rank_title_to_s24",[ (store_script_param_1, ":faction"), (store_script_param_2, ":rank"), (val_clamp, ":rank", 0, 10), (store_sub, ":string", ":faction", kingdoms_begin), (val_mul, ":string", 10), #10 ranks (val_add, ":string", ":rank"), (val_add, ":string", "str_gondor_rank_0"), (str_store_string, s24, ":string"), ]), # script_get_allied_rank_title_to_s24 # PlayerRewardSystem, script: stores in s24 title of a faction, rank, career (mtarini) # param1: faction # param2: rank # output: string 24 # messes up s5 ("get_allied_rank_title_to_s24",[ (store_script_param_1, ":fac"), (store_script_param_2, ":rank"), (str_store_faction_name, s5, ":fac"), (try_begin), (faction_slot_eq, ":fac", slot_faction_side, faction_side_good), (try_begin),(ge, ":rank", 9),(str_store_string, s24, "@Great Hope of {s5}"), (else_try),(eq, ":rank", 8),(str_store_string, s24, "@Hope of {s5}"), (else_try),(eq, ":rank", 7),(str_store_string, s24, "@Indispensable Ally of {s5}"), (else_try),(eq, ":rank", 6),(str_store_string, s24, "@Faithful Ally of {s5}"), (else_try),(eq, ":rank", 5),(str_store_string, s24, "@Trusted Friend of {s5}"), (else_try),(eq, ":rank", 4),(str_store_string, s24, "@Close Friend of {s5}"), (else_try),(eq, ":rank", 3),(str_store_string, s24, "@Friend of {s5}"), (else_try),(eq, ":rank", 2),(str_store_string, s24, "@Familiar to {s5}"), (else_try),(eq, ":rank", 1),(str_store_string, s24, "@Known to {s5}"), (else_try), (str_store_string, s24, "@Stranger to {s5}"), (try_end), (else_try), (try_begin),(ge, ":rank", 9),(str_store_string, s24, "@Great Enforcer of {s5}"), (else_try),(eq, ":rank", 8),(str_store_string, s24, "@Enforcer of {s5}"), (else_try),(eq, ":rank", 7),(str_store_string, s24, "@Important Ally of {s5}"), (else_try),(eq, ":rank", 6),(str_store_string, s24, "@Ally of {s5}"), (else_try),(eq, ":rank", 5),(str_store_string, s24, "@Accomplice of {s5}"), (else_try),(eq, ":rank", 4),(str_store_string, s24, "@Useful Tool of {s5}"), (else_try),(eq, ":rank", 3),(str_store_string, s24, "@Servant of {s5}"), (else_try),(eq, ":rank", 2),(str_store_string, s24, "@Familiar to {s5}"), (else_try),(eq, ":rank", 1),(str_store_string, s24, "@Known to {s5}"), (else_try), (str_store_string, s24, "@Unknown to {s5}"), (try_end), (try_end), ]), # script_get_rank_title_to_s24 ("get_rank_title_to_s24",[ (store_script_param_1, ":faction"), (call_script, "script_get_faction_rank", ":faction"), (assign, ":rank", reg0), (call_script, "script_get_any_rank_title_to_s24", ":faction", ":rank"), ]), # script_get_any_rank_title_to_s24 ("get_any_rank_title_to_s24",[ (store_script_param_1, ":faction"), (store_script_param_2, ":rank"), (try_begin), (eq, ":faction", "$players_kingdom"), (call_script, "script_get_own_rank_title_to_s24", ":faction", ":rank"), (else_try), (call_script, "script_get_allied_rank_title_to_s24", ":faction", ":rank"), (try_end), ]), # script_new_rank_attained # messes up s10 ("new_rank_attained", [ (store_script_param_1, ":fac"), (store_script_param_2, ":rank"), (store_script_param, ":is_promoted", 3), #swy-- play a different sound depending on the allegiance of the player (try_begin), (neg|faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (play_sound, "snd_new_rank_evil"), (else_try), (play_sound, "snd_new_rank_good"), (try_end), (call_script, "script_get_rank_title_to_s24", ":fac"), (str_store_troop_name, s10, "trp_player"), (assign, reg0, ":rank"), (assign, reg1, ":is_promoted"), (assign, ":news_color", color_bad_news), (try_begin), (eq, ":is_promoted", 1), (assign, ":news_color", color_good_news), (try_end), (display_message, "@You have been {reg1?promoted:demoted} to {s24} ({reg0})!", ":news_color"), ]), # script_increase_rank # difference can be a negative value # messes up s11 ("increase_rank", [ (store_script_param_1, ":fac"),# gain rank (need rank points to advance) (store_script_param_2, ":difference"), (try_begin), (is_between, ":fac", kingdoms_begin, kingdoms_end), (neq, ":difference", 0), (call_script, "script_get_faction_rank", ":fac"), (assign, ":old_rank", reg0), (faction_get_slot, ":val", ":fac", slot_faction_rank), #swy-- uninitialized globals default to zero, # -- take advantage of this by adding one to get the saved multiplier: # -- 0 = x1 | 1 = x2 | 2 = x3 | 3 = x4 (store_add, ":rank_multiplier", "$tld_option_rank_gain_rate", 1), (val_mul, ":difference", ":rank_multiplier"), #swy-- (try_begin), #InVain: Home faction bonus (eq, "$players_kingdom", ":fac"), (gt, ":difference", 0), (val_mul, ":difference", 120), (val_div, ":difference", 100), #(display_message, "@home faction bonus"), (try_end), #InVain: Charisma bonus (store_attribute_level, ":player_charisma", trp_player, ca_charisma), (val_mul, ":difference", 100), (val_mul, ":difference", ":player_charisma"), (val_div, ":difference", 1200), #starts to scale from 12, reduces below (val_max, ":difference", 1), (val_add, ":val", ":difference"), (ge, ":val", 0), #no negative rank points (faction_set_slot, ":fac", slot_faction_rank, ":val"), (call_script, "script_get_faction_rank", ":fac"), (assign, ":new_rank", reg0), # gain influence = 1/8 rank points gain (rounded) Was 1/10 (faction_get_slot, ":val", ":fac", slot_faction_influence), (store_add, ":inf_dif", ":difference", 8/2), (val_div, ":inf_dif", 8), #swy-- uninitialized globals default to zero, # -- take advantage of this by adding one to get the saved multiplier: # -- 0 = x1 | 1 = x2 | 2 = x3 | 3 = x4 (store_add, ":inf_multiplier", "$tld_option_influence_gain_rate", 1), (val_mul, ":inf_dif", ":inf_multiplier"), #swy-- (val_add, ":val", ":inf_dif"), (faction_set_slot, ":fac", slot_faction_influence, ":val"), # display message # (store_mod, reg10, ":difference", 100),(store_div, reg11, ":difference", 100), # (try_begin), (lt, reg10, 10), (str_store_string, s10, "@.0"), (else_try), (str_store_string, s10, "@."), (try_end), (str_store_faction_name, s11, ":fac"), (assign, reg11, ":difference"), (assign, reg12, ":inf_dif"), (assign, reg1, 1), (assign, ":news_color", color_good_news), (try_begin), (lt, reg11, 0), (val_abs, reg11), (val_abs, reg12), (assign, reg1, 0), (assign, ":news_color", color_bad_news), (try_end), # (display_message, "@{reg1?Earned:Lost} {reg12} influence with {s11}.", ":news_color"), # MV: why do this?? (try_begin), #InVain: Home faction bonus (eq, "$players_kingdom", ":fac"), (neq, ":difference", 0), (display_message, "@You {reg1?earned:lost} {reg11} rank points {reg12?and {reg12} influence :}with your home faction {s11}.", ":news_color"), (else_try), (neq, ":difference", 0), (display_message, "@You {reg1?earned:lost} {reg11} rank points {reg12?and {reg12} influence :}with {s11}.", ":news_color"), (try_end), # rank increased? (try_begin), (neq, ":old_rank", ":new_rank"), (call_script, "script_new_rank_attained", ":fac", ":new_rank", reg1), (try_end), (try_end), ]), # script_get_faction_rank # converts rank points to rank number # input: faction # output: reg0 = rank 0-9 or higher ("get_faction_rank", [ (store_script_param_1, ":faction"), (faction_get_slot, ":rank_points", ":faction", slot_faction_rank), # current formula rank points (rank) = Ax^2 + Bx (assign, ":A", 5), (assign, ":B", 45), # rank = (sqrt(B*B+4*A*rp)-B)/(2*A) (store_mul, ":AC4", ":rank_points", 4), (val_mul, ":AC4", ":A"), (store_mul, ":rank", ":B", ":B"), (val_add, ":rank", ":AC4"), (convert_to_fixed_point, ":rank"), (store_sqrt, ":rank", ":rank"), (convert_from_fixed_point, ":rank"), (val_sub, ":rank", ":B"), (val_div, ":rank", 2), (val_div, ":rank", ":A"), (assign, reg0, ":rank"), ]), # script_get_rank_points_for_rank # converts rank number to rank points # input: rank 0-9 or higher # output: reg0 = rank points needed ("get_rank_points_for_rank", [ (store_script_param_1, ":rank"), # current formula rank points (rank) = Ax^2 + Bx (assign, ":A", 5), (assign, ":B", 45), (store_mul, ":ranksquared", ":rank", ":rank"), (store_mul, ":rank_points", ":ranksquared", ":A"), (store_mul, ":Bx", ":rank", ":B"), (val_add, ":rank_points", ":Bx"), (assign, reg0, ":rank_points"), ]), # script_find_closest_enemy_town_or_host # input: faction f, party x # output: reg0 = closest party to x enemy of f, but friend of player, reg1 = its distance ("find_closest_enemy_town_or_host",[ (store_script_param, ":fac", 1), (store_script_param, ":target", 2), (assign, ":mindist", 100000), (assign, ":res", -1), (try_for_parties, ":party"), (party_is_active, ":party"), (party_slot_eq, ":party", slot_center_destroyed, 0), # TLD (this_or_next|party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), # its a host (this_or_next|party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_alone), # or a lone hero (is_between, ":party", centers_begin, centers_end), #or a town (store_faction_of_party, ":pfac", ":party"), (store_relation, ":relation", ":pfac", ":fac"), (lt, ":relation", 0), # it's an enemy... (store_relation, ":relation", ":pfac", "$players_kingdom"), (ge, ":relation", 0), # and it's your friend (store_distance_to_party_from_party, ":dist", ":party", ":target"), (lt, ":dist", ":mindist"), (assign, ":mindist", ":dist"), (assign, ":res", ":party"), (try_end), (assign, reg0, ":res"), (assign, reg1, ":dist"), ]), #script_spend_influence_of ("spend_influence_of",[ (store_script_param_1, ":price"), (store_script_param_2, ":fac"), (faction_get_slot, ":influence", ":fac", slot_faction_influence), (val_sub, ":influence", ":price"), (faction_set_slot, ":fac", slot_faction_influence, ":influence"), (str_store_faction_name, s1, ":fac"), (assign, reg10, ":price"), (assign, reg11, ":influence"), (display_message, "@You spent {reg10} of your influence with {s1}, with {reg11} remaining.") ]), # script_game_get_join_cost # This script is called from the game engine for calculating troop join cost. # Input: param1: troop_id, # Output: reg0: join cost ("game_get_join_cost", [ (store_script_param_1, ":troop_id"), (store_character_level, ":troop_level", ":troop_id"), (party_get_slot, ":relation", "$current_town", slot_center_player_relation), (call_script, "script_game_get_troop_wage", ":troop_id",0), (store_mul, ":join_cost", reg0, ":troop_level"), # join cost: Wage*troop level: Higher level troops are expensive to recruit #(val_mul, ":join_cost", 2), (val_div, ":join_cost", 2), (store_sub, ":relation_mod", 120, ":relation"), (val_mul, ":join_cost", ":relation_mod"), (val_div, ":join_cost", 100), # trait discounts: 75% of the original price (store_troop_faction, ":troop_faction", ":troop_id"), (assign, ":apply_discount", 0), (try_begin), (eq, ":troop_faction", "fac_gondor"), (troop_slot_eq, "trp_traits", slot_trait_gondor_friend, 1), (assign, ":apply_discount", 1), (try_end), (try_begin), (eq, ":troop_faction", "fac_rohan"), (troop_slot_eq, "trp_traits", slot_trait_rohan_friend, 1), (assign, ":apply_discount", 1), (try_end), (try_begin), (this_or_next|eq, ":troop_faction", "fac_lorien"), (this_or_next|eq, ":troop_faction", "fac_imladris"), (eq, ":troop_faction", "fac_woodelf"), (troop_slot_eq, "trp_traits", slot_trait_elf_friend, 1), (assign, ":apply_discount", 1), (try_end), (try_begin), (this_or_next|eq, ":troop_faction", "fac_harad"), (this_or_next|eq, ":troop_faction", "fac_rhun"), (eq, ":troop_faction", "fac_khand"), (troop_slot_eq, "trp_traits", slot_trait_brigand_friend, 1), (assign, ":apply_discount", 1), (try_end), (try_begin), (eq, ":apply_discount", 1), (val_mul, ":join_cost", 3), (val_div, ":join_cost", 4), (try_end), (try_begin), (eq, ":troop_id", "trp_volunteers"), (set_trigger_result, -1), (else_try), (assign, reg0, ":join_cost"), (set_trigger_result, reg0), (try_end), ]), # script_get_troop_disband_cost # Call this script to know how much the player earns if he sends this troop home (mtarini) # Input: param1: troop_id, # Input: param2: 0 = auto, 1 = perfect helath 2 = wounded # Input: param3: 0 = sent home from map, 1 = given to city, 2 = given to host # Output: reg0: leave cost ("get_troop_disband_cost", [ (store_script_param_1, ":troop_id"), (store_script_param_2, ":opt"), (store_script_param, ":origin", 3), # determine if troop is wounded (assign, ":wounded",0), (try_begin),(eq,":opt",0), # auto check if wounded (try_begin), (call_script, "script_cf_is_troop_in_party_wounded", ":troop_id", "p_main_party"), (assign, ":wounded",1), (try_end), (else_try), (eq,":opt",2), # assume it is wounded (assign, ":wounded",1), (try_end), (assign, ":perc", 40), # base: 80 percent #InVain: Halved all values, because script_game_get_join_cost changed to exponential growth (with troop level) (try_begin),(eq,":origin",0), (assign, ":perc", 25), (try_end), # from map: 70% (try_begin),(eq,":origin",1), (assign, ":perc", 35), (try_end), # to city garrison: 80% (try_begin),(eq,":origin",2), (assign, ":perc", 40), (try_end), # to war party: 90% (try_begin),(eq,":wounded",1),(val_sub,":perc", 15), (try_end), # if wounded: -30% (call_script, "script_game_get_join_cost", ":troop_id"), (val_mul, reg0, ":perc"), (val_div, reg0, 100), # when this troop leaves, you gain $ join_cost * perc/100 ]), # script_get_party_disband_cost # Call this script to know how much the player earns if this entire party is disbanded (mtarini) # Input: param1: party_id, # Input: param2: 0 = sent home from map, 1 = given to city 2 = given to host # Output: reg0: leave cost of party ("get_party_disband_cost", [ (store_script_param_1, ":party_id"), (store_script_param_2, ":origin"), (party_get_num_companion_stacks, ":num_stacks", ":party_id"), (assign, ":tot", 0), (try_for_range, ":i", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_id", ":i"), (party_stack_get_size, ":n_ok", ":party_id", ":i"), (party_stack_get_num_wounded, ":n_wounded", ":party_id", ":i"), (val_sub, ":n_ok", ":n_wounded"), (call_script, "script_get_troop_disband_cost", ":stack_troop",1,":origin"), (val_mul, reg0, ":n_ok"), (val_add, ":tot", reg0), (call_script, "script_get_troop_disband_cost", ":stack_troop",2,":origin"), (val_mul, reg0, ":n_wounded"), (val_add, ":tot", reg0), (try_end), (assign, reg0, ":tot"), ]), # script_game_get_troop_wage # This script is called from the game engine for calculating troop wages. (mod by mtarini) # Input: param1: troop_id, param2: party-id # Output: reg0: weekly wage ("game_get_troop_wage", [ (store_script_param_1, ":troop_id"), (store_script_param_2, ":unused"), #party id (store_troop_faction, ":troop_faction", ":troop_id"), (store_character_level, ":troop_level", ":troop_id"), (assign, ":wage", ":troop_level"), (val_add, ":wage", 3), (val_mul, ":wage", ":wage"), (val_div, ":wage", 25), (troop_get_type, ":race", ":troop_id"), (try_begin), (eq, ":race", tf_troll), (neq, ":troop_id", "trp_npc21"), #not for Berta (val_add, ":wage", 5), (val_mul, ":wage", 10),# trolls cost x 27, #InVain: reduced to 10, which still amounts to ~800 (try_end), (try_begin), #mounted troops cost 50% more than the normal cost (troop_is_mounted, ":troop_id"), (val_mul, ":wage", 150), (val_div, ":wage", 100), (try_end), (try_begin), #discount if you have chieftain sword (troop_has_item_equipped, "trp_player", "itm_dun_berserker"), (eq, ":troop_faction", "fac_dunland"), (val_mul, ":wage", 100), (val_div, ":wage", 115), (try_end), (try_begin), #discount if you have warg rider helmet (troop_has_item_equipped, "trp_player", "itm_gundabad_helm_e"), (this_or_next|eq, ":troop_id", "trp_c4_gunda_warg_rider"), (this_or_next|eq, ":troop_id", "trp_c4_gunda_warg_rider"), (eq, ":troop_id", "trp_c5_gunda_clan_rider"), (val_mul, ":wage", 100), (val_div, ":wage", 120), (try_end), (try_begin), #discount if you have warg rider helmet (troop_has_item_equipped, "trp_player", "itm_gundabad_helm_e"), (this_or_next|eq, ":troop_id", "trp_c3_moria_wolf_rider"), (this_or_next|eq, ":troop_id", "trp_c4_moria_warg_rider"), (this_or_next|eq, ":troop_id", "trp_c3_mordor_warg_rider"), (this_or_next|eq, ":troop_id", "trp_c4_mordor_great_warg_rider"), (this_or_next|eq, ":troop_id", "trp_ac2_isen_wolf_rider"), (this_or_next|eq, ":troop_id", "trp_ac3_isen_warg_rider"), (this_or_next|eq, ":troop_id", "trp_ac4_isen_white_hand_rider"), (eq, ":troop_id", "trp_c5_moria_clan_rider"), (val_mul, ":wage", 100), (val_div, ":wage", 110), (try_end), (try_begin), (troop_is_hero,":troop_id"), # no upkeep for heros! (player included) (assign, reg0, 0), (try_end), (try_begin), (neg|is_between, ":troop_faction", kingdoms_begin, kingdoms_end), # bandits are free (assign, reg0, 0), (try_end), (try_begin), #after war of the two towers has started, remaining enemy side troops in player party are free (gt, "$tld_war_began", 1), (faction_get_slot, ":troop_side", ":troop_faction", slot_faction_side), (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), (neq, ":player_side", ":troop_side"), (assign, reg0, 0), (try_end), (assign, reg0, ":wage"), (set_trigger_result, reg0), ]), # script_game_get_total_wage (mod by mtarini) # This script is called from the game engine for calculating total wage of the player party which is shown at the party window. # Input: none # Output: reg0: weekly wage ("game_get_total_wage", [ (assign, ":total_wage", 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"), (party_stack_get_size, ":stack_size", "p_main_party", ":i_stack"), (call_script, "script_game_get_troop_wage", ":stack_troop",0), (val_mul, reg0, ":stack_size"), (val_add, ":total_wage", reg0), (try_end), (assign, reg0, ":total_wage"), (set_trigger_result, reg0), ]), #MV: Note that non-kingdom troops like bandits don't need upkeep! # script_compute_wage_per_faction (mtarini) # Input: arg1 = faction # Input: arg1 = party # Output: reg4 = weekly wage per faction (player has to pay) ("compute_wage_per_faction", [ (store_script_param_1, ":fac"), (store_script_param_2, ":party"), (try_begin), (lt, ":party", 0), (assign, ":party", "p_main_party"), (try_end), (assign, ":spending", 0), # for this faction (party_get_num_companion_stacks, ":num_stacks",":party"), (try_for_range, ":i", 0, ":num_stacks"), (party_stack_get_size, ":stack_size",":party",":i"), (party_stack_get_troop_id, ":stack_troop",":party",":i"), (store_troop_faction, ":fac_troop", ":stack_troop"), (eq,":fac_troop",":fac"), (call_script, "script_game_get_troop_wage", ":stack_troop",0 ), (assign, ":cur_wage", reg0), (val_mul, ":cur_wage", ":stack_size"), (val_add, ":spending", ":cur_wage"), (try_end), # end of for each stack (assign, reg4, ":spending"), ]), #MV: update this script to charge for player's reserves (p_player_garrison) - or not #InVain: Done # script_make_player_pay_upkeep (mtarini) # no input, no output ("make_player_pay_upkeep", [(call_script, "script_update_respoint"), # make sure respoint are up-to-date (with current gold) (assign, ":party", "p_main_party"), # pay only for player party (no garrisons, for now) (troop_get_slot, ":reserve_party_cap", "trp_player", slot_troop_player_reserve_party), (troop_get_slot, ":reserve_party_ac", "trp_player", slot_troop_player_reserve_adv_camp), (assign, ":n_tot_unpaid_troops", 0), # for all factions (assign, ":n_tot_unpaid_troops_reserve", 0), # for all factions (assign, ":tot_spending", 0), # for all factions (str_clear, s10 ), # list of unpaid faction (try_begin), (neq, "$g_fast_mode", 1), (display_message, "@Troop upkeep:"), (try_end), (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (try_begin), (eq, ":fac", "fac_guldur"), (faction_get_slot, ":allowance", "fac_mordor", slot_faction_respoint), (else_try), (faction_get_slot, ":allowance", ":fac", slot_faction_respoint), (try_end), (assign, ":spending", 0), # for this faction (assign, ":n_unpaid_troops", 0), # for this faction #main party (party_get_num_companion_stacks, ":num_stacks",":party"), (try_for_range_backwards, ":i", 0, ":num_stacks"), (party_stack_get_size, ":stack_size",":party",":i"), (party_stack_get_troop_id, ":stack_troop",":party",":i"), (store_troop_faction, ":fac_troop", ":stack_troop"), (eq,":fac_troop",":fac"), (call_script, "script_game_get_troop_wage", ":stack_troop",0 ), (assign, ":cur_wage", reg0), (val_mul, ":cur_wage", ":stack_size"), # up to 50% discont, if spent time indoor (store_sub, ":total_payment", 8, "$g_cur_week_half_daily_wage_payments"), #between 0 and 4 (val_mul, ":cur_wage", ":total_payment"), (val_div, ":cur_wage", 8), (try_begin), (ge, ":allowance",":cur_wage"), # CAN afford (val_add, ":spending", ":cur_wage"), (val_add, ":tot_spending", ":cur_wage"), (val_sub, ":allowance",":cur_wage"), (troop_set_slot, ":stack_troop", slot_troop_upkeep_not_paid, 0), (else_try), # CAN'T afford (val_add, ":n_unpaid_troops", ":stack_size"), (troop_set_slot, ":stack_troop", slot_troop_upkeep_not_paid, 1), (try_end), (try_end), # end of for each stack #capital reserves (try_begin), (party_is_active, ":reserve_party_cap"), (party_get_num_companion_stacks, ":num_stacks",":reserve_party_cap"), (try_for_range_backwards, ":i", 0, ":num_stacks"), (gt, ":reserve_party_cap", 0), (party_stack_get_size, ":stack_size",":reserve_party_cap",":i"), (party_stack_get_troop_id, ":stack_troop",":reserve_party_cap",":i"), (store_troop_faction, ":fac_troop", ":stack_troop"), (eq,":fac_troop",":fac"), (call_script, "script_game_get_troop_wage", ":stack_troop",0 ), (assign, ":cur_wage", reg0), (val_mul, ":cur_wage", ":stack_size"), (val_div, ":cur_wage", 2), #half wages for reserves (try_begin), (ge, ":allowance",":cur_wage"), # CAN afford (val_add, ":spending", ":cur_wage"), (val_add, ":tot_spending", ":cur_wage"), (val_sub, ":allowance",":cur_wage"), (troop_set_slot, ":stack_troop", slot_troop_upkeep_not_paid, 0), (else_try), # CAN'T afford: For reserves, we don't give warning. Troops leave immediatly. (party_remove_members, ":reserve_party_cap", ":stack_troop", 1), (val_add, ":n_tot_unpaid_troops_reserve", 1), (try_end), (try_end), # end of for each stack # (else_try), # (display_message, "@no cap reserves"), (try_end), #advance camp reserves (try_begin), (party_is_active, ":reserve_party_ac"), (party_get_num_companion_stacks, ":num_stacks",":reserve_party_ac"), (try_for_range_backwards, ":i", 0, ":num_stacks"), (gt, ":reserve_party_ac", 0), (party_stack_get_size, ":stack_size",":reserve_party_ac",":i"), (party_stack_get_troop_id, ":stack_troop",":reserve_party_ac",":i"), (store_troop_faction, ":fac_troop", ":stack_troop"), (eq,":fac_troop",":fac"), (call_script, "script_game_get_troop_wage", ":stack_troop",0 ), (assign, ":cur_wage", reg0), (val_mul, ":cur_wage", ":stack_size"), (val_div, ":cur_wage", 2), #half wages for reserves (try_begin), (ge, ":allowance",":cur_wage"), # CAN afford (val_add, ":spending", ":cur_wage"), (val_add, ":tot_spending", ":cur_wage"), (val_sub, ":allowance",":cur_wage"), (troop_set_slot, ":stack_troop", slot_troop_upkeep_not_paid, 0), (else_try), # CAN'T afford: For reserves, we don't give warning. Troops leave immediatly. (party_remove_members, ":reserve_party_ac", ":stack_troop", 1), (val_add, ":n_tot_unpaid_troops_reserve", 1), (try_end), (try_end), # end of for each stack # (else_try), # (display_message, "@no ac reserves"), (try_end), (try_begin),(gt, ":n_unpaid_troops", 0 ), (assign, reg12, ":n_unpaid_troops"), (str_store_faction_name,s11,":fac"), (try_begin), (gt, ":n_tot_unpaid_troops", 0), # not first time (str_store_string, s10, "@{s11} and {s10}"), (str_store_string, s12, "@their"), (else_try), (str_store_string, s10, "@{s11}"), (str_store_string, s12, "@its"), (try_end), (assign, ":n_unpaid_troops", ":stack_size" ), # for this faction (try_end), (val_add, ":n_tot_unpaid_troops", ":n_unpaid_troops"), (gt, ":spending", 0), (store_mul, reg10, ":spending", -1), (call_script, "script_add_faction_rps", ":fac", reg10), (try_end), # end of for each faction (try_begin),(eq, ":tot_spending", 0 ),(eq, ":n_tot_unpaid_troops", 0 ), (neq, "$g_fast_mode", 1), (display_message, "@[no upkeep costs]"), (try_end), (try_begin),(gt, ":n_tot_unpaid_troops", 0), (neq, "$g_fast_mode", 1), (display_message, "@Short of Resource Points!!", color_bad_news), (display_message, "@{s10} will soon reassign some of {s12} troops away from your party!", color_bad_news), (gt, ":n_tot_unpaid_troops_reserve", 1), (display_message, "@{s10} has reassigned troops from your reserves.", color_bad_news), (try_end), (assign, "$g_cur_week_half_daily_wage_payments", 0), # reset "rest in city" discount ]), # script_make_unpaid_troop_go (mtarini) # No input, no output. Just makes the "unpaid" troops of player party leave the party, if you still don't have the money ("make_unpaid_troop_go",[ (call_script, "script_update_respoint"), # make sure respoint are up-to-date (with current gold) (assign, ":party", "p_main_party"), (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, ":tot_spending", 0), # for all factions (str_clear, s12 ), # list of unpaid faction (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (faction_get_slot, ":allowance", ":fac", slot_faction_respoint), (assign, ":spending", 0), # for this faction #(assign, ":n_tot_left", 0), # for this factions (assign, ":msg_shown", 0), (try_for_range_backwards, ":i", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i"), (ge, ":stack_troop", 0), (troop_slot_eq, ":stack_troop", slot_troop_upkeep_not_paid, 1), # the upkeep of these guys wasn't paid (store_troop_faction, ":fac_troop", ":stack_troop"),(eq,":fac_troop",":fac"), # and they are of the right faction (troop_set_slot, ":stack_troop", slot_troop_upkeep_not_paid, 0), (party_stack_get_size, ":stack_size",":party",":i"), (party_stack_get_num_wounded, ":stack_wounded",":party",":i"), (call_script, "script_game_get_troop_wage", ":stack_troop",0 ), (assign, ":wage", reg0), (call_script, "script_get_troop_disband_cost", ":stack_troop",1 ,0 ), (assign, ":gain_ok", reg0), (call_script, "script_get_troop_disband_cost", ":stack_troop",2 ,0 ), (assign, ":gain_ko", reg0), # up to 50% discount, if spent time indoor (store_sub, ":total_payment", 8, "$g_cur_week_half_daily_wage_payments"), #between 0 and 4 (val_mul, ":wage", ":total_payment"), (val_div, ":wage", 8), (assign, ":n_left", 0), # for his stack (try_for_range, ":unused", 0, ":stack_size"), # for each troop in stack (try_begin), (ge, ":allowance",":wage"), # CAN afford: stays. Pay wage (val_add, ":spending", ":wage"), (val_add, ":tot_spending", ":wage"), (val_sub, ":allowance",":wage"), (else_try), # CAN'T afford: leaves. Gain premium. (assign, ":gain", ":gain_ok"), (try_begin), (gt, ":stack_wounded", 0), # if wounded, gain less money (val_sub, ":stack_wounded", 1), (assign, ":gain", ":gain_ko"), (try_end), (val_sub, ":spending", ":gain"), # gain RP (val_sub, ":tot_spending", ":gain"), # gain RP (val_add, ":allowance",":gain"), # gain RP (val_add, ":n_left", 1), #(val_add, ":n_tot_left", 1), (try_end), (try_end), # end of a stack (gt, ":n_left", 0), (try_begin),(eq, ":msg_shown", 0), (str_store_faction_name,s11,":fac"), (display_message, "@Superior orders from {s11} to reassign troops:", color_bad_news), (assign, ":msg_shown", 1), # only once (try_end), (str_store_troop_name_by_count,s10,":stack_troop", ":n_left"), (assign, reg12, ":n_left"), (display_message, "@{reg12} {s10} left the party!", color_bad_news), (party_remove_members, ":party", ":stack_troop", ":n_left"), (try_end), # end of for all stacks (neq, ":spending", 0), (store_mul, reg10, ":spending", -1), (call_script, "script_add_faction_rps", ":fac", reg10), (try_end), # end of for each faction ]), ############################# TLD PLAYER REWARD SYSTEM --- SCRIPTS END (mtarini) #############################?# ### given two factions, fails if they are not allies... ("cf_factions_are_allies", [ (store_script_param_1, ":a"), (store_script_param_2, ":b"), (faction_get_slot, ":a",":a", slot_faction_side), (faction_get_slot, ":b",":b", slot_faction_side), (try_begin), # eye and hand still allies? (le, "$tld_war_began",1), (try_begin), (eq,":a", faction_side_hand),(assign,":a",faction_side_eye), (try_end), (try_begin), (eq,":b", faction_side_hand),(assign,":b",faction_side_eye), (try_end), (try_end), (eq,":a",":b"), ]), # script_get_entry_point_with_most_similar_facing (mtarini) # used to make warg spawn from an entry point which will give it an appropriate facing # stores in reg1 the entry point (in 0..64) with a facting more similar to 1st param ("get_entry_point_with_most_similar_facing", [ (store_script_param_1, ":target"), (store_add, ":target2", ":target", 360), (try_begin), (ge,":target", 180), (store_add, ":target2", ":target", -360), (try_end), (assign, reg1, 5), (assign, ":best", 9999), (try_for_range, ":i", 5, 9), # avoid 0..4 (entry_point_get_position,pos10,":i"), (position_get_rotation_around_z, reg10, pos10), #(try_begin),(assign,reg5,":i"),(le,reg5,20),(display_message, "@Pos N.{reg5}:{reg10}"),(try_end), (neq,reg10,0.0), # skip undefined positions # find min distance from target2, target (store in reg12) (store_sub, reg11, reg10, ":target2"),(val_abs, reg11), (store_sub, reg12, reg10, ":target"), (val_abs, reg12), (val_min, reg12,reg11), (lt, reg12, ":best"), (assign, ":best", reg12), (assign, reg1, ":i"), (try_end), #(set_show_messages,1), #(display_message, "@Selected:{reg1}"), ]), # ("cf_troop_cant_ride_item", [ (store_script_param_1, ":trp"), (store_script_param_2, ":mount_item"), (troop_get_type, ":race", ":trp"), (assign, ":mount_type", 0), # 0 = horse 1 = warg, 2 = huge warg 4 = pony (try_begin),(eq,":mount_item", "itm_warg_reward"), (assign, ":mount_type", 2), (else_try),(is_between, ":mount_item", item_warg_begin, item_warg_end),(assign, ":mount_type", 1), (else_try),(eq, ":mount_item", "itm_spider"), (assign, ":mount_type", 1), # Only orcs can ride spiders (else_try),(eq, ":mount_item", "itm_pony"), (assign, ":mount_type", 4), (try_end), (assign, ":rider_type", 0), # 0 = human 1 = orc, 2 = uruk 4 = dwarf (try_begin),(eq, ":race", tf_orc), (assign, ":rider_type" , 1), # non-orcs (uruks & hai included) cannot ride ordinary wargs (else_try),(is_between, ":race", tf_orc_begin, tf_orc_end),(assign, ":rider_type" , 2), (else_try),(eq, ":race", tf_dwarf), (assign, ":rider_type" , 4), (try_end), #(assign, reg10,":rider_type"),(assign, reg12,":mount_item"),(assign, reg11,":mount_type"), (display_message, "@cazz {reg10} {reg11} (itm: {reg12})"), (try_begin), #orcs can ride great wargs with higher riding skill (eq, ":race", tf_orc),(eq,":mount_item", "itm_warg_reward"), (store_skill_level, ":riding", skl_riding, ":trp"), (gt, ":riding", 5), (assign, ":mount_type", ":rider_type"), (try_end), (neq, ":mount_type", ":rider_type"), # non orc riding wargs, or orc riding non wargs ]), #script_cf_is_troop_in_party_wounded #is a regular troop wounded inside a party? (mtarini) # INPUT: arg1 = faction_no, arg2 = owner_troop_no #OUTPUT: nothing (can fail) ("cf_is_troop_in_party_wounded", [ (store_script_param, ":troop", 1), (store_script_param, ":party", 2), (assign, ":yes", 0), (party_get_num_companion_stacks, ":num_stacks", ":party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party", ":i_stack"), (eq, ":stack_troop", ":troop"), (party_stack_get_num_wounded,":nw",":party",":i_stack"), (gt, ":nw", 1), # if there are wounded (assign, ":yes", 1), # then yes (try_end), (eq, ":yes", 1), # fails if not wounded ]), #script_cf_is_troop_in_party_not_wounded # as above, but the opposite ("cf_is_troop_in_party_not_wounded",[ (store_script_param, ":troop", 1), (store_script_param, ":party", 2), (assign, ":yes", 0), (party_get_num_companion_stacks, ":num_stacks", ":party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party", ":i_stack"), (eq, ":stack_troop", ":troop"), (party_stack_get_num_wounded,":nw",":party",":i_stack"), (gt, ":nw", 1), # if there are wounded (assign, ":yes", 1), # then yes (try_end), (eq, ":yes", 0), # fails if not wounded ]), ]), ############################# TLD FANGORN SCRIPTS (mtarini) #############################?# #script_fangorn_deal_damage # script: deal 'fangorn damage' to a party (abstact attack by ents): (mtarini) # INPUT: party to deal damage # OUTPUT: reg0 killed troops. reg1 = wonded troops. reg2 = wounded player (1 or 0) ("fangorn_deal_damage", [(store_script_param_1, ":party"), (assign,":killed",0), (assign,":wounded",0), (assign,":leader_wounded",0), (try_begin), (store_random_in_range, reg0,0,100), (lt, reg0, "$g_fangorn_rope_pulled"), # if fangorn rope is not pulled enough, get away with this (party_get_num_companion_stacks, ":num_stacks",":party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (party_stack_get_size, ":stack_size",":party",":i_stack"), (assign, reg0, ":stack_size"), #(display_message,"@DEBUG: processing a stack of {reg0} troops"), (try_for_range, ":i",0,":stack_size"), (store_random_in_range, reg0,0,5), (eq, reg0, 2), # kill 1 in 5 (try_begin), (store_random_in_range, reg0,0,2), (this_or_next|eq, reg0, 0), # wound 1 in 2 just wounded (and all heros) (troop_is_hero,":stack_troop"), (neg|troop_is_wounded,":stack_troop"), # wound (party_wound_members,":party",":stack_troop",1), (try_begin), (troop_is_hero,":stack_troop"), (troop_set_health,":stack_troop",0), # heroes (including player) gets 0 health (try_end), (try_begin), (eq, ":i",0), (val_add,":leader_wounded",1), (else_try), (val_add,":wounded",1), (try_end), (else_try), #kill (neg|troop_is_hero,":stack_troop"), #MV (party_remove_members,":party",":stack_troop",1), (val_add,":killed",reg0), (try_end), (try_end), (try_end), (try_end), (assign, reg0, ":killed"), (assign, reg1, ":wounded"), (assign, reg2, ":leader_wounded"), ]), #script_after_fangorn_damage_to_player # script: after_fangorn_damage_to_player: (mtarini) ("after_fangorn_damage_to_player", [ (try_begin), (this_or_next|gt,reg0,0), (gt,reg1,0), (display_message,"@Fangorn claimed {reg0} killed and {reg1} wounded among your troops!", color_bad_news), (try_end), (try_begin), (eq,reg2,1), (display_message,"@You were wounded in Fangorn!", color_bad_news), (try_end), (assign, ":player_victim", reg2), (store_add, ":troop_victims", reg1,reg0), # killed + wounded victims (try_begin), (eq, ":player_victim", 1), (eq, ":troop_victims", 0), (jump_to_menu, "mnu_fangorn_killed_player_only"), (else_try), (eq, ":player_victim", 0), (gt, ":troop_victims", 0), (jump_to_menu, "mnu_fangorn_killed_troop_only"), (else_try), (eq, ":player_victim", 1), (gt, ":troop_victims", 0), (jump_to_menu, "mnu_fangorn_killed_troop_and_player"), (else_try), (change_screen_map), # no victims at all (try_end), ]), #script_party_is_in_fangorn # Script: is this party curretnly inside fangorn? (mtarini) # INPUT: party to test # OUTPUT: reg0 = 1 if yes ("party_is_in_fangorn", [(set_fixed_point_multiplier, 100), (store_script_param_1, ":party"), (party_get_position, pos1, ":party"), (party_get_position, pos2, "p_fangorn_center"), (get_distance_between_positions, ":dist", pos1, pos2), (party_get_current_terrain, ":terrain_type", ":party"), # (assign, reg0, ":dist"), # (assign, reg1, ":terrain_type"), # (display_message,"@Distance from Fangorn: {reg0}, terrain: {reg1}"), (try_begin), (lt, ":dist", 2400), #MV: was 3200 (this_or_next|eq, ":terrain_type", rt_steppe_forest), (this_or_next|eq, ":terrain_type", rt_forest), (eq, ":terrain_type", rt_snow_forest), (assign, reg0, 1), (else_try), (assign, reg0, 0), (try_end), ]), #script_fangorn_fight_ents # Script: start a battle with wandering ents (mtarini) ("fangorn_fight_ents",[ (store_random_in_range, ":scene_to_use", "scn_forest_fangorn1", "scn_forest_ithilien_small1"), #(assign,"$g_fangorn_rope_pulled", 0), # ents calm down after a good fight (val_max,"$g_fangorn_rope_pulled", 21), # this also means ents gets a max reinforcement of at least 3 (call_script, "script_safe_remove_party","$g_encountered_party"), #remove ent party (quest_set_slot, "qst_investigate_fangorn", slot_quest_target_amount, 0), (assign, "$g_encountered_party", "p_legend_fangorn"), # just so that the find music script dosn't go nuts (modify_visitors_at_site, ":scene_to_use"), (reset_visitors), (set_jump_entry, 4), #(display_message, "@spawn at 4"), (set_visitor, 4, "trp_player"), (store_random_in_range, ":num_ents", 1, 3), (set_visitors, 0, "trp_ent", ":num_ents"), (set_party_battle_mode), (set_battle_advantage, 0), (assign, "$g_battle_result", 0), (assign, "$g_mt_mode", vba_normal), (assign, "$cant_leave_encounter", 1), (assign, "$g_next_menu", "mnu_fangorn_battle_debrief"), (set_jump_mission,"mt_fangorn_battle_new"), (jump_to_scene,":scene_to_use" ), (change_screen_mission), ]), ############################# TLD FANGORN SCRIPTS END ############################## ############################## GAME START MEGASCRIPT ############################### #script_game_start: # This script is called when a new game is started # INPUT: none ("game_start",[ (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive), (troop_set_slot, "trp_player", slot_troop_occupation, slto_kingdom_hero), (troop_set_slot, "trp_player", slot_troop_prisoner_of_party, -1), (try_for_range, ":cur_troop", kingdom_heroes_begin, kingdom_heroes_end), (troop_set_slot, ":cur_troop", slot_troop_prisoner_of_party, -1), (troop_set_slot, ":cur_troop", slot_troop_custom_banner_flag_type, -1), (troop_set_slot, ":cur_troop", slot_troop_custom_banner_map_flag_type, -1), (try_end), (troop_set_slot, "trp_player", slot_troop_custom_banner_flag_type, -1), (troop_set_slot, "trp_player", slot_troop_custom_banner_map_flag_type, -1), #Assigning global constant (call_script, "script_store_average_center_value_per_faction"), (troop_set_slot, "trp_player", slot_troop_custom_banner_bg_color_1, 0xFFFFFFFF), (troop_set_slot, "trp_player", slot_troop_custom_banner_bg_color_2, 0xFFFFFFFF), (troop_set_slot, "trp_player", slot_troop_custom_banner_charge_color_1, 0xFFFFFFFF), (troop_set_slot, "trp_player", slot_troop_custom_banner_charge_color_2, 0xFFFFFFFF), (troop_set_slot, "trp_player", slot_troop_custom_banner_charge_color_3, 0xFFFFFFFF), (troop_set_slot, "trp_player", slot_troop_custom_banner_charge_color_4, 0xFFFFFFFF), (faction_set_slot, "fac_outlaws", slot_faction_side , faction_side_noside), (faction_set_slot, "fac_deserters", slot_faction_side , faction_side_noside), (faction_set_slot, "fac_mountain_bandits", slot_faction_side , faction_side_noside), (faction_set_slot, "fac_forest_bandits", slot_faction_side , faction_side_noside), (faction_set_slot, "fac_commoners", slot_faction_side , faction_side_good), #Setting background colors for banners ]+[ (troop_set_slot, "trp_banner_background_color_array", x, color_list[x]) for x in range(len(color_list)) ]+[ (str_store_troop_name, s5, "trp_player"), (party_set_name, "p_main_party", s5), (call_script, "script_update_party_creation_random_limits"), # Reseting player party icon (assign, "$g_player_party_icon", -1), # Setting food bonuses (item_set_slot, "itm_smoked_fish", slot_item_food_bonus, 5), (item_set_slot, "itm_dried_meat", slot_item_food_bonus, 5), (item_set_slot, "itm_cattle_meat", slot_item_food_bonus, 7), (item_set_slot, "itm_human_meat", slot_item_food_bonus, 6), #(item_set_slot, "itm_lembas", slot_item_food_bonus, 20), (item_set_slot, "itm_maggoty_bread", slot_item_food_bonus, 2), (item_set_slot, "itm_cram", slot_item_food_bonus, 3), (item_set_slot, "itm_horse_meat", slot_item_food_bonus, 5), (call_script, "script_initialize_npcs"), # Setting book intelligence requirements #(item_set_slot, "itm_book_tactics", slot_item_intelligence_requirement, 9), ]+[ # Faction init from data in module_constants.py # War system (foxyman) (faction_set_slot, faction_init[x][0], slot_faction_strength , faction_init[x][1]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_culture , faction_init[x][2]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_leader , faction_init[x][3][0]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_marshall , faction_init[x][3][1]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_tier_1_troop , faction_init[x][4][0]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_tier_2_troop , faction_init[x][4][1]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_tier_3_troop , faction_init[x][4][2]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_tier_4_troop , faction_init[x][4][3]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_tier_5_troop , faction_init[x][4][4]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_ranged_troop , faction_init[x][4][5]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_troll_troop , faction_init[x][4][6]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_reinforcements_a, faction_init[x][5][0]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_reinforcements_b, faction_init[x][5][1]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_reinforcements_c, faction_init[x][5][2]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_prisoner_train , faction_init[x][5][3]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_party_map_banner, faction_init[x][7]) for x in range(len(faction_init)) ]+[ # troop slots (faction_set_slot, faction_init[x][0], slot_faction_deserter_troop , faction_init[x][8][0]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_guard_troop , faction_init[x][8][1]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_rider_troop , faction_init[x][8][2]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_archer_troop , faction_init[x][8][3]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_castle_guard_troop, faction_init[x][8][4]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_capital , faction_init[x][9]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_side , faction_init[x][10]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_home_theater , faction_init[x][11]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_init[x][0], slot_faction_advance_camp , faction_init[x][12]) for x in range(len(faction_init)) ]+[ # rumors in shops and tavers (faction_set_slot, faction_strings[x][0], slot_faction_rumors_begin , faction_strings[x][1]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_strings[x][0], slot_faction_rumors_end , faction_strings[x][2]) for x in range(len(faction_init)) ]+[ # ambient sounds (faction_set_slot, faction_strings[x][0], slot_faction_ambient_sound_day , faction_strings[x][3]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_strings[x][0], slot_faction_ambient_sound_always, faction_strings[x][4]) for x in range(len(faction_init)) ]+[ (faction_set_slot, faction_strings[x][0], slot_faction_occasional_sound1_day,faction_strings[x][5]) for x in range(len(faction_init)) ]+[ #Armoured Troll Variants (troop_set_slot, "trp_moria_vet_troll", slot_troop_troll_armoured_variant, "trp_moria_armored_troll"), (troop_set_slot, "trp_isen_vet_troll", slot_troop_troll_armoured_variant, "trp_isen_armored_troll"), (troop_set_slot, "trp_mordor_vet_troll", slot_troop_troll_armoured_variant, "trp_mordor_olog_hai"), # fixed faction info (try_for_range, ":faction", kingdoms_begin, kingdoms_end), (faction_get_slot, reg30, ":faction", slot_faction_strength), (faction_set_slot, ":faction", slot_faction_strength_tmp, reg30), (faction_get_slot, reg30, ":faction", slot_faction_home_theater), (faction_set_slot, ":faction", slot_faction_active_theater, reg30), (assign, reg30, 1), (try_for_range, ":unused", 0, ":faction"), (val_mul, reg30, 2), (try_end), (faction_set_slot, ":faction", slot_faction_mask, reg30), (try_end), (faction_set_slot, "fac_player_supporters_faction", slot_faction_marshall, "trp_player"), # Towns: (try_for_range, ":item_no", trade_goods_begin, trade_goods_end), (store_sub, ":offset", ":item_no", trade_goods_begin), (val_add, ":offset", slot_town_trade_good_prices_begin), (try_for_range, ":center_no", centers_begin, centers_end), (party_set_slot, ":center_no", ":offset", average_price_factor), (try_end), (try_end), # setting up trade and messenger routes ]+concatenate_scripts([ [ (call_script, "script_set_trade_route_between_centers", routes_list[x][0], routes_list[x][y]) for y in range (len(routes_list[x])) ] for x in range(len(routes_list)) ])+[ (call_script, "script_center_change_trade_good_production", "p_town_minas_tirith", "itm_tools", 110, 0), (call_script, "script_center_change_trade_good_production", "p_town_pelargir", "itm_smoked_fish", 130, 0), (call_script, "script_center_change_trade_good_production", "p_town_linhir", "itm_tools", 120, 0), (call_script, "script_center_change_trade_good_production", "p_town_dol_amroth", "itm_tools", 130, 0), (call_script, "script_center_change_trade_good_production", "p_town_edhellond", "itm_tools", 80, 0), (call_script, "script_center_change_trade_good_production", "p_town_lossarnach", "itm_tools", 130, 0), (call_script, "script_center_change_trade_good_production", "p_town_tarnost", "itm_tools", 140, 0), (call_script, "script_center_change_trade_good_production", "p_town_tarnost", "itm_smoked_fish", 110, 0), (call_script, "script_center_change_trade_good_production", "p_town_erech", "itm_tools", 130, 0), (call_script, "script_center_change_trade_good_production", "p_town_pinnath_gelin", "itm_tools", 135, 0), (call_script, "script_center_change_trade_good_production", "p_town_aldburg", "itm_tools", 86, 0), (call_script, "script_center_change_trade_good_production", "p_town_edoras", "itm_tools", 130, 0), (call_script, "script_center_change_trade_good_production", "p_town_hornburg", "itm_tools", 140, 0), (call_script, "script_center_change_trade_good_production", "p_town_east_emnet", "itm_dried_meat", 120, 0), (call_script, "script_center_change_trade_good_production", "p_town_westfold", "itm_tools", 120, 0), (call_script, "script_center_change_trade_good_production", "p_town_west_emnet", "itm_tools", 100, 0), (call_script, "script_center_change_trade_good_production", "p_town_eastfold", "itm_tools", 100, 0), (call_script, "script_center_change_trade_good_production", "p_town_morannon", "itm_tools", 100, 0), (call_script, "script_center_change_trade_good_production", "p_town_minas_morgul", "itm_tools", 125, 0), (try_for_range, ":unused", 0, 1), (call_script, "script_average_trade_good_productions"), (try_end), (call_script, "script_normalize_trade_good_productions"), # Centers init from data in module_constants.py ]+[ (party_set_slot, center_list[x][0], slot_town_center , center_list[x][1][0]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_castle , center_list[x][1][1]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_prison , center_list[x][1][2]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_tavern , center_list[x][1][3]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_arena , center_list[x][1][4]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_walls , center_list[x][1][5]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_menu_background , center_list[x][1][6]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_elder , center_list[x][2][3]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_captain , center_list[x][2][0]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_weaponsmith , center_list[x][2][1]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_merchant , center_list[x][2][2]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_town_recruits_pt , center_list[x][2][4]) for x in range(len(center_list)) ]+[ #walker types (party_set_slot, center_list[x][0], slot_center_walker_0_troop, center_list[x][2][6]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_1_troop, center_list[x][2][7]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_2_troop, center_list[x][2][8]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_3_troop, center_list[x][2][9]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_4_troop, center_list[x][2][6]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_5_troop, center_list[x][2][7]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_6_troop, center_list[x][2][8]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_7_troop, center_list[x][2][9]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_8_troop, center_list[x][2][6]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_walker_9_troop, center_list[x][2][7]) for x in range(len(center_list)) ]+[ (party_set_banner_icon, center_list[x][0], center_list[x][3][0]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_strength_income, center_list[x][6]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_garrison_limit, center_list[x][7]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_destroy_on_capture,center_list[x][8]) for x in range(len(center_list)) ]+[ (party_set_slot, center_list[x][0], slot_center_siegability, center_list[x][9]) for x in range(len(center_list)) ]+[ #item abundancy in center shops (troop_set_slot, center_list[x][2][1], slot_troop_shop_gold ,center_list[x][4][0]) for x in range(len(center_list)) ]+[ (troop_set_slot, center_list[x][2][2], slot_troop_shop_gold ,center_list[x][4][0]) for x in range(len(center_list)) ]+[ #battlegear and horses numbers stored in merchant troop skills (troop_set_slot, "trp_skill2item_type", x ,skill2item_list[x]) for x in range(len(skill2item_list)) ]+[ # give centers to lords, put said lord there (call_script, "script_give_center_to_lord", center_list[x][0], center_list[x][2][5], 0) for x in range(len(center_list)) ]+[ # center fixed info filling (try_for_range, ":town_no", centers_begin, centers_end), (party_set_slot, ":town_no", slot_party_type, spt_town), (try_begin), (party_slot_eq, ":town_no", slot_town_walls, -1), (party_get_slot, reg30, ":town_no", slot_town_center), (party_set_slot, ":town_no", slot_town_walls, reg30), (try_end), (party_set_slot, ":town_no", slot_town_store, "scn_town_store"), (party_set_slot, ":town_no", slot_town_alley, "scn_town_alley"), (try_end), #healers (party_set_slot, "p_town_morannon", slot_town_healer, "trp_morannon_healer"), (party_set_slot, "p_town_minas_tirith", slot_town_healer, "trp_minas_tirith_healer"), (party_set_slot, "p_town_edoras", slot_town_healer, "trp_edoras_healer"), (party_set_slot, "p_town_isengard", slot_town_healer, "trp_isengard_healer"), (party_set_slot, "p_town_dol_guldur", slot_town_healer, "trp_guldur_healer"), (party_set_slot, "p_town_gundabad", slot_town_healer, "trp_gundabad_healer"), (party_set_slot, "p_town_thranduils_halls", slot_town_healer, "trp_mirkwood_healer"), # Centers spawns init from ws_party_spawns_list in module_constants.py ]+[ (party_set_slot, ws_party_spawns_list[x][0], slot_center_spawn_scouts, ws_party_spawns_list[x][1]) for x in range(len(ws_party_spawns_list)) ]+[ (party_set_slot, ws_party_spawns_list[x][0], slot_center_spawn_raiders, ws_party_spawns_list[x][2]) for x in range(len(ws_party_spawns_list)) ]+[ (party_set_slot, ws_party_spawns_list[x][0], slot_center_spawn_patrol, ws_party_spawns_list[x][3]) for x in range(len(ws_party_spawns_list)) ]+[ (party_set_slot, ws_party_spawns_list[x][0], slot_center_spawn_caravan, ws_party_spawns_list[x][4]) for x in range(len(ws_party_spawns_list)) ]+[ # disable some evil centers at start ]+[ (disable_party, centers_disabled_at_start[x]) for x in range(len(centers_disabled_at_start)) ]+[ # make henneth hardly visible when player is evil (try_begin), (neg|faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (party_set_flags, "p_town_henneth_annun", pf_always_visible, 0), (try_end), (try_for_range, ":center_no", centers_begin, centers_end), (party_set_slot, ":center_no", slot_center_last_spotted_enemy, -1), (party_set_slot, ":center_no", slot_center_is_besieged_by, -1), (party_set_slot, ":center_no", slot_center_last_taken_by_troop, -1), #Assigning random prosperity (store_random_in_range, ":random_prosperity_adder", -25, 15), (call_script, "script_get_center_ideal_prosperity", ":center_no"), (assign, ":prosperity", reg0), (val_add, ":prosperity", ":random_prosperity_adder"), (try_begin), (party_slot_eq, ":center_no", slot_party_type, spt_town), (val_add, ":prosperity", 20), (try_end), (val_clamp, ":prosperity", 0, 100), (party_set_slot, ":center_no", slot_town_prosperity, ":prosperity"), (try_end), (try_for_range, ":town_no", centers_begin, centers_end), (store_faction_of_party, ":faction", ":town_no"), (faction_get_slot, ":tmp",":faction", slot_faction_reinforcements_a), (party_set_slot, ":town_no", slot_town_reinforcements_a, ":tmp"), (faction_get_slot, ":tmp",":faction", slot_faction_reinforcements_b), (party_set_slot, ":town_no", slot_town_reinforcements_b, ":tmp"), (faction_get_slot, ":tmp",":faction", slot_faction_reinforcements_c), (party_set_slot, ":town_no", slot_town_reinforcements_c, ":tmp"), # set center theater according to faction theater - never changes except for advance camps (faction_get_slot, ":tmp", ":faction", slot_faction_home_theater), (party_set_slot, ":town_no", slot_center_theater, ":tmp"), # victory points value on capture/destruction (party_set_slot, ":town_no", slot_party_victory_value, ws_center_vp), # ambient sounds for centers from faction defaults (faction_get_slot, ":tmp", ":faction", slot_faction_ambient_sound_day), (party_set_slot, ":town_no", slot_center_ambient_sound_day, ":tmp"), (faction_get_slot, ":tmp", ":faction", slot_faction_ambient_sound_always), (party_set_slot, ":town_no", slot_center_ambient_sound_always, ":tmp"), (faction_get_slot, ":tmp", ":faction", slot_faction_occasional_sound1_day), (party_set_slot, ":town_no", slot_center_occasional_sound1_day, ":tmp"), (try_end), ]+[ # specific centers ambient sounds (party_set_slot, center_sounds[x][0], slot_center_ambient_sound_day , center_sounds[x][1]) for x in range(len(center_sounds)) ]+[ (party_set_slot, center_sounds[x][0], slot_center_ambient_sound_always, center_sounds[x][2]) for x in range(len(center_sounds)) ]+[ (party_set_slot, center_sounds[x][0], slot_center_occasional_sound1_day,center_sounds[x][3]) for x in range(len(center_sounds)) ]+[ (party_set_slot, subfaction_data[x][1], slot_town_reinforcements_a, subfaction_data[x][4][0]) for x in range(len(subfaction_data)) ]+[ (party_set_slot, subfaction_data[x][1], slot_town_reinforcements_b, subfaction_data[x][4][1]) for x in range(len(subfaction_data)) ]+[ (party_set_slot, subfaction_data[x][1], slot_town_reinforcements_c, subfaction_data[x][4][2]) for x in range(len(subfaction_data)) ]+[ (party_add_members, subfaction_data[x][1], subfaction_data[x][5][y],1) for x in range(len(subfaction_data)) for y in range(len(subfaction_data[x][5])) ]+[ #Initialize walkers (try_for_range, ":center_no", centers_begin, centers_end), (party_slot_eq, ":center_no", slot_party_type, spt_town), (try_for_range, ":walker_no", 0, num_town_walkers), (call_script, "script_center_set_walker_to_type", ":center_no", ":walker_no", walkert_default), (try_end), (try_end), # TLD banner assignment # assign main faction banners to kings, then lords ]+[ (troop_set_slot, faction_init[x][3][0], slot_troop_banner_scene_prop, faction_init[x][6]) for x in range(len(faction_init)) ]+[ (try_for_range, ":kingdom_hero", kingdom_heroes_begin, kingdom_heroes_end), (troop_add_gold,":kingdom_hero",100000), (store_troop_faction, ":kingdom_hero_faction", ":kingdom_hero"), # other heroes get banners like lords, except Rohan & Gondor vassals (which will be overwritten later) (faction_get_slot,":kingdom_leader",":kingdom_hero_faction",slot_faction_leader), (troop_get_slot, ":banner_id", ":kingdom_leader", slot_troop_banner_scene_prop), (troop_set_slot, ":kingdom_hero", slot_troop_banner_scene_prop, ":banner_id"), (store_character_level, ":level", ":kingdom_hero"), (store_mul, ":renown", ":level", ":level"), (val_div, ":renown", 2), (try_begin), (faction_slot_eq, ":kingdom_hero_faction", slot_faction_leader, ":kingdom_hero"), #(troop_set_slot, ":kingdom_hero", slot_troop_loyalty, 100), #InVain: No loyalty in TLD #(store_random_in_range, ":random_renown", 250, 400), (assign, ":renown_bonus", 300), #InVain: no renown randomization, but let's keep the bonus for now until we decide what to do with renown. #(else_try), #(store_random_in_range, ":random_loyalty", 50, 100), #(troop_set_slot, ":kingdom_hero", slot_troop_loyalty, ":random_loyalty"), #InVain: No loyalty in TLD #(store_random_in_range, ":random_renown", 100, 200), (try_end), (val_add, ":renown", ":renown_bonus"), (troop_set_slot, ":kingdom_hero", slot_troop_renown, ":renown"), (store_random_in_range, ":random_readiness", 0, 100), (troop_set_slot, ":kingdom_hero", slot_troop_readiness_to_join_army, ":random_readiness"), (troop_set_slot, ":kingdom_hero", slot_troop_readiness_to_follow_orders, 100), (troop_set_slot, ":kingdom_hero", slot_troop_player_order_state, spai_undefined), (troop_set_slot, ":kingdom_hero", slot_troop_player_order_object, -1), (try_end), # Rohan lord banners (troop_set_slot, "trp_knight_1_9", slot_troop_banner_scene_prop, "spr_banner_f01"), # westfold (troop_set_slot, "trp_knight_1_10", slot_troop_banner_scene_prop, "spr_banner_f05"), # westemnet (troop_set_slot, "trp_knight_1_11", slot_troop_banner_scene_prop, "spr_banner_f02"), # aldburg # (troop_set_slot, "trp_knight_1_12", slot_troop_banner_scene_prop, "spr_banner_ed"), # hama is king's man (troop_set_slot, "trp_knight_1_13", slot_troop_banner_scene_prop, "spr_banner_f06"), # eastfold (troop_set_slot, "trp_knight_1_14", slot_troop_banner_scene_prop, "spr_banner_f07"), # eastemnet # Gondor vassals lord banners (troop_set_slot, "trp_knight_1_1", slot_troop_banner_scene_prop, "spr_banner_ek"), # lamedon (troop_set_slot, "trp_knight_1_3", slot_troop_banner_scene_prop, "spr_banner_er"), # dol amroth (troop_set_slot, "trp_knight_1_4", slot_troop_banner_scene_prop, "spr_banner_en"), # pelargir (troop_set_slot, "trp_knight_1_5", slot_troop_banner_scene_prop, "spr_banner_ed"), # blackroot vale (troop_set_slot, "trp_knight_1_6", slot_troop_banner_scene_prop, "spr_banner_eg"), # pinnath gelin (troop_set_slot, "trp_knight_1_8", slot_troop_banner_scene_prop, "spr_banner_f21"), # lossarnach # fill center slots (try_for_range, ":center_no", centers_begin, centers_end), (store_faction_of_party, ":original_faction", ":center_no"), # (faction_get_slot, ":culture", ":original_faction", slot_faction_culture), # (party_set_slot, ":center_no", slot_center_culture, ":culture"), (party_set_slot, ":center_no", slot_center_original_faction, ":original_faction"), (party_set_slot, ":center_no", slot_center_ex_faction, ":original_faction"), # TLD center guards (faction_get_slot, ":troop", ":original_faction", slot_faction_guard_troop), (party_set_slot, ":center_no", slot_town_guard_troop, ":troop"), (faction_get_slot, ":troop", ":original_faction", slot_faction_archer_troop), (party_set_slot, ":center_no", slot_town_archer_troop, ":troop"), (faction_get_slot, ":troop", ":original_faction", slot_faction_castle_guard_troop), (party_set_slot, ":center_no", slot_town_castle_guard_troop, ":troop"), (try_end), # TLD specific center guards ]+concatenate_scripts([[ (party_set_slot, subfaction_data[x][1], slot_town_guard_troop , subfaction_data[x][3][0]) , (party_set_slot, subfaction_data[x][1], slot_town_archer_troop , subfaction_data[x][3][1]) , (party_set_slot, subfaction_data[x][1], slot_town_castle_guard_troop , subfaction_data[x][3][2]) , (party_set_slot, subfaction_data[x][1],slot_party_subfaction , subfaction_data[x][0]), (party_get_slot, ":weaponsmith", subfaction_data[x][1] , slot_town_weaponsmith), (troop_set_slot, ":weaponsmith", slot_troop_subfaction , subfaction_data[x][0]), (party_get_slot, ":horse_merchant", subfaction_data[x][1] , slot_town_merchant), (troop_set_slot, ":horse_merchant", slot_troop_subfaction , subfaction_data[x][0]), ] for x in range(len(subfaction_data)) ])+[ # rohan towns subfaction assignment (currently, for sake or geographical region identification only) (party_set_slot, "p_town_east_emnet", slot_party_subfaction , subfac_east_emnet), (party_set_slot, "p_town_west_emnet", slot_party_subfaction , subfac_west_emnet), (party_set_slot, "p_town_eastfold", slot_party_subfaction , subfac_eastfold), (party_set_slot, "p_town_westfold", slot_party_subfaction , subfac_westfold), (party_set_slot, "p_town_minas_tirith", slot_town_castle_guard_troop, "trp_steward_guard"), # minas tirith exception (party_set_slot, "p_town_woodsmen_village", slot_town_castle_guard_troop, "trp_i5_woodmen_night_guard"), # woodmen exception # set kingdom_heros status and wealth of heroes and kings (try_for_range, ":troop_id", kingdom_heroes_begin, kingdom_heroes_end), (store_troop_faction, ":faction_id", ":troop_id"), (is_between, ":faction_id", kingdoms_begin, kingdoms_end), (troop_set_slot, ":troop_id", slot_troop_original_faction, ":faction_id"), (troop_set_slot, ":troop_id", slot_troop_occupation, slto_kingdom_hero), # (try_begin), #No wealth in TLD, slot is used for different stuff # (faction_slot_eq, ":faction_id", slot_faction_leader, ":troop_id"), # (troop_set_slot, ":troop_id", slot_troop_wealth, 200000), # (else_try), # (troop_set_slot, ":troop_id", slot_troop_wealth, 60000), # (try_end), (try_end), # Add town garrisons (try_for_range, ":center_no", centers_begin, centers_end), (assign, ":initial_wealth", 20000), #Add initial center wealth (try_begin), (is_between, ":center_no", centers_begin, centers_end), (val_mul, ":initial_wealth", 2), (try_end), (party_set_slot, ":center_no", slot_town_wealth, ":initial_wealth"), (assign, ":garrison_strength", 13), (store_faction_of_party, ":center_faction", ":center_no"), (try_begin), (party_slot_eq, ":center_no", slot_party_type, spt_town), (assign, ":garrison_strength", 80), #InVain, was 20, increased this to initially counter lowered reinforcement rate for towns. (try_end), (try_begin), # TLD: capitals get more #InVain Isn't really needed anymore, since now all centers start at full strength. Keeping it just in case. (faction_slot_eq, ":center_faction", slot_faction_capital, ":center_no"), (assign, ":garrison_strength", 160), #InVain: was 40 (try_end), (party_get_slot, ":garrison_limit", ":center_no", slot_center_garrison_limit), (try_begin), (neg|faction_slot_eq, ":center_faction", slot_faction_side, faction_side_good), (val_mul, ":garrison_limit", 150), (val_div, ":garrison_limit", 100), (try_end), (try_for_range, ":unused", 0, ":garrison_strength"), (call_script, "script_cf_reinforce_party", ":center_no"), (try_begin), #TLD: don't go overboard (party_get_num_companions, ":garrison_size", ":center_no"), (le, ":garrison_limit", ":garrison_size"), (assign, ":garrison_strength", 0), (try_end), (try_end), #Fill town food stores upto 1/2 the limit (call_script, "script_center_get_food_store_limit", ":center_no"), (assign, ":food_store_limit", reg0), (val_div, ":food_store_limit", 2), (party_set_slot, ":center_no", slot_party_food_store, ":food_store_limit"), (try_end), #Retainers Begin #Assign retainers before spawning parties (call_script, "script_assign_retainers"), #Retainers End # spawn some lords in distinct towns, TLD ]+[ (call_script, "script_create_kingdom_hero_party", lords_spawn[x][0], lords_spawn[x][1]) for x in range(len(lords_spawn)) ]+[ # spawn other specific location lords (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (faction_get_slot, ":king", ":fac", slot_faction_leader ), (faction_get_slot, ":marshal", ":fac", slot_faction_marshall ), (faction_get_slot, ":town", ":fac", slot_faction_capital ), (try_begin),(troop_slot_eq, ":king", slot_troop_leaded_party, 0), (str_store_troop_name, s15, ":king"), (str_store_party_name, s16, ":town"), #(display_message, "@deploying king {s15} in {s16}"), (call_script, "script_create_kingdom_hero_party", ":king", ":town"), (try_end), (try_begin),(troop_slot_eq, ":marshal", slot_troop_leaded_party, 0), (str_store_troop_name, s15, ":marshal"), (str_store_party_name, s16, ":town"), #(display_message, "@deploying marshal {s15} in {s16}"), (call_script, "script_create_kingdom_hero_party", ":marshal", ":town"), (try_end), (try_end), # spawn any other lord in random places, TLD (try_for_range, ":hero", kingdom_heroes_begin, kingdom_heroes_end), (troop_slot_eq, ":hero", slot_troop_leaded_party, 0), (store_troop_faction, ":faction", ":hero"), (call_script,"script_cf_select_random_town_with_faction", ":faction"),(assign,":center",reg0), (call_script, "script_create_kingdom_hero_party", ":hero", ":center"), (party_set_slot, ":center", slot_town_player_odds, 1000), (try_end), (try_for_range, ":unused", 0, 8), (call_script, "script_spawn_bandits"), (try_end), (set_spawn_radius, 50), (try_for_range, ":unused", 0, 25), (spawn_around_party,"p_main_party","pt_looters"), (try_end), # generating notes (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end), (call_script, "script_update_faction_notes", ":faction_no"), (store_random_in_range, ":random_no", -60, 0), (faction_set_slot, ":faction_no", slot_faction_ai_last_offensive_time, ":random_no"), (try_end), (try_for_range, ":cur_troop", kingdom_heroes_begin, kingdom_heroes_end), (call_script, "script_update_troop_notes", ":cur_troop"), (try_end), (call_script, "script_update_troop_notes", "trp_player"), (try_for_range, ":cur_center", centers_begin, centers_end), (call_script, "script_update_center_notes", ":cur_center"), (try_end), #MV: good lords are upstanding, Eye sadistic, Hand cunning (try_for_range, ":lord", kingdom_heroes_begin, kingdom_heroes_end), (store_troop_faction, ":lord_faction", ":lord"), (try_begin), (faction_slot_eq, ":lord_faction", slot_faction_side, faction_side_good), (troop_set_slot, ":lord", slot_lord_reputation_type, lrep_upstanding), (else_try), (faction_slot_eq, ":lord_faction", slot_faction_side, faction_side_eye), (troop_set_slot, ":lord", slot_lord_reputation_type, lrep_debauched), (else_try), (troop_set_slot, ":lord", slot_lord_reputation_type, lrep_cunning), (try_end), (try_end), (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end), (call_script, "script_faction_recalculate_strength", ":faction_no"), (try_end), (call_script, "script_get_player_party_morale_values"), (party_set_morale, "p_main_party", reg0), # assigning game global variables (assign, "$g_fangorn_rope_pulled", 0), #(assign, "$g_ent_seen", 0), (assign, "$g_ent_water_ever_drunk", 0), (assign, "$g_ent_water_taking_effect", 0), (assign, "$number_of_player_deaths", 0), (assign, "$g_player_luck", 200), #no luck in TLD (assign, "$disable_npc_complaints", 0), #MV: back to 0 (assign, "$tld_war_began",0), (assign, "$prev_day", 1), (assign, "$dungeons_in_scene", 0), # flag for dungeon presence in a scene (assign, "$found_moria_entrance", 0), (assign, "$current_player_region", -1), (assign, "$spawn_horse", 1), (assign, "$gate_aggravator_agent", 1), #re-used for controlling if aggravators spawn # (assign, "$equip_needs_checking", 1), (assign, "$g_tld_conversations_done", 0), (assign, "$g_tld_gandalf_state", -1), (assign, "$g_tld_nazgul_state", -1), ################ 808 globals (assign, "$trait_captain_infantry_week", 0), (assign, "$trait_captain_archer_week", 0), (assign, "$trait_captain_cavalry_week", 0), (assign, "$trait_check_commands_issued", 0), (assign, "$trait_check_stealth_success", 0), (assign, "$trait_check_unarmored_berserker", 0), (assign, "$trait_check_battle_scarred", 0), # (assign, "$minas_tirith_healing", 0), # (assign, "$edoras_healing" , 0), # (assign, "$isengard_healing" , 0), # (assign, "$morannon_healing" , 0), (assign, "$meta_alarm", 0), (assign, "$alarm_level", 0), (assign, "$rescue_stage", 0), (assign, "$active_rescue", 0), # (assign, "$sorcerer_quest", 0), (assign, "$rescue_wall_battle", 0), (assign, "$rescue_courtyard_scene_2", 0), (assign, "$rescue_stealth_scene_2", 0), (assign, "$wall_mounted_troop1", 0), #(assign, "$wall_mounted_troop2", 0), (assign, "$wall_mounted_troop3", 0), #(assign, "$wall_mounted_troop4", 0), (assign, "$wall_mounted_troop5", 0), (assign, "$wall_missile_troop1", 0), (assign, "$wall_missile_troop2", 0), (assign, "$wall_missile_troop3", 0), (assign, "$wall_missile_troop4", 0), (assign, "$wall_missile_troop5", 0), (assign, "$rescue_convo_troop", 0), #initialize game option defaults (see camp menu) (assign, "$tld_option_crossdressing", 0), # item restrictions ON by default (assign, "$tld_option_formations", 1),# ON by default (assign, "$tld_option_town_menu_hidden", 1), #town features hidden by default (assign, "$tld_option_injuries", 1), #injuries for npcs and player ON by default (assign, "$tld_option_death_npc", 1), #permanent death for npcs ON by default (assign, "$tld_option_death_player", 0), #permanent death for player OFF by default (assign, "$tld_option_cutscenes", 1),# ON by default (assign, "$tld_campaign_diffulty", 1),# default difficulty (assign, "$g_fast_mode", 0),# OFF by default (assign, "$tld_option_morale", 1), # Battle morale ON by default (assign, "$tld_option_animal_ambushes", 1), # Ambushes ON by default (assign, "$wound_setting", 12), # rnd, 0-3 result in wounds (assign, "$healing_setting", 7), # rnd, 0-3 result in wounds (assign, "$initial_party_value", 0), (assign, "$player_side_faction", 0), (assign, "$enemy_side_faction", 0), (assign, "$inital_player_xp", 0), # savegame compartibillity globals. USE THOSE in code if need be # Feel free to rename them... BUT if so rename then in variables.txt BEFORE you compile your code!!! (assign, "$g_fac_str_siegable", fac_str_weak), #when can you siege a faction, increases with player level #(assign, "$battle_renown_total", 0), (assign, "$g_defiled_armor_item", 0), (assign, "$g_defiled_armor_rotation", 0), #these are used for strategic options/tweaks (assign, "$tld_option_siege_reqs", 0), #0,1,2 : Siege strength requirements: Normal/Halved/None (assign, "$tld_option_siege_relax_rate", 100), #50/100/200 : Siege str. req. relaxation rate (assign, "$tld_option_regen_rate", 0), #0,1,2,3 : Str. regen rate: Normal/Halved/Battles only/None (assign, "$tld_option_regen_limit", 500), #500/1000/1500 : Factions don't regen below (assign, "$tld_option_max_parties", 1500), #300/350/400/450...900 : Parties don't spawn after this many parties are on map. (assign, "$creature_ambush_counter", 5), # Starts out at 5 to give early game players some peace. (assign, "$gondor_reinforcement_event",0), #kham - Gondor Reinforcement Event (assign, "$gondor_reinforcement_event_menu",0), #kham - Gondor Reinforcement Event (assign, "$first_time_town", 0), #kham - rumour tutorial box (assign, "$formations_tutorial", 0), #Kham - Formations Tutorial. (assign, "$total_kills",0), #Kham - Kill Counter (assign, "$player_allowed_siege",0), #Kham - Player Initiated Sieges (assign, "$butcher_trait_kills", 0), #Kham - Butcher Trait (assign, "$player_control_allies",0), #Kham - Player Control Allies global (assign, "$show_mount_ko_message",1),#Kham - Show Horse KO Message - Player Damage Only by default (assign, "$dormant_spawn_radius", 1), #Kham - Dormant Spawn Radius initialize (assign, "$tld_player_level_to_begin_war",8), #Kham - Custom Level to Start the War (assign, "$FormAI_AI_no_defense",0), #Kham - FormAI - don't allow AI Defensive (party_set_slot, "p_main_party", slot_party_number_following_player, 0), (assign, "$lore_mode", 1),# unused (assign, "$play_ambient_sounds", 1), #Kham - Squelch compiler warnings (assign, "$original_savegame_version", 0), (assign, "$cheatmode_used", 0), (assign, "$hold_f1", 0), (assign, "$dormant_spawn_radius", 0), (assign, "$mouse_coordinates", 0), #wb only (assign, "$attacker_archer_melee",0), (assign, "$attacker_team_3", 5), (assign, "$rescue_convo_troop", 3), (assign, "$tld_options_overlay_14", 2), (assign, "$g_display_agent_labels", 2), (val_mul, "$hold_f1", "$cheatmode_used"), (val_mul, "$hold_f1", "$original_savegame_version"), (val_mul, "$hold_f1", "$dormant_spawn_radius"), (val_mul, "$hold_f1", "$mouse_coordinates"), (val_mul, "$hold_f1", "$attacker_archer_melee"), (val_mul, "$attacker_archer_melee", "$hold_f1"), (val_mul, "$attacker_archer_melee", "$attacker_team_3"), (val_mul, "$attacker_archer_melee", "$rescue_convo_troop"), (val_mul, "$attacker_archer_melee", "$tld_options_overlay_14"), (val_mul, "$attacker_archer_melee", "$g_display_agent_labels"), (val_mul, "$attacker_archer_melee", "$allies_leadership"), #Kham - Squelch compiler warnings END #(try_for_range, ":beacon", "p_amon_din", "p_spawn_points_end"), # (set_position_delta, -3.0,6.0,65.0), # (party_add_particle_system, ":beacon", "psys_lamp_fire"), #(try_end), #Kham - Initialize Faction War Council slots (try_for_range, ":faction_wc", kingdoms_begin, kingdoms_end), (faction_set_slot, ":faction_wc", slot_faction_war_council, 0), (try_end), # Set Light Armor Slot for Berserker Trait (call_script, "script_set_slot_light_armor"), (assign,"$savegame_version", 40), #Rafa: Savegame version (assign,"$original_savegame_version", "$savegame_version"), ] + (is_a_wb_script==1 and [ #Init WB Only globals (assign, "$bright_nights",1), #Kham - Brighter Nights (assign, "$field_ai_lord",1), #Kham - Battlefield Lord AI (assign, "$field_ai_horse_archer",1), #Kham - Battlefield Horse Archer AI (assign, "$options_horse_archer_ai", "$field_ai_horse_archer"), # Used to keep track of player choice. (assign, "$field_ai_archer_aim",1), #Kham - Battlefield Archer Aim (assign, "$advanced_siege_ai",1), #Kham - Advanced Siege AI - default is ON (assign, "$pref_cam_mode", 0), #Kham - Camera Preference - Default is Default (assign, "$tld_spawn_battle_animals", 1), #Kham - Battle Animals (assign, "$g_display_agent_labels",0), #Kham - Troop Labels for WB #InVain: Disabled (assign, "$show_hide_labels", 0), #Kham - Toggle for Troop Labels (assign, "$batching_check_period", 3000), #Kham - For Batching (assign, "$first_time", 0), #squelch compiler warnings (assign, "$FormAI_autorotate", 1), #Autorotate for New Formations force to 1 (assign, "$player_deploy_troops", 1), #Make sure troops hold when battle starts. (assign, "$FormAI_AI_Control_Troops", 0), #AI Control Dead Player's Troops (FormV5) (assign, "$slow_when_wounded",1), #Kham - Agents get slower when wounded (assign, "$battle_encounter_effects",1), #Kham - Special Effects on Battlefield #Custom Camera Initialize (call_script, "script_init_camera"), (call_script, "script_initialize_guildmaster_companion_strings"), #Kham - Reassign divisions (try_for_range, ":troop_no", soldiers_begin, soldiers_end), (call_script, "script_troop_default_division", ":troop_no", 0), (troop_get_class, ":division", ":troop_no"), (neq, ":division", reg0), (troop_set_class, ":troop_no", reg0), (try_end), #For Field AI Triggers (party_set_slot, "p_main_party", slot_party_pref_wu_lance, 1), (party_set_slot, "p_main_party", slot_party_pref_wu_harcher, 1), (party_set_slot, "p_main_party", slot_party_pref_wu_spear, 1), (party_set_slot, "p_main_party", slot_party_pref_dmg_tweaks, 1), (party_set_slot, "p_main_party", slot_party_pref_div_dehorse, grc_infantry), (party_set_slot, "p_main_party", slot_party_pref_div_no_ammo, grc_infantry), # Squelch Compiler Warnings (assign, "$g_custom_armor_param_count", 0), (assign, "$g_custom_armor_param_count", 0), (assign, "$g_custom_armor_mandatory", 1), ##Init Custom Armors## (try_for_range, ":item_no", "itm_gondor_custom", "itm_stones_siege"), (item_set_slot, ":item_no", slot_item_player_color, 0), (item_set_slot, ":item_no", slot_item_num_components, 1), #allows it to be customized (try_end), (item_set_slot, "itm_gondor_custom", slot_item_materials_begin, "str_gondor1"), (item_set_slot, "itm_gondor_custom", slot_item_materials_end, "str_gondor_end"), (item_set_slot, "itm_gondor_custom", slot_item_init_script, -1), (item_set_slot, "itm_gondor_custom", slot_item_num_components, 1), (item_set_slot, "itm_white_tunic_a", slot_item_player_color, 1), (item_set_slot, "itm_white_tunic_a", slot_item_num_components, 1), (item_set_slot, "itm_white_tunic_a", slot_item_materials_begin, "str_dale_coat"), (item_set_slot, "itm_white_tunic_a", slot_item_materials_end, "str_dale_coat_end"), (troop_set_slot, "trp_townsman", slot_troop_has_custom_armour, 1), (troop_set_slot, "trp_watchman", slot_troop_has_custom_armour, 1), (troop_set_slot, "trp_walker_woman_rohan_t", slot_troop_has_custom_armour, 1), (troop_set_slot, "trp_walker_woman_rohan_d", slot_troop_has_custom_armour, 1), (troop_set_slot, "trp_walker_woman_gondor_b", slot_troop_has_custom_armour, 1), (troop_set_slot, "trp_walker_woman_gondor_bw", slot_troop_has_custom_armour, 1), (item_set_slot, "itm_rhun_armor_a", slot_item_player_color, 1), (item_set_slot, "itm_rhun_armor_a", slot_item_num_components, 1), (item_set_slot, "itm_rhun_armor_a", slot_item_materials_begin, "str_rhunarmortexture_fem"), (item_set_slot, "itm_rhun_armor_a", slot_item_materials_end, "str_female_mats_end"), (item_set_slot, "itm_rhun_armor_b", slot_item_player_color, 1), (item_set_slot, "itm_rhun_armor_b", slot_item_num_components, 1), (item_set_slot, "itm_rhun_armor_b", slot_item_materials_begin, "str_rhunarmortexture_fem"), (item_set_slot, "itm_rhun_armor_b", slot_item_materials_end, "str_female_mats_end"), (item_set_slot, "itm_rhun_armor_d", slot_item_player_color, 1), (item_set_slot, "itm_rhun_armor_d", slot_item_num_components, 1), (item_set_slot, "itm_rhun_armor_d", slot_item_materials_begin, "str_rhunarmortexture_fem"), (item_set_slot, "itm_rhun_armor_d", slot_item_materials_end, "str_female_mats_end"), (item_set_slot, "itm_beorn_berserk", slot_item_player_color, 1), (item_set_slot, "itm_beorn_berserk", slot_item_num_components, 1), (item_set_slot, "itm_beorn_berserk", slot_item_materials_begin, "str_beornings_female"), (item_set_slot, "itm_beorn_berserk", slot_item_materials_end, "str_khand_light_fem"), (item_set_slot, "itm_khand_light", slot_item_player_color, 1), (item_set_slot, "itm_khand_light", slot_item_num_components, 1), (item_set_slot, "itm_khand_light", slot_item_materials_begin, "str_khand_light_fem"), (item_set_slot, "itm_khand_light", slot_item_materials_end, "str_npc18_intro"), #Init HP shield (try_for_range, ":has_hp_shield", heroes_begin, heroes_end), (troop_set_slot, ":has_hp_shield", slot_troop_hp_shield, 200), (try_end), (try_for_range, ":has_hp_shield", trp_aragorn, trp_gimli+1), (troop_set_slot, ":has_hp_shield", slot_troop_hp_shield, 200), (troop_set_slot, ":has_hp_shield", slot_troop_has_combat_ai, 1), (try_end), (troop_set_slot, "trp_nazgul", slot_troop_hp_shield, 1000000), (troop_set_slot, "trp_killer_witcher", slot_troop_hp_shield, 200), (troop_set_slot, "trp_badass_theo", slot_troop_hp_shield, 200), (call_script, "script_get_hp_shield_value", "trp_moria_troll"), (call_script, "script_get_hp_shield_value", "trp_mordor_olog_hai"), (call_script, "script_get_hp_shield_value", "trp_isen_armored_troll"), (call_script, "script_get_hp_shield_value", "trp_ent"), (try_for_range, ":trolls", trp_moria_troll, trp_multiplayer_profile_troop_male), (call_script, "script_get_hp_shield_value", ":trolls"), (try_end), (troop_set_slot, "trp_i5_beorning_carrock_berserker", slot_troop_hp_shield, 30), (troop_set_slot, "trp_i6_isen_uruk_berserker", slot_troop_hp_shield, 30), (troop_set_slot, "trp_i4_gunda_orc_berserker", slot_troop_hp_shield, 20), (troop_set_slot, "trp_i5_khand_pit_master", slot_troop_hp_shield, 30), (troop_set_slot, "trp_player", slot_troop_hp_shield, 1), (troop_set_slot, "trp_black_numenorean_sorcerer", slot_troop_hp_shield, 100), (troop_set_slot, "trp_orc_pretender", slot_troop_hp_shield, 50), (try_for_range, ":NPC_hp_shield", "trp_npc1", heroes_begin), (troop_set_slot, ":NPC_hp_shield", slot_troop_hp_shield, 1), (try_end), (try_for_range, ":NPC_hp_shield", "trp_npc18", "trp_werewolf"), (troop_set_slot, ":NPC_hp_shield", slot_troop_hp_shield, 1), (try_end), #Init Health Regeneration on Kill (assign, "$g_wp_player_hr_active", 1), # Set to 0 to prevent player regeneration. 1 to activate. (assign, "$g_wp_ai_hr_active", 1), # Set to 0 to prevent AI regeneration. 1 to activate. # Init Advanced Combat AI (try_for_range, ":has_combat_ai", kingdom_heroes_begin, kingdom_heroes_end), (troop_set_slot, ":has_combat_ai", slot_troop_has_combat_ai, 1), (try_end), (troop_set_slot, "trp_npc5", slot_troop_has_combat_ai, 1), #Glorfindel (troop_set_slot, "trp_npc13", slot_troop_has_combat_ai, 1), #Lykyada (troop_set_slot, "trp_black_numenorean_sorcerer", slot_troop_has_combat_ai, 1), (troop_set_slot, "trp_nazgul", slot_troop_has_combat_ai, 1), (troop_set_slot, "trp_badass_theo", slot_troop_has_combat_ai, 1), (troop_set_slot, "trp_killer_witcher", slot_troop_has_combat_ai, 1), ] or []) + [ #Squelch MB 1.011 Compiler Warnings ] + ((not is_a_wb_script==1) and [ (assign, "$bright_nights", 1), (assign, "$show_key_binds_toggle", 0), (assign, "$g_last_archery_point_earned", 0), (assign, "$tutorial_num_total_dummies_destroyed", 0), (val_add, "$bright_nights", "$show_key_binds_toggle"), (val_add, "$g_last_archery_point_earned", "$show_key_binds_toggle"), (val_add, "$show_key_binds_toggle", "$bright_nights"), (val_add, "$tutorial_num_total_dummies_destroyed", "$g_last_archery_point_earned"), ] or []) + [ #Squelch MB 1.011 Compiler Warnings END ]), # script_refresh_volunteers_in_town (mtarini and others) ("refresh_volunteers_in_town",[ (store_script_param_1, ":town"), # Rafa note: notice town existence is not checked here (party_get_slot, ":volunteers", ":town", slot_town_volunteer_pt), (try_begin), (ge,":volunteers",0), # Rafa: if slot_town_volunteer_pt < 0 we don't reinforce (store_faction_of_party, ":fac", ":town"), # friendly towns only (store_relation, ":rel", ":fac", "$players_kingdom"), #MV fixed (ge, ":rel", 0), (assign,reg0,":town"), #(display_message,"@Beginning the reinforcement phase for {reg0}"), (try_begin), # Rafa: Invalid volunteer party number correction, needed for legacy support (gt, ":volunteers", 0), (call_script,"script_cf_neg_1p","script_cf_party_exists",":volunteers"), # doesn't exists #(neg|party_is_active,":volunteers"), (assign, ":volunteers", 0), #(display_message,"@Found an invalid party at {reg0}, fixing"), (try_end), (try_begin), # If a volunteer party still doesn't exists, create one (eq, ":volunteers", 0), #(display_message,"@Creating a party on {reg0}"), (call_script, "script_create_volunteers_party",":town",0), (assign,":volunteers",reg0), #(display_message,"@Volunteers party id:{reg0}"), #(party_is_active, ":town"), #(spawn_around_party, ":town", "pt_volunteers"), #Kham - use actual party template instead of 'none' #(assign, ":volunteers", reg0), #(party_attach_to_party, ":volunteers", ":town"), #(party_set_slot, ":town", slot_town_volunteer_pt, ":volunteers"), ##(party_set_name, ":volunteers", "@Volunteers"), # was "@_+_" # Kham - no need to rename as we created an actual party template #(party_set_flags, ":volunteers", pf_no_label), #(party_set_ai_behavior, ":volunteers", ai_bhvr_hold), #(store_faction_of_party, ":town_fac", ":town"), #(try_begin), # (faction_slot_eq, ":town_fac", slot_faction_side, faction_side_good), # (str_store_string, s4, "@Volunteers"), # (str_store_string, s3, "@--- Volunteers ---"), #(else_try), # (str_store_string, s4, "@Reserves"), # (str_store_string, s3, "@--- Reserves ---"), #(try_end), #(party_set_name, ":volunteers", "@{s4}"), #(troop_set_name, "trp_volunteers", s3), (try_end), #(eq,0,1), ## debug: failing on pourpose (gt,":volunteers",0), # Rafa: a very crude handling of the volunteer's party not being created # compute ideal number of volunteers #InVain: Adjusted to account for bigger starting garrison sizes, putting more weight on player progress #current formula is =((garrison/10 + rank*5 + leadership*10) * (relation*2+100))/1000 +3 (store_party_size_wo_prisoners, ":to_add", ":town"), (val_div, ":to_add", 10), (call_script, "script_get_faction_rank", ":fac"), (assign, ":rank", reg0), (val_mul, ":rank", 5), (val_add, ":to_add", ":rank"), (store_skill_level, ":lead_bonus", "skl_leadership", "trp_player"), (val_mul, ":lead_bonus", 10), (val_add, ":to_add", ":lead_bonus"), # orc bonus #(assign, ":is_orc_faction", 0), (try_begin), (this_or_next|eq, ":fac", "fac_mordor"), (this_or_next|eq, ":fac", "fac_isengard"), (this_or_next|eq, ":fac", "fac_moria"), (this_or_next|eq, ":fac", "fac_guldur"), (eq, ":fac", "fac_gundabad"), #(assign, ":is_orc_faction", 1), (val_mul, ":to_add", 120), (val_div, ":to_add", 100), #+20% for orc factions #InVain: Not sure if still needed (due to huge orc starting garrisons), but let's keep it for now. (else_try), (this_or_next|eq, ":fac", "fac_imladris"), (this_or_next|eq, ":fac", "fac_lorien"), (eq, ":fac", "fac_woodelf"), (val_mul, ":to_add", 80), (val_div, ":to_add", 100), #-20% for elf factions (try_end), # town relations bonus +size*rel/100 (party_get_slot, ":center_relation", ":town", slot_center_player_relation), (val_mul, ":center_relation", 2), #Invain (val_add, ":center_relation", 100), (val_mul, ":to_add", ":center_relation"), (val_div, ":to_add", 1000), (val_add, ":to_add", 3), #add some extra, so the below code still works (volunteers don't fill up if less than 4) (val_max, ":to_add", 6), #additional saveguard #] + (is_a_wb_script==1 and [ (try_begin), #campaign AI (difficulty setting) (assign, ":campaign_ai", "$tld_campaign_diffulty"), (val_add, ":campaign_ai", 3), (val_mul, ":to_add", ":campaign_ai"), (val_div, ":to_add", 4), (try_end), #] or []) + [ #(assign, ":ideal_size", ":to_add"), (store_party_size, ":vol_total", ":volunteers"), #InVain: before adding new volunteers, we train the old ones, using the same formula as above (without garrison size) (store_add, ":vol_xp", ":rank", ":lead_bonus"), (val_mul, ":vol_xp", ":center_relation"), (party_get_num_companion_stacks, ":vol_stacks", ":volunteers"), (val_mul, ":vol_xp", ":vol_stacks"), #multiply with number of stacks, because xp are distributed among stacks, not troops (val_div, ":vol_xp", 80), (party_upgrade_with_xp, ":volunteers", ":vol_xp", 0), # compute how many soldiers to add to volunteers (val_sub, ":to_add", ":vol_total"), # how many troops to add/remove to volunteers (in theory) (val_mul, ":to_add", 2), (val_div, ":to_add", 3), # fill 2/3 of the gap per time (store_random_in_range, ":rand", 0, 5), (val_add, ":rand", -2), (val_add, ":to_add", ":rand"), # plus random -2 .. +2 (store_add, ":target_size", ":vol_total", ":to_add"), (party_get_slot, ":recruit_template", ":town", slot_town_recruits_pt), (try_begin), (party_is_active, ":town"), (gt, ":to_add", 0), # add volunteers! # this is to simulate slower growth for smaller templates (e.g. rangers) (store_div, ":reinf_rounds", ":to_add", 3), #average troops per template is 3-4; need minimum of 3 to actually reinforce (try_for_range, ":unused", 0, ":reinf_rounds"), (try_begin), (store_party_size, ":current_size", ":volunteers"), (le, ":target_size", ":current_size"), (assign, ":reinf_rounds", 0), #stop reinforcing if already too many (else_try), (party_add_template, ":volunteers", ":recruit_template"), (try_end), (try_end), (store_party_size, ":current_size", ":volunteers"), #for every volunteer, remove a t1 or t2 troop from the garrison (store_sub, ":to_remove", ":current_size", ":vol_total"), #how many volunteers were added? (faction_get_slot, ":t_1_troop", ":fac", slot_faction_tier_1_troop), (party_count_members_of_type, ":t_1_count", ":town", ":t_1_troop"), (party_remove_members, ":town", ":t_1_troop", ":to_remove"), (try_begin), (lt, ":t_1_count", ":to_remove"), (party_remove_members, ":town", ":t_1_troop", ":to_remove"), (val_sub, ":to_remove", ":t_1_count"), (faction_get_slot, ":t_2_troop", ":fac", slot_faction_tier_2_troop), (party_remove_members, ":town", ":t_2_troop", ":to_remove"), (try_end), #(store_party_size, ":vol_total", ":volunteers"), # recompute for the benefit of puny orcs below (else_try), (lt, ":to_add", 0), # remove volunteers! #MV: kept this code, effect: a trickle of player recruits joins the garrison (val_mul, ":to_add", -1), (try_for_range, ":unused", 0, ":to_add"), (call_script, "script_cf_party_select_random_regular_troop", ":volunteers"), (assign, ":guy", reg0), # can fail (try_begin), #Kham - When the chosen one is Volunteer, let us run the script again (eq, ":guy", "trp_volunteers"), (call_script, "script_cf_party_select_random_regular_troop", ":volunteers"), (assign, ":guy", reg0), (try_end), (neq, ":guy", "trp_volunteers"), #Kham - If it is still the volunteer, then just prevent him from being moved. (party_remove_members_wounded_first, ":volunteers", ":guy", 1), (party_add_members, ":town", ":guy", 1), (try_end), (try_end), # add a couple of orc volunteers each day #InVain: Let's not do this, it clutters the volunteers party # (try_begin), # (eq, ":is_orc_faction", 1), # (gt, ":ideal_size", ":vol_total"), #only if needed # (faction_get_slot, ":puny_orc", ":fac", slot_faction_tier_1_troop), # (gt, ":puny_orc", 0), # (party_add_members, ":volunteers", ":puny_orc", 2), # (try_end), #Remove highest level troop every day (counters volunteer training going overboard) (party_get_num_companion_stacks, ":num_stacks", ":volunteers"), (assign, ":highest_level", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":volunteers", ":i_stack"), (store_character_level, ":troop_level", ":stack_troop"), (party_stack_get_size, ":stack_size", ":volunteers", ":i_stack"), (try_begin), #limit number of higher level volunteers (gt, ":troop_level", 10), (gt, ":stack_size", 2), (party_remove_members_wounded_first, ":volunteers", ":stack_troop", 1), (faction_get_slot, ":t_2_troop", ":fac", slot_faction_tier_2_troop), (party_add_members, ":town", ":t_2_troop", 1), #we stay fair - add a basic troop to the garrison (try_end), (gt, ":troop_level", ":highest_level"), (assign, ":highest_level", ":troop_level"), (assign, ":highest_level_troop", ":stack_troop"), (assign, ":highest_level_stack_size", ":stack_size"), (try_end), (ge, ":highest_level", 6), #affects t2 troops (orcs: t3) (val_mul, ":highest_level", ":highest_level_stack_size"), (store_random_in_range, ":random", 0, 100), (le, ":random", ":highest_level"), (party_remove_members_wounded_first, ":volunteers", ":highest_level_troop", 1), (faction_get_slot, ":t_2_troop", ":fac", slot_faction_tier_2_troop), (party_add_members, ":town", ":t_2_troop", 1), #we stay fair - add a basic troop to the garrison #(str_store_party_name, s1, ":town"), #(str_store_troop_name, s2, ":highest_level_troop"), #(display_message, "@{s1}: removed volunteer {s2}"), (try_begin), #umbar reward helm spawns black numenoreans for hire (troop_has_item_equipped, "trp_player", "itm_umb_helm_reward"), (troop_get_type, ":player_race", "trp_player"), #only if player is human (neg|is_between, ":player_race", tf_orc_begin, tf_orc_end), (this_or_next|eq, ":fac", fac_mordor), #only in Mordor and eye factions (this_or_next|eq, ":fac", fac_guldur), (is_between, ":fac", fac_harad, fac_moria), (call_script, "script_get_faction_rank", ":fac"), #from rank 2 upwards (ge, reg0, 2), (assign, ":num_numenor_troops", 0), (try_for_range, ":numenor_troop", "trp_i2_mordor_num_renegade", "trp_noldorin_commander"), (party_count_members_of_type, reg1, ":volunteers",":numenor_troop"), (val_add, ":num_numenor_troops", reg1), (try_end), (le, ":num_numenor_troops", 5), (store_attribute_level, ":player_charisma", "trp_player", ca_charisma), (val_mul, ":player_charisma", 2), (store_random_in_range, ":chance", 0, 100), (le, ":chance", ":player_charisma"), (val_div, ":chance", 20), (val_max, ":chance", 1), (party_add_members, ":volunteers", "trp_i2_mordor_num_renegade", ":chance"), # (str_store_party_name, s5, ":town"), # (display_message, "@Black Numenorean added to {s5}"), (try_end), (try_end), ]), # script_game_event_party_encounter: # This script is called from the game engine whenever player party encounters another party or a battle on the world map # INPUT: # param1: encountered_party # param2: second encountered_party (if this was a battle ("game_event_party_encounter", [ (store_script_param_1, "$g_encountered_party"), (store_script_param_2, "$g_encountered_party_2"),# encountered_party2 is set when we come across a battle or siege, otherwise it's a negative value (party_get_current_terrain, "$current_player_terrain","p_main_party"), (call_script, "script_get_region_of_party","p_main_party"),(assign, "$current_player_region", reg1), (call_script, "script_get_close_landmark","p_main_party"), (assign, "$current_player_landmark", reg0), # if camping very close to a town, enter town instead... (try_begin), (eq, "$g_encountered_party", "p_camp_bandits" ), (lt, "$g_encountered_party_2", 0 ), (is_between, "$current_player_landmark", centers_begin, centers_end), (store_distance_to_party_from_party, ":party_distance", "p_main_party", "$current_player_landmark"), (lt, ":party_distance", 1), (assign, "$g_encountered_party", "$current_player_landmark" ), (try_end), #(str_store_party_name, s15, "$g_encountered_party"),(display_message, "@event_party_encounter: {s15}"), (call_script, "script_player_meets_party","$g_encountered_party"), # to set resource points (mtarini) #(store_encountered_party, "$g_encountered_party"), #(store_encountered_party2,"$g_encountered_party_2"), # encountered_party2 is set when we come across a battle or siege, otherwise it's a minus value (store_faction_of_party, "$g_encountered_party_faction","$g_encountered_party"), (store_relation, "$g_encountered_party_relation", "$g_encountered_party_faction", "fac_player_faction"), (party_get_slot, "$g_encountered_party_type", "$g_encountered_party", slot_party_type), (party_get_template_id,"$g_encountered_party_template","$g_encountered_party"), #(try_begin), # (gt, "$g_encountered_party_2", 0), # (store_faction_of_party, "$g_encountered_party_2_faction","$g_encountered_party_2"), # (store_relation, "$g_encountered_party_2_relation", "$g_encountered_party_2_faction", "fac_player_faction"), # (party_get_template_id,"$g_encountered_party_2_template","$g_encountered_party_2"), #(else_try), # (assign, "$g_encountered_party_2_faction",-1), # (assign, "$g_encountered_party_2_relation", 0), # (assign,"$g_encountered_party_2_template", -1), #(try_end), #NPC companion changes begin (call_script, "script_party_count_fit_regulars", "p_main_party"), (assign, "$playerparty_prebattle_regulars", reg0), (assign, "$g_last_rest_center", -1), (assign, "$talk_context", 0), (assign,"$g_player_surrenders",0), (assign,"$g_enemy_surrenders",0), (assign, "$g_leave_encounter",0), (assign, "$g_engaged_enemy", 0), (try_begin), (neg|is_between, "$g_encountered_party", centers_begin, centers_end), (rest_for_hours, 0), #stop waiting (try_end), (assign, "$new_encounter", 1), #check this in the menu. (assign, "$prebattle_talk_done",0), #check this in the menu. (try_begin), (lt, "$g_encountered_party_2",0), #Normal encounter. Not battle or siege. (try_begin),(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town ), (party_slot_eq, "$g_encountered_party", slot_center_destroyed, 0), (jump_to_menu, "mnu_castle_outside"), (else_try),(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town), (party_slot_eq, "$g_encountered_party", slot_center_destroyed, 1), (jump_to_menu, "mnu_town_ruins"), (else_try),(party_slot_eq, "$g_encountered_party", slot_party_type, spt_cattle_herd),(jump_to_menu, "mnu_cattle_herd"), #MV: DON'T REMOVE (else_try),(eq, "$g_encountered_party", "p_test_scene" ),(jump_to_menu, "mnu_test_scene"), (else_try),(eq, "$g_encountered_party", "p_battlefields" ),(jump_to_menu, "mnu_battlefields"), #(else_try),(eq, "$g_encountered_party", "p_training_ground"),(jump_to_menu, "mnu_tutorial"), (else_try),(eq, "$g_encountered_party", "p_camp_bandits" ),(jump_to_menu, "mnu_camp"), (else_try),(eq, "$g_encountered_party", "p_ancient_ruins" ),(jump_to_menu, "mnu_ancient_ruins"), #TLD sorcerer (else_try),(eq, "$g_encountered_party_template", "pt_ruins"),(jump_to_menu, "mnu_ruins"), #TLD ruins (else_try),(eq, "$g_encountered_party_template", "pt_village"),(jump_to_menu, "mnu_village_quest"), ## TLD Defend / Raid Village Quests- Kham (else_try),(this_or_next|eq, "$g_encountered_party_template", "pt_scout_camp_small"),(eq, "$g_encountered_party_template", "pt_scout_camp_large"),(jump_to_menu, "mnu_scout_camp_quest"), ## TLD Destroy Scout Camp Quests- Kham (else_try),(eq, "$g_encountered_party", "p_ring_hunter_lair"),(jump_to_menu, "mnu_ring_hunter_lair"), ## TLD Ring Hunters Quest - Lair (kham) (else_try),(eq, "$g_encountered_party", "p_raft"),(jump_to_menu, "mnu_raftmen"), ## TLD Raftmen - Amath Dollen (Kham) # (else_try),(try_for_range, ":beacon", "p_amon_din", "p_spawn_points_end"), (eq, "$g_encountered_party", ":beacon"), (jump_to_menu, "mnu_gondor_beacons"),(try_end), ## TLD Gondor Beacons - Kham (else_try),(eq, "$g_encountered_party_template", "pt_legendary_place"),(jump_to_menu, "mnu_legendary_place"), #TLD legendary places (else_try),(eq, "$g_encountered_party_template", "pt_mound"),(jump_to_menu, "mnu_burial_mound"), #TLD 808 (else_try),(eq, "$g_encountered_party_template", "pt_pyre" ),(jump_to_menu, "mnu_funeral_pyre"), #TLD 808 (else_try),(eq, "$g_encountered_party", "p_old_ford" ),(jump_to_menu, "mnu_camp"), (else_try),(eq, "$g_encountered_party_template", "pt_refugees"),(jump_to_menu, "mnu_refugees_quest"), #Kham (else_try),(jump_to_menu, "mnu_simple_encounter"), (try_end), (else_try), #Battle or siege (try_begin), (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), (try_begin), (eq, "$auto_enter_town", "$g_encountered_party"), (jump_to_menu, "mnu_town"), (else_try), (eq, "$auto_besiege_town", "$g_encountered_party"), (jump_to_menu, "mnu_besiegers_camp_with_allies"), (else_try), (jump_to_menu, "mnu_join_siege_outside"), (try_end), (else_try), (jump_to_menu, "mnu_pre_join"), (try_end), (try_end), (assign,"$auto_enter_town",0), (assign,"$auto_besiege_town",0), ]), #script_game_event_simulate_battle: # This script is called whenever the game simulates the battle between two parties on the map. # INPUT: # param1: Defender Party # param2: Attacker Party ("game_event_simulate_battle",[ (store_script_param_1, ":root_defender_party"), (store_script_param_2, ":root_attacker_party"), (try_begin), (this_or_next|neg|party_is_active,":root_defender_party"), (neg|party_is_active,":root_attacker_party"), (set_trigger_result, 1), (else_try), (store_faction_of_party, ":defender_faction", ":root_defender_party"), (store_faction_of_party, ":attacker_faction", ":root_attacker_party"), (neq, ":defender_faction", "fac_player_faction"), (neq, ":attacker_faction", "fac_player_faction"), (store_relation, ":reln", ":defender_faction", ":attacker_faction"), (ge, ":reln", 0), (set_trigger_result, 1), (else_try), (assign, ":trigger_result", 0), (try_begin), (this_or_next|eq, "$g_battle_simulation_cancel_for_party", ":root_defender_party"), (eq, "$g_battle_simulation_cancel_for_party", ":root_attacker_party"), (assign, "$g_battle_simulation_cancel_for_party", -1), (assign, "$auto_enter_town", "$g_battle_simulation_auto_enter_town_after_battle"), (assign, ":trigger_result", 1), (else_try), (try_begin), (this_or_next|party_slot_eq, ":root_defender_party", slot_party_retreat_flag, 1), (party_slot_eq, ":root_attacker_party", slot_party_retreat_flag, 1), (assign, ":trigger_result", 1), #End battle! (try_end), (party_set_slot, ":root_attacker_party", slot_party_retreat_flag, 0), ## (assign, ":cancel_attack", 0), (party_collect_attachments_to_party, ":root_defender_party", "p_collective_ally"), (party_collect_attachments_to_party, ":root_attacker_party", "p_collective_enemy"), # (call_script, "script_party_count_fit_for_battle", "p_collective_ally"), (call_script, "script_party_calculate_strength", "p_collective_ally", 0), (assign, ":defender_strength", reg0), # (call_script, "script_party_count_fit_for_battle", "p_collective_enemy"), (call_script, "script_party_calculate_strength", "p_collective_enemy", 0), (assign, ":attacker_strength", reg0), (store_add, ":total_strength", ":defender_strength", ":attacker_strength"), (val_div, ":total_strength", 40), (val_max, ":total_strength", 50), (store_div, ":defender_strength", ":defender_strength", 20), (val_min, ":defender_strength", ":total_strength"), #InVain: Make max invested strength per round scale with overall battle scale. (val_max, ":defender_strength", 1), (store_div, ":attacker_strength", ":attacker_strength", 20), (val_min, ":attacker_strength", ":total_strength"), #InVain: Make max invested strength per round scale with overall battle scale. (val_add, ":attacker_strength", 1), (try_begin), #For sieges increase attacker casualties and reduce defender casualties. (this_or_next|party_slot_eq, ":root_defender_party", slot_party_type, spt_castle), (party_slot_eq, ":root_defender_party", slot_party_type, spt_town), #(val_mul, ":defender_strength", 123), #it was 1.5 in old version, now it is only 1.23 #(val_div, ":defender_strength", 100), (val_mul, ":attacker_strength", 2), #it was 0.5 in old version, now it is only 1 / 1.23 (val_div, ":attacker_strength", 3), (store_character_level, ":player_level", "trp_player"), #Invain: Make attackers more powerful with player level (val_mul, ":player_level", 3), (val_min, ":attacker_strength", ":player_level"), (party_slot_eq, ":root_attacker_party", slot_party_type, spt_guardian), #guardian parties take 3x less casualties in sieges (val_div, ":defender_strength", 3), (try_end), (call_script, "script_party_count_fit_for_battle", "p_collective_ally", 0), (assign, ":old_defender_strength", reg0), (try_begin), # night in TLD is primary WAR TIME =)! GA # (neg|is_currently_night), #Don't fight at night (inflict_casualties_to_party_group, ":root_attacker_party", ":defender_strength", "p_temp_casualties"), (party_collect_attachments_to_party, ":root_attacker_party", "p_collective_enemy"), (try_end), (call_script, "script_party_count_fit_for_battle", "p_collective_enemy", 0), (assign, ":new_attacker_strength", reg0), (try_begin), #make sure leader dies last, so their skills apply (gt, ":new_attacker_strength", 0), (party_stack_get_troop_id, ":party_leader", ":root_attacker_party", 0), (is_between, ":party_leader", soldiers_begin, trp_last), #just to be sure (troop_is_hero, ":party_leader"), (troop_set_health, ":party_leader", 100), (try_end), (try_begin), (gt, ":new_attacker_strength", 0), # night in TLD is primary WAR TIME =)! GA # (neg|is_currently_night), #Don't fight at night (inflict_casualties_to_party_group, ":root_defender_party", ":attacker_strength", "p_temp_casualties"), (party_collect_attachments_to_party, ":root_defender_party", "p_collective_ally"), (try_end), (call_script, "script_party_count_fit_for_battle", "p_collective_ally", 0), (assign, ":new_defender_strength", reg0), (try_begin), #make sure leader dies last, so their skills apply (gt, ":new_defender_strength", 0), (party_stack_get_troop_id, ":party_leader", ":root_defender_party", 0), (is_between, ":party_leader", soldiers_begin, trp_last), #just to be sure (troop_is_hero, ":party_leader"), (troop_set_health, ":party_leader", 100), (try_end), (try_begin), (this_or_next|eq, ":new_attacker_strength", 0), (eq, ":new_defender_strength", 0), # Battle concluded! determine winner (assign, ":do_not_end_battle", 0), (try_begin), (neg|troop_is_wounded, "trp_player"), (eq, ":new_defender_strength", 0), (eq, "$auto_enter_town", "$g_encountered_party"), (eq, ":old_defender_strength", ":new_defender_strength"), (assign, ":do_not_end_battle", 1), (try_end), (eq, ":do_not_end_battle", 0), (try_begin), (eq, ":new_attacker_strength", 0), (eq, ":new_defender_strength", 0), (assign, ":root_winner_party", -1), (assign, ":root_defeated_party", -1), (assign, ":collective_casualties", -1), (else_try), (eq, ":new_attacker_strength", 0), (assign, ":root_winner_party", ":root_defender_party"), (assign, ":root_defeated_party", ":root_attacker_party"), (assign, ":collective_casualties", "p_collective_enemy"), (else_try), (assign, ":root_winner_party", ":root_attacker_party"), (assign, ":root_defeated_party", ":root_defender_party"), (assign, ":collective_casualties", "p_collective_ally"), (try_end), (party_clear, "p_temp_party"), (try_begin), (ge, ":root_winner_party", 0), (call_script, "script_get_nonempty_party_in_group", ":root_winner_party"), (assign, ":nonempty_winner_party", reg0), (call_script, "script_remove_empty_parties_in_group", ":root_winner_party"), #GA: purge all empty winner parties, stash prisoners to p_temp_party (store_faction_of_party, ":faction_receiving_prisoners", ":nonempty_winner_party"), (store_faction_of_party, ":defeated_faction", ":root_defeated_party"), (else_try), (assign, ":nonempty_winner_party", -1), (try_end), (try_begin), (ge, ":collective_casualties", 0), (assign, "$g_move_heroes", 1), (party_set_faction, "p_temp_party", ":faction_receiving_prisoners"), (call_script, "script_party_add_party_prisoners", "p_temp_party", ":collective_casualties"), (call_script, "script_party_prisoners_add_party_companions", "p_temp_party", ":collective_casualties", 0), (try_end), (try_begin), (ge, ":collective_casualties", 0), (party_get_num_companion_stacks, ":num_stacks", ":collective_casualties"), (else_try), (assign, ":num_stacks", 0), (try_end), (try_for_range, ":troop_iterator", 0, ":num_stacks"), (party_stack_get_troop_id, ":cur_troop_id", ":collective_casualties", ":troop_iterator"), (troop_is_hero, ":cur_troop_id"), (call_script, "script_remove_troop_from_prison", ":cur_troop_id"), (troop_set_slot, ":cur_troop_id", slot_troop_leaded_party, -1), (store_current_day, ":day_of_defeat"), (troop_set_slot, ":cur_troop_id", slot_troop_respawn_timer, ":day_of_defeat"), (store_random_in_range, ":rand", 0, 100), (str_store_troop_name_link, s1, ":cur_troop_id"), (str_store_faction_name_link, s2, ":faction_receiving_prisoners"), (store_troop_faction, ":defeated_troop_faction", ":cur_troop_id"), (str_store_faction_name_link, s3, ":defeated_troop_faction"), (try_begin), (ge, ":rand", hero_escape_after_defeat_chance), (party_stack_get_troop_id, ":leader_troop_id", ":nonempty_winner_party", 0), (is_between, ":leader_troop_id", kingdom_heroes_begin, kingdom_heroes_end), #disable non-kingdom parties capturing enemy lords # (party_add_prisoners, ":nonempty_winner_party", ":cur_troop_id", 1), #TLD: lords captured will later be moved to prisoner train (gt, reg0, 0), #(troop_set_slot, ":cur_troop_id", slot_troop_is_prisoner, 1), (troop_set_slot, ":cur_troop_id", slot_troop_prisoner_of_party, ":nonempty_winner_party"), (display_log_message, "str_hero_taken_prisoner"), (else_try), (party_remove_members, "p_temp_party", ":cur_troop_id", 1), #TLD: lords captured will later be moved to prisoner train (try_begin), (store_relation, ":rel", "$players_kingdom", ":defeated_troop_faction"), (lt, ":rel", 0), (assign, ":news_color", color_good_news), (else_try), (assign, ":news_color", color_bad_news), (try_end), (try_begin), (neq, "$g_fast_mode", 1), (display_message,"@{s1} of {s3} was defeated in battle.", ":news_color"), (try_end), #(display_message,"@{s1} of {s3} was defeated in battle but managed to escape.", ":news_color"), ######################## map heroes injuries and deaths (eq, "$tld_option_death_npc", 1), # if death option is available (store_random_in_range,":rnd",0,100), (try_begin), (store_character_level, ":player_level", "trp_player"), #InVain: Scale lord death chance with player level (val_sub, ":player_level", 10), (val_div, ":player_level", 2), (lt,":rnd", ":player_level"), (is_between, ":cur_troop_id", "trp_knight_1_1", kingdom_heroes_end), #kings and marshals cannot die for now (store_troop_faction, ":cur_troop_faction", ":cur_troop_id"), (neg|faction_slot_eq, ":cur_troop_faction", slot_faction_marshall, ":cur_troop_id"), #make sure it's not a marshall # MV: additional random chance to survive if there are too few lords in the faction (assign, ":total_lords", 0), # exclude non-active kings, but count himself (try_for_range, ":some_lord", kingdom_heroes_begin, kingdom_heroes_end), (store_troop_faction, ":some_lord_faction", ":some_lord"), (eq, ":some_lord_faction", ":cur_troop_faction"), # is not a king OR is a marshall (=don't count non-active kings) (this_or_next|neg|faction_slot_eq, ":some_lord_faction", slot_faction_leader, ":some_lord"), (faction_slot_eq, ":some_lord_faction", slot_faction_marshall, ":some_lord"), (neg|troop_slot_eq, ":some_lord", slot_troop_wound_mask, wound_death), #not dead (val_add, ":total_lords", 1), (try_end), # 1 lord left (him) 0%, 2 lords left 10% (some small factions),... 6 lords left 50% chance to die (store_random_in_range,":rnd_last_chance",0,100), (store_sub, ":last_chance", ":total_lords", 1), (val_mul, ":last_chance", 10), (lt, ":rnd_last_chance", ":last_chance"), # die for real? (gt, ":nonempty_winner_party", 0), (call_script, "script_hero_leader_killed_abstractly", ":cur_troop_id",":nonempty_winner_party"), (try_end), (try_end), (try_begin), (store_troop_faction, ":cur_troop_faction", ":cur_troop_id"), (faction_slot_eq, ":cur_troop_faction", slot_faction_marshall, ":cur_troop_id"), (faction_set_slot, ":cur_troop_faction", slot_faction_scripted_until, 0), (faction_get_slot, ":theater", ":cur_troop_faction", slot_faction_active_theater), #Marshall is defeated, refresh ai. (assign, "$g_recalculate_ais", ":theater"), (try_end), (try_end), (try_begin), (ge, ":collective_casualties", 0), (party_get_num_prisoner_stacks, ":num_stacks", ":collective_casualties"), (else_try), (assign, ":num_stacks", 0), (try_end), (try_for_range, ":troop_iterator", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":cur_troop_id", ":collective_casualties", ":troop_iterator"), (troop_is_hero, ":cur_troop_id"), (call_script, "script_remove_troop_from_prison", ":cur_troop_id"), (store_troop_faction, ":cur_troop_faction", ":cur_troop_id"), (str_store_troop_name_link, s1, ":cur_troop_id"), (str_store_faction_name_link, s2, ":faction_receiving_prisoners"), (str_store_faction_name_link, s3, ":cur_troop_faction"), (display_log_message,"str_hero_freed"), (try_end), (try_begin), # TLD: spawn prisoner train (store_party_size, ":size", "p_temp_party"), (gt, ":size", 0), (try_begin), (store_party_size_wo_prisoners, ":comps", "p_temp_party"), (val_sub, ":size", ":comps"), (gt, ":size", 0), (is_between, ":faction_receiving_prisoners", kingdoms_begin, kingdoms_end), (faction_get_slot, ":prisoner_train_pt", ":faction_receiving_prisoners", slot_faction_prisoner_train), (neq, ":prisoner_train_pt", -1), (set_spawn_radius, 1), (spawn_around_party, ":nonempty_winner_party", ":prisoner_train_pt"), (assign, ":prisoner_train", reg0), (party_set_faction, ":prisoner_train", ":faction_receiving_prisoners"), (party_set_slot, ":prisoner_train", slot_party_victory_value, ws_p_train_vp), (party_set_slot, ":prisoner_train", slot_party_type, spt_prisoner_train), (assign, "$g_move_heroes", 0), #MV set to 0, lords escape (call_script, "script_party_prisoners_add_party_prisoners", ":prisoner_train", "p_temp_party"), (call_script, "script_party_remove_all_prisoners", "p_temp_party"), (call_script, "script_find_random_nearby_friendly_town", ":prisoner_train", 1), # (str_store_faction_name, s1, ":faction_receiving_prisoners"), # (party_set_name, ":prisoner_train", "@{s1} Prisoner Train"), (party_set_slot, ":prisoner_train", slot_party_ai_state, spai_undefined), (party_set_ai_behavior, ":prisoner_train", ai_bhvr_travel_to_party), (party_set_ai_object, ":prisoner_train", reg0), (party_set_slot, ":prisoner_train", slot_party_ai_object, reg0), (party_set_flags, ":prisoner_train", pf_default_behavior, 0), (try_end), (try_begin), (gt, ":root_winner_party", 0), (distribute_party_among_party_group, "p_temp_party", ":root_winner_party"), (try_end), # TLD: spawn prisoner train end (try_end), (call_script, "script_clear_party_group", ":root_defeated_party", ":faction_receiving_prisoners"), (assign, ":trigger_result", 1), #End battle! #Center captured (try_begin), (ge, ":collective_casualties", 0), (party_get_slot, ":cur_party_type", ":root_defeated_party", slot_party_type), (this_or_next|eq, ":cur_party_type", spt_town), (eq, ":cur_party_type", spt_castle), (store_faction_of_party, ":winner_faction", ":root_winner_party"), (store_faction_of_party, ":defeated_faction", ":root_defeated_party"), (faction_set_slot, ":winner_faction", slot_faction_scripted_until, 0), (faction_get_slot, ":faction_theater", ":winner_faction", slot_faction_active_theater), (assign, "$g_recalculate_ais", ":faction_theater"), (try_begin), (party_get_slot, ":center_theater", ":root_defeated_party", slot_center_theater), (neq, ":center_theater", ":faction_theater"), (assign, "$g_recalculate_ais", ":center_theater"), (try_end), (str_store_party_name, s1, ":root_defeated_party"), (str_store_faction_name, s2, ":winner_faction"), (str_store_faction_name, s3, ":defeated_faction"), (try_begin), (store_relation, ":rel", "$players_kingdom", ":winner_faction"), (gt, ":rel", 0), (assign, ":news_color", color_good_news), (play_sound, "snd_enemy_lord_dies"), (else_try), (assign, ":news_color", color_bad_news), (play_sound, "snd_lord_dies"), (try_end), (try_begin), (party_slot_ge, ":root_defeated_party", slot_center_destroy_on_capture, 1), (display_log_message, "@{s2} have razed {s1}!", ":news_color"), (else_try), (display_log_message, "str_center_captured", ":news_color"), (try_end), (try_begin), (eq, "$g_encountered_party", ":root_defeated_party"), ## (display_message, "@Player participation in siege called from g_encountered_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), ## (eq, "$g_encountered_party_2", ":root_defeated_party"), ## (display_message, "@Player participation in siege called from game_event_simulate_battle thanks to g_encountered_party"), ## (try_end), ## (try_begin), ## (eq, "$g_enemy_party", ":root_defeated_party"), ## (display_message, "@Player participation in siege called from game_event_simulate_battle thanks to g_encountered_party"), ## (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", kingdom_heroes_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), (try_begin), #TLD: if center destroyable, disable it, otherwise proceed as normal (party_slot_ge, ":root_defeated_party", slot_center_destroy_on_capture, 1), (call_script, "script_destroy_center", ":root_defeated_party"), (else_try), (call_script, "script_give_center_to_faction", ":root_defeated_party", ":winner_faction"), (call_script, "script_order_best_besieger_party_to_guard_center", ":root_defeated_party", ":winner_faction"), # add a small garrison (try_begin), (eq, ":winner_faction", "$players_kingdom"), (try_for_range, ":unused", 0, 10), #InVain: higher, to counter lowered reinforcement rate. Was 5 (call_script, "script_cf_reinforce_party", ":root_defeated_party"), (try_end), (else_try), (try_for_range, ":unused", 0, 20), #InVain: higher, to counter lowered reinforcement rate. Was 5 (call_script, "script_cf_reinforce_party", ":root_defeated_party"), (try_end), (try_end), (try_end), (try_end), (try_end), #ADD XP (try_begin), (party_slot_eq, ":root_attacker_party", slot_party_type, spt_kingdom_hero_party), (store_random_in_range, ":random_num",0, 100), (lt, ":random_num", 25), (gt, ":new_attacker_strength", 0), (call_script, "script_upgrade_hero_party", ":root_attacker_party", 1000), (try_end), (try_begin), (party_slot_eq, ":root_defender_party", slot_party_type, spt_kingdom_hero_party), (store_random_in_range, ":random_num",0, 100), (lt, ":random_num", 25), (gt, ":new_defender_strength", 0), (call_script, "script_upgrade_hero_party", ":root_defender_party", 1000), (try_end), (try_begin), #ozan - do not randomly end battles aganist towns or castles. (neg|party_slot_eq, ":root_defender_party", slot_party_type, spt_castle), #added by ozan (neg|party_slot_eq, ":root_defender_party", slot_party_type, spt_town), #added by ozan #end ozan (party_get_slot, ":attacker_root_strength", ":root_attacker_party", slot_party_cached_strength), (party_get_slot, ":attacker_nearby_friend_strength", ":root_attacker_party", slot_party_nearby_friend_strength), (party_get_slot, ":strength_of_attacker_followers", ":root_attacker_party", slot_party_follower_strength), (store_add, ":total_attacker_strength", ":attacker_root_strength", ":attacker_nearby_friend_strength"), (val_add, ":total_attacker_strength", ":strength_of_attacker_followers"), (party_get_slot, ":defender_root_strength", ":root_defender_party", slot_party_cached_strength), (party_get_slot, ":defender_nearby_friend_strength", ":root_defender_party", slot_party_nearby_friend_strength), (party_get_slot, ":strength_of_defender_followers", ":root_defender_party", slot_party_follower_strength), (store_add, ":total_defender_strength", ":defender_root_strength", ":defender_nearby_friend_strength"), (val_add, ":total_attacker_strength", ":strength_of_defender_followers"), #Players can make save loads and change history because these random values are not determined from random_slots of troops (store_random_in_range, ":random_num", 0, 100), (try_begin), (lt, ":random_num", 10), #not when retreat parties are involved (party_get_template_id, ":attacker_party_template", ":root_attacker_party"), (party_get_template_id, ":defender_party_template", ":root_defender_party"), (neq, ":attacker_party_template", "pt_retreat_troops"), (neq, ":defender_party_template", "pt_retreat_troops"), (assign, ":trigger_result", 1), #End battle! (try_end), (else_try), (party_get_slot, ":attacker_root_strength", ":root_attacker_party", slot_party_cached_strength), (party_get_slot, ":attacker_nearby_friend_strength", ":root_attacker_party", slot_party_nearby_friend_strength), (party_get_slot, ":strength_of_followers", ":root_attacker_party", slot_party_follower_strength), (store_add, ":total_attacker_strength", ":attacker_root_strength", ":attacker_nearby_friend_strength"), (val_add, ":total_attacker_strength", ":strength_of_followers"), (party_get_slot, ":defender_root_strength", ":root_defender_party", slot_party_cached_strength), (party_get_slot, ":defender_nearby_friend_strength", ":root_defender_party", slot_party_nearby_friend_strength), (store_add, ":total_defender_strength", ":defender_root_strength", ":defender_nearby_friend_strength"), (val_mul, ":total_defender_strength", 13), #multiply defender strength with 1.3 (val_div, ":total_defender_strength", 10), (gt, ":total_defender_strength", ":total_attacker_strength"), (gt, ":total_defender_strength", 3), #Players can make save loads and change history because these random values are not determined from random_slots of troops (store_random_in_range, ":random_num", 0, 100), (try_begin), (lt, ":random_num", 5), #15% is a bit higher than 10% (which is open area escape probability) #not when retreat parties are involved (party_get_template_id, ":attacker_party_template", ":root_attacker_party"), (party_get_template_id, ":defender_party_template", ":root_defender_party"), (neq, ":attacker_party_template", "pt_retreat_troops"), (neq, ":defender_party_template", "pt_retreat_troops"), (assign, ":trigger_result", 1), #End battle! (call_script, "script_find_theater", ":root_defender_party"), (assign, "$g_recalculate_ais", reg0), #added new (try_end), (try_end), (try_end), (set_trigger_result, ":trigger_result"), (try_end), ]), #script_game_event_battle_end: # This script is called whenever the game ends the battle between two parties on the map. # INPUT: # param1: Defender Party # param2: Attacker Party ("game_event_battle_end",[ (store_script_param_1, ":root_defender_party"), (store_script_param_2, ":root_attacker_party"), #Fixing deleted heroes (try_for_range, ":cur_troop", kingdom_heroes_begin, kingdom_heroes_end), (troop_get_slot, ":cur_party", ":cur_troop", slot_troop_leaded_party), (troop_get_slot, ":cur_prisoner_of_party", ":cur_troop", slot_troop_prisoner_of_party), (try_begin), (ge, ":cur_party", 0), (assign, ":continue", 0), (try_begin), (neg|party_is_active, ":cur_party"), (assign, ":continue", 1), (else_try), (party_count_companions_of_type, ":amount", ":cur_party", ":cur_troop"), (le, ":amount", 0), (assign, ":continue", 1), (try_end), (eq, ":continue", 1), (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, s1, ":cur_troop"), (display_message, "@DEBUG: {s1} no longer leads a party."), (try_end), (troop_set_slot, ":cur_troop", slot_troop_leaded_party, -1), (try_end), (try_begin), (ge, ":cur_prisoner_of_party", 0), (assign, ":continue", 0), (try_begin), (neg|party_is_active, ":cur_prisoner_of_party"), (assign, ":continue", 1), (else_try), (party_count_prisoners_of_type, ":amount", ":cur_prisoner_of_party", ":cur_troop"), (le, ":amount", 0), (assign, ":continue", 1), (try_end), (eq, ":continue", 1), (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, s1, ":cur_troop"), (display_message, "@DEBUG: {s1} is no longer a prisoner."), (try_end), (call_script, "script_remove_troop_from_prison", ":cur_troop"), #searching player (try_begin), (party_count_prisoners_of_type, ":amount", "p_main_party", ":cur_troop"), (gt, ":amount", 0), (troop_set_slot, ":cur_troop", slot_troop_prisoner_of_party, "p_main_party"), (assign, ":continue", 0), (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, s1, ":cur_troop"), (display_message, "@DEBUG: {s1} is now a prisoner of player."), (try_end), (try_end), (eq, ":continue", 1), #searching kingdom heroes (try_for_range, ":cur_troop_2", kingdom_heroes_begin, kingdom_heroes_end), (eq, ":continue", 1), (troop_get_slot, ":cur_prisoner_of_party_2", ":cur_troop_2", slot_troop_leaded_party), (party_is_active, ":cur_prisoner_of_party_2"), (party_count_prisoners_of_type, ":amount", ":cur_prisoner_of_party_2", ":cur_troop"), (gt, ":amount", 0), (troop_set_slot, ":cur_troop", slot_troop_prisoner_of_party, ":cur_prisoner_of_party_2"), (assign, ":continue", 0), (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, s1, ":cur_troop"), (str_store_party_name, s2, ":cur_prisoner_of_party_2"), (display_message, "@DEBUG: {s1} is now a prisoner of {s2}."), (try_end), (try_end), #searching walled centers (try_for_range, ":cur_prisoner_of_party_2", centers_begin, centers_end), (party_slot_eq, ":cur_prisoner_of_party_2", slot_center_destroyed, 0), #TLD - not destroyed (eq, ":continue", 1), (party_count_prisoners_of_type, ":amount", ":cur_prisoner_of_party_2", ":cur_troop"), (gt, ":amount", 0), (troop_set_slot, ":cur_troop", slot_troop_prisoner_of_party, ":cur_prisoner_of_party_2"), (assign, ":continue", 0), (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, s1, ":cur_troop"), (str_store_party_name, s2, ":cur_prisoner_of_party_2"), (display_message, "@DEBUG: {s1} is now a prisoner of {s2}."), (try_end), (try_end), (try_end), (try_end), (try_begin), #if a cover party miraculously survives, turn it into a regular scout party (assign, ":scout_party", 0), (try_begin), (party_is_active, ":root_attacker_party"), (party_get_template_id, ":attacker_party_template", ":root_attacker_party"), (eq, ":attacker_party_template", "pt_retreat_troops"), (assign, ":scout_party", ":root_attacker_party"), (else_try), (party_is_active, ":root_defender_party"), (party_get_template_id, ":defender_party_template", ":root_defender_party"), (eq, ":defender_party_template", "pt_retreat_troops"), (assign, ":scout_party", ":root_defender_party"), (try_end), (gt, ":scout_party", 0), (party_set_slot, ":scout_party", slot_party_type, spt_scout), (faction_get_slot, ":capital", "$players_kingdom", slot_faction_capital), (party_set_slot, ":scout_party", slot_party_home_center, ":capital"), #er... something (party_set_slot, ":scout_party", slot_party_victory_value, ws_scout_vp), # victory points for party kill (party_set_faction, ":scout_party", "$players_kingdom"), (str_store_faction_name, s1, "$players_kingdom"), (party_set_name, ":scout_party", "@{s1} Scouts"), (party_set_slot, ":scout_party", slot_party_ai_object, ":capital"), (party_set_slot, ":scout_party", slot_party_ai_state, spai_undefined), (party_set_ai_behavior, ":scout_party", ai_bhvr_patrol_location), (party_set_ai_patrol_radius, ":scout_party", 30), (try_end), ]), #script_order_best_besieger_party_to_guard_center: # INPUT: param1: defeated_center, param2: winner_faction ("order_best_besieger_party_to_guard_center",[ (store_script_param, ":defeated_center", 1), (store_script_param, ":winner_faction", 2), (assign, ":best_party", -1), (assign, ":best_party_strength", 0), (try_for_range, ":kingdom_hero", kingdom_heroes_begin, kingdom_heroes_end), (troop_get_slot, ":kingdom_hero_party", ":kingdom_hero", slot_troop_leaded_party), (gt, ":kingdom_hero_party", 0), (store_distance_to_party_from_party, ":dist", ":kingdom_hero_party", ":defeated_center"), (lt, ":dist", 5), (store_faction_of_party, ":kingdom_hero_party_faction", ":kingdom_hero_party"), (eq, ":winner_faction", ":kingdom_hero_party_faction"), #If marshall has captured the castle, then do not leave him behind. (neg|faction_slot_eq, ":winner_faction", slot_faction_marshall, ":kingdom_hero"), (assign, ":has_besiege_ai", 0), (try_begin), (party_slot_eq, ":kingdom_hero_party", slot_party_ai_state, spai_besieging_center), (party_slot_eq, ":kingdom_hero_party", slot_party_ai_object, ":defeated_center"), (assign, ":has_besiege_ai", 1), (else_try), (party_slot_eq, ":kingdom_hero_party", slot_party_ai_state, spai_accompanying_army), (party_get_slot, ":kingdom_hero_party_commander_party", ":kingdom_hero_party", slot_party_commander_party), (party_slot_eq, ":kingdom_hero_party_commander_party", slot_party_ai_state, spai_besieging_center), (party_slot_eq, ":kingdom_hero_party_commander_party", slot_party_ai_object, ":defeated_center"), (assign, ":has_besiege_ai", 1), (try_end), (eq, ":has_besiege_ai", 1), (party_get_slot, ":kingdom_hero_party_strength", ":kingdom_hero_party", slot_party_cached_strength),#recently calculated (gt, ":kingdom_hero_party_strength", ":best_party_strength"), (assign, ":best_party_strength", ":kingdom_hero_party_strength"), (assign, ":best_party", ":kingdom_hero_party"), (try_end), (try_begin), (gt, ":best_party", 0), (call_script, "script_party_set_ai_state", ":best_party", spai_holding_center, ":defeated_center"), (party_set_slot, ":best_party", slot_party_commander_party, -1), (party_set_flags, ":best_party", pf_default_behavior, 1), (try_end), ]), #script_game_get_item_buy_price_factor: # This script is called from the game engine for calculating the buying price of any item. # INPUT: param1: item_kind_id # OUTPUT: trigger_result and reg0 = price_factor ("game_get_item_buy_price_factor", [ (store_script_param_1, ":item_kind_id"), (assign, ":price_factor", 100), (call_script, "script_get_trade_penalty", ":item_kind_id"), (assign, ":trade_penalty", reg0), (try_begin), (is_between, "$g_encountered_party", centers_begin, centers_end), (is_between, ":item_kind_id", trade_goods_begin, trade_goods_end), (store_sub, ":item_slot_no", ":item_kind_id", trade_goods_begin), (val_add, ":item_slot_no", slot_town_trade_good_prices_begin), (party_get_slot, ":price_factor", "$g_encountered_party", ":item_slot_no"), (val_mul, ":price_factor", 100), #normalize price factor to range 0..100 (val_div, ":price_factor", average_price_factor), (try_end), (store_add, ":penalty_factor", 100, ":trade_penalty"), (val_mul, ":price_factor", ":penalty_factor"), (val_div, ":price_factor", 100), (assign, reg0, ":price_factor"), (set_trigger_result, reg0), ]), #script_game_get_item_sell_price_factor: # This script is called from the game engine for calculating the selling price of any item. # INPUT: param1: item_kind_id # OUTPUT: trigger_result and reg0 = price_factor ("game_get_item_sell_price_factor", [ (store_script_param_1, ":item_kind_id"), # (assign, ":price_factor", 100), # (call_script, "script_get_trade_penalty", ":item_kind_id"), # (assign, ":trade_penalty", reg0), # (try_begin), # (is_between, "$g_encountered_party", centers_begin, centers_end), # (is_between, ":item_kind_id", trade_goods_begin, trade_goods_end), # (store_sub, ":item_slot_no", ":item_kind_id", trade_goods_begin), # (val_add, ":item_slot_no", slot_town_trade_good_prices_begin), # (party_get_slot, ":price_factor", "$g_encountered_party", ":item_slot_no"), # (val_mul, ":price_factor", 100),#normalize price factor to range 0..100 # (val_div, ":price_factor", average_price_factor), # (else_try), # (val_mul, ":trade_penalty", 4), #increase trade penalty while selling # (try_end), # (store_add, ":penalty_divisor", 100, ":trade_penalty"), # (val_mul, ":price_factor", 100), # (val_div, ":price_factor", ":penalty_divisor"), (party_get_skill_level, ":trade_skill", "p_main_party", skl_trade), #trade skill adds 5% per level up to 100% price (val_mul, ":trade_skill", 5), (store_add, reg0, 50, ":trade_skill"), # (store_faction_of_party,":faction","$g_encountered_party"), (faction_get_slot, ":faction_mask", "$ambient_faction", slot_faction_mask),# items of wrong faction are less valuable when selling (item_get_slot,":item_faction_mask",":item_kind_id",slot_item_faction), (val_and,":item_faction_mask",":faction_mask"), (try_begin), (eq,":item_faction_mask",0), (val_div, reg0,5), # discount for wrong faction items 80% (try_end), (val_min, reg0, 100), (set_trigger_result, reg0), ]), # script_get_trade_penalty # Input: param1 troop_id, # Output: reg0 ("get_trade_penalty", [ (store_script_param_1, ":item_kind_id"), (assign, ":penalty",0), (party_get_skill_level, ":trade_skill", "p_main_party", skl_trade), (try_begin), (is_between, ":item_kind_id", trade_goods_begin, trade_goods_end), (assign, ":penalty",20), (store_mul, ":skill_bonus", ":trade_skill", 1), (val_sub, ":penalty", ":skill_bonus"), (else_try), (assign, ":penalty",100), (store_mul, ":skill_bonus", ":trade_skill", 5), (val_sub, ":penalty", ":skill_bonus"), (try_end), (assign, ":penalty_multiplier", 1000), ## # Apply penalty if player is hostile to merchants faction ## (store_relation, ":merchants_reln", "fac_merchants", "fac_player_supporters_faction"), ## (try_begin), ## (lt, ":merchants_reln", 0), ## (store_sub, ":merchants_reln_dif", 10, ":merchants_reln"), ## (store_mul, ":merchants_relation_penalty", ":merchants_reln_dif", 20), ## (val_add, ":penalty_multiplier", ":merchants_relation_penalty"), ## (try_end), # Apply penalty if player is on bad terms with the town (try_begin), (is_between, "$g_encountered_party", centers_begin, centers_end), (party_get_slot, ":center_relation", "$g_encountered_party", slot_center_player_relation), (store_mul, ":center_relation_penalty", ":center_relation", -3), (val_add, ":penalty_multiplier", ":center_relation_penalty"), (try_begin), (lt, ":center_relation", 0), (store_sub, ":center_penalty_multiplier", 100, ":center_relation"), (val_mul, ":penalty_multiplier", ":center_penalty_multiplier"), (val_div, ":penalty_multiplier", 100), (try_end), (try_end), # Apply penalty if player is on bad terms with the merchant (not currently used) (call_script, "script_troop_get_player_relation", "$g_talk_troop"), (assign, ":troop_reln", reg0), #(troop_get_slot, ":troop_reln", "$g_talk_troop", slot_troop_player_relation), (try_begin), (lt, ":troop_reln", 0), (store_sub, ":troop_reln_dif", 0, ":troop_reln"), (store_mul, ":troop_relation_penalty", ":troop_reln_dif", 20), (val_add, ":penalty_multiplier", ":troop_relation_penalty"), (try_end), (val_mul, ":penalty", ":penalty_multiplier"), (val_div, ":penalty", 1000), (val_max, ":penalty", 1), (assign, reg0, ":penalty"), ]), #script_game_event_buy_item: # This script is called from the game engine when player buys an item. # INPUT: param1: item_kind_id ("game_event_buy_item", [ (store_script_param_1, ":item_kind_id"), (store_script_param_2, ":reclaim_mode"), (try_begin), (is_between, ":item_kind_id", trade_goods_begin, trade_goods_end), (store_sub, ":item_slot_no", ":item_kind_id", trade_goods_begin), (val_add, ":item_slot_no", slot_town_trade_good_prices_begin), (party_get_slot, ":multiplier", "$g_encountered_party", ":item_slot_no"), (try_begin), (eq, ":reclaim_mode", 0), (val_add, ":multiplier", 10), (else_try), (val_add, ":multiplier", 15), (try_end), (val_min, ":multiplier", maximum_price_factor), (party_set_slot, "$g_encountered_party", ":item_slot_no", ":multiplier"), (try_end), # (assign, "$equip_needs_checking", 1), #TLD, need to check ]), #script_game_event_sell_item: # This script is called from the game engine when player sells an item. # INPUT: param1 = item_kind_id ("game_event_sell_item", [ (store_script_param_1, ":item_kind_id"), (store_script_param_2, ":return_mode"), (try_begin), (is_between, ":item_kind_id", trade_goods_begin, trade_goods_end), (store_sub, ":item_slot_no", ":item_kind_id", trade_goods_begin), (val_add, ":item_slot_no", slot_town_trade_good_prices_begin), (party_get_slot, ":multiplier", "$g_encountered_party", ":item_slot_no"), (try_begin), (eq, ":return_mode", 0), (val_sub, ":multiplier", 15), (else_try), (val_sub, ":multiplier", 10), (try_end), (val_max, ":multiplier", minimum_price_factor), (party_set_slot, "$g_encountered_party", ":item_slot_no", ":multiplier"), (try_end), ]), # script_game_get_prisoner_price # This script is called from the game engine for calculating prisoner price # Input: param1 = troop_id, # Output: reg0 ("game_get_prisoner_price", [ (store_script_param_1, ":troop_id"), (assign, reg0, 50), (try_begin), (store_character_level, ":troop_level", ":troop_id"), (assign, ":ransom_amount", ":troop_level"), (val_add, ":ransom_amount", 10), (val_mul, ":ransom_amount", ":ransom_amount"), (val_div, ":ransom_amount", 6), (assign, reg0, ":ransom_amount"), (try_end), (set_trigger_result, reg0), ]), # script_game_check_prisoner_can_be_sold # This script is called from the game engine for checking if a given troop can be sold. # Input: param1: troop_id, # Output: reg0: 1= can be sold; 0= cannot be sold. ("game_check_prisoner_can_be_sold", [ (store_script_param_1, ":troop_id"), (assign, reg0, 0), (try_begin), (neg|troop_is_hero, ":troop_id"), (assign, reg0, 1), (try_end), (set_trigger_result, reg0), ]), #script_game_event_detect_party: # This script is called from the game engine when player party inspects another party. # INPUT: param1 = Party-id ("game_event_detect_party", [ (store_script_param_1, ":party_id"), (try_begin), (party_slot_eq, ":party_id", slot_party_type, spt_kingdom_hero_party), (party_stack_get_troop_id, ":leader", ":party_id", 0), (is_between, ":leader", kingdom_heroes_begin, kingdom_heroes_end), (call_script, "script_update_troop_location_notes", ":leader", 0), (else_try), (is_between, ":party_id", centers_begin, centers_end), (party_get_num_attached_parties, ":num_attached_parties", ":party_id"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":party_id", ":attached_party_rank"), (party_stack_get_troop_id, ":leader", ":attached_party", 0), (is_between, ":leader", kingdom_heroes_begin, kingdom_heroes_end), (call_script, "script_update_troop_location_notes", ":leader", 0), (try_end), (try_end), ]), #script_game_event_undetect_party: # This script is called from the game engine when player party inspects another party. # INPUT: param1 = Party-id ("game_event_undetect_party", [ (store_script_param_1, ":party_id"), (try_begin), (party_slot_eq, ":party_id", slot_party_type, spt_kingdom_hero_party), (party_stack_get_troop_id, ":leader", ":party_id", 0), (is_between, ":leader", kingdom_heroes_begin, kingdom_heroes_end), (call_script, "script_update_troop_location_notes", ":leader", 0), (try_end), ]), #script_game_get_statistics_line: # This script is called from the game engine when statistics page is opened. # INPUT: param1 = line_no ("game_get_statistics_line", [ (store_script_param_1, ":line_no"), (try_begin), (eq, ":line_no", 0), (assign, reg1, "$number_of_player_deaths"), (store_sub, reg2, reg1, 1), (str_store_string, s1, "@Left for dead but miraculously survived: {reg1?{reg1} time{reg2?s:}:NEVER}"), (set_result_string, s1), # skip line 1, for a sspacer (else_try), (eq, ":line_no", 2), (get_player_agent_kill_count, reg1), (str_store_string, s1, "str_number_of_troops_killed_reg1"), (set_result_string, s1), (else_try), (eq, ":line_no", 3), (get_player_agent_kill_count, reg1, 1), (str_store_string, s1, "str_number_of_troops_wounded_reg1"), (set_result_string, s1), (else_try), (eq, ":line_no", 4), (get_player_agent_own_troop_kill_count, reg1), (str_store_string, s1, "str_number_of_own_troops_killed_reg1"), (set_result_string, s1), (else_try), (eq, ":line_no", 5), (get_player_agent_own_troop_kill_count, reg1, 1), (str_store_string, s1, "str_number_of_own_troops_wounded_reg1"), (set_result_string, s1), # (else_try), # (eq, ":line_no", 5), # test!! # (get_player_agent_own_troop_kill_count, reg1, 1), # (str_store_string, s1, "@So let's think of something worth keeping track of!"), # (set_result_string, s1), (try_end), ]), #script_game_get_date_text: # This script is called from the game engine when the date needs to be displayed. # INPUT: arg1 = number of days passed since the beginning of the game # OUTPUT: result string = date # TLD: used Steward's Reckoning!!! -- mtarini ("game_get_date_text", [ (store_script_param_2, ":num_hours"), (store_div, ":num_days", ":num_hours", 24), (store_add, ":cur_day", ":num_days", 15), (assign, ":cur_month", 7), (assign, ":cur_year", 3018), # -- osgiliath conquered by mordor in 3018 -- mtarini (assign, ":try_range", 99999), (try_for_range, ":unused", 0, ":try_range"), (try_begin), # the 5 "one day months" (this_or_next|eq, ":cur_month", 1), (this_or_next|eq, ":cur_month", 5), (this_or_next|eq, ":cur_month", 9), (this_or_next|eq, ":cur_month",13), (eq, ":cur_month",17), (assign, ":month_day_limit", 1), (else_try), # normal othor months have 30 days (assign, ":month_day_limit", 30), (try_end), (try_begin), (gt, ":cur_day", ":month_day_limit"), (val_sub, ":cur_day", ":month_day_limit"), (val_add, ":cur_month", 1), (try_begin), (gt, ":cur_month", 17), (val_sub, ":cur_month", 17), (val_add, ":cur_year", 1), (try_end), (else_try), (assign, ":try_range", 0), (try_end), (try_end), (assign, reg1, ":cur_day"), (assign, reg2, ":cur_year"), (try_begin),(eq, ":cur_month", 1), (str_store_string, s1, "str_calendar_spec_day_1"), (else_try) ,(eq, ":cur_month", 2), (str_store_string, s1, "str_january_reg1_reg2"), (else_try) ,(eq, ":cur_month", 3), (str_store_string, s1, "str_february_reg1_reg2"), (else_try) ,(eq, ":cur_month", 4), (str_store_string, s1, "str_march_reg1_reg2"), (else_try) ,(eq, ":cur_month", 5), (str_store_string, s1, "str_calendar_spec_day_2"), (else_try) ,(eq, ":cur_month", 6), (str_store_string, s1, "str_april_reg1_reg2"), (else_try) ,(eq, ":cur_month", 7), (str_store_string, s1, "str_may_reg1_reg2"), (else_try) ,(eq, ":cur_month", 8), (str_store_string, s1, "str_june_reg1_reg2"), (else_try) ,(eq, ":cur_month", 9), (str_store_string, s1, "str_calendar_spec_day_3"), (else_try) ,(eq, ":cur_month",10), (str_store_string, s1, "str_july_reg1_reg2"), (else_try) ,(eq, ":cur_month",11), (str_store_string, s1, "str_august_reg1_reg2"), (else_try) ,(eq, ":cur_month",12), (str_store_string, s1, "str_september_reg1_reg2"), (else_try) ,(eq, ":cur_month",13), (str_store_string, s1, "str_calendar_spec_day_4"), (else_try) ,(eq, ":cur_month",14), (str_store_string, s1, "str_october_reg1_reg2"), (else_try) ,(eq, ":cur_month",15), (str_store_string, s1, "str_november_reg1_reg2"), (else_try) ,(eq, ":cur_month",16), (str_store_string, s1, "str_december_reg1_reg2"), (else_try) ,(eq, ":cur_month",17), (str_store_string, s1, "str_calendar_spec_day_5"), (try_end), (set_result_string, s1), ]), #script_game_get_money_text: # This script is called from the game engine when an amount of money needs to be displayed. # INPUT: arg1 = amount in units # OUTPUT: result string = money in text ("game_get_money_text", [ (store_script_param_1, ":amount"), (str_store_faction_name, s2, "$ambient_faction"), (try_begin), (eq, ":amount", 1), (str_store_string, s1, "@1 Res.Pt ({s2})"), #(str_store_string, s1, "str_1_denar"), (else_try), (assign, reg1, ":amount"), (str_store_string, s1, "@{reg1} Res.Pts ({s2})"), #(str_store_string, s1, "str_reg1_denars"), (try_end), (set_result_string, s1), ]), #script_game_get_party_companion_limit: # This script is called from the game engine when the companion limit is needed for a party. # INPUT: arg1 = none # OUTPUT: reg0 = companion_limit ("game_get_party_companion_limit", [ #(assign, ":troop_no", "trp_player"), (assign, ":limit", 10), (store_skill_level, ":skill", "skl_leadership", "trp_player"), (store_attribute_level, ":charisma", "trp_player", ca_charisma), (troop_get_type, ":race", "trp_player"), (val_mul, ":skill", 5), (val_add, ":limit", ":skill"), (val_add, ":limit", ":charisma"), #GA: add some capacity if there are orcs in the party (you can recruit loads of orcs in TLD) (assign,":total",0), (party_get_num_companion_stacks, ":num_stacks", "p_main_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), #count number of orcs in party (party_stack_get_troop_id, ":stack_troop", "p_main_party", ":i_stack"), (troop_get_type, ":type", ":stack_troop"), (eq, ":type", tf_orc), (neg|troop_is_mounted, ":stack_troop"), (party_stack_get_size, ":stack_size", "p_main_party", ":i_stack"), (val_add, ":total", ":stack_size"), (try_end), (try_begin), (player_has_item, "itm_orc_idol_reward"), (eq, ":race", tf_orc), (val_mul, ":total", orc_bonus_nominator+4), (val_div, ":total", orc_bonus_denominator+4), (else_try), (player_has_item, "itm_orc_idol_reward"), (val_mul, ":total", orc_bonus_nominator+2 ), (val_div, ":total", orc_bonus_denominator+2), (else_try), (val_mul, ":total", orc_bonus_nominator ), (val_div, ":total", orc_bonus_denominator), (try_end), (val_add, ":limit", ":total"), (try_begin), (troop_has_item_equipped, "trp_player", "itm_isen_uruk_heavy_reward"), (assign, ":total", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), #count number of Uruks in party (party_stack_get_troop_id, ":stack_troop", "p_main_party", ":i_stack"), (troop_get_type, ":type", ":stack_troop"), (this_or_next|eq, ":type", tf_uruk), (eq, ":type", tf_urukhai), (neg|troop_is_mounted, ":stack_troop"), (party_stack_get_size, ":stack_size", "p_main_party", ":i_stack"), (val_add, ":total", ":stack_size"), (try_end), (val_mul, ":total", orc_bonus_nominator-1 ), (val_div, ":total", orc_bonus_denominator-1), (val_add, ":limit", ":total"), (try_end), # MV: Add ranks bonus - note that it also counts ranks with dead and turned-hostile factions (try_for_range, ":faction", kingdoms_begin, kingdoms_end), (call_script, "script_get_faction_rank", ":faction"), (val_add, ":limit", reg0), (try_begin), (eq, ":faction", "$players_kingdom"), (val_add, ":limit", reg0), # double for home faction (try_end), (try_end), (assign, reg0, ":limit"), (set_trigger_result, reg0), ]), # script_get_party_tot_join_cost (mtarini) # Input: arg1 = party_no # Output: reg0 = total ("get_party_total_join_cost", [ (store_script_param_1, ":party_no"), (assign, ":total", 0), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (call_script, "script_game_get_join_cost", ":stack_troop",0), (val_mul, reg0, ":stack_size"), (val_add, ":total", reg0), (try_end), (assign, reg0, ":total"), ]), # script_get_party_min_join_cost (mtarini) # Input: arg1 = party_no # Output: reg0 = returns party with minimal cost ("get_party_min_join_cost", [ (store_script_param_1, ":party_no"), (assign, ":res", 9999999), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (call_script, "script_game_get_join_cost", ":stack_troop",0), (val_min, ":res", reg0), (try_end), (assign, reg0, ":res"), ]), # script_get_party_max_ranking_slot(mtarini) # Input: arg1 = party_no # Output: reg0 = returns party slot with max cost ("get_party_max_ranking_slot", [ (store_script_param_1, ":party_no"), (assign, ":res", 0), (assign, ":max", 0), (store_faction_of_party, ":pfac", ":party_no"), (party_get_slot, ":psubfac", ":party_no", slot_party_subfaction), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (store_character_level, ":lvl", ":stack_troop"), (store_troop_faction, ":fac", ":stack_troop"), (troop_get_slot, ":subfac", ":stack_troop", slot_troop_subfaction), (try_begin), (eq, ":fac", ":pfac"), (val_add, ":lvl", 20), (try_end), # bonus for same faction (try_begin), (eq, ":subfac", ":psubfac"), (val_add, ":lvl", 20), (try_end), # bonus for same subfaction (try_begin), (lt, ":max", ":lvl"), (assign, ":max", ":lvl"), (assign, ":res", ":i_stack"), (try_end), (try_end), (assign, reg0, ":res"), ]), # script_party_split_by_faction (mtarini) # Input: arg1 = party_A, retains only the player and troops of given faction # Input: arg2 = party_B, receives the rest, old A = new A + new B # Input: arg3 = faction ("party_split_by_faction", [ (store_script_param_1, ":partyA"), (store_script_param_2, ":partyB"), (store_script_param, ":fac", 3), (party_get_num_companion_stacks, ":num_stacks", ":partyA"), (party_clear, ":partyB"), (try_for_range_backwards, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":partyA", ":i_stack"), (store_troop_faction, ":fac_t", ":stack_troop"), (neq, ":stack_troop", "trp_player"), # player stays in A (neg|troop_is_hero, ":stack_troop"), # heroes stay in A (for hosts and stuff) (neq, ":fac_t", ":fac"), (party_stack_get_size, ":stack_size",":partyA",":i_stack"), (party_remove_members, ":partyA", ":stack_troop", ":stack_size"), (party_add_members, ":partyB", ":stack_troop", ":stack_size"), (try_end), ]), # script_reconstruct_main_party (MV) # Reconstruct main party after splitting by script_party_split_by_faction ("reconstruct_main_party",[ #(call_script, "script_party_add_party", "p_main_party", "p_temp_party"), #mtarini code that was replaced #MV: recreate the main party from p_encountered_party_backup (main backup) and p_main_party (factionalized main minus troops given away) # I replaced the script_party_add_party solely because it messes up the party order as set by the player # Possible bug in any case: loss of stack experience which is kept by the engine only for main party stacks (party_get_num_companion_stacks, ":num_stacks", "p_encountered_party_backup"), (party_get_num_companion_stacks, ":num_stacks_2", "p_main_party"), # for every troop in p_encountered_party_backup try to find a match in p_main_party and remove as many as needed (try_for_range_backwards, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", "p_encountered_party_backup", ":i_stack"), (party_stack_get_size, ":stack_size", "p_encountered_party_backup", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), #no heroes (store_troop_faction, ":troop_faction", ":stack_troop"), (eq, ":troop_faction", "$g_talk_troop_faction"), (assign, ":troop_found", 0), (try_for_range, ":j_stack", 0, ":num_stacks_2"), (party_stack_get_troop_id, ":stack_troop_2", "p_main_party", ":j_stack"), (party_stack_get_size, ":stack_size_2", "p_main_party", ":j_stack"), (neg|troop_is_hero, ":stack_troop_2"), #no heroes (eq, ":stack_troop", ":stack_troop_2"), (assign, ":troop_found", 1), (lt, ":stack_size_2", ":stack_size"), #stack_size-stack_size_2 of this troop were given away (store_sub, ":given_away", ":stack_size", ":stack_size_2"), (party_remove_members, "p_encountered_party_backup", ":stack_troop", ":given_away"), (try_end), # if not found in p_main_party, but still of the correct faction, whole stack was given (eq, ":troop_found", 0), (party_remove_members, "p_encountered_party_backup", ":stack_troop", ":stack_size"), (try_end), # now copy p_encountered_party_backup over p_main_party #(call_script, "script_party_copy", "p_main_party", "p_encountered_party_backup"), will copy the player too, # so he'll be there twice, before the engine removes him - no need to risk anything funny there, so doing it manually (party_clear, "p_main_party"), #player still there! (assign, ":source_party", "p_encountered_party_backup"), (assign, ":target_party", "p_main_party"), # script_party_add_party_companions (party_get_num_companion_stacks, ":num_stacks",":source_party"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (neq, ":stack_troop", "trp_player"), #crucial (party_stack_get_size, ":stack_size",":source_party",":stack_no"), (party_add_members, ":target_party", ":stack_troop", ":stack_size"), (party_stack_get_num_wounded, ":num_wounded", ":source_party", ":stack_no"), (party_wound_members, ":target_party", ":stack_troop", ":num_wounded"), (try_end), # script_party_prisoners_add_party_prisoners (party_get_num_prisoner_stacks, ":num_stacks",":source_party"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (party_prisoner_stack_get_size, ":stack_size",":source_party",":stack_no"), (party_add_prisoners, ":target_party", ":stack_troop", ":stack_size"), (try_end), ]), #script_game_reset_player_party_name: # This script is called from the game engine when the player name is changed. # INPUT: none # OUTPUT: none ("game_reset_player_party_name", [(str_store_troop_name, s5, "trp_player"), (party_set_name, "p_main_party", s5), ]), # script_party_get_ideal_size @used for NPC parties. # Input: arg1 = party_no # Output: reg0: ideal size ("party_get_ideal_size", [ (store_script_param_1, ":party_no"), (assign, ":limit", 30), (party_stack_get_troop_id, ":party_leader", ":party_no", 0), (try_begin), (party_slot_eq, ":party_no", slot_party_type, spt_kingdom_hero_party), (gt, ":party_leader", 0), #Kham fix (is_between, ":party_leader", kingdom_heroes_begin, kingdom_heroes_end), (store_faction_of_party, ":faction_id", ":party_no"), (assign, ":limit", 40), #InVain: Was 10, increased by 30 to make up for removed renown bonus (store_skill_level, ":skill", "skl_leadership", ":party_leader"), #3-10 leadership for lords, 15-50 skill bonus (store_attribute_level, ":charisma", ":party_leader", ca_charisma), #=20 Charisma for most lords (val_mul, ":skill", 5), (val_add, ":limit", ":skill"), (val_add, ":limit", ":charisma"), # limit= 10+CHA+(Lea+5), between 45 and 80 troops limit # (troop_get_slot, ":troop_renown", ":party_leader", slot_troop_renown), #~800 renown, 1100 for kings #InVain: Removed renown # (store_div, ":renown_bonus", ":troop_renown", 25), #= 32 - 44 # (val_add, ":limit", ":renown_bonus"), #= between 77 - 124 troops limit (try_begin), (faction_slot_eq, ":faction_id", slot_faction_marshall, ":party_leader"), (val_add, ":limit", 70), #TLD: was 100, kings were too strong --> around 200 base limit for marshalls (try_end), (try_end), #Kham - if player has level of 0 then ideal limit will be exactly same, if player has level of 80 then ideal limit will be multiplied by 2 ((80 + 80) / 80) #below code will increase limits a little as the game progresses and player gains level (store_character_level, ":level", "trp_player"), (val_min, ":level", 90), (store_add, ":level_factor", 90, ":level"), (val_mul, ":limit", ":level_factor"), (val_div, ":limit", 90), #Kham - comment out old party limit increase #(store_character_level, ":level", "trp_player"), #increase limits a little bit as the game progresses. #(store_add, ":level_factor", 90, ":level"), #(val_mul, ":limit", ":level_factor"), #(val_div, ":limit", 90), (party_stack_get_troop_id, ":party_leader", ":party_no", 0), (troop_get_type, ":race", ":party_leader"), (try_begin), (gt, ":race", 0), #Kham - Fix again (is_between,":race",tf_elf_begin,tf_elf_end), # (CppCoder): Decrease party size of elven parties. (val_mul, ":limit", 3), # CC: Was 2/3, upped to 3/4, elves wouldn't siege properly (val_div, ":limit", 4), (else_try), (gt, ":race", 0), #Kham - Fix again (eq, ":faction_id", "fac_rhun"), # (CppCoder): Rhun now receives a boost to party size. (4/3) (val_mul, ":limit", 4), (val_div, ":limit", 3), (else_try), (gt, ":race", 0), (eq, ":faction_id", "fac_moria"), # (InVain): Moria now receives a boost to party size. (4/3) (val_mul, ":limit", 4), (val_div, ":limit", 3), (else_try), (gt, ":race", 0), (eq, ":faction_id", "fac_gundabad"), # (InVain): Gundabad now receives a boost to party size. (4/3) (val_mul, ":limit", 4), (val_div, ":limit", 3), (try_end), #] + (is_a_wb_script==1 and [ (try_begin), (is_between, ":faction_id", kingdoms_begin, kingdoms_end), #(store_relation, ":player_relation", ":faction_id", "$players_kingdom"), #(lt, ":player_relation", 0), (assign, ":campaign_ai", "$tld_campaign_diffulty"), (val_add, ":campaign_ai", 2), (val_mul, ":limit", 3), (val_div, ":limit", ":campaign_ai"), (try_end), # ] or []) + [ (assign, reg0, ":limit"), ]), # stores the dominant race of a party (somewhat random) (mtarini) # input: PARTY. Output: reg0: dominant race ("party_get_dominant_race",[ (store_script_param_1, ":party"), (party_get_num_companion_stacks, ":num_stacks",":party"), (store_random_in_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":size_a",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (troop_get_type,":val_a",":tr"), (store_random_in_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":size_b",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (troop_get_type,":val_b",":tr"), (store_random_in_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":size_c",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (troop_get_type,":val_c",":tr"), (try_begin),(eq,":val_a",":val_b"),(val_add,":size_a",":size_b"),(try_end), (try_begin),(eq,":val_b",":val_c"),(val_add,":size_b",":size_c"),(try_end), (try_begin),(eq,":val_c",":val_a"),(val_add,":size_c",":size_a"),(try_end), (try_begin),(ge,":size_a",":size_b"),(ge,":size_a",":size_c"),(assign, reg0, ":val_a"), (else_try),(ge,":size_b",":size_a"),(ge,":size_b",":size_c"),(assign, reg0, ":val_b"), (else_try), (assign, reg0, ":val_c"), (try_end), ]), # stores the dominant faction of a party (somewhat random) (mtarini) # input: PARTY. Output: reg0: dominant race ("party_get_dominant_faction",[ (store_script_param_1, ":party"), (party_get_num_companion_stacks, ":num_stacks",":party"), (store_random_in_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":size_a",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (store_troop_faction,":val_a",":tr"), (store_random_in_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":size_b",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (store_troop_faction,":val_b",":tr"), (store_random_in_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":size_c",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (store_troop_faction,":val_c",":tr"), (try_begin),(eq,":val_a",fac_player_faction),(assign, ":val_a", "$players_kingdom"),(try_end), (try_begin),(eq,":val_b",fac_player_faction),(assign, ":val_b", "$players_kingdom"),(try_end), (try_begin),(eq,":val_c",fac_player_faction),(assign, ":val_c", "$players_kingdom"),(try_end), (try_begin),(eq,":val_a",":val_b"),(val_add,":size_a",":size_b"),(try_end), (try_begin),(eq,":val_b",":val_c"),(val_add,":size_b",":size_c"),(try_end), (try_begin),(eq,":val_c",":val_a"),(val_add,":size_c",":size_a"),(try_end), (try_begin),(ge,":size_a",":size_b"),(ge,":size_a",":size_c"),(assign, reg0, ":val_a"), (else_try), (ge,":size_b",":size_a"),(ge,":size_b",":size_c"),(assign, reg0, ":val_b"), (else_try), (assign, reg0, ":val_c"), (try_end), ]), #script_game_get_party_prisoner_limit: # This script is called from the game engine when the prisoner limit is needed for main party. # INPUT: arg1 = party_no # OUTPUT: reg0 = prisoner_limit ("game_get_party_prisoner_limit", [#(store_script_param_1, ":party_no"), #(assign, ":troop_no", "trp_player"), (assign, ":limit", 0), (store_skill_level, ":skill", "skl_prisoner_management", "trp_player"), (store_mul, ":limit", ":skill", 5), (val_add, ":limit", 5), (assign, reg0, ":limit"), (set_trigger_result, reg0), ]), #script_game_get_item_extra_text: # This script is called from the game engine when an item's properties are displayed. # INPUT: arg1 = item_no, arg2 = extra_text_id (this can be between 0-7 (7 included)), arg3 = item_modifier # OUTPUT: result_string = item extra text, trigger_result = text color (0 for default) ("game_get_item_extra_text", [ (store_script_param, ":item_no", 1), (store_script_param, ":extra_text_id", 2), (store_script_param, ":item_modifier", 3), #(item_get_type,":itp", ":item_no"), (item_get_type, ":type", ":item_no"), #Ren: Moved this out of the try block below as it's now use in two places #(item_get_slot, ":light_armor", ":item_no", slot_item_light_armor), (try_begin), (eq,":item_no","itm_lembas"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+30 to Party Morale"),(try_end), (set_trigger_result, color_item_text_morale), (else_try), (eq,":item_no","itm_cooking_cauldron"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+20 to Party Morale"),(try_end), (set_trigger_result, color_item_text_morale), (else_try), (eq,":item_no","itm_rohan_saddle"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Riding Skill"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@during battles"),(try_end), #(try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Horse Archery"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_map"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Pathfinding"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_orc_brew"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+2 to Wound Treatment (Party)"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+2 to Surgery (Party)"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@+2 to Pathfinding (Party)"),(try_end), (try_begin),(eq, ":extra_text_id", 3),(set_result_string, "@Use from Camp Menu"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_ent_water"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Use from"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@Action Menu"),(try_end), (set_trigger_result, color_item_text_normal), (else_try), (eq,":item_no","itm_athelas_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Bonus to Wound Treatment (Party)"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@Bonus to Surgery (Party)"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@Bonus to First Aid (Party)"),(try_end), (try_begin),(eq, ":extra_text_id", 3),(set_result_string, "@Use from Camp Menu"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_hammer_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Weapon Mastery"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_garlic_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Wound Treatment"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_scroll_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Tactics"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_torque_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Power Strike"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_ring_a_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Strength"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@during battles"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_ring_b_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Agility"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@during battles"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_herbarium_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Wound Treatment"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_silmarillion_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Leadership"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_elven_cloak"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Wildcraft"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_wilderness_cowl"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Tracking"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Athletics"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_elven_amulet_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Power Draw"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@during battles"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_book_of_moria"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@The record of Balin's lost expedition."),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@Who might be interested in this?"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_beorn_shield_reward"), (eq, ":item_modifier", imod_reinforced), (try_begin), (eq, ":extra_text_id", 0),(set_result_string, "@Bonus to Shield Skill"),(set_trigger_result, color_item_text_bonus), (try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@Turns nature to your side"),(set_trigger_result, color_item_text_special),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped. (Effects scale with Wildcraft)"),(set_trigger_result, color_item_text_special),(try_end), (else_try), (eq,":item_no","itm_beorn_axe_reward"), (eq, ":item_modifier", imod_masterwork), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Bonus to Power Strike"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped. (Effects scale with Wildcraft)"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_angmar_whip_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Trainer"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(eq, "$tld_option_morale", 0),(set_result_string, "@Recruits Tribal Orcs"),(set_trigger_result, color_item_text_special),(try_end), (try_begin), (eq, "$tld_option_morale", 1), (eq, ":extra_text_id", 1), (store_skill_level, reg1, "skl_leadership", "trp_player"), (val_div, reg1, 3), (gt, reg1, 0), (str_store_string, s3, "@rally"), (try_begin),(gt, reg1, 1),(str_store_string, s3, "@rallies"),(try_end), (set_result_string, "@+{reg1} {s3} in battle"), (set_trigger_result, color_item_text_bonus), (try_end), (try_begin),(eq, "$tld_option_morale", 1),(eq, ":extra_text_id", 2),(set_result_string, "@Recruits Tribal Orcs"),(set_trigger_result, color_item_text_special),(try_end), (else_try), (eq,":item_no","itm_horn_gondor_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Leadership"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Charisma"),(try_end), (try_begin), (eq, "$tld_option_morale", 1), (eq, ":extra_text_id", 2), (store_skill_level, reg1, "skl_leadership", "trp_player"), (val_div, reg1, 3), (gt, reg1, 0), (str_store_string, s3, "@rally"), (try_begin),(gt, reg1, 1),(str_store_string, s3, "@rallies"),(try_end), (set_result_string, "@+{reg1} {s3} in battle"), (try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_drums_of_the_deep"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Call Reinforcements"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@(Effect scales with Strength and Charisma)"),(try_end), (try_begin),(eq, ":extra_text_id", 3),(set_result_string, "@Use from Camp Menu"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_harad_totem_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to First Aid"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Surgery"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_phial_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Wildcraft"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Leadership"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@+1 to Intelligence"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_khand_knife_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Leadership"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Charisma"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_witchking_helmet"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+2 to Surgery"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to First Aid"),(try_end), (try_begin),(eq, ":extra_text_id", 3),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_khamul_helm"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Riding"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Mounted Archery"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_rhun_horse_h"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Bonus to Riding"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped. (Effect scales with Strength)"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_warg_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Orcs: +1 Riding Requirement"),(set_trigger_result, color_bad_news),(try_end), (else_try), (eq,":item_no","itm_wheeled_cage"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Prisoner Mgmt"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_tome_of_knowledge"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+2 to Tactics"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 Intelligence"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_crebain_reward"), (try_begin), (eq, ":extra_text_id", 0), (store_skill_level, reg1, "skl_persuasion", "trp_player"), (val_div, reg1, 3), (val_add, reg1, 1), (set_result_string, "@+{reg1} to Spotting"), (set_trigger_result, color_item_text_bonus), (try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@(Scales with Wildcraft)"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_miruvor_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Strengthens all Heroes"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+2 to First Aid (Party)"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@Use from Camp Menu"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_isen_uruk_heavy_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Trainer"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@lead more Uruks"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_leather_gloves_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Power Draw"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_fur_gloves_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Power Throw"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_gauntlets_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Power Strike"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_umb_helm_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+2 to Tactics"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@Recruit Black Numenoreans from various places"),(try_end), (try_begin),(eq, ":extra_text_id", 3),(set_result_string, "@(Scales with Charisma. Human leaders only.)"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_thrush_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Tactics"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Spotting"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_leather_boots_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Athletics"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to Power Throw"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_black_snake_armor"), (eq, ":item_modifier", imod_lordly), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+2 to Weapon Master"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+1 to First Aid"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_tiara_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@+1 to Surgery"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@+2 to First Aid"),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_dun_berserker"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Less Dunnish upkeep"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_gundabad_helm_e"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Less Wargs upkeep"),(try_end), (try_begin),(eq, ":extra_text_id", 1),(set_result_string, "@when equipped"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq, ":item_no", "itm_beorn_chief"), (eq, ":item_modifier", imod_lordly), (try_begin),(eq, ":extra_text_id", 0), (set_result_string, "@Light Armor"), (try_end), (try_begin),(eq, ":extra_text_id", 1), (set_result_string, "@Bonus to Strength (Player only)"),(set_trigger_result, color_item_text_bonus),(try_end), (try_begin),(eq, ":extra_text_id", 2),(set_result_string, "@(Scales with Wildcraft)"),(set_trigger_result, color_item_text_bonus),(try_end), (else_try), (eq,":item_no","itm_orc_idol_reward"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Lead more Orcs"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), (eq,":item_no","itm_camel"), (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Can scare horses"),(try_end), (set_trigger_result, color_item_text_bonus), (else_try), #(store_and,reg20,":itp", itp_food), (neq, reg20,0), #(eq,":itp", itp_food), (this_or_next|is_between, ":item_no", food_begin, food_end), (eq, ":item_no", "itm_horse_meat"), (try_begin), (eq, ":extra_text_id", 0), (assign, ":continue", 1), (call_script, "script_are_there_orcs", "p_main_party"), (try_begin), (eq, ":item_no", "itm_cattle_meat"), (le, reg0, 0), (eq, ":item_modifier", imod_rotten), (assign, ":continue", 0), (try_end), (eq, ":continue", 1), (item_get_slot, ":food_bonus", ":item_no", slot_item_food_bonus), (assign, reg1, ":food_bonus"), (set_result_string, "@+{reg1} to Party Morale"), (set_trigger_result, color_item_text_morale), (try_end), ] + (is_a_wb_script==1 and [ (else_try), (this_or_next|eq, ":type", itp_type_bow), (this_or_next|eq, ":type", itp_type_crossbow), (eq, ":type", itp_type_thrown), (item_get_horse_speed, reg55, ":item_no"), #Don't worry. Im not crazy. This is equal to shoot speed. :D (gt, reg55, 0), #just in case. (try_begin),(eq, ":extra_text_id", 0),(set_result_string, "@Range: {reg55}"),(try_end), (set_trigger_result, color_item_text_normal), ] or []) + [ (try_end), #Ren: Check if race restrictions are applicable (try_begin), (eq, ":extra_text_id", 4), #If it's body, head, or foot armor show the race restrictions (this_or_next|eq, ":type", itp_type_body_armor), (eq, ":type", itp_type_foot_armor), (store_item_value, reg30, ":item_no"), (val_mod, reg30,10), (troop_get_type, ":race", "$player_current_troop_type"), (assign, ":can_use", 0), #Base messages on side. Good players don't need to know about orcs or uruks, evil player's don't need to know about elves or dwarves (try_begin), (faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (try_begin), (eq, reg30, 8), (str_store_string, s2, "@Dwarves"), (try_begin), (eq, ":race", tf_dwarf), (assign, ":can_use", 1), (try_end), (else_try), #Good is pretty simple since it's either dwarf only, or everyone but dwarf (str_store_string, s2, "@Humans and Elves"), (try_begin), (neq, ":race", tf_dwarf), (assign, ":can_use", 1), (try_end), (try_end), (else_try), (try_begin), (eq, reg30, 1), (str_store_string, s2, "@Orcs"), (try_begin), (eq, ":race", tf_orc), (assign, ":can_use", 1), (try_end), (else_try), (eq, reg30, 2), (str_store_string, s2, "@Uruks and Uruk-Hai"), (try_begin), (this_or_next|eq, ":race", tf_uruk), ( eq, ":race", tf_urukhai), (assign, ":can_use", 1), (try_end), (else_try), (eq, reg30, 3), (str_store_string, s2, "@Humans, Uruks, and Uruk-Hai"), (try_begin), (neq, ":race", tf_orc), (assign, ":can_use", 1), (try_end), (else_try), (str_store_string, s2, "@Humans"), (assign, ":can_use", 1), (try_begin), (this_or_next|eq, ":race", tf_orc), (this_or_next|eq, ":race", tf_uruk), ( eq, ":race", tf_urukhai), (assign, ":can_use", 0), (try_end), (try_end), (try_end), (set_result_string, "@This item can be used by {s2}"), (try_begin), (eq, ":can_use",1), (set_trigger_result, color_good_news), (else_try), (set_trigger_result, color_bad_news), (try_end), (try_end), ]), #script_game_on_disembark: # This script is called from the game engine when the player reaches the shore with a ship. # INPUT: pos0 = disembark position ("game_on_disembark", [#swy-- add some additional sexy guards to the callback, 69 means true! (assign, "$do_you_want_to_disembark_called", 69), (question_box,"@Do you want to disembark?"), # (jump_to_menu, "mnu_disembark"), ]), #script_game_context_menu_get_buttons: # This script is called from the game engine when the player clicks the right mouse button over a party on the map. # INPUT: arg1 = party_no # OUTPUT: none, fills the menu buttons ("game_context_menu_get_buttons", [(store_script_param, ":party_no", 1), (try_begin), (neq, ":party_no", "p_main_party"), (context_menu_add_item, "@Move here", cmenu_move), (try_end), (try_begin), (is_between, ":party_no", centers_begin, centers_end), (context_menu_add_item, "@View notes", 1), (else_try), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (gt, ":num_stacks", 0), (party_stack_get_troop_id, ":troop_no", ":party_no", 0), (is_between, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end), (context_menu_add_item, "@View notes", 2), (try_end), #MV debug stuff (try_begin), (eq, cheat_switch, 1), (call_script, "script_party_calculate_strength", ":party_no", 0), (context_menu_add_item, "@Debug str: {reg0}", 3), (try_end), ] + (is_a_wb_script==1 and [ #swy-- add an Accompany option to the right-click menu for allied parties, mostly lifted from Native Warband... (try_begin), (neq, ":party_no", "p_main_party"), (store_faction_of_party, ":party_faction", ":party_no"), (call_script, "script_cf_factions_are_allies", ":party_faction", "$players_kingdom"), (neg|is_between, ":party_no", centers_begin, "p_save10"), (context_menu_add_item, "str_cmenu_follow", cmenu_follow), (try_end), ] or []) + [ ]), #script_game_event_context_menu_button_clicked: # This script is called from the game engine when the player clicks on a button at the right mouse menu. # INPUT: arg1 = party_no, arg2 = button_value ("game_event_context_menu_button_clicked", [(store_script_param, ":party_no", 1), (store_script_param, ":button_value", 2), (try_begin), (eq, ":button_value", 1), (change_screen_notes, 3, ":party_no"), (else_try), (eq, ":button_value", 2), (party_stack_get_troop_id, ":troop_no", ":party_no", 0), (change_screen_notes, 1, ":troop_no"), (try_end), ]), #script_game_get_skill_modifier_for_troop # This script is called from the game engine when a skill's modifiers are needed # Mtarini: added magic item effects # GA: added wounds effect # INPUT: arg1 = troop_no, arg2 = skill_no # OUTPUT: trigger_result = modifier_value ("game_get_skill_modifier_for_troop",[ (store_script_param, ":troop_no", 1), (store_script_param, ":skill_no", 2), (assign, ":modifier_value", 0), (try_begin), (eq, "$disable_skill_modifiers", 0), # Here we test for items that go in the inventory and that # ONLY the player is supposed to have (try_begin), (eq, ":troop_no", "trp_player"), (try_begin), (eq, ":skill_no", "skl_ironflesh"), # Ironflesh (else_try), (eq, ":skill_no", "skl_power_strike"), # Power Strike (try_begin), (player_has_item, "itm_torque_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_power_draw"), # Power Draw (try_begin), (player_has_item, "itm_elven_amulet_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_weapon_master"), # Weapon Master (try_begin), (player_has_item, "itm_hammer_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_athletics"), # Athletics (else_try), (eq, ":skill_no", "skl_riding"), # Riding (try_begin), (player_has_item, "itm_rohan_saddle"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_trainer"), # Trainer (try_begin), (player_has_item, "itm_angmar_whip_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_tactics"), # Tactics (try_begin), (player_has_item, "itm_tome_of_knowledge"), (val_add, ":modifier_value", 2), (try_end), (try_begin), (player_has_item, "itm_scroll_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_thrush_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_pathfinding"), # Pathfinding (try_begin), (player_has_item, "itm_map"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_spotting"), # Spotting (try_begin), (player_has_item, "itm_crebain_reward"), # Remember that Persuasion is Wildcraft! (store_skill_level, reg1, "skl_persuasion", "trp_player"), (val_div, reg1, 3), (val_add, reg1, 1), (val_add, ":modifier_value", reg1), (try_end), (try_begin), (player_has_item, "itm_thrush_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_first_aid"), # First Aid (try_begin), (player_has_item, "itm_harad_totem_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_surgery"), # Surgery (try_begin), (player_has_item, "itm_harad_totem_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_wound_treatment"), # Wound Treatment (try_begin), (player_has_item, "itm_garlic_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_herbarium_reward"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_persuasion"), # Persuasion (AKA Wildcraft) (try_begin), (player_has_item, "itm_phial_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_elven_cloak"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_prisoner_management"), # Prisoner Management (try_begin), (player_has_item, "itm_wheeled_cage"), (val_add, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_leadership"), # Leadership (try_begin), (player_has_item, "itm_silmarillion_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_horn_gondor_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_khand_knife_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_phial_reward"), (val_add, ":modifier_value", 1), (try_end), (end_try), (end_try), # Here we check for equipment and wounds (try_begin), (this_or_next|is_between, ":troop_no", companions_begin, companions_end), (this_or_next|is_between, ":troop_no", new_companions_begin, new_companions_end), (eq, ":troop_no", "trp_player"), (troop_get_slot, ":wound_mask", ":troop_no", slot_troop_wound_mask), (try_begin), (eq, ":skill_no", "skl_pathfinding"), # Pathfinding (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_orc_brew"), (item_slot_eq, "itm_orc_brew", slot_item_is_active, 1), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_weapon_master"), # Weapon Master (try_begin), (troop_has_item_equipped, ":troop_no", "itm_black_snake_armor"), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_shield"), # Shield (try_begin), (troop_has_item_equipped, ":troop_no", "itm_beorn_shield_reward"), # Remember that Persuasion is Wildcraft! (store_skill_level, reg1, "skl_persuasion", ":troop_no"), (val_div, reg1, 2), (val_add, ":modifier_value", reg1), (try_end), (else_try), (eq, ":skill_no", "skl_riding"), # Riding (try_begin), (troop_has_item_equipped, ":troop_no", "itm_khamul_helm"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_rhun_horse_h"), (store_attribute_level, reg1, ":troop_no", ca_strength), (val_div, reg1, 9), (val_add, ":modifier_value", reg1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_leg), #leg injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (try_begin), #dwarf MEANS no riding skills (mtarini) and no mounted archery (troop_get_type, ":race", ":troop_no"), (eq, ":race", tf_dwarf), (assign, ":modifier_value", -10), (try_end), (else_try), (eq, ":skill_no", "skl_power_draw"), # Power Draw (try_begin), (troop_has_item_equipped, ":troop_no", "itm_leather_gloves_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_arm), #arm injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_power_throw"), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_fur_gloves_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_leather_boots_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_arm), #arm injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_trainer"), # Trainer (try_begin), (troop_has_item_equipped, ":troop_no", "itm_isen_uruk_heavy_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_first_aid"), # First Aid (try_begin), (troop_has_item_equipped, ":troop_no", "itm_witchking_helmet"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_black_snake_armor"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped,":troop_no", "itm_tiara_reward"), (val_add, ":modifier_value", 2), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_miruvor_reward"), (item_slot_eq, "itm_miruvor_reward", slot_item_is_active, 1), (val_add, ":modifier_value", 4), (try_end), (try_begin), (player_has_item, "itm_athelas_reward"), (item_slot_eq, "itm_athelas_reward", slot_item_is_active, 1), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_surgery"), # Surgery (try_begin), (troop_has_item_equipped, ":troop_no", "itm_witchking_helmet"), (val_add, ":modifier_value", 2), (try_end), (try_begin), (troop_has_item_equipped,":troop_no", "itm_tiara_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_athelas_reward"), (item_slot_eq, "itm_athelas_reward", slot_item_is_active, 1), (val_add, ":modifier_value", 2), (try_end), (try_begin), (player_has_item, "itm_orc_brew"), (item_slot_eq, "itm_orc_brew", slot_item_is_active, 1), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_athletics"), # Athletics (try_begin), (troop_has_item_equipped, ":troop_no", "itm_leather_boots_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_wilderness_cowl"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_leg), #leg injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_tactics"), # Tactics (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_umb_helm_reward"), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_power_strike"), # Power Strike (try_begin), (troop_has_item_equipped, ":troop_no", "itm_gauntlets_reward"), (val_add, ":modifier_value", 1), (try_end), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_beorn_axe_reward"), (store_skill_level, reg1, "skl_persuasion", ":troop_no"), (val_div, reg1, 2), (val_add, ":modifier_value", reg1), (try_end), (try_begin), (store_and, ":check" ,":wound_mask", wound_arm), #arm injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_wound_treatment"), # Wound Treatment (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (try_begin), (player_has_item, "itm_athelas_reward"), (item_slot_eq, "itm_athelas_reward", slot_item_is_active, 1), (val_add, ":modifier_value", 2), (try_end), (try_begin), (player_has_item, "itm_orc_brew"), (item_slot_eq, "itm_orc_brew", slot_item_is_active, 1), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_engineer"), # Engineering (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_spotting"), # Spotting (try_begin), (store_and, ":check" ,":wound_mask", wound_head), #head injury (neq, ":check", 0), (val_sub, ":modifier_value", 1), (try_end), (else_try), (eq, ":skill_no", "skl_horse_archery"), # Horse archery (try_begin), (troop_has_item_equipped, ":troop_no", "itm_khamul_helm"), (val_add, ":modifier_value", 1), (try_end), (try_begin), #dwarf MEANS no mounted archery (GA) (troop_get_type, ":race", ":troop_no"), (eq, ":race", tf_dwarf), (assign, ":modifier_value", -10), (try_end), (else_try), (eq, ":skill_no", "skl_persuasion"), (try_begin), (troop_has_item_equipped, ":troop_no", "itm_wilderness_cowl"), (troop_has_item_equipped, ":troop_no", "itm_leather_boots_reward"), (troop_has_item_equipped, ":troop_no", "itm_fur_gloves_reward"), (val_add, ":modifier_value", 2), (try_end), (else_try), (eq, ":skill_no", "skl_tracking"), #Wildcraft (try_begin), (troop_has_item_equipped, ":troop_no", "itm_wilderness_cowl"), (val_add, ":modifier_value", 1), (try_end), (try_end), (end_try), (end_try), (set_trigger_result, ":modifier_value"), ]), # Note to modders: Uncomment these if you'd like to use the following. #script_game_check_party_sees_party # This script is called from the game engine when a party is inside the range of another party # INPUT: arg1 = party_no_seer, arg2 = party_no_seen # OUTPUT: trigger_result = true or false (1 = true, 0 = false) ("game_check_party_sees_party", [(store_script_param, ":party_no_seer", 1), (store_script_param, ":party_no_seen", 2), (try_begin), (eq, ":party_no_seer", "p_main_party"), (neg|faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (party_get_skill_level, ":spot", "p_main_party", "skl_spotting"), (lt,":spot",7), # rangers are invis unless high spotting (party_get_template_id,":spot",":party_no_seen"), (this_or_next|eq, ":spot", "pt_ranger_scouts"),# evil player does not see rangers x_x (this_or_next|eq, ":spot", "pt_ranger_raiders"), (eq, ":party_no_seen", "p_town_henneth_annun"),# evil player does not see henneth (set_trigger_result, 0), (else_try), (set_trigger_result, 1), (try_end), ]), #script_game_get_party_speed_multiplier # This script is called from the game engine when a skill's modifiers are needed # INPUT: arg1 = party_no # OUTPUT: trigger_result = multiplier (scaled by 100, meaning that giving 100 as the trigger result does not change the party speed) ("game_get_party_speed_multiplier", [ (store_script_param, ":party_no", 1), (party_get_template_id, ":template_no", ":party_no"), (party_get_current_terrain, ":terrain", ":party_no"), (try_begin), (this_or_next|eq, ":template_no", "pt_wild_troll"), ( eq, ":template_no", "pt_raging_trolls"), (set_trigger_result, 45), (try_begin), (eq, "$cheat_mode",1), (display_message, "@DEBUG: Trolls for Troll quest are sped down."), (try_end), (else_try), (eq, ":template_no", "pt_refugees"), (set_trigger_result, 55), (else_try), (eq, "$g_player_is_captive", 1), #while burning trees (eq, ":template_no", "pt_ents"), (set_trigger_result, 45), (else_try), (faction_get_slot, ":guardian_party_exists", "fac_isengard", slot_faction_guardian_party), (gt, ":guardian_party_exists", 1), (eq, ":party_no", ":guardian_party_exists"), (try_begin), (check_quest_active, "qst_guardian_party_quest"), (is_currently_night), (set_trigger_result, 140), #simple way of making sure it arrives at night time ;) (else_try), (check_quest_active, "qst_guardian_party_quest"), (set_trigger_result, 15), (else_try), (set_trigger_result, 100), (try_end), (else_try), (is_between, ":terrain", rt_forest_begin, rt_forest_end), (party_get_skill_level, ":speed_multiplier", ":party_no", skl_persuasion), #Wildcraft (try_begin), (ge,":speed_multiplier",1), (val_mul,":speed_multiplier",2), (val_add,":speed_multiplier",100), (else_try), (assign,":speed_multiplier",100), (try_end), (val_max, ":speed_multiplier", 0), (set_trigger_result, ":speed_multiplier"), #Debug #(try_begin), # (eq, ":party_no", "p_main_party"), # (assign, reg10, ":speed_multiplier"), # (display_message, "@Wildcraft Speed Multiplier - {reg10}", color_good_news), #(try_end), (else_try), (set_trigger_result, 100), (try_end), ]), #script_setup_talk_info # INPUT: $g_talk_troop, $g_talk_troop_relation, $current_town (TLD) ("setup_talk_info", [ (try_begin), (is_between, "$g_talk_troop", mayors_begin, mayors_end), (party_slot_eq, "$current_town", slot_town_elder, "$g_talk_troop"), #redundant, but doesn't hurt (party_get_slot, ":relation", "$current_town", slot_center_player_relation), (str_store_party_name, s61, "$current_town"), (else_try), (assign, ":relation", "$g_talk_troop_relation"), (str_store_troop_name, s61, "$g_talk_troop"), (try_end), (talk_info_set_relation_bar, ":relation"), (str_store_string, s61, "@ {s61}"), (assign, reg1, ":relation"), (str_store_string, s62, "str_relation_reg1"), (talk_info_set_line, 0, s61), (talk_info_set_line, 1, s62), (call_script, "script_describe_relation_to_s63", ":relation"), (talk_info_set_line, 3, s63), ]), #script_setup_talk_info_companions ("setup_talk_info_companions", [ (call_script, "script_npc_morale", "$g_talk_troop"), (assign, ":troop_morale", reg0), (talk_info_set_relation_bar, ":troop_morale"), (str_store_troop_name, s61, "$g_talk_troop"), (str_store_string, s61, "@ {s61}"), (assign, reg1, ":troop_morale"), (str_store_string, s62, "str_morale_reg1"), (talk_info_set_line, 0, s61), (talk_info_set_line, 1, s62), (talk_info_set_line, 3, s63), ]), #script_update_party_creation_random_limits # INPUT: none ("update_party_creation_random_limits", [ (store_character_level, ":player_level", "trp_player"), (store_mul, ":upper_limit", ":player_level", 3), (val_add, ":upper_limit", 25), (val_min, ":upper_limit", 100), (set_party_creation_random_limits, 0, ":upper_limit"), (assign, reg0, ":upper_limit"), ]), #script_set_trade_route_between_centers # INPUT: param1: center_no_1, param2: center_no_2 ("set_trade_route_between_centers", [(store_script_param, ":center_no_1", 1), (store_script_param, ":center_no_2", 2), (assign, ":center_1_added", 0), (assign, ":center_2_added", 0), (try_for_range, ":cur_slot", slot_town_trade_routes_begin, slot_town_trade_routes_end), (try_begin), (eq, ":center_1_added", 0), (party_slot_eq, ":center_no_1", ":cur_slot", 0), (party_set_slot, ":center_no_1", ":cur_slot", ":center_no_2"), (assign, ":center_1_added", 1), (try_end), (try_begin), (eq, ":center_2_added", 0), (party_slot_eq, ":center_no_2", ":cur_slot", 0), (party_set_slot, ":center_no_2", ":cur_slot", ":center_no_1"), (assign, ":center_2_added", 1), (try_end), (try_end), (try_begin), (eq, ":center_1_added", 0), (str_store_party_name, s1, ":center_no_1"), (display_message, "@ERROR: More than 15 trade routes are given for {s1}."), (try_end), (try_begin), (eq, ":center_2_added", 0), (str_store_party_name, s1, ":center_no_2"), (display_message, "@ERROR: More than 15 trade routes are given for {s1}."), (try_end), ]), #script_center_change_trade_good_production # INPUT: param1 = center_no, param2 = item_id, param3 = production_rate (should be between -100 (for net consumption) and 100 (for net production) # param4: randomness (between 0-100) ("center_change_trade_good_production",[ (store_script_param, ":center_no", 1), (store_script_param, ":item_no", 2), (store_script_param, ":production_rate", 3), # (val_mul, ":production_rate", 5), (store_script_param, ":randomness", 4), (store_random_in_range, ":random_num", 0, ":randomness"), (store_random_in_range, ":random_sign", 0, 2), (try_begin), (eq, ":random_sign", 0), (val_add, ":production_rate", ":random_num"), (else_try), (val_sub, ":production_rate", ":random_num"), (try_end), (val_sub, ":item_no", trade_goods_begin), (val_add, ":item_no", slot_town_trade_good_productions_begin), (party_get_slot, ":old_production_rate", ":center_no", ":item_no"), (val_add, ":production_rate", ":old_production_rate"), (party_set_slot, ":center_no", ":item_no", ":production_rate"), ]), #script_average_trade_good_productions # INPUT: none ("average_trade_good_productions",[ (store_sub, ":item_to_slot", slot_town_trade_good_productions_begin, trade_goods_begin), # (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin), (try_for_range, ":center_no", centers_begin, centers_end), (party_slot_eq, ":center_no", slot_center_destroyed, 0), #TLD - not destroyed (try_for_range, ":other_center", centers_begin, centers_end), (party_is_active, ":other_center"), #TLD (party_slot_eq, ":other_center", slot_center_destroyed, 0), #TLD - not destroyed (is_between, ":center_no", centers_begin, centers_end), (neq, ":other_center", ":center_no"), (store_distance_to_party_from_party, ":cur_distance", ":center_no", ":other_center"), (lt, ":cur_distance", 110), (store_sub, ":dist_factor", 110, ":cur_distance"), (try_for_range, ":cur_good", trade_goods_begin, trade_goods_end), (store_add, ":cur_good_slot", ":cur_good", ":item_to_slot"), (party_get_slot, ":center_production", ":center_no", ":cur_good_slot"), (party_get_slot, ":other_center_production", ":other_center", ":cur_good_slot"), (store_sub, ":prod_dif", ":center_production", ":other_center_production"), (gt, ":prod_dif", 0), (store_mul, ":prod_dif_change", ":prod_dif", 1), ## (try_begin), ## (is_between, ":center_no", centers_begin, centers_end), ## (is_between, ":other_center", centers_begin, centers_end), ## (val_mul, ":cur_distance", 2), ## (try_end), (val_mul ,":prod_dif_change", ":dist_factor"), (val_div ,":prod_dif_change", 110), (val_add, ":other_center_production", ":prod_dif_change"), (party_set_slot, ":other_center", ":cur_good_slot", ":other_center_production"), (try_end), (try_end), (try_end), ]), #script_normalize_trade_good_productions # INPUT: none ("normalize_trade_good_productions", [ (store_sub, ":item_to_slot", slot_town_trade_good_productions_begin, trade_goods_begin), (try_for_range, ":cur_good", trade_goods_begin, trade_goods_end), (assign, ":total_production", 0), (assign, ":num_centers", 0), (store_add, ":cur_good_slot", ":cur_good", ":item_to_slot"), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), #TLD - not destroyed (val_add, ":num_centers", 1), (try_begin), (is_between, ":center_no", centers_begin, centers_end), #each town is weighted as 5 villages... (val_add, ":num_centers", 4), (try_end), (party_get_slot, ":center_production", ":center_no", ":cur_good_slot"), (val_add, ":total_production", ":center_production"), (try_end), (store_div, ":new_production_difference", ":total_production", ":num_centers"), (neq, ":new_production_difference", 0), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), #TLD - not destroyed (is_between, ":center_no", centers_begin, centers_end), (party_get_slot, ":center_production", ":center_no", ":cur_good_slot"), (val_sub, ":center_production", ":new_production_difference"), (party_set_slot, ":center_no", ":cur_good_slot", ":center_production"), (try_end), (try_end), ]), #script_do_merchant_town_trade # INPUT: arg1 = party_no (of the merchant), arg2 = center_no ("do_merchant_town_trade",[ (store_script_param_1, ":party_no"), (store_script_param_2, ":center_no"), (call_script, "script_do_party_center_trade", ":party_no", ":center_no", 20), #change prices by 20% (assign, ":total_change", reg0), #Adding the earnings to the wealth (maximum changed price is the earning) (val_div, ":total_change", 2), (str_store_party_name, s1, ":party_no"), (str_store_party_name, s2, ":center_no"), (assign, reg1, ":total_change"), ## (try_begin), ## (eq, "$cheat_mode", 1), ## (display_message, "@Merchant {s1} traded with {s2} and earned {reg1} denars."), ## (try_end), #Adding tax revenue to the center (party_get_slot, ":accumulated_tariffs", ":center_no", slot_center_accumulated_tariffs), (party_get_slot, ":prosperity", ":center_no", slot_town_prosperity), (store_add, ":tax_gain", ":prosperity", 10), (val_mul, ":tax_gain", ":total_change"), (val_div, ":tax_gain", 2200), #(10 + prosperity) / 110 * 5% of the merchant's revenue. (val_add, ":accumulated_tariffs", ":tax_gain"), (party_set_slot, ":center_no", slot_center_accumulated_tariffs, ":accumulated_tariffs"), # (try_begin), # (is_between, ":center_no", centers_begin, centers_end), # (party_get_slot, ":merchant",":center_no",slot_town_merchant), # (gt, ":merchant", 0), # (store_mul, ":merchant_profit", ":total_change", 1), # (val_div, ":merchant_profit", 2), # (troop_add_gold, ":merchant", ":merchant_profit"), # (try_end), #Adding 1 to center prosperity (try_begin), (store_random_in_range, ":rand", 0, 100), (lt, ":rand", 35), (call_script, "script_change_center_prosperity", ":center_no", 1), (try_end), ]), #script_troop_calculate_strength: # INPUT: arg1 = troop_id # OUTPUT: reg0 = strength ("troop_calculate_strength", [ (store_script_param_1, ":troop"), #TLD: Troop strength = ((level+11)^2-27)/100 #InVain: New troop strength = (level^2+100)/50, favors troops >lvl 30, esp against orcs (store_character_level, reg0, ":troop"), (val_mul, reg0, reg0), (val_add, reg0, 100), (val_div, reg0, 50), # (val_add, reg0, 11), # (val_mul, reg0, reg0), # (val_sub, reg0, 27), # (val_div, reg0, 100), #(troop_get_type,":troop",":troop"), #(try_begin),(eq, ":troop", tf_orc),(val_div, reg0, 2),(try_end), #GA: plain orcs get strength halved - MV: NO. They already have lower strength because of their levels - see below how low-tier orcs are inferior. If you want orc parties to be weaker in AI battles, change their party templates to have less high-tier and more low-tier troops. And do the math to make sure you don't go too far. # Here's the output # Humans (tiers 1-7): 2,4,6, 9,16,25,31 (Uruks use these too) # Elves (T1-6): 2,5,7,10,19,29 # Dwarves (T1-6): 2,4,7, 9,18,28 # Orcs (T1-6): 1,3,5, 8,14,22 ]), #script_party_calculate_regular_strength: # INPUT: arg1 = party_id # OUTPUT: reg0 = strength ("party_calculate_regular_strength", [ (store_script_param_1, ":party"), #Party_id (assign, ":strength", 0), (party_get_num_companion_stacks, ":num_stacks",":party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (neg|troop_is_hero, ":stack_troop"), (call_script, "script_troop_calculate_strength", ":stack_troop"), (assign, ":stack_strength", reg0), (party_stack_get_size, ":stack_size",":party",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_sub, ":stack_size", ":num_wounded"), (val_mul, ":stack_strength", ":stack_size"), (val_add, ":strength", ":stack_strength"), (try_end), # Evil handicap when evil player (try_begin), (neg|faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (store_faction_of_party, ":party_faction", ":party"), (neg|faction_slot_eq, ":party_faction", slot_faction_side, faction_side_good), (val_mul, ":strength", evil_party_str_handicap), (val_div, ":strength", 100), (try_end), (assign, reg0, ":strength"), ]), #script_party_calculate_strength: # INPUT: arg1 = party_id, arg2 = exclude leader # OUTPUT: reg0 = strength ("party_calculate_strength", [ (store_script_param_1, ":party"), #Party_id (store_script_param_2, ":exclude_leader"), #Party_id (party_get_template_id, ":party_template", ":party"), (assign, ":strength", 0), (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, ":first_stack", 0), (try_begin), (neq, ":exclude_leader", 0), (assign, ":first_stack", 1), (try_end), (try_for_range, ":i_stack", ":first_stack", ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (call_script, "script_troop_calculate_strength", ":stack_troop"), (assign, ":stack_strength", reg0), (try_begin), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size",":party",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_sub, ":stack_size", ":num_wounded"), (val_mul, ":stack_strength", ":stack_size"), (else_try), (troop_is_wounded, ":stack_troop"), #hero... (assign,":stack_strength",0), (try_end), (val_add, ":strength", ":stack_strength"), (try_end), (party_set_slot, ":party", slot_party_cached_strength, ":strength"), # Evil handicap when evil player (try_begin), (neg|faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (store_faction_of_party, ":party_faction", ":party"), (neg|faction_slot_eq, ":party_faction", slot_faction_side, faction_side_good), (val_mul, ":strength", evil_party_str_handicap), (val_div, ":strength", 100), (try_end), (assign, reg0, ":strength"), (try_begin), #InVain: Cover troops always have 1 party strength, so they don't win battles (eq,":party_template", "pt_retreat_troops"), (assign, reg0, 1), (try_end), (try_begin), #InVain: guardian parties are stronger (party_slot_eq, ":party", slot_party_type, spt_guardian), (val_mul, ":strength", 3), (val_div, ":strength", 2), (try_end), ]), #script_loot_player_items: # INPUT: arg1 = enemy_party_no ("loot_player_items", [ (store_script_param, ":enemy_party_no", 1), (troop_get_inventory_capacity, ":inv_cap", "trp_player"), (try_for_range, ":i_slot", 0, ":inv_cap"), (troop_get_inventory_slot, ":item_id", "trp_player", ":i_slot"), (ge, ":item_id", 0), (troop_get_inventory_slot_modifier, ":item_modifier", "trp_player", ":i_slot"), # all items looted with max probability. No easy life :) GA # (try_begin), # (is_between, ":item_id", trade_goods_begin, trade_goods_end), (assign, ":randomness", 20), # (else_try), # (is_between, ":item_id", horses_begin, horses_end), # (assign, ":randomness", 15), # (else_try), # (this_or_next|is_between, ":item_id", weapons_begin, weapons_end), # (is_between, ":item_id", ranged_weapons_begin, ranged_weapons_end), # (assign, ":randomness", 5), # (else_try), # (this_or_next|is_between, ":item_id", armors_begin, armors_end), # (is_between, ":item_id", shields_begin, shields_end), # (assign, ":randomness", 5), # (try_end), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":randomness"), (item_get_slot, ":reward", ":item_id", slot_item_given_as_reward), (neq, ":reward", 1),#If Item is a reward, dont let it get jacked. (troop_remove_item, "trp_player", ":item_id"), (try_begin), (gt, ":enemy_party_no", 0), (party_get_slot, ":cur_loot_slot", ":enemy_party_no", slot_party_next_looted_item_slot), (val_add, ":cur_loot_slot", slot_party_looted_item_1), (party_set_slot, ":enemy_party_no", ":cur_loot_slot", ":item_id"), (val_sub, ":cur_loot_slot", slot_party_looted_item_1), (val_add, ":cur_loot_slot", slot_party_looted_item_1_modifier), (party_set_slot, ":enemy_party_no", ":cur_loot_slot", ":item_modifier"), (val_sub, ":cur_loot_slot", slot_party_looted_item_1_modifier), (val_add, ":cur_loot_slot", 1), (val_mod, ":cur_loot_slot", num_party_loot_slots), (party_set_slot, ":enemy_party_no", slot_party_next_looted_item_slot, ":cur_loot_slot"), (try_end), (try_end), (store_troop_gold, ":cur_gold", "trp_player"), (store_div, ":max_lost", ":cur_gold", 4), (store_div, ":min_lost", ":cur_gold", 10), (store_random_in_range, ":lost_gold", ":min_lost", ":max_lost"), (troop_remove_gold, "trp_player", ":lost_gold"), (party_set_extra_text, ":enemy_party_no", "@Looted your items"), ]), #script_party_calculate_loot: # INPUT: param1: Party-id # Returns num looted items in reg(0) ("party_calculate_loot", [ (store_script_param_1, ":enemy_party"), #Enemy Party_id (faction_get_slot, ":faction_mask", "$players_kingdom", slot_faction_mask), (call_script, "script_calculate_main_party_shares"),(assign, ":num_player_party_shares", reg0), # (assign, ":num_ally_shares", reg1), # (store_add, ":num_shares", ":num_player_party_shares", ":num_ally_shares"), #Calculate player loot probability # (assign, ":loot_probability", 100), # (val_mul, ":loot_probability", 10), # (val_div, ":loot_probability", ":num_shares"), (assign, ":can_steal", 1), # can steal objects of own faction or , of no faction (try_begin), (faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (assign, ":can_steal", 0),(try_end), # good guys don't steal # Loot the defeated party (store_mul, ":loot_probability", player_loot_share, 2), (val_mul, ":loot_probability", "$g_strength_contribution_of_player"), (party_get_skill_level, ":player_party_looting", "p_main_party", "skl_looting"), (val_add, ":player_party_looting", 10), (val_mul, ":loot_probability", ":player_party_looting"), #InVain: X*(looting+10)^2/200 = X*0,5 ... X*2 (val_mul, ":loot_probability", ":player_party_looting"), (val_div, ":loot_probability", 200), (val_div, ":loot_probability", ":num_player_party_shares"), (assign, ":dest", "trp_temp_troop"), #(try_begin),(eq,"$tld_option_crossdressing", 0),(assign, ":dest", "trp_temp_troop_2"),(try_end), (troop_clear_inventory,"trp_temp_troop"), (party_get_num_companion_stacks, ":num_stacks",":enemy_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":enemy_party",":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size",":enemy_party",":i_stack"), (try_for_range, ":unused", 0, ":stack_size"), (troop_loot_troop,":dest",":stack_troop",":loot_probability"), (try_end), (try_end), # substitute forbidden items with "metal scraps" (mtarini) # ################################## (try_begin), (eq,"$tld_option_crossdressing", 0), (call_script,"script_troop_copy_all_items_from_troop", "trp_temp_troop_2","trp_temp_troop"), (troop_clear_inventory,"trp_temp_troop"), (troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop_2"), #(assign, reg10, ":inv_cap"), (display_message,"@debug: starting scrapization over {reg10} objects..."), (try_for_range, ":i_slot", 0, ":inv_cap"), (troop_get_inventory_slot, ":item_id", "trp_temp_troop_2", ":i_slot"), (ge, ":item_id", 0), #(display_message,"@debug: non zero obj..."), (try_begin), (item_get_type, ":it", ":item_id"), (eq, ":it", itp_type_horse), (try_begin), (troop_get_type, ":race","$g_player_troop"), (is_between, ":race", tf_orc_begin, tf_orc_end), # orcs: (try_begin), (is_between, ":item_id", item_warg_begin , item_warg_end), (troop_add_item, "trp_temp_troop", ":item_id"), # keep any warg (else_try), (troop_add_item, "trp_temp_troop", "itm_horse_meat"), # turn any horse in meat (try_end), # (else_try), # # non orcs: # (try_begin), # (is_between, ":item_id", item_warg_begin , item_warg_end), # trash any warg # (else_try), # (troop_add_item, "trp_temp_troop", ":item_id"), # keep any horse # (try_end), (try_end), (else_try), (eq, ":can_steal", 1), # if can steal... (item_get_slot, reg10, ":item_id", slot_item_faction), (store_and, reg11, reg10, ":faction_mask"), #(this_or_next|eq, reg10, 0), # can steal objects with no faction (neq, reg11, 0), # can steal objects of player's faction ] + (is_a_wb_script and [ (neg|item_has_property, ":item_id", itp_unique), #additional safeguards - don't loot reward items (item_has_property, ":item_id", itp_shop), #only loot shop items ] or []) + [ # don't replace item (troop_add_item, "trp_temp_troop", ":item_id"), (else_try), # replace item with scrap #(store_random_in_range, ":rand", 0, 100), (ge, ":rand", 75), (store_item_value, ":val", ":item_id"), (assign, reg20, ":val"), (str_store_item_name,s20,":item_id"), # random rounding of values (so that average total values is kept the same) (assign, ":rounding", 0), (try_begin), (lt,":val",scrap_bad_value), (store_random_in_range, ":rounding", 0, scrap_bad_value), (else_try), (lt,":val",scrap_medium_value),(store_random_in_range, ":rounding", 0, scrap_medium_value - scrap_bad_value), (else_try), (lt,":val",scrap_good_value), (store_random_in_range, ":rounding", 0, scrap_good_value - scrap_medium_value), (try_end), (val_mul, ":rounding", ":player_party_looting"), #InVain: rounding*(looting+10)^2/200 (val_mul, ":rounding", ":player_party_looting"), (val_div, ":rounding", 200), #=0,5...2,0 (val_add, ":val", ":rounding"), (assign, reg21, ":rounding"), (str_store_string, s22, "@nothing"), (try_begin),(ge,":val",scrap_good_value), (troop_add_item, "trp_temp_troop", "itm_metal_scraps_good"), (str_store_string,s22,"@Good"), (else_try), (ge,":val",scrap_medium_value), (troop_add_item, "trp_temp_troop", "itm_metal_scraps_medium"),(str_store_string,s22,"@Med"), (else_try), (ge,":val",scrap_bad_value/2), (troop_add_item, "trp_temp_troop", "itm_metal_scraps_bad"), (str_store_string,s22,"@Bad"), (try_end), #(display_message,"@debug: turned a {s20} {reg20} (+{reg21}) into {reg22}..."), (try_end), (try_end), (try_end), # adding any special loot from party "looted item" slots (item that where stolen by the party) (try_for_range, ":i_loot", 0, num_party_loot_slots), (store_add, ":cur_loot_slot", ":i_loot", slot_party_looted_item_1), (party_get_slot, ":item_no", "$g_enemy_party", ":cur_loot_slot"), (gt, ":item_no", 0), (party_set_slot, "$g_enemy_party", ":cur_loot_slot", 0), (val_sub, ":cur_loot_slot", slot_party_looted_item_1), (val_add, ":cur_loot_slot", slot_party_looted_item_1_modifier), (party_get_slot, ":item_modifier", "$g_enemy_party", ":cur_loot_slot"), (troop_add_item, "trp_temp_troop", ":item_no", ":item_modifier"), (try_end), (party_set_slot, "$g_enemy_party", slot_party_next_looted_item_slot, 0), # put "goods" in loot if it was a caravan (or farmers) (assign, ":num_looted_items",0), (try_begin), (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan), (store_mul, ":plunder_amount", player_loot_share, 30), (val_mul, ":plunder_amount", "$g_strength_contribution_of_player"), (val_div, ":plunder_amount", 100), (val_div, ":plunder_amount", ":num_player_party_shares"), (try_begin), (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan), # (val_clamp, ":plunder_amount", 1, 50), (reset_item_probabilities, 100), (assign, ":range_min", trade_goods_begin), (assign, ":range_max", trade_goods_end), (else_try), (val_div, ":plunder_amount", 5), #(val_clamp, ":plunder_amount", 1, 10), (reset_item_probabilities, 1), (assign, ":range_min", normal_food_begin), (assign, ":range_max", food_end), (try_end), (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin), (try_for_range, ":cur_goods", ":range_min", ":range_max"), (store_add, ":cur_price_slot", ":cur_goods", ":item_to_price_slot"), (party_get_slot, ":cur_price", "$g_enemy_party", ":cur_price_slot"), (val_max, ":cur_price", 1), #Avoid division by zero (assign, ":cur_probability", 100), (val_mul, ":cur_probability", average_price_factor), (val_div, ":cur_probability", ":cur_price"), (val_mul, ":cur_probability", average_price_factor), (val_div, ":cur_probability", ":cur_price"), (val_mul, ":cur_probability", average_price_factor), (val_div, ":cur_probability", ":cur_price"), #(assign, reg0, ":cur_probability"), (set_item_probability_in_merchandise, ":cur_goods", ":cur_probability"), (try_end), (troop_add_merchandise, "trp_temp_troop", itp_type_goods, ":plunder_amount"), #(assign, reg5, ":plunder_amount"), (val_add, ":num_looted_items", ":plunder_amount"), (try_end), # count how many objects were accumulated in total (troop_get_inventory_capacity, ":inv_cap", "trp_temp_troop"), (try_for_range, ":i_slot", 0, ":inv_cap"), (troop_get_inventory_slot, ":item_id", "trp_temp_troop", ":i_slot"), (ge, ":item_id", 0), (val_add, ":num_looted_items",1), (try_end), (try_begin), #if no loot at all, add a chance for one or two bad metal scraps (eq, ":num_looted_items",0), (store_random_in_range, ":rand", 0, 20), (ge, ":player_party_looting", ":rand"), (store_div, ":amount", ":player_party_looting", 10), (troop_add_items, "trp_temp_troop", "itm_metal_scraps_bad", ":amount"), (val_add, ":num_looted_items", ":amount"), (try_end), (assign, reg0, ":num_looted_items"), ]), #script_calculate_main_party_shares: # Returns number of player party shares in reg0 ("calculate_main_party_shares", [ (assign, ":num_player_party_shares",player_loot_share), # Add shares for player's party (party_get_num_companion_stacks, ":num_stacks","p_main_party"), (try_for_range, ":i_stack", 1, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"), (try_begin), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size","p_main_party",":i_stack"), (val_add, ":num_player_party_shares", ":stack_size"), (else_try), (val_add, ":num_player_party_shares", hero_loot_share), (try_end), (try_end), (assign, reg0, ":num_player_party_shares"), ]), #script_party_give_xp_and_gold: # INPUT: param1: destroyed Party-id # calculates and gives player paty's share of gold and xp. ("party_give_xp_and_gold", [ (store_script_param_1, ":enemy_party"), #Party_id (call_script, "script_calculate_main_party_shares"), (assign, ":num_player_party_shares", reg0), # (assign, ":num_ally_shares", reg1), # (store_add, ":num_total_shares", ":num_player_party_shares", ":num_ally_shares"), (assign, ":total_gain", 0), (party_get_num_companion_stacks, ":num_stacks",":enemy_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":enemy_party",":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size",":enemy_party",":i_stack"), (store_character_level, ":level", ":stack_troop"), (store_add, ":gain", ":level", 10), (val_mul, ":gain", ":gain"), (val_div, ":gain", 10), (store_mul, ":stack_gain", ":gain", ":stack_size"), (val_add, ":total_gain", ":stack_gain"), (try_end), (val_mul, ":total_gain", "$g_strength_contribution_of_player"), (val_div, ":total_gain", 100), (val_min, ":total_gain", 40000), #eliminate negative results # (store_mul, ":player_party_xp_gain", ":total_gain", ":num_player_party_shares"), # (val_div, ":player_party_xp_gain", ":num_total_shares"), (assign, ":player_party_xp_gain", ":total_gain"), (store_random_in_range, ":r", 80, 100), #InVain: was 50-100, decrease randomness (val_mul, ":player_party_xp_gain", ":r"), (val_div, ":player_party_xp_gain", 100), (party_add_xp, "p_main_party", ":player_party_xp_gain"), # TLD - XP Bonus for INT Characters (assign, reg79, ":player_party_xp_gain"), (store_div, ":base_xp_share", ":player_party_xp_gain", 100), (party_get_num_companion_stacks, ":num_stacks_new", "p_main_party"), (try_for_range, ":stack", 0, ":num_stacks_new"), (party_stack_get_troop_id, ":stack_troop_new", "p_main_party", ":stack"), (troop_is_hero, ":stack_troop_new"), (try_begin), (store_attribute_level, ":int", ":stack_troop_new", ca_intelligence), (ge, ":int", 10), (assign, reg80, ":int"), # (store_mul, ":int_xp_bonus_multi", ":int", 10), # (assign, reg81, ":int_xp_bonus_multi"), # (val_div, ":int_xp_bonus_multi", 3), # (assign, reg82, ":int_xp_bonus_multi"), # (val_max, ":int_xp_bonus_multi", 1), # (store_mul, ":int_xp_bonus", ":base_xp_share", ":int_xp_bonus_multi"), # (assign, reg83, ":int_xp_bonus"), # (val_div, ":int_xp_bonus", 100), # (assign, reg84, ":int_xp_bonus"), #InVain: New formula, exponential growth for much bigger effect (store_sub, ":int_xp_bonus_multi", ":int", 3), (val_mul, ":int_xp_bonus_multi",":int_xp_bonus_multi"), #exponential base (assign, reg81, ":int_xp_bonus_multi"), (val_div, ":int_xp_bonus_multi", 40), #soften growth a bit (assign, reg83, ":int_xp_bonus_multi"), (store_mul, ":int_xp_bonus", ":base_xp_share", ":int_xp_bonus_multi"), (assign, reg84, ":int_xp_bonus"), (val_max, ":int_xp_bonus", 1), (add_xp_to_troop, ":int_xp_bonus", ":stack_troop_new", ), #Debug # (try_begin), # (eq, "$cheat_mode", 1), # (str_store_troop_name, s77, ":stack_troop_new"), #(display_message, "@{reg79} shared XP", color_good_news), # (display_message, "@{s77} has INT={reg80} - INT*INT={reg81}"), # (display_message, "@{reg83} reduced INT XP multi"), # (display_message, "@{s77} received {reg84} bonus XP", color_good_news), # (try_end), (try_begin), (eq, ":stack_troop_new", "trp_player"), (gt, ":int_xp_bonus", 50), #don't inform about peanuts (display_message, "@You gained {reg84} experience from your intelligence."), (try_end), (try_end), #agility wp bonus (try_begin), (store_attribute_level, ":agi", ":stack_troop_new", ca_agility), (ge, ":agi", 12), (store_sub, ":agi_wp_bonus_multi", ":agi", 3), (val_mul, ":agi_wp_bonus_multi",":agi_wp_bonus_multi"), #exponential base (store_mul, ":agi_wp_bonus", ":base_xp_share", ":agi_wp_bonus_multi"), (val_div, ":agi_wp_bonus", 1000), (troop_add_proficiency_points, ":stack_troop_new", ":agi_wp_bonus"), (assign, reg84, ":agi_wp_bonus"), (try_begin), (eq, ":stack_troop_new", "trp_player"), (gt, ":agi_wp_bonus", 2), (display_message, "@You gained {reg84} weapon points from your agility."), (try_end), (try_end), (try_end), # TLD - XP Bonus for INT Characters END (store_mul, ":player_gold_gain", ":total_gain", player_loot_share), (val_min, ":player_gold_gain", 60000), #eliminate negative results (store_random_in_range, ":r", 50, 100), (val_mul, ":player_gold_gain", ":r"), (val_div, ":player_gold_gain", 100), (val_div, ":player_gold_gain", ":num_player_party_shares"), #add gold now (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_is_hero, ":stack_troop"), (call_script, "script_troop_add_gold", ":stack_troop", ":player_gold_gain"), (try_end), (try_end), #Add morale (assign, ":morale_gain", ":total_gain"), (val_div, ":morale_gain", ":num_player_party_shares"), (call_script, "script_change_player_party_morale", ":morale_gain"), ]), #script_setup_troop_meeting: # INPUT: param1: troop_id with which meeting will be made, param2: troop_dna (optional) ("setup_troop_meeting", [ (store_script_param_1, ":meeting_troop"), (store_script_param_2, ":troop_dna"), (set_jump_mission, "mt_conversation_encounter"), (modify_visitors_at_site, "scn_conversation_scene"), (reset_visitors), (set_visitor, 0, "trp_player"), (troop_equip_items, ":meeting_troop"), (try_begin), (this_or_next|eq, ":meeting_troop", "trp_mordor_lord"), (eq, ":meeting_troop", "trp_lorien_lord"), (set_visitor, 18, ":meeting_troop", ":troop_dna"), (else_try), (set_visitor, 17, ":meeting_troop", ":troop_dna"), (try_end), (jump_to_scene, "scn_conversation_scene"), (change_screen_map_conversation, ":meeting_troop"), ]), #script_setup_party_meeting: # INPUT: param1: Party-id with which meeting will be made. ("setup_party_meeting", [ (store_script_param_1, ":meeting_party"), (try_begin), # party_meeting used as an indicator that conversation is with party (lt, "$g_encountered_party_relation", 0), #hostile (assign,"$party_meeting",-1), (else_try), (assign,"$party_meeting",1), # (call_script, "script_music_set_situation_with_culture", mtf_sit_encounter_hostile), (try_end), (set_jump_mission,"mt_conversation_encounter"), (modify_visitors_at_site,"scn_conversation_scene"),(reset_visitors), (set_visitor,0,"trp_player"), (party_stack_get_troop_id, ":meeting_troop",":meeting_party",0), (party_stack_get_troop_dna,":troop_dna",":meeting_party",0), (troop_equip_items, ":meeting_troop"), (try_begin), (this_or_next|eq,":meeting_troop","trp_mordor_lord"), (eq,":meeting_troop","trp_lorien_lord"), (set_visitor,18,":meeting_troop",":troop_dna"), (else_try), (set_visitor,17,":meeting_troop",":troop_dna"), (try_end), (call_script, "script_party_copy", "p_encountered_party_backup", ":meeting_party"), (party_remove_members,"p_encountered_party_backup",":meeting_troop",1), #add company to an opponent talker cf_party_remove_random_regular_troop (try_for_range, ":entry", 19, 30), (call_script, "script_cf_party_remove_random_regular_troop", "p_encountered_party_backup"), (store_random_in_range, ":rnd",1, 100000), # some random faces/equip for background troops (set_visitor,":entry",reg0,":rnd"), (try_end), (jump_to_scene,"scn_conversation_scene"), (change_screen_map_conversation, ":meeting_troop"), ]), #script_party_remove_all_companions: # INPUT: # param1: Party-id from which companions will be removed. # "$g_move_heroes" : controls if heroes will also be removed. ("party_remove_all_companions", [ (store_script_param_1, ":party"), #Source Party_id (party_get_num_companion_stacks, ":num_companion_stacks",":party"), (try_for_range_backwards, ":stack_no", 0, ":num_companion_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":stack_no"), (this_or_next|neg|troop_is_hero, ":stack_troop"), (eq, "$g_move_heroes", 1), (party_stack_get_size, ":stack_size",":party",":stack_no"), (party_remove_members, ":party", ":stack_troop", ":stack_size"), (try_end), ]), #script_party_remove_all_prisoners: # INPUT: param1: Party-id from which prisoners will be removed. # "$g_move_heroes" : controls if heroes will also be removed. ("party_remove_all_prisoners", [ (store_script_param_1, ":party"), #Source Party_id (party_get_num_prisoner_stacks, ":num_prisoner_stacks",":party"), (try_for_range_backwards, ":stack_no", 0, ":num_prisoner_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":party",":stack_no"), (this_or_next|neg|troop_is_hero, ":stack_troop"), (eq, "$g_move_heroes", 1), (party_prisoner_stack_get_size, ":stack_size",":party",":stack_no"), (party_remove_prisoners, ":party", ":stack_troop", ":stack_size"), (try_end), ]), #script_party_add_party_companions: # INPUT: param1: Party-id to add the second part, param2: Party-id which will be added to the first one. # "$g_move_heroes" : controls if heroes will also be added. ("party_add_party_companions", [ (store_script_param_1, ":target_party"), #Target Party_id (store_script_param_2, ":source_party"), #Source Party_id (party_get_num_companion_stacks, ":num_stacks",":source_party"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (this_or_next|neg|troop_is_hero, ":stack_troop"), (eq, "$g_move_heroes", 1), (party_stack_get_size, ":stack_size",":source_party",":stack_no"), (party_add_members, ":target_party", ":stack_troop", ":stack_size"), (party_stack_get_num_wounded, ":num_wounded", ":source_party", ":stack_no"), (party_wound_members, ":target_party", ":stack_troop", ":num_wounded"), (try_end), ]), #script_party_add_party_prisoners: # INPUT: param1: Party-id to add the second party, param2: Party-id which will be added to the first one. # "$g_move_heroes" : controls if heroes will also be added. # mtarini: in TLD remember to set faction of target party before calling this! ("party_add_party_prisoners", [ (store_script_param_1, ":target_party"), #Target Party_id (store_script_param_2, ":source_party"), #Source Party_id (store_faction_of_party, ":fac_a",":target_party"), # mtarini: store faction of receiving party (party_get_num_prisoner_stacks, ":num_stacks",":source_party"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (this_or_next|neg|troop_is_hero, ":stack_troop"), (eq, "$g_move_heroes", 1), (party_prisoner_stack_get_size, ":stack_size",":source_party",":stack_no"), # mtarini for TLD: adding freed prisoners to prisoners or to companinons, according to if they are friend enemies (store_troop_faction,":fac_b",":stack_troop"), (store_relation, ":rel" ,":fac_a" ,":fac_b"), (try_begin), (gt, ":rel", 0), # receiving partyis friend with freed prisoner (call_script, "script_cf_factions_are_allies", ":fac_b",":fac_a"), (party_add_members, ":target_party", ":stack_troop", ":stack_size"), (else_try), # receiving party is enemy with freed prisoners (party_add_prisoners, ":target_party", ":stack_troop", ":stack_size"), (try_end), (try_end), ]), #script_party_prisoners_add_party_companions: # INPUT: param1: Party-id to add the second part, param2: Party-id which will be added to the first one. # "$g_move_heroes" : controls if heroes will also be added. ("party_prisoners_add_party_companions", [ (store_script_param_1, ":target_party"), #Target Party_id (store_script_param_2, ":source_party"), #Source Party_id (store_script_param, ":player_involved", 3), (party_get_num_companion_stacks, ":num_stacks",":source_party"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (this_or_next|neg|troop_is_hero, ":stack_troop"), (eq, "$g_move_heroes", 1), (troop_get_type,":race",":stack_troop"), (store_troop_faction, ":faction", ":stack_troop"), (neq,":race",tf_troll), (assign, ":can_capture", 1), (try_begin), (this_or_next|eq,":race",tf_orc), ## TLD good guys finish all orcs, evil guys finish all elves, GA (this_or_next|eq,":race",tf_uruk), (this_or_next|eq,":race",tf_urukhai), (this_or_next|eq,":race",tf_lorien), (this_or_next|eq,":race",tf_imladris), (eq,":race",tf_woodelf), (assign, ":can_capture", 0), (try_begin), #except if player party is involved and capture prisoners quest active (eq, ":source_party", "p_collective_enemy"), (eq, ":player_involved", 1), (check_quest_active, "qst_capture_prisoners"), (is_between, ":faction", kingdoms_begin, kingdoms_end), #only applies to faction troops, no bandits (assign, ":can_capture", 1), (try_end), (try_end), (eq, ":can_capture", 1), (party_stack_get_size, ":stack_size",":source_party",":stack_no"), (try_begin), (eq, ":source_party", "p_collective_enemy"), #player party involved? Scale prisoners with prisoner management (eq, ":player_involved", 1), (party_get_skill_level, ":prs_management", "p_main_party", "skl_prisoner_management"), (val_mul, ":prs_management", ":stack_size"), (val_div, ":prs_management", 20), (val_add, ":stack_size", 1), (store_random_in_range, ":stack_size_new", ":prs_management", ":stack_size"), (assign, ":stack_size", ":stack_size_new"), (try_end), (party_add_prisoners, ":target_party", ":stack_troop", ":stack_size"), (try_end), ]), #script_party_prisoners_add_party_prisoners: # INPUT: param1: Party-id to add the second part, param2: Party-id which will be added to the first one. # "$g_move_heroes" : controls if heroes will also be added. ("party_prisoners_add_party_prisoners", [ (store_script_param_1, ":target_party"), #Target Party_id (store_script_param_2, ":source_party"), #Source Party_id (party_get_num_prisoner_stacks, ":num_stacks",":source_party"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (this_or_next|neg|troop_is_hero, ":stack_troop"), (eq, "$g_move_heroes", 1), (party_prisoner_stack_get_size, ":stack_size",":source_party",":stack_no"), (party_add_prisoners, ":target_party", ":stack_troop", ":stack_size"), (try_end), ]), # script_party_add_party: # INPUT: param1: Party-id to add the second part, param2: Party-id which will be added to the first one. # "$g_move_heroes" : controls if heroes will also be added. ("party_add_party", [ (store_script_param_1, ":target_party"), #Target Party_id (store_script_param_2, ":source_party"), #Source Party_id (call_script, "script_party_add_party_companions", ":target_party", ":source_party"), (call_script, "script_party_prisoners_add_party_prisoners", ":target_party", ":source_party"), ]), #script_party_copy: # INPUT: param1: Party-id to copy the second party, param2: Party-id which will be copied to the first one. ("party_copy", [ (assign, "$g_move_heroes", 1), (store_script_param_1, ":target_party"), #Target Party_id (store_script_param_2, ":source_party"), #Source Party_id (party_clear, ":target_party"), (store_faction_of_party, reg10, ":source_party"), (party_set_faction, ":target_party", reg10), (call_script, "script_party_add_party", ":target_party", ":source_party"), ]), #script_clear_party_group: # INPUT: param1: Party-id of the root of the group. # param2: winner faction # This script will clear the root party and all parties attached to it recursively. ("clear_party_group", [ (store_script_param_1, ":root_party"), (store_script_param_2, ":winner_faction"), (try_begin), (ge, ":root_party", 0), #MV fix for script errors #TLD assign faction strength penalties for party destruction, GA (store_faction_of_party, ":faction", ":root_party"), # Check if Isengard Guardian Party (try_begin), (check_quest_active, "qst_guardian_party_quest"), (faction_get_slot, ":guardian_party_exists", "fac_isengard", slot_faction_guardian_party), (eq, ":root_party", ":guardian_party_exists"), (quest_slot_eq, "qst_guardian_party_quest", slot_quest_target_party, ":root_party"), (call_script, "script_send_on_conversation_mission", tld_cc_gandalf_rohan_quest_win), (call_script, "script_destroy_center", p_town_isengard), (troop_get_slot, ":saru_party", trp_isengard_lord, slot_troop_leaded_party), (gt, ":saru_party", 0), (call_script, "script_clear_party_group", ":saru_party", "fac_rohan"), (troop_set_slot, trp_isengard_lord, slot_troop_occupation, 0), #just to be sure #(display_message, "@legion defeated"), (else_try), #Ent party? (quest_slot_eq, "qst_guardian_party_quest", slot_quest_target_party, ":root_party"), # (quest_get_slot, ":target_center", "qst_guardian_party_quest", slot_quest_target_center), # (call_script, "script_destroy_center", ":target_center"), (call_script, "script_cf_isengard_guardian_quest_fail"), #(display_message, "@Ents defeated"), (try_end), # Guardian Party Quest - END (try_begin), (is_between, ":faction", kingdoms_begin, kingdoms_end), (faction_get_slot,":strength",":faction",slot_faction_strength_tmp), (party_get_slot,":party_value", ":root_party",slot_party_victory_value), #(party_get_slot,":party_type", ":root_party",slot_party_type), # (try_begin), # (eq,":party_type",spt_kingdom_hero_party), #hosts dying decrease faction strength unconditionally (val_sub, ":strength", ":party_value"), #debug stuff (faction_get_slot, ":debug_loss", ":faction", slot_faction_debug_str_loss), (val_add, ":debug_loss", ":party_value"), (faction_set_slot, ":faction", slot_faction_debug_str_loss, ":debug_loss"), # (else_try), # (store_div,":s0",":strength",1000), # (store_sub,":s",":strength",":party_value"), # (val_div,":s",1000), # (eq,":s0",":s"), # (val_sub, ":strength",":party_value"), # lesser parties dying can't shift faction strength through threshold # (try_end), (try_begin), (ge, "$tld_war_began", 1), #Invain: no faction strength changes before war starts (faction_set_slot,":faction",slot_faction_strength_tmp,":strength"), # new strength stored in tmp slot to be processed in a trigger every 2h (try_end), # add half victory points to the winner faction (for non-player victories), distribute full points to theater factions in player victories (Kham Nov 2018) (try_begin), (ge, "$tld_war_began", 1), #Invain: no faction strength changes before war starts (neq, "$tld_option_regen_rate", 3), #None - no regen, even from battles (is_between, ":winner_faction", kingdoms_begin, kingdoms_end), (try_begin), (eq, "$player_won_last_battle", 1), (call_script, "script_find_theater", "p_main_party"), (assign, ":player_theater", reg0), (assign, ":num_allied_factions_in_theater", 0), (try_for_range, ":ally_factions_in_theater", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":ally_factions_in_theater", slot_faction_state, sfs_active), (store_relation, ":rel_w_player", "$players_kingdom", ":ally_factions_in_theater"), (gt, ":rel_w_player", 0), (faction_slot_eq, ":ally_factions_in_theater", slot_faction_active_theater, ":player_theater"), (val_add, ":num_allied_factions_in_theater", 1), (try_end), (gt, ":num_allied_factions_in_theater", 0), (try_begin), #Revert to original formula if there is only 1 faction in a theater (eq, ":num_allied_factions_in_theater", 1), (assign, ":num_allied_factions_in_theater", 2), (try_end), (store_div, ":win_value", ":party_value", ":num_allied_factions_in_theater"), (try_for_range, ":str_share", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":str_share", slot_faction_state, sfs_active), (store_relation, ":rel_w_player_2", "$players_kingdom", ":str_share"), (gt, ":rel_w_player_2", 0), (faction_slot_eq, ":str_share", slot_faction_active_theater, ":player_theater"), (faction_get_slot,":winner_strength",":str_share",slot_faction_strength_tmp), (val_add, ":winner_strength", ":win_value"), (val_min, ":winner_strength", fac_str_max), #limit max strength (faction_set_slot,":str_share",slot_faction_strength_tmp,":winner_strength"), #debug stuff (faction_get_slot, ":debug_gain", ":str_share", slot_faction_debug_str_gain), (val_add, ":debug_gain", ":win_value"), (faction_set_slot, ":str_share", slot_faction_debug_str_gain, ":debug_gain"), #debug (try_begin), (eq, cheat_switch, 1), (assign,reg60,":party_value"), (assign,reg61,":strength"), (assign,reg62,":win_value"), (assign,reg63,":winner_strength"), (str_store_faction_name,s1,":faction"), (str_store_faction_name,s2,":str_share"), (try_begin), (is_between, ":str_share", kingdoms_begin, kingdoms_end), #(display_message,"@DEBUG: {s1} strength -{reg60} to {reg61}, {s2} strength +{reg62} to {reg63}."), #mvdebug (else_try), #(display_message,"@DEBUG: {s1} strength -{reg60} to {reg61}, defeat by {s2}."), #mvdebug (try_end), (try_end), (try_end), #End range pot sharing (assign, "$player_won_last_battle", 0), (else_try), #Start non-player victories (faction_get_slot,":winner_strength",":winner_faction",slot_faction_strength_tmp), (store_div, ":win_value", ":party_value", 2), #this formula could be balanced after playtesting (val_add, ":winner_strength", ":win_value"), (val_min, ":winner_strength", fac_str_max), #limit max strength (faction_set_slot,":winner_faction",slot_faction_strength_tmp,":winner_strength"), #debug stuff (faction_get_slot, ":debug_gain", ":winner_faction", slot_faction_debug_str_gain), (val_add, ":debug_gain", ":win_value"), (faction_set_slot, ":winner_faction", slot_faction_debug_str_gain, ":debug_gain"), (try_end), (try_end), #debug (try_begin), (eq, cheat_switch, 1), (assign,reg0,":party_value"), (assign,reg1,":strength"), (assign,reg2,":win_value"), (assign,reg3,":winner_strength"), (str_store_faction_name,s1,":faction"), (str_store_faction_name,s2,":winner_faction"), (try_begin), (is_between, ":winner_faction", kingdoms_begin, kingdoms_end), #(display_message,"@DEBUG: {s1} strength -{reg0} to {reg1}, {s2} strength +{reg2} to {reg3}."), #mvdebug (else_try), #(display_message,"@DEBUG: {s1} strength -{reg0} to {reg1}, defeat by {s2}."), #mvdebug (try_end), (try_end), (try_end), #end TLD (party_clear, ":root_party"), (party_get_num_attached_parties, ":num_attached_parties", ":root_party"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":root_party", ":attached_party_rank"), (call_script, "script_clear_party_group", ":attached_party", ":winner_faction"), # TLD bug here: this will give str loss/gain twice in player battles (try_end), (try_end), ]), #script_get_nonempty_party_in_group: # INPUT: param1: Party-id of the root of the group. # OUTPUT: reg0: nonempy party-id ("get_nonempty_party_in_group", [ (store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_companion_stacks", ":party_no"), (try_begin), (gt, ":num_companion_stacks", 0), (assign, reg0, ":party_no"), (else_try), (assign, reg0, -1), (party_get_num_attached_parties, ":num_attached_parties", ":party_no"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (lt, reg0, 0), (party_get_attached_party_with_rank, ":attached_party", ":party_no", ":attached_party_rank"), (call_script, "script_get_nonempty_party_in_group", ":attached_party"), (try_end), (try_end), ]), #script_collect_prisoners_from_empty_parties: # INPUT: param1: Party-id of the root of the group, param2: Party to collect prisoners in. # make sure collection party is cleared before calling this. ("collect_prisoners_from_empty_parties", [ (store_script_param_1, ":party_no"), (store_script_param_2, ":collection_party"), (party_get_num_companions, ":num_companions", ":party_no"), (try_begin), (eq, ":num_companions", 0), #party is empty (has no companions). Collect its prisoners. (party_get_num_prisoner_stacks, ":num_stacks",":party_no"), (try_for_range, ":stack_no", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":party_no",":stack_no"), (troop_is_hero, ":stack_troop"), (party_add_members, ":collection_party", ":stack_troop", 1), (try_end), (try_end), (party_get_num_attached_parties, ":num_attached_parties", ":party_no"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":party_no", ":attached_party_rank"), (call_script, "script_collect_prisoners_from_empty_parties", ":attached_party", ":collection_party"), (try_end), ]), #script_print_casualties_to_s0: # INPUT: param1: Party_id, param2: 0 = use new line, 1 = use comma, 2 = party of routed troops #OUTPUT: string register 0. ("print_casualties_to_s0", [(store_script_param, ":party_no", 1), (store_script_param, ":use_comma", 2), (str_clear, s0), (assign, ":total_reported", 0), (assign, ":total_wounded", 0), (assign, ":total_killed", 0), (assign, ":total_routed", 0), (assign, ":num_routed", 0), (party_get_num_companion_stacks, ":num_stacks",":party_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party_no",":i_stack"), (party_stack_get_size, ":stack_size",":party_no",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party_no",":i_stack"), (store_sub, ":num_killed", ":stack_size", ":num_wounded"), (try_begin), (eq, ":party_no", "p_player_casualties"), (troop_get_slot, ":num_routed", ":stack_troop", slot_troop_routed_us), (store_sub, ":num_killed", ":num_killed", ":num_routed"), (else_try), (eq, ":party_no", "p_ally_casualties"), (troop_get_slot, ":num_routed", ":stack_troop", slot_troop_routed_allies), (store_sub, ":num_killed", ":num_killed", ":num_routed"), (else_try), (eq, ":party_no", "p_enemy_casualties"), (troop_get_slot, ":num_routed", ":stack_troop", slot_troop_routed_enemies), (store_sub, ":num_killed", ":num_killed", ":num_routed"), (try_end), (store_sub, ":stack_size", ":stack_size", ":num_routed"), (val_add, ":total_killed", ":num_killed"), (val_add, ":total_wounded", ":num_wounded"), (val_add, ":total_routed", ":num_routed"), (try_begin), (this_or_next|gt, ":num_killed", 0), (this_or_next|gt, ":num_wounded", 0), (gt, ":num_routed", 0), (store_add, reg3, ":num_killed", ":num_wounded"), (val_add, reg3, ":num_routed"), (str_store_troop_name_by_count, s1, ":stack_troop", reg3), (try_begin), (troop_is_hero, ":stack_troop"), (assign, reg3, 0), (try_end), (try_begin), (gt, ":num_killed", 0), (gt, ":num_wounded", 0), (gt, ":num_routed", 0), (assign, reg4, ":num_killed"), (assign, reg5, ":num_wounded"), (assign, reg6, ":num_routed"), (str_store_string, s2, "@{reg4} killed, {reg5} wounded, {reg6} routed"), (else_try), (gt, ":num_killed", 0), (gt, ":num_wounded", 0), (assign, reg4, ":num_killed"), (assign, reg5, ":num_wounded"), (str_store_string, s2, "@{reg4} killed, {reg5} wounded"), (else_try), (gt, ":num_killed", 0), (gt, ":num_routed", 0), (assign, reg4, ":num_killed"), (assign, reg5, ":num_routed"), (str_store_string, s2, "@{reg4} killed, {reg5} routed"), (else_try), (gt, ":num_wounded", 0), (gt, ":num_routed", 0), (assign, reg4, ":num_wounded"), (assign, reg5, ":num_routed"), (str_store_string, s2, "@{reg4} wounded, {reg5} routed"), (else_try), (gt, ":num_killed", 0), (str_store_string, s2, "@killed"), (else_try), (gt, ":num_routed", 0), (str_store_string, s2, "@routed"), (else_try), (str_store_string, s2, "@wounded"), (try_end), (try_begin), (eq, ":use_comma", 1), (try_begin), (eq, ":total_reported", 0), (str_store_string, s0, "@{reg3?{reg3}:} {s1} ({s2})"), (else_try), (str_store_string, s0, "@{s0}, {reg3?{reg3}:} {s1} ({s2})"), (try_end), (else_try), (str_store_string, s0, "@{s0}^{reg3?{reg3}:} {s1} ({s2})"), (try_end), (val_add, ":total_reported", 1), (try_end), (try_end), (try_begin), (this_or_next|gt, ":total_killed", 0), (this_or_next|gt, ":total_wounded", 0), (gt, ":total_routed", 0), (store_add, reg3, ":total_killed", ":total_wounded"), (val_add, reg3, ":total_routed"), (try_begin), (gt, ":total_killed", 0), (gt, ":total_wounded", 0), (gt, ":total_routed", 0), (assign, reg4, ":total_killed"), (assign, reg5, ":total_wounded"), (assign, reg6, ":total_routed"), (str_store_string, s2, "@{reg4} killed, {reg5} wounded, {reg6} routed"), (else_try), (gt, ":total_killed", 0), (gt, ":total_wounded", 0), (assign, reg4, ":total_killed"), (assign, reg5, ":total_wounded"), (str_store_string, s2, "@{reg4} killed, {reg5} wounded"), (else_try), (gt, ":total_wounded", 0), (gt, ":total_routed", 0), (assign, reg4, ":total_wounded"), (assign, reg5, ":total_routed"), (str_store_string, s2, "@{reg4} wounded, {reg5} routed"), (else_try), (gt, ":total_killed", 0), (gt, ":total_routed", 0), (assign, reg4, ":total_killed"), (assign, reg5, ":total_routed"), (str_store_string, s2, "@{reg4} killed, {reg5} routed"), (else_try), (gt, ":total_killed", 0), (str_store_string, s2, "@killed"), (else_try), (gt, ":total_routed", 0), (str_store_string, s2, "@routed"), (else_try), (str_store_string, s2, "@wounded"), (try_end), (str_store_string, s0, "@{s0}^TOTAL: {reg3} ({s2})"), (else_try), (try_begin),(eq, ":use_comma", 1),(str_store_string, s0, "@None"), (else_try), (str_store_string, s0, "@^None"), (try_end), (try_end), ]), #script_write_fit_party_members_to_stack_selection # INPUT: param1: party_no, exclude_leader #OUTPUT: trp_stack_selection_amounts slots (slot 0 = number of stacks, 1 = number of men fit, 2..n = stack sizes (fit)) # trp_stack_selection_ids slots (2..n = stack troops) ("write_fit_party_members_to_stack_selection", [ (store_script_param, ":party_no", 1), (store_script_param, ":exclude_leader", 2), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (assign, ":slot_index", 2), (assign, ":total_fit", 0), (try_for_range, ":stack_index", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":stack_index"), (assign, ":num_fit", 0), (try_begin), (troop_is_hero, ":stack_troop"), (try_begin), (neg|troop_is_wounded, ":stack_troop"), (this_or_next|eq, ":exclude_leader", 0), (neq, ":stack_index", 0), (assign, ":num_fit",1), (try_end), (else_try), (party_stack_get_size, ":num_fit", ":party_no", ":stack_index"), (party_stack_get_num_wounded, ":num_wounded", ":party_no", ":stack_index"), (val_sub, ":num_fit", ":num_wounded"), (try_end), (try_begin), (gt, ":num_fit", 0), (troop_set_slot, "trp_stack_selection_amounts", ":slot_index", ":num_fit"), (troop_set_slot, "trp_stack_selection_ids", ":slot_index", ":stack_troop"), (val_add, ":slot_index", 1), (try_end), (val_add, ":total_fit", ":num_fit"), (try_end), (val_sub, ":slot_index", 2), (troop_set_slot, "trp_stack_selection_amounts", 0, ":slot_index"), (troop_set_slot, "trp_stack_selection_amounts", 1, ":total_fit"), ]), #script_remove_fit_party_member_from_stack_selection # INPUT: param1: slot_index #OUTPUT: reg0 = troop_no # trp_stack_selection_amounts slots (slot 0 = number of stacks, 1 = number of men fit, 2..n = stack sizes (fit)) # trp_stack_selection_ids slots (2..n = stack troops) ("remove_fit_party_member_from_stack_selection", [ (store_script_param, ":slot_index", 1), (val_add, ":slot_index", 2), (troop_get_slot, ":amount", "trp_stack_selection_amounts", ":slot_index"), (troop_get_slot, ":troop_no", "trp_stack_selection_ids", ":slot_index"), (val_sub, ":amount", 1), (troop_set_slot, "trp_stack_selection_amounts", ":slot_index", ":amount"), (troop_get_slot, ":total_amount", "trp_stack_selection_amounts", 1), (val_sub, ":total_amount", 1), (troop_set_slot, "trp_stack_selection_amounts", 1, ":total_amount"), (try_begin), (le, ":amount", 0), (troop_get_slot, ":num_slots", "trp_stack_selection_amounts", 0), (store_add, ":end_cond", ":num_slots", 2), (store_add, ":begin_cond", ":slot_index", 1), (try_for_range, ":index", ":begin_cond", ":end_cond"), (store_sub, ":prev_index", ":index", 1), (troop_get_slot, ":value", "trp_stack_selection_amounts", ":index"), (troop_set_slot, "trp_stack_selection_amounts", ":prev_index", ":value"), (troop_get_slot, ":value", "trp_stack_selection_ids", ":index"), (troop_set_slot, "trp_stack_selection_ids", ":prev_index", ":value"), (try_end), (val_sub, ":num_slots", 1), (troop_set_slot, "trp_stack_selection_amounts", 0, ":num_slots"), (try_end), (assign, reg0, ":troop_no"), ]), #script_remove_random_fit_party_member_from_stack_selection #OUTPUT: reg0 = troop_no # trp_stack_selection_amounts slots (slot 0 = number of stacks, 1 = number of men fit, 2..n = stack sizes (fit)) # trp_stack_selection_ids slots (2..n = stack troops) ("remove_random_fit_party_member_from_stack_selection", [ (troop_get_slot, ":total_amount", "trp_stack_selection_amounts", 1), (store_random_in_range, ":random_troop", 0, ":total_amount"), (troop_get_slot, ":num_slots", "trp_stack_selection_amounts", 0), (store_add, ":end_cond", ":num_slots", 2), (try_for_range, ":index", 2, ":end_cond"), (troop_get_slot, ":amount", "trp_stack_selection_amounts", ":index"), (val_sub, ":random_troop", ":amount"), (lt, ":random_troop", 0), (assign, ":end_cond", 0), (store_sub, ":slot_index", ":index", 2), (try_end), (call_script, "script_remove_fit_party_member_from_stack_selection", ":slot_index"), ]), #script_tld_start_training_at_training_ground # Sets up the training scene and spawns player and opponents of appropriate race and equipment # INPUT: # $g_tld_training_mode = abm_training, abm_team or abm_gauntlet # $g_tld_training_opponents = 1-4 for abm_training, 4-12 for abm_team # $g_tld_training_weapon = player weapon type ("tld_start_training_at_training_ground", [ (set_jump_mission, "mt_training_ground_training"), (party_get_slot, ":training_scene", "$g_encountered_party", slot_town_arena), (jump_to_scene, ":training_scene"), (modify_visitors_at_site, ":training_scene"), (reset_visitors), # Set up player and his team, if any (try_begin), (eq, "$g_tld_training_mode", abm_training), (assign, ":player_entry_point", 4), (else_try), (assign, ":player_entry_point", 12), (try_end), # Player (set_visitor, ":player_entry_point", "trp_player"), (call_script, "script_tld_training_equip_entry_point", ":player_entry_point", "trp_player", 0, "$g_tld_training_weapon", 0), #not mounted #Player team - first check for unwounded companions, then fill up with medium training troops (try_begin), (eq, "$g_tld_training_mode", abm_team), (assign, ":teammates_needed", 3), (store_add, ":teammate_entry_point", ":player_entry_point", 1), # companions (party_get_num_companion_stacks, ":num_stacks", "p_main_party"), (try_for_range, ":stack_no", 1, ":num_stacks"), (gt, ":teammates_needed", 0), (party_stack_get_troop_id, ":cur_troop", "p_main_party", ":stack_no"), (troop_is_hero, ":cur_troop"), (neg|troop_is_wounded, ":cur_troop"), (set_visitor, ":teammate_entry_point", ":cur_troop"), (call_script, "script_tld_training_equip_entry_point", ":teammate_entry_point", ":cur_troop", 0, -1, -1), #random weapon type and mount (val_add, ":teammate_entry_point", 1), (val_sub, ":teammates_needed", 1), (try_end), # filling up (try_for_range, ":unused", 0, ":teammates_needed"), (store_random_in_range, ":random_no", 0, 100), (try_begin), (lt, ":random_no", 30), (faction_get_slot, ":teammate", "$g_encountered_party_faction", slot_faction_tier_1_troop), (else_try), (lt, ":random_no", 70), (faction_get_slot, ":teammate", "$g_encountered_party_faction", slot_faction_tier_2_troop), (else_try), (faction_get_slot, ":teammate", "$g_encountered_party_faction", slot_faction_tier_3_troop), (try_end), (set_visitor, ":teammate_entry_point", ":teammate"), (call_script, "script_tld_training_equip_entry_point", ":teammate_entry_point", ":teammate", 0, -1, -1), #random weapon type and mount (val_add, ":teammate_entry_point", 1), (try_end), (else_try), (eq, "$g_tld_training_mode", abm_mass_melee), (store_add, ":teammate_entry_point", ":player_entry_point", 1), # filling up (try_for_range, ":unused", 0, 3), (store_random_in_range, ":random_no", 0, 100), (try_begin), (lt, ":random_no", 30), (faction_get_slot, ":teammate", "$g_encountered_party_faction", slot_faction_tier_1_troop), (else_try), (lt, ":random_no", 70), (faction_get_slot, ":teammate", "$g_encountered_party_faction", slot_faction_tier_2_troop), (else_try), (faction_get_slot, ":teammate", "$g_encountered_party_faction", slot_faction_tier_3_troop), (try_end), (set_visitors, ":teammate_entry_point", ":teammate", 6), # 1 player + 6*3 troops = 19 vs. 24 enemies (call_script, "script_tld_training_equip_entry_point", ":teammate_entry_point", ":teammate", 0, -1, -1), #random weapon type and mount (val_add, ":teammate_entry_point", 1), (try_end), (try_end), #Set up enemies (try_begin), (eq, "$g_tld_training_mode", abm_training), (assign, ":first_enemy_entry_point", 5), (else_try), (assign, ":first_enemy_entry_point", 16), (try_end), (store_add, ":last_enemy_entry_point_plus_one", ":first_enemy_entry_point", "$g_tld_training_opponents"), # (try_begin), (store_character_level, ":player_level_bias", "trp_player"), (val_clamp, ":player_level_bias", 1, 30), #1-29 (val_sub, ":player_level_bias", 15), #-14..+14 (try_for_range, ":entry_point", ":first_enemy_entry_point", ":last_enemy_entry_point_plus_one"), # choose opponent based on player level and random number (store_random_in_range, ":random_no", 0, 100), (val_add, ":random_no", ":player_level_bias"), #-14..+113 (try_begin),(lt,":random_no",20),(faction_get_slot,":opponent","$g_encountered_party_faction",slot_faction_tier_1_troop), (else_try),(lt,":random_no",40),(faction_get_slot,":opponent","$g_encountered_party_faction",slot_faction_tier_2_troop), (else_try),(lt,":random_no",60),(faction_get_slot,":opponent","$g_encountered_party_faction",slot_faction_tier_3_troop), (else_try),(lt,":random_no",80),(faction_get_slot,":opponent","$g_encountered_party_faction",slot_faction_tier_4_troop), (else_try), (faction_get_slot,":opponent","$g_encountered_party_faction",slot_faction_tier_5_troop), (try_end), # arm the opponent randomly (try_begin), (eq, "$g_tld_training_mode", abm_mass_melee), (set_visitors, ":entry_point", ":opponent", 2), #24 dudes (else_try), (neq, "$g_tld_training_mode", abm_gauntlet), (set_visitor, ":entry_point", ":opponent"), #gauntlet does this in the mission template (try_end), (call_script, "script_tld_training_equip_entry_point", ":entry_point", ":opponent", 1, -1, -1), #random weapon type and mount (try_end), # (try_end), (change_screen_mission), ]), #script_tld_training_equip_entry_point # Equip entry point with training items for a weapon type # INPUT: entry_point to override # troop to spawn there # team: 0-player, 1-enemy # weapon_type = itp_X; -1 for random # is_mounted = 0 or 1, flag for mounted weapons; -1 for random # OUTPUT: none ("tld_training_equip_entry_point", [ (store_script_param_1, ":entry_point"), (store_script_param_2, ":troop"), (store_script_param, ":team", 3), (store_script_param, ":weapon_type", 4), (store_script_param, ":is_mounted", 5), (troop_get_type, ":race", ":troop"), (assign, ":is_orc", 0), (try_begin), (is_between, ":race", tf_orc_begin, tf_orc_end), (assign, ":is_orc", 1), (try_end), #(set_visitor, ":entry_point", ":troop"), (mission_tpl_entry_clear_override_items, "mt_training_ground_training", ":entry_point"), (try_begin),(eq,"$g_talk_troop","trp_trainer_gondor"),(assign,":shield_item","itm_gon_tab_shield_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_rohan" ),(assign,":shield_item","itm_rohan_shield_c"), (else_try),(eq,"$g_talk_troop","trp_trainer_elf" ),(assign,":shield_item","itm_mirkwood_spear_shield_c"), (else_try),(eq,"$g_talk_troop","trp_trainer_dwarf" ),(assign,":shield_item","itm_beorn_shield"), (else_try),(eq,"$g_talk_troop","trp_trainer_dale" ), (try_begin),(eq, ":team", 0), (assign, ":shield_item" , "itm_dale_shield_a"), (else_try), (assign, ":shield_item" , "itm_dale_shield_b"), (try_end), (else_try),(eq,"$g_talk_troop","trp_trainer_harad" ),(assign,":shield_item","itm_harad_shield_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_rhun" ),(assign,":shield_item","itm_rhun_shield"), (else_try),(eq,"$g_talk_troop","trp_trainer_khand" ),(assign,":shield_item","itm_tab_shield_small_round_b"), (else_try),(eq,"$g_talk_troop","trp_trainer_beorn" ),(assign,":shield_item","itm_beorn_shield"), (else_try),(eq,"$g_talk_troop","trp_trainer_umbar" ),(assign,":shield_item","itm_umb_shield_b"), (else_try),#(eq, "$g_talk_troop", "trp_trainer_mordor"), #or isengard - for all orcs (assign, ":shield_item" , "itm_orc_shield_a"), (try_end), # clothes (try_begin), (eq, ":team", 0), #player team (try_begin),(eq,"$g_talk_troop","trp_trainer_gondor"),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_rohan" ),#(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","rohan_armor_a"), #naked (else_try),(eq,"$g_talk_troop","trp_trainer_elf" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_dwarf" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_dale" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_harad" ),#(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_harad_tunic"), # naked (else_try),(eq,"$g_talk_troop","trp_trainer_rhun" ),#(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"),# naked (else_try),(eq,"$g_talk_troop","trp_trainer_khand" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_beorn" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_black_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_umbar" ),#(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_beorn_tunic"), # naked (else_try), #(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_white_tunic_a"), #naked (try_end), (else_try), #opponents (try_begin),(eq,"$g_talk_troop","trp_trainer_gondor"),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_black_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_rohan" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_rohan_recruit"), (else_try),(eq,"$g_talk_troop","trp_trainer_elf" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_black_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_dwarf" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_black_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_dale" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_black_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_harad" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_harad_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_rhun" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_rhun_armor_a"), (else_try),(eq,"$g_talk_troop","trp_trainer_khand" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_khand_light"), (else_try),(eq,"$g_talk_troop","trp_trainer_beorn" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_woodman_tunic"), (else_try),(eq,"$g_talk_troop","trp_trainer_umbar" ),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point","itm_harad_tunic"), (else_try),#(eq,"$g_talk_troop","trp_trainer_mordor"), #or isengard - for all orcs # (try_begin),(eq, ":race", tf_orc), # (mission_tpl_entry_add_override_item, "mt_training_ground_training", ":entry_point", "itm_orc_tribal_a"), # (else_try), # (mission_tpl_entry_add_override_item, "mt_training_ground_training", ":entry_point", "itm_black_tunic"), # (try_end), (try_end), (try_end), # proper boots (try_begin), (is_between, ":race", tf_orc_begin, tf_orc_end), #(mission_tpl_entry_add_override_item, "mt_training_ground_training", ":entry_point", "itm_orc_ragwrap"), # no footwear for orcs or urucs (else_try), (mission_tpl_entry_add_override_item, "mt_training_ground_training", ":entry_point", "itm_leather_boots"), (try_end), # random equipment (no more type_thrown) (try_begin), (eq, ":weapon_type", -1), (store_random_in_range, ":random_no", 0, 100), (try_begin), (lt, ":random_no", 15), (neq, "$g_tld_training_mode", abm_mass_melee), (assign, ":weapon_type", itp_type_bow), #15% chance (else_try), (lt, ":random_no", 25), (neq, "$g_tld_training_mode", abm_mass_melee), (assign, ":weapon_type", itp_type_thrown), #10% (else_try), (lt, ":random_no", 50), (assign, ":weapon_type", itp_type_one_handed_wpn), #25% (else_try), (lt, ":random_no", 75), (assign, ":weapon_type", itp_type_two_handed_wpn), #25% (else_try), (assign, ":weapon_type", itp_type_polearm), #25% (try_end), (try_end), # random mounted status (try_begin), (eq, ":is_mounted", -1), (store_random_in_range, ":is_mounted", 0, 100), (val_div, ":is_mounted", 80), #20% chance mounted (eq, "$g_tld_training_mode", abm_mass_melee), (assign, ":is_mounted", 0), (try_end), # overrides: no horses for dwarves and big orcs, always horses for rohan (try_begin), (this_or_next|eq, "$g_talk_troop", "trp_trainer_dwarf"), (is_between, ":race", tf_urukhai, tf_orc_end), (assign, ":is_mounted", 0), (else_try), (eq, "$g_talk_troop", "trp_trainer_rohan"), (assign, ":is_mounted", 1), (try_end), # equip mount (try_begin), (eq, ":is_mounted", 1), (try_begin), (eq, ":is_orc", 1), (mission_tpl_entry_add_override_item, "mt_training_ground_training", ":entry_point", "itm_warg_1b"), (else_try), (mission_tpl_entry_add_override_item, "mt_training_ground_training", ":entry_point", "itm_sumpter_horse"), (try_end), (try_end), # choose set of items according to weapon type (assign, ":item_1", -1), (assign, ":item_2", -1), (assign, ":item_3", -1), (assign, ":item_4", -1), (try_begin), (eq, ":weapon_type", itp_type_bow), (assign, ":item_1", "itm_practice_bow"), (assign, ":item_2", "itm_arrows"), (assign, ":item_3", "itm_wood_club"), (else_try), (eq, ":weapon_type", itp_type_thrown), (assign, ":item_1", "itm_wooden_javelin"), (assign, ":item_2", ":shield_item"), (assign, ":item_3", "itm_wood_club"), (else_try), (eq, ":weapon_type", itp_type_one_handed_wpn), (store_random_in_range, ":random_no", 0, 3), (assign, ":item_1", "itm_wood_club"), (assign, ":item_2", ":shield_item"), (else_try), (eq, ":weapon_type", itp_type_two_handed_wpn), (assign, ":item_1", "itm_twohand_wood_club"), (else_try), #(eq, ":weapon_type", itp_type_polearm), (try_begin), (eq, ":is_mounted", 1), (assign, ":item_1", "itm_practice_staff"), (assign, ":item_2", ":shield_item"), (else_try), (assign, ":item_1", "itm_practice_staff"), (try_end), (try_end), #...and equip (try_begin),(ge,":item_1",0),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point",":item_1"),(try_end), (try_begin),(ge,":item_2",0),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point",":item_2"),(try_end), (try_begin),(ge,":item_3",0),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point",":item_3"),(try_end), (try_begin),(ge,":item_4",0),(mission_tpl_entry_add_override_item,"mt_training_ground_training",":entry_point",":item_4"),(try_end), ]), #script_get_random_melee_training_weapon # OUTPUT: reg0 = weapon_1, reg1 = weapon_2 ("get_random_melee_training_weapon", [ (assign, ":weapon_1", -1), (assign, ":weapon_2", -1), (store_random_in_range, ":random_no", 0, 3), (try_begin),(eq, ":random_no", 0), (else_try),(eq, ":random_no", 1), (else_try), (try_end), (assign, reg0, ":weapon_1"), (assign, reg1, ":weapon_2"), ]), #script_party_count_fit_regulars: # Returns the number of unwounded regular companions in a party # INPUT: param1: Party-id ("party_count_fit_regulars", [ (store_script_param_1, ":party"), (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, reg0, 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size",":party",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_sub, ":stack_size", ":num_wounded"), (val_add, reg0, ":stack_size"), (try_end), ]), # small script, mtarini ("cf_party_is_mostly_mounted", [ (store_script_param_1, ":party"), (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, ":num_foot",0), (assign, ":num_mounted",0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (assign, ":x",1), (try_begin), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size,":x",":party",":i_stack"), (try_end), (try_begin),(troop_is_mounted, ":stack_troop"), (val_add, ":num_mounted",":x"), (else_try), (val_add, ":num_foot", ":x"), (try_end), (try_end), (ge, ":num_mounted",":num_foot"), ]), #script_party_count_fit_for_battle: # Returns the number of unwounded companions in a party # INPUT: param1: Party-id # OUTPUT: reg0 = result ("party_count_fit_for_battle", [ (store_script_param_1, ":party"), #Party_id (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, reg0, 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (assign, ":num_fit",0), (try_begin), (troop_is_hero, ":stack_troop"), (try_begin), (neg|troop_is_wounded, ":stack_troop"), (assign, ":num_fit",1), (else_try), # TLD, track wounded status (troop_set_slot, ":stack_troop", slot_troop_wounded, 1), (try_end), (else_try), (party_stack_get_size, ":num_fit",":party",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_sub, ":num_fit", ":num_wounded"), (try_end), (val_add, reg0, ":num_fit"), (try_end), ]), #script_party_count_members_with_full_health # Returns the number of unwounded regulars, and heroes other than player with 100% hitpoints in a party # INPUT: param1: Party-id # OUTPUT: reg0 = result ("party_count_members_with_full_health", [ (store_script_param_1, ":party"), #Party_id (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, reg0, 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (assign, ":num_fit",0), (try_begin), (troop_is_hero, ":stack_troop"), (neq, ":stack_troop", "trp_player"), (store_troop_health, ":troop_hp", ":stack_troop"), (try_begin), (ge, ":troop_hp", 80), (assign, ":num_fit",1), (try_end), (else_try), (party_stack_get_size, ":num_fit",":party",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_sub, ":num_fit", ":num_wounded"), (val_max, ":num_fit", 0), (try_end), (val_add, reg0, ":num_fit"), (try_end), ]), ("party_count_wounded", [ (store_script_param_1, ":party"), #Party_id (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, reg0, 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (try_begin), (troop_is_hero, ":stack_troop"), (store_troop_health, ":troop_hp", ":stack_troop"), (try_begin), (le, ":troop_hp", 99), (val_add, reg0,5), # heros count for 5 (try_end), (else_try), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_add, reg0, ":num_wounded"), (try_end), (try_end), ]), #script_get_stack_with_rank: # Returns the stack no, containing unwounded regular companions with rank rank. # INPUT: param1: Party-id, param2: rank ("get_stack_with_rank", [ (store_script_param_1, ":party"), #Party_id (store_script_param_2, ":rank"), #Rank (party_get_num_companion_stacks, ":num_stacks",":party"), (assign, reg(0), -1), (assign, ":num_total", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (eq, reg(0), -1), #continue only if we haven't found the result yet. (party_stack_get_troop_id, ":stack_troop",":party",":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size",":party",":i_stack"), (party_stack_get_num_wounded, ":num_wounded",":party",":i_stack"), (val_sub, ":stack_size", ":num_wounded"), (val_add, ":num_total", ":stack_size"), (try_begin), (lt, ":rank", ":num_total"), (assign, reg(0), ":i_stack"), (try_end), (try_end), ]), #script_inflict_casualties_to_party: # INPUT: param1 = Party-id, param2 = number of rounds #OUTPUT: This script doesn't return a value but populates the parties p_temp_wounded and p_temp_killed with the wounded and killed. #Example: (script_inflict_casualties_to_party, "_p_main_party" ,50), - simulates 50 rounds of casualties to main_party. ("inflict_casualties_to_party", [ (party_clear, "p_temp_casualties"), (store_script_param_1, ":party"), #Party_id (call_script, "script_party_count_fit_regulars", ":party"), (assign, ":num_fit", reg(0)), #reg(47) = number of fit regulars. (store_script_param_2, ":num_attack_rounds"), #number of attacks (try_for_range, ":unused", 0, ":num_attack_rounds"), (gt, ":num_fit", 0), (store_random_in_range, ":attacked_troop_rank", 0 , ":num_fit"), #attack troop with rank reg(46) (assign, reg1, ":attacked_troop_rank"), (call_script, "script_get_stack_with_rank", ":party", ":attacked_troop_rank"), (assign, ":attacked_stack", reg(0)), #reg(53) = stack no to attack. (party_stack_get_troop_id, ":attacked_troop",":party",":attacked_stack"), (store_character_level, ":troop_toughness", ":attacked_troop"), (val_add, ":troop_toughness", 5), #troop-toughness = level + 5 (assign, ":casualty_chance", 10000), (val_div, ":casualty_chance", ":troop_toughness"), #dying chance (try_begin), (store_random_in_range, ":rand_num", 0 ,10000), (lt, ":rand_num", ":casualty_chance"), #check chance to be a casualty (store_random_in_range, ":rand_num2", 0, 2), #check if this troop will be wounded or killed (try_begin), (troop_is_hero,":attacked_troop"), #currently troop can't be a hero, but no harm in keeping this. (store_troop_health, ":troop_hp",":attacked_troop"), (val_sub, ":troop_hp", 45), (val_max, ":troop_hp", 1), (troop_set_health, ":attacked_troop", ":troop_hp"), (else_try), (lt, ":rand_num2", 1), #wounded (party_add_members, "p_temp_casualties", ":attacked_troop", 1), (party_wound_members, "p_temp_casualties", ":attacked_troop", 1), (party_wound_members, ":party", ":attacked_troop", 1), (else_try), #killed (party_add_members, "p_temp_casualties", ":attacked_troop", 1), (party_remove_members, ":party", ":attacked_troop", 1), (try_end), (val_sub, ":num_fit", 1), #adjust number of fit regulars. (try_end), (try_end), ]), #script_move_members_with_ratio: # INPUT: param1 = Source Party-id, param2 = Target Party-id # pin_number = ratio of members to move, multiplied by 1000 #OUTPUT: This script doesn't return a value but moves some of the members of source party to target party according to the given ratio. ("move_members_with_ratio", [ (store_script_param_1, ":source_party"), #Source Party_id (store_script_param_2, ":target_party"), #Target Party_id (party_get_num_prisoner_stacks, ":num_stacks",":source_party"), (try_for_range_backwards, ":stack_no", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (party_prisoner_stack_get_size, ":stack_size",":source_party",":stack_no"), (store_mul, ":number_to_move",":stack_size","$pin_number"), (val_div, ":number_to_move", 1000), (party_remove_prisoners, ":source_party", ":stack_troop", ":number_to_move"), (assign, ":number_moved", reg0), (party_add_prisoners, ":target_party", ":stack_troop", ":number_moved"), (try_end), (party_get_num_companion_stacks, ":num_stacks",":source_party"), (try_for_range_backwards, ":stack_no", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":source_party",":stack_no"), (party_stack_get_size, ":stack_size",":source_party",":stack_no"), (store_mul, ":number_to_move",":stack_size","$pin_number"), (val_div, ":number_to_move", 1000), (party_remove_members, ":source_party", ":stack_troop", ":number_to_move"), (assign, ":number_moved", reg0), (party_add_members, ":target_party", ":stack_troop", ":number_moved"), (try_end), ]), # script_count_parties_of_faction_and_party_type: # counts number of active parties with a template and faction. # Input: arg1 = faction_no, arg2 = party_type # Output: reg0 = count ("count_parties_of_faction_and_party_type", [ (store_script_param_1, ":faction_no"), (store_script_param_2, ":party_type"), (assign, reg0, 0), (try_for_parties, ":party_no"), (party_is_active, ":party_no"), (party_slot_eq, ":party_no", slot_center_destroyed, 0), #TLD (party_slot_eq, ":party_no", slot_party_type, ":party_type"), (store_faction_of_party, ":cur_faction", ":party_no"), (eq, ":cur_faction", ":faction_no"), (val_add, reg0, 1), (try_end), ]), #script_cf_select_random_town_with_faction: # This script selects a random town in range [centers_begin, centers_end) such that faction of the town is equal to given_faction # INPUT: arg1 = faction_no #OUTPUT: reg0 = town_no, this script may return false if there is no matching town. ("cf_select_random_town_with_faction", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), # First count num matching spawn points (assign, ":no_towns", 0), (try_for_range,":cur_town", centers_begin, centers_end), (party_is_active, ":cur_town"), #TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), #TLD (store_faction_of_party, ":cur_faction", ":cur_town"), (eq, ":cur_faction", ":faction_no"), (val_add, ":no_towns", 1), (try_end), (gt, ":no_towns", 0), #Fail if there are no towns (store_random_in_range, ":random_town", 0, ":no_towns"), (assign, ":no_towns", 0), (try_for_range,":cur_town", centers_begin, centers_end), (party_is_active, ":cur_town"), #TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), #TLD (eq, ":result", -1), (store_faction_of_party, ":cur_faction", ":cur_town"), (eq, ":cur_faction", ":faction_no"), (val_add, ":no_towns", 1), (gt, ":no_towns", ":random_town"), (assign, ":result", ":cur_town"), (try_end), (assign, reg0, ":result"), ]), #script_cf_select_random_town_allied: # This script selects a random town in range [centers_begin, centers_end) such that faction of the town is allied # INPUT: arg1 = faction_no #OUTPUT: reg0 = town_no, this script may return false if there is no matching town. reg1 = distance ("cf_select_random_town_allied", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), (assign, ":dist", 0), # First count num matching spawn points (assign, ":no_towns", 0), (try_for_range,":cur_town", centers_begin, centers_end), (party_is_active, ":cur_town"), #TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), #TLD (store_faction_of_party, ":cur_faction", ":cur_town"), (store_relation, ":relation", ":faction_no", ":cur_faction"), (ge, ":relation", 0), #TLD: allied towns #(store_distance_to_party_from_party, ":dist", "p_main_party", ":cur_town"), (call_script, "script_get_tld_distance", "p_main_party", ":cur_town"), (assign, ":dist", reg0), (le, ":dist", tld_max_quest_distance), #TLD: not too far (val_add, ":no_towns", 1), (try_end), (gt, ":no_towns", 0), #Fail if there are no towns (store_random_in_range, ":random_town", 0, ":no_towns"), (assign, ":no_towns", 0), (try_for_range,":cur_town", centers_begin, centers_end), (party_is_active, ":cur_town"), #TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), #TLD - not destroyed (eq, ":result", -1), (store_faction_of_party, ":cur_faction", ":cur_town"), (store_relation, ":relation", ":faction_no", ":cur_faction"), (ge, ":relation", 0), #TLD: allied towns #(store_distance_to_party_from_party, ":dist", "p_main_party", ":cur_town"), (call_script, "script_get_tld_distance", "p_main_party", ":cur_town"), (assign, ":dist", reg0), (le, ":dist", tld_max_quest_distance), #TLD: not too far (val_add, ":no_towns", 1), (gt, ":no_towns", ":random_town"), (assign, ":result", ":cur_town"), (try_end), (assign, reg0, ":result"), (assign, reg1, ":dist"), ]), #script_cf_select_random_walled_center_with_faction_and_owner_priority_no_siege: # INPUT: arg1 = faction_no, arg2 = owner_troop_no #OUTPUT: reg0 = center_no (Can fail) ("cf_select_random_walled_center_with_faction_and_owner_priority_no_siege", [ (store_script_param, ":faction_no", 1), (store_script_param, ":troop_no", 2), #This script is used only to spawn lords, so make sure they spawn in their home theater (faction_get_slot, ":home_theater", ":faction_no", slot_faction_home_theater), #TLD (assign, ":result", -1), (assign, ":no_centers", 0), (try_for_range,":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_center"), (eq, ":cur_faction", ":faction_no"), (party_slot_eq, ":cur_center", slot_center_theater, ":home_theater"), #TLD (party_slot_eq, ":cur_center", slot_center_is_besieged_by, -1), (val_add, ":no_centers", 1), (party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"), (val_add, ":no_centers", 1000), (try_end), (gt, ":no_centers", 0), #Fail if there are no centers (store_random_in_range, ":random_center", 0, ":no_centers"), (try_for_range,":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (eq, ":result", -1), (store_faction_of_party, ":cur_faction", ":cur_center"), (eq, ":cur_faction", ":faction_no"), (party_slot_eq, ":cur_center", slot_center_theater, ":home_theater"), #TLD (party_slot_eq, ":cur_center", slot_center_is_besieged_by, -1), (val_sub, ":random_center", 1), (try_begin), (party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"), (val_sub, ":random_center", 1000), (try_end), (lt, ":random_center", 0), (assign, ":result", ":cur_center"), (try_end), (assign, reg0, ":result"), ]), #script_cf_select_random_walled_center_with_faction_and_less_strength_priority: # This script selects a random center in range [centers_begin, centers_end) such that faction of the town is equal to given_faction # INPUT: arg1 = faction_no, arg2 = preferred_center_no #OUTPUT: reg0 = town_no, This script may return false if there is no matching town. ("cf_select_random_walled_center_with_faction_and_less_strength_priority", [ (store_script_param, ":faction_no", 1), (store_script_param, ":preferred_center_no", 2), (assign, ":result", -1), #TLD begin (faction_get_slot, ":faction_theater", ":faction_no", slot_faction_active_theater), # TLD: First try to find a center in the active theater, if that fails, go anywhere as normal # Note: this script is only used when lords decide where to go next # First count num matching spawn points (assign, ":no_centers", 0), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_center"), (eq, ":cur_faction", ":faction_no"), (party_slot_eq, ":cur_center", slot_center_theater, ":faction_theater"), #TLD (party_slot_eq, ":cur_center", slot_center_is_besieged_by, -1), (val_add, ":no_centers", 1), (try_begin), (eq, ":cur_center", ":preferred_center_no"), (val_add, ":no_centers", 99), (try_end), (try_end), (gt, ":no_centers", 0), #Fail if there are no centers (store_random_in_range, ":random_center", 0, ":no_centers"), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (eq, ":result", -1), (store_faction_of_party, ":cur_faction", ":cur_center"), (eq, ":cur_faction", ":faction_no"), (party_slot_eq, ":cur_center", slot_center_theater, ":faction_theater"), #TLD (party_slot_eq, ":cur_center", slot_center_is_besieged_by, -1), (val_sub, ":random_center", 1), (try_begin), (eq, ":cur_center", ":preferred_center_no"), (val_sub, ":random_center", 99), (try_end), (lt, ":random_center", 0), (assign, ":result", ":cur_center"), (try_end), #TLD end # First count num matching spawn points (assign, ":no_centers", 0), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_center"), (eq, ":cur_faction", ":faction_no"), (party_slot_eq, ":cur_center", slot_center_is_besieged_by, -1), (val_add, ":no_centers", 1), (try_begin), (eq, ":cur_center", ":preferred_center_no"), (val_add, ":no_centers", 99), (try_end), ## (call_script, "script_party_calculate_regular_strength", ":cur_center"), ## (assign, ":strength", reg0), ## (lt, ":strength", 80), ## (store_sub, ":strength", 100, ":strength"), ## (val_div, ":strength", 20), ## (val_add, ":no_centers", ":strength"), (try_end), (gt, ":no_centers", 0), #Fail if there are no centers (store_random_in_range, ":random_center", 0, ":no_centers"), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (eq, ":result", -1), (store_faction_of_party, ":cur_faction", ":cur_center"), (eq, ":cur_faction", ":faction_no"), (party_slot_eq, ":cur_center", slot_center_is_besieged_by, -1), (val_sub, ":random_center", 1), (try_begin), (eq, ":cur_center", ":preferred_center_no"), (val_sub, ":random_center", 99), (try_end), ## (try_begin), ## (call_script, "script_party_calculate_regular_strength", ":cur_center"), ## (assign, ":strength", reg0), ## (lt, ":strength", 80), ## (store_sub, ":strength", 100, ":strength"), ## (val_div, ":strength", 20), ## (val_sub, ":random_center", ":strength"), ## (try_end), (lt, ":random_center", 0), (assign, ":result", ":cur_center"), (try_end), (assign, reg0, ":result"), ]), #script_cf_select_random_town_at_peace_with_faction: # This script selects a random town in range [centers_begin, centers_end) such that faction of the town is friendly to given_faction # INPUT: arg1 = faction_no #OUTPUT: reg0 = town_no, this script may return false if there is no matching town. ("cf_select_random_town_at_peace_with_faction", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), # First count num matching towns (assign, ":no_towns", 0), (try_for_range,":cur_town", centers_begin, centers_end), (party_is_active,":cur_town"), # TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_town"), (store_relation,":reln", ":cur_faction", ":faction_no"), (ge, ":reln", 0), (val_add, ":no_towns", 1), (try_end), (gt, ":no_towns", 0), #Fail if there are no towns (store_random_in_range, ":random_town", 0, ":no_towns"), (assign, ":no_towns", 0), (try_for_range,":cur_town", centers_begin, centers_end), (eq, ":result", -1), (party_is_active,":cur_town"), # TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_town"), (store_relation,":reln", ":cur_faction", ":faction_no"), (ge, ":reln", 0), (val_add, ":no_towns", 1), (gt, ":no_towns", ":random_town"), (assign, ":result", ":cur_town"), (try_end), (assign, reg0, ":result"), ]), #script_cf_select_random_town_at_peace_with_faction_in_trade_route # INPUT: arg1 = town_no, arg2 = faction_no #OUTPUT: reg0 = town_no, this script may return false if there is no matching town. ("cf_select_random_town_at_peace_with_faction_in_trade_route", [ (store_script_param, ":town_no", 1), (store_script_param, ":faction_no", 2), (assign, ":result", -1), (assign, ":no_towns", 0), (try_for_range, ":cur_slot", slot_town_trade_routes_begin, slot_town_trade_routes_end), (party_get_slot, ":cur_town", ":town_no", ":cur_slot"), (gt, ":cur_town", 0), (party_is_active,":cur_town"), # TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_town"), (store_relation, ":reln", ":cur_faction", ":faction_no"), (ge, ":reln", 0), (val_add, ":no_towns", 1), (try_end), (gt, ":no_towns", 0), #Fail if there are no towns (store_random_in_range, ":random_town", 0, ":no_towns"), (try_for_range, ":cur_slot", slot_town_trade_routes_begin, slot_town_trade_routes_end), (eq, ":result", -1), (party_get_slot, ":cur_town", ":town_no", ":cur_slot"), (gt, ":cur_town", 0), (party_is_active,":cur_town"), # TLD (party_slot_eq, ":cur_town", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_town"), (store_relation, ":reln", ":cur_faction", ":faction_no"), (ge, ":reln", 0), (val_sub, ":random_town", 1), (lt, ":random_town", 0), (assign, ":result", ":cur_town"), (try_end), (assign, reg0, ":result"), ]), # script_shuffle_troop_slots: # Shuffles a range of slots of a given troop. Used for exploiting a troop as an array. # INPUT: arg1 = troop_no, arg2 = slot_begin, arg3 = slot_end ("shuffle_troop_slots", [ (store_script_param, ":troop_no", 1), (store_script_param, ":slots_begin", 2), (store_script_param, ":slots_end", 3), (try_for_range, ":cur_slot_no", ":slots_begin", ":slots_end"), (store_random_in_range, ":random_slot_no", ":slots_begin", ":slots_end"), #reg(58) = random slot. Now exchange slots reg(57) and reg(58) (troop_get_slot, ":cur_slot_value", ":troop_no", ":cur_slot_no"), #temporarily store the value in slot reg(57) in reg(59) (troop_get_slot, ":random_slot_value", ":troop_no", ":random_slot_no"), #temporarily store the value in slot reg(58) in reg(60) (troop_set_slot, ":troop_no", ":cur_slot_no", ":random_slot_value"), # Now exchange the two... (troop_set_slot, ":troop_no", ":random_slot_no", ":cur_slot_value"), (try_end), ]), # script_get_random_quest # INPUT: arg1 = troop_no (of the troop in conversation), arg2 = min_importance (of the quest) #OUTPUT: reg0 = quest_no (the slots of the quest will be filled after calling this script) ("get_random_quest", [ (store_script_param_1, ":giver_troop"), (store_character_level, ":player_level", "trp_player"), (store_troop_faction, ":giver_faction_no", ":giver_troop"), (troop_get_slot, ":giver_party_no", ":giver_troop", slot_troop_leaded_party), #(troop_get_slot, ":giver_reputation", ":giver_troop", slot_lord_reputation_type), (assign, ":giver_center_no", -1), (try_begin), (gt, ":giver_party_no", 0), (party_get_attached_to, ":giver_center_no", ":giver_party_no"), (else_try), (is_between, "$g_encountered_party", centers_begin, centers_end), (assign, ":giver_center_no", "$g_encountered_party"), (try_end), (try_begin), (troop_slot_eq, ":giver_troop", slot_troop_occupation, slto_kingdom_hero), (try_begin), (ge, "$g_talk_troop_faction_relation", 0), (assign, ":quests_begin", lord_quests_begin), (assign, ":quests_end", lord_quests_end), (assign, ":quests_begin_2", lord_quests_begin_2), (assign, ":quests_end_2", lord_quests_end_2), (else_try), (assign, ":quests_begin", enemy_lord_quests_begin), (assign, ":quests_end", enemy_lord_quests_end), (assign, ":quests_begin_2", 0), (assign, ":quests_end_2", 0), (try_end), (else_try), (is_between, ":giver_troop", mayors_begin, mayors_end), (assign, ":quests_begin", mayor_quests_begin), (assign, ":quests_end", mayor_quests_end), (assign, ":quests_begin_2", mayor_quests_begin_2), (assign, ":quests_end_2", mayor_quests_end_2), (else_try), (assign, ":quests_begin", mayor_quests_begin), (assign, ":quests_end", mayor_quests_end), (assign, ":quests_begin_2", 0), (assign, ":quests_end_2", 0), (try_end), (assign, ":result", -1), (try_for_range, ":unused", 0, 30), #Repeat trial twenty times - MV: changed to 30 (eq, ":result", -1), (assign, ":quest_target_troop", -1), (assign, ":quest_target_center", -1), (assign, ":quest_target_faction", -1), (assign, ":quest_object_faction", -1), (assign, ":quest_object_troop", -1), (assign, ":quest_object_center", -1), (assign, ":quest_target_party", -1), (assign, ":quest_target_party_template", -1), (assign, ":quest_target_amount", -1), (assign, ":quest_target_dna", -1), (assign, ":quest_target_item", -1), (assign, ":quest_importance", 1), (assign, ":quest_xp_reward", 0), (assign, ":quest_gold_reward", 0), (assign, ":quest_rank_reward", 0), #TLD (assign, ":quest_giver_fac_str_effect", 0), #TLD (assign, ":quest_target_fac_str_effect", 0), #TLD (assign, ":quest_convince_value", 0), (assign, ":quest_expiration_days", 0), (assign, ":quest_dont_give_again_period", 0), ## Quest Range Extender - Kham (store_sub, ":num_possible_old_quests", ":quests_end", ":quests_begin"), (store_sub, ":num_possible_new_quests", ":quests_end_2", ":quests_begin_2"), (store_add, ":num_possible_total_quests", ":num_possible_old_quests", ":num_possible_new_quests"), # (store_add. ":num_possible_total_quests_plus_1",":num_possible_total_quests", 1), (store_random_in_range, ":quest_no", 0, ":num_possible_total_quests"), (try_begin), (lt, ":quest_no", ":num_possible_old_quests"), (store_random_in_range, ":quest_no", ":quests_begin", ":quests_end"), (else_try), (store_random_in_range, ":quest_no", ":quests_begin_2", ":quests_end_2"), (try_end), ## Quest Range Extender END - Kham #MV: Change this line and uncomment for testing only, don't let it slip into SVN (or else :)) #(assign, ":quest_no", "qst_escort_merchant_caravan"), #mtarini: ok, ok, so we put in a menu: (try_begin), (ge, "$cheat_imposed_quest", 0),(assign, ":quest_no", "$cheat_imposed_quest"),(try_end), (neg|check_quest_active,":quest_no"), (neg|quest_slot_ge, ":quest_no", slot_quest_dont_give_again_remaining_days, 1), (try_begin), #GA: Galadriel wants sorcerer killed (eq, ":quest_no", "qst_mirkwood_sorcerer"), (try_begin), (eq, ":giver_troop", "trp_lorien_lord"), # only Galadriel gives this quest (ge, ":player_level", 15), # CC: Was 1, change to 15, too hard if available at level 1. (assign, ":quest_expiration_days", 10), (assign, ":quest_dont_give_again_period", 10000), (assign, ":quest_importance", 4), (assign, ":quest_xp_reward", 3000), (assign, ":quest_gold_reward", 1500), (assign, ":quest_rank_reward", 80), (assign, ":quest_object_faction", "fac_lorien"), (assign, ":quest_target_faction", "fac_guldur"), (assign, ":quest_giver_fac_str_effect", 500), (assign, ":quest_target_fac_str_effect", -500), (assign, ":result", ":quest_no"), (try_end), (else_try), ##Kham - Defend refugees #(eq, cheat_switch, 1), #(troop_slot_eq, "trp_player", slot_troop_home, 22), #Kham Cheat Mode (eq, ":quest_no", "qst_blank_quest_01"), (try_begin), (eq, "$tld_war_began", 1), (neg|check_quest_active,"qst_blank_quest_01"), (call_script, "script_cf_init_quest_defend_refugees"), (assign, ":quest_target_party_template", reg55), (assign, ":quest_object_center", reg56), (assign, ":quest_target_center", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":result", ":quest_no"), (try_end), (else_try), ##Kham - Hunt Down refugees #(eq, cheat_switch, 1), #(troop_slot_eq, "trp_player", slot_troop_home, 22), #Kham Cheat Mode (eq, "$tld_war_began", 1), (eq, ":quest_no", "qst_blank_quest_02"), (try_begin), (neg|check_quest_active,"qst_blank_quest_02"), (call_script, "script_cf_init_quest_hunt_refugees"), (assign, ":quest_target_party_template", reg55), (assign, ":quest_object_center", reg56), (assign, ":quest_target_center", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":result", ":quest_no"), (try_end), (else_try), #Kham - Sea Battle (both sides) (eq, "$tld_war_began", 1), (eq, ":quest_no", "qst_blank_quest_03"), (try_begin), (neg|check_quest_active, "qst_blank_quest_03"), (call_script, "script_cf_init_quest_sea_battle"), (assign, ":quest_object_troop", reg55), (assign, ":quest_object_center", reg56), (assign, ":quest_target_center", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":result", ":quest_no"), (try_end), (else_try), ] + (is_a_wb_script==1 and [ #Kham - Kill Quest Targeted (eq, "$tld_war_began", 1), (eq, ":quest_no", "qst_blank_quest_04"), (try_begin), (neg|check_quest_active, "qst_blank_quest_04"), (call_script, "script_cf_init_kill_quest_target"), (assign, ":quest_target_faction", reg54), (assign, ":quest_object_troop", reg55), (assign, ":quest_target_troop", reg56), (assign, ":quest_target_amount", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":quest_target_party_template", reg64), (assign, ":result", ":quest_no"), (try_end), ] or [(eq, 0, 1),]) + [ (else_try), #Kham - Kill Quest Faction Troops ] + (is_a_wb_script==1 and [ (eq, "$tld_war_began", 1), (eq, ":quest_no", "qst_blank_quest_05"), (try_begin), (neg|check_quest_active, "qst_blank_quest_05"), (call_script, "script_cf_init_kill_quest_faction"), (assign, ":quest_object_troop", reg55), (assign, ":quest_target_faction", reg56), (assign, ":quest_target_amount", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":result", ":quest_no"), (try_end), ] or [(eq, 0, 1),]) + [ (else_try), #Kham - Defeat Lord ] + (is_a_wb_script==1 and [ (eq, "$tld_war_began", 1), (eq, ":quest_no", "qst_blank_quest_06"), (try_begin), (neg|check_quest_active, "qst_blank_quest_06"), (call_script, "script_cf_init_defeat_lord_quest"), (assign, ":quest_object_troop", reg55), (assign, ":quest_target_troop", reg56), (assign, ":quest_target_amount", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":result", ":quest_no"), (try_end), ] or [(eq, 0, 1),]) + [ (else_try), #Kham - Kill Quest - Bandits (Mayor Quest) ] + (is_a_wb_script==1 and [ (eq, ":quest_no", "qst_blank_quest_17"), (try_begin), (neg|check_quest_active, "qst_blank_quest_17"), (call_script, "script_cf_init_kill_quest_bandit"), (assign, ":quest_object_troop", reg55), (assign, ":quest_target_troop", reg56), (assign, ":quest_target_amount", reg57), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":quest_target_party_template", reg64), (assign, ":quest_target_center", ":giver_center_no"), #we need the giver center for the quest helper trigger #InVain (assign, ":quest_object_faction", ":giver_faction_no"), (assign, ":quest_giver_fac_str_effect", ":quest_xp_reward"), (val_div, ":quest_giver_fac_str_effect", 10), (val_mul, ":quest_giver_fac_str_effect", 10), #round to full 10s (assign, ":result", ":quest_no"), (try_end), ] or [(eq, 0, 1),]) + [ (else_try), ##Kham: Defend village (eq, ":quest_no", "qst_defend_village"), (try_begin), (neg|check_quest_active,"qst_defend_village"), (faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), (neq, ":giver_faction_no", "fac_woodelf"), #Woodelves don't help villagers (neq, ":giver_faction_no", "fac_lorien"), #No villages near Lorien (ge, "$g_talk_troop_faction_relation", 2), (is_between, ":player_level", 3,21), (gt, ":giver_center_no", 0),#Skip if lord is outside the center (assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (assign, ":cur_target_center", reg0), (assign, ":dist", reg1), (store_faction_of_party,":cur_object_faction",":cur_object_center"), ## Store Faction of Object Center - So that we can set up appropriate raiders (neq, ":cur_target_center", ":giver_center_no"),#Skip current center (ge, ":dist", 20), (assign, ":quest_object_faction", ":cur_object_faction"), (assign, ":quest_target_party_template", "pt_village"), (assign, ":quest_object_center", ":cur_object_center"), (assign, ":quest_target_center", ":cur_target_center"), (assign, ":quest_importance", 4), (assign, ":quest_xp_reward", 150), (assign, ":quest_gold_reward", 200), (assign, ":quest_rank_reward", 16), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 2), (assign, ":quest_dont_give_again_period", 7), (try_end), (else_try), ##Kham: Raid village (eq, ":quest_no", "qst_raid_village"), (try_begin), (neg|check_quest_active,"qst_raid_village"), (neg|faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), (ge, "$g_talk_troop_faction_relation", 2), (is_between, ":player_level", 3,21), (gt, ":giver_center_no", 0),#Skip if lord is outside the center (assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town ##Kham - lets force the faction (try_begin), (this_or_next|eq, ":giver_center_no", "p_town_morannon"), (this_or_next|eq, ":giver_center_no", "p_town_cirith_ungol"), ( eq, ":giver_center_no", "p_town_khand_camp"), (store_random_in_range, ":town", 0,2), (try_begin), (eq, ":town", 0), (assign, reg0, "p_town_minas_tirith"), (else_try), (assign, reg0, "p_town_east_emnet"), (try_end), (else_try), (this_or_next|eq, ":giver_faction_no", "fac_moria"), ( eq, ":giver_center_no", "p_town_dol_guldur"), (assign, reg0, "p_town_cerin_amroth"), (else_try), (eq, ":giver_center_no", "p_town_rhun_main_camp"), (store_random_in_range, ":town", 0,2), (try_begin), (eq, ":town", 0), (assign, reg0, "p_town_dale"), (else_try), (assign, reg0, "p_town_ironhill_camp"), (try_end), (else_try), (eq, ":giver_center_no", "p_town_gundabad"), (store_random_in_range, ":town", 0,2), (try_begin), (eq, ":town", 0), (assign, reg0, "p_town_beorning_village"), (else_try), (assign, reg0, "p_town_ironhill_camp"), (try_end), (else_try), (this_or_next|eq, ":giver_faction_no", "fac_isengard"), ( eq, ":giver_faction_no", "fac_dunland"), (store_random_in_range, ":town", 0,3), (try_begin), (eq,":town", 0), (assign, reg0, "p_town_edoras"), (else_try), (eq, ":town",1), (assign, reg0, "p_town_west_emnet"), (else_try), (assign, reg0, "p_town_east_emnet"), (try_end), (else_try), (eq, ":giver_faction_no", "fac_harad"), (store_random_in_range, ":town", 0,3), (try_begin), (eq,":town", 0), (assign, reg0, "p_town_pelargir"), (else_try), (eq, ":town",1), (assign, reg0, "p_town_lossarnach"), (else_try), (assign, reg0, "p_town_linhir"), (try_end), (else_try), (eq, ":giver_faction_no", "fac_umbar"), (store_random_in_range, ":town", 0,3), (try_begin), (eq,":town", 0), (assign, reg0, "p_town_pelargir"), (else_try), (eq, ":town",1), (assign, reg0, "p_town_tarnost"), (else_try), (assign, reg0, "p_town_linhir"), (try_end), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), (assign, ":cur_target_center", reg0), (assign, ":dist", reg1), (store_faction_of_party,":cur_target_faction",":cur_target_center"), ## Store Faction of Target Village - So that we can set up appropriate guards/troops (neq, ":cur_target_center", ":giver_center_no"),#Skip current center #(ge, ":dist", 20), (assign, ":quest_target_faction", ":cur_target_faction"), (assign, ":quest_target_party_template", "pt_village"), (assign, ":quest_object_center", ":cur_object_center"), (assign, ":quest_target_center", ":cur_target_center"), (assign, ":quest_importance", 4), (assign, ":quest_xp_reward", 150), (assign, ":quest_gold_reward", 400), (assign, ":quest_rank_reward", 12), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 3), (assign, ":quest_dont_give_again_period", 7), (try_end), (else_try), ##Kham: Destroy Scout Camp (eq, ":quest_no", "qst_destroy_scout_camp"), (try_begin), #(eq, 1, cheat_switch), ## Cheat Switch on for testing purposes (neg|check_quest_active,"qst_destroy_scout_camp"), (eq, "$tld_war_began", 1), (ge, "$g_talk_troop_faction_relation", 1), (is_between, ":player_level", 11,31), #(faction_get_slot, ":faction_side", ":giver_faction_no", slot_faction_side), #(call_script, "script_force_faction_center_by_region", ":giver_party_no", ":faction_side"), (call_script,"script_cf_get_random_enemy_center_in_theater",":giver_party_no"), # Gets a enemy center in the current theater (assign, ":cur_target_center", reg0), (neq, ":cur_target_center", "p_town_henneth_annun"), # HA not allowed #(neq, ":cur_target_center", ":giver_center_no"),#Skip current center (try_begin), (is_between, ":player_level", 11,17), #levels 11-16 (assign, ":quest_target_party_template", "pt_scout_camp_small"), (assign, ":quest_xp_reward", 250), (assign, ":quest_gold_reward", 300), (assign, ":quest_rank_reward", 12), (else_try), (is_between,":player_level",17,26), #levels 17-25 (assign, ":quest_target_party_template", "pt_scout_camp_large"), (assign, ":quest_xp_reward", 450), (assign, ":quest_gold_reward", 700), (assign, ":quest_rank_reward", 20), (else_try), (ge, ":player_level", 26), #levels 26 and greater (assign, ":quest_target_party_template", "pt_scout_camp_large"), (assign, ":quest_xp_reward", 500), (assign, ":quest_gold_reward", 750), (assign, ":quest_rank_reward", 26), (try_end), (call_script,"script_cf_spawn_around_party_on_walkable_terrain",":giver_party_no",":quest_target_party_template",15), (assign,"$qst_destroy_scout_camp_party",reg0), (call_script, "script_move_party_to_hardcoded_locations", "$qst_destroy_scout_camp_party"), #Checks if party needs to be moved. (store_faction_of_party,":cur_target_faction",":cur_target_center"), ## Store Faction of Target - So that we can set up appropriate guards/troops (assign, ":quest_target_faction", ":cur_target_faction"), # (assign, ":quest_object_center", ":cur_object_center"), (assign, ":quest_target_center", ":cur_target_center"), (assign, ":quest_importance", 4), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 7), (assign, ":quest_dont_give_again_period", 7), (try_end), (else_try), #mtarini: Saruman wants a troll be captured (eq, ":quest_no", "qst_capture_troll"), (try_begin), (this_or_next|eq, ":giver_troop", "trp_isengard_lord"), # only saruman gives this quest (eq, ":giver_troop", "trp_guldur_lord"), (ge, ":player_level", 7), (assign, ":quest_object_faction", ":giver_faction_no"), (assign, ":quest_expiration_days", 15), (assign, ":quest_dont_give_again_period", 20), (store_free_inventory_capacity,":tmp"),(gt,":tmp",0), # otherwise, no room for cage (assign, ":quest_importance", 3), (assign, ":quest_xp_reward", 1500), (assign, ":quest_gold_reward", 500), (assign, ":quest_rank_reward", 20), (assign, ":quest_giver_fac_str_effect", 40), (assign, ":result", ":quest_no"), (try_end), (else_try), #mtarini: good-sided lords wants a troll be killed (eq, ":quest_no", "qst_kill_troll"), (try_begin), (gt, ":player_level", 6), (faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), (assign, ":quest_object_faction", ":giver_faction_no"), #(faction_slot_eq, ":giver_faction_no", slot_faction_leader, ":giver_troop"), (call_script, "script_cf_select_random_town_with_faction", ":giver_faction_no"),#Can fail (assign, ":cur_object_center", reg0), (neq, ":cur_object_center", ":giver_center_no"),#Skip current center (neq,":cur_target_center", "p_town_henneth_annun"),#Skip Henneth Annun #(call_script, "script_get_random_enemy_center", ":giver_party_no"), #(assign, ":cur_target_center", reg0), #(ge, ":cur_target_center", 0), #(store_faction_of_party, ":cur_target_faction", ":cur_target_center"), #(is_between, ":cur_target_faction", kingdoms_begin, kingdoms_end), (assign, ":quest_object_center", ":cur_object_center"), #(assign, ":quest_target_center", ":cur_target_center"), (assign, ":quest_importance", 3), (assign, ":quest_xp_reward", 1500), (assign, ":quest_gold_reward", 500), (assign, ":quest_rank_reward", 20), (assign, ":quest_giver_fac_str_effect", 50), (assign, ":quest_expiration_days", 10), (assign, ":quest_dont_give_again_period", 30), (assign, ":result", ":quest_no"), (try_end), (else_try), #mtarini: Saruman wants Fangorn to be investigated (eq, ":quest_no", "qst_investigate_fangorn"), (try_begin), (eq, ":giver_troop", "trp_isengard_lord"), # only saruman gives this quest (ge, ":player_level", 4), (assign, ":quest_expiration_days", 40), (assign, ":quest_dont_give_again_period", 500), (assign, ":quest_importance", 2), (assign, ":quest_xp_reward", 100), (assign, ":quest_gold_reward", 500), (assign, ":quest_rank_reward", 30), (assign, ":result", ":quest_no"), (try_end), (else_try), #Kolba: Lost spears - given by Brand (eq, ":quest_no", "qst_find_lost_spears"), (try_begin), (troop_slot_eq, "trp_player", slot_troop_home, 22), #Kham Cheat Mode (eq, cheat_switch, 1), #CC: Enabled only with cheat switch, for now (eq, ":giver_troop", "trp_dale_lord"), # only brand gives this quest (ge, ":player_level", 4), (assign, ":quest_expiration_days", 40), (assign, ":quest_dont_give_again_period", 180), (assign, ":quest_importance", 2), (assign, ":quest_xp_reward", 100), (assign, ":quest_gold_reward", 500), (assign, ":quest_rank_reward", 50), (assign, ":result", ":quest_no"), (try_end), # Mayor quests (else_try), (eq, ":quest_no", "qst_escort_merchant_caravan"), (is_between, ":giver_center_no", centers_begin, centers_end), (party_get_slot, ":quest_target_party_template", ":giver_center_no", slot_center_spawn_caravan), (gt, ":quest_target_party_template", 0), #only for centers that spawn caravans (call_script, "script_cf_select_random_town_allied", ":giver_faction_no"),#Can fail (assign, ":cur_target_dist", reg1), (neq, ":giver_center_no", reg0), (neq, reg0, "p_town_henneth_annun"),#Skip Henneth Annun (assign, ":quest_target_center", reg0), (store_faction_of_party,":quest_target_faction",":quest_target_center"), # (store_random_party_in_range, ":quest_target_center", centers_begin, centers_end), # (store_distance_to_party_from_party, ":dist", ":giver_center_no",":quest_target_center"), (assign, ":quest_gold_reward", ":cur_target_dist"), (val_add, ":quest_gold_reward", 25), (val_mul, ":quest_gold_reward", 25), (val_div, ":quest_gold_reward", 10), (store_div, ":quest_rank_reward", ":quest_gold_reward", 20), (assign, ":quest_target_amount", ":quest_rank_reward"), #target amount = minimal party size (assign, ":quest_xp_reward", ":quest_gold_reward"), (val_mul, ":quest_xp_reward", 5), (val_add, ":quest_xp_reward", 100), (assign, ":quest_target_fac_str_effect", 80), #(assign, ":quest_expiration_days", 7), (assign, "$escort_merchant_caravan_mode", 0), (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_deliver_wine"), (is_between, ":giver_center_no", centers_begin, centers_end), #(store_random_party_in_range, ":quest_target_center", centers_begin, centers_end), (call_script, "script_cf_select_random_town_allied", ":giver_faction_no"),#Can fail (neq, reg0, "p_town_henneth_annun"),#Skip Henneth Annun (assign, ":quest_target_center", reg0), (assign, ":cur_target_dist", reg1), (neq, ":giver_center_no", ":quest_target_center"), (store_faction_of_party,":quest_target_faction",":quest_target_center"), (party_get_slot, ":elder", ":quest_target_center", slot_town_elder), (neq, ":elder", "trp_no_troop"), #make sure there is an elder to deliver stuff to (gt, ":elder", 0), (assign, ":quest_target_troop", ":elder"), # (store_random_in_range, ":random_no", 0, 2), # (try_begin), # (eq, ":random_no", 0), # (assign, ":quest_target_item", "itm_quest_wine"), # (else_try), (assign, ":quest_target_item", "itm_siege_supply"), #TLD # (try_end), (store_random_in_range, ":quest_target_amount", 4, 8), (val_div, ":player_level", 2), (val_add, ":quest_target_amount", ":player_level"), (val_clamp, ":quest_target_amount", 4, 30), #(store_distance_to_party_from_party, ":dist", ":giver_center_no",":quest_target_center"), (assign, ":quest_gold_reward", ":cur_target_dist"), (val_add, ":quest_gold_reward", 2), (assign, ":multiplier", 5), (val_add, ":multiplier", ":quest_target_amount"), (val_mul, ":quest_gold_reward", ":multiplier"), (val_div, ":quest_gold_reward", 100), (val_mul, ":quest_gold_reward", 30), (store_mul, ":quest_xp_reward", ":quest_gold_reward", 4), (store_div, ":quest_rank_reward", ":quest_target_amount", 2), (store_mul, ":quest_target_fac_str_effect", ":quest_target_amount", 5), (assign, ":quest_importance", 4), (assign, ":quest_expiration_days", 7), (assign, ":quest_dont_give_again_period", 10), (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_troublesome_bandits"), (is_between, ":giver_center_no", centers_begin, centers_end), (store_faction_of_party,":quest_object_faction",":giver_center_no"), (store_character_level, ":quest_gold_reward", "trp_player"), (val_add, ":quest_gold_reward", 20), (val_mul, ":quest_gold_reward", 35), (val_div, ":quest_gold_reward",100), (val_mul, ":quest_gold_reward", 10), (assign, ":quest_giver_fac_str_effect", 20), (store_mul, ":quest_xp_reward", ":quest_gold_reward", 7), (assign, ":quest_rank_reward", 8), (assign, ":quest_importance", 4), (assign, ":quest_expiration_days", 30), (assign, ":quest_dont_give_again_period", 15), (assign, ":result", ":quest_no"), # (else_try), # (eq, ":quest_no", "qst_kidnapped_girl"), # (is_between, ":giver_center_no", centers_begin, centers_end), # (store_random_in_range, ":quest_target_center", villages_begin, villages_end), # (store_character_level, ":quest_target_amount"), # (val_add, ":quest_target_amount", 15), # (store_distance_to_party_from_party, ":dist", ":giver_center_no", ":quest_target_center"), # (val_add, ":dist", 15), # (val_mul, ":dist", 2), # (val_mul, ":quest_target_amount", ":dist"), # (val_div, ":quest_target_amount",100), # (val_mul, ":quest_target_amount",10), # (assign, ":quest_gold_reward", ":quest_target_amount"), # (val_div, ":quest_gold_reward", 40), # (val_mul, ":quest_gold_reward", 10), # (assign, ":quest_dont_give_again_period", 30), # (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_move_cattle_herd"), (is_between, ":giver_center_no", centers_begin, centers_end), #(call_script, "script_cf_select_random_town_at_peace_with_faction", ":giver_faction_no"), (call_script, "script_cf_select_random_town_allied", ":giver_faction_no"),#Can fail (assign, ":cur_target_dist", reg1), (neq, ":giver_center_no", reg0), (assign, ":quest_target_center", reg0), (store_faction_of_party,":quest_target_faction",":quest_target_center"), #(store_distance_to_party_from_party, ":dist",":giver_center_no",":quest_target_center"), (assign, ":quest_gold_reward", ":cur_target_dist"), (val_add, ":quest_gold_reward", 25), (val_mul, ":quest_gold_reward", 50), (val_div, ":quest_gold_reward", 20), (store_div, ":quest_xp_reward", ":quest_gold_reward", 3), (store_mul, ":quest_rank_reward", ":cur_target_dist", 8), (val_div, ":quest_rank_reward", tld_max_quest_distance), (assign, ":quest_target_fac_str_effect", 70), (assign, ":quest_importance", 8), (assign, ":quest_expiration_days", 20), (assign, ":quest_dont_give_again_period", 12), (assign, ":result", ":quest_no"), # (else_try), # (eq, ":quest_no", "qst_persuade_lords_to_make_peace"), # (is_between, ":giver_center_no", centers_begin, centers_end), # (store_faction_of_party, ":cur_object_faction", ":giver_center_no"), # (call_script, "script_cf_faction_get_random_enemy_faction", ":cur_object_faction"), # (assign, ":cur_target_faction", reg0), # (call_script, "script_cf_get_random_lord_except_king_with_faction", ":cur_object_faction"), # (assign, ":cur_object_troop", reg0), # (call_script, "script_cf_get_random_lord_except_king_with_faction", ":cur_target_faction"), # (assign, ":quest_target_troop", reg0), # (assign, ":quest_object_troop", ":cur_object_troop"), # (assign, ":quest_target_faction", ":cur_target_faction"), # (assign, ":quest_object_faction", ":cur_object_faction"), # (assign, ":quest_gold_reward", 12000), # (assign, ":quest_convince_value", 7000), # (assign, ":quest_expiration_days", 30), # (assign, ":quest_dont_give_again_period", 100), # (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_deal_with_looters"), (is_between, ":player_level", 0, 15), (is_between, ":giver_center_no", centers_begin, centers_end), # (store_faction_of_party, ":cur_object_faction", ":giver_center_no"), (assign, ":quest_target_party_template", "pt_looters"), #can be regionalized for different bandits (store_num_parties_destroyed_by_player, ":num_looters_destroyed", ":quest_target_party_template"), (party_template_set_slot,":quest_target_party_template",slot_party_template_num_killed,":num_looters_destroyed"), (quest_set_slot,"qst_deal_with_looters",slot_quest_current_state,0), #(quest_set_slot,"$random_merchant_quest_no",slot_quest_target_party_template,"pt_looters"), (assign, ":quest_target_center", ":giver_center_no"), (store_faction_of_party,":quest_object_faction",":quest_target_center"), (assign, ":quest_gold_reward", 500), (assign, ":quest_xp_reward", 500), (assign, ":quest_rank_reward", 8), (assign, ":quest_giver_fac_str_effect", 20), (assign, ":quest_importance", 4), (assign, ":quest_expiration_days", 20), (assign, ":quest_dont_give_again_period", 18), (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_deal_with_night_bandits"), (neg|faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), #TLD: evil factions only (is_between, ":player_level", 0, 20), (is_between, ":giver_center_no", centers_begin, centers_end), (faction_get_slot, ":bandit_troop", ":giver_faction_no", slot_faction_tier_1_troop), (party_set_slot, ":giver_center_no", slot_center_has_bandits, ":bandit_troop"), #(party_slot_ge, ":giver_center_no", slot_center_has_bandits, 1), (assign, ":quest_target_center", ":giver_center_no"), (store_faction_of_party,":quest_object_faction",":quest_target_center"), (assign, ":quest_gold_reward", 150), (assign, ":quest_xp_reward", 200), (assign, ":quest_rank_reward", 8), (assign, ":quest_giver_fac_str_effect", 10), (assign, ":quest_importance", 4), (assign, ":quest_expiration_days", 4), (assign, ":quest_dont_give_again_period", 10), (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_deliver_iron"), (eq, "$tld_option_crossdressing", 0), #only if Item Restriction is ON, so loot produces scraps (store_div, ":quest_target_amount", ":player_level", 2), (val_min, ":quest_target_amount", 10), #don't scale too much. (store_random_in_range, ":random", 0, 4), (val_add, ":quest_target_amount", ":random"), (val_max, ":quest_target_amount", 2), #don't scale too little (try_begin), (le, ":player_level", 4), (assign, ":quest_target_item", scraps_begin), #only bad scraps (else_try), (le, ":player_level", 8), (store_random_in_range, ":quest_target_item", scraps_begin, scraps_begin+2), #bad and medium scraps (else_try), (store_random_in_range, ":quest_target_item", scraps_begin, scraps_end), (try_end), #empty merchant store of that food - done here and not in dialogs to prevent exploit (party_get_slot, ":center_merchant", ":giver_center_no", slot_town_merchant), #horse+goods guy (try_begin), (neq, ":center_merchant", "trp_no_troop"), (store_item_kind_count, ":num_items", ":quest_target_item", ":center_merchant"), (ge, ":num_items", 1), (troop_remove_items, ":center_merchant", ":quest_target_item", ":num_items"), (troop_sort_inventory, ":center_merchant"), (try_end), (assign, ":quest_target_center", ":giver_center_no"), (store_faction_of_party,":quest_object_faction",":quest_target_center"), (store_item_value, ":item_value", ":quest_target_item"), (val_mul, ":item_value", 3), (val_div, ":item_value", 2), #1.5x profit (store_mul, ":quest_gold_reward", ":quest_target_amount", ":item_value"), (store_mul, ":quest_xp_reward", ":quest_target_amount", 20), (store_div, ":quest_rank_reward", ":quest_target_amount", 2), #1-3 (store_div, ":quest_importance", ":quest_target_amount", 3), (store_div, ":quest_giver_fac_str_effect", ":quest_gold_reward", 50), (val_max, ":quest_giver_fac_str_effect", 15), (assign, ":quest_expiration_days", 20), (assign, ":quest_dont_give_again_period", 15), (assign, ":result", ":quest_no"), (else_try), (eq, ":quest_no", "qst_deliver_food"), (store_random_in_range, ":quest_target_amount", 3, 7), (val_div, ":player_level", 2), (val_add, ":quest_target_amount", ":player_level"), #(store_random_in_range, ":quest_target_item", normal_food_begin, food_end), ###empty merchant store of all food - done here and not in dialogs to prevent exploit (party_get_slot, ":center_merchant", ":giver_center_no", slot_town_merchant), #horse+goods guy (try_for_range, ":food_item", food_begin, food_end), (neq, ":center_merchant", "trp_no_troop"), (store_item_kind_count, ":num_items", ":food_item", ":center_merchant"), (ge, ":num_items", 1), (troop_remove_items, ":center_merchant", ":food_item", ":num_items"), (troop_sort_inventory, ":center_merchant"), (try_end), (assign, ":quest_target_center", ":giver_center_no"), (store_faction_of_party,":quest_object_faction",":quest_target_center"), (assign, ":item_value", 80), # an average (store_mul, ":quest_gold_reward", ":quest_target_amount", ":item_value"), (store_mul, ":quest_xp_reward", ":quest_target_amount", 20), (store_div, ":quest_rank_reward", ":quest_target_amount", 2), #1-3 (store_div, ":quest_importance", ":quest_target_amount", 2), (store_mul, ":quest_giver_fac_str_effect", ":quest_target_amount", 5), (assign, ":quest_expiration_days", ":quest_target_amount", 5), (assign, ":quest_dont_give_again_period", 10), (assign, ":result", ":quest_no"), (else_try), ##Kham - Reinforce Center #(eq, cheat_switch, 1), #(troop_slot_eq, "trp_player", slot_troop_home, 22), #Kham Cheat Mode (eq, ":quest_no", "qst_blank_quest_16"), (try_begin), (eq, "$tld_war_began", 1), (neg|check_quest_active,"qst_blank_quest_16"), (call_script, "script_cf_init_quest_reinforce_center"), (assign, ":quest_object_center", reg55), (assign, ":quest_target_amount", reg56), (assign, ":quest_target_center", reg57), (store_faction_of_party,":quest_object_faction",":quest_target_center"), (assign, ":quest_importance", reg58), (assign, ":quest_xp_reward", reg59), (assign, ":quest_gold_reward", reg60), (assign, ":quest_rank_reward", reg61), (assign, ":quest_expiration_days", reg62), (assign, ":quest_dont_give_again_period", reg63), (assign, ":result", ":quest_no"), (try_end), (else_try), (eq, ":quest_no", "qst_lend_surgeon"), (try_begin), (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting) #(neq, ":giver_reputation", lrep_quarrelsome), #(neq, ":giver_reputation", lrep_debauched), (assign, ":max_surgery_level", 0), (assign, ":best_surgeon", -1), (party_get_num_companion_stacks, ":num_stacks","p_main_party"), (try_for_range, ":i_stack", 1, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"), (troop_is_hero, ":stack_troop"), (store_skill_level, ":cur_surgery_skill", skl_surgery, ":stack_troop"), (gt, ":cur_surgery_skill", ":max_surgery_level"), (assign, ":max_surgery_level", ":cur_surgery_skill"), (assign, ":best_surgeon", ":stack_troop"), (try_end), (store_character_level, ":cur_level", "trp_player"), (assign, ":required_skill", 5), (val_div, ":cur_level", 10), (val_add, ":required_skill", ":cur_level"), (ge, ":max_surgery_level", ":required_skill"), #Skip if party skill level is less than the required value (assign, ":quest_object_troop", ":best_surgeon"), (assign, ":quest_importance", 4), (assign, ":quest_xp_reward", 100), (assign, ":quest_gold_reward", 200), (assign, ":quest_dont_give_again_period", 15), (assign, ":result", ":quest_no"), (try_end), # Lord Quests # (else_try), # (eq, ":quest_no", "qst_meet_spy_in_enemy_town"), # (try_begin), # (eq, "$players_kingdom", ":giver_faction_no"), # (neq, ":giver_reputation", lrep_goodnatured), # (call_script, "script_troop_get_player_relation", ":giver_troop"), # (assign, ":giver_relation", reg0), # (gt, ":giver_relation", 3), # (call_script, "script_cf_faction_get_random_enemy_faction", ":giver_faction_no"), # (assign, ":enemy_faction", reg0), # (store_relation, ":reln", ":enemy_faction", "fac_player_supporters_faction"), # (lt, ":reln", 0), # (call_script, "script_cf_select_random_town_with_faction", ":enemy_faction"), # (assign, ":cur_target_center", reg0), # #Just to make sure that there is a free walker # (call_script, "script_cf_center_get_free_walker", ":cur_target_center"), # (assign, ":quest_target_center", ":cur_target_center"), # (store_random_in_range, ":quest_target_amount", secret_signs_begin, secret_signs_end), # (assign, ":result", ":quest_no"), # (assign, ":quest_gold_reward", 500), # (assign, ":quest_expiration_days", 30), # (assign, ":quest_dont_give_again_period", 50), # (quest_set_slot, "qst_meet_spy_in_enemy_town", slot_quest_gold_reward, 500), # (try_end), # (else_try), # (eq, ":quest_no", "qst_raid_caravan_to_start_war"), # (try_begin), # (eq, "$players_kingdom", ":giver_faction_no"), # (this_or_next|eq, ":giver_reputation", lrep_cunning), # (this_or_next|eq, ":giver_reputation", lrep_quarrelsome), # ( eq, ":giver_reputation", lrep_debauched), # (gt, ":player_level", 10), # (neg|faction_slot_eq, ":giver_faction_no", slot_faction_leader, ":giver_troop"),#Can not take the quest from the king # (call_script, "script_cf_faction_get_random_friendly_faction", ":giver_faction_no"),#Can fail # (assign, ":quest_target_faction", reg0), # (store_troop_faction, ":quest_object_faction", ":giver_troop"), # (assign, ":quest_target_party_template", "pt_kingdom_caravan_party"), # (assign, ":quest_target_amount", 2), # (assign, ":result", ":quest_no"), # (assign, ":quest_expiration_days", 30), # (assign, ":quest_dont_give_again_period", 100), # (try_end), (else_try), (eq, ":quest_no", "qst_deliver_message"), (try_begin), (ge, "$g_talk_troop_faction_relation", 0), (lt, ":player_level", 20), (call_script, "script_cf_get_random_lord_in_a_center_with_faction", ":giver_faction_no"),#Can fail (assign, ":cur_target_troop", reg0), (assign, ":cur_target_dist", reg1), (neq, ":cur_target_troop", ":giver_troop"),#Skip himself (call_script, "script_get_troop_attached_party", ":cur_target_troop"), (assign, ":cur_target_center", reg0),#cur_target_center will definitely be a valid center (neq,":giver_center_no", ":cur_target_center"),#Skip current center (neq,":cur_target_center", "p_town_henneth_annun"),#Skip Henneth Annun (assign, ":quest_target_center", ":cur_target_center"), (store_faction_of_party,":quest_target_faction",":quest_target_center"), (assign, ":quest_target_troop", ":cur_target_troop"), #(assign, ":quest_xp_reward", 30), #TLD: changed to 30-50 (store_mul, ":quest_xp_reward", 20, ":cur_target_dist"), (val_div, ":quest_xp_reward", tld_max_quest_distance), (val_add, ":quest_xp_reward", 30), #(assign, ":quest_gold_reward", 40), #TLD: changed to 40-80 (store_mul, ":quest_gold_reward", 40, ":cur_target_dist"), (val_div, ":quest_gold_reward", tld_max_quest_distance), (val_add, ":quest_gold_reward", 40), (store_mul, ":quest_rank_reward", 4, ":cur_target_dist"), # 3-7 (val_div, ":quest_rank_reward", tld_max_quest_distance), (val_add, ":quest_rank_reward", 3), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 30), (try_end), (else_try), (eq, ":quest_no", "qst_escort_messenger"), (try_begin), (hero_can_join, "p_main_party"), #Skip if player has no available slots (ge, "$g_talk_troop_faction_relation", 0), (ge, ":player_level", 10), # TLD: Choose messenger of appropriate race (try_begin), (this_or_next|eq, "$g_talk_troop_faction", "fac_mordor"), (this_or_next|eq, "$g_talk_troop_faction", "fac_isengard"), (this_or_next|eq, "$g_talk_troop_faction", "fac_moria"), (this_or_next|eq, "$g_talk_troop_faction", "fac_guldur"), (eq, "$g_talk_troop_faction", "fac_gundabad"), (assign, ":cur_object_troop", "trp_messenger_orc"), (else_try), (eq, "$g_talk_troop_faction", "fac_dwarf"), (assign, ":cur_object_troop", "trp_messenger_dwarf"), (else_try), (this_or_next|eq, "$g_talk_troop_faction", "fac_lorien"), (this_or_next|eq, "$g_talk_troop_faction", "fac_imladris"), (eq, "$g_talk_troop_faction", "fac_woodelf"), (assign, ":cur_object_troop", "trp_messenger_elf"), (else_try), # (CppCoder): Bugfix, evil men need different messenger than regular men. (faction_slot_eq|neg, "$g_talk_troop_faction", slot_faction_side, faction_side_good), (assign, ":cur_object_troop", "trp_messenger_evil_man"), (else_try), (assign, ":cur_object_troop", "trp_messenger_man"), (try_end), (call_script, "script_cf_select_random_town_allied", ":giver_faction_no"),#Can fail (assign, ":cur_target_center", reg0), (assign, ":cur_target_dist", reg1), (neq, ":cur_target_center", ":giver_center_no"), (neq,":cur_target_center", "p_town_henneth_annun"),#Skip Henneth Annun (store_mul, ":quest_xp_reward", 200, ":cur_target_dist"), # 200-400 (val_div, ":quest_xp_reward", tld_max_quest_distance), (val_add, ":quest_xp_reward", 200), (store_mul, ":quest_gold_reward", 100, ":cur_target_dist"), # 200-300 (val_div, ":quest_gold_reward", tld_max_quest_distance), (val_add, ":quest_gold_reward", 200), (store_mul, ":quest_rank_reward", 10, ":cur_target_dist"), # 7-17 (val_div, ":quest_rank_reward", tld_max_quest_distance), (val_add, ":quest_rank_reward", 7), (assign, ":quest_importance", 10), (assign, ":quest_target_fac_str_effect", 40), (assign, ":quest_object_troop", ":cur_object_troop"), (assign, ":quest_target_center", ":cur_target_center"), (store_faction_of_party,":quest_target_faction",":quest_target_center"), (assign, ":quest_expiration_days", 20), (assign, ":quest_dont_give_again_period", 8), (assign, ":result", ":quest_no"), (try_end), ## (else_try), ## (eq, ":quest_no", "qst_hunt_down_raiders"), ## (try_begin), ## (gt, ":player_level", 10), ## (faction_slot_eq, ":giver_faction_no", slot_faction_leader, ":giver_troop"), ## (call_script, "script_cf_select_random_town_with_faction", ":giver_faction_no"),#Can fail ## (assign, ":cur_object_center", reg0), ## (neq, ":cur_object_center", ":giver_center_no"),#Skip current center ## (call_script, "script_get_random_enemy_center", ":giver_party_no"), ## (assign, ":cur_target_center", reg0), ## (ge, ":cur_target_center", 0), ## (store_faction_of_party, ":cur_target_faction", ":cur_target_center"), ## (is_between, ":cur_target_faction", kingdoms_begin, kingdoms_end), ## ## (assign, ":quest_object_center", ":cur_object_center"), ## (assign, ":quest_target_center", ":cur_target_center"), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 1500), ## (assign, ":quest_gold_reward", 1000), ## (assign, ":result", ":quest_no"), ## (try_end), ## (else_try), ## (eq, ":quest_no", "qst_bring_back_deserters"), ## (try_begin), ## (gt, ":player_level", 5), ## (faction_get_slot, ":cur_target_party_template", ":giver_faction_no", slot_faction_deserter_party_template), ## (faction_get_slot, ":cur_target_troop", ":giver_faction_no", slot_faction_deserter_troop), ## (gt, ":cur_target_party_template", 0),#Skip factions with no deserter party templates ## (store_num_parties_of_template, ":num_deserters", ":cur_target_party_template"), ## (ge, ":num_deserters", 2),#Skip if there are less than 2 active deserter parties ## ## (assign, ":quest_target_troop", ":cur_target_troop"), ## (assign, ":quest_target_party_template", ":cur_target_party_template"), ## (assign, ":quest_target_amount", 5), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 500), ## (assign, ":quest_gold_reward", 300), ## (assign, ":result", ":quest_no"), ## (try_end), ## (else_try), ## (eq, ":quest_no", "qst_deliver_supply_to_center_under_siege"), ## (try_begin), ## (gt, ":player_level", 10), ## (gt, ":giver_center_no", 0),#Skip if lord is outside the center ## (call_script, "script_cf_get_random_siege_location_with_faction", ":giver_faction_no"),#Can fail ## (assign, ":quest_target_center", reg0), ## (assign, ":quest_target_amount", 10), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 500), ## (assign, ":quest_gold_reward", 300), ## (assign, ":result", ":quest_no"), ## (try_end), ## (else_try), ## (eq, ":quest_no", "qst_bring_reinforcements_to_siege"), ## (try_begin), ## (gt, ":player_level", 10), ## (call_script, "script_cf_get_random_siege_location_with_attacker_faction", ":giver_faction_no"),#Can fail ## (assign, ":cur_target_center", reg0), ## (store_random_in_range, ":random_no", 5, 11), ## (troops_can_join, ":random_no"),#Skip if the player doesn't have enough room ## (call_script, "script_cf_get_number_of_random_troops_from_party", ":giver_party_no", ":random_no"),#Can fail ## (assign, ":cur_object_troop", reg0), ## (party_get_battle_opponent, ":cur_target_party", ":cur_target_center"), ## (party_get_num_companion_stacks, ":num_stacks", ":cur_target_party"), ## (gt, ":num_stacks", 0),#Skip if the besieger party has no troops ## (party_stack_get_troop_id, ":cur_target_troop", ":cur_target_party", 0), ## (troop_is_hero, ":cur_target_troop"),#Skip if the besieger party has no heroes ## (neq, ":cur_target_troop", ":giver_troop"),#Skip if the quest giver is the same troop ## (assign, ":quest_target_troop", ":cur_target_troop"), ## (assign, ":quest_object_troop", ":cur_object_troop"), ## (assign, ":quest_target_party", ":cur_target_party"), ## (assign, ":quest_target_center", ":cur_target_center"), ## (assign, ":quest_target_amount", ":random_no"), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 400), ## (assign, ":quest_gold_reward", 200), ## (assign, ":result", ":quest_no"), ## (try_end), (else_try), (eq, ":quest_no", "qst_deliver_message_to_enemy_lord"), (try_begin), (eq, 1, 0), #disabled - no dealings with the enemy (ge, "$g_talk_troop_faction_relation", 0), (is_between, ":player_level", 5, 25), (call_script, "script_cf_get_random_lord_from_enemy_faction_in_a_center", ":giver_faction_no"),#Can fail (assign, ":cur_target_troop", reg0), (assign, ":cur_target_dist", reg1), (call_script, "script_get_troop_attached_party", ":cur_target_troop"), (assign, ":quest_target_center", reg0),#quest_target_center will definitely be a valid center (assign, ":quest_target_troop", ":cur_target_troop"), (assign, ":quest_importance", 8), #(assign, ":quest_xp_reward", 200), # TLD 200-300 (store_mul, ":quest_xp_reward", 100, ":cur_target_dist"), (val_div, ":quest_xp_reward", tld_max_quest_distance), (val_add, ":quest_xp_reward", 200), #(assign, ":quest_gold_reward", 0), # TLD 300-400 (store_mul, ":quest_gold_reward", 100, ":cur_target_dist"), (val_div, ":quest_gold_reward", tld_max_quest_distance), (val_add, ":quest_gold_reward", 300), (store_mul, ":quest_rank_reward", 5, ":cur_target_dist"), # rank 5-10 (val_div, ":quest_rank_reward", tld_max_quest_distance), (val_add, ":quest_rank_reward", 5), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 40), (try_end), ## (else_try), ## (eq, ":quest_no", "qst_bring_prisoners_to_enemy"), ## (try_begin), ## (gt, ":player_level", 10), ## (is_between, ":giver_center_no", centers_begin, centers_end),#Skip if the quest giver is not at a center ## (store_random_in_range, ":random_no", 5, 11), ## (troops_can_join_as_prisoner, ":random_no"),#Skip if the player doesn't have enough room ## (call_script, "script_get_random_enemy_town", ":giver_center_no"), ## (assign, ":cur_target_center", reg0), ## (ge, ":cur_target_center", 0),#Skip if there are no enemy towns ## (store_faction_of_party, ":cur_target_faction", ":cur_target_center"), ## (faction_get_slot, ":cur_object_troop", ":cur_target_faction", slot_faction_tier_5_troop), ## (assign, ":quest_target_center", ":cur_target_center"), ## (assign, ":quest_object_troop", ":cur_object_troop"), ## (assign, ":quest_target_amount", ":random_no"), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 300), ## (assign, ":quest_gold_reward", 200), ## (assign, ":result", ":quest_no"), ## (try_end), # (else_try), #GA: quest to defend refugees caravan from raiders # (eq, ":quest_no", "qst_deal_with_bandits_at_lords_village"), # (faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), # (neg|is_between, ":giver_faction_no", fac_lorien,fac_dale), #elves and dwarves do not give such quests # (neq, ":giver_faction_no", fac_dwarf), # (ge, "$g_talk_troop_faction_relation", 0), # (ge, ":player_level", 5), # (gt, ":giver_center_no", 0),#Skip if lord is outside the center # (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting) # (assign, ":quest_target_party", ":cur_target_center"), # (assign, ":result", ":quest_no"), # (assign, ":quest_expiration_days", 1), (else_try), (eq, ":quest_no", "qst_raise_troops"), (try_begin), (neq, ":giver_faction_no", "fac_player_supporters_faction"), #we need tier_1_troop a valid value (ge, "$g_talk_troop_faction_relation", 0), (store_character_level, ":cur_level", "trp_player"), (gt, ":cur_level", 5), (val_min, ":cur_level", 29), #stop scaling at lvl 29 --> never ask for more than 15 troops, never ask for t6 #Kham - Dynamic Amount / Levels Begin - Makes it easier for low level players to do this quest, and not give up precious troops. (store_div, ":target_amount_base", ":cur_level", 3), #(party_get_skill_level, ":trainer_modifier", "p_main_party", "skl_trainer"), #(val_div, ":trainer_modifier", 2), #(val_max, ":trainer_modifier", 1), #(val_add, ":target_amount_base", ":trainer_modifier"), #inVain: Removed training modifier. We don't want punish the player for being good at training (store_div, ":target_amount_max", ":cur_level", 5), (val_add, ":target_amount_max", 1), #keep in mind that store_random_in_range reduces max amount by 1 (val_add, ":target_amount_max", ":target_amount_base"), (store_random_in_range, ":quest_target_amount", ":target_amount_base", ":target_amount_max"), (try_begin), #Elves and Dwarves have a dif max amount cause it is hard to maintain these troops. (this_or_next|eq, ":giver_faction_no", "fac_dwarf"), (this_or_next|eq, ":giver_faction_no", "fac_lorien"), (this_or_next|eq, ":giver_faction_no", "fac_imladris"), ( eq, ":giver_faction_no", "fac_woodelf"), (val_mul, ":quest_target_amount", 3), (val_div, ":quest_target_amount", 4), (try_end), (store_add, ":quest_importance", ":quest_target_amount", 1), (val_min, ":quest_importance", 10), (party_get_free_companions_capacity, ":free_capacity", "p_main_party"), (le, ":quest_target_amount", ":free_capacity"), (faction_get_slot, ":quest_object_troop", ":giver_faction_no", slot_faction_tier_1_troop), (store_add, ":level_up_min", ":cur_level", 7), #InVain: was 10 (store_add, ":level_up_max", ":cur_level", 21), #InVain: was 26 #(val_min, ":level_up_max", 51), (store_random_in_range, ":level_up", ":level_up_min", ":level_up_max"), (assign, reg76, ":level_up_min"), (assign, reg77, ":level_up_max"), (assign, reg78, ":level_up"), #(display_message, "@min: {reg76}; max {reg77}; level up: {reg78} rounds"), #Kham - Dynamic Amount / Levels END #(val_add, ":level_up", ":cur_level"), #InVain: Removed this. Now the scaling won't go overboard (val_div, ":level_up", 10), #(store_mul, ":quest_gold_reward", ":quest_target_amount", 10), (assign, ":quest_target_troop", ":quest_object_troop"), (try_for_range, ":unused", 0, ":level_up"), (troop_get_upgrade_troop, ":level_up_troop", ":quest_target_troop", 0), (gt, ":level_up_troop", 0), (assign, ":quest_target_troop", ":level_up_troop"), #(val_mul, ":quest_gold_reward", 7), #(val_div, ":quest_gold_reward", 4), (try_end), ## (try_begin), ## (ge, ":cur_level", 15), ## (faction_get_slot, ":cur_target_troop", ":giver_faction_no", slot_faction_tier_5_troop), ## (assign, ":quest_gold_reward", 300), ## (else_try), ## (faction_get_slot, ":cur_target_troop", ":giver_faction_no", slot_faction_tier_4_troop), ## (assign, ":quest_gold_reward", 150), ## (try_end), ## (gt, ":cur_target_troop", 0), #InVain: calculate reward based on troop wage (scales exponentially with troop level) (call_script, "script_game_get_troop_wage", ":quest_target_troop",0), (store_mul, ":quest_gold_reward", reg0, ":quest_target_amount"), (val_mul, ":quest_gold_reward", 5), (assign, ":quest_xp_reward", ":quest_gold_reward"), (assign, ":quest_rank_reward", ":quest_gold_reward"), (val_div, ":quest_rank_reward", 30), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 50), (assign, ":quest_dont_give_again_period", 15), (assign, ":quest_object_faction", ":giver_faction_no"), (try_end), # (else_try), # (eq, ":quest_no", "qst_collect_taxes"), # (try_begin), # (neq, ":giver_reputation", lrep_goodnatured), # (neq, ":giver_reputation", lrep_upstanding), # (ge, "$g_talk_troop_faction_relation", 0), # (call_script, "script_cf_troop_get_random_leaded_town_or_village_except_center", ":giver_troop", ":giver_center_no"), # (assign, ":quest_target_center", reg0), # (assign, ":quest_importance", 1), # (assign, ":quest_gold_reward", 0), # (assign, ":quest_xp_reward", 100), # (assign, ":result", ":quest_no"), # (assign, ":quest_expiration_days", 50), # (assign, ":quest_dont_give_again_period", 20), # (try_end), (else_try), (eq, ":quest_no", "qst_hunt_down_fugitive"), (try_begin), (ge, "$g_talk_troop_faction_relation", 0), #(call_script, "script_cf_select_random_village_with_faction", ":giver_faction_no"), # TLD: Choose fugitive of appropriate race (try_begin), (this_or_next|eq, "$g_talk_troop_faction", "fac_mordor"), (this_or_next|eq, "$g_talk_troop_faction", "fac_isengard"), (this_or_next|eq, "$g_talk_troop_faction", "fac_moria"), (this_or_next|eq, "$g_talk_troop_faction", "fac_guldur"), (eq, "$g_talk_troop_faction", "fac_gundabad"), (assign, ":cur_object_troop", "trp_fugitive_orc"), (else_try), (eq, "$g_talk_troop_faction", "fac_dwarf"), (assign, ":cur_object_troop", "trp_fugitive_dwarf"), (else_try), (this_or_next|eq, "$g_talk_troop_faction", "fac_lorien"), (this_or_next|eq, "$g_talk_troop_faction", "fac_imladris"), (eq, "$g_talk_troop_faction", "fac_woodelf"), (assign, ":cur_object_troop", "trp_fugitive_elf"), (else_try), (assign, ":cur_object_troop", "trp_fugitive_man"), (try_end), (assign, ":quest_object_troop", ":cur_object_troop"), (call_script, "script_cf_select_random_town_allied", ":giver_faction_no"),#Can fail (assign, ":quest_target_center", reg0), #(assign, ":quest_target_dist", reg1), (neq, ":quest_target_center", ":giver_center_no"), (store_faction_of_party,":quest_target_faction",":quest_target_center"), (assign,":quest_object_faction",":giver_faction_no"), (assign, ":quest_importance", 4), (assign, ":quest_gold_reward", 300), (assign, ":quest_xp_reward", 300), (assign, ":quest_rank_reward", 13), (store_random_in_range, ":quest_target_dna", 0, 1000000), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 30), (assign, ":quest_dont_give_again_period", 20), (try_end), ## (else_try), ## (eq, ":quest_no", "qst_capture_messenger"), ## (try_begin), ## (call_script, "script_cf_faction_get_random_enemy_faction", ":giver_faction_no"), ## (assign, ":cur_target_faction", reg0), ## (faction_get_slot, ":cur_target_troop", ":cur_target_faction", slot_faction_rider_troop), ## (gt, ":cur_target_troop", 0),#Checking the validiy of cur_target_troop ## (store_num_parties_destroyed_by_player, ":quest_target_amount", "pt_messenger_party"), ## ## (assign, ":quest_target_troop", ":cur_target_troop"), ## (assign, ":quest_target_party_template", ":cur_target_party_template"), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 700), ## (assign, ":quest_gold_reward", 400), ## (assign, ":result", ":quest_no"), ## (try_end), # (else_try), # (eq, ":quest_no", "qst_kill_local_merchant"), # (try_begin), # (this_or_next|eq, ":giver_reputation", lrep_quarrelsome), # (this_or_next|eq, ":giver_reputation", lrep_cunning), # ( eq, ":giver_reputation", lrep_debauched), # (neg|faction_slot_eq, ":giver_faction_no", slot_faction_leader, ":giver_troop"),#Can not take the quest from the king # (ge, "$g_talk_troop_faction_relation", 0), # (gt, ":player_level", 5), # (is_between, ":giver_center_no", centers_begin, centers_end), # (assign, ":quest_importance", 1), # (assign, ":quest_xp_reward", 300), # (assign, ":quest_gold_reward", 1000), # (assign, ":result", ":quest_no"), # (assign, ":quest_expiration_days", 10), # (assign, ":quest_dont_give_again_period", 30), # (try_end), (else_try), (eq, ":quest_no", "qst_bring_back_runaway_serfs"), (try_begin), (neg|faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), #(neq, ":giver_reputation", lrep_goodnatured), #(neq, ":giver_reputation", lrep_upstanding), (ge, "$g_talk_troop_faction_relation", 0), (ge, ":player_level", 5), (gt, ":giver_center_no", 0),#Skip if lord is outside the center (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting) (assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town #(call_script, "script_cf_select_random_town_with_faction", ":giver_faction_no"), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (assign, ":cur_target_center", reg0), (assign, ":dist", reg1), (neq, ":cur_target_center", ":giver_center_no"),#Skip current center (ge, ":dist", 20), (assign, ":quest_target_party_template", "pt_runaway_serfs"), (assign, ":quest_object_center", ":cur_object_center"), (store_faction_of_party,":quest_object_faction",":giver_faction_no"), (assign, ":quest_target_center", ":cur_target_center"), (store_faction_of_party,":quest_target_faction",":quest_target_center"), (assign, ":quest_giver_fac_str_effect", 50), (assign, ":quest_target_fac_str_effect", -50), (assign, ":quest_importance", 8), (assign, ":quest_xp_reward", 300), (assign, ":quest_gold_reward", 600), (assign, ":quest_rank_reward", 9), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 30), (assign, ":quest_dont_give_again_period", 17), (assign, "$qst_bring_back_runaway_serfs_num_parties_returned", 0), (assign, "$qst_bring_back_runaway_serfs_num_parties_fleed", 0), (try_end), (else_try), (eq, ":quest_no", "qst_follow_spy"), (try_begin), (troop_slot_eq, "trp_player", slot_troop_home, 22), #Kham Cheat Mode (eq, cheat_switch, 1), #Enabled only with cheat switch, for now (ge, "$g_talk_troop_faction_relation", 0), #(neq, ":giver_reputation", lrep_goodnatured), (party_get_skill_level, ":tracking_skill", "p_main_party", "skl_tracking"), (ge, ":tracking_skill", 2), (ge, ":player_level", 10), (eq, "$g_defending_against_siege", 0), #Skip if the center is under siege (because of resting) (gt, ":giver_party_no", 0), #Skip if the quest giver doesn't have a party (gt, ":giver_center_no", 0), #skip if the quest giver is not in a center (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town), #skip if we are not in a town. (party_get_position, pos2, "p_main_party"), (assign, ":max_distance", 0), (assign, ":cur_object_center", 0), (try_for_range, ":unused_2", 0, 3), #MV: more distant centers more likely, was 10 (call_script, "script_cf_get_random_enemy_center_within_range", ":giver_party_no", tld_max_quest_distance), (assign, ":random_object_center", reg0), (assign, ":cur_distance", reg1), (party_get_position, pos3, ":random_object_center"), (map_get_random_position_around_position, pos4, pos3, 6), (gt, ":cur_distance", 10), #MV: not too close (gt, ":cur_distance", ":max_distance"), (assign, ":max_distance", ":cur_distance"), (assign, ":cur_object_center", ":random_object_center"), (copy_position, pos63, pos4), #Do not change pos63 until quest is accepted (try_end), (gt, ":cur_object_center", 0), #Skip if there are no enemy centers #TLD good/evil troops and party templates (try_begin), (faction_slot_eq, ":giver_faction_no", slot_faction_side, faction_side_good), (assign, ":quest_object_troop", "trp_spy_evil"), (assign, ":quest_target_troop", "trp_spy_partner_evil"), (assign, ":quest_target_party_template", "pt_spy_evil"), (assign, ":quest_target_party", "pt_spy_partners_evil"), #abusing this for the second template (else_try), (assign, ":quest_object_troop", "trp_spy"), (assign, ":quest_target_troop", "trp_spy_partner"), (assign, ":quest_target_party_template", "pt_spy"), (assign, ":quest_target_party", "pt_spy_partners"), #abusing this for the second template (try_end), (assign, ":quest_object_center", ":cur_object_center"), (assign, ":cur_target_dist", ":max_distance"), (assign, ":quest_importance", 12), (store_mul, ":quest_xp_reward", 1000, ":cur_target_dist"), #TLD: 3000-4000 (val_div, ":quest_xp_reward", tld_max_quest_distance), (val_add, ":quest_xp_reward", 3000), (store_mul, ":quest_gold_reward", 1000, ":cur_target_dist"), #TLD: 2000-3000 (val_div, ":quest_gold_reward", tld_max_quest_distance), (val_add, ":quest_gold_reward", 2000), (store_mul, ":quest_rank_reward", 5, ":cur_target_dist"), # TLD: 15-20 (val_div, ":quest_rank_reward", tld_max_quest_distance), (val_add, ":quest_rank_reward", 15), (assign, ":quest_dont_give_again_period", 50), (assign, ":result", ":quest_no"), (assign, "$qst_follow_spy_run_away", 0), (assign, "$qst_follow_spy_meeting_state", 0), (assign, "$qst_follow_spy_meeting_counter", 0), (assign, "$qst_follow_spy_spy_back_in_town", 0), (assign, "$qst_follow_spy_partner_back_in_town", 0), (assign, "$qst_follow_spy_no_active_parties", 0), (try_end), (else_try), (eq, ":quest_no", "qst_capture_enemy_hero"), (try_begin), #(eq, "$players_kingdom", ":giver_faction_no"), #(neg|faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"), (ge, "$tld_war_began", 1), # War started (ge, ":player_level", 15), #(call_script, "script_cf_faction_get_random_enemy_faction", ":giver_faction_no"),#Can fail (assign, ":quest_object_faction", ":giver_faction_no"), (assign, ":quest_giver_fac_str_effect", 150), (assign, ":quest_gold_reward", 2000), (assign, ":quest_xp_reward", 2500), (assign, ":quest_rank_reward", 24), (assign, ":quest_importance", 12), (assign, ":quest_expiration_days", 30), (assign, ":quest_dont_give_again_period", 35), (assign, ":result", ":quest_no"), (try_end), (else_try), (eq, ":quest_no", "qst_lend_companion"), (try_begin), (ge, "$g_talk_troop_faction_relation", 0), (assign, ":total_heroes", 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"), (troop_is_hero, ":stack_troop"), (this_or_next|is_between, ":stack_troop", companions_begin, companions_end), (is_between, ":stack_troop", new_companions_begin, new_companions_end), (store_character_level, ":stack_level", ":stack_troop"), (ge, ":stack_level", 15), (assign, ":is_quest_hero", 0), (try_for_range, ":i_quest", 0, all_quests_end), (check_quest_active, ":i_quest"), (this_or_next|quest_slot_eq, ":i_quest", slot_quest_target_troop, ":stack_troop"), (quest_slot_eq, ":i_quest", slot_quest_object_troop, ":stack_troop"), (assign, ":is_quest_hero", 1), (try_end), (eq, ":is_quest_hero", 0), (val_add, ":total_heroes", 1), (try_end), (gt, ":total_heroes", 0),#Skip if party has no eligible heroes (store_random_in_range, ":random_hero", 0, ":total_heroes"), (assign, ":total_heroes", 0), (assign, ":cur_target_troop", -1), (try_for_range, ":i_stack", 0, ":num_stacks"), (eq, ":cur_target_troop", -1), (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"), (troop_is_hero, ":stack_troop"), (neq, ":stack_troop", "trp_player"), (store_character_level, ":stack_level", ":stack_troop"), (ge, ":stack_level", 15), (assign, ":is_quest_hero", 0), (try_for_range, ":i_quest", 0, all_quests_end), (check_quest_active, ":i_quest"), (this_or_next|quest_slot_eq, ":i_quest", slot_quest_target_troop, ":stack_troop"), (quest_slot_eq, ":i_quest", slot_quest_object_troop, ":stack_troop"), (assign, ":is_quest_hero", 1), (try_end), (eq, ":is_quest_hero", 0), (val_add, ":total_heroes", 1), (gt, ":total_heroes", ":random_hero"), (assign, ":cur_target_troop", ":stack_troop"), (try_end), (assign, ":quest_target_troop", ":cur_target_troop"), (store_current_day, ":quest_target_amount"), (val_add, ":quest_target_amount", 5), #Kham - from 8 to 5. (assign, ":quest_importance", 3), (assign, ":quest_xp_reward", 200), (assign, ":quest_gold_reward", 300), (assign, ":quest_rank_reward", 10), (assign, ":result", ":quest_no"), (assign, ":quest_dont_give_again_period", 30), (try_end), # (else_try), # (eq, ":quest_no", "qst_collect_debt"), # (try_begin), # (ge, "$g_talk_troop_faction_relation", 0), # # Find a vassal (within the same kingdom?) # (call_script, "script_cf_get_random_lord_in_a_center_with_faction", ":giver_faction_no"),#Can fail # (assign, ":quest_target_troop", reg0), # (neq, ":quest_target_troop", ":giver_troop"),#Skip himself # (call_script, "script_get_troop_attached_party", ":quest_target_troop"), # (assign, ":quest_target_center", reg0),#cur_target_center will definitely be a valid center # (neq,":giver_center_no", ":quest_target_center"),#Skip current center # (assign, ":quest_xp_reward", 30), # (assign, ":quest_gold_reward", 40), # (assign, ":result", ":quest_no"), # (store_random_in_range, ":quest_target_amount", 6, 9), # (val_mul, ":quest_target_amount", 500), # (store_div, ":quest_convince_value", ":quest_target_amount", 5), # (assign, ":quest_expiration_days", 90), # (assign, ":quest_dont_give_again_period", 20), # (try_end), ## (else_try), ## (eq, ":quest_no", "qst_capture_conspirators"), ## (try_begin), ## (eq, 1,0), #TODO: disable this for now ## (ge, ":player_level", 10), ## (is_between, ":giver_center_no", centers_begin, centers_end),#Skip if quest giver's center is not a town ## (party_slot_eq, ":giver_center_no", slot_town_lord, ":giver_troop"),#Skip if the current center is not ruled by the quest giver ## (call_script, "script_cf_get_random_kingdom_hero", ":giver_faction_no"),#Can fail ## ## (assign, ":quest_target_troop", reg0), ## (assign, ":quest_target_center", ":giver_center_no"), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 10), ## (assign, ":quest_gold_reward", 10), ## (assign, ":result", ":quest_no"), ## (store_character_level, ":cur_level"), ## (val_div, ":cur_level", 5), ## (val_max, ":cur_level", 3), ## (store_add, ":max_parties", 4, ":cur_level"), ## (store_random_in_range, "$qst_capture_conspirators_num_parties_to_spawn", 4, ":max_parties"), ## (assign, "$qst_capture_conspirators_num_troops_to_capture", 0), ## (assign, "$qst_capture_conspirators_num_parties_spawned", 0), ## (assign, "$qst_capture_conspirators_leave_meeting_counter", 0), ## (assign, "$qst_capture_conspirators_party_1", 0), ## (assign, "$qst_capture_conspirators_party_2", 0), ## (assign, "$qst_capture_conspirators_party_3", 0), ## (assign, "$qst_capture_conspirators_party_4", 0), ## (assign, "$qst_capture_conspirators_party_5", 0), ## (assign, "$qst_capture_conspirators_party_6", 0), ## (assign, "$qst_capture_conspirators_party_7", 0), ## (try_end), ## (else_try), ## (eq, ":quest_no", "qst_defend_nobles_against_peasants"), ## (try_begin), ## (eq, 1,0), #TODO: disable this for now ## (ge, ":player_level", 10), ## (is_between, ":giver_center_no", centers_begin, centers_end),#Skip if quest giver's center is not a town ## (party_slot_eq, ":giver_center_no", slot_town_lord, ":giver_troop"),#Skip if the current center is not ruled by the quest giver ## ## (assign, ":quest_target_center", ":giver_center_no"), ## (assign, ":quest_importance", 1), ## (assign, ":quest_xp_reward", 10), ## (assign, ":quest_gold_reward", 10), ## (assign, ":result", ":quest_no"), ## (store_character_level, ":cur_level"), ## (val_div, ":cur_level", 5), ## (val_max, ":cur_level", 4), ## (store_add, ":max_parties", 4, ":cur_level"), ## (store_random_in_range, "$qst_defend_nobles_against_peasants_num_peasant_parties_to_spawn", 4, ":cur_level"), ## (store_random_in_range, "$qst_defend_nobles_against_peasants_num_noble_parties_to_spawn", 4, ":cur_level"), ## (assign, "$qst_defend_nobles_against_peasants_num_nobles_to_save", 0), ## (assign, "$qst_defend_nobles_against_peasants_num_nobles_saved", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_1", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_2", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_3", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_4", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_5", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_6", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_7", 0), ## (assign, "$qst_defend_nobles_against_peasants_peasant_party_8", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_1", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_2", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_3", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_4", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_5", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_6", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_7", 0), ## (assign, "$qst_defend_nobles_against_peasants_noble_party_8", 0), ## (try_end), # (else_try), # (eq, ":quest_no", "qst_incriminate_loyal_commander"), # (try_begin), # (neq, ":giver_reputation", lrep_upstanding), # (neq, ":giver_reputation", lrep_goodnatured), # (eq, "$players_kingdom", ":giver_faction_no"), # (ge, ":player_level", 10), # (faction_slot_eq, ":giver_faction_no", slot_faction_leader, ":giver_troop"), # (assign, ":try_times", 1), # (assign, ":found", 0), # (try_for_range, ":unused", 0, ":try_times"), # (call_script, "script_cf_faction_get_random_enemy_faction", ":giver_faction_no"),#Can fail # (assign, ":cur_target_faction", reg0), # (faction_get_slot, ":cur_target_troop", ":cur_target_faction", slot_faction_leader), # (assign, ":num_centerless_heroes", 0), # (try_for_range, ":cur_kingdom_hero", kingdom_heroes_begin, kingdom_heroes_end), # (troop_slot_eq, ":cur_kingdom_hero", slot_troop_occupation, slto_kingdom_hero), # #(troop_slot_eq, ":cur_kingdom_hero", slot_troop_is_prisoner, 0), # (neg|troop_slot_ge, ":cur_kingdom_hero", slot_troop_prisoner_of_party, 0), # (neq, ":cur_target_troop", ":cur_kingdom_hero"), # (store_troop_faction, ":cur_kingdom_hero_faction", ":cur_kingdom_hero"), # (eq, ":cur_target_faction", ":cur_kingdom_hero_faction"), # ## (call_script, "script_get_number_of_hero_centers", ":cur_kingdom_hero"), # ## (eq, reg0, 0), # (val_add, ":num_centerless_heroes", 1), # (try_end), # (gt, ":num_centerless_heroes", 0), # (assign, ":cur_object_troop", -1), # (store_random_in_range, ":random_kingdom_hero", 0, ":num_centerless_heroes"), # (try_for_range, ":cur_kingdom_hero", kingdom_heroes_begin, kingdom_heroes_end), # (eq, ":cur_object_troop", -1), # (troop_slot_eq, ":cur_kingdom_hero", slot_troop_occupation, slto_kingdom_hero), # (neq, ":cur_target_troop", ":cur_kingdom_hero"), # (store_troop_faction, ":cur_kingdom_hero_faction", ":cur_kingdom_hero"), # (eq, ":cur_target_faction", ":cur_kingdom_hero_faction"), # ## (call_script, "script_get_number_of_hero_centers", ":cur_kingdom_hero"), # ## (eq, reg0, 0), # (val_sub, ":random_kingdom_hero", 1), # (lt, ":random_kingdom_hero", 0), # (assign, ":cur_object_troop", ":cur_kingdom_hero"), # (try_end), # (assign, ":cur_target_center", -1), # (call_script, "script_get_troop_attached_party", ":cur_target_troop"), # (is_between, reg0, centers_begin, centers_end), # (party_slot_eq, reg0, slot_town_lord, ":cur_target_troop"), # (assign, ":cur_target_center", reg0), # (assign, ":try_times", -1),#Exit the second loop # (assign, ":found", 1), # (try_end), # (eq, ":found", 1), # (assign, "$incriminate_quest_sacrificed_troop", 0), # (party_get_num_companion_stacks, ":num_stacks", "p_main_party"), # (try_for_range, ":i_stack", 1, ":num_stacks"), # (eq ,"$incriminate_quest_sacrificed_troop", 0), # (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"), # (neg|troop_is_hero, ":stack_troop"), # (store_character_level, ":stack_troop_level", ":stack_troop"), # (ge, ":stack_troop_level", 25), # (assign, "$incriminate_quest_sacrificed_troop", ":stack_troop"), # (try_end), # (gt, "$incriminate_quest_sacrificed_troop", 0), # (assign, ":quest_target_troop", ":cur_target_troop"), # (assign, ":quest_object_troop", ":cur_object_troop"), # (assign, ":quest_target_center", ":cur_target_center"), # (assign, ":quest_target_faction", ":cur_target_faction"), # (assign, ":quest_importance", 1), # (assign, ":quest_xp_reward", 700), # (assign, ":quest_gold_reward", 1000), # (assign, ":result", ":quest_no"), # (assign, ":quest_expiration_days", 30), # (assign, ":quest_dont_give_again_period", 180), # (try_end), (else_try), (eq, ":quest_no", "qst_capture_prisoners"), (try_begin), #not given by factions that have only elven or orcish enemies in the initial theatre, since elves and orcs can't be taken prisoner # central theater - no mercy there #(neq, ":giver_faction_no", "fac_moria"), #Invain: These two can easily go for Beornings, Dale, or Rohan #(neq, ":giver_faction_no", "fac_guldur"), (neq, ":giver_faction_no", "fac_lorien"), (neq, ":giver_faction_no", "fac_imladris"), (store_character_level, ":quest_target_amount", "trp_player"), (gt, ":quest_target_amount", 5), (val_clamp, ":quest_target_amount", 6, 31), (val_div, ":quest_target_amount", 3), #2-10 #(assign, ":quest_target_troop", ":cur_target_troop"), #(assign, ":quest_target_faction", ":cur_target_faction"), (assign, ":quest_importance", 3), #(store_character_level, ":quest_gold_reward", ":cur_target_troop"), (store_mul, ":quest_gold_reward", ":quest_target_amount", 20), (val_add, ":quest_gold_reward", 50), # 90-250 (assign, ":quest_xp_reward", ":quest_gold_reward"), (val_mul, ":quest_xp_reward", 5), (val_div, ":quest_xp_reward", 7), (assign, ":quest_rank_reward", ":quest_target_amount"), (assign, ":quest_object_faction", ":giver_faction_no"), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 90), (assign, ":quest_dont_give_again_period", 16), (try_end), (else_try), (eq, ":quest_no", "qst_rescue_prisoners"), (try_begin), (ge, "$tld_war_began", 1), (store_character_level, ":quest_target_amount", "trp_player"), (gt, ":quest_target_amount", 7), (val_clamp, ":quest_target_amount", 8, 21), (val_sub, ":quest_target_amount", 4), #4-16 (assign, ":quest_importance", 6), (store_mul, ":quest_gold_reward", ":quest_target_amount", 20), (assign, ":quest_xp_reward", ":quest_gold_reward"), (store_mul, ":quest_rank_reward", ":quest_target_amount", 2), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 60), (assign, ":quest_dont_give_again_period", 14), (assign, ":quest_object_faction", ":giver_faction_no"), (try_end), (else_try), (eq, ":quest_no", "qst_scout_enemy_town"), (try_begin), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (assign, ":quest_target_center", reg0), (assign, ":dist", reg1), (assign, ":quest_target_troop", 0), #abuse this as a boolean flag: if town scouted (assign, ":quest_importance", 2), (store_mul, ":quest_gold_reward", ":dist", 5), (assign, ":quest_xp_reward", ":dist"), (store_div, ":quest_rank_reward", ":dist", 7), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 5), (assign, ":quest_dont_give_again_period", 12), (try_end), (else_try), (eq, ":quest_no", "qst_dispatch_scouts"), (try_begin), (ge, ":player_level", 5), (faction_get_slot, ":capital", ":giver_faction_no", slot_faction_capital), #count on capitals to have scouts (party_get_slot, ":center_scouts", ":capital", slot_center_spawn_scouts), (gt, ":center_scouts", 0), (assign, ":quest_target_party_template", ":center_scouts"), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (assign, ":quest_target_center", reg0), (assign, ":dist", reg1), (assign, ":quest_object_faction", ":giver_faction_no"), (faction_get_slot, ":tier_1_troop", ":quest_object_faction", slot_faction_tier_1_troop), #4 of these (faction_get_slot, ":tier_2_troop", ":quest_object_faction", slot_faction_tier_2_troop), #2 of these (faction_get_slot, ":tier_3_troop", ":quest_object_faction", slot_faction_tier_3_troop), #1 of these, and used for member chat (gt, ":tier_1_troop", 0), (gt, ":tier_2_troop", 0), (gt, ":tier_3_troop", 0), (assign, ":quest_object_troop", ":tier_3_troop"), (store_div, ":quest_target_amount", ":player_level", 2), (val_min, ":quest_target_amount", 3), (val_max, ":quest_target_amount", 15), #rank and fac str reward will receive a bonus per party strength, defined in quest dialog (assign, ":quest_importance", 4), (store_mul, ":quest_gold_reward", ":dist", 7), (assign, ":quest_xp_reward", ":dist"), (store_div, ":quest_rank_reward", ":dist", 10), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 10), (assign, ":quest_dont_give_again_period", 14), (assign, ":quest_object_faction", ":giver_faction_no"), (assign, ":quest_giver_fac_str_effect", 10), (try_end), (else_try), (eq, ":quest_no", "qst_eliminate_patrols"), (try_begin), (gt, "$tld_war_began", 0), (ge, ":player_level", 10), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (assign, ":quest_target_center", reg0), (store_faction_of_party, ":quest_target_faction", ":quest_target_center"), #Kham - keep track of faction to check if it is active/inactive (assign, ":quest_object_faction", ":giver_faction_no"), #(assign, ":dist", reg1), #find a random enemy scout/raider/patrol/caravan spawned in the enemy center (party_get_slot, ":center_scouts", ":quest_target_center", slot_center_spawn_scouts), (party_get_slot, ":center_raiders", ":quest_target_center", slot_center_spawn_raiders), (party_get_slot, ":center_patrol", ":quest_target_center", slot_center_spawn_patrol), (party_get_slot, ":center_caravan", ":quest_target_center", slot_center_spawn_caravan), (store_random_in_range, ":random_no", 0, 4), (assign, ":min_amount", 0), ##Kham - added + 1 to min amount as it is a bit easier now, when we allow for assists. (assign, ":done", 0), (try_begin), (eq, ":random_no", 0), (gt, ":center_caravan", 0), (assign, ":done", 1), (assign, ":quest_target_party_template", ":center_caravan"), (assign, ":min_amount", 4), (assign, ":base_reward", 3), (else_try), (eq, ":done", 0), (le, ":random_no", 1), (gt, ":center_patrol", 0), (assign, ":done", 1), (assign, ":quest_target_party_template", ":center_patrol"), (assign, ":min_amount", 4), (assign, ":base_reward", 4), (else_try), (eq, ":done", 0), (le, ":random_no", 2), (gt, ":center_raiders", 0), (assign, ":done", 1), (assign, ":quest_target_party_template", ":center_raiders"), (assign, ":min_amount", 5), (assign, ":base_reward", 2), (else_try), (eq, ":done", 0), (gt, ":center_scouts", 0), (assign, ":done", 1), (assign, ":quest_target_party_template", ":center_scouts"), (assign, ":min_amount", 6), (assign, ":base_reward", 1), (try_end), (eq, ":done", 1), #should never happen, but who knows # get a random party, used only to find the template name - won't work for caravans with changed names! #(store_random_party_of_template, ":quest_target_party" ":quest_target_party_template"), #can fail, expensive (assign, ":quest_target_amount", ":player_level"), (val_clamp, ":quest_target_amount", 10, 31), #10-30 (val_add, ":quest_target_amount", 10), #20-40 (val_mul, ":quest_target_amount", 5), #100-200 (val_mul, ":quest_target_amount", ":min_amount"), (val_div, ":quest_target_amount", 100), #min_amount - 2*min_amount (store_num_parties_destroyed_by_player, ":num_already_destroyed", ":quest_target_party_template"), (party_template_set_slot, ":quest_target_party_template", slot_party_template_num_killed, ":num_already_destroyed"), (quest_set_slot, "qst_eliminate_patrols", slot_quest_current_state, 0), #Kham - Use Current State to track # kills. (val_mul, ":base_reward", ":quest_target_amount"), (assign, ":quest_importance", 12), (store_mul, ":quest_gold_reward", ":base_reward", 50), (store_mul, ":quest_xp_reward", ":base_reward", 20), (store_mul, ":quest_rank_reward", ":base_reward", 2), (store_mul, ":quest_giver_fac_str_effect", ":base_reward", 5), (store_mul, ":quest_target_fac_str_effect", ":base_reward", -10), (assign, ":result", ":quest_no"), (assign, ":quest_expiration_days", 40), (assign, ":quest_dont_give_again_period", 16), (try_end), (try_end), (try_end), (try_begin), (neq, ":result", -1), (try_begin), (ge, ":quest_target_center", 0), (store_faction_of_party, ":quest_target_faction", ":quest_target_center"), (try_end), (quest_set_slot, ":result", slot_quest_target_troop, ":quest_target_troop"), (quest_set_slot, ":result", slot_quest_target_center, ":quest_target_center"), (quest_set_slot, ":result", slot_quest_object_troop, ":quest_object_troop"), (quest_set_slot, ":result", slot_quest_target_faction, ":quest_target_faction"), (quest_set_slot, ":result", slot_quest_object_faction, ":quest_object_faction"), (quest_set_slot, ":result", slot_quest_object_center, ":quest_object_center"), (quest_set_slot, ":result", slot_quest_target_party, ":quest_target_party"), (quest_set_slot, ":result", slot_quest_target_party_template, ":quest_target_party_template"), (quest_set_slot, ":result", slot_quest_target_amount, ":quest_target_amount"), (quest_set_slot, ":result", slot_quest_importance, ":quest_importance"), (quest_set_slot, ":result", slot_quest_xp_reward, ":quest_xp_reward"), (quest_set_slot, ":result", slot_quest_gold_reward, ":quest_gold_reward"), (quest_set_slot, ":result", slot_quest_rank_reward, ":quest_rank_reward"), (quest_set_slot, ":result", slot_quest_giver_fac_str_effect, ":quest_giver_fac_str_effect"), (quest_set_slot, ":result", slot_quest_target_fac_str_effect, ":quest_target_fac_str_effect"), (quest_set_slot, ":result", slot_quest_convince_value, ":quest_convince_value"), (quest_set_slot, ":result", slot_quest_expiration_days, ":quest_expiration_days"), (quest_set_slot, ":result", slot_quest_dont_give_again_period, ":quest_dont_give_again_period"), (quest_set_slot, ":result", slot_quest_current_state, 0), (quest_set_slot, ":result", slot_quest_giver_troop, ":giver_troop"), (quest_set_slot, ":result", slot_quest_giver_center, ":giver_center_no"), (quest_set_slot, ":result", slot_quest_target_dna, ":quest_target_dna"), (quest_set_slot, ":result", slot_quest_target_item, ":quest_target_item"), (try_end), (assign, reg0, ":result"), ]), # script_cf_get_random_enemy_center_within_range # Note that reg0 will NEVER be Henneth Annun # INPUT: arg1 = party_no, arg2 = range (in kms) #OUTPUT: reg0 = center_no, reg1 = distance ("cf_get_random_enemy_center_within_range", [ (store_script_param, ":party_no", 1), (store_script_param, ":range", 2), (assign, ":num_centers", 0), (assign, ":dist", 0), (store_faction_of_party, ":faction_no", ":party_no"), (try_for_range, ":cur_center", centers_begin, centers_end), (neq, ":cur_center", "p_town_henneth_annun"), #Don't allow Henneth Annun to be a target of quests - Kham (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":cur_faction", ":cur_center"), (store_relation, ":cur_relation", ":faction_no", ":cur_faction"), (lt, ":cur_relation", 0), (call_script, "script_get_tld_distance", ":party_no", ":cur_center"), (assign, ":dist", reg0), (le, ":dist", ":range"), (val_add, ":num_centers", 1), (try_end), (gt, ":num_centers", 0), (store_random_in_range, ":random_center", 0, ":num_centers"), (assign, ":end_cond", centers_end), (try_for_range, ":cur_center", centers_begin, ":end_cond"), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (neq, ":cur_center", "p_town_henneth_annun"), #Don't allow Henneth Annun to be a target of quests - Kham (store_faction_of_party, ":cur_faction", ":cur_center"), (store_relation, ":cur_relation", ":faction_no", ":cur_faction"), (lt, ":cur_relation", 0), (call_script, "script_get_tld_distance", ":party_no", ":cur_center"), (assign, ":dist", reg0), (le, ":dist", ":range"), (val_sub, ":random_center", 1), (lt, ":random_center", 0), (assign, ":result", ":cur_center"), (assign, ":end_cond", 0),#break (try_end), (assign, reg0, ":result"), (assign, reg1, ":dist"), ]), # script_cf_faction_get_random_enemy_faction # INPUT: arg1 = faction_no #OUTPUT: reg0 = faction_no (Can fail) ("cf_faction_get_random_enemy_faction", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), (assign, ":count_factions", 0), (try_for_range, ":cur_faction", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active), (store_relation, ":cur_relation", ":faction_no", ":cur_faction"), (le, ":cur_relation", -1), (val_add, ":count_factions", 1), (try_end), (store_random_in_range,":random_faction",0,":count_factions"), (assign, ":count_factions", 0), (try_for_range, ":cur_faction", kingdoms_begin, kingdoms_end), (eq, ":result", -1), (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active), (store_relation, ":cur_relation", ":faction_no", ":cur_faction"), (le, ":cur_relation", -1), (val_add, ":count_factions", 1), (gt, ":count_factions", ":random_faction"), (assign, ":result", ":cur_faction"), (try_end), (neq, ":result", -1), (assign, reg0, ":result"), ]), # script_cf_faction_get_random_friendly_faction # INPUT: arg1 = faction_no #OUTPUT: reg0 = faction_no (Can fail) ("cf_faction_get_random_friendly_faction", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), (assign, ":count_factions", 0), (try_for_range, ":cur_faction", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active), (neq, ":cur_faction", ":faction_no"), (store_relation, ":cur_relation", ":faction_no", ":cur_faction"), (ge, ":cur_relation", 0), (val_add, ":count_factions", 1), (try_end), (store_random_in_range,":random_faction",0,":count_factions"), (assign, ":count_factions", 0), (try_for_range, ":cur_faction", kingdoms_begin, kingdoms_end), (eq, ":result", -1), (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active), (neq, ":cur_faction", ":faction_no"), (store_relation, ":cur_relation", ":faction_no", ":cur_faction"), (ge, ":cur_relation", 0), (val_add, ":count_factions", 1), (gt, ":count_factions", ":random_faction"), (assign, ":result", ":cur_faction"), (try_end), (neq, ":result", -1), (assign, reg0, ":result"), ]), # script_cf_get_random_lord_in_a_center_with_faction # INPUT: arg1 = faction_no #OUTPUT: reg0 = troop_no, Can Fail! reg1 = distance #TLD change: all allied lords, not only faction lords ("cf_get_random_lord_in_a_center_with_faction", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), (assign, ":dist", 0), (assign, ":count_lords", 0), (try_for_range, ":lord_no", heroes_begin, heroes_end), (store_troop_faction, ":lord_faction_no", ":lord_no"), #(eq, ":faction_no", ":lord_faction_no"), (store_relation, ":relation", ":faction_no", ":lord_faction_no"), (ge, ":relation", 0), #TLD: allied lords (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero), #(troop_slot_eq, ":lord_no", slot_troop_is_prisoner, 0), (neg|troop_slot_ge, ":lord_no", slot_troop_prisoner_of_party, 0), (troop_get_slot, ":lord_party", ":lord_no", slot_troop_leaded_party), (ge, ":lord_party", 0), (party_get_attached_to, ":lord_attachment", ":lord_party"), (is_between, ":lord_attachment", centers_begin, centers_end), #is troop in a center? #(store_distance_to_party_from_party, ":dist", "p_main_party", ":lord_attachment"), (call_script, "script_get_tld_distance", "p_main_party", ":lord_attachment"), (assign, ":dist", reg0), (le, ":dist", tld_max_quest_distance), #TLD: not too far (val_add, ":count_lords", 1), (try_end), (store_random_in_range, ":random_lord", 0, ":count_lords"), (assign, ":count_lords", 0), (try_for_range, ":lord_no", heroes_begin, heroes_end), (eq, ":result", -1), (store_troop_faction, ":lord_faction_no", ":lord_no"), #(eq, ":faction_no", ":lord_faction_no"), (store_relation, ":relation", ":faction_no", ":lord_faction_no"), (ge, ":relation", 0), #TLD: allied lords (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero), #(troop_slot_eq, ":lord_no", slot_troop_is_prisoner, 0), (neg|troop_slot_ge, ":lord_no", slot_troop_prisoner_of_party, 0), (troop_get_slot, ":lord_party", ":lord_no", slot_troop_leaded_party), (ge, ":lord_party", 0), (party_get_attached_to, ":lord_attachment", ":lord_party"), (is_between, ":lord_attachment", centers_begin, centers_end), #is troop in a center? #(store_distance_to_party_from_party, ":dist", "p_main_party", ":lord_attachment"), (call_script, "script_get_tld_distance", "p_main_party", ":lord_attachment"), (assign, ":dist", reg0), (le, ":dist", tld_max_quest_distance), #TLD: not too far (val_add, ":count_lords", 1), (lt, ":random_lord", ":count_lords"), (assign, ":result", ":lord_no"), (try_end), (neq, ":result", -1), (assign, reg0, ":result"), (assign, reg1, ":dist"), ]), # script_cf_get_random_lord_except_king_with_faction # Input: arg1 = faction_no # Output: reg0 = troop_no, Can Fail! ("cf_get_random_lord_except_king_with_faction", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), (assign, ":count_lords", 0), (try_for_range, ":lord_no", heroes_begin, heroes_end), (store_troop_faction, ":lord_faction_no", ":lord_no"), (eq, ":faction_no", ":lord_faction_no"), (neg|faction_slot_eq, ":faction_no", slot_faction_leader, ":lord_no"), (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero), #(troop_slot_eq, ":lord_no", slot_troop_is_prisoner, 0), (neg|troop_slot_ge, ":lord_no", slot_troop_prisoner_of_party, 0), (troop_get_slot, ":lord_party", ":lord_no", slot_troop_leaded_party), (ge, ":lord_party", 0), (val_add, ":count_lords", 1), (try_end), (store_random_in_range, ":random_lord", 0, ":count_lords"), (assign, ":count_lords", 0), (try_for_range, ":lord_no", heroes_begin, heroes_end), (eq, ":result", -1), (store_troop_faction, ":lord_faction_no", ":lord_no"), (eq, ":faction_no", ":lord_faction_no"), (neg|faction_slot_eq, ":faction_no", slot_faction_leader, ":lord_no"), (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero), #(troop_slot_eq, ":lord_no", slot_troop_is_prisoner, 0), (neg|troop_slot_ge, ":lord_no", slot_troop_prisoner_of_party, 0), (troop_get_slot, ":lord_party", ":lord_no", slot_troop_leaded_party), (ge, ":lord_party", 0), (val_add, ":count_lords", 1), (lt, ":random_lord", ":count_lords"), (assign, ":result", ":lord_no"), (try_end), (neq, ":result", -1), (assign, reg0, ":result"), ]), # script_cf_get_random_lord_from_enemy_faction_in_a_center # Input: arg1 = faction_no # Output: reg0 = troop_no, Can Fail! reg1 = distance #TLD: gets an enemy lord - removed friendly-to-player condition, it will never happen ("cf_get_random_lord_from_enemy_faction_in_a_center", [ (store_script_param_1, ":faction_no"), (assign, ":result", -1), (assign, ":dist", 0), (assign, ":count_lords", 0), (try_for_range, ":lord_no", heroes_begin, heroes_end), (store_troop_faction, ":lord_faction_no", ":lord_no"), (neq, ":lord_faction_no", ":faction_no"), # (store_relation, ":our_relation", ":lord_faction_no", "fac_player_supporters_faction"), (store_relation, ":lord_relation", ":lord_faction_no", ":faction_no"), (lt, ":lord_relation", 0), # (ge, ":our_relation", 0), (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero), #(troop_slot_eq, ":lord_no", slot_troop_is_prisoner, 0), (neg|troop_slot_ge, ":lord_no", slot_troop_prisoner_of_party, 0), (troop_get_slot, ":lord_party", ":lord_no", slot_troop_leaded_party), (ge, ":lord_party", 0), (party_get_attached_to, ":lord_attachment", ":lord_party"), (is_between, ":lord_attachment", centers_begin, centers_end), #is troop in a center? #(store_distance_to_party_from_party, ":dist", "p_main_party", ":lord_attachment"), (call_script, "script_get_tld_distance", "p_main_party", ":lord_attachment"), (assign, ":dist", reg0), (le, ":dist", tld_max_quest_distance), #TLD: not too far (val_add, ":count_lords", 1), (try_end), (store_random_in_range, ":random_lord", 0, ":count_lords"), (assign, ":count_lords", 0), (try_for_range, ":lord_no", heroes_begin, heroes_end), (eq, ":result", -1), (store_troop_faction, ":lord_faction_no", ":lord_no"), (neq, ":lord_faction_no", ":faction_no"), # (store_relation, ":our_relation", ":lord_faction_no", "fac_player_supporters_faction"), (store_relation, ":lord_relation", ":lord_faction_no", ":faction_no"), (lt, ":lord_relation", 0), # (ge, ":our_relation", 0), (troop_slot_eq, ":lord_no", slot_troop_occupation, slto_kingdom_hero), #(troop_slot_eq, ":lord_no", slot_troop_is_prisoner, 0), (neg|troop_slot_ge, ":lord_no", slot_troop_prisoner_of_party, 0), (troop_get_slot, ":lord_party", ":lord_no", slot_troop_leaded_party), (ge, ":lord_party", 0), (party_get_attached_to, ":lord_attachment", ":lord_party"), (is_between, ":lord_attachment", centers_begin, centers_end), #is troop in a center? #(store_distance_to_party_from_party, ":dist", "p_main_party", ":lord_attachment"), (call_script, "script_get_tld_distance", "p_main_party", ":lord_attachment"), (assign, ":dist", reg0), (le, ":dist", tld_max_quest_distance), #TLD: not too far (val_add, ":count_lords", 1), (lt, ":random_lord", ":count_lords"), (assign, ":result", ":lord_no"), (try_end), (neq, ":result", -1), (assign, reg0, ":result"), (assign, reg1, ":dist"), ]), # script_get_closest_center # Input: arg1 = party_no # Output: reg0 = center_no (closest) ("get_closest_center", [ (store_script_param_1, ":party_no"), (assign, ":min_distance", 9999999), (assign, reg0, -1), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_distance_to_party_from_party, ":party_distance", ":party_no", ":center_no"), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, reg0, ":center_no"), (try_end), ]), # script_get_close_landmark (mtarini) MV: corrected typo so searching for script_get_close_landmark works # a landmark is more generic that just a center. Not only towns but every 3D object visibile on the map is a landmark # Input: arg1 = party_no # Output: reg0 = landmark no (closest, max dist 8),. Else -1 ("get_close_landmark", [ (store_script_param_1, ":party_no"), (assign, ":min_distance", 8), # max range of landmarks (assign, reg0, -1), (try_for_range, ":center_no", landmark_begin, landmark_end), (party_is_active, ":center_no"), #MV: Barad Dur caused script errors, probably because it was destroyed (this_or_next|eq, ":center_no", "p_town_erebor"), # erebor looks the same if destroyed (this_or_next|eq, ":center_no", "p_town_isengard"), # iseengard looks the same if destroyed (party_slot_eq, ":center_no", slot_center_destroyed, 0), # destroyed stuff are not landmarks (store_distance_to_party_from_party, ":party_distance", ":party_no", ":center_no"), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, reg0, ":center_no"), (try_end), (try_begin),(eq, reg0, "p_town_minas_tirith"), (assign, ":sight_range", 3.5), #InVain: Slightly reduced, was 4 (else_try), (eq, reg0, "p_town_erebor"), (assign, ":sight_range", 4), (else_try), (eq, reg0, "p_town_isengard"), (assign, ":sight_range", 6), (else_try), (eq, reg0, "p_town_hornburg"), (assign, ":sight_range", 3), #InVain: Customised so we get both the Hornburg landmark and Hemls Deep region scenes. (else_try), (eq, reg0, "p_town_dol_amroth"), (assign, ":sight_range", 5), #InVain (else_try), (eq, reg0, "p_town_umbar_camp"), (assign, ":sight_range", 8), #InVain (else_try), (eq, reg0, "p_town_linhir"), (assign, ":sight_range", 8), #InVain (else_try), (eq, reg0, "p_town_tarnost"), (assign, ":sight_range", 8), #InVain (else_try), (this_or_next|eq, reg0, "p_town_west_osgiliath"), (eq, reg0, "p_town_east_osgiliath"), (assign, ":sight_range", 2.0), #InVain: trying to get this right so that Osgiliath battle scenes only appear when very near on on the Osgiliath map icons, but also on the 'river' between both centers (else_try), (assign, ":sight_range", 3.5),(try_end), # default #InVain made this bigger, was 2.5 (try_begin), (gt, ":min_distance", ":sight_range"), # smaller sigth range of everything but minas thirit (assign, reg0, -1), (try_end), (try_begin),(eq, reg0, -1), # no landmark found (set_fixed_point_multiplier,100.0), (party_get_position, pos10, ":party_no"), (position_get_x,":x",pos10),(position_get_y,":y",pos10), (is_between, ":y", -19130, -18800), (try_begin), (gt, ":x", -2072), (assign, reg0, landmark_great_east_road ), (else_try), (assign, reg0, landmark_old_forest_road ), (try_end), (try_end), ]), # script_cf_store_landmark_description_in_s17 (mtarini) MV: corrected careless copy/paste # a landmark is more generic that just a center. Not only towns but every 3D object visibile on the map is a landmark # Output: s17: the string ("cf_store_landmark_description_in_s17", [ (store_script_param_1, ":landmark"), (ge, ":landmark", 0), (assign, ":ok", 1), (try_begin), (eq, ":landmark", landmark_great_east_road ), (str_store_string, s17, "@near the Great East Road, the abandoned old road"), (else_try), (eq, ":landmark", landmark_old_forest_road ), (str_store_string, s17, "@near what is left of the Old Forest Road, the ancient dwarven path that used to cross the thick forest"), (else_try), (str_store_party_name, s15, ":landmark"), (eq,":landmark","p_hand_isen"), (str_store_string, s17, "@close to the Hand-shaped sign of Saruman, pointing toward the tower of Orthanc"), (else_try), (eq,":landmark","p_town_minas_tirith"), (str_store_string, s17, "@in sight of the majestic City Walls of Minas Tirith, the White City"), #InVain new landmark scenes start (else_try), (eq,":landmark","p_town_edoras"), (str_store_string, s17, "@in sight of Edoras, the capital of Rohan"), (else_try), (eq,":landmark","p_town_hornburg"), (str_store_string, s17, "@in sight of the Hornburg, the great fortress of Rohan"), (else_try), (eq,":landmark","p_town_dol_amroth"), (str_store_string, s17, "@in sight of Dol Amroth, the seat of the Princes of Belfalas"), (else_try), (eq,":landmark","p_town_morannon"), (str_store_string, s17, "@in sight of the Morannon, the Black Gate of Mordor"), (else_try), (eq,":landmark","p_town_dol_guldur"), (str_store_string, s17, "@in sight of Dol Guldur, Sauron's northern fortress"), (else_try), (eq,":landmark","p_town_beorn_house"), (str_store_string, s17, "@on the green pastures and many-flowered meadows surrounding Beorn's House"), (else_try), (eq,":landmark","p_town_moria"), (str_store_string, s17, "@on the shores of Lake Mirrormere, near the East Gate of Moria"), (else_try), (eq,":landmark","p_town_esgaroth"), (str_store_string, s17, "@on the shores of the Long Lake, in sight of Esgaroth, the Laketown"), (else_try), (this_or_next|eq,":landmark","p_town_linhir"), (this_or_next|eq,":landmark","p_town_tarnost"), (eq,":landmark","p_town_umbar_camp"), (str_store_string, s17, "@near the coast of Gondor. You can hear the distant sound of the waves and the cries of the seagulls."), #InVain new landmark scenes end (else_try), (this_or_next|eq,":landmark","p_town_west_osgiliath"), ## Osgiliath - In Vain (eq,":landmark","p_town_east_osgiliath"), (str_store_string, s17, "@in the outskirts of Osgiliath, the former capital of Gondor"), (else_try), (eq,":landmark","p_town_erebor"), (str_store_string, s17, "@in sight of the entrance to Erebor, the dwarven fortress"), (else_try), (eq,":landmark","p_town_isengard"), (str_store_string, s17, "@in sight of the dark Tower of Orthanc"), (else_try), (eq,":landmark","p_old_ford"), (str_store_string, s17, "@near the Old Ford, where the Old Forest Road crosses the River Anduin"), (else_try), (is_between,":landmark",fords_big_begin, fords_big_end), # Anduin fords (str_store_string, s17, "@near a big ford crossing the River {s15}"), (else_try), (is_between,":landmark",fords_small_begin, fords_small_end), # small fords (str_store_string, s17, "@near a small ford crossing the River {s15}"), (else_try), (assign, ":ok", 0), # no good description found (try_end), (eq, ":ok", 1), ]), # script_get_closest_walled_center_of_faction # Input: arg1 = party_no, arg2 = kingdom_no # Output: reg0 = center_no (closest) ("get_closest_center_of_faction", [ (store_script_param_1, ":party_no"), (store_script_param_2, ":kingdom_no"), (assign, ":min_distance", 99999), (assign, ":result", -1), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":faction_no", ":center_no"), (eq, ":faction_no", ":kingdom_no"), (store_distance_to_party_from_party, ":party_distance", ":party_no", ":center_no"), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, ":result", ":center_no"), (try_end), (assign, reg0, ":result"), ]), # script_let_nearby_parties_join_current_battle # Input: arg1 = besiege_mode, arg2 = dont_add_friends # Output: none ("let_nearby_parties_join_current_battle", [ (store_script_param, ":besiege_mode", 1), (store_script_param, ":dont_add_friends", 2), (assign, ":join_distance", 5), #Kham - Changed from 4 (try_begin), (is_currently_night), (assign, ":join_distance", 3), #Kham - Changed from 3 (try_end), (try_for_parties, ":party_no"), (neq, ":party_no", "p_main_party"), (neq, ":party_no", "$g_enemy_party"), (party_is_active, ":party_no"), # Warband fix (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 (get_party_ai_behavior, ":behavior", ":party_no"), (neq, ":behavior", ai_bhvr_in_town), (neg|party_slot_eq, ":party_no", slot_party_type, spt_cattle_herd), #TLD: "cattle" won't join (assign, ":caravan_continue", 1), (try_begin), (party_get_template_id, ":template_type", ":party_no"), (this_or_next|party_slot_eq, ":party_no", slot_party_type, spt_kingdom_caravan), #Caravans (is_between, ":template_type", "pt_gondor_caravan", "pt_gondor_p_train"), #again, caravans #(display_message, "@Caravan - Check", color_bad_news), (party_get_attached_to, ":attached_to_party", ":party_no"), (this_or_next|party_is_in_any_town, ":party_no"), (is_between, ":attached_to_party", centers_begin, centers_end), (assign, ":caravan_continue", 0), #(display_message, "@Caravan - Denied", color_good_news), (try_end), (eq, ":caravan_continue", 1), (store_distance_to_party_from_party, ":distance", ":party_no", "p_main_party"), (lt, ":distance", ":join_distance"), (store_faction_of_party, ":faction_no", ":party_no"), (store_faction_of_party, ":enemy_faction", "$g_enemy_party"), (try_begin), (eq, ":faction_no", "fac_player_supporters_faction"), (assign, ":reln_with_player", 100), (else_try), (store_relation, ":reln_with_player", ":faction_no", "fac_player_supporters_faction"), (try_end), (try_begin), (eq, ":faction_no", ":enemy_faction"), (assign, ":reln_with_enemy", 100), (else_try), (store_relation, ":reln_with_enemy", ":faction_no", ":enemy_faction"), (try_end), (assign, ":deserters", 0), (try_begin), (eq, ":enemy_faction", "fac_deserters"), (assign, ":deserters", 1), (try_end), (assign, ":enemy_side", 1), (try_begin), (neq, "$g_enemy_party", "$g_encountered_party"), (assign, ":enemy_side", 2), (try_end), (try_begin), (eq, ":besiege_mode", 0), (lt, ":reln_with_player", 0), (gt, ":reln_with_enemy", 0), (party_get_slot, ":party_type", ":party_no", slot_party_type), #(eq, ":party_type", spt_kingdom_hero_party), #TLD: all parties can join (neq, ":party_type", spt_town), #...except towns (neq, ":party_type", spt_kingdom_caravan), #...and caravans #(get_party_ai_behavior, ":ai_bhvr", ":party_no"), #(neq, ":ai_bhvr", ai_bhvr_avoid_party), - Kham Removed (Nov 2018) (party_quick_attach_to_current_battle, ":party_no", ":enemy_side"), #attach as enemy (str_store_party_name, s1, ":party_no"), (display_message, "str_s1_joined_battle_enemy", color_bad_news), (else_try), (eq, ":dont_add_friends", 0), (gt, ":reln_with_player", 0), (this_or_next|lt, ":reln_with_enemy", 0), (eq, ":deserters", 1), # Added Help against Deserters (Nov 2018) (assign, ":do_join", 1), (try_begin), (eq, ":besiege_mode", 1), (assign, ":do_join", 0), # (eq, ":faction_no", "$players_kingdom"), # (faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"), # (assign, ":do_join", 1), (try_end), (eq, ":do_join", 1), (party_get_slot, ":party_type", ":party_no"), #(eq, ":party_type", spt_kingdom_hero_party), #TLD: all parties can join (neq, ":party_type", spt_town), #...except towns (neq, ":party_type", spt_kingdom_caravan), #...and caravans (quest_get_slot, ":escorted_caravan", "qst_escort_merchant_caravan", slot_quest_target_party), #check for caravan quest (neq, ":party_no", ":escorted_caravan"), #MV commented out personal relations #(party_stack_get_troop_id, ":leader", ":party_no", 0), # (troop_get_slot, ":player_relation", ":leader", slot_troop_player_relation), #(call_script, "script_troop_get_player_relation", ":leader"), #(assign, ":player_relation", reg0), #(ge, ":player_relation", 0), (party_quick_attach_to_current_battle, ":party_no", 0), #attach as friend (str_store_party_name, s1, ":party_no"), (display_message, "str_s1_joined_battle_friend", color_good_news), (try_end), (try_end), ]), # script_party_wound_all_members # Input: arg1 = party_no ("party_wound_all_members_aux", [ (store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_stacks",":party_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party_no",":i_stack"), (try_begin), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size",":party_no",":i_stack"), (party_wound_members, ":party_no", ":stack_troop", ":stack_size"), (else_try), (troop_set_health, ":stack_troop", 0), (try_end), (try_end), (party_get_num_attached_parties, ":num_attached_parties", ":party_no"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":party_no", ":attached_party_rank"), (call_script, "script_party_wound_all_members_aux", ":attached_party"), (try_end), ]), # script_party_wound_all_members. identical to script_party_wound_all_members # Input: arg1 = party_no ("party_wound_all_members", [ (store_script_param_1, ":party_no"), (call_script, "script_party_wound_all_members_aux", ":party_no"), ]), # script_calculate_battle_advantage # Kham -changes below script making advantage not only quantity but also quality dependant, tactics is made a bit more important too + orc bonus # Output: reg0 = battle advantage ("calculate_battle_advantage", [ (call_script, "script_tld_party_count_strength", "p_collective_friends"), #Kham - Changed script_party_count_fit_for_battle with new script (assign, ":friend_count", reg0), (party_get_skill_level, ":player_party_tactics", "p_main_party", skl_tactics), (party_get_skill_level, ":ally_party_tactics", "p_collective_friends", skl_tactics), (val_max, ":player_party_tactics", ":ally_party_tactics"), (call_script, "script_tld_party_count_strength", "p_collective_enemy"), #Kham - Changed script_party_count_fit_for_battle with new script (assign, "$enemy_count1", reg0), ## of enemies also for scenes ## TLD, total number of combatants, needed for random scene generation, GA (store_add, "$number_of_combatants", ":friend_count","$enemy_count1"), (party_get_skill_level, ":enemy_party_tactics", "p_collective_enemy", skl_tactics), (val_add, ":friend_count", 1), (val_add, "$enemy_count1", 1), #Kham - Orc Bonus for Battle Advantage (call_script, "script_party_get_dominant_race", "p_collective_friends"), (assign, ":raceFriends", reg0), (call_script, "script_party_get_dominant_race", "p_collective_enemy"), (assign, ":raceEnemy", reg0), (try_begin), (is_between, ":raceFriends", tf_orc_begin, tf_orc_end), (assign, ":orcFriends",1), (else_try), (is_between, ":raceEnemy", tf_orc_begin, tf_orc_end), (assign, ":orcEnemy",1), (else_try), (assign, ":orcFriends",0), (assign, ":orcEnemy", 0), (try_end), (try_begin), (ge, ":friend_count", "$enemy_count1"), (val_mul, ":friend_count", 100), (store_div, ":ratio", ":friend_count", "$enemy_count1"), (try_begin), (eq, ":orcFriends",1), (store_sub, ":raw_advantage", ":ratio", 75), (else_try), (store_sub, ":raw_advantage", ":ratio", 100), (try_end), (else_try), (val_mul, "$enemy_count1", 100), (store_div, ":ratio", "$enemy_count1", ":friend_count"), (try_begin), (eq, ":orcEnemy",1), (store_sub, ":raw_advantage", 75, ":ratio"), (else_try), (store_sub, ":raw_advantage", 100, ":ratio"), (try_end), (try_end), (val_mul, ":raw_advantage", 2), (try_begin), (eq, ":orcFriends",1), (val_mul, ":player_party_tactics", 50), (else_try), (val_mul, ":player_party_tactics", 30), (try_end), (try_begin), (eq, ":orcEnemy",1), (val_mul, ":enemy_party_tactics", 50), (else_try), (val_mul, ":enemy_party_tactics", 30), (try_end), (val_add, ":raw_advantage", ":player_party_tactics"), (val_sub, ":raw_advantage", ":enemy_party_tactics"), (val_div, ":raw_advantage", 100), (assign, reg0, ":raw_advantage"), #Kham - Colour Battle Advantage (try_begin), (gt, reg0, 0), (assign, ":color", color_good_news), (else_try), (eq, reg0, 0), (assign, ":color", 0xFF808080), (else_try), (assign, ":color", color_bad_news), (try_end), (display_message, "@Battle Advantage = {reg0}.", ":color"), ]), # script_cf_check_enemies_nearby # Input: none # Output: none, fails when enemies are nearby ("cf_check_enemies_nearby", [ (get_player_agent_no, ":player_agent"), (agent_is_alive, ":player_agent"), (agent_get_position, pos1, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (assign, ":result", 0), (set_fixed_point_multiplier, 100), (try_for_agents,":cur_agent"), (neq, ":cur_agent", ":player_agent"), (agent_is_alive, ":cur_agent"), (agent_is_human, ":cur_agent"), (agent_get_position, pos2, ":cur_agent"), (get_distance_between_positions, ":cur_distance", pos1, pos2), (le, ":cur_distance", 1500), #15 meters #(neg|agent_is_ally, ":cur_agent"), (agent_get_team, ":team", ":cur_agent"), (teams_are_enemies, ":team", ":player_team"), (assign, ":result", 1), # (agent_get_troop_id, ":troop", ":cur_agent"), #keep for further testing # (str_store_troop_name, s1, ":troop"), # (display_message, "@enemy {s1} found"), (try_end), (eq, ":result", 0), ]), # script_get_heroes_attached_to_center_aux # For internal use only ("get_heroes_attached_to_center_aux", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":party_no_to_collect_heroes"), (party_get_num_companion_stacks, ":num_stacks",":center_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":center_no",":i_stack"), (troop_is_hero, ":stack_troop"), (party_add_members, ":party_no_to_collect_heroes", ":stack_troop", 1), (try_end), (party_get_num_attached_parties, ":num_attached_parties", ":center_no"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":center_no", ":attached_party_rank"), (call_script, "script_get_heroes_attached_to_center_aux", ":attached_party", ":party_no_to_collect_heroes"), (try_end), ]), # script_get_heroes_attached_to_center # Input: arg1 = center_no, arg2 = party_no_to_collect_heroes # Output: none, adds heroes to the party_no_to_collect_heroes party ("get_heroes_attached_to_center", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":party_no_to_collect_heroes"), #swy-- "p_temp_party" is often used as arg2 in here. (party_clear, "p_temp_party_2"), (party_clear, ":party_no_to_collect_heroes"), (call_script, "script_get_heroes_attached_to_center_aux", ":center_no", "p_temp_party_2"), #swy-- reorders the stack entries to make faction leaders (if any) always the first. # -- this is important to avoid funny situations in throne rooms, specially with # -- Thranduil/silvan elf commanders spawning in his throne with him in his halls! # -- # (this basically cherrypicks our leader from a temp party, if any, moving it to the asked destination and then copying the rest) (store_faction_of_party, ":center_fac", ":center_no"), (faction_get_slot, ":trp_leader", ":center_fac", slot_faction_leader), (party_get_num_companion_stacks, ":num_stacks", "p_temp_party_2"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", "p_temp_party_2", ":i_stack"), #-- (eq, ":stack_troop", ":trp_leader"), (party_add_members, ":party_no_to_collect_heroes", ":stack_troop", 1), (party_remove_members, "p_temp_party_2", ":stack_troop", 1), (try_end), #swy-- we've singled out and moved the leader to the emptied final party beforehand, # -- copy the rest of heroes using this handy helper function, boom! reordered! (assign, ":mh_backup", "$g_move_heroes"), (assign, "$g_move_heroes", 1), #parameter-like global var needed for the helper script to copy heroes too, we reset it back when finished... for reasons. (call_script, "script_party_add_party_companions", ":party_no_to_collect_heroes", "p_temp_party_2"), (assign, "$g_move_heroes", ":mh_backup"), ]), # script_get_heroes_attached_to_center_as_prisoner_aux # For internal use only ("get_heroes_attached_to_center_as_prisoner_aux", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":party_no_to_collect_heroes"), (party_get_num_prisoner_stacks, ":num_stacks",":center_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop",":center_no",":i_stack"), (troop_is_hero, ":stack_troop"), (party_add_members, ":party_no_to_collect_heroes", ":stack_troop", 1), (try_end), (party_get_num_attached_parties, ":num_attached_parties", ":center_no"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":center_no", ":attached_party_rank"), (call_script, "script_get_heroes_attached_to_center_as_prisoner_aux", ":attached_party", ":party_no_to_collect_heroes"), (try_end), ]), # script_get_heroes_attached_to_center_as_prisoner # Input: arg1 = center_no, arg2 = party_no_to_collect_heroes # Output: none, adds heroes to the party_no_to_collect_heroes party ("get_heroes_attached_to_center_as_prisoner", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":party_no_to_collect_heroes"), (party_clear, ":party_no_to_collect_heroes"), (call_script, "script_get_heroes_attached_to_center_as_prisoner_aux", ":center_no", ":party_no_to_collect_heroes"), ]), # script_give_center_to_faction # Input: arg1 = center_no, arg2 = faction ("give_center_to_faction", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":faction_no"), # first remove any volunteers - Kham #(party_get_slot, ":volunteers", ":center_no", slot_town_volunteer_pt), #(try_begin), # (gt, ":volunteers", 0), # (party_is_active, ":volunteers"), # (party_detach, ":volunteers"), # (call_script, "script_safe_remove_party", ":volunteers"), #(try_end), (call_script,"script_delete_volunteers_party",":center_no"), (try_begin), (check_quest_active, "qst_join_siege_with_army"), (quest_slot_eq, "qst_join_siege_with_army", slot_quest_target_center, ":center_no"), (call_script, "script_abort_quest", "qst_join_siege_with_army", 0), #Reactivating follow army quest (faction_get_slot, ":faction_marshall", "$players_kingdom", slot_faction_marshall), (str_store_troop_name_link, s9, ":faction_marshall"), (setup_quest_text, "qst_follow_army"), (str_store_string, s2, "@{s9} wants you to resume following his army until further notice."), (call_script, "script_start_quest", "qst_follow_army", ":faction_marshall"), #(assign, "$g_player_follow_army_warnings", 0), (try_end), #(store_faction_of_party, ":old_faction", ":center_no"), (call_script, "script_give_center_to_faction_aux", ":center_no", ":faction_no"), #(call_script, "script_update_village_market_towns"), # If this is Edoras and Hornburg is still Rohan's, move capital #(try_begin), # (eq, ":center_no", "p_town_edoras"), # (eq, ":old_faction", "fac_rohan"), # (faction_slot_eq, "fac_rohan", slot_faction_capital, "p_town_edoras"), # (store_faction_of_party, ":hornburg_faction", "p_town_hornburg"), # (eq, ":hornburg_faction", "fac_rohan"), # (faction_set_slot, "fac_rohan", slot_faction_capital, "p_town_hornburg"), # (display_message, "@Rohan capital moved from Edoras to Hornburg!"), #(try_end), (try_for_range, ":cur_faction", kingdoms_begin, kingdoms_end), (call_script, "script_faction_recalculate_strength", ":cur_faction"), (try_end), (party_get_slot, ":theater", ":center_no", slot_center_theater), (assign, "$g_recalculate_ais", ":theater"), ]), # script_give_center_to_faction_aux # Input: arg1 = center_no, arg2 = faction ("give_center_to_faction_aux", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":faction_no"), (store_faction_of_party, ":old_faction", ":center_no"), (party_set_slot, ":center_no", slot_center_ex_faction, ":old_faction"), (party_set_faction, ":center_no", ":faction_no"), (call_script,"script_cancel_all_related_center_quest",":center_no"), ## Not needed in TLD - Kham #(try_begin), # (party_slot_eq, ":center_no", slot_party_type, spt_village), # (party_get_slot, ":farmer_party", ":center_no", slot_village_farmer_party), # (gt, ":farmer_party", 0), # (party_is_active, ":farmer_party"), # (party_set_faction, ":farmer_party", ":faction_no"), #(try_end), (party_get_slot, ":old_town_lord", ":center_no", slot_town_lord), #TLD changes: give captured centers to kings, place faction banner (faction_get_slot, ":king", ":faction_no", slot_faction_leader), (party_set_slot, ":center_no", slot_town_lord, ":king"), (faction_get_slot,":faction_banner",":faction_no",slot_faction_party_map_banner), (party_set_banner_icon, ":center_no", ":faction_banner"), #TLD: change NPCs and walkers - since I'm lazy, I'll just give them clones of the faction capital NPCs and walkers (faction_get_slot, ":capital", ":faction_no", slot_faction_advance_camp), #InVain: use advance camp instead = military walkers, no elders (captured centers are just military bases for the captors) (party_get_slot, ":value", ":capital", slot_town_elder), (party_set_slot, ":center_no", slot_town_elder, ":value"), (party_get_slot, ":value", ":capital", slot_town_captain), (party_set_slot, ":center_no", slot_town_captain, ":value"), (party_get_slot, ":value", ":capital", slot_town_weaponsmith), (party_set_slot, ":center_no", slot_town_weaponsmith, ":value"), (party_get_slot, ":value", ":capital", slot_town_merchant), (party_set_slot, ":center_no", slot_town_merchant, ":value"), (party_get_slot, ":value", ":capital", slot_town_recruits_pt), (party_set_slot, ":center_no", slot_town_recruits_pt, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_0_troop), (party_set_slot, ":center_no", slot_center_walker_0_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_1_troop), (party_set_slot, ":center_no", slot_center_walker_1_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_2_troop), (party_set_slot, ":center_no", slot_center_walker_2_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_3_troop), (party_set_slot, ":center_no", slot_center_walker_3_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_4_troop), (party_set_slot, ":center_no", slot_center_walker_4_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_5_troop), (party_set_slot, ":center_no", slot_center_walker_5_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_6_troop), (party_set_slot, ":center_no", slot_center_walker_6_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_7_troop), (party_set_slot, ":center_no", slot_center_walker_7_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_8_troop), (party_set_slot, ":center_no", slot_center_walker_8_troop, ":value"), (party_get_slot, ":value", ":capital", slot_center_walker_9_troop), (party_set_slot, ":center_no", slot_center_walker_9_troop, ":value"), (faction_get_slot, ":value", ":faction_no", slot_faction_guard_troop), (party_set_slot, ":center_no", slot_town_guard_troop, ":value"), (faction_get_slot, ":value", ":faction_no", slot_faction_archer_troop), (party_set_slot, ":center_no", slot_town_archer_troop, ":value"), (faction_get_slot, ":value", ":faction_no", slot_faction_castle_guard_troop), (party_set_slot, ":center_no", slot_town_castle_guard_troop, ":value"), # Change center spawns to be the same as for faction advance camps, only if there was such a spawn before (faction_get_slot, ":adv_camp", ":faction_no", slot_faction_advance_camp), (try_begin), (party_get_slot, ":old_value", ":center_no", slot_center_spawn_scouts), (gt, ":old_value", 0), (party_get_slot, ":value", ":adv_camp", slot_center_spawn_scouts), (party_set_slot, ":center_no", slot_center_spawn_scouts, ":value"), (try_end), (try_begin), (party_get_slot, ":old_value", ":center_no", slot_center_spawn_raiders), (gt, ":old_value", 0), (party_get_slot, ":value", ":adv_camp", slot_center_spawn_raiders), (party_set_slot, ":center_no", slot_center_spawn_raiders, ":value"), (try_end), (try_begin), (party_get_slot, ":old_value", ":center_no", slot_center_spawn_patrol), (gt, ":old_value", 0), (party_get_slot, ":value", ":adv_camp", slot_center_spawn_patrol), (party_set_slot, ":center_no", slot_center_spawn_patrol, ":value"), (try_end), (try_begin), (party_get_slot, ":old_value", ":center_no", slot_center_spawn_caravan), (gt, ":old_value", 0), (party_get_slot, ":value", ":adv_camp", slot_center_spawn_caravan), (party_set_slot, ":center_no", slot_center_spawn_caravan, ":value"), (try_end), #reduce income to 5 if non-zero (party_get_slot, ":strength_income", ":center_no", slot_center_strength_income), (val_min, ":strength_income", str_income_low), (party_set_slot, ":center_no", slot_center_strength_income, ":strength_income"), #TLD: old faction loses faction strength # (faction_get_slot,":strength",":old_faction",slot_faction_strength_tmp), # (val_sub, ":strength", ws_center_vp), # (faction_set_slot,":old_faction",slot_faction_strength_tmp,":strength"), # #debug stuff # (faction_get_slot, ":debug_loss", ":old_faction", slot_faction_debug_str_loss), # (val_add, ":debug_loss", ws_center_vp), # (faction_set_slot, ":old_faction", slot_faction_debug_str_loss, ":debug_loss"), # #TLD: conquering faction gains faction strength # (faction_get_slot,":winner_strength",":faction_no",slot_faction_strength_tmp), # (store_div, ":win_value", ws_center_vp, 2), #this formula could be balanced after playtesting # (val_add, ":winner_strength", ":win_value"), # (faction_set_slot,":faction_no",slot_faction_strength_tmp,":winner_strength"), # #debug stuff # (faction_get_slot, ":debug_gain", ":faction_no", slot_faction_debug_str_gain), # (val_add, ":debug_gain", ":win_value"), # (faction_set_slot, ":faction_no", slot_faction_debug_str_gain, ":debug_gain"), # #debug # (try_begin), # (eq, cheat_switch, 1), # (assign,reg0,ws_center_vp), # (assign,reg1,":strength"), # (assign,reg2,":win_value"), # (assign,reg3,":winner_strength"), # (str_store_faction_name,s1,":old_faction"), # (str_store_faction_name,s2,":faction_no"), # (str_store_party_name,s3,":center_no"), # (display_message,"@DEBUG: {s3} captured: {s1} strength -{reg0} to {reg1}, {s2} strength +{reg2} to {reg3}."), # (try_end), (call_script, "script_update_faction_notes", ":old_faction"), (call_script, "script_update_faction_notes", ":faction_no"), (call_script, "script_update_center_notes", ":center_no"), (call_script, "script_update_troop_notes", ":king"), # TLD (try_begin), (ge, ":old_town_lord", 0), (call_script, "script_update_troop_notes", ":old_town_lord"), (try_end), #(try_for_range, ":other_center", centers_begin, centers_end), # (party_is_active, ":other_center"), #TLD # (neq, ":other_center", ":center_no"), # (party_slot_eq, ":other_center", slot_center_destroyed, 0), # TLD # (party_slot_eq, ":other_center", slot_village_bound_center, ":center_no"), #TLD - Removed (kham) # (call_script, "script_give_center_to_faction_aux", ":other_center", ":faction_no"), #(try_end), ]), # script_give_center_to_lord # in TLD, used only at inital setup # Input: arg1 = center_no, arg2 = lord_troop, arg3 = add_garrison_to_center ("give_center_to_lord", [ (store_script_param, ":center_no", 1), (store_script_param, ":lord_troop_id", 2), (store_script_param, ":add_garrison", 3), (party_get_slot, ":old_lord_troop_id", ":center_no", slot_town_lord), (store_troop_faction, ":lord_troop_faction", ":lord_troop_id"), (party_set_faction, ":center_no", ":lord_troop_faction"), (party_set_slot, ":center_no", slot_town_lord, ":lord_troop_id"), (call_script, "script_update_troop_notes", ":lord_troop_id"), (call_script, "script_update_center_notes", ":center_no"), (call_script, "script_update_faction_notes", ":lord_troop_faction"), (try_begin), (ge, ":old_lord_troop_id", 0), (call_script, "script_update_troop_notes", ":old_lord_troop_id"), (store_troop_faction, ":old_lord_troop_faction", ":old_lord_troop_id"), (call_script, "script_update_faction_notes", ":old_lord_troop_faction"), (try_end), (try_begin), (eq, ":add_garrison", 1), (this_or_next|party_slot_eq, ":center_no", slot_party_type, spt_town), (party_slot_eq, ":center_no", slot_party_type, spt_castle), (assign, ":garrison_strength", 3), (try_begin), (party_slot_eq, ":center_no", slot_party_type, spt_town), (assign, ":garrison_strength", 9), (try_end), (try_for_range, ":unused", 0, ":garrison_strength"), (call_script, "script_cf_reinforce_party", ":center_no"), (try_end), ## ADD some XP initially (try_for_range, ":unused", 0, 7), (store_mul, ":xp_range_min", 150, ":garrison_strength"), (store_mul, ":xp_range_max", 200, ":garrison_strength"), (store_random_in_range, ":xp", ":xp_range_min", ":xp_range_max"), (party_upgrade_with_xp, ":center_no", ":xp", 0), (try_end), (try_end), ]), # script_cf_get_random_enemy_center # Input: arg1 = party_no # Output: reg0 = center_no ("cf_get_random_enemy_center", [ (store_script_param_1, ":party_no"), (assign, ":result", -1), (assign, ":total_enemy_centers", 0), (store_faction_of_party, ":party_faction", ":party_no"), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":center_faction", ":center_no"), (store_relation, ":party_relation", ":center_faction", ":party_faction"), (lt, ":party_relation", 0), (val_add, ":total_enemy_centers", 1), (try_end), (gt, ":total_enemy_centers", 0), (store_random_in_range, ":random_center", 0, ":total_enemy_centers"), (assign, ":total_enemy_centers", 0), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (eq, ":result", -1), (store_faction_of_party, ":center_faction", ":center_no"), (store_relation, ":party_relation", ":center_faction", ":party_faction"), (lt, ":party_relation", 0), (val_sub, ":random_center", 1), (lt, ":random_center", 0), (assign, ":result", ":center_no"), (try_end), (assign, reg0, ":result"), ]), # script_find_travel_location # Input: arg1 = center_no # Output: reg0 = new_center_no (to travel within the same faction) ("find_travel_location", [ (store_script_param_1, ":center_no"), (store_faction_of_party, ":faction_no", ":center_no"), (assign, ":total_weight", 0), (try_for_range, ":cur_center_no", centers_begin, centers_end), (party_is_active, ":cur_center_no"), #TLD (party_slot_eq, ":cur_center_no", slot_center_destroyed, 0), # TLD (neq, ":center_no", ":cur_center_no"), (store_faction_of_party, ":center_faction_no", ":cur_center_no"), (eq, ":faction_no", ":center_faction_no"), #(store_distance_to_party_from_party, ":cur_distance", ":center_no", ":cur_center_no"), (call_script, "script_get_tld_distance", ":center_no", ":cur_center_no"), (assign, ":cur_distance", reg0), (val_add, ":cur_distance", 1), (assign, ":new_weight", 100000), (val_div, ":new_weight", ":cur_distance"), (val_add, ":total_weight", ":new_weight"), (try_end), (assign, reg0, -1), (try_begin), (eq, ":total_weight", 0), (else_try), (store_random_in_range, ":random_weight", 0 , ":total_weight"), (assign, ":total_weight", 0), (assign, ":done", 0), (try_for_range, ":cur_center_no", centers_begin, centers_end), (party_is_active, ":cur_center_no"), #TLD (party_slot_eq, ":cur_center_no", slot_center_destroyed, 0), # TLD (eq, ":done", 0), (neq, ":center_no", ":cur_center_no"), (store_faction_of_party, ":center_faction_no", ":cur_center_no"), (eq, ":faction_no", ":center_faction_no"), #(store_distance_to_party_from_party, ":cur_distance", ":center_no", ":cur_center_no"), (call_script, "script_get_tld_distance", ":center_no", ":cur_center_no"), (assign, ":cur_distance", reg0), (val_add, ":cur_distance", 1), (assign, ":new_weight", 100000), (val_div, ":new_weight", ":cur_distance"), (val_add, ":total_weight", ":new_weight"), (lt, ":random_weight", ":total_weight"), (assign, reg0, ":cur_center_no"), (assign, ":done", 1), (try_end), (try_end), ]), # script_get_relation_between_parties # Input: arg1 = party_no_1, arg2 = party_no_2 # Output: reg0 = relation between parties ("get_relation_between_parties", [ (store_script_param_1, ":party_no_1"), (store_script_param_2, ":party_no_2"), (store_faction_of_party, ":party_no_1_faction", ":party_no_1"), (store_faction_of_party, ":party_no_2_faction", ":party_no_2"), (try_begin), (eq, ":party_no_1_faction", ":party_no_2_faction"), (assign, reg0, 100), (else_try), (store_relation, ":relation", ":party_no_1_faction", ":party_no_2_faction"), (assign, reg0, ":relation"), (try_end), ]), # script_cf_reinforce_party # Input: arg1 = party_no, # Output: none # Adds reinforcement to party according to its type and faction ("cf_reinforce_party", [ (store_script_param_1, ":party_no"), (store_faction_of_party, ":party_faction", ":party_no"), (party_get_slot, ":party_type",":party_no", slot_party_type), (try_begin), (eq, ":party_no", "p_main_party"), #for testing, but doesn't hurt (assign, ":party_type", spt_kingdom_hero_party), (assign, ":party_faction", "$players_kingdom"), (else_try), (eq, ":party_faction", "fac_player_supporters_faction"), (party_get_slot, ":town_lord", ":party_no", slot_town_lord), (try_begin), (gt, ":town_lord", 0), (troop_get_slot, ":party_faction", ":town_lord", slot_troop_original_faction), (else_try), (party_get_slot, ":party_faction", ":party_no", slot_center_original_faction), (try_end), (try_end), (faction_get_slot, ":party_template_a", ":party_faction", slot_faction_reinforcements_a), (faction_get_slot, ":party_template_b", ":party_faction", slot_faction_reinforcements_b), (faction_get_slot, ":party_template_c", ":party_faction", slot_faction_reinforcements_c), # For Gondor subfaction garrisons, no harm for others (town_reinf=faction_reinf) (try_begin), (eq, ":party_type", spt_town), (eq, ":party_faction", "fac_gondor"), (party_get_slot, ":subfac", ":party_no", slot_party_subfaction), (neq, ":subfac", 0), (party_get_slot, ":party_template_a", ":party_no", slot_town_reinforcements_a), (party_get_slot, ":party_template_b", ":party_no", slot_town_reinforcements_b), (party_get_slot, ":party_template_c", ":party_no", slot_town_reinforcements_c), (try_end), (store_random_in_range, ":rand", 0, 100), # A, B, or C (assign, ":offset", 0), # (MV: did) uncomment the following block to make a 8% of mixing between gondor subfactions (try_begin), (eq, ":party_faction", "fac_gondor"), # only in gondor.... (store_random_in_range, ":rand2", 0, 100), (le, ":rand2", 20), # 20% of times... was 8% (party_get_slot, ":subfac", ":party_no", slot_party_subfaction), (try_begin), #Gondor subfaction lords get subfaction reinforcements, subfaction towns get Gondor reinforcements... (neq, ":subfac", 0), (try_begin), (eq, ":party_type", spt_town), (faction_get_slot, ":party_template_a", ":party_faction", slot_faction_reinforcements_a), (faction_get_slot, ":party_template_b", ":party_faction", slot_faction_reinforcements_b), (faction_get_slot, ":party_template_c", ":party_faction", slot_faction_reinforcements_c), (else_try), (store_mul, ":offset", ":subfac", 3), (try_end), (else_try), #regular Gondor parties get a random subfaction reinforcement... (store_random_in_range, ":offset", 1, len(subfaction_data)+1 ), (val_mul, ":offset", 3), #(val_mul,":rand",75),(val_div,":rand",100), # but cannot pick "C" - MV: let them anyway (try_end), (try_end), (assign, ":party_template", 0), #MV/Native: different reinforcements for towns and heroes #InVain: Changed towns from 60/35/5 to 30/60/10, to allow stronger and more archer-heavy garrisons (try_begin), (eq, ":party_type", spt_town), (try_begin), (lt, ":rand", 30), (store_add, ":party_template", ":party_template_a", ":offset"), # base tier 1 and 2 troops (else_try), (lt, ":rand", 90), (store_add, ":party_template", ":party_template_b", ":offset"), # tier 3 archers mixed with other tier 3 troops and tier 2 archers (else_try), (store_add, ":party_template", ":party_template_c", ":offset"), # tier 4 troop mix (try_end), (else_try), #(eq, ":party_type", spt_kingdom_hero_party), #MV: hosts or guardians (try_begin), (lt, ":rand", 50), (store_add, ":party_template", ":party_template_a", ":offset"), # base tier 1 and 2 troops (else_try), (lt, ":rand", 80), (store_add, ":party_template", ":party_template_b", ":offset"), # tier 3 archers mixed with other tier 3 troops and tier 2 archers (else_try), (store_add, ":party_template", ":party_template_c", ":offset"), # tier 4 troop mix (try_end), (try_end), (try_begin), (eq, ":party_no", "p_town_minas_tirith"), # special minas tirith rule,,, (store_random_in_range, ":rand2", 0, 100), (le, ":rand2", 10), # 20% of times... #InVain lowered probability because Tower Guards are just too damn strong... (assign, ":party_template", "pt_gondor_reinf_d"), (try_end), (try_begin), #InVain: Piggyback troll recruitment for towns (eq, ":party_type", spt_town), (faction_get_slot, ":fac_troll", ":party_faction", slot_faction_troll_troop), (gt, ":fac_troll", 0), #check for troll factions (troop_get_upgrade_troop, ":fac_troll_up", ":fac_troll", 0), (troop_get_slot, ":armoured", ":fac_troll_up", slot_troop_troll_armoured_variant), (try_begin), (eq, ":party_faction", fac_gundabad), (assign, ":armoured", ":fac_troll_up"), (try_end), (party_get_num_companions, ":party_size", ":party_no"), (store_div, ":max_trolls", ":party_size", 100), (store_div, ":max_armoured_trolls", ":party_size", 150), (party_count_members_of_type,":num_base_trolls", ":party_no", ":fac_troll"), (lt, ":num_base_trolls", ":max_trolls"), (party_add_members, ":party_no", ":fac_troll", 1), (this_or_next|faction_slot_eq, ":party_faction", slot_faction_capital, ":party_no"), (eq, ":party_no", "p_town_minas_morgul"), (party_count_members_of_type,":num_armoured", ":party_no", ":armoured"), (lt, ":num_armoured", ":max_armoured_trolls"), (party_add_members, ":party_no", ":armoured", 1), (try_end), (try_begin), (gt, ":party_template", 0), (party_is_active, ":party_no"), #TLD (party_slot_eq, ":party_no", slot_center_destroyed, 0), # TLD (party_add_template, ":party_no", ":party_template"), (try_end), ]), # script_hire_men_to_kingdom_hero_party # [Old TLD change: Hiring troops based on nearby town wealth instead of hero wealth] # New TLD change: Hiring troops based only on current and ideal party size # Input: arg1 = troop_no (hero of the party) # Output: none ("hire_men_to_kingdom_hero_party", [ (store_script_param_1, ":troop_no"), (store_troop_faction, ":troop_faction", ":troop_no"), (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party), # (call_script, "script_find_random_nearby_friendly_town", ":party_no", 0), # (assign, ":nearby_center", reg0), # (party_get_slot, ":cur_wealth", ":nearby_center", slot_town_wealth), # (assign, ":hiring_budget", ":cur_wealth"), # (val_mul, ":hiring_budget", 4), # (val_div, ":hiring_budget", 5), (assign, ":num_rounds", 1), #GA: add standard bearers to hero parties (try_begin), (eq,":troop_faction","fac_lorien"), (party_count_members_of_type,":num", ":party_no", "trp_lothlorien_standard_bearer"), (lt, ":num", 3), (party_add_members, ":party_no", "trp_lothlorien_standard_bearer", 2), (else_try), (eq,":troop_faction","fac_imladris"), (party_count_members_of_type,":num", ":party_no", "trp_i6_rivendell_standard_bearer"), (lt, ":num", 3), (party_add_members, ":party_no", "trp_i6_rivendell_standard_bearer", 2), (else_try), (eq,":troop_faction","fac_woodelf"), (party_count_members_of_type,":num", ":party_no", "trp_i5_greenwood_standard_bearer"), (lt, ":num", 3), (party_add_members, ":party_no", "trp_i5_greenwood_standard_bearer", 2), (else_try), (eq,":troop_faction","fac_mordor"), (party_count_members_of_type,":num", ":party_no", "trp_i5_mordor_uruk_standard_bearer"), (lt, ":num", 4), (party_add_members, ":party_no", "trp_i5_mordor_uruk_standard_bearer", 2), (else_try), (eq,":troop_faction","fac_isengard"), (party_count_members_of_type,":num", ":party_no", "trp_i5_isen_uruk_standard_bearer"), (lt, ":num", 4), (party_add_members, ":party_no", "trp_i5_isen_uruk_standard_bearer", 2), (try_end), #Retainers Begin #See if this lord has retainer troops (try_begin), (troop_get_slot, ":retainer_troop", ":troop_no", slot_troop_retainer_troop), (gt, ":retainer_troop", 0), (party_count_members_of_type,":num", ":party_no", ":retainer_troop"), (store_skill_level, ":retainer_limit", skl_leadership, ":troop_no"), (val_mul, ":retainer_limit", 2), (val_add, ":retainer_limit", 5), #up to 25 #TODO: Ren - May need to add a multiplier for orc retainers (lt, ":num", ":retainer_limit"), (party_add_members, ":party_no", ":retainer_troop", 3), (try_end), #Retainers End (call_script, "script_party_get_ideal_size", ":party_no"), (assign, ":ideal_size", reg0), # (display_message, "@DEBUG: Host ideal size: {reg0}", debug_color), (store_mul, ":ideal_top_size", ":ideal_size", 3), (val_div, ":ideal_top_size", 2), (party_get_num_companions, ":party_size", ":party_no"), (try_for_range, ":unused", 0 , ":num_rounds"), (try_begin), (lt, ":party_size", ":ideal_size"), (gt, ":party_no", 0), (call_script, "script_cf_reinforce_party", ":party_no"), (else_try), (gt, ":party_size", ":ideal_top_size"), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (assign, ":total_regulars", 0), (assign, ":total_regular_levels", 0), (try_for_range_backwards, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (store_character_level, ":stack_level", ":stack_troop"), (store_troop_faction, ":stack_faction", ":stack_troop"), (try_begin), (eq, ":troop_faction", ":stack_faction"), (val_mul, ":stack_level", 3), #reducing the chance of the faction troops' removal (try_end), (val_mul, ":stack_level", ":stack_size"), (val_add, ":total_regulars", ":stack_size"), (val_add, ":total_regular_levels", ":stack_level"), (try_end), (gt, ":total_regulars", 0), (store_div, ":average_level", ":total_regular_levels", ":total_regulars"), (try_for_range_backwards, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (store_character_level, ":stack_level", ":stack_troop"), (store_troop_faction, ":stack_faction", ":stack_troop"), (try_begin), (eq, ":troop_faction", ":stack_faction"), (val_mul, ":stack_level", 3), (try_end), (store_sub, ":level_dif", ":average_level", ":stack_level"), (val_div, ":level_dif", 3), (store_add, ":prune_chance", 10, ":level_dif"), (gt, ":prune_chance", 0), (call_script, "script_get_percentage_with_randomized_round", ":stack_size", ":prune_chance"), (gt, reg0, 0), (party_remove_members, ":party_no", ":stack_troop", reg0), (try_end), (try_end), (try_end), #MV test code begin # (try_begin), # (eq, cheat_switch, 1), # (store_troop_faction, ":faction_no", ":troop_no"), # (this_or_next|eq, ":faction_no", "fac_gondor"), # (eq, ":faction_no", "fac_mordor"), # (assign, reg1, ":party_size"), # (assign, reg2, ":ideal_size"), # (str_store_troop_name, s1, ":troop_no"), # (party_get_num_companions, reg3, ":party_no"), # (display_message, "@DEBUG: {s1} reinforces, current:{reg1} ideal:{reg2} new:{reg3}.", 0x30FFC8), # (try_end), #MV test code end #InVain: Piggyback troll recruitment for lords (try_begin), (faction_get_slot, ":fac_troll", ":troop_faction", slot_faction_troll_troop), (gt, ":fac_troll", 0), #check for troll factions (troop_get_upgrade_troop, ":fac_troll_up", ":fac_troll", 0), (troop_get_slot, ":armoured", ":fac_troll_up", slot_troop_troll_armoured_variant), (store_div, ":max_trolls", ":party_size", 60), (store_div, ":max_armoured_trolls", ":party_size", 100), (party_count_members_of_type,":num_base_trolls", ":party_no", ":fac_troll"), (lt, ":num_base_trolls", ":max_trolls"), (party_add_members, ":party_no", ":fac_troll", 1), (gt, ":armoured", 0), #rules out Gundabad (party_count_members_of_type,":num_armoured", ":party_no", ":armoured"), (lt, ":num_armoured", ":max_armoured_trolls"), (party_add_members, ":party_no", ":armoured", 1), (try_end), ]), # script_find_random_nearby_friendly_town # TLD script # Input: arg1 = party_no, from where to find town; arg2 = include castles # Output: reg0 = center party no ("find_random_nearby_friendly_town", [ (store_script_param, ":party_no", 1), (store_script_param, ":c_castles", 2), (store_faction_of_party, ":party_faction", ":party_no"), (assign, ":min_dis", 10000000), (assign, reg0, -1), (try_for_parties, ":party"), (this_or_next|party_slot_eq, ":party", slot_party_type, spt_town), (neq, ":c_castles", 0), (this_or_next|party_slot_eq, ":party", slot_party_type, spt_town), (party_slot_eq, ":party", slot_party_type, spt_castle), (party_is_active, ":party"), #TLD (party_slot_eq, ":party", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":faction", ":party"), (eq, ":faction", ":party_faction"), (store_distance_to_party_from_party, ":dis", ":party", ":party_no"), (store_random_in_range, ":rand", 0, ":min_dis"), (this_or_next|gt, ":rand", ":dis"), (eq, reg0, -1), (assign, reg0, ":party"), (assign, ":min_dis", ":dis"), (try_end), ]), # script_get_percentage_with_randomized_round # Input: arg1 = value, arg2 = percentage # Output: none ("get_percentage_with_randomized_round", [ (store_script_param, ":value", 1), (store_script_param, ":percentage", 2), (store_mul, ":result", ":value", ":percentage"), (val_div, ":result", 100), (store_mul, ":used_amount", ":result", 100), (val_div, ":used_amount", ":percentage"), (store_sub, ":left_amount", ":value", ":used_amount"), (try_begin), (gt, ":left_amount", 0), (store_mul, ":chance", ":left_amount", ":percentage"), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":chance"), (val_add, ":result", 1), (try_end), (assign, reg0, ":result"), ]), # script_get_troop_attached_party # Input: arg1 = troop_no # Output: reg0 = party_no (-1 if troop's party is not attached to a party) ("get_troop_attached_party", [ (store_script_param_1, ":troop_no"), (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party), (assign, ":attached_party_no", -1), (try_begin), (ge, ":party_no", 0), (party_get_attached_to, ":attached_party_no", ":party_no"), (try_end), (assign, reg0, ":attached_party_no"), ]), # script_center_get_food_consumption # Input: arg1 = center_no # Output: reg0: food consumption (1 food item counts as 100 units) ("center_get_food_consumption", [ (store_script_param_1, ":center_no"), (assign, ":food_consumption", 0), (try_begin), (party_slot_eq, ":center_no", slot_party_type, spt_town), (assign, ":food_consumption", 500), (else_try), (party_slot_eq, ":center_no", slot_party_type, spt_castle), (assign, ":food_consumption", 50), (try_end), (assign, reg0, ":food_consumption"), ]), # script_center_get_food_store_limit # Input: arg1 = center_no # Output: reg0: food consumption (1 food item counts as 100 units) ("center_get_food_store_limit", [ (store_script_param_1, ":center_no"), (assign, ":food_store_limit", 0), (try_begin), (party_slot_eq, ":center_no", slot_party_type, spt_town), (assign, ":food_store_limit", 50000), (else_try), (party_slot_eq, ":center_no", slot_party_type, spt_castle), (assign, ":food_store_limit", 1500), (try_end), (assign, reg0, ":food_store_limit"), ]), # script_village_set_state # Input: arg1 = center_no arg2:new_state # Output: reg0: food consumption (1 food item counts as 100 units) ("village_set_state",[ (store_script_param_1, ":village_no"), (store_script_param_2, ":new_state"), # (party_get_slot, ":old_state", ":village_no", slot_village_state), (try_begin), (eq, ":new_state", 0), (party_set_extra_text, ":village_no", "str_empty_string"), #(party_set_slot, ":village_no", slot_village_raided_by, -1), (else_try), (eq, ":new_state", svs_being_raided), (party_set_extra_text, ":village_no", "@(Being Raided)"), (else_try), (eq, ":new_state", svs_looted), (party_set_extra_text, ":village_no", "@(Looted)"), #(party_set_slot, ":village_no", slot_village_raided_by, -1), (call_script, "script_change_center_prosperity", ":village_no", -30), (else_try), (eq, ":new_state", svs_under_siege), (party_set_extra_text, ":village_no", "@(Under Siege)"), (try_end), #(party_set_slot, ":village_no", slot_village_state, ":new_state"), ]), # script_process_sieges #called from triggers ("process_sieges", [ (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD #Reducing siege hardness every day by 20 (party_get_slot, ":siege_hardness", ":center_no", slot_center_siege_hardness), (val_sub, ":siege_hardness", 20), (val_max, ":siege_hardness", 0), (party_set_slot, ":center_no", slot_center_siege_hardness, ":siege_hardness"), (party_get_slot, ":town_food_store", ":center_no", slot_party_food_store), (call_script, "script_center_get_food_store_limit", ":center_no"), (assign, ":food_store_limit", reg0), (try_begin), (party_get_slot, ":besieger_party", ":center_no", slot_center_is_besieged_by), (ge, ":besieger_party", 0), #town is under siege #Reduce prosperity of besieged center by -1 with a 33% chance every day. (try_begin), (store_random_in_range, ":random_no", 0, 3), (eq, ":random_no", 0), (call_script, "script_change_center_prosperity", ":center_no", -1), (try_end), (store_faction_of_party, ":center_faction", ":center_no"), # Lift siege unless there is an enemy party nearby (assign, ":siege_lifted", 0), (try_begin), (try_begin), (neg|party_is_active, ":besieger_party"), (assign, ":siege_lifted", 1), (else_try), (store_distance_to_party_from_party, ":besieger_distance", ":center_no", ":besieger_party"), (gt, ":besieger_distance", 5), (assign, ":siege_lifted", 1), (else_try), #MV: possibly redundant code (store_faction_of_party, ":besieger_faction", ":besieger_party"), (store_relation, ":reln", ":besieger_faction", ":center_faction"), (gt, ":reln", 0), #MV: if center changed hands (assign, ":siege_lifted", 1), (try_end), (eq, ":siege_lifted", 1), (try_for_range, ":enemy_hero", kingdom_heroes_begin, kingdom_heroes_end), (troop_slot_eq, ":enemy_hero", slot_troop_occupation, slto_kingdom_hero), (troop_get_slot, ":enemy_party", ":enemy_hero", slot_troop_leaded_party), (ge, ":enemy_party", 0), (party_is_active, ":enemy_party"), (store_faction_of_party, ":party_faction", ":enemy_party"), (store_relation, ":reln", ":party_faction", ":center_faction"), (lt, ":reln", 0), (store_distance_to_party_from_party, ":distance", ":center_no", ":enemy_party"), (lt, ":distance", 4), (assign, ":besieger_party", ":enemy_party"), (party_set_slot, ":center_no", slot_center_is_besieged_by, ":enemy_party"), (assign, ":siege_lifted", 0), (try_end), (try_end), (try_begin), (eq, ":siege_lifted", 1), (call_script, "script_lift_siege", ":center_no", 1), (else_try), (call_script, "script_center_get_food_consumption", ":center_no"), (assign, ":food_consumption", reg0), (val_sub, ":town_food_store", ":food_consumption"), # reduce food only under siege??? (try_begin), (le, ":town_food_store", 0), #town is starving (store_random_in_range, ":r", 0, 100), (lt, ":r", 10), (call_script, "script_party_wound_all_members", ":center_no"), # town falls with 10% chance if starving (try_end), (try_end), (else_try), #town is not under siege... (val_add, ":town_food_store", 30), #add 30 food (significant for castles only. (try_end), (val_min, ":town_food_store", ":food_store_limit"), (val_max, ":town_food_store", 0), (party_set_slot, ":center_no", slot_party_food_store, ":town_food_store"), (try_end), ]), # script_lift_siege # Input: arg1 = center_no, arg2 = display_message # Output: none #called from triggers ("lift_siege", [ (store_script_param, ":center_no", 1), (store_script_param, ":display_message", 2), (party_set_slot, ":center_no", slot_center_is_besieged_by, -1), #clear siege (call_script, "script_village_set_state", ":center_no", 0), #clear siege flag (try_begin), (eq, ":center_no", "$g_player_besiege_town"), (assign, "$g_siege_method", 0), #remove siege progress (try_end), (try_begin), (eq, ":display_message", 1), (str_store_party_name_link, s3, ":center_no"), (try_begin), (store_faction_of_party, ":faction", ":center_no"), (store_relation, ":rel", "$players_kingdom", ":faction"), (gt, ":rel", 0), (assign, ":news_color", color_good_news), (else_try), (assign, ":news_color", color_bad_news), (try_end), (display_message, "@{s3} is no longer under siege.", ":news_color"), (try_end), ]), # script_process_alarms #called from triggers ("process_alarms", [(try_for_range, ":center_no", centers_begin, centers_end), (party_set_slot, ":center_no", slot_center_last_spotted_enemy, -1), (try_end), (assign, ":spotting_range", 2), (try_begin), (is_currently_night), (assign, ":spotting_range", 1), (try_end), (try_begin), (party_slot_eq, ":center_no", slot_center_has_watch_tower, 1), (val_mul, ":spotting_range", 2), (try_end), (try_for_parties, ":party_no"), (party_slot_eq, ":party_no", slot_party_type, spt_kingdom_hero_party), (neg|party_is_in_any_town, ":party_no"), (party_is_active, ":party_no"), (store_faction_of_party, ":party_faction", ":party_no"), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_distance_to_party_from_party, ":distance", ":party_no", ":center_no"), (le, ":distance", ":spotting_range"), (store_faction_of_party, ":center_faction", ":center_no"), (store_relation, ":reln", ":center_faction", ":party_faction"), (lt, ":reln", 0), (party_set_slot, ":center_no", slot_center_last_spotted_enemy, ":party_no"), (try_end), (try_end), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":center_faction", ":center_no"), (this_or_next|party_slot_eq, ":center_no", slot_town_lord, "trp_player"), (eq, ":center_faction", "$players_kingdom"), (party_get_slot, ":enemy_party", ":center_no", slot_center_last_spotted_enemy), (ge, ":enemy_party", 0), (store_distance_to_party_from_party, ":dist", "p_main_party", ":center_no"), (assign, ":has_messenger", 0), (try_begin), (this_or_next|party_slot_eq, ":center_no", slot_town_lord, "trp_player"), (eq, ":center_faction", "fac_player_supporters_faction"), (party_slot_eq, ":center_no", slot_center_has_messenger_post, 1), (assign, ":has_messenger", 1), (try_end), (this_or_next|lt, ":dist", 30), (eq, ":has_messenger", 1), (neq, "$g_fast_mode", 1), (str_store_party_name_link, s1, ":center_no"), (display_message, "@Enemies spotted near {s1}."), (try_end), ]), # script_get_center_faction_relation_including_player # Input: arg1: center_no, arg2: target_faction_no # Output: reg0: relation #called from triggers ("get_center_faction_relation_including_player", [ (store_script_param, ":center_no", 1), (store_script_param, ":target_faction_no", 2), (store_faction_of_party, ":center_faction", ":center_no"), (store_relation, ":reln", ":center_faction", ":target_faction_no"), (try_begin), (party_slot_eq, ":center_no", slot_town_lord, "trp_player"), (store_relation, ":reln", "fac_player_supporters_faction", ":target_faction_no"), (try_end), (assign, reg0, ":reln"), ]), # script_check_and_finish_active_army_quests_for_faction # Input: faction_no # Output: none ("check_and_finish_active_army_quests_for_faction", [ (store_script_param_1, ":faction_no"), (try_begin), (eq, "$players_kingdom", ":faction_no"), (try_begin), (check_quest_active, "qst_report_to_army"), (call_script, "script_cancel_quest", "qst_report_to_army"), (try_end), (assign, ":one_active", 0), (try_for_range, ":quest_no", army_quests_begin, army_quests_end), (check_quest_active, ":quest_no"), (call_script, "script_cancel_quest", ":quest_no"), (assign, ":one_active", 1), (try_end), (try_begin), (check_quest_active, "qst_follow_army"), (assign, ":one_active", 1), (call_script, "script_end_quest", "qst_follow_army"), (try_end), (eq, ":one_active", 1), #(faction_get_slot, ":last_offensive_time", ":faction_no", slot_faction_ai_last_offensive_time), (quest_get_slot, ":starting_hours", qst_follow_army, slot_quest_xp_reward), (store_current_hours, ":cur_hours"), (store_sub, ":total_time_served", ":cur_hours", ":starting_hours"), (val_min, ":total_time_served", 240), #up to 10 days (store_mul, ":xp_reward", ":total_time_served", 4), (val_div, ":xp_reward", 50), (val_mul, ":xp_reward", 50), (val_add, ":xp_reward", 50), (add_xp_as_reward, ":xp_reward"), (store_div, ":rank_reward", ":xp_reward", 10), (call_script, "script_increase_rank", ":faction_no", ":rank_reward"), (try_end), ]), # script_troop_get_player_relation # Input: arg1 = troop_no # Output: reg0 = effective relation (modified by troop reputation, honor, etc.) #TLD: no reputation and honor ("troop_get_player_relation", [ (store_script_param_1, ":troop_no"), (troop_get_slot, ":effective_relation", ":troop_no", slot_troop_player_relation), (assign, reg0, ":effective_relation"), ]), # script_change_player_relation_with_troop # Input: arg1 = troop_no, arg2 = relation difference ("change_player_relation_with_troop", [ (store_script_param_1, ":troop_no"), (store_script_param_2, ":difference"), (try_begin), (neq, ":troop_no", "trp_player"), (neg|is_between, ":troop_no", soldiers_begin, soldiers_end), (neq, ":difference", 0), #InVain: Charisma bonus (store_attribute_level, ":player_charisma", trp_player, ca_charisma), (try_begin), (gt, ":difference", 0), (val_mul, ":difference", 100), (val_mul, ":difference", ":player_charisma"), (val_div, ":difference", 1200), #starts to scale from 12, reduces below (else_try), (val_mul, ":difference", 100), (val_div, ":difference", 10), #starts to scale from 10 (try_end), (call_script, "script_troop_get_player_relation", ":troop_no"), (assign, ":old_effective_relation", reg0), (troop_get_slot, ":player_relation", ":troop_no", slot_troop_player_relation), (val_add, ":player_relation", ":difference"), (val_clamp, ":player_relation", -100, 101), (try_begin), (troop_set_slot, ":troop_no", slot_troop_player_relation, ":player_relation"), (str_store_troop_name_link, s1, ":troop_no"), (call_script, "script_troop_get_player_relation", ":troop_no"), (assign, ":new_effective_relation", reg0), (neq, ":old_effective_relation", ":new_effective_relation"), (assign, reg1, ":old_effective_relation"), (assign, reg2, ":new_effective_relation"), (try_begin), (gt, ":difference", 0), (display_message, "str_troop_relation_increased", color_good_news), (else_try), (lt, ":difference", 0), (display_message, "str_troop_relation_detoriated", color_bad_news), (try_end), (try_begin), (eq, ":troop_no", "$g_talk_troop"), (assign, "$g_talk_troop_relation", ":new_effective_relation"), (call_script, "script_setup_talk_info"), (try_end), (call_script, "script_update_troop_notes", ":troop_no"), (try_end), #Friendship Rewards Begin #Add relation change to friendship reward progress (try_begin), (is_between, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end), (call_script, "script_lord_friendship_reward_progress", ":troop_no", ":difference"), (try_end), #Friendship Rewards End (try_end), ]), # script_change_player_relation_with_center # Input: arg1 = party_no, arg2 = relation difference ("change_player_relation_with_center", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":difference"), #InVain: Charisma bonus (store_attribute_level, ":player_charisma", trp_player, ca_charisma), (try_begin), (gt, ":difference", 0), (val_mul, ":difference", 100), (val_mul, ":difference", ":player_charisma"), (val_div, ":difference", 1200), #starts to scale from 12, reduces below (val_max, ":difference", 1), (else_try), (val_mul, ":difference", 100), (val_div, ":difference", 10), #starts to scale from 10 (val_min, ":difference", -1), (try_end), (party_get_slot, ":player_relation", ":center_no", slot_center_player_relation), (assign, reg1, ":player_relation"), (val_add, ":player_relation", ":difference"), (val_clamp, ":player_relation", -100, 100), (assign, reg2, ":player_relation"), (party_set_slot, ":center_no", slot_center_player_relation, ":player_relation"), (str_store_party_name_link, s1, ":center_no"), (try_begin), (gt, ":difference", 0), (display_message, "@Your relation with {s1} has improved.", color_good_news), (else_try), (lt, ":difference", 0), (display_message, "@Your relation with {s1} has deteriorated."), (try_end), (try_begin), (is_between, "$g_talk_troop", mayors_begin, mayors_end), (assign, "$g_talk_troop_relation", ":player_relation"), (call_script, "script_setup_talk_info"), (try_end), ]), # script_change_player_relation_with_faction # Input: arg1 = faction_no, arg2 = relation difference ("change_player_relation_with_faction", [ (store_script_param_1, ":faction_no"), (store_script_param_2, ":difference"), (store_relation, ":player_relation", ":faction_no", "fac_player_supporters_faction"), (assign, reg1, ":player_relation"), (val_add, ":player_relation", ":difference"), (assign, reg2, ":player_relation"), (set_relation, ":faction_no", "fac_player_faction", ":player_relation"), (set_relation, ":faction_no", "fac_player_supporters_faction", ":player_relation"), (str_store_faction_name_link, s1, ":faction_no"), (try_begin), (gt, ":difference", 0), (display_message, "str_faction_relation_increased", color_good_news), (else_try), (lt, ":difference", 0), (display_message, "str_faction_relation_detoriated", color_bad_news), (try_end), (call_script, "script_update_all_notes"), ]), # script_set_player_relation_with_faction # Input: arg1 = faction_no, arg2 = relation ("set_player_relation_with_faction", [ (store_script_param_1, ":faction_no"), (store_script_param_2, ":relation"), (store_relation, ":player_relation", ":faction_no", "fac_player_supporters_faction"), (store_sub, ":reln_dif", ":relation", ":player_relation"), (call_script, "script_change_player_relation_with_faction", ":faction_no", ":reln_dif"), ]), # script_cf_get_random_active_faction_except_player_faction_and_faction # Input: arg1 = except_faction_no # Output: reg0 = random_faction ("cf_get_random_active_faction_except_player_faction_and_faction", [ (store_script_param_1, ":except_faction_no"), (assign, ":num_factions", 0), (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end), (neq, ":faction_no", "fac_player_supporters_faction"), (neq, ":faction_no", ":except_faction_no"), (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active), (val_add, ":num_factions", 1), (try_end), (gt, ":num_factions", 0), (assign, ":selected_faction", -1), (store_random_in_range, ":random_faction", 0, ":num_factions"), (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end), (ge, ":random_faction", 0), (neq, ":faction_no", "fac_player_supporters_faction"), (neq, ":faction_no", ":except_faction_no"), (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active), (val_sub, ":random_faction", 1), (lt, ":random_faction", 0), (assign, ":selected_faction", ":faction_no"), (try_end), (assign, reg0, ":selected_faction"), ]), # script_change_player_party_morale # Input: arg1 = morale difference # Output: none ("change_player_party_morale", [ (store_script_param_1, ":morale_dif"), (party_get_morale, ":cur_morale", "p_main_party"), (store_add, ":new_morale", ":cur_morale", ":morale_dif"), (val_clamp, ":new_morale", 0, 100), (party_set_morale, "p_main_party", ":new_morale"), (try_begin), (lt, ":new_morale", ":cur_morale"), (store_sub, reg1, ":cur_morale", ":new_morale"), (display_message, "str_party_lost_morale", color_bad_news), (else_try), (gt, ":new_morale", ":cur_morale"), (store_sub, reg1, ":new_morale", ":cur_morale"), (display_message, "str_party_gained_morale", color_good_news), (try_end), ]), # script_cf_player_has_item_without_modifier # Input: arg1 = item_id, arg2 = modifier # Output: none (can_fail) ("cf_player_has_item_without_modifier", [ (store_script_param, ":item_id", 1), (store_script_param, ":modifier", 2), (player_has_item, ":item_id"), #checking if any of the meat is not rotten (assign, ":has_without_modifier", 0), (troop_get_inventory_capacity, ":inv_size", "trp_player"), (try_for_range, ":i_slot", 0, ":inv_size"), (troop_get_inventory_slot, ":cur_item", "trp_player", ":i_slot"), (eq, ":cur_item", ":item_id"), (troop_get_inventory_slot_modifier, ":cur_modifier", "trp_player", ":i_slot"), (call_script, "script_are_there_orcs", "p_main_party"), (this_or_next|neq, ":cur_modifier", ":modifier"), (gt, reg0, 0), (assign, ":has_without_modifier", 1), (assign, ":inv_size", 0), #break (try_end), (eq, ":has_without_modifier", 1), ]), # script_get_player_party_morale_values # Output: reg0 = player_party_morale_target # Changed to make higher level troops less affected by morale / party size ("get_player_party_morale_values", [ # calculate the total number of guys and the cumulative level of the # party. (party_get_num_companion_stacks, ":num_stacks","p_main_party"), (assign, ":level_total", 0), (assign, ":num_men", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_main_party", ":i_stack"), (store_character_level, ":level", ":stack_troop"), (try_begin), (troop_is_hero, ":stack_troop"), (val_add, ":num_men", 1), #InVain: Was 3, reduced to WB standart (val_add, ":level_total", ":level"), (else_try), (party_stack_get_size, ":stack_size","p_main_party",":i_stack"), (val_add, ":num_men", ":stack_size"), (val_mul, ":level", ":stack_size"), (val_add, ":level_total", ":level"), (try_end), (try_end), # take the total number of guys and put it in the right range to do more # maths on it. divide this value by the cumulative level to get our # morale penalty based on size. this results in lower level troops # being more inclined to be unhappy than higher level troops and higher # level troops can kick guys in line up to a point. # 5 * (count+5)^2 / (count * level) #InVain: Old formular commented out, this was silly maths # (store_add, ":morale_penalty_for_size", ":num_men", 5), # (val_mul, ":morale_penalty_for_size", ":morale_penalty_for_size"), # (val_mul, ":morale_penalty_for_size", 5), # (val_div, ":morale_penalty_for_size", ":level_total"), #InVain: New formula for proper exponential growth, overtakes old linear growth at ca. 120 troops # 5+ (x^3 / 25*level_total) (store_mul, ":morale_penalty_for_size", ":num_men", ":num_men"), (val_mul, ":morale_penalty_for_size", ":num_men"), (val_div, ":morale_penalty_for_size", ":level_total"), (val_div, ":morale_penalty_for_size", 25), (val_add, ":morale_penalty_for_size", 5), # the math works great for large numbers but not so great for small ones. # if we get a value that's more than twice the size, min it to that. #InVain: Not needed anymore # (try_begin), # (store_mul, ":double", ":num_men", 2), # (gt, ":morale_penalty_for_size", ":double"), # (assign, ":morale_penalty_for_size", ":double"), # (try_end), #InVain: Penalty if you go over your party size limit (can happen with Warg riders) (call_script, "script_game_get_party_companion_limit"), (assign, ":party_size_limit", reg0), (try_begin), (gt, ":num_men", ":party_size_limit"), (store_sub, ":penalty", ":num_men", ":party_size_limit"), (val_add, ":morale_penalty_for_size", ":penalty"), (try_end), (assign, "$g_player_party_morale_modifier_party_size", ":morale_penalty_for_size"), (store_skill_level, ":player_leadership", "skl_leadership", "trp_player"), (store_mul, "$g_player_party_morale_modifier_leadership", ":player_leadership", 7), (assign, ":new_morale", "$g_player_party_morale_modifier_leadership"), (val_sub, ":new_morale", "$g_player_party_morale_modifier_party_size"), (val_add, ":new_morale", 50), (assign, "$g_player_party_morale_modifier_food", 0), (try_for_range, ":cur_edible", food_begin, food_end), (call_script, "script_cf_player_has_item_without_modifier", ":cur_edible", imod_rotten), (item_get_slot, ":food_bonus", ":cur_edible", slot_item_food_bonus), (val_add, "$g_player_party_morale_modifier_food", ":food_bonus"), (try_end), (try_begin), #For Horse Meat (call_script, "script_cf_player_has_item_without_modifier", "itm_horse_meat", imod_rotten), (item_get_slot, ":food_bonus", "itm_horse_meat", slot_item_food_bonus), (val_add, "$g_player_party_morale_modifier_food", ":food_bonus"), (try_end), (val_add, ":new_morale", "$g_player_party_morale_modifier_food"), (try_begin), (eq, "$g_player_party_morale_modifier_food", 0), (assign, "$g_player_party_morale_modifier_no_food", 30), (val_sub, ":new_morale", "$g_player_party_morale_modifier_no_food"), (else_try), (assign, "$g_player_party_morale_modifier_no_food", 0), (try_end), # TLD morale-boosting items (non-cumulative) (try_begin), (player_has_item, "itm_lembas"), (val_add, ":new_morale", 30), (else_try), (player_has_item, "itm_cooking_cauldron"), (val_add, ":new_morale", 20), (try_end), # TLD: nothing for this #(assign, "$g_player_party_morale_modifier_debt", 0), #(try_begin), # (gt, "$g_player_debt_to_party_members", 0), # (call_script, "script_calculate_player_faction_wage"), # (assign, ":total_wages", reg0), # (store_mul, "$g_player_party_morale_modifier_debt", "$g_player_debt_to_party_members", 10), # (val_div, "$g_player_party_morale_modifier_debt", ":total_wages"), # (val_clamp, "$g_player_party_morale_modifier_debt", 1, 31), # (val_sub, ":new_morale", "$g_player_party_morale_modifier_debt"), #(try_end), (val_clamp, ":new_morale", 0, 100), (assign, reg0, ":new_morale"), ]), # script_add_notification_menu # Input: arg1 = menu_no, arg2 = menu_var_1, arg3 = menu_var_2 # Output: none ("add_notification_menu", [ (store_script_param, ":menu_no", 1), (store_script_param, ":menu_var_1", 2), (store_script_param, ":menu_var_2", 3), (assign, ":end_cond", 1), (try_for_range, ":cur_slot", 0, ":end_cond"), (try_begin), (troop_slot_ge, "trp_notification_menu_types", ":cur_slot", 1), (val_add, ":end_cond", 1), (else_try), (troop_set_slot, "trp_notification_menu_types", ":cur_slot", ":menu_no"), (troop_set_slot, "trp_notification_menu_var1", ":cur_slot", ":menu_var_1"), (troop_set_slot, "trp_notification_menu_var2", ":cur_slot", ":menu_var_2"), (try_end), (try_end), ]), # script_finish_quest # Input: arg1 = quest_no, arg2 = finish_percentage # Output: none ("finish_quest", [ (store_script_param_1, ":quest_no"), (store_script_param_2, ":finish_percentage"), (quest_get_slot, ":quest_giver", ":quest_no", slot_quest_giver_troop), (store_troop_faction, ":quest_faction", ":quest_giver"), (quest_get_slot, ":quest_target_faction", ":quest_no", slot_quest_target_faction), (quest_get_slot, ":quest_giver_center", ":quest_no", slot_quest_giver_center), (quest_get_slot, ":quest_importance", ":quest_no", slot_quest_importance), (quest_get_slot, ":quest_xp_reward", ":quest_no", slot_quest_xp_reward), (quest_get_slot, ":quest_gold_reward", ":quest_no", slot_quest_gold_reward), (quest_get_slot, ":quest_rank_reward", ":quest_no", slot_quest_rank_reward), (quest_get_slot, ":quest_giver_fac_str_effect", ":quest_no", slot_quest_giver_fac_str_effect), (quest_get_slot, ":quest_target_fac_str_effect", ":quest_no", slot_quest_target_fac_str_effect), #Exceptions (try_begin), (eq, ":quest_no", "qst_deliver_message"), (assign, ":quest_gold_reward", 0), #already paid in target currency (try_end), (try_begin), (lt, ":finish_percentage", 100), (val_mul, ":quest_xp_reward", ":finish_percentage"), (val_div, ":quest_xp_reward", 100), (val_mul, ":quest_gold_reward", ":finish_percentage"), (val_div, ":quest_gold_reward", 100), (val_mul, ":quest_rank_reward", ":finish_percentage"), (val_div, ":quest_rank_reward", 100), (val_mul, ":quest_giver_fac_str_effect", ":finish_percentage"), (val_div, ":quest_giver_fac_str_effect", 100), (val_mul, ":quest_target_fac_str_effect", ":finish_percentage"), (val_div, ":quest_target_fac_str_effect", 100), #Changing the relation factor. Negative relation if less than 75% of the quest is finished. #Positive relation if more than 75% of the quest is finished. (assign, ":importance_multiplier", ":finish_percentage"), (val_sub, ":importance_multiplier", 75), (val_mul, ":quest_importance", ":importance_multiplier"), (val_div, ":quest_importance", 100), (else_try), #(val_div, ":quest_importance", 4), (val_max, ":quest_importance", 1), (try_end), (try_begin), (is_between, ":quest_giver", mayors_begin, mayors_end), (call_script, "script_change_player_relation_with_center", ":quest_giver_center", ":quest_importance"), (else_try), (call_script, "script_change_player_relation_with_troop", ":quest_giver", ":quest_importance"), (try_end), #InVain: Bonus quest XP from intelligence #(assign, reg78, ":quest_xp_reward"), (store_attribute_level, ":int", "trp_player", ca_intelligence), (store_mul, ":int_xp_multi", ":int",":int"), (val_div, ":int_xp_multi", 8), (val_add, ":int_xp_multi", 100), #(assign, reg79, ":int_xp_multi"), (val_mul, ":quest_xp_reward", ":int_xp_multi"), (val_div, ":quest_xp_reward", 100), #(assign, reg80, ":quest_xp_reward"), #(display_message, "@base xp: {reg78}; multi: {reg79}; XP reward: {reg80}"), (add_xp_as_reward, ":quest_xp_reward"), (call_script, "script_add_faction_rps", ":quest_faction", ":quest_gold_reward"), (call_script, "script_increase_rank", ":quest_faction", ":quest_rank_reward"), (call_script, "script_end_quest", ":quest_no"), #execute faction strength consequences, negative outcomes defined in script_abort_quest (try_begin), (gt, "$tld_war_began", 0), (ge, ":quest_giver_fac_str_effect", 1), (faction_get_slot,":giver_strength",":quest_faction",slot_faction_strength_tmp), (val_add, ":giver_strength", ":quest_giver_fac_str_effect"), (faction_set_slot,":quest_faction",slot_faction_strength_tmp,":giver_strength"), (str_store_faction_name, s1, ":quest_faction"), (display_message, "@{s1} gained faction strength!", color_good_news), (try_end), (try_begin), (gt, "$tld_war_began", 0), (is_between, ":quest_target_faction", kingdoms_begin, kingdoms_end), #Check if there's an actual target faction (lt, ":quest_target_fac_str_effect", 0), #negative strength effect if enemy faction is target (faction_get_slot,":enemy_strength",":quest_target_faction",slot_faction_strength_tmp), (val_add, ":enemy_strength", ":quest_target_fac_str_effect"), (faction_set_slot,":quest_target_faction",slot_faction_strength_tmp,":enemy_strength"), (str_store_faction_name, s1, ":quest_target_faction"), (display_message, "@{s1} lost faction strength!", color_good_news), (else_try), #if target faction is an ally (e.g. escort caravan quest) (gt, "$tld_war_began", 0), (is_between, ":quest_target_faction", kingdoms_begin, kingdoms_end), #Check if there's an actual target faction (gt, ":quest_target_fac_str_effect", 0), #positive strength effect for allied targets (eg caravan quests) (faction_get_slot,":enemy_strength",":quest_target_faction",slot_faction_strength_tmp), (val_add, ":enemy_strength", ":quest_target_fac_str_effect"), (faction_set_slot,":quest_target_faction",slot_faction_strength_tmp,":enemy_strength"), (str_store_faction_name, s1, ":quest_target_faction"), (display_message, "@{s1} gained faction strength!", color_good_news), (try_end), ]), # script_get_information_about_troops_position # Input: arg1 = troop_no, arg2 = time (0 if present tense, 1 if past tense) # Output: s1 = String, reg0 = knows-or-not ("get_information_about_troops_position", [ (store_script_param_1, ":troop_no"), (store_script_param_2, reg3), (troop_get_type, reg4, ":troop_no"), (try_begin), (gt, reg4, 1), #MV: non-humans are male (assign, reg4, 0), (try_end), (str_store_troop_name, s2, ":troop_no"), (assign, ":found", 0), (troop_get_slot, ":center_no", ":troop_no", slot_troop_cur_center), (try_begin), (gt, ":center_no", 0), (is_between, ":center_no", centers_begin, centers_end), (str_store_party_name_link, s3, ":center_no"), (str_store_string, s1, "@{s2} {reg3?was:is currently} at {s3}."), (assign, ":found", 1), (else_try), (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party), (gt, ":party_no", 0), (call_script, "script_get_troop_attached_party", ":troop_no"), (assign, ":center_no", reg0), (try_begin), (is_between, ":center_no", centers_begin, centers_end), (str_store_party_name_link, s3, ":center_no"), (str_store_string, s1, "@{s2} {reg3?was:is currently} at {s3}."), (assign, ":found", 1), (else_try), (get_party_ai_behavior, ":ai_behavior", ":party_no"), (eq, ":ai_behavior", ai_bhvr_travel_to_party), (get_party_ai_object, ":ai_object", ":party_no"), (is_between, ":ai_object", centers_begin, centers_end), (call_script, "script_get_closest_center", ":party_no"), (str_store_party_name_link, s4, reg0), (str_store_party_name_link, s3, ":ai_object"), (str_store_string, s1, "@{s2} {reg3?was:is} travelling to {s3} and {reg4?she:he} {reg3?was:should be} close to {s4}{reg3?: at the moment}."), (assign, ":found", 1), (else_try), (call_script, "script_get_closest_center", ":party_no"), (str_store_party_name_link, s3, reg0), (str_store_string, s1, "@{s2} {reg3?was:is} in wilderness and {reg4?she:he} {reg3?was:should be} close to {s3}{reg3?: at the moment}."), (assign, ":found", 1), (try_end), (else_try), #(troop_slot_ge, ":troop_no", slot_troop_is_prisoner, 1), (troop_slot_ge, ":troop_no", slot_troop_prisoner_of_party, 0), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (party_count_prisoners_of_type, ":num_prisoners", ":center_no", ":troop_no"), (gt, ":num_prisoners", 0), (assign, ":found", 1), (str_store_party_name_link, s3, ":center_no"), (str_store_string, s1, "@{s2} {reg3?was:is} being held captive at {s3}."), (try_end), (try_begin), (eq, ":found", 0), (str_store_string, s1, "@{s2} {reg3?was:has been} taken captive by {reg4?her:his} enemies."), (assign, ":found", 1), (try_end), (try_end), (try_begin), (eq, ":found", 0), (str_store_string, s1, "@{reg3?{s2}'s location was unknown:I don't know where {s2} is}."), (try_end), (assign, reg0, ":found"), ]), # script_recruit_troop_as_companion # Input: arg1 = troop_no, # Output: none ("recruit_troop_as_companion", [ (store_script_param_1, ":troop_no"), (troop_set_slot, ":troop_no", slot_troop_occupation, slto_player_companion), #(troop_set_slot, ":troop_no", slot_troop_cur_center, -1), (troop_set_auto_equip, ":troop_no",0), (party_add_members, "p_main_party", ":troop_no", 1), (str_store_troop_name, s6, ":troop_no"), (display_message, "@{s6} has joined your party"), ]), # "script_str_store_race_adj" (stringNo, raceNo) (mtarini) ("str_store_race_adj", [ (store_script_param_1, ":stN"), (store_script_param_2, ":race"), (str_clear, ":stN"), (try_begin), (is_between,":race",tf_elf_begin,tf_elf_end), (str_store_string, ":stN", "@elven"), (else_try), (eq,":race",tf_dwarf), (str_store_string, ":stN", "@dwarven"), (else_try), (eq,":race",tf_orc), (str_store_string, ":stN", "@orc"), # also an adjective (else_try), (eq,":race",tf_uruk), (str_store_string, ":stN", "@uruk"), # also an adjective (else_try), (eq,":race",tf_urukhai), (str_store_string, ":stN", "@uruk-hai"), # also an adjective (else_try), (eq,":race",tf_troll), (str_store_string, ":stN", "@trollish"), (else_try), (eq,":race",tf_dwarf), (str_store_string, ":stN", "@dwarven"), (else_try), (str_store_string, ":stN", "@man"), # also and adjective (try_end), ]), # "script_str_store_party_movement_verb" (stringNo, PartyNo) (mtarini) # stores "charging, riding, marching" etc ("str_store_party_movement_verb", [ (store_script_param_1, ":stN"), (store_script_param_2, ":party"), (str_clear, ":stN"), (try_begin), (call_script, "script_cf_party_is_mostly_mounted", ":party"), (str_store_string, ":stN", "@riding"), (else_try), (store_faction_of_party, ":fac", ":party"), (try_begin), (is_between,":fac",kingdoms_begin,kingdoms_end), (str_store_string, ":stN", "@marching"), (else_try), (str_store_string, ":stN", "@charging"), # for bandits, desertes, civilians, etc. (try_end), (try_end), ]), # script_str_store_distrusting_friend_dialog_in_s14_to_18 # used to set dialog when party A (player) meets friendlty party B, but it is not trusted by them # parameters: three factions (see below) # output: 4 lines of dialogs # s14 party B: first line, # s15 party A: response 1: (used to quit dialog) # s16 party B: answer 1 # s17 party A: response 2: (used to get an answer) # s18 party B: answer 2 ( "str_store_distrusting_friend_dialog_in_s14_to_18", [ (store_script_param_1, ":facA"), # of party A (usually, player) (store_script_param_2, ":facB"), # of party B (other party) (store_script_param, ":facC", 3), # of the place of meeting, or -1 if no man land (str_store_faction_name, s20, ":facA"), (str_store_faction_name, s21, ":facB"), (faction_get_slot, ":sideA", ":facA", slot_faction_side), (faction_get_slot, ":sideB", ":facB", slot_faction_side), (store_add, ":tmp", "str_faction_side_name", ":sideA"),(str_store_string, s22, ":tmp"), (store_add, ":tmp", "str_faction_side_name", ":sideB"),(str_store_string, s23, ":tmp"), (try_begin), (eq, ":facA", ":facC"), # situation 1: partyB is traspassing! (try_begin), (eq, ":sideA", faction_side_good), (str_store_string, s14, "@We know this is your land, {playername}.^Trust us, we're here to fight our common Enemy."), (str_store_string, s15, "@I trust you. {s20} and {s21} should be friends and trust each other."), (str_store_string, s16, "@There is wisdom in your words, {playername}."), (str_store_string, s17, "@Why should I? Better leave the land of {s20}."), (str_store_string, s18, "@We will go in peace, as soon as we have completed our mission, of which, I'm afraid, we cannot tell you."), (else_try), (eq, ":sideA", ":sideB"), # eye vs eye, or hand vs hand (str_store_string, s14, "@Is this your land, {playername}? This place stinks.^But stay calm, we are in {s20} only to follow orders by our common Master."), (str_store_string, s15, "@Yes, go on, do whatever {s22} says."), (str_store_string, s16, "@Of course."), (str_store_string, s17, "@I don't like this. What brings your lot here, all the way from {s21}?"), (str_store_string, s18, "@Do you fear us, {playername} from {s20}? Mmm, what are you hiding from {s22}?^^Leave us alone, and noone gets hurt."), (else_try), # eye vs hand, or hand vs eye (str_store_string, s14, "@It's a servant of {s22}. Fear {s23}, {playername}!"), (str_store_string, s15, "@Our allies, are you? I guess you can pass. "), (str_store_string, s16, "@And we shall not kill you, for now."), (str_store_string, s17, "@This land belongs to {s20}... {s23} has no business here."), (str_store_string, s18, "@We will stay as long as our master commands! Thank your fate that we didn't come for you."), (try_end), (else_try), (eq, ":facB", ":facC"), # situation 2: partyA is trespassing! (try_begin), (eq, ":sideB", faction_side_good), # good guys (str_store_string, s14, "@You wear the colors of {s20}. What is your business in {s21}?^Speak quickly!"), (str_store_string, s15, "@We are pursuing our enemies, who are also your enemies!"), (str_store_string, s16, "@Maybe. Or maybe you are spies.^Go back where you belong, soldier of {s20}."), (str_store_string, s17, "@We are friends of {s21}."), (str_store_string, s18, "@Time will tell if you speak the truth. It is difficult to tell friend from foe these days."), (else_try), # any bad guys (eq, ":sideA", ":sideB"), # eye vs eye, or hand vs hand (str_store_string, s14, "@What are you doing here in {s21}, {s20} scum? This is our place, not yours!"), (str_store_string, s15, "@You dare question direct orders from {s23}?"), (str_store_string, s16, "@Guess not. But I still don't like having you around.^I'll be watching you, {playername} of {s20}."), (str_store_string, s17, "@None of your business, pig!"), (str_store_string, s18, "@*growls*^You should be glad you fight for our Master, otherwise you would not get away with this trespassing."), (else_try), # any bad guys # eye vs hand, or hand vs eye (str_store_string, s14, "@What are you doing so far from home, slave of {s22}? Around here, {s23} is the Master!"), (str_store_string, s15, "@Quiet! I didn't came for you. This time."), (str_store_string, s16, "@And I've orders to let you pass. This time."), (str_store_string, s17, "@None of your business."), (str_store_string, s18, "@You slaves of {s22} are weak! You are fortunate that we consider you to be allies..."), (try_end), (else_try), # situation 3: common ground (try_begin), (eq, ":sideA", faction_side_good), (str_store_string, s14, "@Look whom we meet so far from home: soldiers of {s20}! Is this good news or bad?"), (str_store_string, s15, "@{s20} and {s21} fight for a common cause. We should cooperate in hostile lands."), (str_store_string, s16, "@In these dark times, it is everybody for themselves, {playername}.^But I wish you a safe journey home."), (str_store_string, s17, "@Neither good, nor bad. Our business is our own."), (str_store_string, s18, "@Everybody on his way, then."), (else_try), # bad guys (str_store_string, s14, "@What are you trying to do, {s20} scum? Steal our spoils?"), (str_store_string, s15, "@Ha! Soon there will be spoils for everybody."), (str_store_string, s16, "@Yes. Unless you get killed first."), (str_store_string, s17, "@You don't get any spoils if YOU get killed, scum of {s21}."), (str_store_string, s18, "@Is that a threat? Be thankful that we have enemies around to slaughter before it is your turn."), (try_end), (try_end), ]), # "script_str_store_battle_cry" (stringNo, PartyNo) (mtarini) # used in prebattle dialog ("str_store_party_battle_cry_in_s4", [ (store_script_param_1, ":partyA"), (store_script_param_2, ":defending"), (store_faction_of_party, ":factionA",":partyA"), # note: we get the *dominant* race of player party, so that he sees differnt things said to him according to who he is accompaning him # note: we get the *dominant* race of player party, so that he sees differnt things said to him according to who he is accompaning him (call_script, "script_party_get_dominant_faction", "p_main_party"),(assign,":factionB",reg0), #(store_faction_of_party, ":facB","p_main_party"), (troop_get_type, ":raceA" , "$g_talk_troop"), (call_script, "script_party_get_dominant_race", "p_main_party"),(assign,":raceB",reg0), #(troop_get_type, ":raceB" , "trp_player"), (faction_get_slot, ":sideA",":factionA", slot_faction_side), (faction_get_slot, ":sideB",":factionB", slot_faction_side), (call_script, "script_get_region_of_party", "p_main_party"), (assign, ":region", reg1), (call_script, "script_region_get_faction", ":region", ":sideA" ), (assign, ":factionR", reg1), # semplify all human races into "human" (try_begin), (neg|is_between, ":raceB", tf_orc_begin, tf_orc_end), (neg|is_between, ":raceB", tf_elf_begin, tf_elf_end), (neq, ":raceB", tf_dwarf), (neq, ":raceB", tf_troll), (assign, ":raceB", tf_male), (try_end), (try_begin), (neg|is_between, ":raceA", tf_orc_begin, tf_orc_end), (neg|is_between, ":raceA", tf_elf_begin, tf_elf_end), (neq, ":raceA", tf_dwarf), (assign, ":raceA", tf_male), (try_end), (str_clear, s14),(str_clear, s15),(str_clear, s16),(str_clear, s17),(str_clear, s18),(str_clear, s19), (str_store_faction_name, s16, ":factionA"), (call_script, "script_str_store_race_adj", s15, ":raceB"), (try_begin), (eq, ":raceB", tf_male), (str_store_string, s19, "@{s15} "), (try_end), (str_store_faction_name, s18, ":factionB"), # s14: possible incipit for when speaker is attacked (try_begin), (eq, ":defending", 1), (store_random_in_range, ":rand", 0,4), (try_begin),(eq,":rand", 0), (str_store_string, s14, "@The enemy is upon us! ^"), (else_try),(eq,":rand", 1), (str_store_string, s14, "@They are upon us! ^"), (else_try),(eq,":rand", 3), (str_store_string, s14, "@{playername} and {his/her} rabble from {s18} is upon us! ^"), (try_end), (try_end), (store_add, reg2, str_shortname_region_begin , ":region"), (try_begin), (ge, ":region", region_rhun), (store_sub, reg2, ":region", region_rhun), (val_add, reg2, str_shortname_region_begin_new), (try_end), (str_store_string,s17,reg2), (str_clear, s4), # for war cryes, you can use: # -- factionA, sideA, raceA: faction, side, race of party WHICH IS TALKING # -- factionB, sideB, raceB: faction, side, race of enemy of A (i.e. player) # -- region, factionR: the region where the battle takes pace, and the faction of that region # s14: "They are attacking", if A is being attacked, or nothing (empty string) # s15: adjective for raceB # s16: faction name of A # s17: short region name # s18: faction name of B # s19: adjective for raceB, but nothing if human (assign, ":done", 0), # first pass will fail (assign, ":rand", -1), # first pass will fail (try_for_range, ":i", 0, 2000), (eq, ":done", 0), (try_begin),(eq,":rand",first_count()), (eq, ":defending", 1), (neg|is_between, ":raceA", tf_orc_begin, tf_orc_end), (is_between, ":raceB", tf_orc_begin, tf_orc_end), (str_store_string, s4, "@ORCS! ORCS!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":defending", 1), (eq, ":sideB", faction_side_good), (neg|is_between, ":factionA", kingdoms_begin, kingdoms_end), # civilians (is_between, ":raceB", tf_orc_begin, tf_orc_end), (str_store_string, s4, "@ORCS! ORCS! Fight for your life!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":defending", 1), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (is_between, ":raceB", tf_elf_begin, tf_elf_end), (str_store_string, s4, "@Elven ghosts!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":defending", 1), (eq, ":sideA", faction_side_good), (str_store_string, s4, "@Here they come! Hold ranks!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":defending", 1), (str_store_string, s4, "@We are under attack!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":defending", 1), (eq, ":factionB", fac_rohan), (str_store_string, s4, "@Horse people! The horse people are upon us!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":defending", 1), (eq, ":factionB", fac_gondor), (str_store_string, s4, "@Men from the White City? Let them come, to their death!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (eq, ":raceB", tf_male), (str_store_string, s4, "@Death to men!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (is_between, ":raceB", tf_orc_begin, tf_orc_end), (str_store_string, s4, "@Kill the maggots!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":sideA", faction_side_eye ), (eq, ":sideB", faction_side_hand ), (str_store_string, s4, "@Death to traitors of the Eye!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":sideA", faction_side_hand ), (eq, ":sideB", faction_side_eye ), (str_store_string, s4, "@Death to traitors of the White Hand!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":sideB", faction_side_good), (str_store_string, s4, "@{s14}Kill them all! Take no prisoners!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (str_store_string, s4, "@Tonight we feast on {s15} flesh!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (str_store_string, s4, "@Gharr! Kill! Kill! Kill!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":raceB", tf_dwarf), (str_store_string, s4, "@Slaughter these half men!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceB", tf_elf_begin, tf_elf_end), (str_store_string, s4, "@Fear no elven ghosts!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":raceA", tf_male), (eq, ":raceB", tf_male), (eq, ":sideB", faction_side_good), (str_store_string, s4, "@{s14}Double rations to the one bringing me the most heads!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":sideB", faction_side_good), (this_or_next|is_between, ":raceA", tf_orc_begin, tf_orc_end), (neq, ":raceB", tf_male), (str_store_string, s4, "@{s14}Double rations to the one bringing me the most {s15} heads!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_dunland), (eq, ":factionB", fac_rohan), (str_store_string, s4, "@{s14}Kill these horse thieves!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_dunland), (eq, ":factionB", fac_rohan), (str_store_string, s4, "@Kill them all! Take back what is ours!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":sideA", faction_side_good ), (str_store_string, s4, "@Tonight there will be one less enemy of {s16}!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_dwarf), (str_store_string, s4,"@Baruk Khazâd! Khazâd ai-mênu!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_rohan ), (str_store_string, s4,"@{s14}Riders of Rohan! Remember what you fight for!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_mordor), (str_store_string, s4,"@{s14}More {s19}heads to decorate the gates of Morannon!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_isengard), (str_store_string, s4,"@The Wise Master shall be pleased when I show him the body of {playername}!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_elf_begin, tf_elf_end), (is_between, ":raceB", tf_orc_begin, tf_orc_end), (str_store_string, s4,"@{s14}Now we will put an end to the suffering of these foul things."), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_imladris), (str_store_string, s4,"@{s14}Today we shall battle the enemies of Imladris and all that is fair."), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_elf_begin, tf_elf_end), (is_between, ":region", region_n_mirkwood, region_s_mirkwood+1), (str_store_string, s4,"@All who enter Mirkwood with malice shall never leave!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":raceA", tf_male), (eq, ":sideA", faction_side_good), (eq, ":defending", 1), (str_store_string, s4,"@Men of {s16}, the enemy is here! Fight for your land!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":raceA", tf_male), (eq, ":sideA", faction_side_good), (eq, ":defending", 0), (str_store_string, s4,"@Men of {s16}, charge! Fight for your land!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_harad), (str_store_string, s4,"@{s14}Grind their bodies into the sand!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_rhun), (eq, ":raceB", tf_dwarf), (str_store_string, s4,"@{s14}Dwarves or men, they are no match for our fierceness!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_rhun), (is_between, ":raceB", tf_elf_begin, tf_elf_end), (str_store_string, s4,"@{s14}Elves or men, they are no match for our fierceness!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":factionA", fac_rhun, fac_khand+1), (str_store_string, s4,"@{s14}Flesh to shatter, throats to cut, blood to spill!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_khand), (str_store_string, s4,"@Put on the masks of warriors, men! Today the doom falls upon our enemies from {s18}!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_umbar), (eq, ":defending", 1), (str_store_string, s4,"@They seek the tempest, and they shall have it! Men, prepare to fight!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_umbar), (eq, ":defending", 0), (str_store_string, s4,"@Draw your weapons, men, for tempest is unleashed upon our enemies!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (is_between, ":factionA", kingdoms_begin, kingdoms_end), (str_store_string, s4,"@Orcs of {s16}, get ready! Here are a few throats for you to cut!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_guldur), (neg|is_between, ":raceB", tf_elf_begin, tf_elf_end), (str_store_string, s4,"@These friend of elves will fall under our blades!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceB", tf_elf_begin, tf_elf_end), (str_store_string, s4,"@These Elves will fall under our blades!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (is_between, ":factionA", kingdoms_begin, kingdoms_end), (str_store_string, s4,"@Raahh! Draw your weapons, scum of {s16}! Tonight we feast on {s15} entrails!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (is_between, ":raceA", tf_orc_begin, tf_orc_end), (str_store_string, s4,"@Rha! {s14}More {s15} bodies to disfigure with our twisted weapons!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionB", fac_dunland), (str_store_string, s4,"@Slaughter these puny thieves of {s18} now! Then we burn their homes and cut down their families."), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", ":factionR"), (eq, ":defending", 0), (neq, ":factionA", fac_umbar), (str_store_string, s4,"@Death to the trespassers of the lands of {s16}!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":sideA", faction_side_good), (eq, ":factionA", ":factionR"), (eq, ":defending", 0), (str_store_string, s4,"@CHARGE! Let's clear the {s18} {s19}scum from {s17}!"), (assign, ":done", 1), (else_try),(eq,":rand",next_count()), (eq, ":factionA", fac_beorn), (str_store_string, s4,"@{s14}Now that {s19}scum will taste the fury of the bear people!"), (assign, ":done", 1), (try_end), # end of pass: roll a number beween 0 and N_POSSIBILITIES - 1 for next pass (store_random_in_range, ":rand", 0, next_count() ), # fix for uneven randomization... (val_add, ":rand", ":i"), (val_mod, ":rand", curr_count() ), (try_end), (assign, reg55, curr_count() ), (assign, reg40, ":defending"), (assign, reg41,":factionA"), (assign, reg42,":factionB"), (assign, reg43,":factionR"), (assign, reg44,":sideA"), (assign, reg45,":sideB"), (assign, reg46,":raceA"), (assign, reg47,":raceB"), (assign, reg48,":region"), # (display_message, "@DEBUG: def:{reg40} Fac:({reg41},{reg42},{reg43}). Sid:({reg44},{reg45}). Rac:({reg46},{reg47}). Region:{reg48}"), # default battle cries, if no good one found (try_begin),(eq, ":done", 0), (try_begin), (encountered_party_is_attacker), (str_store_string, s4, "@Attack!"), (else_try), (str_store_string, s4, "@We are under attack!"), (try_end), (try_end), ]), # regions... put results in reg1 (mtarini) ("get_region_of_party", [ (store_script_param_1, ":party"), (party_get_current_terrain, ":t",":party"), (party_get_position, pos1, ":party"), #Kham - fixed, used to be 'p_main_party' (call_script,"script_get_region_of_pos1", ":t"), ]), # regions... of a pos: put results in reg1 (mtarini) # first parameter: terrain type # script_get_region_of_pos1 ("get_region_of_pos1", [ (store_script_param_1, ":terrain_type"), (position_get_x,":x",pos1),(position_get_y,":y",pos1), #(store_add,":sum", ":x",":y"), (store_sub,":diff", ":x",":y"), (set_fixed_point_multiplier,100.0), #(assign, reg5,":x"),(assign, reg6,":y"),(convert_to_fixed_point,reg5),(convert_to_fixed_point,reg6),(display_message,"@you are in ({reg5},{reg6})..."), (assign, reg1, -1), (try_begin), # mordor? (is_between, ":x", -20800, -7784 ),(is_between, ":y", -3190, 8500), (assign, reg1, region_mordor), (else_try), # dead marshes? (ge, ":x", -6800), (ge, ":y", -4900), (store_add,":h",":y",":x"), (lt, ":h", -8000), (eq, ":terrain_type", rt_swamp), (assign, reg1, region_dead_marshes), (else_try), # ithilien? (north or south) (is_between, ":x", -7800, -5700 ),(is_between, ":y", -2243, 6500), (try_begin),(ge,":y",4700), (assign, reg1, region_s_ithilien), (else_try),(ge,":y",2460), (assign, reg1, region_c_ithilien), (else_try), (assign, reg1, region_n_ithilien), (try_end), (else_try), # # s _ ithilien? (second chance) (is_between, ":x", -8000, -3400 ),(is_between, ":y", 6000,8500), (lt, ":diff", -10650), (assign, reg1, region_s_ithilien), (else_try), # entwash? (delta entwash or wetwand) (position_set_x,pos20,-3800),(position_set_y,pos20,-2000),(position_set_z,pos20,0.0), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",1950), (try_begin), (position_set_x,pos20,-5500),(position_set_y,pos20,-2200),(position_set_z,pos20,0.0), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",2200), (assign, reg1, region_wetwang), (else_try), (this_or_next|eq, ":terrain_type", rt_swamp), (eq, ":terrain_type", rt_snow_forest), (assign, reg1, region_entwash), (try_end), (gt, reg1, 0), (else_try), # lorien forest? (is_between, ":x", -1200, 2910),(is_between, ":y", -14100, -12143), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_lorien), (else_try), # lorien 2 (party_get_position, pos20, "p_town_cerin_dolen"), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",800), (assign, reg1, region_lorien), (else_try), #pelennor fields? (position_set_x,pos20,-500),(position_set_y,pos20,-13100),(position_set_z,pos20,0), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",700), (assign, reg1, region_lorien), (else_try), #pelennor fields? (position_set_x,pos20,-5306),(position_set_y,pos20,+2132),(position_set_z,pos20,0), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",700), (assign, reg1, region_pelennor), (else_try), #pelennor fields 2nd chance (party_get_position, pos20 ,"p_town_minas_tirith"), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",600), #make it slightly bigger than Minas Tirith landmark range (350) (assign, reg1, region_pelennor), (else_try), # c_ ithilien? (second chance, after Pelennor) (position_set_x,pos20,-6000),(position_set_y,pos20,3700),(position_set_z,pos20,0.0), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",1150), (assign, reg1, region_c_ithilien), (else_try), # s _ ithilien? (second chance, after c_ithilien) (position_set_x,pos20,-6400),(position_set_y,pos20,5900),(position_set_z,pos20,0.0), (get_distance_between_positions,":dist",pos1,pos20), (lt,":dist",1900), (assign, reg1, region_s_ithilien), (else_try), # determine on which side of the white mountains... #(store_mul,":k",":x",374.4),(store_mul,":k2",":y",1000), (val_add,":k",":k2"), #(ge,":k",725184), # IF somethings fails, uncomment reg 0 save/restoration #(assign,:"tmp",reg0), (copy_position, pos10, pos1), (call_script,"script_pos10_which_side_of_white_mountains"), #(assign,":side_of_wm",reg0),(assign,reg0,":tmp"), (eq,reg0,1), # SOUTH of white mountains... pick region by GONDOR subfaction town proximity of gondor (assign, reg1, region_lebennin), (assign, ":min_dist", 1000000), (try_for_range, ":i", "p_town_pelargir" , "p_town_edoras" ), # scan all gondor fiefdom cityes (party_get_slot, ":fief", ":i", slot_party_subfaction), (gt, ":fief", 0), (party_get_position,pos20,":i"), (get_distance_between_positions, ":dist", pos20, pos1), (try_begin), (le, ":dist", ":min_dist"), (store_add, reg1, region_pelennor, ":fief"), (assign, ":min_dist", ":dist"), (try_end), (try_end), (else_try), # NORTH of white mountains... # #### # drudan forsest? (is_between, ":x", -4636, -3400),(is_between, ":y", +941, 1997), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_druadan_forest), (else_try), # firien_wood? (is_between, ":x", -3345, -1792),(is_between, ":y", +80, 1449), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_firien_wood), (else_try), # helm's deep? (party_get_position,pos20,"p_town_hornburg"), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 700), (assign, reg1, region_hornburg), (else_try), # harrowdale? (valley where edoras is) (is_between, ":x", 1958, 2515),(is_between, ":y", -1778, -501), (assign, reg1, region_harrowdale), (else_try), # anorien? between entwash and white mountains (position_set_x,pos20,-4390),(position_set_y,pos20,+1540),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1950), (assign, reg1, region_anorien), (try_begin), (position_set_x,pos20,-5800),(position_set_y,pos20,+100),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 600), (assign, reg1, region_cair_andros), (try_end), (else_try), # around isengard? (position_set_x,pos20,5300),(position_set_y,pos20,-5600),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1100), (assign, reg1, region_isengard), (else_try), # gap of rohan? (is_between, ":x", 4856, 6269),(is_between, ":y", -4215,-2812), (assign, reg1, region_gap_of_rohan), (else_try), # fangorn? (position_set_x,pos20,4650),(position_set_y,pos20,-8550),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 3050), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_fangorn), (else_try), # the region_emyn_muil? (position_set_x,pos20,-4300),(position_set_y,pos20,-5500),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1500), (lt, ":x", -3485), (assign, reg1, region_emyn_muil), (else_try), # Western Emyn Muil (position_set_x,pos20,-3350),(position_set_y,pos20,-5650),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1250), (assign, reg1, region_w_emyn_muil), (else_try), # East Emnet 1 (is_between, ":x", -2700, 800),(is_between, ":y", -6900,-3100), (assign, reg1, region_east_emnet), (else_try), # evertything else, in a BIG region, is in rohan... (is_between, ":x", -3557,5893 ),(is_between, ":y", -6900, 1057), # pick emnet (assign, reg1, region_east_emnet), (assign, ":min_dist", 1000000), (try_for_range, ":i", "p_town_east_emnet" , "p_town_morannon" ), # scan all rohan "emnet/fold" cityes (party_get_slot, ":fief", ":i", slot_party_subfaction), (gt, ":fief", 0), (party_get_position,pos20,":i"), (get_distance_between_positions, ":dist", pos20, pos1), (try_begin), (le, ":dist", ":min_dist"), (store_add, reg1, region_harrowdale, ":fief"), (assign, ":min_dist", ":dist"), (try_end), (try_end), (else_try), # the dagorlad? (is_between, ":x",-9371, -3474),(is_between, ":y",-6081 , -2932), (assign, reg1, region_dagorlad), (else_try), # N Ithilien 2 (is_between, ":x",-7800, -4700),(is_between, ":y",-3000 , -200), (assign, reg1, region_n_ithilien), (else_try), # the s updeep? (position_set_x,pos20,-3650),(position_set_y,pos20,-8150),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 450), (assign, reg1, region_s_undeep), (else_try), # the n updeep? (position_set_x,pos20,-3050),(position_set_y,pos20,-9650),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 550), (assign, reg1, region_n_undeep), (else_try), # the wold? (is_between, ":x", -3500,3000 ),(is_between, ":y", -9800, -6514), (assign, reg1, region_the_wold), (else_try), # the wold 2 (position_set_x,pos20,-3600),(position_set_y,pos20,-8950),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 400), (assign, reg1, region_the_wold), (else_try), # South of Erebor? (Realm of Dale) (is_between, ":x", -6800, -5558 ),(is_between, ":y", -22800, -21875), (assign, reg1, region_s_erebor), (else_try), # Erebor foothills (position_set_x,pos20,-6143),(position_set_y,pos20,-23085),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1100), (assign, reg1, region_erebor), (else_try), # c Mirkwood (is_between, ":x", -8100, -1900),(is_between, ":y", -19800, -15600), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_c_mirkwood), (else_try), # c.mirkwood?, road is still mirkwood (is_between, ":x", -7500,-2000),(is_between, ":y", -19929, -18581), (assign, reg1, region_c_mirkwood), (else_try), # n.mirkwood? (is_between, ":x", -8041, -28),(is_between, ":y", -29935, -19881), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_n_mirkwood), (else_try), # s.mirkwood? (is_between, ":x", -9828,-1943),(is_between, ":y", -15600, -11829), (is_between, ":terrain_type", rt_forest_begin,rt_forest_end), (assign, reg1, region_s_mirkwood), (else_try), # s.mirkwood?, dol gundur is still mirkwood (is_between, ":x", -4595, -3750),(is_between, ":y", -13519, -12885), (assign, reg1, region_s_mirkwood), (else_try), # Rhun/Eastern Rhovanion (lt, ":x", -6700), (assign, reg1, region_rhun), (else_try), # grey mts 1 (position_set_x,pos20,150),(position_set_y,pos20,-24750),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1850), (assign, reg1, region_grey_mountains), (else_try), # N Anduin Vale 1 (position_set_x,pos20,2740),(position_set_y,pos20,-23850),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1450), (assign, reg1, region_n_anduin_vale), (else_try), # N Anduin Vale 2 (position_set_x,pos20,1200),(position_set_y,pos20,-22500),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 1600), (assign, reg1, region_n_anduin_vale), (else_try), # N Anduin Vale 3 (is_between, ":x", -1900, 1800 ),(is_between, ":y", -21900, -19700), (assign, reg1, region_n_anduin_vale), (else_try), # grey mts 2 (is_between, ":x", -12230, -100 ),(is_between, ":y", -32120, -23000), (assign, reg1, region_grey_mountains), (else_try), # n Mirkwood 2 (fill the gaps) (is_between, ":x", -6800, -300 ),(is_between, ":y", -23000, -19800), (assign, reg1, region_n_mirkwood), (else_try), # Souther Misty Mts, south of Moria (position_set_x,pos20,4850),(position_set_y,pos20,-11950),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 2500), (assign, reg1, region_s_misty_mountains), (else_try), # Dimrill Dale? (is_between, ":x", 3380, 5900 ),(is_between, ":y", -15396, -13843), (assign, reg1, region_dimrill), (else_try), # N Misty Mountains (is_between, ":x", 1800,6000),(is_between, ":y", -23809,-13400), (assign, reg1, region_misty_mountains), (else_try), # Gladden fields (position_set_x,pos20,-140),(position_set_y,pos20,-15500),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (ge, ":x", -570), (le, ":dist", 1250), (assign, reg1, region_gladden_fields), (else_try), (is_between, ":x", -5800,1800),(is_between, ":y", -19800,-13200), (assign, reg1, region_anduin_banks), (else_try), # S Anduin Vale (position_set_x,pos20,-3200),(position_set_y,pos20,-12800),(position_set_z,pos20,0), (get_distance_between_positions, ":dist", pos20, pos1), (le, ":dist", 2100), (assign, reg1, region_s_anduin_vale), (try_begin), # where anduin vale and brown lands overlap, check terrain type (is_between, ":x", -8005,-2900 ),(is_between, ":y", -11900, -5200), (this_or_next|eq, ":terrain_type", rt_steppe), (eq, ":terrain_type", rt_desert), (assign, reg1, region_brown_lands), (try_end), (else_try), # the brown_lands? (is_between, ":x", -8005,-2900 ),(is_between, ":y", -11900, -5200), (assign, reg1, region_brown_lands), (else_try), # Celebrant (is_between, ":x", -2900,3100), (is_between, ":y", -13200,-9800), (assign, reg1, region_celebrant), (try_end), ]), ("tld_party_relocate_near_party", [ (store_script_param_1, ":pa"), (store_script_param_2, ":pb"), (store_script_param, ":dist",3), (call_script, "script_party_which_side_of_white_mountains", ":pb"), (assign, ":pb_is_south", reg0), (try_for_range, ":i", 0, 40), # try 40 times (party_relocate_near_party, ":pa", ":pb",":dist"), (assign, ":pa_is_south", 0), (call_script, "script_party_which_side_of_white_mountains", ":pa"), (assign, ":pa_is_south", reg0), (eq,":pa_is_south",":pb_is_south"), (assign, ":i", 20), # break (try_begin), (ge,":i",39), (display_message, "@TLD ERROR! could not spawn the party on the same side of the white mountains"), (try_end), (try_end), ]), # script_region_get_faction: (mtarini) # given a region, it return (in reg1) the "default faction" ruling in that region, if any (else, -1) (matrini) # parameter 2: BIAS: use thinking of this side (good, eye, hand), or -1 if no bias ("region_get_faction", [ (store_script_param_1, ":region_id"), (store_script_param_2, ":bias"), (try_begin), (eq,":region_id", region_gap_of_rohan), (ge, ":bias", faction_side_eye), (assign, reg1, fac_dunland), (else_try),(is_between,":region_id", region_n_ithilien, region_c_ithilien+1), (ge, ":bias", faction_side_eye), (assign, reg1, fac_mordor), (else_try), (eq,":region_id", region_s_ithilien), (ge, ":bias", faction_side_eye), (assign, reg1, fac_harad), (else_try), (eq,":region_id", region_befalas), (ge, ":bias", faction_side_eye), (assign, reg1, fac_umbar), (else_try), (is_between,":region_id", region_pelennor, region_harrowdale), (assign, reg1, fac_gondor), (else_try), (is_between, ":region_id", region_harrowdale, region_entwash), (assign, reg1, fac_rohan), (else_try), (eq, ":region_id", region_isengard), (assign, reg1, fac_isengard), (else_try), (eq, ":region_id", region_lorien), (assign, reg1, fac_lorien), (else_try), (eq, ":region_id", region_n_mirkwood), (assign, reg1, fac_woodelf), (else_try), (eq, ":region_id", region_brown_lands ), (assign, reg1, fac_khand), (else_try), (eq, ":region_id", region_s_mirkwood), (assign, reg1, fac_guldur), (else_try), (eq, ":region_id", region_dimrill), #InVain new regions (assign, reg1, fac_moria), (else_try), (eq, ":region_id", region_s_erebor), #InVain new regions (assign, reg1, fac_dale), (else_try), (this_or_next|eq, ":region_id", region_mordor ), (this_or_next|eq, ":region_id", region_dagorlad ), (eq, ":region_id", region_emyn_muil ), (assign, reg1, fac_mordor), (else_try), (assign, reg1, -1), # no man land (try_end) ]), # script_jump_to_random_scene (GA and mtarini) # Input: arg1 = region code # Input: arg2 = terrain type # Input: arg3 = visible landmark (if any, else -1) # Output: none ("jump_to_random_scene", [ (store_script_param, ":region",1), (store_script_param, ":terrain",2), (store_script_param, ":landmark",3), #(assign, reg10, ":landmark"),(display_message,"@LANDMARK: {reg10}"), (assign,":small_scene",0), (assign, "$small_scene_used", 0), (try_begin),(lt,"$number_of_combatants",70),(assign,":small_scene",1), # small scene variants are right after standard ones in module_scenes (else_try),(lt,"$enemy_count1",30), (assign,":small_scene",1), # no point in walking half an hour to stomp couple orcs (try_end), # in the following, according to region and terrain type, setup the first, the second, or both these variables: (assign, ":native_terrain_to_use", -1), # this is you need random terrain generation using a ground level vanilla terrain (assign, ":scene_to_use", -1), # this if you want to use a specific scene (assign, "$bs_day_sound", "snd_wind_ambiance"), # default ambience (assign, "$bs_night_sound", "snd_wind_ambiance"), (try_begin), (eq,":landmark","p_town_erebor"), (assign, "$small_scene_used", 1), (assign,":scene_to_use","scn_erebor_outside"), (else_try), (eq,":landmark","p_town_minas_tirith"), (assign,":scene_to_use","scn_minas_tirith_outside"), #InVain new landmark scenes begin (else_try), (eq,":landmark","p_town_edoras"), (store_random_in_range, ":scene_to_use", "scn_edoras_outside_1", "scn_hornburg_outside_1"), (else_try), (eq,":landmark","p_town_hornburg"), #Right outside Hornburg, this must be before region_hornburg (assign,":scene_to_use","scn_hornburg_near"), (else_try), #Region Hornburg / Helms Deep (eq,":region",region_hornburg), (store_random_in_range, ":scene_to_use", "scn_hornburg_outside_1", "scn_dolamroth_outside_1"), (else_try), (eq,":landmark","p_town_dol_amroth"), (assign, ":native_terrain_to_use", rt_plain), # gondor default (store_random_in_range, ":scene_to_use", "scn_dolamroth_outside_1", "scn_morannon_outside_1"), # (assign, "$bs_day_sound", "snd_seaside_occasional"), (else_try), (eq,":landmark","p_town_morannon"), (store_random_in_range, ":scene_to_use", "scn_morannon_outside_1", "scn_dolguldur_outside_1"), (assign, "$bs_day_sound", "snd_morgul_ambiance"), (assign, "$bs_night_sound", "snd_morgul_ambiance"), (else_try), (eq,":landmark","p_town_dol_guldur"), (store_random_in_range, ":scene_to_use", "scn_dolguldur_outside_1", "scn_beorn_outside_1"), (assign, "$small_scene_used", 1), (assign, "$bs_day_sound", "snd_evilforest_ambiance"), (assign, "$bs_night_sound", "snd_evilforest_ambiance"), (else_try), (eq,":landmark","p_town_beorn_house"), (store_random_in_range, ":scene_to_use", "scn_beorn_outside_1", "scn_moria_outside_1"), (assign, "$bs_day_sound", "snd_bees_birds_ambiance"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (eq,":landmark","p_town_moria"), #InVain: Keep this BEFORE region_dimrill! (store_random_in_range, ":scene_to_use", "scn_moria_outside_1", "scn_dimrill_dale"), # (assign, "$bs_day_sound", "snd_tirith_top_occasional"), (else_try), (eq,":region",region_dimrill), (assign, ":native_terrain_to_use", rt_mountain_forest), (assign,":scene_to_use","scn_dimrill_dale"), #randomized # (assign, "$bs_day_sound", "snd_tirith_top_occasional"), (else_try), (eq,":landmark","p_town_esgaroth"), #InVain: Keep this BEFORE region_s_erebor! (assign, ":native_terrain_to_use", rt_steppe), (store_random_in_range, ":scene_to_use", "scn_esgaroth_outside_1", "scn_s_erebor"), (else_try), (eq,":region",region_s_erebor), (assign, ":native_terrain_to_use", rt_steppe), (store_random_in_range, ":scene", 0, 4), (try_begin), (eq, ":scene",0), (assign,":scene_to_use","scn_dale_village_battlefield_1"), (else_try), (assign,":scene_to_use","scn_s_erebor"), (try_end), (else_try), (this_or_next|eq,":landmark","p_town_calembel"), (eq, ":region", region_lamedon), (store_random_in_range, ":scene", 0, 8), (eq, ":scene",0), (assign,":scene_to_use","scn_gondor_battlefield_morgul"), (else_try), (this_or_next|eq,":landmark","p_town_west_osgiliath"), #InVain: Keep this BEFORE Ithilien / Emyn Arnen. Otherwise we get forest scenes in Osgiliath. (eq,":landmark","p_town_east_osgiliath"), (assign, "$small_scene_used", 1), (store_random_in_range, ":scene", 0, 4), (try_begin), (eq, ":scene",0), (assign,":scene_to_use","scn_osgiliath_outskirts"), (else_try), (eq, ":scene",1), (assign,":scene_to_use","scn_osgiliath_outskirts_2"), (else_try), (eq, ":scene",2), (assign,":scene_to_use","scn_osgiliath_outskirts_3"), (else_try), (assign,":scene_to_use","scn_osgiliath_outskirts_4"), (try_end), (else_try), #coastal scenes (this_or_next|eq,":landmark","p_town_linhir"), #InVain: Keep this BEFORE region_lebennin and the other Gondor regions (this_or_next|eq,":landmark","p_town_tarnost"), (eq,":landmark","p_town_umbar_camp"), (assign, "$small_scene_used", 1), (store_random_in_range, ":scene", 0, 4), (try_begin), (eq, ":scene",0), (assign,":scene_to_use","scn_lebennin_coast_1"), (else_try), (eq, ":scene",1), (assign,":scene_to_use","scn_lebennin_coast_2"), (else_try), (eq, ":scene",2), (assign, ":native_terrain_to_use", rt_plain), (assign,":scene_to_use","scn_lebennin_coast_3"), #randomized scene in half of tries (else_try), (assign, ":native_terrain_to_use", rt_plain), (assign,":scene_to_use","scn_lebennin_coast_3"), #randomized scene in half of tries (try_end), (else_try), #Custom Lebennin scenes (eq,":region",region_lebennin), #InVain: Keep this AFTER coastal scenes (store_random_in_range, ":scene", 1, 100), (try_begin), (is_between,":scene",1,10), (assign,":scene_to_use","scn_lebennin_1"), #custom flower hills (else_try), (is_between,":scene",10,20), (assign,":scene_to_use","scn_lebennin_2"), #custom flower hills (else_try), (is_between,":scene",20,30), (assign,":scene_to_use","scn_lebennin_3"), #custom flower hills (else_try), (is_between,":scene",30,40), (assign,":scene_to_use","scn_lebennin_4"), #custom flower hills (else_try), (is_between,":scene",40,42), (assign,":scene_to_use","scn_village_gondor_battlefield_1"), # Gondor village (else_try), (is_between,":scene",42,44), (assign,":scene_to_use","scn_village_gondor_battlefield_2"), # Gondor village (else_try), (is_between,":scene",44,46), (assign,":scene_to_use","scn_scout_camp_gondor_battlefield_1"), # Gondor village ruins (else_try), (is_between,":scene",46,48), (assign,":scene_to_use","scn_scout_camp_gondor_battlefield_2"), # Gondor village ruins (else_try), (assign, ":native_terrain_to_use", rt_plain), # gondor default (try_end), (else_try), #Pelennor fields (eq,":region",region_pelennor), #InVain: Keep this AFTER Minas_Tirith_outside and Osgiliath_Outskirts landmark scenes! (store_random_in_range, ":scene_to_use", "scn_pelennor_1", "scn_village_gondor_battlefield_1"), #InVain new landmark scenes end (else_try), (eq,":landmark","p_town_isengard"), (assign, ":native_terrain_to_use", rt_steppe), (assign,":scene_to_use","scn_isengard_outside"), # (else_try), # (eq,":landmark","p_hand_isen"), # (assign,":scene_to_use","scn_handsign"), # randomize this scene (else_try), (is_between,":landmark", fords_big_begin, fords_big_end), # Anduin fords (store_mod, ":tmp", ":landmark", 3), #3 big fords scenes (store_add, ":scene_to_use", "scn_ford_big1", ":tmp"), #(store_random_in_range, ":scene_to_use", "scn_ford_big1", "scn_ford_small1"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (is_between,":landmark", fords_small_begin, fords_small_end), # Anduin fords (store_mod, ":tmp", ":landmark", 3), #3 small fords scenes (store_add, ":scene_to_use", "scn_ford_small1", ":tmp"), #(store_random_in_range, ":scene_to_use", "scn_ford_small1", "scn_erebor_siege"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (eq,":landmark", landmark_great_east_road ), (assign, ":native_terrain_to_use", rt_steppe), (assign,":scene_to_use","scn_great_east_road"), (else_try), (eq,":landmark", landmark_old_forest_road ), (assign,":scene_to_use","scn_old_forest_road"), (else_try), (eq,":region",region_dead_marshes), (assign,":scene_to_use","scn_deadmarshes"), (assign, "$bs_day_sound", "snd_deadmarshes_ambiance"), (assign, "$bs_night_sound", "snd_deadmarshes_ambiance"), (else_try), (this_or_next|eq,":region",region_firien_wood), (eq,":region",region_druadan_forest), (assign, "$small_scene_used", 1), (store_random_in_range, ":scene_to_use", "scn_forest_firien1", "scn_forest_end"), (assign, "$bs_day_sound", "snd_neutralforest_ambiance"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (eq,":region",region_lorien), (assign, "$small_scene_used", 1), (store_random_in_range, ":scene_to_use", "scn_forest_lorien1", "scn_forest_mirkwood_small1"), (assign, "$bs_day_sound", "snd_neutralforest_ambiance"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (eq,":region",region_fangorn), (assign, "$small_scene_used", 1), (store_random_in_range, ":scene_to_use", "scn_forest_fangorn1", "scn_forest_ithilien_small1"), (assign, "$bs_day_sound", "snd_fangorn_ambiance"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (eq,":region",region_n_mirkwood), (assign, "$small_scene_used", 1), (try_begin), (eq, ":small_scene", 1), (store_random_in_range, ":scene_to_use", "scn_forest_mirkwood_small1", "scn_forest_firien1"), (else_try), (store_random_in_range, ":scene_to_use", scn_forest_mirkwood0, scn_forest_mirkwood6), (try_end), (assign, "$bs_day_sound", "snd_evilforest_ambiance"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (is_between,":region",region_s_mirkwood,region_c_mirkwood+1), (assign, "$small_scene_used", 1), (try_begin), (eq, ":small_scene", 1), (store_random_in_range, ":scene_to_use", "scn_forest_mirkwood_small1", "scn_forest_firien1"), (else_try), (store_random_in_range, ":scene_to_use", scn_forest_mirkwood1, scn_forest_mirkwood9+1), (try_end), (assign, "$bs_day_sound", "snd_evilforest_ambiance"), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), (is_between,":region",region_n_ithilien,region_s_ithilien+1), (try_begin), (eq, ":small_scene", 1), (assign, "$small_scene_used", 1), (store_random_in_range, ":scene_to_use", "scn_forest_ithilien_small1", "scn_forest_lorien1"), (else_try), (store_random_in_range, reg1, 0,5), (try_begin),(ge, reg1, 2),(store_random_in_range, ":scene_to_use", "scn_forest_ithilien1", scn_forest_ithilien6+1), (else_try),(assign, ":native_terrain_to_use", rt_plain), (try_end), (try_end), (assign, "$bs_night_sound", "snd_night_ambiance"), (else_try), # occasional forest terrain, in gondor: use forest battlefield regardless of region (but gondor outer terrain) (is_between, ":terrain", rt_forest_begin, rt_forest_end), (is_between,":region",region_pelennor, region_anorien+1), (assign, ":native_terrain_to_use", rt_forest), (assign,":scene_to_use","scn_random_scene_plain_small"), # so that outer terrain of gondor is used (assign, "$bs_day_sound", "snd_neutralforest_ambiance"), (assign, "$small_scene_used", 1), (else_try), # occasional forest terrain, in rohan: use forest battlefield regardless of region (but rohan outer terrain) (is_between, ":terrain", rt_forest_begin, rt_forest_end), (is_between,":region",region_harrowdale, region_westfold+1), (assign, ":native_terrain_to_use", rt_steppe_forest), (assign,":scene_to_use","scn_random_scene_steppe_small"), # so that outer terrain of rohan is used (assign, "$bs_day_sound", "snd_neutralforest_ambiance"), (assign, "$small_scene_used", 1), (else_try), # gondor regions (is_between,":region",region_pelennor, region_anorien+1), (store_random_in_range, ":scene", 1, 200), (try_begin), (is_between,":scene",0,5), (assign,":scene_to_use","scn_village_gondor_battlefield_1"), #InVain: Gondor village (assign, "$small_scene_used", 1), (else_try), (is_between,":scene",5,10), (assign,":scene_to_use","scn_village_gondor_battlefield_2"), #InVain: Gondor village (assign, "$small_scene_used", 1), (else_try), (is_between,":scene",10,15), (assign,":scene_to_use","scn_scout_camp_gondor_battlefield_1"), #InVain: Gondor village ruins (assign, "$small_scene_used", 1), (else_try), (is_between,":scene",15,20), (assign,":scene_to_use","scn_scout_camp_gondor_battlefield_2"), #InVain: Gondor village ruins (assign, "$small_scene_used", 1), (else_try), (assign, ":native_terrain_to_use", rt_plain), # gondor default (try_end), (else_try), # dagorlad (eq,":region",region_dagorlad), (assign, ":native_terrain_to_use", rt_desert_forest), # should look more grey / drier (assign, ":scene_to_use", "scn_dagorlad_random"), (try_begin), (eq, ":small_scene", 1), (assign, ":scene_to_use", "scn_dagorlad_random_small"), (assign, "$small_scene_used", 1), (try_end), (else_try), # dry-brown regions (this_or_next|is_between,":region",region_n_undeep , region_s_undeep +1), (this_or_next|eq,":region",region_emyn_muil), (this_or_next|eq,":region",region_w_emyn_muil), (eq,":region",region_brown_lands), (assign, ":native_terrain_to_use", rt_desert_forest), (else_try), # rohan regions (this_or_next|eq,":region",region_the_wold), (is_between,":region",region_harrowdale, region_gap_of_rohan+1), (assign, ":native_terrain_to_use", rt_steppe), # rohan default (else_try), # northern regions (this_or_next|eq,":region",region_s_erebor), (this_or_next|eq,":region",region_erebor), (this_or_next|eq,":region",region_anduin_banks), (this_or_next|eq,":region",region_n_anduin_vale), (this_or_next|eq,":region",region_s_anduin_vale), (this_or_next|eq,":region",region_celebrant), (this_or_next|eq,":region",region_s_misty_mountains), (this_or_next|eq,":region",region_misty_mountains), (eq,":region",region_grey_mountains), (assign, ":native_terrain_to_use", rt_steppe_forest), (else_try), # marshes (small scene) (this_or_next|eq,":region",region_dead_marshes), (this_or_next|eq,":region",region_wetwang), (this_or_next|eq,":region",region_gladden_fields), (eq,":region",region_entwash), (eq, ":small_scene", 1), (assign, ":scene_to_use", "scn_swamp_small"), (assign, "$small_scene_used", 1), (else_try), # friendly marshes (this_or_next|eq,":region",region_gladden_fields), (eq,":region",region_entwash), (store_random_in_range, ":scene_to_use", scn_swamp_1, scn_swamp_5), (else_try), # evil marshes (this_or_next|eq,":region",region_wetwang), (eq,":region",region_dead_marshes), (store_random_in_range, ":scene_to_use", scn_swamp_4, scn_swamp_6+1), (else_try), # anything else (assign, ":native_terrain_to_use", rt_steppe), (try_end), # not set the terrain (try_begin),(gt, ":native_terrain_to_use", -1), # use native terrain autogeneration # make the terrain index SKIP the interval betweem desert (escluded) and mountain_forest (included) (try_begin),(gt ,":native_terrain_to_use",rt_desert),(val_sub,":native_terrain_to_use",rt_mountain_forest-rt_desert),(try_end), # -4 (try_begin),(neq,"$relocated",1), (assign,"$relocated",1), # don't store current location if already relocated (party_relocate_near_party,"p_pointer_player","p_main_party",0), #remember original player location (try_end), (store_random_in_range, ":radius", 1, 5), # radius around base terrain Z=0 position for seed generation (store_add, reg10, "p_pointer_z_0_begin", ":native_terrain_to_use"), (party_relocate_near_party,"p_main_party",reg10,":radius"), # teleport to requested region #(display_message,"@debug: teleporitng to party ID N. {reg10}"), (try_begin),(eq,":scene_to_use",-1), # no scene_to_use defined: use the dafault one for the selected native terrain terrain (store_add, ":scene_to_use", ":native_terrain_to_use", "scn_random_scene_steppe" ), #2 (val_sub, ":scene_to_use", 2), # -2 steppe is terrain 2 (try_begin), (eq, ":small_scene", 1), # shring scene #(le, ":native_terrain_to_use", rt_desert), # forest don't have a small version (val_add, ":scene_to_use", "scn_random_scene_steppe_small"), #+10 (val_sub, ":scene_to_use", "scn_random_scene_steppe"), # -2 go to small scene index (assign, "$small_scene_used", 1), (try_end), (try_end), (try_end), (try_begin), (ge, "$force_scene", 1), (assign, ":scene_to_use", "$force_scene"), (display_message,"@Cheat: Impose a battlefield"), (try_end), (try_begin), (eq, "$cheat_mode", 1), (assign, reg10,":scene_to_use"), (display_message,"@debug: using scene ID N. {reg10}"), (try_end), (jump_to_scene,":scene_to_use"), ]), # script_maybe_relocate_player_from_z0 (GA and mtarini) ("maybe_relocate_player_from_z0",[ (try_begin), #if "walk around place" used (eq, "$relocated", 1), (assign, "$relocated", 0), (party_relocate_near_party, "p_main_party", "p_pointer_player", 0), (try_end), ]), # script_enter_dungeon # Input: arg1 = center_no, arg2 = mission_template_no # Output: none ("enter_dungeon", [ (store_script_param_1, ":center_no"), (store_script_param_2, ":mission_template_no"), (set_jump_mission,":mission_template_no"), (party_get_slot, ":dungeon_scene", ":center_no", slot_town_prison), (modify_visitors_at_site,":dungeon_scene"),(reset_visitors), (assign, ":cur_pos", 16), (call_script, "script_get_heroes_attached_to_center_as_prisoner", ":center_no", "p_temp_party"), (party_get_num_companion_stacks, ":num_stacks","p_temp_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_temp_party",":i_stack"), (lt, ":cur_pos", 32), # spawn up to entry point 32 (set_visitor, ":cur_pos", ":stack_troop"), (val_add,":cur_pos", 1), (try_end), (set_jump_entry, 0), (jump_to_scene,":dungeon_scene"), (scene_set_slot, ":dungeon_scene", slot_scene_visited, 1), (change_screen_mission), ]), # script_enter_court # Input: arg1 = center_no # Output: none ("enter_court", [ (store_script_param_1, ":center_no"), (assign, "$talk_context", tc_court_talk), (set_jump_mission,"mt_visit_town_castle"), (party_get_slot, ":castle_scene", ":center_no", slot_town_castle), (modify_visitors_at_site,":castle_scene"), (reset_visitors), # Adding guards (party_get_slot, ":guard_troop", ":center_no", slot_town_castle_guard_troop), # -- (try_begin), (le, ":guard_troop", 0), (assign, ":guard_troop", "trp_i6_gon_tower_spearman"), (try_end), (set_visitor, 6, ":guard_troop"), (set_visitor, 7, ":guard_troop"), # Place the two hobbits; USE ENTRY POINT 8 !!! (mtarini) (try_begin), (gt, "$tld_war_began", 0), (faction_slot_eq, "fac_isengard", slot_faction_state, sfs_defeated), (eq, ":castle_scene", "scn_minas_tirith_castle"), (try_begin), (troop_slot_eq, "trp_pippin_notmet", slot_troop_met_previously, 0), (set_visitor, 8, "trp_pippin_notmet"), # a "halfling" (else_try), (set_visitor, 8, "trp_pippin"), (try_end), (else_try), (gt, "$tld_war_began", 0), (faction_slot_eq, "fac_isengard", slot_faction_state, sfs_defeated), (eq, ":castle_scene", "scn_edoras_castle"), (try_begin), (troop_slot_eq, "trp_merry_notmet", slot_troop_met_previously, 0), (set_visitor, 8, "trp_merry_notmet"), # a "halfling" (else_try), (set_visitor, 8, "trp_merry"), (try_end), (try_end), (assign, ":cur_pos", 16), (call_script, "script_get_heroes_attached_to_center", ":center_no", "p_temp_party"), (party_get_num_companion_stacks, ":num_stacks", "p_temp_party"), # Bugfix (mtarini): repristinate original af_flags... (try_for_range, ":i", 0, 32), (try_begin), (is_between, ":i", 1, 16), (mission_tpl_entry_set_override_flags, "mt_visit_town_castle", ":i", af_override_horse ), (else_try), (mission_tpl_entry_set_override_flags, "mt_visit_town_castle", ":i", af_override_horse | af_override_weapons | af_override_head | af_override_gloves ), (try_end), (try_end), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_temp_party",":i_stack"), (lt, ":cur_pos", 32), # Spawn up to entry point 31 (try_begin), #swy-- throne entry point for leader only ( eq, ":castle_scene", "scn_thranduil_hall_room"), ( eq, ":cur_pos", 16), (neq, ":stack_troop", "trp_woodelf_lord"), # -- (val_max, ":cur_pos", 17), (try_end), (set_visitor, ":cur_pos", ":stack_troop"), (try_begin), (this_or_next|eq, ":stack_troop", "trp_knight_3_11"), # Imladris elves all in helms (this_or_next|eq, ":stack_troop", "trp_knight_3_12"), (this_or_next|eq, ":stack_troop", "trp_imladris_lord"), (this_or_next|eq, ":stack_troop", "trp_lorien_lord"), (eq, ":stack_troop", "trp_mordor_lord"), # Mouth of Sauron in hood (mission_tpl_entry_set_override_flags, "mt_visit_town_castle", ":cur_pos", af_override_horse | af_override_weapons ), (try_end), (val_add,":cur_pos", 1), (try_end), # TLD NPC companions (val_max, ":cur_pos", 17), # if no one else in court, skip 16 (could be a throne) # (try_for_range, ":cur_troop", companions_begin, new_companions_end), # (this_or_next|is_between, ":cur_troop", companions_begin, companions_end), # (is_between, ":cur_troop", new_companions_begin, new_companions_end), # (troop_slot_eq, ":cur_troop", slot_troop_cur_center, ":center_no"), # (neg|main_party_has_troop, ":cur_troop"), # not already hired # (neq, ":cur_troop", "trp_npc20"), #Exception for Zigûrphel # (assign, ":on_lease", 0), # (try_begin), # (check_quest_active,"qst_lend_companion"), # (quest_slot_eq, "qst_lend_companion", slot_quest_target_troop, ":cur_troop"), # (assign, ":on_lease", 1), # (try_end), # (eq, ":on_lease", 0), # (store_faction_of_party, ":center_faction", ":center_no"), # (store_troop_faction, ":troop_faction", ":cur_troop"), # (store_relation, ":rel", ":center_faction", ":troop_faction"), # (ge, ":rel", 0), # only spawn if friendly center # (lt, ":cur_pos", 32), # spawn up to entry point 31, can have multiple companions in a single town castle # (set_visitor, ":cur_pos", ":cur_troop"), # (val_add,":cur_pos", 1), # (try_end), (jump_to_scene,":castle_scene"), (scene_set_slot, ":castle_scene", slot_scene_visited, 1), (change_screen_mission), ]), # script_find_high_ground_around_pos1 # Input: pos1 should hold center_position_no, arg1 = team_no, arg2 = search_radius (in meters) # Output: pos52 contains highest ground within meters of team leader # Destroys position registers: pos10, pos11, pos15 ("find_high_ground_around_pos1", [ (store_script_param, ":team_no", 1), (store_script_param, ":search_radius", 2), (val_mul, ":search_radius", 100), (get_scene_boundaries, pos10,pos11), #(team_get_leader, ":ai_leader", ":team_no"), (call_script, "script_team_get_nontroll_leader", ":team_no"), (assign, ":ai_leader", reg0), (agent_get_position, pos1, ":ai_leader"), (set_fixed_point_multiplier, 100), (position_get_x, ":o_x", pos1), (position_get_y, ":o_y", pos1), (store_sub, ":min_x", ":o_x", ":search_radius"), (store_sub, ":min_y", ":o_y", ":search_radius"), (store_add, ":max_x", ":o_x", ":search_radius"), (store_add, ":max_y", ":o_y", ":search_radius"), (position_get_x, ":scene_min_x", pos10), (position_get_x, ":scene_max_x", pos11), (position_get_y, ":scene_min_y", pos10), (position_get_y, ":scene_max_y", pos11), (val_max, ":min_x", ":scene_min_x"), (val_max, ":min_y", ":scene_min_y"), (val_min, ":max_x", ":scene_max_x"), (val_min, ":max_y", ":scene_max_y"), (store_div, ":min_x_meters", ":min_x", 100), (store_div, ":min_y_meters", ":min_y", 100), (store_div, ":max_x_meters", ":max_x", 100), (store_div, ":max_y_meters", ":max_y", 100), (assign, ":highest_pos_z", -10000), (copy_position, pos52, pos1), (init_position, pos15), (try_for_range, ":i_x", ":min_x_meters", ":max_x_meters"), (store_mul, ":i_x_cm", ":i_x", 100), (try_for_range, ":i_y", ":min_y_meters", ":max_y_meters"), (store_mul, ":i_y_cm", ":i_y", 100), (position_set_x, pos15, ":i_x_cm"), (position_set_y, pos15, ":i_y_cm"), (position_set_z, pos15, 10000), (position_set_z_to_ground_level, pos15), (position_get_z, ":cur_pos_z", pos15), (try_begin), (gt, ":cur_pos_z", ":highest_pos_z"), (copy_position, pos52, pos15), (assign, ":highest_pos_z", ":cur_pos_z"), (try_end), (try_end), (try_end), ]), # script_remove_agent (mtarini) ("remove_agent", [ (store_script_param, ":agent", 1), (init_position, pos5), # send agent to Pluto ;) (agent_set_position,":agent", pos5), (agent_set_hit_points, ":agent", 0,0), # self destruct it! (set_show_messages,0), ] + (is_a_wb_script==1 and [ # make aggravator a statue (WB Only) (agent_set_no_death_knock_down_only, ":agent", 0), ] or []) + [ (agent_deliver_damage_to_agent, ":agent", ":agent"), (set_show_messages,1), ]), # script_select_battle_tactic ("select_battle_tactic", [ (assign, ":defense_not_an_option", 0), (assign, "$ai_team_1_battle_tactic", 0), (get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (try_begin), (num_active_teams_le, 2), (try_begin),(eq, ":player_team", 0),(assign, "$ai_team_1", 1), (else_try), (assign, "$ai_team_1", 0), (try_end), (assign, "$ai_team_2", -1), (else_try), (try_begin),(eq, ":player_team", 0),(assign, "$ai_team_1", 1), (else_try), (assign, "$ai_team_1", 0), (try_end), (store_add, "$ai_team_2", ":player_team", 2), (try_end), (set_show_messages, 0), (call_script, "script_select_battle_tactic_aux", "$ai_team_1", ":defense_not_an_option"), # swy: second parameter is always zero here (assign, "$ai_team_1_battle_tactic", reg0), (try_begin), (ge, "$ai_team_2", 0), (try_begin), (eq, "$ai_team_1_battle_tactic", btactic_hold), (assign, ":defense_not_an_option", 1), #don't let two AI defend at the same time (try_end), (call_script, "script_select_battle_tactic_aux", "$ai_team_2", ":defense_not_an_option"), (assign, "$ai_team_2_battle_tactic", reg0), (try_end), (set_show_messages, 1), ]), # script_select_battle_tactic_aux # Input: team_no # Output: battle_tactic ("select_battle_tactic_aux", [ (store_script_param, ":team_no", 1), (store_script_param, ":defense_not_an_option", 2), (assign, ":battle_tactic", btactic_follow_leader), (get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (try_begin), (eq, "$cant_leave_encounter", 1), (teams_are_enemies, ":team_no", ":player_team"), (assign, ":defense_not_an_option", 1), (try_end), (call_script, "script_team_get_class_percentages", ":team_no", 0), # (assign, ":ai_perc_infantry", reg0), (assign, ":ai_perc_archers", reg1), (assign, ":ai_perc_cavalry", reg2), (call_script, "script_team_get_class_percentages", ":team_no", 1),#enemies of the ai_team # (assign, ":enemy_perc_infantry", reg0), (assign, ":enemy_perc_archers", reg1), #(assign, ":enemy_perc_cavalry", reg2), (store_random_in_range, ":rand", 0, 100), (try_begin), (assign, ":continue", 0), (try_begin), (teams_are_enemies, ":team_no", ":player_team"), (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_hero_party), (assign, ":continue", 1), (else_try), (neg|teams_are_enemies, ":team_no", ":player_team"), (gt, "$g_ally_party", 0), (party_slot_eq, "$g_ally_party", slot_party_type, spt_kingdom_hero_party), (assign, ":continue", 1), (try_end), #(this_or_next|lt, ":rand", 20), (eq, ":continue", 1), (try_begin), (eq, ":defense_not_an_option", 0), (gt, ":ai_perc_archers", 50), (lt, ":ai_perc_cavalry", 35), (assign, ":battle_tactic", btactic_hold), (else_try), (eq, "$small_scene_used", 1), (gt, ":enemy_perc_archers", 50), (this_or_next|gt, ":ai_perc_cavalry", 30), (lt, ":ai_perc_archers", 30), (assign, ":battle_tactic", 0), #charge (else_try), (this_or_next|lt, ":rand", 80), (eq, "$small_scene_used", 1), (assign, ":battle_tactic", btactic_follow_leader), (try_end), (try_end), (assign, reg0, ":battle_tactic"), ]), # script_battle_tactic_init ("battle_tactic_init", [ (call_script, "script_battle_tactic_init_aux", "$ai_team_1", "$ai_team_1_battle_tactic"), (try_begin), (ge, "$ai_team_2", 0), (call_script, "script_battle_tactic_init_aux", "$ai_team_2", "$ai_team_2_battle_tactic"), (try_end), ]), # script_battle_tactic_init_aux # Input: team_no, battle_tactic ("orig_battle_tactic_init_aux", # formations change [ (store_script_param, ":team_no", 1), (store_script_param, ":battle_tactic", 2), #(team_get_leader, ":ai_leader", ":team_no"), (call_script, "script_team_get_nontroll_leader", ":team_no"), (assign, ":ai_leader", reg0), (try_begin), (eq, ":battle_tactic", btactic_hold), ] + (is_a_wb_script==1 and [ (agent_is_active, ":ai_leader"), ] or []) + [ (agent_get_position, pos1, ":ai_leader"), (call_script, "script_find_high_ground_around_pos1", ":team_no", 30), (copy_position, pos1, pos52), (call_script, "script_find_high_ground_around_pos1", ":team_no", 30), # call again just in case we are not at peak point. (copy_position, pos1, pos52), (call_script, "script_find_high_ground_around_pos1", ":team_no", 30), # call again just in case we are not at peak point. (team_give_order, ":team_no", grc_everyone, mordr_hold), (team_set_order_position, ":team_no", grc_everyone, pos52), (team_give_order, ":team_no", grc_archers, mordr_advance), (team_give_order, ":team_no", grc_archers, mordr_advance), (else_try), (eq, ":battle_tactic", btactic_follow_leader), ] + (is_a_wb_script==1 and [ (agent_is_active, ":ai_leader"), ] or []) + [ #(team_get_leader, ":ai_leader", ":team_no"), (agent_set_speed_limit, ":ai_leader", 8), (agent_get_position, pos60, ":ai_leader"), (team_give_order, ":team_no", grc_everyone, mordr_hold), (team_set_order_position, ":team_no", grc_everyone, pos60), (else_try), (eq, ":battle_tactic", 0), (team_get_leader, ":ai_leader", ":team_no"), (ge, ":ai_leader", 0), (agent_is_alive, ":ai_leader"), (call_script, "script_team_get_average_position_of_enemies", ":team_no"), (copy_position, pos80, pos0), (agent_get_position, pos81, ":ai_leader"), (position_transform_position_to_local, pos82, pos81, pos80), #pos62 = vector to enemy w.r.t leader (position_normalize_origin, ":distance_to_enemy", pos82), (convert_from_fixed_point, ":distance_to_enemy"), (assign, reg17, ":distance_to_enemy"), (position_get_x, ":dir_x", pos82), (position_get_y, ":dir_y", pos82), (val_mul, ":dir_x", 23), (val_mul, ":dir_y", 23), #move 23 meters (position_set_x, pos82, ":dir_x"), (position_set_y, pos82, ":dir_y"), (position_transform_position_to_parent, pos83, pos81, pos82), #pos63 is 23m away from leader in the direction of the enemy. (position_set_z_to_ground_level, pos83), (team_give_order, ":team_no", grc_everyone, mordr_hold), (team_set_order_position, ":team_no", grc_everyone, pos83), (team_give_order, ":team_no", grc_everyone, mordr_spread_out), (try_end), ]), # script_battle_tactic_apply ("battle_tactic_apply", [ (call_script, "script_battle_tactic_apply_aux", "$ai_team_1", "$ai_team_1_battle_tactic"), (assign, "$ai_team_1_battle_tactic", reg0), (try_begin), (ge, "$ai_team_2", 0), (call_script, "script_battle_tactic_apply_aux", "$ai_team_2", "$ai_team_2_battle_tactic"), (assign, "$ai_team_2_battle_tactic", reg0), (try_end), ]), # script_battle_tactic_apply_aux # Input: team_no, battle_tactic # Output: battle_tactic ("orig_battle_tactic_apply_aux", # formations change [ (store_script_param, ":team_no", 1), (store_script_param, ":battle_tactic", 2), (store_mission_timer_a, ":mission_time"), (try_begin), (eq, ":battle_tactic", btactic_hold), (copy_position, pos1, pos52), (call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team_no", 1), (assign, ":avg_dist", reg0), (assign, ":min_dist", reg1), (try_begin), (this_or_next|lt, ":min_dist", 1000), (lt, ":avg_dist", 4000), (assign, ":battle_tactic", 0), (team_give_order, ":team_no", grc_everyone, mordr_charge), (try_end), (else_try), (eq, ":battle_tactic", btactic_follow_leader), #(team_get_leader, ":ai_leader", ":team_no"), (call_script, "script_team_get_nontroll_leader", ":team_no"), (assign, ":ai_leader", reg0), ] + (is_a_wb_script==1 and [ (agent_is_active, ":ai_leader"), ] or []) + [ (try_begin), (gt, ":ai_leader", 0), #Fix - Kham (agent_is_alive, ":ai_leader"), (agent_set_speed_limit, ":ai_leader", 9), (call_script, "script_team_get_average_position_of_enemies", ":team_no"), (copy_position, pos60, pos0), (agent_get_position, pos61, ":ai_leader"), (position_transform_position_to_local, pos62, pos61, pos60), #pos62 = vector to enemy w.r.t leader (position_normalize_origin, ":distance_to_enemy", pos62), (convert_from_fixed_point, ":distance_to_enemy"), (assign, reg17, ":distance_to_enemy"), (position_get_x, ":dir_x", pos62), (position_get_y, ":dir_y", pos62), (val_mul, ":dir_x", 23), (val_mul, ":dir_y", 23), #move 23 meters (position_set_x, pos62, ":dir_x"), (position_set_y, pos62, ":dir_y"), (position_transform_position_to_parent, pos63, pos61, pos62), #pos63 is 23m away from leader in the direction of the enemy. (position_set_z_to_ground_level, pos63), (team_give_order, ":team_no", grc_everyone, mordr_hold), (team_set_order_position, ":team_no", grc_everyone, pos63), (team_give_order, ":team_no", grc_infantry, mordr_advance), #Slowly inch our infantry forward # (team_give_order, ":team_no", grc_everyone, mordr_follow), (agent_get_position, pos1, ":ai_leader"), (assign, ":continue", 0), (try_begin), (ge, ":mission_time", 60), (assign, ":continue", 1), (else_try), (ge, ":mission_time", 30), (lt, ":distance_to_enemy", 120), (assign, ":continue", 1), (try_end), (try_begin), (eq, ":continue", 1), (assign, ":battle_tactic", 0), (team_give_order, ":team_no", grc_everyone, mordr_charge), (agent_set_speed_limit, ":ai_leader", 60), (try_end), (else_try), (assign, ":battle_tactic", 0), (team_give_order, ":team_no", grc_everyone, mordr_charge), (try_end), (else_try), (eq, ":battle_tactic", 0), (try_begin), (ge, ":mission_time", 12), (team_give_order, ":team_no", grc_everyone, mordr_charge), (try_end), (try_end), (try_begin), # charge everyone after a while (neq, ":battle_tactic", 0), (ge, ":mission_time", 300), (assign, ":battle_tactic", 0), (team_give_order, ":team_no", grc_everyone, mordr_charge), (call_script, "script_team_get_nontroll_leader", ":team_no"), (assign, ":ai_leader", reg0), (gt, ":ai_leader", 0), #Fix - Kham (agent_set_speed_limit, ":ai_leader", 60), (try_end), (assign, reg0, ":battle_tactic"), ]), # script_team_get_class_percentages # Input: arg1: team_no, arg2: try for team's enemies # Output: reg0: percentage infantry, reg1: percentage archers, reg2: percentage cavalry ("team_get_class_percentages", [ (assign, ":num_infantry", 0), (assign, ":num_archers", 0), (assign, ":num_cavalry", 0), (assign, ":num_total", 0), (store_script_param, ":team_no", 1), (store_script_param, ":negate", 2), (try_for_agents,":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_is_human, ":cur_agent"), (agent_get_team, ":agent_team", ":cur_agent"), (assign, ":continue", 0), (try_begin), (eq, ":negate", 1), (teams_are_enemies, ":agent_team", ":team_no"), (assign, ":continue", 1), (else_try), (eq, ":agent_team", ":team_no"), (assign, ":continue", 1), (try_end), (eq, ":continue", 1), (val_add, ":num_total", 1), (agent_get_class, ":agent_class", ":cur_agent"), (try_begin), (eq, ":agent_class", grc_infantry), (val_add, ":num_infantry", 1), (else_try), (eq, ":agent_class", grc_archers), (val_add, ":num_archers", 1), (else_try), (eq, ":agent_class", grc_cavalry), (val_add, ":num_cavalry", 1), (try_end), (try_end), (try_begin), (eq, ":num_total", 0), (assign, ":num_total", 1), (try_end), (store_mul, ":perc_infantry",":num_infantry",100), (val_div, ":perc_infantry",":num_total"), (store_mul, ":perc_archers",":num_archers",100), (val_div, ":perc_archers",":num_total"), (store_mul, ":perc_cavalry",":num_cavalry",100), (val_div, ":perc_cavalry",":num_total"), (assign, reg0, ":perc_infantry"), (assign, reg1, ":perc_archers"), (assign, reg2, ":perc_cavalry"), ]), # script_get_closest3_distance_of_enemies_at_pos1 # Input: arg1: team_no, pos1 # Output: reg0: distance in cms. ("get_closest3_distance_of_enemies_at_pos1", [ (assign, ":min_distance_1", 100000), (assign, ":min_distance_2", 100000), (assign, ":min_distance_3", 100000), (store_script_param, ":team_no", 1), (try_for_agents,":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_is_human, ":cur_agent"), (agent_get_team, ":agent_team", ":cur_agent"), (teams_are_enemies, ":agent_team", ":team_no"), (agent_get_position, pos2, ":cur_agent"), (get_distance_between_positions,":cur_dist",pos2,pos1), (try_begin), (lt, ":cur_dist", ":min_distance_1"), (assign, ":min_distance_3", ":min_distance_2"), (assign, ":min_distance_2", ":min_distance_1"), (assign, ":min_distance_1", ":cur_dist"), (else_try), (lt, ":cur_dist", ":min_distance_2"), (assign, ":min_distance_3", ":min_distance_2"), (assign, ":min_distance_2", ":cur_dist"), (else_try), (lt, ":cur_dist", ":min_distance_3"), (assign, ":min_distance_3", ":cur_dist"), (try_end), (try_end), (assign, ":total_distance", 0), (assign, ":total_count", 0), (try_begin), (lt, ":min_distance_1", 100000), (val_add, ":total_distance", ":min_distance_1"), (val_add, ":total_count", 1), (try_end), (try_begin), (lt, ":min_distance_2", 100000), (val_add, ":total_distance", ":min_distance_2"), (val_add, ":total_count", 1), (try_end), (try_begin), (lt, ":min_distance_3", 100000), (val_add, ":total_distance", ":min_distance_3"), (val_add, ":total_count", 1), (try_end), (assign, ":average_distance", 100000), (try_begin), (gt, ":total_count", 0), (store_div, ":average_distance", ":total_distance", ":total_count"), (try_end), (assign, reg0, ":average_distance"), (assign, reg1, ":min_distance_1"), (assign, reg2, ":min_distance_2"), (assign, reg3, ":min_distance_3"), ]), # script_team_get_average_position_of_enemies # Input: arg1: team_no, # Output: pos0: average position. ("team_get_average_position_of_enemies", [ (store_script_param_1, ":team_no"), (init_position, pos0), (assign, ":num_enemies", 0), (assign, ":accum_x", 0), (assign, ":accum_y", 0), (assign, ":accum_z", 0), (try_for_agents,":enemy_agent"), (agent_is_alive, ":enemy_agent"), (agent_is_human, ":enemy_agent"), (agent_get_team, ":enemy_team", ":enemy_agent"), (teams_are_enemies, ":team_no", ":enemy_team"), (agent_get_position, pos62, ":enemy_agent"), (position_get_x, ":x", pos62), (position_get_y, ":y", pos62), (position_get_z, ":z", pos62), (val_add, ":accum_x", ":x"), (val_add, ":accum_y", ":y"), (val_add, ":accum_z", ":z"), (val_add, ":num_enemies", 1), (try_end), (try_begin), #to avoid division by zeros at below division part. (le, ":num_enemies", 0), (assign, ":num_enemies", 1), (try_end), (store_div, ":average_x", ":accum_x", ":num_enemies"), (store_div, ":average_y", ":accum_y", ":num_enemies"), (store_div, ":average_z", ":accum_z", ":num_enemies"), (position_set_x, pos0, ":average_x"), (position_set_y, pos0, ":average_y"), (position_set_z, pos0, ":average_z"), (assign, reg0, ":num_enemies"), ]), # script_search_troop_prisoner_of_party # Input: arg1 = troop_no # Output: reg0 = party_no (-1 if troop is not a prisoner.) ("search_troop_prisoner_of_party", [ (store_script_param_1, ":troop_no"), (assign, ":prisoner_of", -1), (try_for_parties, ":party_no"), (eq, ":prisoner_of", -1), (this_or_next|eq, ":party_no", "p_main_party"), (ge, ":party_no", centers_begin), (party_count_prisoners_of_type, ":troop_found", ":party_no", ":troop_no"), (gt, ":troop_found", 0), (assign, ":prisoner_of", ":party_no"), (try_end), (assign, reg0, ":prisoner_of"), ]), # script_change_debt_to_troop # Input: arg1 = troop_no, arg2 = new debt amount # Output: none NOT USED IN TLD # ("change_debt_to_troop", # [ (store_script_param_1, ":troop_no"), # (store_script_param_2, ":new_debt"), # (troop_get_slot, ":cur_debt", ":troop_no", slot_troop_player_debt), # (assign, reg1, ":cur_debt"), # (val_add, ":cur_debt", ":new_debt"), # (assign, reg2, ":cur_debt"), # (troop_set_slot, ":troop_no", slot_troop_player_debt, ":cur_debt"), # (str_store_troop_name_link, s1, ":troop_no"), # (display_message, "@You now owe {reg2} RPs to {s1}."), # ]), # script_abort_quest # Input: arg1 = quest_no, arg2 = apply relation penalty # Output: none ("abort_quest", [ (store_script_param_1, ":quest_no"), (store_script_param_2, ":abort_type"), #0=aborted by event, 1=abort by talking 2=abort by expire (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -2), (quest_get_slot, ":quest_giver", ":quest_no", slot_quest_giver_troop), (store_troop_faction, ":quest_faction", ":quest_giver"), (quest_get_slot, ":quest_target_faction", ":quest_no", slot_quest_target_faction), (quest_get_slot, ":quest_giver_fac_str_effect", ":quest_no", slot_quest_giver_fac_str_effect), (val_div, ":quest_giver_fac_str_effect", 2), (quest_get_slot, ":quest_target_fac_str_effect", ":quest_no", slot_quest_target_fac_str_effect), (val_div, ":quest_target_fac_str_effect", 2), # (quest_get_slot, ":quest_object_troop", ":quest_no", slot_quest_object_troop), (try_begin), (this_or_next|eq, ":quest_no", "qst_deliver_message"), (eq, ":quest_no", "qst_deliver_message_to_enemy_lord"), (assign, ":quest_return_penalty", -2), (assign, ":quest_expire_penalty", -3), (else_try), (eq, ":quest_no", "qst_escort_messenger"), (quest_get_slot, ":quest_object_troop", "qst_escort_messenger", slot_quest_object_troop), (party_remove_members, "p_main_party", ":quest_object_troop", 1), (assign, ":quest_return_penalty", -2), (assign, ":quest_expire_penalty", -3), ## (else_try), ## (eq, ":quest_no", "qst_rescue_lady_under_siege"), ## (party_remove_members, "p_main_party", ":quest_object_troop", 1), ## (else_try), ## (eq, ":quest_no", "qst_deliver_message_to_lover"), ## (else_try), ## (eq, ":quest_no", "qst_bring_prisoners_to_enemy"), ## (try_begin), ## (check_quest_succeeded, ":quest_no"), ## (quest_get_slot, ":quest_target_amount", ":quest_no", slot_quest_target_amount), ## (quest_get_slot, ":quest_object_troop", ":quest_no", slot_quest_object_troop), ## (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), ## (call_script, "script_game_get_join_cost", ":quest_object_troop"), ## (assign, ":reward", reg0), ## (val_mul, ":reward", ":quest_target_amount"), ## (val_div, ":reward", 2), ## (else_try), ## (quest_get_slot, ":reward", ":quest_no", slot_quest_target_amount), ## (try_end), ## (call_script, "script_change_debt_to_troop", ":quest_giver_troop", ":reward"), ## (else_try), ## (eq, ":quest_no", "qst_bring_reinforcements_to_siege"), ## (quest_get_slot, ":quest_target_amount", ":quest_no", slot_quest_target_amount), ## (quest_get_slot, ":quest_object_troop", ":quest_no", slot_quest_object_troop), ## (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), ## (call_script, "script_game_get_join_cost", ":quest_object_troop"), ## (assign, ":reward", reg0), ## (val_mul, ":reward", ":quest_target_amount"), ## (val_mul, ":reward", 2), ## (call_script, "script_change_debt_to_troop", ":quest_giver_troop", ":reward"), ## (else_try), ## (eq, ":quest_no", "qst_deliver_supply_to_center_under_siege"), ## (quest_get_slot, ":quest_target_amount", ":quest_no", slot_quest_target_amount), ## (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), ## (store_item_value, ":reward", "itm_siege_supply"), ## (val_mul, ":reward", ":quest_target_amount"), ## (call_script, "script_change_debt_to_troop", ":quest_giver_troop", ":reward"), (else_try), (eq, ":quest_no", "qst_raise_troops"), #(quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), #(call_script, "script_change_debt_to_troop", ":quest_giver_troop", 100), (assign, ":quest_return_penalty", -4), (assign, ":quest_expire_penalty", -5), (else_try), (eq, ":quest_no", "qst_deal_with_looters"), (quest_get_slot, ":looter_template", "qst_deal_with_looters", slot_quest_target_party_template), (try_for_parties, ":cur_party_no"), (party_get_template_id, ":cur_party_template", ":cur_party_no"), (eq, ":cur_party_template", ":looter_template"), (party_set_flags, ":cur_party_no", pf_quest_party, 0), (try_end), (assign, ":quest_return_penalty", -4), (assign, ":quest_expire_penalty", -5), # (else_try), # (eq, ":quest_no", "qst_deal_with_bandits_at_lords_village"), # (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), # (call_script, "script_change_debt_to_troop", ":quest_giver_troop", 200), # (assign, ":quest_return_penalty", -5), # (assign, ":quest_expire_penalty", -6), # (else_try), # (eq, ":quest_no", "qst_collect_taxes"), # (quest_get_slot, ":gold_reward", ":quest_no", slot_quest_gold_reward), # (quest_set_slot, ":quest_no", slot_quest_gold_reward, 0), # (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), # (call_script, "script_change_debt_to_troop", ":quest_giver_troop", ":gold_reward"), # (assign, ":quest_return_penalty", -4), # (assign, ":quest_expire_penalty", -6), ## (else_try), ## (eq, ":quest_no", "qst_capture_messenger"), ## (else_try), ## (eq, ":quest_no", "qst_bring_back_deserters"), (else_try), (eq, ":quest_no", "qst_hunt_down_fugitive"), (assign, ":quest_return_penalty", -3), (assign, ":quest_expire_penalty", -4), # (else_try), # (eq, ":quest_no", "qst_kill_local_merchant"), (else_try), (eq, ":quest_no", "qst_bring_back_runaway_serfs"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -1), (else_try), (eq, ":quest_no", "qst_lend_companion"), # (else_try), # (eq, ":quest_no", "qst_collect_debt"), # (try_begin), # (quest_slot_eq, "qst_collect_debt", slot_quest_current_state, 1), #debt collected but not delivered # (quest_get_slot, ":debt", "qst_collect_debt", slot_quest_target_amount), # (quest_get_slot, ":quest_giver", "qst_collect_debt", slot_quest_giver_troop), # (call_script, "script_change_debt_to_troop", ":quest_giver", ":debt"), # (assign, ":quest_return_penalty", -3), # (assign, ":quest_expire_penalty", -6), # (else_try), # (assign, ":quest_return_penalty", -3), # (assign, ":quest_expire_penalty", -4), # (try_end), # (else_try), # (eq, ":quest_no", "qst_deal_with_bandits_at_lords_village"), # (assign, ":quest_return_penalty", -6), # (assign, ":quest_expire_penalty", -6), # (else_try), # (eq, ":quest_no", "qst_raid_caravan_to_start_war"), # (assign, ":quest_return_penalty", -10), # (assign, ":quest_expire_penalty", -13), # (else_try), # (eq, ":quest_no", "qst_persuade_lords_to_make_peace"), # (assign, ":quest_return_penalty", -10), # (assign, ":quest_expire_penalty", -13), (else_try), (eq, ":quest_no", "qst_deal_with_night_bandits"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -1), (else_try), (eq, ":quest_no", "qst_deliver_food"), (assign, ":quest_return_penalty", -2), (assign, ":quest_expire_penalty", -4), (else_try), (eq, ":quest_no", "qst_deliver_iron"), (assign, ":quest_return_penalty", -2), (assign, ":quest_expire_penalty", -4), (else_try), (eq, ":quest_no", "qst_follow_spy"), (assign, ":quest_return_penalty", -2), (assign, ":quest_expire_penalty", -3), (try_begin), (party_is_active, "$qst_follow_spy_spy_party"), (call_script, "script_safe_remove_party", "$qst_follow_spy_spy_party"), (try_end), (try_begin), (party_is_active, "$qst_follow_spy_spy_partners_party"), (call_script, "script_safe_remove_party", "$qst_follow_spy_spy_partners_party"), (try_end), (else_try), (eq, ":quest_no", "qst_capture_enemy_hero"), (assign, ":quest_return_penalty", -3), (assign, ":quest_expire_penalty", -4), (else_try), (eq, ":quest_no", "qst_scout_enemy_town"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -2), (else_try), (eq, ":quest_no", "qst_dispatch_scouts"), (assign, ":quest_return_penalty", -2), (assign, ":quest_expire_penalty", -3), #Enemy lord quests (else_try), (eq, ":quest_no", "qst_lend_surgeon"), ## (else_try), ## (eq, ":quest_no", "qst_lend_companion"), ## (quest_get_slot, ":quest_target_troop", "qst_lend_companion", slot_quest_target_troop), ## (party_add_members, "p_main_party", ":quest_target_troop", 1), ## (else_try), ## (eq, ":quest_no", "qst_capture_conspirators"), ## (else_try), ## (eq, ":quest_no", "qst_defend_nobles_against_peasants"), # (else_try), # (eq, ":quest_no", "qst_incriminate_loyal_commander"), # (assign, ":quest_return_penalty", -5), # (assign, ":quest_expire_penalty", -6), ## (else_try), ## (eq, ":quest_no", "qst_hunt_down_raiders"), ## (else_try), ## (eq, ":quest_no", "qst_capture_prisoners"), #Kingdom lady quests # (else_try), # (eq, ":quest_no", "qst_rescue_lord_by_replace"), # (assign, ":quest_return_penalty", -1), # (assign, ":quest_expire_penalty", -1), # (else_try), # (eq, ":quest_no", "qst_deliver_message_to_prisoner_lord"), # (assign, ":quest_return_penalty", 0), # (assign, ":quest_expire_penalty", -1), # (else_try), # (eq, ":quest_no", "qst_duel_for_lady"), # (assign, ":quest_return_penalty", -1), # (assign, ":quest_expire_penalty", -1), #Kingdom Army quests (else_try), (eq, ":quest_no", "qst_follow_army"), #(assign, ":quest_return_penalty", -4), #(assign, ":quest_expire_penalty", -5), (else_try), (eq, ":quest_no", "qst_deliver_cattle_to_army"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -2), (else_try), (eq, ":quest_no", "qst_join_siege_with_army"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -2), (else_try), (eq, ":quest_no", "qst_scout_waypoints"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -2), #Village Elder quests # (else_try), # (eq, ":quest_no", "qst_deliver_grain"), # (assign, ":quest_return_penalty", -6), # (assign, ":quest_expire_penalty", -7), # (else_try), # (eq, ":quest_no", "qst_deliver_cattle"), # (assign, ":quest_return_penalty", -3), # (assign, ":quest_expire_penalty", -4), # (else_try), # (eq, ":quest_no", "qst_train_peasants_against_bandits"), # (assign, ":quest_return_penalty", -4), # (assign, ":quest_expire_penalty", -5), #Mayor quests (else_try), (eq, ":quest_no", "qst_deliver_wine"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -3), #(val_add, "$debt_to_merchants_guild", "$qst_deliver_wine_debt"), (else_try), (eq, ":quest_no", "qst_move_cattle_herd"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -3), (else_try), (eq, ":quest_no", "qst_escort_merchant_caravan"), (assign, ":quest_return_penalty", -1), (assign, ":quest_expire_penalty", -3), (else_try), (eq, ":quest_no", "qst_troublesome_bandits"), (assign, ":quest_return_penalty", 0), (assign, ":quest_expire_penalty", -2), #Other quests # (else_try), # (eq, ":quest_no", "qst_join_faction"), # (assign, ":quest_return_penalty", -3), # (assign, ":quest_expire_penalty", -3), # (try_begin), # (call_script, "script_get_number_of_hero_centers", "trp_player"), # (gt, reg0, 0), # (call_script, "script_change_player_relation_with_faction", "$g_invite_faction", -10), # (try_end), # (assign, "$g_invite_faction", 0), # (assign, "$g_invite_faction_lord", 0), # (assign, "$g_invite_offered_center", 0), # (else_try), # (eq, ":quest_no", "qst_eliminate_bandits_infesting_village"), # (assign, ":quest_return_penalty", -3), # (assign, ":quest_expire_penalty", -3), (try_end), (try_begin), (gt, ":abort_type", 0), #execute faction strength consequences, positive outcomes defined in script_finish_quest (try_begin), (gt, "$tld_war_began", 0), (ge, ":quest_giver_fac_str_effect", 1), (faction_get_slot,":giver_strength",":quest_faction",slot_faction_strength_tmp), (val_sub, ":giver_strength", ":quest_giver_fac_str_effect"), (faction_set_slot,":quest_faction",slot_faction_strength_tmp,":giver_strength"), (str_store_faction_name, s1, ":quest_faction"), (display_message, "@{s1} lost faction strength!", color_bad_news), (try_end), (try_begin), (gt, "$tld_war_began", 0), (is_between, ":quest_target_faction", kingdoms_begin, kingdoms_end), #Check if there's an actual target faction (lt, ":quest_target_fac_str_effect", 0), #negative strength effect if enemy faction is target... (faction_get_slot,":enemy_strength",":quest_target_faction",slot_faction_strength_tmp), (val_sub, ":enemy_strength", ":quest_target_fac_str_effect"), #...becomes positive if quest fails (faction_set_slot,":quest_target_faction",slot_faction_strength_tmp,":enemy_strength"), (str_store_faction_name, s1, ":quest_target_faction"), (display_message, "@{s1} gained faction strength!", color_bad_news), (else_try), #if target faction is an ally (e.g. escort caravan quest) (gt, "$tld_war_began", 0), (is_between, ":quest_target_faction", kingdoms_begin, kingdoms_end), #Check if there's an actual target faction (gt, ":quest_target_fac_str_effect", 0), #positive strength effect for allied targets (eg caravan quests)... (faction_get_slot,":enemy_strength",":quest_target_faction",slot_faction_strength_tmp), (val_sub, ":enemy_strength", ":quest_target_fac_str_effect"), #... becomes negative is quest fails (faction_set_slot,":quest_target_faction",slot_faction_strength_tmp,":enemy_strength"), (str_store_faction_name, s1, ":quest_target_faction"), (display_message, "@{s1} lost faction strength!", color_bad_news), (try_end), #execute relation penalties (quest_get_slot, ":quest_giver", ":quest_no", slot_quest_giver_troop), (assign, ":relation_penalty", ":quest_return_penalty"), (try_begin), (eq, ":abort_type", 2), (assign, ":relation_penalty", ":quest_expire_penalty"), (try_end), (try_begin), # (this_or_next|is_between, ":quest_giver", village_elders_begin, village_elders_end), (is_between, ":quest_giver", mayors_begin, mayors_end), (quest_get_slot, ":quest_giver_center", ":quest_no", slot_quest_giver_center), (call_script, "script_change_player_relation_with_center", ":quest_giver_center", ":relation_penalty"), (else_try), (call_script, "script_change_player_relation_with_troop", ":quest_giver", ":relation_penalty"), (try_end), (try_end), (fail_quest, ":quest_no"), #NPC companion changes begin (try_begin), (gt, ":abort_type", 0), (call_script, "script_objectionable_action", tmt_honest, "str_fail_quest"), (try_end), #NPC companion changes end (call_script, "script_end_quest", ":quest_no"), ]), # script_cf_is_quest_troop # Input: arg1 = troop_no # Output: none (can fail) ("cf_is_quest_troop", [ (store_script_param_1, ":troop_no"), (assign, ":is_quest_troop", 0), (try_for_range, ":cur_quest", all_quests_begin, all_quests_end), (check_quest_active, ":cur_quest"), (quest_get_slot, ":quest_troop_1", ":cur_quest", slot_quest_target_troop), (quest_get_slot, ":quest_troop_2", ":cur_quest", slot_quest_object_troop), (quest_get_slot, ":quest_troop_3", ":cur_quest", slot_quest_giver_troop), (this_or_next|eq, ":quest_troop_1", ":troop_no"), (this_or_next|eq, ":quest_troop_2", ":troop_no"), (eq, ":quest_troop_3", ":troop_no"), (assign, ":is_quest_troop", 1), (try_end), (eq, ":is_quest_troop", 1), ]), # script_check_friendly_kills # Input: none # Output: none (changes the morale of the player's party) ("check_friendly_kills", [(get_player_agent_own_troop_kill_count, ":count"), (try_begin), (neq, "$g_player_current_own_troop_kills", ":count"), (val_sub, ":count", "$g_player_current_own_troop_kills"), (val_add, "$g_player_current_own_troop_kills", ":count"), (val_mul, ":count", -1), (call_script, "script_change_player_party_morale", ":count"), (try_end), ]), # script_simulate_retreat # Input: arg1 = players_side_damage, arg2 = enemy_side_damage, s5 = title_string # Output: none ("simulate_retreat", [ (call_script, "script_music_set_situation_with_culture", mtf_sit_killed), (set_show_messages, 0), (store_script_param, ":players_side_damage", 1), #damage dealt by the player side on the enemy side (store_script_param, ":enemy_side_damage", 2), #vice versa # tactics reduces enemy side damage *150/(tactics*2+10) = 150%...50% (party_get_skill_level, ":player_party_tactics", "p_main_party", "skl_tactics"), (val_mul, ":enemy_side_damage", 150), (val_mul, ":player_party_tactics", 2), (val_add, ":player_party_tactics", 10), (val_div, ":enemy_side_damage", ":player_party_tactics"), (val_div, ":enemy_side_damage", 10), (assign, ":players_side_strength", 0), (assign, ":enemy_side_strength", 0), (assign, ":do_calculate", 1), (try_begin), (try_for_agents, ":cur_agent"), (agent_is_human, ":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_set_slot, ":cur_agent", slot_agent_is_alive_before_retreat, 1),#needed for simulation (agent_get_troop_id, ":cur_troop", ":cur_agent"), (store_character_level, ":cur_level", ":cur_troop"), (val_add, ":cur_level", 5), (try_begin), (troop_is_hero, ":cur_troop"), (val_add, ":cur_level", 5), (try_end), (try_begin), (agent_is_ally, ":cur_agent"), (val_add, ":players_side_strength", ":cur_level"), (else_try), (val_add, ":enemy_side_strength", ":cur_level"), (try_end), (try_end), (eq, "$pin_player_fallen", 0), (lt, ":enemy_side_strength", ":players_side_strength"), (assign, ":do_calculate", 0), (try_end), (try_begin), (eq, ":do_calculate", 1), (assign, "$g_last_mission_player_damage", 0), (party_clear, "p_temp_party"), (party_clear, "p_temp_party_2"), (call_script, "script_simulate_battle_with_agents_aux", 0, ":players_side_damage"), (call_script, "script_simulate_battle_with_agents_aux", 1, ":enemy_side_damage"), (assign, ":display_casualties", 0), (try_begin), (gt, "$g_last_mission_player_damage", 0), (assign, ":display_casualties", 1), (assign, reg1, "$g_last_mission_player_damage"), (str_store_string, s12, "str_casualty_display_hp"), (else_try), (str_clear, s12), (try_end), (call_script, "script_print_casualties_to_s0", "p_temp_party", 1), (try_begin), (party_get_num_companion_stacks, ":num_stacks", "p_temp_party"), (gt, ":num_stacks", 0), (assign, ":display_casualties", 1), (try_end), (str_store_string_reg, s10, s0), (call_script, "script_print_casualties_to_s0", "p_temp_party_2", 1), (try_begin), (party_get_num_companion_stacks, ":num_stacks", "p_temp_party_2"), (gt, ":num_stacks", 0), (assign, ":display_casualties", 1), (try_end), (str_store_string_reg, s11, s0), (try_begin), (eq, ":display_casualties", 1), (dialog_box,"str_casualty_display", s5), (try_end), (try_end), (set_show_messages, 1), #Calculating morale penalty (can be between 0-30) (assign, ":ally_casualties", 0), (assign, ":enemy_casualties", 0), (assign, ":total_allies", 0), (try_for_agents, ":cur_agent"), (agent_is_human, ":cur_agent"), (try_begin), (agent_is_ally, ":cur_agent"), (val_add, ":total_allies", 1), (try_begin), (neg|agent_is_alive, ":cur_agent"), (val_add, ":ally_casualties", 1), (try_end), (else_try), (neg|agent_is_alive, ":cur_agent"), (val_add, ":enemy_casualties", 1), (try_end), (try_end), (store_add, ":total_casualties", ":ally_casualties", ":enemy_casualties"), (try_begin), (gt, ":total_casualties", 0), (store_mul, ":morale_adder", ":ally_casualties", 100), (val_div, ":morale_adder", ":total_casualties"), (val_mul, ":morale_adder", ":ally_casualties"), (val_div, ":morale_adder", ":total_allies"), (val_mul, ":morale_adder", -30), (val_div, ":morale_adder", 100), (call_script, "script_change_player_party_morale", ":morale_adder"), (try_end), ]), # script_simulate_battle_with_agents_aux # For internal use only, only for calulating retreat # Input: arg1 = attacker_side (0 = ally, 1 = enemy), arg2 = damage amount # Output: none ("simulate_battle_with_agents_aux", [ (store_script_param_1, ":attacker_side"), (store_script_param_2, ":damage"), (get_player_agent_no, ":player_agent"), (try_for_agents, ":cur_agent"), (neq, ":player_agent", ":cur_agent"), (agent_is_human, ":cur_agent"), #do not check agent_is_alive, check slot_agent_is_alive_before_retreat instead, so that dead agents can still hit enemies (agent_slot_eq, ":cur_agent", slot_agent_is_alive_before_retreat, 1), (try_begin), (agent_is_ally, ":cur_agent"), (assign, ":cur_agents_side", 0), (else_try), (assign, ":cur_agents_side", 1), (try_end), (eq, ":cur_agents_side", ":attacker_side"), (agent_get_position, pos2, ":cur_agent"), (assign, ":closest_agent", -1), (assign, ":min_distance", 100000), (try_for_agents, ":cur_agent_2"), (agent_is_human, ":cur_agent_2"), (agent_is_alive, ":cur_agent_2"), (try_begin), (agent_is_ally, ":cur_agent_2"), (assign, ":cur_agents_side_2", 0), (else_try), (assign, ":cur_agents_side_2", 1), (try_end), (this_or_next|neq, ":cur_agent_2", ":player_agent"), (eq, "$pin_player_fallen", 0), (neq, ":attacker_side", ":cur_agents_side_2"), (agent_get_position, pos3, ":cur_agent_2"), (get_distance_between_positions, ":cur_distance", pos2, pos3), (lt, ":cur_distance", ":min_distance"), (assign, ":min_distance", ":cur_distance"), (assign, ":closest_agent", ":cur_agent_2"), (try_end), (ge, ":closest_agent", 0), #Fight (agent_get_class, ":agent_class", ":cur_agent"), (assign, ":agents_speed", 1), (assign, ":agents_additional_hit", 0), (try_begin), (eq, ":agent_class", grc_archers), (assign, ":agents_additional_hit", 2), (else_try), (eq, ":agent_class", grc_cavalry), (assign, ":agents_speed", 2), (try_end), (agent_get_class, ":agent_class", ":closest_agent"), (assign, ":agents_speed_2", 1), (try_begin), (eq, ":agent_class", grc_cavalry), (assign, ":agents_speed_2", 2), (try_end), (assign, ":agents_hit", 18000), (val_add, ":min_distance", 3000), (val_div, ":agents_hit", ":min_distance"), (val_mul, ":agents_hit", 2),# max 10, min 2 hits within 150 meters (val_mul, ":agents_hit", ":agents_speed"), (val_div, ":agents_hit", ":agents_speed_2"), (val_add, ":agents_hit", ":agents_additional_hit"), (assign, ":cur_damage", ":damage"), (agent_get_troop_id, ":closest_troop", ":closest_agent"), (agent_get_troop_id, ":cur_troop", ":cur_agent"), (store_character_level, ":closest_level", ":closest_troop"), (store_character_level, ":cur_level", ":cur_troop"), (store_sub, ":level_dif", ":cur_level", ":closest_level"), (val_div, ":level_dif", 5), (val_add, ":cur_damage", ":level_dif"), (try_begin), (eq, ":closest_agent", ":player_agent"), (val_div, ":cur_damage", 2), (store_agent_hit_points, ":init_player_hit_points", ":player_agent", 1), (try_end), (try_for_range, ":unused", 0, ":agents_hit"), (store_random_in_range, ":random_damage", 0, 100), (lt, ":random_damage", ":cur_damage"), (agent_deliver_damage_to_agent, ":cur_agent", ":closest_agent"), (try_end), (try_begin), (eq, ":closest_agent", ":player_agent"), (store_agent_hit_points, ":final_player_hit_points", ":player_agent", 1), (store_sub, ":hit_points_difference", ":init_player_hit_points", ":final_player_hit_points"), (val_add, "$g_last_mission_player_damage", ":hit_points_difference"), (try_end), (neg|agent_is_alive, ":closest_agent"), (try_begin), (eq, ":attacker_side", 1), (party_add_members, "p_temp_party", ":closest_troop", 1), (try_begin), (agent_is_wounded, ":closest_agent"), (party_wound_members, "p_temp_party", ":closest_troop", 1), (try_end), (else_try), (party_add_members, "p_temp_party_2", ":closest_troop", 1), (try_begin), (agent_is_wounded, ":closest_agent"), (party_wound_members, "p_temp_party_2", ":closest_troop", 1), (try_end), (try_end), (try_end), ]), # script_map_get_random_position_around_position_within_range # Input: arg1 = minimum_distance in km, arg2 = maximum_distance in km, pos1 = origin position # Output: pos2 = result position ("map_get_random_position_around_position_within_range", [ (store_script_param_1, ":min_distance"), (store_script_param_2, ":max_distance"), (val_mul, ":min_distance", 100), (assign, ":continue", 1), (try_for_range, ":unused", 0, 20), (eq, ":continue", 1), (map_get_random_position_around_position, pos2, pos1, ":max_distance"), (get_distance_between_positions, ":distance", pos2, pos1), (ge, ":distance", ":min_distance"), (assign, ":continue", 0), (try_end), ]), # script_troop_get_leaded_center_with_index # Input: arg1 = troop_no, arg2 = center index within range between zero and the number of centers that troop owns # Output: reg0 = center_no ("troop_get_leaded_center_with_index", [ (store_script_param_1, ":troop_no"), (store_script_param_2, ":random_center"), (assign, ":result", -1), (assign, ":center_count", 0), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (eq, ":result", -1), (party_slot_eq, ":center_no", slot_town_lord, ":troop_no"), (val_add, ":center_count", 1), (gt, ":center_count", ":random_center"), (assign, ":result", ":center_no"), (try_end), (assign, reg0, ":result"), ]), # script_cf_troop_get_random_leaded_walled_center_with_less_strength_priority # Input: arg1 = troop_no, arg2 = preferred_center_no # Output: reg0 = center_no (Can fail) ("cf_troop_get_random_leaded_walled_center_with_less_strength_priority", [ (store_script_param, ":troop_no", 1), (store_script_param, ":preferred_center_no", 2), (assign, ":num_centers", 0), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (party_slot_eq, ":center_no", slot_town_lord, ":troop_no"), (party_slot_eq, ":center_no", slot_center_is_besieged_by, -1), (val_add, ":num_centers", 1), (try_begin), (eq, ":center_no", ":preferred_center_no"), (val_add, ":num_centers", 99), (try_end), ## (call_script, "script_party_calculate_regular_strength", ":center_no"), ## (assign, ":strength", reg0), ## (lt, ":strength", 80), ## (store_sub, ":strength", 100, ":strength"), ## (val_div, ":strength", 20), ## (val_add, ":num_centers", ":strength"), (try_end), (gt, ":num_centers", 0), (store_random_in_range, ":random_center", 0, ":num_centers"), (assign, ":result", -1), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (eq, ":result", -1), (party_slot_eq, ":center_no", slot_town_lord, ":troop_no"), (party_slot_eq, ":center_no", slot_center_is_besieged_by, -1), (val_sub, ":random_center", 1), (try_begin), (eq, ":center_no", ":preferred_center_no"), (val_sub, ":random_center", 99), (try_end), ## (try_begin), ## (call_script, "script_party_calculate_regular_strength", ":center_no"), ## (assign, ":strength", reg0), ## (lt, ":strength", 80), ## (store_sub, ":strength", 100, ":strength"), ## (val_div, ":strength", 20), ## (val_sub, ":random_center", ":strength"), ## (try_end), (lt, ":random_center", 0), (assign, ":result", ":center_no"), (try_end), (assign, reg0, ":result"), ]), # script_cf_troop_get_random_leaded_town_or_village_except_center # Input: arg1 = troop_no, arg2 = except_center_no # Output: reg0 = center_no (Can fail) ("cf_troop_get_random_leaded_town_or_village_except_center", [ (store_script_param_1, ":troop_no"), (store_script_param_2, ":except_center_no"), (assign, ":num_centers", 0), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (neg|party_slot_eq, ":center_no", slot_party_type, spt_castle), (party_slot_eq, ":center_no", slot_town_lord, ":troop_no"), (neq, ":center_no", ":except_center_no"), (val_add, ":num_centers", 1), (try_end), (gt, ":num_centers", 0), (store_random_in_range, ":random_center", 0, ":num_centers"), (assign, ":end_cond", centers_end), (try_for_range, ":center_no", centers_begin, ":end_cond"), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (neg|party_slot_eq, ":center_no", slot_party_type, spt_castle), (party_slot_eq, ":center_no", slot_town_lord, ":troop_no"), (neq, ":center_no", ":except_center_no"), (val_sub, ":random_center", 1), (lt, ":random_center", 0), (assign, ":target_center", ":center_no"), (assign, ":end_cond", 0), (try_end), (assign, reg0, ":target_center"), ]), ("start_current_battle", [ (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), (call_script, "script_calculate_battleside_races"), (troop_get_type, reg1, "trp_player"), (try_begin), #TLD: dwarves are always on foot (eq, reg1, tf_dwarf), (mission_tpl_entry_set_override_flags, "mt_lead_charge", 3, af_override_horse), (try_end), (set_party_battle_mode), (assign, ":mission", "mt_lead_charge"), #Kham - Edited to accommodate new MTs for quests. (try_begin), (check_quest_active, "qst_blank_quest_02"), (this_or_next|eq, "$g_encountered_party", "$qst_refugee_party_1"), (this_or_next|eq, "$g_encountered_party", "$qst_refugee_party_2"), ( eq, "$g_encountered_party", "$qst_refugee_party_3"), (assign, ":mission", "mt_hunt_down_refugees"), (else_try), (assign, ":mission", "mt_lead_charge"), (try_end), (set_jump_mission,":mission"), #Kham - End (call_script, "script_jump_to_random_scene","$current_player_region","$current_player_terrain","$current_player_landmark"), (assign, "$g_next_menu", "mnu_simple_encounter"), (jump_to_menu, "mnu_battle_debrief"), (change_screen_mission), ]), # script_collect_friendly_parties # Fills the party p_collective_friends with the members of parties attached to main_party and ally_party_no ("collect_friendly_parties", [ (party_collect_attachments_to_party, "p_main_party", "p_collective_friends"), (try_begin), (gt, "$g_ally_party", 0), (party_collect_attachments_to_party, "$g_ally_party", "p_temp_party"), (assign, "$g_move_heroes", 1), (call_script, "script_party_add_party", "p_collective_friends", "p_temp_party"), (try_end), ]), # script_encounter_calculate_fit # Input: arg1 = troop_no ("encounter_calculate_fit",[ # (assign, "$g_enemy_fit_for_battle_old", "$g_enemy_fit_for_battle"), # (assign, "$g_friend_fit_for_battle_old", "$g_friend_fit_for_battle"), # (assign, "$g_main_party_fit_for_battle_old", "$g_main_party_fit_for_battle"), # (call_script, "script_party_count_fit_for_battle", "p_main_party"), ## Commenting out - Kham # (assign, "$g_main_party_fit_for_battle", reg(0)), (call_script, "script_collect_friendly_parties"), (call_script, "script_party_count_fit_for_battle", "p_collective_friends"), (assign, "$g_friend_fit_for_battle", reg(0)), (party_clear, "p_collective_ally"), (try_begin), (gt, "$g_ally_party", 0), (party_is_active, "$g_ally_party"), (party_collect_attachments_to_party, "$g_ally_party", "p_collective_ally"), # (call_script, "script_party_count_fit_for_battle", "p_collective_ally"), # (val_add, "$g_friend_fit_for_battle", reg(0)), (try_end), (party_clear, "p_collective_enemy"), (try_begin), (party_is_active, "$g_enemy_party"), (party_collect_attachments_to_party, "$g_enemy_party", "p_collective_enemy"), (try_end), (call_script, "script_party_count_fit_for_battle", "p_collective_enemy"), (assign, "$g_enemy_fit_for_battle", reg0), (assign, reg11, "$g_enemy_fit_for_battle"), (assign, reg10, "$g_friend_fit_for_battle"), ]), # script_encounter_init_variables # Input: arg1 = troop_no ("encounter_init_variables", [ (assign, "$capture_screen_shown", 0), (assign, "$loot_screen_shown", 0), (assign, "$thanked_by_ally_leader", 0), (assign, "$g_battle_result", 0), (assign, "$cant_leave_encounter", 0), (assign, "$cant_talk_to_enemy", 0), (assign, "$last_defeated_hero", 0), (assign, "$last_freed_hero", 0), (assign, "$num_routed_us", 0),# Kham (assign, "$num_routed_allies", 0),#Kham (assign, "$num_routed_enemies", 0),#Kham (call_script, "script_encounter_calculate_fit"), (call_script, "script_party_copy", "p_main_party_backup", "p_main_party"), (call_script, "script_party_calculate_strength", "p_main_party", 0), (assign, "$g_starting_strength_main_party", reg0), (call_script, "script_party_copy", "p_encountered_party_backup", "p_collective_enemy"), (call_script, "script_party_calculate_strength", "p_collective_enemy", 0), (assign, "$g_starting_strength_enemy_party", reg0), # (assign, "$g_starting_strength_ally_party", 0), (assign, "$g_strength_contribution_of_player", 100), (call_script, "script_party_copy", "p_collective_friends_backup", "p_collective_friends"), (call_script, "script_party_calculate_strength", "p_collective_friends", 0), (assign, "$g_starting_strength_friends", reg0), (try_begin), #swy-- don't divide by zero when entering West Emmet menu... probably deeper in the maze of code (gt, "$g_starting_strength_friends", 0), (store_mul, "$g_strength_contribution_of_player","$g_starting_strength_main_party", 100), # reduce contribution if we are helping someone. (val_div, "$g_strength_contribution_of_player","$g_starting_strength_friends"), (try_end), # (try_begin), # (gt, "$g_ally_party", 0), # (call_script, "script_party_copy", "p_ally_party_backup", "p_collective_ally"), # (call_script, "script_party_calculate_strength", "p_collective_ally"), # (assign, "$g_starting_strength_ally_party", reg0), # (store_add, ":starting_strength_factor_combined","$g_starting_strength_ally_party","$g_starting_strength_main_party"), # (store_mul, "$g_strength_contribution_of_player","$g_starting_strength_main_party", 80), #reduce contribution if we are helping someone. # (val_div, "$g_strength_contribution_of_player",":starting_strength_factor_combined"), # (try_end), ]), #script_party_vote_race # each party member "votes" his race,. Votes accumulate in reg15 and reg16 (races groups) 17,18,19 (races) and tmp_slots (factions) -- mtarini # outputs: reg20: majority race group (tf_male: humans+elves+dwarf OR tf_orc: beasts) # outputs: reg21: majority race (beasts VS humans VS dwarf VS elves) # outputs: reg22: majority faction (or: NO FACTION for the rest) ("party_vote_race", [ (store_script_param_1, ":party"), #Party_id # zero all voting (assign, reg15, 0), # orcoids (assign, reg16, 0), # humanoids (assign, reg17, 0), # humans, includes evil humans (assign, reg18, 0), # dwarves (assign, reg19, 0), # elves (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (faction_set_slot,":fac", slot_faction_temp_value, 0), (try_end), (assign, ":no_fac_votes", 0), # (party_get_num_companion_stacks, ":num_stacks",":party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size, ":n",":party",":i_stack"), (party_stack_get_troop_id, ":tr",":party",":i_stack"), (troop_get_type,":race",":tr"), (store_troop_faction,":fac",":tr"), (try_begin),(eq, ":tr", "trp_player"), (val_mul, ":n", 8), # player "vote" counts for 8! (assign, ":fac", "$players_kingdom"), (try_end), (try_begin),(is_between, ":race", tf_orc_begin, tf_orc_end), (val_add, reg15, ":n"), (else_try), (val_add, reg16, ":n"), (try_begin),(eq, ":race", tf_dwarf), (val_add, reg18, ":n"), (else_try), (is_between, ":race", tf_elf_begin, tf_elf_end), (val_add, reg19, ":n"), (else_try), (val_add, reg17, ":n"), (try_end), (try_end), (try_begin),(is_between, ":fac", kingdoms_begin, kingdoms_end), (faction_get_slot, ":tmp", ":fac", slot_faction_temp_value), (val_add, ":tmp",":n"), (faction_set_slot, ":fac", slot_faction_temp_value,":tmp"), (else_try), (val_add, ":no_fac_votes", ":n"), (try_end), (try_end), # count votes (try_begin), (gt, reg15, reg16), (assign, reg20, tf_orc), # RACE GROUP (assign, reg21, tf_orc), # RACE (else_try), (assign, reg20, tf_male), # RACE GROUP (try_begin), (gt, reg19, reg18),(gt, reg19, reg17), (assign, reg21, tf_elf_begin), # RACE (else_try), (gt, reg18, reg17), (assign, reg21, tf_dwarf),# RACE (else_try), (assign, reg21, tf_male),# RACE (try_end), (try_end), (assign, reg22, fac_no_faction ), # a random default (assign, ":max", ":no_fac_votes"), (try_for_range, ":fac", kingdoms_begin, kingdoms_end), (faction_get_slot,":votes", ":fac", slot_faction_temp_value ), (gt, ":votes", ":max"), (assign, ":max", ":votes"), (assign, reg22, ":fac"), (try_end), ]), #script_calculate_battleside_races # compute with domiant race each side of a battle is (mtarini) # $player_side_race_group = humanoids or orchoids # $player_side_race = eld, dwarves or men ("calculate_battleside_races", [ # fcount friends (call_script, "script_party_vote_race", "p_collective_friends"), (assign, "$player_side_race_group", reg20), (assign, "$player_side_race", reg21), (assign, "$player_side_faction", reg22), (call_script, "script_party_vote_race", "p_collective_enemy"), (assign, "$enemy_side_race_group", reg20), (assign, "$enemy_side_race", reg21), (assign, "$enemy_side_faction", reg22), ]), # script_get_first_agent_with_troop_id # Input: arg1 = troop_no # Output: agent_id ("cf_get_first_agent_with_troop_id", [ (store_script_param_1, ":troop_no"), # (store_script_param_2, ":agent_no_to_begin_searching_after"), (assign, ":result", -1), (try_for_agents, ":cur_agent"), (eq, ":result", -1), ## (try_begin), ## (eq, ":cur_agent", ":agent_no_to_begin_searching_after"), ## (assign, ":agent_no_to_begin_searching_after", -1), ## (try_end), ## (eq, ":agent_no_to_begin_searching_after", -1), (agent_get_troop_id, ":cur_troop_no", ":cur_agent"), (eq, ":cur_troop_no", ":troop_no"), (assign, ":result", ":cur_agent"), (try_end), (assign, reg0, ":result"), (neq, reg0, -1), ]), # script_cf_team_get_average_position_of_agents_with_type_to_pos1 # Input: arg1 = team_no, arg2 = class_no (grc_everyone, grc_infantry, grc_cavalry, grc_archers, grc_heroes) # Output: none, pos1 = average_position (0,0,0 if there are no matching agents) ("cf_team_get_average_position_of_agents_with_type_to_pos1", [ (store_script_param_1, ":team_no"), (store_script_param_2, ":class_no"), (assign, ":total_pos_x", 0), (assign, ":total_pos_y", 0), (assign, ":total_pos_z", 0), (assign, ":num_agents", 0), (set_fixed_point_multiplier, 100), (try_for_agents, ":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_is_human, ":cur_agent"), (agent_get_team, ":cur_team_no", ":cur_agent"), (eq, ":cur_team_no", ":team_no"), (agent_get_class, ":cur_class_no", ":cur_agent"), (this_or_next|eq, ":class_no", grc_everyone), (eq, ":class_no", ":cur_class_no"), (agent_get_position, pos1, ":cur_agent"), (position_get_x, ":cur_pos_x", pos1), (val_add, ":total_pos_x", ":cur_pos_x"), (position_get_y, ":cur_pos_y", pos1), (val_add, ":total_pos_y", ":cur_pos_y"), (position_get_z, ":cur_pos_z", pos1), (val_add, ":total_pos_z", ":cur_pos_z"), (val_add, ":num_agents", 1), (try_end), (gt, ":num_agents", 1), (val_div, ":total_pos_x", ":num_agents"), (val_div, ":total_pos_y", ":num_agents"), (val_div, ":total_pos_z", ":num_agents"), (init_position, pos1), (position_move_x, pos1, ":total_pos_x"), (position_move_y, pos1, ":total_pos_y"), (position_move_z, pos1, ":total_pos_z"), ]), # script_cf_turn_windmill_fans # Input: arg1 = instance_no (none = 0) ("cf_turn_windmill_fans", [(store_script_param_1, ":instance_no"), (scene_prop_get_instance, ":windmill_fan_object", "spr_windmill_fan_turning", ":instance_no"), (ge, ":windmill_fan_object", 0), (prop_instance_get_position, pos1, ":windmill_fan_object"), (position_rotate_y, pos1, 10), (prop_instance_animate_to_position, ":windmill_fan_object", pos1, 100), (val_add, ":instance_no", 1), (call_script, "script_cf_turn_windmill_fans", ":instance_no"), ]), # script_print_party_members # Input: arg1 = party_no # Output: s51 = output string. "noone" if the party is empty ("print_party_members", [(store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_stacks",":party_no"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop",":party_no",":i_stack"), (troop_is_hero, ":stack_troop"), (try_begin), (eq, ":i_stack", 0), (str_store_troop_name, s51, ":stack_troop"), (try_end), (str_store_troop_name, s50, ":stack_troop"), (try_begin), (eq, ":i_stack", 1), (str_store_string, s51, "str_s50_and_s51"), (else_try), (gt, ":i_stack", 1), (str_store_string, s51, "str_s50_comma_s51"), (try_end), (try_end), (try_begin), (eq, ":num_stacks", 0), (str_store_string, s51, "str_noone"), (try_end), ]), # script_round_value # Input: arg1 = value # Output: reg0 = rounded_value ("round_value", [ (store_script_param_1, ":value"), (try_begin), (lt, ":value", 100), (neq, ":value", 0), (val_add, ":value", 5), (val_div, ":value", 10), (val_mul, ":value", 10), (try_begin), (eq, ":value", 0), (assign, ":value", 5), (try_end), (else_try), (lt, ":value", 300), (val_add, ":value", 25), (val_div, ":value", 50), (val_mul, ":value", 50), (else_try), (val_add, ":value", 50), (val_div, ":value", 100), (val_mul, ":value", 100), (try_end), (assign, reg0, ":value"), ]), # script_change_banners_and_chest ("change_banners_and_chest", [(party_get_slot, ":cur_leader", "$g_encountered_party", slot_town_lord), (try_begin), (ge, ":cur_leader", 0), #normal_banner_begin (troop_get_slot, ":troop_banner_object", ":cur_leader", slot_troop_banner_scene_prop), (gt, ":troop_banner_object", 0), (replace_scene_props, banner_scene_props_begin, ":troop_banner_object"), (else_try), (replace_scene_props, banner_scene_props_begin, "spr_empty"), #custom_banner_begin # (troop_get_slot, ":flag_spr", ":cur_leader", slot_troop_custom_banner_flag_type), # (ge, ":flag_spr", 0), # (val_add, ":flag_spr", custom_banner_flag_scene_props_begin), # (replace_scene_props, banner_scene_props_begin, ":flag_spr"), # (else_try), # (replace_scene_props, banner_scene_props_begin, "spr_empty"), (try_end), (try_begin), #(neq, ":cur_leader", "trp_player"), (faction_slot_eq, "$players_kingdom", slot_faction_capital, "$g_encountered_party"), (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", tld_player_level_to_own_chest), #leave unlocked (else_try), (replace_scene_props, "spr_player_chest", "spr_locked_player_chest"), (try_end), ]), # script_remove_siege_objects # removes all objects inappropriate for siege scene (all troop/mount spawners etc) ("remove_siege_objects",[ # (try_for_range, ":prop", "spr_troop_guard", "spr_ZT_mb_chestnut"), # (replace_scene_props, ":prop", "spr_empty"), # (try_end), (try_for_range, ":prop", "spr_horse_riv_warhorse", "spr_spiderweb"), (replace_scene_props, ":prop", "spr_empty"), (try_end), (replace_scene_props, "spr_horse_player_horse", "spr_empty"), (try_for_range, ":prop", "spr_horse_warg_1C", "spr_sound_waterfall"), (replace_scene_props, ":prop", "spr_empty"), (try_end), (try_for_range, ":prop", "spr_troop_civilian", "spr_water_fall_big"), (replace_scene_props, ":prop", "spr_empty"), (try_end), (try_for_range, ":prop", "spr_troop_rider", spr_troop_messenger+1), (replace_scene_props, ":prop", "spr_empty"), (try_end), ]), # script_describe_relation_to_s63 # Input: arg1 = relation (-100 .. 100) # Output: none ("describe_relation_to_s63", [(store_script_param_1, ":relation"), (store_add, ":normalized_relation", ":relation", 100), (val_add, ":normalized_relation", 5), (store_div, ":str_offset", ":normalized_relation", 10), (val_clamp, ":str_offset", 0, 20), (store_add, ":str_id", "str_relation_mnus_100", ":str_offset"), (str_store_string, s63, ":str_id"), ]), # script_describe_center_relation_to_s3 # Input: arg1 = relation (-100 .. 100) # Output: none # ("describe_center_relation_to_s3", # [(store_script_param_1, ":relation"), # (store_add, ":normalized_relation", ":relation", 100), # (val_add, ":normalized_relation", 5), # (store_div, ":str_offset", ":normalized_relation", 10), # (val_clamp, ":str_offset", 0, 20), # (store_add, ":str_id", "str_center_relation_mnus_100", ":str_offset"), # (str_store_string, s3, ":str_id"), # ]), # script_center_ambiance_sounds # to be called every two seconds. TODO for TLD centers ("center_ambiance_sounds", [(set_fixed_point_multiplier, 100), (try_begin), (assign, ":sound", 0), (ge, "$play_ambient_sounds", 1), (try_begin), (party_slot_eq, "$g_encountered_party", slot_party_type, spt_town), (party_get_slot,":sound","$g_encountered_party", slot_center_occasional_sound1_day), (gt, ":sound", 0), (else_try), (ge, "$play_ambient_sounds", 2), #we use 0 and 1 for off/on, greater than that stores sound# (assign, ":sound", "$play_ambient_sounds"), (try_end), (gt, ":sound", 0), #play somewhere around the player (get_player_agent_no, ":player_agent"), (agent_get_position, pos5, ":player_agent"), (store_random_in_range, ":x", -1000, 1000), (store_random_in_range, ":y", -1000, 1000), (position_move_x, pos5, ":x"), (position_move_y, pos5, ":y"), #(neg|is_currently_night), (store_random_in_range, ":r", 0, 7), (ge, ":r", 5), ] + (is_a_wb_script==1 and [ (play_sound_at_position, ":sound", pos5), ] or [ (play_sound, ":sound"), ]) + [ (try_end), ]), # script_center_set_walker_to_type # Input: arg1 = center_no, arg2 = walker_no, arg3 = walker_type, # Output: none ("center_set_walker_to_type", [ (store_script_param, ":center_no", 1), (store_script_param, ":walker_no", 2), (store_script_param, ":walker_type", 3), (store_add, ":type_slot", slot_center_walker_0_type, ":walker_no"), (party_set_slot, ":center_no", ":type_slot", ":walker_type"), (store_random_in_range, ":walker_dna", 0, 1000000), (store_add, ":dna_slot", slot_center_walker_0_dna, ":walker_no"), (party_set_slot, ":center_no", ":dna_slot", ":walker_dna"), ]), # script_cf_center_get_free_walker # Input: arg1 = center_no # Output: reg0 = walker no (can fail) ("cf_center_get_free_walker", [ (store_script_param, ":center_no", 1), (assign, ":num_free_walkers", 0), (try_for_range, ":walker_no", 0, num_town_walkers), (store_add, ":type_slot", slot_center_walker_0_type, ":walker_no"), (party_slot_eq, ":center_no", ":type_slot", walkert_default), (val_add, ":num_free_walkers", 1), (try_end), (gt, ":num_free_walkers", 0), (assign, reg0, -1), (store_random_in_range, ":random_rank", 0, ":num_free_walkers"), (try_for_range, ":walker_no", 0, num_town_walkers), (store_add, ":type_slot", slot_center_walker_0_type, ":walker_no"), (party_slot_eq, ":center_no", ":type_slot", walkert_default), (val_sub, ":num_free_walkers", 1), (eq, ":num_free_walkers", ":random_rank"), (assign, reg0, ":walker_no"), (try_end), ]), # script_center_remove_walker_type_from_walkers # Input: arg1 = center_no, arg2 = walker_type, # Output: reg0 = 1 if comment found, 0 otherwise; s61 will contain comment string if found ("center_remove_walker_type_from_walkers", [ (store_script_param, ":center_no", 1), (store_script_param, ":walker_type", 2), (try_for_range, ":walker_no", 0, num_town_walkers), (store_add, ":type_slot", slot_center_walker_0_type, ":walker_no"), (party_slot_eq, ":center_no", ":type_slot", ":walker_type"), (call_script, "script_center_set_walker_to_type", ":center_no", ":walker_no", walkert_default), (try_end), ]), # script_init_town_walkers ("init_town_walkers", [(try_begin), (this_or_next|eq, "$town_nighttime", 0), (this_or_next|eq, "$current_town", "p_town_west_osgiliath"), # walkers there in osgiliaths (this_or_next|eq, "$current_town", "p_town_east_osgiliath"), # walkers there in osgiliaths (this_or_next|eq, "$current_town", "p_town_cair_andros"), # walkers there in osgiliaths (neq, "$g_defending_against_siege", 0), # walkers there when siege (try_begin), ## Kham Edit for more town walkers! (this_or_next|is_between, "$current_town", isengard_mordor_centers_begin, isengard_mordor_centers_end), (this_or_next|is_between, "$current_town", moria_centers_begin, moria_centers_end), ( is_between, "$current_town", gundabad_centers_begin, gundabad_centers_end), (neq, "$current_town", p_town_goblin_north_outpost), #exception, too many walkers clog the ladders #(set_visitors, ":entry_no", ":walker_troop_id",6), #entry points 32-39 (assign, ":num_walkers", 5), (else_try), (this_or_next|eq, "$current_town", "p_town_woodelf_camp"), (this_or_next|eq, "$current_town", "p_town_thranduils_halls"), (this_or_next|eq, "$current_town", "p_town_woodelf_west_camp"), (this_or_next|eq, "$current_town", "p_town_caras_galadhon"), (this_or_next|eq, "$current_town", "p_town_cerin_dolen"), (this_or_next|eq, "$current_town", "p_town_cerin_amroth"), (this_or_next|eq, "$current_town", "p_town_thranduils_halls"), ( eq, "$current_town", "p_town_henneth_annun"), #( eq, "$current_town", "p_town_imladris_camp"), #Enough space for lots of walkers #(set_visitors, ":entry_no", ":walker_troop_id",1), (assign, ":num_walkers", 2), (else_try), #(set_visitors, ":entry_no", ":walker_troop_id",4), (assign, ":num_walkers", 4), (try_end), ## Kham Edit for more town walkers! - END (try_for_range, ":entry_no", town_walker_entries_start, 40), (try_for_range, ":unused", 0, ":num_walkers"), (store_random_in_range, ":walker_no", 0, num_town_walkers), (store_add, ":troop_slot", slot_center_walker_0_troop, ":walker_no"), (try_begin), (eq, "$g_defending_against_siege", 0), (party_get_slot, ":walker_troop_id", "$current_town", ":troop_slot"), (else_try), # TODO: put military walkers when siege (party_get_slot, ":walker_troop_id", "$current_town", ":troop_slot"), (try_end), (gt, ":walker_troop_id", 0), (set_visitor, ":entry_no", ":walker_troop_id"), (try_end), (try_end), (try_end), ]), # script_cf_enter_center_location_bandit_check ("cf_enter_center_location_bandit_check", [ (neq, "$town_nighttime", 0), (party_slot_ge, "$current_town", slot_center_has_bandits, 1), (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting) (eq, "$sneaked_into_town", 0),#Skip if sneaked (party_get_slot, ":cur_scene", "$current_town", slot_town_center), (set_jump_mission, "mt_bandits_at_night"), (modify_visitors_at_site, ":cur_scene"), (reset_visitors), (party_get_slot, ":bandit_troop", "$current_town", slot_center_has_bandits), (troop_get_upgrade_troop, ":bandit_troop2", ":bandit_troop", 0), (store_character_level, ":level", "trp_player"), (assign, ":spawn_amount", 1), (assign, "$num_center_bandits", 0), (try_begin), (gt, ":level", 12), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":level"), (assign, ":spawn_amount", 3), (else_try), (gt, ":level", 6), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":level"), (assign, ":spawn_amount", 2), (try_end), (val_add, "$num_center_bandits", ":spawn_amount"), (set_visitors, 30, ":bandit_troop", ":spawn_amount"), (try_begin), (gt, ":level", 3), (assign, ":spawn_amount", 1), (try_begin), (gt, ":level", 15), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":level"), (assign, ":spawn_amount", 3), (else_try), (gt, ":level", 9), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":level"), (assign, ":spawn_amount", 2), (try_end), (set_visitors, 31, ":bandit_troop2", ":spawn_amount"), (val_add, "$num_center_bandits", ":spawn_amount"), (try_end), #(assign, "$town_entered", 1), (assign, "$all_doors_locked", 1), #(display_message, "@You have run into a trap!", 0xFFFF2222), (display_message, "@You are attacked by a group of bandits!", 0xFFFF2222), (jump_to_scene, ":cur_scene"), (change_screen_mission), ]), # script_init_town_agent ("init_town_agent", [ (store_script_param, ":agent_no", 1), (agent_get_troop_id, ":troop_no", ":agent_no"), (set_fixed_point_multiplier, 100), (assign, ":stand_animation", -1), (agent_set_slot, ":agent_no", 0, -1), #walker target, set to -1 here, reassigned for walkers later (try_begin), # (this_or_next|is_between, ":troop_no", armor_merchants_begin, armor_merchants_end), (is_between, ":troop_no", weapon_merchants_begin, weapon_merchants_end), (try_begin), (troop_get_type, ":cur_troop_gender", ":troop_no"), (eq, ":cur_troop_gender", 0), (agent_set_animation, ":agent_no", "anim_stand_townguard"), (else_try), (agent_set_animation, ":agent_no", "anim_stand_townguard"), (try_end), (else_try), (this_or_next|eq, ":troop_no", "trp_gondor_lord"), # mtarini: let sire Denethor sit. GA: as well as Saruman. Them are always in capitals ( eq, ":troop_no", "trp_isengard_lord"), (assign, ":stand_animation", "anim_sit_on_throne"), (else_try), (eq, ":troop_no", "trp_woodelf_lord"), (eq, "$current_town", "p_town_thranduils_halls"), (assign, ":stand_animation", "anim_sit_on_throne"), # GA: sitting Thranduil, but only in his halls (else_try), (eq, ":troop_no", "trp_gundabad_lord"), (eq, "$current_town", "p_town_gundabad"), (assign, ":stand_animation", "anim_sit_on_throne"), # GA: sitting Burza, but only in his cave (else_try), (is_between, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end), (assign, ":stand_animation", "anim_stand_lord"), (else_try), (is_between, ":troop_no", soldiers_begin, soldiers_end), (assign, ":stand_animation", "anim_stand_townguard"), (try_end), (try_begin), (ge, ":stand_animation", 0), (agent_set_stand_animation, ":agent_no", ":stand_animation"), (agent_set_animation, ":agent_no", ":stand_animation"), (store_random_in_range, ":random_no", 0, 100), (agent_set_animation_progress, ":agent_no", ":random_no"), (try_end), ]), # script_init_town_walker_agents ("init_town_walker_agents", [(assign, ":num_walkers", 0), (try_for_agents, ":cur_agent"), # (agent_get_troop_id, ":cur_troop", ":cur_agent"), # (is_between, ":cur_troop", walkers_begin, walkers_end), (agent_get_entry_no, ":entry", ":cur_agent"), (is_between, ":entry",town_walker_entries_start,40), (val_add, ":num_walkers", 1), (agent_get_position, pos1, ":cur_agent"), (store_random_in_range, ":i_e_p", town_walker_entries_start, 40),#Entry points (agent_set_slot, ":cur_agent", slot_agent_target_entry_point, ":i_e_p"), (agent_set_slot, ":cur_agent", slot_agent_walker_type, 1), (call_script, "script_set_town_walker_destination", ":cur_agent"), #equip carry items (agent_get_troop_id, ":walker_troop", ":cur_agent"), (this_or_next|party_slot_eq, "$current_town", slot_center_walker_1_troop, ":walker_troop"), #walker troops 1 and 2 are "workers" (party_slot_eq, "$current_town", slot_center_walker_2_troop, ":walker_troop"), (store_random_in_range, ":chance", 0, 100), (lt, ":chance", 60), #remove weapons and helms ] + (is_a_wb_script==1 and [ (try_for_range, ":weapon_slot", 0, 4), (agent_get_item_slot, ":item", ":cur_agent", ":weapon_slot"), (gt, ":item", 1), (agent_unequip_item, ":cur_agent", ":item", ":weapon_slot"), (try_end), (try_begin), (agent_get_item_slot, ":helm", ":cur_agent", ek_head), (gt, ":helm", 1), (neg|item_has_property, ":helm", itp_civilian), (agent_unequip_item, ":cur_agent", ":helm", ek_head), (try_end), (store_random_in_range, ":item", "itm_civilian_carry_amphora", "itm_civilian_carry_wood2"), (agent_equip_item, ":cur_agent", ":item", 1), (agent_set_wielded_item, ":cur_agent", ":item"), (agent_set_attack_action, ":cur_agent", 3, 1), ] or []) + [ (try_end), ]), # script_agent_get_town_walker_details # This script assumes this is one of town walkers. # Input: agent_id # Output: reg0: town_walker_type, reg1: town_walker_dna ("agent_get_town_walker_details", [(store_script_param, ":agent_no", 1), (agent_get_entry_no, ":entry_no", ":agent_no"), (store_sub, ":walker_no", ":entry_no", town_walker_entries_start), (store_add, ":type_slot", slot_center_walker_0_type, ":walker_no"), (party_get_slot, ":walker_type", "$current_town", ":type_slot"), (store_add, ":dna_slot", slot_center_walker_0_dna, ":walker_no"), (party_get_slot, ":walker_dna", "$current_town", ":dna_slot"), (assign, reg0, ":walker_type"), (assign, reg1, ":walker_dna"), (assign, reg2, ":walker_no"), ]), # script_tick_town_walkers ("tick_town_walkers", [(try_for_agents, ":cur_agent"), # (agent_get_troop_id, ":cur_troop", ":cur_agent"), # (is_between, ":cur_troop", walkers_begin, walkers_end), # (agent_get_entry_no, ":entry", ":cur_agent"), # (this_or_next|is_between, ":entry",town_walker_entries_start,40), # (is_between, ":entry",25,29), #guards (agent_get_slot, ":target_entry_point", ":cur_agent", slot_agent_target_entry_point), (ge, ":target_entry_point", 0), (agent_slot_eq, ":cur_agent", slot_agent_walker_type, 1), #civilian walker (entry_point_get_position, pos1, ":target_entry_point"), (try_begin), (lt, ":target_entry_point", town_walker_entries_start), (init_position, pos2), (position_set_y, pos2, 250), (position_transform_position_to_parent, pos1, pos1, pos2), (try_end), (agent_get_position, pos2, ":cur_agent"), (get_distance_between_positions, ":distance", pos1, pos2), (lt, ":distance", 400), (assign, ":random_no", 0), (try_begin), (lt, ":target_entry_point", town_walker_entries_start), (store_random_in_range, ":random_no", 0, 100), (try_end), (lt, ":random_no", 20), (call_script, "script_set_town_walker_destination", ":cur_agent"), (try_end), ]), # script_set_town_walker_destination ########(commented out by Kham to use the below) # Input: arg1 = agent_no #("set_town_walker_destination", # [(store_script_param_1, ":agent_no"), # (assign, reg0, 9), # (assign, reg1, 10), # (assign, reg2, 12), # (assign, reg3, 32), # (assign, reg4, 33), # (assign, reg5, 34), # (assign, reg6, 35), # (assign, reg7, 36), # (assign, reg8, 37), # (assign, reg9, 38), # (assign, reg10, 39), # (try_for_agents, ":cur_agent"), # (agent_get_troop_id, ":cur_troop", ":cur_agent"), # (is_between, ":cur_troop", walkers_begin, walkers_end), # (agent_get_entry_no, ":entry", ":cur_agent"), # (is_between, ":entry",town_walker_entries_start,40), # (agent_get_slot, ":target_entry_point", ":cur_agent", 0), # (try_begin),(eq, ":target_entry_point", 9),(assign, reg0, 0), # (else_try) ,(eq, ":target_entry_point",10),(assign, reg1, 0), # (else_try) ,(eq, ":target_entry_point",12),(assign, reg2, 0), # (else_try) ,(eq, ":target_entry_point",32),(assign, reg3, 0), # (else_try) ,(eq, ":target_entry_point",33),(assign, reg4, 0), # (else_try) ,(eq, ":target_entry_point",34),(assign, reg5, 0), # (else_try) ,(eq, ":target_entry_point",35),(assign, reg6, 0), # (else_try) ,(eq, ":target_entry_point",36),(assign, reg7, 0), # (else_try) ,(eq, ":target_entry_point",37),(assign, reg8, 0), # (else_try) ,(eq, ":target_entry_point",38),(assign, reg9, 0), # (else_try) ,(eq, ":target_entry_point",39),(assign,reg10, 0), # (try_end), # (try_end), # (assign, ":try_limit", 100), # (assign, ":target_entry_point", 0), # (try_for_range, ":unused", 0, ":try_limit"), # (shuffle_range, 0, 11), # (gt, reg0, 0), # (assign, ":target_entry_point", reg0), # (assign, ":try_limit", 0), # (try_end), # (try_begin), # (gt, ":target_entry_point", 0), # (agent_set_slot, ":agent_no", 0, ":target_entry_point"), # (entry_point_get_position, pos1, ":target_entry_point"), # (try_begin), # (lt, ":target_entry_point", town_walker_entries_start), # (init_position, pos2), # (position_set_y, pos2, 250), # (position_transform_position_to_parent, pos1, pos1, pos2), # (try_end), # (agent_set_scripted_destination, ":agent_no", pos1, 0), # # (agent_get_troop_id, ":troop_no", ":agent_no"), # orcs and dwarves walk slower # (troop_get_type,":try_limit",":troop_no"), # (try_begin), # (neq, "$current_town", "p_town_west_osgiliath"), # guys run in osgiliaths # (neq, "$current_town", "p_town_east_osgiliath"), ## (neq, "$g_defending_against_siege", 0), # guys run when siege # (try_begin), # (this_or_next|eq,":try_limit",tf_orc), # (eq,":try_limit",tf_dwarf), # (store_random_in_range,reg10,2,4), (agent_set_speed_limit, ":agent_no", reg10), # orc dwarf walk slower # (else_try), # (store_random_in_range,reg10,3,6), (agent_set_speed_limit, ":agent_no", reg10), # humans # (try_end), # (try_end), # (try_end), #]), # script_set_town_walker_destination - For More Town Walkers Edit - Kham (Source from xenoargh) # Input: arg1 = agent_no # Output: none ("set_town_walker_destination", [(store_script_param_1, ":agent_no"), (store_random_in_range, ":rand_dest", 1 ,12), #(agent_get_entry_no, ":entry", ":agent_no"), #(agent_get_slot, ":walker_type", ":agent_no", slot_agent_walker_type), #(agent_slot_eq, ":agent_no", slot_agent_walker_type, 1), #only for civilian walker (assign, ":is_guard", 0), (try_begin), #walkers #(is_between, ":entry",town_walker_entries_start,40), #(eq, ":walker_type", 1), (eq, ":rand_dest", 1), (assign, ":target_entry_point", 9), (else_try), (eq, ":rand_dest", 2), (assign, ":target_entry_point", 10), (else_try), (eq, ":rand_dest", 3), (assign, ":target_entry_point", 12), (else_try), (eq, ":rand_dest", 4), (assign, ":target_entry_point", 32), (else_try), (eq, ":rand_dest", 2), (assign, ":target_entry_point", 33), (else_try), (eq, ":rand_dest", 5), (assign, ":target_entry_point", 34), (else_try), (eq, ":rand_dest", 6), (assign, ":target_entry_point", 35), (else_try), (eq, ":rand_dest", 7), (assign, ":target_entry_point", 36), (else_try), (eq, ":rand_dest", 8), (assign, ":target_entry_point", 37), (else_try), (eq, ":rand_dest", 9), (assign, ":target_entry_point", 38), (else_try), (eq, ":rand_dest", 10), (assign, ":target_entry_point", 39), (else_try), (assign, ":target_entry_point", 10), (try_end), (try_begin), (agent_set_slot, ":agent_no", slot_agent_target_entry_point, ":target_entry_point"), (ge, ":target_entry_point", 0), (entry_point_get_position, pos1, ":target_entry_point"), (try_begin), (init_position, pos2), (position_set_y, pos2, 250), (position_transform_position_to_parent, pos1, pos1, pos2), (try_end), (agent_set_scripted_destination, ":agent_no", pos1, 0), (agent_get_troop_id, ":troop_no", ":agent_no"), # orcs and dwarves walk slower (troop_get_type,":try_limit",":troop_no"), (try_begin), # (neq, "$current_town", "p_town_west_osgiliath"), # guys run in osgiliaths # (neq, "$current_town", "p_town_east_osgiliath"), # (neq, "$g_defending_against_siege", 0), # guys run when siege (try_begin), (this_or_next|eq,":try_limit",tf_orc), (eq,":try_limit",tf_dwarf), (neq, ":is_guard", 1), (store_random_in_range,reg10,1,7), # orc dwarf walk slower (else_try), (neq, ":is_guard", 1), (store_random_in_range,reg10,2,8), # humans (else_try), #guards move slow (store_random_in_range,reg10,1,3), (try_end), (try_begin), (this_or_next|eq, "$current_town", "p_town_west_osgiliath"), (eq, "$current_town", "p_town_east_osgiliath"), (val_add, reg10, 4), (try_end), (agent_set_speed_limit, ":agent_no", reg10), (try_end), (try_end), ]), # script_siege_init_ai_and_belfry # Output: none (required for siege mission templates) ("siege_init_ai_and_belfry", [(assign, "$cur_belfry_pos", 50), (assign, ":cur_belfry_object_pos", slot_scene_belfry_props_begin), (store_current_scene, ":cur_scene"), #Collecting belfry objects (try_for_range, ":i_belfry_instance", 0, 3), (scene_prop_get_instance, ":belfry_object", "spr_belfry_a", ":i_belfry_instance"), (ge, ":belfry_object", 0), (scene_set_slot, ":cur_scene", ":cur_belfry_object_pos", ":belfry_object"), (val_add, ":cur_belfry_object_pos", 1), (try_end), (try_for_range, ":i_belfry_instance", 0, 3), (scene_prop_get_instance, ":belfry_object", "spr_belfry_platform_a", ":i_belfry_instance"), (ge, ":belfry_object", 0), (scene_set_slot, ":cur_scene", ":cur_belfry_object_pos", ":belfry_object"), (val_add, ":cur_belfry_object_pos", 1), (try_end), (try_for_range, ":i_belfry_instance", 0, 3), (scene_prop_get_instance, ":belfry_object", "spr_belfry_platform_b", ":i_belfry_instance"), (ge, ":belfry_object", 0), (scene_set_slot, ":cur_scene", ":cur_belfry_object_pos", ":belfry_object"), (val_add, ":cur_belfry_object_pos", 1), (try_end), (assign, "$belfry_rotating_objects_begin", ":cur_belfry_object_pos"), (try_for_range, ":i_belfry_instance", 0, 5), (scene_prop_get_instance, ":belfry_object", "spr_belfry_wheel", ":i_belfry_instance"), (ge, ":belfry_object", 0), (scene_set_slot, ":cur_scene", ":cur_belfry_object_pos", ":belfry_object"), (val_add, ":cur_belfry_object_pos", 1), (try_end), (assign, "$last_belfry_object_pos", ":cur_belfry_object_pos"), #Lifting up the platform at the beginning (try_begin), (scene_prop_get_instance, ":belfry_object_to_rotate", "spr_belfry_platform_a", 0), (try_end), #Moving the belfry objects to their starting position (entry_point_get_position,pos1,55), (entry_point_get_position,pos3,50), (try_for_range, ":i_belfry_object_pos", slot_scene_belfry_props_begin, "$last_belfry_object_pos"), (assign, ":pos_no", pos_belfry_begin), (val_add, ":pos_no", ":i_belfry_object_pos"), (val_sub, ":pos_no", slot_scene_belfry_props_begin), (scene_get_slot, ":cur_belfry_object", ":cur_scene", ":i_belfry_object_pos"), (prop_instance_get_position, pos2, ":cur_belfry_object"), (try_begin), (eq, ":cur_belfry_object", ":belfry_object_to_rotate"), (position_rotate_x, pos2, 90), (try_end), (position_transform_position_to_local, ":pos_no", pos1, pos2), (position_transform_position_to_parent, pos4, pos3, ":pos_no"), (prop_instance_animate_to_position, ":cur_belfry_object", pos4, 1), (try_end), (assign, "$belfry_positioned", 0), (assign, "$belfry_num_slots_positioned", 0), (assign, "$belfry_num_men_pushing", 0), ]), # script_cf_siege_move_belfry # Output: none (required for siege mission templates) ("cf_siege_move_belfry", [(neq, "$last_belfry_object_pos", slot_scene_belfry_props_begin), (entry_point_get_position,pos1,50), (entry_point_get_position,pos4,55), (get_distance_between_positions, ":total_distance", pos4, pos1), (store_current_scene, ":cur_scene"), (scene_get_slot, ":first_belfry_object", ":cur_scene", slot_scene_belfry_props_begin), (prop_instance_get_position, pos2, ":first_belfry_object"), (entry_point_get_position,pos1,"$cur_belfry_pos"), (position_transform_position_to_parent, pos3, pos1, pos_belfry_begin), (position_transform_position_to_parent, pos5, pos4, pos_belfry_begin), (get_distance_between_positions, ":cur_distance", pos2, pos3), (get_distance_between_positions, ":distance_left", pos2, pos5), (try_begin), (le, ":cur_distance", 10), (val_add, "$cur_belfry_pos", 1), (entry_point_get_position,pos1,"$cur_belfry_pos"), (position_transform_position_to_parent, pos3, pos1, pos_belfry_begin), (get_distance_between_positions, ":cur_distance", pos2, pos3), (try_end), (neq, "$cur_belfry_pos", 50), (assign, ":base_speed", 20), (store_div, ":slow_range", ":total_distance", 60), (store_sub, ":distance_moved", ":total_distance", ":distance_left"), (try_begin), (lt, ":distance_moved", ":slow_range"), (store_mul, ":base_speed", ":distance_moved", -60), (val_div, ":base_speed", ":slow_range"), (val_add, ":base_speed", 80), (else_try), (lt, ":distance_left", ":slow_range"), (store_mul, ":base_speed", ":distance_left", -60), (val_div, ":base_speed", ":slow_range"), (val_add, ":base_speed", 80), (try_end), (store_mul, ":belfry_speed", ":cur_distance", ":base_speed"), (try_begin), (eq, "$belfry_num_men_pushing", 0), (assign, ":belfry_speed", 1000000), (else_try), (val_div, ":belfry_speed", "$belfry_num_men_pushing"), (try_end), (try_begin), (le, "$cur_belfry_pos", 55), (init_position, pos3), (position_rotate_x, pos3, ":distance_moved"), (scene_get_slot, ":base_belfry_object", ":cur_scene", slot_scene_belfry_props_begin), (prop_instance_get_position, pos4, ":base_belfry_object"), (entry_point_get_position,pos1,"$cur_belfry_pos"), (try_for_range, ":i_belfry_object_pos", slot_scene_belfry_props_begin, "$last_belfry_object_pos"), (scene_get_slot, ":cur_belfry_object", ":cur_scene", ":i_belfry_object_pos"), (try_begin), (ge, ":i_belfry_object_pos", "$belfry_rotating_objects_begin"), (prop_instance_get_starting_position, pos5, ":base_belfry_object"), (prop_instance_get_starting_position, pos6, ":cur_belfry_object"), (position_transform_position_to_local, pos7, pos5, pos6), (position_transform_position_to_parent, pos5, pos4, pos7), (position_transform_position_to_parent, pos6, pos5, pos3), (prop_instance_set_position, ":cur_belfry_object", pos6), (else_try), (assign, ":pos_no", pos_belfry_begin), (val_add, ":pos_no", ":i_belfry_object_pos"), (val_sub, ":pos_no", slot_scene_belfry_props_begin), (position_transform_position_to_parent, pos2, pos1, ":pos_no"), (prop_instance_animate_to_position, ":cur_belfry_object", pos2, ":belfry_speed"), (try_end), (try_end), (try_end), (gt, "$cur_belfry_pos", 55), (assign, "$belfry_positioned", 1), ]), # script_cf_siege_rotate_belfry_platform # Input: none # Output: none (required for siege mission templates) ("cf_siege_rotate_belfry_platform", [(eq, "$belfry_positioned", 1), (scene_prop_get_instance, ":belfry_object", "spr_belfry_platform_a", 0), (prop_instance_get_position, pos1, ":belfry_object"), (position_rotate_x, pos1, -90), (prop_instance_animate_to_position, ":belfry_object", pos1, 400), (assign, "$belfry_positioned", 2), ]), # script_cf_siege_assign_men_to_belfry # Output: none (required for siege mission templates) ("cf_siege_assign_men_to_belfry", [(store_mission_timer_a, ":cur_seconds"), (neq, "$last_belfry_object_pos", slot_scene_belfry_props_begin), (assign, ":end_trigger", 0), (try_begin), (lt, "$belfry_positioned", 3), (get_player_agent_no, ":player_agent"), (store_current_scene, ":cur_scene"), (scene_get_slot, ":first_belfry_object", ":cur_scene", slot_scene_belfry_props_begin), (prop_instance_get_position, pos2, ":first_belfry_object"), (assign, ":slot_1_positioned", 0), (assign, ":slot_2_positioned", 0), (assign, ":slot_3_positioned", 0), (assign, ":slot_4_positioned", 0), (assign, ":slot_5_positioned", 0), (assign, ":slot_6_positioned", 0), (assign, "$belfry_num_slots_positioned", 0), (assign, "$belfry_num_men_pushing", 0), (try_for_agents, ":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_is_human, ":cur_agent"), (try_begin), (agent_get_slot, ":x_pos", ":cur_agent", slot_agent_target_x_pos), (neq, ":x_pos", 0), (agent_get_slot, ":y_pos", ":cur_agent", slot_agent_target_y_pos), (try_begin), (eq, ":x_pos", -600), (try_begin), (eq, ":y_pos", 0), (assign, ":slot_1_positioned", 1), (else_try), (eq, ":y_pos", -200), (assign, ":slot_2_positioned", 1), (else_try), (assign, ":slot_3_positioned", 1), (try_end), (else_try), (try_begin), (eq, ":y_pos", 0), (assign, ":slot_4_positioned", 1), (else_try), (eq, ":y_pos", -200), (assign, ":slot_5_positioned", 1), (else_try), (assign, ":slot_6_positioned", 1), (try_end), (try_end), (val_add, "$belfry_num_slots_positioned", 1), (init_position, pos1), (position_move_x, pos1, ":x_pos"), (position_move_y, pos1, ":y_pos"), (init_position, pos3), (position_move_x, pos3, ":x_pos"), (position_move_y, pos3, -1000), (position_transform_position_to_parent, pos4, pos2, pos1), (position_transform_position_to_parent, pos5, pos2, pos3), (agent_get_position, pos6, ":cur_agent"), (get_distance_between_positions, ":target_distance", pos6, pos4), (get_distance_between_positions, ":waypoint_distance", pos6, pos5), (try_begin), (this_or_next|lt, ":target_distance", ":waypoint_distance"), (lt, ":waypoint_distance", 600), (agent_set_scripted_destination, ":cur_agent", pos4, 1), (else_try), (agent_set_scripted_destination, ":cur_agent", pos5, 1), (try_end), (try_begin), (le, ":target_distance", 300), (val_add, "$belfry_num_men_pushing", 1), (try_end), (else_try), (agent_get_team, ":cur_agent_team", ":cur_agent"), (this_or_next|eq, "$attacker_team", ":cur_agent_team"), ( eq, "$attacker_team_2", ":cur_agent_team"), (try_begin), (gt, ":cur_seconds", 20), (agent_get_position, pos1, ":cur_agent"), (agent_set_scripted_destination, ":cur_agent", pos1, 0), (else_try), (try_begin), (team_get_movement_order, ":order1", "$attacker_team", grc_infantry), (team_get_movement_order, ":order2", "$attacker_team", grc_cavalry), (team_get_movement_order, ":order3", "$attacker_team", grc_archers), (this_or_next|neq, ":order1", mordr_stand_ground), (this_or_next|neq, ":order2", mordr_stand_ground), (neq, ":order3", mordr_stand_ground), (set_show_messages, 0), (team_give_order, "$attacker_team", grc_everyone, mordr_stand_ground), (set_show_messages, 1), (try_end), (try_end), (try_end), (try_end), (try_begin), (lt, "$belfry_num_slots_positioned", 6), (try_for_agents, ":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_get_team, ":cur_agent_team", ":cur_agent"), (this_or_next|eq, "$attacker_team", ":cur_agent_team"), ( eq, "$attacker_team_2", ":cur_agent_team"), (neq, ":player_agent", ":cur_agent"), (agent_get_class, ":agent_class", ":cur_agent"), (this_or_next|eq, ":agent_class", grc_infantry), (eq, ":agent_class", grc_cavalry), (agent_get_slot, ":x_pos", ":cur_agent", 1), (eq, ":x_pos", 0), (assign, ":y_pos", 0), (try_begin), (eq, ":slot_1_positioned", 0), (assign, ":x_pos", -600), (assign, ":y_pos", 0), (val_add, ":slot_1_positioned", 1), (else_try), (eq, ":slot_2_positioned", 0), (assign, ":x_pos", -600), (assign, ":y_pos", -200), (val_add, ":slot_2_positioned", 1), (else_try), (eq, ":slot_3_positioned", 0), (assign, ":x_pos", -600), (assign, ":y_pos", -400), (val_add, ":slot_3_positioned", 1), (else_try), (eq, ":slot_4_positioned", 0), (assign, ":x_pos", 600), (assign, ":y_pos", 0), (val_add, ":slot_4_positioned", 1), (else_try), (eq, ":slot_5_positioned", 0), (assign, ":x_pos", 600), (assign, ":y_pos", -200), (val_add, ":slot_5_positioned", 1), (else_try), (eq, ":slot_6_positioned", 0), (assign, ":x_pos", 600), (assign, ":y_pos", -400), (val_add, ":slot_6_positioned", 1), (try_end), (val_add, "$belfry_num_slots_positioned", 1), (agent_set_slot, ":cur_agent", 1, ":x_pos"), (agent_set_slot, ":cur_agent", 2, ":y_pos"), (try_end), (try_end), (try_begin), (store_mission_timer_a, ":cur_timer"), (gt, ":cur_timer", 20), (lt, "$belfry_num_slots_positioned", 6), (try_for_agents, ":cur_agent"), (agent_is_alive, ":cur_agent"), (agent_get_team, ":cur_agent_team", ":cur_agent"), (this_or_next|eq, "$attacker_team", ":cur_agent_team"), ( eq, "$attacker_team_2", ":cur_agent_team"), (neq, ":player_agent", ":cur_agent"), (agent_get_slot, ":x_pos", ":cur_agent", 1), (eq, ":x_pos", 0), (assign, ":y_pos", 0), (try_begin), (eq, ":slot_1_positioned", 0), (assign, ":x_pos", -600), (assign, ":y_pos", 0), (val_add, ":slot_1_positioned", 1), (else_try), (eq, ":slot_2_positioned", 0), (assign, ":x_pos", -600), (assign, ":y_pos", -200), (val_add, ":slot_2_positioned", 1), (else_try), (eq, ":slot_3_positioned", 0), (assign, ":x_pos", -600), (assign, ":y_pos", -400), (val_add, ":slot_3_positioned", 1), (else_try), (eq, ":slot_4_positioned", 0), (assign, ":x_pos", 600), (assign, ":y_pos", 0), (val_add, ":slot_4_positioned", 1), (else_try), (eq, ":slot_5_positioned", 0), (assign, ":x_pos", 600), (assign, ":y_pos", -200), (val_add, ":slot_5_positioned", 1), (else_try), (eq, ":slot_6_positioned", 0), (assign, ":x_pos", 600), (assign, ":y_pos", -400), (val_add, ":slot_6_positioned", 1), (try_end), (val_add, "$belfry_num_slots_positioned", 1), (agent_set_slot, ":cur_agent", 1, ":x_pos"), (agent_set_slot, ":cur_agent", 2, ":y_pos"), (try_end), (try_end), (else_try), (assign, ":end_trigger", 1), (try_for_agents, ":cur_agent"), (agent_clear_scripted_mode, ":cur_agent"), (try_end), (set_show_messages, 0), (team_give_order, "$attacker_team", grc_everyone, mordr_charge), (set_show_messages, 1), (try_end), (eq, ":end_trigger", 1), ]), # script_siege_move_archers_to_archer_positions ("siege_move_archers_to_archer_positions", [(try_for_agents, ":agent_no"), (agent_is_alive, ":agent_no"), (agent_get_class, ":agent_class", ":agent_no"), ] + (is_a_wb_script==1 and [ (try_begin), #Kham : horse archer siege fix? (agent_get_troop_id, ":agent_troop", ":agent_no"), (troop_is_guarantee_ranged, ":agent_troop"), (troop_is_guarantee_horse, ":agent_troop"), (troop_is_mounted, ":agent_troop"), (assign, ":agent_class", grc_archers), ## TODO proficiency check to make sure they're suited to ranged (not throwing)? (try_end), ] or []) + [ (eq, ":agent_class", grc_archers), (try_begin), (agent_is_defender, ":agent_no"), # defending archers go to their respective points (agent_slot_eq, ":agent_no", slot_agent_is_not_reinforcement, 0), (try_begin), (agent_slot_eq, ":agent_no", slot_agent_target_entry_point, 0), (agent_get_team, ":team", ":agent_no"), #0, 2, 4 (store_div, ":team_slot", ":team", 2), #0, 1, 2 (neg|troop_slot_eq,"trp_no_troop",":team_slot",-1), #choke point not taken (try_begin),(eq,":team",0),(store_random_in_range, ":random_entry_point", 50, 56), (ge, ":random_entry_point", 53), (assign, ":random_entry_point", 42), #left (else_try),(eq,":team",2),(store_random_in_range, ":random_entry_point", 54, 57), (ge, ":random_entry_point", 55), (assign, ":random_entry_point", 41), #center (else_try), (store_random_in_range, ":random_entry_point", 56, 62), (ge, ":random_entry_point", 59), (assign, ":random_entry_point", 43), #right (try_end), (agent_set_slot, ":agent_no", slot_agent_target_entry_point, ":random_entry_point"), (try_end), (try_begin), (agent_get_position, pos0, ":agent_no"), (agent_get_slot, ":target_entry", ":agent_no", slot_agent_target_entry_point), (gt, ":target_entry", 0), (entry_point_get_position, pos1, ":target_entry"), (get_distance_between_positions, ":dist", pos0, pos1), (lt, ":dist", 300), (agent_clear_scripted_mode, ":agent_no"), (agent_set_slot, ":agent_no", slot_agent_is_in_scripted_mode, 0), (agent_set_slot, ":agent_no", slot_agent_is_not_reinforcement, 1), # #debug # (str_store_troop_name, s1, ":agent_troop"), # (assign, reg0, ":agent_no"), # (assign, reg78, ":target_entry"), # (display_message, "@{s1} ({reg0}) reached pos {reg78}"), (else_try), (gt, ":target_entry", 0), (agent_get_simple_behavior, ":agent_sb", ":agent_no"), #(agent_get_combat_state, ":agent_cs", ":agent_no"), (this_or_next|eq, ":agent_sb", aisb_ranged), (eq, ":agent_sb", aisb_go_to_pos),#scripted mode #(eq, ":agent_cs", 7), # 7 = no visible targets (state for ranged units) #InVain: Disabled, this made the AI too unpredictable (try_begin), (agent_slot_eq, ":agent_no", slot_agent_is_in_scripted_mode, 0), (agent_set_scripted_destination, ":agent_no", pos1, 0), ] + (is_a_wb_script==1 and [ (agent_force_rethink, ":agent_no"), ] or []) + [ (agent_set_slot, ":agent_no", slot_agent_is_in_scripted_mode, 1), # #debug # (str_store_troop_name, s1, ":agent_troop"), # (assign, reg0, ":agent_no"), # (assign, reg78, ":target_entry"), # (display_message, "@{s1} ({reg0}) moving to pos {reg78}"), (try_end), (else_try), #(try_begin), (agent_slot_eq, ":agent_no", slot_agent_is_in_scripted_mode, 1), (agent_clear_scripted_mode, ":agent_no"), (agent_set_slot, ":agent_no", slot_agent_is_in_scripted_mode, 0), #(str_store_troop_name, s1, ":agent_troop"), #(assign, reg0, ":agent_no"), # (display_message, "@{s1} ({reg0}) seeing target or changed mode"), #(try_end), (try_end), (else_try), # when archer is an attacker (neg|agent_is_defender, ":agent_no"), (agent_get_ammo,":ammo",":agent_no"), (try_begin), (lt,":ammo",2), (agent_clear_scripted_mode, ":agent_no"), (agent_ai_set_always_attack_in_melee, ":agent_no", 1), ] + (is_a_wb_script==1 and [ (agent_set_division, ":agent_no", grc_infantry), (agent_force_rethink, ":agent_no"), ] or []) + [ (else_try), (ge,"$attacker_reinforcement_stage",10), (agent_get_combat_state,":combat_state", ":agent_no"), (eq, ":combat_state", 0), #not aiming at anyone (agent_clear_scripted_mode, ":agent_no"), (agent_ai_set_always_attack_in_melee, ":agent_no", 1), ] + (is_a_wb_script==1 and [ (agent_set_division, ":agent_no", grc_infantry), (agent_force_rethink, ":agent_no"), ] or []) + [ (try_end), (try_end), (try_end), ]), # script_store_movement_order_name_to_s1 # Input: arg1 = team_no, arg2 = class_no # Output: s1 = order_name ("store_movement_order_name_to_s1", [(store_script_param_1, ":team_no"), (store_script_param_2, ":class_no"), (team_get_movement_order, ":cur_order", ":team_no", ":class_no"), (try_begin),(eq, ":cur_order", mordr_hold ),(str_store_string, s1, "@Holding"), (else_try) ,(eq, ":cur_order", mordr_follow ),(str_store_string, s1, "@Following"), (else_try) ,(eq, ":cur_order", mordr_charge ),(str_store_string, s1, "@Charging"), (else_try) ,(eq, ":cur_order", mordr_advance ),(str_store_string, s1, "@Advancing"), (else_try) ,(eq, ":cur_order", mordr_fall_back ),(str_store_string, s1, "@Falling Back"), (else_try) ,(eq, ":cur_order", mordr_stand_closer),(str_store_string, s1, "@Standing Closer"), (else_try) ,(eq, ":cur_order", mordr_spread_out ),(str_store_string, s1, "@Spreading Out"), (else_try) ,(eq, ":cur_order", mordr_stand_ground),(str_store_string, s1, "@Standing"), (else_try) , (str_store_string, s1, "@N/A"), (try_end), ]), # script_store_riding_order_name_to_s1 # Input: arg1 = team_no, arg2 = class_no # Output: s1 = order_name ("store_riding_order_name_to_s1", [(store_script_param_1, ":team_no"), (store_script_param_2, ":class_no"), (team_get_riding_order, ":cur_order", ":team_no", ":class_no"), (try_begin), (eq, ":cur_order", rordr_free), (str_store_string, s1, "@Free"), (else_try), (eq, ":cur_order", rordr_mount), (str_store_string, s1, "@Mount"), (else_try), (eq, ":cur_order", rordr_dismount), (str_store_string, s1, "@Dismount"), (else_try), (str_store_string, s1, "@N/A"), (try_end), ]), # script_store_weapon_usage_order_name_to_s1 # Input: arg1 = team_no, arg2 = class_no # Output: s1 = order_name ("store_weapon_usage_order_name_to_s1", [(store_script_param_1, ":team_no"), (store_script_param_2, ":class_no"), (team_get_weapon_usage_order, ":cur_order", ":team_no", ":class_no"), (team_get_hold_fire_order, ":cur_hold_fire", ":team_no", ":class_no"), (try_begin), (eq, ":cur_order", wordr_use_any_weapon), (eq, ":cur_hold_fire", aordr_fire_at_will), (str_store_string, s1, "@Any Weapon"), (else_try), (eq, ":cur_order", wordr_use_blunt_weapons), (eq, ":cur_hold_fire", aordr_fire_at_will), (str_store_string, s1, "@Blunt Weapons"), (else_try), (eq, ":cur_order", wordr_use_any_weapon), (eq, ":cur_hold_fire", aordr_hold_your_fire), (str_store_string, s1, "str_hold_fire"), (else_try), (eq, ":cur_order", wordr_use_blunt_weapons), (eq, ":cur_hold_fire", aordr_hold_your_fire), (str_store_string, s1, "str_blunt_hold_fire"), (else_try), (str_store_string, s1, "@N/A"), (try_end), ]), # script_team_give_order_from_order_panel # Input: arg1 = leader_agent_no, arg2 = class_no # Output: none ("team_give_order_from_order_panel", [(store_script_param_1, ":leader_agent_no"), (store_script_param_2, ":order"), (agent_get_team, ":team_no", ":leader_agent_no"), (set_show_messages, 0), (try_begin), (eq, "$g_formation_infantry_selected", 1), (team_give_order, ":team_no", grc_infantry, ":order"), (try_end), (try_begin), (eq, "$g_formation_archers_selected", 1), (team_give_order, ":team_no", grc_archers, ":order"), (try_end), (try_begin), (eq, "$g_formation_cavalry_selected", 1), (team_give_order, ":team_no", grc_cavalry, ":order"), (try_end), (try_begin), (eq, ":order", mordr_hold), (agent_get_position, pos1, ":leader_agent_no"), (try_begin), (eq, "$g_formation_infantry_selected", 1), (team_set_order_position, ":team_no", grc_infantry, pos1), (try_end), (try_begin), (eq, "$g_formation_archers_selected", 1), (team_set_order_position, ":team_no", grc_archers, pos1), (try_end), (try_begin), (eq, "$g_formation_cavalry_selected", 1), (team_set_order_position, ":team_no", grc_cavalry, pos1), (try_end), (try_end), (try_begin), (eq, "$tld_option_formations", 1), (call_script, "script_player_order_formations", ":order"), #for formations ] + (is_a_wb_script==1 and [ (else_try), (eq, "$tld_option_formations", 2), (call_script, "script_player_order_formations_moto", ":order"), #for formations v5 ] or []) + [ (try_end), (set_show_messages, 1), ]), # script_update_order_panel # Input: arg1 = team_no ("update_order_panel", [(store_script_param_1, ":team_no"), (set_fixed_point_multiplier, 1000), (assign, ":old_is_infantry_listening", 0), (try_begin), (class_is_listening_order, ":team_no", grc_infantry), (assign, ":old_is_infantry_listening", 1), (try_end), (assign, ":old_is_archers_listening", 0), (try_begin), (class_is_listening_order, ":team_no", grc_archers), (assign, ":old_is_archers_listening", 1), (try_end), (assign, ":old_is_cavalry_listening", 0), (try_begin), (class_is_listening_order, ":team_no", grc_cavalry), (assign, ":old_is_cavalry_listening", 1), (try_end), (call_script, "script_store_movement_order_name_to_s1", ":team_no", grc_infantry), (overlay_set_text, "$g_presentation_infantry_movement", s1), (call_script, "script_store_riding_order_name_to_s1", ":team_no", grc_infantry), (overlay_set_text, "$g_presentation_infantry_riding", s1), (call_script, "script_store_weapon_usage_order_name_to_s1", ":team_no", grc_infantry), (overlay_set_text, "$g_presentation_infantry_weapon_usage", s1), (call_script, "script_store_movement_order_name_to_s1", ":team_no", grc_archers), (overlay_set_text, "$g_presentation_archers_movement", s1), (call_script, "script_store_riding_order_name_to_s1", ":team_no", grc_archers), (overlay_set_text, "$g_presentation_archers_riding", s1), (call_script, "script_store_weapon_usage_order_name_to_s1", ":team_no", grc_archers), (overlay_set_text, "$g_presentation_archers_weapon_usage", s1), (call_script, "script_store_movement_order_name_to_s1", ":team_no", grc_cavalry), (overlay_set_text, "$g_presentation_cavalry_movement", s1), (call_script, "script_store_riding_order_name_to_s1", ":team_no", grc_cavalry), (overlay_set_text, "$g_presentation_cavalry_riding", s1), (call_script, "script_store_weapon_usage_order_name_to_s1", ":team_no", grc_cavalry), (overlay_set_text, "$g_presentation_cavalry_weapon_usage", s1), (try_begin), (eq, ":old_is_infantry_listening", 1), (eq, ":old_is_archers_listening", 1), (eq, ":old_is_cavalry_listening", 1), (team_set_order_listener, ":team_no", grc_everyone), (else_try), (eq, ":old_is_infantry_listening", 1), (team_set_order_listener, ":team_no", grc_infantry), (else_try), (eq, ":old_is_archers_listening", 1), (team_set_order_listener, ":team_no", grc_archers), (else_try), (eq, ":old_is_cavalry_listening", 1), (team_set_order_listener, ":team_no", grc_cavalry), (try_end), (position_set_y, pos1, 660), (position_set_x, pos1, 250), (overlay_set_position, "$g_presentation_infantry_movement", pos1), (position_set_x, pos1, 400), (overlay_set_position, "$g_presentation_infantry_riding", pos1), (position_set_x, pos1, 550), (overlay_set_position, "$g_presentation_infantry_weapon_usage", pos1), (position_set_y, pos1, 620), (position_set_x, pos1, 250), (overlay_set_position, "$g_presentation_archers_movement", pos1), (position_set_x, pos1, 400), (overlay_set_position, "$g_presentation_archers_riding", pos1), (position_set_x, pos1, 550), (overlay_set_position, "$g_presentation_archers_weapon_usage", pos1), (position_set_y, pos1, 580), (position_set_x, pos1, 250), (overlay_set_position, "$g_presentation_cavalry_movement", pos1), (position_set_x, pos1, 400), (overlay_set_position, "$g_presentation_cavalry_riding", pos1), (position_set_x, pos1, 550), (overlay_set_position, "$g_presentation_cavalry_weapon_usage", pos1), ]), # script_update_agent_position_on_map # Input: arg1 = agent_no, pos2 = map_size_pos ("update_agent_position_on_map", [(store_script_param_1, ":agent_no"), (agent_get_slot, ":agent_overlay", ":agent_no", slot_agent_map_overlay_id), (get_player_agent_no, ":player_agent"), (try_begin), (le, ":agent_overlay", 0), (set_fixed_point_multiplier, 1000), (try_begin), (eq, ":agent_no", ":player_agent"), (create_mesh_overlay, reg1, "mesh_player_dot"), (position_set_x, pos1, 500), (position_set_y, pos1, 500), (overlay_set_size, reg1, pos1), (else_try), (create_mesh_overlay, reg1, "mesh_white_dot"), (position_set_x, pos1, 200), (position_set_y, pos1, 200), (overlay_set_size, reg1, pos1), (try_end), (overlay_set_alpha, reg1, 0x88), (agent_set_slot, ":agent_no", slot_agent_map_overlay_id, reg1), (assign, ":agent_overlay", reg1), (try_end), (try_begin), (neq, ":agent_no", ":player_agent"), (agent_get_party_id, ":agent_party", ":agent_no"), (try_begin), (eq, ":agent_party", "p_main_party"), (agent_get_class, ":agent_class", ":agent_no"), (try_begin), (eq, ":agent_class", grc_archers), (overlay_set_color, ":agent_overlay", 0x34c6e4), (else_try), (eq, ":agent_class", grc_cavalry), (overlay_set_color, ":agent_overlay", 0x569619), (else_try), #grc_infantry (overlay_set_color, ":agent_overlay", 0x8d5220), (try_end), (else_try), (agent_is_ally, ":agent_no"), (overlay_set_color, ":agent_overlay", 0x5555FF), (else_try), (overlay_set_color, ":agent_overlay", 0xFF0000), (try_end), (try_end), (try_begin), (eq, ":agent_no", ":player_agent"), (agent_get_look_position, pos1, ":agent_no"), (position_get_rotation_around_z, ":rot", pos1), (init_position, pos10), (position_rotate_z, pos10, ":rot"), (overlay_set_mesh_rotation, ":agent_overlay", pos10), (call_script, "script_convert_3d_pos_to_map_pos"), (else_try), (agent_get_position, pos1, ":agent_no"), (call_script, "script_convert_3d_pos_to_map_pos"), (try_end), (overlay_set_position, ":agent_overlay", pos0), ]), # script_convert_3d_pos_to_map_pos # Input: pos1 = 3d_pos, pos2 = map_size_pos # Output: pos0 = map_pos ("convert_3d_pos_to_map_pos", [(set_fixed_point_multiplier, 1000), (position_transform_position_to_local, pos3, pos2, pos1), (position_get_x, ":agent_x_pos", pos3), (position_get_y, ":agent_y_pos", pos3), (val_max, "$g_battle_map_scale", 1), #MV defensive fix to avoid division by zero (val_div, ":agent_x_pos", "$g_battle_map_scale"), (val_div, ":agent_y_pos", "$g_battle_map_scale"), (set_fixed_point_multiplier, 1000), (store_sub, ":map_x", 980, "$g_battle_map_width"), (store_sub, ":map_y", 730, "$g_battle_map_height"), (val_add, ":agent_x_pos", ":map_x"), (val_add, ":agent_y_pos", ":map_y"), (position_set_x, pos0, ":agent_x_pos"), (position_set_y, pos0, ":agent_y_pos"), ]), # script_update_order_flags_on_map ("update_order_flags_on_map", [(set_fixed_point_multiplier, 1000), (get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (assign, ":old_is_infantry_listening", 0), (try_begin), (class_is_listening_order, ":player_team", grc_infantry), (assign, ":old_is_infantry_listening", 1), (try_end), (assign, ":old_is_archers_listening", 0), (try_begin), (class_is_listening_order, ":player_team", grc_archers), (assign, ":old_is_archers_listening", 1), (try_end), (assign, ":old_is_cavalry_listening", 0), (try_begin), (class_is_listening_order, ":player_team", grc_cavalry), (assign, ":old_is_cavalry_listening", 1), (try_end), (get_scene_boundaries, pos2, pos3), (team_get_movement_order, ":cur_order", ":player_team", grc_infantry), (try_begin), (eq, ":cur_order", mordr_hold), (team_get_order_position, pos1, ":player_team", grc_infantry), (call_script, "script_convert_3d_pos_to_map_pos"), (overlay_set_alpha, "$g_battle_map_infantry_order_flag", 0xFF), (overlay_set_position, "$g_battle_map_infantry_order_flag", pos0), (else_try), (overlay_set_alpha, "$g_battle_map_infantry_order_flag", 0), (try_end), (team_get_movement_order, ":cur_order", ":player_team", grc_archers), (try_begin), (eq, ":cur_order", mordr_hold), (team_get_order_position, pos1, ":player_team", grc_archers), (call_script, "script_convert_3d_pos_to_map_pos"), (overlay_set_alpha, "$g_battle_map_archers_order_flag", 0xFF), (overlay_set_position, "$g_battle_map_archers_order_flag", pos0), (else_try), (overlay_set_alpha, "$g_battle_map_archers_order_flag", 0), (try_end), (team_get_movement_order, ":cur_order", ":player_team", grc_cavalry), (try_begin), (eq, ":cur_order", mordr_hold), (team_get_order_position, pos1, ":player_team", grc_cavalry), (call_script, "script_convert_3d_pos_to_map_pos"), (overlay_set_alpha, "$g_battle_map_cavalry_order_flag", 0xFF), (overlay_set_position, "$g_battle_map_cavalry_order_flag", pos0), (else_try), (overlay_set_alpha, "$g_battle_map_cavalry_order_flag", 0), (try_end), (try_begin), (eq, ":old_is_infantry_listening", 1), (eq, ":old_is_archers_listening" , 1), (eq, ":old_is_cavalry_listening" , 1), (team_set_order_listener, ":player_team", grc_everyone), (else_try), (eq, ":old_is_infantry_listening", 1), (team_set_order_listener, ":player_team", grc_infantry), (else_try), (eq, ":old_is_archers_listening", 1), (team_set_order_listener, ":player_team", grc_archers), (else_try), (eq, ":old_is_cavalry_listening", 1), (team_set_order_listener, ":player_team", grc_cavalry), (try_end), ]), # script_update_order_panel_checked_classes ("update_order_panel_checked_classes", [(get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (try_begin), (class_is_listening_order, ":player_team", grc_infantry), (overlay_set_val, "$g_presentation_obj_4", 1), (assign, "$g_formation_infantry_selected", 1), (overlay_animate_to_alpha, "$g_presentation_obj_1", 250, 0x44), (else_try), (overlay_set_val, "$g_presentation_obj_4", 0), (assign, "$g_formation_infantry_selected", 0), (overlay_animate_to_alpha, "$g_presentation_obj_1", 250, 0), (try_end), (try_begin), (class_is_listening_order, ":player_team", grc_archers), (overlay_set_val, "$g_presentation_obj_5", 1), (assign, "$g_formation_archers_selected", 1), (overlay_animate_to_alpha, "$g_presentation_obj_2", 250, 0x44), (else_try), (overlay_set_val, "$g_presentation_obj_5", 0), (assign, "$g_formation_archers_selected", 0), (overlay_animate_to_alpha, "$g_presentation_obj_2", 250, 0), (try_end), (try_begin), (class_is_listening_order, ":player_team", grc_cavalry), (overlay_set_val, "$g_presentation_obj_6", 1), (assign, "$g_formation_cavalry_selected", 1), (overlay_animate_to_alpha, "$g_presentation_obj_3", 250, 0x44), (else_try), (overlay_set_val, "$g_presentation_obj_6", 0), (assign, "$g_formation_cavalry_selected", 0), (overlay_animate_to_alpha, "$g_presentation_obj_3", 250, 0), (try_end), ]), # script_update_order_panel_statistics_and_map ("update_order_panel_statistics_and_map", #TODO: Call this in every battle mission template, once per second [(set_fixed_point_multiplier, 1000), (assign, ":num_us_ready_infantry", 0), (assign, ":num_us_ready_archers", 0), (assign, ":num_us_ready_cavalry", 0), (assign, ":num_us_wounded_infantry", 0), (assign, ":num_us_wounded_archers", 0), (assign, ":num_us_wounded_cavalry", 0), (assign, ":num_us_dead_infantry", 0), (assign, ":num_us_dead_archers", 0), (assign, ":num_us_dead_cavalry", 0), (assign, ":num_allies_ready_men", 0), (assign, ":num_allies_wounded_men", 0), (assign, ":num_allies_dead_men", 0), (assign, ":num_enemies_ready_men", 0), (assign, ":num_enemies_wounded_men", 0), (assign, ":num_enemies_dead_men", 0), # CC: Modified code. (assign, ":num_us_routed_men", 0), (assign, ":num_allies_routed_men", 0), (assign, ":num_enemies_routed_men", 0), # CC: Modified code ends here. (get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (assign, ":old_is_infantry_listening", 0), (try_begin), (class_is_listening_order, ":player_team", grc_infantry), (assign, ":old_is_infantry_listening", 1), (try_end), (assign, ":old_is_archers_listening", 0), (try_begin), (class_is_listening_order, ":player_team", grc_archers), (assign, ":old_is_archers_listening", 1), (try_end), (assign, ":old_is_cavalry_listening", 0), (try_begin), (class_is_listening_order, ":player_team", grc_cavalry), (assign, ":old_is_cavalry_listening", 1), (try_end), (get_scene_boundaries, pos2, pos3), (try_for_agents,":cur_agent"), # CC: Modified to prevent routed enemies from showing as dead, wounded, or alive, and to count the routed troops. (try_begin), (eq, "$tld_option_morale", 1), (agent_slot_eq, ":cur_agent", slot_agent_routed, 2), (agent_get_party_id, ":agent_party", ":cur_agent"), (try_begin), (eq, ":agent_party", "p_main_party"), (val_add, ":num_us_routed_men", 1), (else_try), (agent_is_ally, ":cur_agent"), (val_add, ":num_allies_routed_men", 1), (else_try), (val_add, ":num_enemies_routed_men", 1), (try_end), (try_end), (agent_slot_eq|neg, ":cur_agent", slot_agent_routed, 2), # CC: Modified code ends here. (agent_is_human, ":cur_agent"), (agent_get_class, ":agent_class", ":cur_agent"), (agent_get_party_id, ":agent_party", ":cur_agent"), (agent_get_slot, ":agent_overlay", ":cur_agent", slot_agent_map_overlay_id), (try_begin), (eq, ":agent_party", "p_main_party"), (try_begin), (agent_is_alive, ":cur_agent"), (call_script, "script_update_agent_position_on_map", ":cur_agent"), (try_begin),(eq, ":agent_class", grc_archers),(val_add, ":num_us_ready_archers", 1), (else_try),(eq, ":agent_class", grc_cavalry),(val_add, ":num_us_ready_cavalry", 1), (else_try), (val_add, ":num_us_ready_infantry",1), (try_end), (else_try), (overlay_set_alpha, ":agent_overlay", 0), (agent_is_wounded, ":cur_agent"), (try_begin),(eq, ":agent_class", grc_archers),(val_add, ":num_us_wounded_archers", 1), (else_try),(eq, ":agent_class", grc_cavalry),(val_add, ":num_us_wounded_cavalry", 1), (else_try), (val_add, ":num_us_wounded_infantry",1), (try_end), (else_try), (try_begin),(eq, ":agent_class", grc_archers),(val_add, ":num_us_dead_archers", 1), (else_try),(eq, ":agent_class", grc_cavalry),(val_add, ":num_us_dead_cavalry", 1), (else_try), (val_add, ":num_us_dead_infantry",1), (try_end), (try_end), (else_try), (agent_is_ally, ":cur_agent"), (try_begin), (agent_is_alive, ":cur_agent"), (call_script, "script_update_agent_position_on_map", ":cur_agent"), (val_add, ":num_allies_ready_men", 1), (else_try), (overlay_set_alpha, ":agent_overlay", 0), (agent_is_wounded, ":cur_agent"), (val_add, ":num_allies_wounded_men", 1), (else_try), (val_add, ":num_allies_dead_men", 1), (try_end), (else_try), (try_begin), (agent_is_alive, ":cur_agent"), (call_script, "script_update_agent_position_on_map", ":cur_agent"), (val_add, ":num_enemies_ready_men", 1), (else_try), (overlay_set_alpha, ":agent_overlay", 0), (agent_is_wounded, ":cur_agent"), (val_add, ":num_enemies_wounded_men", 1), (else_try), (val_add, ":num_enemies_dead_men", 1), (try_end), (try_end), (try_end), (assign, reg1, ":num_us_ready_infantry"), (assign, reg2, ":num_us_ready_archers"), (assign, reg3, ":num_us_ready_cavalry"), (store_add, ":num_us_ready_men", ":num_us_ready_infantry", ":num_us_ready_archers"), (val_add, ":num_us_ready_men", ":num_us_ready_cavalry"), (store_add, ":num_us_wounded_men", ":num_us_wounded_infantry", ":num_us_wounded_archers"), (val_add, ":num_us_wounded_men", ":num_us_wounded_cavalry"), (store_add, ":num_us_dead_men", ":num_us_dead_infantry", ":num_us_dead_archers"), (val_add, ":num_us_dead_men", ":num_us_dead_cavalry"), (assign, reg4, ":num_us_ready_men"), (assign, reg5, ":num_us_wounded_men"), (assign, reg6, ":num_us_dead_men"), (assign, reg7, ":num_allies_ready_men"), (assign, reg8, ":num_allies_wounded_men"), (assign, reg9, ":num_allies_dead_men"), (assign, reg10, ":num_enemies_ready_men"), (assign, reg11, ":num_enemies_wounded_men"), (assign, reg12, ":num_enemies_dead_men"), (overlay_set_text, "$g_presentation_obj_7", "@Infantry ({reg1})"), (overlay_set_text, "$g_presentation_obj_8", "@Archers ({reg2})"), (overlay_set_text, "$g_presentation_obj_9", "@Cavalry ({reg3})"), (overlay_set_text, "$g_battle_us_ready", "@{reg4}"), (overlay_set_text, "$g_battle_us_wounded", "@{reg5}"), (overlay_set_text, "$g_battle_us_dead", "@{reg6}"), (overlay_set_text, "$g_battle_allies_ready", "@{reg7}"), (overlay_set_text, "$g_battle_allies_wounded", "@{reg8}"), (overlay_set_text, "$g_battle_allies_dead", "@{reg9}"), (overlay_set_text, "$g_battle_enemies_ready", "@{reg10}"), (overlay_set_text, "$g_battle_enemies_wounded", "@{reg11}"), (overlay_set_text, "$g_battle_enemies_dead", "@{reg12}"), (try_begin), (eq, "$tld_option_morale", 1), (assign, reg12, ":num_us_routed_men"), (overlay_set_text, "$g_presentation_obj_31", "@{reg12}"), (assign, reg12, ":num_allies_routed_men"), (overlay_set_text, "$g_presentation_obj_32", "@{reg12}"), (assign, reg12, ":num_enemies_routed_men"), (overlay_set_text, "$g_presentation_obj_33", "@{reg12}"), (try_end), (assign, ":stat_position_x", 100), (assign, ":stat_position_y", 100), (val_add, ":stat_position_x", 150), (val_add, ":stat_position_y", 80), (position_set_x, pos1, ":stat_position_x"), (position_set_y, pos1, ":stat_position_y"), (overlay_set_position, "$g_battle_us_ready", pos1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_battle_us_wounded", pos1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_battle_us_dead", pos1), (try_begin), (eq, "$tld_option_morale", 1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_presentation_obj_31", pos1), (val_add, ":stat_position_x", -150), (try_end), (val_add, ":stat_position_x", -300), (val_add, ":stat_position_y", -40), (position_set_x, pos1, ":stat_position_x"), (position_set_y, pos1, ":stat_position_y"), (overlay_set_position, "$g_battle_allies_ready", pos1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_battle_allies_wounded", pos1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_battle_allies_dead", pos1), (try_begin), (eq, "$tld_option_morale", 1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_presentation_obj_32", pos1), (val_add, ":stat_position_x", -150), (try_end), (val_add, ":stat_position_x", -300), (val_add, ":stat_position_y", -40), (position_set_x, pos1, ":stat_position_x"), (position_set_y, pos1, ":stat_position_y"), (overlay_set_position, "$g_battle_enemies_ready", pos1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_battle_enemies_wounded", pos1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_battle_enemies_dead", pos1), (try_begin), (eq, "$tld_option_morale", 1), (val_add, ":stat_position_x", 150), (position_set_x, pos1, ":stat_position_x"), (overlay_set_position, "$g_presentation_obj_33", pos1), (val_add, ":stat_position_x", -150), (try_end), (call_script, "script_update_order_flags_on_map"), (try_begin), (eq, ":old_is_infantry_listening", 1), (eq, ":old_is_archers_listening", 1), (eq, ":old_is_cavalry_listening", 1), (team_set_order_listener, ":player_team", grc_everyone), (else_try), (eq, ":old_is_infantry_listening", 1), (team_set_order_listener, ":player_team", grc_infantry), (else_try), (eq, ":old_is_archers_listening", 1), (team_set_order_listener, ":player_team", grc_archers), (else_try), (eq, ":old_is_cavalry_listening", 1), (team_set_order_listener, ":player_team", grc_cavalry), (try_end), ]), # script_consume_food # Input: arg1: order of the food to be consumed # Output: none ("consume_food", [(store_script_param, ":selected_food", 1), (troop_get_inventory_capacity, ":capacity", "trp_player"), (try_for_range, ":cur_slot", 0, ":capacity"), (troop_get_inventory_slot, ":cur_item", "trp_player", ":cur_slot"), (this_or_next|is_between, ":cur_item", food_begin, food_end), (eq, ":cur_item", "itm_horse_meat"), (troop_get_inventory_slot_modifier, ":item_modifier", "trp_player", ":cur_slot"), #Kham - Orcs / Uruks eat rotten food (call_script, "script_are_there_orcs", "p_main_party"), (assign, ":continue", 1), (try_begin), (le, reg0, 0), (eq, ":item_modifier", imod_rotten), (assign, ":continue", 0), (try_end), (eq, ":continue", 1), #Kham - End (item_slot_eq, ":cur_item", slot_item_is_checked, 0), (item_set_slot, ":cur_item", slot_item_is_checked, 1), (val_sub, ":selected_food", 1), (lt, ":selected_food", 0), (assign, ":capacity", 0), (troop_inventory_slot_get_item_amount, ":cur_amount", "trp_player", ":cur_slot"), (val_sub, ":cur_amount", 1), (troop_inventory_slot_set_item_amount, "trp_player", ":cur_slot", ":cur_amount"), (try_end), ]), # script_calculate_troop_score_for_center #InVain: Not used in TLD # Input: arg1 = troop_no, arg2 = center_no # Output: reg0 = score ("calculate_troop_score_for_center", [(store_script_param, ":troop_no", 1), (store_script_param, ":center_no", 2), (assign, ":num_center_points", 1), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (assign, ":center_owned", 0), (try_begin), (eq, ":troop_no", "trp_player"), (party_slot_eq, ":cur_center", slot_town_lord, stl_reserved_for_player), (assign, ":center_owned", 1), (try_end), (this_or_next|party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"), (eq, ":center_owned", 1), (try_begin), (party_slot_eq, ":cur_center", slot_party_type, spt_town), (val_add, ":num_center_points", 4), (else_try), (party_slot_eq, ":cur_center", slot_party_type, spt_castle), (val_add, ":num_center_points", 2), (else_try), (val_add, ":num_center_points", 1), (try_end), (try_end), #(store_add, ":score", 500, ":troop_renown"), (store_add, ":score", 500, 1000), #just a fictional number to keep out renown. (val_div, ":score", ":num_center_points"), (store_random_in_range, ":random", 50, 100), (val_mul, ":score", ":random"), (try_begin), (party_slot_eq, ":center_no", slot_center_last_taken_by_troop, ":troop_no"), (val_mul, ":score", 3), (val_div, ":score", 2), (try_end), (try_begin), (eq, ":troop_no", "trp_player"), (faction_get_slot, ":faction_leader", "$players_kingdom"), (call_script, "script_troop_get_player_relation", ":faction_leader"), (assign, ":leader_relation", reg0), #(troop_get_slot, ":leader_relation", ":faction_leader", slot_troop_player_relation), (val_mul, ":leader_relation", 2), (val_add, ":score", ":leader_relation"), (try_end), (assign, reg0, ":score"), ]), #script_do_party_center_trade # INPUT: arg1 = party_no, arg2 = center_no, arg3 = percentage_change_in_center # OUTPUT: reg0 = total_change ("do_party_center_trade", [ (store_script_param, ":party_no", 1), (store_script_param, ":center_no", 2), (store_script_param, ":percentage_change", 3), (assign, ":total_change", 0), (store_sub, ":item_to_price_slot", slot_town_trade_good_prices_begin, trade_goods_begin), (try_for_range, ":cur_good", trade_goods_begin, trade_goods_end), (store_add, ":cur_good_price_slot", ":cur_good", ":item_to_price_slot"), (party_get_slot, ":cur_merchant_price", ":party_no", ":cur_good_price_slot"), (party_get_slot, ":cur_center_price", ":center_no", ":cur_good_price_slot"), (store_sub, ":price_dif", ":cur_merchant_price", ":cur_center_price"), (assign, ":cur_change", ":price_dif"), (val_abs, ":cur_change"), (val_add, ":total_change", ":cur_change"), (val_mul, ":cur_change", ":percentage_change"), (val_div, ":cur_change", 100), (try_begin), (lt, ":price_dif", 0), (val_mul, ":cur_change", -1), (try_end), (val_add, ":cur_center_price", ":cur_change"), (party_set_slot, ":center_no", ":cur_good_price_slot", ":cur_center_price"), (party_set_slot, ":party_no", ":cur_good_price_slot", ":cur_center_price"), (try_end), (assign, reg0, ":total_change"), ]), # script_find_cheapest_item_in_inv_of_type # puts in reg0 the cheapest item in an given troop invetory, of a given type # param1: troop id # param2: object type MIN # param3: object type MAX, or 0 if only one object type ("find_cheapest_item_in_inv_of_type",[ (store_script_param_1, ":troop"), (store_script_param_2, ":item_type_min"), (store_script_param, ":item_type_max",3), (try_begin), (eq, ":item_type_max",0), (store_add, ":item_type_max",":item_type_min", 1), (try_end), (assign, reg0, -1), (assign, ":min_value", 1<<15 ), (troop_get_inventory_capacity, ":max", ":troop"), (try_for_range, ":i_slot", 0, ":max"), (troop_get_inventory_slot, ":item", ":troop", ":i_slot"), (ge, ":item", 0), (item_get_type, ":type", ":item"), (is_between, ":type", ":item_type_min", ":item_type_max"), (store_item_value, ":value", ":item"), (lt, ":value", ":min_value"), (assign, ":min_value", ":value"), (assign, reg0, ":item"), (try_end), ]), # script_start_as_one # script to start the game as one... troop -- mtarini # (copys that troop stats, items, factions, race, etc, into player) ("start_as_one",[ (set_show_messages, 0), (store_script_param, ":troop", 1), (assign, "$player_current_troop_type", ":troop"), # copy faction (store_troop_faction, ":fac", ":troop"), (call_script, "script_player_join_faction", ":fac"), (troop_get_slot, "$players_subkingdom",":troop", slot_troop_subfaction), # subfaction # copy race (troop_get_type,":race",":troop"), (troop_get_type,":playerace","trp_player"), (try_begin), # if player chose woman, preserve woman. If chose orc/dwarf troop - force orc/dwarf (this_or_next|neq, ":playerace", tf_female), (this_or_next|is_between, ":race", tf_orc_begin,tf_orc_end), (eq, ":race", tf_dwarf), (troop_set_type,"trp_player",":race"), (try_end), # copy items (troop_clear_inventory, "trp_player"), #(troop_get_inventory_capacity, ":inv_cap", ":troop"), # CC: Maybe fix? (set_show_messages, 0), (try_for_range, ":item", 0, "itm_save_compartibility_item10"), (troop_remove_items, "trp_player", ":item", 1), (try_end), (set_show_messages, 1), # option 1 add everything he has # (try_for_range, ":i_slot", 0, ":inv_cap"), # (troop_get_inventory_slot, ":item_id", ":troop", ":i_slot"), # (ge, ":item_id", 0), # (item_get_type, ":type", ":item_id"), # (assign, ":problem", 0), # (try_begin),(eq, ":type", itp_type_body_armor), (assign, ":problem", imod_battered), # (else_try), (eq, ":type", itp_type_foot_armor), (assign, ":problem", imod_ragged), # (else_try), (eq, ":type", itp_type_head_armor), (assign, ":problem", imod_battered), # (else_try), (eq, ":type", itp_type_hand_armor), (assign, ":problem", imod_battered), # (else_try), (eq, ":type", itp_type_horse ) , (assign, ":problem", imod_swaybacked), # (else_try), (eq, ":type", itp_type_one_handed_wpn), (assign, ":problem", imod_cracked), # (else_try), (eq, ":type", itp_type_two_handed_wpn), (assign, ":problem", imod_cracked), # (else_try), (eq, ":type", itp_type_polearm), (assign, ":problem", imod_cracked), # (else_try), (eq, ":type", itp_type_arrows), (assign, ":problem", imod_bent), # (else_try), (eq, ":type", itp_type_bolts), (assign, ":problem", imod_bent), # (else_try), (eq, ":type", itp_type_shield), (assign, ":problem", imod_battered), # (else_try), (eq, ":type", itp_type_bow), (assign, ":problem", imod_cracked), # (else_try), (eq, ":type", itp_type_thrown), (assign, ":problem", imod_bent), # (try_end), # (troop_add_item, "trp_player", ":item_id", ":problem"), # (try_end), # option 2 for each category, add one object per category, onlg if required, and the cheapest! (troop_get_slot, ":flags", ":troop", slot_troop_flags), (try_begin),(store_and,reg13,":flags",tfg_boots),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_foot_armor,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_ragged), (try_end), (try_begin),(store_and,reg13,":flags",tfg_armor),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_body_armor,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_battered), (try_end), (try_begin),(store_and,reg13,":flags",tfg_helm),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_head_armor,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_battered), (try_end), (try_begin),(store_and,reg13,":flags",tfg_gloves),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_hand_armor,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_battered), (try_end), (try_begin),(store_and,reg13,":flags",tfg_horse),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_horse,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_swaybacked), (try_end), (try_begin),(store_and,reg13,":flags",tfg_shield),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_shield,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_battered), (try_end), (try_begin),(store_and,reg13,":flags",tfg_ranged),(neq,reg13,0), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_bow,itp_type_thrown+1),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_bent), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_arrows,0),(assign,":item",reg0), (gt,":item",0), (troop_add_item, "trp_player", ":item", imod_bent), (try_end), # assign weapon (try_begin), (call_script,"script_find_cheapest_item_in_inv_of_type",":troop",itp_type_one_handed_wpn,itp_type_polearm+1),(assign,":item",reg0), (gt,":item",0), (assign,":problem", imod_cracked), (try_begin),(eq, ":troop", "trp_i1_dun_wildman"), (assign, ":item", "itm_dunland_spear"), (try_end), # exception! Otherwie they get "orc club" (try_begin),(store_item_value, ":value", ":item"),(lt,":value", 50),(assign,":problem", 0), (try_end), # pity for pityful weapons! (troop_add_item, "trp_player", ":item", ":problem"), (try_end), # copy stats: attrib (try_for_range, ":i", 0, 4), (store_attribute_level, ":x",":troop",":i"), (troop_raise_attribute, "trp_player",":i",-1000), (troop_raise_attribute, "trp_player",":i",":x"), #(assign, reg10, ":x"),(assign, reg11, ":i"),(display_message, "@Rising skill {reg11} to {reg10}"), (try_end), # copy stats: skills (assign, "$disable_skill_modifiers", 1), (try_for_range, ":i", 0, 38 ), (store_skill_level, ":x", ":i", ":troop"), (troop_raise_skill, "trp_player",":i",-1000), (troop_raise_skill, "trp_player",":i",":x"), # (troop_raise_skill, "trp_player","skl_inventory_management",-100), #set these to 0 # (troop_raise_skill, "trp_player","skl_prisoner_management",-100), # (troop_raise_skill, "trp_player","skl_trade",-100), (try_end), (assign, "$disable_skill_modifiers", 0), # copy stats: proficienceis (try_for_range, ":i", 0, 6), (store_proficiency_level, ":x", ":i", ":troop"), (troop_raise_proficiency, "trp_player",":i",-1000), #(val_div, ":x", 4), # weapon proficiencies are too high! #(val_min, ":x", 60), (troop_raise_proficiency, "trp_player",":i",":x"), (try_end), (troop_equip_items, "trp_player"), # clear nonequipped inventory (cancel this, let's give em full inventory - kham) #(try_for_range, ":i_slot", 9, ":inv_cap"), # (troop_set_inventory_slot, "trp_player", ":i_slot", -1), #(try_end), # clear any non-ranged weapon except one (cancel this, let's give em full inventory - kham) #(store_random_in_range, ":die_roll", 0, 2), #(assign, ":weapon_found",0), #(try_for_range, ":i", 0, 9), # (try_begin),(lt, ":die_roll", 1), (store_sub, ":j", 8, ":i"),(else_try), (assign,":j",":i"),(end_try), #50% chance of reverse order # (troop_get_inventory_slot, ":item_id", "trp_player", ":j"), # (ge, ":item_id", 0), # (item_get_type, ":type", ":item_id"), # (this_or_next|eq, ":type", itp_type_one_handed_wpn), # (this_or_next|eq, ":type", itp_type_two_handed_wpn), # (eq, ":type", itp_type_polearm), # (try_begin),(eq,":weapon_found",1),(troop_set_inventory_slot, "trp_player", ":j", -1),(try_end), # (assign, ":weapon_found",1), #(try_end), # give appropriate food for race/faction (call_script, "script_get_food_of_race_and_faction", ":race", ":fac"), (troop_add_item, "trp_player", reg0 ), ]), #script_player_join_faction # INPUT: arg1 = faction_no ("player_join_faction", [ (set_show_messages,0), (store_script_param, ":faction_no", 1), (assign,"$players_kingdom",":faction_no"), (faction_set_slot, "fac_player_supporters_faction", slot_faction_ai_state, sfai_default), # (assign, "$players_oath_renounced_against_kingdom", 0), (try_for_range,":other_kingdom",kingdoms_begin,kingdoms_end), (faction_slot_eq, ":other_kingdom", slot_faction_state, sfs_active), (neq, ":other_kingdom", "fac_player_supporters_faction"), (try_begin), (neq, ":other_kingdom", ":faction_no"), (store_relation, ":other_kingdom_reln", ":other_kingdom", ":faction_no"), (else_try), (store_relation, ":other_kingdom_reln", "fac_player_supporters_faction", ":other_kingdom"), (val_max, ":other_kingdom_reln", 50), #TLD (try_end), (call_script, "script_set_player_relation_with_faction", ":other_kingdom", ":other_kingdom_reln"), (try_end), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD #Give center to kingdom if player is the owner (party_slot_eq, ":cur_center", slot_town_lord, "trp_player"), (party_set_faction, ":cur_center", ":faction_no"), (try_end), (try_for_range, ":quest_no", lord_quests_begin, lord_quests_end), (check_quest_active, ":quest_no"), (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), (store_troop_faction, ":quest_giver_faction", ":quest_giver_troop"), (store_relation, ":quest_giver_faction_relation", "fac_player_supporters_faction", ":quest_giver_faction"), (lt, ":quest_giver_faction_relation", 0), (call_script, "script_abort_quest", ":quest_no", 0), (try_end), (try_begin), (neq, ":faction_no", "fac_player_supporters_faction"), (faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive), (faction_set_slot, "fac_player_supporters_faction", slot_faction_leader, "trp_player"), (try_end), (call_script, "script_store_average_center_value_per_faction"), (call_script, "script_update_all_notes"), (assign, "$g_recalculate_ais", 2), (set_show_messages,1), ]), #script_agent_reassign_team # INPUT: arg1 = agent_no ("agent_reassign_team", [ (store_script_param, ":agent_no", 1), (get_player_agent_no, ":player_agent"), (try_begin), (ge, ":player_agent", 0), (agent_is_human, ":agent_no"), (agent_is_ally, ":agent_no"), (agent_get_party_id, ":party_no", ":agent_no"), (gt, ":party_no", -1), (neq, ":party_no", "p_main_party"), (assign, ":continue", 1), (store_faction_of_party, ":party_faction", ":party_no"), (try_begin), (eq, ":party_faction", "$players_kingdom"), (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end), (faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"), (assign, ":continue", 0), (else_try), (party_stack_get_troop_id, ":leader_troop_id", ":party_no", 0), (neg|is_between, ":leader_troop_id", kingdom_heroes_begin, kingdom_heroes_end), (assign, ":continue", 0), (try_end), (eq, ":continue", 1), (agent_get_team, ":player_team", ":player_agent"), (val_add, ":player_team", 2), (agent_set_team, ":agent_no", ":player_team"), (try_end), ]), #script_start_quest # INPUT: arg1 = quest_no, arg2 = giver_troop_no, s2 = description_text ("start_quest", [(store_script_param, ":quest_no", 1), (store_script_param, ":giver_troop_no", 2), (try_begin), (is_between, ":giver_troop_no", kingdom_heroes_begin, kingdom_heroes_end), (str_store_troop_name_link, s62, ":giver_troop_no"), (else_try), (str_store_troop_name, s62, ":giver_troop_no"), (try_end), (str_store_string, s63, "@Given by: {s62}"), (store_current_hours, ":cur_hours"), (str_store_date, s60, ":cur_hours"), (str_store_string, s60, "@Given on: {s60}"), (add_quest_note_from_sreg, ":quest_no", 0, s60, 0), (add_quest_note_from_sreg, ":quest_no", 1, s63, 0), (add_quest_note_from_sreg, ":quest_no", 2, s2, 0), (try_begin), (quest_slot_ge, ":quest_no", slot_quest_expiration_days, 1), (quest_get_slot, reg0, ":quest_no", slot_quest_expiration_days), (add_quest_note_from_sreg, ":quest_no", 7, "@You have {reg0} days to finish this quest.", 0), (try_end), #Adding dont_give_again_for_days value (try_begin), (quest_slot_ge, ":quest_no", slot_quest_dont_give_again_period, 1), (quest_get_slot, ":dont_give_again_period", ":quest_no", slot_quest_dont_give_again_period), (quest_set_slot, ":quest_no", slot_quest_dont_give_again_remaining_days, ":dont_give_again_period"), (try_end), (start_quest, ":quest_no", ":giver_troop_no"), (display_message, "str_quest_log_updated"), ]), #script_conclude_quest # INPUT: arg1 = quest_no ("conclude_quest", [(store_script_param, ":quest_no", 1), (conclude_quest, ":quest_no"), (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), (str_store_troop_name, s59, ":quest_giver_troop"), (add_quest_note_from_sreg, ":quest_no", 7, "@This quest has been concluded. Talk to {s59} to finish it.", 0), ]), #script_succeed_quest # INPUT: arg1 = quest_no ("succeed_quest", [(store_script_param, ":quest_no", 1), (succeed_quest, ":quest_no"), (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), (str_store_troop_name, s59, ":quest_giver_troop"), (add_quest_note_from_sreg, ":quest_no", 7, "@This quest has been successfully completed. Talk to {s59} to claim your reward.", 0), ]), #script_fail_quest # INPUT: arg1 = quest_no ("fail_quest", [(store_script_param, ":quest_no", 1), (fail_quest, ":quest_no"), (quest_get_slot, ":quest_giver_troop", ":quest_no", slot_quest_giver_troop), (str_store_troop_name, s59, ":quest_giver_troop"), (add_quest_note_from_sreg, ":quest_no", 7, "@This quest has failed. Talk to {s59} to explain the situation.", 0), ]), #script_report_quest_troop_positions # INPUT: arg1 = quest_no, arg2 = troop_no, arg3 = note_index ("report_quest_troop_positions", [(store_script_param, ":quest_no", 1), (store_script_param, ":troop_no", 2), (store_script_param, ":note_index", 3), (call_script, "script_get_information_about_troops_position", ":troop_no", 1), (str_store_string, s5, "@At the time quest was given:^{s1}"), (add_quest_note_from_sreg, ":quest_no", ":note_index", s5, 1), (call_script, "script_update_troop_location_notes", ":troop_no", 1), ]), #script_end_quest # INPUT: arg1 = quest_no ("end_quest", [(store_script_param, ":quest_no", 1), (str_clear, s1), (add_quest_note_from_sreg, ":quest_no", 0, s1, 0), (add_quest_note_from_sreg, ":quest_no", 1, s1, 0), (add_quest_note_from_sreg, ":quest_no", 2, s1, 0), (add_quest_note_from_sreg, ":quest_no", 3, s1, 0), (add_quest_note_from_sreg, ":quest_no", 4, s1, 0), (add_quest_note_from_sreg, ":quest_no", 5, s1, 0), (add_quest_note_from_sreg, ":quest_no", 6, s1, 0), (add_quest_note_from_sreg, ":quest_no", 7, s1, 0), (try_begin), (neg|check_quest_failed, ":quest_no"), (val_add, "$g_total_quests_completed", 1), (try_end), (complete_quest, ":quest_no"), (try_begin), (this_or_next|is_between, ":quest_no", mayor_quests_begin, mayor_quests_end), (is_between, ":quest_no", "qst_blank_quest_16", "qst_blank_quest_18"), (assign, "$merchant_quest_last_offerer", -1), (assign, "$merchant_offered_quest", -1), (try_end), (try_begin), #find remaining quest target parties, make them normal parties (spawned from Quest Helper Trigger ) (this_or_next|eq, ":quest_no", "qst_deal_with_looters"), (eq, ":quest_no", "qst_blank_quest_17"), (quest_get_slot, ":target_template", ":quest_no", slot_quest_target_party_template), (try_for_parties, ":quest_targets"), (party_get_template_id, ":party_template", ":quest_targets"), (eq, ":party_template", ":target_template"), (party_set_faction, ":quest_targets", "fac_outlaws"), (party_set_flags, ":quest_targets", pf_quest_party, 0), (try_end), (try_end), ]), #script_cancel_quest # INPUT: arg1 = quest_no ("cancel_quest", [(store_script_param, ":quest_no", 1), (str_clear, s1), (add_quest_note_from_sreg, ":quest_no", 0, s1, 0), (add_quest_note_from_sreg, ":quest_no", 1, s1, 0), (add_quest_note_from_sreg, ":quest_no", 2, s1, 0), (add_quest_note_from_sreg, ":quest_no", 3, s1, 0), (add_quest_note_from_sreg, ":quest_no", 4, s1, 0), (add_quest_note_from_sreg, ":quest_no", 5, s1, 0), (add_quest_note_from_sreg, ":quest_no", 6, s1, 0), (add_quest_note_from_sreg, ":quest_no", 7, s1, 0), (cancel_quest, ":quest_no"), (try_begin), (this_or_next|is_between, ":quest_no", mayor_quests_begin, mayor_quests_end), (is_between, ":quest_no", "qst_blank_quest_16", "qst_blank_quest_18"), (assign, "$merchant_quest_last_offerer", -1), (assign, "$merchant_offered_quest", -1), (try_end), (try_begin), #find remaining quest target parties, make them normal parties (spawned from Quest Helper Trigger ) (this_or_next|eq, ":quest_no", "qst_deal_with_looters"), (eq, ":quest_no", "qst_blank_quest_17"), (quest_get_slot, ":target_template", ":quest_no", slot_quest_target_party_template), (try_for_parties, ":quest_targets"), (party_get_template_id, ":party_template", ":quest_targets"), (eq, ":party_template", ":target_template"), (party_set_faction, ":quest_targets", "fac_outlaws"), (party_set_flags, ":quest_targets", pf_quest_party, 0), (try_end), (try_end), ]), #script_update_faction_notes # INPUT: faction_no ("update_faction_notes", [(store_script_param, ":faction_no", 1), (try_begin), (is_between, ":faction_no", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active), (faction_get_slot, ":faction_leader", ":faction_no", slot_faction_leader), (str_store_faction_name, s5, ":faction_no"), (str_store_troop_name_link, s6, ":faction_leader"), (assign, ":num_centers", 0), (str_store_string, s8, "str_empty_string"), (try_for_range_backwards, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":center_faction", ":cur_center"), (eq, ":center_faction", ":faction_no"), (try_begin), (eq, ":num_centers", 0), (str_store_party_name_link, s8, ":cur_center"), (else_try), (eq, ":num_centers", 1), (str_store_party_name_link, s7, ":cur_center"), (str_store_string, s8, "@{s7} and {s8}"), (else_try), (str_store_party_name_link, s7, ":cur_center"), (str_store_string, s8, "@{s7}, {s8}"), (try_end), (val_add, ":num_centers", 1), (try_end), (assign, ":num_members", 0), (str_store_string, s10, "@noone"), (try_for_range_backwards, ":loop_var", kingdom_heroes_begin - 1, kingdom_heroes_end), (assign, ":cur_troop", ":loop_var"), (try_begin), #swy: this seems to add an additional initial dummy # entry to the heroes range and replace that by the player. was hardcoded. (eq, ":loop_var", kingdom_heroes_begin - 1), (assign, ":cur_troop", "trp_player"), (assign, ":troop_faction", "$players_kingdom"), (else_try), (store_troop_faction, ":troop_faction", ":cur_troop"), (try_end), (eq, ":troop_faction", ":faction_no"), (neq, ":cur_troop", ":faction_leader"), (troop_slot_eq, ":cur_troop", slot_troop_occupation, slto_kingdom_hero), (try_begin), (eq, ":num_members", 0), (str_store_troop_name_link, s10, ":cur_troop"), (else_try), (eq, ":num_members", 1), (str_store_troop_name_link, s9, ":cur_troop"), (str_store_string, s10, "@{s9} and {s10}"), (else_try), (str_store_troop_name_link, s9, ":cur_troop"), (str_store_string, s10, "@{s9}, {s10}"), (try_end), (val_add, ":num_members", 1), (try_end), (str_store_string, s12, "@no one"), (assign, ":num_enemies", 0), (try_for_range_backwards, ":cur_faction", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":cur_faction", slot_faction_state, sfs_active), (store_relation, ":cur_relation", ":cur_faction", ":faction_no"), (lt, ":cur_relation", 0), (try_begin), (eq, ":num_enemies", 0), (str_store_faction_name_link, s12, ":cur_faction"), (else_try), (eq, ":num_enemies", 1), (str_store_faction_name_link, s11, ":cur_faction"), (str_store_string, s12, "@{s11} and {s12}"), (else_try), (str_store_faction_name_link, s11, ":cur_faction"), (str_store_string, s12, "@{s11}, {s12}"), (try_end), (val_add, ":num_enemies", 1), (try_end), # Maybe we could add more information about the factions? Like where they come from. -CC (add_faction_note_from_sreg, ":faction_no", 0, "@{s5} is ruled by {s6}.^It controls {s8}.^Its commanders are {s10}.^{s5} is at war with {s12}.", 0), (else_try), (is_between, ":faction_no", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":faction_no", slot_faction_state, sfs_defeated), (str_store_faction_name, s5, ":faction_no"), (add_faction_note_from_sreg, ":faction_no", 0, "@{s5} has been defeated!", 0), (str_clear, s1), (add_faction_note_from_sreg, ":faction_no", 1, s1, 0), (else_try), (str_clear, s1), (add_faction_note_from_sreg, ":faction_no", 0, s1, 0), (add_faction_note_from_sreg, ":faction_no", 1, s1, 0), (try_end), #MV: show faction leader banner instead of (non-existent) faction pic # (try_begin), # (is_between, ":faction_no", "fac_gondor", kingdoms_end), #Excluding player kingdom # (add_faction_note_tableau_mesh, ":faction_no", "tableau_faction_note_mesh"), # (else_try), (add_faction_note_tableau_mesh, ":faction_no", "tableau_faction_note_mesh_banner"), # (try_end), ] + (is_a_wb_script==1 and [ #swy-- this is needed to show by default the note entries on Warband... (faction_set_note_available, ":faction_no", 1), #swy-- don't show this, it's useless... (faction_set_note_available, "fac_player_faction", 0), ] or []) ), #script_update_faction_traveler_notes # INPUT: faction_no ("update_faction_traveler_notes", [(store_script_param, ":faction_no", 1), (assign, ":total_men", 0), (try_for_parties, ":cur_party"), (store_faction_of_party, ":center_faction", ":cur_party"), (eq, ":center_faction", ":faction_no"), (party_get_num_companions, ":num_men", ":cur_party"), (val_add, ":total_men", ":num_men"), (try_end), (str_store_faction_name, s5, ":faction_no"), (assign, reg1, ":total_men"), (add_faction_note_from_sreg, ":faction_no", 1, "@{s5} has a strength of {reg1} men in total.", 1), ] + (is_a_wb_script==1 and [ #swy-- this is needed to show by default the note entries on Warband... (faction_set_note_available, ":faction_no", 1), ] or []) ), #script_update_troop_notes # INPUT: troop_no ("update_troop_notes", [(store_script_param, ":troop_no", 1), (str_store_troop_name, s54, ":troop_no"), (try_begin), (eq, ":troop_no", "trp_player"), # (this_or_next|eq, 0, 1), # "$player_has_homage" is always 0 in TLD # ( eq, "$players_kingdom", "fac_player_supporters_faction"), (assign, ":troop_faction", "$players_kingdom"), (else_try), (store_troop_faction, ":troop_faction", ":troop_no"), (try_end), (try_begin), (neq, ":troop_no", "trp_player"), (neg|is_between, ":troop_faction", kingdoms_begin, kingdoms_end), (str_clear, s54), (add_troop_note_from_sreg, ":troop_no", 0, s54, 0), (add_troop_note_from_sreg, ":troop_no", 1, s54, 0), (add_troop_note_from_sreg, ":troop_no", 2, s54, 0), (else_try), (faction_get_slot, ":faction_leader", ":troop_faction", slot_faction_leader), (str_store_troop_name_link, s55, ":faction_leader"), (str_store_faction_name_link, s56, ":troop_faction"), (assign, reg4, 0), (assign, reg6, 0), (try_begin), (eq, ":troop_faction", "fac_player_faction"), (assign, reg6, 1), (else_try), (eq, ":faction_leader", ":troop_no"), (assign, reg4, 1), (try_end), (assign, ":num_centers", 0), (str_store_string, s58, "@no holdings"), (try_for_range_backwards, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_center_destroyed, 0), # TLD (party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"), (try_begin), (eq, ":num_centers", 0), (str_store_party_name_link, s58, ":cur_center"), (else_try), (eq, ":num_centers", 1), (str_store_party_name_link, s57, ":cur_center"), (str_store_string, s58, "@{s57} and {s58}"), (else_try), (str_store_party_name_link, s57, ":cur_center"), (str_store_string, s58, "@{s57}, {s58}"), (try_end), (val_add, ":num_centers", 1), (try_end), (troop_get_type, reg3, ":troop_no"), (try_begin), (gt, reg3, 1), #MV: non-humans are male (assign, reg3, 0), (try_end), (str_clear, s59), (try_begin), # (troop_get_slot, ":relation", ":troop_no", slot_troop_player_relation), (call_script, "script_troop_get_player_relation", ":troop_no"), (assign, ":relation", reg0), (store_add, ":normalized_relation", ":relation", 100), (val_add, ":normalized_relation", 5), (store_div, ":str_offset", ":normalized_relation", 10), (val_clamp, ":str_offset", 0, 20), (store_add, ":str_id", "str_relation_mnus_100_ns", ":str_offset"), (neq, ":str_id", "str_relation_plus_0_ns"), (str_store_string, s60, "@{reg3?She:He}"), (str_store_string, s59, ":str_id"), (str_store_string, s59, "@^{s59}"), (try_end), (assign, reg9, ":num_centers"), (assign, reg10, 0), #alive (try_begin), (troop_slot_eq, ":troop_no", slot_troop_wound_mask, wound_death), #dead (assign, reg10, 1), (try_end), (add_troop_note_from_sreg, ":troop_no", 0, "@{reg6?:{reg4?{s54} is the ruler of {s56}.^:{s54} serves {s55} of {s56}.^}}{reg9?{reg3?She:He} is the {reg3?lady:lord} of {s58}.:}{s59}{reg10?^{reg3?She:He} died on the battlefield!:}", 0), (add_troop_note_tableau_mesh, ":troop_no", "tableau_troop_note_mesh"), ] + (is_a_wb_script==1 and [ #swy-- this is needed to show by default the note entries on Warband... (troop_set_note_available, ":troop_no", 1), ] or []) + [ (try_end), ]), #script_update_troop_location_notes # INPUT: troop_no ("update_troop_location_notes", [(store_script_param, ":troop_no", 1), (store_script_param, ":see_or_hear", 2), (call_script, "script_get_information_about_troops_position", ":troop_no", 1), (try_begin), (neq, reg0, 0), (troop_get_type, reg1, ":troop_no"), (try_begin), (gt, reg1, 1), #MV: non-humans are male (assign, reg1, 0), (try_end), (try_begin), (eq, ":see_or_hear", 0), (add_troop_note_from_sreg, ":troop_no", 2, "@The last time you saw {reg1?her:him}, {s1}", 1), (else_try), (add_troop_note_from_sreg, ":troop_no", 2, "@The last time you heard about {reg1?her:him}, {s1}", 1), (try_end), (try_end), ] + (is_a_wb_script==1 and [ #swy-- this is needed to show by default the note entries on Warband... (troop_set_note_available, ":troop_no", 1), ] or []) ), #script_update_center_notes # INPUT: center_no ("update_center_notes", [(store_script_param, ":center_no", 1), (party_get_slot, ":lord_troop", ":center_no", slot_town_lord), (try_begin), (ge, ":lord_troop", 0), (store_troop_faction, ":lord_faction", ":lord_troop"), (faction_slot_eq, ":lord_faction", slot_faction_state, sfs_active), #TLD (str_store_troop_name_link, s1, ":lord_troop"), (try_begin), (eq, ":lord_troop", "trp_player"), (gt, "$players_kingdom", 0), (str_store_faction_name_link, s2, "$players_kingdom"), (else_try), (str_store_faction_name_link, s2, ":lord_faction"), (try_end), (str_store_party_name, s50, ":center_no"), (try_begin), (party_slot_eq, ":center_no", slot_party_type, spt_town), (str_store_string, s51, "@The {s50}"), # "town of" stricken out # (else_try), # (party_slot_eq, ":center_no", slot_party_type, spt_village), # (party_get_slot, ":bound_center", ":center_no", slot_village_bound_center), # (str_store_party_name_link, s52, ":bound_center"), # (str_store_string, s51, "@The village of {s50} near {s52}"), (else_try), (str_store_string, s51, "@{s50}"), (try_end), (str_store_string, s2, "@{s50} belongs to {s1} of {s2}.^"), #TLD: was s51 ] + (is_a_wb_script==1 and [ #swy-- this is needed to show by default the note entries on Warband, this one goes in the loop because we don't want to show everything... (party_set_note_available, ":center_no", 1), ] or []) + [ (else_try), (str_clear, s2), (try_end), (call_script, "script_get_prosperity_text_to_s50", ":center_no"), (try_begin), #TLD: if party is disabled, clear all text so there will be no wiki entry (this_or_next|party_slot_eq, ":center_no", slot_center_destroyed, 1), # TLD (neg|party_is_active, ":center_no"), (str_clear, s2), ] + (is_a_wb_script==1 and [ #swy-- this completely hides the notes on Warband, nice and tidy... (party_set_note_available, ":center_no", 0), ] or []) + [ (try_end), (add_party_note_from_sreg, ":center_no", 0, "@{s2}", 0), #TLD: no prosperity #(add_party_note_from_sreg, ":center_no", 0, "@{s2}Its prosperity is: {s50}", 0), (add_party_note_tableau_mesh, ":center_no", "tableau_center_note_mesh"), ]), #script_update_center_recon_notes # INPUT: center_no # OUTPUT: none ("update_center_recon_notes", [(store_script_param, ":center_no", 1), (try_begin), (is_between, ":center_no", centers_begin, centers_end), (party_get_slot, ":center_food_store", ":center_no", slot_party_food_store), (call_script, "script_center_get_food_consumption", ":center_no"), (assign, ":food_consumption", reg0), (store_div, reg6, ":center_food_store", ":food_consumption"), (party_collect_attachments_to_party, ":center_no", "p_collective_ally"), (party_get_num_companions, reg5, "p_collective_ally"), (add_party_note_from_sreg, ":center_no", 1, "@Current garrison consists of {reg5} men.^Has food stock for {reg6} days.", 1), (try_end), ]), #script_update_all_notes ("update_all_notes", [ (call_script, "script_update_troop_notes", "trp_player"), (try_for_range, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end), (call_script, "script_update_troop_notes", ":troop_no"), (try_end), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), # TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (call_script, "script_update_center_notes", ":center_no"), (try_end), (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end), (call_script, "script_update_faction_notes", ":faction_no"), (try_end), ]), #script_shield_item_set_banner # INPUT: agent_no # OUTPUT: none ("shield_item_set_banner", [ (store_script_param, ":tableau_no",1), (store_script_param, ":agent_no", 2), (store_script_param, ":troop_no", 3), (assign, ":banner_troop", -1), (assign, ":banner_mesh", "mesh_banners_default_b"), (try_begin), (lt, ":agent_no", 0), (try_begin), (ge, ":troop_no", 0), (this_or_next|troop_slot_ge, ":troop_no", slot_troop_banner_scene_prop, 1), ( eq, ":troop_no", "trp_player"), (assign, ":banner_troop", ":troop_no"), (else_try), (this_or_next|is_between, ":troop_no", companions_begin, companions_end), (is_between, ":troop_no", new_companions_begin, new_companions_end), (assign, ":banner_troop", "trp_player"), (else_try), (assign, ":banner_mesh", "mesh_banners_default_a"), (try_end), (else_try), (agent_get_troop_id, ":troop_id", ":agent_no"), (this_or_next|troop_slot_ge, ":troop_id", slot_troop_banner_scene_prop, 1), ( eq, ":troop_no", "trp_player"), (assign, ":banner_troop", ":troop_id"), (else_try), (agent_get_party_id, ":agent_party", ":agent_no"), (try_begin), (lt, ":agent_party", 0), (this_or_next|is_between, ":troop_id", companions_begin, companions_end), (is_between, ":troop_id", new_companions_begin, new_companions_end), (main_party_has_troop, ":troop_id"), (assign, ":agent_party", "p_main_party"), (try_end), (ge, ":agent_party", 0), (party_get_template_id, ":party_template", ":agent_party"), (try_begin), (eq, ":party_template", "pt_deserters"), (assign, ":banner_mesh", "mesh_banners_default_c"), (else_try), (is_between, ":agent_party", centers_begin, centers_end), (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord), (ge, ":town_lord", 0), (assign, ":banner_troop", ":town_lord"), (else_try), (this_or_next|party_slot_eq, ":agent_party", slot_party_type, spt_kingdom_hero_party), ( eq, ":agent_party", "p_main_party"), (party_get_num_companion_stacks, ":num_stacks", ":agent_party"), (gt, ":num_stacks", 0), (party_stack_get_troop_id, ":leader_troop_id", ":agent_party", 0), (this_or_next|troop_slot_ge, ":leader_troop_id", slot_troop_banner_scene_prop, 1), ( eq, ":leader_troop_id", "trp_player"), (assign, ":banner_troop", ":leader_troop_id"), (try_end), (else_try), #Check if we are in a tavern (eq, "$talk_context", tc_tavern_talk), (neq, ":troop_no", "trp_player"), (assign, ":banner_mesh", "mesh_banners_default_d"), (else_try), #can't find party, this can be a town guard (neq, ":troop_no", "trp_player"), (is_between, "$g_encountered_party", centers_begin, centers_end), (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord), (ge, ":town_lord", 0), (assign, ":banner_troop", ":town_lord"), (try_end), (try_begin), (ge, ":banner_troop", 0), (try_begin), (neg|troop_slot_ge, ":banner_troop", slot_troop_banner_scene_prop, 1), (assign, ":banner_mesh", "mesh_banners_default_b"), (else_try), (troop_get_slot, ":banner_spr", ":banner_troop", slot_troop_banner_scene_prop), (store_add, ":banner_scene_props_end", banner_scene_props_end_minus_one, 1), (is_between, ":banner_spr", banner_scene_props_begin, ":banner_scene_props_end"), (val_sub, ":banner_spr", banner_scene_props_begin), (store_add, ":banner_mesh", ":banner_spr", arms_meshes_begin), (try_end), (try_end), (cur_item_set_tableau_material, ":tableau_no", ":banner_mesh"), ]), #script_add_troop_to_cur_tableau # INPUT: troop_no ("add_troop_to_cur_tableau",[ (store_script_param, ":troop_no",1), (set_fixed_point_multiplier, 100), (assign, ":banner_mesh", -1), (troop_get_slot, ":banner_spr", ":troop_no", slot_troop_banner_scene_prop), (store_add, ":banner_scene_props_end", banner_scene_props_end_minus_one, 1), (try_begin), (is_between, ":banner_spr", banner_scene_props_begin, ":banner_scene_props_end"), (val_sub, ":banner_spr", banner_scene_props_begin), (store_add, ":banner_mesh", ":banner_spr", banner_meshes_begin), (try_end), (cur_tableau_clear_override_items), (try_begin),#TLD: mouth of sauron keeps his hood (this_or_next|eq,":troop_no","trp_mordor_lord"), (this_or_next|eq,":troop_no","trp_dorwinion_spirit"), (this_or_next|eq,":troop_no","trp_dorwinion_spirit_leader"), (eq, ":troop_no", "trp_nazgul"), (cur_tableau_set_override_flags, af_override_weapons), (else_try), (cur_tableau_set_override_flags, af_override_head|af_override_weapons), (try_end), (init_position, pos2), (cur_tableau_set_camera_parameters, 1, 6, 6, 10, 10000), (init_position, pos5), (troop_get_type,":type",":troop_no"), # TLD: get dwarves and orcs on screen in notes (try_begin), (this_or_next|eq,":type",tf_dwarf),(eq,":type",tf_orc), (assign, ":eye_height", 142), (else_try), (assign, ":eye_height", 162), (try_end), (store_mul, ":camera_distance", ":troop_no", 87323), # (val_mod, ":camera_distance", 5), (assign, ":camera_distance", 139), (store_mul, ":camera_yaw", ":troop_no", 124337), (val_mod, ":camera_yaw", 50), (val_add, ":camera_yaw", -25), (store_mul, ":camera_pitch", ":troop_no", 98123), (val_mod, ":camera_pitch", 20), (val_add, ":camera_pitch", -14), (assign, ":animation", anim_stand_man), ## (troop_get_inventory_slot, ":horse_item", ":troop_no", ek_horse), ## (try_begin), ## (gt, ":horse_item", 0), ## (assign, ":eye_height", 210), ## (cur_tableau_add_horse, ":horse_item", pos2, anim_horse_stand, 0), ## (assign, ":animation", anim_ride_0), ## (position_set_z, pos5, 125), ## (try_begin), ## (is_between, ":camera_yaw", -10, 10), #make sure horse head doesn't obstruct face. ## (val_min, ":camera_pitch", -5), ## (try_end), ## (try_end), (position_set_z, pos5, ":eye_height"), # camera looks towards -z axis (position_rotate_x, pos5, -90), (position_rotate_z, pos5, 180), # now apply yaw and pitch (position_rotate_y, pos5, ":camera_yaw"), (position_rotate_x, pos5, ":camera_pitch"), (position_move_z, pos5, ":camera_distance", 0), (position_move_x, pos5, 5, 0), (try_begin), (ge, ":banner_mesh", 0), (init_position, pos1), (position_set_z, pos1, -1500), (position_set_x, pos1, 265), (position_set_y, pos1, 400), (position_transform_position_to_parent, pos3, pos5, pos1), (cur_tableau_add_mesh, ":banner_mesh", pos3, 400, 0), (try_end), #TLD Kham - If troll, bend. (try_begin), (troop_get_type, ":is_troll", ":troop_no"), (eq, ":is_troll", tf_troll), (assign, ":animation", "anim_troll_or_ent_bend_continue"), (try_end), (cur_tableau_add_troop, ":troop_no", pos2, ":animation" , 0), (cur_tableau_set_camera_position, pos5), (copy_position, pos8, pos5), (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up (position_rotate_z, pos8, 30), (position_rotate_x, pos8, -60), (cur_tableau_add_sun_light, pos8, 175,150,125), ]), #script_add_troop_to_cur_tableau_for_character # INPUT: troop_no ("add_troop_to_cur_tableau_for_character", [ (store_script_param, ":troop_no",1), (set_fixed_point_multiplier, 100), (cur_tableau_clear_override_items), (cur_tableau_set_override_flags, af_override_fullhelm), ## (cur_tableau_set_override_flags, af_override_head|af_override_weapons), (init_position, pos2), (cur_tableau_set_camera_parameters, 1, 4, 8, 10, 10000), (init_position, pos5), (assign, ":cam_height", 150), # (val_mod, ":camera_distance", 5), (assign, ":camera_distance", 360), (assign, ":camera_yaw", -15), (assign, ":camera_pitch", -18), (assign, ":animation", anim_stand_man), (position_set_z, pos5, ":cam_height"), # camera looks towards -z axis (position_rotate_x, pos5, -90), (position_rotate_z, pos5, 180), # now apply yaw and pitch (position_rotate_y, pos5, ":camera_yaw"), (position_rotate_x, pos5, ":camera_pitch"), (position_move_z, pos5, ":camera_distance", 0), (position_move_x, pos5, 5, 0), (try_begin), (troop_is_hero, ":troop_no"), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", -1), (else_try), (store_mul, ":random_seed", ":troop_no", 126233), (val_mod, ":random_seed", 1000), (val_add, ":random_seed", 1), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", ":random_seed"), (try_end), (cur_tableau_set_camera_position, pos5), (copy_position, pos8, pos5), (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up (position_rotate_z, pos8, 30), (position_rotate_x, pos8, -60), (cur_tableau_add_sun_light, pos8, 175,150,125), ]), #script_add_troop_to_cur_tableau_for_inventory # INPUT: troop_no ("add_troop_to_cur_tableau_for_inventory", [ (store_script_param, ":troop_no",1), (store_mod, ":side", ":troop_no", 4), #side flag is inside troop_no value (val_div, ":troop_no", 4), #removing the flag bit (val_mul, ":side", 90), #to degrees (try_begin), # TLD equipment appropriateness check (eq, "$tld_option_crossdressing", 0), (this_or_next|eq, ":troop_no", "trp_player"), (this_or_next|is_between, ":troop_no", companions_begin, companions_end), (is_between, ":troop_no", new_companions_begin, new_companions_end), (call_script, "script_check_equipped_items", ":troop_no"), (try_end), (set_fixed_point_multiplier, 100), (cur_tableau_clear_override_items), (init_position, pos2), (position_rotate_z, pos2, ":side"), (cur_tableau_set_camera_parameters, 1, 4, 6, 10, 10000), (init_position, pos5), (assign, ":cam_height", 105), # (val_mod, ":camera_distance", 5), (assign, ":camera_distance", 380), (assign, ":camera_yaw", -15), (assign, ":camera_pitch", -18), (assign, ":animation", anim_stand_man), (position_set_z, pos5, ":cam_height"), # camera looks towards -z axis (position_rotate_x, pos5, -90), (position_rotate_z, pos5, 180), # now apply yaw and pitch (position_rotate_y, pos5, ":camera_yaw"), (position_rotate_x, pos5, ":camera_pitch"), (position_move_z, pos5, ":camera_distance", 0), (position_move_x, pos5, 5, 0), #TLD Kham - If troll, bend. (try_begin), (troop_get_type, ":is_troll", ":troop_no"), (eq, ":is_troll", tf_troll), (assign, ":animation", "anim_troll_or_ent_bend_continue"), (try_end), (try_begin), (troop_is_hero, ":troop_no"), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", -1), (else_try), (store_mul, ":random_seed", ":troop_no", 126233), (val_mod, ":random_seed", 1000), (val_add, ":random_seed", 1), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", ":random_seed"), (try_end), (cur_tableau_set_camera_position, pos5), (copy_position, pos8, pos5), (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up (position_rotate_z, pos8, 30), (position_rotate_x, pos8, -60), (cur_tableau_add_sun_light, pos8, 175,150,125), ]), #script_add_troop_to_cur_tableau_for_party # INPUT: troop_no ("add_troop_to_cur_tableau_for_party", [ (store_script_param, ":troop_no",1), (store_mod, ":hide_weapons", ":troop_no", 2), #hide_weapons flag is inside troop_no value (val_div, ":troop_no", 2), #removing the flag bit (set_fixed_point_multiplier, 100), (cur_tableau_clear_override_items), (try_begin), (eq, ":hide_weapons", 1), (cur_tableau_set_override_flags, af_override_fullhelm|af_override_head|af_override_weapons), (try_end), (init_position, pos2), (cur_tableau_set_camera_parameters, 1, 6, 6, 10, 10000), (init_position, pos5), (assign, ":cam_height", 105), # (val_mod, ":camera_distance", 5), (assign, ":camera_distance", 450), (assign, ":camera_yaw", 15), (assign, ":camera_pitch", -18), (assign, ":animation", anim_stand_man), (troop_get_inventory_slot, ":horse_item", ":troop_no", ek_horse), (try_begin), (gt, ":horse_item", 0), (eq, ":hide_weapons", 0), (cur_tableau_add_horse, ":horse_item", pos2, "anim_horse_stand", 0), (assign, ":animation", "anim_ride_0"), (assign, ":camera_yaw", 23), (assign, ":cam_height", 150), (assign, ":camera_distance", 550), (try_end), (position_set_z, pos5, ":cam_height"), # camera looks towards -z axis (position_rotate_x, pos5, -90), (position_rotate_z, pos5, 180), # now apply yaw and pitch (position_rotate_y, pos5, ":camera_yaw"), (position_rotate_x, pos5, ":camera_pitch"), (position_move_z, pos5, ":camera_distance", 0), (position_move_x, pos5, 5, 0), #TLD Kham - If troll, bend. (try_begin), (troop_get_type, ":is_troll", ":troop_no"), (eq, ":is_troll", tf_troll), (assign, ":animation", "anim_troll_or_ent_bend_continue"), (try_end), (try_begin), (troop_is_hero, ":troop_no"), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", -1), (else_try), (store_mul, ":random_seed", ":troop_no", 126233), (val_mod, ":random_seed", 1000), (val_add, ":random_seed", 1), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", ":random_seed"), (try_end), (cur_tableau_set_camera_position, pos5), (copy_position, pos8, pos5), (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up (position_rotate_z, pos8, 30), (position_rotate_x, pos8, -60), (cur_tableau_add_sun_light, pos8, 175,150,125), ]), #script_get_prosperity_text_to_s50 # INPUT: center_no ("get_prosperity_text_to_s50", [(store_script_param, ":center_no", 1), (party_get_slot, ":prosperity", ":center_no", slot_town_prosperity), (val_div, ":prosperity", 20), (try_begin),(eq, ":prosperity", 0),(str_store_string, s50, "@Very Poor"), (else_try) ,(eq, ":prosperity", 1),(str_store_string, s50, "@Poor"), (else_try) ,(eq, ":prosperity", 2),(str_store_string, s50, "@Average"), (else_try) ,(eq, ":prosperity", 3),(str_store_string, s50, "@Rich"), (else_try) , (str_store_string, s50, "@Very Rich"), (try_end), ]), #script_spawn_bandits ("spawn_bandits", [(set_spawn_radius,5), (try_begin), (lt, "$tld_war_began", 1), (assign, ":bandit_multiplier", 3), (else_try), (assign, ":bandit_multiplier", 2), (try_end), (try_begin), (store_num_parties_of_template, ":num_parties", "pt_mountain_bandits"), (store_mul, ":max_num_parties", num_mountain_bandit_spawn_points, ":bandit_multiplier"), (lt,":num_parties",":max_num_parties"), # 2 bandits per spawn point on average - was 4 (store_random,":spawn_point",num_mountain_bandit_spawn_points), (val_add,":spawn_point","p_mountain_bandit_spawn_point"), (spawn_around_party,":spawn_point","pt_mountain_bandits"), (party_set_slot, reg0, slot_party_type, spt_bandit), # Added by foxyman, TLD (try_end), (try_begin), (store_num_parties_of_template, ":num_parties", "pt_forest_bandits"), (store_mul, ":max_num_parties", num_forest_bandit_spawn_points, ":bandit_multiplier"), (lt,":num_parties",":max_num_parties"), (store_random,":spawn_point",num_forest_bandit_spawn_points), (val_add,":spawn_point","p_forest_bandit_spawn_point"), (spawn_around_party,":spawn_point","pt_forest_bandits"), (party_set_slot, reg0, slot_party_type, spt_bandit), # Added by foxyman, TLD (try_end), (try_begin), (store_num_parties_of_template, ":num_parties", "pt_sea_raiders"), (store_mul, ":max_num_parties", num_sea_raider_spawn_points, ":bandit_multiplier"), (lt,":num_parties",":max_num_parties"), (store_random,":spawn_point",num_sea_raider_spawn_points), (val_add,":spawn_point","p_sea_raider_spawn_point_1"), (spawn_around_party,":spawn_point","pt_sea_raiders"), (party_set_slot, reg0, slot_party_type, spt_bandit), # Added by foxyman, TLD (try_end), (try_begin), (store_num_parties_of_template, ":num_parties", "pt_steppe_bandits"), (store_mul, ":max_num_parties", num_steppe_bandit_spawn_points, ":bandit_multiplier"), (lt,":num_parties",":max_num_parties"), (store_random,":spawn_point",num_steppe_bandit_spawn_points), (val_add,":spawn_point","p_steppe_bandit_spawn_point"), (spawn_around_party,":spawn_point","pt_steppe_bandits"), (party_set_slot, reg0, slot_party_type, spt_bandit), # Added by foxyman, TLD (try_end), (try_begin), (store_num_parties_of_template, ":num_parties", "pt_looters"), (lt,":num_parties",30), # 1 looter per 3 towns (store_random_in_range,":spawn_point",centers_begin,advcamps_begin), (spawn_around_party,":spawn_point","pt_looters"), (party_set_slot, reg0, slot_party_type, spt_bandit), # Added by foxyman, TLD (assign, ":spawned_party_id", reg0), # (try_begin), #MV: commented out - quest looters don't disappear, they are neutral # (check_quest_active, "qst_deal_with_looters"), # (party_set_flags, ":spawned_party_id", pf_quest_party, 1), # (else_try), (party_set_flags, ":spawned_party_id", pf_quest_party, 0), # (try_end), (try_end), (try_begin), (store_num_parties_of_template, ":num_parties", "pt_deserters"), (lt,":num_parties",10), #was 15 (set_spawn_radius, 4), (try_for_range, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", 5), (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party), (store_troop_faction, ":troop_faction", ":troop_no"), (neq, ":troop_faction", "fac_player_supporters_faction"), (gt, ":party_no", 0), (neg|party_is_in_any_town, ":party_no"), #MV: this doesn't seem to work, so added two equivalent lines (party_get_attached_to, ":attached_to_party", ":party_no"), (neg|is_between, ":attached_to_party", centers_begin, centers_end), (faction_get_slot, ":tier_1_troop", ":troop_faction", slot_faction_deserter_troop), (faction_get_slot, ":tier_ranged_troop", ":troop_faction", slot_faction_ranged_troop), (try_begin), # only evil factions have deserters, good ones have -1 for deserter troop (ge, ":tier_1_troop", 0), ## (party_get_attached_to, ":attached_party_no", ":party_no"), ## (lt, ":attached_party_no", 0),#in wilderness (spawn_around_party, ":party_no", "pt_deserters"), (party_set_slot, reg0, slot_party_type, spt_bandit), # Added by foxyman, TLD (assign, ":new_party", reg0), (store_character_level, ":level", "trp_player"), (store_mul, ":max_number_to_add", ":level", 2), (val_add, ":max_number_to_add", 5), (store_random_in_range, ":number_to_add", 2, ":level"), #high tier units (party_add_members, ":new_party", ":tier_1_troop", ":number_to_add"), (store_random_in_range, ":random_no", 1, 4), (try_for_range, ":unused", 0, ":random_no"), (party_upgrade_with_xp, ":new_party", 1000000, 0), (try_end), (store_random_in_range, ":number_to_add", 3, ":level"), (party_add_members, ":new_party", ":tier_1_troop", ":number_to_add"), (store_random_in_range, ":random_no", 0, 2), (try_for_range, ":unused", 0, ":random_no"), (party_upgrade_with_xp, ":new_party", 20000, 0), (try_end), (store_random_in_range, ":number_to_add", 2, ":level"), (party_add_members, ":new_party", ":tier_ranged_troop", ":number_to_add"), (store_random_in_range, ":random_no", 0, 2), (try_for_range, ":unused", 0, ":random_no"), (party_upgrade_with_xp, ":new_party", 25000, 0), (try_end), (store_random_in_range, ":number_to_add", 10, ":max_number_to_add"), (party_add_members, ":new_party", ":tier_1_troop", ":number_to_add"), (try_end), ## (str_store_party_name, s1, ":party_no"), ## (call_script, "script_get_closest_center", ":party_no"), ## (try_begin), ## (gt, reg0, 0), ## (str_store_party_name, s2, reg0), ## (else_try), ## (str_store_string, s2, "@unknown place"), ## (try_end), ## (assign, reg1, ":number_to_add"), ## (display_message, "@{reg1} Deserters spawned from {s1}, near {s2}."), (try_end), (try_end), ]), #script_count_mission_casualties_from_agents ("count_mission_casualties_from_agents", [(party_clear, "p_player_casualties"), (party_clear, "p_enemy_casualties"), (party_clear, "p_ally_casualties"), (assign, "$any_allies_at_the_last_battle", 0), # Reset routed count (try_for_range, ":troop_no", 0, "trp_last"), (troop_set_slot, ":troop_no", slot_troop_routed_us, 0), (troop_set_slot, ":troop_no", slot_troop_routed_allies, 0), (troop_set_slot, ":troop_no", slot_troop_routed_enemies, 0), (try_end), (try_for_agents, ":cur_agent"), #(agent_slot_eq|neg, ":cur_agent", slot_agent_routed, 2), (agent_is_human, ":cur_agent"), (agent_get_troop_id, ":agent_troop_id", ":cur_agent"), (neg|is_between, ":agent_troop_id", warg_ghost_begin, warg_ghost_end), # dont count riderless wargs (neg|is_between, ":agent_troop_id", "trp_spider", "trp_dorwinion_sack"), (neq, ":agent_troop_id", "trp_werewolf"), (neq, ":agent_troop_id", "trp_gate_aggravator"), # Don't count gate aggravator - Kham (agent_get_party_id, ":agent_party", ":cur_agent"), # Kham - Code added for WB fleeing operation ] + (is_a_wb_script==1 and [ (try_begin), (agent_is_routed, ":cur_agent"), (neg|is_between, ":agent_troop_id", warg_ghost_begin, warg_ghost_end), (neg|is_between, ":agent_troop_id", "trp_spider", "trp_dorwinion_sack"), (neq, ":agent_troop_id", "trp_werewolf"), (neq, ":agent_troop_id", "trp_gate_aggravator"), # Don't count gate aggravator - Kham (agent_set_slot, ":cur_agent", slot_agent_routed, 2), (try_end), ] or []) + [ # CC: code modified to count routed agents. (try_begin), (agent_slot_eq, ":cur_agent", slot_agent_routed, 2), (troop_get_slot, ":num_routed_us1", ":agent_troop_id", slot_troop_routed_us), (troop_get_slot, ":num_routed_allies1", ":agent_troop_id", slot_troop_routed_allies), (troop_get_slot, ":num_routed_enemies1", ":agent_troop_id", slot_troop_routed_enemies), (try_begin), (eq, ":agent_party", "p_main_party"), (val_add, ":num_routed_us1", 1), (troop_set_slot, ":agent_troop_id", slot_troop_routed_us, ":num_routed_us1"), (val_add, "$num_routed_us", ":num_routed_us1"), (else_try), (agent_is_ally|neg, ":cur_agent"), (val_add, ":num_routed_enemies1", 1), (troop_set_slot, ":agent_troop_id", slot_troop_routed_enemies, ":num_routed_enemies1"), (val_add, "$num_routed_enemies", ":num_routed_enemies1"), (else_try), (agent_is_ally, ":cur_agent"), (val_add, ":num_routed_allies1", 1), (troop_set_slot, ":agent_troop_id", slot_troop_routed_allies, ":num_routed_allies1"), (val_add, "$num_routed_allies", ":num_routed_allies1"), (try_end), (try_end), # CC: code end. (try_begin), (neq, ":agent_party", "p_main_party"), (agent_is_ally, ":cur_agent"), (assign, "$any_allies_at_the_last_battle", 1), (try_end), (neg|agent_is_alive, ":cur_agent"), (try_begin), (eq, ":agent_party", "p_main_party"), (party_add_members, "p_player_casualties", ":agent_troop_id", 1), (try_begin), (agent_slot_eq|neg, ":cur_agent", slot_agent_routed, 2), (agent_slot_eq|this_or_next, ":cur_agent", slot_agent_wounded, 1), (agent_is_wounded, ":cur_agent"), (party_wound_members, "p_player_casualties", ":agent_troop_id", 1), (try_end), (else_try), (agent_is_ally, ":cur_agent"), (party_add_members, "p_ally_casualties", ":agent_troop_id", 1), (try_begin), (agent_slot_eq|neg, ":cur_agent", slot_agent_routed, 2), (agent_slot_eq|this_or_next, ":cur_agent", slot_agent_wounded, 1), (agent_is_wounded, ":cur_agent"), (party_wound_members, "p_ally_casualties", ":agent_troop_id", 1), (try_end), (else_try), (party_add_members, "p_enemy_casualties", ":agent_troop_id", 1), (try_begin), (agent_slot_eq|neg, ":cur_agent", slot_agent_routed, 2), (agent_slot_eq|this_or_next, ":cur_agent", slot_agent_wounded, 1), (agent_is_wounded, ":cur_agent"), (party_wound_members, "p_enemy_casualties", ":agent_troop_id", 1), (try_end), (try_end), (try_end), ]), #script_get_max_skill_of_player_party # INPUT: arg1 = skill_no # OUTPUT: reg0 = max_skill, reg1 = skill_owner_troop_no ("get_max_skill_of_player_party", [(store_script_param, ":skill_no", 1), (party_get_num_companion_stacks, ":num_stacks","p_main_party"), (store_skill_level, ":max_skill", ":skill_no", "trp_player"), (assign, ":skill_owner", "trp_player"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_main_party",":i_stack"), (troop_is_hero, ":stack_troop"), (neg|troop_is_wounded, ":stack_troop"), (store_skill_level, ":cur_skill", ":skill_no", ":stack_troop"), (gt, ":cur_skill", ":max_skill"), (assign, ":max_skill", ":cur_skill"), (assign, ":skill_owner", ":stack_troop"), (try_end), (party_get_skill_level, reg0, "p_main_party", ":skill_no"), (assign, reg1, ":skill_owner"), ]), #script_upgrade_hero_party # INPUT: arg1 = party_id, arg2 = xp_amount ("upgrade_hero_party", [(store_script_param, ":party_no", 1), (store_script_param, ":xp_amount", 2), (party_upgrade_with_xp, ":party_no", ":xp_amount", 0), ]), #script_get_improvement_details # INPUT: arg1 = improvement # OUTPUT: reg0 = base_cost # ("get_improvement_details", # [(store_script_param, ":improvement_no", 1), # (try_begin), # (eq, ":improvement_no", slot_center_has_manor), # (str_store_string, s0, "@Manor"), # (str_store_string, s1, "@A manor lets you rest at the village and pay your troops half wages while you rest."), # (assign, reg0, 8000), # (else_try), # (eq, ":improvement_no", slot_center_has_fish_pond), # (str_store_string, s0, "@Mill"), # (str_store_string, s1, "@A mill increases village prosperity by 5%."), # (assign, reg0, 6000), # (else_try), # (eq, ":improvement_no", slot_center_has_watch_tower), # (str_store_string, s0, "@Watch Tower"), # (str_store_string, s1, "@A watch tower lets the villagers raise alarm earlier. The time it takes for enemies to loot the village increases by 25%."), # (assign, reg0, 5000), # (else_try), # (eq, ":improvement_no", slot_center_has_school), # (str_store_string, s0, "@School"), # (str_store_string, s1, "@A shool increases the loyality of the villagers to you by +1 every month."), # (assign, reg0, 9000), # (else_try), # (eq, ":improvement_no", slot_center_has_messenger_post), # (str_store_string, s0, "@Messenger Post"), # (str_store_string, s1, "@A messenger post lets the inhabitants send you a message whenever enemies are nearby, even if you are far away from here."), # (assign, reg0, 4000), # (else_try), # (eq, ":improvement_no", slot_center_has_prisoner_tower), # (str_store_string, s0, "@Prison Tower"), # (str_store_string, s1, "@A prison tower reduces the chance of captives held here running away successfully."), # (assign, reg0, 7000), # (try_end), # ]), #script_cf_troop_agent_is_alive # INPUT: arg1 = troop_id ("cf_troop_agent_is_alive", [(store_script_param, ":troop_no", 1), (assign, ":alive_count", 0), (try_for_agents, ":cur_agent"), (agent_get_troop_id, ":cur_agent_troop", ":cur_agent"), (eq, ":troop_no", ":cur_agent_troop"), (agent_is_alive, ":cur_agent"), (val_add, ":alive_count", 1), (try_end), (gt, ":alive_count", 0), ]), #script_get_troop_item_amount # INPUT: arg1 = troop_no, arg2 = item_no # OUTPUT: reg0 = item_amount ("get_troop_item_amount", [(store_script_param, ":troop_no", 1), (store_script_param, ":item_no", 2), (troop_get_inventory_capacity, ":inv_cap", ":troop_no"), (assign, ":count", 0), (try_for_range, ":i_slot", 0, ":inv_cap"), (troop_get_inventory_slot, ":cur_item", ":troop_no", ":i_slot"), (eq, ":cur_item", ":item_no"), (val_add, ":count", 1), (try_end), (assign, reg0, ":count"), ]), # script_cf_troop_has_item # INPUT: arg1 = troop_no, arg2 = item_no ("cf_troop_has_item", [(store_script_param, ":troop_no", 1), (store_script_param, ":item_no", 2), (troop_get_inventory_capacity, ":inv_cap", ":troop_no"), (try_for_range, ":i_slot", 0, ":inv_cap"), (troop_get_inventory_slot, ":cur_item", ":troop_no", ":i_slot"), (eq, ":cur_item", ":item_no"), (assign, ":inv_cap", 0), (try_end), (eq, ":inv_cap", 0), ]), # script_cf_troop_has_active_item # INPUT: arg1 = troop_no, arg2 = item_no ("cf_troop_has_active_item", [(store_script_param, ":troop_no", 1), (store_script_param, ":item_no", 2), (troop_get_inventory_capacity, ":inv_cap", ":troop_no"), (try_for_range, ":i_slot", 0, ":inv_cap"), (troop_get_inventory_slot, ":cur_item", ":troop_no", ":i_slot"), (eq, ":cur_item", ":item_no"), (item_slot_eq, ":cur_item", slot_item_is_active, 1), (assign, ":inv_cap", 0), (try_end), (eq, ":inv_cap", 0), ]), #script_apply_attribute_bonuses # Checks if items that change attributes are in the player inventory and adds or removes an attribute bonus ("apply_attribute_bonuses",[ # Tulcarisil, STR+1 (call_script, "script_apply_attribute_bonus_for_item", "itm_ring_a_reward", 0, ca_strength, 1), # beorn chieftain armor, Wildcraft/2 = STR (store_skill_level, reg1, "skl_persuasion", "trp_player"), (val_div, reg1, 2), (call_script, "script_apply_attribute_bonus_for_item", "itm_beorn_chief", 1, ca_strength, reg1), # Finwarisil, AGI+1 (call_script, "script_apply_attribute_bonus_for_item", "itm_ring_b_reward", 0, ca_agility, 1), # Light of Galadriel, INT+1 (call_script, "script_apply_attribute_bonus_for_item", "itm_phial_reward", 0, ca_intelligence, 1), (call_script, "script_apply_attribute_bonus_for_item", "itm_tome_of_knowledge", 0, ca_intelligence, 1), # Horn of Gondor, CHA+1 (call_script, "script_apply_attribute_bonus_for_item", "itm_horn_gondor_reward", 0, ca_charisma, 1), # Khand Sacrificial Knife, CHA+1 (call_script, "script_apply_attribute_bonus_for_item", "itm_khand_knife_reward", 0, ca_charisma, 1), # Witchking Helmet, CHA+1 when equipped #(call_script, "script_apply_attribute_bonus_for_item", "itm_witchking_helmet", 1, ca_charisma, 1), #(call_script, "script_apply_attribute_bonus_for_item", "itm_isen_uruk_heavy_reward", 1, ca_charisma, 1), ]), #script_apply_attribute_bonus_for_item # Checks if items that change attributes are in the player inventory and adds or removes an attribute bonus ("apply_attribute_bonus_for_item",[ (store_script_param, ":item", 1), (store_script_param, ":must_be_equipped", 2), (store_script_param, ":attr", 3), (store_script_param, ":attr_bonus", 4), (str_store_item_name, s7, ":item"), (try_begin), (eq, ":attr", ca_strength), (assign, ":slot", slot_item_strength_bonus), (str_store_string, s6, "@Strength"), (else_try), (eq, ":attr", ca_agility), (assign, ":slot", slot_item_agility_bonus), (str_store_string, s6, "@Agility"), (else_try), (eq, ":attr", ca_intelligence), (assign, ":slot", slot_item_intelligence_bonus), (str_store_string, s6, "@Intelligence"), (else_try), #(eq, ":attr", ca_charisma), (assign, ":slot", slot_item_charisma_bonus), (str_store_string, s6, "@Charisma"), (try_end), (try_begin), (assign, ":item_gives_bonus", 0), (try_begin), (eq, ":must_be_equipped", 1), (troop_has_item_equipped, "trp_player", ":item"), (assign, ":item_gives_bonus", 1), (else_try), (eq, ":must_be_equipped", 0), (player_has_item, ":item"), # Doesn't work for equipped items (assign, ":item_gives_bonus", 1), (try_end), (eq, ":item_gives_bonus", 1), (try_begin), # just got it (item_slot_eq, ":item", ":slot", 0), (troop_raise_attribute, "trp_player", ":attr", ":attr_bonus"), (item_set_slot, ":item", ":slot", 1), (display_message, "@You've gained {s6} from gaining {s7}", color_good_news), (try_end), (else_try), #lost or unequipped it (item_slot_eq, ":item", ":slot", 1), (val_mul, ":attr_bonus", -1), (troop_raise_attribute, "trp_player", ":attr", ":attr_bonus"), (item_set_slot, ":item", ":slot", 0), (display_message, "@You've lost {s6} from losing {s7}", color_bad_news), (try_end), ]), #script_get_name_from_dna_to_s50 # INPUT: arg1 = dna, arg2 = troop_no (MV added for races) # OUTPUT: s50 = name ("get_name_from_dna_to_s50", [(store_script_param, ":dna", 1), (store_script_param, ":troop", 2), (troop_get_type, ":race", ":troop"), (try_begin), (is_between, ":race", tf_orc_begin, tf_orc_end), (assign, ":names_begin", names_orc_begin), (assign, ":names_end", names_orc_end), (else_try), (eq, ":race", tf_dwarf), (assign, ":names_begin", names_dwarf_begin), (assign, ":names_end", names_dwarf_end), (else_try), (is_between, ":race", tf_elf_begin, tf_elf_end), (assign, ":names_begin", names_elf_begin), (assign, ":names_end", names_elf_end), (else_try), (assign, ":names_begin", names_begin), (assign, ":names_end", names_end), (try_end), (store_sub, ":num_names", ":names_end", ":names_begin"), (store_sub, ":num_surnames", surnames_end, surnames_begin), (assign, ":selected_name", ":dna"), (val_mod, ":selected_name", ":num_names"), (assign, ":selected_surname", ":dna"), (val_div, ":selected_surname", ":num_names"), (val_mod, ":selected_surname", ":num_surnames"), (val_add, ":selected_name", ":names_begin"), (val_add, ":selected_surname", surnames_begin), (str_store_string, s50, ":selected_name"), (str_store_string, s50, ":selected_surname"), (try_begin), #add a little extra (lt, ":selected_surname", surnames_nickname_begin), # somebody of sometown format (try_begin), (is_between, ":race", tf_orc_begin, tf_orc_end), (str_store_string, s50, "@{s50} Caves"), (else_try), (eq, ":race", tf_dwarf), (str_store_string, s50, "@{s50} Mines"), (else_try), (is_between, ":race", tf_elf_begin, tf_elf_end), (str_store_string, s50, "@{s50} Woods"), (try_end), (try_end), ]), #script_change_center_prosperity # INPUT: arg1 = center_no, arg2 = difference ("change_center_prosperity", [(store_script_param, ":center_no", 1), (store_script_param, ":difference", 2), (party_get_slot, ":prosperity", ":center_no", slot_town_prosperity), (store_add, ":new_prosperity", ":prosperity", ":difference"), (val_clamp, ":new_prosperity", 0, 100), (store_div, ":old_state", ":prosperity", 20), (store_div, ":new_state", ":new_prosperity", 20), (try_begin), (neq, ":old_state", ":new_state"), (str_store_party_name_link, s2, ":center_no"), (call_script, "script_get_prosperity_text_to_s50", ":center_no"), (str_store_string, s3, s50), (party_set_slot, ":center_no", slot_town_prosperity, ":new_prosperity"), (call_script, "script_get_prosperity_text_to_s50", ":center_no"), (str_store_string, s4, s50), #(display_message, "@Prosperity of {s2} has changed from {s3} to {s4}."), (call_script, "script_update_center_notes", ":center_no"), (else_try), (party_set_slot, ":center_no", slot_town_prosperity, ":new_prosperity"), (try_end), ]), #script_get_center_ideal_prosperity # INPUT: arg1 = center_no # OUTPUT: reg0 = ideal_prosperity ("get_center_ideal_prosperity", [#(store_script_param, ":center_no", 1), (assign, ":ideal", 40), (assign, reg0, ":ideal"), ]), #script_troop_add_gold # INPUT: arg1 = troop_no, arg2 = amount ("troop_add_gold", [(store_script_param, ":troop_no", 1), (store_script_param, ":amount", 2), (troop_add_gold, ":troop_no", ":amount"), (try_begin), (eq, ":troop_no", "trp_player"), #(play_sound, "snd_money_received"), (try_end), ]), #NPC companion changes begin ("initialize_npcs",[ # set strings #good companions # Mablung (troop_set_slot, "trp_npc1", slot_troop_morality_type, tmt_egalitarian), (troop_set_slot, "trp_npc1", slot_troop_morality_value, 3), (troop_set_slot, "trp_npc1", slot_troop_2ary_morality_type, tmt_honest), (troop_set_slot, "trp_npc1", slot_troop_2ary_morality_value, 2), (troop_set_slot, "trp_npc1", slot_troop_personalityclash_object, "trp_npc9"), #Gulm/none (troop_set_slot, "trp_npc1", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc1", slot_troop_personalitymatch_object, "trp_npc6"), #Luevanna (troop_set_slot, "trp_npc1", slot_troop_home, "p_town_west_osgiliath"), (troop_set_slot, "trp_npc1", slot_troop_payment_request, 2500 / companionPriceMult ), (troop_set_slot, "trp_npc1", slot_troop_cur_center, "p_town_henneth_annun"), #TLD (troop_set_slot, "trp_npc1", slot_troop_rank_request, 4), #TLD # Cirdil (troop_set_slot, "trp_npc2", slot_troop_morality_type, tmt_egalitarian), (troop_set_slot, "trp_npc2", slot_troop_morality_value, 2), (troop_set_slot, "trp_npc2", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc2", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc2", slot_troop_personalityclash_object, "trp_npc9"), #Gulm/none (troop_set_slot, "trp_npc2", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc2", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung (troop_set_slot, "trp_npc2", slot_troop_home, "p_town_minas_morgul"), (troop_set_slot, "trp_npc2", slot_troop_payment_request, 300 / companionPriceMult ), (troop_set_slot, "trp_npc2", slot_troop_cur_center, "p_town_minas_tirith"), #TLD (troop_set_slot, "trp_npc2", slot_troop_rank_request, 1), #TLD # Ulfas (troop_set_slot, "trp_npc3", slot_troop_morality_type, tmt_aristocratic), (troop_set_slot, "trp_npc3", slot_troop_morality_value, 4), (troop_set_slot, "trp_npc3", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc3", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc3", slot_troop_personalityclash_object, "trp_npc1"), #Mablung (troop_set_slot, "trp_npc3", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc3", slot_troop_personalitymatch_object, "trp_npc4"), #Gálmynë (troop_set_slot, "trp_npc3", slot_troop_home, "p_ford_fangorn"), (troop_set_slot, "trp_npc3", slot_troop_payment_request, 700 / companionPriceMult), (troop_set_slot, "trp_npc3", slot_troop_cur_center, "p_town_hornburg"), #TLD (troop_set_slot, "trp_npc3", slot_troop_rank_request, 2), #TLD # Gálmynë (troop_set_slot, "trp_npc4", slot_troop_morality_type, tmt_aristocratic), (troop_set_slot, "trp_npc4", slot_troop_morality_value, -1), (troop_set_slot, "trp_npc4", slot_troop_2ary_morality_type, tmt_honest), (troop_set_slot, "trp_npc4", slot_troop_2ary_morality_value, 1), (troop_set_slot, "trp_npc4", slot_troop_personalityclash_object, "trp_npc9"), #Gulm/none (troop_set_slot, "trp_npc4", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc4", slot_troop_personalitymatch_object, "trp_npc8"), #Faniul (troop_set_slot, "trp_npc4", slot_troop_home, "p_ford_brown_lands"), #Field of Celebrant ford (troop_set_slot, "trp_npc4", slot_troop_payment_request, 3000 / companionPriceMult), (troop_set_slot, "trp_npc4", slot_troop_cur_center, "p_town_edoras"), #TLD (troop_set_slot, "trp_npc4", slot_troop_rank_request, 4), #TLD # Glorfindel (troop_set_slot, "trp_npc5", slot_troop_morality_type, tmt_honest), (troop_set_slot, "trp_npc5", slot_troop_morality_value, 3), (troop_set_slot, "trp_npc5", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc5", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc5", slot_troop_personalityclash_object, "trp_npc9"), #Gulm/none (troop_set_slot, "trp_npc5", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc5", slot_troop_personalitymatch_object, "trp_npc9"), #Gulm/none (troop_set_slot, "trp_npc5", slot_troop_home, "p_town_isengard"), (troop_set_slot, "trp_npc5", slot_troop_payment_request, 5000 / companionPriceMult), (troop_set_slot, "trp_npc5", slot_troop_cur_center, "p_town_caras_galadhon"), #TLD (troop_set_slot, "trp_npc5", slot_troop_rank_request, 7), #TLD # Luevanna (troop_set_slot, "trp_npc6", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc6", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc6", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc6", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc6", slot_troop_personalityclash_object, "trp_npc7"), #Kíli (troop_set_slot, "trp_npc6", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc6", slot_troop_personalitymatch_object, "trp_npc5"), #Glorfindel (troop_set_slot, "trp_npc6", slot_troop_home, "p_town_dol_guldur"), (troop_set_slot, "trp_npc6", slot_troop_payment_request, 1000 / companionPriceMult), (troop_set_slot, "trp_npc6", slot_troop_cur_center, "p_town_thranduils_halls"), #TLD (troop_set_slot, "trp_npc6", slot_troop_rank_request, 3), #TLD # Kíli (troop_set_slot, "trp_npc7", slot_troop_morality_type, tmt_aristocratic), (troop_set_slot, "trp_npc7", slot_troop_morality_value, 3), (troop_set_slot, "trp_npc7", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc7", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc7", slot_troop_personalityclash_object, "trp_npc5"), #Glorfindel (troop_set_slot, "trp_npc7", slot_troop_personalityclash2_object, "trp_npc6"), #Luevanna (troop_set_slot, "trp_npc7", slot_troop_personalitymatch_object, "trp_npc8"), #Faniul (troop_set_slot, "trp_npc7", slot_troop_home, "p_town_moria"), (troop_set_slot, "trp_npc7", slot_troop_payment_request, 800 / companionPriceMult ), (troop_set_slot, "trp_npc7", slot_troop_cur_center, "p_town_erebor"), #TLD (troop_set_slot, "trp_npc7", slot_troop_rank_request, 2), #TLD # Faniul (troop_set_slot, "trp_npc8", slot_troop_morality_type, tmt_egalitarian), (troop_set_slot, "trp_npc8", slot_troop_morality_value, 4), (troop_set_slot, "trp_npc8", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc8", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc8", slot_troop_personalityclash_object, "trp_npc3"), #Ulfas (troop_set_slot, "trp_npc8", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc8", slot_troop_personalitymatch_object, "trp_npc7"), #Kíli (troop_set_slot, "trp_npc8", slot_troop_home, "p_town_beorn_house"), (troop_set_slot, "trp_npc8", slot_troop_payment_request, 1000 / companionPriceMult), (troop_set_slot, "trp_npc8", slot_troop_cur_center, "p_town_dale"), #TLD (troop_set_slot, "trp_npc8", slot_troop_rank_request, 3), #TLD #evil companions # Gulm (troop_set_slot, "trp_npc9", slot_troop_morality_type, tmt_aristocratic), (troop_set_slot, "trp_npc9", slot_troop_morality_value, 4), (troop_set_slot, "trp_npc9", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc9", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc9", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc9", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc9", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc9", slot_troop_home, "p_town_hornburg"), (troop_set_slot, "trp_npc9", slot_troop_payment_request, 2000 / companionPriceMult), (troop_set_slot, "trp_npc9", slot_troop_cur_center, "p_town_urukhai_h_camp"), #TLD (troop_set_slot, "trp_npc9", slot_troop_rank_request, 4), #TLD # Durgash (troop_set_slot, "trp_npc10", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc10", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc10", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc10", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc10", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc10", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc10", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc10", slot_troop_home, -1), (troop_set_slot, "trp_npc10", slot_troop_payment_request, 800 / companionPriceMult), (troop_set_slot, "trp_npc10", slot_troop_cur_center, "p_town_isengard"), #TLD (troop_set_slot, "trp_npc10", slot_troop_rank_request, 2), #TLD # Ufthak (troop_set_slot, "trp_npc11", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc11", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc11", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc11", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc11", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc11", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc11", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc11", slot_troop_home, -1), (troop_set_slot, "trp_npc11", slot_troop_payment_request, 100 / companionPriceMult), (troop_set_slot, "trp_npc11", slot_troop_cur_center, "p_town_cirith_ungol"), #TLD (troop_set_slot, "trp_npc11", slot_troop_rank_request, 0), #TLD # Gorbag (troop_set_slot, "trp_npc12", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc12", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc12", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc12", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc12", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc12", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc12", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc12", slot_troop_home, -1), (troop_set_slot, "trp_npc12", slot_troop_payment_request, 1800 / companionPriceMult), (troop_set_slot, "trp_npc12", slot_troop_cur_center, "p_town_minas_morgul"), #TLD (troop_set_slot, "trp_npc12", slot_troop_rank_request, 4), #TLD # Lykyada (troop_set_slot, "trp_npc13", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc13", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc13", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc13", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc13", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc13", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc13", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc13", slot_troop_home, -1), (troop_set_slot, "trp_npc13", slot_troop_payment_request, 4000 / companionPriceMult), (troop_set_slot, "trp_npc13", slot_troop_cur_center, "p_town_harad_camp"), #TLD (troop_set_slot, "trp_npc13", slot_troop_rank_request, 6), #TLD # Fuldimir (troop_set_slot, "trp_npc14", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc14", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc14", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc14", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc14", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc14", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc14", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc14", slot_troop_home, -1), (troop_set_slot, "trp_npc14", slot_troop_payment_request, 400 / companionPriceMult), (troop_set_slot, "trp_npc14", slot_troop_cur_center, "p_town_umbar_camp"), #TLD (troop_set_slot, "trp_npc14", slot_troop_rank_request, 1), #TLD # Bolzog (troop_set_slot, "trp_npc15", slot_troop_morality_type, tmt_egalitarian), (troop_set_slot, "trp_npc15", slot_troop_morality_value, 1), (troop_set_slot, "trp_npc15", slot_troop_2ary_morality_type, tmt_honest), (troop_set_slot, "trp_npc15", slot_troop_2ary_morality_value, -1), (troop_set_slot, "trp_npc15", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc15", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc15", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc15", slot_troop_home, -1), (troop_set_slot, "trp_npc15", slot_troop_payment_request, 700 / companionPriceMult), (troop_set_slot, "trp_npc15", slot_troop_cur_center, "p_town_moria"), #TLD (troop_set_slot, "trp_npc15", slot_troop_rank_request, 2), #TLD # Varfang (troop_set_slot, "trp_npc16", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc16", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc16", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc16", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc16", slot_troop_personalityclash_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc16", slot_troop_personalityclash2_object, "trp_npc2"), #Cirdil/none (troop_set_slot, "trp_npc16", slot_troop_personalitymatch_object, "trp_npc1"), #Mablung/none (troop_set_slot, "trp_npc16", slot_troop_home, -1), (troop_set_slot, "trp_npc16", slot_troop_payment_request, 800 / companionPriceMult), (troop_set_slot, "trp_npc16", slot_troop_cur_center, "p_town_rhun_main_camp"), #TLD (troop_set_slot, "trp_npc16", slot_troop_rank_request, 2), #TLD #additional companions # Dímborn (troop_set_slot, "trp_npc17", slot_troop_morality_type, -1), (troop_set_slot, "trp_npc17", slot_troop_morality_value, 0), (troop_set_slot, "trp_npc17", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc17", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc17", slot_troop_personalityclash_object, "trp_npc9"), #Gulm/none (troop_set_slot, "trp_npc17", slot_troop_personalityclash2_object, "trp_npc10"), #Durgash/none (troop_set_slot, "trp_npc17", slot_troop_personalitymatch_object, "trp_npc6"), #Luevanna (troop_set_slot, "trp_npc17", slot_troop_home, "p_town_cerin_dolen"), (troop_set_slot, "trp_npc17", slot_troop_payment_request, 400 / companionPriceMult ), (troop_set_slot, "trp_npc17", slot_troop_cur_center, "p_town_woodsmen_village"), #TLD (troop_set_slot, "trp_npc17", slot_troop_rank_request, 1), #TLD # New Companions # Turmbathu (troop_set_slot, "trp_npc18", slot_troop_morality_type, tmt_aristocratic), (troop_set_slot, "trp_npc18", slot_troop_morality_value, 3), (troop_set_slot, "trp_npc18", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc18", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc18", slot_troop_personalityclash_object, "trp_npc16"), #Varfang (troop_set_slot, "trp_npc18", slot_troop_personalityclash2_object, "trp_npc9"), #Gulm (troop_set_slot, "trp_npc18", slot_troop_personalitymatch_object, "trp_npc13"), #Lykada (troop_set_slot, "trp_npc18", slot_troop_home, "p_legend_amonhen"), (troop_set_slot, "trp_npc18", slot_troop_payment_request, 1500 / companionPriceMult ), (troop_set_slot, "trp_npc18", slot_troop_cur_center, "p_town_khand_camp"), #TLD (troop_set_slot, "trp_npc18", slot_troop_rank_request, 3), #TLD # Heidrek (troop_set_slot, "trp_npc19", slot_troop_morality_type, tmt_egalitarian), (troop_set_slot, "trp_npc19", slot_troop_morality_value, 2), (troop_set_slot, "trp_npc19", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc19", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc19", slot_troop_personalityclash_object, "trp_npc11"), #Ufthak (troop_set_slot, "trp_npc19", slot_troop_personalityclash2_object, "trp_npc1"), #Mablung/None (troop_set_slot, "trp_npc19", slot_troop_personalitymatch_object, "trp_npc16"), #Varfang (troop_set_slot, "trp_npc19", slot_troop_home, "p_town_edoras"), (troop_set_slot, "trp_npc19", slot_troop_payment_request, 800 / companionPriceMult ), (troop_set_slot, "trp_npc19", slot_troop_cur_center, "p_town_dunland_camp"), #TLD (troop_set_slot, "trp_npc19", slot_troop_rank_request, 2), #TLD # Zigûrphel (troop_set_slot, "trp_npc20", slot_troop_morality_type, tmt_honest), (troop_set_slot, "trp_npc20", slot_troop_morality_value, 2), (troop_set_slot, "trp_npc20", slot_troop_2ary_morality_type, tmt_aristocratic), (troop_set_slot, "trp_npc20", slot_troop_2ary_morality_value, 3), (troop_set_slot, "trp_npc20", slot_troop_personalityclash_object, "trp_npc13"), #Lykada (troop_set_slot, "trp_npc20", slot_troop_personalityclash2_object, "trp_npc14"), #Fuldimir (troop_set_slot, "trp_npc20", slot_troop_personalitymatch_object, "trp_npc15"), #Bolzog (troop_set_slot, "trp_npc20", slot_troop_home, "p_town_erebor"), (troop_set_slot, "trp_npc20", slot_troop_payment_request, 2500 / companionPriceMult ), (troop_set_slot, "trp_npc20", slot_troop_cur_center, "p_town_dol_guldur"), #TLD (troop_set_slot, "trp_npc20", slot_troop_rank_request, 5), #TLD # Troll Berta (troop_set_slot, "trp_npc21", slot_troop_morality_type, tmt_egalitarian), (troop_set_slot, "trp_npc21", slot_troop_morality_value, 2), (troop_set_slot, "trp_npc21", slot_troop_2ary_morality_type, -1), (troop_set_slot, "trp_npc21", slot_troop_2ary_morality_value, 0), (troop_set_slot, "trp_npc21", slot_troop_personalityclash_object, "trp_npc20"), #Zigûrphel (troop_set_slot, "trp_npc21", slot_troop_personalityclash2_object, "trp_no_troop"), #none (troop_set_slot, "trp_npc21", slot_troop_personalitymatch_object, "trp_npc11"), #Ufthak (troop_set_slot, "trp_npc21", slot_troop_home, "p_town_dol_guldur"), (troop_set_slot, "trp_npc21", slot_troop_payment_request, 2500 / companionPriceMult ), (troop_set_slot, "trp_npc21", slot_troop_cur_center, "p_town_gundabad"), #TLD (troop_set_slot, "trp_npc21", slot_troop_rank_request, 5), #TLD #Others (placeholder) (try_for_range, ":placeholder_troops", "trp_npc22", "trp_werewolf"), (troop_set_slot, ":placeholder_troops", slot_troop_morality_type, -1), (troop_set_slot, ":placeholder_troops", slot_troop_morality_value, 0), (troop_set_slot, ":placeholder_troops", slot_troop_2ary_morality_type, -1), (troop_set_slot, ":placeholder_troops", slot_troop_2ary_morality_value, 0), (troop_set_slot, ":placeholder_troops", slot_troop_personalityclash_object, "trp_npc14"), #Fuldimir (troop_set_slot, ":placeholder_troops", slot_troop_personalityclash2_object, "trp_npc13"), #Lykada (troop_set_slot, ":placeholder_troops", slot_troop_personalitymatch_object, "trp_npc15"), #Bolzog (troop_set_slot, ":placeholder_troops", slot_troop_home, -1), (troop_set_slot, ":placeholder_troops", slot_troop_payment_request, 2000 / companionPriceMult ), (troop_set_slot, ":placeholder_troops", slot_troop_cur_center, -1), #TLD (troop_set_slot, ":placeholder_troops", slot_troop_rank_request, 0), #TLD (try_end), (store_sub, "$number_of_npc_slots", slot_troop_strings_end, slot_troop_intro), # 131-101=30 strings per NPC # Old Companions (store_sub, ":total_companions", companions_end, companions_begin), (try_begin), (store_sub, reg1, "str_companion_strings_end", "str_npc1_intro"), #total actual strings (store_mul, reg2, "$number_of_npc_slots", ":total_companions"), #total strings needed (neq, reg1, reg2), (display_message, "@ERROR: Companion strings actual/needed: {reg1}/{reg2}", 0xFFFF2222), (try_end), (try_for_range, ":npc", companions_begin, companions_end), (try_for_range, ":slot_addition", 0, "$number_of_npc_slots"), (store_add, ":slot", ":slot_addition", slot_troop_intro), (store_mul, ":string_addition", ":slot_addition", ":total_companions"), #MV: was 16 (store_add, ":string", "str_npc1_intro", ":string_addition"), (val_add, ":string", ":npc"), (val_sub, ":string", companions_begin), (troop_set_slot, ":npc", ":slot", ":string"), (try_end), (try_end), # New Companions (store_sub, ":total_companions_new", new_companions_end, new_companions_begin), (try_begin), (store_sub, reg11, "str_new_companion_strings_end", "str_npc18_intro"), #total actual strings (store_mul, reg22, "$number_of_npc_slots", ":total_companions_new"), #total strings needed (neq, reg11, reg22), (display_message, "@ERROR: Companion strings actual/needed: {reg11}/{reg22}", color_good_news), (try_end), (try_for_range, ":npc_new", new_companions_begin, new_companions_end), (try_for_range, ":slot_addition_new", 0, "$number_of_npc_slots"), (store_add, ":slot_new", ":slot_addition_new", slot_troop_intro), #101 (store_mul, ":string_addition_new", ":slot_addition_new", ":total_companions_new"), #MV: was 16 (0*3) (store_add, ":string_new", "str_npc18_intro", ":string_addition_new"), #2301 + 0 (val_add, ":string_new", ":npc_new"), #(2301 + 940) (val_sub, ":string_new", new_companions_begin), #(3241-940) = 1361 (troop_set_slot, ":npc_new", ":slot_new", ":string_new"), (try_end), (try_end), (call_script, "script_add_log_entry", logent_game_start, "trp_player", -1, -1, -1), ]), # script_objectionable_action ("objectionable_action", [ (store_script_param_1, ":action_type"), (store_script_param_2, ":action_string"), # (str_store_string, 12, ":action_string"), # (display_message, "@Objectionable action check: {s12}"), (assign, ":grievance_minimum", -2), (assign, ":npc_last_displayed", 0), (try_for_range, ":npc", companions_begin, new_companions_end), (this_or_next|is_between, ":npc", companions_begin, companions_end), (is_between, ":npc", new_companions_begin, new_companions_end), (main_party_has_troop, ":npc"), ###Primary morality check (try_begin), (troop_slot_eq, ":npc", slot_troop_morality_type, ":action_type"), (try_begin), (eq, ":npc", "trp_npc21"), #Berta exception - doesn't care about casualties (neq, ":action_string", "str_excessive_casualties"), (try_end), (troop_get_slot, ":value", ":npc", slot_troop_morality_value), (try_begin), (troop_slot_eq, ":npc", slot_troop_morality_state, tms_acknowledged), # npc is betrayed, major penalty to player honor and morale (troop_get_slot, ":grievance", ":npc", slot_troop_morality_penalties), (val_mul, ":value", 2), (val_add, ":grievance", ":value"), (troop_set_slot, ":npc", slot_troop_morality_penalties, ":grievance"), (else_try), (this_or_next|troop_slot_eq, ":npc", slot_troop_morality_state, tms_dismissed), (eq, "$disable_npc_complaints", 1), # npc is quietly disappointed (troop_get_slot, ":grievance", ":npc", slot_troop_morality_penalties), (val_add, ":grievance", ":value"), (troop_set_slot, ":npc", slot_troop_morality_penalties, ":grievance"), (else_try), # npc raises the issue for the first time (troop_slot_eq, ":npc", slot_troop_morality_state, tms_no_problem), (gt, ":value", ":grievance_minimum"), (assign, "$npc_with_grievance", ":npc"), (assign, "$npc_grievance_string", ":action_string"), (assign, "$npc_grievance_slot", slot_troop_morality_state), (assign, ":grievance_minimum", ":value"), (assign, "$npc_praise_not_complaint", 0), (try_begin), (lt, ":value", 0), (assign, "$npc_praise_not_complaint", 1), (try_end), (try_end), ###Secondary morality check (else_try), (troop_slot_eq, ":npc", slot_troop_2ary_morality_type, ":action_type"), (troop_get_slot, ":value", ":npc", slot_troop_2ary_morality_value), (try_begin), (troop_slot_eq, ":npc", slot_troop_2ary_morality_state, tms_acknowledged), # npc is betrayed, major penalty to player honor and morale (troop_get_slot, ":grievance", ":npc", slot_troop_morality_penalties), (val_mul, ":value", 2), (val_add, ":grievance", ":value"), (troop_set_slot, ":npc", slot_troop_morality_penalties, ":grievance"), (else_try), (this_or_next|troop_slot_eq, ":npc", slot_troop_2ary_morality_state, tms_dismissed), (eq, "$disable_npc_complaints", 1), # npc is quietly disappointed (troop_get_slot, ":grievance", ":npc", slot_troop_morality_penalties), (val_add, ":grievance", ":value"), (troop_set_slot, ":npc", slot_troop_morality_penalties, ":grievance"), (else_try), # npc raises the issue for the first time (troop_slot_eq, ":npc", slot_troop_2ary_morality_state, tms_no_problem), (gt, ":value", ":grievance_minimum"), (assign, "$npc_with_grievance", ":npc"), (assign, "$npc_grievance_string", ":action_string"), (assign, "$npc_grievance_slot", slot_troop_2ary_morality_state), (assign, ":grievance_minimum", ":value"), (assign, "$npc_praise_not_complaint", 0), (try_begin), (lt, ":value", 0), (assign, "$npc_praise_not_complaint", 1), (try_end), (try_end), (try_end), (try_begin), (gt, "$npc_with_grievance", 0), (eq, "$npc_praise_not_complaint", 0), (neq, "$npc_with_grievance", ":npc_last_displayed"), (str_store_troop_name, 4, "$npc_with_grievance"), (display_message, "@{s4} looks upset."), (assign, ":npc_last_displayed", "$npc_with_grievance"), (try_end), (try_end), ]), ("post_battle_personality_clash_check", [ # (display_message, "@Post-victory personality clash check"), (try_for_range, ":npc", companions_begin, new_companions_end), (this_or_next|is_between, ":npc", companions_begin, companions_end), (is_between, ":npc", new_companions_begin, new_companions_end), (eq, "$disable_npc_complaints", 0), (main_party_has_troop, ":npc"), (neg|troop_is_wounded, ":npc"), (troop_get_slot, ":other_npc", ":npc", slot_troop_personalityclash2_object), (main_party_has_troop, ":other_npc"), (neg|troop_is_wounded, ":other_npc"), # (store_random_in_range, ":random", 0, 3), (try_begin), (troop_slot_eq, ":npc", slot_troop_personalityclash2_state, 0), (try_begin), # (eq, ":random", 0), (assign, "$npc_with_personality_clash_2", ":npc"), (try_end), (try_end), (try_end), (try_for_range, ":npc", companions_begin, new_companions_end), (this_or_next|is_between, ":npc", companions_begin, companions_end), (is_between, ":npc", new_companions_begin, new_companions_end), (troop_slot_eq, ":npc", slot_troop_personalitymatch_state, 0), (eq, "$disable_npc_complaints", 0), (main_party_has_troop, ":npc"), (neg|troop_is_wounded, ":npc"), (troop_get_slot, ":other_npc", ":npc", slot_troop_personalitymatch_object), (main_party_has_troop, ":other_npc"), (neg|troop_is_wounded, ":other_npc"), (assign, "$npc_with_personality_match", ":npc"), (try_end), (try_begin), (gt, "$npc_with_personality_clash_2", 0), (assign, "$npc_map_talk_context", slot_troop_personalityclash2_state), (start_map_conversation, "$npc_with_personality_clash_2"), (else_try), (gt, "$npc_with_personality_match", 0), (assign, "$npc_map_talk_context", slot_troop_personalitymatch_state), (start_map_conversation, "$npc_with_personality_match"), (try_end), ]), #script_event_player_defeated_enemy_party ("event_player_defeated_enemy_party", [# (try_begin), # (check_quest_active, "qst_raid_caravan_to_start_war"), # (neg|check_quest_concluded, "qst_raid_caravan_to_start_war"), # (party_slot_eq, "$g_enemy_party", slot_party_type, spt_kingdom_caravan), # (store_faction_of_party, ":enemy_faction", "$g_enemy_party"), # (quest_slot_eq, "qst_raid_caravan_to_start_war", slot_quest_target_faction, ":enemy_faction"), # (quest_get_slot, ":cur_state", "qst_raid_caravan_to_start_war", slot_quest_current_state), # (quest_get_slot, ":quest_target_amount", "qst_raid_caravan_to_start_war", slot_quest_target_amount), # (val_add, ":cur_state", 1), # (quest_set_slot, "qst_raid_caravan_to_start_war", slot_quest_current_state, ":cur_state"), # (try_begin), # (ge, ":cur_state", ":quest_target_amount"), # #(quest_get_slot, ":quest_target_faction", "qst_raid_caravan_to_start_war", slot_quest_target_faction), # #(quest_get_slot, ":quest_giver_troop", "qst_raid_caravan_to_start_war", slot_quest_giver_troop), # #(store_troop_faction, ":quest_giver_faction", ":quest_giver_troop"), # #(call_script, "script_diplomacy_start_war_between_kingdoms", ":quest_target_faction", ":quest_giver_faction", 1), # (call_script, "script_succeed_quest", "qst_raid_caravan_to_start_war"), # (try_end), # (try_end), (try_begin), (eq, "$g_battle_result", 1), (assign, "$player_won_last_battle", 1), #(display_message, "@Player won last battle", color_neutral_news), #debug (try_end), ]), #script_event_player_captured_as_prisoner #InVain: Not used in TLD ("event_player_captured_as_prisoner", [ #Removing followers of the player (try_for_range, ":troop_no", kingdom_heroes_begin, kingdom_heroes_end), (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party), (gt, ":party_no", 0), (party_slot_eq, ":party_no", slot_party_commander_party, "p_main_party"), (call_script, "script_party_set_ai_state", ":party_no", spai_undefined, -1), (party_set_slot, ":party_no", slot_party_commander_party, -1), (assign, "$g_recalculate_ais", 2), (try_end), ]), #NPC morale both returns a string and reg0 as the morale value ("npc_morale", [ (store_script_param_1, ":npc"), (troop_get_slot, ":morality_grievances", ":npc", slot_troop_morality_penalties), (troop_get_slot, ":personality_grievances", ":npc", slot_troop_personalityclash_penalties), (party_get_morale, ":party_morale", "p_main_party"), (store_sub, ":troop_morale", ":party_morale", ":morality_grievances"), (val_sub, ":troop_morale", ":personality_grievances"), (val_add, ":troop_morale", 50), (assign, reg8, ":troop_morale"), (val_mul, ":troop_morale", 3), (val_div, ":troop_morale", 4), (val_clamp, ":troop_morale", 0, 100), (assign, reg5, ":party_morale"), (assign, reg6, ":morality_grievances"), (assign, reg7, ":personality_grievances"), (assign, reg9, ":troop_morale"), # (str_store_troop_name, s11, ":npc"), # (display_message, "@{s11}'s morale = PM{reg5} + 50 - MG{reg6} - PG{reg7} = {reg8} x 0.75 = {reg9}"), (try_begin),(lt, ":morality_grievances", 3),(str_store_string, 7, "str_happy"), (else_try) ,(lt, ":morality_grievances",15),(str_store_string, 7, "str_content"), (else_try) ,(lt, ":morality_grievances",30),(str_store_string, 7, "str_concerned"), (else_try) ,(lt, ":morality_grievances",45),(str_store_string, 7, "str_not_happy"), (else_try) , (str_store_string, 7, "str_miserable"), (try_end), (try_begin),(lt, ":personality_grievances", 3),(str_store_string, 6, "str_happy"), (else_try) ,(lt, ":personality_grievances",15),(str_store_string, 6, "str_content"), (else_try) ,(lt, ":personality_grievances",30),(str_store_string, 6, "str_concerned"), (else_try) ,(lt, ":personality_grievances",45),(str_store_string, 6, "str_not_happy"), (else_try) , (str_store_string, 6, "str_miserable"), (try_end), (try_begin),(gt,":troop_morale",80),(str_store_string,8, "str_happy" ),(str_store_string, 63, "str_bar_enthusiastic"), (else_try) ,(gt,":troop_morale",60),(str_store_string,8, "str_content" ),(str_store_string, 63, "str_bar_content"), (else_try) ,(gt,":troop_morale",40),(str_store_string,8, "str_concerned"),(str_store_string, 63, "str_bar_weary"), (else_try) ,(gt,":troop_morale",20),(str_store_string,8, "str_not_happy"),(str_store_string, 63, "str_bar_disgruntled"), (else_try) , (str_store_string,8, "str_miserable"),(str_store_string, 63, "str_bar_miserable"), (try_end), (str_store_string, 21, "str_npc_morale_report"), (assign, reg0, ":troop_morale"), ]), #NPC morale both returns a string and reg0 as the morale value # "script_retire_companion" #InVain: Not used in TLD ("retire_companion", [ (store_script_param_1, ":npc"), (store_script_param_2, ":length"), (remove_member_from_party, ":npc", "p_main_party"), (troop_set_slot, ":npc", slot_troop_personalityclash_penalties, 0), (troop_set_slot, ":npc", slot_troop_morality_penalties, 0), (troop_get_slot, ":renown", "trp_player", slot_troop_renown), (store_add, ":return_renown", ":renown", ":length"), (troop_set_slot, ":npc", slot_troop_occupation, slto_retirement), (troop_set_slot, ":npc", slot_troop_return_renown, ":return_renown"), ]), #script_reduce_companion_morale_for_clash # INPUT: arg1 = troop_no for companion1 arg2 = troop_no for companion2 arg3 = slot_for_clash_state # slot_for_clash_state means: 1=give full penalty to companion1; 2=give full penalty to companion2; 3=give penalty equally ("reduce_companion_morale_for_clash",[ (store_script_param, ":companion_1", 1), (store_script_param, ":companion_2", 2), (store_script_param, ":slot_for_clash_state", 3), (troop_get_slot, ":clash_state", ":companion_1", ":slot_for_clash_state"), (troop_get_slot, ":grievance_1", ":companion_1", slot_troop_personalityclash_penalties), (troop_get_slot, ":grievance_2", ":companion_2", slot_troop_personalityclash_penalties), (try_begin), (eq, ":clash_state", pclash_penalty_to_self), (val_add, ":grievance_1", 5), (else_try), (eq, ":clash_state", pclash_penalty_to_other), (val_add, ":grievance_2", 5), (else_try), (eq, ":clash_state", pclash_penalty_to_both), (val_add, ":grievance_1", 3), (val_add, ":grievance_2", 3), (try_end), (troop_set_slot, ":companion_1", slot_troop_personalityclash_penalties, ":grievance_1"), (troop_set_slot, ":companion_2", slot_troop_personalityclash_penalties, ":grievance_2"), ]), #script_calculate_ransom_amount_for_troop #InVain: This is largely inconsequential in TLD, could be cleaned up # INPUT: arg1 = troop_no # OUTPUT: reg0 = ransom_amount ("calculate_ransom_amount_for_troop", [(store_script_param, ":troop_no", 1), (store_troop_faction, ":faction_no", ":troop_no"), (assign, ":ransom_amount", 400), (try_begin), (faction_slot_eq, ":faction_no", slot_faction_leader, ":troop_no"), (val_add, ":ransom_amount", 4000), (try_end), (assign, ":num_center_points", 0), (try_for_range, ":cur_center", centers_begin, centers_end), (party_is_active, ":cur_center"), #TLD (party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"), (try_begin), (party_slot_eq, ":cur_center", slot_party_type, spt_town), (val_add, ":num_center_points", 4), (else_try), (party_slot_eq, ":cur_center", slot_party_type, spt_castle), (val_add, ":num_center_points", 2), (else_try), (val_add, ":num_center_points", 1), (try_end), (try_end), (val_mul, ":num_center_points", 500), (val_add, ":ransom_amount", ":num_center_points"), (troop_get_slot, ":renown", ":troop_no", slot_troop_renown), (val_mul, ":renown", 2), (val_add, ":ransom_amount", ":renown"), (store_mul, ":ransom_max_amount", ":ransom_amount", 3), (val_div, ":ransom_max_amount", 2), (store_random_in_range, ":random_ransom_amount", ":ransom_amount", ":ransom_max_amount"), (val_div, ":random_ransom_amount", 100), (val_mul, ":random_ransom_amount", 100), (assign, reg0, ":random_ransom_amount"), ]), # script_cf_check_hero_can_escape_from_player # Input: arg1 = troop_no # Output: none (can fail) ("cf_check_hero_can_escape_from_player", #InVain: Invert order of this check, now we check if they can be captured, not if they can escape [ (store_script_param_1, ":troop_no"), (check_quest_active, "qst_capture_enemy_hero"), (assign, ":can_capture", 1), # (try_begin), # (check_quest_active, "qst_capture_enemy_hero"), # (assign, ":can_capture", 1), # (try_end), (try_begin), #can't capture faction leaders (store_troop_faction, ":faction_no", ":troop_no"), (faction_slot_eq, ":faction_no", slot_faction_leader, ":troop_no"), (assign, ":can_capture", 0), (else_try), #can't capture more than one (assign, ":has_prisoner", 0), (party_get_num_prisoner_stacks, ":num_stacks", "p_main_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop", "p_main_party", ":i_stack"), (troop_is_hero, ":stack_troop"), (troop_slot_eq, ":stack_troop", slot_troop_occupation, slto_kingdom_hero), (assign, ":has_prisoner", 1), (try_end), (eq, ":has_prisoner", 1), (assign, ":can_capture", 0), (try_end), (eq, ":can_capture", 1), (party_get_skill_level, ":prs_management", "p_main_party", "skl_prisoner_management"), (val_mul, ":prs_management", 9), (val_add, ":prs_management", 20), #scaling goes 20, 29, 38, 47, 56, 65, 74, 83, 92, 102, 110 (store_random_in_range, ":rand", 0, 100), (gt, ":prs_management", ":rand"), ]), # script_cf_party_remove_random_regular_troop # Input: arg1 = party_no # Output: troop_id that has been removed (can fail) ("cf_party_remove_random_regular_troop", [(store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (assign, ":num_troops", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (val_add, ":num_troops", ":stack_size"), (try_end), (assign, reg0, -1), (gt, ":num_troops", 0), (store_random_in_range, ":random_troop", 0, ":num_troops"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (val_sub, ":random_troop", ":stack_size"), (lt, ":random_troop", 0), (assign, ":num_stacks", 0), #break (party_remove_members, ":party_no", ":stack_troop", 1), (assign, reg0, ":stack_troop"), (try_end), ]), # script_cf_party_select_random_regular_troop # Input: arg1 = party_no # Output: troop_id that has been removed (can fail) ("cf_party_select_random_regular_troop", [(store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_stacks", ":party_no"), (assign, ":num_troops", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (val_add, ":num_troops", ":stack_size"), (try_end), (assign, reg0, -1), (gt, ":num_troops", 0), (store_random_in_range, ":random_troop", 0, ":num_troops"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (val_sub, ":random_troop", ":stack_size"), (lt, ":random_troop", 0), (assign, ":num_stacks", 0), #break (assign, reg0, ":stack_troop"), (try_end), ]), # script_place_player_banner_near_inventory ("place_player_banner_near_inventory", [ #normal_banner_begin (troop_get_slot, ":troop_banner_object", "trp_player", slot_troop_banner_scene_prop), #custom_banner_begin # (troop_get_slot, ":flag_spr", "trp_player", slot_troop_custom_banner_flag_type), (try_begin), #normal_banner_begin (gt, ":troop_banner_object", 0), (scene_prop_get_instance, ":flag_object", ":troop_banner_object", 0), #custom_banner_begin # (ge, ":flag_spr", 0), # (val_add, ":flag_spr", custom_banner_flag_scene_props_begin), # (scene_prop_get_instance, ":flag_object", ":flag_spr", 0), (try_begin), (ge, ":flag_object", 0), (get_player_agent_no, ":player_agent"), (agent_get_look_position, pos1, ":player_agent"), (position_move_y, pos1, -500), (position_rotate_z, pos1, 180), (position_set_z_to_ground_level, pos1), (position_move_z, pos1, 300), (prop_instance_set_position, ":flag_object", pos1), (try_end), (scene_prop_get_instance, ":pole_object", "spr_banner_pole", 0), (try_begin), (ge, ":pole_object", 0), (position_move_z, pos1, -320), (prop_instance_set_position, ":pole_object", pos1), (try_end), (else_try), (init_position, pos1), (position_move_z, pos1, -1000000), (scene_prop_get_instance, ":flag_object", banner_scene_props_begin, 0), (try_begin), (ge, ":flag_object", 0), (prop_instance_set_position, ":flag_object", pos1), (try_end), (scene_prop_get_instance, ":pole_object", "spr_banner_pole", 0), (try_begin), (ge, ":pole_object", 0), (prop_instance_set_position, ":pole_object", pos1), (try_end), (try_end), ]), # script_place_player_banner_near_inventory_bms ("place_player_banner_near_inventory_bms", [ #normal_banner_begin (troop_get_slot, ":troop_banner_object", "trp_player", slot_troop_banner_scene_prop), #custom_banner_begin # (troop_get_slot, ":flag_spr", "trp_player", slot_troop_custom_banner_flag_type), (try_begin), #normal_banner_begin (gt, ":troop_banner_object", 0), (replace_scene_props, banner_scene_props_begin, ":troop_banner_object"), #custom_banner_begin # (ge, ":flag_spr", 0), # (val_add, ":flag_spr", custom_banner_flag_scene_props_begin), # (replace_scene_props, banner_scene_props_begin, ":flag_spr"), (try_end), ]), # script_stay_captive_for_hours # Input: arg1 = num_hours # Output: none ("stay_captive_for_hours", [(store_script_param, ":num_hours", 1), (store_current_hours, ":cur_hours"), (val_add, ":cur_hours", ":num_hours"), (val_max, "$g_check_autos_at_hour", ":cur_hours"), (val_add, ":num_hours", 1), (rest_for_hours, ":num_hours", 0, 0), ]), # script_set_parties_around_player_ignore_player # Input: arg1 = ignore_range, arg2 = num_hours_to_ignore ("set_parties_around_player_ignore_player", [(store_script_param, ":ignore_range", 1), (store_script_param, ":num_hours", 2), (try_for_parties, ":party_no"), (party_is_active, ":party_no"), (store_distance_to_party_from_party, ":dist", "p_main_party", ":party_no"), (lt, ":dist", ":ignore_range"), (party_ignore_player, ":party_no", ":num_hours"), (try_end), ]), # script_randomly_make_prisoner_heroes_escape_from_party # Input: arg1 = party_no, arg2 = escape_chance_mul_1000 ("randomly_make_prisoner_heroes_escape_from_party", [(store_script_param, ":party_no", 1), (store_script_param, ":escape_chance", 2), # (assign, ":quest_troop_1", -1), # (assign, ":quest_troop_2", -1), # (try_begin), # (check_quest_active, "qst_rescue_lord_by_replace"), # (quest_get_slot, ":quest_troop_1", "qst_rescue_lord_by_replace", slot_quest_target_troop), # (try_end), # (try_begin), # (check_quest_active, "qst_deliver_message_to_prisoner_lord"), # (quest_get_slot, ":quest_troop_2", "qst_deliver_message_to_prisoner_lord", slot_quest_target_troop), # (try_end), (party_get_num_prisoner_stacks, ":num_stacks", ":party_no"), (try_for_range_backwards, ":i_stack", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (troop_is_hero, ":stack_troop"), # (neq, ":stack_troop", ":quest_troop_1"), # (neq, ":stack_troop", ":quest_troop_2"), (troop_slot_eq, ":stack_troop", slot_troop_occupation, slto_kingdom_hero), (store_random_in_range, ":random_no", 0, 1000), (lt, ":random_no", ":escape_chance"), (party_remove_prisoners, ":party_no", ":stack_troop", 1), (call_script, "script_remove_troop_from_prison", ":stack_troop"), (str_store_troop_name_link, s1, ":stack_troop"), (try_begin), (eq, ":party_no", "p_main_party"), (str_store_string, s2, "@your party"), (else_try), (str_store_party_name, s2, ":party_no"), (try_end), (assign, reg0, 0), (try_begin), (this_or_next|eq, ":party_no", "p_main_party"), (party_slot_eq, ":party_no", slot_town_lord, "trp_player"), (assign, reg0, 1), (try_end), (store_troop_faction, ":troop_faction", ":stack_troop"), (str_store_faction_name_link, s3, ":troop_faction"), (display_message, "@{reg0?One of your prisoners, :}{s1} of {s3} has escaped from captivity!"), (try_end), ]), # script_draw_banner_to_region # Input: arg1 = troop_no, arg2 = center_pos_x, arg3 = center_pos_y, arg4 = width, arg5 = height, arg6 = stretch_width, arg7 = stretch_height, arg8 = default_scale, arg9 = max_charge_scale, arg10 = drawn_item_type # drawn_item_type is 0 for banners, 1 for shields, 2 for heater shield, 3 for armor # arguments will be used as fixed point values ("draw_banner_to_region", [ (store_script_param, ":troop_no", 1), (store_script_param, ":center_pos_x", 2), (store_script_param, ":center_pos_y", 3), (store_script_param, ":width", 4), (store_script_param, ":height", 5), (store_script_param, ":stretch_width", 6), (store_script_param, ":stretch_height", 7), (store_script_param, ":default_scale", 8), (store_script_param, ":max_charge_scale", 9), (store_script_param, ":drawn_item_type", 10), (troop_get_slot, ":bg_type", ":troop_no", slot_troop_custom_banner_bg_type), (val_add, ":bg_type", custom_banner_backgrounds_begin), (troop_get_slot, ":bg_color_1", ":troop_no", slot_troop_custom_banner_bg_color_1), (troop_get_slot, ":bg_color_2", ":troop_no", slot_troop_custom_banner_bg_color_2), (troop_get_slot, ":num_charges", ":troop_no", slot_troop_custom_banner_num_charges), (troop_get_slot, ":positioning", ":troop_no", slot_troop_custom_banner_positioning), (call_script, "script_get_troop_custom_banner_num_positionings", ":troop_no"), (assign, ":num_positionings", reg0), (val_mod, ":positioning", ":num_positionings"), (init_position, pos2), (position_set_x, pos2, ":width"), (position_set_y, pos2, ":height"), (assign, ":default_value", 1), (convert_to_fixed_point, ":default_value"), (position_set_z, pos2, ":default_value"), (init_position, pos1), (position_set_x, pos1, ":center_pos_x"), (position_set_y, pos1, ":center_pos_y"), (position_move_z, pos1, -20), (init_position, pos3), (position_set_x, pos3, ":default_scale"), (position_set_y, pos3, ":default_scale"), (position_set_z, pos3, ":default_value"), (try_begin), (this_or_next|eq, ":bg_type", "mesh_custom_banner_bg"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg01"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg02"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg03"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg08"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg09"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg10"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg11"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg12"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg13"), (this_or_next|eq, ":bg_type", "mesh_custom_banner_fg16"), (eq, ":bg_type", "mesh_custom_banner_fg17"), (cur_tableau_add_mesh_with_scale_and_vertex_color, ":bg_type", pos1, pos2, 0, ":bg_color_1"), (else_try), (cur_tableau_add_mesh_with_scale_and_vertex_color, ":bg_type", pos1, pos3, 0, ":bg_color_1"), (try_end), (position_move_z, pos1, -20), (position_move_x, pos2, ":width"), (position_move_y, pos2, ":height"), (cur_tableau_add_mesh_with_scale_and_vertex_color, "mesh_custom_banner_bg", pos1, pos2, 0, ":bg_color_2"), (assign, ":charge_stretch", ":stretch_width"), (val_min, ":charge_stretch", ":stretch_height"), (val_min, ":charge_stretch", ":max_charge_scale"), (call_script, "script_get_custom_banner_charge_type_position_scale_color", "trp_player", ":positioning"), (try_begin), (this_or_next|eq, ":drawn_item_type", 2), #heater shield (eq, ":drawn_item_type", 3), #armor (assign, ":change_center_pos", 0), (try_begin), (eq, ":num_charges", 1), (assign, ":change_center_pos", 1), (else_try), (eq, ":num_charges", 2), (eq, ":positioning", 1), (assign, ":change_center_pos", 1), (else_try), (eq, ":num_charges", 3), (eq, ":positioning", 1), (assign, ":change_center_pos", 1), (try_end), (try_begin), (eq, ":change_center_pos", 1), (val_add, ":center_pos_y", 30), (try_end), (try_end), (try_begin), (ge, ":num_charges", 1), (val_mul, reg1, ":charge_stretch"), (val_div, reg1, 10000), (position_get_x, ":x", pos0), (position_get_y, ":y", pos0), (val_mul, ":x", ":stretch_width"), (val_mul, ":y", ":stretch_height"), (val_div, ":x", 10000), (val_div, ":y", 10000), (val_add, ":x", ":center_pos_x"), (val_add, ":y", ":center_pos_y"), (position_set_x, pos0, ":x"), (position_set_y, pos0, ":y"), (assign, ":scale_value", reg1), (convert_to_fixed_point, ":scale_value"), (store_mul, ":scale_value_inverse", ":scale_value", -1), (init_position, pos4), (position_set_x, pos4, ":scale_value"), (position_set_y, pos4, ":scale_value"), (position_set_z, pos4, ":scale_value"), (store_div, ":orientation", reg0, 256), #orientation flags (try_begin), (this_or_next|eq, ":orientation", 1), (eq, ":orientation", 3), (position_set_x, pos4, ":scale_value_inverse"), (try_end), (try_begin), (this_or_next|eq, ":orientation", 2), (eq, ":orientation", 3), (position_set_y, pos4, ":scale_value_inverse"), (try_end), (val_mod, reg0, 256), #remove orientation flags (cur_tableau_add_mesh_with_scale_and_vertex_color, reg0, pos0, pos4, 0, reg2), (try_end), (try_begin), (ge, ":num_charges", 2), (val_mul, reg4, ":charge_stretch"), (val_div, reg4, 10000), (position_get_x, ":x", pos1), (position_get_y, ":y", pos1), (val_mul, ":x", ":stretch_width"), (val_mul, ":y", ":stretch_height"), (val_div, ":x", 10000), (val_div, ":y", 10000), (val_add, ":x", ":center_pos_x"), (val_add, ":y", ":center_pos_y"), (position_set_x, pos1, ":x"), (position_set_y, pos1, ":y"), (assign, ":scale_value", reg4), (convert_to_fixed_point, ":scale_value"), (store_mul, ":scale_value_inverse", ":scale_value", -1), (init_position, pos4), (position_set_x, pos4, ":scale_value"), (position_set_y, pos4, ":scale_value"), (position_set_z, pos4, ":scale_value"), (store_div, ":orientation", reg3, 256), #orientation flags (try_begin), (this_or_next|eq, ":orientation", 1), (eq, ":orientation", 3), (position_set_x, pos4, ":scale_value_inverse"), (try_end), (try_begin), (this_or_next|eq, ":orientation", 2), (eq, ":orientation", 3), (position_set_y, pos4, ":scale_value_inverse"), (try_end), (val_mod, reg3, 256), #remove orientation flags (cur_tableau_add_mesh_with_scale_and_vertex_color, reg3, pos1, pos4, 0, reg5), (try_end), (try_begin), (ge, ":num_charges", 3), (val_mul, reg7, ":charge_stretch"), (val_div, reg7, 10000), (position_get_x, ":x", pos2), (position_get_y, ":y", pos2), (val_mul, ":x", ":stretch_width"), (val_mul, ":y", ":stretch_height"), (val_div, ":x", 10000), (val_div, ":y", 10000), (val_add, ":x", ":center_pos_x"), (val_add, ":y", ":center_pos_y"), (position_set_x, pos2, ":x"), (position_set_y, pos2, ":y"), (assign, ":scale_value", reg7), (convert_to_fixed_point, ":scale_value"), (store_mul, ":scale_value_inverse", ":scale_value", -1), (init_position, pos4), (position_set_x, pos4, ":scale_value"), (position_set_y, pos4, ":scale_value"), (position_set_z, pos4, ":scale_value"), (store_div, ":orientation", reg6, 256), #orientation flags (try_begin), (this_or_next|eq, ":orientation", 1), (eq, ":orientation", 3), (position_set_x, pos4, ":scale_value_inverse"), (try_end), (try_begin), (this_or_next|eq, ":orientation", 2), (eq, ":orientation", 3), (position_set_y, pos4, ":scale_value_inverse"), (try_end), (val_mod, reg6, 256), #remove orientation flags (cur_tableau_add_mesh_with_scale_and_vertex_color, reg6, pos2, pos4, 0, reg8), (try_end), (try_begin), (ge, ":num_charges", 4), (val_mul, reg10, ":charge_stretch"), (val_div, reg10, 10000), (position_get_x, ":x", pos3), (position_get_y, ":y", pos3), (val_mul, ":x", ":stretch_width"), (val_mul, ":y", ":stretch_height"), (val_div, ":x", 10000), (val_div, ":y", 10000), (val_add, ":x", ":center_pos_x"), (val_add, ":y", ":center_pos_y"), (position_set_x, pos3, ":x"), (position_set_y, pos3, ":y"), (assign, ":scale_value", reg10), (convert_to_fixed_point, ":scale_value"), (store_mul, ":scale_value_inverse", ":scale_value", -1), (init_position, pos4), (position_set_x, pos4, ":scale_value"), (position_set_y, pos4, ":scale_value"), (position_set_z, pos4, ":scale_value"), (store_div, ":orientation", reg9, 256), #orientation flags (try_begin), (this_or_next|eq, ":orientation", 1), (eq, ":orientation", 3), (position_set_x, pos4, ":scale_value_inverse"), (try_end), (try_begin), (this_or_next|eq, ":orientation", 2), (eq, ":orientation", 3), (position_set_y, pos4, ":scale_value_inverse"), (try_end), (val_mod, reg9, 256), #remove orientation flags (cur_tableau_add_mesh_with_scale_and_vertex_color, reg9, pos3, pos4, 0, reg11), (try_end), ]), # script_get_troop_custom_banner_num_positionings # Input: arg1 = troop_no # Output: reg0 = num_positionings ("get_troop_custom_banner_num_positionings", [ (store_script_param, ":troop_no", 1), (troop_get_slot, ":num_charges", ":troop_no", slot_troop_custom_banner_num_charges), (try_begin), (eq, ":num_charges", 1), (assign, ":num_positionings", 2), (else_try), (eq, ":num_charges", 2), (assign, ":num_positionings", 4), (else_try), (eq, ":num_charges", 3), (assign, ":num_positionings", 6), (else_try), (assign, ":num_positionings", 2), (try_end), (assign, reg0, ":num_positionings"), ]), # script_get_custom_banner_charge_type_position_scale_color # Input: arg1 = troop_no, arg2 = positioning_index # Output: reg0 = type_1 # reg1 = scale_1 # reg2 = color_1 # reg3 = type_2 # reg4 = scale_2 # reg5 = color_2 # reg6 = type_3 # reg7 = scale_3 # reg8 = color_3 # reg9 = type_4 # reg10 = scale_4 # reg11 = color_4 ("get_custom_banner_charge_type_position_scale_color",[ (store_script_param, ":troop_no", 1), (store_script_param, ":positioning", 2), (troop_get_slot, ":num_charges", ":troop_no", slot_troop_custom_banner_num_charges), (init_position, pos0), (init_position, pos1), (init_position, pos2), (init_position, pos3), (troop_get_slot, reg0, ":troop_no", slot_troop_custom_banner_charge_type_1), (val_add, reg0, custom_banner_charges_begin), (troop_get_slot, reg2, ":troop_no", slot_troop_custom_banner_charge_color_1), (troop_get_slot, reg3, ":troop_no", slot_troop_custom_banner_charge_type_2), (val_add, reg3, custom_banner_charges_begin), (troop_get_slot, reg5, ":troop_no", slot_troop_custom_banner_charge_color_2), (troop_get_slot, reg6, ":troop_no", slot_troop_custom_banner_charge_type_3), (val_add, reg6, custom_banner_charges_begin), (troop_get_slot, reg8, ":troop_no", slot_troop_custom_banner_charge_color_3), (troop_get_slot, reg9, ":troop_no", slot_troop_custom_banner_charge_type_4), (val_add, reg9, custom_banner_charges_begin), (troop_get_slot, reg11, ":troop_no", slot_troop_custom_banner_charge_color_4), (try_begin), (eq, ":num_charges", 1), (try_begin), (eq, ":positioning", 0), (assign, reg1, 100), (else_try), (assign, reg1, 50), (try_end), (else_try), (eq, ":num_charges", 2), (try_begin), (eq, ":positioning", 0), (position_set_y, pos0, 25), (position_set_y, pos1, -25), (assign, reg1, 40), (assign, reg4, 40), (else_try), (eq, ":positioning", 1), (position_set_x, pos0, -25), (position_set_x, pos1, 25), (assign, reg1, 40), (assign, reg4, 40), (else_try), (eq, ":positioning", 2), (position_set_x, pos0, -25), (position_set_y, pos0, 25), (position_set_x, pos1, 25), (position_set_y, pos1, -25), (assign, reg1, 50), (assign, reg4, 50), (else_try), (position_set_x, pos0, -25), (position_set_y, pos0, -25), (position_set_x, pos1, 25), (position_set_y, pos1, 25), (assign, reg1, 50), (assign, reg4, 50), (try_end), (else_try), (eq, ":num_charges", 3), (try_begin), (eq, ":positioning", 0), (position_set_y, pos0, 33), (position_set_y, pos2, -33), (assign, reg1, 30), (assign, reg4, 30), (assign, reg7, 30), (else_try), (eq, ":positioning", 1), (position_set_x, pos0, -33), (position_set_x, pos2, 33), (assign, reg1, 30), (assign, reg4, 30), (assign, reg7, 30), (else_try), (eq, ":positioning", 2), (position_set_x, pos0, -30), (position_set_y, pos0, 30), (position_set_x, pos2, 30), (position_set_y, pos2, -30), (assign, reg1, 35), (assign, reg4, 35), (assign, reg7, 35), (else_try), (eq, ":positioning", 3), (position_set_x, pos0, -30), (position_set_y, pos0, -30), (position_set_x, pos2, 30), (position_set_y, pos2, 30), (assign, reg1, 35), (assign, reg4, 35), (assign, reg7, 35), (else_try), (eq, ":positioning", 4), (position_set_x, pos0, -25), (position_set_y, pos0, -25), (position_set_y, pos1, 25), (position_set_x, pos2, 25), (position_set_y, pos2, -25), (assign, reg1, 50), (assign, reg4, 50), (assign, reg7, 50), (else_try), (position_set_x, pos0, -25), (position_set_y, pos0, 25), (position_set_y, pos1, -25), (position_set_x, pos2, 25), (position_set_y, pos2, 25), (assign, reg1, 50), (assign, reg4, 50), (assign, reg7, 50), (try_end), (else_try), (try_begin), (eq, ":positioning", 0), (position_set_x, pos0, -25), (position_set_y, pos0, 25), (position_set_x, pos1, 25), (position_set_y, pos1, 25), (position_set_x, pos2, -25), (position_set_y, pos2, -25), (position_set_x, pos3, 25), (position_set_y, pos3, -25), (assign, reg1, 50), (assign, reg4, 50), (assign, reg7, 50), (assign, reg10, 50), (else_try), (position_set_y, pos0, 30), (position_set_x, pos1, -30), (position_set_x, pos2, 30), (position_set_y, pos3, -30), (assign, reg1, 35), (assign, reg4, 35), (assign, reg7, 35), (assign, reg10, 35), (try_end), (try_end), ]), # script_get_random_custom_banner # Input: arg1 = troop_no ("get_random_custom_banner",[ (store_script_param, ":troop_no", 1), (store_random_in_range, ":num_charges", 1, 5), (troop_set_slot, ":troop_no", slot_troop_custom_banner_num_charges, ":num_charges"), (store_random_in_range, ":random_color_index", 0, 42), (call_script, "script_get_custom_banner_color_from_index", ":random_color_index"), (assign, ":color_1", reg0), (troop_set_slot, ":troop_no", slot_troop_custom_banner_bg_color_1, ":color_1"), (assign, ":end_cond", 1), (try_for_range, ":unused", 0, ":end_cond"), (store_random_in_range, ":random_color_index", 0, 42), (call_script, "script_get_custom_banner_color_from_index", ":random_color_index"), (assign, ":color_2", reg0), (try_begin), (call_script, "script_cf_check_color_visibility", ":color_1", ":color_2"), (troop_set_slot, ":troop_no", slot_troop_custom_banner_bg_color_2, ":color_2"), (else_try), (val_add, ":end_cond", 1), (try_end), (try_end), (assign, ":end_cond", 4), (assign, ":cur_charge", 0), (try_for_range, ":unused", 0, ":end_cond"), (store_random_in_range, ":random_color_index", 0, 42), (call_script, "script_get_custom_banner_color_from_index", ":random_color_index"), (assign, ":charge_color", reg0), (try_begin), (call_script, "script_cf_check_color_visibility", ":charge_color", ":color_1"), (call_script, "script_cf_check_color_visibility", ":charge_color", ":color_2"), (store_add, ":cur_slot", ":cur_charge", slot_troop_custom_banner_charge_color_1), (troop_set_slot, ":troop_no", ":cur_slot", ":charge_color"), (store_random_in_range, ":random_charge", custom_banner_charges_begin, custom_banner_charges_end), (val_sub, ":random_charge", custom_banner_charges_begin), (store_add, ":cur_slot", ":cur_charge", slot_troop_custom_banner_charge_type_1), (troop_set_slot, ":troop_no", ":cur_slot", ":random_charge"), (val_add, ":cur_charge", 1), (else_try), (val_add, ":end_cond", 1), (try_end), (try_end), (store_random_in_range, ":random_bg", custom_banner_backgrounds_begin, custom_banner_backgrounds_end), (val_sub, ":random_bg", custom_banner_backgrounds_begin), (troop_set_slot, ":troop_no", slot_troop_custom_banner_bg_type, ":random_bg"), (store_random_in_range, ":random_flag", custom_banner_flag_types_begin, custom_banner_flag_types_end), (val_sub, ":random_flag", custom_banner_flag_types_begin), (troop_set_slot, ":troop_no", slot_troop_custom_banner_flag_type, ":random_flag"), (store_random_in_range, ":random_positioning", 0, 4), (troop_set_slot, ":troop_no", slot_troop_custom_banner_positioning, ":random_positioning"), ]), # script_get_custom_banner_color_from_index # Input: arg1 = color_index # Output: reg0 = color ("get_custom_banner_color_from_index",[ (store_script_param, ":color_index", 1), (assign, ":cur_color", 0xFF000000), (assign, ":red", 0x00),(assign, ":green", 0x00),(assign, ":blue", 0x00), (store_mod, ":mod_i_color", ":color_index", 7), (try_begin),(eq, ":mod_i_color", 0), (assign, ":blue", 0xFF), (else_try) ,(eq, ":mod_i_color", 1),(assign, ":red", 0xEE), (else_try) ,(eq, ":mod_i_color", 2),(assign, ":red", 0xFB),(assign, ":green", 0xAC), (else_try) ,(eq, ":mod_i_color", 3),(assign, ":red", 0x5F), (assign, ":blue", 0xFF), (else_try) ,(eq, ":mod_i_color", 4),(assign, ":red", 0x05),(assign, ":green", 0x44), (else_try) ,(eq, ":mod_i_color", 5),(assign, ":red", 0xEE),(assign, ":green", 0xEE),(assign, ":blue", 0xEE), (else_try) , (assign, ":red", 0x22),(assign, ":green", 0x22),(assign, ":blue", 0x22), (try_end), (store_div, ":cur_tone", ":color_index", 7), (store_sub, ":cur_tone", 8, ":cur_tone"), (val_mul, ":red" , ":cur_tone"),(val_div, ":red" , 8), (val_mul, ":green", ":cur_tone"),(val_div, ":green", 8), (val_mul, ":blue" , ":cur_tone"),(val_div, ":blue" , 8), (val_mul, ":green", 0x100), (val_mul, ":red", 0x10000), (val_add, ":cur_color", ":blue"), (val_add, ":cur_color", ":green"), (val_add, ":cur_color", ":red"), (assign, reg0, ":cur_color"), ]), # script_cf_check_color_visibility # Input: arg1 = color_1, arg2 = color_2 ("cf_check_color_visibility",[ (store_script_param, ":color_1", 1), (store_script_param, ":color_2", 2), (store_mod, ":blue_1", ":color_1", 256), (store_div, ":green_1", ":color_1", 256), (val_mod, ":green_1", 256), (store_div, ":red_1", ":color_1", 256 * 256), (val_mod, ":red_1", 256), (store_mod, ":blue_2", ":color_2", 256), (store_div, ":green_2", ":color_2", 256), (val_mod, ":green_2", 256), (store_div, ":red_2", ":color_2", 256 * 256), (val_mod, ":red_2", 256), (store_sub, ":red_dif", ":red_1", ":red_2"), (val_abs, ":red_dif"), (store_sub, ":green_dif", ":green_1", ":green_2"), (val_abs, ":green_dif"), (store_sub, ":blue_dif", ":blue_1", ":blue_2"), (val_abs, ":blue_dif"), (assign, ":max_dif", 0), (val_max, ":max_dif", ":red_dif"), (val_max, ":max_dif", ":green_dif"), (val_max, ":max_dif", ":blue_dif"), (ge, ":max_dif", 64), ]), # script_get_next_active_kingdom # Input: arg1 = faction_no # Output: reg0 = faction_no (does not choose player faction) ("get_next_active_kingdom",[ (store_script_param, ":faction_no", 1), (assign, ":end_cond", kingdoms_end), (try_for_range, ":unused", kingdoms_begin, ":end_cond"), (val_add, ":faction_no", 1), (try_begin), (ge, ":faction_no", kingdoms_end), (assign, ":faction_no", kingdoms_begin), (try_end), (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active), (neq, ":faction_no", "fac_player_supporters_faction"), (assign, ":end_cond", 0), (try_end), (assign, reg0, ":faction_no"), ]), # script_store_average_center_value_per_faction # Output: sets $g_average_center_value_per_faction ("store_average_center_value_per_faction",[ (store_sub, ":num_towns", centers_end, centers_begin), (assign, ":num_factions", 0), (try_for_range, ":faction_no", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":faction_no", slot_faction_state, sfs_active), (val_add, ":num_factions", 1), (try_end), (val_max, ":num_factions", 1), (store_mul, "$g_average_center_value_per_faction", ":num_towns", 2), (val_mul, "$g_average_center_value_per_faction", 10), (val_div, "$g_average_center_value_per_faction", ":num_factions"), ]), # script_remove_cattles_if_herd_is_close_to_party #InVain: Not used in TLD # Input: arg1 = party_no, arg2 = maximum_number_of_cattles_required # Output: reg0 = number_of_cattles_removed ("remove_cattles_if_herd_is_close_to_party", [ (store_script_param, ":party_no", 1), (store_script_param, ":max_req", 2), (assign, ":cur_req", ":max_req"), (try_for_parties, ":cur_party"), (gt, ":cur_req", 0), (party_slot_eq, ":cur_party", slot_party_type, spt_cattle_herd), (store_distance_to_party_from_party, ":dist", ":cur_party", ":party_no"), (lt, ":dist", 3), #Do not use the quest herd (assign, ":subcontinue", 1), (try_begin), (check_quest_active, "qst_move_cattle_herd"), (quest_slot_eq, "qst_move_cattle_herd", slot_quest_target_party, ":cur_party"), (assign, ":subcontinue", 0), (try_end), (eq, ":subcontinue", 1), (party_count_companions_of_type, ":num_cattle", ":cur_party", "trp_cattle"), (try_begin), (le, ":num_cattle", ":cur_req"), (assign, ":num_added", ":num_cattle"), (call_script, "script_safe_remove_party", ":cur_party"), (else_try), (assign, ":num_added", ":cur_req"), (party_remove_members, ":cur_party", "trp_cattle", ":cur_req"), (try_end), (val_sub, ":cur_req", ":num_added"), (try_begin), (party_slot_eq, ":party_no", slot_party_type, spt_village), (party_get_slot, ":village_cattle_amount", ":party_no", slot_village_number_of_cattle), (val_add, ":village_cattle_amount", ":num_added"), (party_set_slot, ":party_no", slot_village_number_of_cattle, ":village_cattle_amount"), (try_end), (assign, reg3, ":num_added"), (str_store_party_name_link, s1, ":party_no"), (display_message, "@You brought {reg3} heads of cattle to {s1}."), (try_end), (store_sub, reg0, ":max_req", ":cur_req"), ]), ("lord_comment_to_s43",[ (store_script_param, ":lord", 1), (store_script_param, ":default_string", 2), (troop_get_slot,":reputation", ":lord", slot_lord_reputation_type), (val_add,":reputation", ":default_string"), (str_store_string,43,":reputation"), ]), #Troop Commentaries begin # script_add_log_entry # Input: arg1 = entry_type, arg2 = event_actor, arg3 = center_object, arg4 = troop_object, arg5 = faction_object # Output: none ("add_log_entry",[ (store_script_param, ":entry_type", 1), (store_script_param, ":actor", 2), (store_script_param, ":center_object", 3), (store_script_param, ":troop_object", 4), (store_script_param, ":faction_object", 5), (assign, ":center_object_lord", -1), (assign, ":center_object_faction", -1), (assign, ":troop_object_faction", -1), (try_begin), (gt, ":center_object", 0), (party_get_slot, ":center_object_lord", ":center_object", slot_town_lord), (store_faction_of_party, ":center_object_faction", ":center_object"), (try_end), (try_begin), (ge, ":troop_object", 0), (store_troop_faction, ":troop_object_faction", ":troop_object"), (try_end), (val_add, "$num_log_entries", 1), (store_current_hours, ":entry_time"), (troop_set_slot, "trp_log_array_entry_type", "$num_log_entries", ":entry_type"), (troop_set_slot, "trp_log_array_entry_time", "$num_log_entries", ":entry_time"), (troop_set_slot, "trp_log_array_actor", "$num_log_entries", ":actor"), (troop_set_slot, "trp_log_array_center_object", "$num_log_entries", ":center_object"), (troop_set_slot, "trp_log_array_center_object_lord", "$num_log_entries", ":center_object_lord"), (troop_set_slot, "trp_log_array_center_object_faction", "$num_log_entries", ":center_object_faction"), (troop_set_slot, "trp_log_array_troop_object", "$num_log_entries", ":troop_object"), (troop_set_slot, "trp_log_array_troop_object_faction", "$num_log_entries", ":troop_object_faction"), (troop_set_slot, "trp_log_array_faction_object", "$num_log_entries", ":faction_object"), (try_begin), (eq, "$cheat_mode", 1), (assign, reg3, "$num_log_entries"), (assign, reg4, ":entry_type"), (display_message, "@Log entry {reg3}: type {reg4}"), (try_begin), (gt, ":center_object", 0), (str_store_party_name, s4, ":center_object"), (display_message, "@Center: {s4}"), (try_end), (try_begin), (gt, ":troop_object", 0), (str_store_troop_name, s4, ":troop_object"), (display_message, "@Troop: {s4}"), (try_end), (try_begin), (gt, ":center_object_lord", 0), (str_store_troop_name, s4, ":center_object_lord"), (display_message, "@Lord: {s4}"), (try_end), (try_end), (try_begin), (this_or_next|gt, "$g_ally_party", 0), (eq, ":entry_type", logent_player_participated_in_siege), (try_begin), (eq, "$cheat_mode", 1), (display_message, "@Ally party is present"), (try_end), (try_for_range, ":hero", kingdom_heroes_begin, kingdom_heroes_end), (party_count_companions_of_type, ":hero_present", "p_collective_friends", ":hero"), (gt, ":hero_present", 0), (troop_set_slot, ":hero", slot_troop_present_at_event, "$num_log_entries"), # (store_sub, ":skip_up_to_here", "$num_log_entries", 1), # (troop_set_slot, ":hero", slot_troop_last_comment_slot, ":skip_up_to_here"), (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, 4, ":hero"), (display_message, "@{s4} is present at event"), (try_end), (try_end), (try_end), ]), # script_get_relevant_comment_for_log_entry # Input: arg1 = log_entry_no, # Output: reg0 = comment_id; reg1 = relevance # Notes: 50 is the default relevance. # A comment with relevance less than 30 will always be skipped. # A comment with relevance 75 or more will never be skipped. # A comment with relevance 50 has about 50% chance to be skipped. # If there is more than one comment that is not skipped, the system will randomize their relevance values, and then choose the highest one. # Also note that the relevance of events decreases as time passes. After three months, relevance reduces to 50%, after 6 months, 25%, etc... ("get_relevant_comment_for_log_entry", #TLD not sure if used in TLD, just took out all non-TLD strings [(store_script_param, ":log_entry_no", 1), (troop_get_slot, ":entry_type", "trp_log_array_entry_type", ":log_entry_no"), (troop_get_slot, ":entry_time", "trp_log_array_entry_time", ":log_entry_no"), #(troop_get_slot, ":actor", "trp_log_array_actor", ":log_entry_no"), ## (troop_get_slot, ":center_object", "trp_log_array_center_object", ":log_entry_no"), #(troop_get_slot, ":center_object_lord", "trp_log_array_center_object_lord", ":log_entry_no"), (troop_get_slot, ":center_object_faction", "trp_log_array_center_object_faction", ":log_entry_no"), (troop_get_slot, ":troop_object", "trp_log_array_troop_object", ":log_entry_no"), (troop_get_slot, ":troop_object_faction", "trp_log_array_troop_object_faction", ":log_entry_no"), (troop_get_slot, ":faction_object", "trp_log_array_faction_object", ":log_entry_no"), (assign, ":relevance", 0), (assign, ":comment", -1), (assign, ":suggested_relation_change", 0), (troop_get_slot, ":reputation", "$g_talk_troop", slot_lord_reputation_type), (store_current_hours, ":current_time"), (store_sub, ":entry_hours_elapsed", ":current_time", ":entry_time"), #Post 0907 changes begin (assign, ":players_kingdom_relation", 0), ##the below is so that lords will not congratulate player on attacking neutrals (try_begin), (eq, "$cheat_mode", 1), (try_begin), (assign, reg5, ":log_entry_no"), (assign, reg6, ":entry_type"), (assign, reg8, ":entry_time"), (gt, "$players_kingdom", 0), (try_begin), (gt, ":troop_object_faction", 0), (store_relation, ":players_kingdom_relation", "$players_kingdom", ":troop_object_faction"), (assign, reg7, ":players_kingdom_relation"), (display_message, "@Event #{reg5}, type {reg6}, time {reg8}: player's kingdom relation to troop object = {reg7}"), (else_try), (gt, ":center_object_faction", 0), (store_relation, ":players_kingdom_relation", "$players_kingdom", ":center_object_faction"), (assign, reg7, ":players_kingdom_relation"), (display_message, "@Event #{reg5}, type {reg6}, time {reg8}: player's kingdom relation to center object faction = {reg7}"), (else_try), (gt, ":faction_object", 0), (store_relation, ":players_kingdom_relation", "$players_kingdom", ":faction_object"), (assign, reg7, ":players_kingdom_relation"), (display_message, "@Event #{reg5}, type {reg6}, time {reg8}: player's kingdom relation to faction object = {reg7}"), (else_try), (display_message, "@Event #{reg5}, type {reg6}, time {reg8}. No relevant kingdom relation"), (try_end), (else_try), (display_message, "@Event #{reg5}, type {reg6}, time {reg8}. Player unaffiliated"), (try_end), (try_end), (try_begin), (eq, ":entry_type", logent_game_start), (eq, "$g_talk_troop_met", 0), (is_between, "$g_talk_troop_faction_relation", -5, 5), (is_between, "$g_talk_troop_relation", -5, 5), (assign, ":relevance", 25), #normal_banner_begin #(troop_get_slot, ":banner", "trp_player", slot_troop_banner_scene_prop), #custom_banner_begin # (troop_get_slot, ":banner", "trp_player", slot_troop_custom_banner_flag_type), # (store_random_in_range, ":renown_check", 100, 200), # (try_begin), # (eq, ":reputation", lrep_none), # (gt, "$players_kingdom", 0), # (assign, ":comment", "str_comment_intro_liege_affiliated"), # # (else_try), # # (gt, ":plyr_renown", ":renown_check"), # # (assign, ":comment", "str_comment_intro_famous_liege"), # # (val_add, ":comment", ":reputation"), # (else_try), # #normal_banner_begin # (gt, ":banner", 0), # #custom_banner_begin # # (ge, ":banner", 0), # (assign, ":comment", "str_comment_intro_noble_liege"), # (val_add, ":comment", ":reputation"), # (else_try), # (assign, ":comment", "str_comment_intro_common_liege"), # (val_add, ":comment", ":reputation"), # (try_end), #Post 0907 changes end # (else_try), # (eq, ":entry_type", logent_village_raided), # (eq, ":actor", "trp_player"), # (try_begin), # (eq, ":center_object_lord", "$g_talk_troop"), # (assign, ":relevance", 200), # (assign, ":suggested_relation_change", -1), # (assign, ":comment", "str_comment_you_raided_my_village_default"), # (try_begin), # (lt, "$g_talk_troop_faction_relation", -5), # (this_or_next|eq, ":reputation", lrep_goodnatured), # (eq, ":reputation", lrep_upstanding), # (assign, ":comment", "str_comment_you_raided_my_village_enemy_benevolent"), # (else_try), # (lt, "$g_talk_troop_faction_relation", -5), # (this_or_next|eq, ":reputation", lrep_cunning), # (eq, ":reputation", lrep_selfrighteous), # (assign, ":comment", "str_comment_you_raided_my_village_enemy_coldblooded"), # (else_try), # (lt, "$g_talk_troop_faction_relation", -5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_raided_my_village_enemy_spiteful"), # (else_try), # (lt, "$g_talk_troop_faction_relation", -5), # (assign, ":comment", "str_comment_you_raided_my_village_enemy"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_raided_my_village_unfriendly_spiteful"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_you_raided_my_village_friendly"), # (try_end), # (try_end), # (else_try), # (eq, ":entry_type", logent_village_extorted), # (eq, ":actor", "trp_player"), # (try_begin), # (eq, ":center_object_lord", "$g_talk_troop"), # (assign, ":relevance", 30), # (assign, ":suggested_relation_change", -1), # (assign, ":comment", "str_comment_you_robbed_my_village_default"), # (try_begin), # (lt, "$g_talk_troop_faction_relation", -5), # (this_or_next|eq, ":reputation", lrep_cunning), # (eq, ":reputation", lrep_selfrighteous), # (assign, ":comment", "str_comment_you_robbed_my_village_enemy_coldblooded"), # (else_try), # (lt, "$g_talk_troop_faction_relation", -5), # (assign, ":comment", "str_comment_you_robbed_my_village_enemy"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_robbed_my_village_friendly_spiteful"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_you_robbed_my_village_friendly"), # (try_end), # (try_end), # (else_try), # (eq, ":entry_type", logent_caravan_accosted), # (eq, ":actor", "trp_player"), # (eq, ":faction_object", "$g_talk_troop_faction"), # (faction_slot_eq, "$g_talk_troop_faction", slot_faction_leader, "$g_talk_troop"), # (assign, ":relevance", 30), # (assign, ":suggested_relation_change", -1), # (assign, ":comment", "str_comment_you_accosted_my_caravan_default"), # (try_begin), # (lt, "$g_talk_troop_faction_relation", -5), # (assign, ":comment", "str_comment_you_accosted_my_caravan_enemy"), # (try_end), # (else_try), # (eq, ":entry_type", logent_helped_peasants), # (eq, ":actor", "trp_player"), # (try_begin), # (eq, ":center_object_lord", "$g_talk_troop"), # (assign, ":relevance", 40), # (assign, ":suggested_relation_change", 0), # (try_begin), # (this_or_next|eq, ":reputation", lrep_goodnatured), # (eq, ":reputation", lrep_upstanding), # (assign, ":comment", "str_comment_you_helped_villagers_benevolent"), # (assign, ":suggested_relation_change", 1), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_helped_villagers_friendly_cruel"), # (assign, ":suggested_relation_change", -1), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_helped_villagers_unfriendly_spiteful"), # (assign, ":suggested_relation_change", -1), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_you_helped_villagers_friendly"), # (else_try), # (this_or_next|eq, ":reputation", lrep_selfrighteous), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_helped_villagers_cruel"), # (assign, ":suggested_relation_change", -1), # (else_try), # (assign, ":comment", "str_comment_you_helped_villagers_default"), # (try_end), # (try_end), # ###Combat events # (else_try), # (eq, ":entry_type", logent_castle_captured_by_player), # (try_begin), # (eq, ":center_object_lord", "$g_talk_troop"), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_captured_my_castle_enemy_spiteful"), # (assign, ":relevance", 200), # (else_try), # (eq, ":center_object_lord", "$g_talk_troop"), # (this_or_next|eq, ":reputation", lrep_martial), # (eq, ":reputation", lrep_goodnatured), # (assign, ":comment", "str_comment_you_captured_my_castle_enemy_chivalrous"), # (assign, ":relevance", 200), # (else_try), # (eq, ":center_object_lord", "$g_talk_troop"), # (assign, ":comment", "str_comment_you_captured_my_castle_enemy"), # (assign, ":relevance", 200), # (else_try), # (eq, "$players_kingdom", "$g_talk_troop_faction"), # (lt, ":players_kingdom_relation", 0), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_captured_a_castle_allied_spiteful"), # (assign, ":relevance", 75), # (else_try), # (eq, "$players_kingdom", "$g_talk_troop_faction"), # (lt, ":players_kingdom_relation", 0), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_you_captured_a_castle_allied_friendly"), # (assign, ":relevance", 75), # (else_try), # (eq, "$players_kingdom", "$g_talk_troop_faction"), # (lt, ":players_kingdom_relation", 0), # (lt, "$g_talk_troop_relation", -5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_captured_a_castle_allied_unfriendly_spiteful"), # (assign, ":relevance", 75), # (else_try), # (eq, "$players_kingdom", "$g_talk_troop_faction"), # (lt, ":players_kingdom_relation", 0), # (lt, "$g_talk_troop_relation", -5), # (assign, ":comment", "str_comment_you_captured_a_castle_allied_unfriendly"), # (assign, ":relevance", 75), # (else_try), # (eq, "$players_kingdom", "$g_talk_troop_faction"), # (lt, ":players_kingdom_relation", 0), # (assign, ":comment", "str_comment_you_captured_a_castle_allied"), # (assign, ":relevance", 75), # (try_end), #Post 0907 changes begin (else_try), (this_or_next|eq, ":entry_type", logent_lord_defeated_by_player), (eq, ":entry_type", logent_lord_helped_by_player), (troop_slot_eq, "$g_talk_troop", slot_troop_present_at_event, ":log_entry_no"), (try_begin), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_defeated_a_lord_unfriendly_spiteful"), (assign, ":relevance", 150), (else_try), (lt, "$g_talk_troop_relation", -5), (assign, ":comment", "str_comment_we_defeated_a_lord_unfriendly"), (assign, ":relevance", 150), (else_try), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_defeated_a_lord_cruel"), (assign, ":relevance", 150), (else_try), (eq, ":reputation", lrep_quarrelsome), (assign, ":comment", "str_comment_we_defeated_a_lord_cruel"), (assign, ":relevance", 150), (else_try), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_we_defeated_a_lord_upstanding"), (assign, ":relevance", 150), (else_try), (assign, ":comment", "str_comment_we_defeated_a_lord_default"), (assign, ":relevance", 150), (try_end), (else_try), (this_or_next|eq, ":entry_type", logent_castle_captured_by_player), (eq, ":entry_type", logent_player_participated_in_siege), (troop_slot_eq, "$g_talk_troop", slot_troop_present_at_event, ":log_entry_no"), (try_begin), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_fought_in_siege_unfriendly_spiteful"), (assign, ":relevance", 150), (else_try), (lt, "$g_talk_troop_relation", -5), (assign, ":comment", "str_comment_we_fought_in_siege_unfriendly"), (assign, ":relevance", 150), (else_try), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_fought_in_siege_cruel"), (assign, ":relevance", 150), (else_try), (eq, ":reputation", lrep_quarrelsome), (assign, ":comment", "str_comment_we_fought_in_siege_quarrelsome"), (assign, ":relevance", 150), (else_try), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_we_fought_in_siege_upstanding"), (assign, ":relevance", 150), (else_try), (assign, ":comment", "str_comment_we_fought_in_siege_default"), (assign, ":relevance", 150), (try_end), (else_try), (eq, ":entry_type", logent_player_participated_in_major_battle), (troop_slot_eq, "$g_talk_troop", slot_troop_present_at_event, ":log_entry_no"), (try_begin), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_fought_in_major_battle_unfriendly_spiteful"), (assign, ":relevance", 150), (else_try), (lt, "$g_talk_troop_relation", -5), (assign, ":comment", "str_comment_we_fought_in_major_battle_unfriendly"), (assign, ":relevance", 150), (else_try), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_fought_in_major_battle_cruel"), (assign, ":relevance", 150), (else_try), (eq, ":reputation", lrep_quarrelsome), (assign, ":comment", "str_comment_we_fought_in_major_battle_cruel"), (assign, ":relevance", 150), (else_try), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_we_fought_in_major_battle_upstanding"), (assign, ":relevance", 150), (else_try), (assign, ":comment", "str_comment_we_fought_in_major_battle_default"), (assign, ":relevance", 150), (try_end), (else_try), (eq, ":entry_type", logent_lord_defeated_by_player), (try_begin), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_goodnatured), (assign, ":comment", "str_comment_you_defeated_me_enemy_chivalrous"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_debauched), (eq, ":reputation", lrep_quarrelsome), (assign, ":comment", "str_comment_you_defeated_me_enemy_spiteful"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (assign, ":comment", "str_comment_you_defeated_me_enemy"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_upstanding), (eq, ":reputation", lrep_cunning), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy_pragmatic"), (assign, ":relevance", 85), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_goodnatured), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy_chivalrous"), (assign, ":relevance", 85), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy_spiteful"), (assign, ":relevance", 85), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy"), (assign, ":relevance", 85), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (faction_slot_eq, "$players_kingdom", slot_faction_leader, "$g_talk_troop"), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_liege"), (assign, ":relevance", 70), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_unfriendly_spiteful"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_spiteful"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_upstanding), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_unfriendly_chivalrous"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (assign, ":comment", "str_comment_you_defeated_a_lord_allied"), (assign, ":relevance", 65), (try_end), (else_try), (eq, ":entry_type", logent_lord_defeated_by_player), (try_begin), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_goodnatured), (assign, ":comment", "str_comment_you_defeated_me_enemy_chivalrous"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_debauched), (eq, ":reputation", lrep_quarrelsome), (assign, ":comment", "str_comment_you_defeated_me_enemy_spiteful"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (assign, ":comment", "str_comment_you_defeated_me_enemy"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_upstanding), (eq, ":reputation", lrep_cunning), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy_pragmatic"), (assign, ":relevance", 85), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_goodnatured), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy_chivalrous"), (assign, ":relevance", 85), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy_spiteful"), (assign, ":relevance", 85), (else_try), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (assign, ":comment", "str_comment_you_defeated_my_friend_enemy"), (assign, ":relevance", 85), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (faction_slot_eq, "$players_kingdom", slot_faction_leader, "$g_talk_troop"), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_liege"), (assign, ":relevance", 70), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_unfriendly_spiteful"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_spiteful"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_upstanding), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_you_defeated_a_lord_allied_unfriendly_chivalrous"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (assign, ":comment", "str_comment_you_defeated_a_lord_allied"), (assign, ":relevance", 65), (try_end), (else_try), (eq, ":entry_type", logent_lord_helped_by_player), (neq, ":troop_object", "$g_talk_troop"), (eq, ":troop_object_faction", "$g_talk_troop_faction"), (try_begin), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_upstanding), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_you_helped_my_ally_unfriendly_chivalrous"), (assign, ":relevance", 65), (assign, ":suggested_relation_change", 2), (else_try), (lt, "$g_talk_troop_relation", -5), (assign, ":comment", "str_comment_you_helped_my_ally_unfriendly"), (assign, ":relevance", 0), (else_try), (eq, ":reputation", lrep_none), (assign, ":comment", "str_comment_you_helped_my_ally_liege"), (assign, ":relevance", 65), (assign, ":suggested_relation_change", 3), (else_try), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_helped_my_ally_unfriendly_spiteful"), (assign, ":relevance", 65), (else_try), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_helped_my_ally_spiteful"), (assign, ":relevance", 65), (else_try), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_you_helped_my_ally_chivalrous"), (assign, ":relevance", 65), (assign, ":suggested_relation_change", 2), (else_try), (eq, ":troop_object", "$g_talk_troop"), (assign, ":comment", "str_comment_you_helped_my_ally_default"), (try_end), (else_try), (eq, ":entry_type", logent_player_defeated_by_lord), (troop_slot_eq, "$g_talk_troop", slot_troop_present_at_event, ":log_entry_no"), (try_begin), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_were_defeated_unfriendly_spiteful"), (assign, ":relevance", 150), (else_try), (lt, "$g_talk_troop_relation", -5), (assign, ":comment", "str_comment_we_were_defeated_unfriendly"), (assign, ":relevance", 150), (else_try), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_we_were_defeated_cruel"), (assign, ":relevance", 150), (else_try), (assign, ":comment", "str_comment_we_were_defeated_default"), (assign, ":relevance", 150), (try_end), (else_try), (eq, ":entry_type", logent_player_defeated_by_lord), (try_begin), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_I_defeated_you_enemy_spiteful"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_I_defeated_you_enemy_chivalrous"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_goodnatured), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_I_defeated_you_enemy_benevolent"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_cunning), (assign, ":comment", "str_comment_I_defeated_you_enemy_coldblooded"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (assign, ":comment", "str_comment_I_defeated_you_enemy"), (assign, ":relevance", 200), (else_try), (eq, ":troop_object", "$g_talk_troop"), (assign, ":comment", "str_comment_I_defeated_you_enemy"), (assign, ":relevance", 200), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (gt, "$g_talk_troop_relation", 5), (assign, ":comment", "str_comment_you_were_defeated_allied_friendly_spiteful"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_debauched), (lt, "$g_talk_troop_relation", -5), (assign, ":comment", "str_comment_you_were_defeated_allied_unfriendly_cruel"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (le, "$g_talk_troop_relation", 5), (assign, ":comment", "str_comment_you_were_defeated_allied_spiteful"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (eq, ":reputation", lrep_selfrighteous), (assign, ":comment", "str_comment_you_were_defeated_allied_pitiless"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (eq, ":reputation", lrep_upstanding), (lt, "$g_talk_troop_relation", -15), (assign, ":comment", "str_comment_you_were_defeated_allied_unfriendly_upstanding"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, "$g_talk_troop_relation", -10), (assign, ":comment", "str_comment_you_were_defeated_allied_unfriendly"), (assign, ":relevance", 65), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (assign, ":comment", "str_comment_you_were_defeated_allied"), (assign, ":relevance", 65), (try_end), (else_try), (eq, ":entry_type", logent_player_retreated_from_lord), (troop_slot_eq, "$g_talk_troop", slot_troop_present_at_event, ":log_entry_no"), (try_begin), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_abandoned_us_unfriendly_spiteful"), (assign, ":relevance", 150), (assign, ":suggested_relation_change", -5), (else_try), (lt, "$g_talk_troop_relation", -5), (eq, ":reputation", lrep_selfrighteous), (assign, ":comment", "str_comment_you_abandoned_us_unfriendly_pitiless"), (assign, ":relevance", 150), (assign, ":suggested_relation_change", -5), (else_try), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_abandoned_us_spiteful"), (assign, ":suggested_relation_change", -5), (else_try), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_you_abandoned_us_chivalrous"), (assign, ":relevance", 150), (assign, ":suggested_relation_change", -2), (else_try), (this_or_next|eq, ":reputation", lrep_upstanding), (eq, ":reputation", lrep_goodnatured), (assign, ":comment", "str_comment_you_abandoned_us_benefitofdoubt"), (assign, ":relevance", 150), (assign, ":suggested_relation_change", -1), (else_try), (assign, ":comment", "str_comment_you_abandoned_us_default"), (assign, ":relevance", 150), (assign, ":suggested_relation_change", -2), (try_end), (else_try), (this_or_next|eq, ":entry_type", logent_player_retreated_from_lord), (eq, ":entry_type", logent_player_retreated_from_lord_cowardly), (eq, ":troop_object", "$g_talk_troop"), (try_begin), (eq, "$cheat_mode", 1), (assign, reg7, ":entry_hours_elapsed"), (display_message, "@Elapsed hours: {reg7}"), (try_end), (gt, ":entry_hours_elapsed", 2), (try_begin), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_ran_from_me_enemy_spiteful"), (assign, ":relevance", 25), (else_try), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_you_ran_from_me_enemy_chivalrous"), (assign, ":relevance", 25), (else_try), (this_or_next|eq, ":reputation", lrep_goodnatured), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_you_ran_from_me_enemy_benevolent"), (assign, ":relevance", 25), (else_try), (eq, ":reputation", lrep_cunning), (assign, ":comment", "str_comment_you_ran_from_me_enemy_coldblooded"), (assign, ":relevance", 25), (else_try), (assign, ":comment", "str_comment_you_ran_from_me_enemy"), (assign, ":relevance", 25), (try_end), (else_try), (eq, ":entry_type", logent_player_retreated_from_lord_cowardly), (try_begin), (eq, "$players_kingdom", "$g_talk_troop_faction"), (neq, ":troop_object", "$g_talk_troop"), (lt, "$g_talk_troop_relation", 5), (eq, ":reputation", lrep_martial), (assign, ":comment", "str_comment_you_ran_from_foe_allied_chivalrous"), (assign, ":relevance", 80), (assign, ":suggested_relation_change", -3), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (neq, ":troop_object", "$g_talk_troop"), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_you_ran_from_foe_allied_upstanding"), (assign, ":relevance", 80), (assign, ":suggested_relation_change", -1), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (neq, ":troop_object", "$g_talk_troop"), (lt, "$g_talk_troop_relation", 5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_ran_from_foe_allied_spiteful"), (assign, ":relevance", 80), (try_end), (else_try), (eq, ":entry_type", logent_lord_defeated_but_let_go_by_player), (try_begin), (eq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_let_me_go_spiteful"), (assign, ":relevance", 300), (assign, ":suggested_relation_change", -15), (else_try), (eq, ":troop_object", "$g_talk_troop"), (ge, "$g_talk_troop_faction_relation", 0), (assign, ":comment", "str_comment_you_let_me_go_default"), (assign, ":relevance", 300), (assign, ":suggested_relation_change", 2), (else_try), (eq, ":troop_object", "$g_talk_troop"), (lt, "$g_talk_troop_faction_relation", 0), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_upstanding), (assign, ":suggested_relation_change", 5), (assign, ":relevance", 300), (assign, ":comment", "str_comment_you_let_me_go_enemy_chivalrous"), (else_try), (eq, ":troop_object", "$g_talk_troop"), (lt, "$g_talk_troop_faction_relation", 0), (this_or_next|eq, ":reputation", lrep_selfrighteous), (eq, ":reputation", lrep_cunning), (assign, ":relevance", 300), (assign, ":comment", "str_comment_you_let_me_go_enemy_coldblooded"), (else_try), (eq, ":troop_object", "$g_talk_troop"), (lt, "$g_talk_troop_faction_relation", 0), (assign, ":relevance", 300), (assign, ":comment", "str_comment_you_let_me_go_enemy"), (assign, ":suggested_relation_change", 1), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (neq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_martial), (eq, ":reputation", lrep_goodnatured), (assign, ":comment", "str_comment_you_let_go_a_lord_allied_chivalrous"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (neq, ":troop_object", "$g_talk_troop"), (eq, ":reputation", lrep_upstanding), (assign, ":comment", "str_comment_you_let_go_a_lord_allied_upstanding"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (neq, ":troop_object", "$g_talk_troop"), (this_or_next|eq, ":reputation", lrep_cunning), (eq, ":reputation", lrep_selfrighteous), (assign, ":comment", "str_comment_you_let_go_a_lord_allied_coldblooded"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (neq, ":troop_object", "$g_talk_troop"), (lt, "$g_talk_troop_relation", -5), (this_or_next|eq, ":reputation", lrep_quarrelsome), (eq, ":reputation", lrep_debauched), (assign, ":comment", "str_comment_you_let_go_a_lord_allied_unfriendly_spiteful"), (assign, ":relevance", 80), (else_try), (eq, "$players_kingdom", "$g_talk_troop_faction"), (lt, ":players_kingdom_relation", 0), (neq, ":troop_object", "$g_talk_troop"), (assign, ":comment", "str_comment_you_let_go_a_lord_allied"), (assign, ":relevance", 80), (try_end), #Internal faction relations # (else_try), # (eq, ":entry_type", logent_pledged_allegiance), # (eq, ":actor", "trp_player"), # (try_begin), # (eq, ":faction_object", "$g_talk_troop_faction"), # (neq, ":troop_object", "$g_talk_troop"), # (assign, ":relevance", 200), # (try_begin), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_martial), # (assign, ":comment", "str_comment_pledged_allegiance_allied_martial_unfriendly"), # (else_try), # (eq, ":reputation", lrep_martial), # (assign, ":comment", "str_comment_pledged_allegiance_allied_martial"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_quarrelsome), # (assign, ":comment", "str_comment_pledged_allegiance_allied_quarrelsome_unfriendly"), # (else_try), # (eq, ":reputation", lrep_quarrelsome), # (assign, ":comment", "str_comment_pledged_allegiance_allied_quarrelsome"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_selfrighteous), # (assign, ":comment", "str_comment_pledged_allegiance_allied_selfrighteous_unfriendly"), # (else_try), # (eq, ":reputation", lrep_selfrighteous), # (assign, ":comment", "str_comment_pledged_allegiance_allied_selfrighteous"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_cunning), # (assign, ":comment", "str_comment_pledged_allegiance_allied_cunning_unfriendly"), # (else_try), # (eq, ":reputation", lrep_cunning), # (assign, ":comment", "str_comment_pledged_allegiance_allied_cunning"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_pledged_allegiance_allied_debauched_unfriendly"), # (else_try), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_pledged_allegiance_allied_debauched"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_goodnatured), # (assign, ":comment", "str_comment_pledged_allegiance_allied_goodnatured_unfriendly"), # (else_try), # (eq, ":reputation", lrep_goodnatured), # (assign, ":comment", "str_comment_pledged_allegiance_allied_goodnatured"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_upstanding), # (assign, ":comment", "str_comment_pledged_allegiance_allied_upstanding_unfriendly"), # (else_try), # (eq, ":reputation", lrep_upstanding), # (assign, ":comment", "str_comment_pledged_allegiance_allied_upstanding"), # (try_end), # (try_end), # (else_try), # (eq, ":entry_type", logent_fief_granted_village), # (eq, ":actor", "trp_player"), # (try_begin), # (eq, ":faction_object", "$g_talk_troop_faction"), # (neq, ":troop_object", "$g_talk_troop"), # (eq, ":faction_object", "$players_kingdom"), # (assign, ":relevance", 110), # (try_begin), # (gt, "$g_talk_troop_relation", 5), # (this_or_next|eq, ":reputation", lrep_selfrighteous), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied_friendly_cruel"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_cunning), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied_friendly_cynical"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied_friendly"), # (else_try), # (is_between, "$g_talk_troop_relation", -5, 5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied_spiteful"), # (assign, ":suggested_relation_change", -2), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (eq, ":reputation", lrep_upstanding), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied_unfriendly_upstanding"), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied_unfriendly_spiteful"), # (else_try), # (assign, ":comment", "str_comment_our_king_granted_you_a_fief_allied"), # (try_end), # (try_end), # (else_try), # (eq, ":entry_type", logent_renounced_allegiance), # (eq, ":actor", "trp_player"), # (try_begin), # (eq, ":faction_object", "$g_talk_troop_faction"), # (neq, ":troop_object", "$g_talk_troop"), # (try_begin), # (ge, "$g_talk_troop_faction_relation", 0), # (neq, "$g_talk_troop_faction", "$players_kingdom"), # (assign, ":relevance", 180), # (try_begin), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_friendly"), # (else_try), # (ge, "$g_talk_troop_relation", 0), # (eq, ":reputation", lrep_goodnatured), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_friendly"), # (try_end), # (else_try), # (lt, "$g_talk_troop_faction_relation", 0), # (assign, ":relevance", 300), # (try_begin), # (ge, "$g_talk_troop_relation", 0), # (this_or_next|eq, ":reputation", lrep_selfrighteous), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_unfriendly_moralizing"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (this_or_next|eq, ":reputation", lrep_goodnatured), # (eq, ":reputation", lrep_upstanding), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_enemy_friendly"), # (else_try), # (gt, "$g_talk_troop_relation", 5), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_enemy"), # (else_try), # (is_between, "$g_talk_troop_relation", -5, 5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_unfriendly_spiteful"), # (assign, ":suggested_relation_change", -2), # (else_try), # (lt, "$g_talk_troop_relation", -5), # (this_or_next|eq, ":reputation", lrep_quarrelsome), # (this_or_next|eq, ":reputation", lrep_selfrighteous), # (eq, ":reputation", lrep_debauched), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_unfriendly_spiteful"), # (else_try), # (assign, ":comment", "str_comment_you_renounced_your_alliegance_default"), # (try_end), # (try_end), # (try_end), (try_end), (assign, reg0, ":comment"), (assign, reg1, ":relevance"), (assign, reg2, ":suggested_relation_change"), ]), # script_get_relevant_comment_to_s42 # Input: none # Output: reg0 = 1 if comment found, 0 otherwise; s61 will contain comment string if found ("get_relevant_comment_to_s42", [(troop_get_slot, ":reputation", "$g_talk_troop", slot_lord_reputation_type), (try_begin), (eq, "$cheat_mode", 1), (store_add, ":rep_string", ":reputation", "str_personality_archetypes"), (str_store_string, s15, ":rep_string"), (display_message, "@Reputation type: {s15}"), (try_end), (assign, ":highest_score_so_far", 50), (assign, ":best_comment_so_far", -1), (assign, ":comment_found", 0), (assign, ":best_log_entry", -1), (assign, ":comment_relation_change", 0), (store_current_hours, ":current_time"), #prevents multiple comments in conversations in same hour # (troop_get_slot, ":talk_troop_last_comment_time", "$g_talk_troop", slot_troop_last_comment_time), #"$num_log_entries should also be set to one, not zero. This is included in the initialize npcs script, although could be moved to game_start (troop_get_slot, ":talk_troop_last_comment_slot", "$g_talk_troop", slot_troop_last_comment_slot), (troop_set_slot, "$g_talk_troop", slot_troop_last_comment_slot, "$num_log_entries"), (store_add, ":log_entries_plus_one", "$num_log_entries", 1), (try_for_range, ":log_entry_no", 1, ":log_entries_plus_one"), # It should be log entries plus one, so that the try_ sequence does not stop short of the last log entry # $Num_log_entries is now the number of the last log entry, which begins at "1" rather than "0" # This is so that (le, ":log_entry_no", ":talk_troop_last_comment_slot") works properly (troop_get_slot, ":entry_time", "trp_log_array_entry_time", ":log_entry_no"), # (val_max, ":entry_time", 1), #This is needed for pre-game events to be commented upon, if hours are used rather than the order of events (store_sub, ":entry_hours_elapsed", ":current_time", ":entry_time"), (try_begin), (le, ":log_entry_no", ":talk_troop_last_comment_slot"), # (le, ":entry_time", ":talk_troop_last_comment_time"), (try_begin), (eq, ":log_entry_no", ":talk_troop_last_comment_slot"), (eq, "$cheat_mode", 1), (assign, reg5, ":log_entry_no"), (display_message, "@Entries up to #{reg5} skipped"), (try_end), # I suggest using the log entry number as opposed to time so that events in the same hour can be commented upon # This feels more natural, for example, if there are other lords in the court when the player pledges allegiance (else_try), # (le, ":entry_hours_elapsed", 3), #don't comment on really fresh events # (else_try), (call_script, "script_get_relevant_comment_for_log_entry", ":log_entry_no"), (gt, reg1, 10), (assign, ":score", reg1), (assign, ":comment", reg0), (store_random_in_range, ":rand", 70, 140), (val_mul, ":score", ":rand"), (store_add, ":entry_time_score", ":entry_hours_elapsed", 500), #approx. one month (val_mul, ":score", 1000), (val_div, ":score", ":entry_time_score"), ###Relevance decreases over time - halved after one month, one-third after two, etc (try_begin), (gt, ":score", ":highest_score_so_far"), (assign, ":highest_score_so_far", ":score"), (assign, ":best_comment_so_far", ":comment"), (assign, ":best_log_entry", ":log_entry_no"), (assign, ":comment_relation_change", reg2), (try_end), (try_end), (try_end), (try_begin), (gt, ":best_comment_so_far", 0), (assign, ":comment_found", 1), #comment found print it to s61 now. (troop_get_slot, ":actor", "trp_log_array_actor", ":best_log_entry"), (troop_get_slot, ":center_object", "trp_log_array_center_object", ":best_log_entry"), (troop_get_slot, ":center_object_lord", "trp_log_array_center_object_lord", ":best_log_entry"), (troop_get_slot, ":center_object_faction", "trp_log_array_center_object_faction", ":best_log_entry"), (troop_get_slot, ":troop_object", "trp_log_array_troop_object", ":best_log_entry"), (troop_get_slot, ":troop_object_faction", "trp_log_array_troop_object_faction", ":best_log_entry"), (troop_get_slot, ":faction_object", "trp_log_array_faction_object", ":best_log_entry"), (try_begin), (ge, ":actor", 0), (str_store_troop_name, s50, ":actor"), (try_end), (try_begin), (ge, ":center_object", 0), (str_store_party_name, s51, ":center_object"), (try_end), (try_begin), (ge, ":center_object_lord", 0), (str_store_troop_name, s52, ":center_object_lord"), (try_end), (try_begin), (ge, ":center_object_faction", 0), (str_store_faction_name, s53, ":center_object_faction"), (try_end), (try_begin), (ge, ":troop_object", 0), (str_store_troop_name, s54, ":troop_object"), (try_end), (try_begin), (ge, ":troop_object_faction", 0), (str_store_faction_name, s55, ":troop_object_faction"), (try_end), (try_begin), (ge, ":faction_object", 0), (str_store_faction_name, s56, ":faction_object"), (try_end), (str_store_string, s42, ":best_comment_so_far"), (try_end), (assign, reg0, ":comment_found"), (assign, "$log_comment_relation_change", ":comment_relation_change"), ]), # script_get_culture_with_party_faction_for_music # Input: arg1 = party_no # Output: reg0 = culture ("get_culture_with_party_faction_for_music", [ (store_script_param, ":party_no", 1), (store_faction_of_party, ":faction_no", ":party_no"), (try_begin), (this_or_next|eq, ":faction_no", "fac_player_faction"), (eq, ":faction_no", "fac_player_supporters_faction"), (assign, ":faction_no", "$players_kingdom"), (try_end), (try_begin), (is_between, ":party_no", centers_begin, centers_end), (this_or_next|eq, ":faction_no", "fac_player_supporters_faction"), (neg|is_between, ":faction_no", kingdoms_begin, kingdoms_end), (party_get_slot, ":faction_no", ":party_no", slot_center_original_faction), (try_end), (faction_get_slot, ":result", ":faction_no", slot_faction_culture), #MV: commented this out! it overwrote a valid result! # (try_begin), # (this_or_next|eq, ":faction_no", "fac_outlaws"), # # (this_or_next|eq, ":faction_no", "fac_peasant_rebels"), # (this_or_next|eq, ":faction_no", "fac_deserters"), # (this_or_next|eq, ":faction_no", "fac_mountain_bandits"), # (eq, ":faction_no", "fac_forest_bandits"), # (assign, ":result", mtf_culture_6), # (else_try), # (assign, ":result", 0), #no culture, including player with no bindings to another kingdom # (try_end), (assign, reg0, ":result"), ]), # script_music_set_situation_with_culture # Input: arg1 = music_situation ("music_set_situation_with_culture", [ (store_script_param, ":situation", 1), (assign, ":culture", 0), #no culture (try_begin), (this_or_next|eq, ":situation", mtf_sit_town), (this_or_next|eq, ":situation", mtf_sit_day), (this_or_next|eq, ":situation", mtf_sit_night), (this_or_next|eq, ":situation", mtf_sit_town_infiltrate), (eq, ":situation", mtf_sit_encounter_hostile), (call_script, "script_get_culture_with_party_faction_for_music", "$g_encountered_party"), (val_or, ":culture", reg0), (else_try), (this_or_next|eq, ":situation", mtf_sit_ambushed), (eq, ":situation", mtf_sit_fight), (call_script, "script_get_culture_with_party_faction_for_music", "$g_encountered_party"), (val_or, ":culture", reg0), (call_script, "script_get_culture_with_party_faction_for_music", "p_main_party"), (val_or, ":culture", reg0), (call_script, "script_get_closest_center", "p_main_party"), (call_script, "script_get_culture_with_party_faction_for_music", reg0), (val_or, ":culture", reg0), (else_try), (eq, ":situation", mtf_sit_travel), #(call_script, "script_get_culture_with_party_faction_for_music", "p_main_party"), #(val_or, ":culture", reg0), (call_script, "script_get_closest_center", "p_main_party"), (call_script, "script_get_culture_with_party_faction_for_music", reg0), (val_or, ":culture", reg0), (else_try), (eq, ":situation", mtf_sit_victorious), (call_script, "script_get_culture_with_party_faction_for_music", "p_main_party"), (val_or, ":culture", reg0), (else_try), (eq, ":situation", mtf_sit_killed), (call_script, "script_get_culture_with_party_faction_for_music", "$g_encountered_party"), (val_or, ":culture", reg0), (try_end), (try_begin), (this_or_next|eq, ":situation", mtf_sit_town), (eq, ":situation", mtf_sit_day), (try_begin), (is_currently_night), (assign, ":situation", mtf_sit_night), (try_end), (try_end), (music_set_situation, ":situation"), (music_set_culture, ":culture"), # (assign, reg0, ":situation"), # (assign, reg1, ":culture"), # (display_message,"@DEBUG: music_set_situation_with_culture: situation {reg0}, culture {reg1}"), #MV: Custom TLD music for towns, because we have too many cultures and town-specific tracks (try_begin), (eq, ":situation", mtf_sit_town), (assign, ":track", 0), (store_faction_of_party, ":town_faction", "$g_encountered_party"), (try_begin), (this_or_next|eq, ":town_faction", "fac_gondor"), (eq, ":town_faction", "fac_rohan"), (store_random_in_range, ":random", 0, 100), (lt, ":random", 10), #play alliance track 10% of the time (assign, ":track", "track_TLD_Alliance_Towns"), (else_try), (eq, ":town_faction", "fac_gondor"), (try_begin), (eq, "$g_encountered_party", "p_town_minas_tirith"), (assign, ":track", "track_TLD_Minas_Tirith"), (else_try), (eq, "$g_encountered_party", "p_town_dol_amroth"), (assign, ":track", "track_TLD_Dol_Amroth"), (else_try), (eq, "$g_encountered_party", "p_town_erech"), (assign, ":track", "track_TLD_Black_Root"), (else_try), (eq, "$g_encountered_party", "p_town_lossarnach"), (assign, ":track", "track_TLD_Lossarnach"), (else_try), (eq, "$g_encountered_party", "p_town_pinnath_gelin"), (assign, ":track", "track_TLD_Pinnath_Gelin"), (else_try), (eq, "$g_encountered_party", "p_town_west_osgiliath"), (assign, ":track", "track_TLD_Osgiliath"), (else_try), (eq, "$g_encountered_party", "p_town_henneth_annun"), (assign, ":track", "track_TLD_Henneth_Annun"), (else_try), (eq, "$g_encountered_party", "p_town_cair_andros"), (assign, ":track", "track_infiltration_evil"), (else_try), (assign, ":track", "track_TLD_Gondor_Cities"), (try_end), (else_try), (eq, ":town_faction", "fac_rohan"), (try_begin), (eq, "$g_encountered_party", "p_town_edoras"), (assign, ":track", "track_TLD_Edoras"), (else_try), (eq, "$g_encountered_party", "p_town_hornburg"), (assign, ":track", "track_TLD_Helms_Deep"), (else_try), (assign, ":track", "track_TLD_Rohan_Village"), (try_end), (else_try), (eq, ":town_faction", "fac_dwarf"), (try_begin), (eq, "$g_encountered_party", "p_town_ironhill_camp"), (assign, ":track", "track_TLD_Iron_Hill_Mine"), (else_try), (assign, ":track", "track_TLD_Erebor"), (try_end), (else_try), (this_or_next|eq, ":town_faction", "fac_mordor"), (this_or_next|eq, ":town_faction", "fac_guldur"), (eq, ":town_faction", "fac_moria"), (try_begin), (eq, "$g_encountered_party", "p_town_minas_morgul"), (assign, ":track", "track_TLD_Minas_Morgul"), (else_try), (eq, "$g_encountered_party", "p_town_morannon"), (assign, ":track", "track_infiltration_good"), (else_try), (assign, ":track", "track_TLD_Orc_Camp"), (try_end), (else_try), (eq, ":town_faction", "fac_isengard"), (try_begin), (eq, "$g_encountered_party", "p_town_isengard"), (assign, ":track", "track_TLD_Isengard_Town"), (else_try), (assign, ":track", "track_TLD_Uruk_Camp"), (try_end), (else_try), (eq, ":town_faction", "fac_lorien"), (assign, ":track", "track_TLD_Lothlorien"), (else_try), (eq, ":town_faction", "fac_imladris"), (assign, ":track", "track_TLD_Rivendell_Camp"), (else_try), (eq, ":town_faction", "fac_woodelf"), (assign, ":track", "track_TLD_Mirkwood_Camp"), (else_try), (eq, ":town_faction", "fac_dale"), (try_begin), (eq, "$g_encountered_party", "p_town_esgaroth"), (assign, ":track", "track_TLD_Esgaroth"), (else_try), (assign, ":track", "track_TLD_Dale"), (try_end), (else_try), (eq, ":town_faction", "fac_harad"), (assign, ":track", "track_TLD_Harad_Camp"), (else_try), (eq, ":town_faction", "fac_rhun"), (assign, ":track", "track_TLD_Rhun_Encampment"), (else_try), (eq, ":town_faction", "fac_khand"), (assign, ":track", "track_TLD_Khand_Encampment"), (else_try), (eq, ":town_faction", "fac_umbar"), (assign, ":track", "track_TLD_Corsair_Camp"), (else_try), (eq, ":town_faction", "fac_gundabad"), (assign, ":track", "track_TLD_Gundabad_Camp"), (else_try), (eq, ":town_faction", "fac_dunland"), (assign, ":track", "track_TLD_Dunland_Camp"), (else_try), #(eq, ":town_faction", "fac_beorn"), (assign, ":track", "track_TLD_Beorning_Town"), (try_end), (play_track, ":track", 1), (try_end), #MV: Custom TLD music for battles, because we have too many cultures to use mtf_culture_X flags (try_begin), (this_or_next|eq, ":situation", mtf_sit_fight), (eq, ":situation", mtf_sit_ambushed), (assign, ":track", 0), (store_faction_of_party, ":faction", "$g_encountered_party"), #could be enemy or ally (try_begin), (neg|is_between, ":faction", kingdoms_begin, kingdoms_end), #bandits etc. have no music (try_begin), (gt, "$g_encountered_party_2", 0), (store_faction_of_party, ":faction", "$g_encountered_party_2"), #could be enemy or ally (try_end), (try_begin), (neg|is_between, ":faction", kingdoms_begin, kingdoms_end), #bandits etc. have no music (assign, ":faction", "$players_kingdom"), #third and last option (try_end), (try_end), # now ":faction" is one of the major factions # (assign, reg0, ":faction"), # (str_store_faction_name, s4, ":faction"), # (display_message,"@DEBUG: choosing battle music for faction {reg0} ({s4})"), (try_begin), (eq, ":faction", "fac_gondor"), (store_random_in_range, ":random", 0, 100), (try_begin), (lt, ":random", 50), # 50/50 chance for each track (CppCoder) (assign, ":track", "track_TLD_Battle_Gondor"), (else_try), (assign, ":track", "track_TLD_Battle_Gondor_2"), (try_end), (else_try), (eq, ":faction", "fac_dwarf"), (assign, ":track", "track_TLD_Battle_Dwarves"), (else_try), (eq, ":faction", "fac_rohan"), (assign, ":track", "track_TLD_Battle_Rohan"), (else_try), (eq, ":faction", "fac_mordor"), (assign, ":track", "track_TLD_Battle_Mordor"), (else_try), (eq, ":faction", "fac_isengard"), (assign, ":track", "track_TLD_Battle_Isengard"), (else_try), (eq, ":faction", "fac_lorien"), (assign, ":track", "track_TLD_Battle_Elves"), (else_try), (eq, ":faction", "fac_imladris"), (assign, ":track", "track_TLD_Battle_Imladris"), (else_try), (eq, ":faction", "fac_woodelf"), (assign, ":track", "track_TLD_Battle_Wood_Elves"), (else_try), (eq, ":faction", "fac_dale"), (assign, ":track", "track_TLD_Battle_Barding"), (else_try), (eq, ":faction", "fac_harad"), (assign, ":track", "track_TLD_Battle_Far_Harad"), (else_try), # Khand (eq, ":faction", "fac_khand"), (assign, ":track", "track_TLD_Battle_Khand"), (else_try), # Rhun (eq, ":faction", "fac_rhun"), (assign, ":track", "track_TLD_Battle_Rhun"), (else_try), # Corsairs (eq, ":faction", "fac_umbar"), (assign, ":track", "track_TLD_Battle_Corsair"), (else_try), #some orc factions (this_or_next|eq, ":faction", "fac_moria"), (eq, ":faction", "fac_guldur"), (assign, ":track", "track_TLD_Battle_Orcs"), (else_try), (eq, ":faction", "fac_gundabad"), (assign, ":track", "track_TLD_Battle_Gundabad"), (else_try), (eq, ":faction", "fac_dunland"), (assign, ":track", "track_TLD_Battle_Dunland"), (else_try), #(eq, ":faction", "fac_beorn"), (assign, ":track", "track_TLD_Battle_Beorn"), (try_end), (play_track, ":track", 0), (try_end), #MV: Custom TLD music for travel, because we have too many cultures to use mtf_culture_X flags #Picks closest center and tries to find the music of its ORIGINAL faction, if any #If there is none, plays standard travel music (TLD_Map_Day_X) #Even if there is a faction, there is 20% chance it will play standard travel music (so if the player doesn't travel much and stays in the same country, won't be bored by the same factional music) (try_begin), (eq, ":situation", mtf_sit_travel), (assign, ":track", 0), (call_script, "script_get_closest_center", "p_main_party"), (assign, ":closest_center", reg0), (party_get_slot, ":faction", ":closest_center", slot_center_original_faction), (store_random_in_range, ":random", 0, 100), (try_begin), (lt, ":random", 20), #20% of the time, just play standard travel music, regardless of territory (assign, ":faction", 0), #reset faction to invalid (try_end), # (assign, reg0, ":faction"), # (str_store_faction_name, s4, ":faction"), # (display_message,"@DEBUG: choosing travel music for faction {reg0} ({s4})"), (assign, ":no_tracks", 0), #available tracks per faction, used to pick one at random (try_begin), (eq, ":faction", "fac_gondor"), (assign, ":track", "track_TLD_Map_Gondor_A"), (assign, ":no_tracks", 5), (else_try), (eq, ":faction", "fac_dwarf"), (assign, ":track", "track_TLD_Map_Dwarves_A"), (assign, ":no_tracks", 3), (else_try), (eq, ":faction", "fac_rohan"), (assign, ":track", "track_TLD_Map_Rohan_A"), (assign, ":no_tracks", 4), (else_try), #all orc factions (this_or_next|eq, ":faction", "fac_mordor"), (this_or_next|eq, ":faction", "fac_isengard"), (this_or_next|eq, ":faction", "fac_moria"), (this_or_next|eq, ":faction", "fac_guldur"), (eq, ":faction", "fac_gundabad"), (assign, ":track", "track_TLD_Map_Orcs_A"), (assign, ":no_tracks", 4), (else_try), #elven factions (this_or_next|eq, ":faction", "fac_lorien"), (this_or_next|eq, ":faction", "fac_imladris"), (eq, ":faction", "fac_woodelf"), (assign, ":track", "track_TLD_Map_Elven_A"), (assign, ":no_tracks", 5), # (else_try), # (eq, ":faction", "fac_dale"), (else_try), (eq, ":faction", "fac_harad"), (assign, ":track", "track_TLD_Map_Harad_A"), (assign, ":no_tracks", 4), (else_try), #some evil men (this_or_next|eq, ":faction", "fac_rhun"), (this_or_next|eq, ":faction", "fac_khand"), (eq, ":faction", "fac_umbar"), (assign, ":track", "track_TLD_Map_Khand_A"), (assign, ":no_tracks", 3), (else_try), (eq, ":faction", "fac_dunland"), (assign, ":track", "track_TLD_Map_Dunland_A"), (assign, ":no_tracks", 2), # (else_try), # (eq, ":faction", "fac_beorn"), (else_try), #couldn't find a faction (Dale, Beorn), play standard travel music (try_begin), (is_currently_night), (assign, ":track", "track_TLD_Map_Night_A"), (assign, ":no_tracks", 7), (else_try), (assign, ":track", "track_TLD_Map_Day_A"), (assign, ":no_tracks", 11), (try_end), (try_end), (store_random_in_range, ":random_track_index", 0, ":no_tracks"), (val_add, ":track", ":random_track_index"), (play_track, ":track", 0), (try_end), ]), # script_combat_music_set_situation_with_culture ("combat_music_set_situation_with_culture", [ (assign, ":situation", mtf_sit_fight), (assign, ":num_allies", 0), (assign, ":num_enemies", 0), (try_for_agents, ":agent_no"), (agent_is_alive, ":agent_no"), (agent_is_human, ":agent_no"), (agent_get_troop_id, ":agent_troop_id", ":agent_no"), (store_character_level, ":troop_level", ":agent_troop_id"), (val_add, ":troop_level", 10), (val_mul, ":troop_level", ":troop_level"), (try_begin), (agent_is_ally, ":agent_no"), (val_add, ":num_allies", ":troop_level"), (else_try), (val_add, ":num_enemies", ":troop_level"), (try_end), (try_end), (val_mul, ":num_allies", 4), #play ambushed music if we are 2 times outnumbered. (val_div, ":num_allies", 3), (try_begin), (lt, ":num_allies", ":num_enemies"), (assign, ":situation", mtf_sit_ambushed), (try_end), (call_script, "script_music_set_situation_with_culture", ":situation"), ]), # script_set_items_for_tournament # Input: arg1 = horse_chance, arg2 = lance_chance (with horse only), arg3 = sword_chance, arg4 = axe_chance, arg5 = bow_chance (without horse only), arg6 = javelin_chance (with horse only), arg7 = mounted_bow_chance (with horse only), arg8 = crossbow_sword_chance, arg9 = armor_item_begin, arg10 = helm_item_begin # Output: none (sets mt_arena_melee_fight items) ("set_items_for_tournament", [ (store_script_param, ":horse_chance", 1), (store_script_param, ":lance_chance", 2), (store_script_param, ":sword_chance", 3), (store_script_param, ":axe_chance", 4), (store_script_param, ":bow_chance", 5), (store_script_param, ":javelin_chance", 6), (store_script_param, ":mounted_bow_chance", 7), (store_script_param, ":crossbow_sword_chance", 8), (store_script_param, ":armor_item_begin", 9), (store_script_param, ":helm_item_begin", 10), (store_add, ":total_chance", ":sword_chance", ":axe_chance"), (val_add, ":total_chance", ":crossbow_sword_chance"), (try_for_range, ":i_ep", 0, 32), (mission_tpl_entry_clear_override_items, "mt_arena_melee_fight", ":i_ep"), (assign, ":has_horse", 0), (store_div, ":cur_team", ":i_ep", 8), (try_begin), (store_random_in_range, ":random_no", 0, 100), (lt, ":random_no", ":horse_chance"), (assign, ":has_horse", 1), (try_end), (try_begin), (eq, ":has_horse", 1), (store_add, ":cur_total_chance", ":total_chance", ":lance_chance"), (val_add, ":cur_total_chance", ":javelin_chance"), (val_add, ":cur_total_chance", ":mounted_bow_chance"), (else_try), (store_add, ":cur_total_chance", ":total_chance", ":bow_chance"), (try_end), (store_random_in_range, ":random_no", 0, ":cur_total_chance"), (try_begin), (val_sub, ":random_no", ":sword_chance"), (lt, ":random_no", 0), (try_begin), (store_random_in_range, ":sub_random_no", 0, 100), (lt, ":sub_random_no", 50), # (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"), (else_try), (try_end), (else_try), (val_sub, ":random_no", ":axe_chance"), (lt, ":random_no", 0), # (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"), (else_try), (val_sub, ":random_no", ":crossbow_sword_chance"), (lt, ":random_no", 0), (else_try), (eq, ":has_horse", 0), (val_sub, ":random_no", ":bow_chance"), (lt, ":random_no", 0), (else_try), (eq, ":has_horse", 1), (val_sub, ":random_no", ":lance_chance"), (lt, ":random_no", 0), # (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"), (else_try), (eq, ":has_horse", 1), (val_sub, ":random_no", ":javelin_chance"), (lt, ":random_no", 0), # (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_shield"), (else_try), (eq, ":has_horse", 1), (val_sub, ":random_no", ":mounted_bow_chance"), (lt, ":random_no", 0), #(mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_bow"), #(mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", "itm_practice_arrows"), (try_end), (try_begin), (ge, ":armor_item_begin", 0), (store_add, ":cur_armor_item", ":armor_item_begin", ":cur_team"), (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_armor_item"), (try_end), (try_begin), (ge, ":helm_item_begin", 0), (store_add, ":cur_helm_item", ":helm_item_begin", ":cur_team"), (mission_tpl_entry_add_override_item, "mt_arena_melee_fight", ":i_ep", ":cur_helm_item"), (try_end), (try_end), ]), # script_custom_battle_end ("custom_battle_end", [ (assign, "$g_custom_battle_team1_death_count", 0), (assign, "$g_custom_battle_team2_death_count", 0), (try_for_agents, ":cur_agent"), (agent_is_human, ":cur_agent"), (neg|agent_is_alive, ":cur_agent"), (agent_get_team, ":cur_team", ":cur_agent"), (try_begin), (eq, ":cur_team", 0), (val_add, "$g_custom_battle_team1_death_count", 1), (else_try), (val_add, "$g_custom_battle_team2_death_count", 1), (try_end), (try_end), ]), # script_remove_troop_from_prison # Input: troop_no ("remove_troop_from_prison", [ (store_script_param, ":troop_no", 1), (troop_set_slot, ":troop_no", slot_troop_prisoner_of_party, -1), # (try_begin), # (check_quest_active, "qst_rescue_lord_by_replace"), # (quest_slot_eq, "qst_rescue_lord_by_replace", slot_quest_target_troop, ":troop_no"), # (call_script, "script_cancel_quest", "qst_rescue_lord_by_replace"), # (try_end), # (try_begin), # (check_quest_active, "qst_deliver_message_to_prisoner_lord"), # (quest_slot_eq, "qst_deliver_message_to_prisoner_lord", slot_quest_target_troop, ":troop_no"), # (call_script, "script_cancel_quest", "qst_deliver_message_to_prisoner_lord"), # (try_end), ]), # script_TLD_troop_banner_slot_init # run at the start of the game ("TLD_troop_banner_slot_init", [ (troop_set_slot, "trp_i1_loss_woodsman", slot_troop_banner_scene_prop, "mesh_banner_e02"), (troop_set_slot, "trp_i2_loss_axeman", slot_troop_banner_scene_prop, "mesh_banner_e03"), (troop_set_slot, "trp_i5_loss_axemaster", slot_troop_banner_scene_prop, "mesh_banner_e04"), (troop_set_slot, "trp_i1_lam_clansman", slot_troop_banner_scene_prop, "mesh_banner_e09"), (troop_set_slot, "trp_i2_lam_footman", slot_troop_banner_scene_prop, "mesh_banner_e10"), (troop_set_slot, "trp_i3_lam_veteran", slot_troop_banner_scene_prop, "mesh_banner_e11"), (troop_set_slot, "trp_i1_pinnath_plainsman", slot_troop_banner_scene_prop, "mesh_banner_e05"), (troop_set_slot, "trp_c2_pinnath_rider", slot_troop_banner_scene_prop, "mesh_banner_e06"), (troop_set_slot, "trp_c3_pinnath_knight", slot_troop_banner_scene_prop, "mesh_banner_e07"), ## BRV does not have shields (troop_set_slot, "trp_i1_amroth_recruit", slot_troop_banner_scene_prop, "mesh_banner_e16"), (troop_set_slot, "trp_c2_amroth_squire", slot_troop_banner_scene_prop, "mesh_banner_e17"), (troop_set_slot, "trp_c3_amroth_vet_squire",slot_troop_banner_scene_prop, "mesh_banner_e17"), (troop_set_slot, "trp_c4_amroth_knight", slot_troop_banner_scene_prop, "mesh_banner_e18"), (troop_set_slot, "trp_c5_amroth_vet_knight",slot_troop_banner_scene_prop, "mesh_banner_e18"), (troop_set_slot, "trp_c6_amroth_swan_knight", slot_troop_banner_scene_prop, "mesh_banner_e18"), ]), #script_TLD_shield_item_set_banner, by GA # INPUT: agent_no ("TLD_shield_item_set_banner", [ (store_script_param, ":tableau_no",1), (store_script_param, ":agent_no", 2), (store_script_param, ":troop_no", 3), # (assign, ":banner_troop", -1), (assign, ":banner_mesh", "mesh_banners_default_b"), (try_begin), (neq,":agent_no",-1), # (agent_get_party_id,":party",":agent_no"), (try_begin), (is_between,":troop_no","trp_i1_rhun_tribesman","trp_c4_rhun_veteran_swift_horseman"),# Rhun randomized heraldry (store_random_in_range,":banner_mesh","mesh_circular_8mosaic1","mesh_circular_8mosaic10"), (else_try), (is_between,":troop_no","trp_i1_harad_levy","trp_ac5_harondor_black_snake"),# Harad randomized heraldry (store_random_in_range,":banner_mesh",275,300), #(else_try), #(eq,"$player_universal_banner",1), # indicator for the ability to set player's own banner #(eq,":party",":player_party"), #(troop_get_slot,":banner_mesh","trp_player",slot_troop_banner_scene_prop), (try_end), (try_end), (cur_item_set_tableau_material, ":tableau_no",":banner_mesh"), ]), # script_TLD_initialize_civilian_clothes ("TLD_initialize_civilian_clothes", [(store_script_param, ":tableau_no", 1), #(store_script_param, ":agent_no", 2), (store_script_param, ":troop_no", 3), (store_troop_faction, ":fac", ":troop_no"), (val_sub, ":fac", kingdoms_begin), (try_begin), ]+concatenate_scripts([ [ (eq, ":fac", x), (try_begin), ]+concatenate_scripts([ [ (eq, ":tableau_no", fac_tableau_list[x][z][0]), (store_random_in_range, ":rand", 0, len(fac_tableau_list[x][z][1])), (try_begin), ]+concatenate_scripts([ [ (eq, ":rand", y), (cur_item_set_tableau_material, ":tableau_no", fac_tableau_list[x][z][1][y]), (else_try), ] for y in range(len(fac_tableau_list[x][z][1])) ])+[ (try_end), (else_try), ] for z in range(len(fac_tableau_list[x])) ])+[ (try_end), (else_try), ] for x in range(len(fac_tableau_list)) ])+[ (try_end), ]), # script_set_item_faction ("set_item_faction", set_item_faction()+[ (item_set_slot, "itm_wood_club", slot_item_faction,0xFFFFFFFF), # mtarini: make a few items all factions (item_set_slot, "itm_twohand_wood_club", slot_item_faction,0xFFFFFFFF), (item_set_slot, "itm_metal_scraps_bad", slot_item_faction,0xFFFFFFFF), # scraps needed for selling w/o faction discount (item_set_slot, "itm_metal_scraps_medium", slot_item_faction,0xFFFFFFFF), (item_set_slot, "itm_metal_scraps_good", slot_item_faction,0xFFFFFFFF), # CC: Easiest way to make this work... (faction_get_slot, ":mordor_mask", "fac_mordor", slot_faction_mask), (item_set_slot, "itm_spider", slot_item_faction, ":mordor_mask"), ]), # script_fill_camp_chests # INPUT: faction # fills camp chests with items used by this faction ("fill_camp_chests", [ (store_script_param_1, ":faction"), (faction_get_slot, ":fm", ":faction", slot_faction_mask), (troop_clear_inventory,"trp_camp_chest_faction"), (troop_clear_inventory,"trp_camp_chest_none"), (troop_ensure_inventory_space,"trp_camp_chest_faction",70), (troop_ensure_inventory_space,"trp_camp_chest_none",70), (store_add,":last_item_plus_one","itm_ent_body",1), (try_for_range,":item","itm_no_item",":last_item_plus_one"), (item_get_slot,":item_faction_mask",":item",slot_item_faction), # (assign,":ii",":item_faction_mask"), (try_begin), (eq,":item_faction_mask",0), (troop_add_item,"trp_camp_chest_none",":item",0), (else_try), (val_and,":item_faction_mask",":fm"), (try_begin), (neq,":item_faction_mask",0), (troop_add_item,"trp_camp_chest_faction",":item",0), (try_end), (try_end), (try_end), ]), # script_fill_merchants_CHEAT # fills smiths across the land with faction stuff ("fill_merchants_cheat", [ (set_merchandise_modifier_quality,150), (try_for_range,":cur_merchant",weapon_merchants_begin,weapon_merchants_end), (reset_item_probabilities,100), (troop_clear_inventory,":cur_merchant"), (store_troop_faction,":faction",":cur_merchant"), (faction_get_slot, ":fac_mask", ":faction", slot_faction_mask), (troop_get_slot,":subfaction",":cur_merchant",slot_troop_subfaction), (assign, ":subfac_mask", 1),(try_for_range, ":unused", 0, ":subfaction"),(val_mul, ":subfac_mask", 2),(try_end), (try_for_range,":item","itm_no_item","itm_ent_body"), (item_get_slot,":item_faction_mask",":item",slot_item_faction), (val_and,":item_faction_mask",":fac_mask"), (item_get_slot,":item_subfaction_mask",":item",slot_item_subfaction), (val_and,":item_subfaction_mask",":subfac_mask"), (try_begin), (neq,":item_faction_mask",0),(neq,":item_subfaction_mask",0),(troop_add_item,":cur_merchant",":item",0), (try_end), (try_end), (try_end), ]), # scripts for gondor tableau shields, by GA # Input: tableau, agent, troop ("TLD_gondor_round_shield_banner", [ (store_script_param, ":tableau_no",1),(store_script_param, ":agent_no", 2),(store_script_param, ":tr", 3), (assign, ":bm", "mesh_banner_e08"), #default tableau black (try_begin),(neq,":agent_no",-1), (try_begin),(is_between,":tr","trp_a1_blackroot_hunter" ,"trp_i1_amroth_recruit" ),(assign, ":bm", "mesh_banner_e02"), (else_try) ,(is_between,":tr","trp_i1_pinnath_plainsman" ,"trp_i1_amroth_recruit" ),(assign, ":bm", "mesh_banner_e05"), (else_try) ,(is_between,":tr","trp_i1_lam_clansman" ,"trp_i1_pinnath_plainsman" ),(assign, ":bm", "mesh_banner_e09"), (else_try) ,(is_between,":tr","trp_i1_pel_watchman" ,"trp_i1_lam_clansman" ),(assign, ":bm", "mesh_banner_e12"), (else_try) ,(is_between,":tr","trp_i1_amroth_recruit" ,"trp_a1_lorien_scout" ),(assign, ":bm", "mesh_banner_e16"), (else_try) ,(is_between,":tr","trp_i1_loss_woodsman" ,"trp_i3_loss_vet_axeman"),(assign, ":bm", "mesh_banner_e19"), (else_try) ,(is_between,":tr","trp_i3_loss_vet_axeman","trp_i5_loss_axemaster" ),(assign, ":bm", "mesh_banner_e20"), (else_try) ,(is_between,":tr","trp_i5_loss_axemaster" ,"trp_i1_pel_watchman" ),(assign, ":bm", "mesh_banner_e21"), (else_try) ,(eq, ":tr","trp_knight_1_8" ),(assign, ":bm", "mesh_banner_e21"), #Forlong (else_try) ,(eq, ":tr","trp_knight_1_1" ),(assign, ":bm", "mesh_banner_e11"), #Angbor (else_try), ##Kham - Player Subfac Tableaus (eq, ":tr", "trp_player"), (troop_get_slot, ":subfac", "trp_player", slot_troop_subfaction), (gt, ":subfac",0), (try_begin), (this_or_next|eq, ":subfac", subfac_regular), ( eq, ":subfac", subfac_blackroot), (assign, ":bm", "mesh_banner_e02"), (else_try), (eq, ":subfac", subfac_pinnath_gelin), (assign, ":bm", "mesh_banner_e05"), (else_try), (eq, ":subfac", subfac_ethring), (assign, ":bm", "mesh_banner_e09"), (else_try), (eq, ":subfac", subfac_pelargir), (assign, ":bm", "mesh_banner_e12"), (else_try), (eq, ":subfac", subfac_dol_amroth), (assign, ":bm", "mesh_banner_e16"), (else_try), (eq, ":subfac", subfac_lossarnach), (assign, ":bm", "mesh_banner_e19"), (try_end), ##Kham - Player Subfac Tableaus END (else_try) ,(troop_get_slot,":b",":tr",slot_troop_banner_scene_prop),(neq,":b",0),(assign,":bm",":b"), # for other troops get mesh from banner slot (try_end), (try_end), (cur_item_set_tableau_material, ":tableau_no",":bm"), ]), ("TLD_gondor_kite_shield_banner", [ (store_script_param, ":tableau_no",1),(store_script_param, ":agent_no", 2),(store_script_param, ":tr", 3), (assign, ":bm", "mesh_banner_gondor"), #default tableau black (try_begin),(neq,":agent_no",-1), (try_begin),(is_between,":tr","trp_a1_blackroot_hunter" ,"trp_i1_amroth_recruit" ),(assign, ":bm", "mesh_banner_e04"), (else_try) ,(is_between,":tr","trp_i1_pinnath_plainsman","trp_a1_blackroot_hunter"),(assign, ":bm", "mesh_banner_e07"), (else_try) ,(is_between,":tr","trp_i1_lam_clansman" ,"trp_i1_pinnath_plainsman"),(assign, ":bm", "mesh_banner_e11"), (else_try) ,(is_between,":tr","trp_i1_pel_watchman" ,"trp_i1_lam_clansman"),(assign, ":bm", "mesh_banner_e14"), (else_try) ,(is_between,":tr","trp_i1_amroth_recruit" ,"trp_c6_amroth_swan_knight"),(assign, ":bm", "mesh_banner_e17"), (else_try) ,(is_between,":tr","trp_c6_amroth_swan_knight" ,"trp_a1_lorien_scout"),(assign, ":bm", "mesh_banner_e18"), (else_try) ,(eq, ":tr","trp_knight_1_3" ),(assign, ":bm", "mesh_banner_e18"), #Imrahil (else_try) ,(eq, ":tr","trp_knight_1_6" ),(assign, ":bm", "mesh_banner_e07"), #Hirluin (else_try) ,(eq, ":tr","trp_knight_6_1" ),(assign, ":bm", "mesh_banner_e11"), #Dervorin (else_try) ,(eq, ":tr","trp_knight_6_2" ),(assign, ":bm", "mesh_banner_e09"), #Golasgil (else_try), ##Kham - Player Subfac Tableaus (eq, ":tr", "trp_player"), (call_script, "script_get_faction_rank", "fac_gondor"), (assign, ":rank", reg0), (troop_get_slot, ":subfac", "trp_player", slot_troop_subfaction), (ge, ":subfac",0), (try_begin), (this_or_next|eq, ":subfac", subfac_regular), ( eq, ":subfac", subfac_blackroot), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e04"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e03"), (else_try), (assign, ":bm", "mesh_banner_e02"), (try_end), (else_try), (eq, ":subfac", subfac_pinnath_gelin), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e07"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e06"), (else_try), (assign, ":bm", "mesh_banner_e05"), (try_end), (else_try), (eq, ":subfac", subfac_ethring), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e11"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e10"), (else_try), (assign, ":bm", "mesh_banner_e09"), (try_end), (else_try), (eq, ":subfac", subfac_pelargir), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e13"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e14"), (else_try), (assign, ":bm", "mesh_banner_e12"), (try_end), (else_try), (eq, ":subfac", subfac_dol_amroth), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e18"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e17"), (else_try), (assign, ":bm", "mesh_banner_e16"), (try_end), (else_try), (eq, ":subfac", subfac_lossarnach), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_f21"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e21"), (else_try), (assign, ":bm", "mesh_banner_e19"), (try_end), (try_end), ##Kham - Player Subfac Tableaus END (else_try) ,(troop_get_slot,":b",":tr",slot_troop_banner_scene_prop),(neq,":b",0),(assign,":bm",":b"), # for other troops get mesh from banner slot (try_end), (try_end), (cur_item_set_tableau_material, ":tableau_no",":bm"), ]), ("TLD_gondor_tower_shield_banner", [ (store_script_param, ":tableau_no",1),(store_script_param, ":agent_no", 2),(store_script_param, ":tr", 3), (assign, ":bm", "mesh_banner_gondor"), #default tableau black (try_begin),(neq,":agent_no",-1), (try_begin),(is_between,":tr","trp_a1_blackroot_hunter" ,"trp_i1_amroth_recruit" ),(assign, ":bm", "mesh_banner_e03"), (else_try) ,(is_between,":tr","trp_i1_pinnath_plainsman","trp_a1_blackroot_hunter" ),(assign, ":bm", "mesh_banner_e06"), (else_try) ,(is_between,":tr","trp_i1_lam_clansman" ,"trp_i1_pinnath_plainsman"),(assign, ":bm", "mesh_banner_e10"), (else_try), ##Kham - Player Subfac Tableaus (eq, ":tr", "trp_player"), (call_script, "script_get_faction_rank", "fac_gondor"), (assign, ":rank", reg0), (troop_get_slot, ":subfac", "trp_player", slot_troop_subfaction), (ge, ":subfac",0), (try_begin), (this_or_next|eq, ":subfac", subfac_regular), ( eq, ":subfac", subfac_blackroot), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e04"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e03"), (else_try), (assign, ":bm", "mesh_banner_e02"), (try_end), (else_try), (eq, ":subfac", subfac_pinnath_gelin), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e07"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e06"), (else_try), (assign, ":bm", "mesh_banner_e05"), (try_end), (else_try), (eq, ":subfac", subfac_ethring), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e11"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e10"), (else_try), (assign, ":bm", "mesh_banner_e09"), (try_end), (else_try), (eq, ":subfac", subfac_pelargir), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e13"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e14"), (else_try), (assign, ":bm", "mesh_banner_e12"), (try_end), (else_try), (eq, ":subfac", subfac_dol_amroth), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e18"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e17"), (else_try), (assign, ":bm", "mesh_banner_e16"), (try_end), (else_try), (eq, ":subfac", subfac_lossarnach), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_f21"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e21"), (else_try), (assign, ":bm", "mesh_banner_e19"), (try_end), (try_end), ##Kham - Player Subfac Tableaus END (else_try) ,(troop_get_slot,":b",":tr",slot_troop_banner_scene_prop),(neq,":b",0),(assign,":bm",":b"), # for other troops get mesh from banner slot (try_end), (try_end), (cur_item_set_tableau_material, ":tableau_no",":bm"), ]), ("TLD_gondor_square_shield_banner", [ (store_script_param, ":tableau_no",1),(store_script_param, ":agent_no", 2),(store_script_param, ":tr", 3), (assign, ":bm", "mesh_banner_gondor"), #default tableau black (try_begin),(neq,":agent_no",-1), (try_begin),(is_between,":tr","trp_i1_pel_watchman","trp_i1_lam_clansman"),(assign, ":bm", "mesh_banner_e13"), (else_try) ,(is_between,":tr","trp_steward_guard" ,"trp_a4_ithilien_ranger" ),(assign, ":bm", "mesh_banner_e15"), (else_try) ,(eq, ":tr", "trp_knight_1_4" ), (assign, ":bm", "mesh_banner_e14"), #Orthalion (else_try), ##Kham - Player Subfac Tableaus (eq, ":tr", "trp_player"), (call_script, "script_get_faction_rank", "fac_gondor"), (assign, ":rank", reg0), (troop_get_slot, ":subfac", "trp_player", slot_troop_subfaction), (ge, ":subfac",0), (try_begin), (this_or_next|eq, ":subfac", subfac_regular), ( eq, ":subfac", subfac_blackroot), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e04"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e03"), (else_try), (assign, ":bm", "mesh_banner_e02"), (try_end), (else_try), (eq, ":subfac", subfac_pinnath_gelin), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e07"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e06"), (else_try), (assign, ":bm", "mesh_banner_e05"), (try_end), (else_try), (eq, ":subfac", subfac_ethring), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e11"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e10"), (else_try), (assign, ":bm", "mesh_banner_e09"), (try_end), (else_try), (eq, ":subfac", subfac_pelargir), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e13"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e14"), (else_try), (assign, ":bm", "mesh_banner_e12"), (try_end), (else_try), (eq, ":subfac", subfac_dol_amroth), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_e18"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e17"), (else_try), (assign, ":bm", "mesh_banner_e16"), (try_end), (else_try), (eq, ":subfac", subfac_lossarnach), (try_begin), (ge, ":rank", 7), (assign, ":bm", "mesh_banner_f21"), (else_try), (is_between, ":rank", 3, 7), (assign, ":bm", "mesh_banner_e21"), (else_try), (assign, ":bm", "mesh_banner_e19"), (try_end), (try_end), ##Kham - Player Subfac Tableaus END (try_end), (try_end), (cur_item_set_tableau_material, ":tableau_no",":bm"), ]), # script_tld_get_rumor_to_s61 # Input: troop, center, agent # Output: s61 will contain rumor string ("tld_get_rumor_to_s61", [(store_script_param, ":troop", 1), (store_script_param, ":center", 2), (store_script_param, ":agent", 3), #check rumor heard already (once a day), troop slot for merchants/lords/etc, center slots for walkers (assign, ":no_new_rumor", 0), (agent_get_entry_no, ":entry_no", ":agent"), (try_begin), (is_between,":entry_no", town_walker_entries_start, town_walker_entries_start+num_town_walkers), (val_add, ":entry_no", slot_center_rumor_check_begin), (try_begin), (party_slot_eq, ":center", ":entry_no", 1), # rumor heard earlier (assign, ":no_new_rumor", 1), (else_try), (party_set_slot, ":center", ":entry_no", 1), # rumor set as already heard (try_end), (else_try), (try_begin), (troop_slot_eq, ":troop", slot_troop_rumor_check, 1), # rumor heard earlier (assign, ":no_new_rumor", 1), (else_try), (troop_set_slot, ":troop", slot_troop_rumor_check, 1), # rumor set as already heard (try_end), (try_end), (try_begin), (eq,":no_new_rumor", 1), # agent knows nothing new (str_store_string, s61, "str_last_rumor"), (else_try), (store_random_in_range,":rumor_type",0,100), (store_troop_faction,":faction","$g_talk_troop"), (try_begin), (is_between, ":rumor_type", 0, 80), #faction specific rumors (faction_get_slot,":rumors_begin",":faction",slot_faction_rumors_begin), (faction_get_slot,":rumors_end" ,":faction",slot_faction_rumors_end), (store_random_in_range,":string",":rumors_begin",":rumors_end"), (try_begin), (lt, ":rumor_type", 40), (call_script, "script_change_player_relation_with_center", "$current_town", 1), (lt, ":rumor_type", 20), (call_script, "script_increase_rank", ":faction", 1), (try_end), (else_try), (is_between, ":rumor_type", 80, 95), #generic rumors (add_xp_as_reward, ":rumor_type"), (faction_get_slot,":faction_side",":faction",slot_faction_side), (try_begin), (eq,":faction_side",faction_side_good), (store_random_in_range,":string","str_good_rumor_begin","str_evil_rumor_begin"), #good guys get good and neutral rumors (else_try), (store_random_in_range,":string","str_neutral_rumor_begin","str_legendary_rumor_begin"), (try_end), (else_try), (is_between, ":rumor_type", 95, 100), #legendary rumors (store_random_in_range,":string","str_legendary_rumor_begin","str_last_rumor"), (try_begin), (eq, ":string", "str_legendary_rumor_amonhen"), (neg|party_is_active, "p_legend_amonhen"), (enable_party, "p_legend_amonhen"), (display_log_message, "@A new location is now available on the map!", color_good_news), (party_set_slot, "p_legend_amonhen", slot_legendary_visited, 0), (party_set_slot, "p_legend_amonhen", slot_legendary_explored, 0), (else_try), (eq, ":string", "str_legendary_rumor_deadmarshes"), (neg|party_is_active, "p_legend_deadmarshes"), (enable_party, "p_legend_deadmarshes"), (display_log_message, "@A new location is now available on the map!", color_good_news), (party_set_slot, "p_legend_amonhen", slot_legendary_visited, 0), (party_set_slot, "p_legend_amonhen", slot_legendary_explored, 0), (else_try), (eq, ":string", "str_legendary_rumor_mirkwood"), (neg|party_is_active, "p_legend_mirkwood"), (enable_party, "p_legend_mirkwood"), (display_log_message, "@A new location is now available on the map!", color_good_news), (party_set_slot, "p_legend_amonhen", slot_legendary_visited, 0), (party_set_slot, "p_legend_amonhen", slot_legendary_explored, 0), (else_try), (this_or_next|eq, ":string", "str_legendary_rumor_begin"), (eq, ":string", "str_legendary_rumor_fangorn"), (faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), # evil guys can't uncover Entmoot (neg|party_is_active, "p_legend_fangorn"), (enable_party, "p_legend_fangorn"), (display_log_message, "@A new location is now available on the map!", color_good_news), (party_set_slot, "p_legend_amonhen", slot_legendary_visited, 0), (party_set_slot, "p_legend_amonhen", slot_legendary_explored, 0), (try_end), (try_end), (str_store_string, s61, ":string"), (try_end), ]), ##### TLD 808 TRAITS ###############################################################3 #script_gain_trait #input: trait number - see slot_trait_* ("gain_trait",[ (store_script_param, ":trait", 1), (troop_set_slot, "trp_traits", ":trait", 1), # Title string = First title string + 2*(slot-1) (store_sub, ":title_string", ":trait", 1), (val_add, ":title_string", ":title_string"), (val_add, ":title_string", tld_first_trait_string), (str_store_string, s5, ":title_string"), (display_log_message, "@New trait gained: {s5}.", color_good_news), (play_sound, "snd_gong"), ]), #script_cf_gain_trait_blessed ("cf_gain_trait_blessed",[ (troop_slot_eq, "trp_traits", slot_trait_blessed, 0), (troop_get_type, ":race","$g_player_troop"), (neg|is_between, ":race", tf_orc_begin, tf_orc_end), (call_script, "script_gain_trait", slot_trait_blessed), (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, 20), (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, 20), (troop_raise_proficiency_linear, "trp_player", wpt_polearm, 20), (troop_raise_proficiency_linear, "trp_player", wpt_archery, 20), (troop_raise_proficiency_linear, "trp_player", wpt_throwing, 20), (troop_raise_attribute, "trp_player", ca_strength, 1), (troop_raise_attribute, "trp_player", ca_agility , 1), (troop_raise_attribute, "trp_player", ca_charisma, 1), (display_log_message, "@Gained permanent +1 to Strength.", color_good_news), (display_log_message, "@Gained permanent +1 to Agility.", color_good_news), (display_log_message, "@Gained permanent +1 to Charisma.", color_good_news), (display_log_message, "@Gained permanent +20 to weapon proficiencies.", color_good_news), ]), #script_cf_gain_trait_reverent ("cf_gain_trait_reverent",[ (troop_slot_eq, "trp_traits", slot_trait_reverent, 0), (call_script, "script_gain_trait", slot_trait_reverent), ]), #script_cf_gain_trait_merciful ("cf_gain_trait_merciful",[ (troop_slot_eq, "trp_traits", slot_trait_merciful, 0), (call_script, "script_gain_trait", slot_trait_merciful), ]), #script_cf_gain_trait_elf_friend ("cf_gain_trait_elf_friend",[ (troop_slot_eq, "trp_traits", slot_trait_elf_friend, 0), (call_script, "script_gain_trait", slot_trait_elf_friend), ]), #script_cf_gain_trait_kings_man ("cf_gain_trait_kings_man",[ (troop_slot_eq, "trp_traits", slot_trait_rohan_friend, 0), (call_script, "script_gain_trait", slot_trait_rohan_friend), ]), #script_cf_gain_trait_stewards_blessing ("cf_gain_trait_stewards_blessing",[ (troop_slot_eq, "trp_traits", slot_trait_gondor_friend, 0), (call_script, "script_gain_trait", slot_trait_gondor_friend), ]), #script_cf_gain_trait_brigand_friend ("cf_gain_trait_brigand_friend",[ (troop_slot_eq, "trp_traits", slot_trait_brigand_friend, 0), (call_script, "script_gain_trait", slot_trait_brigand_friend), ]), #script_cf_gain_trait_oathkeeper ("cf_gain_trait_oathkeeper",[ (troop_slot_eq, "trp_traits", slot_trait_oathkeeper, 0), (try_begin), (troop_slot_eq, "trp_traits", slot_trait_oathbreaker, 1), (troop_set_slot, "trp_traits", slot_trait_oathbreaker, 0), (try_end), (call_script, "script_gain_trait", slot_trait_oathkeeper), ]), #script_cf_gain_trait_oathbreaker ("cf_gain_trait_oathbreaker",[ (troop_slot_eq, "trp_traits", slot_trait_oathbreaker, 0), (try_begin), (troop_slot_eq, "trp_traits", slot_trait_oathkeeper, 1), (troop_set_slot, "trp_traits", slot_trait_oathkeeper, 0), (try_end), (call_script, "script_gain_trait", slot_trait_oathbreaker), ]), #script_cf_gain_trait_orc_pit_champion ("cf_gain_trait_orc_pit_champion",[ (troop_slot_eq, "trp_traits", slot_trait_orc_pit_champion, 0), (call_script, "script_gain_trait", slot_trait_orc_pit_champion), ]), #script_cf_gain_trait_despoiler ("cf_gain_trait_despoiler",[ (troop_slot_eq, "trp_traits", slot_trait_despoiler, 0), (call_script, "script_gain_trait", slot_trait_despoiler), ]), #script_cf_gain_trait_accursed ("cf_gain_trait_accursed",[ (troop_slot_eq, "trp_traits", slot_trait_accursed, 0), (call_script, "script_gain_trait", slot_trait_accursed), ]), #script_cf_gain_trait_berserker ("cf_gain_trait_berserker",[ (troop_slot_eq, "trp_traits", slot_trait_berserker, 0), (troop_raise_attribute, "trp_player", ca_strength, 2), (display_log_message, "@Gained permanent +2 to Strength.", color_good_news), (call_script, "script_gain_trait", slot_trait_berserker), ]), #script_cf_gain_trait_stealthy ("cf_gain_trait_stealthy",[ (troop_slot_eq, "trp_traits", slot_trait_stealthy, 0), (call_script, "script_gain_trait", slot_trait_stealthy), ]), #script_cf_gain_trait_infantry_captain ("cf_gain_trait_infantry_captain",[ (troop_slot_eq, "trp_traits", slot_trait_infantry_captain, 0), (call_script, "script_gain_trait", slot_trait_infantry_captain), ]), #script_cf_gain_trait_archer_captain ("cf_gain_trait_archer_captain",[ (troop_slot_eq, "trp_traits", slot_trait_archer_captain, 0), (call_script, "script_gain_trait", slot_trait_archer_captain), ]), #script_cf_gain_trait_cavalry_captain ("cf_gain_trait_cavalry_captain",[ (troop_slot_eq, "trp_traits", slot_trait_cavalry_captain, 0), (call_script, "script_gain_trait", slot_trait_cavalry_captain), ]), #script_cf_gain_trait_command_voice ("cf_gain_trait_command_voice",[ (troop_slot_eq, "trp_traits", slot_trait_command_voice, 0), (troop_get_type, ":race","$g_player_troop"), (neg|is_between, ":race", tf_orc_begin, tf_orc_end), (troop_raise_attribute, "trp_player", ca_charisma, 2), (display_log_message, "@Gained permanent +2 to Charisma.", color_good_news), (call_script, "script_gain_trait", slot_trait_command_voice), ]), #script_cf_gain_trait_battle_scarred ("cf_gain_trait_battle_scarred",[ (troop_slot_eq, "trp_traits", slot_trait_battle_scarred, 0), (troop_get_type, ":race","$g_player_troop"), (neg|is_between, ":race", tf_orc_begin, tf_orc_end), (call_script, "script_gain_trait", slot_trait_battle_scarred), (troop_raise_attribute, "trp_player", ca_charisma, -1), (display_log_message, "@Lost permanent -1 to Charisma.", color_bad_news), (store_skill_level, ":skill", skl_ironflesh, "trp_player"), (neg|ge, ":skill", 10), (troop_raise_skill, "trp_player", skl_ironflesh, 1), (display_log_message, "@Gained permanent +1 to Ironflesh.", color_good_news), ]), #script_cf_gain_trait_fell_beast ("cf_gain_trait_fell_beast",[ (troop_slot_eq, "trp_traits", slot_trait_fell_beast, 0), (troop_get_type, ":race","$g_player_troop"), (is_between, ":race", tf_orc_begin, tf_orc_end), (troop_raise_attribute, "trp_player", ca_strength, 5), (display_log_message, "@Gained permanent +5 to Strength.", color_good_news), (troop_raise_attribute, "trp_player", ca_charisma, -2), (display_log_message, "@Lost permanent -2 to Charisma.", color_bad_news), (store_skill_level, ":skill", skl_ironflesh, "trp_player"), (try_begin),(lt, ":skill",9),(troop_raise_skill, "trp_player", skl_ironflesh, 2), (display_log_message, "@Gained permanent +2 to Ironflesh.", color_good_news), (else_try),(eq, ":skill",9),(troop_raise_skill, "trp_player", skl_ironflesh, 1), (display_log_message, "@Gained permanent +1 to Ironflesh.", color_good_news), (try_end), (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, 10), (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, 10), (troop_raise_proficiency_linear, "trp_player", wpt_polearm, 10), (troop_raise_proficiency_linear, "trp_player", wpt_archery, 10), (troop_raise_proficiency_linear, "trp_player", wpt_throwing, 10), (display_log_message, "@Gained permanent +10 to weapon proficiencies.", color_good_news), (call_script, "script_gain_trait", slot_trait_fell_beast), ]), #script_cf_gain_trait_foe_hammer ("cf_gain_trait_foe_hammer",[ (troop_slot_eq, "trp_traits", slot_trait_foe_hammer, 0), (troop_raise_proficiency_linear, "trp_player", wpt_one_handed_weapon, 10), (troop_raise_proficiency_linear, "trp_player", wpt_two_handed_weapon, 10), (troop_raise_proficiency_linear, "trp_player", wpt_polearm, 10), (troop_raise_proficiency_linear, "trp_player", wpt_archery, 10), (troop_raise_proficiency_linear, "trp_player", wpt_throwing, 10), (display_log_message, "@Gained permanent +10 to weapon proficiencies.", color_good_news), (call_script, "script_gain_trait", slot_trait_foe_hammer), (store_skill_level, ":skill", skl_tactics, "trp_player"), (neg|ge, ":skill", 10), (troop_raise_skill, "trp_player", skl_tactics, 1), (display_log_message, "@Gained permanent +1 to Tactics.", color_good_news), ]), #script_cf_check_trait_captain ("cf_check_trait_captain",[ (troop_slot_eq, "trp_traits", slot_trait_archer_captain, 0), (troop_slot_eq, "trp_traits", slot_trait_infantry_captain, 0), (troop_slot_eq, "trp_traits", slot_trait_cavalry_captain, 0), (party_get_num_companions, ":party_size", "p_main_party"), (ge, ":party_size", 50), #MV: has to command a sizable party to be called Captain (party_get_num_companion_stacks, ":numstacks", "p_main_party"), (assign, ":inf_count", 0), (assign, ":arc_count", 0), (assign, ":cav_count", 0), (try_for_range, ":stack", 1, ":numstacks"), (party_stack_get_troop_id, ":troop_type", "p_main_party", ":stack"), (party_stack_get_size, ":stack_size", "p_main_party", ":stack"), #MV: added this, so all troops are counted, not just types #(party_stack_get_troop_id, ":troop", "p_main_party", ":stack"), #(troop_get_slot, ":troop_type", ":troop", 6), #MV: whatever was kept here, it's not there now (try_begin), (neg|troop_is_guarantee_ranged, ":troop_type"), (neg|troop_is_mounted, ":troop_type"), (store_character_level, ":level", ":troop_type"), (ge, ":level", 10), (val_add, ":inf_count", ":stack_size"), (else_try), (troop_is_guarantee_ranged, ":troop_type"), (neg|troop_is_mounted, ":troop_type"), (val_add, ":arc_count", ":stack_size"), (else_try), (troop_is_mounted, ":troop_type"), (val_add, ":cav_count", ":stack_size"), (try_end), (try_end), (try_begin), (gt, ":inf_count", ":arc_count"), (gt, ":inf_count", ":cav_count"), (val_add, "$trait_captain_infantry_week", 1), (else_try), (gt, ":arc_count", ":inf_count"), (gt, ":arc_count", ":cav_count"), (val_add, "$trait_captain_archer_week", 1), (else_try), (gt, ":cav_count", ":arc_count"), (gt, ":cav_count", ":inf_count"), (val_add, "$trait_captain_cavalry_week", 1), (try_end), (store_skill_level, ":level", skl_leadership, "trp_player"), (ge, ":level", 6), (store_random,":rnd", 100), (try_begin), (gt, "$trait_captain_infantry_week", "$trait_captain_archer_week"), (gt, "$trait_captain_infantry_week", "$trait_captain_cavalry_week"), (assign, ":accumulated_captain", "$trait_captain_infantry_week"), (val_mul, ":accumulated_captain", 10), (neg|ge, ":rnd", ":accumulated_captain"), (call_script, "script_cf_gain_trait_infantry_captain"), (else_try), (gt, "$trait_captain_archer_week", "$trait_captain_infantry_week"), (gt, "$trait_captain_archer_week", "$trait_captain_cavalry_week"), (assign, ":accumulated_captain", "$trait_captain_archer_week"), (val_mul, ":accumulated_captain", 10), (neg|ge, ":rnd", ":accumulated_captain"), (call_script, "script_cf_gain_trait_archer_captain"), (else_try), (gt, "$trait_captain_cavalry_week", "$trait_captain_archer_week"), (gt, "$trait_captain_cavalry_week", "$trait_captain_infantry_week"), (assign, ":accumulated_captain", "$trait_captain_cavalry_week"), (val_mul, ":accumulated_captain", 10), (neg|ge, ":rnd", ":accumulated_captain"), (call_script, "script_cf_gain_trait_cavalry_captain"), (try_end), ]), #script_check_agent_armor ("check_agent_armor",[ (try_begin), (troop_slot_eq, "trp_traits", slot_trait_berserker, 0), (troop_get_inventory_slot, ":armor", "trp_player", ek_body), (try_begin), (this_or_next|neg|ge, ":armor", 1), (item_slot_eq, ":armor", slot_item_light_armor, 1), (store_random_in_range, ":x", 0, 2), (val_add, "$trait_check_unarmored_berserker", ":x"), (try_end), (try_end), ]), ############### HEALING AND DEATH FROM 808 modified by GA ############################ #script_injury_routine #Input: npc to injure ("injury_routine",[ (store_script_param_1, ":npc"), (str_store_troop_name, s1, ":npc"), (try_begin), (eq,":npc", "trp_player"), (str_store_string,s11,"@You_have"), (val_add, "$trait_check_battle_scarred", 1), #MV (else_try), (str_store_string,s11,"@{s1}_has"), (try_end), (store_random, ":rnd", "$wound_setting"), (troop_get_slot, ":wound_mask", ":npc", slot_troop_wound_mask), (try_begin), (eq, ":rnd", 0), (store_and, ":x", ":wound_mask", wound_leg), (eq, ":x", 0), #(store_skill_level,":x",skl_riding ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_riding, ":x"), #(store_skill_level,":x",skl_athletics,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_athletics, ":x"), (troop_raise_attribute, ":npc", ca_agility, -2), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, -15), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, -15), (troop_raise_proficiency_linear, ":npc", wpt_polearm, -15), (val_or, ":wound_mask", wound_leg), (troop_set_slot, ":npc", slot_troop_wound_mask, ":wound_mask"), (display_message, "@{s11}_suffered_a_serious_wound.", color_bad_news), (display_message, "@The_leg_has_been_badly_maimed_in_battle."), (display_message, "@(-2_athletics,_-1_riding,_-2_agility,_-15_melee_skill)"), (else_try), (eq, ":rnd", 1), (store_and, ":x", ":wound_mask", wound_arm), (eq, ":x", 0), #(store_skill_level,":x",skl_power_draw ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_power_draw ,":x"), #(store_skill_level,":x",skl_power_throw ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_power_throw ,":x"), #(store_skill_level,":x",skl_power_strike,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_power_strike,":x"), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, -20), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, -20), (troop_raise_proficiency_linear, ":npc", wpt_polearm, -20), (troop_raise_proficiency_linear, ":npc", wpt_archery, -20), (troop_raise_proficiency_linear, ":npc", wpt_throwing, -20), (troop_raise_attribute, ":npc", ca_strength, -2), (val_or, ":wound_mask", wound_arm), (troop_set_slot, ":npc", slot_troop_wound_mask, ":wound_mask"), (display_message, "@{s11}_suffered_a_serious_wound.", color_bad_news), (display_message, "@The_arm_has_been_badly_maimed_in_battle."), (display_message, "@(-20_weapon_skill,_-2_strength,_-1_power_attacks)"), (else_try), (eq, ":rnd", 2), (store_and, ":x", ":wound_mask", wound_head), (eq, ":x", 0), #(store_skill_level,":x",skl_trade ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_trade, ":x"), #(store_skill_level,":x",skl_first_aid ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_first_aid, ":x"), #(store_skill_level,":x",skl_surgery ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_surgery, ":x"), #(store_skill_level,":x",skl_wound_treatment,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_wound_treatment, ":x"), #(store_skill_level,":x",skl_spotting ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_spotting, ":x"), #(store_skill_level,":x",skl_pathfinding ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_pathfinding, ":x"), #(store_skill_level,":x",skl_tactics ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_tactics, ":x"), #(store_skill_level,":x",skl_tracking ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_tracking, ":x"), #(store_skill_level,":x",skl_trainer ,":npc"),(val_min,":x",1),(val_mul,":x",-1),(troop_raise_skill,":npc",skl_trainer, ":x"), (troop_raise_proficiency_linear, ":npc", wpt_archery , -15), (troop_raise_proficiency_linear, ":npc", wpt_throwing, -15), (val_or, ":wound_mask", wound_head), (troop_set_slot, ":npc", slot_troop_wound_mask, ":wound_mask"), (display_message, "@{s11}_suffered_a_serious_wound.", color_bad_news), (display_message, "@The_head_has_suffered_a_heavy_blow."), (display_message, "@(-1_intelligence_skills,_-15_missile_skill)"), (else_try), (eq, ":rnd", 3), (store_and, ":x", ":wound_mask", wound_chest), (eq, ":x", 0), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, -20), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, -20), (troop_raise_proficiency_linear, ":npc", wpt_polearm, -20), (troop_raise_proficiency_linear, ":npc", wpt_archery, -20), (troop_raise_proficiency_linear, ":npc", wpt_throwing, -20), (val_or, ":wound_mask", wound_chest), (troop_set_slot, ":npc", slot_troop_wound_mask, ":wound_mask"), (display_message, "@{s11}_suffered_a_serious_wound.", color_bad_news), (display_message, "@The_chest_has_suffered_some_cracked_ribs."), (display_message, "@(-20_weapon_skill)"), (else_try), (eq, ":rnd", 4), (assign, ":wounds", 0), #count # of wounds (try_begin),(store_and,":x",":wound_mask",wound_leg ),(neq,":x",0),(val_add,":wounds",1),(try_end), (try_begin),(store_and,":x",":wound_mask",wound_arm ),(neq,":x",0),(val_add,":wounds",1),(try_end), (try_begin),(store_and,":x",":wound_mask",wound_head ),(neq,":x",0),(val_add,":wounds",1),(try_end), (try_begin),(store_and,":x",":wound_mask",wound_chest),(neq,":x",0),(val_add,":wounds",1),(try_end), (val_mul, ":wounds", 10), (store_random, ":rnd", 100), (neg|ge, ":rnd", ":wounds"), (try_begin), (neq,":npc", "trp_player"), (eq, "$tld_option_death_npc", 1), (display_message, "@{s1}_has_been_killed.", color_bad_news), (troop_set_slot, ":npc", slot_troop_wound_mask, wound_death), (remove_member_from_party,":npc","p_main_party"), (add_troop_to_site, ":npc", "scn_erebor_castle_2", 0), #Teleport them somewhere else! (call_script, "script_build_mound_for_dead_hero", ":npc", "p_main_party"), (else_try), (eq,":npc", "trp_player"), (eq, "$tld_option_death_player", 1), (display_message, "@You_were_killed.", color_bad_news), #(assign, "$g_tutorial_entered", 1), (finish_mission, 1), (jump_to_menu, "mnu_death"), #should be mnu_death here (try_end), (try_end), ]), #script_healing_routine ("healing_routine",[ (store_script_param_1, ":npc"), (str_store_troop_name, s1, ":npc"), (try_begin), (eq,":npc", "trp_player"), (str_store_string,s11,"@You_have"), (else_try), (str_store_string,s11,"@{s1}_has"), (try_end), (troop_get_slot, ":wound_mask", ":npc", slot_troop_wound_mask), (try_begin), (neq, ":wound_mask", 0), # only injured heroes apply (neq, ":wound_mask", wound_death),# only alive heroes apply (store_random_in_range, ":rnd", 0, "$healing_setting"), (str_store_troop_name, s1, ":npc"), (try_begin), (eq, ":rnd", 0), (store_and, ":check", ":wound_mask", wound_leg), (neq, ":check", 0), #(store_skill_level,":skill",skl_riding ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_riding, ":x"), #(store_skill_level,":skill",skl_athletics,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",2),(troop_raise_skill,":npc",skl_athletics, ":x"), (troop_raise_attribute, ":npc", ca_agility, 2), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, 15), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, 15), (troop_raise_proficiency_linear, ":npc", wpt_polearm, 15), (val_sub, ":wound_mask", wound_leg), (display_message, "@{s1}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_leg_wound_has_healed."), (display_message, "@(+2_athletics,_+1_riding,_+2_agility,_+15_melee_skill)"), (else_try), (eq, ":rnd", 1), (store_and, ":check", ":wound_mask", wound_arm), (neq, ":check", 0), #(store_skill_level,":skill",skl_power_draw ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_power_draw, ":x"), #(store_skill_level,":skill",skl_power_throw ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_power_throw, ":x"), #(store_skill_level,":skill",skl_power_strike,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_power_strike, ":x"), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_polearm, 20), (troop_raise_proficiency_linear, ":npc", wpt_archery, 20), (troop_raise_proficiency_linear, ":npc", wpt_throwing, 20), (troop_raise_attribute, ":npc", ca_strength, 2), (val_sub, ":wound_mask", wound_arm), (display_message, "@{s1}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_arm_wound_has_healed."), (display_message, "@(+20_weapon_skill,_+2_strength,_+1_power_attacks)"), (else_try), (eq, ":rnd", 2), (store_and, ":check", ":wound_mask", wound_head), (neq, ":check", 0), #(store_skill_level,":skill",skl_trade ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_trade, ":x"), #(store_skill_level,":skill",skl_first_aid ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_first_aid, ":x"), #(store_skill_level,":skill",skl_surgery ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_surgery, ":x"), #(store_skill_level,":skill",skl_wound_treatment,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_wound_treatment, ":x"), #(store_skill_level,":skill",skl_pathfinding ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_pathfinding, ":x"), #(store_skill_level,":skill",skl_spotting ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_spotting, ":x"), #(store_skill_level,":skill",skl_tracking ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_tracking, ":x"), #(store_skill_level,":skill",skl_tactics ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_tactics, ":x"), #(store_skill_level,":skill",skl_trainer ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_trainer, ":x"), (troop_raise_proficiency_linear, ":npc", wpt_archery, 15), (troop_raise_proficiency_linear, ":npc", wpt_throwing, 15), (val_sub, ":wound_mask", wound_head), (display_message, "@{s1}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_head_wound_has_healed."), (display_message, "@(+1_intelligence_skills,_+15_missile_skill)"), (else_try), (eq, ":rnd", 3), (store_and, ":check", ":wound_mask", wound_chest), (neq, ":check", 0), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_polearm, 20), (troop_raise_proficiency_linear, ":npc", wpt_archery, 20), (troop_raise_proficiency_linear, ":npc", wpt_throwing, 20), (val_sub, ":wound_mask", wound_chest), (display_message, "@{s1}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_cracked_ribs_have_healed."), (display_message, "@(+20_weapon_skill)"), (try_end), (troop_set_slot, ":npc", slot_troop_wound_mask, ":wound_mask"), (store_troop_health, ":x", ":npc", 0), (val_add, ":x", 10), (troop_set_health, ":npc", ":x"), (try_end), ]), #script_heal_party ("heal_party",[ (store_random, ":rnd", 4), (try_begin), (eq, ":rnd", 0), (heal_party, "p_main_party"), (else_try), (try_for_range, ":npc", companions_begin, new_companions_end), (this_or_next|is_between, ":npc", companions_begin, companions_end), (is_between, ":npc", new_companions_begin, new_companions_end), (party_count_companions_of_type, ":num", "p_main_party", ":npc"), (eq, ":num", 1), (store_troop_health, ":hp", ":npc", 0), (val_mul, ":hp", 10), (val_div, ":hp", 7), (troop_set_health, ":npc", ":hp"), (try_end), (store_troop_health, ":hp", "trp_player", 0), (val_mul, ":hp", 10), (val_div, ":hp", 7), (troop_set_health, "trp_player", ":hp"), (try_end), ]), #script_optional_healing_boost ("cf_optional_healing_boost",[ #(neg|eq, "$healing_boost_setting", 0), (try_begin), (store_troop_health, ":hp", "trp_player", 0), # (try_begin), # (eq, "$healing_boost_setting", 20), (val_mul, ":hp", 10), (val_div, ":hp", 8), # (else_try), # (eq, "$healing_boost_setting", 10), # (val_mul, ":hp", 10), # (val_div, ":hp", 9), # (try_end), (troop_set_health, "trp_player", ":hp"), (try_end), (try_for_range, ":troop", companions_begin, new_companions_end), (this_or_next|is_between, ":troop", companions_begin, companions_end), (is_between, ":troop", new_companions_begin, new_companions_end), (troop_get_slot, ":local3", ":troop", 0), (eq, ":local3", 1), (store_troop_health, ":hp", ":troop", 0), (neg|ge, ":hp", 100), # (try_begin), # (eq, "$healing_boost_setting", 20), (val_mul, ":hp", 10), (val_div, ":hp", 8), # (else_try), # (eq, "$healing_boost_setting", 10), # (val_mul, ":hp", 10), # (val_div, ":hp", 9), # (try_end), (troop_set_health, ":troop", ":hp"), (str_store_troop_name, s1, ":troop"), (display_message, "@{s1}_has_had_his_health_boosted", 0), (try_end), ]), #script_hero_leader_killed_abstractly ("hero_leader_killed_abstractly",[ (store_script_param_1, ":hero"), (store_script_param_2, ":place"), (store_faction_of_party, ":place_faction", ":place"), (str_store_faction_name, s28, ":place_faction"), (troop_set_slot, ":hero", slot_troop_wound_mask, wound_death), (str_store_troop_name, s1, ":hero"), (store_troop_faction,":fac",":hero"), (str_store_faction_name, s2, ":fac"), (assign, ":news_color", color_bad_news), (try_begin), (store_relation, ":rel", "$players_kingdom", ":fac"), (lt, ":rel", 0), (assign, ":news_color", color_good_news), (play_sound, "snd_enemy_lord_dies"), (else_try), (play_sound, "snd_lord_dies"), (try_end), (display_message, "@News_has_arrived_that_{s1}_of_{s2}_was_killed_in_battle_by_the_forces_of_{s28}!", ":news_color"), (call_script,"script_build_mound_for_dead_hero",":hero",":place"), (call_script, "script_update_troop_notes", ":hero"), ]), #script_build_mound_for_dead_hero ("build_mound_for_dead_hero",[ (store_script_param_1, ":hero"), (store_script_param_2, ":place"), (troop_set_slot, ":hero", slot_troop_wound_mask, wound_death), (str_store_troop_name, s1, ":hero"), (store_troop_faction,":fac",":hero"), (store_faction_of_party, ":place_faction", ":place"), #(set_spawn_radius, 0), (try_begin), (faction_slot_eq, ":fac", slot_faction_side, faction_side_good), #(spawn_around_party, ":place", "pt_mound"), (call_script,"script_cf_spawn_around_party_on_walkable_terrain",":place", "pt_mound",3), (party_set_name, reg0, "@{s1}'s_Burial_Mound"), (else_try), #(spawn_around_party, ":place", "pt_pyre"), (call_script,"script_cf_spawn_around_party_on_walkable_terrain",":place", "pt_pyre",3), (party_set_name, reg0, "@{s1}'s_Funeral_Pyre"), (try_end), #(party_set_faction,reg0,":fac"), (party_set_slot, reg0, slot_mound_state, 1), (party_set_slot, reg0, slot_party_commander_party, ":hero"), (party_set_slot, reg0, slot_mound_killer_faction, ":place_faction"), (call_script, "script_move_party_to_hardcoded_locations", reg0), #Checks if party needs to be moved. ]), #script_display_dead_heroes ("display_dead_heroes",[ (try_for_range, ":hero", heroes_begin, heroes_end), (troop_slot_eq, ":hero", slot_troop_wound_mask, wound_death), (str_store_troop_name, s1, ":hero"), (display_message, "@{s1}_is_logged_as_dead"), (try_end), ]), ############ HEALING AND DEATH FROM 808 ENDS ############################################## ############ RESCUE & STEALTH FROM 808 BEGINS############################################## #script_rescue_information ("rescue_information",[ (try_begin), (eq, "$rescue_stage", 0), (display_message, "@You_have_been_discovered_before_scaling_the_wall.", color_bad_news), (display_message, "@The_enemy_is_coming_in_force,_you_must_flee!", color_bad_news), (else_try), (eq, "$rescue_stage", 1), (display_message, "@Scout_this_area_alone_and_meet_your_men_beyond!"), (display_message, "@Be_stealthy_but_eliminate_any_threats_quickly!"), (else_try), (eq, "$rescue_stage", 2), (display_message, "@You_are_spotted_by_a_patrol!", color_bad_news), (display_message, "@Eliminate_them_before_the_alarm_spreads!", color_bad_news), (else_try), (eq, "$rescue_stage", 3), (display_message, "@Scout_this_area_alone_and_meet_your_men_beyond!"), (display_message, "@Be_stealthy_but_eliminate_any_threats_quickly!"), (else_try), (eq, "$rescue_stage", 4), (display_message, "@You_are_spotted_by_a_patrol!", color_bad_news), (display_message, "@Eliminate_them_before_the_alarm_spreads!", color_bad_news), (else_try), (eq, "$rescue_stage", 5), (display_message, "@You_have_reached_the_dungeons!"), (display_message, "@Eliminate_the_guards_and_free_your_men!"), (try_end), ]), #script_initialize_general_rescue ("initialize_general_rescue",[ ]), #script_initialize_sorcerer_quest ("initialize_sorcerer_quest",[ (assign, "$meta_alarm", 0), #disabled for now, was random before (assign, "$rescue_courtyard_scene_1", "scn_tld_sorcerer_forest_a"), (assign, "$rescue_stealth_scene_1", "scn_tld_sorcerer_forest_b"), (assign, "$rescue_final_scene", "scn_tld_sorcerer_forest_c"), (assign, "$guard_troop1", "trp_i1_mordor_orc_snaga"), (assign, "$guard_troop2", "trp_i2_mordor_orc"), (assign, "$guard_troop3", "trp_i2_mordor_orc"), (assign, "$guard_troop4", "trp_i2_mordor_orc"), (assign, "$guard_troop5", "trp_a2_mordor_orc_archer"), (assign, "$guard_troop6", "trp_i2_mordor_num_renegade"), (assign, "$guard_troop7", "trp_i3_mordor_large_orc"), (assign, "$guard_troop8", "trp_i4_mordor_fell_orc"), (assign, "$guard_troop9", "trp_i2_mordor_num_renegade"), (assign, "$guard_troop10", "trp_i2_mordor_orc"), ]), #script_final_sorcerer_fight ("final_sorcerer_fight",[ (set_jump_mission, "mt_sorcerer_mission"), (jump_to_scene, "$rescue_final_scene", 0), (reset_visitors), (modify_visitors_at_site, "$rescue_final_scene"), (call_script, "script_set_infiltration_companions"), (set_visitor, 10, "trp_black_numenorean_sorcerer", 0), #InVain: defining sorcerer's bodyguard by player level instead of randomly. Did not touch guard_troops above in case they're used anywhere else. (store_character_level, ":player_level", "trp_player"), (assign, ":spawn_number", "$stealth_results"), #1-4 (val_min, ":spawn_number", 3), (try_begin), (lt, ":player_level", 20), #InVain: First 5 entry points are around the sorcerer (set_visitors, 11, "trp_i2_mordor_orc", ":spawn_number"),(set_visitors, 12, "trp_a2_mordor_orc_archer", ":spawn_number"),(set_visitors, 13, "trp_i2_mordor_num_renegade", ":spawn_number"), (ge, "$meta_alarm", 2),(set_visitors, 14, "trp_i3_mordor_num_warrior", ":spawn_number"),(set_visitors, 15, "trp_i4_mordor_num_vet_warrior", 1), #InVain: Last 5 entry points are further away, troops will arrive later. If he flees, you will encounter them on the way. (ge, "$meta_alarm", 5),(set_visitors, 16, "trp_i3_mordor_large_orc", 2),(set_visitors, 17, "trp_i4_mordor_fell_orc", 2), (ge, "$meta_alarm", 7),(set_visitors, 18, "trp_a2_mordor_orc_archer", 2),(set_visitors, 19, "trp_i3_mordor_large_orc", 2),(set_visitors, 20, "trp_i4_mordor_num_vet_warrior", 1), (else_try), (ge, ":player_level", 20), #Don't change numbers, only troop types. Sorcerer's behavior (flee or join the fight) is conditioned by number of remaining troops. #InVain: First 5 entry points are around the sorcerer (set_visitors, 11, "trp_i3_mordor_large_orc", ":spawn_number"),(set_visitors, 12, "trp_a3_mordor_large_orc_archer", ":spawn_number"),(set_visitors, 13, "trp_i3_mordor_num_warrior", ":spawn_number"), (ge, "$meta_alarm", 2),(set_visitors, 14, "trp_i4_mordor_num_vet_warrior", ":spawn_number"),(set_visitors, 15, "trp_i5_mordor_num_champion", 1), #InVain: Last 5 entry points are further away, troops will arrive later. If he flees, you will encounter them on the way. (ge, "$meta_alarm", 5),(set_visitors, 16, "trp_i4_mordor_fell_orc", 2),(set_visitors, 17, "trp_i4_mordor_fell_uruk", 2), (ge, "$meta_alarm", 7),(set_visitors, 18, "trp_a4_mordor_fell_orc_archer", 2),(set_visitors, 19, "trp_i4_mordor_fell_orc", 2),(set_visitors, 20, "trp_i5_mordor_num_champion", 1), (try_end), # (try_begin), # (is_between, "$meta_alarm", 0, 4), # (set_visitor, 11, "$guard_troop2", 0),(set_visitor, 12, "$guard_troop2", 0),(set_visitor, 13, "$guard_troop3", 0),(set_visitor, 14, "$guard_troop3", 0),(set_visitor, 15, "$guard_troop3", 0),(set_visitor, 16, "$guard_troop4", 0),(set_visitor, 17, "$guard_troop4", 0),(set_visitor, 18, "$guard_troop5", 0),(set_visitor, 19, "$guard_troop5", 0),(set_visitor, 20, "$guard_troop6", 0), # (else_try), # (is_between, "$meta_alarm", 4, 7), # (set_visitor, 11, "$guard_troop3", 0),(set_visitor, 12, "$guard_troop3", 0),(set_visitor, 13, "$guard_troop4", 0),(set_visitor, 14, "$guard_troop4", 0),(set_visitor, 15, "$guard_troop4", 0),(set_visitor, 16, "$guard_troop5", 0),(set_visitor, 17, "$guard_troop5", 0),(set_visitor, 18, "$guard_troop6", 0),(set_visitor, 19, "$guard_troop6", 0),(set_visitor, 20, "$guard_troop7", 0), # (else_try), # (is_between, "$meta_alarm", 7, 9), # (set_visitor, 11, "$guard_troop4", 0),(set_visitor, 12, "$guard_troop4", 0),(set_visitor, 13, "$guard_troop5", 0),(set_visitor, 14, "$guard_troop5", 0),(set_visitor, 15, "$guard_troop5", 0),(set_visitor, 16, "$guard_troop6", 0),(set_visitor, 17, "$guard_troop6", 0),(set_visitor, 18, "$guard_troop7", 0),(set_visitor, 19, "$guard_troop7", 0),(set_visitor, 20, "$guard_troop8", 0), # (else_try), # (ge, "$meta_alarm", 9), # (set_visitor, 11, "$guard_troop5", 0),(set_visitor, 12, "$guard_troop6", 0),(set_visitor, 13, "$guard_troop6", 0),(set_visitor, 14, "$guard_troop7", 0),(set_visitor, 15, "$guard_troop7", 0),(set_visitor, 16, "$guard_troop8", 0),(set_visitor, 17, "$guard_troop8", 0),(set_visitor, 18, "$guard_troop9", 0),(set_visitor, 19, "$guard_troop10",0),(set_visitor, 20, "$guard_troop10",0), # (try_end), ]), #script_set_infiltration_companions ("set_infiltration_companions",[ (set_visitor, 0, "trp_player", 0), (assign, ":entry", 0), (try_for_range, ":faction", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":kia", ":faction", slot_fcomp_kia), (faction_get_slot, ":troop", ":faction", slot_fcomp_troopid), (val_add, ":entry", 1), (neg|eq, ":troop", 0), (neg|eq, ":kia", 1), (set_visitor, ":entry", ":troop", 0), (try_end), ]), #script_set_infiltration_player_record ("set_infiltration_player_record",[ (store_troop_health, ":hp", "trp_player", 0), (faction_set_slot, "fac_mission_companion_10", slot_fcomp_troopid, "trp_player"), (faction_set_slot, "fac_mission_companion_10", slot_fcomp_hp , ":hp"), ]), #script_infiltration_battle_wall ("infiltration_battle_wall",[ (set_jump_mission, "mt_battle_wall_mission"), (reset_visitors), (modify_visitors_at_site, "$rescue_wall_battle"), (try_for_range, reg1, 10, 20), (store_random_in_range, reg2, 1, 6), (try_begin),(eq, reg2, 1),(assign, reg3, "$wall_mounted_troop1"), (else_try),(eq, reg2, 2),(assign, reg3, "$guard_troop3"), (else_try),(eq, reg2, 3),(assign, reg3, "$wall_mounted_troop3"), (else_try),(eq, reg2, 4),(assign, reg3, "$guard_troop4"), (else_try),(eq, reg2, 5),(assign, reg3, "$wall_mounted_troop5"), (try_end), (set_visitor, reg1, reg3, 0), (try_end), (try_for_range, reg1, 23, 27), (store_random_in_range, reg2, 1, 6), (try_begin),(eq, reg2, 1),(assign, reg3, "$wall_missile_troop1"), (else_try),(eq, reg2, 2),(assign, reg3, "$wall_missile_troop2"), (else_try),(eq, reg2, 3),(assign, reg3, "$wall_missile_troop3"), (else_try),(eq, reg2, 4),(assign, reg3, "$wall_missile_troop4"), (else_try),(eq, reg2, 5),(assign, reg3, "$wall_missile_troop5"), (try_end), (set_visitor, reg1, reg3, 0), (try_end), (call_script, "script_set_infiltration_companions"), ]), #script_infiltration_combat_1 ("infiltration_combat_1",[ (set_jump_mission, "mt_infiltration_combat_mission"), (jump_to_scene, "$rescue_courtyard_scene_1", 0), (reset_visitors), (modify_visitors_at_site, "$rescue_courtyard_scene_1"), (call_script, "script_set_infiltration_companions", 0, 0), (assign, reg1, "$guard_troop2"), (assign, reg2, "$guard_troop2"), (assign, reg3, "$guard_troop3"), (assign, reg4, "$guard_troop3"), (assign, reg5, "$guard_troop4"), (assign, reg5, "$guard_troop4"), (assign, reg7, "$guard_troop5"), (assign, reg8, "$guard_troop5"), (assign, reg9, "$guard_troop6"), (assign, reg10, "$guard_troop6"), (assign, reg11, "$guard_troop7"), (assign, reg12, "$guard_troop7"), (assign, reg13, "$guard_troop8"), (assign, reg14, "$guard_troop8"), (assign, reg15, "$guard_troop9"), (assign, reg16, "$guard_troop9"), (assign, reg17, "$guard_troop10"), (store_random_in_range, ":local0", 1, 6), (val_add, ":local0", "$meta_alarm"), (val_min, ":local0", 10), (val_add, ":local0", 10), (assign, ":local1", 7), (val_add, ":local1", "$meta_alarm"), (try_for_range, ":entry", 10, ":local0"), (shuffle_range, 1, ":local1"), (neg|eq, reg1, 0), (set_visitor, ":entry", reg1, 0), (try_end), ]), #script_infiltration_combat_2 ("infiltration_combat_2",[ (set_jump_mission, "mt_infiltration_combat_mission"), (jump_to_scene, "$rescue_courtyard_scene_2", 0), (reset_visitors), (modify_visitors_at_site, "$rescue_courtyard_scene_2"), (call_script, "script_set_infiltration_companions"), (assign, reg1, "$guard_troop2"), (assign, reg2, "$guard_troop2"), (assign, reg3, "$guard_troop3"), (assign, reg4, "$guard_troop3"), (assign, reg5, "$guard_troop4"), (assign, reg5, "$guard_troop4"), (assign, reg7, "$guard_troop5"), (assign, reg8, "$guard_troop5"), (assign, reg9, "$guard_troop6"), (assign, reg10, "$guard_troop6"), (assign, reg11, "$guard_troop7"), (assign, reg12, "$guard_troop7"), (assign, reg13, "$guard_troop8"), (assign, reg14, "$guard_troop8"), (assign, reg15, "$guard_troop9"), (assign, reg16, "$guard_troop9"), (assign, reg17, "$guard_troop10"), (store_random_in_range, ":local0", 1, 6), (val_add, ":local0", "$meta_alarm"), (val_min, ":local0", 10), (val_add, ":local0", 10), (assign, ":local1", 7), (val_add, ":local1", "$meta_alarm"), (try_for_range, ":entry", 10, ":local0"), (shuffle_range, 1, ":local1"), (neg|eq, reg1, 0), (set_visitor, ":entry", reg1, 0), (try_end), ]), #script_infiltration_stealth_1 ("infiltration_stealth_1",[ (set_jump_mission, "mt_infiltration_stealth_mission"), (jump_to_scene, "$rescue_final_scene", 0), (reset_visitors), (modify_visitors_at_site, "$rescue_final_scene"), (set_visitor, 0, "trp_player", 0), (set_visitor, 1, "$guard_troop2", 0), (set_visitor, 3, "$guard_troop2", 0), (set_visitor, 6, "$guard_troop2", 0), (set_visitor, 9, "$guard_troop2", 0), (set_visitor, 14, "$guard_troop2", 0), (set_visitor, 16, "$guard_troop2", 0), ]), #script_infiltration_stealth_2 ("infiltration_stealth_2",[ (set_jump_mission, "mt_infiltration_stealth_mission"), (jump_to_scene, "$rescue_stealth_scene_1", 0), (reset_visitors), (modify_visitors_at_site, "$rescue_stealth_scene_1"), (set_visitor, 0, "trp_player", 0), (set_visitor, 1, "$guard_troop1", 0), (set_visitor, 3, "$guard_troop1", 0), (set_visitor, 6, "$guard_troop1", 0), (set_visitor, 9, "$guard_troop1", 0), (set_visitor, 14, "$guard_troop1", 0), (set_visitor, 16, "$guard_troop1", 0), ]), #script_set_meta_stealth ("set_meta_stealth",[ (assign, "$current_companions_total", 0), (assign, "$meta_stealth", 0), (try_for_range, ":faction", "fac_mission_companion_1", "fac_mission_companion_11"), (faction_get_slot, ":troop", ":faction", 1), (neg|eq, ":troop", 0), (store_skill_level, reg1, skl_athletics, ":troop"), (val_sub, reg1, 3), (val_max, reg1, 1), (val_mul, reg1, 2), (try_begin), (call_script, "script_cf_is_a_night_troop", ":troop"), (val_add, reg1, 2), (try_end), (try_begin), (troop_is_hero, ":troop"), (store_skill_level, reg3, "skl_persuasion", ":troop"), (val_add, reg1, reg3), (try_end), (val_add, "$meta_stealth", reg1), (val_add, "$current_companions_total", 1), (try_end), (try_begin), (ge, "$current_companions_total", 1), (store_mul, reg2, "$current_companions_total", "$current_companions_total"), #(store_skill_level, reg1, skl_athletics, "trp_player"), (party_get_skill_level, ":party_wildcraft", "p_main_party", skl_persuasion), #if companions chosen, take party wildcraft (val_max, ":party_wildcraft", 1), #avoid /0 (val_div, reg2, ":party_wildcraft"), (val_add, reg2, 2), (val_max, reg2, 1), #avoid /0 (val_mul, ":party_wildcraft", 2), (val_div, ":party_wildcraft", 3), (val_add, "$meta_stealth", ":party_wildcraft"), (val_div, "$meta_stealth", reg2), (val_clamp, "$meta_stealth", 1, 11), (else_try), (eq, "$current_companions_total", 0), (store_skill_level, ":player_athletics", skl_athletics, "trp_player"), #2/3 of player athletics + wildcraft (store_skill_level, ":player_wildcraft", skl_persuasion, "trp_player"), (store_add, reg1, ":player_athletics", ":player_wildcraft"), (val_mul, reg1, 2), (val_div, reg1, 3), # (val_sub, reg1, "$old_ranger_path_modifier"), (val_add, "$meta_stealth", reg1), (val_add, "$meta_stealth", 2), (val_min, "$meta_stealth", 10), (try_end), (try_begin), (troop_slot_eq, "trp_traits", slot_trait_stealthy, 1), (try_begin),( eq, "$current_companions_total", 0),(val_add, "$meta_stealth", 3), (else_try),(neg|eq, "$current_companions_total", 0),(val_add, "$meta_stealth", 1), (try_end), (try_end), # (assign, reg66, "$meta_stealth"), # (display_message, "@meta_stealth: {reg66}"), ]), #script_crunch_stealth_results ("crunch_stealth_results",[ (store_mul, ":stealth_malus", "$meta_alarm", 0), #disabled for now (store_mul, ":stealth_bonus", "$meta_stealth", 6), #variable, 6-60 (store_random_in_range, ":chance", 60, 100), (val_add, ":chance", ":stealth_malus"), (val_sub, ":chance", ":stealth_bonus"), (assign, reg11, "$meta_stealth"), (assign, reg12, "$meta_alarm"), (assign, reg14, ":stealth_bonus"), (assign, reg13, ":chance"), (try_begin), (le, ":chance", 15), (assign, "$stealth_results", 1), #should not happen at low stealth (else_try),(is_between, ":chance", 15, 50),(assign, "$stealth_results", 2), (else_try),(is_between, ":chance", 50, 85),(assign, "$stealth_results", 3), #should not happen at high stealth (else_try), (ge, ":chance", 85), (assign, "$stealth_results", 4), (try_end), ]), #script_rescue_information ("rescue_information",[ (try_begin), (eq, "$rescue_stage", 0), (display_message, "@You_have_been_discovered_before_scaling_the_wall.", 4294901760), (display_message, "@The_enemy_is_coming_in_force,_you_must_flee!", 4294901760), (else_try), (eq, "$rescue_stage", 1), (display_message, "@Scout_this_area_alone_and_meet_your_men_beyond!", 4294901760), (display_message, "@Be_stealthy_but_eliminate_any_threats_quickly!", 4294901760), (else_try), (eq, "$rescue_stage", 2), (display_message, "@You_are_spotted_by_a_patrol!", 4294901760), (display_message, "@Eliminate_them_before_the_alarm_spreads!", 4294901760), (else_try), (eq, "$rescue_stage", 3), (display_message, "@Scout_this_area_alone_and_meet_your_men_beyond!", 4294901760), (display_message, "@Be_stealthy_but_eliminate_any_threats_quickly!", 4294901760), (else_try), (eq, "$rescue_stage", 4), (display_message, "@You_are_spotted_by_a_patrol!", 4294901760), (display_message, "@Eliminate_them_before_the_alarm_spreads!", 4294901760), (else_try), (eq, "$rescue_stage", 5), (display_message, "@You_have_reached_the_dungeons!", 0), (display_message, "@Eliminate_the_guards_and_free_your_men!", 0), (try_end), ]), #script_infiltration_mission_final_casualty_tabulation ("infiltration_mission_final_casualty_tabulation",[ (try_for_range, ":faction", "fac_mission_companion_1", "fac_mission_companion_11"), (faction_get_slot, ":troop", ":faction", slot_fcomp_agentid), (faction_get_slot, ":local2", ":faction", slot_fcomp_hp), (faction_get_slot, ":local3", ":faction", slot_fcomp_kia), (try_begin), (troop_is_hero, ":troop"), (store_random_in_range, ":rnd", 20, 30), (try_begin), (eq, ":faction", "fac_mission_companion_10"), (neg|gt, ":rnd", ":local2"), (troop_set_health, ":troop", ":local2"), (else_try), (eq, ":faction", "fac_mission_companion_10"), (gt, ":rnd", ":local2"), (troop_set_health, ":troop", ":rnd"), (else_try), (neg|eq, ":troop", 0), (gt, ":rnd", ":local2"), (troop_set_health, ":troop", ":rnd"), (else_try), (neg|eq, ":troop", 0), (neg|gt, ":rnd", ":local2"), (troop_set_health, ":troop", ":local2"), (try_end), (else_try), (neg|troop_is_hero, ":troop"), (eq, ":local3", 1), (party_remove_members, "p_main_party", ":troop", 1), (try_end), (try_end), ]), #script_infiltration_initialize_companion_records ("infiltration_initialize_companion_records",[ (try_for_range, ":faction", "fac_mission_companion_1", "fac_mission_companion_11"), (faction_set_slot, ":faction", slot_fcomp_troopid, 0), # troop ID (faction_set_slot, ":faction", slot_fcomp_agentid, 0), # agent ID (faction_set_slot, ":faction", slot_fcomp_hp, 0), # current hp (faction_set_slot, ":faction", slot_fcomp_kia, 0), # kia = 1 (try_end), ]), #script_infiltration_mission_update_companion_casualties ("infiltration_mission_update_companion_casualties",[ #(faction_get_slot, ":compagent", "fac_mission_companion_10", slot_fcomp_agentid), (faction_get_slot, ":local1", "fac_mission_companion_10", slot_fcomp_hp), (store_agent_hit_points, ":hp", "$current_player_agent", 0), (try_begin), (neg|ge, ":hp", ":local1"), (faction_set_slot, "fac_mission_companion_10", slot_fcomp_hp, ":hp"), (try_end), #(get_player_agent_no, ":player"), (try_for_agents, ":agent"), (agent_is_ally, ":agent"), (agent_is_human, ":agent"), (neg|eq, ":agent", "$current_player_agent"), (store_agent_hit_points, ":hp", ":agent", 0), # (agent_get_troop_id, ":local4", ":agent"), (try_begin), (agent_is_alive|neg, ":agent"), (try_for_range, ":fac", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":compagent", ":fac", slot_fcomp_agentid), (faction_get_slot, ":local6", ":fac", slot_fcomp_kia), (neg|eq, ":local6", 1), (eq, ":compagent", ":agent"), (faction_set_slot, ":fac", slot_fcomp_hp, ":hp"), (faction_set_slot, ":fac", slot_fcomp_kia, 1), (try_end), (else_try), (agent_is_alive, ":agent"), (try_for_range, ":fac", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":compagent", ":fac", slot_fcomp_agentid), (eq, ":compagent", ":agent"), (faction_get_slot, ":local1", ":fac", slot_fcomp_hp), (neg|ge, ":hp", ":local1"), (faction_set_slot, ":fac", slot_fcomp_hp, ":hp"), (try_end), (try_end), (try_end), ]), #script_infiltration_mission_synch_agents_and_troops ("infiltration_mission_synch_agents_and_troops",[ (try_for_range, ":fac", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_set_slot, ":fac", slot_fcomp_agentid, 0), (try_end), (get_player_agent_no, "$current_player_agent"), (faction_set_slot, "fac_mission_companion_10", slot_fcomp_agentid, "$current_player_agent"), (try_for_agents, ":agent"), (neg|eq, ":agent", "$current_player_agent"), (agent_is_ally, ":agent"), (agent_is_human, ":agent"), (agent_get_troop_id, ":troop", ":agent"), (try_for_range, ":fac", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":troop_comp", ":fac", slot_fcomp_troopid), (faction_get_slot, ":local4", ":fac", slot_fcomp_agentid), (faction_get_slot, ":local5", ":fac", slot_fcomp_kia), (neg|eq, ":local5", 1), # not kia (eq, ":local4", 0), (eq, ":troop_comp", ":troop"), (assign, ":local6", 0), (try_for_range, ":facc", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":agent2", ":facc", slot_fcomp_agentid), (eq, ":agent2", ":agent"), (assign, ":local6", 1), (try_end), (eq, ":local6", 0), (faction_set_slot, ":fac", slot_fcomp_agentid, ":agent"), (try_end), (try_end), ]), #script_infiltration_mission_set_hit_points ("infiltration_mission_set_hit_points",[ #(get_player_agent_no, ":player"), (try_for_range, ":comp", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":comp_agent", ":comp", slot_fcomp_agentid), (faction_get_slot, ":local3", ":comp", slot_fcomp_kia), (faction_get_slot, ":hp", ":comp", slot_fcomp_hp), (faction_get_slot, ":troop", ":comp", slot_fcomp_troopid), (try_begin), (neg|eq, ":comp_agent", "$current_player_agent"), (neg|eq, ":troop", 0), (neg|eq, ":local3", 1), (agent_set_hit_points, ":comp_agent", ":hp", 0), (try_end), # (faction_get_slot, ":comp_agent", "fac_mission_companion_10", slot_fcomp_agentid), (faction_get_slot, ":hp", "fac_mission_companion_10", slot_fcomp_hp), (agent_set_hit_points, "$current_player_agent", ":hp", 0), (try_end), ]), #script_rescue_failed ("rescue_failed",[ (assign, ":local0", 0), (assign, ":comp_captured", 0), (try_begin),(eq, "$active_rescue", 1),(assign, ":local0", 1), (else_try),(eq, "$active_rescue", 2),(assign, ":local0", 2), (else_try),(eq, "$active_rescue", 3),(assign, ":local0", 3), (else_try),(eq, "$active_rescue", 4),(assign, ":local0", 4), (try_end), (try_begin), (lt, "$active_rescue", 5), (neq, ":local0", 0), (assign, ":comp_captured", 0), (try_for_range, ":comp", "fac_mission_companion_1", "fac_mission_companion_10"), (assign, ":local3", 0), # (faction_get_slot, ":local4", ":comp", slot_fcomp_hp), (faction_get_slot, ":local5", ":comp", slot_fcomp_kia), (faction_get_slot, ":troop_comp", ":comp", slot_fcomp_troopid), (eq, ":local5", 1), #swy: both lists are contiguous, that's why this seems to work. was hardcoded (try_for_range, ":npc", companions_begin, new_companions_end), (this_or_next|is_between, ":npc", companions_begin, heroes_end), (is_between, ":npc", new_companions_begin, new_companions_end), (eq, ":troop_comp", ":npc"), (assign, ":local8", ":local0"), (val_add, ":local8", 5), (troop_set_slot, ":npc", 0, ":local8"), (assign, ":local3", 1), (party_remove_members, "p_main_party", ":npc", 1), (str_store_troop_name, s1, ":npc"), (display_message, "@{s1}_has_been_captured_by_the_enemy.", 4294901760), (try_begin), (eq, ":local3", 1), (eq, ":local0", 1), # (val_add, "$heroes_captured_by_gondor", 1), (val_add, ":comp_captured", 1), (str_store_party_name, s2, "p_town_minas_tirith"), (display_message, "@Gondor_takes_a_captive"), (else_try), (eq, ":local3", 1), (eq, ":local0", 2), # (val_add, "$heroes_captured_by_rohan", 1), (val_add, ":comp_captured", 1), (str_store_party_name, s2, "p_town_hornburg"), (display_message, "@Rohan_takes_a_captive"), (else_try), (eq, ":local3", 1), (eq, ":local0", 3), # (val_add, "$heroes_captured_by_mordor", 1), (val_add, ":comp_captured", 1), (str_store_party_name, s2, "p_town_minas_morgul"), (display_message, "@Mordor_takes_a_captive"), (else_try), (eq, ":local3", 1), (eq, ":local0", 4), # (val_add, "$heroes_captured_by_isengard", 1), (val_add, ":comp_captured", 1), (str_store_party_name, s2, "p_town_isengard"), (display_message, "@Isengard_takes_a_captive"), (try_end), (try_end), (try_end), (try_end), (try_begin), (lt, "$active_rescue", 5), (neq, ":local0", 0), (try_begin), (eq, "$current_companions_total", 0), (tutorial_box, "@You_were_grievously_wounded_and_your_body_piled_with_the_dead._Picking_your_moment_you_managed_to_escape_over_the_wall_but_the_enemy_may_have_seen_your_movements._Best_to_be_quickly_away."), (else_try), (eq, ":comp_captured", 1), (tutorial_box, "@You_were_grievously_wounded_in_battle._Your_men_managed_to_drag_you_away_but_took_horrific_casualties_in_the_effort."), (else_try), (gt, ":comp_captured", 1), (tutorial_box, "@You_were_grievously_wounded_in_battle._Your_men_managed_to_drag_you_away_but_took_horrific_casualties_in_the_effort._Unfortunately,_some_of_your_companions_have_been_captured and dragged to {s2}."), (try_end), (else_try), (eq, "$active_rescue", 5), # Mirkwood sorcerer (try_begin), (gt, "$current_companions_total", 0), (tutorial_box, "@You_were_grievously_wounded_in_battle._Your_men_managed_to_drag_you_away_from_the_fighting,_but_unfortunately_the_sorcerer_has_managed_to_escape."), (else_try), (eq, "$current_companions_total", 0), (tutorial_box, "@You_were_grievously_wounded_and_your_body_piled_with_the_dead._Picking_the_right_moment_you_managed_to_escape,_but_unfortunately_the_sorcerer_has_managed_to_escape."), (try_end), (try_begin), (check_quest_active, "qst_mirkwood_sorcerer"), (call_script, "script_fail_quest", "qst_mirkwood_sorcerer"), (try_end), (try_end), ]), #script_store_hero_death ("store_hero_death",[ (assign, "$no_dead_companions", 0), (get_player_agent_no, "$current_player_agent"), (try_for_agents, ":agent"), (agent_is_human, ":agent"), (agent_is_ally, ":agent"), (neg|eq, ":agent", "$current_player_agent"), (agent_is_alive|neg, ":agent"), (val_add, "$no_dead_companions", 1), (try_end), (try_for_range, ":comp", "fac_mission_companion_1", "fac_mission_companion_10"), (faction_get_slot, ":local5", ":comp", slot_fcomp_kia), (eq, ":local5", 1), (faction_get_slot, ":troop_comp", ":comp", slot_fcomp_troopid), (neg|troop_is_hero, ":troop_comp"), (gt, "$no_dead_companions", 0), (val_sub, "$no_dead_companions", 1), (try_end), ]), #script_mt_sneak_1 ("mt_sneak_1",[ (store_script_param_1, ":enemy_agent"), (try_begin),(eq, "$positions", 3),(eq, "$last_agent_position", 2),(agent_set_scripted_destination, ":enemy_agent", 2), (else_try),(eq, "$positions", 2),(eq, "$last_agent_position", 3),(agent_set_scripted_destination, ":enemy_agent", 1), (else_try),(eq, "$positions", 7),(eq, "$last_agent_position", 6),(agent_set_scripted_destination, ":enemy_agent", 6), (else_try),(eq, "$positions", 5),(eq, "$last_agent_position", 7),(agent_set_scripted_destination, ":enemy_agent", 4), (else_try),(eq, "$positions",11),(agent_set_scripted_destination, ":enemy_agent", 8), (else_try),(eq, "$positions",15),(agent_set_scripted_destination, ":enemy_agent", 14), (else_try),(eq, "$positions",19),(agent_set_scripted_destination, ":enemy_agent", 17), (else_try),(eq, "$positions",16),(agent_set_scripted_destination, ":enemy_agent", 20), (else_try),(eq, "$positions",20),(agent_set_scripted_destination, ":enemy_agent", 16), (else_try),(assign, reg20, "$positions"),(val_add, reg20, 1),(agent_set_scripted_destination, ":enemy_agent", reg20), (try_end), ]), #script_mt_sneak_2 ("mt_sneak_2",[ (store_script_param_1, ":enemy_agent"), (try_begin),(eq, "$positions", 4),(agent_set_scripted_destination, ":enemy_agent", 1), (else_try),(eq, "$positions", 8),(agent_set_scripted_destination, ":enemy_agent", 5), (else_try),(eq, "$positions", 14),(eq, "$last_agent_position", 13),(agent_set_scripted_destination, ":enemy_agent", 13), (else_try),(eq, "$positions", 13),(eq, "$last_agent_position", 14),(agent_set_scripted_destination, ":enemy_agent", 12), (else_try),(eq, "$positions", 12),(eq, "$last_agent_position", 13),(agent_set_scripted_destination, ":enemy_agent", 11), (else_try),(eq, "$positions", 11),(eq, "$last_agent_position", 12),(agent_set_scripted_destination, ":enemy_agent", 10), (else_try),(eq, "$positions", 10),(eq, "$last_agent_position", 11),(agent_set_scripted_destination, ":enemy_agent", 9), (else_try),(eq, "$positions", 20),(eq, "$last_agent_position", 19),(agent_set_scripted_destination, ":enemy_agent", 19), (else_try),(eq, "$positions", 19),(eq, "$last_agent_position", 20),(agent_set_scripted_destination, ":enemy_agent", 16), (else_try),(eq, "$positions", 16),(eq, "$last_agent_position", 19),(agent_set_scripted_destination, ":enemy_agent", 15), (else_try),(assign, reg20, "$positions"),(val_add, reg20, 1),(agent_set_scripted_destination, ":enemy_agent", reg20), (try_end), ]), #script_isen_sneak_1 ("isen_sneak_1",[ (store_script_param_1, ":enemy_agent"), (try_begin),(eq, "$positions", 1),(agent_set_scripted_destination, ":enemy_agent", 2), (else_try),(eq, "$positions", 2),(agent_set_scripted_destination, ":enemy_agent", 1), (else_try),(eq, "$positions", 3),(agent_set_scripted_destination, ":enemy_agent", 4), (else_try),(eq, "$positions", 4),(agent_set_scripted_destination, ":enemy_agent", 3), (else_try),(eq, "$positions", 6),(agent_set_scripted_destination, ":enemy_agent", 7), (else_try),(eq, "$positions", 7),(agent_set_scripted_destination, ":enemy_agent", 6), (else_try),(eq, "$positions", 9),(agent_set_scripted_destination, ":enemy_agent",10), (else_try),(eq, "$positions",10),(agent_set_scripted_destination, ":enemy_agent", 9), (else_try),(eq, "$positions",14),(agent_set_scripted_destination, ":enemy_agent",15), (else_try),(eq, "$positions",15),(agent_set_scripted_destination, ":enemy_agent",14), (else_try),(eq, "$positions",16),(agent_set_scripted_destination, ":enemy_agent",17), (else_try),(eq, "$positions",17),(agent_set_scripted_destination, ":enemy_agent",16), (else_try),(assign, reg20, "$positions"),(val_add, reg20, 1),(agent_set_scripted_destination, ":enemy_agent", reg20), (try_end), ]), #script_wounded_hero_cap_mission_health ("wounded_hero_cap_mission_health",[ (get_player_agent_no, ":player"), (assign, ":local1", 0), (try_for_agents, ":agent"), (neg|eq, ":agent", ":player"), (agent_is_human, ":agent"), (agent_is_ally, ":agent"), (agent_get_troop_id, ":local2", ":agent"), (try_for_range, ":npc", companions_begin, new_companions_end), (this_or_next|is_between, ":npc", companions_begin, companions_end), (is_between, ":npc", new_companions_begin, new_companions_end), (eq, ":local2", ":npc"), (troop_get_slot, ":local4", ":npc", slot_troop_wound_mask), (assign, ":hp", 100), (val_mul, ":local4", 10), (val_sub, ":hp", ":local4"), (store_agent_hit_points, ":hp_cur", ":agent", 0), (neg|ge, ":hp", ":hp_cur"), (agent_set_hit_points, ":agent", ":hp", 0), (assign, ":local1", 1), (try_end), (try_end), (try_begin), (eq, ":local1", 1), (display_message, "@Some_of_your_companions_are_suffering_from_old_wounds.", 4294901760), (try_end), ]), #script_set_hero_companion ("set_hero_companion",[ (store_script_param_1, ":comp_troop"), (try_begin), # store horoes actual health (troop_is_hero, ":comp_troop"), (store_troop_health, ":hp", ":comp_troop", 0), (else_try), (assign, ":hp", 100), (try_end), (store_add, ":comp", "fac_mission_companion_1", reg0), # reg0 traces total # of companions picked (faction_set_slot, ":comp", slot_fcomp_troopid, ":comp_troop"), (faction_set_slot, ":comp", slot_fcomp_hp, ":hp"), (faction_set_slot, ":comp", slot_fcomp_kia, 0), (val_add, reg0,1), # one more companion added ]), #script_initialize_center_scene #GA: transferred from town menu so that can double it elsewhere ("initialize_center_scene",[ (assign, "$talk_context", 0), (set_jump_mission,"mt_town_center"), (store_script_param_1, ":town_scene"), (try_begin), (call_script, "script_cf_enter_center_location_bandit_check"), (else_try), (try_begin), (lt, ":town_scene", 1), (party_get_slot, ":town_scene", "$current_town", slot_town_center), (try_end), (modify_visitors_at_site, ":town_scene"), (reset_visitors), (assign, "$g_mt_mode", tcm_default), (store_faction_of_party, ":town_faction","$current_town"), # TLD center specific guards # (try_begin), # (neg|party_slot_eq,"$current_town", slot_town_prison, -1), # (party_get_slot, ":troop_prison_guard", "$current_town", slot_town_archer_troop), # (else_try), # (party_get_slot, ":troop_prison_guard", "$current_town", slot_town_guard_troop), # (try_end), (try_begin), (neg|party_slot_eq,"$current_town", slot_town_castle, -1), (party_get_slot, ":troop_castle_guard", "$current_town", slot_town_castle_guard_troop), (else_try), (party_get_slot, ":troop_castle_guard", "$current_town", slot_town_guard_troop), (try_end), (try_begin), (neg|party_slot_eq,"$current_town", slot_town_captain, -1), (party_get_slot, ":barracks_troop", "$current_town", slot_town_captain), (else_try), (party_get_slot, ":barracks_troop", "$current_town", slot_town_castle_guard_troop), (try_end), (set_visitor, 23, ":troop_castle_guard"), (set_visitor, 24, ":barracks_troop"), # TLD center specific guards (party_get_slot, ":tier_2_troop", "$current_town", slot_town_guard_troop), (assign, ":tier_3_troop", ":tier_2_troop"), (try_begin), (troop_get_upgrade_troop, ":upgrade_troop", ":tier_2_troop", 1), #try secondary upgrade path first - favours spearmen (gt, ":upgrade_troop", 0), (neg|troop_is_guarantee_ranged, ":upgrade_troop"), (neg|troop_is_guarantee_horse, ":upgrade_troop"), (assign, ":tier_3_troop", ":upgrade_troop"), (else_try), (troop_get_upgrade_troop, ":upgrade_troop", ":tier_2_troop", 0), (gt, ":upgrade_troop", 0), (assign, ":tier_3_troop", ":upgrade_troop"), (try_end), #(party_get_slot, ":tier_3_troop", "$current_town", slot_town_archer_troop), #was slot_town_archer_troop ######## (try_begin), (gt,":tier_2_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_i4_gon_swordsman"),(assign,reg1,"trp_i4_gon_swordsman"),(assign,reg2,"trp_a4_gon_archer"),(assign,reg3,"trp_i3_footman_of_rohan"), (try_end), (shuffle_range,0,4), (set_visitors,25,reg0,1),(set_visitors,26,reg1,1),(set_visitors,27,reg2,1),(set_visitors,28,reg3,1), #MV replaced by companion NPC, if any, and no castle #TLD NPC companions (try_begin), #(this_or_next|eq, "$current_town", "p_town_dol_guldur"), #(party_slot_eq, "$current_town", slot_town_castle, -1), #no town castle (neq, "$sneaked_into_town", 1), #haven't sneaked in (try_for_range, ":cur_troop", companions_begin, new_companions_end), (this_or_next|is_between, ":cur_troop", companions_begin, companions_end), (is_between, ":cur_troop", new_companions_begin, new_companions_end), (troop_slot_eq, ":cur_troop", slot_troop_cur_center, "$current_town"), (neg|main_party_has_troop, ":cur_troop"), #not already hired (assign, ":on_lease", 0), (try_begin), (check_quest_active,"qst_lend_companion"), (quest_slot_eq, "qst_lend_companion", slot_quest_target_troop, ":cur_troop"), (assign, ":on_lease", 1), (try_end), (eq, ":on_lease", 0), (store_troop_faction, ":troop_faction", ":cur_troop"), (store_relation, ":rel", ":town_faction", ":troop_faction"), (ge, ":rel", 0), #only spawn if friendly center (set_visitor, 9, ":cur_troop"), #only one companion NPC per town! (try_end), (try_end), (party_get_slot, ":spawned_troop", "$current_town", slot_town_weaponsmith), (try_begin), (neq, ":spawned_troop", "trp_no_troop"), (set_visitor, 10, ":spawned_troop"), (try_end), (party_get_slot, ":spawned_troop", "$current_town", slot_town_elder), (try_begin), (neq, ":spawned_troop", "trp_no_troop"), (set_visitor, 11, ":spawned_troop"), (try_end), (party_get_slot, ":spawned_troop", "$current_town", slot_town_merchant), (try_begin), (neq, ":spawned_troop", "trp_no_troop"), (set_visitor, 12, ":spawned_troop"), (try_end), #TLD: lords in the streets 16-22, if no castle (try_begin), (party_slot_eq, "$current_town", slot_town_castle, -1), #no town castle (assign, ":cur_pos", 16), (call_script, "script_get_heroes_attached_to_center", "$current_town", "p_temp_party"), (party_get_num_companion_stacks, ":num_stacks","p_temp_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop","p_temp_party",":i_stack"), (lt, ":cur_pos", 23), # spawn up to entry point 22 (set_visitor, ":cur_pos", ":stack_troop"), (try_begin), (this_or_next|eq, ":stack_troop", "trp_knight_3_11"), #imladris elves all in helms (this_or_next|eq, ":stack_troop", "trp_knight_3_12"), (this_or_next|eq, ":stack_troop", "trp_imladris_lord"), (eq, ":stack_troop", "trp_lorien_lord"), #Galadriel in her invis peryphery #swy-- debug thingie, it gets called, so the loop works as intended in wb # (str_store_troop_name, s1, ":stack_troop"), # (assign, reg1, ":cur_pos"), # (display_message,"@shit just got real: entry point:{reg1} troop:{s1}"), #swy-- this doesn't seem to do anything in WB unless the set_jump_mission//change_screen_mission is properly sandwitched -> (mission_tpl_entry_set_override_flags, "mt_town_center", ":cur_pos", af_override_horse|af_override_weapons), (try_end), (val_add,":cur_pos", 1), (try_end), (try_end), (try_begin), #TLD: fugitive in a town (check_quest_active, "qst_hunt_down_fugitive"), #(neg|is_currently_night), (quest_slot_eq, "qst_hunt_down_fugitive", slot_quest_target_center, "$current_town"), (neg|check_quest_succeeded, "qst_hunt_down_fugitive"), (neg|check_quest_failed, "qst_hunt_down_fugitive"), (quest_get_slot, ":quest_object_troop", "qst_hunt_down_fugitive", slot_quest_object_troop), (set_visitor, 9, ":quest_object_troop"), #spawn in place of any NPC companion, so sceners won't make a fuss (try_end), (call_script, "script_init_town_walkers"), (assign, "$gate_aggravator_agent", 0), (assign, ":override_state", af_override_horse), (try_begin), (eq, "$sneaked_into_town", 1), #setup disguise (assign, ":override_state", af_override_all), (try_end), (mission_tpl_entry_set_override_flags, "mt_town_center", 0, ":override_state"), #entry 0 always in center & w/o horse (try_begin), (this_or_next|eq, "$current_town", "p_town_moria"), #no mounts in cave towns (this_or_next|eq, "$current_town", "p_town_goblin_north_outpost"), (eq, "$current_town", "p_town_erebor"), (mission_tpl_entry_set_override_flags, "mt_town_center", 1, ":override_state"), (mission_tpl_entry_set_override_flags, "mt_town_center", 2, ":override_state"), (try_end), (mission_tpl_entry_set_override_flags, "mt_town_center", 3, ":override_state"), (mission_tpl_entry_set_override_flags, "mt_town_center", 4, ":override_state"), (mission_tpl_entry_set_override_flags, "mt_town_center", 5, ":override_state"), (mission_tpl_entry_set_override_flags, "mt_town_center", 6, ":override_state"), (mission_tpl_entry_set_override_flags, "mt_town_center", 7, ":override_state"), (change_screen_mission), (try_end), #if bandits ]), # script_calculate_renown_value # Input: arg1 = troop_no # Output: fills $battle_renown_value ("calculate_renown_value", [ (call_script, "script_party_calculate_strength", "p_main_party", 0), (assign, ":main_party_strength", reg0), (call_script, "script_party_calculate_strength", "p_collective_enemy", 0), (assign, ":enemy_strength", reg0), (call_script, "script_party_calculate_strength", "p_collective_friends", 0), (assign, ":friends_strength", reg0), (val_add, ":friends_strength", 1), (store_mul, ":enemy_strength_ratio", ":enemy_strength", 100), (val_div, ":enemy_strength_ratio", ":friends_strength"), (assign, ":renown_val", ":enemy_strength"), (val_mul, ":renown_val", ":enemy_strength_ratio"), (val_div, ":renown_val", 100), (val_mul, ":renown_val", ":main_party_strength"), (val_div, ":renown_val",":friends_strength"), (store_div, "$battle_renown_value", ":renown_val", 5), (val_min, "$battle_renown_value", 2500), (convert_to_fixed_point, "$battle_renown_value"), (store_sqrt, "$battle_renown_value", "$battle_renown_value"), (convert_from_fixed_point, "$battle_renown_value"), (assign, reg8, "$battle_renown_value"), #(display_message, "@Renown value for this battle is {reg8}.",0xFFFFFFFF), ]), # script_injure_companions ("injure_companions",[ (try_begin), (eq, "$tld_option_injuries",1), (try_for_range, ":npc",companions_begin,new_companions_end), # assume companions are always in our main party, if ever spawned on battlefield (this_or_next|is_between, ":npc", companions_begin, companions_end), (is_between, ":npc", new_companions_begin, new_companions_end), (troop_slot_eq, ":npc", slot_troop_wounded, 1), # was wounded in this battle? (call_script, "script_injury_routine", ":npc"), (troop_set_slot,":npc", slot_troop_wounded, 0), (try_end), (try_end), ]), #script_check_equipped_items ("check_equipped_items",[ (store_script_param_1, ":npc"), (assign,"$remove_item", 0), (troop_get_type, ":race", ":npc"), (try_for_range,":inv_slot",ek_body,ek_gloves), # EQUIPMENT CHECKS (troop_get_inventory_slot, ":item", ":npc", ":inv_slot"), (ge, ":item", 0), (store_add,":item_slot",slot_troop_armor_type-ek_body,":inv_slot"), #slot_troop_armor_type, slot_troop_boots_type consequtive slots #(neq, ":item_slot", slot_troop_boots_type), (neg|troop_slot_eq,":npc",":item_slot",":item"), # equipped item changed to other? (store_item_value, reg30, ":item"), (val_mod, reg30,10), #(neq, reg30, 0), # non-commonly used item? (item value last digit !=0, stores allowed races) #InVain: Removed, now checks all the time. (try_begin), # swy: if it's a dwarven item and not a dwarven troop; remove it (eq, reg30, 8), (neq, ":race", tf_dwarf), (assign, "$remove_item", 1), (else_try), # swy: if it's an orc item and not a orc troop; remove it (eq, reg30, 1), (neq, ":race", tf_orc), (assign, "$remove_item", 1), (else_try), # swy: if it's an uruk item and not some kind of uruk troop; remove it (eq, reg30, 2), (neq, ":race", tf_uruk), (neq, ":race", tf_urukhai), (assign, "$remove_item", 1), #Uruks and Uruk-hai share equipment #InVain: Turned conditions around. Now, short races are only allowed to wear their own gear. (else_try), # swy: if it is NOT a dwarven item and it's a dwarven troop; remove it (neq, reg30, 8), (eq, ":race", tf_dwarf), (assign, "$remove_item", 1), (else_try), # swy: if it is NOT an orc item and it's an orc troop; remove it (neq, reg30, 1), (eq, ":race", tf_orc), (assign, "$remove_item", 1), (else_try), # swy: if it is NOT an uruk item and it's some kind of uruk troop; remove it (neq, reg30, 2), (neq, reg30, 3), #use 3 for shared items (e.g. some boots) (this_or_next|eq, ":race", tf_uruk), ( eq, ":race", tf_urukhai), (assign, "$remove_item", 1), #Uruks and Uruk-hai share equipment (try_end), (try_begin), (eq,"$remove_item",1), (dialog_box,"@Item you just equipped does not fit characters of this race and will be removed into player inventory shortly^^Make sure your equipment has space for the item, or it will be lost","@Inappropriate equipment"), (troop_set_slot,":npc",":item_slot",-1), # needs removing! (else_try), (troop_set_slot,":npc",":item_slot", ":item"), #remember new equipment (try_end), (try_end), # check for mount, issue warning if wrong (troop_get_inventory_slot, ":item", ":npc", ek_horse), (try_begin), (neg|troop_slot_eq,":npc",slot_troop_horse_type,":item"), # mount changed from previous? #(display_message, "@WOAH, MOUNT CHANGED!!"), (troop_set_slot,":npc",slot_troop_horse_type, ":item"), # remember new mount (it's not removed) (try_begin), (ge, ":item", 0), (call_script, "script_cf_troop_cant_ride_item", ":npc", ":item"), (assign,"$remove_item", 1), (dialog_box,"@The mount you just equipped does not fit characters of this race. Be warned that there will be problems with the animal behaviour on the battlefield, if you leave it as this","@Inappropriate mount"), (try_end), (try_end), ]), ("unequip_items",[ (store_script_param_1, ":npc"), (try_begin), (eq,"$tld_option_crossdressing",0), (eq,"$remove_item",1), (try_for_range,":inv_slot",ek_body,ek_gloves), # CHECKS FOR EQUIPMENT REMOVAL for body and feet (troop_get_inventory_slot, ":item", ":npc", ":inv_slot"), (ge, ":item", 0), (troop_get_inventory_slot_modifier, ":mod", ":npc", ":inv_slot"), (store_add,":item_slot",slot_troop_armor_type-ek_body,":inv_slot"), (troop_slot_eq,":npc",":item_slot", -1), # item marked for removal? (troop_set_inventory_slot, ":npc", ":inv_slot", -1), # remove item from equipment (troop_add_item, "trp_player", ":item", ":mod"), # move item into player's inventory (try_end), (troop_get_inventory_slot, ":item", ":npc", ek_horse), (troop_set_slot,":npc",slot_troop_horse_type, ":item"), (assign,"$remove_item", 0), (try_end), ]), #script_battle_health_management #MV: copied over from 808 for use in a trigger for berserker and inf/arch/cav captain traits ("battle_health_management",[ #don't do this, we want to heal only player troops on his command # (try_for_agents, ":agent"), # berserkers heal # (agent_is_alive, ":agent"), # (agent_get_troop_id, ":troop", ":agent"), # (this_or_next|eq, ":troop", "trp_i4_dun_wolf_warrior"), # (this_or_next|eq, ":troop", "trp_dunnish_berserker"), # (this_or_next|eq, ":troop", "trp_i6_isen_uruk_berserker"), # (this_or_next|eq, ":troop", "trp_i4_khand_pit_champion"), # (eq, ":troop", "trp_i5_khand_pit_master"), # (store_agent_hit_points, ":hp", ":agent", 0), # (neg|ge, ":hp", 50), # (val_mul, ":hp", 10), # (val_div, ":hp", 8), # (agent_set_hit_points, ":agent", ":hp", 0), # (assign, reg1, ":hp"), # (str_store_troop_name, 1, ":troop"), # (try_end), ] + (not is_a_wb_script==1 and [ (try_begin), # player heal when berserker or has torque #MV: berserker only -- Kham - Revamped with Battle Kill Healing instead. (get_player_agent_no, ":player"), #(player_has_item|this_or_next, "itm_dunlending_torque"), (troop_slot_eq, "trp_traits", slot_trait_berserker, 1), (store_agent_hit_points, ":hp", ":player", 0), (val_add, ":hp", 20), #MV: gain absolute 20%, instead of relative +25% (val_min, ":hp", 100), (agent_set_hit_points, ":player", ":hp", 0), (str_store_string, s24, "str_trait_title_berserker"), (display_message, "@{s24}: Some of your wounds healed!"), (try_end), ] or []) + [ (try_begin), # heal classes acc to captainship (this_or_next|troop_slot_eq, "trp_traits", slot_trait_archer_captain, 1), (this_or_next|troop_slot_eq, "trp_traits", slot_trait_infantry_captain, 1), (troop_slot_eq, "trp_traits", slot_trait_cavalry_captain, 1), (get_player_agent_no, ":player"), (agent_get_team, ":player_team", ":player"), (try_for_agents, ":agent"), #(agent_is_ally, ":agent"), #MV: replaced with player team check, makes more sense (agent_is_alive, ":agent"), (agent_is_human, ":agent"), (neq, ":agent", ":player"), (agent_get_team, ":agent_team", ":agent"), (eq, ":agent_team", ":player_team"), (agent_get_class, ":class", ":agent"), (assign, ":heal_agent", 0), (try_begin), (eq, ":class", grc_infantry), (troop_slot_eq, "trp_traits", slot_trait_infantry_captain, 1), (assign, ":heal_agent", 1), (else_try), (eq, ":class", grc_archers), (troop_slot_eq, "trp_traits", slot_trait_archer_captain, 1), (assign, ":heal_agent", 1), (else_try), (eq, ":class", grc_cavalry), (troop_slot_eq, "trp_traits", slot_trait_cavalry_captain, 1), (assign, ":heal_agent", 1), (try_end), (eq, ":heal_agent", 1), #(agent_slot_eq, ":agent", 6, 0), #MV: hm, what's this slot? marking which agents received healing? unneeded if done once per battle (store_agent_hit_points, ":hp", ":agent", 0), (val_add, ":hp", 20), #MV: gain absolute 20%, instead of relative +25% (val_min, ":hp", 100), (agent_set_hit_points, ":agent", ":hp", 0), #(agent_set_slot, ":agent", 6, 1), (try_end), (try_begin), (troop_slot_eq, "trp_traits", slot_trait_infantry_captain, 1), (str_store_string, s24, "str_trait_title_infantry_captain"), (display_message, "@{s24}: Your infantry feels better!"), (try_end), (try_begin), (troop_slot_eq, "trp_traits", slot_trait_archer_captain, 1), (str_store_string, s24, "str_trait_title_archer_captain"), (display_message, "@{s24}: Your archers feel better!"), (try_end), (try_begin), (troop_slot_eq, "trp_traits", slot_trait_cavalry_captain, 1), (str_store_string, s24, "str_trait_title_cavalry_captain"), (display_message, "@{s24}: Your cavalry feels better!"), (try_end), (try_end), ]), #script_start_conversation_cutscene (MV) #Input: conversation number #Starts a cutscene according to the conversation number ("start_conversation_cutscene",[ (store_script_param_1, ":convo_code"), (call_script, "script_find_theater", "p_main_party"), (assign, ":current_theater", reg0), #determine talker (try_begin), (this_or_next|eq, ":convo_code", tld_cc_gandalf_rohan_quest_start), (this_or_next|eq, ":convo_code", tld_cc_gandalf_rohan_quest_win), (this_or_next|eq, ":convo_code", tld_cc_gandalf_rohan_quest_fail), (this_or_next|eq, ":convo_code", tld_cc_gandalf_advice), (this_or_next|eq, ":convo_code", tld_cc_gandalf_ally_down), (this_or_next|eq, ":convo_code", tld_cc_gandalf_enemy_down), (eq, ":convo_code", tld_cc_gandalf_victory), (try_begin), (this_or_next|eq, ":current_theater", theater_SE), (eq, ":current_theater", theater_SW), (assign, "$g_tld_convo_talker", "trp_gandalf"), (else_try), (assign, "$g_tld_convo_talker", "trp_radagast"), (try_end), (else_try), (assign, "$g_tld_convo_talker", "trp_nazgul"), (try_end), #fill up dialog lines in strings s50, s51... and set number of lines ##GANDALF (try_begin), (eq, ":convo_code", tld_cc_gandalf_advice), # find closest good faction (faction_get_slot, ":player_capital", "$players_kingdom", slot_faction_capital), (assign, ":min_distance", 9999999), (assign, ":nearest_faction", -1), (try_for_range, ":faction", kingdoms_begin, kingdoms_end), (neq, ":faction", "$players_kingdom"), (faction_slot_eq, ":faction", slot_faction_side, faction_side_good), (faction_get_slot, ":capital", ":faction", slot_faction_capital), (call_script, "script_get_tld_distance", ":player_capital", ":capital"), (assign, ":party_distance", reg0), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, ":nearest_faction", ":faction"), (assign, "$g_tld_convo_subject", ":capital"), #remember where to send Gandalf next (try_end), (str_store_faction_name, s2, "$players_kingdom"), (faction_get_slot, ":player_king", "$players_kingdom", slot_faction_leader), (str_store_troop_name, s3, ":player_king"), (troop_get_type, reg3, ":player_king"), (try_begin), (gt, reg3, 1), #MV: non-humans are male (assign, reg3, 0), (try_end), (faction_get_slot, ":nearest_king", ":nearest_faction", slot_faction_leader), (str_store_troop_name, s4, ":nearest_king"), (str_store_string, s50, "@Ah, what a coincidence, running into you, {playername}! You might not know me, but are not unknown to me. I am on my way to {s4}, but I have just come from {s3} and your name has come up. {s3} is counting on you in these perilous times and if you had thought to pursue some distracting course of action, you might wish to reconsider it and focus on aiding {s2} to your utmost capabilities."), (str_store_string, s51, "@Who are you?"), (str_store_string, s52, "@A friend of {s3} and the people of {s2}. Now hurry! Mordor draws all wicked things, and the Dark Power is bending all its will to gather them there. Time is running out for all that is good in this world, unless we make count our every action to oppose it!"), (str_store_string, s53, "@What should I do?"), (str_store_string, s54, "@Find {s3}'s whereabouts immediately and speak with {reg3?her:him}. Good luck!"), (assign, "$g_tld_convo_lines", 5), (val_or, "$g_tld_conversations_done", tld_conv_bit_gandalf_advice), (else_try), (eq, ":convo_code", tld_cc_gandalf_ally_down), (assign, ":best_strength", -1), (assign, ":best_faction", -1), (try_for_range, ":faction", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":faction", slot_faction_side, faction_side_good), (faction_get_slot, ":strength", ":faction", slot_faction_strength), (gt, ":strength", ":best_strength"), (assign, ":best_strength", ":strength"), (assign, ":best_faction", ":faction"), (try_end), (str_store_faction_name, s2, "$players_kingdom"), (str_store_faction_name, s3, "$g_tld_convo_subject"), (faction_get_slot, ":dead_king", "$g_tld_convo_subject", slot_faction_leader), (str_store_troop_name, s4, ":dead_king"), (str_store_faction_name, s5, ":best_faction"), (str_store_string, s50, "@Good to see the Shadow has not yet managed to defeat you, {playername}."), (try_begin), (eq, "$g_tld_convo_talker", trp_gandalf), (str_store_string, s51, "@You are the one they call Gandalf or Mithrandir."), (else_try), (str_store_string, s51, "@You are the one they call Radagast."), (try_end), (str_store_string, s52, "@That is what some call me. In my times I have also been called other things, but unless the Darkness is stopped, soon there may not be anyone left to call me anything at all."), (str_store_string, s53, "@What do you mean?"), (str_store_string, s54, "@In spite of their valiant resistance, {s3} has been overwhelmed by the forces of evil. {s3}'s people are scattered and the good {s4} is no more."), (str_store_string, s55, "@You bring dismal news, wizard."), (str_store_string, s56, "@But I also bring a message of hope. The people of {s5} are still holding firm. Their warriors are fearless and their leaders resolute."), (str_store_string, s57, "@What should I do?"), (str_store_string, s58, "@Help them fight the enemy as best as you can. Never relent! But be on your guard! There are older and fouler things than Orcs in the world."), (assign, "$g_tld_convo_lines", 9), (val_or, "$g_tld_conversations_done", tld_conv_bit_gandalf_ally_down), (else_try), (eq, ":convo_code", tld_cc_gandalf_enemy_down), (str_store_faction_name, s3, "$g_tld_convo_subject"), (faction_get_slot, ":dead_king", "$g_tld_convo_subject", slot_faction_leader), (str_store_troop_name, s4, ":dead_king"), (str_store_string, s50, "@Beware, {playername}, the might of Darkness crumbles. {s3} has fallen, as has its leader {s4}."), (str_store_string, s51, "@What do you want of me, old man?"), (str_store_string, s52, "@Just know that a Dawn is coming. It is inevitable. And should you still be alive to see it, consider what you shall have to say for yourself then."), (assign, "$g_tld_convo_lines", 3), (val_or, "$g_tld_conversations_done", tld_conv_bit_gandalf_enemy_down), (else_try), (eq, ":convo_code", tld_cc_gandalf_victory), (call_script, "script_get_faction_rank", "$g_talk_troop_faction"), (call_script, "script_get_own_rank_title_to_s24", "$players_kingdom", reg0), (str_store_string, s50, "@Well met, {playername}, {s24}. My trust in you has not been misplaced. The might of the forces of the Shadow has been broken and your efforts played no small part in it!"), (try_begin), (eq, "$g_tld_convo_talker", trp_gandalf), (str_store_string, s51, "@Thank you, Mithrandir!"), (else_try), (str_store_string, s51, "@Thank you, Radagast!"), (try_end), (str_store_string, s52, "@The wizard Saruman is gone and Barad Dur has been shattered to dust along with its Dark Lord! All the peoples of Middle Earth are relieved of the threat that nearly consumed all that was good and pure in this world. The Enemy is vanquished and The King has returned!"), (str_store_string, s53, "@It was a long and bloody war and many of our close friends are also no longer with us."), (str_store_string, s54, "@There is much to regret and mourn, and even more to rebuild and mend in the coming days. But for now, let us be jubilant with those of our friends that are with us still and celebrate all we have achieved in The Last Days Of The Third Age."), (assign, "$g_tld_convo_lines", 5), (val_or, "$g_tld_conversations_done", tld_conv_bit_gandalf_victory), (else_try), (eq, ":convo_code", tld_cc_gandalf_rohan_quest_start), (try_begin), #find target) (party_slot_eq, "p_town_hornburg", slot_center_destroyed, 0), (assign, ":target_center", "p_town_hornburg"), (str_store_string, s1, "@Orcs are marching against Helm's Deep."), (else_try), (assign, ":target_center", "p_town_edoras"), (str_store_string, s1, "@Orcs are marching against Edoras."), (try_end), (str_store_party_name, s3, ":target_center"), (str_store_string, s50, "@Ah, {playername}, happy chance that we come on each other in this fashion! Grim tidings I bring from Western Rohan, and haste is sore needed."), (str_store_string, s51, "@What tidings do you bring, Mithrandir? What can I do?"), (str_store_string, s52, "@Saruman has loosed Isengard upon Rohan. {s1} For the success of my designs, the valiant Rohirrim must not fall, {playername}! The danger to them is very great, yet also the emptying of Isengard has left it vulnerable, for Saruman has despatched his full strength against Theoden King. This may be the time to move into Nan Curunir. A choice is now laid before you, Commander, a choice you must make, for neither you nor I may be everywhere at once!"), (str_store_string, s53, "@Do you want me to help King Theoden defend {s3}, or hasten to Isengard and see what I can do?"), (str_store_string, s54, "@Either would be a great boon to me. You must decide your course on your own, {playername}, as shall I. Shadowfax shall bear me now on a swift errand. You must act quickly as well! Hasten now!"), (assign, "$g_tld_convo_lines", 5), (setup_quest_text, "qst_guardian_party_quest"), (str_store_string, s2, "@Gandalf asked you to either help Theoden defend {s3} or find out what is happening in Isengard."), (call_script, "script_start_quest", "qst_guardian_party_quest", "trp_gandalf"), (quest_set_slot, "qst_guardian_party_quest", slot_quest_target_center, ":target_center"), (quest_set_slot, "qst_guardian_party_quest", slot_quest_expiration_days, 3), (quest_set_slot, "qst_guardian_party_quest", slot_quest_xp_reward, 3000), (try_begin), #send Theoden and disable Rohan faction AI (troop_get_slot, ":theoden_party", "trp_rohan_lord", slot_troop_leaded_party), (gt, ":theoden_party", 0), (party_is_active, ":theoden_party"), (call_script, "script_party_set_ai_state", ":theoden_party", spai_holding_center, ":target_center"), (party_set_ai_initiative, ":theoden_party",0), (store_current_hours, ":cur_hours"), (val_add, ":cur_hours", 72), #72 hours no AI recalc (party_set_slot, ":theoden_party", slot_party_scripted_ai, ":cur_hours"), (try_end), (store_current_hours, ":cur_hours"), (val_add, ":cur_hours", 72), #72 hours no AI recalc (faction_set_slot, "fac_rohan", slot_faction_scripted_until, ":cur_hours"), (faction_set_slot, "fac_rohan", slot_faction_ai_state, sfai_default), (faction_set_slot, "fac_rohan", slot_faction_ai_object, -1), (try_for_range, ":unused", 0, 15), #weaken HD garrison (call_script, "script_party_count_fit_for_battle", ":target_center"), (gt, reg0, 150), (inflict_casualties_to_party_group, ":target_center", 200, p_temp_wounded), (try_end), (try_for_range, ":unused", 0, 10), #weaken Theoden (troop_get_slot, ":theoden_party", "trp_rohan_lord", slot_troop_leaded_party), (gt, ":theoden_party", 0), (call_script, "script_party_count_fit_for_battle", ":theoden_party"), (gt, reg0, 100), (inflict_casualties_to_party_group, ":theoden_party", 200, p_temp_wounded), (troop_set_health, "trp_rohan_lord", 100), (try_end), (faction_set_slot, "fac_rohan", slot_faction_ai_state, sfai_default), #cancel any campaigns (faction_set_slot, "fac_rohan", slot_faction_ai_object, -1), (call_script,"script_check_and_finish_active_army_quests_for_faction","$players_kingdom",), #quit any campaign quests #spawn ents, set as target party (set_spawn_radius,4), (spawn_around_party, "p_town_isengard", "pt_none"), (assign, ":ent_party", reg0), (party_set_name, ":ent_party", "@Ents"), (party_add_members, ":ent_party", trp_ent, 40), (party_set_icon, ":ent_party", icon_ent), (party_set_ai_object, ":ent_party", "p_town_isengard"), (party_set_slot, ":ent_party", slot_party_ai_state, spai_undefined), (call_script, "script_party_set_ai_state", ":ent_party", spai_undefined, -1), (party_set_faction, ":ent_party", fac_commoners), #so they don't get attacked (party_set_ai_initiative, ":ent_party", 0), # (store_current_hours, ":cur_hours"), # (val_add, ":cur_hours", 100), # (party_set_slot, ":ent_party", slot_party_scripted_ai, ":cur_hours"), (party_set_slot, ":ent_party", slot_party_type, spt_guardian), (party_add_leader, ":ent_party", "trp_ent_1"), (troop_raise_skill, "trp_ent_1", skl_tactics, 10), (quest_set_slot, "qst_guardian_party_quest", slot_quest_target_party, ":ent_party"), (call_script,"script_create_smoking_remnants","p_town_isengard","icon_shrubbery",48,1), (else_try), (eq, ":convo_code", tld_cc_gandalf_rohan_quest_win), (try_begin), (quest_slot_ge, "qst_guardian_party_quest", slot_quest_current_state, 1), #Isengard (str_store_string, s50, "@Hail, {playername}! I hope you are unhurt? At any rate, I am pleased you aided my friend Fangorn, or you may know him as Treebeard. The tree shepherds are very mighty, but it was likely that they marched to their doom. You have perhaps saved them from a great peril, Commander, and for that I am glad. I would not like to see the oldest of all living things pass from the world, no, not just yet… no, not before they see the Entwives again, I should hope."), (str_store_string, s51, "@Missing String"), (str_store_string, s52, "@Well, thank you, {playername}, and farewell. We may meet again, ere the waning of the moon!"), (assign, "$g_tld_convo_lines", 3), (else_try), #Helm's Deep (str_store_string, s50, "@Hail, {playername}! I hope you are unhurt? At any rate, you seem to have lain your blade to the right foe. No enemy has yet taken the Hornburg, and likely none ever shall – not while the likes of you defend Helm’s Gate, I’ll warrant!"), (str_store_string, s51, "@Missing String"), (str_store_string, s52, "@Your deed has greatly helped my design, better even than I could have hoped or planned. Farewell, {playername}, and thank you. We may meet again, ere the waning of the moon!"), (assign, "$g_tld_convo_lines", 3), (try_end), (quest_get_slot, ":target_center", qst_guardian_party_quest, slot_quest_target_center), (remove_member_from_party, trp_aragorn, ":target_center"), (remove_member_from_party, trp_legolas, ":target_center"), (remove_member_from_party, trp_gimli, ":target_center"), (call_script, "script_finish_quest", "qst_guardian_party_quest", 100), (call_script, "script_increase_rank", "fac_rohan", 50), (quest_set_slot, "qst_treebeard_kill_orcs", slot_quest_current_state, 1), #disable Treebeard quest (else_try), (eq, ":convo_code", tld_cc_gandalf_rohan_quest_fail), (str_store_string, s50, "@{Playername}, I will ask you a thing now. You are accounted an able captain, and a dutiful one; were you overmastered by great foes? Did you tarry overlong, for caution or even fear? Behold, we are now come into a greater peril than I could have foreseen. The strength of Rohan is broken, her people scattered and shieldless: Helm’s Deep has fallen. The trees are withered untimely, and night lies over the forge-fires of Isengard: the Ents of Fangorn Forest are dead or driven back."), (str_store_string, s51, "@Missing String"), (str_store_string, s52, "@You have failed me, {playername} – or perhaps it is I who have failed you. Perhaps there was some flaw in my design, some grave blunder I did not recognise… The terror of Mordor comes. Leave me now, {playername}. We may meet again… or perhaps not."), (assign, "$g_tld_convo_lines", 3), (call_script, "script_end_quest", "qst_guardian_party_quest"), ##NAZGUL (else_try), (eq, ":convo_code", tld_cc_nazgul_baggins), (str_store_string, s50, "@Bagginsssss... Sssshhhire..."), (str_store_string, s51, "@I... don't know!"), (str_store_string, s52, "@It... beckonsssssss..."), (assign, "$g_tld_convo_lines", 3), (val_or, "$g_tld_conversations_done", tld_conv_bit_nazgul_baggins), (else_try), (eq, ":convo_code", tld_cc_nazgul_evil_war), (str_store_string, s50, "@Treachery... Unforgiven..."), (str_store_string, s51, "@But I..."), (str_store_string, s52, "@Noone... oppossssses... Barad Dur... and livessss!"), (assign, "$g_tld_convo_lines", 3), (val_or, "$g_tld_conversations_done", tld_conv_bit_nazgul_evil_war), (else_try), (eq, ":convo_code", tld_cc_nazgul_victory), (str_store_string, s50, "@All... must... submit... and... serve..."), (try_begin), (faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_eye), (str_store_string, s51, "@I serve the Eye!"), (else_try), (str_store_string, s51, "@I shall serve the Eye!"), (try_end), (assign, "$g_tld_convo_lines", 2), (val_or, "$g_tld_conversations_done", tld_conv_bit_nazgul_victory), (try_end), #start the cutscene (jump_to_menu, "mnu_auto_conversation_cutscene"), #send the conversation party back immediately (call_script, "script_send_from_conversation_mission", "$g_tld_convo_talker"), #Kham - Start Intro Quest (Gandalf) (try_begin), (eq, ":convo_code", tld_cc_gandalf_advice), (faction_get_slot, ":capital", "$players_kingdom", slot_faction_capital), (str_store_party_name, s1, ":capital"), (faction_get_slot, ":faction_lord", "$players_kingdom", slot_faction_leader), (str_store_troop_name_link, s9, ":faction_lord"), (setup_quest_text, "qst_tld_introduction"), (str_store_string, s2, "@Go to {s1} and speak with {s9}."), (call_script, "script_start_quest", "qst_tld_introduction", "$g_tld_convo_talker"), (quest_set_slot, "qst_tld_introduction", slot_quest_target_troop, ":faction_lord"), (try_end), ]), #script_send_on_conversation_mission (MV) #Input: mission/conversation code #Reroutes or spawns Gandalf/Nazgul party and sends it to meet the player for a specific conversation ("send_on_conversation_mission",[ (store_script_param_1, ":mission_code"), #determine mission troop and its data (try_begin), (this_or_next|eq, ":mission_code", tld_cc_gandalf_rohan_quest_start), (this_or_next|eq, ":mission_code", tld_cc_gandalf_rohan_quest_win), (this_or_next|eq, ":mission_code", tld_cc_gandalf_rohan_quest_fail), (this_or_next|eq, ":mission_code", tld_cc_gandalf_advice), (this_or_next|eq, ":mission_code", tld_cc_gandalf_ally_down), (this_or_next|eq, ":mission_code", tld_cc_gandalf_enemy_down), (eq, ":mission_code", tld_cc_gandalf_victory), (assign, ":mission_troop_side", faction_side_good), (assign, ":state", "$g_tld_gandalf_state"), (call_script, "script_find_theater", "p_main_party"), (assign, ":current_theater", reg0), (try_begin), (this_or_next|eq, ":current_theater", theater_SE), (eq, ":current_theater", theater_SW), (assign, ":mission_troop", "trp_gandalf"), (assign, ":party_template", "pt_gandalf"), (else_try), (assign, ":mission_troop", "trp_radagast"), (assign, ":party_template", "pt_radagast"), (try_end), (else_try), (assign, ":mission_troop", "trp_nazgul"), (assign, ":party_template", "pt_nazgul"), (assign, ":mission_troop_side", faction_side_eye), (assign, ":state", "$g_tld_nazgul_state"), (try_end), # check if party is missing when it shouldn't be; recover by creating it (this should never happen, but we handle it anyway) (troop_get_slot, ":party", ":mission_troop", slot_troop_leaded_party), (assign, ":party_missing_bug", 0), (try_begin), (gt, ":party", 0), (neg|party_is_active, ":party"), (assign, ":party_missing_bug", 1), (try_end), #if it's not spawned, spawn it (try_begin), (this_or_next|eq, ":state", -1), #mission troop inactive (eq, ":party_missing_bug", 1), #...or a missing party #find nearest mission troop-friendly town (assign, ":min_distance", 9999999), (assign, ":nearest_town", -1), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":center_faction", ":center_no"), (faction_slot_eq, ":center_faction", slot_faction_side, ":mission_troop_side"), #e.g. Nazgul spawns in the nearest Eye town (call_script, "script_get_tld_distance", "p_main_party", ":center_no"), (assign, ":party_distance", reg0), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, ":nearest_town", ":center_no"), (try_end), #this should never happen, but it's handled (try_begin), (eq, ":nearest_town", -1), (assign, ":nearest_town", "p_main_party"), (try_end), #spawn the party (set_spawn_radius, 0), (spawn_around_party, ":nearest_town", ":party_template"), (assign, ":party", reg0), (troop_set_slot, ":mission_troop", slot_troop_leaded_party, ":party"), #this is how we know it has a party (try_end), #find the party and send it to meet the player (troop_get_slot, ":party", ":mission_troop", slot_troop_leaded_party), (try_begin), #(party_is_active, ":party"), #no need, we guarantee this (party_set_ai_behavior, ":party", ai_bhvr_attack_party), (party_set_ai_object, ":party", "p_main_party"), (party_set_flags, ":party", pf_default_behavior, 0), (try_end), (assign, ":state", ":mission_code"), #this overwrites any previous mission, even if it was a conversation - more recent news are more important (try_begin), (this_or_next|eq, ":mission_troop", "trp_gandalf"), (eq, ":mission_troop", "trp_radagast"), (assign, "$g_tld_gandalf_state", ":state"), (else_try), (assign, "$g_tld_nazgul_state", ":state"), (try_end), ]), #script_send_from_conversation_mission (MV) #Input: mission troop #Send a Gandalf/Nazgul party after the conversation to some town ("send_from_conversation_mission",[ (store_script_param_1, ":mission_troop"), #determine mission troop data (try_begin), (this_or_next|eq, ":mission_troop", "trp_gandalf"), (eq, ":mission_troop", "trp_radagast"), (assign, ":mission_troop_side", faction_side_good), (else_try), (assign, ":mission_troop_side", faction_side_eye), (try_end), #find nearest mission troop-friendly town (assign, ":min_distance", 9999999), (assign, ":nearest_town", -1), (try_for_range, ":center_no", centers_begin, centers_end), (party_is_active, ":center_no"), #TLD (party_slot_eq, ":center_no", slot_center_destroyed, 0), # TLD (store_faction_of_party, ":center_faction", ":center_no"), (faction_slot_eq, ":center_faction", slot_faction_side, ":mission_troop_side"), #e.g. Nazgul spawns in the nearest Eye town (call_script, "script_get_tld_distance", "p_main_party", ":center_no"), (assign, ":party_distance", reg0), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, ":nearest_town", ":center_no"), (try_end), #this should never happen, but it's handled (try_begin), (eq, ":nearest_town", -1), (assign, ":nearest_town", "p_town_minas_tirith"), (try_end), (try_begin), (this_or_next|eq, ":mission_troop", "trp_gandalf"), (eq, ":mission_troop", "trp_radagast"), (eq, "$g_tld_gandalf_state", tld_cc_gandalf_advice), (assign, ":nearest_town", "$g_tld_convo_subject"), #special case (try_end), #find the party and send it to the town (troop_get_slot, ":party", ":mission_troop", slot_troop_leaded_party), (try_begin), #(party_is_active, ":party"), #no need, we guarantee this (party_set_ai_behavior, ":party", ai_bhvr_travel_to_party), (party_set_ai_object, ":party", ":nearest_town"), (party_set_flags, ":party", pf_default_behavior, 0), (try_end), (assign, ":state", 0), # we are done, but the party still exists (try_begin), (this_or_next|eq, ":mission_troop", "trp_gandalf"), (eq, ":mission_troop", "trp_radagast"), (assign, "$g_tld_gandalf_state", ":state"), (else_try), (assign, "$g_tld_nazgul_state", ":state"), (try_end), ]), # script_party_eject_nonfaction (GA) # troops nonfaction for ":source" & given from ":recipient_initial" to ":source" - are returned back to ":recipient" # Input: arg1 = party_A, source, retains target faction and heroes # Input: arg2 = party_B, gets non-faction troops it had initially according to arg4 (usually p_main_party) # Input: arg3 = initial composition of party_B #Output: arg3 stores troops returned back to recipient ("party_eject_nonfaction",[ (store_script_param_1, ":source"), (store_script_param_2, ":recipient"), (store_script_param, ":recipient_initial", 3), #subtract recipient from recipient_initial, relies on recipient being subset of recipient_initial! (party_get_num_companion_stacks, ":num_stacks", ":recipient"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":st", ":recipient", ":i_stack"), (party_stack_get_size, ":ss",":recipient",":i_stack"), (party_remove_members, ":recipient_initial", ":st", ":ss"), (try_end), #clear recipient_initial from any hero troops and prisoners (try_for_range, ":hero", heroes_begin, heroes_end), #(remove_troops_from_prisoners, ":hero",":recipient_initial"), #InVain: This led to a bug where hero prisoners vanished after giving troops to a friend. Since the script isn't called in any situation that might affect heroes or hero prisoners, I think it's save to disable it. (remove_member_from_party, ":hero",":recipient_initial"), (try_end), (remove_member_from_party, "trp_player",":recipient_initial"), #remove faction from recipient_initial and nonfaction from source, add nonfaction to recipient (store_faction_of_party, ":fac", ":source"), (call_script, "script_party_copy", "p_temp_party", ":recipient_initial"), #needs a copy to iterate through, since member removing fucks up stacks order (party_get_num_companion_stacks, ":num_stacks", "p_temp_party"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_size , ":ss", "p_temp_party", ":i_stack"), (party_stack_get_troop_id, ":st", "p_temp_party", ":i_stack"), (store_troop_faction, ":ft", ":st"), (try_begin), (eq, ":ft", ":fac"), (party_remove_members, ":recipient_initial", ":st", ":ss"),# factions outta recipient_initial, stay in source # CC: Mordor and Guldur share troops (else_try),(eq, ":ft", "fac_guldur"),(eq,":fac","fac_mordor"), (party_remove_members, ":recipient_initial", ":st", ":ss"),# factions outta recipient_initial, stay in source (else_try),(eq, ":ft", "fac_mordor"),(eq,":fac","fac_guldur"), (party_remove_members, ":recipient_initial", ":st", ":ss"),# factions outta recipient_initial, stay in source (else_try), (party_remove_members, ":source" , ":st", ":ss"),# nonfactions outta source, stay in recipient_initial (try_end), (try_end), (call_script, "script_party_add_party_companions", ":recipient", ":recipient_initial"), #transfer nonfactions to recipient ]), # script_stand_back (GA) # returns orcs and uruks to default body position at the end of conversation ("stand_back",[ # reset leaning animaton after dialog ends (get_player_agent_no, "$current_player_agent"), (agent_get_horse,reg1,"$current_player_agent"), (troop_get_type, ":race", "$player_current_troop_type"), (try_begin), (is_between, ":race", tf_orc_begin, tf_orc_end), (try_begin),(eq, reg1, -1),(agent_set_animation, "$current_player_agent", "anim_cancel_ani_stand"), (else_try), (agent_set_animation, "$current_player_agent", "anim_cancel_ani_ride"), (try_end), (try_end), ]), # script_remove_empty_parties_in_group (GA) # stashes prisoners into p_temp_party ("remove_empty_parties_in_group",[ (store_script_param_1, ":root_party"), (try_begin), (gt, ":root_party", 0), (party_get_num_attached_parties, ":num_attached_parties", ":root_party"), (try_for_range, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":root_party", ":attached_party_rank"), (gt, ":attached_party", 0), (party_get_num_companions, ":troops", ":attached_party"), (try_begin), (eq, ":troops",0), # no more soldiers here? (party_get_num_prisoners,reg1, ":attached_party"), (try_begin), # transfer prisoners (gt, reg1, 0), (call_script, "script_party_add_party_prisoners", "p_temp_party", ":attached_party"), (try_end), (try_end), (call_script, "script_remove_empty_parties_in_group", ":attached_party"), (try_begin), (eq, ":troops", 0), (call_script, "script_safe_remove_party",":attached_party"),# remove empty party after subtree iterations and prisoner stashing are done (try_end), (try_end), (try_end), ]), # script_get_food_of_race_and_faction (mtarini) # puts resulting item in reg0 ("get_food_of_race_and_faction",[ (store_script_param_1, ":race"), (store_script_param_2, ":fac"), (try_begin),(is_between, ":race", tf_orc_begin, tf_orc_end), (assign, reg0, "itm_maggoty_bread"), (else_try),(is_between, ":race", tf_elf_begin, tf_elf_end), (assign, reg0, "itm_lembas"), (else_try),(this_or_next|eq,":fac", "fac_dale"),(this_or_next|eq,":fac","fac_umbar"),(eq,":fac","fac_beorn"), (assign, reg0, "itm_smoked_fish"), (else_try),(faction_slot_eq,":fac", slot_faction_side, faction_side_good), (assign, reg0, "itm_cram"), (else_try), (assign, reg0, "itm_dried_meat"), (try_end), ]), # another useful self explainatory script... (mtarini) ("troop_copy_all_items_from_troop",[ (store_script_param_1, ":dest"), (store_script_param_2, ":source"), (troop_get_inventory_capacity, ":n", ":source"), (troop_ensure_inventory_space,":dest",":n"), #(assign, ":debug_count", 0), # for debug (troop_clear_inventory,":dest"), (try_for_range, ":i", 0, ":n"), (troop_get_inventory_slot, ":item_id", ":source", ":i"), (ge, ":item_id", 0), (troop_get_inventory_slot_modifier, ":item_mod", ":source", ":i"), (troop_add_item, ":dest", ":item_id",":item_mod",), #(val_add, ":debug_count", 1), # for debug (try_end), #(assign, reg51, ":debug_count"), (display_message, "@debug: copyed {reg51} items"), ]), # another useful self explainatory script... (mtarini) ("store_random_scene_position_in_pos10",[ (get_scene_boundaries,pos1,pos2), (position_get_x,":min_x",pos1),(position_get_y,":min_y",pos1), (position_get_x,":max_x",pos2),(position_get_y,":max_y",pos2), (val_add, ":min_x", 100),(val_sub, ":max_x", 100), (val_add, ":min_y", 100),(val_sub, ":min_y", 100), (store_random_in_range, ":x", ":min_x", ":max_x"), (store_random_in_range, ":y", ":min_y", ":max_y"), (init_position, pos10), (position_set_x, pos10, ":x"), (position_set_y, pos10, ":y"), (position_set_z_to_ground_level, pos10), ]), # utility script (mtarini) # removes from party A the prisoners, as dictated from party B (except wonded) # returns removed number in reg0 ("party_remove_party_from_prisoners",[ (store_script_param_1, ":dest"), (store_script_param_2, ":remove_list"), (assign, ":removed", 0), (party_get_num_companion_stacks, ":num_stacks", ":remove_list"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":trp", ":remove_list", ":i_stack"), (party_stack_get_size, ":n", ":remove_list", ":i_stack"), (party_stack_get_num_wounded, ":w", ":remove_list", ":i_stack"), (val_sub, ":n", ":w"), (party_remove_prisoners, ":dest", ":trp", ":n"), (val_add, ":removed", reg0), (try_end), (assign, reg0, ":removed"), ]), ("save_compartibility_script7",[]), ("save_compartibility_script8",[]), ("save_compartibility_script9",[]), ("save_compartibility_script10",[]), ### WARBAND HARDCODED SCRIPTS # ("game_quick_start",[]), # ("game_set_multiplayer_mission_end",[]), # ("game_enable_cheat_menu",[]), # ("game_get_console_command",[]), # ("game_get_scene_name",[]), # ("game_get_mission_template_name",[]), # ("game_receive_url_response",[]), # ("game_get_cheat_mode",[]), # ("game_receive_network_message",[]), # ("game_get_multiplayer_server_option_for_mission_template",[]), # ("game_multiplayer_server_option_for_mission_template_to_string",[]), # ("game_multiplayer_event_duel_offered",[]), # ("game_get_multiplayer_game_type_enum",[]), # ("game_multiplayer_get_game_type_mission_template",[]), # #script_add_troop_to_cur_tableau_for_profile # # INPUT: troop_no # # OUTPUT: none # ("add_troop_to_cur_tableau_for_profile", # [(store_script_param, ":troop_no",1), # (set_fixed_point_multiplier, 100), # (cur_tableau_clear_override_items), # (cur_tableau_set_camera_parameters, 1, 4, 6, 10, 10000), # (init_position, pos5), # (assign, ":cam_height", 105), # # (val_mod, ":camera_distance", 5), # (assign, ":camera_distance", 380), # (assign, ":camera_yaw", -15), # (assign, ":camera_pitch", -18), # (assign, ":animation", anim_stand_man), # (position_set_z, pos5, ":cam_height"), # # camera looks towards -z axis # (position_rotate_x, pos5, -90), # (position_rotate_z, pos5, 180), # # now apply yaw and pitch # (position_rotate_y, pos5, ":camera_yaw"), # (position_rotate_x, pos5, ":camera_pitch"), # (position_move_z, pos5, ":camera_distance", 0), # (position_move_x, pos5, 5, 0), # (profile_get_banner_id, ":profile_banner"), # (try_begin), # (ge, ":profile_banner", 0), # (init_position, pos2), # (val_add, ":profile_banner", banner_meshes_begin), # (position_set_x, pos2, -175), # (position_set_y, pos2, -300), # (position_set_z, pos2, 180), # (position_rotate_x, pos2, 90), # (position_rotate_y, pos2, -15), # (cur_tableau_add_mesh, ":profile_banner", pos2, 0, 0), # (try_end), # (init_position, pos2), # (try_begin), # (troop_is_hero, ":troop_no"), # (cur_tableau_add_troop, ":troop_no", pos2, ":animation", -1), # (else_try), # (store_mul, ":random_seed", ":troop_no", 126233), # (val_mod, ":random_seed", 1000), # (val_add, ":random_seed", 1), # (cur_tableau_add_troop, ":troop_no", pos2, ":animation", ":random_seed"), # (try_end), # (cur_tableau_set_camera_position, pos5), # (copy_position, pos8, pos5), # (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up # (position_rotate_z, pos8, 30), # (position_rotate_x, pos8, -60), # (cur_tableau_add_sun_light, pos8, 175,150,125), # ]), # script_cf_is_a_night_troop # Fails if the troop iterated is a night troop (ie. no nighttime penalites) # Input: Troop ID # Output: Fail ("cf_is_a_night_troop", [ (store_script_param_1, ":troop_id"), (assign, ":continue", 1), (try_begin), (this_or_next|eq, ":troop_id", "trp_a5_dun_night_wolf"), (this_or_next|eq, ":troop_id", "trp_ac5_dun_raven_rider"), (this_or_next|eq, ":troop_id", "trp_i5_woodmen_night_guard"), (this_or_next|eq, ":troop_id", "trp_a5_woodmen_night_stalker"), (this_or_next|eq, ":troop_id", "trp_i5_corsair_night_raider"), (this_or_next|eq, ":troop_id", "trp_a5_corsair_master_assassin"), (this_or_next|eq, ":troop_id", "trp_i5_far_harad_panther_guard"), (this_or_next|eq, ":troop_id", "trp_i6_frealaf_raider"), (this_or_next|eq, ":troop_id", "trp_mordor_olog_hai"), ( eq, ":troop_id", "trp_a5_blackroot_shadow_hunter"), (assign, ":continue", 0), (try_end), (eq, ":continue", 1), ]), # script_cf_reinforce_next_theater # Gives next theater a fac str boost # Input: 1) Theater that got defeated; 2) Faction that got defeated # Output: none, divvies up fac str constant between remaining factions in next theater ("cf_reinforce_next_theater", [ (store_script_param_1, ":defeated_theater"), (store_script_param_2, ":defeated_faction"), (faction_get_slot, ":defeated_faction_side", ":defeated_faction", slot_faction_side), # find closest enemy faction (faction_get_slot, ":defeated_faction_capital", ":defeated_faction", slot_faction_capital), (assign, ":min_distance", 9999999), (assign, ":nearest_enemy_faction", -1), (try_for_range, ":faction", kingdoms_begin, kingdoms_end), (neq, ":faction", ":defeated_faction"), (try_begin), (eq, "$tld_war_began", 1), (this_or_next|eq, ":defeated_faction_side", faction_side_eye), (eq, ":defeated_faction_side", faction_side_hand), (assign, ":defeated_faction_side", faction_side_eye), (try_end), (neg|faction_slot_eq, ":faction", slot_faction_side, ":defeated_faction_side"), (faction_get_slot, ":capital", ":faction", slot_faction_capital), (call_script, "script_get_tld_distance", ":defeated_faction_capital", ":capital"), (assign, ":party_distance", reg0), (lt, ":party_distance", ":min_distance"), (assign, ":min_distance", ":party_distance"), (assign, ":nearest_enemy_faction", ":faction"), (try_end), (call_script, "script_check_active_factions_in_theater", ":defeated_theater", ":nearest_enemy_faction"), (eq, reg0, 1), #theater cleared (call_script, "script_find_next_theater", ":defeated_faction", ":defeated_theater"), (assign, ":next_theater", reg0), #Round 2 (call_script, "script_check_active_factions_in_theater", ":next_theater", ":nearest_enemy_faction"), (try_begin), (eq, reg0, 1), #if theater cleared (call_script, "script_find_next_theater", ":defeated_faction", ":next_theater"), (assign, ":next_theater", reg0), (assign, ":no_enemies_found", 1), (try_end), #Round 3, should be enough (try_begin), (eq, ":no_enemies_found", 1), (call_script, "script_check_active_factions_in_theater", ":next_theater", ":nearest_enemy_faction"), (eq, reg0, 1), (call_script, "script_find_next_theater", ":defeated_faction", ":next_theater"), (assign, ":next_theater", reg0), (try_end), (try_begin), (eq, "$tld_war_began", 1), (try_begin), (eq, ":defeated_faction_side", faction_side_good), (call_script, "script_reinforce_next_theater_aux", faction_side_good, ":next_theater"), (else_try), (call_script, "script_reinforce_next_theater_aux", faction_side_hand, ":next_theater"), (call_script, "script_reinforce_next_theater_aux", faction_side_eye, ":next_theater"), (try_end), (else_try), (eq, "$tld_war_began", 2), #War of Two Towers (try_begin), (eq, ":defeated_faction_side", faction_side_eye), (call_script, "script_reinforce_next_theater_aux", faction_side_eye, ":next_theater"), (else_try), (call_script, "script_reinforce_next_theater_aux", faction_side_hand, ":next_theater"), (try_end), (try_end), (neq, reg1, 0), (str_store_faction_name, s22, ":defeated_faction"), (call_script, "script_theater_name_to_s15", ":next_theater"), (try_begin), (store_relation, ":rel", "$players_kingdom", ":defeated_faction"), (gt, ":rel", 0), (assign, ":news_color", color_good_news), (else_try), (assign, ":news_color", color_bad_news), (try_end), (display_message, "@The Remnant Forces of {s22} have gathered to reinforce the {s15} theater!", ":news_color"), (display_message, "@The strength of the remaining allied factions of the {s15} theater has increased", ":news_color"), ]), ("reinforce_next_theater_aux", [ (store_script_param_1, ":fac_side"), (store_script_param_2, ":next_theater"), (assign, ":num_factions", 0), (try_for_range, ":active_factions", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":active_factions", slot_faction_side, ":fac_side"), (faction_get_slot, ":home_theater", ":active_factions", slot_faction_home_theater), (eq, ":home_theater", ":next_theater"), (faction_slot_eq, ":active_factions", slot_faction_state, sfs_active), (val_add, ":num_factions", 1), (try_end), (try_begin), (gt, ":num_factions", 0), (assign, reg1, ":num_factions"), (store_div, ":fac_str_boost", fac_str_reinforcement_boost, ":num_factions"), (try_for_range, ":factions_reinforced", kingdoms_begin, kingdoms_end), (faction_slot_eq, ":factions_reinforced", slot_faction_side, ":fac_side"), (faction_get_slot, ":home_theater", ":factions_reinforced", slot_faction_home_theater), (eq, ":home_theater", ":next_theater"), (faction_slot_eq, ":factions_reinforced", slot_faction_state, sfs_active), (faction_get_slot,":current_strength",":factions_reinforced",slot_faction_strength_tmp), (store_add, ":reinforced_strength", ":current_strength", ":fac_str_boost"), (faction_set_slot,":factions_reinforced",slot_faction_strength_tmp,":reinforced_strength"), #Debug (try_begin), (troop_slot_eq, "trp_player", slot_troop_home, 22), #Kham Cheat Mode, (assign, reg65, ":fac_str_boost"), (str_store_faction_name, s30, ":factions_reinforced"), (display_message, "@{s30} reinforced by {reg65} fac str"), (try_end), #debug end (try_end), (else_try), (assign, reg1, 0), #If fails, we catch it above (try_end), ]), ] command_cursor_scripts = [ ###command_cursor_minimod_begin### # script_cf_shirt_pos1_along_y_axis_to_ground # Input: max distance to shift before failing # Output: pos1 shifted to ground level along forward y-axis ("cf_shift_pos1_along_y_axis_to_ground", [ (store_script_param, ":max_distance", 1), (assign, reg0, 1), #output value (assign, reg10, ":max_distance"), (assign, reg11, 0), #distance so far (get_scene_boundaries, pos10, pos11), (position_get_x, reg12, pos10), (position_get_y, reg13, pos10), (position_get_x, reg14, pos11), (position_get_y, reg15, pos11), (call_script, "script_shift_pos1_along_y_axis_to_ground_aux"), (eq, reg0, 1), #if max distance or scene boundaries were reached, fail (position_set_z_to_ground_level, pos1), ]), ("shift_pos1_along_y_axis_to_ground_aux", [ (val_add, reg2, 100), (copy_position, pos2, pos1), (position_set_z_to_ground_level, pos2), (position_get_x, ":pos1_x", pos1), (position_get_y, ":pos1_y", pos1), (position_get_z, ":pos1_z", pos1), (position_get_z, ":ground_z", pos2), (try_begin), #IF: (this_or_next|ge, reg11, reg10), #distance so far > max_distance OR (this_or_next|le, ":pos1_x", reg12), #pos1 x <= scene min x OR (this_or_next|le, ":pos1_y", reg13), #pos1 y <= scene min y OR (this_or_next|ge, ":pos1_x", reg14), #pos1 x >= scene max x OR (ge, ":pos1_y", reg15), #pos1 y >= scene max y THEN (assign, reg0, -1), #the outer function fails (else_try), (lt, ":ground_z", ":pos1_z"), (position_move_y, pos1, 100), (call_script, "script_shift_pos1_along_y_axis_to_ground_aux"), (try_end), ]), ###command_cursor_minimod_end### ### Kham Gondor Reinforcement Event Scripts ### Kham Defend Center Scripts ("defend_center", [ (store_script_param_1, ":lord"), (store_script_param_2, ":center_to_defend"), (call_script, "script_defend_center_aux", ":lord", ":center_to_defend"), ]), #("defend_minas_tirith", [ # (store_script_param_1, ":lord"), # (call_script, "script_defend_center_aux", ":lord", "p_town_minas_tirith"), # ]), ("defend_center_aux", [ (store_script_param_1, ":lord"), (store_script_param_2, ":center_to_defend"), (assign, ":OK", 0), (try_begin), (call_script, "script_defend_center_aux_AI", ":lord", ":center_to_defend"), (assign, ":OK", reg0), (try_end), (try_begin), (eq, "$cheat_mode", 1), (neq, "$g_fast_mode", 1), (eq, 0,1), # never (assign, reg1, ":lord"), (str_store_troop_name, s1, ":lord"), (str_store_party_name, s2, ":center_to_defend"), (try_begin), (eq, ":OK", 1), (display_message, "@lord {reg1}: {s1} is defending {s2}", color_good_news), (else_try), (display_message, "@lord {reg1}: {s1} NOT defending {s2}", color_bad_news), (try_end), (try_end), ]), ("defend_center_aux_AI", [ (store_script_param_1, ":lord"), (store_script_param_2, ":center_to_defend"), (assign, ":OK", 0), (try_begin), (troop_get_slot, ":party", ":lord", slot_troop_leaded_party), (party_is_active, ":party"), (party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_accompanying_army), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_engaging_army), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_besieging_center), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_retreating_to_center), (call_script, "script_party_set_ai_state", ":party", spai_holding_center, ":center_to_defend"), (assign, ":OK", 1), (try_end), (assign, reg0, ":OK"), ]), ### Kham - Patrol Center Scripts ("patrol_center", [ (store_script_param_1, ":lord"), (store_script_param_2, ":center_to_patrol"), (call_script, "script_patrol_center_aux", ":lord", ":center_to_patrol"), ]), ("patrol_center_aux", [ (store_script_param_1, ":lord"), (store_script_param_2, ":center_to_patrol"), (assign, ":OK", 0), (try_begin), (call_script, "script_patrol_center_aux_AI", ":lord", ":center_to_patrol"), (assign, ":OK", reg0), (try_end), (try_begin), (eq, "$cheat_mode", 1), (neq, "$g_fast_mode", 1), (eq, 0,1), # never (assign, reg1, ":lord"), (str_store_troop_name, s1, ":lord"), (str_store_party_name, s2, ":center_to_patrol"), (try_begin), (eq, ":OK", 1), (display_message, "@lord {reg1}: {s1} is patrolling around {s2}", color_good_news), (else_try), (display_message, "@lord {reg1}: {s1} NOT patrolling around {s2}", color_bad_news), (try_end), (try_end), ]), ("patrol_center_aux_AI", [ (store_script_param_1, ":lord"), (store_script_param_2, ":center_to_patrol"), (assign, ":OK", 0), (try_begin), (troop_get_slot, ":party", ":lord", slot_troop_leaded_party), (party_is_active, ":party"), (party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_accompanying_army), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_engaging_army), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_besieging_center), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_retreating_to_center), (call_script, "script_party_set_ai_state", ":party", spai_patrolling_around_center, ":center_to_patrol"), (assign, ":OK", 1), (try_end), (assign, reg0, ":OK"), ]), ### Kham - Accompany Marshall Scripts ("accompany_marshall", [ (store_script_param_1, ":lord"), (store_script_param_2, ":lord_to_follow"), (call_script, "script_accompany_marshall_aux", ":lord", ":lord_to_follow"), ]), ("accompany_marshall_aux", [ (store_script_param_1, ":lord"), (store_script_param_2, ":lord_to_follow"), (assign, ":OK", 0), (try_begin), (call_script, "script_accompany_marshall_aux_AI", ":lord", ":lord_to_follow"), (assign, ":OK", reg0), (try_end), (try_begin), (eq, "$cheat_mode", 1), (neq, "$g_fast_mode", 1), (eq, 0,1), # never (assign, reg1, ":lord"), (str_store_troop_name, s1, ":lord"), (str_store_troop_name, s2, ":lord_to_follow"), (try_begin), (eq, ":OK", 1), (display_message, "@lord {reg1}: {s1} is accompanying {s2}", color_good_news), (else_try), (display_message, "@lord {reg1}: {s1} NOT accompanying {s2}", color_bad_news), (try_end), (try_end), ]), ("accompany_marshall_aux_AI", [ (store_script_param_1, ":lord"), (store_script_param_2, ":lord_to_follow"), (assign, ":OK", 0), (try_begin), (troop_get_slot, ":party", ":lord", slot_troop_leaded_party), (party_is_active, ":party"), (party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_accompanying_army), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_engaging_army), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_besieging_center), (neg|party_slot_eq, ":party", slot_party_ai_state, spai_retreating_to_center), (call_script, "script_party_set_ai_state", ":party", spai_accompanying_army, ":lord_to_follow"), (party_set_ai_initiative, ":party", 10), (assign, ":OK", 1), (try_end), (assign, reg0, ":OK"), ]), ### Kham Gondor Reinforcement Event Scripts End #script_find_theater # Script: Which theater am I in? (Kham) # INPUT: party to test # OUTPUT: reg0 = theater_SW, theater_SE, theater_C, theater_N, 0 ("find_theater", [(set_fixed_point_multiplier, 100), (store_script_param_1, ":party"), (assign, ":OK", 0), (try_for_range, ":center", centers_begin, centers_end), #(party_is_active, ":center"), (store_faction_of_party, ":faction",":center"), (faction_get_slot, ":home_theater", ":faction", slot_faction_home_theater), (party_get_position, pos1, ":party"), (party_get_position, pos2, ":center"), (get_distance_between_positions, ":dist", pos1, pos2), (lt, ":dist", 3200), #MV: was 3200 (try_begin), (eq, ":OK",0), (eq, ":home_theater",theater_SE), (assign, reg0, theater_SE), (assign, ":OK",1), #(display_message, "@Debug: Theater_SE"), (else_try), (eq, ":OK",0), (eq, ":home_theater",theater_SW), (assign, reg0, theater_SW), (assign, ":OK",1), #(display_message, "@Debug: Theater_SW"), (else_try), (eq, ":OK",0), (eq, ":home_theater",theater_C), (assign, reg0, theater_C), (assign, ":OK",1), #(display_message, "@Debug: Theater_C"), (else_try), (eq, ":OK",0), (eq, ":home_theater",theater_N), (assign, reg0, theater_N), (assign, ":OK",1), #(display_message, "@Debug: Theater_N"), (else_try), (eq, ":OK",0), (assign, reg0, 0), (assign, ":OK",1), #(display_message, "@Debug: Can't Find"), (try_end), (try_end), ]), # script_find_closest_enemy_town_or_host_only # Kham - removed FRIEND of player condition to make it apply to non-player parties # input: faction f, party x # output: reg0 = closest party to x enemy of f, NOT a friend of player, reg1 = its distance ("find_closest_enemy_town_or_host_only",[ (store_script_param, ":fac", 1), (store_script_param, ":target", 2), (assign, ":mindist", 100000), (assign, ":res", -1), (try_for_parties, ":party"), (party_is_active, ":party"), (party_slot_eq, ":party", slot_center_destroyed, 0), # TLD (this_or_next|party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), # its a host (this_or_next|party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_alone), # or a lone hero (is_between, ":party", centers_begin, centers_end), #or a town (store_faction_of_party, ":pfac", ":party"), (store_relation, ":relation", ":pfac", ":fac"), (lt, ":relation", 0), # it's an enemy... (store_distance_to_party_from_party, ":dist", ":party", ":target"), (lt, ":dist", ":mindist"), (assign, ":mindist", ":dist"), (assign, ":res", ":party"), (try_end), (assign, reg0, ":res"), (assign, reg1, ":dist"), ]), #Kham - New Traits Scripts #script_cf_gain_trait_butcher ("cf_gain_trait_butcher",[ (troop_slot_eq, "trp_traits", slot_trait_butcher, 0), (call_script, "script_gain_trait", slot_trait_butcher), ]), #script_gain_trait_well_travelled ("gain_trait_well_travelled",[ (call_script, "script_gain_trait", slot_trait_well_travelled), (store_skill_level, ":skill_1", skl_pathfinding, "trp_player"), (try_begin), (lt, ":skill_1", 10), (troop_raise_skill, "trp_player", skl_pathfinding, 1), (display_log_message, "@Gained permanent +1 to Pathfinding.", color_good_news), (try_end), (store_skill_level, ":skill_2", skl_spotting, "trp_player"), (try_begin), (lt, ":skill_2", 10), (troop_raise_skill, "trp_player", skl_spotting, 1), (display_log_message, "@Gained permanent +1 to Spotting.", color_good_news), (try_end), ]), #script_force_faction_center_by_region - Kham #Used to force faction center for spawning quest party templates #input = faction_side_good, faction_side_eye, faction_side_hand #output = reg0, target_center ("force_faction_center_by_region",[ (store_script_param_1, ":party_no"), (store_script_param_2, ":side"), ## Get Region (call_script, "script_get_region_of_party", ":party_no"), (assign, ":region", reg1), ## Start with Evil Side Targets` (try_begin), (this_or_next|eq, ":side", faction_side_eye), ( eq, ":side", faction_side_hand), ## Rohan Region (try_begin), (is_between, ":region", region_harrowdale, region_misty_mountains), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_edoras"), (assign, reg0, "p_town_edoras"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_east_emnet"), (assign, reg0, "p_town_east_emnet"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_eastfold"), (assign, reg0, "p_town_eastfold"), (else_try), (eq, ":town",3), (party_is_active, "p_town_west_emnet"), (assign, reg0, "p_town_west_emnet"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Gondor Region (else_try), (is_between, ":region", region_pelennor, region_harrowdale), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_minas_tirith"), (assign, reg0, "p_town_minas_tirith"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_pelargir"), (assign, reg0, "p_town_pelargir"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_linhir"), (assign, reg0, "p_town_linhir"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_lossarnach"), (assign, reg0, "p_town_lossarnach"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Center Region (else_try), (is_between, ":region", region_misty_mountains, region_n_mirkwood), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_caras_galadhon"), (assign, reg0, "p_town_caras_galadhon"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_imladris_camp"), (assign, reg0, "p_town_imladris_camp"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_beorn_house"), (assign, reg0, "p_town_beorn_house"), (else_try), (eq, ":town", 3), (party_is_active, "p_town_cerin_dolen"), (assign, reg0, "p_town_cerin_dolen"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Mirkwood Region (else_try), (is_between, ":region", region_n_mirkwood, region_c_mirkwood), (store_random_in_range, ":town", 0,3), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_thranduils_halls"), (assign, reg0, "p_town_thranduils_halls"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_woodelf_camp"), (assign, reg0, "p_town_woodelf_camp"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_woodelf_west_camp"), (assign, reg0, "p_town_woodelf_west_camp"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## North Region (else_try), (is_between, ":region", region_c_mirkwood, region_grey_mountains), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_dale"), (assign, reg0, "p_town_dale"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_erebor"), (assign, reg0, "p_town_erebor"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_esgaroth"), (assign, reg0, "p_town_esgaroth"), (else_try), (eq, ":town", 3), (party_is_active, "p_town_ironhill_camp"), (assign, reg0, "p_town_ironhill_camp"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), (else_try), ## Everything else, target Gondor (try_begin), (party_is_active, "p_town_minas_tirith"), (assign, reg0, "p_town_minas_tirith"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), (try_end), ## End Evil side ## Good Side Targets (else_try), ##Isengard Area (try_begin), (is_between, ":region", region_harrowdale, region_misty_mountains), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_isengard"), (assign, reg0, "p_town_isengard"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_dunland_camp"), (assign, reg0, "p_town_dunland_camp"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_urukhai_outpost"), (assign, reg0, "p_town_urukhai_outpost"), (else_try), (eq, ":town", 3), (party_is_active, "p_town_urukhai_r_camp"), (assign, reg0, "p_town_urukhai_r_camp"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Mordor / Khand / Umbar (else_try), (is_between, ":region", region_pelennor, region_harrowdale), (store_random_in_range, ":town", 0,3), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_minas_morgul"), (assign, reg0, "p_town_minas_morgul"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_umbar_camp"), (assign, reg0, "p_town_umbar_camp"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_khand_camp"), (assign, reg0, "p_town_khand_camp"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Center Region (else_try), (is_between, ":region", region_misty_mountains, region_n_mirkwood), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_dol_guldur"), (assign, reg0, "p_town_dol_guldur"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_gundabad"), (assign, reg0, "p_town_gundabad"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_moria"), (assign, reg0, "p_town_moria"), (else_try), (eq, ":town", 3), (party_is_active, "p_town_goblin_south_outpost"), (assign, reg0, "p_town_goblin_south_outpost"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Mirkwood Region (else_try), (is_between, ":region", region_n_mirkwood, region_c_mirkwood), (store_random_in_range, ":town", 0,3), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_gundabad_m_outpost"), (assign, reg0, "p_town_gundabad_m_outpost"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_dol_guldur"), (assign, reg0, "p_town_dol_guldur"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_rhun_south_camp"), (assign, reg0, "p_town_rhun_south_camp"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## North (else_try), (is_between, ":region", region_c_mirkwood, region_grey_mountains), (store_random_in_range, ":town", 0,4), (try_begin), (eq, ":town", 0), (party_is_active, "p_town_morannon"), (assign, reg0, "p_town_morannon"), (else_try), (eq, ":town", 1), (party_is_active, "p_town_rhun_main_camp"), (assign, reg0, "p_town_rhun_main_camp"), (else_try), (eq, ":town", 2), (party_is_active, "p_town_goblin_north_outpost"), (assign, reg0, "p_town_goblin_north_outpost"), (else_try), (eq, ":town", 3), (party_is_active, "p_town_rhun_north_camp"), (assign, reg0, "p_town_rhun_north_camp"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), ## Everything else, target Mordor (else_try), (try_begin), (party_is_active, "p_town_morannon"), (assign, reg0, "p_town_morannon"), (else_try), (call_script, "script_cf_get_random_enemy_center_within_range", "p_main_party", tld_max_quest_distance), (try_end), (try_end), ## End Good Side Targets (try_end), #end Script ]), # script_safe_remove_party # kills a party, but checks that it is a spawned party, to avoid corruption # INPUT: param1: Party-id ("safe_remove_party", [ (store_script_param_1, ":party_id"), (str_store_party_name, s1, ":party_id"), (try_begin), (eq, "$cheat_mode",1), (neg|party_is_active, ":party_id"), #(display_message, "@DEBUG: Removing INVALID party {s1}"), (try_end), (try_begin), (is_between, ":party_id","p_main_party", "p_scribble_242"), (neq, ":party_id", "p_main_party"), (disable_party, ":party_id"), (tutorial_box, "@INVALID PARTY BEING REMOVED ({s1})! DISABLED INSTEAD. PLEASE LET THE DEVS KNOW. THIS IS A TEST AGAINST SAVE GAME CORRUPTION."), (try_begin), (eq, "$cheat_mode",1), #(display_message, "@{s1} disabled"), (try_end), (else_try), (neq, ":party_id", "p_main_party"), (remove_party, ":party_id"), (try_begin), (eq, "$cheat_mode",1), #(display_message, "@{s1} removed"), (try_end), (try_end), ]), ############################# TLD CHEAP PARTY HANDLING #############################?# # Objective: spawn fewer parties, to try avoiding corruption # # How to use: # every time you want to "remove_party" a party, call "script_remove_party" instead. # every time you want to "spawn_around_party" a party, call "script_spawn_around_party" instead. # # Effect: on removal, party aren't removed, they are just disabled and go dormant. # on creation, if there's a dormant parties of the same tamplate, it is revived and used. ("remove_party",[ (store_script_param_1, ":party"), (party_set_slot, ":party", slot_party_dormant, 1), (party_clear, ":party", slot_party_dormant, 1), (party_add_members, ":party", "trp_dormant", 1), (disable_party, ":party"), # hide it #Debug (try_begin), (eq, "$cheat_mode", 1), (str_store_party_name, s1, ":party"), (display_message, "@DEBUG: {s1} made dormant."), (try_end), ]), ("spawn_around_party",[ (store_script_param_1, ":around"), (store_script_param_2, ":pt"), # look for a suitable dormant party (assign, ":found", -1), (try_for_parties, ":party"), (lt, ":found", 0), # didn't find it yet (neg|party_is_active, ":party"), (party_slot_eq, ":party", slot_party_dormant, 1), (party_get_template_id, ":x", ":party"),(eq, ":x", ":pt"), (assign, ":found", ":party"), (try_end), (try_begin), (ge, ":found", 0), # dormant party found: use it! (party_clear, ":found"), (party_add_template, ":found", ":pt"), (party_set_slot, ":party", slot_party_dormant, 0), (enable_party, ":found"), (assign, reg0, ":found"), (party_relocate_near_party, reg0, ":around", 2), # use "$dormant_spawn_radius" instead of 2 when we start using the new script below #Debug (try_begin), (eq, "$cheat_mode", 1), (str_store_party_name, s1, reg0), (str_store_party_name, s2, ":around"), (display_message, "@DEBUG: Dormant {s1} spawned around {s2}"), (try_end), (else_try), # dormant party not found (spawn_around_party, ":around", ":pt"), #Debug (try_begin), (eq, "$cheat_mode", 1), (str_store_party_name, s1, reg0), (str_store_party_name, s2, ":around"), (display_message, "@DEBUG: No Dormant {s1} found. Creating one near {s2}"), (try_end), (try_end), ]), ("set_spawn_radius",[ (store_script_param_1, ":x"), (assign, "$dormant_spawn_radius", ":x"), (set_spawn_radius, ":x"), ]), ## Kham - script_healing_routine_full #script_healing_routine ("healing_routine_full",[ (store_script_param_1, ":npc"), (troop_get_slot, ":wound_mask", ":npc", slot_troop_wound_mask), (try_begin), (neq, ":wound_mask", 0), # only injured heroes apply (neq, ":wound_mask", wound_death),# only alive heroes apply (try_for_range, ":rnd", 0, 4), (str_store_troop_name, s1, ":npc"), (try_begin), (eq,":npc", "trp_player"), (str_store_string,s11,"@You_have"), (else_try), (str_store_string,s11,"@{s1}_has"), (try_end), (try_begin), (eq, ":rnd", 0), (store_and, ":check", ":wound_mask", wound_leg), (neq, ":check", 0), #(store_skill_level,":skill",skl_riding ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_riding, ":x"), #(store_skill_level,":skill",skl_athletics,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",2),(troop_raise_skill,":npc",skl_athletics, ":x"), (troop_raise_attribute, ":npc", ca_agility, 2), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, 15), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, 15), (troop_raise_proficiency_linear, ":npc", wpt_polearm, 15), (val_sub, ":wound_mask", wound_leg), (display_message, "@{s11}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_leg_wound_has_healed."), (display_message, "@(+2_athletics,_+1_riding,_+2_agility,_+15_melee_skill)"), (else_try), (eq, ":rnd", 1), (store_and, ":check", ":wound_mask", wound_arm), (neq, ":check", 0), #(store_skill_level,":skill",skl_power_draw ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_power_draw, ":x"), #(store_skill_level,":skill",skl_power_throw ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_power_throw, ":x"), #(store_skill_level,":skill",skl_power_strike,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_power_strike, ":x"), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_polearm, 20), (troop_raise_proficiency_linear, ":npc", wpt_archery, 20), (troop_raise_proficiency_linear, ":npc", wpt_throwing, 20), (troop_raise_attribute, ":npc", ca_strength, 2), (val_sub, ":wound_mask", wound_arm), (display_message, "@{s11}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_arm_wound_has_healed."), (display_message, "@(+20_weapon_skill,_+2_strength,_+1_power_attacks)"), (else_try), (eq, ":rnd", 2), (store_and, ":check", ":wound_mask", wound_head), (neq, ":check", 0), #(store_skill_level,":skill",skl_trade ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_trade, ":x"), #(store_skill_level,":skill",skl_first_aid ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_first_aid, ":x"), #(store_skill_level,":skill",skl_surgery ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_surgery, ":x"), #(store_skill_level,":skill",skl_wound_treatment,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_wound_treatment, ":x"), #(store_skill_level,":skill",skl_pathfinding ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_pathfinding, ":x"), #(store_skill_level,":skill",skl_spotting ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_spotting, ":x"), #(store_skill_level,":skill",skl_tracking ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_tracking, ":x"), #(store_skill_level,":skill",skl_tactics ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_tactics, ":x"), #(store_skill_level,":skill",skl_trainer ,":npc"),(assign,":x",10),(val_sub,":x",":skill"),(val_min,":x",1),(troop_raise_skill,":npc",skl_trainer, ":x"), (troop_raise_proficiency_linear, ":npc", wpt_archery, 15), (troop_raise_proficiency_linear, ":npc", wpt_throwing, 15), (val_sub, ":wound_mask", wound_head), (display_message, "@{s11}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_head_wound_has_healed."), (display_message, "@(+1_intelligence_skills,_+15_missile_skill)"), (else_try), (eq, ":rnd", 3), (store_and, ":check", ":wound_mask", wound_chest), (neq, ":check", 0), (troop_raise_proficiency_linear, ":npc", wpt_one_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_two_handed_weapon, 20), (troop_raise_proficiency_linear, ":npc", wpt_polearm, 20), (troop_raise_proficiency_linear, ":npc", wpt_archery, 20), (troop_raise_proficiency_linear, ":npc", wpt_throwing, 20), (val_sub, ":wound_mask", wound_chest), (display_message, "@{s1}_recovered_from_a_serious_wound.", color_good_news), (display_message, "@The_cracked_ribs_have_healed."), (display_message, "@(+20_weapon_skill)"), (try_end), (try_end), (troop_set_slot, ":npc", slot_troop_wound_mask, ":wound_mask"), (try_end), ]), #script_cf_party_exists #checks if a party exists, fails if not (Rafa) # INPUT: arg1 = party_no # OUTPUT: nothing (fails if party doesn't exists) ("cf_party_exists",[ (store_script_param_1, ":checked_party_no"), (assign,":tmp",reg0), (assign,reg0,":checked_party_no"), #(display_message, "@Party existence check got called for party {reg0}"), (ge,":checked_party_no",0), (try_begin), # this try assumes that party_is_active is way faster than iterating through parties # should be stress tested against a pure try_for_parties solution, someday (party_is_active, ":checked_party_no"), (assign, ":party_exists", 1), #(display_message, "@Party {reg0} is active, finished"), (else_try), #(display_message, "@Party {reg0} is not active, checking if it exists"), (assign, ":party_exists", 0), (try_for_parties, ":party_no"), (eq,":party_no",":checked_party_no"), (assign,":party_exists",1), #(display_message, "@Party {reg0} found"), (try_end), (try_end), (assign,reg0,":tmp"), (eq,":party_exists",1), ]), #script_cf_neg_1p #inverts the fail condition of a script with 1 parameter (Rafa) # INPUT: arg1 = script to be called # INPUT: arg2 = script arg 1 # OUTPUT: the same as the called script, plus succeeds if the script fails and fails if script succeeds ("cf_neg_1p",[ (store_script_param_1, ":script_no"), (store_script_param_2,":arg1"), (assign,":result",0), (try_begin), (call_script,":script_no",":arg1"), (assign,":result",1), (end_try), (eq,":result",0), ]), #script_cf_party_is_disabled #checks if a party is disabled, fails if not (Rafa) # INPUT: arg1 = party_no # OUTPUT: nothing (fails if party is not disabled) ("cf_party_is_disabled",[ (store_script_param_1, ":party_no"), (neg|party_is_active,":party_no"), (call_script, "script_cf_party_exists",":party_no"), ]), #script_delete_volunteers_party #deletes a town volunteer party # INPUT: arg1 = town_no # OUTPUT: nothing ("delete_volunteers_party",[ (store_script_param_1, ":town"), (try_begin), (is_between,":town", centers_begin, centers_end), (call_script,"script_cf_party_exists",":town"), (party_get_slot, ":volunteers", ":town", slot_town_volunteer_pt), (gt,":volunteers",0), (party_set_slot,":town",slot_town_volunteer_pt,0), (call_script,"script_cf_party_exists",":volunteers"), # we only remove valid parties (call_script,"script_safe_remove_party",":volunteers"), (try_end), ]), #script_create_volunteers_party #creates or replaces a town volunteer party #overrides negative slot_town_volunteer_pt values # INPUT: arg1 = town_no, # arg2: 0 to delete the old volunteer party # any other value to keep it # (if arg2!=0, always store the old volunteer party number before calling this script and delete it yourself after it's not longer used) # OUTPUT: reg0: the volunteer party id or -1 if wasn't created # dirties s4 ("create_volunteers_party",[ (store_script_param_1, ":town"), (store_script_param_2, ":keep_old_party"), (assign,":volunteers",-1), (try_begin), (is_between,":town", centers_begin, centers_end), (call_script,"script_cf_party_exists",":town"), (party_get_slot, ":volunteers", ":town", slot_town_volunteer_pt), (try_begin), (gt,":volunteers",0), (eq,":keep_old_party",0), (call_script,"script_delete_volunteers_party",":town"), (end_try), (spawn_around_party, ":town", "pt_volunteers"), #Kham - use actual party template instead of 'none' (assign, ":volunteers", reg0), (party_attach_to_party, ":volunteers", ":town"), (party_set_slot, ":town", slot_town_volunteer_pt, ":volunteers"), #(party_set_name, ":volunteers", "@Volunteers"), # was "@_+_" # Kham - no need to rename as we created an actual party template (party_set_flags, ":volunteers", pf_no_label), (party_set_ai_behavior, ":volunteers", ai_bhvr_hold), (store_faction_of_party, ":town_fac", ":town"), (try_begin), (faction_slot_eq, ":town_fac", slot_faction_side, faction_side_good), (str_store_string, s4, "@Volunteers"), (else_try), (str_store_string, s4, "@Reserves"), (try_end), (party_set_name, ":volunteers", "@{s4}"), (try_end), (assign,reg0,":volunteers"), #just in case it was dirtied someplace ]), #script_migrate_volunteer_system (Rafa) # deletes all the trp_volunteers and makes sure that all the volunteer parties are valid and of template pf_volunteers # INPUT: nothing # OUTPUT: nothing # dirties reg0 ("migrate_volunteer_system",[ #for every party (try_for_parties, ":party_no"), #check if it has a volunteer stack and delete it if found (party_count_members_of_type, ":volunteers_no", ":party_no", trp_volunteers), # does a 0 call to party_remove_members fails? if then, enclose this check on a try and add a (gt,":volunteers_no",0) here (party_remove_members, ":party_no", trp_volunteers, ":volunteers_no"), (try_end), (try_for_range,":town",centers_begin,centers_end), (try_begin), #check if the center exists and has a volunteer party (call_script,"script_cf_party_exists",":town"), (party_get_slot, ":volunteer_pt_no", ":town", slot_town_volunteer_pt), (gt,":volunteer_pt_no",0), #without a volunteer party we have no need to proceed (we could even remove the player's party if we did!) (try_begin), #check if it's valid; if not valid, delete it ## CAUTION, TO DO: check if volunteer parties get disabled at times (i.e.: when disabling advance camps) # meanwhile we remove disabled volunteer parties (might want to change that) (neg|party_is_active,":volunteer_pt_no"), (call_script,"script_delete_volunteers_party",":town"), (else_try), #check if the center is in hands of the enemy, if so delete the volunteer party (store_faction_of_party,":centers_faction",":town"), (store_relation,":relation",":centers_faction","$players_kingdom"), (lt,":relation",0), (call_script,"script_delete_volunteers_party",":party_no"), (else_try), #check if the volunteer party template is pt_none (party_get_template_id, ":party_template", ":volunteer_pt_no"), (eq,":party_template",pt_none), #in that case, change it (call_script,"script_create_volunteers_party",":town",1), (assign,":new_volunteer_pt_no",reg0), (call_script,"script_party_copy",":new_volunteer_pt_no",":volunteer_pt_no"), (call_script,"script_safe_remove_party",":volunteer_pt_no"), (try_end), (try_end), (try_end), ]), #script_cf_spawn_around_party_on_walkable_terrain #Input: arg1: party to spawn around - arg2: spawning party template - arg3: spawning radius #Output: reg0: Party ID of spawned party #Spourious output: pos1: position of the generating party pos2: position of spawned party #Fails if couldn't spawn a party on walkable terrain ("cf_spawn_around_party_on_walkable_terrain", [ (store_script_param, ":generating_party", 1), (store_script_param, ":template", 2), (store_script_param, ":radius", 3), (gt, ":template", 0), # Fail if party template is incorrect (party_get_position, pos1, ":generating_party",), #(assign, ":terrain_check", 0), # Check if spawned party is not in weird terrain (assign,":lower_bound",0), (try_for_range_backwards, ":unused", ":lower_bound", 50), (map_get_land_position_around_position, pos2, pos1, ":radius"), #(map_get_random_position_around_position, pos2, pos1, ":radius"), (party_set_position, "p_terrain_party", pos2), (party_get_current_terrain, ":terrain_type", "p_terrain_party"), (try_begin), (neq, ":terrain_type", rt_water), (neq, ":terrain_type", rt_mountain), (neq, ":terrain_type", rt_river), #(assign, ":terrain_check", 1), (assign, ":lower_bound", 9999), (try_end), (try_end), # (eq,":terrain_check",1), # Fail here if couldn't find a valid place (neq,":lower_bound",0), # Fail here if couldn't find a valid place (spawn_around_party,":generating_party",":template"), (party_set_position, reg0, pos2), #Debug #(str_store_party_name, s10, ":generating_party"), #(str_store_party_name, s11, reg0), #(display_log_message, "@Giver: {s10} --- Spawned: {s11}"), ]), #script_destroy_scout_camp_consequences #Executes the faction strength changes of the destroy scout camp quest and shows the corresponding messages #arg1: 0: Mission failed Not 0: Mission succeeded #Dirties s10,s14,s11,s13 ("destroy_scout_camp_consequences", [ (store_script_param_1, ":success"), #Faction Strength Changes - Balance Document can be found on Google Drive: https://goo.gl/CErgSN (str_clear, s10), (str_clear, s14), (str_clear, s11), (str_clear, s13), (try_begin), (eq,":success",0), (str_store_string, s10, "@have taken measure of your faction's current strength and has grown bolder."), (str_store_string, s14, "@loses Faction Strength as supply lines were disrupted."), (assign,":news_color",color_bad_news), (else_try), (str_store_string, s10, "@loses Faction Strength due to the destruction of their camp."), (str_store_string, s14, "@gains Faction Strength as news of your victory spreads."), (assign,":news_color",color_good_news), (try_end), (quest_get_slot, ":scout_camp_faction", "qst_destroy_scout_camp", slot_quest_target_faction), (quest_get_slot, ":quest_giver_troop", "qst_destroy_scout_camp", slot_quest_giver_troop), (store_troop_faction, ":quest_giver_faction", ":quest_giver_troop"), (str_store_faction_name, s11, ":scout_camp_faction"), (str_store_faction_name, s13, ":quest_giver_faction"), (display_message,"@{s11} {s10}",":news_color"), (display_message,"@{s13} {s14}",":news_color"), (faction_get_slot,":enemy_strength",":scout_camp_faction",slot_faction_strength_tmp), (faction_get_slot,":giver_strength",":quest_giver_faction",slot_faction_strength_tmp), (store_character_level, ":level", "trp_player"), (val_max,":level",11), # Keep ":level" between 11 and 23 (val_min,":level",30), (quest_get_slot,":camp_template","qst_destroy_scout_camp",slot_quest_target_party_template), (try_begin), (eq,":camp_template","pt_scout_camp_small"), #Small Scout Camp (try_begin), # Failure: Enemy Win Min: 125; Max: 150 - Hero Loss Min: 275; Max: 300 (eq,":success",0), (val_mul, ":level",5), (val_add, ":level", 70), (val_add, ":enemy_strength", ":level"), (val_add, ":level", 150), (val_sub, ":giver_strength", ":level"), (else_try), #Success: Enemy Loss Min: 93; Max: 108 - Hero Win Min: 148; Max: 163 (val_mul, ":level",3), (val_add, ":level", 60), (val_sub, ":enemy_strength", ":level"), (val_add, ":level", 55), (val_add, ":giver_strength", ":level"), (try_end), (else_try), (eq,":camp_template","pt_scout_camp_large"), #Fortified Scout Camp (try_begin), # Failure: Enemy Win Min: 270; Max: 320 - Hero Loss Min: 420; Max: 470 (eq,":success",0), (val_mul, ":level",10), (val_add, ":level", 100), (val_add, ":enemy_strength", ":level"), (val_add, ":level", 150), (val_sub, ":giver_strength", ":level"), (else_try), # Success: Enemy Loss Min: 145; Max: 170 - Hero Win Min: 200; Max: 225 (val_mul, ":level",5), (val_add, ":level", 60), (val_sub, ":enemy_strength", ":level"), (val_add, ":level", 55), (val_add, ":giver_strength", ":level"), (try_end), (try_end), (faction_set_slot,":quest_giver_faction",slot_faction_strength_tmp,":giver_strength"), (faction_set_slot,":scout_camp_faction",slot_faction_strength_tmp,":enemy_strength"), ]), #script_cf_get_random_center_in_theater # Gets a random, active and not destroyed center at the arg1 party theater, relation filter optional, fails if there is none #input: arg1: party to get the theater #input: arg2: filter by relation to arg1 party: # values: -2:enemy # -1:neutral or friendly # 0:all # >0:of that value of faction_no #output: reg0 the selected center ("cf_get_random_center_in_theater", [ (store_script_param_1, ":party_no"), (store_script_param_2, ":filter"), # Retrieve the party theater (getting the theater of the closest center to the party) (call_script,"script_get_closest_center",":party_no"), (assign, ":center_no",reg0), (party_get_slot,":party_theater",":center_no",slot_center_theater), # Retrieve the party faction too (store_faction_of_party,":party_faction",":party_no"), # Gets the quick array (call_script,"script_warp_get_quick_array"), (assign, ":array",reg0), # Populates the array with the enemy centers at the theater (try_for_range,":center_no",centers_begin,centers_end), #if active and not destroyed (party_is_active,":center_no"), (party_get_slot,":destroyed",":center_no",slot_center_destroyed), (eq,":destroyed",0), #and on the same theater (party_get_slot,":center_theater",":center_no",slot_center_theater), (eq,":center_theater",":party_theater"), #And with filter (assign,":applies",0), (try_begin), # Filter 0: all apply (eq,":filter",0), (assign,":applies",1), (else_try), (store_faction_of_party,":center_faction",":center_no"), (store_relation,":rel",":center_faction",":party_faction"), (eq,":filter",-2), # Filter = -2, enemy centers apply (lt,":rel",0), (assign,":applies",1), (else_try), (eq,":filter",-1), # Filter = -1, neutral or friendly centers apply (ge,":rel",0), (assign,":applies",1), (else_try), (gt,":filter",0), # Filter > 0: of a certain faction_no (eq,":center_faction",":filter"), (assign,":applies",1), (try_end), (try_begin), #Store the center on the array's tail if it pass the filter (eq,":applies",1), (call_script,"script_warp_array_push",":array",":center_no"), (try_end), (try_end), # Retrieves a random element of the array. (assign,reg0,-1), (try_begin), (call_script,"script_cf_warp_get_random",":array"), (try_end), #(call_script,"script_warp_array_length",":array"), #(assign,":length",reg0), # Get the array's length # We don't want to fail ATM as that would left the array undeleted (no longer a problem with the quick array use, but's still a good practice) # (store_random_in_range,":rnd",0,":length"), # Get a random number from 0 to length-1 # (val_add,":rnd",1), # Increase the random number in one in order to match the array indexes, which go from 1 to length # (call_script,"script_cf_warp_array_get",":array",":rnd"), # this would leave a random center on reg0 or fail #(try_end), # Deletes the array # (call_script,"script_warp_array_delete",":array"), # no longer needed by the quick array use # Fails if no center was found (ge,reg0,0), ]), #aliases: ("cf_get_random_enemy_center_in_theater",[ (store_script_param_1, ":party_no"), (call_script,"script_cf_get_random_center_in_theater",":party_no",-2), ]), ("cf_get_random_friendly_center_in_theater",[ (store_script_param_1, ":party_no"), (call_script,"script_cf_get_random_center_in_theater",":party_no",-1), ]), #script_create_smoking_remnants #Create temporary smoking remnants #arg1: party in whose position remnants will spawn #arg2: remnants icon #arg3: smoking time #arg4: visibility: 0: normal visibility - 1: always visible #dirties reg0, pos10 ("create_smoking_remnants", [ (store_script_param,":spawning_party",1), (store_script_param,":icon", 2), (store_script_param,":time", 3), (store_script_param,":always_visible",4), (try_begin), # Time >0: Burning remains (gt,":time",0), (party_get_position,pos10,":spawning_party"), (call_script,"script_create_temp_map_prop_on_pos10",":icon",":time",":always_visible","psys_map_village_looted_smoke"), #other candidate effect is "psys_map_village_fire_smoke" (val_div,":time",2), # Flames for (time/2)-1 (val_sub,":time",1), (call_script,"script_create_temp_map_prop_on_pos10",":icon",":time",":always_visible","psys_map_village_fire"), (try_end), ]), #script_create_temp_map_prop_on_pos10 #Creates a temporary icon on the map on pos10, with optional particle effects #arg1: prop icon #arg2: prop duration #arg3: visibility: 0: normal visibility - 1: always visible #arg4: effect: <0: no effects >=0: particle system effect #dirties reg0, pos10 ("create_temp_map_prop_on_pos10",[ (store_script_param,":icon", 1), (store_script_param,":time", 2), (store_script_param,":always_visible",3), (store_script_param,":particle", 4), (try_begin), (gt,":time",0), (spawn_around_party,"p_main_party","pt_none"), (assign,":party_no",reg0), (party_set_position,":party_no",pos10), (party_set_icon,":party_no",":icon"), (party_set_flags,":party_no",pf_is_static|pf_no_label,1), (party_set_flags,":party_no",pf_always_visible,":always_visible"), (party_set_ai_behavior, ":party_no", ai_bhvr_hold), #(party_set_name,":party_no","@Prop"), # for savegame debug (party_set_slot,":party_no",slot_center_destroyed,1), (party_set_slot, ":party_no", slot_village_smoke_added, ":time"), (try_begin), (ge,":particle",0), (party_add_particle_system, ":party_no", ":particle"), (try_end), (try_end), ]), #script_update_savegame #Updates the current game state to the latest version, in order to keep backwards compatibility. #Input: none #Output: Updated game state ("update_savegame",[ (try_for_range, ":trolls", trp_moria_troll, trp_ent+1), (call_script, "script_get_hp_shield_value", ":trolls"), (try_end), (try_begin), (lt,"$savegame_version",1), (call_script,"script_migrate_volunteer_system"), (assign,"$savegame_version",1), (try_end), (try_begin), (lt,"$savegame_version",2), # Fix Cair Andros elder (try_begin), (party_is_active,"p_town_cair_andros"), (store_faction_of_party, ":faction_no", "p_town_cair_andros"), (faction_get_slot, ":capital", ":faction_no", slot_faction_capital), (party_get_slot, ":elder", ":capital", slot_town_elder), (party_set_slot, "p_town_cair_andros", slot_town_elder, ":elder"), (try_end), # Fix capturable centers tavern keepers ]+concatenate_scripts([[ (try_begin), (assign, ":center_no", center_list[x][0]), (party_is_active,":center_no"), (party_set_slot,":center_no",slot_town_captain, center_list[x][2][0]), (try_end), ] for x in range(len(center_list)) if center_list[x][8]==0] )+[ (assign,"$savegame_version",2), (try_end), (try_begin), #Kham - Aug 17, 2017 (lt,"$savegame_version",3), #add Begin War Choice & Field Ai Menu & Brighter Nights (assign, "$tld_player_level_to_begin_war",8), #Kham - Custom Level to Start the War (assign, "$bright_nights",1), #Kham - Brighter Nights (assign, "$field_ai_lord",1), #Kham - Battlefield Lord AI (assign, "$field_ai_horse_archer",1), #Kham - Battlefield Horse Archer AI (assign, "$field_ai_archer_aim",1), #Kham - Battlefield Archer Aim (assign, "$savegame_version",3), (try_end), (try_begin), #Kham - Oct 13, 2017 (lt,"$savegame_version",4), (assign, "$advanced_siege_ai",1), #Kham - Advanced Siege AI (assign, "$savegame_version",4), (try_end), (try_begin), #Kham - Jan 2018 (lt,"$savegame_version",5), (item_set_slot, "itm_horse_meat", slot_item_food_bonus, 5), (assign, "$savegame_version",5), (try_end), (try_begin), #Kham - Jan 2018 (lt,"$savegame_version",6), (item_set_slot, "itm_beorn_berserk", slot_item_player_color, 1), (item_set_slot, "itm_beorn_berserk", slot_item_num_components, 1), (item_set_slot, "itm_beorn_berserk", slot_item_materials_begin, "str_beornings_female"), (item_set_slot, "itm_beorn_berserk", slot_item_materials_end, "str_khand_light_fem"), (item_set_slot, "itm_khand_light", slot_item_player_color, 1), (item_set_slot, "itm_khand_light", slot_item_num_components, 1), (item_set_slot, "itm_khand_light", slot_item_materials_begin, "str_khand_light_fem"), (item_set_slot, "itm_khand_light", slot_item_materials_end, "str_npc18_intro"), (assign, "$slow_when_wounded", 1), (assign, "$savegame_version",6), (try_end), (try_begin), #Kham - Jan 2019 (lt,"$savegame_version",7), (try_for_range, ":has_combat_ai", kingdom_heroes_begin, kingdom_heroes_end), (troop_set_slot, ":has_combat_ai", slot_troop_has_combat_ai, 1), (try_end), (troop_set_slot, "trp_npc5", slot_troop_has_combat_ai, 1), #Glorfindel (troop_set_slot, "trp_npc13", slot_troop_has_combat_ai, 1), #Lykyada (troop_set_slot, "trp_black_numenorean_sorcerer", slot_troop_has_combat_ai, 1), (troop_set_slot, "trp_nazgul", slot_troop_has_combat_ai, 1), (troop_set_slot, "trp_badass_theo", slot_troop_has_combat_ai, 1), (troop_set_slot, "trp_killer_witcher", slot_troop_has_combat_ai, 1), (assign, "$savegame_version",7), (try_end), (try_begin), #Kham - Jan 2019 (lt,"$savegame_version",7), (assign, "$battle_encounter_effects", 1), (assign, "$savegame_version",8), (try_end), (try_begin), #Kham - March 2019 (lt, "$savegame_version", 8), (faction_set_slot, "fac_guldur", slot_faction_tier_1_troop, trp_i1_guldur_orc_snaga ), (faction_set_slot, "fac_guldur", slot_faction_tier_2_troop, trp_a2_guldur_orc_tracker ), (faction_set_slot, "fac_guldur", slot_faction_tier_3_troop, trp_a3_guldur_large_orc_tracker ), (faction_set_slot, "fac_guldur", slot_faction_tier_4_troop, trp_a4_guldur_fell_orc_tracker ), (faction_set_slot, "fac_guldur", slot_faction_tier_5_troop, trp_c4_mordor_great_warg_rider ), (assign, "$savegame_version", 9), (try_end), (try_begin), #Kham - April 2019 (lt, "$savegame_version", 9), (call_script, "script_initialize_guildmaster_companion_strings"), (assign, "$savegame_version", 10), (try_end), (try_begin), #Kham - March 2020 (lt, "$savegame_version", 10), (troop_set_slot, "trp_moria_vet_troll", slot_troop_troll_armoured_variant, "trp_moria_armored_troll"), (troop_set_slot, "trp_isen_vet_troll", slot_troop_troll_armoured_variant, "trp_isen_armored_troll"), (troop_set_slot, "trp_mordor_vet_troll", slot_troop_troll_armoured_variant, "trp_mordor_olog_hai"), (faction_set_slot, "fac_moria", slot_faction_troll_troop, "trp_moria_troll"), (faction_set_slot, "fac_isengard", slot_faction_troll_troop, "trp_isen_troll"), (faction_set_slot, "fac_mordor", slot_faction_troll_troop, "trp_mordor_troll"), (faction_set_slot, "fac_gundabad", slot_faction_troll_troop, "trp_gunda_troll"), (assign, "$savegame_version", 11), (try_end), (try_begin), #Kham - March 2020 (lt, "$savegame_version", 11), (try_for_range, ":kingdoms", kingdoms_begin, kingdoms_end), (neq, ":kingdoms", "fac_moria"), (neq, ":kingdoms", "fac_isengard"), (neq, ":kingdoms", "fac_mordor"), (neq, ":kingdoms", "fac_gundabad"), (neq, ":kingdoms", "fac_guldur"), (faction_set_slot, ":kingdoms", slot_faction_troll_troop, -1), (try_end), (faction_set_slot, "fac_guldur", slot_faction_troll_troop, "trp_mordor_troll"), (assign, "$savegame_version", 12), (try_end), (try_begin), #InVain - March 2020 (le, "$savegame_version", 12), (try_for_range, ":trolls", trp_moria_troll, trp_multiplayer_profile_troop_male), (troop_set_type, ":trolls", tf_troll), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (troop_add_item, ":trolls", "itm_troll_head", imod_rotten), (try_end), (assign, "$savegame_version", 13), (try_end), (try_begin), #InVain - March 2020, fix troll stats for old savegames (le, "$savegame_version", 13), (try_for_range, ":trolls", trp_moria_troll, trp_multiplayer_profile_troop_male), (store_skill_level, ":ironflesh", skl_ironflesh, ":trolls"), (lt, ":ironflesh", 6), #so we don't affect new savegames which already have correct troll stats (troop_raise_skill, ":trolls", skl_ironflesh, -15), (troop_raise_skill, ":trolls", skl_ironflesh, 10), (store_skill_level, ":power_strike", skl_power_strike, ":trolls"), (lt, ":power_strike", 5), #so we don't affect new savegames which already have correct troll stats (troop_raise_skill, ":trolls", skl_power_strike, -15), (troop_raise_skill, ":trolls", skl_power_strike, 10), (store_proficiency_level, ":one_handed", wpt_one_handed_weapon, ":trolls"), (lt, ":one_handed", 70), #so we don't affect new savegames which already have correct troll stats (troop_raise_proficiency_linear, ":trolls", wpt_one_handed_weapon, -100), (troop_raise_proficiency_linear, ":trolls", wpt_one_handed_weapon, 80), (store_proficiency_level, ":two_handed", wpt_two_handed_weapon, ":trolls"), (lt, ":one_handed", 70), #so we don't affect new savegames which already have correct troll stats (troop_raise_proficiency_linear, ":two_handed", wpt_two_handed_weapon, -100), (troop_raise_proficiency_linear, ":two_handed", wpt_two_handed_weapon, 80), (try_end), (assign, "$savegame_version", 14), (try_end), (try_begin), #InVain - April 2020, fix Goblin stats for old savegames (le, "$savegame_version", 14), (try_for_range, ":trolls", trp_mountain_goblin, trp_future_troop_10), (troop_set_type, ":trolls", tf_orc), (try_end), (assign, "$savegame_version", 15), (try_end), (try_begin), #InVain - April 2020, fix Ziggy NPC clash dialogue (le, "$savegame_version", 15), (troop_set_slot, "trp_npc20", slot_troop_personalityclash_object, "trp_npc13"), #Lykada (troop_set_slot, "trp_npc20", slot_troop_personalityclash2_object, "trp_npc14"), #Fuldimir (assign, "$savegame_version", 16), (try_end), (try_begin), #InVain - April 2020, fix Goblin names for old savegames, clear remnants of former troop's inventory, add some stub items (le, "$savegame_version", 16), (troop_set_name, "trp_mountain_goblin", "@Mountain Goblin"), (troop_remove_item, "trp_mountain_goblin", "itm_white_tunic_a"), (troop_remove_item, "trp_mountain_goblin", "itm_leather_boots"), (troop_add_item, "trp_mountain_goblin", "itm_orc_simple_spear"), (troop_add_item, "trp_mountain_goblin", "itm_orc_tribal_a"), (troop_set_name, "trp_tribal_orc", "@Tribal Orc"), (troop_remove_item, "trp_tribal_orc", "itm_white_tunic_a"), (troop_remove_item, "trp_tribal_orc", "itm_leather_boots"), (troop_add_item, "trp_mountain_goblin", "itm_orc_tribal_a"), (troop_add_item, "trp_tribal_orc", "itm_wood_club"), (troop_set_name, "trp_tribal_orc_warrior", "@Tribal Orc Warrior"), (troop_add_item, "trp_mountain_goblin", "itm_orc_tribal_c"), (troop_add_item, "trp_mountain_goblin", "itm_orc_simple_spear"), (troop_set_name, "trp_tribal_orc_chief", "@Tribal Orc Chief"), (troop_add_item, "trp_mountain_goblin", "itm_orc_tribal_c"), (troop_add_item, "trp_mountain_goblin", "itm_orc_sabre"), ] + (is_a_wb_script==1 and [ (troop_set_plural_name, "trp_mountain_goblin", "@Mountain Goblins"), (troop_set_plural_name, "trp_tribal_orc", "@Tribal Orcs"), (troop_set_plural_name, "trp_tribal_orc_warrior", "@Tribal Orc Warriors"), (troop_set_plural_name, "trp_tribal_orc_chief", "@Tribal Orc Chiefs"), ] or [ ]) + [ (assign, "$savegame_version", 17), (try_end), (try_begin), #InVain - February 2021, remove advance camp guildmasters (avoid troop mixups), cancel any quests (le, "$savegame_version", 17), (try_for_range, ":advance_camps", "p_advcamp_gondor", "p_centers_end"), (party_set_slot, ":advance_camps", slot_town_elder, "trp_no_troop"), (try_end), (try_for_range, ":quest", mayor_quests_begin, mayor_quests_end_2), (quest_get_slot, ":giver", ":quest", slot_quest_giver_troop), (is_between, ":giver", "trp_elder_wosgiliath", "trp_village_1_elder"), (cancel_quest, ":quest"), (display_message, "@A quest was cancelled for update compatibility. No need to worry."), (try_end), (assign, "$savegame_version", 18), (try_end), (try_begin), #InVain - March 2021, update berserker armours (le, "$savegame_version", 18), (call_script, "script_set_slot_light_armor"), (assign, "$savegame_version", 19), (try_end), (try_begin), #InVain - March 2021, new hp shields (le, "$savegame_version", 18), (troop_set_slot, "trp_i5_beorning_carrock_berserker", slot_troop_hp_shield, 30), (troop_set_slot, "trp_i6_isen_uruk_berserker", slot_troop_hp_shield, 30), (troop_set_slot, "trp_i4_gunda_orc_berserker", slot_troop_hp_shield, 20), (troop_set_slot, "trp_i5_khand_pit_master", slot_troop_hp_shield, 30), (troop_set_slot, "trp_npc9", slot_troop_hp_shield, 30), (troop_set_slot, "trp_npc5", slot_troop_hp_shield, 50), (assign, "$savegame_version", 19), (try_end), (try_begin), #InVain - April 2021, fix Gunda nw outpost scene (le, "$savegame_version", 19), (party_set_slot, p_town_gundabad_nw_outpost, slot_town_center, scn_gundabad_nw_outpost_center), (try_end), (try_begin), #InVain - 31 July 2021 - implement campaign difficulty (le, "$savegame_version", 19), ] + (is_a_wb_script==1 and [ (options_get_campaign_ai, reg1), (neq, reg1, 1), (options_set_campaign_ai, 1), (display_message, "@Campaign difficulty set to default due to new features. Re-adjust in Game Options.") ] or []) + [ (assign, "$savegame_version", 20), (try_end), (try_begin), #InVain - 29 Sept 2021 - update merchant stats to meet armour strength requirements, add fallback armours (le, "$savegame_version", 20), (try_for_range, ":merchant_troop", weapon_merchants_begin, trp_merchants_end), (troop_raise_attribute, ":merchant_troop", ca_strength, -30), (troop_raise_attribute, ":merchant_troop", ca_strength, 21), (troop_get_inventory_slot, ":armour", ":merchant_troop", ek_body), (le, ":armour", 1), (store_troop_faction, ":faction", ":merchant_troop"), (troop_get_type, ":race", ":merchant_troop"), (assign, ":replacement_armour", "itm_black_tunic"), (try_begin), (eq, ":faction", fac_dwarf), (assign, ":replacement_armour", "itm_dwarf_vest"), (else_try), (eq, ":faction", fac_rhun), (assign, ":replacement_armour", "itm_rhun_armor_j"), (else_try), (eq, ":faction", fac_khand), (assign, ":replacement_armour", "itm_khand_light_lam"), (else_try), (eq, ":race", tf_orc), (assign, ":replacement_armour", "itm_moria_armor_a"), (else_try), (eq, ":race", tf_urukhai), (assign, ":replacement_armour", "itm_isen_uruk_light_a"), (else_try), (eq, ":race", tf_uruk), (assign, ":replacement_armour", "itm_m_uruk_light_a"), (try_end), (troop_set_inventory_slot, ":merchant_troop", ek_body, ":replacement_armour"), (try_end), (assign, "$savegame_version", 21), (try_end), (try_begin), #InVain - 16 Oct 2021, add missing (le, "$savegame_version", 21), (troop_set_slot, "trp_elder_uhcamp", slot_troop_gm_companion_1, "str_isengard_hunting_camp_guildmaster_companion"), (troop_set_slot, "trp_elder_uhcamp", slot_troop_gm_companion_player_found, "str_isengard_hunting_camp_guildmaster_player_found_ok"), (party_set_slot, "p_town_urukhai_h_camp", slot_party_has_companion, 1), (assign, "$savegame_version", 22), (try_end), (try_begin), #InVain - 21 Oct 2021, fix strength for healers to meet armour requirements (le, "$savegame_version", 22), (try_for_range, ":healer", trp_morannon_healer, trp_hungry_uruk), (troop_raise_attribute, ":healer", ca_strength, -30), (troop_raise_attribute, ":healer", ca_strength, 30), (try_end), (assign, "$savegame_version", 23), (try_end), (try_begin), #InVain - 29 Oct 2021, fix SE advance camp positions (le, "$savegame_version", 23), (set_fixed_point_multiplier, 100), (try_for_range, ":campplace", "p_camplace_S1", "p_camplace_S4"), (party_get_position, pos1, ":campplace"), (position_get_y, ":y", pos1), (val_add, ":y", 500), (position_set_y, pos1, ":y"), (party_set_position, ":campplace", pos1), (try_end), (try_for_range, ":adv_camp", "p_advcamp_gondor", "p_centers_end"), (party_is_active, ":adv_camp"), (party_get_position, pos1, ":adv_camp"), (position_get_x, ":x", pos1), (position_get_y, ":y", pos1), (ge, ":y", 10), (le, ":x", -20), (val_add, ":y", 500), (position_set_y, pos1, ":y"), (party_set_position, ":adv_camp", pos1), (try_end), (assign, "$savegame_version", 24), (try_end), (try_begin), #InVain - 31 Dec 2021, fix bald elf lords and wargs in elf shops (le, "$savegame_version", 24), (try_for_range, ":lord", kingdom_heroes_begin, kingdom_heroes_end), (troop_has_item_equipped, ":lord", "itm_witchking_helmet"), (troop_remove_item, ":lord", "itm_witchking_helmet"), (troop_add_item, ":lord", "itm_tiara_reward"), (try_end), (troop_add_item, "trp_lorien_items", "itm_saddle_horse"), (troop_add_item, "trp_imladris_items", "itm_saddle_horse"), (call_script, "script_set_item_faction"), (assign, "$savegame_version", 25), (try_end), (try_begin), #InVain - 31 Jan 2022, set campaign difficulty as global variable (le, "$savegame_version", 25), (assign, "$tld_campaign_diffulty", 1), (display_message, "@Savegame compatibility: Campaign Difficulty set to default. Adjust in TLD options."), (assign, "$savegame_version", 26), (try_end), (try_begin), #InVain - 4 May 2022, set subfac mask for Gondor heavy greaves (le, "$savegame_version", 26), (item_set_slot,"itm_gondor_heavy_greaves", slot_item_subfaction, 40), (assign, "$savegame_version", 27), (try_end), (try_begin), #InVain - 20 August 2022, disable troop identifiers (le, "$savegame_version", 27), (assign, "$g_display_agent_labels",0), (assign, "$show_hide_labels", 0), (assign, "$savegame_version", 28), (try_end), (try_begin), #InVain - 26 Sept 2022, fix trainer troops wearing no armour (le, "$savegame_version", 28), (try_for_range, ":trainer_troop", training_ground_trainers_begin, training_ground_trainers_end), (troop_raise_attribute, ":trainer_troop", ca_strength, 30), (try_end), (assign, "$savegame_version", 29), (try_end), (try_begin), #InVain - 9 Oct 2022, reset respawn timer for old savegames (le, "$savegame_version", 29), (try_for_range, ":lord", kingdom_heroes_begin, kingdom_heroes_end), (troop_set_slot, ":lord", slot_troop_respawn_timer, 1), (try_end), (assign, "$savegame_version", 30), (try_end), #Retainers Begin (try_begin), #Renmauzuo - 9 Oct 2022, assign retainer troops to lords (le, "$savegame_version", 30), (call_script, "script_assign_retainers"), (assign, "$savegame_version", 31), (try_end), #Retainers End (try_begin), #InVain - 9 Oct 2022, update Rohan town archer troops (le, "$savegame_version", 31), (faction_set_slot, "fac_rohan", slot_faction_archer_troop, "trp_a3_dism_skirmisher_of_rohan"), (try_for_range, ":center_no", centers_begin, centers_end), (store_faction_of_party, ":center_faction", ":center_no"), (eq, ":center_faction", "fac_rohan"), (party_set_slot, ":center_no", slot_town_archer_troop, "trp_a3_dism_skirmisher_of_rohan"), (try_end), (assign, "$savegame_version", 32), (try_end), (try_begin), #InVain - 10 Oct 2023, cancel Isengard legion quest (le, "$savegame_version", 32), (check_quest_active, "qst_guardian_party_quest"), (quest_get_slot, ":attacking_faction", "qst_guardian_party_quest", slot_quest_object_center), (try_for_range, ":lords", kingdom_heroes_begin, kingdom_heroes_end), (store_troop_faction, ":lord_fac", ":lords"), (eq, ":lord_fac", ":attacking_faction"), (troop_get_slot, ":lord_party", ":lords", slot_troop_leaded_party), (gt, ":lord_party", 0), (party_set_slot, ":lord_party", slot_party_scripted_ai, 0), (try_end), (call_script, "script_cancel_quest", "qst_guardian_party_quest"), (display_message, "@Notice: Isengard Last Stand quest cancelled for savegame compatibility reasons. Isengard can now be sieged like a regular city."), (assign, "$savegame_version", 33), (party_set_slot, "p_town_isengard", slot_center_siegability, tld_siegable_capital), (try_end), (try_begin), #InVain - 22 Oct 2023, update merchants (le, "$savegame_version", 33), (call_script, "script_set_item_faction"), (assign, "$savegame_version", 34), (try_end), (try_begin), #InVain - 14 Nov 2023, HP shield for companions + make sure equipment shows up in old savegames (le, "$savegame_version", 34), (try_for_range, ":has_hp_shield", trp_aragorn, trp_gimli+1), (troop_set_slot, ":has_hp_shield", slot_troop_hp_shield, 200), (troop_set_slot, ":has_hp_shield", slot_troop_has_combat_ai, 1), (try_end), ] + (is_a_wb_script==1 and [ (call_script, "script_clone_troop", "trp_a5_arnor_master_ranger", "trp_aragorn"), (call_script, "script_clone_troop", "trp_a5_greenwood_vigilant", "trp_legolas"), (call_script, "script_clone_troop", "trp_i6_dwarf_longbeard_axeman", "trp_gimli"), ] or []) + [ (assign, "$savegame_version", 35), (try_end), (try_begin), #InVain - assign surgery to lords, turn on lore mode (le, "$savegame_version", 35), (try_for_range, ":lord", kingdom_heroes_begin, kingdom_heroes_end), (store_troop_faction, ":faction", ":lord"), (faction_slot_eq, ":faction", slot_faction_side, faction_side_good), (troop_raise_skill, ":lord", skl_surgery, 8), (else_try), (troop_raise_skill, ":lord", skl_surgery, 4), (try_end), (assign, "$lore_mode", 1), (assign, "$savegame_version", 36), (try_end), (try_begin), #InVain - update equipment (le, "$savegame_version", 36), (try_for_range, ":trp", trp_aragorn, trp_last), (troop_raise_attribute, ":trp", ca_strength, 30), (troop_equip_items, ":trp"), (try_end), (assign, "$savegame_version", 37), # (troop_add_item, trp_pippin_notmet, itm_rohan_armor_th, imod_battered), # (troop_equip_items, trp_pippin_notmet), # (call_script, "script_clone_troop", "trp_pippin_notmet_old", "trp_pippin_notmet"), (check_quest_active, "qst_deliver_message_hobbit"), (call_script, "script_cancel_quest", "qst_deliver_message_hobbit"), (display_message, "@Hobbit quest aborted for compatibility reasons. Hobbits will now only appear after certain conditions are met."), (try_end), (try_begin), #Update Radagast for old savegames (le, "$savegame_version", 37), ] + (is_a_wb_script==1 and [ (call_script, "script_clone_troop", "trp_knight_4_12", "trp_radagast"), ] or []) + [ (troop_remove_item, "trp_radagast", itm_beorn_chief), (troop_remove_item, "trp_radagast", itm_beorn_helmet), (troop_remove_item, "trp_radagast", itm_evil_gauntlets_a), (troop_remove_item, "trp_radagast", itm_beorn_shield_reward), (troop_remove_item, "trp_radagast", itm_dwarf_throwing_axe), (troop_remove_item, "trp_radagast", itm_beorn_shield_reward), (troop_add_item, "trp_radagast", itm_woodman_scout, imod_cloak), (troop_add_item, "trp_radagast", itm_hunter, 0), (troop_add_item, "trp_radagast", itm_beorn_staff, 0), (troop_raise_skill, trp_radagast, skl_riding, 8), (troop_equip_items, "trp_radagast"), (assign, "$savegame_version", 38), (try_end), (try_begin), #InVain - update town walkers (le, "$savegame_version", 38), (try_for_range, ":center", centers_begin, centers_end), (try_for_range, ":slot", slot_center_walker_0_troop, slot_center_walker_0_dna), (party_get_slot, ":troop", ":center", ":slot"), (troop_is_mounted, ":troop"), (party_get_slot, ":new_troop", ":center", slot_town_guard_troop), #should be infantry (party_set_slot, ":center", ":slot", ":new_troop"), (try_end), (try_end), (assign, "$savegame_version", 39), (try_end), (try_begin), #InVain - update Hornburg castle scene, set healer slots (le, "$savegame_version", 39), (party_set_slot, "p_town_hornburg", slot_town_castle, -1), (party_set_slot, "p_town_morannon", slot_town_healer, "trp_morannon_healer"), (party_set_slot, "p_town_minas_tirith", slot_town_healer, "trp_minas_tirith_healer"), (party_set_slot, "p_town_edoras", slot_town_healer, "trp_edoras_healer"), (party_set_slot, "p_town_isengard", slot_town_healer, "trp_isengard_healer"), (party_set_slot, "p_town_dol_guldur", slot_town_healer, "trp_guldur_healer"), (party_set_slot, "p_town_gundabad", slot_town_healer, "trp_gundabad_healer"), (party_set_slot, "p_town_thranduils_halls", slot_town_healer, "trp_mirkwood_healer"), (assign, "$savegame_version", 40), (try_end), ]), #Kham # Returns the sum of levels of fit for battle troops used to calculate battle advantage # INPUT: # param1: Party-id # OUTPUT: reg0 = result ("tld_party_count_strength", [ (store_script_param_1, ":party"), #Party_id (party_get_num_companion_stacks, ":num_stacks", ":party"), (assign, reg0, 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, ":stack_troop", ":party", ":i_stack"), (store_character_level, ":troop_level", ":stack_troop"), (assign, ":num_fit", 0), (try_begin), (troop_is_hero, ":stack_troop"), # (store_troop_health, ":troop_hp", ":stack_troop"), (try_begin), (neg|troop_is_wounded, ":stack_troop"), # (ge, ":troop_hp", 20), (assign, ":num_fit", ":troop_level"), (try_end), (else_try), (party_stack_get_size, ":num_fit", ":party", ":i_stack"), (party_stack_get_num_wounded, ":num_wounded", ":party", ":i_stack"), (val_sub, ":num_fit", ":num_wounded"), (try_end), (val_add, reg0, ":num_fit"), (try_end), ]), #Kham: "Update Battle Map" #battle_map # script_update_battle_map # Input: none # Output: none ("update_battle_map", [ (set_fixed_point_multiplier, 1000), (get_scene_boundaries, 2, 3), (try_for_agents, ":agent_no"), (agent_is_human, ":agent_no"), (agent_get_slot, ":map_id", ":agent_no", slot_agent_map_overlay_id), (try_begin), (agent_is_alive, ":agent_no"), (call_script, "script_update_agent_position_on_map", ":agent_no"), (else_try), (overlay_set_alpha, ":map_id", 0), (try_end), (try_end), ]), #Kham - Check if there are orcs / uruks in Party #script_are_there_orcs #Input: party #Output: reg0: Number of Orcs + Uruks Stacks ("are_there_orcs", [ (store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_stacks",":party_no"), (assign, ":num_orcs", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, reg1, ":party_no",":i_stack"), (troop_get_type, ":is_orc", reg1), (try_begin), (this_or_next|is_between, ":is_orc", tf_orc_begin, tf_orc_end), (eq, ":is_orc", tf_troll), #Trolls too (val_add, ":num_orcs", 1), (try_end), (try_end), (assign, reg0, ":num_orcs"), #(display_message, "@DEBUG: {reg0} orc stacks in party"), ]), #Kham - Check if there are elves in Party #script_are_there_elves #Input: party #Output: reg0: Number of Elf Stacks ("are_there_elves", [ (store_script_param_1, ":party_no"), (party_get_num_companion_stacks, ":num_stacks",":party_no"), (assign, ":num_elf", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, reg1, ":party_no",":i_stack"), (troop_get_type, ":is_elf", reg1), (try_begin), (is_between, ":is_elf", tf_elf_begin, tf_elf_end), (val_add, ":num_elf", 1), (try_end), (try_end), (assign, reg0, ":num_elf"), #(display_message, "@DEBUG: {reg0} elf stacks in party"), ]), #Kham - Look for lowest level troop & Remove them #script_remove_highest_or_lowest_level_troop #Input: party, amount, low level or high level (0 or 1), #Output: removes number of highest/lowest level troop, s6 stores the name of the troop ("remove_highest_or_lowest_level_troop", [ (store_script_param, ":party_no",1), (store_script_param, ":amount",2), (store_script_param, ":minmax",3), (assign,":troops_to_fill", ":amount"), # pick X troops to remove, starting for the lowest level (try_for_range,":unused",0,":amount"), (gt,":amount", 0), (assign,":minlevel", 100), (assign,":maxlevel", 1), (assign,":mintroop", "trp_no_troop"), (party_get_num_companion_stacks, ":stacks", ":party_no"), (try_for_range, ":stack", 0, ":stacks"), (party_stack_get_troop_id,":troop",":party_no",":stack"), (neg|troop_is_hero,":troop"), (troop_get_type, ":type", ":troop"), (assign, ":continue", 0), # Here, we check if the player is Evil, which means that the cannibalism can trigger.... (try_begin), (neg|faction_slot_eq, "$players_kingdom", slot_faction_side,faction_side_good), (assign, ":continue",1), (try_end), #So we only let Evil Players or Elven troops continue, cause only Evil Players would have cannibalism trigger, and only elves leave (this_or_next| eq, ":continue", 1), (is_between, ":type", tf_elf_begin, tf_elf_end), (store_character_level,":level",":troop"), (try_begin), (eq, ":minmax", 0), #Low Levels (lt,":level",":minlevel"), (assign,":minlevel",":level"), #remember new minimal level troop (assign,":mintroop",":troop"), (else_try), (eq, ":minmax", 1), #High Levels (gt, ":level", ":maxlevel"), (assign, ":maxlevel", ":level"), #remember new maximum level troop (assign, ":mintroop", ":troop"), (try_end), (try_end), (try_begin), # extracting troops (neq,":mintroop","trp_no_troop"), # if suitable troops exist (party_count_companions_of_type, ":n", ":party_no", ":mintroop"), (try_begin), (ge, ":n", ":troops_to_fill"), # enough troops here, end iterations (val_sub, ":amount", 1), (assign,":unused",":amount"), (assign,":n",":troops_to_fill"), (try_end), (party_remove_members, ":party_no", ":mintroop", ":n"), (val_sub,":troops_to_fill",":n"), (else_try), (display_message,"@Something wrong, not enough troops to remove"), (try_end), (str_store_troop_name, s6, ":mintroop"), #Debug (try_begin), (eq, "$cheat_mode", 1), (str_store_troop_name, s1, ":mintroop"), (try_begin), (eq, ":minmax",0), (assign, reg1, ":minlevel"), (else_try), (assign, reg1, ":maxlevel"), (try_end), (display_message, "@Troop: {s6} - Level: {reg1}"), (try_end), (try_end), ]), #script_cf_check_if_only_capital_left - Kham #Input: center (this is called during player initiated sieges) #When it fails, that means there are still other center for the input center's faction. ("cf_check_if_only_capital_left", [ (store_script_param_1, ":center"), #Get the faction of the encountered party(center) (store_faction_of_party, ":faction_encountered", ":center"), (assign, ":centers_left", 0), #Check all centers (try_for_range, ":cur_party", centers_begin, centers_end), #Store the Faction & the sad_elf_ of the center being checked (store_faction_of_party, ":fac", ":cur_party"), #(faction_get_slot, ":capital", ":fac", slot_faction_capital), #Store the original faction of the center (to see later if it changed hands) (party_get_slot, ":orig_faction", ":cur_party", slot_center_original_faction), #Check that the current center being checked has the same faction as the encountered party(center) (eq, ":faction_encountered", ":fac"), #(neq, ":center", ":capital"), (neg|is_between, ":cur_party", advcamps_begin, advcamps_end), #don't count advance camps (try_begin), (party_slot_ge, ":cur_party", slot_center_destroy_on_capture, 1), #Is the center destroyable? (party_slot_eq, ":cur_party", slot_center_destroyed, 0), #if it is destroyable, is it destroyed? (val_add, ":centers_left", 1), #If the center is destroyable, but not destroyed, add 1 #(str_store_party_name, s3, ":cur_party"), #(display_message, "@{s3} - not-destroyed"), (else_try), (party_slot_eq, ":cur_party", slot_center_destroy_on_capture, 0), #Is the center NOT destroyable (changes hands)? (eq, ":orig_faction", ":fac"), #If it does change hands, is it with its original faction? (val_add, ":centers_left", 1), #If so, add 1 #(str_store_party_name, s3, ":cur_party"), #(display_message, "@{s3} - not taken"), (else_try), (val_add, ":centers_left",0), # all else, don't add anything #(str_store_party_name, s3, ":cur_party"), #(display_message, "@{s3} - nothing added"), (try_end), (try_end), #try for range end #DEBUG (try_begin), (eq, "$cheat_mode",1), (assign, reg6, ":centers_left"), (str_store_faction_name, s2, ":faction_encountered"), (display_message, "@{reg6} Centers Left for {s2}", color_good_news), (try_end), (le, ":centers_left", 1), #Fail if capital is not the only one left. ]), #Kham - Check if there are troop stack of the faction specified #script_find_troop_of_faction #Input: party; faction #Output: reg0: Number of Troop Stacks of Seleted Faction ("find_troop_of_faction", [ (store_script_param_1, ":party_no"), (store_script_param_2, ":faction"), (party_get_num_companion_stacks, ":num_stacks",":party_no"), (assign, ":num_troops", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_stack_get_troop_id, reg1, ":party_no",":i_stack"), (store_troop_faction, ":troop_fac", reg1), (try_begin), (eq, ":troop_fac", ":faction"), (val_add, ":num_troops", 1), (try_end), (try_end), (assign, reg0, ":num_troops"), (str_store_faction_name, s1, ":faction"), (display_message, "@DEBUG: {reg0} troop stacks of {s1} found"), ]), #kham - Check if Player party can hide (Wildcraft Skill) #script_cf_can_hide_from_enemy ("cf_can_hide_from_enemy", [ (party_get_num_companions, ":number", "p_main_party"), (party_get_skill_level, ":skill", "p_main_party", skl_persuasion), (assign, ":continue", 0), (try_begin), (le, ":number", 8), (assign, ":continue", 1), (else_try), (ge, ":skill", 1), (val_mul, ":skill", 4), #Multiplier (val_add, ":skill", 10), #Base 10 troops (le, ":number", ":skill"), #If NUMBER less than / equal to Wildcraft Skill Bonus, then allow hide. (assign, ":continue", 1), (try_end), #Debug (assign, reg1, ":skill"), (assign, reg2, ":number"), #(display_message, "@Wildcraft Skill Hide Party Limit - {reg1}. Player Companions - {reg2}"), (eq, ":continue", 1), ]), ("hide_number_of_hours", [ (party_get_num_companions, ":number", "p_main_party"), (party_get_skill_level, ":skill", "p_main_party", skl_persuasion), #Wildcraft (try_begin), (le, ":number", 8), (rest_for_hours, 8, 3, 0), (else_try), (ge, ":skill", 1), (val_div, ":number", ":skill"), (val_min, ":number", 8), (assign, reg1, ":skill"), (assign, reg2, ":number"), (assign, ":hours", ":number"), (try_begin), (gt, ":hours", 7), (rest_for_hours, 8,3,0), (display_message, "@DEBUG: 8 Hours to hide"), (else_try), (is_between, ":hours", 6,8), (rest_for_hours, 7, 3, 0), (display_message, "@DEBUG: 7 Hours to hide"), (else_try), (is_between, ":hours", 4,6), (rest_for_hours, 6,3,0), (display_message, "@DEBUG: 6 Hours to hide"), (else_try), (lt, ":hours", 4), (rest_for_hours, 5,3,0), (display_message, "@DEBUG: 5 Hours to hide"), (try_end), (try_end), ]), ## Kham Quest Scripts #Defend Refugee Quest #script_cf_init_quest_defend_refugees #qst_blank_quest_01 ("cf_init_quest_defend_refugees", [ (faction_get_slot, ":side", "$g_talk_troop_faction", slot_faction_side), (eq, ":side", faction_side_good), (ge, "$g_talk_troop_faction_relation", 0), (this_or_next|neq, "$g_talk_troop_faction", "fac_lorien"), #Elves don't care about the refugees ( neq, "$g_talk_troop_faction", "fac_woodelf"), #Elves don't care about the refugees (store_character_level, ":player_level", "trp_player"), (is_between, ":player_level", 14, 21), (assign, ":giver_center_no", -1), (troop_get_slot, ":giver_party_no", "$g_talk_troop", slot_troop_leaded_party), (try_begin), (gt, ":giver_party_no", 0), (party_get_attached_to, ":giver_center_no", ":giver_party_no"), (else_try), (is_between, "$g_encountered_party", centers_begin, centers_end), (assign, ":giver_center_no", "$g_encountered_party"), (try_end), (gt, ":giver_center_no", 0),#Skip if lord is outside the center (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting) (assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town (call_script, "script_cf_get_random_friendly_center_in_theater", "p_main_party",), (assign, ":cur_target_center", reg0), (store_faction_of_party, ":center_faction", ":cur_target_center"), (try_begin), (this_or_next|eq, ":center_faction", "fac_lorien"), (this_or_next|eq, ":center_faction", "fac_woodelf"), ( eq, ":center_faction", "fac_imladris"), (try_for_range, ":beorn_center", "p_town_woodsmen_village", "p_town_moria"), (party_slot_eq, ":beorn_center", slot_center_destroyed, 0), (assign, ":cur_target_center", ":beorn_center"), (try_end), (try_end), (call_script, "script_get_tld_distance", "p_main_party", ":cur_target_center"), (ge, reg0, 10), (neq, ":cur_target_center", ":giver_center_no"),#Skip current center (neq,":cur_target_center", "p_town_henneth_annun"),#Skip Henneth Annun (party_slot_eq, ":cur_target_center", slot_center_destroyed, 0), #Center should not be destroyed (ge, ":cur_target_center",0), #Should be valid center (assign, reg55, "pt_refugees"), #quest_target_party_template (assign, reg56, ":cur_object_center"), #quest_object_center (assign, reg57, ":cur_target_center"), #quest_target_center (assign, reg58, 8), #quest_importance (assign, reg59, 400), #quest_xp_reward (assign, reg60, 750), #quest_gold_reward (assign, reg61, 18), #quest_rank_reward (assign, reg62, 15), #quest_expiration_days (assign, reg63, 10), #quest_dont_give_again_period ]), ("cf_quest_defend_refugees_party_creation", [ (quest_get_slot, ":quest_giver_center", "$random_quest_no", slot_quest_giver_center), (quest_get_slot, ":quest_target_center", "$random_quest_no", slot_quest_target_center), (quest_get_slot, ":quest_target_party_template", "$random_quest_no", slot_quest_target_party_template), #Init Quest Global Vars here (assign, "$qst_refugees_escaped", 0), (assign, "$qst_refugees_killed", 0), (assign, "$qst_raider_party_total", 0), (assign, "$qst_refugee_party_1_escaped", 0), (assign, "$qst_refugee_party_2_escaped", 0), (assign, "$qst_refugee_party_3_escaped", 0), (assign, "$qst_raider_party_defeated", 0), (call_script, "script_find_theater", "p_main_party"), (assign, ":theater", reg0), (assign, ":raiders", "pt_mordor_scouts"), (assign, ":raiders2", "pt_mordor_scouts"), (assign, ":raiders3", "pt_mordor_scouts"), (assign, ":guards", "pt_gondor_scouts"), (try_begin), (eq, ":theater", theater_SE), (assign, ":raiders", "pt_mordor_scouts"), (assign, ":raiders2", "pt_khand_scouts"), (assign, ":raiders3", "pt_harad_scouts"), (assign, ":guards", "pt_gondor_scouts"), (else_try), (eq, ":theater", theater_SW), (assign, ":raiders", "pt_isengard_scouts_warg"), (assign, ":raiders2", "pt_dunland_scouts"), (assign, ":raiders3", "pt_isengard_scouts"), (assign, ":guards", "pt_rohan_scouts"), (else_try), (eq, ":theater", theater_C), (assign, ":raiders", "pt_gundabad_scouts"), (assign, ":raiders2", "pt_moria_scouts"), (assign, ":raiders3", "pt_guldur_scouts"), (assign, ":guards", "pt_beorn_scouts"), (else_try), (assign, ":raiders", "pt_rhun_scouts"), (assign, ":raiders2", "pt_gundabad_scouts"), (assign, ":raiders3", "pt_rhun_scouts"), (assign, ":guards", "pt_dale_scouts"), (try_end), (try_begin), (store_faction_of_party, ":target_fac", ":quest_target_center"), (eq, ":target_fac", "fac_beorn"), (assign, ":guards", "pt_beorn_scouts"), (try_end), (store_random_in_range, ":refugee_radius", 1, 5), (set_spawn_radius, ":refugee_radius"), #Refugee Party 1 (spawn_around_party,":quest_giver_center",":quest_target_party_template"), (assign, "$qst_refugee_party_1", reg0), (party_add_template, "$qst_refugee_party_1", ":guards"), (party_set_ai_behavior,"$qst_refugee_party_1",ai_bhvr_travel_to_party), (party_set_ai_object,"$qst_refugee_party_1",":quest_target_center"), (party_set_flags, "$qst_refugee_party_1", pf_default_behavior, 0), (party_set_flags, "$qst_refugee_party_1", pf_quest_party, 1), (party_set_flags, "$qst_refugee_party_1", pf_always_visible, 1), #Refugee Party 2 (spawn_around_party,":quest_giver_center",":quest_target_party_template"), (assign, "$qst_refugee_party_2", reg0), (party_add_template, "$qst_refugee_party_2", ":guards"), (party_set_ai_behavior,"$qst_refugee_party_2",ai_bhvr_travel_to_party), (party_set_ai_object,"$qst_refugee_party_2",":quest_target_center"), (party_set_flags, "$qst_refugee_party_2", pf_default_behavior, 0), (party_set_flags, "$qst_refugee_party_2", pf_quest_party, 1), (party_set_flags, "$qst_refugee_party_2", pf_always_visible, 1), #Refugee Party 3 (spawn_around_party,":quest_giver_center",":quest_target_party_template"), (assign, "$qst_refugee_party_3", reg0), (party_add_template, "$qst_refugee_party_3", ":guards"), (party_set_ai_behavior,"$qst_refugee_party_3",ai_bhvr_travel_to_party), (party_set_ai_object,"$qst_refugee_party_3",":quest_target_center"), (party_set_flags, "$qst_refugee_party_3", pf_default_behavior, 0), (party_set_flags, "$qst_refugee_party_3", pf_quest_party, 1), (party_set_flags, "$qst_refugee_party_3", pf_always_visible, 1), (store_random_in_range, ":raider_radius", 1, 4), (set_spawn_radius, ":raider_radius"), (store_character_level, ":level", "trp_player"), #Raider Party (spawn_around_party, ":quest_target_center", ":raiders"), (assign, "$qst_raider_party_1", reg0), (party_add_template, "$qst_raider_party_1", ":raiders"), #(party_add_template, "$qst_raider_party_1", ":raiders"), (try_begin), (is_between, ":level", 14,17), (party_add_template, "$qst_raider_party_1", ":raiders"), (else_try), (ge, ":level", 17), (party_add_template, "$qst_raider_party_1", ":raiders"), (party_add_template, "$qst_raider_party_1", ":raiders"), (try_end), (party_set_name, "$qst_raider_party_1", "@Raiders"), (party_set_ai_behavior,"$qst_raider_party_1",ai_bhvr_attack_party), (party_set_ai_object,"$qst_raider_party_1","$qst_refugee_party_1"), (party_set_flags, "$qst_raider_party_1", pf_quest_party, 1), (party_set_faction, "$qst_raider_party_1", "fac_manhunters"), (party_set_ai_initiative, "$qst_raider_party_1", 10), #Raider Party 2 (spawn_around_party, ":quest_target_center", ":raiders2"), (assign, "$qst_raider_party_2", reg0), (party_add_template, "$qst_raider_party_2", ":raiders2"), #(party_add_template, "$qst_raider_party_2", ":raiders2"), (try_begin), (is_between, ":level", 14,17), (party_add_template, "$qst_raider_party_2", ":raiders2"), (else_try), (ge, ":level", 17), (party_add_template, "$qst_raider_party_2", ":raiders2"), (party_add_template, "$qst_raider_party_2", ":raiders2"), (try_end), (party_set_name, "$qst_raider_party_2", "@Raiders"), (party_set_ai_behavior,"$qst_raider_party_2",ai_bhvr_attack_party), (party_set_ai_object,"$qst_raider_party_2","$qst_refugee_party_2"), (party_set_flags, "$qst_raider_party_2", pf_quest_party, 1), (party_set_faction, "$qst_raider_party_2", "fac_manhunters"), (party_set_ai_initiative, "$qst_raider_party_2", 10), #Raider Party 3 (spawn_around_party,":quest_target_center",":raiders3"), (assign, "$qst_raider_party_3", reg0), (party_add_template, "$qst_raider_party_3", ":raiders3"), #(party_add_template, "$qst_raider_party_3", ":raiders3"), (try_begin), (is_between, ":level", 14,17), (party_add_template, "$qst_raider_party_3", ":raiders3"), (else_try), (ge, ":level", 17), (party_add_template, "$qst_raider_party_3", ":raiders3"), (party_add_template, "$qst_raider_party_3", ":raiders3"), (try_end), (party_set_name, "$qst_raider_party_3", "@Raiders"), (party_set_ai_behavior,"$qst_raider_party_3",ai_bhvr_attack_party), (party_set_ai_object,"$qst_raider_party_3","$qst_refugee_party_3"), (party_set_flags, "$qst_raider_party_3", pf_quest_party, 1), (party_set_faction, "$qst_raider_party_3", "fac_manhunters"), (party_set_ai_initiative, "$qst_raider_party_3", 10), (set_relation, "fac_innocents", "fac_manhunters", -100), (rest_for_hours, 1, 3), ]), # Hunt Down Refugee Quest #script_cf_init_quest_hunt_refugees #qst_blank_quest_02 ("cf_init_quest_hunt_refugees", [ (faction_get_slot, ":side", "$g_talk_troop_faction", slot_faction_side), (neq, ":side", faction_side_good), (ge, "$g_talk_troop_faction_relation", 0), (store_character_level, ":player_level", "trp_player"), (is_between, ":player_level", 14, 21), (assign, ":giver_center_no", -1), (troop_get_slot, ":giver_party_no", "$g_talk_troop", slot_troop_leaded_party), (try_begin), (gt, ":giver_party_no", 0), (party_get_attached_to, ":giver_center_no", ":giver_party_no"), (else_try), (is_between, "$g_encountered_party", centers_begin, centers_end), (assign, ":giver_center_no", "$g_encountered_party"), (try_end), (gt, ":giver_center_no", 0),#Skip if lord is outside the center (neq, ":giver_center_no", "p_town_morannon"), #Morannon is too far from any fiefs. (eq, "$g_defending_against_siege", 0),#Skip if the center is under siege (because of resting) (assign, ":cur_object_center", ":giver_center_no"), #TLD: just start from the same town (call_script, "script_cf_get_random_enemy_center_in_theater", "p_main_party",), (assign, ":cur_target_center", reg0), (store_faction_of_party, ":center_faction", ":cur_target_center"), (try_begin), (this_or_next|eq, ":center_faction", "fac_lorien"), (this_or_next|eq, ":center_faction", "fac_woodelf"), ( eq, ":center_faction", "fac_imladris"), (try_for_range, ":beorn_center", "p_town_woodsmen_village", "p_town_moria"), (party_slot_eq, ":beorn_center", slot_center_destroyed, 0), (assign, ":cur_target_center", ":beorn_center"), (try_end), (try_end), (call_script, "script_get_tld_distance", "p_main_party", ":cur_target_center"), #(display_log_message, "@DEBUG: Distance {reg0}", color_bad_news), (le, reg0, 20), (neq, ":cur_target_center", ":giver_center_no"),#Skip current center (neq,":cur_target_center", "p_town_henneth_annun"),#Skip Henneth Annun (party_slot_eq, ":cur_target_center", slot_center_destroyed, 0), #Center should not be destroyed (ge, ":cur_target_center",0), #Should be valid center (assign, reg55, "pt_refugees"), #quest_target_party_template (assign, reg56, ":cur_object_center"), #quest_object_center (assign, reg57, ":cur_target_center"), #quest_target_center (assign, reg58, 8), #quest_importance (assign, reg59, 300), #quest_xp_reward (assign, reg60, 600), #quest_gold_reward (assign, reg61, 9), #quest_rank_reward (assign, reg62, 10), #quest_expiration_days (assign, reg63, 10), #quest_dont_give_again_period ]), ("cf_quest_hunt_refugees_party_creation", [ (quest_get_slot, ":quest_target_center", "$random_quest_no", slot_quest_target_center), (quest_get_slot, ":quest_target_party_template", "$random_quest_no", slot_quest_target_party_template), #Init Quest Global Vars here (assign, "$qst_refugees_escaped", 0), (assign, "$qst_refugees_killed", 0), (assign, "$qst_refugee_party_1_escaped", 0), (assign, "$qst_refugee_party_2_escaped", 0), (assign, "$qst_refugee_party_3_escaped", 0), (assign, "$qst_refugee_party_1_killed", 0), (assign, "$qst_refugee_party_2_killed", 0), (assign, "$qst_refugee_party_3_killed", 0), (assign, "$qst_reinforcement_party", -1), (call_script, "script_find_theater", "p_main_party"), (assign, ":theater", reg0), (assign, ":guards", "pt_gondor_scouts"), (try_begin), (eq, ":theater", theater_SE), (assign, ":guards", "pt_gondor_scouts"), (else_try), (eq, ":theater", theater_SW), (assign, ":guards", "pt_rohan_scouts"), (else_try), (eq, ":theater", theater_C), (assign, ":guards", "pt_beorn_scouts"), (else_try), (assign, ":guards", "pt_dale_scouts"), (try_end), (try_begin), (store_faction_of_party, ":target_fac", ":quest_target_center"), (eq, ":target_fac", "fac_beorn"), (assign, ":guards", "pt_beorn_scouts"), (try_end), (store_random_in_range, ":refugee_radius", 25, 35), (set_spawn_radius, ":refugee_radius"), (store_character_level, ":level", "trp_player"), #Refugee Party 1 (spawn_around_party,":quest_target_center",":quest_target_party_template"), (assign, "$qst_refugee_party_1", reg0), (party_add_template, "$qst_refugee_party_1", ":guards"), (party_add_template, "$qst_refugee_party_1", ":guards"), (try_begin), (is_between, ":level", 14,17), (party_add_template, "$qst_refugee_party_1", ":guards"), (else_try), (ge, ":level", 17), (party_add_template, "$qst_refugee_party_1", ":guards"), (party_add_template, "$qst_refugee_party_1", ":guards"), (try_end), (party_set_ai_behavior,"$qst_refugee_party_1",ai_bhvr_travel_to_party), (party_set_ai_object,"$qst_refugee_party_1",":quest_target_center"), (party_set_flags, "$qst_refugee_party_1", pf_default_behavior, 0), (party_set_flags, "$qst_refugee_party_1", pf_quest_party, 1), (party_set_flags, "$qst_refugee_party_1", pf_always_visible, 1), #Refugee Party 2 (spawn_around_party,":quest_target_center",":quest_target_party_template"), (assign, "$qst_refugee_party_2", reg0), (party_add_template, "$qst_refugee_party_2", ":guards"), (party_add_template, "$qst_refugee_party_2", ":guards"), (try_begin), (is_between, ":level", 14,17), (party_add_template, "$qst_refugee_party_2", ":guards"), (else_try), (ge, ":level", 17), (party_add_template, "$qst_refugee_party_2", ":guards"), (party_add_template, "$qst_refugee_party_2", ":guards"), (try_end), (party_set_ai_behavior,"$qst_refugee_party_2",ai_bhvr_travel_to_party), (party_set_ai_object,"$qst_refugee_party_2",":quest_target_center"), (party_set_flags, "$qst_refugee_party_2", pf_default_behavior, 0), (party_set_flags, "$qst_refugee_party_2", pf_quest_party, 1), (party_set_flags, "$qst_refugee_party_2", pf_always_visible, 1), #Refugee Party 3 (spawn_around_party,":quest_target_center",":quest_target_party_template"), (assign, "$qst_refugee_party_3", reg0), (party_add_template, "$qst_refugee_party_3", ":guards"), (party_add_template, "$qst_refugee_party_3", ":guards"), (try_begin), (is_between, ":level", 14,17), (party_add_template, "$qst_refugee_party_3", ":guards"), (else_try), (ge, ":level", 17), (party_add_template, "$qst_refugee_party_3", ":guards"), (party_add_template, "$qst_refugee_party_3", ":guards"), (try_end), (party_set_ai_behavior,"$qst_refugee_party_3",ai_bhvr_travel_to_party), (party_set_ai_object,"$qst_refugee_party_3",":quest_target_center"), (party_set_flags, "$qst_refugee_party_3", pf_default_behavior, 0), (party_set_flags, "$qst_refugee_party_3", pf_quest_party, 1), (party_set_flags, "$qst_refugee_party_3", pf_always_visible, 1), ]), #script_cf_init_quest_reinforce_center #qst_blank_quest_16 ("cf_init_quest_reinforce_center", [ (eq, "$g_talk_troop_faction", "$players_kingdom"), (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", 12), (store_random_in_range, ":to_donate", 45, 76), (assign, ":result", -1), (assign, ":end", 100), (try_for_range, ":unused", 0, ":end"), (store_random_in_range, ":centers", centers_begin, centers_end), (eq, ":result", -1), (party_is_active, ":centers"), (store_faction_of_party, ":fac", ":centers"), #(eq, ":fac", "$g_talk_troop_faction"), #Uncomment this if you want to limit to your own faction only. (call_script, "script_get_faction_rank", "$g_talk_troop_faction"), (assign, ":rank", reg0), #rank points to rank number 0-9 (lt, ":rank", 1), #Must be at least known to the faction (str_store_party_name, s10, ":centers"), #(display_message, "@DEBUG: Center - {s10}", color_item_text_bonus), (party_get_num_companions, ":garrison", ":centers"), (try_begin), #Orc Factions (this_or_next|eq, ":fac", "fac_mordor"), (this_or_next|eq, ":fac", "fac_isengard"), (this_or_next|eq, ":fac", "fac_moria"), (this_or_next|eq, ":fac", "fac_guldur"), ( eq, ":fac", "fac_gundabad"), (le, ":garrison", 300), (store_random_in_range, ":to_donate", 85, 111), (assign, ":result", ":centers"), (assign, ":end", 0), #(display_log_message, "@DEBUG: Orc Center Found"), (else_try), #Dwarves / Elves (this_or_next|is_between, ":centers", "p_town_caras_galadhon", "p_town_woodsmen_village"), (this_or_next|is_between, ":centers", "p_town_erebor", "p_advcamp_gondor"), (eq, ":centers", "p_town_imladris_camp"), (le, ":garrison", 120), (store_random_in_range, ":to_donate", 40, 56), (assign, ":result", ":centers"), (assign, ":end", 0), #(display_log_message, "@DEBUG: Elf Center Found"), (else_try), (le, ":garrison", 200), (assign, ":result", ":centers"), (assign, ":end", 0), #(display_log_message, "@DEBUG: Other Center Found"), (try_end), (try_end), (neq, ":result", -1), (assign, ":quest_target_center", ":result"), (party_slot_eq, ":quest_target_center", slot_center_destroyed, 0), #Center shouldn't be destroyed (ge, ":quest_target_center",0), #Should be valid center (assign, reg55, "$g_encountered_party"),#quest_object_center (assign, reg56, ":to_donate"), #quest_target_amount (assign, reg57, ":quest_target_center"),#quest_target_center (assign, reg58, 5), #quest_importance (assign, reg59, 200), #quest_xp_reward (assign, reg60, 300), #quest_gold_reward (assign, reg61, 16), #quest_rank_reward (assign, reg62, 7), #quest_expiration_days (assign, reg63, 8), #quest_dont_give_again_period #Debug #(assign, reg2, ":garrison"), #(display_log_message, "@Target: {reg57} -- Garrison: {reg2}", color_good_news), ]), #script_cf_init_quest_sea_battle #qst_blank_quest_03 ("cf_init_quest_sea_battle", [ (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", 15), #(ge, "$g_talk_troop_faction_relation", 0), (try_begin), (faction_get_slot, ":side", "$g_talk_troop_faction", slot_faction_side), (neq, ":side", faction_side_good), (assign, ":quest_side", 1), #1 is Evil #(display_message, "@DEBUG: Side Evil"), (else_try), (assign, ":quest_side", 0), #0 is Good #(display_message, "@DEBUG: Side Good"), (try_end), (assign, ":continue", 0), (try_begin), (eq, ":quest_side", 0), (this_or_next|eq, "$g_talk_troop", "trp_knight_1_3"), #Imrahil (this_or_next|eq, "$g_talk_troop", "trp_gondor_lord"), #Denethor (this_or_next|eq, "$g_talk_troop", "trp_knight_1_4"), #Orthalion (Pelargir Lord) (this_or_next|eq, "$g_talk_troop", "trp_dale_lord"), #Brand (is_between, "$g_talk_troop", "trp_knight_5_1", "trp_knight_5_6"), # Other Dale Lords (assign, ":continue", 1), (else_try), (this_or_next|eq, "$g_talk_troop", "trp_umbar_lord"), #Tulmir (this_or_next|eq, "$g_talk_troop", "trp_rhun_lord"), #Jarl_Helcaroth (this_or_next|is_between, "$g_talk_troop", "trp_knight_3_1", "trp_knight_3_6"), #Umbar Lords (is_between, "$g_talk_troop", "trp_knight_2_11", "trp_knight_2_16"), #Rhun Lords (assign, ":continue", 1), (try_end), (eq, ":continue", 1), (assign, ":continue_2", 0), #need a second check for the faction strength checks (assign, ":cur_target_center", "p_town_edhellond"), #Default to Edhellond (store_random_in_range, ":rand", 0,100), (try_begin), (this_or_next|eq, "$g_talk_troop_faction", "fac_gondor"), (eq, "$g_talk_troop_faction", "fac_umbar"), (faction_get_slot,":strength","fac_gondor",slot_faction_strength), #hacky way to ensure that enemy faction is still alive. (gt, ":strength", 500), (faction_get_slot,":strength","fac_umbar",slot_faction_strength), (gt, ":strength", 500), (assign, ":continue_2", 1), (try_begin), (ge, ":rand", 50), (assign, ":cur_target_center", "p_town_dol_amroth"), (try_end), (else_try), (this_or_next|eq, "$g_talk_troop_faction", "fac_dale"), (eq, "$g_talk_troop_faction", "fac_rhun"), (faction_get_slot,":strength","fac_dale",slot_faction_strength), #hacky way to ensure that enemy faction is still alive. (gt, ":strength", 500), (faction_get_slot,":strength","fac_rhun",slot_faction_strength), (gt, ":strength", 500), (assign, ":continue_2", 1), (assign, ":cur_target_center", "p_town_esgaroth"), (try_end), (eq, ":continue_2", 1), (try_begin), (eq, "$g_talk_troop_faction", "fac_umbar"), (assign, ":cur_object_center", "p_town_umbar_camp"), #If Umbar, Talk to Umbar Guild Master (else_try), (eq, "$g_talk_troop_faction", "fac_rhun"), (assign, ":cur_object_center", "p_town_rhun_main_camp"), #If Rhun, Talk to Rhun Main Camp GM. (else_try), (this_or_next|eq, "$g_talk_troop_faction", "fac_gondor"), ( eq, "$g_talk_troop_faction", "fac_dale"), (assign, ":cur_object_center", ":cur_target_center"), #if Good, Target is Object (try_end), (party_slot_eq, ":cur_target_center", slot_center_destroyed, 0), #Cant be destroyed / captured. (ge, ":cur_target_center",0), #Should be valid center (ge, ":cur_object_center",0), #Should be valid center (assign, reg55, "$g_talk_troop"), #quest_object_troop (assign, reg56, ":cur_object_center"), #quest_object_center (assign, reg57, ":cur_target_center"), #quest_target_center (assign, reg58, 10), #quest_importance (assign, reg59, 500), #quest_xp_reward (assign, reg60, 800), #quest_gold_reward (assign, reg61, 32), #quest_rank_reward (assign, reg62, 5), #quest_expiration_days (assign, reg63, 15), #quest_dont_give_again_period ]), #script_quest_sea_battle_consequences #arg1: 0: Mission failed Not 0: Mission succeeded #Dirties s10,s14,s11,s13 ("quest_sea_battle_consequences", [ (store_script_param_1, ":success"), #Faction Strength Changes - Balance Document can be found on Google Drive: https://goo.gl/CErgSN (str_clear, s10), (str_clear, s14), (str_clear, s11), (str_clear, s13), (try_begin), (eq,":success",0), (str_store_string, s10, "@have won the sea battle, demoralizing your troops. The enemy may take advantage of this defeat and attack more frequently."), (str_store_string, s14, "@loses Faction Strength due to the destructive raid."), (assign,":news_color",color_bad_news), (else_try), (str_store_string, s10, "@loses Faction Strength due to the your success at the sea."), (str_store_string, s14, "@gains Faction Strength as news of your victory spreads."), (assign,":news_color",color_good_news), (try_end), (quest_get_slot, ":quest_giver_troop", "qst_blank_quest_03", slot_quest_object_troop), (store_troop_faction, ":quest_giver_faction", ":quest_giver_troop"), (try_begin), (eq, ":quest_giver_faction", "fac_gondor"), (assign, ":enemy_faction", "fac_umbar"), (else_try), (eq, ":quest_giver_faction", "fac_rhun"), (assign, ":enemy_faction", "fac_dale"), (else_try), (eq, ":quest_giver_faction", "fac_umbar"), (assign, ":enemy_faction", "fac_gondor"), (else_try), (assign, ":enemy_faction", "fac_rhun"), (try_end), (str_store_faction_name, s11, ":enemy_faction"), (str_store_faction_name, s13, ":quest_giver_faction"), (display_message,"@{s11} {s10}",":news_color"), (display_message,"@{s13} {s14}",":news_color"), (faction_get_slot,":enemy_strength",":enemy_faction",slot_faction_strength_tmp), (faction_get_slot,":giver_strength",":quest_giver_faction",slot_faction_strength_tmp), (store_character_level, ":level", "trp_player"), (val_max,":level",15), # ":level" should not be less than 15 (val_min,":level",99), (try_begin), (try_begin), # Failure: Enemy Win Min: 125; Max: 150 - Hero Loss Min: 275; Max: 300 (eq,":success",0), (val_mul, ":level", 7), (val_add, ":level", 80), (val_add, ":enemy_strength", ":level"), (val_add, ":level", 80), (val_sub, ":giver_strength", ":level"), (else_try), #Success: Enemy Loss Min: 93; Max: 108 - Hero Win Min: 148; Max: 163 (val_mul, ":level",10), (val_add, ":level", 60), (val_sub, ":enemy_strength", ":level"), (val_add, ":level", 55), (val_add, ":giver_strength", ":level"), (try_end), (try_end), (faction_set_slot,":quest_giver_faction",slot_faction_strength_tmp,":giver_strength"), (faction_set_slot,":enemy_faction",slot_faction_strength_tmp,":enemy_strength"), ]), # script_cf_init_kill_quest # qst_blank_quest_04 ("cf_init_kill_quest_target", [ (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", 20), (call_script, "script_cf_get_random_enemy_center_in_theater", "p_main_party",), (assign, ":target_center", reg0), (store_faction_of_party, ":target_faction", ":target_center"), (faction_get_slot, ":tier_3_troop", ":target_faction", slot_faction_tier_3_troop), (faction_get_slot, ":tier_4_troop", ":target_faction", slot_faction_tier_4_troop), (assign, ":type", 0), (try_begin), (store_random_in_range, ":random_troop", 0, 10), (try_begin), (le, ":random_troop", 5), (assign, ":target", ":tier_3_troop"), (store_random_in_range, ":amount", 15, 26), (store_mul, ":xp_reward", ":amount", 25), #375 - 650 (assign, ":type", 1), (else_try), (assign, ":target", ":tier_4_troop"), (store_random_in_range, ":amount", 16, 21), #640-840 (store_mul, ":xp_reward", ":amount", 40), (assign, ":type", 2), (try_end), (try_begin), (ge, ":player_level", 27), (store_div, ":add", ":player_level", 2), (val_add, ":amount", ":add"), (try_end), (try_end), (store_add, ":gold_reward", ":xp_reward", 75), #450-715 (try_begin), (store_div, ":rank_reward", ":xp_reward", 20), #18-42 (val_min, ":rank_reward", 30), #18-30 (try_end), (assign, reg54, ":target_faction"), #quest_target_faction (assign, reg55, "$g_talk_troop"), #quest_object_troop (assign, reg56, ":target"), #quest_target_troop (assign, reg57, ":amount"), #quest_target_amount (assign, reg58, 10), #quest_importance (assign, reg59, ":xp_reward"), #quest_xp_reward #375-840 (assign, reg60, ":gold_reward"), #quest_gold_reward #450-715 (assign, reg61, ":rank_reward"), #quest_rank_reward #18-30 (assign, reg62, 30), #quest_expiration_days (assign, reg63, 10), #quest_dont_give_again_period (assign, reg64, ":type"), #quest_target_party_template - analog for troop type ]), # script_cf_init_kill_quest_faction #qst_blank_quest_05 ("cf_init_kill_quest_faction", [ (neg|faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), # Evil Only (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", "$tld_player_level_to_begin_war"), (call_script, "script_cf_get_random_enemy_center_in_theater", "p_main_party",), (assign, ":target_center", reg0), (store_faction_of_party, ":target_faction", ":target_center"), (store_mul, ":amount", ":player_level", 3), (store_mul, ":xp_reward", ":amount", 5), # lvl*15 (store_add, ":gold_reward", ":xp_reward", 75), #lvl*15+75 (try_begin), (store_div, ":rank_reward", ":xp_reward", 20), (val_min, ":rank_reward", 35), (try_end), (try_begin), (gt, ":player_level", 20), (val_add, ":xp_reward", 100), (val_add, ":gold_reward", 150), (val_add, ":rank_reward", 10), (try_end), (assign, reg55, "$g_talk_troop"), #quest_object_troop (assign, reg56, ":target_faction"), #quest_target_faction (assign, reg57, ":amount"), #quest_target_amount (assign, reg58, 10), #quest_importance (assign, reg59, ":xp_reward"), #quest_xp_reward (assign, reg60, ":gold_reward"), #quest_gold_reward (assign, reg61, ":rank_reward"), #quest_rank_reward (assign, reg62, 30), #quest_expiration_days (assign, reg63, 15), #quest_dont_give_again_period ]), #script_troop_talk_presentation #Shows a hero/enemy talking during battle #Inputs: ## store to s30 the text you want to show before calling the script. ## $troop_talk_hero = troop ID for upper right portrait; ## $troop_talk_enemy for lower left portrait; ## $troop_talk_duration for how long it should last (seconds) #Output: Presentation ("troop_talk_presentation", [ (store_script_param, ":troop_id", 1), #$troop_talk_hero (store_script_param, ":duration", 2), #$troop_talk_duration (store_script_param, ":alignment", 3), # 0 or 1 (val_mul, ":duration", 100), (assign, "$troop_talk_duration", ":duration"), (try_begin), (eq, ":alignment", 0), #Hero (assign, "$troop_talk_hero", ":troop_id"), (start_presentation, "prsnt_troop_talk_hero"), (else_try), (assign, "$troop_talk_enemy", ":troop_id"), (start_presentation, "prsnt_troop_talk_enemy"), (try_end), ]), #script_get_intro_text #input: faction_id ("get_intro_text",[ (store_script_param, ":faction_id", 1), (store_add, ":intro_string", ":faction_id", "str_gondor_intro"), (val_sub, ":intro_string", 3), #First faction (Gondor) is faction_id #3 (try_begin), (this_or_next|eq, ":faction_id", "fac_beorn"), (eq, ":faction_id", "fac_dunland"), (val_sub, ":intro_string", 1), (else_try), (eq, ":faction_id", "fac_gundabad"), (assign, ":intro_string", "str_gundabad_intro"), (try_end), (str_store_string, s5, ":intro_string"), (store_add, ":intro_string_2", ":faction_id", "str_gondor_intro_2"), (val_sub, ":intro_string_2", 3), #First faction (Gondor) is faction_id #3 (str_store_string, s10, ":intro_string_2"), ]), #script_check_num_following_player # Output: reg65 continue or not ("check_num_following_player", [ (assign, ":scouts", 0), (assign, ":raider", 0), (assign, ":war_party", 0), (try_for_parties, ":followers"), (party_slot_eq, ":followers", slot_party_following_player, 1), (party_get_slot, ":type", ":followers", slot_party_type), (try_begin), (eq, ":type", spt_scout), (val_add, ":scouts", 1), (else_try), (eq, ":type", spt_raider), (val_add, ":raider", 1), (else_try), (eq, ":type", spt_patrol), (val_add, ":war_party", 1), (try_end), (try_end), (assign, ":continue", 0), (store_faction_of_party, ":faction", "$g_encountered_party"), (call_script, "script_get_faction_rank", ":faction"), (assign, ":rank", reg0), #rank points to rank number 0-9 (try_begin), (is_between, ":rank", 3, 5), (eq, ":scouts", 0), (assign, ":continue", 1), (else_try), (is_between, ":rank", 5, 7), (lt, ":scouts", 3), (eq, ":raider", 0), (assign, ":continue", 1), (else_try), (ge, ":rank", 7), (lt, ":scouts", 4), (lt, ":raider", 3), (eq, ":war_party", 0), (assign, ":continue", 1), (try_end), (assign, reg65, ":continue"), ]), #script_party_follow_player #Input: Party that will follow player ("party_follow_player", [ (store_script_param_1, ":party"), (store_current_hours, ":cur_time"), (store_add, ":obey_until_time", ":cur_time", 10*24), # commands last 10 days (party_set_slot, ":party", slot_party_following_player, 1), (party_set_slot, ":party", slot_party_follow_player_until_time, ":obey_until_time"), #no lord ai changes until this time (party_set_slot, ":party", slot_party_commander_party, "p_main_party"), (call_script, "script_party_set_ai_state", ":party", spai_accompanying_army, "p_main_party"), (party_set_ai_initiative, ":party", 10), #don't react to random enemies much (troop_set_slot, "$g_talk_troop", slot_troop_player_order_state, spai_accompanying_army), (troop_set_slot, "$g_talk_troop", slot_troop_player_order_object, "p_main_party"), (faction_get_slot, ":influence", "$g_talk_troop_faction", slot_faction_influence), (val_sub, ":influence", "$tld_action_cost"), (faction_set_slot, "$g_talk_troop_faction", slot_faction_influence, ":influence"), (assign, reg67, "$tld_action_cost"), (assign, reg66, ":influence"), (str_store_faction_name, s1, "$g_talk_troop_faction"), (display_message, "@You spent {reg67} of your influence with {s1}, with {reg66} remaining."), (party_get_slot, ":num_followers", "p_main_party", slot_party_number_following_player), #(assign, reg65, ":num_followers"), (val_add, ":num_followers", 1), #(assign, reg64, ":num_followers"), (party_set_slot, "p_main_party", slot_party_number_following_player, ":num_followers"), (party_get_slot, ":num_followers", "p_main_party", slot_party_number_following_player), #(assign, reg63, ":num_followers"), #(display_message, "@Orig - {reg65}; New - {reg64} - Set- {reg63}", color_good_news), ]), #script_calculate_formula_a #input: none #output: $g_formula_a, used in script_calculate_rank_gain_new ("calculate_formula_a", [ #Kham - Called in encounter game menus (e.g simple encounter) #Calculate A: Sum of All Enemy Party Types / 10. (assign, "$g_ally_victory_value_point", 0), (assign, ":nf_enemy_party_type_sum", 0), (try_for_parties, ":cur_party"), (party_get_battle_opponent, ":opponent", ":cur_party"), (this_or_next|eq, ":opponent", "$g_encountered_party"), (this_or_next|eq, ":opponent", "p_main_party"), (eq, ":opponent", "$g_encountered_party_2"), (neq, ":cur_party", "p_main_party"), (party_get_slot, ":party_type", ":cur_party", slot_party_type), (party_get_slot, ":party_victory_value_point", ":cur_party", slot_party_victory_value), (store_faction_of_party, ":party_faction", ":cur_party"), (store_relation, ":party_relation", ":party_faction", "$players_kingdom"), (try_begin), (gt, ":party_relation", 0), #ally (val_add, "$g_ally_victory_value_point", ":party_victory_value_point"), (else_try), (eq, ":party_type", spt_bandit), (val_add, ":nf_enemy_party_type_sum", 10), #Bandits only get 10 points (else_try), (eq, ":party_type", spt_guardian), (val_add, ":nf_enemy_party_type_sum", 300), #guard legion counts for two lords (actual victory point value is too big) (else_try), (val_add, ":nf_enemy_party_type_sum", ":party_victory_value_point"), #Add vp here for primary party encountered. (try_end), #Debug (try_begin), (troop_slot_eq, "trp_player", slot_troop_home, 22), #kham test mode (str_store_party_name, s15, ":cur_party"), (str_store_party_name, s16, ":opponent"), (display_message, "@{s15} VS {s16}", color_good_news), (try_end), (try_end), (assign, reg71, ":nf_enemy_party_type_sum"), #Debug for A (val_mul, ":nf_enemy_party_type_sum", 20), #multiply by 10, we do this to bring this value to asimilar level as B and C, then divide all by 200 #InVain Aug 2020: tripled for testing (assign, "$g_formula_a", ":nf_enemy_party_type_sum"), (assign, reg67, ":nf_enemy_party_type_sum"), #Debug for A (try_begin), (troop_slot_eq, "trp_player", slot_troop_home, 22), #kham test mode (display_message, "@Pre-div: {reg71} - A: {reg67}", color_good_news), (try_end), #END Calculate A ]), #script_calculate_rank_gain_new #Input: none #Output: rank gain ("calculate_rank_gain_new", [ #Calculate A: Sum of All Enemy Party Types / 10 - Found in encounter menus: $g_formula_a (assign, ":enemy_party_type_sum", "$g_formula_a"), (assign, reg67, ":enemy_party_type_sum"), #Debug for A #End Calculate A #Calculate B: Enemy losses , sum of all killed troops' strength values (store_sub, ":enemy_party_destroyed_strength", "$g_starting_strength_enemy_party", "$after_battle_enemy_strength"), (assign, reg68, ":enemy_party_destroyed_strength"), #Debug for B #(val_div, ":enemy_party_destroyed_strength", 200), #Removed as of Apr 22, 2018 #InVain We do this at the end of the calculation, to avoid rounding issues (val_mul, ":enemy_party_destroyed_strength", 2), #InVain Aug 2020, for testing (assign, reg69, ":enemy_party_destroyed_strength"), #Debug for B w/ divider #Calculate C: Own Losses, sum of all killed troops' strength values (store_sub, ":player_party_losses_strength", "$g_starting_strength_main_party", "$after_battle_player_strength"), (assign, reg70, ":player_party_losses_strength"), #Debug for C (val_sub, ":player_party_losses_strength", 100), (val_max, ":player_party_losses_strength", 0), (try_begin), (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), #side asymmetry: Good side players get pay more for losses (eq, ":player_side", faction_side_good), (val_mul, ":player_party_losses_strength", 2), (try_end), #(val_div, ":player_party_losses_strength", 200), #Removed as of Apr 22, 2018 #InVain We do this at the end of the calculation, to avoid rounding issues (assign, reg64, ":player_party_losses_strength"), #Debug for C w/ subtraction and division #Calculate D: Player share in the battle - Player party strength [player] in relation to allied parties' strength [allies] (try_begin), #side asymmetry: Good side players profit more from fighting with allies, regardless of how much they actually contribute (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), (eq, ":player_side", faction_side_good), (store_mul, ":player_with_multiplier", "$g_starting_strength_main_party", 150), #InVain: we later divide it by 100, so we get 120/100=20% bonus to the player's party strength (else_try), (store_mul, ":player_with_multiplier", "$g_starting_strength_main_party", 100), (try_end), #(store_add, ":player_with_allies", "$g_starting_strength_main_party", "$g_starting_strength_friends"), #InVain: $g_starting_strength_friends already contains the player party #(val_div, ":player_with_allies", 100), #InVain: We do this part later, to avoid rounding issues (store_div, ":player_share_of_battle", ":player_with_multiplier", "$g_starting_strength_friends"), (val_min, ":player_share_of_battle", 100), (assign, reg61, ":player_share_of_battle"), #Debug for D #Calculate E: Helping allies #(store_add, ":helping_allies_sum", 1, ":helping_bonus"), #we can scratch that, it's a leftover #(assign, reg63, ":helping_allies_sum"), #New E Formula: a = Sum of victory points of allied parties; b = Strength of allied parties (without the player); c = Strength of enemy parties #E = a*(c/b-1) = (ac/b) - a (store_sub, ":ally_str", "$g_starting_strength_friends", "$g_starting_strength_main_party"), #b (val_max, ":ally_str", 1), #>0, sometimes you happen to help parties that have 0 troops left (assign, ":enemy_str", "$g_starting_strength_enemy_party"), #c (store_mul, ":max_enemy_str", ":ally_str", 2), #so the helping bonus doesn't go out of hand, we only scale it up to twice outnumbered allies (val_min, ":enemy_str", ":max_enemy_str"), (try_begin), (gt, "$g_ally_victory_value_point", 0), (assign, reg77, "$g_ally_victory_value_point"), (assign, ":ally_victory_points", "$g_ally_victory_value_point"), (store_mul, ":minuend", ":ally_victory_points", ":enemy_str"), (val_div, ":minuend", ":ally_str"), (store_sub, ":helping_allies_sum", ":minuend", ":ally_victory_points"), (val_max, ":helping_allies_sum", 0), (val_div, ":helping_allies_sum", 5), #nerf a bit (val_add, ":helping_allies_sum", 2), #tweak a bit (allows to hit the 4 rank point = 1 inf threshold more often) (else_try), (assign, ":helping_allies_sum", 0), (try_end), (assign, reg63, ":helping_allies_sum"), #Sum of AB-C (store_add, ":formula_abc", ":enemy_party_type_sum", ":enemy_party_destroyed_strength"), #A+B (val_sub, ":formula_abc", ":player_party_losses_strength"), #(A+B) - C (val_div, ":formula_abc", 200), #As per Apr 22 Formula #InVain: Here we bring the values of ABC down to a reasonable level that translates into rank gain. Because they're already summed up, we avoid excessive rounding inaccuracy. (val_max, ":formula_abc", 1), (try_begin), #Debug (troop_slot_eq, "trp_player", slot_troop_home, 22), (display_message, "@Pre-Division: A:{reg71} -- B:{reg68} -- C:{reg70} -- D:{reg61} -- E:{reg63}", color_bad_news), (try_end), (try_begin), #If Fighting Alone: [A + B - C] /200 (le, "$g_ally_victory_value_point", 0), (assign, ":rank_gain", ":formula_abc"), (assign, ":debug", 1), (else_try), #If others help you: [A + B - C] /200 *D /100 (gt, "$g_ally_victory_value_point", 0), #There are allies (neq, "$nf_helping_allies", 1), #and they are helping you instead of you helping them (store_mul, ":formula_abcd", ":formula_abc", ":player_share_of_battle"), (store_div, ":rank_gain", ":formula_abcd", 100), #InVain: Divide D by 100, so it's a simple multiplier. (assign, ":debug", 2), (else_try), #If others help you: [A + B - C] /200 *D /100 + E (eq, "$nf_helping_allies", 1), (store_mul, ":formula_abcd", ":formula_abc", ":player_share_of_battle"), (val_div, ":formula_abcd", 100), #InVain: Divide D by 100, as above. (store_add, ":rank_gain", ":formula_abcd", ":helping_allies_sum"), (assign, ":debug", 3), (try_end), #Complete Formula [(A+B-C)*D] / 20000 + E (val_add, ":rank_gain", 2), #InVain: balanced so that even raiders or (big) scout parties usually give at least 4 rank = 1 influence, let's see if this is too much. (assign, reg62, ":rank_gain"), #Debug: (try_begin), (troop_slot_eq, "trp_player", slot_troop_home, 22), (try_begin), (eq, ":debug", 1), (display_message, "@Formula: [(A:{reg67} + B:{reg69} - C:{reg64})", color_bad_news), (else_try), (eq, ":debug", 2), (display_message, "@Formula: [(A:{reg67} + B:{reg69} - C:{reg64}) * D: {reg61}]/20000", color_bad_news), (else_try), (eq, ":debug", 3), (display_message, "@Formula: [(A:{reg67} + B:{reg69} - C:{reg64}) * D: {reg61}]/100 + E: {reg63}", color_bad_news), (try_end), (display_message, "@Total: {reg62}", color_good_news), (try_end), (assign, "$new_rank_formula_calculated", 1), (assign, "$nf_helping_allies", 0), ]), ### Kham Attack Party Scripts #InVain: unused, keep for now ("attack_party", [ (store_script_param_1, ":lord"), (store_script_param_2, ":party_to_attack"), (call_script, "script_attack_party_aux", ":lord", ":party_to_attack"), ]), ("attack_party_aux", [ (store_script_param_1, ":lord"), (store_script_param_2, ":party_to_attack"), (assign, ":OK", 0), (try_begin), (call_script, "script_attack_party_aux_ai", ":lord", ":party_to_attack"), (assign, ":OK", reg0), (try_end), (try_begin), (eq, "$cheat_mode", 1), (assign, reg1, ":lord"), (str_store_troop_name, s1, ":lord"), (str_store_party_name, s2, ":party_to_attack"), (try_begin), (eq, ":OK", 1), (display_message, "@lord {reg1}: {s1} is attacking {s2}", color_good_news), (else_try), (display_message, "@lord {reg1}: {s1} NOT attacking {s2}", color_bad_news), (try_end), (try_end), ]), ("attack_party_aux_AI", [ (store_script_param_1, ":lord"), (store_script_param_2, ":party_to_attack"), (assign, ":OK", 0), (try_begin), (troop_get_slot, ":party", ":lord", slot_troop_leaded_party), (party_is_active, ":party"), (party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), #(neg|party_slot_eq, ":party", slot_party_ai_state, spai_accompanying_army), #(neg|party_slot_eq, ":party", slot_party_ai_state, spai_engaging_army), #(neg|party_slot_eq, ":party", slot_party_ai_state, spai_besieging_center), #(neg|party_slot_eq, ":party", slot_party_ai_state, spai_retreating_to_center), (call_script, "script_party_set_ai_state", ":party", spai_engaging_army, ":party_to_attack"), (party_set_slot, ":party", slot_party_scripted_ai, 1), (party_set_ai_initiative, ":party", 10), (faction_get_slot, ":guardian_party_exists", "fac_isengard", slot_faction_guardian_party), # Guardian Party spawned (try_begin), (party_is_active, ":guardian_party_exists"), (call_script, "script_party_set_ai_state", ":guardian_party_exists", spai_engaging_army, ":party"), #Force GP to attack (try_end), (assign, ":OK", 1), (try_end), (assign, reg0, ":OK"), ]), ### Kham Attack Party Scripts END #script_last_faction_stand and auxillary scripts #Called from Defeat Faction trigger, when fac str less than or equal to 0, surviving lords move to their capital for a last stand. #Input: faction #Output: none, AI moves ("last_faction_stand", [ (store_script_param_1, ":faction"), (faction_get_slot, ":capital", ":faction", slot_faction_capital), (faction_set_slot, ":faction", slot_faction_ai_state, sfai_default), (try_for_range, ":lord", heroes_begin, heroes_end), (store_troop_faction, ":lord_faction", ":lord"), (eq, ":lord_faction", ":faction"), (neg|troop_slot_eq, ":lord", slot_troop_wound_mask, wound_death), (call_script, "script_last_faction_stand_aux", ":lord", ":capital"), (try_end), ]), ("last_faction_stand_aux", [ (store_script_param_1, ":lord"), (store_script_param_2, ":capital"), (assign, ":OK", 0), (try_begin), (call_script, "script_last_faction_stand_aux_AI", ":lord", ":capital"), (assign, ":OK", reg0), (try_end), (try_begin), (eq, "$cheat_mode", 1), (assign, reg1, ":lord"), (str_store_troop_name, s1, ":lord"), (str_store_party_name, s2, ":capital"), (try_begin), (eq, ":OK", 1), (display_message, "@lord {reg1}: {s1} is defending {s2}", color_good_news), (else_try), (display_message, "@lord {reg1}: {s1} NOT defending {s2}", color_bad_news), (try_end), (try_end), ]), ("last_faction_stand_aux_AI", [ (store_script_param_1, ":lord"), (store_script_param_2, ":capital"), (assign, ":OK", 0), (try_begin), (troop_get_slot, ":party", ":lord", slot_troop_leaded_party), (party_is_active, ":party"), (party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), (call_script, "script_party_set_ai_state", ":party", spai_holding_center, ":capital"), (assign, ":OK", 1), (try_end), (assign, reg0, ":OK"), ]), # Last Faction Stand Scripts End # script_set_slot_light_armor # input: none; output: runs in game start script ("set_slot_light_armor", [ (item_set_slot, "itm_isen_uruk_light_a", slot_item_light_armor, 1), (item_set_slot, "itm_isen_uruk_light_b", slot_item_light_armor, 1), (item_set_slot, "itm_isen_uruk_light_c", slot_item_light_armor, 1), (item_set_slot, "itm_m_uruk_light_a", slot_item_light_armor, 1), (item_set_slot, "itm_rhun_armor_a", slot_item_light_armor, 1), (item_set_slot, "itm_rhun_armor_b", slot_item_light_armor, 1), (item_set_slot, "itm_rhun_armor_d", slot_item_light_armor, 1), (item_set_slot, "itm_rhun_armor_j", slot_item_light_armor, 1), (item_set_slot, "itm_rhun_armor_m", slot_item_light_armor, 1), (item_set_slot, "itm_rhun_armor_n", slot_item_light_armor, 1), (item_set_slot, "itm_harad_champion", slot_item_light_armor, 1), #(item_set_slot, "itm_panther_guard", slot_item_light_armor, 1), (item_set_slot, "itm_khand_light", slot_item_light_armor, 1), (item_set_slot, "itm_gundabad_armor_a", slot_item_light_armor, 1), (item_set_slot, "itm_gundabad_armor_b", slot_item_light_armor, 1), (item_set_slot, "itm_gundabad_armor_c", slot_item_light_armor, 1), (item_set_slot, "itm_gundabad_armor_d", slot_item_light_armor, 1), (item_set_slot, "itm_gundabad_armor_e", slot_item_light_armor, 1), (item_set_slot, "itm_orc_tribal_a", slot_item_light_armor, 1), (item_set_slot, "itm_orc_tribal_b", slot_item_light_armor, 1), (item_set_slot, "itm_orc_tribal_c", slot_item_light_armor, 1), (item_set_slot, "itm_beorn_berserk", slot_item_light_armor, 1), (item_set_slot, "itm_beorn_chief", slot_item_light_armor, 1), (item_set_slot, "itm_north_leather", slot_item_light_armor, 1), (item_set_slot, "itm_dale_light_b", slot_item_light_armor, 1), (item_set_slot, "itm_lossarnach_axeman", slot_item_light_armor, 1), (item_set_slot, "itm_lossarnach_vet_axeman",slot_item_light_armor, 1), ]), # script_move_party_to_hardcoded_locations #handles scout camps, villages, burial mounds ("move_party_to_hardcoded_locations", [ (store_script_param_1, ":party"), (call_script, "script_get_region_of_party", ":party"), (assign, ":region", reg1), (party_get_current_terrain, ":terrain", ":party"), (set_fixed_point_multiplier,100.0), (party_get_position, pos1, ":party"), (position_get_x, ":x", pos1), (position_get_y, ":y", pos1), (set_fixed_point_multiplier,100.0), (try_begin), (eq, ":region", region_lebennin), (gt, ":y", 7000), (store_random_in_range, ":rand_y", 6700, 6850), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved - Lebennin!"), (else_try), (eq, ":region", region_entwash), (store_random_in_range, ":rand_x", -3500, -1000), (store_random_in_range, ":rand_y", 0, -4400), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), (else_try), (eq, ":region", region_eastfold), (this_or_next|eq, ":terrain", rt_swamp), (is_between, ":y", -1250, -1000), #catch a small spot of plain terrain in the river delta (store_random_in_range, ":rand_x", -3500, -1000), #same as above (store_random_in_range, ":rand_y", 0, -4400), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), (else_try), (this_or_next|eq, ":region", region_mordor), (eq, ":region", region_dagorlad), (store_random_in_range, ":rand_x", -7032, -6887), (store_random_in_range, ":rand_y", -4495, -3473), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), #(assign, reg55, ":rand_x"), #(assign, reg56, ":rand_y"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved - Dagorlad! - {reg55}, {reg56}"), (else_try), #west of Moria (gt, ":x", 6000), (is_between, ":y", -17000, -14000), (position_set_x, pos1, 4681), (position_set_y, pos1, -14714), (party_set_position, ":party", pos1), (else_try), (eq, ":region", region_s_mirkwood), (store_random_in_range, ":rand_x", -4354, -4016), (store_random_in_range, ":rand_y", -15094, -12166), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved! - S Mirkwood"), (else_try), (eq, ":region", region_c_mirkwood), (store_random_in_range, ":rand_x", -6600, -2500), #somewhere along the forest road (store_random_in_range, ":rand_y", -19350, -18400), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved! - S Mirkwood"), (else_try), (eq, ":region", region_n_mirkwood), (try_begin), (is_between, ":x", -2200, -2900), (is_between, ":y", -19600, -21700), (store_random_in_range, ":rand_x", -2200, -2000), (position_set_x, pos1, ":rand_x"), (else_try), (lt, ":x", -2900), (gt, ":y", -21000), (store_random_in_range, ":rand_y", -21800, -22700), (position_set_y, pos1, ":rand_y"), (lt, ":x", -6000), #make sure it isn't teleported into the lake (store_random_in_range, ":rand_x", -6000, -5000), (position_set_x, pos1, ":rand_x"), (try_end), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved! - N Mirkwood"), (else_try), #west of Isengard (gt, ":x", 6000), (is_between, ":y", -7000, -4000), (store_random_in_range, ":random_coord", 0, 4), (try_begin), (eq, ":random_coord", 0), (assign, ":rand_x", 5124), (assign, ":rand_y", -4445), (else_try), (eq, ":random_coord", 1), (assign, ":rand_x", 4348), (assign, ":rand_y", -5178), (else_try), (eq, ":random_coord", 2), (assign, ":rand_x", 4366), (assign, ":rand_y", -4535), (else_try), (assign, ":rand_x", 4876), (assign, ":rand_y", -5117), (try_end), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved! - Isengard"), (else_try), (lt, ":x", -7000), (lt, ":y", -18000), (store_random_in_range, ":rand_x", -3134, -2435), (store_random_in_range, ":rand_y", -19130, -17900), (position_set_x, pos1, ":rand_x"), (position_set_y, pos1, ":rand_y"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved! - North"), (else_try), (this_or_next|eq, ":region", region_gap_of_rohan), (this_or_next|eq, ":region", region_misty_mountains), (eq, ":region", region_anduin_banks), (gt, ":x", 5500), (store_random_in_range, ":rand_x", 3000, 100), (position_set_x, pos1, ":rand_x"), (party_set_position, ":party", pos1), #(display_message, "@Scout Camp Party moved! - Misty Mountains"), (try_end), ]), #script_guild_master_update_troop_location_notes # INPUT: troop_no ("guild_master_update_troop_location_notes", [(store_script_param, ":troop_no", 1), (store_script_param, ":see_or_hear", 2), (call_script, "script_guild_master_get_information_about_troops_position", ":troop_no", 1), (try_begin), (neq, reg0, 0), (troop_get_type, reg1, ":troop_no"), (try_begin), (gt, reg1, 1), #MV: non-humans are male (assign, reg1, 0), (try_end), (try_begin), (eq, ":see_or_hear", 0), (add_troop_note_from_sreg, ":troop_no", 2, "@The last time you saw {reg1?her:him}, {s1}", 1), (else_try), (add_troop_note_from_sreg, ":troop_no", 2, "@The last time you heard about {reg1?her:him}, {s1}", 1), (try_end), (try_end), ] + (is_a_wb_script==1 and [ #swy-- this is needed to show by default the note entries on Warband... (troop_set_note_available, ":troop_no", 1), ] or []) ), # script_guild_master_get_information_about_troops_position # Input: arg1 = troop_no, arg2 = time (0 if present tense, 1 if past tense) # Output: s1 = String, reg0 = knows-or-not ("guild_master_get_information_about_troops_position", [ (store_script_param_1, ":troop_no"), (store_script_param_2, reg3), (troop_get_type, reg4, ":troop_no"), (try_begin), (gt, reg4, 1), #MV: non-humans are male (assign, reg4, 0), (try_end), (str_store_troop_name, s2, ":troop_no"), (assign, ":found", 0), (troop_get_slot, ":center_no", ":troop_no", slot_troop_cur_center), (troop_get_slot, ":party_no", ":troop_no", slot_troop_leaded_party), (try_begin), (gt, ":center_no", 0), (is_between, ":center_no", centers_begin, centers_end), (str_store_party_name_link, s3, ":center_no"), (str_store_string, s1, "@{s2} {reg3?was:is currently} at {s3}."), (assign, ":found", 1), (else_try), (gt, ":party_no", 0), (call_script, "script_get_troop_attached_party", ":troop_no"), (assign, ":center_no", reg0), (is_between, ":center_no", centers_begin, centers_end), (str_store_party_name_link, s3, ":center_no"), (str_store_string, s1, "@{s2} {reg3?was:is currently} at {s3}."), (assign, ":found", 1), (else_try), (gt, ":party_no", 0), (party_is_active, ":party_no"), (call_script, "script_get_region_of_party", ":party_no"), (assign, ":region", reg1), (store_add, reg2, str_shortname_region_begin , ":region"), (try_begin), (ge, ":region", region_rhun), (store_sub, reg2, ":region", region_rhun), (val_add, reg2, str_shortname_region_begin_new), (try_end), (str_store_string,s5,reg2), (str_store_string, s1, "@{s2} {reg3?was:is around {s5}."), (assign, ":found", 1), (try_end), (try_begin), (eq, ":found", 0), (str_store_string, s1, "@{reg3?{s2}'s location was unknown:I don't know where {s2} is}."), (try_end), (assign, reg0, ":found"), ]), #script_encounter_agent_draw_weapon #input: none, based on $g_talk_agent #output: none, agent wields first available weapon to show aggression ("encounter_agent_draw_weapon", [ ] + (is_a_wb_script==1 and [ (store_conversation_agent, "$g_talk_agent"), (try_begin), (agent_get_item_slot, ":item_no", "$g_talk_agent", ek_item_0), (gt, ":item_no", 0), (agent_set_wielded_item, "$g_talk_agent", ":item_no"), (try_end), ] or []) + [ ]), # script_initilize_guildmaster_companion_strings ("initialize_guildmaster_companion_strings", [ (try_for_range, ":guildmasters", mayors_begin, mayors_end), (troop_set_slot, ":guildmasters", slot_troop_gm_companion_ask, -1), (troop_set_slot, ":guildmasters", slot_troop_gm_companion_none, -1), (troop_set_slot, ":guildmasters", slot_troop_gm_companion_player_none, -1), (troop_set_slot, ":guildmasters", slot_troop_gm_companion_player_found, -1), (troop_set_slot, ":guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":guildmasters", slot_troop_gm_companion_2, -1), (try_end), # Strings Begin # Gondor (try_for_range, ":gondor_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":gondor_guildmasters"), (eq, ":troop_faction", "fac_gondor"), (troop_set_slot, ":gondor_guildmasters", slot_troop_gm_companion_ask, "str_gondor_guildmaster_companion_player_ask"), (troop_set_slot, ":gondor_guildmasters", slot_troop_gm_companion_none, "str_gondor_guildmaster_companion_none"), (troop_set_slot, ":gondor_guildmasters", slot_troop_gm_companion_player_none, "str_gondor_guildmaster_companion_player_none_ok"), (troop_set_slot, ":gondor_guildmasters", slot_troop_gm_companion_player_found, "str_gondor_guildmaster_player_found_ok"), (troop_set_slot, ":gondor_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":gondor_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_mtirith", slot_troop_gm_companion_1, "str_gondor_mt_guildmaster_companion"), (troop_set_slot, "trp_elder_henneth", slot_troop_gm_companion_2, "str_gondor_ha_guildmaster_companion"), (party_set_slot, "p_town_minas_tirith", slot_party_has_companion, 1), (party_set_slot, "p_town_henneth_annun", slot_party_has_companion, 1), # Rohan (try_for_range, ":rohan_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":rohan_guildmasters"), (eq, ":troop_faction", "fac_rohan"), (troop_set_slot, ":rohan_guildmasters", slot_troop_gm_companion_ask, "str_rohan_guildmaster_companion_player_ask"), (troop_set_slot, ":rohan_guildmasters", slot_troop_gm_companion_none, "str_rohan_guildmaster_companion_none"), (troop_set_slot, ":rohan_guildmasters", slot_troop_gm_companion_player_none, "str_rohan_guildmaster_companion_player_none_ok"), (troop_set_slot, ":rohan_guildmasters", slot_troop_gm_companion_player_found, "str_rohan_guildmaster_player_found_ok"), (troop_set_slot, ":rohan_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":rohan_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_edoras", slot_troop_gm_companion_1, "str_rohan_edoras_guildmaster_companion"), (troop_set_slot, "trp_elder_hornburg", slot_troop_gm_companion_2, "str_rohan_hornburg_guildmaster_companion"), (party_set_slot, "p_town_edoras", slot_party_has_companion, 1), (party_set_slot, "p_town_hornburg", slot_party_has_companion, 1), # Lorien (try_for_range, ":lorien_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":lorien_guildmasters"), (eq, ":troop_faction", "fac_lorien"), (troop_set_slot, ":lorien_guildmasters", slot_troop_gm_companion_ask, "str_lorien_guildmaster_companion_player_ask"), (troop_set_slot, ":lorien_guildmasters", slot_troop_gm_companion_none, "str_lorien_guildmaster_companion_none"), (troop_set_slot, ":lorien_guildmasters", slot_troop_gm_companion_player_none, "str_lorien_guildmaster_companion_player_none_ok"), (troop_set_slot, ":lorien_guildmasters", slot_troop_gm_companion_player_found, "str_lorien_guildmaster_player_found_ok"), (troop_set_slot, ":lorien_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":lorien_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_cgaladhon", slot_troop_gm_companion_1, "str_lorien_ca_guildmaster_companion"), (party_set_slot, "p_town_caras_galadhon", slot_party_has_companion, 1), # Beorn (try_for_range, ":beorn_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":beorn_guildmasters"), (eq, ":troop_faction", "fac_beorn"), (troop_set_slot, ":beorn_guildmasters", slot_troop_gm_companion_ask, "str_beorn_guildmaster_companion_player_ask"), (troop_set_slot, ":beorn_guildmasters", slot_troop_gm_companion_none, "str_beorn_guildmaster_companion_none"), (troop_set_slot, ":beorn_guildmasters", slot_troop_gm_companion_player_none, "str_beorn_guildmaster_companion_player_none_ok"), (troop_set_slot, ":beorn_guildmasters", slot_troop_gm_companion_player_found, "str_beorn_guildmaster_player_found_ok"), (troop_set_slot, ":beorn_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":beorn_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_wvillage", slot_troop_gm_companion_1, "str_beorn_house_guildmaster_companion"), (party_set_slot, "p_town_woodsmen_village", slot_party_has_companion, 1), # Woodelf (try_for_range, ":woodelf_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":woodelf_guildmasters"), (eq, ":troop_faction", "fac_woodelf"), (troop_set_slot, ":woodelf_guildmasters", slot_troop_gm_companion_ask, "str_woodelf_guildmaster_companion_player_ask"), (troop_set_slot, ":woodelf_guildmasters", slot_troop_gm_companion_none, "str_woodelf_guildmaster_companion_none"), (troop_set_slot, ":woodelf_guildmasters", slot_troop_gm_companion_player_none, "str_woodelf_guildmaster_companion_player_none_ok"), (troop_set_slot, ":woodelf_guildmasters", slot_troop_gm_companion_player_found, "str_woodelf_guildmaster_player_found_ok"), (troop_set_slot, ":woodelf_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":woodelf_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_thalls", slot_troop_gm_companion_1, "str_woodelf_halls_guildmaster_companion"), (party_set_slot, "p_town_thranduils_halls", slot_party_has_companion, 1), # Dale (try_for_range, ":dale_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":dale_guildmasters"), (eq, ":troop_faction", "fac_dale"), (troop_set_slot, ":dale_guildmasters", slot_troop_gm_companion_ask, "str_dale_guildmaster_companion_player_ask"), (troop_set_slot, ":dale_guildmasters", slot_troop_gm_companion_none, "str_dale_guildmaster_companion_none"), (troop_set_slot, ":dale_guildmasters", slot_troop_gm_companion_player_none, "str_dale_guildmaster_companion_player_none_ok"), (troop_set_slot, ":dale_guildmasters", slot_troop_gm_companion_player_found, "str_dale_guildmaster_player_found_ok"), (troop_set_slot, ":dale_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":dale_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_dale", slot_troop_gm_companion_1, "str_dale_main_guildmaster_companion"), (party_set_slot, "p_town_dale", slot_party_has_companion, 1), # Dwarf (try_for_range, ":dwarf_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":dwarf_guildmasters"), (eq, ":troop_faction", "fac_dwarf"), (troop_set_slot, ":dwarf_guildmasters", slot_troop_gm_companion_ask, "str_dwarf_guildmaster_companion_player_ask"), (troop_set_slot, ":dwarf_guildmasters", slot_troop_gm_companion_none, "str_dwarf_guildmaster_companion_none"), (troop_set_slot, ":dwarf_guildmasters", slot_troop_gm_companion_player_none, "str_dwarf_guildmaster_companion_player_none_ok"), (troop_set_slot, ":dwarf_guildmasters", slot_troop_gm_companion_player_found, "str_dwarf_guildmaster_player_found_ok"), (troop_set_slot, ":dwarf_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":dwarf_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_erebor", slot_troop_gm_companion_1, "str_dwarf_erebor_guildmaster_companion"), (party_set_slot, "p_town_erebor", slot_party_has_companion, 1), # Rivendell (try_for_range, ":rivendell_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":rivendell_guildmasters"), (eq, ":troop_faction", "fac_imladris"), (troop_set_slot, ":rivendell_guildmasters", slot_troop_gm_companion_ask, "str_imladris_guildmaster_companion_player_ask"), (troop_set_slot, ":rivendell_guildmasters", slot_troop_gm_companion_none, "str_imladris_guildmaster_companion_none"), (troop_set_slot, ":rivendell_guildmasters", slot_troop_gm_companion_player_none, "str_imladris_guildmaster_companion_player_none_ok"), (troop_set_slot, ":rivendell_guildmasters", slot_troop_gm_companion_player_found, "str_imladris_guildmaster_player_found_ok"), (troop_set_slot, ":rivendell_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":rivendell_guildmasters", slot_troop_gm_companion_2, -1), (try_end), # Rhun (try_for_range, ":rhun_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":rhun_guildmasters"), (eq, ":troop_faction", "fac_rhun"), (troop_set_slot, ":rhun_guildmasters", slot_troop_gm_companion_ask, "str_rhun_guildmaster_companion_player_ask"), (troop_set_slot, ":rhun_guildmasters", slot_troop_gm_companion_none, "str_rhun_guildmaster_companion_none"), (troop_set_slot, ":rhun_guildmasters", slot_troop_gm_companion_player_none, "str_rhun_guildmaster_companion_player_none_ok"), (troop_set_slot, ":rhun_guildmasters", slot_troop_gm_companion_player_found, "str_rhun_guildmaster_player_found_ok"), (troop_set_slot, ":rhun_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":rhun_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_rhun", slot_troop_gm_companion_1, "str_rhun_maincamp_guildmaster_companion"), (party_set_slot, "p_town_rhun_main_camp", slot_party_has_companion, 1), # Guldur (try_for_range, ":guldur_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":guldur_guildmasters"), (eq, ":troop_faction", "fac_guldur"), (troop_set_slot, ":guldur_guildmasters", slot_troop_gm_companion_ask, "str_guldur_guildmaster_companion_player_ask"), (troop_set_slot, ":guldur_guildmasters", slot_troop_gm_companion_none, "str_guldur_guildmaster_companion_none"), (troop_set_slot, ":guldur_guildmasters", slot_troop_gm_companion_player_none, "str_guldur_guildmaster_companion_player_none_ok"), (troop_set_slot, ":guldur_guildmasters", slot_troop_gm_companion_player_found, "str_guldur_guildmaster_player_found_ok"), (troop_set_slot, ":guldur_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":guldur_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_dolguldur", slot_troop_gm_companion_1, "str_guldur_main_guildmaster_companion"), (party_set_slot, "p_town_dol_guldur", slot_party_has_companion, 1), # Moria (try_for_range, ":moria_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":moria_guildmasters"), (eq, ":troop_faction", "fac_moria"), (troop_set_slot, ":moria_guildmasters", slot_troop_gm_companion_ask, "str_moria_guildmaster_companion_player_ask"), (troop_set_slot, ":moria_guildmasters", slot_troop_gm_companion_none, "str_moria_guildmaster_companion_none"), (troop_set_slot, ":moria_guildmasters", slot_troop_gm_companion_player_none, "str_moria_guildmaster_companion_player_none_ok"), (troop_set_slot, ":moria_guildmasters", slot_troop_gm_companion_player_found, "str_moria_guildmaster_player_found_ok"), (troop_set_slot, ":moria_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":moria_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_moria", slot_troop_gm_companion_1, "str_moria_main_guildmaster_companion"), (party_set_slot, "p_town_moria", slot_party_has_companion, 1), # isengard (try_for_range, ":isengard_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":isengard_guildmasters"), (eq, ":troop_faction", "fac_isengard"), (troop_set_slot, ":isengard_guildmasters", slot_troop_gm_companion_ask, "str_isengard_guildmaster_companion_player_ask"), (troop_set_slot, ":isengard_guildmasters", slot_troop_gm_companion_none, "str_isengard_guildmaster_companion_none"), (troop_set_slot, ":isengard_guildmasters", slot_troop_gm_companion_player_none, "str_isengard_guildmaster_companion_player_none_ok"), (troop_set_slot, ":isengard_guildmasters", slot_troop_gm_companion_player_found, "str_isengard_guildmaster_player_found_ok"), (troop_set_slot, ":isengard_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":isengard_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_isengard", slot_troop_gm_companion_1, "str_isengard_main_guildmaster_companion"), (troop_set_slot, "trp_elder_uhcamp", slot_troop_gm_companion_1, "str_isengard_hunting_camp_guildmaster_companion"), (troop_set_slot, "trp_elder_uhcamp", slot_troop_gm_companion_player_found, "str_isengard_hunting_camp_guildmaster_player_found_ok"), (party_set_slot, "p_town_isengard", slot_party_has_companion, 1), (party_set_slot, "p_town_urukhai_h_camp", slot_party_has_companion, 1), # dunland (try_for_range, ":dunland_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":dunland_guildmasters"), (eq, ":troop_faction", "fac_dunland"), (troop_set_slot, ":dunland_guildmasters", slot_troop_gm_companion_ask, "str_dunland_guildmaster_companion_player_ask"), (troop_set_slot, ":dunland_guildmasters", slot_troop_gm_companion_none, "str_dunland_guildmaster_companion_none"), (troop_set_slot, ":dunland_guildmasters", slot_troop_gm_companion_player_none, "str_dunland_guildmaster_companion_player_none_ok"), (troop_set_slot, ":dunland_guildmasters", slot_troop_gm_companion_player_found, "str_dunland_guildmaster_player_found_ok"), (troop_set_slot, ":dunland_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":dunland_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_dunland", slot_troop_gm_companion_1, "str_dunland_main_guildmaster_companion"), (party_set_slot, "p_town_dunland_camp", slot_party_has_companion, 1), # khand (try_for_range, ":khand_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":khand_guildmasters"), (eq, ":troop_faction", "fac_khand"), (troop_set_slot, ":khand_guildmasters", slot_troop_gm_companion_ask, "str_khand_guildmaster_companion_player_ask"), (troop_set_slot, ":khand_guildmasters", slot_troop_gm_companion_none, "str_khand_guildmaster_companion_none"), (troop_set_slot, ":khand_guildmasters", slot_troop_gm_companion_player_none, "str_khand_guildmaster_companion_player_none_ok"), (troop_set_slot, ":khand_guildmasters", slot_troop_gm_companion_player_found, "str_khand_guildmaster_player_found_ok"), (troop_set_slot, ":khand_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":khand_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_khand", slot_troop_gm_companion_1, "str_khand_main_guildmaster_companion"), (party_set_slot, "p_town_khand_camp", slot_party_has_companion, 1), # Umbar (try_for_range, ":umbar_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":umbar_guildmasters"), (eq, ":troop_faction", "fac_umbar"), (troop_set_slot, ":umbar_guildmasters", slot_troop_gm_companion_ask, "str_umbar_guildmaster_companion_player_ask"), (troop_set_slot, ":umbar_guildmasters", slot_troop_gm_companion_none, "str_umbar_guildmaster_companion_none"), (troop_set_slot, ":umbar_guildmasters", slot_troop_gm_companion_player_none, "str_umbar_guildmaster_companion_player_none_ok"), (troop_set_slot, ":umbar_guildmasters", slot_troop_gm_companion_player_found, "str_umbar_guildmaster_player_found_ok"), (troop_set_slot, ":umbar_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":umbar_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_umbar", slot_troop_gm_companion_1, "str_umbar_main_guildmaster_companion"), (party_set_slot, "p_town_umbar_camp", slot_party_has_companion, 1), # Mordor (try_for_range, ":mordor_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":mordor_guildmasters"), (eq, ":troop_faction", "fac_mordor"), (troop_set_slot, ":mordor_guildmasters", slot_troop_gm_companion_ask, "str_mordor_guildmaster_companion_player_ask"), (troop_set_slot, ":mordor_guildmasters", slot_troop_gm_companion_none, "str_mordor_guildmaster_companion_none"), (troop_set_slot, ":mordor_guildmasters", slot_troop_gm_companion_player_none, "str_mordor_guildmaster_companion_player_none_ok"), (troop_set_slot, ":mordor_guildmasters", slot_troop_gm_companion_player_found, "str_mordor_guildmaster_player_found_ok"), (troop_set_slot, ":mordor_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":mordor_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_mmorgul", slot_troop_gm_companion_1, "str_mordor_morgul_guildmaster_companion"), (troop_set_slot, "trp_elder_cungol", slot_troop_gm_companion_1, "str_mordor_cungol_guildmaster_companion"), (party_set_slot, "p_town_minas_morgul", slot_party_has_companion, 1), (party_set_slot, "p_town_cirith_ungol", slot_party_has_companion, 1), # Harad (try_for_range, ":harad_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":harad_guildmasters"), (eq, ":troop_faction", "fac_harad"), (troop_set_slot, ":harad_guildmasters", slot_troop_gm_companion_ask, "str_harad_guildmaster_companion_player_ask"), (troop_set_slot, ":harad_guildmasters", slot_troop_gm_companion_none, "str_harad_guildmaster_companion_none"), (troop_set_slot, ":harad_guildmasters", slot_troop_gm_companion_player_none, "str_harad_guildmaster_companion_player_none_ok"), (troop_set_slot, ":harad_guildmasters", slot_troop_gm_companion_player_found, "str_harad_guildmaster_player_found_ok"), (troop_set_slot, ":harad_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":harad_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_harad", slot_troop_gm_companion_1, "str_harad_main_guildmaster_companion"), (party_set_slot, "p_town_harad_camp", slot_party_has_companion, 1), # Gundabad (try_for_range, ":gunda_guildmasters", mayors_begin, mayors_end), (store_troop_faction, ":troop_faction", ":gunda_guildmasters"), (eq, ":troop_faction", "fac_gundabad"), (troop_set_slot, ":gunda_guildmasters", slot_troop_gm_companion_ask, "str_gundabad_guildmaster_companion_player_ask"), (troop_set_slot, ":gunda_guildmasters", slot_troop_gm_companion_none, "str_gundabad_guildmaster_companion_none"), (troop_set_slot, ":gunda_guildmasters", slot_troop_gm_companion_player_none, "str_gundabad_guildmaster_companion_player_none_ok"), (troop_set_slot, ":gunda_guildmasters", slot_troop_gm_companion_player_found, "str_gundabad_guildmaster_player_found_ok"), (troop_set_slot, ":gunda_guildmasters", slot_troop_gm_companion_1, -1), (troop_set_slot, ":gunda_guildmasters", slot_troop_gm_companion_2, -1), (try_end), (troop_set_slot, "trp_elder_gunda", slot_troop_gm_companion_1, "str_gundabad_guildmaster_companion"), (party_set_slot, "p_town_gundabad", slot_party_has_companion, 1), ]), ("guildmaster_which_faction_companion", [ (store_script_param, ":town", 1), (assign, ":slot", slot_troop_gm_companion_1), (try_begin), (eq, ":town", "p_town_henneth_annun"), (assign, ":slot", slot_troop_gm_companion_2), (try_end), (assign, reg55, ":slot"), ]), #script_get_hp_shield_value #outputs HP shield value to reg0 ("get_hp_shield_value", [ (store_script_param_1, ":troop_id"), (store_skill_level, ":ironflesh", skl_ironflesh, ":troop_id",), (store_mul, reg0, ":ironflesh", 40), # tweakable. Slot is updated via savegame compat script. (troop_set_slot, ":troop_id", slot_troop_hp_shield, reg0), (troop_set_slot, "trp_player", slot_troop_hp_shield, 1), (try_for_range, ":NPC_hp_shield", "trp_npc1", heroes_begin), (troop_set_slot, ":NPC_hp_shield", slot_troop_hp_shield, 1), (try_end), (try_for_range, ":NPC_hp_shield", "trp_npc18", "trp_werewolf"), (troop_set_slot, ":NPC_hp_shield", slot_troop_hp_shield, 1), (try_end), ]), # script_cf_bear_form_selected # This script is called to check if player has selected bear form to fight battles #InVain: Compile this script in M&B 1.011 too, so it doesn't cause compilation errors. # Input: arg1: # Output: reg0: 1= in the bear form; 0= in human form. ("cf_bear_form_selected", [ (assign, reg0, 0), (assign, ":bear_troop", "trp_multiplayer_profile_troop_male"), # Check if agent troop is that (try_begin), (troop_slot_eq, "trp_player", slot_troop_player_clone, ":bear_troop"), (troop_is_hero, ":bear_troop"), (troop_get_inventory_slot, ":horse_item", ":bear_troop", ek_horse), (eq, ":horse_item", "itm_bear"), (assign, reg0, 1), (try_end), (set_trigger_result, reg0), ]), #Retainers Begin # Assigns all retainers to lords at game start. Put in a separate script so it can also be called in the save game update. # #script_assign_retainers # # INPUT: none # # OUTPUT: none ("assign_retainers", [ (troop_set_slot, "trp_gondor_lord", slot_troop_retainer_troop, "trp_steward_guard"), #Steward Guards for Denethor (troop_set_slot, "trp_rohan_lord", slot_troop_retainer_troop, "trp_c6_king_s_man_of_rohan"), #King's Guard for Theoden (troop_set_slot, "trp_knight_1_7", slot_troop_retainer_troop, "trp_a6_ithilien_master_ranger"), #Rangers for Faramir (troop_set_slot, "trp_knight_2_7", slot_troop_retainer_troop, "trp_ac5_camel_rider"), #camel riders for Harad lord ]), #Retainers End #Friendship Rewards Begin # Checks if the lord wants to give a gift to the player based on their friendship level # #script_lord_friendship_reward_progress # # INPUT: troop_no, new_progress # # OUTPUT: none ("lord_friendship_reward_progress", [ (store_script_param, ":troop_no", 1), (store_script_param, ":new_progress", 2), (troop_get_slot, ":old_progress", ":troop_no", slot_troop_friendship_reward_progress), (val_add, ":new_progress", ":old_progress"), (troop_set_slot, ":troop_no", slot_troop_friendship_reward_progress, ":new_progress"), #Randomly select a reward #Ideally this would be sensitive to player's needs (ie, no troops if party is full, but that's hard to do when pre-rolling) (try_begin), (troop_get_slot, ":reward", ":troop_no", slot_troop_friendship_reward_type), (lt, ":reward", 1), (store_random_in_range, ":random_reward", friendship_reward_troops, friendship_reward_end), (troop_set_slot, ":troop_no", slot_troop_friendship_reward_type, ":random_reward"), (try_begin), (eq, ":random_reward", friendship_reward_troops), (call_script, "script_lord_reward_troops_type", ":troop_no"), (else_try), (eq, ":random_reward", friendship_reward_gear), (call_script, "script_lord_reward_equipment_type", ":troop_no"), (try_end), (troop_set_slot, ":troop_no", slot_troop_friendship_reward_id, reg40), (try_end), ]), #Count and Type scripts are split into two so that type can be pre-determined to avoid cheesing, while count is calculated at reward time to use the appropriate relation # Determines the type of troops a lord would like to award the player # #script_lord_reward_troops_type # # INPUT: troop_no # # OUTPUT: reward_troop ("lord_reward_troops_type", [ (store_script_param, ":troop_no", 1), (assign, ":reward_troop", -1), (troop_get_slot, ":party", ":troop_no", slot_troop_leaded_party), (store_troop_faction, ":hero_fac", ":troop_no"), (try_begin), #See if lord has retainer troops first (troop_get_slot, ":reward_troop", ":troop_no", slot_troop_retainer_troop), (gt, ":reward_troop", 0), (else_try), #If no retainer then choose the highest level troop from the lord's party, prioritizing appropriate subfaction troops (gt, ":party", 0), (party_get_slot, ":hero_subfac", ":party", slot_party_subfaction), (troop_get_type, ":hero_type", ":troop_no"), (party_get_num_companion_stacks, ":num_stacks", ":party"), (assign, ":reward_troop_level", 0), (try_for_range, ":stack", 1, ":num_stacks"), #start at 1 to skip the leader #Copy all of the lord's troops to an array for shuffling #This prevents them from always giving out the same troop if they have multiple top tier troops (party_stack_get_troop_id, ":stack_troop", ":party", ":stack"), (troop_set_slot, "trp_temp_array_a", ":stack", ":stack_troop"), (try_end), (call_script, "script_shuffle_troop_slots", "trp_temp_array_a", 1, ":num_stacks"), (try_for_range, ":stack", 1, ":num_stacks"), #start at 1 to skip the leader (troop_get_slot, ":stack_troop", "trp_temp_array_a", ":stack"), (store_character_level, ":troop_level", ":stack_troop"), (str_store_troop_name, s24, ":stack_troop"), (neg|troop_is_hero,":stack_troop"), #just in case #See if this troop is higher level than the current best (ge, ":troop_level", ":reward_troop_level"), #Only give faction appropriate troops (store_troop_faction, ":troop_fac", ":stack_troop"), (eq, ":troop_fac", ":hero_fac"), #If lord has a subfaction they will only give subfaction troops (troop_get_slot, ":troop_subfac", ":stack_troop", slot_troop_subfaction), (this_or_next|eq, ":troop_subfac", ":hero_subfac"), (eq, ":hero_subfac", 0), #Don't give free trolls (troop_get_type, ":type", ":stack_troop"), (neq, ":type", tf_troll), (assign, ":race_appropriate", 1), (try_begin), #Make sure Imladris heroes give appropriate troops (elves give elves, Halbarad gives Dunedain) (eq, ":hero_fac", "fac_imladris"), (neq, ":hero_type", ":type"), (assign, ":race_appropriate", 0), (else_try), #Mordor uruk lords only give uruks (eq, ":hero_fac", "fac_mordor"), (eq, ":hero_type", tf_uruk), (neq, ":type", tf_uruk), (assign, ":race_appropriate", 0), (try_end), (eq, ":race_appropriate", 1), #Don't give standard bearers (neq, ":stack_troop", "trp_lothlorien_standard_bearer"), (neq, ":stack_troop", "trp_i5_greenwood_standard_bearer"), (neq, ":stack_troop", "trp_i6_rivendell_standard_bearer"), (neq, ":stack_troop", "trp_i5_mordor_uruk_standard_bearer"), (neq, ":stack_troop", "trp_i5_mordor_uruk_standard_bearer"), (assign, ":reward_troop_level", ":troop_level"), (assign, ":reward_troop", ":stack_troop"), (try_end), (try_end), (try_begin), #fallback option, incase something went wrong (le, ":reward_troop", 0), (faction_get_slot, ":reward_troop", ":hero_fac", slot_faction_tier_5_troop), (try_end), (assign, reg40, ":reward_troop"), ]), # Determines the number of troops a lord would like to award the player # #script_lord_reward_troops_count # # INPUT: troop_no # # OUTPUT: troop_count ("lord_reward_troops_count", [ (store_script_param, ":troop_no", 1), (troop_get_slot, ":reward_troop", ":troop_no", slot_troop_friendship_reward_id), #Determine number of troops (call_script, "script_troop_get_player_relation", ":troop_no"), (assign, ":player_relation", reg0), (assign, ":troop_count", ":player_relation"), (val_div, ":troop_count", 25), #1-4 based on relation (val_max, ":troop_count", 1), (try_begin), #Give extra orcs (troop_get_type, ":type", ":reward_troop"), (eq, ":type", tf_orc), (val_mul, ":troop_count", 3), (try_end), (assign, reg41, ":troop_count"), ]), # Determines the type of item a lord would like to award the player # #script_lord_reward_equipment_type # # INPUT: troop_no # # OUTPUT: reward_item ("lord_reward_equipment_type", [ (store_script_param, ":troop_no", 1), #Non-combat rulers don't wear appropriate gear, so if it's one of them we subsitute a high tier faction troop (try_begin), (eq, ":troop_no", "trp_lorien_lord"), (assign, ":gear_troop", "trp_a6_lorien_grey_warden"), (else_try), (eq, ":troop_no", "trp_mordor_lord"), (assign, ":gear_troop", "trp_c5_mordor_num_knight"), #Knight so horses can be given (else_try), (eq, ":troop_no", "trp_gondor_lord"), (assign, ":gear_troop", "trp_c6_gon_tower_knight"), (else_try), (eq, ":troop_no", "trp_isengard_lord"), (assign, ":gear_troop", "trp_i6_isen_uruk_berserker"), (else_try), #Combat lords give rewards based on their own gear (assign, ":gear_troop", ":troop_no"), (end_try), (assign, ":eligible_items", 0), (try_for_range, ":item_slot", ek_item_0, ek_food), (troop_get_inventory_slot, ":item", ":gear_troop", ":item_slot"), #Skip if slot is empty (neq, ":item", -1), #Don't give out unique items this way ] + (is_a_wb_script and [ (neg|item_has_property, ":item", itp_unique), (item_has_property, ":item", itp_shop), ] or []) + [ #If item is eligible store it in the array (troop_set_slot, "trp_temp_array_a", ":eligible_items", ":item"), #Increment after storing to prevent off by one errors (val_add, ":eligible_items", 1), (end_try), #Shuffle and pick reward (call_script, "script_shuffle_troop_slots", "trp_temp_array_a", 0, ":eligible_items"), (troop_get_slot, ":reward_item", "trp_temp_array_a", 0), (assign, reg40, ":reward_item"), ]), # Determines the quality of item a lord would like to award the player # #script_lord_reward_equipment_modifier # # INPUT: troop_no # # OUTPUT: selected_mod ("lord_reward_equipment_modifier", [ (store_script_param, ":troop_no", 1), (troop_get_slot, ":reward_item", ":troop_no", slot_troop_friendship_reward_id), #Get appropriate mods based on item type (item_get_type, ":item_type", ":reward_item"), (assign, ":mod0", imod_plain), (try_begin), (eq, ":item_type", itp_type_horse), (assign, ":mod1", imod_spirited), (assign, ":mod2", imod_heavy), (assign, ":mod3", imod_champion), (else_try), (this_or_next | eq, ":item_type", itp_type_arrows), (this_or_next | eq, ":item_type", itp_type_bolts), (this_or_next | eq, ":item_type", itp_type_bullets), (eq, ":item_type", itp_type_thrown), (assign, ":mod1", imod_fine), (assign, ":mod2", imod_balanced), (assign, ":mod3", imod_large_bag), (else_try), (is_between, ":item_type", itp_type_head_armor, itp_type_pistol), (assign, ":mod1", imod_thick), (assign, ":mod2", imod_reinforced), (assign, ":mod3", imod_lordly), (else_try), (assign, ":mod1", imod_heavy), (assign, ":mod2", imod_balanced), (assign, ":mod3", imod_masterwork), (try_end), (call_script, "script_troop_get_player_relation", ":troop_no"), (assign, ":player_relation", reg0), (try_begin), (ge, ":player_relation", 90), (assign, ":selected_mod", ":mod3"), (else_try), (ge, ":player_relation", 60), (assign, ":selected_mod", ":mod2"), (else_try), (ge, ":player_relation", 30), (assign, ":selected_mod", ":mod1"), (else_try), (assign, ":selected_mod", ":mod0"), (try_end), (assign, reg41, ":selected_mod"), ]), #Friendship Rewards End # script_cf_party_remove_random_prisoner, copy of script_cf_party_remove_random_regular_troop (InVain) # Input: arg1 = party_no # Output: troop_id that has been removed (can fail) ("cf_party_remove_random_prisoner", [(store_script_param_1, ":party_no"), (party_get_num_prisoner_stacks, ":num_stacks", ":party_no"), (assign, ":num_troops", 0), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_prisoner_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (val_add, ":num_troops", ":stack_size"), (try_end), (assign, reg0, -1), (gt, ":num_troops", 0), (store_random_in_range, ":random_troop", 0, ":num_troops"), (try_for_range, ":i_stack", 0, ":num_stacks"), (party_prisoner_stack_get_troop_id, ":stack_troop", ":party_no", ":i_stack"), (neg|troop_is_hero, ":stack_troop"), (party_prisoner_stack_get_size, ":stack_size", ":party_no", ":i_stack"), (val_sub, ":random_troop", ":stack_size"), (lt, ":random_troop", 0), (assign, ":num_stacks", 0), #break (party_remove_prisoners, ":party_no", ":stack_troop", 1), (assign, reg0, ":stack_troop"), (try_end), ]), #script_cancel_all_related_center_quest # INPUT: arg1 = party_no ("cancel_all_related_center_quest", [(store_script_param, ":center", 1), (party_get_slot, ":mayor", ":center", slot_town_elder), (try_for_range, ":quest", mayor_quests_begin, mayor_quests_end_2), (check_quest_active, ":quest"), (this_or_next|quest_slot_eq, ":quest", slot_quest_target_center, ":center"), (this_or_next|quest_slot_eq, ":quest", slot_quest_giver_center, ":center"), (this_or_next|quest_slot_eq, ":quest", slot_quest_object_center, ":center"), (quest_slot_eq, ":quest", slot_quest_giver_troop, ":mayor"), (call_script, "script_cancel_quest", ":quest"), (try_end), ]), # script_send_legion # INPUT: arg1 = home_center # arg2 = destination_center # arg3 = legion size # OUTPUT: reg0 = legion party ("send_legion", [ (store_script_param, ":home_center",1), (store_script_param, ":destination",2), (store_script_param, ":reinforcement_waves",3), (store_faction_of_party, ":faction", ":home_center", ), #(party_get_slot, ":center_scouts", ":home_center", slot_center_spawn_scouts), (set_spawn_radius, 1), (spawn_around_party, ":home_center", "pt_none"), (assign, ":guard_party", reg0), (faction_set_slot, ":faction", slot_faction_guardian_party, ":guard_party"), (faction_set_slot, ":faction", slot_faction_guardian_party_spawned, 1), #party slots (str_store_faction_name, s6, ":faction"), (try_begin), (faction_slot_eq, ":faction", slot_faction_side, faction_side_good), (party_set_name, ":guard_party", "@Army of {s6}"), (else_try), (party_set_name, ":guard_party", "@Host of {s6}"), (try_end), (try_begin), (eq, ":faction", "fac_isengard"), (party_set_icon, ":guard_party", icon_wargrider_walk_x4), # (else_try), # (eq, ":faction", "fac_woodelf"), # (party_set_icon, ":guard_party", icon_mirkwood_elf_x3), (try_end), (party_set_slot, ":guard_party", slot_party_type, spt_guardian), #(party_set_slot, ":guard_party", slot_party_victory_value, ws_guard_vp), # huge victory points for party kill (party_set_slot, ":guard_party", slot_party_home_center, ":home_center"), (party_set_faction, ":guard_party", ":faction"), (party_set_slot, ":guard_party", slot_party_ai_object, ":destination"), (party_set_slot, ":destination", slot_center_is_besieged_by, ":guard_party"), (call_script, "script_party_set_ai_state", ":guard_party", spai_besieging_center, ":destination"), (party_set_ai_behavior, ":guard_party", ai_bhvr_attack_party), (party_set_flags, ":guard_party", pf_default_behavior, 1), (party_set_slot, ":guard_party", slot_party_ai_substate, 1), #fill it up with lord army reinforcements and upgrade a lot #(store_random_in_range, ":reinforcement_waves", 50, 60), #average about 8 troops per reinf (try_for_range, ":unused", 0, ":reinforcement_waves"), (call_script, "script_cf_reinforce_party", ":guard_party"), (try_end), (try_for_range, ":unused", 0, 50), (party_upgrade_with_xp, ":guard_party", 6000, 0), (try_end), # (store_random_in_range, ":reinforcement_waves", 50, 60), #average about 8 troops per reinf # (try_for_range, ":unused", 0, ":reinforcement_waves"), # (call_script, "script_cf_reinforce_party", ":guard_party"), # (try_end), # (str_store_party_name, s5, ":destination"), # (display_message, "@host attacking {s5}"), (assign, reg0, ":guard_party"), #should be already reg0 from spawning, just to be sure ]), # #script_cf_isengard_guardian_quest_fail # # INPUT: none # # OUTPUT: none ("cf_isengard_guardian_quest_fail", [(neg|check_quest_failed, "qst_guardian_party_quest"), (quest_get_slot, ":status", "qst_guardian_party_quest", slot_quest_current_state), (is_between, ":status", -10, 10), #lazy way of making sure this script only fires once (val_mul, ":status", 10), (quest_set_slot, "qst_guardian_party_quest", slot_quest_current_state, ":status"), (quest_get_slot, ":target_party", "qst_guardian_party_quest", slot_quest_target_party), (try_begin), (le, ":status", 0), #only catches Ents if Hornburg path or no path taken (gt, ":target_party", 1), (party_is_active, ":target_party"), (party_slot_eq, ":target_party", slot_party_type, spt_guardian), (call_script, "script_safe_remove_party", ":target_party"), (try_end), #detach all parties from destroyed center (quest_get_slot, ":target_center", "qst_guardian_party_quest", slot_quest_target_center), (remove_member_from_party, trp_aragorn, ":target_center"), (remove_member_from_party, trp_legolas, ":target_center"), (remove_member_from_party, trp_gimli, ":target_center"), (party_get_num_attached_parties, ":num_attached_parties", ":target_center"), (try_for_range_backwards, ":attached_party_rank", 0, ":num_attached_parties"), (party_get_attached_party_with_rank, ":attached_party", ":target_center", ":attached_party_rank"), (gt, ":attached_party", 0), (party_is_active, ":attached_party"), (party_detach, ":attached_party"), (inflict_casualties_to_party_group, ":attached_party", 300, p_temp_wounded), (try_end), (try_begin),#disable scripted mode for Theoden and Rohan (troop_get_slot, ":theoden_party", "trp_rohan_lord", slot_troop_leaded_party), (gt, ":theoden_party", 0), (party_set_slot, ":theoden_party", slot_party_scripted_ai, 0), (faction_set_slot, "fac_rohan", slot_faction_scripted_until, 0), (try_end), #destroy it (str_store_party_name, s2, ":target_center"), (display_log_message, "@The host of Isengard has razed {s2}!", color_bad_news), (call_script, "script_destroy_center", ":target_center"), #send Gandalf to have a word with you... (call_script, "script_fail_quest", "qst_guardian_party_quest"), (call_script, "script_send_on_conversation_mission", tld_cc_gandalf_rohan_quest_fail), ]), ] scripts = scripts + ai_scripts + formAI_scripts+ formAI_v5_scripts + morale_scripts + command_cursor_scripts + common_warp_scripts ################################################################################################ ################################## WARBAND ONLY SCRIPTS BELOW ################################## ################################################################################################ #swy-- WB: make it so upgrading troops from the party screen is free, just like in vanilla M&B 1.011, many thanks to mtarini for his fantastic help on Trello! if is_a_wb_script==1: scripts += [ # script_game_get_upgrade_cost # This script is called from game engine for calculating needed troop upgrade exp # Input: # param1: troop_id, # Output: reg0 = needed cost for upgrade ("game_get_upgrade_cost", [ #(store_script_param_1, ":troop_id"), #swy-- hacky workaround to block upgrading by disabling the button on certain occasions... (try_begin), (eq, "$tld_forbid_troop_upgrade_mode", 1), (set_trigger_result, -1), (else_try), (set_trigger_result, 0), (try_end), ]), # cpp: Imported this script from classic Warband. # Fixes the "Terrible" troop morale. Can be expanded on. # script_game_get_morale_of_troops_from_faction # This script is called from the game engine # Input: # param1: faction_no, # Output: reg0: extra morale x 100 ("game_get_morale_of_troops_from_faction", [ #(store_script_param_1, ":troop_no"), (party_get_morale, reg0, "p_main_party"), (set_trigger_result, reg0), ]), ##Troop Presentation - rubik source - kham implement ("troop_tree_recursive_backtracking", [ (store_script_param, ":troop_no", 1), (store_script_param, ":cur_x", 2), (store_script_param, ":cur_y", 3), (store_script_param, ":offset_x", 4), (store_add, ":next_x", ":cur_x", ":offset_x"), # upgrade_troop (troop_get_upgrade_troop, ":upgrade_troop_1", ":troop_no", 0), (troop_get_upgrade_troop, ":upgrade_troop_2", ":troop_no", 1), (try_begin), (gt, ":upgrade_troop_2", 0), (call_script, "script_troop_tree_recursive_backtracking", ":upgrade_troop_2", ":next_x", reg2, ":offset_x"), (assign, ":upgrade_troop_2_y", reg0), (val_add, reg2, 160), # current global y (call_script, "script_troop_tree_recursive_backtracking", ":upgrade_troop_1", ":next_x", reg2, ":offset_x"), (assign, ":upgrade_troop_1_y", reg0), (else_try), (gt, ":upgrade_troop_1", 0), (call_script, "script_troop_tree_recursive_backtracking", ":upgrade_troop_1", ":next_x", reg2, ":offset_x"), (assign, ":upgrade_troop_1_y", reg0), (try_end), # troop_tree_line (try_begin), (gt, ":upgrade_troop_2", 0), (store_add, reg0, ":upgrade_troop_1_y", ":upgrade_troop_2_y"), (val_div, reg0, 2), # ---- upgrade_troop_1 # | # troop_no ---- # | # ---- upgrade_troop_2 (store_div, ":half_offset_x", ":offset_x", 2), (store_add, ":middle_x", ":cur_x", ":half_offset_x"), (call_script, "script_prsnt_line", ":half_offset_x", 4, ":cur_x", reg0, 0), (call_script, "script_prsnt_line", ":half_offset_x", 4, ":middle_x", ":upgrade_troop_1_y", 0), (call_script, "script_prsnt_line", ":half_offset_x", 4, ":middle_x", ":upgrade_troop_2_y", 0), (store_sub, ":size_y", ":upgrade_troop_1_y", ":upgrade_troop_2_y"), (val_add, ":size_y", 4), (call_script, "script_prsnt_line", 4, ":size_y", ":middle_x", ":upgrade_troop_2_y", 0), (else_try), (gt, ":upgrade_troop_1", 0), (assign, reg0, ":upgrade_troop_1_y"), # # troop_no -------- upgrade_troop_1 # (call_script, "script_prsnt_line", ":offset_x", 4, ":cur_x", ":upgrade_troop_1_y", 0), (else_try), (assign, reg0, ":cur_y"), (try_end), # troop name (str_store_troop_name, s1, ":troop_no"), (create_text_overlay, reg1, "@{s1}", tf_center_justify|tf_vertical_align_center|tf_double_space|tf_scrollable), (store_sub, ":name_x", ":cur_x", 57), (store_sub, ":name_y", reg0, 120), (position_set_x, pos1, ":name_x"), (position_set_y, pos1, ":name_y"), (overlay_set_position, reg1, pos1), (position_set_x, pos1, 100), (position_set_y, pos1, 60), (overlay_set_area_size, reg1, pos1), (position_set_x, pos1, 640), (position_set_y, pos1, 640), (overlay_set_size, reg1, pos1), # troop avatar (store_sub, ":avatar_x", ":cur_x", 60), (store_sub, ":avatar_y", reg0, 60), (store_mul, ":cur_troop", ":troop_no", 2), #with weapons (create_image_button_overlay_with_tableau_material, reg1, -1, "tableau_game_party_window", ":cur_troop"), (position_set_x, pos1, 360), (position_set_y, pos1, 480), (overlay_set_size, reg1, pos1), (position_set_x, pos1, ":avatar_x"), (position_set_y, pos1, ":avatar_y"), (overlay_set_position, reg1, pos1), # troop info (troop_set_slot, "trp_stack_selection_amounts", "$g_cur_slot_no", reg1), (troop_set_slot, "trp_stack_selection_ids", "$g_cur_slot_no", ":troop_no"), (val_add, "$g_cur_slot_no", 1), # START Troop Detail: saves data to array - VC-2379 (val_add, "$troop_tree_counter", 1), (troop_set_slot, "trp_temp_array_a", "$troop_tree_counter", reg1), # overlay id (troop_set_slot, "trp_temp_array_b", "$troop_tree_counter", ":troop_no"), # troop_id # END Troop Detail: saves data to array ]), # reg0: cur max_tier ("troop_tree_recursive_detect_max_tier", [ (store_script_param, ":troop_no", 1), (store_script_param, ":cur_tier", 2), # (str_store_troop_name, s5, ":troop_no"), # (assign, reg4, ":cur_tier"), # (display_message, "@TIER {reg4} / {s5}."), (store_add, ":next_tier", ":cur_tier", 1), # upgrade_troop (troop_get_upgrade_troop, ":upgrade_troop_1", ":troop_no", 0), (troop_get_upgrade_troop, ":upgrade_troop_2", ":troop_no", 1), (try_begin), (gt, ":upgrade_troop_1", 0), (gt, ":upgrade_troop_2", 0), # swy: ensure this it doesn't return a self-reference, don't ask me why this happens # with farmers (which are at the start of the soldier block) (neq, ":upgrade_troop_1", ":troop_no"), (neq, ":upgrade_troop_2", ":troop_no"), # (str_store_troop_name, s5, ":upgrade_troop_1"), # (str_store_troop_name, s6, ":upgrade_troop_2"), # (display_message, "@ [2] {s5} / {s6}."), (call_script, "script_troop_tree_recursive_detect_max_tier", ":upgrade_troop_2", ":next_tier"), (call_script, "script_troop_tree_recursive_detect_max_tier", ":upgrade_troop_1", ":next_tier"), (else_try), (gt, ":upgrade_troop_1", 0), # swy: ensure this it doesn't return a self-reference, don't ask me why this happens # with farmers (which are at the start of the soldier block) (neq, ":upgrade_troop_1", ":troop_no"), # (str_store_troop_name, s5, ":upgrade_troop_1"), # (display_message, "@ [1] {s5}."), (call_script, "script_troop_tree_recursive_detect_max_tier", ":upgrade_troop_1", ":next_tier"), (try_end), (try_begin), (gt, ":cur_tier", reg0), (assign, reg0, ":cur_tier"), (try_end), ]), ("prsnt_line", [ (store_script_param, ":size_x", 1), (store_script_param, ":size_y", 2), (store_script_param, ":pos_x", 3), (store_script_param, ":pos_y", 4), (store_script_param, ":color", 5), (create_mesh_overlay, reg1, "mesh_white_plane"), (val_mul, ":size_x", 50), (val_mul, ":size_y", 50), (position_set_x, pos0, ":size_x"), (position_set_y, pos0, ":size_y"), (overlay_set_size, reg1, pos0), (position_set_x, pos0, ":pos_x"), (position_set_y, pos0, ":pos_y"), (overlay_set_position, reg1, pos0), (overlay_set_color, reg1, ":color"), ]), # script_get_page_no_of_troop_tree_for_troop_on # Input: troop_no # Output: page_no ("get_page_no_of_troop_tree_for_troop_on", [ (store_script_param, ":troop_no", 1), (assign, ":page_no", -1), #(store_sub, ":num_factions", npc_kingdoms_end, npc_kingdoms_begin), (store_troop_faction, ":troop_faction", ":troop_no"), (try_begin), (is_between, ":troop_faction", npc_kingdoms_begin, npc_kingdoms_end), (store_sub, ":page_no", ":troop_faction", npc_kingdoms_begin), #(else_try), # (is_between, ":troop_no", soldiers_begin, mercenary_troops_end), # (store_add, ":page_no", ":num_factions", 0), # mercenary #(else_try), # (eq, ":troop_faction", "fac_outlaws"), # (store_add, ":page_no", ":num_factions", 1), # Outlaws #(else_try), # (store_add, ":page_no", ":num_factions", 2), # Others (try_end), (assign, reg0, ":page_no"), ]), ## troop presentation end #### Custom Camera Scripts by dunde, implemented by Kham ("init_camera", [(assign, "$key_camera_toggle", key_end), # «End» key to toggle camera mode. (assign, "$key_camera_next", key_right), # «Right» key to jump to next bot. (assign, "$key_camera_prev", key_left), # «Left» key to jump to prev bot. (assign, "$key_camera_zoom_plus", key_numpad_plus), # «Num +» to zoom in. (assign, "$key_camera_zoom_min", key_numpad_minus), # «Num -» to zoom out. (assign, "$key_camera_height_plus", key_up), (assign, "$key_camera_height_min", key_down), (assign, "$cam_free", 0), (assign, "$g_camera_z", 300), (assign, "$g_camera_y", -1000), (assign, "$cam_shoulder", 0), ]), # Modified MartinF's code for DeathCam # script_dmod_cycle_forwards # Output: New $dmod_current_agent # Used to cycle forwards through valid agents ("dmod_cycle_forwards", [(assign, ":agent_moved", 0), (assign, ":first_agent", -1), (get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (agent_get_team, ":prev_team", "$cam_current_agent"), (try_for_agents, ":agent_no"), (neq, ":agent_moved", 1), (agent_is_human, ":agent_no"), (agent_is_alive, ":agent_no"), (agent_get_team, ":cur_team", ":agent_no"), (agent_get_troop_id, ":troop_id", ":agent_no"), (this_or_next|troop_is_hero, ":troop_id"), (neg|key_is_down, key_left_shift), (this_or_next|eq, ":cur_team", ":prev_team"), (neg|key_is_down, key_left_control), (this_or_next|neq, ":cur_team", ":prev_team"), (neg|key_is_down, key_left_alt), (this_or_next|eq, "$cam_free", 1), (eq, ":cur_team", ":player_team"), (try_begin), (lt, ":first_agent", 0), # Find the 1st agent alive and (1 team or free mod) (assign, ":first_agent", ":agent_no"), (try_end), (gt, ":agent_no", "$cam_current_agent"), # Find next agent alive and (1 team or free mod) (assign, "$cam_current_agent", ":agent_no"), (assign, ":agent_moved", 1), (try_end), (try_begin), (eq, ":agent_moved", 0), # Next Agent not found, but 1st agent found, then the next is the first one (neq, ":first_agent", -1), (assign, "$cam_current_agent", ":first_agent"), (assign, ":agent_moved", 1), (else_try), (eq, ":agent_moved", 0), (eq, ":first_agent", -1), (display_message, "@No Troops Left."), (try_end), (try_begin), (eq, ":agent_moved", 1), # there is next one (try_begin), (agent_is_alive, ":player_agent"), # if player is still alive, push to mode 1 (assign, "$cam_mode", 1), (mission_cam_set_mode, "$cam_mode"), (try_end), (str_store_agent_name, 1, "$cam_current_agent"), (try_end),]), # script_dmod_cycle_backwards # Output: New $dmod_current_agent # Used to cycle backwards through valid agents ("dmod_cycle_backwards", [(assign, ":new_agent", -1), (assign, ":last_agent", -1), (get_player_agent_no, ":player_agent"), (agent_get_team, ":player_team", ":player_agent"), (agent_get_team, ":prev_team", "$cam_current_agent"), (try_for_agents, ":agent_no"), (agent_is_human, ":agent_no"), (agent_is_alive, ":agent_no"), (agent_get_team, ":cur_team", ":agent_no"), (agent_get_troop_id, ":troop_id", ":agent_no"), (this_or_next|troop_is_hero, ":troop_id"), (neg|key_is_down, key_left_shift), (this_or_next|eq, ":cur_team", ":prev_team"), (neg|key_is_down, key_left_control), (this_or_next|neq, ":cur_team", ":prev_team"), (neg|key_is_down, key_left_alt), (this_or_next|eq, "$cam_free", 1), (eq, ":cur_team", ":player_team"), (assign, ":last_agent", ":agent_no"), # Ok, the last (lt, ":agent_no", "$cam_current_agent"), (assign, ":new_agent", ":agent_no"), # prev agent (try_end), (try_begin), (eq, ":new_agent", -1), (neq, ":last_agent", -1), (assign, ":new_agent", ":last_agent"), (else_try), (eq, ":new_agent", -1), (eq, ":last_agent", -1), (display_message, "@No Troops Left."), (try_end), (try_begin), (neq, ":new_agent", -1), # There is prev agent (assign, "$cam_current_agent", ":new_agent"), (try_begin), (agent_is_alive, ":player_agent"), (assign, "$cam_mode", 1), (mission_cam_set_mode, "$cam_mode"), (try_end), (str_store_agent_name, 1, "$cam_current_agent"), (try_end), ]), ### Custom camera end ## Kham Field AI & Skirmish Order Changes (Credit: Caba'drin PBDO & Diplomacy - Modified for TLD) START #script_agent_fix_division by Caba'drin #Input: agent_id #Output: nothing (agent divisions changed, slot set) #To fix AI troop divisions from the engine applying player's party divisions on all agents #This is called after agent_reassign_team, so can safely assume correct team is set ("agent_fix_division", [ (store_script_param_1, ":agent"), (agent_set_slot, ":agent", slot_agent_new_division, -1), (get_player_agent_no, ":player"), #after_mission_start triggers are called after spawn, so globals can't be used yet (try_begin), (ge, ":player", 0), (neq, ":agent", ":player"), (agent_is_human, ":agent"), (agent_get_team, ":player_team", ":player"), (agent_get_team, ":team", ":agent"), (this_or_next|main_hero_fallen), (neq, ":team", ":player_team"), (agent_get_troop_id, ":troop", ":agent"), (try_begin), (troop_is_guarantee_horse, ":troop"), (assign, ":target_division", grc_cavalry), (else_try), (troop_is_guarantee_ranged, ":troop"), (assign, ":target_division", grc_archers), (else_try), (assign, ":target_division", grc_infantry), (try_end), (agent_get_division, ":division", ":agent"), (neq, ":division", ":target_division"), (agent_set_division, ":agent", ":target_division"), (agent_set_slot, ":agent", slot_agent_new_division, ":target_division"), (try_end), ]), # script_weapon_use_backup_weapon # Input: arg1: agent; arg2: 1 - Include Two-Handers, 2 - One-hand only # Output: none # Allows Agents to use backup weapons (neg|lance or bow) when enemies are close by ("weapon_use_backup_weapon", [ # Find non-lance/spear/bow item in inventory (store_script_param_1, ":agent"), (store_script_param_2, ":inc_two_handers"), (assign,":has_choice",0), (assign, ":end", ek_head), (try_for_range, ":i", ek_item_0, ":end"), (agent_get_item_slot, ":item", ":agent",":i"), (gt, ":item", 0), (item_get_type, ":weapontype", ":item"), (try_begin), (eq, ":inc_two_handers", 0), (eq, ":weapontype", itp_type_one_handed_wpn), (assign, ":has_choice", 1), (assign, ":end", ek_item_0), #Loop breaker (else_try), (is_between, ":weapontype", itp_type_one_handed_wpn, itp_type_polearm),#one or two handed (assign,":has_choice",1), (assign, ":end", ek_item_0),#loop breaker (try_end), (try_end), (try_begin),# Equip their backup weapon. (eq, ":has_choice",1), (agent_set_wielded_item, ":agent", ":item"), (try_end), ]), # script_weapon_use_classify_agent # Input: agent_no # Output: None # Used to check what weapon the agent is wielding, and sets the slots appropriately. ("weapon_use_classify_agent", [ (store_script_param_1, ":agent"), (try_begin), (agent_is_alive, ":agent"), (agent_is_non_player, ":agent"), (try_begin), (agent_is_human, ":agent"), (agent_get_troop_id, ":troop",":agent"), (agent_get_wielded_item, ":wielded", ":agent", 0), (neg|troop_is_guarantee_ranged, ":troop"), #Not an archer (neg|troop_is_guarantee_horse, ":troop"), #Not Mounted (agent_get_ammo, ":has_ammo", ":agent", 0), #Double-check this one doesn't have throwing weapons, etc (le, ":has_ammo", 0), #Doesn't have ammo (try_begin), (gt, ":wielded", 0), (item_get_type, ":wielded_type", ":wielded"), (eq, ":wielded_type", itp_type_polearm), # Is it a polearm? (agent_set_slot, ":agent", slot_agent_spear, ":wielded"), #Mark spearmen (else_try), #Check if there's a spear equipped, if not wielded (assign, ":end", ek_head), (try_for_range, ":i", ek_item_0, ":end"), (agent_get_item_slot, ":item", ":agent", ":i"), (gt, ":item", 0), (item_get_type, ":weapontype", ":item"), (eq, ":weapontype", itp_type_polearm), # Is it a spear? (agent_set_slot, ":agent", slot_agent_spear, ":item"), #Mark spearmen (assign, ":end", ek_item_0), #loop Break (try_end), (try_end), (else_try), (neg|agent_is_human, ":agent"), #Is Horse (assign, ":horse", ":agent"), (agent_get_rider, ":agent", ":horse"), (agent_is_active, ":agent"), (agent_get_troop_id, ":troop",":agent"), (agent_get_wielded_item, ":wielded", ":agent", 0), (try_begin), (neg|troop_is_guarantee_ranged, ":troop"), # Not a horsearcher (try_begin), #(this_or_next|is_between, ":wielded", "itm_jousting_lance","itm_glaive"), # Is it a lance? #(is_between, ":wielded", "itm_light_lance","itm_pike"), # Is it a lance? (gt, ":wielded", 0), (item_slot_eq, ":wielded", slot_item_couchable, 1), (agent_set_slot, ":agent", slot_agent_lance, ":wielded"), (agent_set_slot, ":agent", slot_agent_spear, 0), #double-check (else_try), # Force the NPC to wield a lance, but this will only happen if they # actually have a lance equipped. Otherwise this does nothing. (assign, ":end", ek_head), (try_for_range, ":i", ek_item_0, ":end"), (agent_get_item_slot, ":item", ":agent", ":i"), (gt, ":item", 0), (item_slot_eq, ":item", slot_item_couchable, 1), (agent_set_slot, ":agent", slot_agent_lance, ":item"), (agent_set_slot, ":agent", slot_agent_spear, 0), #double-check (agent_set_wielded_item, ":agent", ":item"), (assign, ":end", ek_item_0), (try_end), (try_end), (else_try), (troop_is_guarantee_ranged, ":troop"), # Is a horsearcher...redundant, but making sure (try_begin), (is_between, ":wielded", "itm_short_bow", "itm_dunland_javelin"), # Is it a bow or a horse-useful crossbow? (agent_set_slot, ":agent", slot_agent_horsebow, ":wielded"), (agent_set_slot, ":agent", slot_agent_spear, 0), #double-check (else_try), # Force the NPC to wield their bow, but this will only happen if they # actually have a bow equipped. Otherwise this does nothing. (assign, ":end", "itm_dunland_javelin"), # adjust as needed (try_for_range, ":item", "itm_short_bow",":end"), (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), (agent_set_slot, ":agent", slot_agent_horsebow, ":item"), #Mark horse archers for later use (agent_set_slot, ":agent", slot_agent_spear, 0), #double-check (assign, ":end", "itm_short_bow"),#loop breaker (try_end), (try_end), (try_end), #Lancer or Horse Archer (try_end), #Human v Horse (try_end), #prevent failure ]), # script_cf_order_skirmish_check # Input: Nothing # Output: Nothing # Check for an active Skirmish Order, in lieu of global variables ("cf_order_skirmish_check", [ (get_player_agent_no, ":player"), (agent_get_party_id, ":player_party", ":player"), (assign, ":skirmish", 0), (try_for_range, ":i", slot_party_skirmish_d0, slot_party_skirmish_d8 + 1), (party_slot_eq, ":player_party", ":i", 1), (assign, ":skirmish", 1), (try_end), (eq, ":skirmish", 1), ]), # script_order_skirmish_begin_end # Input: Nothing # Output: Nothing # On key depression, determine if beginning or ending skirmish # If ending, stop any retreating. If beginning, call order_skirmish_skirmish # Display appropriate order text on screen. ("order_skirmish_begin_end", [ (get_player_agent_no, ":player"), (agent_get_team, ":playerteam", ":player"), (agent_get_party_id, ":player_party", ":player"), (assign, ":skirmish", 0), (try_for_range, ":class", 0, 8), (class_is_listening_order, ":playerteam", ":class"), #Listening to Order (store_add, ":class_ordered", ":class", slot_party_skirmish_d0), (party_slot_eq, ":player_party", ":class_ordered", 0), (party_set_slot, ":player_party", ":class_ordered", 1), (assign, ":skirmish", 1), (str_store_string, s1, "@avoid melee"), (try_begin), #Mark class as selected--used for display text (eq, ":class", 0), (assign, ":group0_is_selected", 1), (else_try), (eq, ":class", 1), (assign, ":group1_is_selected", 1), (else_try), (eq, ":class", 2), (assign, ":group2_is_selected", 1), (else_try), (eq, ":class", 3), (assign, ":group3_is_selected", 1), (else_try), (eq, ":class", 4), (assign, ":group4_is_selected", 1), (else_try), (eq, ":class", 5), (assign, ":group5_is_selected", 1), (else_try), (eq, ":class", 6), (assign, ":group6_is_selected", 1), (else_try), (eq, ":class", 7), (assign, ":group7_is_selected", 1), (else_try), (eq, ":class", 8), (assign, ":group8_is_selected", 1), (try_end), (try_end), #Class Loop (try_for_agents, ":agent"), (agent_is_alive, ":agent"), (agent_is_human, ":agent"), (agent_is_non_player, ":agent"), (agent_get_team, ":team", ":agent"), (eq, ":team", ":playerteam"), #On Player's side? (agent_get_division, ":class", ":agent"), (try_begin), #Mark class as in battle--used for display text (eq, ":class", 0), (assign, ":group0_in_battle", 1), (else_try), (eq, ":class", 1), (assign, ":group1_in_battle", 1), (else_try), (eq, ":class", 2), (assign, ":group2_in_battle", 1), (else_try), (eq, ":class", 3), (assign, ":group3_in_battle", 1), (else_try), (eq, ":class", 4), (assign, ":group4_in_battle", 1), (else_try), (eq, ":class", 5), (assign, ":group5_in_battle", 1), (else_try), (eq, ":class", 6), (assign, ":group6_in_battle", 1), (else_try), (eq, ":class", 7), (assign, ":group7_in_battle", 1), (else_try), (eq, ":class", 8), (assign, ":group8_in_battle", 1), (try_end), (class_is_listening_order, ":team", ":class"), #Is the agent's division selected? (eq, ":skirmish", 0), (store_add, ":class_ordered", ":class", slot_party_skirmish_d0), (party_set_slot, ":player_party", ":class_ordered", 0), (try_begin), (agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Is not routing or ordered to retreat (agent_stop_running_away, ":agent"), (try_end), (str_store_string, s1, "@stand and fight"), (try_begin), #Mark class as selected--used for display text (eq, ":class", 0), (assign, ":group0_is_selected", 1), (else_try), (eq, ":class", 1), (assign, ":group1_is_selected", 1), (else_try), (eq, ":class", 2), (assign, ":group2_is_selected", 1), (else_try), (eq, ":class", 3), (assign, ":group3_is_selected", 1), (else_try), (eq, ":class", 4), (assign, ":group4_is_selected", 1), (else_try), (eq, ":class", 5), (assign, ":group5_is_selected", 1), (else_try), (eq, ":class", 6), (assign, ":group6_is_selected", 1), (else_try), (eq, ":class", 7), (assign, ":group7_is_selected", 1), (else_try), (eq, ":class", 8), (assign, ":group8_is_selected", 1), (try_end), (try_end), #Agent loop (str_clear, s2), (str_clear, s3), (assign, ":count_possible", 0), (assign, ":count_selected", 0), (try_begin), (eq, ":group0_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group0_is_selected", 1), (val_add, ":count_selected", 1), (str_store_class_name, s2, 0), (try_end), (try_begin), (eq, ":group1_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group1_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 1), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 1), (try_end), (try_end), (try_begin), (eq, ":group2_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group2_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 2), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 2), (try_end), (try_end), (try_begin), (eq, ":group3_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group3_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 3), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 3), (try_end), (try_end), (try_begin), (eq, ":group4_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group4_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 4), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 4), (try_end), (try_end), (try_begin), (eq, ":group5_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group5_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 5), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 5), (try_end), (try_end), (try_begin), (eq, ":group6_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group6_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 6), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 6), (try_end), (try_end), (try_begin), (eq, ":group7_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group7_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 7), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 7), (try_end), (try_end), (try_begin), (eq, ":group8_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group8_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 8), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 8), (try_end), (try_end), (try_begin), (eq, ":count_selected", ":count_possible"), (str_store_string, s2, "@Everyone"), (try_end), (try_begin), (gt, ":count_selected", 0), (display_message, "@{!}{s2}, {s1}!", 0xFFDDDD66), (try_end), (str_clear, s2), (str_clear, s3), (try_begin), (eq, ":skirmish", 1), (call_script, "script_order_skirmish_skirmish"), (try_end), ]), # script_order_skirmish_skirmish # Input: Nothing # Output: Nothing # Cycle through agents, checking and maintaining distance ("order_skirmish_skirmish", [ (set_fixed_point_multiplier, 1), (get_scene_boundaries, pos2, pos3), (position_get_x, ":bound_right", pos2), (position_get_y, ":bound_top", pos2), (position_get_x, ":bound_left", pos3), (position_get_y, ":bound_bottom", pos3), (try_for_agents, ":agent"), (agent_is_alive, ":agent"), (agent_is_human, ":agent"), (agent_is_non_player, ":agent"), (agent_get_team, ":team", ":agent"), #(eq, ":team", "$fplayer_team_no"), #On Player's side? (agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Is not routing or ordered to retreat (agent_get_division, ":class", ":agent"), (store_add, ":slot", slot_party_skirmish_d0, ":class"), (team_slot_eq, ":team", ":slot", 1), #Division is skirmishing (agent_get_position, pos1, ":agent"), (position_get_x, ":agent_x", pos1), (position_get_y, ":agent_y", pos1), (store_sub, ":dist_right", ":agent_x", ":bound_right"), (store_sub, ":dist_top", ":agent_y", ":bound_top"), (store_sub, ":dist_left", ":bound_left", ":agent_x"), (store_sub, ":dist_bottom", ":bound_bottom", ":agent_y"), (agent_get_ammo, ":ammo", ":agent"), (try_begin), #If agent is too close to edge of map, stop skirmishing. Will resume when back into map (this_or_next|le, ":ammo", 0), #Stop skirmishing and resume orders if out of ammo (this_or_next|le, ":dist_right", 25), #Limits accidental routing, of cav in particular (this_or_next|le, ":dist_top", 25), (this_or_next|le, ":dist_left", 25), (le, ":dist_bottom", 25), (agent_stop_running_away, ":agent"), (else_try), (call_script, "script_get_closest3_distance_of_enemies_at_pos1", ":team", pos1), # Find distance of nearest 3 enemies (assign, ":avg_dist", reg0), (assign, ":closest_dist", reg1), (try_begin), (this_or_next|lt, ":avg_dist", skirmish_min_distance), (lt, ":closest_dist", 700), #If enemy group is getting near or an enemy is on top of agent (agent_start_running_away, ":agent"), (else_try), (ge, ":avg_dist", skirmish_max_distance), #If distance from enemy is (too) large, resume previous order (agent_stop_running_away, ":agent"), (try_end), #Distance to enemy (try_end), #Distance from edge (try_end), #Agent loop ]), ## Caba'drin Orders End ## Kham Field AI & Skirmish Order Changes (Credit: Caba'drin PBDO & Diplomacy - Modified for TLD) START ## Kham Get Troop Encumberance - For Fallen Riders trigger (Credit: Windyplains - Silverstag) # script_ce_get_troop_encumbrance ("ce_get_troop_encumbrance", [ (store_script_param, ":troop_no", 1), (store_script_param, ":skill_no", 2), (assign, ":total_weight", 0), (assign, ":encumbrance", 0), (assign, ":encumbrance_skill_penalty", 0), (assign, ":encumbrance_speed_penalty", 0), (set_fixed_point_multiplier, 1000), ## WEAPON SLOT #0 (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_item_0), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Weapon #0 weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## WEAPON SLOT #1 (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_item_1), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Weapon #1 weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## WEAPON SLOT #2 (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_item_2), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Weapon #2 weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## WEAPON SLOT #3 (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_item_3), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Weapon #3 weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## HEAD (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_head), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Head item weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## BODY (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_body), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Body item weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## FOOT (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_foot), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Foot item weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), ## HAND (try_begin), (troop_get_inventory_slot, ":item_no", ":troop_no", ek_gloves), (ge, ":item_no", 1), (item_get_weight, ":item_weight", ":item_no"), (val_add, ":total_weight", ":item_weight"), ### # (assign, reg1, ":item_weight"), # (assign, reg2, ":total_weight"), # (display_message, "@DEBUG: Glove item weighs {reg1}. Total weight {reg2}.", color_bad_news), (try_end), (val_div, ":total_weight", 10), # Bring the size down due to raising fixed point multiplier to 1000. ## DETERMINE ENCUMBRANCE (try_begin), (store_div, ":encumbrance", ":total_weight", 100), (val_sub, ":encumbrance", 15), (try_end), ## DETERMINE SKILL PENALTIES (store_attribute_level, ":STR", ":troop_no", ca_strength), (val_div, ":STR", 2), (store_attribute_level, ":AGI", ":troop_no", ca_agility), (val_div, ":AGI", 2), (try_begin), ### SHIELD ### (eq, ":skill_no", "skl_shield"), (store_sub, ":penalty", ":encumbrance", ":STR"), (val_div, ":penalty", 8), (assign, ":encumbrance_skill_penalty", ":penalty"), # Diagnostic (assign, reg31, ":encumbrance_skill_penalty"), (str_store_string, s32, "@Shield (-{reg31})"), (else_try), ### POWER DRAW ### (eq, ":skill_no", "skl_power_draw"), (store_add, ":combined", ":STR", ":AGI"), (val_div, ":combined", 2), (store_sub, ":penalty", ":encumbrance", ":combined"), (val_div, ":penalty", 6), (assign, ":encumbrance_skill_penalty", ":penalty"), # Diagnostic (assign, reg31, ":encumbrance_skill_penalty"), (str_store_string, s32, "@Power Draw (-{reg31})"), (else_try), ### RIDING ### (eq, ":skill_no", "skl_riding"), (store_sub, ":penalty", ":encumbrance", ":AGI"), (val_div, ":penalty", 12), (assign, ":encumbrance_skill_penalty", ":penalty"), # Diagnostic (assign, reg31, ":encumbrance_skill_penalty"), (str_store_string, s32, "@Riding (-{reg31})"), (else_try), ### HORSE ARCHERY ### (eq, ":skill_no", "skl_horse_archery"), (store_sub, ":penalty", ":encumbrance", ":AGI"), (val_div, ":penalty", 6), (assign, ":encumbrance_skill_penalty", ":penalty"), # Diagnostic (assign, reg31, ":encumbrance_skill_penalty"), (str_store_string, s32, "@Horse Archery (-{reg31})"), (else_try), ### ATHLETICS ### (eq, ":skill_no", "skl_athletics"), (store_add, ":combined", ":STR", ":AGI"), (val_div, ":combined", 2), (store_sub, ":penalty", ":encumbrance", ":combined"), (val_div, ":penalty", 8), (assign, ":encumbrance_skill_penalty", ":penalty"), # Diagnostic (assign, reg31, ":encumbrance_skill_penalty"), (str_store_string, s32, "@Athletics (-{reg31})"), (else_try), (str_store_string, s32, "@No Skill Penalty Assigned"), (try_end), (val_max, ":encumbrance_skill_penalty", 0), # No beneficial penalties. (store_div, reg1, ":total_weight", 100), (store_mod, reg5, ":total_weight", 100), (assign, reg2, ":encumbrance"), (assign, reg3, ":encumbrance_skill_penalty"), (assign, reg4, ":encumbrance_speed_penalty"), ### DIAGNOSTIC ### # (try_begin), # (eq, ":troop_no", "trp_player"), # (str_store_troop_name, s31, ":troop_no"), # (display_message, "@{s31}, weight = {reg1}.{reg5}, encumbrance = {reg2}, {s32}"), # (try_end), ]), #script_get_closest_melee_enemy #Input: Agent #Output: reg1 - closest melee enemy ("get_closest_melee_enemy", [ (store_script_param_1, ":agent1"), (assign, reg1, 0), (agent_get_position, pos1, ":agent1"), (agent_ai_get_num_cached_enemies, ":enemy_count", ":agent1"), (try_for_range, ":potential_new_target", 0, ":enemy_count"), (agent_ai_get_cached_enemy, ":agent2", ":agent1", ":potential_new_target"), (agent_is_active, ":agent2"), (agent_is_alive, ":agent2"), (agent_is_human, ":agent2"), (assign, reg1, ":agent2"), (assign, ":counter", 0), (try_for_agents, ":agent3"), (neq, ":counter", 2), (neq, ":agent1", ":agent3"), (agent_is_active, ":agent3"), (agent_is_alive, ":agent3"), (agent_is_human, ":agent3"), (agent_ai_get_look_target, ":target", ":agent3"), (eq, ":agent2", ":target"), (val_add, ":counter", 1), (try_end), (neq, ":counter", 2), (assign, reg1, ":agent2"), (try_end), ]), ("party_has_hero", [ (party_get_num_companion_stacks, ":num_stacks", "p_encountered_party_backup"), (assign, ":done",0), (assign, ":num_heroes",0), (try_for_range, ":stack_no", 0, ":num_stacks"), (eq, ":done",0), (party_stack_get_troop_id, ":stack_troop","p_encountered_party_backup",":stack_no"), (is_between, ":stack_troop", kingdom_heroes_begin, kingdom_heroes_end), (val_add, ":num_heroes", 1), (assign, ":done",1), (try_end), (try_begin), (gt, ":num_heroes",0), (assign, reg12, 1), (else_try), (assign, reg12, 0), (try_end), ]), #Kham VC Troop Tree Scripts Start #moto troop tree chief # script_troop_tree_precurse # Input: troop, number of upgrade, number of upgrade2 # Output: reg0 number upgrade, reg1 upgrade2 ("troop_tree_precurse", [(store_script_param, ":troop", 1), (store_script_param, ":ret_val_0", 2), (store_script_param, ":ret_val_1", 3), (assign, ":max_branch_0", ":ret_val_0"), (troop_get_upgrade_troop, ":next_troop", ":troop", 0), (try_begin), (gt, ":next_troop", 0), (store_add, ":max_branch_0", ":ret_val_0", 1), (call_script, "script_troop_tree_precurse", ":next_troop", ":max_branch_0", ":ret_val_1"), (val_max, ":max_branch_0", reg0), (val_max, ":ret_val_1", reg1), (try_end), (troop_get_upgrade_troop, ":next_troop", ":troop", 1), (try_begin), (gt, ":next_troop", 0), (val_add, ":ret_val_0", 1), (val_add, ":ret_val_1", 1), (call_script, "script_troop_tree_precurse", ":next_troop", ":ret_val_0", ":ret_val_1"), (val_max, ":ret_val_0", reg0), (val_max, ":ret_val_1", reg1), (try_end), (val_max, ":ret_val_0", ":max_branch_0"), (assign, reg0, ":ret_val_0"), (assign, reg1, ":ret_val_1"),]), # script_troop_tree_recurse # Input: troop, x_pos, y_pos # Output: reg0 augmented y_pos ("troop_tree_recurse", [(store_script_param, ":troop", 1), (store_script_param, ":x_pos", 2), (store_script_param, ":y_pos", 3), (store_script_param, ":next_y", 3), # Fix height of pic - VC-2379 (val_min, "$troop_tree_pic_height", 272), (store_div, ":scaler", Troop_Tree_Area_Height, "$troop_tree_pic_height"), (store_div, ":scaled_width", Troop_Tree_Tableau_Width, ":scaler"), (store_div, ":scaled_height", Troop_Tree_Tableau_Height, ":scaler"), (store_mul, reg2, ":troop", 2), #picture with weapons (see script_add_troop_to_cur_tableau_for_party) (create_mesh_overlay_with_tableau_material, reg1, -1, "tableau_troop_tree_pic", reg2), # START Troop Detail: saves data to array - VC-2379 (val_add, "$troop_tree_counter", 1), (troop_set_slot, "trp_temp_array_a", "$troop_tree_counter", reg1), # overlay id (troop_set_slot, "trp_temp_array_b", "$troop_tree_counter", ":troop"), # troop_id # END Troop Detail: saves data to array (store_div, reg3, ":scaled_width", 3), #half too much for some reason (store_sub, reg2, ":x_pos", reg3), (position_set_x, pos1, reg2), (position_set_y, pos1, ":y_pos"), (overlay_set_position, reg1, pos1), (position_set_x, pos1, ":scaled_width"), (position_set_y, pos1, ":scaled_height"), (overlay_set_size, reg1, pos1), # (overlay_set_additional_render_height, reg1, 10), #float over lines MOTO # doesn't help (str_store_troop_name, s0, ":troop"), (create_text_overlay, reg1, "@{s0}", tf_center_justify), (position_set_x, pos1, ":x_pos"), (position_set_y, pos1, ":y_pos"), (overlay_set_position, reg1, pos1), (store_div, ":text_scaler", Troop_Tree_Area_Width, "$troop_tree_pic_width"), (val_max, ":text_scaler", ":scaler"), (store_div, reg2, 3500 * Screen_Undistort_Width_Num / Screen_Undistort_Width_Den, ":text_scaler"), (position_set_x, pos1, reg2), (store_div, reg2, 3500, ":text_scaler"), (position_set_y, pos1, reg2), (overlay_set_size, reg1, pos1), (store_div, reg3, ":scaled_height", 2), (store_sub, reg2, ":y_pos", reg3), (store_div, ":height_adjust", "$troop_tree_pic_height", 2), (store_add, ":next_x", ":x_pos", "$troop_tree_pic_width"), (troop_get_upgrade_troop, ":next_troop", ":troop", 0), (try_begin), (gt, ":next_troop", 0), (create_mesh_overlay, reg1, "mesh_white_plane"), (position_set_x, pos1, ":x_pos"), (store_add, reg2, ":y_pos", ":height_adjust"), (position_set_y, pos1, reg2), (overlay_set_position, reg1, pos1), (store_mul, reg2, "$troop_tree_pic_width", 50), (position_set_x, pos1, reg2), (position_set_y, pos1, 50 * 4), (overlay_set_size, reg1, pos1), (overlay_set_color, reg1, Troop_Tree_Line_Color), (call_script, "script_troop_tree_recurse", ":next_troop", ":next_x", ":next_y"), (assign, ":next_y", reg0), (try_end), (troop_get_upgrade_troop, ":next_troop", ":troop", 1), (try_begin), (gt, ":next_troop", 0), (val_sub, ":next_y", "$troop_tree_pic_height"), #half length horizontal, moved halfway (create_mesh_overlay, reg1, "mesh_white_plane"), (store_div, reg2, "$troop_tree_pic_width", 2), (val_add, reg2, ":x_pos"), (position_set_x, pos1, reg2), (store_add, reg2, ":next_y", ":height_adjust"), (position_set_y, pos1, reg2), (overlay_set_position, reg1, pos1), (store_mul, reg2, "$troop_tree_pic_width", 50), (val_div, reg2, 2), (position_set_x, pos1, reg2), (position_set_y, pos1, 50 * 4), (overlay_set_size, reg1, pos1), (overlay_set_color, reg1, Troop_Tree_Line_Color), #vertical to connect (create_mesh_overlay, reg1, "mesh_white_plane"), (store_div, reg2, "$troop_tree_pic_width", 2), (val_add, reg2, ":x_pos"), (position_set_x, pos1, reg2), (store_add, reg2, ":next_y", ":height_adjust"), (position_set_y, pos1, reg2), (overlay_set_position, reg1, pos1), (position_set_x, pos1, 50 * 3), #3/4 to undistort in wide screens (store_sub, reg2, ":y_pos", ":next_y"), (val_mul, reg2, 50), (position_set_y, pos1, reg2), (overlay_set_size, reg1, pos1), (overlay_set_color, reg1, Troop_Tree_Line_Color), (call_script, "script_troop_tree_recurse", ":next_troop", ":next_x", ":next_y"), (assign, ":next_y", reg0), (try_end), (assign, reg0, ":next_y"),]), #script_manage_legs_in_cur_tableau # INPUT: troop_no # OUTPUT: none ("manage_legs_in_cur_tableau", [ (store_script_param, ":troop_no", 1), (cur_tableau_clear_override_items), #(troop_get_inventory_slot, ":armor", ":troop_no", ek_body), (assign, ":flags", 0), (assign, ":troop_no", ":troop_no"), #(try_begin), # (gt, ":armor", itm_no_item), # (item_has_property, ":armor", itp_replaces_helm), # (val_or, ":flags", af_override_head), #(try_end), (try_begin), (gt, ":flags", 0), (cur_tableau_set_override_flags, ":flags"), (try_end), ]), # script_troop_detail_layout # Troop Detail VC-2379 # Description ("troop_detail_layout", [# Done (set_container_overlay, -1), (create_game_button_overlay, "$g_presentation_leave_button", "@Done"), (position_set_x, pos1, Screen_Width - 210),(position_set_y, pos1, 60), (overlay_set_position, "$g_presentation_leave_button", pos1), # Gear/Stats button (str_clear, s1), (try_begin), (eq, "$temp", 1), (str_store_string, s1, "@Inventory"), (else_try), (str_store_string, s1, "@Show stats"), (try_end), (create_game_button_overlay, "$g_presentation_obj_1", s1), (position_set_x, pos1, Screen_Width - 425),(position_set_y, pos1, 60), (overlay_set_position, "$g_presentation_obj_1", pos1), # Show item tooltip (create_check_box_overlay, "$checkbox_show_item_details", "mesh_checkbox_off", "mesh_checkbox_on"), (position_set_x, pos1, 915),(position_set_y, pos1, 675), (overlay_set_position, "$checkbox_show_item_details", pos1), (overlay_set_val, "$checkbox_show_item_details", "$checkbox_show_item_details_val"), (create_text_overlay, "$checkbox_show_item_details_label", "@Show item details ", tf_right_align), (position_set_x, pos1, 915),(position_set_y, pos1, 675 - 5), (overlay_set_position, "$checkbox_show_item_details_label", pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, "$checkbox_show_item_details_label", pos1), (overlay_set_color, "$checkbox_show_item_details_label", 0x000000), (try_begin), (eq, "$temp", 1), (overlay_set_display, "$checkbox_show_item_details_label", 0), (overlay_set_display, "$checkbox_show_item_details", 0), (try_end), # title (create_text_overlay, reg1, "@Troop detail", tf_center_justify), (position_set_x, pos1, 500),(position_set_y, pos1, Screen_Height - 85), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_title),(position_set_y, pos1, font_title), (overlay_set_size, reg1, pos1), (create_text_overlay, reg1, "@Troop detail", tf_center_justify), (position_set_x, pos1, 500 + 1),(position_set_y, pos1, Screen_Height - 85), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_title),(position_set_y, pos1, font_title), (overlay_set_size, reg1, pos1), (create_text_overlay, reg1, "@Troop detail", tf_center_justify), (position_set_x, pos1, 500 + 2),(position_set_y, pos1, Screen_Height - 85 + 1), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_title),(position_set_y, pos1, font_title), (overlay_set_size, reg1, pos1),]), # "script_troop_detail_draw_troop" # Input: troop_id # Output: none ("troop_detail_draw_troop", [(store_script_param_1, ":troop_id"), (try_begin), (eq, "$temp", 1), (store_mul, ":cur_troop", ":troop_id", 2),#with weapons (create_mesh_overlay_with_tableau_material, "$default_troop_portrait", -1, "tableau_troop_tree_pic", ":cur_troop"), (else_try), (create_mesh_overlay_with_tableau_material, "$default_troop_portrait", -1, "tableau_troop_detail_dummy_pic", ":troop_id"), (try_end), (position_set_x, pos1, Troop_Tree_Tableau_Width * 0.8), (position_set_y, pos1, Troop_Tree_Tableau_Height * 0.8), (overlay_set_size, "$default_troop_portrait", pos1), (position_set_x, pos1, 0),(position_set_y, pos1, 150), (overlay_set_position, "$default_troop_portrait", pos1),]), # "script_troop_detail_draw_weapons" # Input: troop_id # Output: none ("troop_detail_draw_weapons", [(store_script_param_1, ":troop_id"), (call_script, "script_troop_detail_draw_weapons_aux", ":troop_id", ek_item_0), (call_script, "script_troop_detail_draw_weapons_aux", ":troop_id", ek_item_1), (call_script, "script_troop_detail_draw_weapons_aux", ":troop_id", ek_item_2), (call_script, "script_troop_detail_draw_weapons_aux", ":troop_id", ek_item_3),]), # "script_troop_detail_draw_weapons_aux" # Input: troop_id, wp_number # Output: none ("troop_detail_draw_weapons_aux", [(store_script_param_1, ":troop_id"), (store_script_param_2, ":wp_number"), (troop_get_inventory_slot, ":wp", ":troop_id", ":wp_number"), (try_begin), (neq, ":wp", -1), (assign, ":y", 500), (store_mul, ":dec_y", 100, ":wp_number"), (val_sub, ":y", ":dec_y"), (store_add, ":y2", ":y", 40), (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"), (position_set_x, pos1, 300),(position_set_y, pos1, ":y"), (overlay_set_position, reg1, pos1), (create_mesh_overlay_with_item_id, reg2, ":wp"), (position_set_x, pos1, 300 + 40),(position_set_y, pos1, ":y2"), (overlay_set_position, reg2, pos1), (position_set_x, pos2, 600),(position_set_y, pos2, 600), (overlay_set_size, reg1, pos2), (overlay_set_alpha, reg1, 0xFF), (overlay_set_size, reg2, pos2), (try_end),]), # "script_troop_detail_stats" # Input: troop_id # Output: none ("troop_detail_stats", [(store_script_param_1, ":troop_id"), (create_mesh_overlay, ":stats_area", "mesh_white_plane"), (position_set_x, pos1, 24 * 1000),(position_set_y, pos1, 24 * 1000), (overlay_set_size, ":stats_area", pos1), (position_set_x, pos1, 450),(position_set_y, pos1, 150), (overlay_set_position, ":stats_area", pos1), (overlay_set_color, ":stats_area", 0xE6D1A7), (str_store_troop_name, s1, ":troop_id"), (store_attribute_level, ":troop_str", ":troop_id", ca_strength), (store_attribute_level, ":troop_agi", ":troop_id", ca_agility), (store_skill_level, ":troop_powerstrike", "skl_power_strike", ":troop_id"), (store_skill_level, ":troop_athletics", "skl_athletics", ":troop_id"), (store_skill_level, ":troop_riding", "skl_riding", ":troop_id"), (store_skill_level, ":troop_powerthrow", "skl_power_throw", ":troop_id"), (store_skill_level, ":troop_powerdraw", "skl_power_draw", ":troop_id"), (store_proficiency_level, ":troop_onehanded", ":troop_id", wpt_one_handed_weapon), (store_proficiency_level, ":troop_twohanded", ":troop_id", wpt_two_handed_weapon), (store_proficiency_level, ":troop_polearm", ":troop_id", wpt_polearm), (store_proficiency_level, ":troop_archery", ":troop_id", wpt_archery), (store_proficiency_level, ":troop_crossbow", ":troop_id", wpt_crossbow), (store_proficiency_level, ":troop_throwing", ":troop_id", wpt_throwing), (store_proficiency_level, ":troop_slings", ":troop_id", wpt_firearm), # Check items for weapon skills of the troops (assign, ":has_onehand", 0), (assign, ":has_twohand", 0), (assign, ":has_polearm", 0), (assign, ":has_crossbow", 0), (assign, ":has_archery", 0), (assign, ":has_sling", 0), (assign, ":has_throw", 0), (try_for_range, ":i", 0, 64), (troop_get_inventory_slot, ":item", ":troop_id", ":i"), (neq, ":item", -1), (item_get_type, ":type", ":item"), (try_begin), (eq, ":type", itp_type_bow), (assign, ":has_archery", 1), (else_try), (eq, ":type", itp_type_crossbow), (assign, ":has_crossbow", 1), (else_try), (eq, ":type", itp_type_pistol), (assign, ":has_sling", 1), (else_try),# throwable spears are both (try_begin), (eq, ":type", itp_type_thrown), (assign, ":has_throw", 1), (try_end), (eq, ":type", itp_type_polearm), (assign, ":has_polearm", 1), (else_try), (eq, ":type", itp_type_one_handed_wpn), (assign, ":has_onehand", 1), (else_try), (eq, ":type", itp_type_two_handed_wpn), (assign, ":has_twohand", 1), (try_end), (try_end), (store_troop_health, ":troop_hp", ":troop_id", 1), (store_character_level, ":troop_level", ":troop_id"), (str_store_string, s1, "@{s1}^"), (assign, reg1, ":troop_level"), (str_store_string, s1, "@{s1}Level: {reg1}^"), (assign, reg1, ":troop_hp"), (str_store_string, s1, "@{s1}Hit Points: {reg1}"), (create_text_overlay, reg1, s1, tf_left_align | tf_double_space), (position_set_x, pos1, 465),(position_set_y, pos1, 530), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (str_clear, s1),(str_clear, s2), (assign, reg1, ":troop_str"), (str_store_string, s1, "@{s1}Atributes: ^ Strength:^"), (str_store_string, s2, "@{s2}^{reg1}^"), (assign, reg1, ":troop_agi"), (str_store_string, s1, "@{s1} Agility:"), (str_store_string, s2, "@{s2}{reg1}"), (create_text_overlay, reg1, s1, tf_left_align | tf_double_space), (position_set_x, pos1, 465),(position_set_y, pos1, 405), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (create_text_overlay, reg1, s2, tf_center_justify | tf_double_space), (position_set_x, pos1, 465 + 145),(position_set_y, pos1, 405), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (str_clear, s1),(str_clear, s2), (assign, reg1, ":troop_powerstrike"), (str_store_string, s1, "@{s1}Main skills: ^"), (str_store_string, s1, "@{s1} Power Strike:^"), (str_store_string, s2, "@{s2}{reg1}^"), (assign, reg1, ":troop_athletics"), (str_store_string, s1, "@{s1} Athletics:^"), (str_store_string, s2, "@{s2}{reg1}^"), (assign, reg1, ":troop_riding"), (str_store_string, s1, "@{s1} Riding:^"), (try_begin), (troop_is_mounted, ":troop_id"), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_powerthrow"), (str_store_string, s1, "@{s1} Power Throw:^"), (try_begin), (eq, ":has_throw", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_powerdraw"), (str_store_string, s1, "@{s1} Power Draw:^^"), (try_begin), (eq, ":has_archery", 1), (str_store_string, s2, "@{s2}{reg1}^^"), (else_try), (str_store_string, s2, "@{s2}-^^"), (try_end), (create_text_overlay, reg1, s1, tf_left_align | tf_double_space), (position_set_x, pos1, 465),(position_set_y, pos1, 170), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (create_text_overlay, reg1, s2, tf_center_justify | tf_double_space), (position_set_x, pos1, 645),(position_set_y, pos1, 170), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (str_clear, s1),(str_clear, s2), (str_store_string, s1, "@{s1}Weapons:^"), (assign, reg1, ":troop_onehanded"), (str_store_string, s1, "@{s1} One Handed:^"), (try_begin), (eq, ":has_onehand", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_twohanded"), (str_store_string, s1, "@{s1} Two Handed:^"), (try_begin), (eq, ":has_twohand", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_polearm"), (str_store_string, s1, "@{s1} Polearms:^"), (try_begin), (eq, ":has_polearm", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_archery"), (str_store_string, s1, "@{s1} Archery:^"), (try_begin), (eq, ":has_archery", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_crossbow"), (str_store_string, s1, "@{s1} Crossbow:^"), (try_begin), (eq, ":has_crossbow", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_throwing"), (str_store_string, s1, "@{s1} Throwing:^"), (try_begin), (eq, ":has_throw", 1), (str_store_string, s2, "@{s2}{reg1}^"), (else_try), (str_store_string, s2, "@{s2}-^"), (try_end), (assign, reg1, ":troop_slings"), (str_store_string, s1, "@{s1} Slings:"), (try_begin), (eq, ":has_sling", 1), (str_store_string, s2, "@{s2}{reg1}"), (else_try), (str_store_string, s2, "@{s2}-"), (try_end), (create_text_overlay, reg1, s1, tf_left_align | tf_double_space), (position_set_x, pos1, 465 + 240),(position_set_y, pos1, 275), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (create_text_overlay, reg1, s2, tf_center_justify | tf_double_space), (position_set_x, pos1, 465 + 240 + 192),(position_set_y, pos1, 275), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1),]), # Uses trp_temp_troop to gather the items # "script_troop_detail_inventory" # Output: $temp2 with the quantity of items on inventory # Output: trp_temp_array_a, trp_temp_array_b, trp_temp_array_c ("troop_detail_inventory", [# Container 1: selection (create_text_overlay, ":gear_container", "str_empty_string", tf_scrollable_style_2), (position_set_x, pos1, 450),(position_set_y, pos1, 150), (overlay_set_position, ":gear_container", pos1), (position_set_x, pos1, 480),(position_set_y, pos1, 480), (overlay_set_area_size, ":gear_container", pos1), (set_container_overlay, ":gear_container"), (troop_sort_inventory, "trp_temp_troop"), (troop_get_inventory_capacity, ":num_slots", "trp_temp_troop"), (store_free_inventory_capacity, ":num_free_slots", "trp_temp_troop"), (store_sub, ":num_items", ":num_slots", ":num_free_slots"), (val_sub, ":num_items", 10), (store_div, ":y_max", ":num_items", 4), (assign, ":box_incr", 115), (val_max, ":y_max", 1), (val_mul, ":y_max", ":box_incr"), (assign, ":x_item", 60), (store_add, ":y_item", ":y_max", 60), (assign, ":count", 0), (assign, ":x_box", 0), (assign, ":y_box", ":y_max"), # 0-70 for body armor, 71-140 for helmet, 141-210 for boots, 211-299 rest # 300+ for imod of each item (assign, ":limit_temp_c", 300), (store_mul, reg0, ":limit_temp_c", 2), (try_for_range, ":slot", 0, reg0), (troop_set_slot, "trp_temp_array_a", ":slot", -1), (troop_set_slot, "trp_temp_array_b", ":slot", -1), (troop_set_slot, "trp_temp_array_c", ":slot", -1), (try_end), (assign, ":armor_slot", 0), (assign, ":helmet_slot", 71), (assign, ":boots_slot", 141), (assign, ":rest_slot", 211), (assign, ":imod_slot_add", 300), (try_for_range, ":slot", 0, ":num_slots"), (troop_get_inventory_slot, ":item", "trp_temp_troop", ":slot"), (neq, ":item", -1), (troop_get_inventory_slot_modifier, ":item_imod", "trp_temp_troop", ":slot"), (item_get_type, ":type", ":item"), (try_begin), (eq, ":type", itp_type_body_armor), (troop_set_slot, "trp_temp_array_c", ":armor_slot", ":item"), (store_add, reg0, ":armor_slot", ":imod_slot_add"), (troop_set_slot, "trp_temp_array_c", reg0, ":item_imod"), (val_add, ":armor_slot", 1), (else_try), (eq, ":type", itp_type_head_armor), (troop_set_slot, "trp_temp_array_c", ":helmet_slot", ":item"), (store_add, reg0, ":helmet_slot", ":imod_slot_add"), (troop_set_slot, "trp_temp_array_c", reg0, ":item_imod"), (val_add, ":helmet_slot", 1), (else_try), (eq, ":type", itp_type_foot_armor), (troop_set_slot, "trp_temp_array_c", ":boots_slot", ":item"), (store_add, reg0, ":boots_slot", ":imod_slot_add"), (troop_set_slot, "trp_temp_array_c", reg0, ":item_imod"), (val_add, ":boots_slot", 1), (else_try), (troop_set_slot, "trp_temp_array_c", ":rest_slot", ":item"), (store_add, reg0, ":rest_slot", ":imod_slot_add"), (troop_set_slot, "trp_temp_array_c", reg0, ":item_imod"), (val_add, ":rest_slot", 1), (try_end), (try_end), (try_for_range, ":slot", 0, ":limit_temp_c"), (troop_get_slot, ":item", "trp_temp_array_c", ":slot"), (try_begin), (neq, ":item", -1), (store_add, reg0, ":slot", 300), (troop_get_slot, ":item_imod", "trp_temp_array_c", reg0), (val_add, ":count", 1), (create_mesh_overlay, reg1, "mesh_mp_inventory_choose"), (position_set_x, pos1, ":x_box"),(position_set_y, pos1, ":y_box"), (overlay_set_position, reg1, pos1), (position_set_x, pos1, 900),(position_set_y, pos1, 900), (overlay_set_size, reg1, pos1), (overlay_set_alpha, reg1, 0xFF), (create_mesh_overlay_with_item_id, reg1, ":item"), (position_set_x, pos1, ":x_item"),(position_set_y, pos1, ":y_item"), (overlay_set_position, reg1, pos1), (position_set_x, pos1, 1250),(position_set_y, pos1, 1250), (overlay_set_size, reg1, pos1), (val_add, ":x_item", 115), (val_add, ":x_box", 115), (try_begin),# next row items (store_mod, ":mod", ":count", 4), (eq, ":mod", 0), (val_sub, ":y_item", 115), (val_sub, ":y_box", 115), (assign, ":x_item", 60), (assign, ":x_box", 0), (try_end), #tooltip (store_add, reg0, ":count", ":imod_slot_add"), (troop_set_slot, "trp_temp_array_a", ":count", reg1), (troop_set_slot, "trp_temp_array_b", ":count", ":item"), (troop_set_slot, "trp_temp_array_b", reg0, ":item_imod"), (try_end), (try_end), (assign, "$temp2", ":count"), (set_container_overlay, -1), # Text about troop inventory (try_begin), (create_text_overlay, reg1, "@(Click on the troop to rotate it)^^Click on pieces of gear ^(helmet, armor, gloves and boots)^ to display them.", tf_center_justify), (position_set_x, pos1, 245),(position_set_y, pos1, 27), (overlay_set_position, reg1, pos1), (position_set_x, pos1, font_normal),(position_set_y, pos1, font_normal), (overlay_set_size, reg1, pos1), (overlay_set_color, reg1, 0x000000), (try_end), ]), # "script_troop_detail_inventory_tooltip" ("troop_detail_inventory_tooltip", [(try_begin), (store_trigger_param_1, ":object"), (store_trigger_param_2, ":enter_leave"), (eq, "$checkbox_show_item_details_val", 1), (eq, "$temp", 2), (try_begin), (eq, ":enter_leave", 1), (close_item_details), (else_try), (assign, ":end_loop", "$temp2"), (val_add, ":end_loop", 1), (try_for_range, ":i", 1, ":end_loop"), (troop_get_slot, reg1, "trp_temp_array_a", ":i"), (eq, ":object", reg1), (troop_get_slot, reg2, "trp_temp_array_b", ":i"), (store_add, reg3, ":i", 300), (troop_get_slot, reg4, "trp_temp_array_b", reg3), (overlay_get_position, pos1, ":object"), (show_item_details_with_modifier, reg2, reg4, pos1, 100), (assign, ":end_loop", 0), (try_end), (try_end), (try_end),]), # "script_troop_detail_update_dummy" # Input: troop_id, $temp2: quantity of items, trp_temp_array_a, # trp_temp_array_b # Output: reg10 : should update presentation ("troop_detail_update_dummy", [(store_script_param_1, ":troop_id"), (store_script_param_2, ":object"), (try_begin), # Rotate (eq, ":object", "$default_troop_portrait"), (val_add, "$troop_detail_dummy_angle", 1), (try_begin), (ge, "$troop_detail_dummy_angle", 4), (assign, "$troop_detail_dummy_angle", 0), (try_end), (assign, ":redraw_troop", 1), (else_try), # Change gear (assign, ":end_loop", "$temp2"), (val_add, ":end_loop", 1), (assign, ":new_item", -1), (assign, reg10, 0), (try_for_range, ":i", 1, ":end_loop"), (troop_get_slot, reg1, "trp_temp_array_a", ":i"), (eq, ":object", reg1), (troop_get_slot, ":new_item", "trp_temp_array_b", ":i"), (store_add, reg0, ":i", 300), (troop_get_slot, ":new_item_imod", "trp_temp_array_b", reg0), (assign, ":end_loop", 0), (item_get_type, ":type", ":new_item"), (try_begin), (eq, ":type", itp_type_body_armor), (call_script, "script_troop_detail_update_dummy_gear_aux", ":troop_id", ek_body, ":new_item", ":new_item_imod"), (else_try), (eq, ":type", itp_type_head_armor), (call_script, "script_troop_detail_update_dummy_gear_aux", ":troop_id", ek_head, ":new_item", ":new_item_imod"), (else_try), (eq, ":type", itp_type_foot_armor), (call_script, "script_troop_detail_update_dummy_gear_aux", ":troop_id", ek_foot, ":new_item", ":new_item_imod"), (else_try), (eq, ":type", itp_type_hand_armor), (call_script, "script_troop_detail_update_dummy_gear_aux", ":troop_id", ek_gloves, ":new_item", ":new_item_imod"), (try_end), (troop_sort_inventory, ":troop_id"), (try_end), (assign, ":redraw_troop", reg10), (try_end), (try_begin), (eq, ":redraw_troop", 1), (start_presentation, "prsnt_troop_detail"), (try_end),]), # "script_troop_detail_update_dummy_gear_aux" # Input: troop_id, body_part, new_item # Output: reg10 with redraw_troop ("troop_detail_update_dummy_gear_aux", [(store_script_param_1, ":troop_id"), (store_script_param_2, ":body_part"), (store_script_param, ":new_item", 3), (store_script_param, ":new_item_imod", 4), (assign, ":redraw_troop", 0), (try_begin), (troop_get_inventory_slot, ":old_item", ":troop_id", ":body_part"), (neq, ":old_item", ":new_item"), (troop_get_inventory_slot_modifier, ":old_item_imod", ":troop_id", ":body_part"), (troop_remove_item, ":troop_id", ":new_item"), (troop_set_inventory_slot, ":troop_id", ":body_part", ":new_item"), (troop_set_inventory_slot_modifier, ":troop_id", ":body_part", ":new_item_imod"), (assign, ":redraw_troop", 1), (neq, ":old_item", -1), (troop_add_item, ":troop_id", ":old_item", ":old_item_imod"), (try_end), (assign, reg10, ":redraw_troop"),]), # Changes between STATS and INVENTORY screens # "script_troop_detail_change_screen" # Input: none # Output: none ("troop_detail_change_screen", [(store_script_param_1, ":troop_id"), (try_begin), (eq, "$temp", 1), (assign, "$temp", 2), # Clone dummy gear (troop_clear_inventory, "trp_temp_troop"), (troop_get_inventory_capacity, ":slots", "trp_temp_troop"), (try_for_range, ":i", 0, ":slots"), (troop_set_inventory_slot, "trp_temp_troop", ":i", -1), (troop_set_inventory_slot_modifier, "trp_temp_troop", ":i", 0), (try_end), (assign, ":clone_slot", 10), (troop_set_auto_equip, "trp_temp_troop", 0), (try_for_range, ":i", 0, ":slots"), (troop_get_inventory_slot, ":item_id", ":troop_id", ":i"), (neq, ":item_id", -1), (troop_get_inventory_slot_modifier, ":item_imod", ":troop_id", ":i"), (troop_set_inventory_slot, "trp_temp_troop", ":clone_slot", ":item_id"), (troop_set_inventory_slot_modifier, "trp_temp_troop", ":clone_slot", ":item_imod"), (val_add, ":clone_slot", 1), (try_end), (assign, "$troop_detail_dummy_angle", 0), (else_try), (assign, "$temp", 1), (try_end), (start_presentation, "prsnt_troop_detail"),]), # script_add_troop_to_cur_tableau_for_troop_detail_dummy # Used on Troop Detail to display the dummy troop (player can switch helmet, # chest, boots) # Input: troop_no (x4 as it has the rotation angle too) ("add_troop_to_cur_tableau_for_troop_detail_dummy", [(store_script_param, ":troop_no",1), (assign, ":side", "$troop_detail_dummy_angle"), (val_mul, ":side", 90), #to degrees (assign, reg0, ":side"), (set_fixed_point_multiplier, 100), (cur_tableau_clear_override_items), #(cur_tableau_set_override_flags, af_override_weapons), (init_position, pos2), (position_rotate_z, pos2, ":side"), (cur_tableau_set_camera_parameters, 1, 6, 6, 10, 10000), (init_position, pos5), (assign, ":cam_height", 105), (assign, ":camera_distance", 450), (assign, ":camera_yaw", 15), (assign, ":camera_pitch", -18), (assign, ":animation", anim_stand_man), (position_set_z, pos5, ":cam_height"), # camera looks towards -z axis (position_rotate_x, pos5, -90), (position_rotate_z, pos5, 180), # now apply yaw and pitch (position_rotate_y, pos5, ":camera_yaw"), (position_rotate_x, pos5, ":camera_pitch"), (position_move_z, pos5, ":camera_distance", 0), (position_move_x, pos5, 5, 0), (call_script, "script_manage_legs_in_cur_tableau", ":troop_no"), (store_mul, ":random_seed", ":troop_no", 126233), (val_mod, ":random_seed", 1000), (val_add, ":random_seed", 1), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", ":random_seed"), (cur_tableau_set_camera_position, pos5), (copy_position, pos8, pos5), (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up (position_rotate_z, pos8, 30), (position_rotate_x, pos8, -60), (cur_tableau_add_sun_light, pos8, 175,150,125),]), #script_game_troop_upgrades_button_clicked # This script is called from the game engine when the player clicks on said button from the party screen # INPUT: arg1 = troop_id ("game_troop_upgrades_button_clicked", [ (store_script_param, reg0, 1), (start_presentation, "prsnt_game_troop_tree"), ]), ("init_item_score", set_item_score()), #script_add_troop_to_custom_armor_tableau # INPUT: troop_no, item (g_current_opened_item_details), side (g_custom_armor_angle) # OUTPUT: none ("add_troop_to_custom_armor_tableau", [ (store_script_param, ":troop_no",1), (store_mul, ":side", "$g_custom_armor_angle", 60), #add some more sides (set_fixed_point_multiplier, 100), (cur_tableau_clear_override_items), (cur_tableau_set_override_flags, af_override_weapons), (init_position, pos2), (position_rotate_z, pos2, ":side"), (cur_tableau_set_camera_parameters, 1, 4, 6, 10, 10000), (init_position, pos5), (assign, ":cam_height", 105), # (val_mod, ":camera_distance", 5), (assign, ":camera_distance", 380), (assign, ":camera_yaw", -15), (assign, ":camera_pitch", -18), (val_clamp, "$g_custom_armor_angle", 0, anim_walk_forward_crouch - anim_walk_backward), (store_add, ":animation", "$g_custom_armor_angle", "anim_walk_backward"), (position_set_z, pos5, ":cam_height"), # camera looks towards -z axis (position_rotate_x, pos5, -90), (position_rotate_z, pos5, 180), # now apply yaw and pitch (position_rotate_y, pos5, ":camera_yaw"), (position_rotate_x, pos5, ":camera_pitch"), (position_move_z, pos5, ":camera_distance", 0), (position_move_x, pos5, 5, 0), (try_begin), #shouldn't be necessary, it's already on the troop (player character) (gt, "$g_current_opened_item_details", -1), (cur_tableau_add_override_item, "$g_current_opened_item_details"), (try_end), (cur_tableau_add_troop, ":troop_no", pos2, ":animation", -1), (cur_tableau_set_camera_position, pos5), (copy_position, pos8, pos5), (position_rotate_x, pos8, -90), #y axis aligned with camera now. z is up (position_rotate_z, pos8, 30), (position_rotate_x, pos8, -60), (cur_tableau_add_sun_light, pos8, 155,155,155), ]), ## Order Weapon Switch # script_order_weapon_type_switch # Input: Order Type # Output: Nothing # On key depression, try to switch division to appropriate weapon ("order_weapon_type_switch", [ (store_script_param_1, ":ordertype"), (get_player_agent_no, ":player"), (agent_get_team, ":playerteam", ":player"), (try_for_agents, ":agent"), (agent_is_alive, ":agent"), (agent_is_human, ":agent"), (agent_is_non_player, ":agent"), (agent_get_team, ":team", ":agent"), (eq, ":team", ":playerteam"), #On Player's side? (agent_get_division, ":class", ":agent"), (agent_get_slot, ":shield_order", ":agent", slot_team_shield_order), (assign, ":possible_shield", 0), #Added to force shield (assign, ":wielded_polearm", 0), #Added for polearm/shield combo (try_begin), #Mark class as in battle (eq, ":class", 0), (assign, ":group0_in_battle", 1), (else_try), (eq, ":class", 1), (assign, ":group1_in_battle", 1), (else_try), (eq, ":class", 2), (assign, ":group2_in_battle", 1), (else_try), (eq, ":class", 3), (assign, ":group3_in_battle", 1), (else_try), (eq, ":class", 4), (assign, ":group4_in_battle", 1), (else_try), (eq, ":class", 5), (assign, ":group5_in_battle", 1), (else_try), (eq, ":class", 6), (assign, ":group6_in_battle", 1), (else_try), (eq, ":class", 7), (assign, ":group7_in_battle", 1), (else_try), (eq, ":class", 8), (assign, ":group8_in_battle", 1), (try_end), (class_is_listening_order, ":team", ":class"), #Is the agent's team selected? (try_begin), #Mark class as selected (eq, ":class", 0), (assign, ":group0_is_selected", 1), (else_try), (eq, ":class", 1), (assign, ":group1_is_selected", 1), (else_try), (eq, ":class", 2), (assign, ":group2_is_selected", 1), (else_try), (eq, ":class", 3), (assign, ":group3_is_selected", 1), (else_try), (eq, ":class", 4), (assign, ":group4_is_selected", 1), (else_try), (eq, ":class", 5), (assign, ":group5_is_selected", 1), (else_try), (eq, ":class", 6), (assign, ":group6_is_selected", 1), (else_try), (eq, ":class", 7), (assign, ":group7_is_selected", 1), (else_try), (eq, ":class", 8), (assign, ":group8_is_selected", 1), (try_end), (agent_get_troop_id, ":troop",":agent"), (try_begin), (troop_is_hero, ":troop"), (assign, ":end", ek_head), (try_for_range, ":i", ek_item_0, ":end"), (troop_get_inventory_slot,":item",":troop",":i"), (gt, ":item", 0), (item_get_type, ":weapontype", ":item"), (try_begin), (eq, ":ordertype", ranged), (str_store_string, s1, "@ready bows and missiles"), (this_or_next|eq, ":weapontype", itp_type_bow), (this_or_next|eq, ":weapontype", itp_type_crossbow), (eq, ":weapontype", itp_type_thrown), (agent_set_wielded_item, ":agent", ":item"), (agent_set_slot, ":agent", slot_team_shield_order, -1), (assign, ":end", ek_item_0),#loop breaker (else_try), (eq, ":ordertype", onehand), (str_store_string, s1, "@ready side arms"), (eq, ":weapontype", itp_type_one_handed_wpn), (agent_set_wielded_item, ":agent", ":item"), (agent_set_slot, ":agent", slot_team_shield_order, 2), (assign, ":end", ek_item_0),#loop breaker (else_try), (eq, ":ordertype", twohands), (str_store_string, s1, "@ready two-hander"), (eq, ":weapontype", itp_type_two_handed_wpn), (agent_set_slot, ":agent", slot_team_shield_order, 2), (agent_set_wielded_item, ":agent", ":item"), (assign, ":end", ek_item_0),#loop breaker (agent_get_wielded_item, ":shield", ":agent", 1), (gt, ":shield", 0), #Has a shield wielded, after equipping 2hander/polearm (agent_unequip_item, ":agent", ":shield"), #Wield weapon with 2 hands, (agent_equip_item, ":agent", ":shield"), #Moves shield to back (else_try), (eq, ":ordertype", polearm), (try_begin), (neq, ":shield_order", 1), #Not ordered to use shields (str_store_string, s1, "@ready polearms"), (eq, ":weapontype", itp_type_polearm), (agent_set_wielded_item, ":agent", ":item"), (assign, ":end", ek_item_0),#loop breaker (else_try), (eq, ":shield_order", 1), #Ordered to use shields (try_begin), (eq, ":wielded_polearm", 0), (str_store_string, s1, "@ready polearms"), (eq, ":weapontype", itp_type_polearm), (agent_set_wielded_item, ":agent", ":item"), (assign, ":wielded_polearm", ":item"), (try_end), (try_begin), (eq, ":weapontype", itp_type_shield), (eq, ":possible_shield", 0), (assign, ":possible_shield", ":item"), (try_end), (gt, ":wielded_polearm", 0), (gt, ":possible_shield", 0), (agent_set_wielded_item, ":agent", ":possible_shield"), (assign, ":end", ek_item_0),#loop breaker (try_end), (else_try), (eq, ":ordertype", shield), #Ordered to use shields (agent_get_wielded_item, ":shield", ":agent", 1), (try_begin), (gt, ":shield", 0), (assign, ":end", ek_item_0),#loop breaker (else_try), (le, ":shield", 0), #No shield currently wielded (eq, ":weapontype", itp_type_shield), (str_store_string, s1, "@shields up"), (assign, ":possible_shield", ":item"), #Track the shield. At end check that shield was actually equipped, force shields (agent_set_wielded_item, ":agent", ":item"), #Moves shield from back to hand (agent_set_slot, ":agent", slot_team_shield_order, 1), (assign, ":end", ek_item_0),#loop breaker (try_end), (else_try), (eq, ":ordertype", noshield), #Ordered to NOT use shields (agent_get_wielded_item, ":shield", ":agent", 1), (gt, ":shield", 0), #Has a shield wielded (item_get_type, ":shield_type", ":shield"), (str_store_string, s1, "@doff shields"), (eq, ":shield_type", itp_type_shield), (agent_unequip_item, ":agent", ":shield"), (agent_set_slot, ":agent", slot_team_shield_order, 0), (agent_equip_item, ":agent", ":shield"), #Moves shield to back (assign, ":end", ek_item_0),#loop breaker (try_end), #Order Type (try_end), (else_try),#regular troops (troop_get_inventory_capacity,":cap",":troop"), (try_for_range, ":i", 0, ":cap"),#(slots < 10)? (troop_get_inventory_slot,":item",":troop",":i"), (gt, ":item", 0), (item_get_type, ":weapontype", ":item"), (try_begin), (eq, ":ordertype", ranged), (str_store_string, s1, "@ready bows and missiles"), (this_or_next|eq, ":weapontype", itp_type_bow), (this_or_next|eq, ":weapontype", itp_type_crossbow), (eq, ":weapontype", itp_type_thrown), (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), (agent_set_slot, ":agent", slot_team_shield_order, -1), (assign, ":cap", 0),#loop breaker (else_try), (eq, ":ordertype", onehand), (str_store_string, s1, "@ready side arms"), (eq, ":weapontype", itp_type_one_handed_wpn), (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), (agent_set_slot, ":agent", slot_team_shield_order, 2), (assign, ":cap", 0),#loop breaker (else_try), (eq, ":ordertype", twohands), (str_store_string, s1, "@ready two-hander"), (eq, ":weapontype", itp_type_two_handed_wpn), (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), (assign, ":cap", 0),#loop breaker (agent_get_wielded_item, ":shield", ":agent", 1), (agent_set_slot, ":agent", slot_team_shield_order, 2), (gt, ":shield", 0), #Has a shield wielded, after equipping 2hander/polearm (agent_unequip_item, ":agent", ":shield"), #Wield weapon with 2 hands, (agent_equip_item, ":agent", ":shield"), #Moves shield to back (else_try), (eq, ":ordertype", polearm), (try_begin), (neq, ":shield_order", 1), #Not ordered to use shields (str_store_string, s1, "@ready polearms"), (eq, ":weapontype", itp_type_polearm), (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), (assign, ":cap", 0),#loop breaker (else_try), (eq, ":shield_order", 1), #Ordered to use shields (try_begin), (eq, ":wielded_polearm", 0), (str_store_string, s1, "@ready polearms"), (eq, ":weapontype", itp_type_polearm), (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), (assign, ":wielded_polearm", ":item"), (try_end), (try_begin), (eq, ":weapontype", itp_type_shield), (eq, ":possible_shield", 0), (assign, ":possible_shield", ":item"), (try_end), (gt, ":wielded_polearm", 0), (gt, ":possible_shield", 0), (agent_set_wielded_item, ":agent", ":possible_shield"), (assign, ":cap", 0),#loop breaker (try_end), (else_try), (eq, ":ordertype", shield), #Ordered to use shields (agent_get_wielded_item, ":shield", ":agent", 1), (try_begin), (gt, ":shield", 0), (assign, ":cap", 0),#loop breaker (else_try), (le, ":shield", 0), #No shield currently wielded (eq, ":weapontype", itp_type_shield), (str_store_string, s1, "@shields up"), (assign, ":possible_shield", ":item"), #Track the shield. At end check that shield was actually equipped, force shields (agent_has_item_equipped, ":agent", ":item"), (agent_set_wielded_item, ":agent", ":item"), #Moves shield from back to hand (agent_set_slot, ":agent", slot_team_shield_order, 1), (assign, ":cap", 0),#loop breaker (try_end), (else_try), (eq, ":ordertype", noshield), #Ordered to NOT use shields (agent_get_wielded_item, ":shield", ":agent", 1), (gt, ":shield", 0), #Has a shield wielded (item_get_type, ":shield_type", ":shield"), (str_store_string, s1, "@doff shields"), (eq, ":shield_type", itp_type_shield), (agent_unequip_item, ":agent", ":shield"), (agent_set_slot, ":agent", slot_team_shield_order, 0), (agent_equip_item, ":agent", ":shield"), #Moves shield to back (assign, ":cap", 0),#loop breaker (try_end), #Order Type (try_end), (try_end), #Hero v Regular Troop (gt, ":possible_shield", 0), #A shield equipped and ordered to use shields (agent_get_wielded_item, ":shield", ":agent", 1), (le, ":shield", 0), #But, no shield currently wielded (assign, ":end", 2), (try_for_range, ":i", 0, ":end"), (agent_get_wielded_item, ":wielded", ":agent", 0), (gt, ":wielded", 0), (agent_unequip_item, ":agent", ":wielded"), (agent_equip_item, ":agent", ":wielded"), #Sheathes weapon (agent_set_wielded_item, ":agent", ":possible_shield"), (try_begin), (eq, ":i", 0), #First time only (gt, ":wielded_polearm", 0), (agent_set_wielded_item, ":agent", ":wielded_polearm"), (try_end), (agent_get_wielded_item, ":shield", ":agent", 1), (gt, ":shield", 0), #If shield equipped (assign, ":end", 0), #Then Break Loop, don't try again (try_end), (try_end), #Agent Loop (str_clear, s2), (str_clear, s3), (assign, ":count_possible", 0), (assign, ":count_selected", 0), (try_begin), (eq, ":group0_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group0_is_selected", 1), (val_add, ":count_selected", 1), (str_store_class_name, s2, 0), (try_end), (try_begin), (eq, ":group1_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group1_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 1), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 1), (try_end), (try_end), (try_begin), (eq, ":group2_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group2_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 2), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 2), (try_end), (try_end), (try_begin), (eq, ":group3_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group3_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 3), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 3), (try_end), (try_end), (try_begin), (eq, ":group4_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group4_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 4), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 4), (try_end), (try_end), (try_begin), (eq, ":group5_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group5_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 5), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 5), (try_end), (try_end), (try_begin), (eq, ":group6_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group6_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 6), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 6), (try_end), (try_end), (try_begin), (eq, ":group7_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group7_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 7), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 7), (try_end), (try_end), (try_begin), (eq, ":group8_in_battle", 1), (val_add, ":count_possible", 1), (eq, ":group8_is_selected", 1), (val_add, ":count_selected", 1), (try_begin), (neg|str_is_empty, s2), (str_store_class_name, s3, 8), (str_store_string, s2, "@{!}{s2}, {s3}"), (else_try), (str_store_class_name, s2, 8), (try_end), (try_end), (try_begin), (eq, ":count_selected", ":count_possible"), (str_store_string, s2, "@Everyone"), (try_end), (try_begin), (gt, ":count_selected", 0), (display_message, "@{!}{s2}, {s1}!", 0xFFDDDD66), (try_end), (str_clear, s2), (str_clear, s3), ]), ## Pointer # script_iterate_pointer_arrow # Input: none # Output: none ("iterate_pointer_arrow", [ (store_mission_timer_a_msec, ":cur_time"), (try_begin), (assign, ":up_down", ":cur_time"), (assign, ":turn_around", ":cur_time"), (val_mod, ":up_down", 1080), (val_div, ":up_down", 3), (scene_prop_get_instance, ":prop_instance", "spr_pointer_arrow", 0), (prop_instance_get_position, pos0, ":prop_instance"), (position_set_z_to_ground_level, pos0), (position_move_z, pos0, "$g_pointer_arrow_height_adder", 1), (set_fixed_point_multiplier, 100), (val_mul, ":up_down", 100), (store_sin, ":up_down_sin", ":up_down"), (position_move_z, pos0, ":up_down_sin", 1), (position_move_z, pos0, 100, 1), (val_mod, ":turn_around", 2880), (val_div, ":turn_around", 8), (init_position, pos1), (position_rotate_z, pos1, ":turn_around"), (position_copy_rotation, pos0, pos1), (prop_instance_set_position, ":prop_instance", pos0), (try_end), ]), ## Batching Process ("cf_batching_ti_agent_spawn_human", [ (store_trigger_param, ":agent", 1), (agent_is_active, ":agent"), (agent_is_human, ":agent"), (store_mission_timer_a_msec, ":time"), (store_random_in_range, ":check_time", 0, 100),#randomize check time within 0.1 sec (val_add, ":check_time", ":time"), (agent_set_slot, ":agent", slot_agent_tick_check_time, ":check_time"), (store_random_in_range, ":check_time", 0, "$batching_check_period"),#randomize reset time (val_add, ":check_time", ":time"), (agent_set_slot, ":agent", slot_agent_period_reset_time, ":check_time"), ]), ("cf_batching_ti_agent_spawn_mount", [ (store_trigger_param, ":agent", 1), (agent_is_active, ":agent"), (neg|agent_is_human, ":agent"), #Mount (store_mission_timer_a_msec, ":time"), (store_random_in_range, ":check_time", 0, 100),#randomize check time within 0.1 sec (val_add, ":check_time", ":time"), (agent_set_slot, ":agent", slot_agent_tick_check_time, ":check_time"), (store_random_in_range, ":check_time", 0, "$batching_check_period"),#randomize reset time (val_add, ":check_time", ":time"), (agent_set_slot, ":agent", slot_agent_period_reset_time, ":check_time"), ]), # script_cf_get_nearest_bandit_party # Input: none # Output: First bandit party that is closer than 75 units of distance to the player # If no party is available, returns distance = -1 # reg0 - party_id # reg1 - party_template # reg2 - distance ("cf_get_nearest_bandit_party", [ (assign, ":found", 0), (try_for_parties, ":nearest_bandit_party"), (eq, ":found", 0), (party_is_active, ":nearest_bandit_party"), (party_slot_eq, ":nearest_bandit_party", slot_party_type, spt_bandit), (party_get_template_id, ":party_template", ":nearest_bandit_party"), (neq, ":party_template", "pt_deserters"), #not deserter troops (call_script, "script_get_tld_distance", "p_main_party", ":nearest_bandit_party"), (assign, ":dist", reg0), (le, ":dist", 75), (call_script, "script_party_count_fit_for_battle", ":nearest_bandit_party"), (gt, reg0, 0), (party_stack_get_troop_id, ":troop", ":nearest_bandit_party", 0), (assign, ":found", 1), #Debug (try_begin), (eq, "$cheat_mode", 1), (str_store_party_name, s11, ":nearest_bandit_party"), (str_store_troop_name, s12, ":troop"), (assign, reg70, ":dist"), (display_message, "@Distance - {reg70} - {s11} Party - {s12} Troop"), (try_end), (try_end), (try_begin), (eq, ":found", 1), (assign, reg0, ":troop"), (assign, reg1, ":party_template"), (assign, reg2, ":dist"), (else_try), (assign, reg2, -1), (try_end), ]), # script_cf_init_kill_quest_bandit # qst_blank_quest_17 ("cf_init_kill_quest_bandit", [ (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", 2), (call_script, "script_cf_get_nearest_bandit_party"), (ge, reg2, 0), # reg2 holds the distance to the bandit party (assign, ":target_troop", reg0), (assign, ":target_template", reg1), (store_random_in_range, ":amount", 15, 26), (val_add, ":amount", ":player_level"), (store_mul, ":xp_reward", ":amount", 4), #min. 68-104 (store_add, ":gold_reward", ":xp_reward", 40), #min. 108-144 (store_div, ":rank_reward", ":xp_reward", 10), #min. 6-11 #(val_min, ":rank_reward", 10), (store_div, ":exp", ":amount", 3), #min 5-8 (val_add, ":exp", 7), #min 12-15 (assign, reg55, "$g_talk_troop"), #quest_object_troop (assign, reg56, ":target_troop"), #quest_target_troop (assign, reg57, ":amount"), #quest_target_amount (assign, reg58, 3), #quest_importance (assign, reg59, ":xp_reward"), #quest_xp_reward (assign, reg60, ":gold_reward"), #quest_gold_reward (assign, reg61, ":rank_reward"), #quest_rank_reward (assign, reg62, ":exp"), #quest_expiration_days (assign, reg63, 10), #quest_dont_give_again_period (assign, reg64, ":target_template"), #quest_target_party_template ]), # script_cf_init_defeat_lord_quest #qst_blank_quest_06 ("cf_init_defeat_lord_quest", [ (store_character_level, ":player_level", "trp_player"), (ge, ":player_level", 18), (store_faction_of_troop, ":quest_giver_faction", "$g_talk_troop"), (call_script, "script_cf_find_target_patrolling_enemy_lord_in_theater", ":quest_giver_faction"), (assign, ":target_lord", reg0), (assign, ":xp_reward", 150), (assign, ":gold_reward", 350), (assign, ":rank_reward", 55), (assign, ":exp", 30), (assign, reg55, "$g_talk_troop"), #quest_object_troop (assign, reg56, ":target_lord"), #quest_target_troop (assign, reg58, 8), #quest_importance (assign, reg59, ":xp_reward"), #quest_xp_reward (assign, reg60, ":gold_reward"), #quest_gold_reward (assign, reg61, ":rank_reward"), #quest_rank_reward (assign, reg62, ":exp"), #quest_expiration_days (assign, reg63, 10), #quest_dont_give_again_period ]), # script_cf_find_target_patrolling_lord ("cf_find_target_patrolling_enemy_lord", [ (assign, ":lord_found", 0), (try_for_range, ":lords", kingdom_heroes_begin, kingdom_heroes_end), (eq, ":lord_found", 0), (neg|troop_slot_eq, ":lords", slot_troop_wound_mask, wound_death), #not dead (call_script, "script_cf_fails_if_sitting_king", ":lords"), #fail if sitting king (troop_get_slot, ":party", ":lords", slot_troop_leaded_party), (gt, ":party", 0), (party_is_active, ":party"), (party_slot_eq, ":party", slot_party_type, spt_kingdom_hero_party), #Has a host (party_get_slot, ":action", ":party", slot_party_ai_state), (neq, ":action", spai_besieging_center), (neq, ":action", spai_accompanying_army), (neq, ":action", spai_holding_center), (store_troop_faction, ":fac", ":lords"), (store_relation, ":rel", "$players_kingdom", ":fac"), (lt, ":rel", 0), #enemies (assign, ":lord_found", 1), # Debug (str_store_troop_name, s70, ":lords"), (display_message, "@{s70} target found"), (assign, reg0, ":lords"), (try_end), (gt, reg0, 0), ]), # script_cf_find_target_patrolling_enemy_lord_in_theater ("cf_find_target_patrolling_enemy_lord_in_theater", [ (store_script_param_1, ":quest_giver_faction"), (call_script, "script_cf_find_target_patrolling_enemy_lord"), (assign, ":target_lord", reg0), (store_troop_faction, ":enemy_fac", ":target_lord"), (faction_get_slot, ":enemy_fac_active_theater", ":enemy_fac", slot_faction_active_theater), (faction_get_slot, ":quest_giver_active_theater", ":quest_giver_faction", slot_faction_active_theater), (eq, ":enemy_fac_active_theater", ":quest_giver_active_theater"), #Target Lord in Active Theater (assign, reg0, ":target_lord"), (gt, reg0, 0), ]), ("clone_troop", [ (store_script_param_1, ":troop_to_clone"), (store_script_param_2, ":troop_clone"), # Clone level and xp #Clone face (str_store_troop_face_keys, s22, ":troop_to_clone"), (troop_set_face_keys, ":troop_clone", s22), # Clone Faction (store_troop_faction, ":fac", ":troop_to_clone"), (troop_set_faction, ":troop_clone", ":fac"), # Clone Race (troop_get_type,":race",":troop_to_clone"), (try_begin), (this_or_next|is_between, ":race", tf_orc_begin,tf_orc_end), (this_or_next|is_between, ":race", tf_elf_begin,tf_elf_end), (eq, ":race", tf_dwarf), (troop_set_type,":troop_clone",":race"), (try_end), # Clone gear (troop_clear_inventory, ":troop_clone"), (troop_get_inventory_capacity, ":slots", ":troop_clone"), (try_for_range, ":i", 0, ":slots"), (troop_set_inventory_slot, ":troop_clone", ":i", -1), (troop_set_inventory_slot_modifier, ":troop_clone", ":i", 0), (try_end), (troop_set_auto_equip, ":troop_clone", 1), (try_for_range, ":i", 0, ":slots"), (troop_get_inventory_slot, ":item_id", ":troop_to_clone", ":i"), (neq, ":item_id", -1), (troop_get_inventory_slot_modifier, ":item_imod", ":troop_to_clone", ":i"), (troop_set_inventory_slot, ":troop_clone", ":i", ":item_id"), (troop_set_inventory_slot_modifier, ":troop_clone", ":i", ":item_imod"), (try_end), # Clone Stats # Attrib (try_for_range, ":i", 0, 4), (store_attribute_level, ":x",":troop_to_clone",":i"), (troop_raise_attribute, ":troop_clone",":i",-1000), (troop_raise_attribute, ":troop_clone",":i",":x"), #(assign, reg10, ":x"),(assign, reg11, ":i"),(display_message, "@Rising skill {reg11} to {reg10}"), (try_end), # Skills (assign, "$disable_skill_modifiers", 1), (try_for_range, ":i", 0, 38 ), (store_skill_level, ":x", ":i", ":troop_to_clone"), (troop_raise_skill, ":troop_clone",":i",-1000), (troop_raise_skill, ":troop_clone",":i",":x"), (try_end), (assign, "$disable_skill_modifiers", 0), # copy stats: proficienceis (try_for_range, ":i", 0, 6), (store_proficiency_level, ":x", ":i", ":troop_to_clone"), (troop_raise_proficiency, ":troop_clone",":i",-1000), #(val_div, ":x", 4), # weapon proficiencies are too high! #(val_min, ":x", 60), (troop_raise_proficiency, ":troop_clone",":i",":x"), (try_end), ]), ("cf_get_custom_armor_ranges", [ (store_script_param_1, ":troop_id"), (store_script_param_2, ":item_id"), (troop_get_inventory_slot_modifier, ":imod", ":troop_id", ek_body), (gt, ":imod", 0), (try_begin), (eq, ":imod", imod_powerful), (eq, ":item_id", "itm_white_tunic_a"), (assign, reg0, "str_dale_coat"), (assign, reg1, "str_tld_wear"), (else_try), (eq, ":imod", imod_fresh), (eq, ":item_id", "itm_white_tunic_a"), (assign, reg0, "str_tld_wear"), (assign, reg1, "str_dale_coat_end"), (try_end), ]), ("set_mordor_cloud_scene_prop", [ (get_player_agent_no, ":player"), (agent_get_position, pos23, ":player"), (set_spawn_position, pos23), (spawn_scene_prop, "spr_mordor_clouds_3", 0), (assign, ":mordor_clouds", reg0), (set_fixed_point_multiplier, 10), (prop_instance_set_scale, ":mordor_clouds", 500,500,500), (display_message, "@Mordor Cloud Spawned"),]), ("lorien_mist_effect", [ (get_player_agent_no, ":player"), (agent_get_team, ":player_team", ":player"), (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), (try_for_agents, ":agent"), (agent_is_active, ":agent"), (agent_is_alive, ":agent"), (agent_get_team, ":agent_team", ":agent"), (try_begin), (eq, ":player_side", faction_side_good), #If Good (try_begin), (eq, ":agent_team", ":player_team"), (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_BUFF), (agent_set_reload_speed_modifier, ":agent", RANGED_RELOAD_SPEED_BUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A golden mist from Lórien covers the battlefield. Your troops feel encouraged by the presence of the Lady.", color_neutral_news), (try_end), (else_try), (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), (agent_set_reload_speed_modifier, ":agent", RANGED_RELOAD_SPEED_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A golden mist from Lórien covers the battlefield. The witch is near, sending shivers down you and your troops' spine.", color_neutral_news), (try_end), (try_end), (else_try), #If Player is Evil (eq, ":agent_team", ":player_team"), #And agent is in player's team (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), (agent_set_reload_speed_modifier, ":agent", RANGED_RELOAD_SPEED_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A golden mist from Lórien covers the battlefield. The witch is near, sending shivers down you and your troops' spine.", color_neutral_news), (try_end), (else_try), #If Player is Evil (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_BUFF), #and agent is not in player's team, they must be good. (agent_set_reload_speed_modifier, ":agent", RANGED_RELOAD_SPEED_BUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A golden mist from Lórien covers the battlefield. Your troops feel encouraged by the presence of the Lady.", color_neutral_news), (try_end), (try_end), (try_end), ]), ("sauron_darkness_effect", [ (get_player_agent_no, ":player"), (agent_get_team, ":player_team", ":player"), (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), (try_for_agents, ":agent"), (agent_is_active, ":agent"), (agent_is_alive, ":agent"), (agent_get_team, ":agent_team", ":agent"), (try_begin), (eq, ":player_side", faction_side_good), #If Good (try_begin), (eq, ":agent_team", ":player_team"), (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), (agent_set_reload_speed_modifier, ":agent", RANGED_RELOAD_SPEED_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@Dark clouds from Mordor cover the battlefield. Your archers have trouble seeing the enemy, and the presence of evil terrifies your men.", color_neutral_news), (try_end), (else_try), (agent_set_damage_modifier, ":agent", WEAPON_DAMAGE_BUFF), (agent_set_speed_modifier, ":agent", SPEED_BUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@Dark clouds from Mordor cover the battlefield. The Dark Lord's presence strengthens you and your men.", color_neutral_news), (try_end), (try_end), (else_try), #If Player is Evil (eq, ":agent_team", ":player_team"), #And agent is in player's team (agent_set_damage_modifier, ":agent", WEAPON_DAMAGE_BUFF), (agent_set_speed_modifier, ":agent", SPEED_BUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@Dark clouds from Mordor cover the battlefield. The Dark Lord's presence strengthens you and your men.", color_neutral_news), (try_end), (else_try), #If Player is Evil (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), #and agent is not in player's team, they must be good. (agent_set_reload_speed_modifier, ":agent", RANGED_RELOAD_SPEED_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@Dark clouds from Mordor cover the battlefield. Your archers have trouble seeing the enemy, and the presence of evil terrifies your men.", color_neutral_news), (try_end), (try_end), (try_end), ]), ("saruman_storm_effect", [ (get_player_agent_no, ":player"), (agent_get_team, ":player_team", ":player"), (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), (try_for_agents, ":agent"), (agent_is_active, ":agent"), (agent_is_alive, ":agent"), (agent_get_team, ":agent_team", ":agent"), (try_begin), (eq, ":player_side", faction_side_good), #If Good (try_begin), (eq, ":agent_team", ":player_team"), (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), (agent_set_speed_modifier, ":agent", SPEED_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A thunderstorm from the Misty Mountains rages over the battlefield. Your troops are slowed down, and the superstitious amongst the men feel scared.", color_neutral_news), (try_end), (else_try), (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A thunderstorm from the Misty Mountains rages over the battlefield. Archers have difficulty in this weather.", color_neutral_news), (try_end), (try_end), (else_try), #If Player is Evil (eq, ":agent_team", ":player_team"), #And agent is in player's team (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A thunderstorm from the Misty Mountains rages over the battlefield. Archers have difficulty in this weather.", color_neutral_news), (try_end), (else_try), #If Player is Evil (agent_set_accuracy_modifier, ":agent", RANGED_ACCURACY_DEBUFF), #and agent is not in player's team, they must be good. (agent_set_speed_modifier, ":agent", SPEED_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A thunderstorm from the Misty Mountains rages over the battlefield. Your troops are slowed down, and the superstitious amongst the men feel scared.", color_neutral_news), (try_end), (try_end), (try_end), ]), ("guldur_fog_effect", [ (get_player_agent_no, ":player"), (agent_get_team, ":player_team", ":player"), (faction_get_slot, ":player_side", "$players_kingdom", slot_faction_side), (try_for_agents, ":agent"), (agent_is_active, ":agent"), (agent_is_alive, ":agent"), (agent_get_team, ":agent_team", ":agent"), (try_begin), (eq, ":player_side", faction_side_good), #If Good (try_begin), (eq, ":agent_team", ":player_team"), (agent_set_max_hit_points, ":agent", MAX_HEALTH_DEBUFF), (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A poisonous fog from Dol Guldur lingers on the battlefield. You and your troops feel weakened. There is fear amongst the men.", color_neutral_news), (try_end), (try_end), (else_try), #If Player is Evil (eq, ":agent_team", ":player_team"), #And agent is in player's team # Do nothing (try_begin), #DEBUG (eq, ":agent", ":player"), (display_message, "@A poisonous fog from Dol Guldur lingers on the battlefield. You do not feel any different, but you hear your enemies suffer and you can smell their fear.", color_neutral_news), (try_end), (else_try), #If Player is Evil (agent_set_max_hit_points, ":agent", MAX_HEALTH_DEBUFF), #and agent is not in player's team, they must be good. (try_end), (try_end), ]), #script_agent_reassign_team # INPUT: arg1 = agent_no # OUTPUT: none ("agent_reassign_team", [ (store_script_param, ":agent_no", 1), (get_player_agent_no, ":player_agent"), (try_begin), (ge, ":player_agent", 0), (agent_is_human, ":agent_no"), (agent_is_ally, ":agent_no"), (agent_get_party_id, ":party_no", ":agent_no"), (neq, ":party_no", "p_main_party"), (assign, ":continue", 1), (store_faction_of_party, ":party_faction", ":party_no"), (try_begin), (eq, ":party_faction", "$players_kingdom"), (is_between, "$players_kingdom", kingdoms_begin, kingdoms_end), (faction_slot_eq, "$players_kingdom", slot_faction_marshall, "trp_player"), (assign, ":continue", 0), (else_try), (party_stack_get_troop_id, ":leader_troop_id", ":party_no", 0), (neg|is_between, ":leader_troop_id", "trp_npc1", "trp_smith_mtirith"), (assign, ":continue", 0), (try_end), (eq, ":continue", 1), (agent_get_team, ":player_team", ":player_agent"), (val_add, ":player_team", 2), (agent_set_team, ":agent_no", ":player_team"), (try_end), ]), #tld_internal_set_good_or_evil_ui (Warband-only) # INPUT: none # OUTPUT: none ("tld_internal_set_good_or_evil_ui", [ (set_fixed_point_multiplier, 100), ] + (is_a_wb_script==1 and [ #swy-- WB: skin the global interface elements on Warband via shader uniform depending on the allegiance of the player, # the UI materials should use the swy_tld_ui_evil_mixing or swy_tld_hp_overlay shaders, # use the 'diffuse' texture for good and the 'diffuse2' slot for evil. (try_begin), (faction_slot_eq, "$players_kingdom", slot_faction_side, faction_side_good), (set_shader_param_float, "@swy_ui_evil", 0), (else_try), (set_shader_param_float, "@swy_ui_evil", 100), # = 1.0 (try_end), #swy-- ] or []) + [ ]), #tld_internal_set_river_color_tinting (Warband-only) # INPUT: arg1 = the custom water multiplier is enabled or not # INPUT: arg2 = red color, in fixed-point format # INPUT: arg3 = green color, in fixed-point format # INPUT: arg4 = blue color, in fixed-point format # OUTPUT: none ("tld_internal_set_river_color_tinting", [ (set_fixed_point_multiplier, 1e6), # swy: six zeros, change it accordingly: 1000000 => 0.005 * 1e6 = 5000.0 => use 5000 as your variable (we can't use floating point numbers in the game .txt interpreter, only in the Python/msys part) ] + (is_a_wb_script==1 and [ (store_script_param_1, ":enabled"), (store_script_param_2, ":r"), (store_script_param, ":g", 3), (store_script_param, ":b", 4), # swy: here are some (hopefully) useful examples: # |RED |GREEN |BLUE # dark brown: 0.01f, 0.002f, 0.002f -> (call_script, "script_tld_internal_set_river_color_tinting", True, int(0.01 * 1e6), int(0.002 * 1e6), int(0.002 * 1e6)), # original mud color: 0.022f, 0.02f, 0.005f -> (call_script, "script_tld_internal_set_river_color_tinting", True, int(0.022 * 1e6), int(0.02 * 1e6), int(0.005 * 1e6)), # disable this thingie: any any any -> (call_script, "script_tld_internal_set_river_color_tinting", False, 0, 0, 0), (set_shader_param_float4, "@swy_river_tinting_color", ":r", ":g", ":b", ":enabled"), # the alpha slot is used for the enablement conditional #swy-- note: by default/at startup this 'swy_river_tinting_color' uniform is set to float4(-1.f, -1.f, -1.f, -1.f); # keep in mind that you can use the river_mud effect (or not) with this, it works independently. ] or []) + [ ]), ("flash_and_animate", [ (store_script_param_1, ":agent"), (store_script_param_2, ":colour"), (try_begin), (eq, ":colour", 1), (mission_cam_set_screen_color, 0xFFFFFFFF), (mission_cam_animate_to_screen_color, 0x00000000, 5000), (else_try), (mission_cam_set_screen_color, 0xFF000000), (mission_cam_animate_to_screen_color, 0x00000000, 5000), (try_end), (agent_get_horse, ":horse", ":agent"), (try_begin), (ge, ":horse", 0), (agent_set_animation, ":agent", "anim_defend_up_onehanded_keep"), (else_try), (agent_set_animation, ":agent", "anim_defend_up_onehanded_keep", 1), (try_end), ]), ("get_position_and_teleport_behind_agent", [ (store_script_param, ":target_agent", 1), (store_script_param, ":teleport_agent",2), (store_script_param, ":distance", 3), (val_mul, ":distance", -1), (agent_get_look_position, pos3, ":target_agent"), (position_move_y, pos3, ":distance"), #(position_rotate_z, pos3, 180), (position_set_z_to_ground_level, pos3), (agent_set_position, ":teleport_agent", pos3), ]), ("wield_agent_weapons", [ (store_script_param_1, ":agent"), (agent_get_troop_id, ":troop", ":agent"), (assign, ":found", 0), (try_for_range, ":weapons", ek_item_0, ek_head), (eq, ":found", 0), (troop_get_inventory_slot, ":to_wield", ":troop", ":weapons"), (gt, ":to_wield", 0), (item_get_type, ":type", ":to_wield"), (this_or_next|eq,":type", itp_type_one_handed_wpn), (this_or_next|eq,":type", itp_type_two_handed_wpn), (eq, ":type", itp_type_polearm), (agent_set_wielded_item, ":agent", ":to_wield"), (assign, ":found", 1), (try_end), (assign, ":found_2", 0), (try_for_range, ":weapons", ek_item_0, ek_head), (eq, ":found_2", 0), (troop_get_inventory_slot, ":to_wield", "trp_player", ":weapons"), (gt, ":to_wield", 0), (item_get_type, ":type", ":to_wield"), (eq, ":type", itp_type_shield), (agent_set_wielded_item, ":agent", ":to_wield"), (assign, ":found_2", 1), (try_end), ]), #script_cf_surrounded_pushback ("cf_surrounded_pushback", [ (store_script_param_1, ":agent"),\ (store_script_param_2, ":step"), (agent_get_position, pos69, ":agent"), #(agent_get_team, ":agent_team", ":agent"), (set_fixed_point_multiplier, 100), (agent_slot_eq, ":agent", slot_troll_agent_charging, 0), #troll should not be charging (assign, ":counter", 0), (try_begin), (eq, ":step", 1), (try_for_agents, ":count", pos69, 400), (neq, ":count", ":agent"), (agent_is_alive, ":count"), (agent_is_active, ":count"), (agent_is_human, ":count"), (gt, ":count", 0), #(agent_get_team, ":count_team", ":count"), #trolls also react against friendly troops, keep your distance! #(teams_are_enemies, ":count_team", ":agent_team"), #(neq, ":count_team", ":agent_team"), (agent_get_troop_id, ":troop_id", ":count"), (troop_get_type, ":race", ":troop_id"), #(neq, ":race", tf_troll), (try_begin), (eq, ":race", tf_troll), (val_sub, ":counter", 15), #pushback is less probable if another troll is around #(display_message, "@troll counted: minus 4"), (try_end), (neg|is_between, ":troop_id", warg_ghost_begin, warg_ghost_end), (neg|is_between, ":troop_id", "trp_spider", "trp_dorwinion_sack"), (neq, ":troop_id", "trp_werewolf"), (val_add, ":counter", 1), (assign, reg78, ":counter"), #(display_message, "@counter: {reg78}"), (try_end), #Debug: #(assign, reg77, ":counter"), #(display_message, "@{reg77} agents nearby", color_bad_news), #(ge, ":counter", 4), #when surrounded by 4 enemies (store_random_in_range, ":pushback_chance", 0, 20), #actually, let's make it slightly random: 10% pushback chance per troop in range (ge, ":counter", ":pushback_chance"), (agent_set_animation, ":agent", "anim_troll_pushback"), (agent_play_sound, ":agent", "snd_troll_yell"), (agent_set_slot, ":agent", slot_agent_troll_swing_status, 1), (store_mission_timer_a_msec, ":timer"), #Debug: # (assign, reg78, ":timer"), # (display_message, "@{reg78} - ready Time", color_good_news), (store_random_in_range, ":rand_timing", 800, 1200), #avoid simultaneous pushbacks (val_add, ":timer", ":rand_timing"), (val_div, ":rand_timing", 200), (agent_set_animation_progress, ":agent", ":rand_timing"), # (assign, reg78, ":timer"), # (display_message, "@{reg78} - minimal hit Time", color_good_news), (agent_set_slot, ":agent", slot_agent_troll_swing_move, ":timer"), (else_try), (eq, ":step", 2), (agent_slot_eq, ":agent", slot_agent_troll_swing_status, 1), (store_mission_timer_a_msec, ":timer_2"), #(agent_slot_ge, ":agent", slot_agent_troll_swing_move, ":timer_2"), (agent_get_slot, ":hit_timer", ":agent", slot_agent_troll_swing_move), (ge, ":timer_2", ":hit_timer"), # (assign, reg78, ":timer_2"), # (display_message, "@{reg78} - actual hit Time", color_good_news), (try_for_agents, ":nearby", pos69, 400), (neq, ":nearby", ":agent"), (agent_is_alive, ":nearby"), (agent_is_active, ":nearby"), (agent_is_human, ":nearby"), (gt, ":nearby", 0), (agent_get_troop_id, ":enemy_troop_id", ":nearby"), (troop_get_type, ":race", ":enemy_troop_id"), (neq, ":race", tf_troll), (neg|is_between, ":enemy_troop_id", warg_ghost_begin, warg_ghost_end), (neg|is_between, ":enemy_troop_id", "trp_spider", "trp_dorwinion_sack"), (neq, ":enemy_troop_id", "trp_werewolf"), (agent_get_horse, ":target_horse", ":nearby"), (try_begin), (lt, ":target_horse", 0), (assign, ":hit_anim", "anim_strike_fly_back_rise"), (else_try), (gt, ":target_horse", 0), (assign, ":hit_anim", "anim_strike_fly_back_rise"), (agent_start_running_away, ":target_horse"), (agent_stop_running_away, ":target_horse"), (try_end), (agent_set_animation, ":nearby", ":hit_anim"), #(set_fixed_point_multiplier, 1), (store_random_in_range,":random_timings",100,500), #fixed point multiplier needs to stay 100 in this loop (agent_set_animation_progress, ":nearby", ":random_timings"), # differentiate timings a bit (store_random_in_range, ":rand_sound", 0, 6), (try_begin), (eq, ":rand_sound", 0), (agent_play_sound, ":agent", "snd_wooden_hit_low_armor_low_damage"), #play sound from troll, not victim, to prevent sound overflow. (else_try), (eq, ":rand_sound", 1), (agent_play_sound, ":agent", "snd_wooden_hit_low_armor_high_damage"), (else_try), (eq, ":rand_sound", 2), (agent_play_sound, ":agent", "snd_wooden_hit_high_armor_low_damage"), (else_try), (eq, ":rand_sound", 3), (agent_play_sound, ":agent", "snd_wooden_hit_high_armor_low_damage"), (else_try), (eq, ":rand_sound", 4), (agent_play_sound, ":agent", "snd_wooden_hit_high_armor_high_damage"), (else_try), (agent_play_sound, ":agent", "snd_blunt_hit"), (try_end), (try_end), (agent_set_slot, ":agent", slot_agent_troll_swing_status, 0), (try_end), ]), #script_aoe_pushback #copied from troll code #input: pos69 ("aoe_pushback", [ (store_script_param_1, ":damage"), (store_script_param_2, ":area"), (set_fixed_point_multiplier, 100), (try_for_agents, ":nearby", pos69, ":area"), (agent_is_alive, ":nearby"), (agent_is_active, ":nearby"), (agent_is_human, ":nearby"), (gt, ":nearby", 0), (agent_get_troop_id, ":enemy_troop_id", ":nearby"), (troop_get_type, ":race", ":enemy_troop_id"), (neq, ":race", tf_troll), (neg|is_between, ":enemy_troop_id", warg_ghost_begin, warg_ghost_end), (neg|is_between, ":enemy_troop_id", "trp_spider", "trp_dorwinion_sack"), (neq, ":enemy_troop_id", "trp_werewolf"), (agent_get_horse, ":target_horse", ":nearby"), (try_begin), (lt, ":target_horse", 0), (assign, ":hit_anim", "anim_strike_fly_back_rise"), (else_try), (gt, ":target_horse", 0), (assign, ":hit_anim", "anim_strike_fly_back_rise"), (agent_start_running_away, ":target_horse"), (agent_stop_running_away, ":target_horse"), (try_end), (agent_set_animation, ":nearby", ":hit_anim"), (str_store_agent_name, s2, ":nearby"), (display_message, "@{s2} attacked"), (agent_deliver_damage_to_agent, ":nearby", ":nearby", ":damage", "itm_troll_aoe"), (try_end), (store_random_in_range,":random_timings",10,50), (agent_set_animation_progress, ":nearby", ":random_timings"), # differentiate timings a bit (store_random_in_range, ":rand_sound", 0, 3), (store_add, ":sound", ":rand_sound", "snd_wooden_hit_low_armor_low_damage"), (play_sound_at_position, ":sound", pos69), ]), #Beornign shapeshifter related mechanics starts here ] + (is_a_wb_script==1 and [ # script_cf_select_bear_form # inputs: None # outputs: None ("cf_select_bear_form", [ (try_begin), # Use the troop slot to remember that player troop morphed to suit the (assign, ":bear_troop", "trp_multiplayer_profile_troop_male"), (troop_set_slot, "trp_player", slot_troop_player_clone, ":bear_troop"), # Proper name and set the shit (str_store_troop_name, s3, "trp_player"), (troop_set_name, ":bear_troop", s3), # Setup race and faction (troop_get_type, ":race", "trp_player"), (troop_set_type,":bear_troop", ":race"), (store_troop_faction, ":fac", "trp_player"), (troop_set_faction, ":bear_troop", ":fac"), # Copy player's xp to bear's (troop_get_xp, ":diff_xp", "trp_player"), (troop_get_xp, ":bear_xp", ":bear_troop"), # Get the difference and add to other troop # NOTE This is hack somehow u can't grant TOO much xp at once (val_sub, ":diff_xp", ":bear_xp"), (store_div, ":n", ":diff_xp", 1000), (store_mod, ":r", ":diff_xp", 1000), (try_for_range, ":unused", 0, ":n"), (add_xp_to_troop, 1000, ":bear_troop"), (end_try), (add_xp_to_troop, ":r", ":bear_troop"), # Clone player into multiplayer something (call_script, "script_clone_troop", "trp_player", ":bear_troop"), # DOESN"T WORK! (troop_raise_skill, ":bear_troop", skl_riding, 10), (troop_set_inventory_slot, ":bear_troop", ek_horse, "itm_bear"), # Transform hp between player troop and player copy # NOTE this doesn't touch the bear agent (horse) # NOTE 2 Health is relative (store_troop_health, ":bear_hp", "trp_player", 0), (troop_set_health, ":bear_troop", ":bear_hp"), # The last piece is in mission module triggers (display_log_message, "@You shapeshift into a bear!", color_neutral_news), (end_try), ]), # script_select_human_form # This script should be called before the mission, or after it. # The current player troop should have correctly computed health # NOTE: This operation work on troops, the current in-battle represenation is not # important, rather what matter if current_player troop is bear or human # Input: relative health of bear troop at the moment # Output: None ("cf_select_human_form", [ (assign, ":bear_troop", "trp_multiplayer_profile_troop_male"), # constant (assign, ":bear_hp", 0), # If we are still in bear form get current bear HP otherwise, get bear troop hp (get_player_agent_no, ":agent"), (try_begin), (ge, ":agent", 0), (agent_get_horse, ":bear" ,":agent"), (ge, ":bear", 0), (agent_is_alive, ":bear"), (agent_is_active, ":bear"), (store_agent_hit_points, ":bear_hp", ":bear", 0), #(display_log_message, "@DEBUG BEAR HP CASE"), (else_try), (ge, ":agent", 0), (agent_is_active, ":agent"), (store_agent_hit_points, ":bear_hp", ":agent", 0), #(display_log_message, "@DEBUG HUMAN CASE"), (else_try), (store_troop_health, ":bear_hp", ":bear_troop", 0), (end_try), #(assign, reg22, ":bear_hp"), #(display_log_message, "@DEBUG Selecting human form & setting hp: {reg22} "), (try_begin), (troop_slot_eq, "trp_player", slot_troop_player_clone, ":bear_troop"), # Remember hp and xp (troop_get_xp, ":bear_xp", ":bear_troop"), (troop_get_xp, ":player_xp", "trp_player"), # Get the difference (val_sub, ":bear_xp", ":player_xp"), # Get back xp earned as bear (assign, reg1, ":bear_xp"), (display_message, "@You got {reg1} experience in bear form."), (add_xp_to_troop, ":bear_xp", "trp_player"), # Reset the slot (troop_set_health, ":bear_troop", ":bear_hp"), (troop_set_health, "trp_player", ":bear_hp"), (set_player_troop, "trp_player"), (troop_set_slot, "trp_player", slot_troop_player_clone, "$g_player_troop"), (try_end), # Reset camera (try_begin), (eq, "$cam_mode", 4), (assign, "$cam_mode", 0), (end_try), ]), # script_bear_attack_no_anim # This script should be called in mission with a specific cooldown # Input: arg1 = agent_no (attacker) # arg2 = base_dmg # arg3 = attack_anim # OUTPUT: none ('bear_attack_no_anim', [ (store_script_param, ":agent_no", 1), (store_script_param, ":base_dmg", 2), (store_script_param, ":attack_anim", 3), # Set defender animation depending on attack type and increase damge (assign, ":max_distance", 300), (agent_get_horse, ":bear", ":agent_no"), (agent_get_position, pos6, ":bear"), (set_fixed_point_multiplier, 100), (position_move_z, pos6, 50, 0), # Attack center is slightly over the ground # Setup attacker position offsets and "fake" attack weapon for different anims (assign, ":attack_item", "itm_beorn_axe"), (try_begin), (eq, ":attack_anim", "anim_bear_slap_right"), #(display_log_message, "@BEAR Attacked with paw slap!"), (val_add, ":base_dmg", 7), (assign, ":fly_anim_base", "anim_strike_fly_back"), (else_try), (eq, ":attack_anim", "anim_bear_uppercut"), #(display_log_message, "@BEAR Attacked with uppercut!"), (val_add, ":base_dmg", 5), (assign, ":fly_anim_base", "anim_strike_fly_back_rise_from_left"), # Hit is from left (else_try), (eq, ":attack_anim", "anim_warg_leapattack"), #(display_log_message, "@BEAR Attacked with leap!"), (assign, ":fly_anim_base", "anim_strike_fly_back"), # Hit is from left # Adjust from where the attack occurs (move in local frame of ref) (position_move_y, pos6, -100, 0), (assign, ":max_distance", 450), (assign, ":attack_item", "itm_beorn_axe_reward"), (else_try), (eq, ":attack_anim", "anim_bear_slam"), (assign, ":attack_item", "itm_beorn_axe_reward"), (val_add, ":base_dmg", 15), #(display_log_message, "@BEAR Attacked with a slam!"), (assign, ":fly_anim_base", "anim_strike_fly_back_near_rise"), # TODO Check this (try_end), # fly_anim_base - > is a generic anim that should fire for human given the bear attack type # fly_anim -> accounts position # hit_anim -> is final anim played # Loop over enemies to check if someone is in front (assign, ":damaged_agents", 0), (assign, ":agents_to_damage", 20), (assign, ":sounds_played", 0), (try_for_agents, ":enemy_agent", pos6, ":max_distance"), (agent_is_alive, ":enemy_agent"), (agent_is_active, ":enemy_agent"), (neq, ":enemy_agent", ":agent_no"), (neq, ":enemy_agent", ":bear"), (le, ":damaged_agents", ":agents_to_damage"), # Stop loop if enough agents were damaged # Get enemy troop data and exclude invisible riders (they are targetted by their mounts) (agent_get_troop_id, ":enemy_troop_id", ":enemy_agent"), #(neg|is_between, ":enemy_troop_id", warg_ghost_begin, warg_ghost_end), #(neg|is_between, ":enemy_troop_id", "trp_spider", "trp_dorwinion_sack"), #(neq, ":enemy_troop_id", "trp_werewolf"), # First position check (agent_get_position, pos8, ":enemy_agent"), (get_distance_between_positions, ":dist", pos6, pos8), #1 , 2 (lt, ":dist", ":max_distance"), (neg|position_is_behind_position, pos8, pos6), #2, 1 # Optional: Check if the enemy was turned back to attacker (try_begin), (position_is_behind_position, pos6, pos8), # attacker (1) behind victim (2) (assign, ":fly_anim", "anim_strike_fly_front"), (else_try), (assign, ":fly_anim", ":fly_anim_base"), (end_try), # Experimental: Limit the attack to "sides" (position_transform_position_to_local, pos8, pos6, pos8), (position_get_x, ":enemy_x_distance", pos8), (ge, ":enemy_x_distance", -150), (lt, ":enemy_x_distance", 150), # TODO We don't handle side hits yet # Set default channel for an attack (assign, ":channel", 0), (assign, ":hit_anim", -1), (agent_get_horse, ":enemy_mount", ":enemy_agent"), (store_skill_level, ":riding_skill", skl_riding, ":enemy_troop_id"), # Proper checks for case of invisible rider/animal targets (assign, ":is_valid_animal", 0), (try_begin), (this_or_next|is_between, ":enemy_troop_id", warg_ghost_begin, warg_ghost_end), (this_or_next|is_between, ":enemy_troop_id", "trp_spider", "trp_dorwinion_sack"), (eq, ":enemy_troop_id", "trp_werewolf"), (try_begin), (ge, ":enemy_mount", 0), (agent_is_alive, ":enemy_mount"), (assign, ":is_valid_animal", 1), (else_try), (assign, ":is_valid_animal", -1), (end_try), (end_try), # Invalid animals are invalid targets (ge, ":is_valid_animal", 0), # Target is either a horse or a man (try_begin), # Agent is an invisible rider (re-target to horse) (eq, ":is_valid_animal", 1), (assign, ":enemy_agent", ":enemy_mount"), # re-target to horse (assign, ":hit_anim", -1), (else_try), # Agent is a horse/an animal (neg|agent_is_human, ":enemy_agent"), (assign, ":hit_anim", -1), (else_try), # Target is a human without a horse (agent_is_human, ":enemy_agent"), (eq, ":enemy_mount", -1), (assign, ":hit_anim", ":fly_anim"), #(display_message, "@DEBUG: Bear strikes human without a horse!"), (else_try), # Target is a human with a horse and a bad skill (ge, ":enemy_mount", 0), (agent_is_active, ":enemy_mount"), (le, ":riding_skill", 5), (assign, ":hit_anim", ":fly_anim"), (agent_start_running_away, ":enemy_mount"), # Dismount (agent_stop_running_away, ":enemy_mount"), #(display_message, "@DEBUG: Bear strikes a bad rider!"), (else_try), # Target is an human with high skill and a horse (ge, ":enemy_mount", 0), (agent_is_active, ":enemy_mount"), (assign, ":hit_anim", "anim_strike_legs_front"), (assign, ":channel", 1), #(display_message, "@DEBUG: Bear strikes a good rider!"), (try_end), # Calc dmg (store_random_in_range, ":dmg", 0, ":base_dmg"), (val_add, ":dmg", ":base_dmg"), #(assign, reg8, ":enemy_agent"), # Play anim only for human target (try_begin), (agent_is_human, ":enemy_agent"), (agent_set_animation, ":enemy_agent", ":hit_anim", ":channel"), (try_end), # Distribute damage (agent_deliver_damage_to_agent_advanced, ":final_dmg", ":agent_no", ":enemy_agent", ":dmg", ":attack_item"), (val_add, ":damaged_agents", 1), # ON-HIT SOUNDS (try_begin), (lt, ":sounds_played", 3), # Calc absorbed dmg and play sound depending on it and final dmg (val_sub, ":dmg", ":final_dmg"), # Animation attack resulting in blunt dmg -> blunt sound # High armour (try_begin), (eq, ":attack_item", "itm_beorn_axe_reward"), # blunt weapon (ge, ":dmg", 25), (agent_play_sound, ":enemy_agent", "snd_wooden_hit_high_armor_high_damage"), # Low armor (else_try), (eq, ":attack_item", "itm_beorn_axe_reward"), (agent_play_sound, ":enemy_agent", "snd_wooden_hit_low_armor_high_damage"), # Slash attack: High armour high damage (else_try), (ge, ":dmg", 25), (ge, ":final_dmg", 15), (agent_play_sound, ":enemy_agent", "snd_metal_hit_high_armor_high_damage"), # Slash: High armour low damage (else_try), (ge, ":dmg", 25), (lt, ":final_dmg", 15), (agent_play_sound, ":enemy_agent", "snd_metal_hit_high_armor_low_damage"), # Slash: low armor (else_try), (lt, ":dmg", 25), (agent_play_sound, ":enemy_agent", "snd_metal_hit_low_armor_high_damage"), (try_end), (val_add, ":sounds_played", 1), (try_end), # END OF SOUND CODE (try_end), ]), # script_cf_gain_trait_bear_shape # Triggered after conditions to get the trait are satisfied ("cf_gain_trait_bear_shape",[ (neg|troop_slot_eq, "trp_traits", slot_trait_bear_shape, 1), # special case as not having the trait could be denoted in many ways (display_log_message, "@Your ability to change skin has manifested, from now on you can walk wild paths both as man and a bear.", color_good_news), (call_script, "script_gain_trait", slot_trait_bear_shape), ]), # script_update_bear_kinship # Fired whenever bear is encountered to form a kinship with them. # slot_trait_bear_shape is 0 - no trait, 1 - trait, n>1, no trait stores bear kinship ("cf_update_bear_kinship",[ (try_begin), (troop_get_slot, ":bear_kinship", "trp_traits", slot_trait_bear_shape), (neq, ":bear_kinship", 1), (lt, ":bear_kinship", 30), # Player strong enough to form kinship with bears (eq, "$players_kingdom", "fac_beorn"), # Only beorning get bear kinship points (store_attribute_level, ":charisma", "trp_player", ca_charisma), (ge, ":charisma", 12), (store_attribute_level, ":strength", "trp_player", ca_strength), (ge, ":strength", 17), # Bear kinship is the amount of appearences when player was with bears and with small party (get_player_agent_no, ":agent"), (agent_get_party_id, ":party", ":agent"), (store_party_size, ":party_size", ":party"), # 2/party_size chance for kiniship + 2) (store_random_in_range,":rnd", 0, 100), (assign, ":chance", 100), (val_div, ":chance", ":party_size"), (val_mul, ":chance", 2), (val_min, ":chance", 50), # 7 % To decrease bear kinship, always (try_begin), (gt, ":rnd", 95), (gt, ":bear_kinship", 2), (val_sub, ":bear_kinship", 1), # chance % To increase (else_try), (le, ":rnd", ":chance"), (val_add, ":bear_kinship", 1), (val_max, ":bear_kinship", 2), (try_end), (troop_set_slot, "trp_traits", slot_trait_bear_shape, ":bear_kinship"), #(assign, reg1, ":bear_kinship"), #(display_message, "@DEBUG Bear kinship: increased {reg1}", color_good_news), (try_end), ]), # script_cf_bearform_on_dismount # Script should be triggered when character dismounts while in bear from. Guy should either # die or reform to human # INPUTS: # arg1 = agent # arg2 = horse agent ("cf_bearform_on_dismount",[ # (display_log_message, "@DEBUG dismount fired"), (store_script_param_1, ":agent"), (store_script_param_2, ":horse"), # Reset camera (try_begin), (eq, "$cam_mode", 4), # Was bear mode (assign, "$cam_mode", 0), (end_try), (try_begin), # Only if horse/bear mount is alive allow it (ge, ":horse", 0), (agent_is_active, ":horse"), (agent_is_alive, ":horse"), # Horse (troop_get_inventory_slot, ":item", "trp_player", ek_horse), (try_begin), (ge, ":item", 0), (agent_equip_item, ":agent", ":item"), (else_try), (agent_unequip_item, ":agent", "itm_bear"), (try_end), # Body (troop_get_inventory_slot, ":item", "trp_player", ek_body), (try_begin),(ge, ":item", 0),(agent_equip_item, ":agent", ":item"), (else_try), (agent_unequip_item, ":agent", "itm_warg_ghost_armour"), (try_end), # Head (troop_get_inventory_slot, ":item", "trp_player", ek_head), (try_begin),(ge, ":item", 0),(agent_equip_item, ":agent", ":item"), (else_try), (agent_unequip_item, ":agent", "itm_empty_head"), (try_end), # Hands (troop_get_inventory_slot, ":item", "trp_player", ek_gloves), (try_begin),(ge, ":item", 0),(agent_equip_item, ":agent", ":item"), (else_try), (agent_unequip_item, ":agent", "itm_empty_hands"), (try_end), # Legs (troop_get_inventory_slot, ":item", "trp_player", ek_foot), (try_begin),(ge, ":item", 0),(agent_equip_item, ":agent", ":item"), (else_try), (agent_unequip_item, ":agent", "itm_empty_legs"), (try_end), # Weapons, only first one has a risk of being ghost lance (troop_get_inventory_slot, ":item", "trp_player", ek_item_0), (agent_unequip_item, ":agent", "itm_warg_ghost_lance"), (try_begin),(ge, ":item", 0), (agent_equip_item, ":agent", ":item", 1), (try_end), (troop_get_inventory_slot, ":item", "trp_player", ek_item_1), (try_begin),(ge, ":item", 0), (agent_equip_item, ":agent", ":item", 2), (try_end), (troop_get_inventory_slot, ":item", "trp_player", ek_item_2), (try_begin),(ge, ":item", 0), (agent_equip_item, ":agent", ":item", 3), (try_end), (troop_get_inventory_slot, ":item", "trp_player", ek_item_3), (try_begin),(ge, ":item", 0),(agent_equip_item, ":agent", ":item", 4), (try_end), # Have proper position (agent_is_alive, ":agent"), (agent_set_animation, ":agent", "anim_hide_inside_warg"), (agent_set_animation, ":agent", "anim_bow_to_lord_stay_down"), # Fadie out the bear (agent_get_position, pos1, ":agent"), (particle_system_burst, "psys_bear_fur", pos1, 100), # Set proper hp (store_agent_hit_points, ":bear_hp", ":horse", 0), # Relative hp (agent_set_hit_points, ":agent", ":bear_hp", 0), (agent_set_visibility, ":agent", 1), (agent_fade_out, ":horse"), (display_log_message, "@You change back to human form...", color_neutral_news), (else_try), # Else kill the player (agent_set_hit_points, ":agent", 0), (agent_deliver_damage_to_agent, ":agent", ":agent", 1), (try_end), ]), # script_show_on_hit_blood # Spawn blood particle on hit # Inputs: # arg1 victim agent # arg2 damage dealt # arg3 dmg_type # ("cf_on_hit_blood", [ (store_script_param, ":victim", 1), #(store_script_param, ":dmg_type", 3), # Check troop height to get proper blood (agent_get_troop_id, ":troop", ":victim"), # Horizontal randomization (store_random_in_range, ":dx", -20, 20), (position_move_x, pos0, ":dx", 0), (try_begin), (ge, ":troop", 0), (troop_get_type, ":race", ":troop"), (try_begin), (eq, ":race", tf_troll), (position_move_z, pos0, 210), (else_try), (this_or_next|is_between, ":race", tf_orc_begin, tf_orc_end), (eq, ":race", tf_dwarf), (neq, ":race", tf_urukhai), (neq, ":race", tf_uruk), (position_move_z, pos0, 165), (else_try), # All the rest -> human size (position_move_z, pos0, 180), (try_end), (else_try), # Animal are target # Horses (agent_get_item_id, ":animal_type", ":victim"), (try_begin), (this_or_next|is_between, ":animal_type", item_horse_begin, item_horse_end), (this_or_next|eq, ":animal_type", "itm_werewolf"), (this_or_next|eq, ":animal_type", "itm_bear"), (eq, ":animal_type", "itm_oliphant"), (position_move_z, pos0, 170), (else_try), # Wargs are shorter (is_between, ":animal_type", item_warg_begin, item_warg_end), (position_move_z, pos0, 155), (else_try), (this_or_next|eq, ":animal_type", "itm_spider"), (eq, ":animal_type", "itm_wolf"), (position_move_z, pos0, 110), (else_try), (position_move_z, pos0, 150), (try_end), (try_end), # Cap the dmg it will be used (store_random_in_range, ":particle_type", 0, 2), (try_begin), # bigger dmg bigger blooood (eq, ":particle_type", 1), (particle_system_burst, "psys_game_blood_rand_2", pos0, 100), (else_try), (particle_system_burst, "psys_game_blood_rand", pos0, 100), (try_end), ]), #script_agent_troop_get_banner_mesh # INPUT: agent_no, troop_no # OUTPUT: banner_mesh ("agent_troop_get_banner_mesh", [ (store_script_param, ":agent_no", 1), (store_script_param, ":troop_no", 2), (assign, ":banner_troop", -1), (assign, ":banner_mesh", "mesh_banners_default_a"), (assign, ":subfaction", -1), # (assign, reg78, ":troop_no"), # (str_store_troop_name, s1, ":troop_no"), # (display_message, "@{reg78}:{s1}"), (try_begin), (lt, ":agent_no", 0), (try_begin), (ge, ":troop_no", 0), (this_or_next|troop_slot_ge, ":troop_no", slot_troop_banner_scene_prop, 1), ( eq, ":troop_no", "trp_player"), (assign, ":banner_troop", ":troop_no"), (else_try), (this_or_next|is_between, ":troop_no", companions_begin, companions_end), (is_between, ":troop_no", new_companions_begin, new_companions_end), (assign, ":banner_troop", "trp_player"), (assign, ":agent_party", "p_main_party"), (else_try), (assign, ":banner_mesh", "mesh_banners_default_a"), (try_end), (else_try), (agent_get_troop_id, ":troop_id", ":agent_no"), (this_or_next|troop_slot_ge, ":troop_id", slot_troop_banner_scene_prop, 1), ( eq, ":troop_no", "trp_player"), (assign, ":banner_troop", ":troop_id"), (else_try), (agent_get_party_id, ":agent_party", ":agent_no"), (try_begin), (lt, ":agent_party", 0), (this_or_next|is_between, ":troop_id", companions_begin, companions_end), (is_between, ":troop_id", new_companions_begin, new_companions_end), (main_party_has_troop, ":troop_id"), (assign, ":agent_party", "p_main_party"), (else_try), #agents from no party (spawned by script) (lt, ":agent_party", 0), (store_troop_faction, ":party_faction", ":troop_id"), (ge, ":party_faction", 1), (faction_get_slot, ":banner_troop", ":party_faction", slot_faction_leader), (troop_get_slot, ":subfaction", ":troop_id", slot_troop_subfaction), (try_end), (ge, ":agent_party", 0), (party_get_template_id, ":party_template", ":agent_party"), (try_begin), #deserters (eq, ":party_template", "pt_deserters"), (assign, ":banner_mesh", "mesh_banners_default_c"), (else_try), #center garrisons (is_between, ":agent_party", centers_begin, centers_end), (party_get_slot, ":town_lord", "$g_encountered_party", slot_town_lord), (ge, ":town_lord", 0), (assign, ":banner_troop", ":town_lord"), (else_try), #hosts (party_slot_eq, ":agent_party", slot_party_type, spt_kingdom_hero_party), #( eq, ":agent_party", "p_main_party"), (party_get_num_companion_stacks, ":num_stacks", ":agent_party"), (gt, ":num_stacks", 0), (party_stack_get_troop_id, ":leader_troop_id", ":agent_party", 0), (this_or_next|troop_slot_ge, ":leader_troop_id", slot_troop_banner_scene_prop, 1), ( eq, ":leader_troop_id", "trp_player"), (assign, ":banner_troop", ":leader_troop_id"), (else_try), #player party (eq, ":agent_party", p_main_party), (faction_get_slot, ":banner_troop", "$players_kingdom", slot_faction_leader), (troop_get_slot, ":subfaction", trp_player, slot_troop_subfaction), (else_try), #other faction parties (store_faction_of_party, ":party_faction", ":agent_party"), (ge, ":party_faction", 1), (faction_get_slot, ":banner_troop", ":party_faction", slot_faction_leader), (try_begin), #extra check for Gondor subfac parties, since these don't have their subfac stored, we need to check them by party template (this_or_next|eq, ":party_template", pt_blackroot_auxila),(eq, ":party_template", pt_brv_patrol), (assign, ":subfaction", subfac_blackroot), (this_or_next|eq, ":party_template", pt_lamedon_auxila),(eq, ":party_template", pt_lamedon_patrol), (assign, ":subfaction", subfac_ethring), (this_or_next|eq, ":party_template", pt_lossarnach_auxila),(eq, ":party_template", pt_lossarnach_patrol), (assign, ":subfaction", subfac_lossarnach), (this_or_next|eq, ":party_template", pt_pinnath_gelin_auxila),(eq, ":party_template", pt_pinnath_patrol), (assign, ":subfaction", subfac_pinnath_gelin), (this_or_next|eq, ":party_template", pt_ranger_scouts),(this_or_next|eq, ":party_template", pt_ranger_raiders),(eq, ":party_template", pt_ranger_patrol), (assign, ":subfaction", subfac_rangers), (eq, ":party_template", pt_amroth_patrol), (assign, ":subfaction", subfac_dol_amroth), (eq, ":party_template", pt_pelargir_patrol), (assign, ":subfaction", subfac_pelargir), (try_end), (try_end), (try_end), (try_begin), (ge, ":banner_troop", 0), (try_begin), (neg|troop_slot_ge, ":banner_troop", slot_troop_banner_scene_prop, 1), (agent_get_party_id, ":agent_party", ":agent_no"), (ge, ":agent_party", 0), (store_faction_of_party, ":party_faction", ":agent_party"), (faction_get_slot, ":banner_troop", ":party_faction", slot_faction_leader), #(assign, ":banner_mesh", "mesh_banners_default_b"), (try_end), (troop_get_slot, ":banner_spr", ":banner_troop", slot_troop_banner_scene_prop), (store_add, ":banner_scene_props_end", banner_scene_props_end_minus_one, 1), (is_between, ":banner_spr", banner_scene_props_begin, ":banner_scene_props_end"), (val_sub, ":banner_spr", banner_scene_props_begin), (store_add, ":banner_mesh", ":banner_spr", arms_meshes_begin), (try_end), (try_begin), (ge, ":subfaction", 1), (try_begin),(eq, ":subfaction", subfac_pelargir), (assign, ":banner_mesh", "mesh_banner_e12"), (else_try), (eq, ":subfaction", subfac_dol_amroth), (assign, ":banner_mesh", "mesh_banner_e17"), (else_try), (eq, ":subfaction", subfac_ethring), (assign, ":banner_mesh", "mesh_banner_e10"), (else_try), (eq, ":subfaction", subfac_lossarnach), (assign, ":banner_mesh", "mesh_banner_e19"), (else_try), (eq, ":subfaction", subfac_pinnath_gelin), (assign, ":banner_mesh", "mesh_banner_e06"), (else_try), (eq, ":subfaction", subfac_blackroot), (assign, ":banner_mesh", "mesh_banner_e03"), (else_try), (eq, ":subfaction", subfac_rangers), (assign, ":banner_mesh", "mesh_banner_e05"), (try_end), (try_end), (assign, reg0, ":banner_mesh"), ]), # #script_troop_agent_set_banner # # INPUT: agent_no # # OUTPUT: none ("troop_agent_set_banner", [ (store_script_param, ":tableau_no",1), (store_script_param, ":agent_no", 2), (store_script_param, ":troop_no", 3), (call_script, "script_agent_troop_get_banner_mesh", ":agent_no", ":troop_no"), (cur_agent_set_banner_tableau_material, ":tableau_no", reg0), ]), # #script_town_guard_patrols # # INPUT: scene prop type for spawning guards # # OUTPUT: none ("town_guard_patrols", [ (store_script_param, ":prop_type",1), (scene_prop_get_num_instances, ":num_patrols", ":prop_type"), (set_fixed_point_multiplier, 100), (get_player_agent_no, ":player_agent"), (try_for_range, ":count", 0, ":num_patrols"), (scene_prop_get_instance, ":instance_no_source", ":prop_type", ":count"), (prop_instance_get_variation_id_2, ":var2_source", ":instance_no_source"), (gt, ":var2_source", 0), (prop_instance_get_position, pos1, ":instance_no_source"), (assign, ":target_found", 0), (scene_prop_get_num_instances, ":num_patrol_targets", "spr_troop_guard_patrol_target_var2"), (try_for_range, ":count_targets", 0, ":num_patrol_targets"), (scene_prop_get_instance, ":instance_no_target", "spr_troop_guard_patrol_target_var2", ":count_targets"), (prop_instance_get_variation_id_2, ":var2_target", ":instance_no_target"), (eq, ":var2_target", ":var2_source"), #patrol target found (assign, ":target_found", 1), (assign, ":num_patrol_targets", 0), #break loop (prop_instance_get_position, pos2, ":instance_no_target"), (try_end), (gt, ":target_found", 0), (try_for_agents, ":agent_no", pos1, 400), (agent_slot_eq, ":agent_no", slot_agent_walker_type, 2), (agent_slot_eq, ":agent_no", slot_agent_target_entry_point, ":instance_no_source"), (neq, ":agent_no", ":player_agent"), (agent_get_position, pos3, ":agent_no"), (get_distance_between_positions, ":dist", pos1, pos3), (le, ":dist", 400), #need to put this extra check because WSE breaks the try_for_agents operation (agent_set_scripted_destination, ":agent_no", pos2), (try_end), (try_for_agents, ":agent_no", pos2, 400), #send back home (agent_slot_eq, ":agent_no", slot_agent_walker_type, 2), (neq, ":agent_no", ":player_agent"), (agent_slot_eq, ":agent_no", slot_agent_target_entry_point, ":instance_no_source"), #check home position (agent_get_position, pos3, ":agent_no"), (get_distance_between_positions, ":dist", pos2, pos3), (le, ":dist", 400), #need to put this extra check because WSE breaks the try_for_agents operation (agent_set_scripted_destination, ":agent_no", pos1), (try_end), (try_end), ]), # #script_siege_adjust_battle_size # # INPUT: none # # OUTPUT: none ("siege_adjust_battle_size", [ (options_get_battle_size, reg5), (try_begin), (gt, reg5, 415), (assign, "$player_battlesize", reg5), (options_set_battle_size, 415), #200 (assign, "$player_battlesize_changed", 1), (try_end), ]), # #script_reset_battle_size # # INPUT: none # # OUTPUT: none ("reset_battle_size", [ (try_begin), (eq, "$player_battlesize_changed", 1), (assign, "$player_battlesize_changed",0), (options_set_battle_size, "$player_battlesize"), (try_end), ]), #script_game_get_use_string #imported from native # This script is called from the game engine for getting using information text # INPUT: used_scene_prop_id # OUTPUT: s0 ("game_get_use_string", [ (store_script_param, ":instance_id", 1), (prop_instance_get_scene_prop_kind, ":scene_prop_id", ":instance_id"), (try_begin), (this_or_next|eq, ":scene_prop_id", "spr_ammo_stack_good"), (eq, ":scene_prop_id", "spr_ammo_stack_evil"), (str_store_string, s0, "@Refill Ammunition"), (try_end), ]), #("script_lookat", pos##, pos##), #by DSTN #This script will take a position and rotate it such that +Y will face the target exactly. #It does this with some basic trig, I'll explain it in the comments inside the script. #INPUT: # Param 1: Positional register of the pos## that will be rotated # Param 2: Positional register of the pos## that will be targeted #OUTPUT: # N/A ("lookat", [ (store_script_param, ":looker", 1), # This is the positional register that will turn to face the :target (+Y being forward) (store_script_param, ":target", 2), # This is the positional register that will be targeted (assign, ":local", pos13), # This just makes the local_var :local equivilent to pos13 (init_position, pos1), # Get a clean positional register so. . . (position_copy_rotation, ":looker", pos1), # We can scrub the rotational data from the :looker to simplify the math # The maths are pretty easy once we figure it out. Essentially, make two triangles with the two positions # Use those triangles to determine the angles that the :looker will need to rotate to face the :target (position_transform_position_to_local, ":local", ":looker", ":target"), # We will use the local data to determine side lengths (position_get_z, ":l_z", ":looker"), # :looker z value (position_get_z, ":t_z", ":target"), # :target z value (position_get_x, ":local_x", ":local"), # The opposite side of the first triangle (position_get_y, ":local_y", ":local"), # The adjacent side of the first triangle (store_sub, ":z_dis", ":l_z", ":t_z"), # The adjacent side of the second triangle (get_distance_between_positions, ":hypo", ":looker", ":target"), # Distance between the positions will be the hypotenuse of both triangles (convert_to_fixed_point, ":z_dis"), # When doing fixed point maths only one needs to be fixed point or else it won't convert from the fp correctly (convert_to_fixed_point, ":local_x"), # When doing fixed point maths only one needs to be fixed point or else it won't convert from the fp correctly # SOH CAH TOA, sin(opp/hyp), cos(adj/hyp), tan(opp/adj) (store_div, ":adj_hyp", ":z_dis", ":hypo"), # Use the second triangle's adjacent / hypotenuse (store_acos, ":x_angle", ":adj_hyp"), # To get the angle we need to adjust the pitch (convert_from_fixed_point, ":x_angle"), # Convert from fixed point to make it useable by the rotation (val_add, ":x_angle", 270), # Move it by 270 degrees to convert the angle into the correct quadrant (try_begin), (eq, ":local_y", 0), # If the adjacent side's length would be 0 (assign, ":z_angle", 0), # Set the yaw to 0 to prevent division by zero errors (else_try), (store_div, ":opp_adj", ":local_x", ":local_y"), # Use the second triangle's opposite side / adjacent side (store_atan, ":z_angle", ":opp_adj"), # To get the angle of the yaw (convert_from_fixed_point, ":z_angle"), # Convert from fixed point to make it useable by the rotation (val_mul, ":z_angle", -1), # Mirror the yaw to change it from CCW to CW (try_end), (try_begin), (lt, ":local_y", 0), # If the :target is behind the :looker (val_add, ":z_angle", 180), # Move the yaw 180 degrees (try_end), (position_rotate_z, ":looker", ":z_angle"), # Rotate left/right (yaw) first (position_rotate_x, ":looker", ":x_angle"), # Then rotate up/down (pitch) last ]), # script_animate_town_agents # Input: Prop type, frequency (pauses), animation type (thrust, right, left, overswing, or random) ("animate_town_agents", [ (store_script_param, ":prop", 1), (store_script_param, ":frequency", 2), (store_script_param, ":animation", 3), (store_script_param, ":item", 4), (set_fixed_point_multiplier, 100), (get_player_agent_no, ":player_agent"), (agent_get_position, pos4, ":player_agent"), (scene_prop_get_num_instances, ":num_props", ":prop"), (try_for_range, ":count", 0, ":num_props"), (scene_prop_get_instance, ":instance_no", ":prop", ":count"), (prop_instance_get_position, pos2, ":instance_no"), (scene_prop_get_slot, ":agent", ":instance_no", slot_prop_agent_1), (prop_instance_get_position, pos3,":instance_no"), (get_distance_between_positions, ":distance", pos3, pos4), # (try_begin), # (eq, ":prop", spr_troop_smith), # (assign, reg66, ":distance"), # (display_message, "@distance: {reg66}"), # (try_end), (is_between, ":distance", 350, 5000), #only if player isn't too close, but also not too far either (avoid too many sounds) (agent_set_look_target_position, ":agent", pos2), (neg|position_is_behind_position, pos2, pos3), (store_random_in_range, ":chance", 0, 15), (ge, ":chance", ":frequency"), #number of pauses (try_begin), (eq, ":animation", 4), (store_random_in_range, ":animation", 0, 4), (try_end), (agent_set_attack_action, ":agent", ":animation", 0), #overhead (agent_get_wielded_item, ":wielded", ":agent", 0), #just to be sure they don't spawn without their item for some reason (lt, ":wielded", 1), (agent_equip_item, ":agent", ":item", 1), (agent_set_wielded_item, ":agent", ":item"), (try_end), ]), ] or [])