Tunnel through two adjacent hexes

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
GForce0
Posts: 63
Joined: May 17th, 2020, 5:58 pm

Tunnel through two adjacent hexes

Post by GForce0 »

Is there a way to create a tunnel through two hexes that are adjacent?
If you do something like this, there will be no tunnel created

Code: Select all

[tunnel]
	[source]
		x=2
		y=6
	[/source]
	[target]
		x=2
		y=7
	[/target]
	[filter]
	[/filter]
	pass_allied_units=yes
	bidirectional = yes
	allow_vision = no
[/tunnel]
Pilauli
Posts: 115
Joined: August 18th, 2020, 12:56 pm

Re: Tunnel through two adjacent hexes

Post by Pilauli »

Why would you want to put a tunnel through two adjacent hexes? It sounds like the units could just walk normally.

(Understanding why you want to do it helps suggest alternate solutions.)
User avatar
GForce0
Posts: 63
Joined: May 17th, 2020, 5:58 pm

Re: Tunnel through two adjacent hexes

Post by GForce0 »

This is for my Counter Strike scenario, which I am making improvements on. (Picture below)
There are different levels connected by ladders. You are not supposed to see the upper and lower levels through the ladder when you are standing in front of or on the ladder.

First I made a tunnel between the two ends of the ladder. Once you step on the ladder, the other end becomes visible by manually removing shroud, without seeing the entire lower route. However, then you can just stand on one end and block the tunnel, and the opponent has no way to attack.

Then, I added an unwalkable overlay in between and made everyone use 5 MP to walk on it. Now if the opponent tries to block the ladder, you can still step on the hex in between and fight him off the ladder. Also, although the whole route is now connected, due to 5MP you still cannot see through the connection and see the lower level. That is good.
However, the strange situation now arises that when you step on the hex in between to attack the opponent who is blocking the ladder, the opponent has the possibility to use the tunnel between the two ends of the ladder and teleport above you and attack you with two units. Realistically speaking, this does not make sense.

Therefore, my plan was to make a tunnel between one end of the ladder and the middle, then a second tunnel from the middle to the other end of the ladder. This way, there is still no vision through the ladder. Secondly, if the ladder is entirely free, you can move through easily, 1MP per hex. Third, you can then only move up until the hex that is free when there is an opponent and not go over him. Finally, you can always attack the opponent when he is trying to block the ladder.

Only problem is that it doesn't work
ladder.png
User avatar
skeptical_troll
Posts: 500
Joined: August 31st, 2015, 11:06 pm

Re: Tunnel through two adjacent hexes

Post by skeptical_troll »

Tunnels connecting 1-hex apart are pointless, the engine will just ignore them (I guess) because units can just move between those hexes normally at the same cost. There's no reason to go through the tunnel and no ways to put barriers between adjacent hex to force the units through a tunnel, AFAIK.
If all you want is preventing vision while keep the possibility to attack, rather than fiddling with tunnels I'd try playing with the vision_cost of units. You can change it with an object (see here and here) and apply it to all units in the scenario, while using a special terrain of your choice for the tunnel ends.
User avatar
GForce0
Posts: 63
Joined: May 17th, 2020, 5:58 pm

Re: Tunnel through two adjacent hexes

Post by GForce0 »

Edit: Never mind

Although there is one thing I don't understand. I have the following now:

Code: Select all

[terrain_type]
    id=ladder
    name= _ "Ladder"
    editor_name= _ "Ladder"
    symbol_image="misc/rails-n-s.png"
    string=Xu^Br|
    aliasof=Qt
    editor_group=CS
[/terrain_type]

[terrain_type]
    id=ladder
    name= _ "Ladder"
    editor_name= _ "Ladder"
    symbol_image="misc/rails-n-s.png"
    string=Xuc^Br|
    aliasof=Qt
    editor_group=CS
[/terrain_type]

[terrain_type]
    id=ladder
    name= _ "Ladder"
    editor_name= _ "Ladder"
    symbol_image="misc/rails-n-s.png"
    string=Xue^Br|
    aliasof=Qt
    editor_group=CS
[/terrain_type]

[terrain_type]
    id=ladder
    name= _ "Ladder"
    editor_name= _ "Ladder"
    symbol_image="misc/rails-n-s.png"
    string=Qxu^Br|
    aliasof=Qt
    editor_group=CS
[/terrain_type]

[terrain_type]
    id=ladder
    name= _ "Ladder"
    editor_name= _ "Ladder"
    symbol_image="misc/rails-n-s.png"
    string=Qxe^Br|
    aliasof=Qt
    editor_group=CS
[/terrain_type]
All hexes with rails turn into "Ladder (Unwalkable)", except for the hexes that were Xu^Br|, those become "Ladder (Rails)"
Why is that?

Also, is it possible to make it "Ladder (Ladder)", and then change vision_cost for Ladder?
Post Reply