Any easier way to do shop locations?

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
Relic
Posts: 10
Joined: November 6th, 2007, 1:39 am

Any easier way to do shop locations?

Post by Relic »

Currently most shop code I see needs the 6 hexes surrounding the shop unit listed.

I tried something else...

[show_if]
[have_unit]
[filter_adjacent]
x=20
y=20
is_enemy=no
[/filter_adjacent]
side=$side_number
[/have_unit]
[/show_if]

This does actually detect and call up the shop if you are next to it, unfortunately, it can be accessed by any unit on the same side.

I am wondering if there is another way to filter it so that it would only detect the unit next to the shop unit.

To keep the code smaller, I made all healers one shop since they serve the same purpose, where ever they are. And the code above does detect if a unit is at the xy so dead shop keepers (if the players get sloppy) won't allow shopping.

Any ideas?
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Any easier way to do shop locations?

Post by Sapient »

[have_unit] asks a question about does any unit exist matching this?

maybe you intended to ask a question about the unit at $x1,$y1 instead.

try this:

Code: Select all

[show_if]
	[have_unit]
               x,y=$x1,$y1
		[filter_adjacent]
			x=20
			y=20
			is_enemy=no
		[/filter_adjacent]
		side=$side_number
	[/have_unit]
[/show_if]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
Relic
Posts: 10
Joined: November 6th, 2007, 1:39 am

Post by Relic »

Must have had the xy in wrong place when I tried that before.

Thanks!

That saves a ton of space instead of having to use all the locations.
Post Reply