Creating unit on walkable hexes [Solved]

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
ChaosRider
Posts: 1361
Joined: April 15th, 2012, 1:15 pm

Creating unit on walkable hexes [Solved]

Post by ChaosRider »

As in title Im trying to write a code to spawn unit on walkable hex (as long as they are available on map without any other units on it) but it sometimes create it on the wall. I have written all impossible hexes in the list in the code yet it doesnt work as should.
Spoiler:
Do you see any wrong lines/bugs?

You could add to Wesnoth next version option to spawn units only on hexes where unit to spawn terrain defense is greater than 0%.
Last edited by ChaosRider on November 1st, 2025, 8:54 am, edited 1 time in total.
Creator of WOTG (+6000 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
User avatar
Ravana
Forum Moderator
Posts: 3372
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: Creating unit on walkable hexes

Post by Ravana »

It is some random mess of code. Just use passable=yes and dont give unit defense where they cant move.
User avatar
ChaosRider
Posts: 1361
Joined: April 15th, 2012, 1:15 pm

Re: Creating unit on walkable hexes

Post by ChaosRider »

Ravana wrote: October 31st, 2025, 10:53 pm It is some random mess of code. Just use passable=yes and dont give unit defense where they cant move.
One line was required to do what I wanted to. Thx.
Creator of WOTG (+6000 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.18 Wesnoth server.
Post Reply