• Please note that we've updated the Mount & Blade II: Bannerlord save file system which requires you to take certain steps in order for your save files to be compatible with e1.7.1 and any later updates. You can find the instructions here.

OSP Code SP Intense Weather(more rain/snow and fog)

Users who are viewing this thread

Crysix

Veteran
Required module.py files to edit:
  • module_scripts
  • module_constants (optional to use instead of the module_scripts)
  • mission_templates
  • (and for the toggle option, anywhere you want, i use it in the module_game_menus)
Intense weather make the battlefield more fogy and rainy. You can also add 50\50 chance for it to occur before each battle if you want, I just use a toggle global variable and personally I leave it on all the time. In module_scripts put "$intense_weather" in the "lco_initialize_presentation" script block as: (assign, "$intense_weather", 1),
if you dont have that you can use it as a constant in the module_constants and the player troop slot, just enter in module_constants the line:
Python:
intense_weather_check             = 1   ##0= turn off, 1= turn on
and in the mission_templates Intense weather code block just change the
Python:
(eq, "$intense_weather", 1),
to
Python:
(troop_get_slot, ":intense_weather_check", "trp_player", intense_weather_check),
(eq, ":intense_weather_check", 1),

To turn on (value=1, to turn off use 0) enter anywhere you want in any shape(button, dropbox, script, menu) the line (assign,"$intense_weather", 1), or if you use the constant use the line (troop_set_slot, "trp_player", intense_weather_check, 1),. (I use the toggle on(value=1) or off(value=0) as menu option in the camp actions menu).

Search and add the weather code block in those entries (marked in orange text) in the mission_templates
a) "lead_charge"
Later in that entry you will see this block and put the code in there:
Python:
(ti_before_mission_start, 0, 0, [],
[
[COLOR=rgb(184, 49, 47)]##Put he Intense Weather code block here##[/COLOR]
   (team_set_relation, 0, 2, 1),
   (team_set_relation, 1, 3, 1),
   (call_script, "script_place_player_banner_near_inventory_bms"),
   (party_clear, "p_routed_enemies"),
   (assign, "$g_latest_order_1", 1),
   (assign, "$g_latest_order_2", 1),
   (assign, "$g_latest_order_3", 1),
   (assign, "$g_latest_order_4", 1),
   ]),

b) "besiege_inner_battle_castle"
later in that entry you will see this block and put the code in there:
Python:
(ti_before_mission_start, 0, 0, [], [(call_script, "script_change_banners_and_chest")[COLOR=rgb(85, 57, 130)], [COLOR=rgb(184, 49, 47)]##Put he Intense Weather code block here##[/COLOR]]),[/COLOR]

c) "besiege_inner_battle_town_center"
later in that entry you will see this block and put the code in there:
Python:
(ti_before_mission_start, 0, 0, [], [(call_script, "script_change_banners_and_chest")[COLOR=rgb(85, 57, 130)], [COLOR=rgb(184, 49, 47)]##Put he Intense Weather code block here##[/COLOR]]),[/COLOR]

d) "castle_attack_walls_defenders_sally"
later in that entry you will see this block and put the code in there:
Python:
(ti_before_mission_start, 0, 0, [],
[
[COLOR=rgb(184, 49, 47)]##Put he Intense Weather code block here##[/COLOR]
   (team_set_relation, 0, 2, 1),
   (team_set_relation, 1, 3, 1),
   (call_script, "script_change_banners_and_chest"),
   (call_script, "script_remove_siege_objects"),
   ]),

And if you want ofc put it anywhere else you desire.

Alternatively instead of the: ##Put he Intense Weather code block here## you can add the code block below to a single new script and just call him in each entry mentioned above^ instead of copying the whole code block to the entries, for example: (call_script, "script_check_intense_weather"), that have the code block in it.

The Intense Weather code block:
Python:
(party_get_current_terrain, ":cur_terrain", "p_main_party"),
           (try_begin),
           (eq, "$intense_weather", 1),
           (eq, ":cur_terrain", rt_desert),
           (store_random_in_range, ":rain_power_yes", 0, 100),
           (le, ":rain_power_yes", 20),
           (store_random_in_range, ":rain_power", 25, 100),
           (set_rain, 1, ":rain_power"),
           (store_random_in_range, ":haze", 25, 100),
           (set_global_haze_amount, ":haze"),
           (store_random_in_range, ":cloud", 25, 100),
           (set_global_cloud_amount, ":cloud"),
           (gt, ":rain_power_yes", 21),
           (store_random_in_range, ":haze", 25, 100),
           (set_global_haze_amount, ":haze"),
           (store_random_in_range, ":cloud", 25, 100),
           (set_global_cloud_amount, ":cloud"),
           (set_rain, 0, 0),
           (store_random_in_range, ":fog_distance_yes", 0, 100),
           (le, ":fog_distance_yes", 50),
           (store_random_in_range, ":fog_distance", 25, 100),
           (set_fog_distance, ":fog_distance", 0x0000FF),
           (gt, ":fog_distance_yes", 51),
           (set_fog_distance, 100),

           (else_try),
           (eq, "$intense_weather", 1),
           (eq, ":cur_terrain", rt_snow),
           (store_random_in_range, ":rain_power_yes", 0, 100),
           (le, ":rain_power_yes", 50),
           (store_random_in_range, ":rain_power", 25, 100),
           (set_rain, 2, ":rain_power"),
           (store_random_in_range, ":haze", 25, 100),
           (set_global_haze_amount, ":haze"),
           (store_random_in_range, ":cloud", 25, 100),
           (set_global_cloud_amount, ":cloud"),
           (gt, ":rain_power_yes", 51),
           (store_random_in_range, ":haze", 25, 100),
           (set_global_haze_amount, ":haze"),
           (store_random_in_range, ":cloud", 25, 100),
           (set_global_cloud_amount, ":cloud"),
           (set_rain, 0, 0),
           (store_random_in_range, ":fog_distance_yes", 0, 100),
           (le, ":fog_distance_yes", 50),
           (store_random_in_range, ":fog_distance", 25, 100),
           (set_fog_distance, ":fog_distance", 0x0000FF),
           (gt, ":fog_distance_yes", 51),
           (set_fog_distance, 100),

           (else_try),
           (eq, "intense_weather", 1),
           (store_random_in_range, ":rain_power_yes", 0, 100),
           (le, ":rain_power_yes", 50),
           (store_random_in_range, ":rain_power", 25, 100),
           (set_rain, 1, ":rain_power"),
           (store_random_in_range, ":haze", 25, 100),
           (set_global_haze_amount, ":haze"),
           (store_random_in_range, ":cloud", 25, 100),
           (set_global_cloud_amount, ":cloud"),
           (gt, ":rain_power_yes", 51),
           (store_random_in_range, ":haze", 25, 100),
           (set_global_haze_amount, ":haze"),
           (store_random_in_range, ":cloud", 25, 100),
           (set_global_cloud_amount, ":cloud"),
           (set_rain, 0, 0),
           (store_random_in_range, ":fog_distance_yes", 0, 100),
           (le, ":fog_distance_yes", 50),
           (store_random_in_range, ":fog_distance", 25, 100),
           (set_fog_distance, ":fog_distance", 0x0000FF),
           (gt, ":fog_distance_yes", 51),
           (set_fog_distance, 100),
           (try_end),
 
Last edited by a moderator:

Tocan

Sergeant Knight at Arms
thanks for sharing. what Antonis and i do, we set the importantest weather parameter with a simple trigger, with that you always have the same weather in the scene. i mean it makes no sense that after tab out/scene reload you haven't the same weather like before
 

Crysix

Veteran
thanks for sharing. what Antonis and i do, we set the importantest weather parameter with a simple trigger, with that you always have the same weather in the scene. i mean it makes no sense that after tab out/scene reload you haven't the same weather like before
True true, i think a fix to that problem will be to store the values of the current scene weather that was set randomly and if its in the same terrain and a few hours didnt passed the weather will get the same first random values that stored and will be reseted to random each few hours(that enough time passed for weather to change) or if you go from snow to grassland so also depand on the terrain to set snow or rain, just a quick idea about that but it really dosent bother me personally, i even re-enter a scene(battle) few times just to get a weather im liking
 
Top Bottom