Saisons effects on maps

Brainstorm ideas of possible additions to the game. Read this before posting!

Moderator: Forum Moderators

Forum rules
Before posting a new idea, you must read the following:
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Saisons effects on maps

Post by hermestrismi »

Is there a campaign or modification that contains the effect of the course of saisons (like map turned slowly to snow in winter than returns to dry in summer )?
Shiki
Developer
Posts: 350
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: Saisons effects on maps

Post by Shiki »

Season Changer Mod comes to mind: r.wesnoth.org/t51067 Mainline MP map Dark Forecast also has something similar. However, they change the terrain during one turn instead of slowly.

HttT S12 Northern Winter has snowfall.
Try out the dark board theme.
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

Shiki wrote: March 4th, 2023, 10:43 am Season Changer Mod comes to mind: r.wesnoth.org/t51067 Mainline MP map Dark Forecast also has something similar. However, they change the terrain during one turn instead of slowly.

HttT S12 Northern Winter has snowfall.
Thank you. I can mix them both. I remember a scenario long ago where it rains temporarily (with even sound effects) but I forget in which campaign
User avatar
egallager
Posts: 584
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: Saisons effects on maps

Post by egallager »

hermestrismi wrote: March 4th, 2023, 11:27 am
Shiki wrote: March 4th, 2023, 10:43 am Season Changer Mod comes to mind: r.wesnoth.org/t51067 Mainline MP map Dark Forecast also has something similar. However, they change the terrain during one turn instead of slowly.

HttT S12 Northern Winter has snowfall.
Thank you. I can mix them both. I remember a scenario long ago where it rains temporarily (with even sound effects) but I forget in which campaign
Flight to Freedom has a scenario like that
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

a small touch here plz

Code: Select all

#define Summer_to_Winter
# This event makes random snowy locations turns to summer at such a
# constant pace that summer will be everywhere exactly when turns countdown ends
	[event]
		name=side 1 turn refresh
		first_time_only=no
		[if]
			[variable]
				name=season_summer_to_winter
				equals=now_begins
			[/variable]
			[then]
			[set_variable]
				name=season_couldown
				value=$turn_number
			[/set_variable]
			[set_variable]
				name=season_couldown
				add=12
			[/set_variable]
             {DEBUG_MSG "winter begins turn $turn_number and ends $season_couldown"}
				[fire_event]
					name=winter_season
					id=winter_season
				[/fire_event]
			[/then]
		[/if]
	[/event]
        [event]
            name=winter_season
					id=winter_season
            first_time_only=no
            delayed_variable_substitution=yes
			[set_variable]
				name=season_summer_to_winter
				value=winter_begins
			[/set_variable]
			[event]
				name=side 1 turn refresh
				first_time_only=no
			[if]
				[variable]
					name=turn_number
					less_than_equal_to=$season_couldown
				[/variable]
				[then]
				
            [random_placement]
                num_items="(size / (size / ($season_couldown - $turn_number)))"
                variable=loc
                allow_less=no
                [filter_location]
                    terrain="{deepAwater_2},{shallowAwater_2},{swamp_2},{regularAflat_2},{regularAcobbles_2},{sand_2},{regularAgreatAtrees_2},{deadAgreatAtrees_2},{regularAforest_2},{sandAforest_2},{summerAforest_2},{winterAforest_2},{regularAhills_2},{sandAhills_2},{regularAmountains_2},{sandAmountains_2},{regularAvillage_2},{ruinAvillage_2},{sandAvillage_2},{regularAcastel_2},{ruinAcastel_2},{sandAcastel_2},{regularAkeep_2},{ruinAkeep_2},{sandAkeep_2}"
                [/filter_location]
                [command]
                    [switch]
                        variable=loc.terrain
                        [case]
                            value={deepAwater_2},{shallowAwater_2},{swamp_2}
                            {VARIABLE terrain Ai}
                        [/case]
                        [case]
                            value={regularAflat_2},{sand_2}
                            {VARIABLE terrain Aa}
                        [/case]
                        [case]
                            value={regularAcobbles_2}
                            {VARIABLE terrain {IcyAcobbles_2}}
                        [/case]
                        [case]
                            value={regularAgreatAtrees_2},{deadAgreatAtrees_2}
                            {VARIABLE terrain {snowAgreatAtrees_2}}
                        [/case]
                        [case]
                            value={regularAforest_2},{sandAforest_2},{summerAforest_2},{winterAforest_2}
                            {VARIABLE_OP terrain rand "{snowAforest_2}"}
                        [/case]
                        [case]
                            value={regularAhills_2},{sandAhills_2}
                            {VARIABLE terrain {snowAhills_2}}
                        [/case]
                        [case]
                            value={regularAmountains_2},{sandAmountains_2}
                            {VARIABLE_OP terrain rand "{snowAmountains_2}"}
                        [/case]
                        [case]
                            value={regularAvillage_2},{ruinAvillage_2},{sandAvillage_2}
                            {VARIABLE_OP terrain rand "{snowAvillage_2}"}
                        [/case]
                        [case]
                            value={regularAcastel_2},{ruinAcastel_2},{sandAcastel_2}
                            {VARIABLE_OP terrain rand "{snowAcastel_2}"}
                        [/case]
                        [case]
                            value={regularAkeep_2},{ruinAkeep_2},{sandAkeep_2}
                            {VARIABLE_OP terrain rand "{snowAkeep_2}"}
                        [/case]
                        # just a fallback in case something goes wrong
                        [else]
                            {VARIABLE terrain $loc.terrain}
                        [/else]
                    [/switch]
                    [terrain]
                        x,y=$loc.x,$loc.y
                        terrain=$terrain
                    [/terrain]
                [/command]
            [/random_placement]
            {CLEAR_VARIABLE terrain}
				[/then]
				[else]
					{CLEAR_VARIABLE season_couldown,season_summer_to_winter}
					[remove_event]
						id=winter_season
					[/remove_event]
				[/else]
			[/if]
        [/event]
	[/event]
#enddef
the

Code: Select all

num_items
here raise an error obviously when

Code: Select all

(size / ($season_couldown - $turn_number)
) give 0.
Any help to avoid both a zero or a great number?
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

the full file if someone want to check
Attachments
EK_1.cfg
(13.08 KiB) Downloaded 25 times
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Saisons effects on maps

Post by beetlenaut »

hermestrismi wrote: March 5th, 2023, 9:02 am Any help to avoid both a zero or a great number?
If you want make sure a value is between 0 and 10, the normal logic for this is:

Code: Select all

if value < 0 then
    set value to 0
if value > 10 then
    set value to 10
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

Well, I used the WFL

Code: Select all

"(size / (abs ($season_couldown - $turn_number) + 1))"
The work was harder than I thought and I consider it 'incomplete'
this only for spring but other seasons are on the same line
before that, I modified the terrain '^Ii' (beam of light) like that:

Code: Select all

[terrain_type]
    symbol_image=beam2-tile
    id=lit2
    name= _ "Lit2"
    editor_name= _ "Beam of Light2"
    string=^Iig
    aliasof=_bas
    light=30
    editor_group=wesnoth-UMC-TDMPtest2,embellishments
[/terrain_type]

{NEW:OVERLAY     (*^Iig)          beam2-[1~3] FLAG=light LAYER=2}
(if smone didn't know how to add a terrain macro, he can just delete the embellishments part)
and put this in the scenario event

Code: Select all

		[set_variable]
			name=what_season_is_it
			value=season_is_spring
		[/set_variable]
and

Code: Select all

{SPRING_ACTIONS}
in scenario toplevel
Attachments
spring_mode.cfg
(8.52 KiB) Downloaded 32 times
general_weather_utils.cfg
(7.41 KiB) Downloaded 30 times
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

I did something wrong here
(I want the changes to take effect only on day not at night)

Code: Select all

#define SPRING_EMBELL_AND_SOUNDS
	[store_time_of_day]
	[/store_time_of_day]
	[random_placement]
		num_items=1
		variable=loc_rand_for_sound
		allow_less=no
		min_distance=1
		[filter_location]
			terrain="*^Fet*,*^Ft*,*^Fp*"
		[/filter_location]
		[command]
			[if]
				[variable]
					name=counter_sound_of_season
					less_than_equal_to=3
				[/variable]
				[then]
					[store_locations]
						[filter_location]
							terrain="*^Fet*,*^Ft*,*^Fp*"
						[/filter_location]
						x,y=$loc_rand_for_sound.x,$loc_rand_for_sound.y
						variable=loc_rand_for_sound_and_emb
						mode=append
					[/store_locations]
					[set_variable]
						name=counter_sound_of_season
						add=1
					[/set_variable]
				[/then]
			[/if]
			{CLEAR_VARIABLE loc_rand_for_sound}
		[/command]
	[/random_placement]
	[foreach]
		array=loc_rand_for_sound_and_emb
		[do]
			[switch]
				variable=time_of_day.id
				[case]
					value="dawn_spring,morning_spring,midday_spring,afternoon_spring"
					{SET_LABEL "$loc_rand_for_sound_and_emb.x" "$loc_rand_for_sound_and_emb.y" ( _ "$loc_rand_for_sound_and_emb.terrain| birds_$loc_rand_for_sound_and_emb.x_$loc_rand_for_sound_and_emb.y ")}
					[terrain]
						terrain=*^Iig
						x,y=$loc_rand_for_sound_and_emb.x,$loc_rand_for_sound_and_emb.y
						layer=overlay
					[/terrain]
					[sound_source]
						id=birds_$loc_rand_for_sound_and_emb.x_$loc_rand_for_sound_and_emb.y
						x,y=$loc_rand_for_sound_and_emb.x,$loc_rand_for_sound_and_emb.y
						check_fogged=no
						check_shrouded=no
						sounds=ambient/birds1.ogg,ambient/birds2.ogg,ambient/birds3.ogg
						delay=6000
						chance=100
						full_range=11
						fade_range=2
						loop=-1
					[/sound_source]
				[/case]
				[else]
					[remove_sound_source]
						id=birds_$loc_rand_for_sound_and_emb.x_$loc_rand_for_sound_and_emb.y
					[/remove_sound_source]
					[terrain]
						terrain=Gs^
						x,y=$loc_rand_for_sound_and_emb.x,$loc_rand_for_sound_and_emb.y
						layer=overlay
					[/terrain]
				[/else]
			[/switch]
		[/do]
	[/foreach]
#enddef
no error and the effect is as intended to be (a label was put) but the terrain changes only one time and the sound too
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Saisons effects on maps

Post by beetlenaut »

If you have a syntax error in a dozen lines of code, someone can probably find it just by looking at the code. In this case though, you have a logic error, which is harder to find, and you have posted about 700 lines of code from six or seven different files. Nobody is likely to find it just by looking. To find the problem, I would run the scenario and track the value of variables with :inspect and {DEBGUG_MSG}. I would see what happened when I changed things. But, with what you have posted, I couldn't do that.

You have two choices. You could zip up the whole campaign and post it. However, it would be better to make a test case: Make a runnable copy of the campaign that only includes the scenario and files needed to make the error occur. In making a test case, you might find the problem yourself, but if not, you could post that instead of the whole campaign. (I know that I could put this all together in a test case myself, but that would take a while, and it's kind of your job anyway.)
hermestrismi wrote: March 7th, 2023, 5:51 pm the terrain changes only one time and the sound too
If something runs only once, the problem is most likely in the code that triggers it. This doesn't look like the relevant part.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

beetlenaut wrote: March 7th, 2023, 11:43 pm If you have a syntax error in a dozen lines of code, someone can probably find it just by looking at the code. In this case though, you have a logic error, which is harder to find, and you have posted about 700 lines of code from six or seven different files. Nobody is likely to find it just by looking. To find the problem, I would run the scenario and track the value of variables with :inspect and {DEBGUG_MSG}. I would see what happened when I changed things. But, with what you have posted, I couldn't do that.

You have two choices. You could zip up the whole campaign and post it. However, it would be better to make a test case: Make a runnable copy of the campaign that only includes the scenario and files needed to make the error occur. In making a test case, you might find the problem yourself, but if not, you could post that instead of the whole campaign. (I know that I could put this all together in a test case myself, but that would take a while, and it's kind of your job anyway.)
hermestrismi wrote: March 7th, 2023, 5:51 pm the terrain changes only one time and the sound too
If something runs only once, the problem is most likely in the code that triggers it. This doesn't look like the relevant part.
Thank you for the explanation. In fact, This is exactly what I did. I am running only a test scenario with only the necessary macros (File : general macros for the terrains abbreviations, file spring mode for the main event) And I run under debug mode and with inspect option.
I made a "set_label" To see what step is successful and I am pretty sure that the whole code is working except the part of the embellishments and sound source which there is no way to find out what happen There since there is no information inside the inspect mode.
The problem may be caused by two things (I think):
1) I made a mistake during the first random_placement (loc_rand_for_sound) maybe the mode (I tried append, Replace and always_clear And the best fit mode is Clearly append) OR the x,y outside the filter_location ...
2) the [foreach] (I think it is the most probable problem). I think it loop only one variables instead of the whole lengths but I tried other expressions to make the iteration with no succes (I also tried [for] ..)
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

A strange thing is when I script "value=morning, .., dusk," (with additional comma) the event happened once and when I corrected it (deleting the additional comma) the code stop working with no error message. I read the save file, there is Indeed many [sound_source] and only one terrain modified embellishments. Both points are well... wiered
User avatar
beetlenaut
Developer
Posts: 2827
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Saisons effects on maps

Post by beetlenaut »

hermestrismi wrote: March 8th, 2023, 12:00 am I think it loop only one variables instead of the whole lengths
Oh, I see. That variable will only contain one element. Your [store_locations] has an x and y, so that is the only location stored, which is not what you want I guess. Also, you can't use [filter_location] inside [store_locations], so that part is being ignored. With :inspect, you would have been able to see that loc_rand_for_sound_and_emb had only one element.

I suppose it's not obvious what an array would look like in :inspect if you've never seen one, but you could look at some simpler arrays to see the difference.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

The logical process I made is like that:
(If time is spring then:)
Step 1: store all forest tiles and pick only one tile (solution: random placement with one items num)
Step 2: mark this tile and clear the random_placement (solution: command -> store location*)
Step 3: in this tile add a sound_source and a new terrain with high lawful bonus. (Solution: foreach -> add sound source with the x/y as id to delete later and replace terrain**)
Step 4: check time of day. If it is day: play the sound source and the tile, if night remove the sound source and remove the tile (solution: inside the foreach -> switch and check the time of day).
Step 5: next turn, the same event repeat but with an additional tile...
* the problem may be here
** the problem may be here
User avatar
hermestrismi
Posts: 626
Joined: February 6th, 2016, 11:28 pm
Location: Tunisia
Contact:

Re: Saisons effects on maps

Post by hermestrismi »

beetlenaut wrote: March 8th, 2023, 12:20 am
hermestrismi wrote: March 8th, 2023, 12:00 am I think it loop only one variables instead of the whole lengths
Oh, I see. That variable will only contain one element. Your [store_locations] has an x and y, so that is the only location stored, which is not what you want I guess. Also, you can't use [filter_location] inside [store_locations], so that part is being ignored. With :inspect, you would have been able to see that loc_rand_for_sound_and_emb had only one element.

I suppose it's not obvious what an array would look like in :inspect if you've never seen one, but you could look at some simpler arrays to see the difference.
Inside the inspect, I saw all the arrays (with index from 0 to 4 as intended) . I mean that I can't find the information about the sound source in the inspect mode.
In fact, I put the set_label to see if the ID is changed and it was. With every turn, a new label was added with a precise ID but no event except the first
Post Reply