Skip to content

Commit

Permalink
Moved windgen variables to region json (#27848)
Browse files Browse the repository at this point in the history
* moved windgen variables to region json
* updated docs for regions
  • Loading branch information
davidpwbrown authored and kevingranade committed Jan 26, 2019
1 parent 0d7b11a commit 2c2b384
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 10 deletions.
10 changes: 9 additions & 1 deletion data/json/regional_map_settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,15 @@
"s_petstore": 1
}
},
"weather": { "base_temperature": 6.5, "base_humidity": 66.0, "base_pressure": 1015.0, "base_acid": 0.0 },
"weather": {
"base_temperature": 6.5,
"base_humidity": 66.0,
"base_pressure": 1015.0,
"base_acid": 0.0,
"base_wind": 5.7,
"base_wind_distrib_peaks": 30,
"base_wind_season_variation": 64
},
"overmap_feature_flag_settings": { "clear_blacklist": false, "blacklist": [ ], "clear_whitelist": false, "whitelist": [ ] }
}
]
21 changes: 14 additions & 7 deletions doc/REGION_SETTINGS.md
Original file line number Diff line number Diff line change
Expand Up @@ -389,12 +389,15 @@ The **weather** section defines the base weather attributes used for the region.

### Fields

| Identifier | Description |
| ------------------ | --------------------------------------------------------------------- |
| `base_temperature` | Base temperature for the region in degrees Celsius. |
| `base_humidity` | Base humidity for the region in relative humidity % |
| `base_pressure` | Base pressure for the region in millibars. |
| `base_acid` | Base acid for the region in ? units. Value >= 1 is considered acidic. |
| Identifier | Description |
| ------------------------------ | --------------------------------------------------------------------- |
| `base_temperature` | Base temperature for the region in degrees Celsius. |
| `base_humidity` | Base humidity for the region in relative humidity % |
| `base_pressure` | Base pressure for the region in millibars. |
| `base_acid` | Base acid for the region in ? units. Value >= 1 is considered acidic. |
| `base_wind` | Base wind for the region in mph units. Roughly the yearly average. |
| `base_wind_distrib_peaks` | How high the wind peaks can go. Higher values produce windier days. |
| `base_wind_season_variation` | How the wind varies with season. Lower values produce more variation |

### Example

Expand All @@ -404,6 +407,10 @@ The **weather** section defines the base weather attributes used for the region.
"base_temperature": 6.5,
"base_humidity": 66.0,
"base_pressure": 1015.0,
"base_acid": 0.0,
"base_wind": 5.7,
"base_wind_distrib_peaks": 30,
"base_wind_season_variation": 64,
"base_acid": 0.0
}
}
Expand Down Expand Up @@ -464,4 +471,4 @@ All additional fields and sections are as defined for a `region_overlay`.
}
}
}]
```
```
8 changes: 6 additions & 2 deletions src/weather_gen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,9 @@ w_point weather_generator::get_weather( const tripoint &location, const time_poi
base_pressure; // Pressure is mostly random, but a bit higher on summer and lower on winter. In millibars.

// Wind power
W = std::max( 0, static_cast<int>( 5.7 / pow( P / 1014.78, rng( 9, 30 ) ) +
( seasonal_variation / 64 ) * rng( 1, 2 ) * W ) );
W = std::max( 0, static_cast<int>( base_wind / pow( P / 1014.78, rng( 9,
base_wind_distrib_peaks ) ) +
( seasonal_variation / base_wind_season_variation ) * rng( 1, 2 ) * W ) );
// Wind direction
// initial static variable
if( current_winddir == 1000 ) {
Expand Down Expand Up @@ -269,5 +270,8 @@ weather_generator weather_generator::load( JsonObject &jo )
ret.base_humidity = jo.get_float( "base_humidity", 66.0 );
ret.base_pressure = jo.get_float( "base_pressure", 1015.0 );
ret.base_acid = jo.get_float( "base_acid", 1015.0 );
ret.base_wind = jo.get_float( "base_wind", 5.7 );
ret.base_wind_distrib_peaks = jo.get_int( "base_wind_distrib_peaks", 30 );
ret.base_wind_season_variation = jo.get_int( "base_wind_season_variation", 64 );
return ret;
}
4 changes: 4 additions & 0 deletions src/weather_gen.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ class weather_generator
double base_humidity = 66.0; // Average humidity
double base_pressure = 1015.0; // Average atmospheric pressure
double base_acid = 0.0;
double base_wind = 5.7; //Average yearly windspeed of New England
int base_wind_distrib_peaks = 30; //How much the wind peaks above average
int base_wind_season_variation =
64; //How much the wind folows seasonal variation ( lower means more change )
static int current_winddir;

weather_generator();
Expand Down

0 comments on commit 2c2b384

Please sign in to comment.