What is this?
This code establishes a system overwriting Native's building slots whereby "upgrades" can be obtained by with the use of agent modifier operations applied from mission templates. Included in this package is also a number of auxiliary buildings which I have not bothered to remove - these can be elaborated on later by request. This is not a complete module, although placeholders values are included for native factions and towns. The effect of changing modifiers will depend on the individual factions. Also included is an initialization framework where the costs are made dynamic and the newer buildings can become upgraded - even by the AI if they are sufficiently wealthy. A number of capitals have some extant infrastructure, however the player can only upgrade them or build one in a conquered center due to their cumulative nature so as to not make a sufficiently motivated player too overpowered. Feel free to give feedback or discuss below, or tell me how awesome this is going to be and what mod you're going to add it in.
What are agent modifiers?
Agent modifiers are operations which make troops faster and stronger in battle. Although it can be used to weaken them instead, it is more interesting to see divergence between difference factions using different weaponry to varying degrees of effectiveness. The operations in use are agent_set_max_hit_points/agent_set_damage_modifier/agent_set_accuracy_modifier/agent_set_speed_modifier/agent_set_reload_speed_modifier/agent_set_ranged_damage_modifier/agent_set_horse_speed_factor, which were introduced in the more recent patches.
What are these special buildings supposed to do?
Will the AI use it?
As I have mentioned in the previous sections, the Native factions come pre-loaded with between 9-10 buildings distributed in their towns. In addition, each walled center owned by a lord gets a chance at building a random infrastructure at the start (based on wealth and renown), and over the span of the game. This calculation will succeed rarely, but if you promote the properly conditioned companion to the aristocracy it might be expedited.
How can I use it?
Since the buildings are constructed along the native system of menus and triggers, the new buildings simply take up more slots and real estate. Just go through the menu and click on the new things, be sure to have enough money. If you are using diplomacy, the lines for building them via the chamberlain and tallying them through the constable can also be made available. Otherwise, one of the new benefits of joining a faction that fits your playing style is that you now have access to their existing improvements - as long as you are using their troops, of course.
Is that everything?
Nope, more stuff below
If anybody wants to package this with modmerger, feel free.
This code establishes a system overwriting Native's building slots whereby "upgrades" can be obtained by with the use of agent modifier operations applied from mission templates. Included in this package is also a number of auxiliary buildings which I have not bothered to remove - these can be elaborated on later by request. This is not a complete module, although placeholders values are included for native factions and towns. The effect of changing modifiers will depend on the individual factions. Also included is an initialization framework where the costs are made dynamic and the newer buildings can become upgraded - even by the AI if they are sufficiently wealthy. A number of capitals have some extant infrastructure, however the player can only upgrade them or build one in a conquered center due to their cumulative nature so as to not make a sufficiently motivated player too overpowered. Feel free to give feedback or discuss below, or tell me how awesome this is going to be and what mod you're going to add it in.
What are agent modifiers?
Agent modifiers are operations which make troops faster and stronger in battle. Although it can be used to weaken them instead, it is more interesting to see divergence between difference factions using different weaponry to varying degrees of effectiveness. The operations in use are agent_set_max_hit_points/agent_set_damage_modifier/agent_set_accuracy_modifier/agent_set_speed_modifier/agent_set_reload_speed_modifier/agent_set_ranged_damage_modifier/agent_set_horse_speed_factor, which were introduced in the more recent patches.
module_mission_templates said:common_battle_init_banner = (
ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(call_script, "script_troop_agent_set_banner", "tableau_game_troop_label_banner", ":agent_no", ":troop_no"),
(call_script, "script_init_agent_modifiers", ":agent_no"),
])
Code:
("init_agent_modifiers",
[
(store_script_param_1, ":agent"),
(agent_get_party_id, ":party_no", ":agent"),
(agent_get_troop_id, ":troop_no", ":agent"),
(try_begin),
(eq, ":party_no", "p_main_party"),
(assign, ":party_faction", "$players_kingdom"),
(val_max, ":party_faction", "fac_player_supporters_faction"),
(else_try),
(party_is_active, ":party_no"),
(store_faction_of_party, ":party_faction", ":party_no"),
(else_try), #spawned agents, bodyguards?
(assign, ":party_faction", "fac_commoners"),
(try_end),
(try_begin), #heros already upgrade skill/items
(troop_is_hero, ":troop_no"),
(assign, ":troop_faction", -1),
(else_try),
(store_faction_of_troop, ":troop_faction", ":troop_no"),
(try_end),
#force triggering
(try_begin),
(eq, "$g_is_quick_battle", 1),
(try_begin), #override previous hero restriction
(get_player_agent_no, ":player_agent"),
(agent_get_rider, ":rider", ":agent"),
(this_or_next|eq, ":rider", ":player_agent"),
(eq, ":player_agent", ":agent"),
(assign, ":troop_faction", "$g_quick_battle_team_1_faction"),
(try_end),
(assign, ":party_faction", ":troop_faction"),
(try_end),
#do some conditionals for agent/party/faction checks
#in general if agent/party mismatch, they are deserters
(try_begin),
# (this_or_next|eq, ":troop_faction", "fac_commoners"),
(try_begin), #player's parties
(eq, ":party_faction", "fac_player_supporters_faction"),
(faction_slot_eq, "fac_player_supporters_faction", slot_faction_state, sfs_active),
# (this_or_next|eq, ":troop_faction", "$g_player_culture"),
(eq, ":troop_faction", "fac_commoners"), #arming mercenaries
(assign, ":troop_faction", ":party_faction"),
(try_end),
(eq, ":troop_faction", ":party_faction"),
(is_between, ":troop_faction", kingdoms_begin, kingdoms_end),
(try_begin), #troops
(agent_is_human, ":agent"),
(faction_get_slot, ":num_buildings", ":party_faction", slot_faction_num_foundrys),
(val_add, ":num_buildings", 100),
(agent_set_damage_modifier, ":agent", ":num_buildings"),
(faction_get_slot, ":num_buildings", ":party_faction", slot_faction_num_arsenals),
(val_add, ":num_buildings", 100),
(agent_set_ranged_damage_modifier, ":agent", ":num_buildings"),
(faction_get_slot, ":num_buildings", ":party_faction", slot_faction_num_ranges),
(val_add, ":num_buildings", 100),
(agent_set_accuracy_modifier, ":agent", ":num_buildings"),
(agent_set_reload_speed_modifier, ":agent", ":num_buildings"),
(faction_get_slot, ":num_buildings", ":party_faction", slot_faction_num_barracks),
(store_agent_hit_points, ":health", ":agent", 1),
(val_add, ":health", ":num_buildings"),
(agent_set_max_hit_points, ":agent", ":health", 1),
(else_try), #horses
(faction_get_slot, ":num_buildings", ":party_faction", slot_faction_num_stables),
(val_add, ":num_buildings", 100),
# (agent_set_horse_speed_factor, ":agent", ":num_buildings"), #this gets modified with current health in CC
# (agent_set_damage_modifier, ":agent", ":num_buildings"), #charge damage?
(agent_set_speed_modifier, ":agent", ":num_buildings"), #this doesn't work well
# (agent_set_damage_modifier, ":agent", ":num_buildings"), #this screws up charge damage - inflicting via operation still works
#horse HP are large enough to warrant percentage increase
(agent_set_max_hit_points, ":agent", ":num_buildings", 0),
(agent_get_rider, ":rider", ":agent"), #surprisingly this works
(agent_set_horse_speed_factor, ":rider", ":num_buildings"), #downside is the rider now gets the bonus, not the horse
(agent_set_slot, ":agent", slot_agent_horse_modifier, ":num_buildings"), #which we can correct here with another trigger
(try_end),
(try_end),
]
),
What are these special buildings supposed to do?
- Foundry - melee damage
- Arsenal - ranged damage
- Stables - horse hp/speed
- Barracks - health (linear)
- Shooting Range - accuracy/reload
Code:
improvement_limit = 12000
equipment_limit = 3000
slot_center_has_manor = 130 #village
slot_center_has_mill = 131
slot_center_has_watch_tower = 132
slot_center_has_plantation = 133
slot_center_has_lumber_yard = 134
slot_center_has_school = 135
slot_center_has_messenger_post = 136 #town, castle, village
slot_center_has_prisoner_tower = 137 #town, castle
slot_center_has_mercenary_hall = 138 #town
slot_center_has_merchant_guild = 139 #town
# slot_center_has_slaver_pit = 138 #town, castle
slot_center_has_academy = 140 #town, castle
slot_center_has_foundry = 141 #towns
slot_center_has_arsenal = 142 #towns
slot_center_has_stables = 143 #towns
slot_center_has_barrack = 144 #town, castle
slot_center_has_shrange = 145 #town, castle
village_improvements_begin = slot_center_has_manor
village_improvements_end = slot_center_has_prisoner_tower
military_infra_begin = slot_center_has_foundry
military_infra_end = slot_center_has_shrange + 1
walled_center_improvements_begin = slot_center_has_messenger_post
walled_center_improvements_end = slot_center_has_shrange + 1
initial_castle_improvements_end = slot_center_has_mercenary_hall
num_improvements = walled_center_improvements_end - village_improvements_begin
Code:
("spt_castle", "castle"),
("spt_town", "town"),
("spt_village", "village"),
("manor", "Manor"),
("mill", "Mill"),
("watchtower", "Watch Tower"),
("plantation", "Plantation"),
("lumber_yard", "Lumber Yard"),
("school", "School"),
("messenger_post", "Messenger Post"),
("prison_tower", "Prisoner Tower"),
("mercenary_hall", "Mercenary Hall"),
("merchant_hall", "Merchant Guild"),
("military_hall", "Military Academy"),
("foundry", "Steelworks Furnace"),
("arsenal", "Great Arsenal"),
("stables", "Companion Range"),
("barracks", "Field Barrack"),
("shooting_range", "Marksmen Gallery"),
("manor_details", "A manor lets you rest at the village and pay your troops half wages while you rest. You will be able to review the garrison, which will become more disciplined."),
("fishpond_details", "A mill increases village prosperity by 5%."),
("watchtower_details", "A watch tower lets the villagers raise alarm earlier. The amount of cattle that can be driven off is halved. The time it takes for enemies to loot the village increases by 50%. The village will also be reinforced with additional watchmen."),
("plantation_details", "A plantation allows for conscription of troops. Workers from surrounding regions will gather here and defend it by force if necessary. In addition, there is a chance that colonial troops will be recruited from the new culture."),
("lumber_details", "A lumber yard deforests the surrounding countryside for a 5% increase in prosperity and results in a decrease in build time for nearby centers."),
("school_details", "A school increases the loyality of the inhabitants to you by +1 every month. The school's graduates will aid in the defense this village."),
("messenger_post_details", "A messenger post lets the inhabitants send you a message whenever enemies are nearby, even if you are far away from here. An officer will be on duty at all times to coordinate the defenses."),
("prison_tower_details", "A prison tower reduces the chance for special captives held here to escape."),
#new stuff below
("merc_hall_details", "A mercenary hall attracts famed adventurers from Calradia and Georia across the sea, hosting up to twice the number of hired blades and reducing their cost in garrisons."),
("merchant_details", "A merchant guild expedites the flow of commerce in this town by increasing base prosperity gained per trade and the number of caravans that can be supported overall. If a mercenary hall is also build, caravans originating from this town will be better escorted."),
("academy_details", "A military academy increases the rate at which soldiers can be trained while in garrison, and also allows the promotion of veteran soldiers to champion status as well as civilizing certain bandit troops."),
("foundry_details", "A foundry produces high-quality weapons using the latest advances in ferrous metallurgy, increasing close-quarter damage done by 1%."),
("arsenal_details", "An arsenal create arms of exceptional quality and stockpiles of deadly ammunition, increasing ranged damage done by 1%."),
("stable_details", "A companion range provides an open pasture for horses to graze and tracks for equestrian exercise, and as such increases the endurance and speed of mounts by 1%."),
("barrack_details", "A barrack establishes permanent cantonments for drilling yards and field hospitals as well as imposing sanitation standards, increasing the health of common soldiers by 1%."),
("shooting_details", "A shooting gallery allows all skirmishers to practice in a variety of gauntlets while honing their precision, allow them to keep firing under any conditions, increasing their reload speed and accuracy by 1%."),
Will the AI use it?
As I have mentioned in the previous sections, the Native factions come pre-loaded with between 9-10 buildings distributed in their towns. In addition, each walled center owned by a lord gets a chance at building a random infrastructure at the start (based on wealth and renown), and over the span of the game. This calculation will succeed rarely, but if you promote the properly conditioned companion to the aristocracy it might be expedited.
script_game_start said:(try_for_range, ":center_no", walled_centers_begin, walled_centers_end),#add town garrisons
......
#create lord parties
(party_get_slot, ":center_lord", ":center_no", slot_town_lord),
(ge, ":center_lord", 1),
(troop_slot_eq, ":center_lord", slot_troop_leaded_party, 0),
(assign, "$g_there_is_no_avaliable_centers", 0),
(call_script, "script_create_kingdom_hero_party", ":center_lord", ":center_no"),
(assign, ":lords_party", "$pout_party"),
(party_attach_to_party, ":lords_party", ":center_no"),
(party_set_slot, ":center_no", slot_town_player_odds, 1000),
(troop_get_slot, ":renown", ":center_lord", slot_troop_renown),
(val_add, ":renown", ":initial_wealth"),
(call_script, "script_allocate_buildings", ":center_no", ":renown"),
script_troop_does_business_in_center said:......
(call_script, "script_npc_upgrade_buildings", ":troop_no", ":center_no"),
#Recruit volunteers
(try_begin),
(is_between, ":center_no", villages_begin, villages_end),
Code:
#script_allocate_buildings
# This script is called to initialize nifty new buildings
# INPUT: center, renown points for allocation
# OUTPUT: s50 to be displayed
("allocate_buildings",
[
(store_script_param, ":center_no", 1),
(store_script_param, ":renown", 2),
(assign, reg0, ":renown"),
(val_mul, ":renown", 10),
(str_store_party_name, s51, ":center_no"),
(str_store_string, s50, "@{s51} allocated {reg0} wealth for buildings"),
(store_random_in_range, ":random", 0, 5),
(try_begin), #not towns anymore
(is_between, ":center_no", castles_begin, castles_end),
(assign, ":range", initial_castle_improvements_end),
(else_try),
(assign, ":range", walled_center_improvements_end),
(try_end),
(try_for_range, ":unused", 0, ":random"),
(store_random_in_range, ":improvements", walled_center_improvements_begin, ":range"),
(try_begin), #reroll if existing, add base infrastructure bonus
(party_slot_ge, ":center_no", ":improvements", 1),
(val_add, ":renown", 1500),
(else_try),
(party_get_slot, ":cost", "p_zendar", ":improvements"),
(ge, ":renown", ":cost"),
(val_sub, ":renown", ":cost"),
(party_set_slot, ":center_no", ":improvements", 1),
(store_sub, ":string", ":improvements", village_improvements_begin),
(val_add, ":string", "str_manor"),
(str_store_string, s51, ":string"),
(str_store_string, s50, "str_s50_comma_s51"),
(try_end),
(try_end),
(display_log_message, "@{s50}"),
]),
#script_npc_upgrade_buildings
# This script is called to initialize nifty new buildings
# INPUT: center, renown points for allocation
# OUTPUT: s50 to be displayed
("npc_upgrade_buildings",
[
(assign, ":improvement_limit", improvement_limit),
(assign, ":equipment_limit", equipment_limit),
(store_script_param, ":troop_no", 1),
(store_script_param, ":center_no", 2),
(troop_get_slot, ":personality", ":troop_no", slot_lord_reputation_type),
(troop_get_slot, ":troop_wealth", ":troop_no", slot_troop_wealth),
(try_begin),
(is_between, ":personality", lrep_martial, lrep_selfrighteous),
(val_div, ":equipment_limit", 2),
(else_try),
(is_between, ":personality", lrep_selfrighteous, lrep_goodnatured),
(val_mul, ":improvement_limit", ":personality"),
(else_try),
(is_between, ":personality", lrep_goodnatured, lrep_custodian),
(try_begin), #exception
(eq, ":personality", lrep_roguish),
(val_sub, ":equipment_limit", 1000),
(else_try),
(store_mul, ":level", ":personality", 250),
(val_sub, ":improvement_limit", ":level"),
(try_end),
(try_end),
#upgrade centers
(try_begin),
(gt, ":troop_wealth", ":improvement_limit"), #surplus cash
(party_slot_eq, ":center_no", slot_center_current_improvement, 0), #not already building
(assign, ":continue", 1),
#this randomization applies so that there is a chance of not building an improvement
(store_random_in_range, ":improvement_no", village_improvements_begin, walled_center_improvements_end),
(party_slot_eq, ":center_no", ":improvement_no", 0), #not already built
(try_begin), #villages
(party_slot_eq, ":center_no", slot_party_type, spt_village),
(ge, ":improvement_no", village_improvements_end),
(assign, ":continue", 0),
(else_try), #towns, castles
(lt, ":improvement_no", walled_center_improvements_begin),
(assign, ":continue", 0),
(try_end),
(eq, ":continue", 1),
(call_script, "script_get_improvement_details", ":improvement_no", 1, 1),
(assign, ":improvement_cost", reg0), # 4000-25000
(store_attribute_level, ":level", ":troop_no", ca_intelligence), #10-70
(store_skill_level, ":skill", "skl_engineer", ":troop_no"), #0 to 15
(val_mul, ":skill", ":level"), # 0 to 105
(store_character_level, ":level", ":troop_no"), #22-50
(val_add, ":skill", ":level"),
(val_sub, ":improvement_cost", ":level"),
#get working strength
(party_get_num_companions, ":divider", ":center_no"), #0~300, ignoring wounded
(party_get_num_prisoners, ":level", ":center_no"), #possibly up to 100
(gt, ":divider", ":level"),
#calculate time - manpower, prosperity, and int/level-based
(party_get_slot, ":multiplier", ":center_no", slot_town_prosperity), #-100 to 100
(val_sub, ":multiplier", ":level"),
(store_sub, ":multiplier", 200, ":multiplier"), #300 to 100
# (val_div, ":level", 2),
# (val_add, ":divider", ":level"), #25 - 400
(store_character_level, ":level", ":troop_no"), #22-50
(val_add, ":divider", ":level"),
(store_attribute_level, ":level", ":troop_no", ca_intelligence), #10-70
(store_skill_level, ":skill", "skl_engineer", ":troop_no"), #0 to 15
(val_mul, ":level", ":skill"), # 0 to 105
(val_add, ":divider", ":level"), #total 30~500
(store_mul, ":improvement_time", ":improvement_cost", ":multiplier"), #400000 - 2700000
(val_div, ":improvement_time", 100),
(val_div, ":improvement_time", ":divider"), #18.18~800
(lt, ":improvement_time", 160), #feasible
(val_max, ":improvement_time", 3), #not instantaneous
(val_sub, ":troop_wealth", ":improvement_cost"),
(try_begin),
(store_faction_of_troop, ":troop_faction", ":troop_no"),
(this_or_next|eq, ":troop_faction", "$players_kingdom"),
(eq, "$cheat_mode", 2),
(assign, reg0, ":improvement_time"),
(display_log_message, "@{s10} constructs a {s0} in {s4}, finish in {reg0} days"),
(try_end),
(assign, "$g_improvement_type", ":improvement_no"),
(call_script, "script_improve_center", ":center_no", ":improvement_time"),
(try_end),
(try_end),
(troop_set_slot, ":troop_no", slot_troop_wealth, ":troop_wealth"),
]
),
How can I use it?
Since the buildings are constructed along the native system of menus and triggers, the new buildings simply take up more slots and real estate. Just go through the menu and click on the new things, be sure to have enough money. If you are using diplomacy, the lines for building them via the chamberlain and tallying them through the constable can also be made available. Otherwise, one of the new benefits of joining a faction that fits your playing style is that you now have access to their existing improvements - as long as you are using their troops, of course.
Code:
(
"center_manage",0,
"{s19}^{reg6?^^You are\
currently building {s7}. The building will be completed after {reg8} day{reg9?s:}.:}",
"none",
[(call_script, "script_get_improvement_progress", "$current_town"),
],
[
("center_build_manor",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
(party_slot_eq, "$g_encountered_party", slot_center_has_manor, 0),
],
"Build a manor.",[(assign, "$g_improvement_type", slot_center_has_manor),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_fish_pond",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
(party_slot_eq, "$g_encountered_party", slot_center_has_mill, 0),
],
"Build a mill.",[(assign, "$g_improvement_type", slot_center_has_mill),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_lumber_mill",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
(party_slot_eq, "$g_encountered_party", slot_center_has_lumber_yard, 0),
],
"Build a lumber mill and saw yard.",[(assign, "$g_improvement_type", slot_center_has_lumber_yard),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_plantation",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
(party_slot_eq, "$g_encountered_party", slot_center_has_plantation, 0),
#requirement - culture different from conquerors
(party_get_slot, ":original_faction", "$current_town", slot_center_original_faction),
(party_get_slot, ":ex_faction", "$current_town", slot_center_ex_faction),
(this_or_next|eq, "$g_encountered_party_faction", ":ex_faction"),
(neq, "$g_encountered_party_faction", ":original_faction"),
],
"Build a plantation.",[(assign, "$g_improvement_type", slot_center_has_plantation),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_watch_tower",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
(party_slot_eq, "$g_encountered_party", slot_center_has_watch_tower, 0),
],
"Build a watch tower.",[(assign, "$g_improvement_type", slot_center_has_watch_tower),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_school",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
(party_slot_eq, "$g_encountered_party", slot_center_has_school, 0),
],
"Build a school.",[(assign, "$g_improvement_type", slot_center_has_school),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_messenger_post",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_center_has_messenger_post, 0),
],
"Build a messenger post.",[(assign, "$g_improvement_type", slot_center_has_messenger_post),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_mercenary_hall",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(party_slot_eq, "$g_encountered_party", slot_center_has_mercenary_hall, 0),
],
"Build a mercenary hall.",[(assign, "$g_improvement_type", slot_center_has_mercenary_hall),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_merchant_hall",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(party_slot_eq, "$g_encountered_party", slot_center_has_merchant_guild, 0),
],
"Build a merchant guild house.",[(assign, "$g_improvement_type", slot_center_has_merchant_guild),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_academy",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(party_slot_eq, "$g_encountered_party", slot_center_has_academy, 0),
(assign, ":end", villages_end),
#store_distance_to_party_from_party, faction check?
(try_for_range, ":centers", villages_begin, ":end"),
(party_slot_eq, ":centers", slot_village_bound_center, "$g_encountered_party"),
(party_slot_ge, ":centers", slot_center_has_school, 1),
(assign, ":end", 0),
(try_end),
(eq, ":end", 0),
],
"Build a military academy.",[(assign, "$g_improvement_type", slot_center_has_academy),
(jump_to_menu, "mnu_center_improve"),]),
("center_build_academy_no",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(party_slot_eq, "$g_encountered_party", slot_center_has_academy, 0),
(assign, ":end", villages_end),
(try_for_range, ":centers", villages_begin, ":end"),
(party_slot_eq, ":centers", slot_village_bound_center, "$g_encountered_party"),
(party_slot_ge, ":centers", slot_center_has_school, 1),
(assign, ":end", 0),
(try_end),
(eq, ":end", villages_end),
(disable_menu_option),
],
"Build a military academy (requires a nearby school).",[]),
("center_build_foundry",[(eq, reg6, 0),
(this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(call_script, "script_cf_center_infrastructure", "$g_encountered_party"),
],
"Build a steel forge.",[(assign, "$g_improvement_type", slot_center_has_foundry), (jump_to_menu, "mnu_center_improve"),]),
("center_build_arsenal",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(call_script, "script_cf_center_infrastructure", "$g_encountered_party"),
],
"Build an arsenal.",[(assign, "$g_improvement_type", slot_center_has_arsenal), (jump_to_menu, "mnu_center_improve"),]),
("center_build_stable",[(eq, reg6, 0),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(call_script, "script_cf_center_infrastructure", "$g_encountered_party"),
],
"Build a companion stable.",[(assign, "$g_improvement_type", slot_center_has_stables),(jump_to_menu, "mnu_center_improve"),]),
("center_build_barrack",[(eq, reg6, 0),
(this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(call_script, "script_cf_center_infrastructure", "$g_encountered_party"),
],
"Build a field barrack.",[(assign, "$g_improvement_type", slot_center_has_barrack),(jump_to_menu, "mnu_center_improve"),]),
("center_build_range",[(eq, reg6, 0),
(this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(call_script, "script_cf_center_infrastructure", "$g_encountered_party"),
],
"Build a shooting range.",[(assign, "$g_improvement_type", slot_center_has_shrange),(jump_to_menu, "mnu_center_improve"),]),
("center_build_prisoner_tower",[(eq, reg6, 0),
(this_or_next|party_slot_eq, "$g_encountered_party", slot_party_type, spt_town),
(party_slot_eq, "$g_encountered_party", slot_party_type, spt_castle),
(party_slot_eq, "$g_encountered_party", slot_center_has_prisoner_tower, 0),
],
"Build a prisoner tower.",[(assign, "$g_improvement_type", slot_center_has_prisoner_tower),
(jump_to_menu, "mnu_center_improve"),]),
("go_back_dot",[],"Go back.",[(jump_to_menu, "$g_next_menu")]),
],
),
(
"center_improve",0,
"{s19} As the party member with the highest engineer skill ({reg2}), {reg3?you reckon:{s3} reckons} that building the {s4} will cost you\
{reg5} denars and will take {reg6} days.",
"none",
[(call_script, "script_get_improvement_details", "$g_improvement_type", 1, 2),
(assign, ":improvement_cost", reg0),
(str_store_string_reg, s4, s0),
(str_store_string_reg, s19, s1),
(call_script, "script_get_max_skill_of_player_party", "skl_engineer"),
(assign, ":max_skill", reg0),
(assign, ":max_skill_owner", reg1),
(assign, reg2, ":max_skill"),
(store_sub, ":multiplier", 21, ":max_skill"),
(val_mul, ":improvement_cost", ":multiplier"),
(val_div, ":improvement_cost", 20),
(assign, ":rate", 100),
#lumber yard bonus
(try_for_range, ":centers", centers_begin, centers_end),
(this_or_next|eq, ":centers", "$g_encountered_party"),
(party_slot_eq, ":centers", slot_village_bound_center, "$g_encountered_party"),
(party_slot_ge, ":centers", slot_center_has_lumber_yard, 1),
(val_add, ":rate", 5),
(try_end),
(store_div, ":improvement_time", ":improvement_cost", ":rate"),
(store_sqrt, ":base_time", ":improvement_cost"),
(val_div, ":base_time", 2),
(val_add, ":base_time", 3),
(val_add, ":improvement_time", ":base_time"),
(assign, reg5, ":improvement_cost"),
(assign, reg6, ":improvement_time"),
(try_begin),
(eq, ":max_skill_owner", "trp_player"),
(assign, reg3, 1),
(else_try),
(assign, reg3, 0),
(str_store_troop_name, s3, ":max_skill_owner"),
(try_end),
(set_fixed_point_multiplier, 100),
(position_set_x, pos0, 60),
(position_set_y, pos0, 30),
(position_set_z, pos0, 90), #scale
(set_game_menu_tableau_mesh, "tableau_troop_note_mesh", ":max_skill_owner", pos0),
(try_begin), #fast build
(eq, "$cheat_mode", 1),
(assign, reg6, 0),
(try_end),
],
[
("improve_cont",[(store_troop_gold, ":cur_gold", "trp_player"),
(store_troop_gold, ":cur_treasury", "trp_household_possessions"),
(val_max, ":cur_gold", ":cur_treasury"),
(ge, ":cur_gold", reg5)],
"Go on.", [(troop_remove_gold, "trp_player", reg5),
(call_script, "script_improve_center", "$g_encountered_party", reg6),
# (party_set_slot, "$g_encountered_party", slot_center_current_improvement, "$g_improvement_type"),
# (store_current_hours, ":cur_hours"),
# (store_mul, ":hours_takes", reg6, 24),
# (val_add, ":hours_takes", ":cur_hours"),
# (party_set_slot, "$g_encountered_party", slot_center_improvement_end_hour, ":hours_takes"),
(jump_to_menu,"mnu_center_manage"),
]),
("forget_it",[], "Forget it.", [(jump_to_menu,"mnu_center_manage")]),
],
),
Is that everything?
Nope, more stuff below
Code:
#script_initialize_improvement_info
("initialize_improvement_info",
[
#these slots determine the cost of improvements
(party_set_slot, "p_zendar", slot_center_has_manor, 8000),
(party_set_slot, "p_zendar", slot_center_has_mill, 6000),
(party_set_slot, "p_zendar", slot_center_has_watch_tower, 5000),
(party_set_slot, "p_zendar", slot_center_has_plantation, 10000),
(party_set_slot, "p_zendar", slot_center_has_lumber_yard, 12000),
(party_set_slot, "p_zendar", slot_center_has_school, 9000),
(party_set_slot, "p_zendar", slot_center_has_messenger_post, 4000),
(party_set_slot, "p_zendar", slot_center_has_prisoner_tower, 7000),
(party_set_slot, "p_zendar", slot_center_has_mercenary_hall, 10000),
(party_set_slot, "p_zendar", slot_center_has_merchant_guild, 25000),
(party_set_slot, "p_zendar", slot_center_has_academy, 60000),
(party_set_slot, "p_zendar", slot_center_has_foundry, 42000),
(party_set_slot, "p_zendar", slot_center_has_arsenal, 33000),
(party_set_slot, "p_zendar", slot_center_has_stables, 25000),
(party_set_slot, "p_zendar", slot_center_has_barrack, 27500),
(party_set_slot, "p_zendar", slot_center_has_shrange, 15000),
#string references are done via offsets
#assign static improvements to capitals - every city gets something?
#swadian
(party_set_slot, "p_town_6", slot_center_has_barrack, 1),
(party_set_slot, "p_town_7", slot_center_has_stables, 2),
(party_set_slot, "p_town_4", slot_center_has_stables, 3),
(party_set_slot, "p_town_16", slot_center_has_foundry, 3),
#vaegir
(party_set_slot, "p_town_2", slot_center_has_foundry, 2),
(party_set_slot, "p_town_8", slot_center_has_shrange, 4),
(party_set_slot, "p_town_9", slot_center_has_arsenal, 3),
#khergit
(party_set_slot, "p_town_10", slot_center_has_shrange, 3),
(party_set_slot, "p_town_17", slot_center_has_stables, 5),
(party_set_slot, "p_town_18", slot_center_has_arsenal, 2),
#nord
(party_set_slot, "p_town_1", slot_center_has_academy, 15),
(party_set_slot, "p_town_1", slot_center_has_foundry, 5),
(party_set_slot, "p_town_2", slot_center_has_barrack, 4),
#rhodok
(party_set_slot, "p_town_3", slot_center_has_barrack, 5),
(party_set_slot, "p_town_5", slot_center_has_arsenal, 3),
(party_set_slot, "p_town_5", slot_center_has_shrange, 4),
(party_set_slot, "p_town_15", slot_center_has_merchant_guild, 1),
#sarranid
(party_set_slot, "p_town_19", slot_center_has_foundry, 2),
(party_set_slot, "p_town_20", slot_center_has_arsenal, 2),
(party_set_slot, "p_town_21", slot_center_has_stables, 2),
(party_set_slot, "p_town_22", slot_center_has_barrack, 2),
(party_set_slot, "p_town_22", slot_center_has_shrange, 2),
]
),
("cf_center_infrastructure",
[
(store_script_param_1, ":center_no"),
(assign, ":end", military_infra_end),
(try_for_range, ":improvements", military_infra_begin, ":end"),
(party_slot_ge, ":center_no", ":improvements", 1),
(assign, ":end", 0),
(try_end),
(eq, ":end", military_infra_end),
]
),
#script_get_improvement_progress
# INPUT: arg1 = center_no
# OUTPUT: stuff and silly strings
("get_improvement_progress",
[(store_script_param, ":center_no", 1),
(try_begin),
(party_slot_eq, ":center_no", slot_party_type, spt_village),
(assign, ":begin", village_improvements_begin),
(assign, ":end", village_improvements_end),
(str_store_string, s17, "str_spt_village"),
(else_try),
(assign, ":begin", walled_center_improvements_begin),
(assign, ":end", walled_center_improvements_end),
(party_slot_eq, ":center_no", slot_party_type, spt_town),
(str_store_string, s17, "str_spt_town"),
(else_try),
(str_store_string, s17, "str_spt_castle"),
(try_end),
(str_clear, s50),
(str_clear, s51),
(str_clear, s52),
(assign, ":num_improvements", 0),
(try_for_range, ":improvement_no", ":begin", ":end"),
(party_get_slot, ":level", ":center_no", ":improvement_no"),
(gt, ":level", 0),
# (party_slot_ge, ":center_no", ":improvement_no", 1),
(store_sub, ":string", ":improvement_no", village_improvements_begin),
(val_add, ":string", "str_manor"),
(str_store_string, s52, ":string"),
(try_begin),
(is_between, ":improvement_no", military_infra_begin, military_infra_end),
(assign, reg9, ":level"),
(str_store_string, s52, "@{s52} (Level {reg9})"),
(try_end),
# (call_script, "script_get_improvement_details", ":improvement_no", 0, 1),
(try_begin),
(eq, ":num_improvements", 0),
(str_store_string_reg, s51, s52),
(else_try),
(str_store_string_reg, s50, s52),
(str_store_string, s51, "str_s50_comma_s51"),
(try_end),
(val_add, ":num_improvements", 1),
(try_end),
(assign, reg8, ":num_improvements"),
(store_sub, reg9, reg8, 1),
(str_store_party_name, s19, ":center_no"),
(str_store_string, s19, "@The {s17} of {s19} has {reg8?{reg9?the following improvements - :built a} {s51}:no improvements}."),
(assign, reg6, 0),
(try_begin),
(party_get_slot, ":cur_improvement", ":center_no", slot_center_current_improvement),
(gt, ":cur_improvement", 0),
# (call_script, "script_get_improvement_details", ":cur_improvement", 0, 1),
(val_sub, ":cur_improvement", village_improvements_begin),
(val_add, ":cur_improvement", "str_manor"),
(str_store_string, s7, ":cur_improvement"),
(assign, reg6, 1),
(store_current_hours, ":cur_hours"),
(party_get_slot, ":finish_time", ":center_no", slot_center_improvement_end_hour),
(val_sub, ":finish_time", ":cur_hours"),
(store_div, reg8, ":finish_time", 24),
(val_max, reg8, 1),
(store_sub, reg9, reg8, 1),
(try_end),
]),
("improve_center", [
(store_script_param_1, ":center_no"),
(store_script_param_2, ":improvement_time"),
(party_set_slot, ":center_no", slot_center_current_improvement, "$g_improvement_type"),
(store_current_hours, ":cur_hours"),
(store_mul, ":hours_takes", ":improvement_time", 24),
(val_add, ":hours_takes", ":cur_hours"),
(party_set_slot, ":center_no", slot_center_improvement_end_hour, ":hours_takes"),
]),