diff --git a/data/campaigns/Under_the_Burning_Suns/scenarios/01_The_Morning_After.cfg b/data/campaigns/Under_the_Burning_Suns/scenarios/01_The_Morning_After.cfg index e65d736a30d..ea9fddd1e7e 100644 --- a/data/campaigns/Under_the_Burning_Suns/scenarios/01_The_Morning_After.cfg +++ b/data/campaigns/Under_the_Burning_Suns/scenarios/01_The_Morning_After.cfg @@ -221,6 +221,24 @@ gender=male [/value] [/set_variables] + + # Smooth out camp luck + {VARIABLE total_elf_pool_gold_value 0} + {VARIABLE current_elf_pool_gold_value_received 0} + {VARIABLE seen_camps 0} + [foreach] + array=elf_pool + [do] + [store_unit_type] + type = $this_item.type + variable = utbs_unit_type + [/store_unit_type] + {VARIABLE_OP total_elf_pool_gold_value add "$utbs_unit_type.cost"} + {CLEAR_VARIABLE utbs_unit_type} + [/do] + [/foreach] + # This will be further reduced when outer_villages are calculated + {VARIABLE_OP total_elf_pool_gold_value multiply "$({ON_DIFFICULTY 0.6 0.5 0.4})"} [/event] # Dialog at start of scenario @@ -971,6 +989,10 @@ [/or] [/not] [/store_locations] + + # Scale average gold value to the number of villages, not size of pool + {VARIABLE_OP total_elf_pool_gold_value multiply "$outer_villages.length"} + {VARIABLE_OP total_elf_pool_gold_value divide "$elf_pool.length"} [/event] [event] @@ -1000,17 +1022,24 @@ # if this village wasn't captured by undead first, the # player has a chance of finding a random elf [then] - {VARIABLE_OP fate rand "1..100"} - - # And check if it's lower than a threshold of + # Check if it's lower than a threshold of # finding an unit that's dependent on difficulty # level: 60% on easy, 50% on normal, 40% on # hard. We use preprocesor to choose appropriate - # chance + # chance. We also account for luckiness, which is + # the difference between expected gold value of + # the elf pool and the gold value of the units + # already found. + # If you want more variability, increase max_fate. + {VARIABLE max_fate 30} + {VARIABLE_OP fate rand "1..$max_fate"} + {VARIABLE expected_elf_pool_gold_value "$($total_elf_pool_gold_value|*$seen_camps|/$outer_villages.length|)"} + {VARIABLE luckiness "$($current_elf_pool_gold_value_received - $expected_elf_pool_gold_value)"} + {VARIABLE_OP seen_camps add 1} [if] [variable] name=fate - less_than_equal_to={ON_DIFFICULTY 60 50 40} + less_than_equal_to="$($max_fate|*{ON_DIFFICULTY 0.6 0.5 0.4} - $luckiness|)" [/variable] [then] # So the RNG smiled upon the player, time to pick a @@ -1033,6 +1062,14 @@ #endif [/unit] + # Add gold value of the unit to luck counter + [store_unit_type] + type = $elf_pool[$random_elf_pool_index].type + variable = utbs_unit_type + [/store_unit_type] + {VARIABLE_OP current_elf_pool_gold_value_received add "$utbs_unit_type.cost"} + {CLEAR_VARIABLE utbs_unit_type} + # When done remove unit from the pool {CLEAR_VARIABLE elf_pool[$random_elf_pool_index]} {CLEAR_VARIABLE random_elf_pool_index} @@ -1053,6 +1090,9 @@ [/else] [/if] {CLEAR_VARIABLE fate} + {CLEAR_VARIABLE max_fate} + {CLEAR_VARIABLE expected_elf_pool_gold_value} + {CLEAR_VARIABLE luckiness} [/then] # If this village was captured by undead first, the player @@ -1443,6 +1483,9 @@ {CLEAR_VARIABLE found_garak} {CLEAR_VARIABLE found_zhul} {CLEAR_VARIABLE bridge_event} + {CLEAR_VARIABLE total_elf_pool_gold_value} + {CLEAR_VARIABLE current_elf_pool_gold_value_received} + {CLEAR_VARIABLE seen_camps} # This clears all those village-specific containers that were holding # information about who had visited the village