JWeather: Project Discussion

Jeckel

Great Reverend
Joined
Nov 16, 2005
Messages
1,637
Location
Peoria, IL
I've always thought the Civ4 game world is to static. This Tile is always Snow, this one always has Ice. What if Tiles had a Temperature, Humidity, Wind Currents, ect. Then Ice Features could melt away when the temp rises or appear when the temp falls. Forests could have a higher chance of catching on fire when they are dry.

Now add in things like Tornado, Hurricanes, and Thunderstorms.. and now it gets interesting.

What is Done​

New Game Mechanic: Air Temperature

When a map is created each Tile is given a Random Temperature. This is done durning the Terrain Generation phase of Map creation, and just after the Plot's TerrainType is set.

Two new tags in the TerrainInfo XML file allow you to control the lowest and highest Temperatures for each Terrain. A Tile's Air Temperature can be slightly higher or lower then these values, but not by much.

This alone creates a very chaotic Initial Temperature Scheme, so I have added 4 new functions to CvPlot. One each to normalize the Temperature Scheme of Land Plots, Lakes Plots, Coast Plots, and Ocean Plots.

I have used slightly different methods in each of the functions, but the basic idea is a follows.

All Land Plots are Normalized first. I go through each Plot and check the Temperature of its 8 adjacent Plots. Only other Land Plots are checked. I get an average of all 9 Plots (the Plot we are checking and the 8 adjacent) Temperatures and apply that. The Lowest and Highest Temperatures of the Plot's Terrain Type are respected and there is some random rolls in there so things don't get to static.

Next Lake Plots are Normalized. I go through all plots and grab those that are isLake() == true. For the moment, I have the Normalize Coast code shoved in here, but I am laying out a better way of giving Lakes their proper Temperature.

Next we Normalize Coast Plots. Coast Plots are any Water Plot that is adjacent to a Land Plot and isn't a Lake. I , again, average the Temperature of the Plot and its 8 adjacent Plots. I then take the lowest Temperature of the 9 checked Plots, add that to the Average Temperature, and divide that new value by 2. This function still needs a little bit of work.

Lastly Normalize the Ocean Plots. Ocean Plots are all Water Plots that aren't Coast. This one is pretty simple. Instead of checking the 8 adjacent Plots, I get an average of all Land and Coast Plots (but NOT Lake Plots) and add a small random factor to it. This is then set as the Oceans Air Temperature.

I run these four functions in that order at the end of Map Creation. They are run in the CvMapGenerator::afterGeneration() function and are called before the call to the Python Map Script afterGeneration() method.

So these seem to generate a resonably realistic Temperature Scheme. There are still a few things that need tweeking, for example I think the Oceans need a some kind of Temperature change as you get father from land, but it is definetly good enough for the moment.

New Game Mechanic: Wind Direction

Air Temperature is great and all, but it isn't much more then a framework to build on. The first thing I have hung on it is Wind Direction. The concept and a few of the new functions are taken from Dom Pedro II's Conqueror's Delight Mod, Naval Mod Compent, so props to him.

At the end of Map Creation, in the CvMapGenerator::afterGeneration() function just before the Python Map Script afterGeneration() method is call and just after the Normalize Temperature functions are called, each Plot will have an Initial Wind Direction set on it.

The Initial Wind Direction is a little more complex then the Normalize Temperature ones. For each Plot on the Map I get the 8 adjacent Plots. Each of those adjacent Plots is given a Weight. For each Plot surrounding those adjacent Plots, the adjacent Plot's Weight is raise. Tiles with a Temperature higher then the origional Plot's Temperature add the most, equal Temperatures add some, and lower Temperatures almost nothing.

Again, not perfect yet, but definetly close. I am almost done laying out some Normalize Wind Direction code that will pull the whole thing together.

New Game Mechanic: Weather Systems

Weather Systems is the title for things like Tornados, Thunder Storms, Hurricanes, ect. I am currently going with the idea of Weather Systems being Units. So far I have Tornados and Thunder Storms added in.

They don't really do much yet, but I did manage to get them moving around on the Wind Currents. I planning things like damage to Units in the same Tile, increased/decreased Food from Tiles, increased/decreased Happiness/Health in Cities, and maybe some other stuff.

New Game Screen: Weather Patterns

I've added a new Screen, 'SHIFT + W', that allows you to see a Map of the World with a Colored Overlays showing Air Temperatures, Wind Directions, and Weather Systems. This screen also has some options to modify the new Systems when World Builder is active.


What I'm Working On​

Not much coding wise this week, RL is pretty busy, but I'm laying thing out on paper in my free time. Besides some tweeks to what is already done, my next coding goal is to add in Moisture and the in game spawning of Weather Systems.
 

Attachments

  • JWeather_Tornado_Moving_0.JPG
    JWeather_Tornado_Moving_0.JPG
    137.3 KB · Views: 333
  • JWeather_Tornado_Moving_1.JPG
    JWeather_Tornado_Moving_1.JPG
    141.6 KB · Views: 282
  • JWeather_Tornado_Moving_2.JPG
    JWeather_Tornado_Moving_2.JPG
    141.3 KB · Views: 262
  • JWeather_ThunderStorm_Raining.JPG
    JWeather_ThunderStorm_Raining.JPG
    83.4 KB · Views: 294
  • JWeather_Overlay_AirTemperature.JPG
    JWeather_Overlay_AirTemperature.JPG
    114.6 KB · Views: 282
  • JWeather_Overlay_WindDirection.JPG
    JWeather_Overlay_WindDirection.JPG
    119.8 KB · Views: 298
Some thanx to the people that created stuff I'm using in this project.

jdog5000 - AIAutoPlay rocks!

Fierabras and Crew - Tornado Graphic :goodjob:
 
I started with the Tornado as Feature, but I didn't like that Forests were removed when the Tornado was placed. It also makes the moving of the Tornado alot easyer if its a Unit. I don't give it any Combat Strength and it can't attack, all its effects will be handled in Python or SDK.

I'll probly also fix it so the Unit Flag isn't show for the Weather Units.. I mean, you would think the flag would get blown away by the Tornado.. :p
 
Ok. Here you are three men who makes st. of that kind.
I requested fierabras if he can make vizualization of events from event system with usage my models.
Faichele (WoC) makes on rework dissaster engine by Primemover for BtS
and you now start work on Weather system.
I think here is many guys who want st. of that kind. If you can cooperate, we all will have awesome system for Weather including dissaster. :goodjob:
If you need some models for it, send word :)
thanks for your work (improvement control especially)
HROCHland
(and sorry for my bad English ;) )
 
This is a cool idea. Natural Disasters and phenomenon would be a great addition.
 
Ok. Here you are three men who makes st. of that kind.
I requested fierabras if he can make vizualization of events from event system with usage my models.
Faichele (WoC) makes on rework dissaster engine by Primemover for BtS
and you now start work on Weather system.
I think here is many guys who want st. of that kind. If you can cooperate, we all will have awesome system for Weather including dissaster. :goodjob:
If you need some models for it, send word :)
thanks for your work (improvement control especially)
HROCHland
(and sorry for my bad English ;) )

Thanx dude, its nice to have fans. You do awesome work aswell. I could really use a Hurricane Model. I picture it like the Tornado, but with more spinning clouds at the top. Also, the spinning air at the bottom of the model would need to be more spinning water then air.

I am not good at graphics, my tallent is coding, so I deffer to you on the what would look best. :band:

This is a cool idea. Natural Disasters and phenomenon would be a great addition.

Thanx, I agree Natural Disasters are going to be a must. I have Tornado and I'm planning to have Tsunami and Blizzard. Any other suggestions on Weather related Disasters... I guess ideas on Weather with positive effects would be good to.. but not as much fun.. :p
 
An Update.

I've been out of town on buisness all week and won't be back for a few more days so I am away from my main modding computer.

However I have got some XML and Python work done, the main part being a new Screen that is way better then the Colored Plot Overlay I had before. I updated the first post with more specific details on what I have done. I also added some more ScreenShots to the second post. :cool:
 
You've probably considered this already, but if not you ought to check Fall from Heaven: Age of Ice which had blizzards in it.

I should imagine weather only really works when your time units are very small. It's not very realistic to have slow moving hurriances at periods of ten years apiece.
 
You've probably considered this already, but if not you ought to check Fall from Heaven: Age of Ice which had blizzards in it.

Yep, I couldn't find the accual blizzard model in Age of Ice, but from a ScreenShot I saw of it, they just modded the BtS Thunderstorm graphic to have a white cloud and more snow-like stuff falling from the cloud, so I just modded the Thunderstorm myself to look more like a blizzard.


I should imagine weather only really works when your time units are very small. It's not very realistic to have slow moving hurriances at periods of ten years apiece.

Well, really, that is a matter of opinion. I personally don't care what "year" it says I'm in, I just watch the number of turns I've been playing, and 1 Turn is always equal to 1 Turn. That said, I'm considering adding several new Calendar options like Hours and Days.
 
Top Bottom