MODULE: Yet another weather module

Started by abstauber, Fri 19/12/2008 17:40:51

Previous topic - Next topic

abstauber

Hi,
I make it quick: I've forked akumayos weather module and this is, what came out.
It can do rain, snow, leaves, landslides, bubbles, insects and so on. It also works fine with SSHs SimpleSnow, so you can combine two effects if you like.

Demogame with source included.
Screenshots (although you won't see much on these):



Module:
V2.0 by Monsieur Ouxx:
https://www.dropbox.com/s/vk8o5zwki1vqj7d/weatherquest%202.0.zip
V1.0 from 2008
www.sonores.de/blog/wp-content/uploads/2008/12/weathermod.scm

Demogame (including the old module)
www.sonores.de/blog/wp-content/uploads/2008/12/weatherquest.zip

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)



pixg

first link is a HTML page with the following...(save as target just saves the html page)

AGSScriptModuleAbstauber, AkumayoWeatherMachine2.07'// Main script for module 'Environment Effects' WeatherModule weather; int WeatherModule::RandomBoundries(int min, int max) { int temp_rand; if ((max-min) < 0) temp_rand = (max-min) *(-1); else temp_rand = max-min; return (Random(temp_rand) + min); } static function WeatherModule::Init(int spritecount, int x_offset, int y_offset) { weather.spritecount = spritecount; Weather_sprites = new DynamicSprite[weather.spritecount]; Weather_enveffect = new Overlay[weather.spritecount]; Weather_slots = new int[weather.spritecount]; weather.x_offset = x_offset; weather.y_offset = y_offset; } static function WeatherModule::SetSprite(int slot, int sprite) { if (slot <= weather.spritecount) Weather_slots[slot] = sprite; else Display("%d",weather.spritecount); } static function WeatherModule::SetOffset(int x_offset, int y_offset) { weather.x_offset = x_offset; weather.y_offset = y_offset; } static function WeatherModule::SetBorders(int x_min, int x_max, int y_top, int y_bottom) { weather.x_min = x_min; weather.x_max = x_max; weather.y_top = y_top; weather.y_bottom = y_bottom; } static function WeatherModule::Start(int envfallingspeed, int envwindspeed, bool pixel_only, int x_jitter, int y_jitter, int x_min, int x_max, int y_top, int y_bottom) { int i; weather.fallingspeed = envfallingspeed; weather.windspeed = envwindspeed; weather.weathergoing = true; weather.pixel_only = pixel_only; weather.x_jitter = x_jitter; weather.y_jitter = y_jitter; weather.y_top = y_top; weather.y_bottom = y_bottom; weather.x_min = x_min; weather.x_max = x_max; int temp_x, temp_y; if (envfallingspeed == 0 && envwindspeed==0) { Display ("Speed values can't be 0 at the same time"); return false; } // make it rain, if no sprites have been supplied if (Weather_slots[0]==0 && weather.pixel_only==false) { weather.pixel_only = true; i=0; while (i 0) { i = 0; while (i < weather.spritecount ) { temp_x = weather.RandomBoundries(weather.x_min, weather.x_max); if (i%2

MurrayL

Your browser is obviously opening the scm file as a text file for some reason. Right click the link and 'Save Link As', or 'Save Target As', or whatever your browser calls it.

pixg

ok basicaly after save target i had to rename the file it was going to save from .htm to .srm

I've imported the script, now I just need to figure how to use it, it seems very complicated.
the demo is great, would have been nice to have a help file or tutorial.

abstauber

OMG, users after 4 years!!  8-0
Hooray!

@MurrayL: Thanks for fixing the links - I've updated the first post.

StillInThe90s

The warnings.log file in the demo zip shows 25 warnings about dynamic sprites not being deleted.
Could this affect performance?

Monsieur OUXX

Hi abstauber,

correct me if I'm wrong but this module creates one overlay per particle, therefore there is an upper limit of 20 particles or so? (because of AGS built-in limitations)
 

abstauber

I'm afraid that's correct. I wrote it in a time where I didn't know about dynamic sprites and such other wizardry :)

Personally I use the way more advanced (but complicated) Particle System Manager from jarakeen.

Monsieur OUXX

Quote from: abstauber on Wed 03/07/2013 09:44:45
I use the way more advanced (but complicated) Particle System Manager from jarakeen.
Is it the one that has a flock of bats in its demo? Damn, I was looking for it.

Anyway:
I created a version that uses a single overlay, which allows to go above the "20 particles" upper limit.
You module remains 99% unchanged -- the end-user simply has to pass a boolean in Weather.Init to tell if he wants to use that feature.

I suggest you update the first post of this thread.

Version 2.0

 

abstauber

QuoteIs it the one that has a flock of bats in its demo? Damn, I was looking for it.
It had bats? Are you sure we're talking about the same module? ;D
This is the one I use: http://www.adventuregamestudio.co.uk/forums/index.php?topic=36706.0

Crimson Wizard

Quote from: Monsieur OUXX on Wed 03/07/2013 00:05:35
correct me if I'm wrong but this module creates one overlay per particle, therefore there is an upper limit of 20 particles or so? (because of AGS built-in limitations)
Too hard to resist ^_^
https://github.com/adventuregamestudio/ags/commit/b12d3aedd6bd388cd8c540987751087098925b46

Spoiler

sadly that version is still pre-alpha and has several weird bugs
[close]

abstauber


Monsieur OUXX

Quote from: abstauber on Wed 03/07/2013 15:10:19
This is the one I use: http://www.adventuregamestudio.co.uk/forums/index.php?topic=36706.0

I've seen that one but the download link(s) is (are) broken.
Also CW I do know you're on the verge of breaking all the built-in limits (that's great!), but I can't wait, and 3.3.0 is still way too buggy to work with it in my case.

Anyway the update I've posted above works BUT don't you beloved scripters forget that it still doesn't work with sprites that have an alpha channel, because of the well-known limitations to DrawImage (here we draw the particles onto a transparent sprite => no go)
 

Alen101

#16
Im trying to use this module but i want to change the sprite. Instead of a blue pixel, some other sprite.
(Heres is the code im using, its very simple i just want a rain but with my own raindrops.)

Code: ags
WeatherModule.Init(16); // Setup 16 sprites
WeatherModule.Start(-1, 2, false,true,false, 0, 320, 0, 144); // Starts with falling speed 4 and windspeed 1
WeatherModule.SetSprite(Here i dont know what to put to make some other sprite instead of the blue pixel to appear.)


Any ideas?

I downloaded the module and the game and look into the code but it gets complicated,For example he use this
Code: ags
 WeatherModule.SetSprite(i, 9);


So that (i), I dont know what the int slot is.

Ive tryed at least to tint the particles with this but i cant make it work.
Code: ags
Weather_sprites.Tint(0, 0, 10, 100, 100);

abstauber

Quote from: Alen101 on Sun 20/12/2015 23:28:09
Code: ags

WeatherModule.SetSprite(Here i dont know what to put to make some other sprite instead of the blue pixel to appear.)

I downloaded the module and the game and look into the code but it gets complicated,For example he use this
Code: ags
 WeatherModule.SetSprite(i, 9);


So that (i), I dont know what the int slot is.

It's been ages since I've used this one. The i is just a counter variable to save some time.

For example you can do this and setup each sprite slot manually
Code: ags

WeatherModule.SetSprite(1, 9);
WeatherModule.SetSprite(2, 9);
WeatherModule.SetSprite(3, 9);
WeatherModule.SetSprite(4, 9);
WeatherModule.SetSprite(5, 9);

Or you use a variable and save a few lines of code. The result is the same.
Code: ags

int i = 1;
while (i < 6) {
    WeatherModule.SetSprite(i, 9);
    i = i + 1;
}

In this example the sprite_slot 9 (your graphic) are being assigned to the weather particles 1 to 5.

Alen101

Ah I understand now!
I used this:
WeatherModule.SetSprite(1, 2000);
So the first drop of rain (in my case) should be the default character front view of the presseted game.

but i just see blue 1x1 pixels.
What i am doing wrong?
Is there a setting im not putting in?
like for example i found looking on the autocomplete
Weather_sprites.Tint(10, 20, 30, 100, 100);
this should change at least the color of the blue pixel
but nothing happens.

abstauber

Take a look at the Start function
Code: ags
WeatherModule.Start(int envfallingspeed = 1, int envwindspeed = 0, bool pixel_only = false,  int x_jitter = false, int y_jitter = false, 
                        int x_min = 0,  int x_max = 320, int y_top = -100, int y_bottom = 200);


There is the parameter pixel_only this needs to be set to false in case you want to use sprites. If it is set to true, the second parameter will be interpreted as a color instead of a sprite slot.

SMF spam blocked by CleanTalk