enclave's WML Macros questions Thread

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

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
zookeeper
WML Wizard
Posts: 9714
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: enclave's WML Macros questions Thread

Post by zookeeper » August 12th, 2016, 9:23 am

Well if you want it to work exactly like backstab except with a different multiplier, then I'd think what you should do is to use the same code as backstab except with a different multiplier.

Changing it to give different multipliers based on how many backstabbers surround the enemy is trickier, but I think not impossible. You'd most likely need at least a separate [damage] block for each possible multiplier. It'll be complicated.

User avatar
Ravana
Moderator
Posts: 1784
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: enclave's WML Macros questions Thread

Post by Ravana » August 12th, 2016, 7:24 pm

For your first post: Not sure if you can do it directly, but would workaround be playing with resistances of flanked unit?

For your second post: https://github.com/ProditorMagnus/Oroci ... s.cfg#L372

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 12th, 2016, 10:00 pm

Thank you very much for trying to help me..

Backstab itself is not a problem.. but problem is to make it all work together.. with multiple backstabbers..
If i use the code as Ravana given then I can't use it for 4xbackstab or 6xbackstab.. I would still need to find different solution..
I will try to put my code into abilities today and see if it solves my problem..

It just says in help:
Common keys and tags for specials with a value
The [damage], [attacks].......
....
backstab: if set to 'yes', this special will only apply to the attacker, and only when there is an enemy on the target's opposite side (i.e. when the standard backstab special applies). {DevFeature1.13|2}} This is now deprecated. The same functionality can be achieved with a [filter_adjacent] in [filter_opponent]; see the implementation of the default backstab special for details.
But i dont have 1.13 to look at the code.. and even if i had, im not sure if i would know where to find it..

Ravana, not sure if I understood about resistances workaround.. maybe i get it.. but sounds complicated.. there must be a simple way.. if backstab works somehow.. then there should be easy way to make it work for 4xbackstabbers and 6x.. or maybe i can even put option for 3 backstabbers (different multiplier) from n,se,sw.. just need my code to work as regular backstab first..
so ill put it into ability instead of weapon special.. see if it helps.. but its quite important for it to work as weapon special :(
but maybe it just cant..


enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 13th, 2016, 4:03 pm

Thanks Ravana, you magic like always :D will try it :)
Any ideas what exactly the $other.unit thing means? is it something that works only when u select to attack a unit? or no clue?

PS. I just read in help it only works with 1.13.
but anyway, ill try filter opponent.. i think thats the key.

PPS. I tried the following:

Code: Select all

					[damage]
					id=flank
					name= _ "flank"
					description= _ "flank"
					multiply=1.5
					[filter_opponent]
					[filter_adjacent]
					adjacent=s,n
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/filter_opponent]
					[/damage]
It seem to work perfectly with one interesting bug..
1) flank special always active.. so my unit always has x1.5 damage.. (7-2)
2) When I actually start the attack on unit, it shows the real damage.. so (5-2) if i dont backstab and (7-2) vs backstabbed unit..
Now i wonder how to fix it..

PPPS. tried to add active_on=offense (doesnt help)
tried to change [filter_opponent] into [filter_defender] (doesnt help)
tried to move initial code with filter self and double filter adjacent into abilities (doesnt help)
copied 1.13 code into my 1.12 special (doesnt help)

in short, so far I can not achieve same effect as thief's backstab ability is, in 1.12
the best achieved result is that it displays double damage all the time, but works double only when u backstab..
ill try to add [and].. maybe i can soften the effect.. to make it look better.

PPPPS. I officially give up. I tried to use [and] and it didn't work so I tried without [and] and achieved the best possible result of ability similar to backstab (but still yet not perfectly matching backstab ability unfortunately)
The code:

Code: Select all

[unit]
...
	[modifications]
		[object]
	    	silent=yes
			[effect]
				apply_to=attack
				name=club
				[set_specials]
					[damage]
					id=flank
					name= _ "flank"
					description= _ "flank"
					multiply=2
					active_on=offense
					[filter_self]
					[filter_adjacent]
					[filter_adjacent]
					adjacent=s,n
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/filter_adjacent]
					[/filter_self]
					[filter_defender]
					[filter_adjacent]
					adjacent=s,n
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/filter_defender]
					[/damage]
				[/set_specials]
			[/effect]
		[/object]
	[/modifications]
This is the best imitation of backstab ability I could achieve..
It only shows double damage of my unit when there is some enemy adjacent that he can backstab. So when there are enemy units around my unit, and one of them can be backstabbed, the unit's damage is doubled, but it only works double for 1 unit, - the one that he can backstab.
Once I complete my flanking code with 3-4-6 sides I will post it here. However I gave up to try to improve my code further. The information I was given on forum and in help plus all my attempts and tyime spent made me believe that this is the only best possible solution. But if somebody come up with idea, I will gladly try it. So feel free to advice (for example lua coded version? backstab somehow is created ([damage] backstab=yes)... so its doable.. maybe not at c++ but lua level?)

PPPPPS. i just realized that it is not even imitation of backstab :) because all units around backstabbed unit get bonus damage (which is exactly what i need, but it is far from backstab ability)

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 13th, 2016, 8:06 pm

zookeeper wrote:Well if you want it to work exactly like backstab except with a different multiplier, then I'd think what you should do is to use the same code as backstab except with a different multiplier.

Changing it to give different multipliers based on how many backstabbers surround the enemy is trickier, but I think not impossible. You'd most likely need at least a separate [damage] block for each possible multiplier. It'll be complicated.
Is there a way to hide some of them ([damage] name showing near unit weapon)? except putting them blank name..
for example leadership ability of 1-5 level only shows once i think.. but it doesnt look like it works similar way for damage specials.. ? with same id..

PS. ah stupid me.. i can set name inactive to blank "".... so it will only show when active..
but I think it will show all 3 when there will be 6 backstabbers.. :(

User avatar
Ravana
Moderator
Posts: 1784
Joined: January 29th, 2012, 12:49 am
Location: Estonia

Re: enclave's WML Macros questions Thread

Post by Ravana » August 13th, 2016, 8:09 pm

1) flank special always active.. so my unit always has x1.5 damage.. (7-2)
1.12 introduced this, for first few weeks it was very annoying, after that I got used to it. Workaround should be another [damage] that negates this(try with conditions or without).

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 13th, 2016, 8:56 pm

Thanks very much Ravana, I will try (I noticed the changes on 1.12.. horseman charge is doubled on his turn.. etc.. but backstab is still backstab :D only doubles on attack.. )

(Couple hours later) I tried to add [damage] like this:

Code: Select all

					[damage]
					name= _ ""
					description= _ ""
					multiply=0.99
					active_on=offense
					cumulative=no
					[filter_self]
					[filter_adjacent]
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/filter_self]
					[/damage]
didn't solve the doubled damage. unfortunately.. still shows doubled. Tried different filters and values.. but not all possible combinations :D if you have a working code anywhere would be happy to see it. If not, dont worry, you helped a lot anyway;)

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 14th, 2016, 11:55 pm

I tried to set "name_inactive" to empty string or to any random name (ability [leadership]) but it didn't work.. always displays the "name". Any ideas?

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 15th, 2016, 9:27 pm

Wow.. thats interesting..
I had ability:

Code: Select all

				[effect]
					apply_to=new_ability
					[abilities]
						[leadership]
							id=cg_flanked
							name= _ "flanked"
							name_inactive="bla"
							description=  _ "This unit is flanked. Flanked units from 2 or 3 sides do 1.2 times less damage to any enemy while being surrounded."
							description_inactive="blabla"
							affect_self=yes
							value=-20
					[filter_self]
					[filter_adjacent]
					adjacent=s,n
					is_enemy=true
					count=2
					[/filter_adjacent]
					[or]					
					[filter_adjacent]
					adjacent=se,nw
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/or]
					[or]
					[filter_adjacent]
					adjacent=sw,ne
					is_enemy=true
					count=2
					[/filter_adjacent]
					[/or]
					[or]
					[filter_adjacent]
					adjacent=sw,se,n
					is_enemy=true
					count=3
					[/filter_adjacent]
					[/or]
					[or]
					[filter_adjacent]
					adjacent=ne,nw,s
					is_enemy=true
					count=3
					[/filter_adjacent]
					[/or]
					[/filter_self]
						[/leadership]	
					[/abilities]
				[/effect]		
And it was working perfectly fine, with one exception, it always showed name and never name_inactive
I changed [filter_self] into [filter] and it started to show name_inactive as well.. so works perfectly fine now..

How come? These filters so confusing.. I wonder what other difference makes [filter_self] from [filter]? and why filter_self was hiding name_inactive..

User avatar
zookeeper
WML Wizard
Posts: 9714
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: enclave's WML Macros questions Thread

Post by zookeeper » August 15th, 2016, 9:41 pm

As the wiki says, [filter] will allow you to determine when the ability is active. Without it, it will always be active and thus name_inactive will never be seen. What [filter_self] does is to not determine whether the ability is active, only whether the unit itself receives its effects.

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 15th, 2016, 9:44 pm

thats interesting.. thanks zookeeper!

I posted my best result to here: http://forums.wesnoth.org/viewtopic.php?f=21&t=44509

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 23rd, 2016, 2:22 am

Strange question maybe.. maybe not.. sorry if yes, i'm a bit too sleepy.

Why when I do the following (Please note, it happens not within [unit] tag, but just anywhere, for example in middle of message options):

Code: Select all

[object]
[filter]
x,y=$cg_temp_action_unit.x,$cg_temp_action_unit.y
[/filter]
[effect]
apply_to=image_mod
add="misc/blank-hex.png~BLIT(terrain\castle\encampment\tall-keep-convex-br.png~CROP(22,43,30,35)~SCALE(30,30),17,40)~BLIT(terrain/castle/encampment/tall-keep-concave-tr.png~CROP(52,54,58,63)~SCALE(39,39)~FL(horiz),21,30)"
[/effect]
[/object]
image overlay appears on my unit, until i click a mouse, then it disappears. There is also a image lag in middle of my screen before I click.

and if I add silent=yes then nothing happens at all.
I guess I'm doing something wrong but im not sure what.. Thanks!

PS. I'm not using [unit_overlay] because it places image static on one side of the unit. Does not turn the image if unit is facing other direction.

User avatar
zookeeper
WML Wizard
Posts: 9714
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: enclave's WML Macros questions Thread

Post by zookeeper » August 23rd, 2016, 2:27 pm

enclave wrote:image overlay appears on my unit, until i click a mouse, then it disappears. There is also a image lag in middle of my screen before I click.

and if I add silent=yes then nothing happens at all.
Not sure about the rest, but this probably happens because a dialog for the object message is displayed, except because you didn't specify the message the dialog is very small or non-existent but still requires a click to dismiss.

enclave
Posts: 794
Joined: December 15th, 2007, 8:52 am

Re: enclave's WML Macros questions Thread

Post by enclave » August 23rd, 2016, 10:33 pm

sounds very much like what it is.. thanks zookeeper :)

but then maybe you know how to put overlay onto unit that will last longer than dialog where it was selected? :D

Post Reply