How to submerge overlays and mapitems on water fields autom?

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.
Tet
Posts: 391
Joined: February 18th, 2009, 5:11 am

How to submerge overlays and mapitems on water fields autom?

Post by Tet »

I would like overlays (on units) be submerged with the unit in water and swamps. Is this possible? If yes how?

I would like scenery items placed randomly on the map be submerged in water and swamp. Is thbis possible? If yes how?
My Temple Project: http://forums.wesnoth.org/viewtopic.php?f=23&t=29800
This is "must-play" campaign! Don´t read the thread, unless you need help. http://forums.wesnoth.org/viewtopic.php?f=8&t=31895
User avatar
dipseydoodle
Posts: 872
Joined: September 16th, 2008, 10:26 pm
Location: The United States of America

Re: How to submerge overlays and mapitems on water fields autom?

Post by dipseydoodle »

Do you mean that you want items and units to be spawned and submerged, or am I not hearing you correctly?
- Dipsey
User avatar
PsychoticKittens
Posts: 573
Joined: May 29th, 2006, 8:49 pm

Re: How to submerge overlays and mapitems on water fields autom?

Post by PsychoticKittens »

I believe he means that he wants the water to overlay parts (or the entire) object like the legs of units are when they are standing on a hex of water. I may be wrong though.
Creator of: Mercenaries Era; Modern Combat
Future Projects: Faunima: Land of Monsters
Temporarily Dropped Projects: Zombie Horde
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How to submerge overlays and mapitems on water fields autom?

Post by zookeeper »

Tet wrote:I would like overlays (on units) be submerged with the unit in water and swamps. Is this possible? If yes how?
Should be possible by adding the overlays into the unit's animations as [xxx_frame] subanimations instead and using the submerge= key on them.
Tet wrote:I would like scenery items placed randomly on the map be submerged in water and swamp. Is thbis possible? If yes how?
You can't submerge them partially like units are, but you can use the ~O image path function to make them somewhat transparent.
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: How to submerge overlays and mapitems on water fields autom?

Post by Luke the Flaming »

Tet wrote:I would like scenery items placed randomly on the map be submerged in water and swamp. Is this possible? If yes how?
Just an idea: you could create a new item simply cancelling the bottom part of the old one with any apt program (if the original is an oak, call it oak_submerged.png and put it in the "images" folder of your campaign, era, whatever...). Then add an [if] clause in the scatter process checking the location where the item is going to be placed; when that's water, swamp, etc. use the ..._submerged.png image you created rather than the standard one.
I don't know if that would look good enough for you, but maybe it is worth trying with an item (and if you're satisfied you could create all the ..._submerged.png you need).
O, Wind, if Winter comes, can Spring be far behind?
Tet
Posts: 391
Joined: February 18th, 2009, 5:11 am

Re: How to submerge overlays and mapitems on water fields autom?

Post by Tet »

Thanks so far. Yes I mean partly covered with water.

Foir the unit overlay: I do place the overlays in an event at recruiting. Basically not useful units get a redflag. It looks reasonably nice, if not in water. How do I do that in an animation?

For the map overlay: I place them at some death events. I did make a partly transparent gravestone. It looks nice. But I did not succed with the coding. I tried filter_wml and copied the terrain code from the swimming wolf. And than a version with NOT as I believe if than else is not possible in event. It did not work. They both fire regardless of terrain. Is there some hint possible?
My Temple Project: http://forums.wesnoth.org/viewtopic.php?f=23&t=29800
This is "must-play" campaign! Don´t read the thread, unless you need help. http://forums.wesnoth.org/viewtopic.php?f=8&t=31895
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: How to submerge overlays and mapitems on water fields autom?

Post by Luke the Flaming »

Tet wrote:For the map overlay: I place them at some death events. I did make a partly transparent gravestone. It looks nice. But I did not succed with the coding. I tried filter_wml and copied the terrain code from the swimming wolf. And than a version with NOT as I believe if than else is not possible in event. It did not work. They both fire regardless of terrain. Is there some hint possible?
I may have not understood what you want to do.
You have an item (gravestone, the "map overlay"?) that you want to place in the hex where a unit dies... and it has to be different (normal or transparent) if that hex is land or water. Right or that's not what you want?
O, Wind, if Winter comes, can Spring be far behind?
Tet
Posts: 391
Joined: February 18th, 2009, 5:11 am

Re: How to submerge overlays and mapitems on water fields autom?

Post by Tet »

Absolutly correct. Items in water are partially submerged by making the lower half transparent. There are examples in the downloads. A half submerged rock is in the mermain campaign of beetlenut.
My Temple Project: http://forums.wesnoth.org/viewtopic.php?f=23&t=29800
This is "must-play" campaign! Don´t read the thread, unless you need help. http://forums.wesnoth.org/viewtopic.php?f=8&t=31895
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: How to submerge overlays and mapitems on water fields autom?

Post by Luke the Flaming »

Ok, then I'd try an [even] name=die that stores the location of the defunct unit, verifies if it is a water, swamp, etc. and with [then] / [else] places there the desired image (transparent or not).
O, Wind, if Winter comes, can Spring be far behind?
Tet
Posts: 391
Joined: February 18th, 2009, 5:11 am

Re: How to submerge overlays and mapitems on water fields autom?

Post by Tet »

I saw some code about if then else. I should get that done.

I am not sure about storing terrain.

I start with a unit_filter than I would like to filter terrain. I assumed it would be automatically the terrain of the first unit. That seems to be wrong. Placing the image is no problem.

Filtering the terrain I need help.
My Temple Project: http://forums.wesnoth.org/viewtopic.php?f=23&t=29800
This is "must-play" campaign! Don´t read the thread, unless you need help. http://forums.wesnoth.org/viewtopic.php?f=8&t=31895
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: How to submerge overlays and mapitems on water fields autom?

Post by Luke the Flaming »

Tet wrote:I saw some code about if then else. I should get that done.

I am not sure about storing terrain.

I start with a unit_filter than I would like to filter terrain. I assumed it would be automatically the terrain of the first unit. That seems to be wrong. Placing the image is no problem.

Filtering the terrain I need help.
This is how I'd do it:

Code: Select all

[event]
    name=die
    first_time_only=no
        [store_locations]
            x,y=$x1,$y1
            variable=graveyard
        [/store_locations]
        [if]
            [variable]
                name=graveyard.terrain
                equals=Ww
            [/variable]
            [or]
                [variable]
                    name=graveyard.terrain
                    equals=Wwr
                [/variable]
            [/or]
            # etc. etc. ... add one [or] for each terrain type you want to 
            # display the submerged gravestone instead of the normal one
        [then]
            {PLACE_IMAGE items/submerged_gravestone.png $x1 $y1}
        [/then]
        [else]
            {PLACE_IMAGE items/gravestone.png $x1 $y1}
        [/else]
        [/if]
        {CLEAR_VARIABLE graveyard}
[/event]
O, Wind, if Winter comes, can Spring be far behind?
Tet
Posts: 391
Joined: February 18th, 2009, 5:11 am

Re: How to submerge overlays and mapitems on water fields autom?

Post by Tet »

This is my last futile attempt. Terrain_type should work. It just does not get the coordinates of the event. There are 6 water terrains. I hope I do not need the if-loops for them.

Code: Select all

[event]
    name=die
    first_time_only=no
	[filter]
        type={DEF}
	 [/filter]
    [message]  
        speaker=unit
		message= _ " ... "
    [/message]
[if]	
    terrain_type=Wo,Ww,Ww^Vm,Chs,Chw,Ss	
	[then]
		{PLACE_IMAGE units/terrain/water-stone.png $x1 $y1}
	[/then]
	[else]
		{PLACE_IMAGE units/terrain/land-stone.png $x1 $y1}
	[/else]
[/if]
[/event]
My Temple Project: http://forums.wesnoth.org/viewtopic.php?f=23&t=29800
This is "must-play" campaign! Don´t read the thread, unless you need help. http://forums.wesnoth.org/viewtopic.php?f=8&t=31895
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: How to submerge overlays and mapitems on water fields autom?

Post by Luke the Flaming »

terrain_type used in that way means nothing (the code expects a tag with a condition after the [if] ); remove that line and try:

Code: Select all

[have_location]
    terrain=Wo,Wwr,Ww,Ww^Vm,Chs,Chw,Ss 
[/have_location]
EDIT: I've added Wwr (reefs) and maybe you'd like to add Wwf (ford) as well.
Last edited by Luke the Flaming on May 19th, 2010, 4:31 pm, edited 2 times in total.
O, Wind, if Winter comes, can Spring be far behind?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: How to submerge overlays and mapitems on water fields autom?

Post by zookeeper »

Tet wrote:This is my last futile attempt. Terrain_type should work.
It should work because you've never seen it work, anyone say it should work and also because nowhere does it say that it should work?
Tet
Posts: 391
Joined: February 18th, 2009, 5:11 am

Re: How to submerge overlays and mapitems on water fields autom?

Post by Tet »

Thx for pointing me to filter Terrain.
I did not find this page on wiki.
http://wiki.wesnoth.org/FilterWML#Filtering_Terrains
Your link did really help, zookeeper.
In case you questioning my logic, I can explain:
I copied the lines from a unit file of some wolf and asumed it might work here as well.
I am not a programmer. For me this is hobby or I believe you call it passtime.
Thank you all for helping out here.
My Temple Project: http://forums.wesnoth.org/viewtopic.php?f=23&t=29800
This is "must-play" campaign! Don´t read the thread, unless you need help. http://forums.wesnoth.org/viewtopic.php?f=8&t=31895
Post Reply