walkable lava

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

walkable lava

Post by Helmet »

Celtic_Minstrel wrote: December 26th, 2022, 10:39 pm You can make lava have its own movement cost in your addon. You need to make a custom "lava archetype" terrain, which will show up in the help but never be used on a map, and a custom version of the lava terrain that is an alias of the lava archetype instead of the unwalkable archetype. Then you need to use movetype patching (the [terrain_defaults] tag) to set all units who don't declare a lava move cost to use the same as the unwalkable move cost. And of course you need to always use your custom lava terrain instead of the built-in one.
Has anyone made a walkable lava yet? It seems like the kind of thing somebody would've done in a scenario. I'm a big believer in not reinventing the wheel whenever it can save me hours of debugging code.

Do I need to add anything to the _main.cfg? That seems like a good step 1 question.
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
Lord-Knightmare
Discord Moderator
Posts: 2363
Joined: May 24th, 2010, 5:26 pm
Location: Somewhere in the depths of Irdya, gathering my army to eventually destroy the known world.
Contact:

Re: walkable lava

Post by Lord-Knightmare »

walkable lava
Play _Tunnel of the Trolls_ of _Under the Burning Suns_
Creator of "War of Legends"
Creator of the Isle of Mists survival scenario.
Maintainer of Forward They Cried
User:Knyghtmare | My Medium
User avatar
Celtic_Minstrel
Developer
Posts: 2216
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: walkable lava

Post by Celtic_Minstrel »

I was going to post how to do it with actual code, but although I remember writing the code for it, I was unable to find it, so… sorry about that.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
User avatar
egallager
Posts: 583
Joined: November 19th, 2020, 7:27 pm
Location: Concord, New Hampshire
Contact:

Re: walkable lava

Post by egallager »

Helmet wrote: December 27th, 2022, 12:39 am
Celtic_Minstrel wrote: December 26th, 2022, 10:39 pm You can make lava have its own movement cost in your addon. You need to make a custom "lava archetype" terrain, which will show up in the help but never be used on a map, and a custom version of the lava terrain that is an alias of the lava archetype instead of the unwalkable archetype. Then you need to use movetype patching (the [terrain_defaults] tag) to set all units who don't declare a lava move cost to use the same as the unwalkable move cost. And of course you need to always use your custom lava terrain instead of the built-in one.
Has anyone made a walkable lava yet? It seems like the kind of thing somebody would've done in a scenario. I'm a big believer in not reinventing the wheel whenever it can save me hours of debugging code.
It exists in Flight to Freedom: https://github.com/cooljeanius/Flight_Freedom/ ... /terrain/terrain.cfg#L14-L28
User avatar
Celtic_Minstrel
Developer
Posts: 2216
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: walkable lava

Post by Celtic_Minstrel »

That looks a bit different… it's an alias of shallow water, not a separate terrain type.
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: walkable lava

Post by Helmet »

Everybody, let's all put walkable lava tiles on a map!

The Drake Clasher is too heavy to fly, so he can't cross lava like the other Drakes. Let's write some WML so the Drake Clasher can traverse lava!

I suggest we make his cautious footsteps represented by movement cost=3.

We need to do multiple things to make lava-walking happen. We need to create a new kind of lava tile, one that allows the Clasher to walk on it. Also, we need the new lava tile to appear in the Map Editor, so we can make a map that uses it (rather than the "old" lava).

Step 1, I guess, is to put some information in the _main.cfg, at the very bottom (outside the campaign tag).
"NU" is the abbreviation for my campaign, "New_Units_17." Substitute your own.

Is this correct? If not, why not?

Code: Select all

	#ifdef EDITOR
		[binary_path]
    			path=data/add-ons/New_Units_17
		[/binary_path]
		[editor_group]
    			id=NU
    			name= _ "My Custom Tileset"
    			icon="group_custom"
		[/editor_group]
		{~add-ons/New_Units_17/utils/terrain.cfg}
		{~add-ons/New_Units_17/utils/terrain_graphics.cfg}
	#endif
Then create a text file within the utils folder, call it terrain.cfg.
Then create a text file within the utils folder, call it terrain_graphics.cfg.

Who wants to do the next step?
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: 2216
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: walkable lava

Post by Celtic_Minstrel »

For the terrain.cfg file, you need to define two terrains.

One of the custom terrains follows the format of the "unwalkable" terrain in the mainline file, which has the terrain code Qt, but of course you fill in all the fields with different values because it's meant to represent lava instead of "unwalkable". At minimum you need a custom ID and terrain code (string). This terrain should have a terrain code that ends in a lowercase t and is referred to as the "archetype". Since you're making a lava terrain, it would be the "lava archetype".

The other custom terrain is literally an exact copy of the existing lava terrain, but change the "aliasof" key to refer to the custom terrain code of the lava archetype terrain (and of course give it a custom ID and terrain code of its own). The terrain code of this one could be the same as the archetype, but drop the final t.

For the terrain_graphics.cfg file, you can copy the lines in the mainline terrain_graphics that refer to lava, and just change the terrain code to your custom lava terrain code.

The last thing you need to add is in your units.cfg file, which is a [terrain_defaults] tag that assigns the cost of the lava archetype terrain (using its ID) to be the same as unwalkable. This means that any unit that specifies an unwalkable movement cost but does not specify a lava movement cost (in other words, a whole bunch of mainline units) will be able to cross lava as if it were unwalkable.

Don't forget that terrain.cfg and terrain_graphics.cfg also need to be included outside of the #ifdef EDITOR block, so they work when playing too.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
JetScootr
Posts: 11
Joined: December 5th, 2022, 11:11 pm

Re: walkable lava

Post by JetScootr »

I'm currently faking it. If you scatter Rubble (Map editor, "rough" category) onto lava it doesn't become walkable, BUT try this:
make a walkable path using "dry hills" (Same category in Map editor) through the lava field. Scatter rubble onto every hex of the path, and about the same number of lava-only hexes. Result: lava field has scattered rubble all over it, and *some* of the rubble is walkable, some isn't.
It's a kludge, but until I get deeper into the Wesnoth code, it's what I got.
Post Reply