Random map with 4 seasons,I have some problems on that...

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
savagust
Posts: 56
Joined: November 19th, 2005, 4:00 am

Random map with 4 seasons,I have some problems on that...

Post by savagust »

I want to make a random map with 4 seasons.

The season of this random map changes every 6 turns.Each season affects certain types of terrain.

Since I haven't made anything like that before, code may be messy.

I have two main problems on it.

Firstly, I don't know how to make the season change every 6 turns but not every turn.Every turn is too often for me :lol:

Secondly, the season remains changing into Spring every turn.It cannot change into other seasons.The cycle of season that I hope is:Spring > Summer > Autumn > Winter > Spring...

I failed to solve the problems myself.
If someone can teach me how to do, I really appreciate :)

Code: Select all

[event]
 name=prestart

 {VARIABLE weather spring}
[/event]

[event]
name=new turn 
first_time_only=no
	[if]
 		[variable]
		  name=weather
		  equals=spring
		[/variable]
	[then]
		[command]
		 {VARIABLE weather summer}
		[/command]
	[/then]
	[/if]

	[if]
 		[variable]
		  name=weather
		  equals=summer
		[/variable]
	[then]
		[command]
		 {VARIABLE weather autumn}
		[/command]
	[/then]
	[/if]

	[if]
 		[variable]
		  name=weather
		  equals=autumn
		[/variable]
	[then]
		[command]
		 {VARIABLE weather winter}
		[/command]
	[/then]
	[/if]

	[if]
 		[variable]
		  name=weather
		  equals=winter
		[/variable]
	[then]
		[command]
		 {VARIABLE weather spring}
		[/command]
	[/then]
	[/if]

[/event]

[event]
name=new turn 
first_time_only=no

	[if]
		[variable] 
     		name=weather
     		equals=spring
     		[/variable] 

	[then]
		[command]
			[message]
			speaker=narrator
	  		message=_ "Spring..."
			[/message]

			[terrain_mask]
			x,y=1,1
			{EMPTY_MASK}
				[rule]
				old=gi
				terrain=g
				[/rule]
			[/terrain_mask]
		[/command]
	[/then]

	[/if]

    	[if]
        		[variable] 
            		name=weather
            		equals=summer
        		[/variable] 

        	[then]
          		[command]
			[message]
			speaker=narrator
	  		message=_ "Summer..."
			[/message]

			[terrain_mask]
			x,y=1,1
			{EMPTY_MASK}
				[rule]
				old=g
				terrain=d
				[/rule]
			[/terrain_mask]
		[/command]
	[/then]
	[/if]

    	[if]
        		[variable] 
            		name=weather
            		equals=autumn
        		[/variable] 

        	[then]
          		[command]
			[message]
			speaker=narrator
	  		message=_ "Autumn..."
			[/message]

			[terrain_mask]
			x,y=1,1
			{EMPTY_MASK}
				[rule]
				old=d
				terrain=w
				[/rule]
			[/terrain_mask]
		[/command]
	[/then]
	[/if]


    	[if]
       	 	[variable] 
            		name=weather
            		equals=winter
        		[/variable] 

        	[then]
          		[command]
			[message]
			speaker=narrator
	  		message=_ "Winter..."
			[/message]

			[terrain_mask]
			x,y=1,1
			{EMPTY_MASK}
				[rule]
				old=w
				terrain=i
				[/rule]
			[/terrain_mask]
		[/command]
	[/then]
	[/if]
[/event]

Last edited by savagust on May 22nd, 2006, 6:54 am, edited 1 time in total.
flava_clown
Posts: 79
Joined: September 24th, 2005, 10:46 am
Location: Spain
Contact:

Post by flava_clown »

take a look in the Despair and Decay campaign. i mean the Haunted Houses scenario. there we change some cave tiles depending on the time of day. however i had to count the turns, so i am pretty sure that you can use the same system for the season changes you wish. just make macros for every season and call them on the turn when you need them.

i will see if i can make an example this weekend but maybe you want try it for yourself, since i can't promise anything. ;)
Imagine there's no countries
It isn't hard to do
Nothing to kill or die for
And no religion too
Imagine all the people
Living life in peace
savagust
Posts: 56
Joined: November 19th, 2005, 4:00 am

Post by savagust »

Your suggestion helps me a lot otherwise I would not find a right direction to try to make it work.

Thanks for your attention and kindly suggestion :D
sparr
Posts: 209
Joined: March 6th, 2006, 5:02 am

Post by sparr »

The trick is to use <ick>MATH</ick>! :)

if turns-((turns/4)*4)==0 then do_stuff_every_fourth_turn

this works because the division gets rounded. ive got a map with tides (water moves in and out every 2-4 turns) that uses this, ill try to dig it up and post the WML.
savagust
Posts: 56
Joined: November 19th, 2005, 4:00 am

Post by savagust »

sparr wrote:The trick is to use <ick>MATH</ick>! :)

if turns-((turns/4)*4)==0 then do_stuff_every_fourth_turn

this works because the division gets rounded. ive got a map with tides (water moves in and out every 2-4 turns) that uses this, ill try to dig it up and post the WML.
I am working on it smoothly with the suggestion of flava_clown

Thanks again, flava_clown :D

However, I still didn't know how to make the season change every 6 turns until now :lol:

May you post an example here?It would help a lot because I don't know where the equation should be added.

Thanks sparr :D
sparr
Posts: 209
Joined: March 6th, 2006, 5:02 am

Post by sparr »

Code: Select all

	[event]
		first_time_only=no
		name=new turn
		{SETVAR temp format $turn_number}
		{SETVAR temp add 2}
		{SETVAR temp multiply .25}
		{SETVAR temp multiply 4}
		{SETVAR temp add -2}
		[if]
			[variable]
				name=temp
				numerical_equals=$turn_number
			[/variable]
			[then]
				{LOWTIDE}
			[/then]
			[else]
				{SETVAR temp format $turn_number}
				{SETVAR temp multiply .25}
				{SETVAR temp multiply 4}
				[if]
					[variable]
						name=temp
						numerical_equals=$turn_number
					[/variable]
					[then]
						{HIGHTIDE}
					[/then]
				[/if]
			[/else]
		[/if]
	[/event]
This changes from low tide to high tide and back every 2 turns. the .25 and 4 constants correspond to the 4 turn complete cycle, and the +/- 2 makes low tide start 2 turns after high tide. For 4 seasons you would have a 24 turn complete cycle, and you would +/- 0 for spring, 6 for summer, 12 for fall, 18 for winter. This would make the game start in the second month of spring, i think... Adjust all the +/- values to make the game start on a different 'month'.
savagust
Posts: 56
Joined: November 19th, 2005, 4:00 am

Post by savagust »

Thanks so much, sparr!

I know how to do it now :D
savagust
Posts: 56
Joined: November 19th, 2005, 4:00 am

Post by savagust »

I modified and added it to my code, but I don't know what I have missed, so my code doesn't work.

I would like to see the whole file so that I could find my mistakes by compare.

May you post the whole file here?

Sorry for bothering you again :(
Post Reply