unit move on 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
Acho161293
Posts: 32
Joined: January 29th, 2020, 10:54 am
Location: indonesian
Contact:

unit move on lava

Post by Acho161293 »

How to make new unit with movement type can move to lava.. . help.
I want to create new type movement unit with animation , if my unit standby on lava. too.. :roll:
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: unit move on lava

Post by Pentarctagon »

Acho161293 wrote: February 7th, 2020, 11:47 am How to make new unit with movement type can move to lava.. . help.
I want to create new type movement unit with animation , if my unit standby on lava. too.. :roll:
Split from here. Please make your own thread instead of posting unrelated questions in other people's threads.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: unit move on lava

Post by Ravana »

Lava uses unwalkable type.
User avatar
MoonyDragon
Posts: 149
Joined: November 29th, 2017, 5:46 pm

Re: unit move on lava

Post by MoonyDragon »

To overwrite some aspects of unit movement, use the [movement_costs] and [defense] tags as described here.
Given that lava is a variation of / alias of unwalkable terrain, you will have to change movement on the unwalkable= key of the tags named above. To allow your unit to walk on lava, include the following code into your [unit] tag:

Code: Select all

[movement_costs]
    unwalkable=1
[/movement_costs]
[defense]
    unwalkable=60
[/defense]
Note that the defence tag defines the chance to get hit, not the chance to evade an attack. Thus, a value of 60 translates into a 40% defense on that terrain ingame.
Default L0 Era - Level 1 leaders with level 0 recruits!
User avatar
Acho161293
Posts: 32
Joined: January 29th, 2020, 10:54 am
Location: indonesian
Contact:

Re: unit move on lava

Post by Acho161293 »

Sure. ,But if my unit move to abyss or chasm . It will drift
User avatar
Acho161293
Posts: 32
Joined: January 29th, 2020, 10:54 am
Location: indonesian
Contact:

Re: unit move on lava

Post by Acho161293 »

how can I make my unit move in lava but cannot move to the abyss. because both have the same type of terrain that is ...unwalkable....
User avatar
Ravana
Forum Moderator
Posts: 3002
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: unit move on lava

Post by Ravana »

No simple way. Options are event to knock back units that move where they shouldnt, or creating new terrain type.
User avatar
Acho161293
Posts: 32
Joined: January 29th, 2020, 10:54 am
Location: indonesian
Contact:

Re: unit move on lava

Post by Acho161293 »

:hmm: can you help me.. how to make that option.. give me example ..
User avatar
Pentarctagon
Project Manager
Posts: 5564
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: unit move on lava

Post by Pentarctagon »

You could use an enter_hex [event], use a [filter] to check for the terrain type(s) that shouldn't be moved over, and then if they match move the unit back to the previous hex.
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
User avatar
octalot
General Code Maintainer
Posts: 786
Joined: July 17th, 2010, 7:40 pm
Location: Austria

Re: unit move on lava

Post by octalot »

There's an example in Under the Burning Sun's 06a_In_the_Tunnels_of_the_Trolls, using a ^Yl terrain overlay defined in data/campaigns/Under_the_Burning_Suns/utils/terrain.cfg.

Please ignore any comment about lava being an alias of snow, that's an ancient issue which was fixed in d4d5160543950a1cbeeff5553cc57144daa81428, before Wesnoth 1.3.1. The comment itself is still in 1.14, but will be removed from 1.15.3.
User avatar
Acho161293
Posts: 32
Joined: January 29th, 2020, 10:54 am
Location: indonesian
Contact:

Re: unit move on lava

Post by Acho161293 »

Pentarctagon wrote: February 8th, 2020, 3:48 pm You could use an enter_hex [event], use a [filter] to check for the terrain type(s) that shouldn't be moved over, and then if they match move the unit back to the previous hex.
Hmm. Ok . I will try it..
Shiki
Developer
Posts: 348
Joined: July 13th, 2015, 9:53 pm
Location: Germany

Re: unit move on lava

Post by Shiki »

Honestly, I wouldn't bother. You may achieve that the unit can't cross unwalkable terrain, but it will not be obvious.
For example, If the shortest place to the destination is over the unwalkable tile, the engine will chose this path when clicking onto the destination tile.

To spin this further, the player may have reached the destination also on a different route without passing over unwalkable terrain. The event about which we talk, would place the unit onto the tile adjacent to the unwalkable tile, the one from which the unwalkable one was entered. But this doesn't have to be the hex from which the move was started, just one which got passed. Depending on the map and unit, the player may now not anymore be able to reach the destination tile.

A completely different problem: You may want to give the unit back the movement points for walking onto the unwalkable tile. You can get this information from the units movement costs, that's easy so far. But if the unit is slowed, you'll have to take that into account too.

In short — using crazy events to overcome limitations usually causes more problems than it solves.

My advice would be to instead adjust the unit's theme to the gameplay: This is a lava unit, which can walk onto lava hexes, and which may also float over unwalkable terrain.
Try out the dark board theme.
User avatar
Celtic_Minstrel
Developer
Posts: 2207
Joined: August 3rd, 2012, 11:26 pm
Location: Canada
Contact:

Re: unit move on lava

Post by Celtic_Minstrel »

On the contrary, my advice would be to make a copy of the lava terrain that's not unwalkable and use that instead of the default lava anywhere. This is perhaps a little complex, as you'd also need to add a new terrain archetype, but it would certainly be the best way of getting the desired result.
Author of The Black Cross of Aleron campaign and Default++ era.
Former maintainer of Steelhive.
Post Reply