enclave's WML Macros questions Thread

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
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Thank you so much beatlenaut! just what I needed.. !

Anyone knows what exactly in details

Code: Select all

 
[effect]
apply_to=image_mod
 replace="O(0)"
[/effect]
means?
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

Makes image completely see-through.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

so would something like 27(90) have some other effect or do nothing at all? (made up random numbers..)

ah first one not even a number.. so A(90)? :D
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

https://wiki.wesnoth.org/ImagePathFunct ... g_function

For O() just try, but you arent expected to use values not between 0 and 1.

You cannot use random number as function name though, no matter which arguments you put there.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Thank you Ravana! I'm so stupid.. didn't realize ~O was just a function like ~crop and such...Thank you!!!
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

so in replace= it should be used without "~"?
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

I wonder then.. if original image is made see through.. then any animation becomes also see through? :(
I wonder if I can find work around.. or was just not lucky and made some silly mistake somewhere?
Have you tried to add animations to see through units?

PS. i will try to add replace=o(100) to animations.. and see if it helps...
PPS. so its not "replace=~O(100)" but "replace=O(100)"?
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Hello..
A filter question..
I have a filter like this

Code: Select all

		[store_villages]
		[filter]
			[filter_side]
				[enemy_of]
					side=$side_number
				[/enemy_of]
			[/filter_side]
			[filter_location]
						[filter]
							ability=settlers_loot
						[/filter]
						radius=3
			[/filter_location]
		[/filter]	
		variable=looted_villages_r1
		[/store_villages]
what it does, it saves all "occupied" by enemy villages, which have friendly units with "settlers_loot" ability around them in 3 hex radius..

I could not find in help how to make it show all "unoccupied" enemy villages...
Could somebody please help... how to filter villages.. with ownership flag, but no unit on them..
Please if you don't know, answer to this post by saying "I don't know, sorry", it will indicate me if I should wait for answer or to find workaround as I would like it done today... kind of ASAP...
Thank you very much everyone!
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

Try [filter_owner] and [filter] that doesnt match anything.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Tried like this and it didnt give any changes..

Code: Select all

		[store_villages]
		[filter]
			[filter_side]
				[enemy_of]
					side=$side_number
				[/enemy_of]
			[/filter_side]

				[filter_owner]
							[not]
				side=$side_number
							[/not]
				[/filter_owner]

			[filter_location]
						[filter]
							ability=settlers_loot
						[/filter]
						radius=3
			[/filter_location]
		[/filter]	
		variable=looted_villages_r1
		[/store_villages]
and this made it not work at all:

Code: Select all

				[filter_owner]
							[not]
				side=$side_number
							[/not]
				[/filter_owner]
				[not]
                    [filter]
                    [/filter]
                [/not]
and the next one doesnt work either..

Code: Select all

	
		[store_villages]
		[filter]
			[filter_side]
				[enemy_of]
					side=$side_number
				[/enemy_of]
			[/filter_side]

			[not]
				[filter]
				owner_side=$side_number
				[/filter]
			[/not]

			[filter_location]
						[filter]
							ability=settlers_loot
						[/filter]
						radius=3
			[/filter_location]

		[/filter]	
		variable=looted_villages_r1
		[/store_villages]
but ill try to experiment more with filter_owner.... didnt see it existed before you told me..
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

This has worked:

Code: Select all

		[store_villages]
		[filter_owner]
				[enemy_of]
					side=$side_number
				[/enemy_of]
		[/filter_owner]
		[and]
				[filter]
					ability=settlers_loot
				[/filter]
				radius=3
		[/and]
		variable=looted_villages_r1
		[/store_villages]
Thanks again Ravana for hint with [filter_owner] .. took me some time to figure out how it works..
basically let me give somebody help on [store_villages] tag..
You do NOT need to specify [filter_location] in it, because it already has it somewhere deep inside.. lua coded or something..
so what you need to put inside the [store_villages] tag is only variable=name and whatever should go inside the standard location filter (https://wiki.wesnoth.org/StandardLocationFilter) but NOT including [filter_location] itself..
and if you need to mix filters.. use [and], without [and] it did NOT work for me..
also [filter_owner] tag is exactly same as standard side filter.. (https://wiki.wesnoth.org/StandardSideFilter) so do NOT include [filter_side] in it...
Hopefuly it helps to someone.. Thanks everyone for reading.
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

hi everyone!
How to remove sound from defense of a unit...?
for example from khalifate Falcon?

I wanted to replace fog clearers with some other unit, but it turns to be a bloody complicated task!
I came across following problems:
1) can not remove sounds so when my walls get hit they scream like birds..
2) my walls have trait of feral or something.. which doesn't bother me, but i cant remove it seems to be.
3) in statistics of killed units it will show pictures of falcon.. not bothering me either since it was showing fog clearers as well (just without picture).

I recently got another report that fog clearers just disappear after reload and I know it's true, it's a fact.. I don't know why but this is happening all the time. They disappear randomly, I have no idea of any logic behind it..

4) Maybe somebody knows what I need to do to
a) when somebody saves game, replace all fog clearers with whatever else units.. with same amounts of health.. what would be event name?
b) when somebody loads game, return all fog clearers instead of whatever units.. is event name on preload?

Seems like the option number 4 may be easier than option number 1,2,3....
I'm sad.
User avatar
Ravana
Forum Moderator
Posts: 3000
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: enclave's WML Macros questions Thread

Post by Ravana »

Since core does not use this unit for fog clearing anymore, it should behave exactly like any other unit. Therefore, if it reliably disappears on loading, then you should report it.
User avatar
beetlenaut
Developer
Posts: 2825
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: enclave's WML Macros questions Thread

Post by beetlenaut »

If you are using fog clearers just because they are the only units without an image, there is another option. You can create or copy any unit you want and make the image= line point to a transparent 72px square.

Replacing a unit one part at a time really is kind of difficult. It's much easier to store/kill the original unit and make a new unit that copies the necessary data from the original one. All the animations, images, and sounds will be taken care of automatically. You can do what you want with traits. (Maybe you want to set "mechanical" if your unit is a wall.) I used this code to turn a necromancer into a lich:

Code: Select all

[unit]
	side=1
	type=Lich
	x=$stored_necromancer.x
	y=$stored_necromancer.y
	name=$stored_necromancer.name
	hitpoints=$stored_necromancer.hitpoints
	experience=$stored_necromancer.experience
	
	# Copy the traits into the new unit:
	[modifications]
		[insert_tag]
			name=trait
			variable=stored_necromancer.modifications.trait[0]
		[/insert_tag]
		[insert_tag]
			name=trait
			variable=stored_necromancer.modifications.trait[1]
		[/insert_tag]
	[/modifications]
[/unit]
(It's also possible that none of this is useful because I'm not clear on what you are trying to do!)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
enclave
Posts: 936
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave »

Thanks beetlenaut for trying to help :)
my code is not much different from yours but I think we do it about the same way.
Spoiler:
Basically I found that not every variable of a unit can be changed in stored state.. when it is unstored, it just doesn't work...
and I have no idea how to remove defense animation with effect since it doesn't show me any id in original core unit code

Code: Select all

 {DEFENSE_ANIM "units/khalifate/falcon.png" "units/khalifate/falcon.png" {SOUND_LIST:GRYPHON_HIT} }

I don't know where to find macro code of {DEFENSE_ANIM..} unfortunately..
and just doing this:

Code: Select all

	[effect]
				apply_to="new_animation"
				[defense_anim]
				[/defense_anim]
				[/effect]
does nothing :)
If I knew something to be able to filter it.. maybe something like [defense_filter] would work.. no idea..
That's why I wrote a question here, because maybe somebody knew how to remove sounds from defense of a unit with some kind of [effect] or trait which is strangely coded in original core falcon unit cfg

Code: Select all

    {TRAIT_FERAL_MUSTHAVE}
or if somebody knows event that fires when player is saving game :D I don't see it..in list of events..
but I think I just figured out way to code it..

If I understood things right, then unfortunately, your way doesn't help me, beetlenaut ;( I think if you try to turn Falcon into Lich you would feel my pain :) but it probably works perfect for necro-lich conversion.. because they most probably making same sounds etc..
or maybe I am missing something?

Ravana how can I be 100% sure to report it? What if there is something in my era making a bug.. Idk..
maybe i will run some tests in default era then :) and if it happens report it..
(ah forgot that for some reason my wesnoth can not save anymore.. my saves all the tiem corrupted :) so well.. maybe when I update to 12.5 I will run tests with fog clearers to 100% tell they disappear, thx for idea)
Post Reply