How to remove terrain graphics mid-scenario

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
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

How to remove terrain graphics mid-scenario

Post by Helmet »

I created an illustration of a huge puddle of green slime and I figured-out how to make it appear on my map. So far, so good. Toward the end of the scenario, however, I want the puddle to go away, revealing the floor underneath. I tried a few things, but either the slime remained visible, or the slime no longer appeared in the scenario at all.

How do I remove a terrain graphic mid-scenario? Thanks.

Code: Select all

[/scenario]
# ... removed code

[terrain_graphics]
		x=18
		y=1
		[image]
			layer=0
			name=green_slime.png
		[/image]
		map="
*,*,*,*,*
,*,*,*,*
*,*,*,*,*
,*,*,*,*
*,*,*,*,*
,*,*,*,*"
[/terrain_graphics] 
[/scenario]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: How to remove terrain graphics mid-scenario

Post by WhiteWolf »

If I remember correctly, the way I did this was to give the [terrain_graphics] a tod condition, and create my custom time of day for it. So the scenario with start with {DEFAULT_SCHEDULE}, then to activate the [terrain_graphics], just use

Code: Select all

[replace_schedule]
	{DEFAUT_SCEDULE_WITH_TERRAINGRAPHICS} # defined somewhere and included in [terrain_graphics] tod keys.
[/replace_schedule]
and to then remove it, just use [replace_schedule] again back to default schedule. You may want to monitor turns so that the actual shown schedule stays the same, and it doesn't go from first watch to afternoon in one turn and things like that.

This may not be the most efficient or elegant way, so someone might come up with something much better, but it did work. (If I remember correctly :) )
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to remove terrain graphics mid-scenario

Post by Helmet »

WhiteWolf wrote: November 30th, 2020, 6:51 am If I remember correctly, the way I did this was to give the [terrain_graphics] a tod condition, and create my custom time of day for it.
Thank you, that's a clever solution. Wouldn't you know it, my scenario occurs in a cave with no schedule. Or maybe the schedule is a lack of schedule. Anyhow, it's always the same time-of-day.

So I guess I need to create an identical schedule with with a different id, then replace the schedule with that schedule. Okay.

It seems like there should be another way to get rid of a terrain graphic, though. This isn't the first time I had this problem, after all. I usually give up and change my plans, but this time I really, really need the terrain graphic to go away.

Code: Select all

    [time]
        id=mushroomcave
        name= _ "Mushroom Cave"
        image=misc/time-schedules/schedule-underground.png
        red=-25
        green=-15
        blue=0
        lawful_bonus=-25
    [/time]
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to remove terrain graphics mid-scenario

Post by Helmet »

It didn't work. I made two identical schedules for the cave, with one difference: one has id=cave_with_slime and one has id=cave_without_slime. I added a variant tag to the terrain_graphics code with tod=cave_with_slime. Then I did replace schedule to the new schedule.

Here is the replace schedule code.

Code: Select all

 	[event]
 		name=turn 10
		[replace_schedule]
			[time]
				id=cave_without_slime
				name= _ "Mushroom Cave"
				image=misc/time-schedules/schedule-underground.png
				red=-25
				green=-15
				blue=0
				lawful_bonus=-25
			[/time]
		[/replace_schedule]
 	[/event]
And here is the code with the variant tag added.

Code: Select all

[terrain_graphics] # scenario 5, corrupted castle
		x=18
		y=1
		[image]
			layer=0
			name=corrupted_castle.png
		[/image]
		[variant]
			tod=cave_with_slime
		[/variant]
		map="
*,*,*,*,*
,*,*,*,*
*,*,*,*,*
,*,*,*,*
*,*,*,*,*
,*,*,*,*"
[/terrain_graphics]
Thanks for your help.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: How to remove terrain graphics mid-scenario

Post by WhiteWolf »

Your variant tag may be in the wrong place.

Now please note that I'm not a terrain expert, so I'm just deducing from an old code:
Spoiler:
So I think it should be:

Code: Select all

[terrain_graphics] # scenario 5, corrupted castle
		x=18
		y=1
		[image]
			layer=0
			name=EMPTY_corrupted_castle.png # this should be an empty (transparent) image, identical in size to corrupted_castle.png.
		        [variant]
          			tod=cave_with_slime
          			name=corrupted_castle.png
		        [/variant]
		[/image]
		map="
*,*,*,*,*
,*,*,*,*
*,*,*,*,*
,*,*,*,*
*,*,*,*,*
,*,*,*,*"
[/terrain_graphics]
The replace schedule fragment looks good, so with this it should now work I think.
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to remove terrain graphics mid-scenario

Post by Helmet »

WhiteWolf wrote: November 30th, 2020, 4:15 pm ...The replace schedule fragment looks good, so with this it should now work I think.
It worked! The green slime is there...and then it goes away. Awesome.

WhiteWolf wrote: November 30th, 2020, 4:15 pm name=EMPTY_corrupted_castle.png # this should be an empty (transparent) image, identical in size to corrupted_castle.png.
I would never have figured this part out. Good heavens, terrain_graphics are complicated. No wonder I don't see them used all that often.

Thanks, WhiteWolf.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
WhiteWolf
Forum Moderator
Posts: 769
Joined: September 22nd, 2009, 7:48 pm
Location: Hungary

Re: How to remove terrain graphics mid-scenario

Post by WhiteWolf »

Glad you got it working :)
Main UMC campaigns: The Ravagers - now for 1.16, with new bugs!
Old UMC works: The Underness Series, consisting of 5 parts: The Desolation of Karlag, The Blind Sentinel, The Stone of the North, The Invasion Of The Western Cavalry, Fingerbone of Destiny
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: How to remove terrain graphics mid-scenario

Post by Celtic_Minstrel »

It's good you found a way to make it work, but I think it would've been simpler to link the slime pool to an overlay terrain. Then you just remove the terrain and it's gone.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to remove terrain graphics mid-scenario

Post by Helmet »

Celtic_Minstrel wrote: December 20th, 2020, 7:37 pm It's good you found a way to make it work, but I think it would've been simpler to link the slime pool to an overlay terrain. Then you just remove the terrain and it's gone.
Are you referring to type=?

In a different scenario, I used type= to get rid of an animated, swirling pool of slime that was one hex in size. I simply changed the hex from Wwg to Wwt and the 16-frame animated pool vanished.

Code: Select all

	[terrain]
		x,y=8,3
		terrain=Wwt
	[/terrain]

Code: Select all

	[terrain_graphics]
		x,y=8,3  
		[tile]
			x=0
			y=0
			type=Wwg
			[image]
				layer=0
				name="pool[16~1].png:180"
			[/image]
		[/tile]
	[/terrain_graphics]
The same solution can be applied to multi-hex terrain graphics?

I'm not sure how to do it. Is it basically the same exact process as the one I explained? Do I simply add a type= above the x,y coordinates? Because that would be a million times easier.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
User avatar
Celtic_Minstrel
Developer
Posts: 2222
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: How to remove terrain graphics mid-scenario

Post by Celtic_Minstrel »

I'm not 100% sure either, as I don't work with terrain graphics much. I think it should be possible but I could be wrong. If the pool actually takes up multiple hexes, you would probably need to put your custom terrain on all the hexes it fills; it's definitely possible to tell the engine that a 4x4 block of a particular terrain uses a single image (volcanoes do exactly that, though it's a 2x2 block).
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
Helmet
Posts: 641
Joined: December 19th, 2006, 5:28 pm
Location: Florida, USA

Re: How to remove terrain graphics mid-scenario

Post by Helmet »

Well, I gave it a shot and couldn't get it to work. When I changed the designated tile, the multi-hex terrain graphic did not disappear like I hoped it would. Oh well. I'll keep using the Time Of Day hack to remove the multi-hex terrain graphic, since it works.
Author of:
DIY Campaign, Confederacy of Swamp Creatures: Big Battle 1, Confederacy of Swamp Creatures: Big Battle 2, Frogfolk Delivery Service, The Pool of Ek.
Post Reply