[remove_shroud] and [terrain] question

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
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Move unit fake image mods and movement costs

Post by Paulomat4 »

Well, I got around the problem, by using an old version of my add-on. I did all changes again, but this time it worked fine. So I haven't been able to detect the error. sorry to bother you all :oops:

next thing I'm working on, are themes. Is it possible to change a theme mid-scenario? I know that there is the theme tag in [scenario]. Is it possible to change this? perhaps using lua or so?
Id like to use this for cutscene parts of scenarios.

EDIT: No answer? well i guess I'll have to do without that then.

I've got another question though:
while trying to improve cutscenes in my campaign I want to create a dagger that get's thrown away onto a unit that is multiple hexes away. the path is straight, so I'd like to use this code:

Code: Select all

		
[move_unit_fake]
type=elvish fighter
x=16,16
y=25,22
image_mods=~O(0%)~BLIT(projectiles/dagger-n.png,0,0)
[/move_unit_fake]
This part of the code

Code: Select all

~O(0%)
should make the elvish fighter image transparent, while this part

Code: Select all

~BLIT(projectiles/dagger-n.png,0,0)
pastes the image of a dagger on top. I've tested the code with dugi's image loading tester and there it shows indeed a dagger. Using the above code shows nothing ingame though. You see the screen moving though, as if it's following a unit.
Have I found a bug? Does

Code: Select all

~O(0%)
reduce the entire image to being transparent? Or have I just done something wrong?

REEDIT:
Also, another question:
I'm trying to limit a units movement to a specific terrain. (namely rails) Is there a way to do it? [movement_costs] seems to do the trick, but it's limited to terrain groups like deep water or mountain. Is there a way to do this?
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
ChaosRider
Posts: 846
Joined: April 15th, 2012, 1:15 pm

Re: Move unit fake image mods

Post by ChaosRider »

I had quite similar question in past, it was about lava to make it heal drakes... for this what you want to do you have to create new terrain group and there add your terrain type. You have to set new terrain group as shallow water or other one but with your own name and select there terrains which you prefer.
I suggest you to look in to wesnoth core files.
Creator of WOTG (+2880 units), MWC (+615 units), SurvivorsArea, RandomColosseum, RC WOTG, RC MWC, ColosseumRandomClonesBattle, BetweenDarknessAndLight, StealingWeapons, MoreUnitsForms, MoreDamageTypes, CanBeOnlyOne, ColosseumOneWinner, BonusSpam, CriticalStrike - available at 1.12 Wesnoth server.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: Move unit fake image mods and movement costs

Post by Sapient »

Paulomat4 wrote: I did all Have I found a bug? Does

Code: Select all

~O(0%)
reduce the entire image to being transparent? Or have I just done something wrong?
I'm not sure if that's a bug or not. The documentation for ~O() on the wiki does say it applies at "render time". But the documentation at the bottom says it applies in left-to-right order. So there's a contradiction in the documentation there.

As a workaround, I would suggest trying ~MASK() with a blank transparent hex
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Multiple Condition tags, possible deprecated [or] syntax

Post by Paulomat4 »

Hey,
while updating an add-on I stumbled upon a problem.
I have:

Code: Select all

[if]
[have_unit]
x,y=$x1,$y1
side=$side_number
[/have_unit]
[and]	
[filter_wml]
[variable]
name=$unit.overlays
equals=""
[/variable]
[/filter_wml]
[or]
[filter_wml]
[variable]
name=$unit.overlays
contains="misc/hornicon.png"
[/variable]
[/filter_wml]
[/or]
[or]
[filter_wml]
[variable]
name=$unit.overlays
contains="misc/staricon.png"
[/variable]
[/filter_wml]
[/or]
[or]
[filter_wml]
[variable]
name=$unit.overlays
contains="misc/moonicon.png"
[/variable]
[/filter_wml]
[/or]
[or]
[filter_wml]
[variable]
name=$unit.overlays
contains="misc/hearticon.png"
[/variable]
[/filter_wml]
[/or]
[/and]
[then]
bla
[/then]
[/if]
while this works as it should I get the error "Invalid WML found: possible deprecated [or] syntax: now forcing re-interpretation" in the top left corner and the stderr.txt file.
The wiki documentation doesn't really say anything about this. Can someone tell me what I did wrong?
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Multiple Condition tags, possible deprecated [or] syntax

Post by zookeeper »

There's no way that works. You're trying to use [filter_wml] as a condition tag in your [if]/[and], and then you have a [variable] inside that, and neither of those things does anything.
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Multiple Condition tags, possible deprecated [or] syntax

Post by Paulomat4 »

Yes, the [filter_wml] were remnants of a different approach. It works now
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Alarantalara
Art Contributor
Posts: 786
Joined: April 23rd, 2010, 8:17 pm
Location: Canada

Re: Move unit fake image mods and movement costs

Post by Alarantalara »

Paulomat4 wrote: REEDIT:
Also, another question:
I'm trying to limit a units movement to a specific terrain. (namely rails) Is there a way to do it? [movement_costs] seems to do the trick, but it's limited to terrain groups like deep water or mountain. Is there a way to do this?
For this one, you're in luck. There is a special terrain type associated with rails for exactly that purpose. Just add a movement cost for Rt and you'll be all set. No core unit uses it (so treats it as flat instead) but it's there.
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: Multiple Condition tags, possible deprecated [or] syntax

Post by Paulomat4 »

For this one, you're in luck. There is a special terrain type associated with rails for exactly that purpose. Just add a movement cost for Rt and you'll be all set. No core unit uses it (so treats it as flat instead) but it's there.
ahhh, thank you. I had already given up on this. Thank you very much!
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

[store_location] ignore hexes with units on it

Post by Paulomat4 »

Hey guys,
it's been a long time, but i'm back on working on my campaign.
I have a scenario where someone "pushes" back all units that get near him. Those unit have a predefined location where they should go to. If there is already a unit on that location, The code is supposed to search in a radius of 1 around that hex for viable (that pass through the filter) hexes. If noone is found the radius is supposed to get bigger and then check again, and so on.
The first round works, the unit is pushed back to it's hex. The second round works as well, the unit goes to one of the three hexes that it can go to.
the next unit that is pushed back tries to go to the hex of unit number two though, and I don't know why. Normally the filter should not let hexes pass on that a unit is standing.

the code is implemented as following:

Code: Select all

	[event]
		name=moveto
		first_time_only=no
		[filter]
			[filter_location]
				[filter]
					id=Orc
				[/filter]
				radius=1
			[/filter_location]
			side=1,3
		[/filter]
		
		[set_variable]
			name=radiuslocationcheck
			value=0
		[/set_variable]
		
		#to be found in utils/pushevent.cfg
		{STEP 24 2 24 1}
		{STEP 25 3 26 2}
		{STEP 25 4 26 4}
		{STEP 24 4 24 5}
		{STEP 23 4 22 4}
		{STEP 23 3 22 2}
			
		[clear_variable]
			name=radiuslocationcheck
		[/clear_variable]
	[/event]
	
	{PUSHEVENT}
macros:

Code: Select all

#define STEP X Y GOTOX GOTOY
[if]
	[variable]
		name=unit.x
		equals={X}
	[/variable]
	[and]
		[variable]
			name=unit.y
			equals={Y}
		[/variable]
	[/and]
	[then]
		[set_variable]
			name=unit.hitpoints
			divide=3
		[/set_variable]
		
		[set_variable]
			name=somexvariable
			value={GOTOX}
		[/set_variable]
		[set_variable]
			name=someyvariable
			value={GOTOY}
		[/set_variable]
		

		
		[if]
			[have_location]
				[not]
					terrain=Ce
				[/not]
				[and]
					[not]
						[filter]
						#check that there is no unit
						[/filter]
					[/not]
				[/and]
				[and]
					x={GOTOX}
					y={GOTOY}
				[/and]
			[/have_location]
			[then]
			{DEBUG_MSG "without radius [then]"}
				[store_locations]
					variable=goto
					[not]
						terrain=Ce
					[/not]
					[and]
						[not]
							[filter]
							#check that there is no unit
							[/filter]
						[/not]
					[/and]
					[and]
						x={GOTOX}
						y={GOTOY}
					[/and]
				[/store_locations]
			[/then]
			[else]
			{DEBUG_MSG "without radius [else]"}
				{VARIABLE_OP radiuslocationcheck add 1}
				[fire_event]
					name=locationcheck
				[/fire_event]
			[/else]
		[/if]
		
		[floating_text]
			[filter]
				id=Orc
			[/filter]
			text= _ "PUSH"
		[/floating_text]
		
		[move_unit]
            id=$unit.id
			to_x=$goto[0].x
			to_y=$goto[0].y
        [/move_unit]
		[modify_unit]
			[filter]
				id=$unit.id
			[/filter]
			hitpoints=$unit.hitpoints
		[/modify_unit]
	[/then]
[/if]

#enddef

#define PUSHEVENT
[event]
	name=locationcheck
	{DEBUG_MSG "locationcheck fired"}

	[if]
		[have_location]
			[not]
				terrain=Ce
			[/not]
			[and]
				[not]
					[filter]
					#check that there is no unit
					[/filter]
				[/not]
			[/and]
			[and]
				x=$somexvariable
				y=$someyvariable
				radius=$radiuslocationcheck
			[/and]
		[/have_location]
		[then]
			{DEBUG_MSG "with radius [then]"}
			[store_locations]
				variable=goto
				[not]
					terrain=Ce
				[/not]
				[and]
					[not]
						[filter]
						#check that there is no unit
						[/filter]
					[/not]
				[/and]
				[and]
					x=$somexvariable
					y=$someyvariable
					radius=$radiuslocationcheck
				[/and]
			[/store_locations]
		[/then]
		[else]
			{DEBUG_MSG "with radius [else]"}
			{VARIABLE_OP radiuslocationcheck add 1}
			[fire_event]
				name=locationcheck
			[/fire_event]
		[/else]
	[/if]
	[clear_variable]
		name=radiuslocationcheck
	[/clear_variable]
[/event]
#enddef
If someone could look into it and tell me where the error might be, I would be very grateful :)
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: [store_location] ignore hexes with units on it

Post by zookeeper »

Well, at least the locationcheck event lacks first_time_only=yes.
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: [store_location] ignore hexes with units on it

Post by Paulomat4 »

Well, at least the locationcheck event lacks first_time_only=yes.
:x I really really hate myself. GODDAMMIT! It works now. I've been looking at these lines of code the whole evening yesterday and half of today.

thank you very much zookeeper. :)
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
tekelili
Posts: 1039
Joined: August 19th, 2009, 9:28 pm

Re: [store_location] ignore hexes with units on it

Post by tekelili »

@Paulomat4: I have been stucked several times in bugs like you had, they are "stupid" but hard to detect. I have developed an habit that maybe you also find usefull -> As much as possible, I never write new code, I always look for an existing code strucutre (mine most of times) similar to task desired and copy-paste it. Then, to modifify or add keys, I also look to copy-paste those keys from previous code working.

In resume: in my experience write new code from scratch in WML has a high risk to run into bugs "difficult to detect". A fanatical use of copy-paste have reduced a lot, times I run into those situations.
Be aware English is not my first language and I could have explained bad myself using wrong or just invented words.
World Conquest II
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Re: [store_location] ignore hexes with units on it

Post by Paulomat4 »

@Paulomat4: I have been stucked several times in bugs like you had, they are "stupid" but hard to detect. I have developed an habit that maybe you also find usefull -> As much as possible, I never write new code, I always look for an existing code strucutre (mine most of times) similar to task desired and copy-paste it. Then, to modifify or add keys, I also look to copy-paste those keys from previous code working.

In resume: in my experience write new code from scratch in WML has a high risk to run into bugs "difficult to detect". A fanatical use of copy-paste have reduced a lot, times I run into those situations.
Thx for the kind advice. I actually tried to do it that way, but the example I used the first time i wrote this code (a few month ago) turned out to be buggy. :lol:
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
Paulomat4
Moderator Emeritus
Posts: 730
Joined: October 16th, 2012, 3:32 pm
Location: Wesmere library, probably summoning Zhangor

Transfer selection from editor to wml

Post by Paulomat4 »

Hey guys,
remember me? I'm not dead yet :D Anyway I've got another question for you guys. Is there a simple way of transferring a selection in the map editor to a location filter in wml?
In this case I'd like to filter for any unit moving to one of the selected hexes.
Sans titre.JPG
I could of course copy every coordinate manually but that would be tedious. Atm I'm using a range of coordinates

Code: Select all

		[filter]
			side=1
			x=1-12
			y=1-20
		[/filter]
but that's too crude, there a hexes that are sticking out which are not included. Ideas?
Creator of Dawn of Thunder and Global Unitmarkers

"I thought Naga's used semi-automatic crossbows with incendiary thermite arrows . . . my beliefs that this race is awesome are now shattered." - Evil Earl
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: Transfer selection from editor to wml

Post by beetlenaut »

Paulomat4 wrote:Is there a simple way of transferring a selection in the map editor to a location filter in wml?
No, I don't think so. Probably the easiest thing to do is to break your area up into three or four ranges that cover everything with nothing extra. Then use [filter_location] with an [or] statement for each range.
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
Post Reply