Help with change_screen_buy_mercenaries

Users who are viewing this thread

McRoddy

Recruit
Hey all.  I have been looking at python code forever now and am starting to get it.  Can anyone tell me if there is a way to pull directly from the party being talked to when using the buy_mercenaries script?  I am creating a new temp_party that is adding troops I list to.  Was wondering if there was a way to pull from the party and not pull the entire party but just a random amount.

[party_tpl|pt_manhunters,"start", [(eq,"$talk_context",tc_party_encounter)], "Hey, you there! You seen any outlaws around here?", "manhunter_talk_b",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_b", [], "Yes, they went this way about an hour ago.", "manhunter_talk_b1",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_b1", [], "I knew it! Come on, lads, lets go get these bastards! Thanks a lot, friend.  Did you need anything?", "manhunter_talk_c1",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_b", [], "No, haven't seen any outlaws lately.", "manhunter_talk_b2",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_b2", [], "Bah. They're holed up in this country like rats, but we'll smoke them out yet. Sooner or later.  Did you need anything?", "manhunter_talk_c1",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_c1", [], "Do you have any men that I can contract?","manhunter_talk_d1",[]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_c1", [], "Would you take some prisoners off my hands?  I'm sure they are worth something to you, lads.", "manhunter_talk_c2",[[store_num_regular_prisoners,reg(0)],[ge,reg(0),1]]],
  [party_tpl|pt_manhunters|plyr,"manhunter_talk_c1", [], "No thank you.", "close_window",[(assign, "$g_leave_encounter",1)]],
  [party_tpl|pt_manhunters,"manhunter_talk_c2", [], "Of course!  The more of those bastards we get, the better our families will eat!", "manhunter_talk_c3",[[change_screen_trade_prisoners]]],
  [party_tpl|pt_manhunters,"manhunter_talk_c3", [], "Thanks for catching this scum for us.  Anything else?", "manhunter_talk_c1",[]],
  [party_tpl|pt_manhunters,"manhunter_talk_d1", [], "Sure.  How much you got?  They don't come cheap.", "manhunter_talk_d2",[
      (assign, "$g_move_heroes", 1),
      (call_script, "script_party_remove_all_companions", "p_temp_party_2"),
      (call_script, "script_party_remove_all_prisoners", "p_temp_party_2"),
      (store_random_in_range, reg(0), 0, 10),
      (store_random_in_range, reg(1), 0, 5),
      (store_random_in_range, reg(2), 0, 3),
      (store_random_in_range, reg(3), 0, 2),
      (store_random_in_range, reg(4), 0, 1),
      (party_add_members,"p_temp_party_2","trp_manhunter",reg(0)),
      (party_add_members,"p_temp_party_2","trp_bounty_hunter",reg(1)),
      (party_add_members,"p_temp_party_2","trp_order_guard",reg(2)),
      (party_add_members,"p_temp_party_2","trp_law_enforcer",reg(3)),
      (party_add_members,"p_temp_party_2","trp_warrant_officer",reg(4)),
      (set_mercenary_source_party,"p_temp_party_2"),
      [change_screen_buy_mercenaries]]],
  [party_tpl|pt_manhunters,"manhunter_talk_d2", [], "Treat them well.  They're great at taking scum as prisoner.  Anything else?", "manhunter_talk_c1",[]],

Thanks for any help.
 
hmm well there would be a couple of ways..

You can use one of the global variables that get set when you encounter a party: $g_encountered_party

So then you can just use that party as your mercenary source party. If you use the store_random_in_range the way you did, it'll exclude some while adding others.

However for realism sake, you might want to make it so that the maximum range of the random is the maximum number available.

Something like:

Code:
(party_get_num_companion_stacks, ":num_stacks","$g_encountered_party"),
(try_for_range, ":i_stack", 0, ":num_stacks"),
	(party_stack_get_troop_id, ":temp_id", ":cur_object", ":i_stack"),
	(party_stack_get_size, ":stack_size",":cur_object",":i_stack"),
	(store_random_in_range, ":random", 0, ":stack_size"),
	(party_add_members,"p_temp_party_2",":temp_id",":random"),
(try_end),

So this will go over each stack in the source party, find out what type of troop they are, how many of them there are and then add a random number to the final source party you will draft your troops from.

What you could also consider is to make a more elaborate system, either based on a certain chance that the whole stack will be for hire (for instance: roll a 100 sided die, if the outcome is under 50, the whole stack will join, otherwise, the whole stack won't join). Or even better, use the players persuasion skill as a guide, for instance adding only a fairly low amount initially, but adding 1 for each lvl of persuasion.

In that case you could use val_clamp so the maximum number doesn't exceed the number in the source party:

(assign, ":join_number", 4),
(store_skill_level , ":player_skill", "skl_persuasion", "trp_player),
(val_add, ":join_number", ":player_skill"),
(val_clamp, ":join_number", 0, ":stack_size"),

that would go in the code block I pasted above, and you'd have to change some of the variable names to match up.

Also note that we've found out that using low randoms is not very random. So instead of doing just a random, 0, stack_size, it might be better to val_mul the stack_size before val_div it again. So do (val_mul, ":stack_size", 10), then do the store_random_in_range and then do (val_div, ":random"),

So there's some options. Of course doing it this way means the units won't actually be gone from the source party since you're just copying them. If you want that, you'd have to remove them from the source party, add them to the temp_party and then after you're done shopping for mercs, you copy the contents of the temp party back to the source party. The game actually has a couple of scripts you can use for this, if you don't want to write the code yourself.

Look for;

#script_party_copy

There's a couple of different ones around there.

Plenty of options :)
 
Back
Top Bottom