OSP Code QoL Specific-Scene Weather Conditions

Users who are viewing this thread

You know how when you go into scene-edit mode, and theres edit weather but it never saves? You can edit the weather with the module system. I found a code of yoshiboys on the forum, and modified it a little.

Code:
 (ti_before_mission_start, 5, 0, [],
        [
	    (store_current_scene,":current_scene"),
		 (try_begin),
		 (eq,":current_scene","scn_your_scene"), #Replace "scn_your_scene" with the name of your scene in the module_scenes.
		    (assign,"$g_time_of_day",2), #The "Hour" of the scene (to make it dark or bright)
		    (set_rain, 1, 35), #The rain of the scene, the first digit, 1 = rain, 2 = snow. second digits are the amount of rain.
		    (set_fog_distance, 60, 0x999999), #Fog, first digits = the distance you can see before you see fog, then second part is the hexidecimal code of the color of the fog.
		 (else_try), #Else try so that any non-specified scene has no rain,fog,and is a normal time.
		    (scene_set_day_time,"$g_time_of_day"),
                    (set_rain, 0, 0),
		    (set_fog_distance, 0, 0x999999),
                 (try_end),
	]),

^ That goes in the module_mission_triggers.py, (For multiplayer, you can have multiples of this script. One in each gamemode to contain all scenes for that gamemode).

You do not need to PM me to use this if you dont want to (preferred though so i know somebody is using it), but credits pl0x.

Gl guys :smile:
 
Here is a better version :grin:

("init_scene_weather",[
    ##template:  (call_script, "script_scene_set_weather_conditions", "scn_your_scene", <time of the day>, <rain type>, <rain amount>, <fog_distance>,  <fog_color>),
    ##examples:
    (call_script, "script_scene_set_weather_conditions", "scn_your_scene", 2, 1, 60, 10, 0xFF0000),
    (call_script, "script_scene_set_weather_conditions", "scn_your_scene_2", 15, 2, 100, 80, 0xFFFFFF),
]),

("scene_set_weather_conditions",[
    ##INPUT:
    ##param 1 - scene id
    ##param 2 - time of the day
    ##param 3 - rain type (1 - rain, 2 - snow, 0 - no rain/no snow)
    ##param 4 - amount of rain
    ##param 5 - fog distance
    ##param 6 - fog color
    ##OUTPUT: none

    (store_script_param, ":scene_id", 1),
    (store_script_param, ":day_time", 2),
    (store_script_param, ":rain_type", 3),
    (store_script_param, ":rain_amount", 4),
    (store_script_param, ":fog_dist", 5),
    (store_script_param, ":fog_color", 6),

    (val_add, ":day_time", 1),
    (scene_set_slot, ":scene_id", slot_scene_day_time, ":day_time"),
    (scene_set_slot, ":scene_id", slot_scene_rain_type, ":rain_type"),
    (scene_set_slot, ":scene_id", slot_scene_rain_amount, ":rain_amount"),
    (scene_set_slot, ":scene_id", slot_scene_fog_dist, ":fog_dist"),
    (scene_set_slot, ":scene_id", slot_scene_fog_color, ":fog_color"),
]),


("scene_apply_weather_conditions",[
    ##INPUT:
    ##param_1 - scene id
    ##OUTPUT: none
    (store_script_param, ":scene_id", 1),

    (scene_get_slot, ":time_of_day", ":scene_id", slot_scene_day_time),
    (try_begin),
      (eq, ":time_of_day", 0),
        ###replace these values with the default ones
        (scene_set_day_time, 14),
        (set_rain, 0, 0),
        (set_fog_distance, 0, 0x999999),
    (else_try),
      (val_sub, ":time_of_day", 1),
      (scene_set_day_time, ":time_of_day"),
 
      (scene_get_slot, ":rain_type", ":scene_id", slot_scene_rain_type),
      (scene_get_slot, ":rain_amount", ":scene_id", slot_scene_rain_amount),
      (set_rain, ":rain_type", ":rain_amount"),
 
      (scene_get_slot, ":fog_dist", ":scene_id", slot_scene_fog_dist),
      (scene_get_slot, ":fog_color", ":scene_id", slot_scene_fog_color),
      (set_fog_distance, ":fog_dist", ":fog_color"),
    (try_end),
]),
slot_scene_day_time    = 743
slot_scene_rain_type    = 744
slot_scene_rain_amount  = 745
slot_scene_fog_dist    = 746
slot_scene_fog_color    = 747
(ti_before_mission_start, 0, 0, [],
  [
    (store_current_scene, ":current_scene"),
    (call_script, "script_scene_apply_weather_conditions", ":current_scene"),
]),


After copy and pasting those scripts in module_scripts and those constants in module_constants, go inside "game_quick_start" script and paste this line
Code:
(call_script, "script_init_scene_weather"),

To set your scene weather conditions, go in the script "init_scene_weather" and copy and paste that template that is inside it, and modify it how you want (you can delete those 2 examples).

For setting default values, go in "scene_apply_weather_conditions" script and edit these 3 lines's values
Code:
        (scene_set_day_time, 14), 
        (set_rain, 0, 0),
        (set_fog_distance, 0, 0x999999),
 
Thats alot more work and main is for people who cant really make it themselfs. This works just as good but easier for the newer people, if they know enough they can make it themselfs xD
 
You are missing a try_end, and obviously putting the actions as an alternative execution won't have any effect where they should. As a matter of fact, you don't even need half the code.

 
(store_current_scene,":current_scene"),
(try_begin),
(eq,":current_scene","scn_your_scene"), #Replace "scn_your_scene" with the name of your scene in the module_scenes.
    (assign,"$g_time_of_day",2), #The "Hour" of the scene (to make it dark or bright)
    (set_rain, 1, 35), #The rain of the scene, the first digit, 1 = rain, 2 = snow. second digits are the amount of rain.
    (set_fog_distance, 60, 0x999999), #Fog, first digits = the distance you can see before you see fog, then second part is the hexidecimal code of the color of the fog.
                (try_end),
              (scene_set_day_time,"$g_time_of_day"),
]),
 
Back
Top Bottom