OSP Code QoL Working in the Salt Mine + Slave Labor

Users who are viewing this thread

Keedo420

Knight at Arms
In my mod, I have added the option to work in the Salt Mine as a way to earn some extra gold. It works basically the same as resting in a town, but the player earns gold instead of losing it.

EDIT: With no troops, the player gets 5 gold per day. With 10 troops, the player gets 45 gold per day. The player may randomly find new salt, iron, silver, gold, or mineral deposits, thus increasing his pay for that day. However, while mining you can be attacked and there is the possibility that you and/or your troops may be injured by cave-ins. It is also possible some of your troops may be killed.

EDIT 2: I have now included the option to put your prisoners to work in the Salt Mine. After putting prisoners to work in the salt mine, you will earn gold based on the number of prisoners working.

EDIT 3: There is now a chance that some prisoners will escape, but you can station troops to help prevent it from happening. The script isn't perfect yet, but here is what I have so far:

In module_game_menus:
  (
    "salt_mine",mnf_enable_hot_keys,
    "You arrive at a small mining camp.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55)],
    [
      ("enter",[],"Approach the camp.",[(set_jump_mission,"mt_town_center"),(jump_to_scene,"scn_salt_mine"),(change_screen_mission)]),
      ("talk_merchant",[]
          ,"Talk to the Mine Merchant.",
          [
              (assign, "$talk_context", 0),
          (assign, ":eek:verride_state", af_override_horse),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 0, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 2, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 3, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 4, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 5, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 6, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 7, ":eek:verride_state"),
              (jump_to_scene, "scn_salt_mine"),
              (change_screen_map_conversation, "trp_salt_mine_merchant"),
          ],"Exit to the camp."),
      ("work_mines",
      [
          (store_troop_health, "$g_player_health","trp_player", 1),
        (str_clear, s1),
          (party_get_num_companions, ":num_men", "p_main_party"),
          (store_mul, reg1, ":num_men", 4),
          (val_add, reg1, 1),
          (str_store_string, s1, "@ ({reg1} denars per day)"),
        ],
        "Volunteer to work in the mines{s1}.",
        [
          (try_begin),
          (neg|gt, "$g_player_health", 20),
          (display_message, "@You are in no condition to work."),
          (jump_to_menu,"mnu_salt_mine"),
        (else_try),
          (assign, "$g_is_working", 1),
          (assign, "$g_last_rest_payment_until", -1),
            (rest_for_hours_interactive, 24, 5, 1), #rest while attackable
            (change_screen_return),
        (try_end),
          ]),
      ("add_prisoners",
      [
        (str_clear, s1),
        (party_get_num_prisoners, "$g_num_prisoners", "p_salt_mine"),
        (assign, reg1, "$g_num_prisoners"),
          (str_store_string, s1, "@ (Currently {reg1} prisoners working)"),
        ],
        "Put prisoners to work in the mines{s1}.",
        [
          (change_screen_exchange_members, 0),
          ]),
      ("add_guards",
      [
        (str_clear, s1),
        (party_get_num_companions, "$g_num_guards", "p_salt_mine"),
        (assign, reg1, "$g_num_guards"),
          (str_store_string, s1, "@ (Currently {reg1} guards on duty)"),
        ],
        "Station guards to watch over prisoners{s1}.",
        [
          (change_screen_exchange_members, 0),
          ]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),

  (
    "slave_labor",mnf_disable_all_keys,
    "{s1}",
    "none",
    [
          (str_clear, s1),
        (assign, reg1, "$g_earnings"),
          (troop_add_gold, "trp_player", "$g_earnings"),
        (try_begin),
          (gt, "$g_num_escapees", 0),
        (str_store_string, s1, "@Some of the prisoners you have working in the mine managed to escape.^The remaining prisoners earned you {reg1} denars this week."),
        (else_try),
          (str_store_string, s1, "@The prisoners you have working in the mine earned you {reg1} denars this week."),
        (try_end),
      ],
    [
      ("continue",[], "Continue...",
      [
          (change_screen_return),
        ]),
    ],
  ),

In module_simple_triggers:
  # Pay denars to player while working in mines
  (1,
  [(try_begin),
      (eq, "$g_is_working", 1),
      (neg|map_free),
      (is_currently_night),
      (store_current_hours, ":cur_hours"),
      (ge, ":cur_hours", "$g_last_rest_payment_until"),
      (store_add, "$g_last_rest_payment_until", ":cur_hours", 24),
      (party_get_num_companions, ":num_men", "p_main_party"),
      (store_mul, ":total_pay", ":num_men", 4),
      (val_add, ":total_pay", 1),
      (display_message, "@You are paid for your labor."),
      (troop_add_gold, "trp_player", ":total_pay"),
    (call_script, "script_mine_work"),
    (assign, "$g_is_working", 0),
  (try_end),
    ]),

# Pay slave labor earnings and check for prisoners escaping
  (24 * 7,
  [
    (try_begin),
    (gt, "$g_num_prisoners", 0),
    (assign, "$g_earnings", 0),
    (assign, "$g_num_escapees", 0),
      (try_for_range, ":center_no", "p_salt_mine", "p_test_scene"),
      (party_get_num_companions,"$g_num_guards",":center_no"),
      (party_get_num_prisoners, "$g_num_prisoners", ":center_no"),
        (store_sub, ":difference", "$g_num_prisoners", "$g_num_guards"),
      (try_begin),
        (gt, ":difference", 0),
        (store_random_in_range, ":random", 0, ":difference"),
        (try_begin),
          (gt, ":random", 5),
        (store_random_in_range, ":escapees", 0, ":difference"),
        (try_begin),
          (eq, ":escapees", 0),
          (assign, ":escapees", 1),
        (try_end),
        (assign, "$g_num_escapees", ":escapees"),
            (party_get_num_prisoner_stacks, ":num_stacks", ":center_no"),
            (try_for_range_backwards, ":troop_iterator", 0, ":num_stacks"),
              (party_prisoner_stack_get_troop_id, ":cur_troop_id", ":center_no", ":troop_iterator"),
              (party_prisoner_stack_get_size, ":stack_size", ":center_no", ":troop_iterator"),
          (try_begin),
            (gt, ":escapees", 0),
            (try_begin),
              (gt, ":stack_size", ":escapees"),
                  (store_sub, ":stack_sub", ":stack_size", ":escapees"),
              (val_sub, ":escapees", ":stack_sub"),
              (party_remove_prisoners, ":center_no", ":cur_troop_id", ":stack_sub"),
            (try_end),
          (try_end),
            (try_end),
        (try_end),
      (try_end),
      (party_get_num_prisoners, "$g_num_prisoners", ":center_no"),
      (store_mul, ":earnings", 10, "$g_num_prisoners"),
        (val_add, "$g_earnings", ":earnings"),
      (jump_to_menu,"mnu_slave_labor"),
      (try_end),
    (try_end),
    ]),

In module_scripts:
# Working in the mines
  ("mine_work",
  [(assign, ":party_no", "p_main_party"),
    (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
    (store_random_in_range, ":random", 0, 10),
    (try_begin),
      (le, ":random", 3),
  (troop_set_health, "trp_player", 80),
(else_try),
  (eq, ":random", 4),
  (troop_set_health, "trp_player", 70),
  (store_random_in_range, ":random_gold", 0, 10),
  (try_begin),
    (le, ":random_gold", 5),
(display_message, "@While working in the mine, you found a new salt deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 10, 100),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 6),
(display_message, "@While working in the mine, you found an iron deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 50, 200),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 7),
(display_message, "@While working in the mine, you found a silver deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 75, 300),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 8 ),
(display_message, "@While working in the mine, you found a gold deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 100, 400),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 9),
(display_message, "@While working in the mine, you found a deposit of rare minerals and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 150, 500),
(troop_add_gold, "trp_player", ":random_amount"),
  (try_end),
(else_try),
  (eq, ":random", 5),
  (troop_set_health, "trp_player", 50),
  (display_message, "@While working in the mine, you were injured during a minor cave-in."),
(else_try),
  (eq, ":random", 6),
  (troop_set_health, "trp_player", 30),
  (display_message, "@While working in the mine, you were hurt during a cave-in."),
(else_try),
  (eq, ":random", 7),
  (troop_set_health, "trp_player", 1),
  (display_message, "@While working in the mine, you were nearly killed during a cave-in."),
(else_try),
  (eq, ":random", 8 ),
  (try_begin),
    (gt, ":num_stacks", 0),
    (call_script, "script_party_wound_all_members", ":party_no"),
    (display_message, "@While working in the mine, you and your troops are wounded during a cave-in."),
  (else_try),
    (troop_set_health, "trp_player", 1),
    (display_message, "@While working in the mine, you were nearly killed during a cave-in."),
  (try_end),
(else_try),
  (eq, ":random", 9),
  (try_begin),
    (gt, ":num_stacks", 0),
    (troop_set_health, "trp_player", 50),
(store_random_in_range, ":random_deaths", 1, 10),
        (inflict_casualties_to_party_group, ":party_no", ":random_deaths", "p_temp_casualties"),
        (call_script, "script_print_casualties_to_s0", "p_temp_casualties", 0),
(str_store_string_reg, s8, s0),
(display_message, "@While working in the mine, a massive cave-in caused your party casualties: {s8}"),
  (else_try),
    (troop_set_health, "trp_player", 1),
    (display_message, "@While working in the mine, you were nearly killed during a cave-in."),
  (try_end),
(try_end),
  ]),
 
sweet idea! I'm working on implementing mines myself (as a place for all those damned prisoners to go to so they don't fill up every town and castle so I might borrow this as an add-on to that if you don't mind.

Will have a look at the actual code in a minute but for now for the balance thing:

working in the mines is pretty dangerous, so rather than not gain health, you should lose some. Also, you could implement random deaths to the player's troops to make this less easily exploitable as a goldmine (pardon the pun) for the player. Of course he could still go off get a stack full of recruits and work them to death in the mines, but if you limit the maximum time he himself can spend there (say making it so after roughly a week he would've lost all his health), it will be less easy. Also you could make the party take a morale hit for this, it's obviously not going to sit very well with mercenaries to work in the mines when they signed on to gain wealth and glory on the battlefield.

[edit] I'm pretty sure you can only use agent tags in missions (i.e. in scenes).

store_troop_health
troop_set_health

These are the two you'll want to be using instead. The troop health is set as a percentage, so health 80 = 80% of total.
 
That actually makes sense. I might even change it so that the number of prisoners in your party increases how much you get paid. The random deaths would fit well into another idea I had which was a random events script which would have random things such as discovering a gold vein or rare gemstones, accidental cave-ins, or maybe even randomly getting attacked by bandits while working (switching to an underground battle scene similar to the dungeon in my mod).
 
@ KEEDO...

nice idea!!! but, in which lines you have to put your brackets...

or can I add it at last position before " ] "


:idea:


thanx
 
timedanze said:
@ KEEDO...

nice idea!!! but, in which lines you have to put your brackets...

or can I add it at last position before " ] "

Well, the salt mine menu is already in module_game_menus. You could just copy the code for it I posted above and paste it over the existing menu. As for the simple trigger, in mine I put it right below the simple trigger that deducts money when resting at a town. Do a search for "# Spawn some bandits" and paste the code above that, but I don't think it matters where it is as long as it is before the last "]". You would also have to open up module_parties and remove the pf_disabled flag from the salt_mine party so it shows up on the map if you haven't already done so.
 
thank you for info! i will try!!  :cool:

edit:

you mean:

"salt_mine",mnf_auto_enter,
    "You enter the salt mine.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55)],
    [
      ("enter",[],"Enter.",[(set_jump_mission,"mt_town_center"),(jump_to_scene,"scn_salt_mine"),(change_screen_mission)]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),




????

but isn´t it for ZENDAR TOWN?? (above there are triggers for Zendar)
 
I personally always add my simple triggers at the end of the file, same with scripts, just before the last closing bracket. That way they're all neatly in one place and you won't have to search through the file to find em. Since it really doesn't matter where they are anyway, I find this a lot easier.

Same with game menus, new menus go at the bottom. Obviously if you add options to existing menus, they have to be put in those particular menus.

Keedo, did you try it with the new operations I put in my post?
 
MartinF said:
I personally always add my simple triggers at the end of the file, same with scripts, just before the last closing bracket. That way they're all neatly in one place and you won't have to search through the file to find em. Since it really doesn't matter where they are anyway, I find this a lot easier.

Same with game menus, new menus go at the bottom. Obviously if you add options to existing menus, they have to be put in those particular menus.

Keedo, did you try it with the new operations I put in my post?

thank you for your hints!! maybe one day I will be a good modder like you, JIK or Keedo...
thanx... - cause at the moment I am really a newbie in case of modding...
 
we all have to start somewhere, mate, and if it's any consolation, I didn't start modding MNB (or any game for that matter) until like 3 weeks ago. So stick with it and if you put in the effort, you'll learn fast.


the salt mine menu is for the salt mine (hence the name :wink: ) I think it's near the Zendar stuff because all the old unused game code is in that area.

Of course for it to work you'll have to put the salt mine back on the map, etc.
 
(assign, "$g_last_rest_payment_until", -1),
          (get_player_agent_no, ":player_agent"), # I added these two lines to store the player's hitpoints before resting
          (store_agent_hit_points,"$g_player_health",":player_agent",1),
          (rest_for_hours_interactive, 24 * 7, 5, 0), #rest while not attackable
          (change_screen_return),

Is that what gives you health?
And one more idea is we can make a script that adds positions for men, like 200 max, every one soldier 5 gold?
If possible but i think it is, and we could use the belfry script? or is that script just for scenes?
 
MartinF said:
[edit] I'm pretty sure you can only use agent tags in missions (i.e. in scenes).

store_troop_health
troop_set_health

These are the two you'll want to be using instead. The troop health is set as a percentage, so health 80 = 80% of total.
Well crap. I searched for a troop_set_health in header_operations, but did not find it for some reason.  :sad: Maybe I misspelled it. I'll try those tags after I get home from work.
 
so from menu_parties.py

("salt_mine","Salt_Mine",icon_village_a|pf_is_static|pf_always_visible|pf_hide_defenders, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(14.2, -31),[]),


i deleted pf_disable BUT I can´t see it on map  :oops:
where is it??
 
timedanze said:
so from menu_parties.py

("salt_mine","Salt_Mine",icon_village_a|pf_is_static|pf_always_visible|pf_hide_defenders, no_menu, pt_none, fac_neutral,0,ai_bhvr_hold,0,(14.2, -31),[]),


i deleted pf_disable BUT I can´t see it on map  :oops:
where is it??

at 14,2 and -31 :smile:

Easiest way is to open the map in the map editor (over in the Unofficial Mod Tools forum) and you'll be able to see it even if it doesn't show up in the game.

If it still doesn't work, just copy paste another town or village and rename that to salt_mine and change the coordinates a little. Of course comment out the original if you're going to do that
 
Cool, I'll be having mining and tree cutting in my mod, so this will help me as well.  Thanks for the complement, but I too am a rookie.  Working on the tutorial system and help from the community got me to where I am now.  Keep at what you are doing, and to thank us, release you scripts as a kit for all to benefit from.  When those starting to learn see how things are implemented, it makes it easier to understand (and put comments!)
 
OK, so that worked. More or less. :smile: The player still heals while working but I've added a random events script that will either reward the player or injure them and/or the troops. I've also changed it so the player can be attacked while working though it is currently a map battle and doesn't take place inside the mine. I have not been attacked yet, possibly due to the placement of the mines and the fact that I've only gone a couple days into the game, so the battle probably takes place in the Salt Mines scene like when you are attacked while resting at a village. Anyway, here's what I have come up with:

In module_game_menus:
  (
    "salt_mine",mnf_enable_hot_keys,
    "You arrive at a small mining camp.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55)],
    [
      ("enter",[],"Approach the camp.",[(set_jump_mission,"mt_town_center"),(jump_to_scene,"scn_salt_mine"),(change_screen_mission)]),
      ("talk_merchant",[]
          ,"Talk to the Mine Merchant.",
          [
              (assign, "$talk_context", 0),
    (assign, ":eek:verride_state", af_override_horse),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 0, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 2, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 3, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 4, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 5, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 6, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 7, ":eek:verride_state"),
              (jump_to_scene, "scn_salt_mine"),
              (change_screen_map_conversation, "trp_salt_mine_merchant"),
          ],"Exit to the camp."),
      ("work_mines",
      [
          (store_troop_health, "$g_player_health","trp_player", 1), # Store player's current hitpoints
        (str_clear, s1),
          (party_get_num_companions, ":num_men", "p_main_party"),
          (store_mul, reg1, ":num_men", 4),
          (val_add, reg1, 1),
          (str_store_string, s1, "@ ({reg1} denars per day)"),
        ],
        "Volunteer to work in the mines{s1}.",
        [
          (try_begin),
      (neg|gt, "$g_player_health", 20), # Check if player is too injured to work
    (display_message, "@You are in no condition to work."),
    (jump_to_menu,"mnu_salt_mine"),
    (else_try),
      (assign, "$g_last_rest_payment_until", -1),
            (rest_for_hours_interactive, 24 * 7, 5, 1), #rest while attackable
            (change_screen_return),
    (try_end),
          ]),
      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),

In module_simple_triggers:
  # Pay denars to player while working in mines
  (1,
  [(neg|map_free),
    (is_currently_night),
    (store_current_hours, ":cur_hours"),
    (ge, ":cur_hours", "$g_last_rest_payment_until"),
    (store_add, "$g_last_rest_payment_until", ":cur_hours", 24),
    (party_get_num_companions, ":num_men", "p_main_party"),
    (store_mul, ":total_pay", ":num_men", 4),
    (val_add, ":total_pay", 1),
    (display_message, "@You are paid for your labor."),
    (troop_add_gold, "trp_player", ":total_pay"),
(call_script, "script_mine_work"), # Script to check for random events while mining
    ]),

In module_scripts:
# Working in the mines
  ("mine_work",
  [(assign, ":party_no", "p_main_party"),
    (party_get_num_companion_stacks, ":num_stacks", ":party_no"),
    (store_random_in_range, ":random", 0, 10),
    (try_begin),
      (le, ":random", 3),
  (troop_set_health, "trp_player", 80),
(else_try),
  (eq, ":random", 4),
  (troop_set_health, "trp_player", 70),
  (store_random_in_range, ":random_gold", 0, 10),
  (try_begin),
    (le, ":random_gold", 5),
(display_message, "@While working in the mine, you found a new salt deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 10, 100),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 6),
(display_message, "@While working in the mine, you found an iron deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 50, 200),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 7),
(display_message, "@While working in the mine, you found a silver deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 75, 300),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 8 ),
(display_message, "@While working in the mine, you found a gold deposit and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 100, 400),
(troop_add_gold, "trp_player", ":random_amount"),
  (else_try),
    (eq, ":random_gold", 9),
(display_message, "@While working in the mine, you found a deposit of rare minerals and are rewarded for the discovery."),
(store_random_in_range, ":random_amount", 150, 500),
(troop_add_gold, "trp_player", ":random_amount"),
  (try_end),
(else_try),
  (eq, ":random", 5),
  (troop_set_health, "trp_player", 50),
  (display_message, "@While working in the mine, you were injured during a minor cave-in."),
(else_try),
  (eq, ":random", 6),
  (troop_set_health, "trp_player", 30),
  (display_message, "@While working in the mine, you were hurt during a cave-in."),
(else_try),
  (eq, ":random", 7),
  (troop_set_health, "trp_player", 1),
  (display_message, "@While working in the mine, you were nearly killed during a cave-in."),
(else_try),
  (eq, ":random", 8 ),
  (try_begin),
    (gt, ":num_stacks", 0),
    (call_script, "script_party_wound_all_members", ":party_no"),
    (display_message, "@While working in the mine, you and your troops are wounded during a cave-in."),
  (else_try),
    (troop_set_health, "trp_player", 1),
    (display_message, "@While working in the mine, you were nearly killed during a cave-in."),
  (try_end),
(else_try),
  (eq, ":random", 9),
  (try_begin),
    (gt, ":num_stacks", 0),
    (troop_set_health, "trp_player", 50),
(store_random_in_range, ":random_deaths", 1, 10),
        (inflict_casualties_to_party_group, ":party_no", ":random_deaths", "p_temp_casualties"),
        (call_script, "script_print_casualties_to_s0", "p_temp_casualties", 0),
(str_store_string_reg, s8, s0),
(display_message, "@While working in the mine, a massive cave-in caused your party casualties: {s8}"),
  (else_try),
    (troop_set_health, "trp_player", 1),
    (display_message, "@While working in the mine, you were nearly killed during a cave-in."),
  (try_end),
(try_end),
  ]),
 
As you can see in this screenshot, I got it working where your troops can be killed, though the message displays a little oddly.
 
OK, so now I am trying to add the option to let players use prisoners as slave labor in the salt mine. The slave labor would accumulate earnings similar to how fiefs accumulate taxes and the player would collect those earnings in the same way that they collect taxes from their fiefs (by visiting them). Here's what I have so far:

In module_game_menus:
  (
    "salt_mine",mnf_enable_hot_keys,
    "You arrive at a small mining camp.",
    "none",
    [(reset_price_rates,0),(set_price_rate_for_item,"itm_salt",55),
          #Adding earnings to player if player has added prisoners to slave labor
        (try_begin),
  (party_slot_gt, "p_salt_mine", slot_center_slave_labor, 0),
          (party_get_slot, ":accumulated_earnings", "p_salt_mine", slot_center_accumulated_rents),
          (gt, ":accumulated_earnings", 0),
          (jump_to_menu, "mnu_slave_labor"),
        (try_end),
],
    [
      ("enter",[],"Approach the camp.",[(set_jump_mission,"mt_town_center"),(jump_to_scene,"scn_salt_mine"),(change_screen_mission)]),
      ("talk_merchant",[]
          ,"Talk to the Mine Merchant.",
          [
              (assign, "$talk_context", 0),
  (assign, ":eek:verride_state", af_override_horse),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 0, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 2, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 3, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 4, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 5, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 6, ":eek:verride_state"),
              (mission_tpl_entry_set_override_flags, "mt_town_center", 7, ":eek:verride_state"),
              (jump_to_scene, "scn_salt_mine"),
              (change_screen_map_conversation, "trp_salt_mine_merchant"),
          ],"Exit to the camp."),
      ("work_mines",
      [
          (store_troop_health, "$g_player_health","trp_player", 1),
  (str_clear, s1),
          (party_get_num_companions, ":num_men", "p_main_party"),
          (store_mul, reg1, ":num_men", 4),
          (val_add, reg1, 1),
          (str_store_string, s1, "@ ({reg1} denars per day)"),
        ],
        "Volunteer to work in the mines{s1}.",
        [
          (try_begin),
    (neg|gt, "$g_player_health", 20),
(display_message, "@You are in no condition to work."),
(jump_to_menu,"mnu_salt_mine"),
  (else_try),
    (assign, "$g_last_rest_payment_until", -1),
            (rest_for_hours_interactive, 24 * 7, 5, 1), #rest while not attackable
            (change_screen_return),
  (try_end),
          ]),
    ("add_prisoners",
      [
        # TO DO: Check for max number of slaves
        ],
        "Put prisoners to work in the mines.",
        [
          # TO DO: Let player add prisoners to slave labor if max number of slaves not yet reached
  (leave_encounter),(change_screen_return)
          ]),

      ("leave",[],"Leave.",[(leave_encounter),(change_screen_return)]),
    ]
  ),
  (
    "slave_labor",mnf_disable_all_keys,
    "You receive the accumulated earnings from the slaves you have working here, amounting to {reg1} denars.",
    "none",
    [
        (str_clear, s3),
        (try_begin),
  (party_slot_gt, "p_salt_mine", slot_center_slave_labor, 0),
          (party_get_slot, ":accumulated_earnings", "p_salt_mine", slot_center_accumulated_rents),
          (assign, reg1, ":accumulated_earnings"),
          (troop_add_gold, "trp_player", ":accumulated_earnings"),
          (party_set_slot, "p_salt_mine", slot_center_accumulated_rents, 0),
        (try_end),
      ],
    [
      ("continue",[], "Continue...",
      [
          (jump_to_menu, "mnu_salt_mine"),
        ]),
    ],
  ),

In module_simple_triggers:
# Accumulate slave labor earnings
  (24 * 7,
  [
      (try_for_range, ":center_no", "p_salt_mine", "p_test_scene"),
        (party_get_slot, ":accumulated_earnings", ":center_no", slot_center_accumulated_rents),
        (assign, ":cur_earnings", 0),
        (party_get_slot, ":slave_labor", ":center_no", slot_center_slave_labor),
        (store_add, ":multiplier", 10, ":slave_labor"),
        (val_mul, ":cur_earnings", ":multiplier"),
        (val_add, ":accumulated_earnings", ":cur_earnings"),
        (party_set_slot, ":center_no", slot_center_accumulated_rents, ":accumulated_earnings"),
      (try_end),
    ]),

What I am having trouble figuring out (as shown in red in the module_game_menus section above) is how to let the player choose which prisoners and how many to add to the slave labor. Any ideas?
 
You could transfer the prisoners to the mine and then calculate from there.

I actually really like this idea, think I will implement something similar. You could build a mine or quarry or whatever using jik's system for the villages and then put your prisoners in there to work.. cool stuff.

So i guess you'd use
change_screen_trade_prisoners

and then add the prisoners to the mine that way, then run a trigger that checks the amount of prisoners and calculates income and how many of them die, etc, each day. Then when the player comes back, he receives the profit and possibly a report on how many died (just add them to a global variable in the trigger, display a message and reset the variable to zero).

Alternatively, if you find that the game messes with the prisoners since the mine doesn't belong to them, you could transfer them into an empty party and use that. The party would just be set on ai_bhvr_hold at the mine (or possibly ai_bhvr_in_town so it doesn't show up on the map) and then you can use that as a source to calculate from.

Just make a menu option for transferring prisoners back and forth.

Just looking at the code I can't find the change_screen_trade_prisoners used anywhere in native, so you may have to use change_screen_exchange_members or change_screen_exchange_with_party

The latter might be better anyway as you can define which party to exchange with, so you can easily drop them in an empty party. Of course this way you can also add normal troops to it, but that might be a good thing since you would need to station some guards. You can even add some stuff in there, like if there aren't enough guards, a random nr of prisoners (depending on the ratio guards:prisoners) escapes each day and you could even put in a revolt, where if the prisoners outnumber the guards enough, they will revolt, kill the guards and become a free party on the map who you can then chase down and obliterate in bloody spartacus fashion.

[edit] Just saw that ramun is the only one who uses the change_screen_trade_prisoners but of course, as the name implies, you would be paid/charged for them so the other option is def the way to go.

[edit2] perhaps the easiest way to do this and make it modular (if you want to put more mines in, or use the system for similar things eslewhere) is to make a new party_template, say pt_slave_laborers. Just chuck one farmer in there. Then when you want to do this for the first time, you use spaw_around_party to create the temp party, just remove the one farmer from it when you're done spawning and then jump to the exchange_members thing. That way, you've got the party id in reg0 as a return for the spawn_around_party and you can store that in a slot for the mine, or for the player, for easy usage (would be less work than doing a try_for_parties and then eq the party template).

Heh you've just given me a great idea to finally put those lazy prisoners that my slave traders collect to some good use :smile:
 
Back
Top Bottom