[Condition Tag] question

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
ZeoN_PoweR
Posts: 11
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

[Condition Tag] question

Post by ZeoN_PoweR » December 18th, 2017, 5:29 pm

Hi all,

I'm trying to create some weapon special for my own use, something like"Black-iron hammer" which can put an resistance debuff on enemy for one turn(like slow) when attack hit. It has two level, lv1 is "resistance to blade & pierce & impact -15%" , while when in lv2, value is double up to 30%. I also try to use some filter to prevent this debuff cumulative, something like when enemy suffer lv1 debuff already, it won't suffer again unless it's another attack with lv2 hammer.

my ideal is:
1. enemy hit by lv1 / lv2 ---> -15% / -30% ; another hit by same level hammer ---> still same value
2. enemy hit by lv1 ---> -15% ; another hit by lv2 hammer ---> become -30% but not -45%
3. enemy hit by lv2 ---> -30% ; another hit by lv1 hammer ---> still -30% but not -45%

Ideal 1. is fine now, but 2. and 3. have problem. When enemy take this lv1 debuff and then take lv2 debuff at the same turn(or vise versa), the total value become -45%. I've study WML wiki but still don't understand the way that condition tag working.

Here is weapon special wml:

Level 1 Hammer

Code: Select all

#define EVENT_ABILITY_ARMOR_BROKEN_LV1
    [event] 
        name=attacker_hits #when use in offence
        first_time_only=no
        [filter_attack]
            special=brakearmor1
        [/filter_attack]
        [filter_second]
            [not]
            	status=broken1 #prevent from same level special
            [/not]
        [/filter_second]
        [filter_second]
            [not]
            	status=broken2 #prevent from higher level special
            [/not]
        [/filter_second]
        {VARIABLE second_unit.status.broken1 yes}

        [unstore_unit]              #when debuff active, it shows "Armor Broken" in floating text
            variable=second_unit
            find_vacant=no
            text= _ "Armor Broken"
            red,green,blue=196,196,128
        [/unstore_unit]
        [object]
            silent=yes
            duration=turn end
            [filter]
                x,y=$x2,$y2
            [/filter]
            [effect]
                apply_to=image_mod   # enemy with this debuff will change color
                replace="CS(50,50,0)"   
            [/effect]
            [effect]            
                apply_to=resistance
        	replace=no  # a temp debuff so not replace 
        	[resistance]
            	blade=15
            	impact=15
            	pierce=15
        	[/resistance]
            [/effect]
        [/object]
    [/event]

    [event]
        name=defender_hits   #when use in defence
        first_time_only=no
        [filter_second_attack]
            special=brakearmor1
        [/filter_second_attack]
        [filter]
            [not]
            	status=broken1   #prevent from same level special
            [/not]
        [/filter]
        [filter]
            [not]
            	status=broken2   #prevent from higher level special
            [/not]
        [/filter]
        {VARIABLE unit.status.broken1 yes}

        [unstore_unit]
            variable=unit
            find_vacant=no
            text= _ "Armor Broken"
            red,green,blue=196,196,128
        [/unstore_unit]

        [object]
            silent=yes
            duration=turn end
            [filter]
                x,y=$x1,$y1
            [/filter]

            [effect]
                apply_to=image_mod   # enemy with this debuff will change color
                replace="CS(50,50,0)"
            [/effect]
            [effect]
                apply_to=resistance
        		replace=no
        	[resistance]
            	blade=15
            	impact=15
            	pierce=15
        	[/resistance]
            [/effect]
        [/object]
    [/event]

    [event]  # Remove color change on unit 
        name=side turn end
        first_time_only=no
        [store_unit]
            [filter]
            	side=$side_number
                status=broken1
            [/filter]
            variable=repair1
        [/store_unit]

        [foreach]
            array=repair1
            [do]
                {CLEAR_VARIABLE this_item.status.broken1}
                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]

        {CLEAR_VARIABLE repair1}
    [/event]
#enddef
Level 2 Hammer

Code: Select all

#define EVENT_ABILITY_ARMOR_BROKEN_LV2
    [event]
        name=attacker_hits
        first_time_only=no
#if lv2 debuff already exist, then nothing happen
        [if]
        	[filter_attack]
            	special=brakearmor2
        	[/filter_attack]   	
       		[filter_second]
				status=broken2
        	[/filter_second]
				[then]
				[/then]
					[else]
					#if lv1 debuff already exist, then debuff add another -15% and become -30%
						[if]
        					[filter_second]
								status=broken1
        					[/filter_second]
        					[then]
        					{VARIABLE second_unit.status.broken3 yes}
	        				[unstore_unit]
	            				variable=second_unit
	            				find_vacant=no
	           					text= _ "Armor Broken"
	            				red,green,blue=196,196,128
	        				[/unstore_unit]
	        				[object]
	            				silent=yes
	            				duration=turn end
						        [filter]
						        	x,y=$x2,$y2
						        [/filter]
						        [effect]
							        apply_to=image_mod
							        replace="CS(50,50,0)"
							    [/effect]
							    [effect]
							        apply_to=resistance
							        replace=no
							    	[resistance]
							        	blade=15
							        	impact=15
							        	pierce=15
							    	[/resistance]
							    [/effect]
							[/object]
	        			[/then]
	        			# put -30% debuff on those enemy that don't have any debuff yet
						[else]
        				{VARIABLE unit.status.broken2 yes}
        					[unstore_unit]
					            variable=unit
					            find_vacant=no
					            text= _ "Armor Broken"
					            red,green,blue=196,196,128
					       	[/unstore_unit]
						    [object]
						        silent=yes
						        duration=turn end
						        [filter]
						            x,y=$x1,$y1
						        [/filter]
						        [effect]
						            apply_to=image_mod
						            replace="CS(50,50,0)"
						        [/effect]
						        [effect]
						            apply_to=resistance
						        	replace=no
						        	[resistance]
						            	blade=30
						            	impact=30
						            	pierce=30
						        	[/resistance]
						        [/effect]
						    [/object]
						[/else]
					[/if]
				[/else]
			[/if]       
    [/event]
# Remove color change on unit
    [event]
        name=side turn end
        first_time_only=no
        [store_unit]
            [filter]
            	side=$side_number
                status=broken2
            [/filter]
            variable=repair2
        [/store_unit]
        [foreach]
            array=repair2
            [do]
            {CLEAR_VARIABLE this_item.status.broken2}
                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE repair2}
    [/event]
#enddef
I know the problem might in filter condition, but I just can't figure out how do[if], [and], [or], [not] work. I also try to use [switch] but problem become worse so I quit. Am I completely using wrong wml? Could someone help me on this, thanks.

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

Re: [Condition Tag] question

Post by Ravana » December 18th, 2017, 5:37 pm

[if] accepts https://wiki.wesnoth.org/ConditionalAct ... ition_Tags, and [filter_attack] is not one of those. Those filters are used to decide, if event should be fired, while [if] is only considered after it is decided to fire that event.

ZeoN_PoweR
Posts: 11
Joined: February 29th, 2012, 2:04 pm
Location: Taiwan

Re: [Condition Tag] question

Post by ZeoN_PoweR » December 19th, 2017, 3:32 pm

Thanks!!!!! You solve my problem again!!! Now weapon_special works perfectly.

Here is revise version

Code: Select all

#define EVENT_ABILITY_BROKEN_LV2
    [event]
        name=attacker_hits
        first_time_only=no
#if lv2 debuff already exist, then nothing happen
        	[filter_attack]
            	special=brakearmor2
        	[/filter_attack]   	
       		[filter_second]
       			[not]
					status=broken2
				[/not]
        	[/filter_second]
#if lv1 debuff already exist, then debuff add another -15% and become -30%
			[if]
				[variable]
					name=second_unit.status.broken1
					equals=yes							
				[/variable]
				[then]
				{CLEAR_VARIABLE second_unit.status.broken1}
				{VARIABLE second_unit.status.broken2 yes}
				[unstore_unit]
    				variable=second_unit
    				find_vacant=no
   					text= _ "Armor Broken"
    				red,green,blue=196,196,128
				[/unstore_unit]
				[object]
    				silent=yes
    				duration=turn end
			        [filter]
			        	x,y=$x2,$y2
			        [/filter]
			        [effect]
				        apply_to=image_mod
				        replace="CS(50,50,0)"
				    [/effect]
				    [effect]
				        apply_to=resistance
				        replace=no
				    	[resistance]
				        	blade=20
				        	impact=20
				        	pierce=20
				    	[/resistance]
				    [/effect]
				[/object]
				[/then]
			# put -30% debuff on those enemy that don't have any debuff yet
				[else]
			{VARIABLE second_unit.status.broken2 yes}
				[unstore_unit]
		            variable=second_unit
		            find_vacant=no
		            text= _ "Armor Broken"
		            red,green,blue=196,196,128
		       	[/unstore_unit]
			    [object]
			        silent=yes
			        duration=turn end
			        [filter]
			            x,y=$x2,$y2
			        [/filter]
			        [effect]
			            apply_to=image_mod
			            replace="CS(50,50,0)"
			        [/effect]
			        [effect]
			            apply_to=resistance
			        	replace=no
			        	[resistance]
			            	blade=30
			            	impact=30
			            	pierce=30
			        	[/resistance]
			        [/effect]
			    [/object]
				[/else]
			[/if]     
   [/event]
   
   [event]
		name=defender_hits
        first_time_only=no
        [filter_second_attack]
            special=brakearmor2
        [/filter_second_attack]
        [filter]
        	[not]
            	status=broken2
            [/not]
        [/filter]
			[if]
				[variable]
					name=unit.status.broken1
					equals=yes							
				[/variable]
				[then]
				{CLEAR_VARIABLE unit.status.broken1}
        		{VARIABLE unit.status.broken2 yes}
		        [unstore_unit]
		            variable=unit
		            find_vacant=no
		            text= _ "Armor Broken"
		            red,green,blue=196,196,128
		        [/unstore_unit]
		        [object]
		            silent=yes
		            duration=turn end
		            [filter]
		                x,y=$x1,$y1
		            [/filter]
		
		            [effect]
		                apply_to=image_mod
		                replace="CS(50,50,0)"
		            [/effect]
		            [effect]
		                apply_to=resistance
		        		replace=no
		        	[resistance]
		            	blade=20
		            	impact=20
		            	pierce=20
		        	[/resistance]
		            [/effect]
		        [/object]
		        [/then]
        		[else]
        		{VARIABLE unit.status.broken2 yes}
		        [unstore_unit]
		            variable=unit
		            find_vacant=no
		            text= _ "Armor Broken"
		            red,green,blue=196,196,128
		        [/unstore_unit]
		
		        [object]
		            silent=yes
		            duration=turn end
		            [filter]
		                x,y=$x1,$y1
		            [/filter]
		            [effect]
		                apply_to=image_mod
		                replace="CS(50,50,0)"
		            [/effect]
		            [effect]
		                apply_to=resistance
		        		replace=no
			        	[resistance]
			            	blade=30
			            	impact=30
			            	pierce=30
			        	[/resistance]
		            [/effect]
		        [/object]
        		[/else]
        	[/if]
    [/event]
   
# Remove color change on unit
    [event]
        name=side turn end
        first_time_only=no
        [store_unit]
            [filter]
            	side=$side_number
                status=broken2
            [/filter]
            variable=repair2
        [/store_unit]
        [foreach]
            array=repair2
            [do]
            {CLEAR_VARIABLE this_item.status.broken2}
                [unstore_unit]
                    variable=this_item
                [/unstore_unit]
            [/do]
        [/foreach]
        {CLEAR_VARIABLE repair2}
    [/event]
#enddef


Post Reply