gaston
Sergeant
Updated April 26, 2011.
Okay, I'm declaring victory on the Wagon Train code. The intent of the wagon train is to give the player character a place to store inventory and troops. The wagon train only has two missions: to accompany the player party or to stay and wait. I think this will be useful for players (especially players who don't belong to a faction) to make their party smaller so they can move faster ( for example to catch bandits). With a wagon train you don't have to disband troops to gain speed.
Updated May 3, 2011. Changed the budget report code thanks to advice from
Step 1. Add a wagon_master to troops. Just copy and rename the caravan master. Give him "knows_pathfinding_10" so he can keep up. Add this troop under household_possessions:
["wagon_possessions","{!}wagon_possessions","{!}wagon_possessions",tf_hero|tf_inactive|tf_is_merchant, 0,reserved, fac_neutral,[],def_attrib|level(1,wp(60),knows_inventory_management_10, 0],
Step 2. Add this to parties, I put mine right under the salt mine:
("wagon_train","Wagon Train",pf_disabled|icon_gray_knight|carries_goods(20), no_menu, pt_none, fac_player_faction,0,escorted_merchant_personality,0,(-5.23,90.26),[(trp_wagon_master,1,0)]),
Step 3. In module_game_menus add the following to the camp menu right before ("resume_travelling",[],"Resume travelling.",
Step 4. In module_dialogs add the following, I put mine under the escort merchant dialog:
Step 5. Put the wagon train on the payroll. Wagon Train troops cost more than troops in the players party because you don't have to buy food for them. You pay them more and they buy their own food. In module_presentations add the following changes to the budget report right below "(this_or_next|eq, ":party_no", "p_main_party")," additions are shown in green.
(this_or_next|eq, ":party_no", "p_main_party"),
(this_or_next|eq, ":party_no", "p_wagon_train"),
(eq, ":garrison_troop", 1),
(assign, ":total_wage", 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_troop_wage", ":stack_troop", ":party_no"),
(assign, ":cur_wage", reg0),
(val_mul, ":cur_wage", ":stack_size"),
(val_add, ":total_wage", ":cur_wage"),
(try_begin),
(eq, ":garrison_troop", 1),
(val_div, ":total_wage", 2), #Half payment for garrisons
(else_try),
(eq, ":party_no", "p_main_party"),
(store_sub, ":total_payment_ratio", 14, "$g_cur_week_half_daily_wage_payments"), #between 0 and 7
(val_mul, ":total_wage", ":total_payment_ratio"),
(val_div, ":total_wage", 14),
(else_try),
(eq, ":party_no", "p_wagon_train"),
(party_get_num_companions, ":num_troops", ":party_no"), ## headcount for food cost
(val_mul, ":num_troops", 12), ##approx weekly food consumption
(store_sub, ":total_payment_ratio", 14, "$g_cur_week_half_daily_wage_payments"), #between 0 and 7
(val_mul, ":total_wage", ":total_payment_ratio"),
(val_div, ":total_wage", 14),
(val_add, ":total_wage", ":num_troops"), ##food cost
(try_end),
## (gt, ":total_wage", 0)
That's it.
I would like to make it clear that this was mostly not my original work. I simply put together bits of existing code. Thanks to everyone for their advice and special thanks to Lumos.
Okay, I'm declaring victory on the Wagon Train code. The intent of the wagon train is to give the player character a place to store inventory and troops. The wagon train only has two missions: to accompany the player party or to stay and wait. I think this will be useful for players (especially players who don't belong to a faction) to make their party smaller so they can move faster ( for example to catch bandits). With a wagon train you don't have to disband troops to gain speed.
Updated May 3, 2011. Changed the budget report code thanks to advice from
Step 1. Add a wagon_master to troops. Just copy and rename the caravan master. Give him "knows_pathfinding_10" so he can keep up. Add this troop under household_possessions:
["wagon_possessions","{!}wagon_possessions","{!}wagon_possessions",tf_hero|tf_inactive|tf_is_merchant, 0,reserved, fac_neutral,[],def_attrib|level(1,wp(60),knows_inventory_management_10, 0],
Step 2. Add this to parties, I put mine right under the salt mine:
("wagon_train","Wagon Train",pf_disabled|icon_gray_knight|carries_goods(20), no_menu, pt_none, fac_player_faction,0,escorted_merchant_personality,0,(-5.23,90.26),[(trp_wagon_master,1,0)]),
Step 3. In module_game_menus add the following to the camp menu right before ("resume_travelling",[],"Resume travelling.",
Code:
("camp_wagon",[(eq, "$wagon_active", 0)],"Form a wagon train",
[(set_spawn_radius, 1),
(party_relocate_near_party, "p_wagon_train", "p_main_party", 1), (enable_party, "p_wagon_train"),
(assign, "$wagon_active", 1),
(display_message, "@Wagon train formed nearby."),
]
),
Step 4. In module_dialogs add the following, I put mine under the escort merchant dialog:
Code:
[trp_wagon_master,"start", [],
"What can I do for you, chief?", "wagon_train_talk",[]],
[anyone|plyr,"wagon_train_talk", [], "You follow my lead and try to stay out of trouble.", "wagon_train_follow_lead",[]],
[anyone,"wagon_train_follow_lead", [], "Alright. We'll be right behind you.", "close_window"[(party_set_ai_behavior, "$g_encountered_party", ai_bhvr_escort_party),
(party_set_ai_object,"$g_encountered_party", "p_main_party"),
(assign, "$g_leave_encounter", 1)]],
[anyone|plyr,"wagon_train_talk", [], "You stay here. I'll be back in a while.", "wagon_train_stay_here",[]],
[anyone,"wagon_train_stay_here", [], "Alright. We'll be waiting here for you.", "close_window",[(party_set_ai_behavior, "$g_encountered_party", ai_bhvr_hold),
(assign, "$g_leave_encounter", 1)]],
[anyone|plyr,"wagon_train_talk", [], "Let's check the inventory.", "start",[(change_screen_loot, "trp_wagon_possessions"),]],
[anyone|plyr,"wagon_train_talk", [], "Let's check the troop assignments.", "start",[(change_screen_exchange_members, "$g_talk_troop_party"),]],
[anyone|plyr, "wagon_train_talk", [], "I want to disband the wagon train.", "wagon_train_disband1", []],
[anyone,"wagon_train_disband1", [(party_get_num_companions,":num_troops","$g_encountered_party"),(gt,":num_troops",1)],
"Are you sure? I still have troops.", "wagon_train_disband2",[]],
[anyone,"wagon_train_disband1", [(party_get_num_companions,":num_troops","$g_encountered_party"),(eq,":num_troops",1)],
"All right. I'll see you around.", "close_window",[(party_clear,"p_wagon_train"),
(party_add_members,"p_wagon_train","trp_wagon_master",1),
(disable_party, "p_wagon_train"),
(assign, "$wagon_active", 0), # To allow for creation of another one
]],
[anyone|plyr, "wagon_train_disband2", [], "Yes, I want to disband the wagon train.", "close_window", [(party_clear,"p_wagon_train"),
(party_add_members,"p_wagon_train","trp_wagon_master",1),
(disable_party, "p_wagon_train"),
(assign, "$wagon_active", 0), # To allow for creation of another one
]],
[anyone|plyr, "wagon_train_disband2", [], "Wait. I want to look at the troops.", "start", [(change_screen_exchange_members, "$g_talk_troop_party"),]],
[anyone|plyr,"wagon_train_talk", [], "Keep up the good work.", "close_window",[(assign, "$g_leave_encounter", 1)]],
Step 5. Put the wagon train on the payroll. Wagon Train troops cost more than troops in the players party because you don't have to buy food for them. You pay them more and they buy their own food. In module_presentations add the following changes to the budget report right below "(this_or_next|eq, ":party_no", "p_main_party")," additions are shown in green.
(this_or_next|eq, ":party_no", "p_main_party"),
(this_or_next|eq, ":party_no", "p_wagon_train"),
(eq, ":garrison_troop", 1),
(assign, ":total_wage", 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_troop_wage", ":stack_troop", ":party_no"),
(assign, ":cur_wage", reg0),
(val_mul, ":cur_wage", ":stack_size"),
(val_add, ":total_wage", ":cur_wage"),
(try_begin),
(eq, ":garrison_troop", 1),
(val_div, ":total_wage", 2), #Half payment for garrisons
(else_try),
(eq, ":party_no", "p_main_party"),
(store_sub, ":total_payment_ratio", 14, "$g_cur_week_half_daily_wage_payments"), #between 0 and 7
(val_mul, ":total_wage", ":total_payment_ratio"),
(val_div, ":total_wage", 14),
(else_try),
(eq, ":party_no", "p_wagon_train"),
(party_get_num_companions, ":num_troops", ":party_no"), ## headcount for food cost
(val_mul, ":num_troops", 12), ##approx weekly food consumption
(store_sub, ":total_payment_ratio", 14, "$g_cur_week_half_daily_wage_payments"), #between 0 and 7
(val_mul, ":total_wage", ":total_payment_ratio"),
(val_div, ":total_wage", 14),
(val_add, ":total_wage", ":num_troops"), ##food cost
(try_end),
## (gt, ":total_wage", 0)
That's it.
I would like to make it clear that this was mostly not my original work. I simply put together bits of existing code. Thanks to everyone for their advice and special thanks to Lumos.