Unit Presence Check

Discussion of all aspects of multiplayer development: unit balancing, map development, server development, and so forth.

Moderator: Forum Moderators

Post Reply
Wevilspore
Posts: 21
Joined: November 20th, 2005, 4:14 am

Unit Presence Check

Post by Wevilspore »

Does anyone know what WML is needed to check to see if any unit is on a given hex? Also, does anyone know how to check the hex a unit is on for it's terrain type?

I need the first to check if a unit is sitting on a destination hex for an intended teleport. The second is so I can set up some units that have terrain specific regeneration: meaning that the unit regenerates but only if it is sitting on the specified terrain.
ott
Inactive Developer
Posts: 838
Joined: September 28th, 2004, 10:20 am

Re: Unit Presence Check

Post by ott »

Wevilspore wrote:Does anyone know what WML is needed to check to see if any unit is on a given hex?
See http://www.wesnoth.org/wiki/EventWML for the moveto event.
Also, does anyone know how to check the hex a unit is on for it's terrain type?
This is not implemented, it is the subject of feature request https://gna.org/bugs/?func=detailitem&item_id=3588 at the bug tracker.
I need the first to check if a unit is sitting on a destination hex for an intended teleport.
You should probably just use a [teleport] tag.
The second is so I can set up some units that have terrain specific regeneration: meaning that the unit regenerates but only if it is sitting on the specified terrain.
See the Oasis terrain in terrain.cfg: you need "heals=true" as an attribute of your terrain.
This quote is not attributable to Antoine de Saint-Exupéry.
Wevilspore
Posts: 21
Joined: November 20th, 2005, 4:14 am

Post by Wevilspore »

My Quote:
The second is so I can set up some units that have terrain specific regeneration: meaning that the unit regenerates but only if it is sitting on the specified terrain.

ott's Quote:
See the Oasis terrain in terrain.cfg: you need "heals=true" as an attribute of your terrain.
You misunderstand. I am trying to set up some units that regenerate only when they occupy a given terrain type, not a healing terrain.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

You could use [store_locations] to store the locations of units of type x that are standing on terrain y. Then you could iterate through the stored array of coordinates and use each coordinate as the unit filter and give them some hp that way. This would of course happen inside a side turn event, so the healing occurs at the beginning of the side's turn.
Wevilspore
Posts: 21
Joined: November 20th, 2005, 4:14 am

Post by Wevilspore »

Wouldn't it be easier to filter for the terrain type rather than the terrain's location?

What I was thinking was to set up, in either the unit or the movement-type, a way to check if the current location's terrain was a given terrain type and then allow the unit its regeneration. I just need to know how to access the unit's current location and use that to look at that location and return the terrain-type at that location.

Any thoughts would be appreciated.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Post by zookeeper »

Wevilspore wrote:Wouldn't it be easier to filter for the terrain type rather than the terrain's location?
Yes, it would. Unfortunately, you can't filter by terrain directly. This is one much-requested (AFAIK) feature that hasn't gotten implemented yet.
Wevilspore
Posts: 21
Joined: November 20th, 2005, 4:14 am

What about Ambush?

Post by Wevilspore »

Doesn't Ambush check for the terrain the current unit is on? What is the WML it uses to do this?
User avatar
Tomsik
Posts: 1401
Joined: February 7th, 2005, 7:04 am
Location: Poland

Re: What about Ambush?

Post by Tomsik »

Wevilspore wrote:Doesn't Ambush check for the terrain the current unit is on? What is the WML it uses to do this?
I think ambush is hardcoded, c++ code checks this, not WML.
Wevilspore
Posts: 21
Joined: November 20th, 2005, 4:14 am

:(

Post by Wevilspore »

Tomsik wrote:I think ambush is hardcoded, c++ code checks this, not WML.
Darn. And all I know is c#, otherwise I could fix this myself.
Post Reply