LSP Code Campaign Gold and Iron Mines (need more gold)

Users who are viewing this thread

This OSP will add in game "old good" gold and iron deposits and of course cheerful digging in  mines. Your peasants will be satisfied.
Gold and ore deposits were randomly assigned to villages. 15% chance of iron and 5% chance of gold.
A gold mine increases village prosperity by 4% every month. Income 100-1000 denars per week.
An iron mine increases village prosperity by 1% every month and allows iron to be purchased from the village.

Installation.

1.We need add some constants.(module_constants.py)

slot numbers - any non used.
slot_village_has_goldmine    = 555#Or pick another unused slot
slot_village_give_goldcoin    = 556#Or pick another unused slot
slot_village_has_iron_ore    = 557#Or pick another unused slot

next constants must be inserted between the lines slot_center_has_manor and slot_center_has_messenger_post. You will need to reorder slot numbers. In native, you can change like this

slot_center_has_manor              =  128 #village
#[OSP] Gold and Iron Mines (need more gold)# [OSP] Gold and Iron Mines (need more gold)
slot_center_has_iron_mine        =  129 #village
slot_center_has_gold_mine        =  130 #village
#[OSP] Gold and Iron Mines (need more gold)# [OSP] Gold and Iron Mines (need more gold)

Or completely renumber village improvements slots, like me (spoiler)
slot_center_has_manor            = 454 #village
slot_center_has_fish_pond        = 455 #village
slot_center_has_watch_tower      = 456 #village
slot_center_has_school          = 457 #village

slot_center_has_iron_mine        = 458 #village
slot_center_has_gold_mine        = 459 #village

slot_center_has_messenger_post  = 460 #town, castle, village
slot_center_has_prisoner_tower  = 461 #town, castle

slot_center_has_blacksmith      = 462 #town, castle

village_improvements_begin = slot_center_has_manor
village_improvements_end  = slot_center_has_prisoner_tower

walled_center_improvements_begin = slot_center_has_messenger_post
walled_center_improvements_end  = slot_center_has_blacksmith

2.In module_game_menus.py search for "center_build_manor" in "center_manage" menu and than add:

        ("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"),]),

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

        ("center_build_iron_mine",[(eq, reg6, 0),
                              (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
                              (party_slot_eq, "$g_encountered_party", slot_center_has_iron_mine, 0),
  (party_slot_eq, "$g_encountered_party", slot_village_has_iron_ore, 1),
                                  ],
      "Build an iron mine.",[(assign, "$g_improvement_type", slot_center_has_iron_mine),
                          (jump_to_menu, "mnu_center_improve"),]),

        ("center_build_gold_mine",[(eq, reg6, 0),
                              (party_slot_eq, "$g_encountered_party", slot_party_type, spt_village),
                              (party_slot_eq, "$g_encountered_party", slot_center_has_gold_mine, 0),
  (party_slot_eq, "$g_encountered_party", slot_village_has_goldmine, 1),
                                  ],
      "Build a gold mine.",[(assign, "$g_improvement_type", slot_center_has_gold_mine),
                          (jump_to_menu, "mnu_center_improve"),]),

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

        ("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_fish_pond, 0),
            ],
    "Build a mill.",[(assign, "$g_improvement_type", slot_center_has_fish_pond),
                    (jump_to_menu, "mnu_center_improve"),]),

3.For Diplomacy add this in module_dialogs.py below [(assign, "$g_improvement_type", slot_center_has_manor),]],

[anyone|plyr, "dplmc_chamberlain_manage_fiefs_build_ask2",
[
(party_slot_eq, "$diplomacy_var", slot_party_type, spt_village),
(party_slot_eq, "$diplomacy_var", slot_center_has_manor, 0),
],
"Build a manor.", "dplmc_chamberlain_manage_fiefs_build_confirm_ask",
[(assign, "$g_improvement_type", slot_center_has_manor),]
],

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

[anyone|plyr, "dplmc_chamberlain_manage_fiefs_build_ask2",
[
(party_slot_eq, "$diplomacy_var", slot_party_type, spt_village),
(party_slot_eq, "$diplomacy_var", slot_center_has_iron_mine, 0),
(party_slot_eq, "$diplomacy_var", slot_village_has_iron_ore,1),
],
"Build an iron mine.", "dplmc_chamberlain_manage_fiefs_build_confirm_ask",
[(assign, "$g_improvement_type", slot_center_has_iron_mine),]
],

[anyone|plyr, "dplmc_chamberlain_manage_fiefs_build_ask2",
[
(party_slot_eq, "$diplomacy_var", slot_party_type, spt_village),
(party_slot_eq, "$diplomacy_var", slot_center_has_gold_mine, 0),
(party_slot_eq, "$diplomacy_var", slot_village_has_goldmine,1),
],
"Build a gold mine.", "dplmc_chamberlain_manage_fiefs_build_confirm_ask",
[(assign, "$g_improvement_type", slot_center_has_gold_mine),]
],

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

[anyone|plyr, "dplmc_chamberlain_manage_fiefs_build_ask2",
[
(party_slot_eq, "$diplomacy_var", slot_party_type, spt_village),
(party_slot_eq, "$diplomacy_var", slot_center_has_fish_pond, 0),
],
"Build a mill.", "dplmc_chamberlain_manage_fiefs_build_confirm_ask",
[(assign, "$g_improvement_type", slot_center_has_fish_pond),]
],

4. Changes in module_scripts.py

4.1. Randomly add deposits in Calradia.
15% chance of iron and 5% chance of gold
In "game_start" script add before last ]),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

    (try_for_range,":cur_village",villages_begin,villages_end),
(store_random_in_range, ":ir_mine",1,20),
  (try_begin),
    (is_between,":ir_mine",1,3), #15% chance of iron
(party_set_slot, ":cur_village", slot_village_has_iron_ore,1),
  (else_try),
    (eq,":ir_mine",5),# 5% chance of gold
(party_set_slot, ":cur_village", slot_village_has_goldmine,1),
  (try_end),
    (try_end),
              (party_set_slot, "p_village_57", slot_village_has_iron_ore,1), # test
(party_set_slot, "p_village_7", slot_village_has_goldmine,1),  # test

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

    ]),

  #script_game_get_use_string
  # This script is called from the game engine for getting using information text

4.2

in script "get_improvement_details"

    (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, 12000),#12000
    (else_try),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

        (eq, ":improvement_no", slot_center_has_gold_mine),
        (str_store_string, s0, "@Gold mine"),
        (str_store_string, s1, "@A gold mine increases village prosperity by 4% every month. Income 100-1000 denars per week."),
        (assign, reg0, 5500),#5500
      (else_try),
        (eq, ":improvement_no", slot_center_has_iron_mine),
        (str_store_string, s0, "@Iron mine"),
        (str_store_string, s1, "@An iron mine increases village prosperity by 1% every month and allows iron to be purchased from the village."),
        (assign, reg0, 4500),
      (else_try),  

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
      (eq, ":improvement_no", slot_center_has_fish_pond),
      (str_store_string, s0, "@Mill"),
      (str_store_string, s1, "@A mill increases village prosperity once by 5%. "),
      (assign, reg0, 6000),#6000
    (else_try),

4.3. Add iron bars in vil. shops.Search for script "refresh_village_merchant_inventory" and add before last ]),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
      (try_begin),
        (party_slot_eq, ":village_no", slot_center_has_iron_mine, 1),
        (store_random_in_range,":rand",1,5),
        (try_for_range, ":unused", 0, ":rand"),
          (troop_add_item,":merchant_troop",itm_iron,0), # add 1-5 iron bars
        (try_end),
      (try_end), 
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### 
  ]),

  # script_refresh_village_defenders

5. module_simple_triggers.py
add in the end of the file.
5.1.Change prosperity of villages.
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
## Monthly change prosperity of villages
  (30 * 24,
    [(try_for_range, ":center_no", villages_begin, villages_end),

    (try_begin),
            (party_slot_eq, ":center_no", slot_center_has_iron_mine, 1),
            (call_script, "script_change_center_prosperity", ":center_no", 1),
        (try_end),

    (try_begin),
            (party_slot_eq, ":center_no", slot_center_has_gold_mine, 1),
            (call_script, "script_change_center_prosperity", ":center_no", 4),
        (try_end),
(try_end),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

5.2.Income from gold mine

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
### weekly rent from goldmine
  (24 * 7,
  [(try_for_range, ":center_no", villages_begin, villages_end),
    (party_slot_ge, ":center_no", slot_town_lord, 0), #unassigned centers do not accumulate rents
(party_slot_eq, ":center_no", slot_village_state, svs_normal),
            (party_slot_eq, ":center_no", slot_center_has_gold_mine, 1),
(store_random_in_range, ":goldmine_rent",100,1000),
            (party_set_slot, ":center_no", slot_village_give_goldcoin, ":goldmine_rent"),
    (try_end), 
    ]),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

6. module_presentations.py.

This will add shiny golden circles from gold mine in weekly budget report  and player treasury.
Open module_presentations.py  >> "budget_report" and search for  #Enterprise ends, taxes begin , than add

    #Enterprise ends, taxes begin
        (party_slot_eq, ":center_no", slot_town_lord, "trp_player"),
        (party_get_slot, ":accumulated_rents", ":center_no", slot_center_accumulated_rents),
        (party_get_slot, ":accumulated_tariffs", ":center_no", slot_center_accumulated_tariffs),

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
        (try_begin),
            (party_slot_eq, ":center_no", slot_center_has_gold_mine, 1),
            (party_get_slot, ":goldm_rent", ":center_no", slot_village_give_goldcoin),
            (val_add, ":accumulated_tariffs", ":goldm_rent"),
        (try_end),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

        (store_add, ":accumulated_total", ":accumulated_rents", ":accumulated_tariffs"),
        (val_add, ":all_centers_accumulated_total", ":accumulated_total"),
        (val_add, ":all_centers_accumulated_taxes_and_rents", ":accumulated_total"),
        (val_add, ":net_change", ":accumulated_total"),
        (str_store_party_name, s0, ":center_no"),
        ##diplomacy begin
        (try_begin),
          (neg|is_between, ":center_no", castles_begin, castles_end),
          (party_get_slot, ":tax_rate", ":center_no", dplmc_slot_center_taxation),
          (neq, ":tax_rate", 0),
          (call_script, "script_dplmc_describe_tax_rate_to_s50", ":tax_rate"),
          (str_store_string, s0, "@{s0} ({s50})"),
        (try_end),
        ##diplomacy end
        (create_text_overlay, reg1, "str_rents_from_s0", 0),
        ##diplomacy begin
        (str_store_party_name, s0, ":center_no"),
        ##diplomacy end
        (position_set_x, pos1, 900),
        (position_set_y, pos1, 900),
        (overlay_set_size, reg1, pos1),
        (position_set_x, pos1, 25),
        (position_set_y, pos1, ":cur_y"),
        (overlay_set_position, reg1, pos1),
        (try_begin),
          (gt, ":accumulated_rents", 0),
          (assign, reg0, ":accumulated_rents"),
          (create_text_overlay, reg1, "@{!}{reg0}", tf_right_align|tf_single_line),
          (overlay_set_color, reg1, 0x00AA00),
        (else_try),
          (create_text_overlay, reg1, "@None", tf_right_align|tf_single_line),
        (try_end),
        (position_set_x, pos1, 900),
        (position_set_y, pos1, 900),
        (overlay_set_size, reg1, pos1),
        (position_set_x, pos1, 500),
        (position_set_y, pos1, ":cur_y"),
        (overlay_set_position, reg1, pos1),
        (val_sub, ":cur_y", 27),

### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
      (try_begin),
          (is_between, ":center_no", villages_begin, villages_end),
                (party_slot_eq, ":center_no", slot_center_has_gold_mine, 1),
  (party_slot_eq, ":center_no", slot_town_lord, "trp_player"),
  (str_store_party_name, s0, ":center_no"),
  (create_text_overlay, reg1, "@Rents from gold mine in {s0}: ", 0),
  (position_set_x, pos1, 900),
                (position_set_y, pos1, 900),
                (overlay_set_size, reg1, pos1),
                (position_set_x, pos1, 25),
                (position_set_y, pos1, ":cur_y"),
                (overlay_set_position, reg1, pos1),
                (party_get_slot, ":goldm_rent", ":center_no", slot_village_give_goldcoin),
            (try_begin),
                      (gt, ":goldm_rent", 0),
                      (assign, reg0, ":goldm_rent"),
                      (create_text_overlay, reg1, "@{!}{reg0}", tf_right_align|tf_single_line),
                      (overlay_set_color, reg1, 0x00AA00),
            (else_try),
                    (create_text_overlay, reg1, "@None", tf_right_align|tf_single_line),
          (try_end),
              (position_set_x, pos1, 900),
              (position_set_y, pos1, 900),
              (overlay_set_size, reg1, pos1),
              (position_set_x, pos1, 500),
              (position_set_y, pos1, ":cur_y"),
              (overlay_set_position, reg1, pos1),
              (val_sub, ":cur_y", 27),
        (try_end),
### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###

        (try_begin),
          (is_between, ":center_no", towns_begin, towns_end),
          (create_text_overlay, reg1, "str_tariffs_from_s0", 0),

and  ingame screenshots

manage menu
mb9_800.jpg

weekly budget menu
mb5.jpg

talk with chamberlain
mb10.jpg

settlement info page (settlement info info presentation code not in this osp )
mb7.jpg

Thanks Native Expansion [BETA] team for inspiring.
Free for non commercial use.
Credits will be enough.

ps. we need more gold!

 
Porshy said:
          (troop_add_item,":merchant_troop",itm_iron,0), # add 1-5 iron bars

is it adding? Because you type 0 for amount
yes,
As  jacobhinds wrote, 0 is the item modifier.
but in fact, this line adds only 1 iron bar, but each time when cycle runs.
 
I've just translated this topic to Turkish. Click to have look, if you want :smile: Thanks for sharing
 
I know this is an old thread but I have the same problem as above so wonder if it was solved.
  # Setting food bonuses in every 6 hours again and again because of a bug (we could not find its reason) which decreases especially slot_item_food_bonus slots of items to 0.
  #Staples
      (item_set_slot, "itm_bread", slot_item_food_bonus, :cool:, #brought up from 4
      (item_set_slot, "itm_grain", slot_item_food_bonus, 2), #new - can be boiled as porridge
 
  #Fat sources - preserved
      (item_set_slot, "itm_smoked_fish", slot_item_food_bonus, 4),
      (item_set_slot, "itm_dried_meat", slot_item_food_bonus, 6),
      (item_set_slot, "itm_cheese", slot_item_food_bonus, 7),
      (item_set_slot, "itm_sausages", slot_item_food_bonus, 7),
      (item_set_slot, "itm_butter", slot_item_food_bonus, 4), #brought down from 8

  #Fat sources - perishable
      (item_set_slot, "itm_chicken", slot_item_food_bonus, 10), #brought up from 7
      (item_set_slot, "itm_cattle_meat", slot_item_food_bonus, 10), #brought down from 7
      (item_set_slot, "itm_pork", slot_item_food_bonus, 10), #brought down from 6
 
  #Produce
      (item_set_slot, "itm_raw_olives", slot_item_food_bonus, 5),
      (item_set_slot, "itm_cabbages", slot_item_food_bonus, 3),
      (item_set_slot, "itm_raw_grapes", slot_item_food_bonus, 5),
      (item_set_slot, "itm_apples", slot_item_food_bonus, 4), #brought down from 5

  #Sweet items
      (item_set_slot, "itm_raw_date_fruit", slot_item_food_bonus, :cool:, #brought down from 8
      (item_set_slot, "itm_honey", slot_item_food_bonus, 6), #brought down from 12
     
      (item_set_slot, "itm_wine", slot_item_food_bonus, 10),
      (item_set_slot, "itm_ale", slot_item_food_bonus, :cool:,
  ]),
  (24,
  []),
  (24,
  []),
  (24,
  []),
  (24,
  []),
  (24,
  []),
  (24,
  []),
  (24,
  []),
  (24,
  []),
  (24,
  []),
###mark edits [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
## Monthly change prosperity of villages
  (30 * 24,
    [(try_for_range, ":center_no", villages_begin, villages_end),

      (try_begin),
            (party_slot_eq, ":center_no", slot_center_has_iron_mine, 1),
            (call_script, "script_change_center_prosperity", ":center_no", 1),
        (try_end),
     
      (try_begin),
            (party_slot_eq, ":center_no", slot_center_has_gold_mine, 1),
            (call_script, "script_change_center_prosperity", ":center_no", 4),
        (try_end),
  (try_end),
###mark edits [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
### mark edits[OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ###
### weekly rent from goldmine
  (24 * 7,
  [(try_for_range, ":center_no", villages_begin, villages_end),
          (party_slot_ge, ":center_no", slot_town_lord, 0), #unassigned centers do not accumulate rents
        (party_slot_eq, ":center_no", slot_village_state, svs_normal),
            (party_slot_eq, ":center_no", slot_center_has_gold_mine, 1),
        (store_random_in_range, ":goldmine_rent",100,1000),
            (party_set_slot, ":center_no", slot_village_give_goldcoin, ":goldmine_rent"),
    (try_end), 
    ]),
###mark edits [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### [OSP] Gold and Iron Mines (need more gold) ### 


]

error
Initializing...
Traceback (most recent call last):
  File "process_global_variables.py", line 7, in <module>
    from module_simple_triggers import *
  File "H:\item sorting\module_simple_triggers.py", line 4263

    ^
SyntaxError: invalid syntax
Exporting strings...
Exporting skills...
Exporting tracks...
Exporting animations...
Exporting meshes...
Exporting sounds...
Exporting skins...
Exporting map icons...
Creating new tag_uses.txt file...
Creating new quick_strings.txt file...
Exporting faction data...
Exporting item data...
Exporting scene data...
Exporting troops data
Exporting particle data...
Exporting scene props...
WARNING: Usage of unassigned global variable: $g_ccoop_currently_dropping_item
WARNING: Usage of unassigned global variable: $g_ccoop_currently_dropping_item
WARNING: Usage of unassigned global variable: $g_ccoop_currently_dropping_item
and loads more
Exporting tableau materials data...
Exporting presentations...

Exporting postfx_params...

______________________________

Grabbing item names and values from ID_items.py
2072 items found
Grabbing item values from module_troops.py
1758 items used by troops
314 unused item names saved to unused_items.txt
Finished
Script processing has ended.
Press any key to exit. . .
 
The op forgot to close a trigger and so did you.
For large blocks better between the tags prepared for it: "Insert code", are read much better and there are no line breaks...
 
Back
Top Bottom