Eagle WML Questions: how to filter disabled attacks? +more

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.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Eagle WML Questions: how to filter disabled attacks? +more

Post by Eagle_11 »

the error:
Spoiler:
Whenever an unit performs a strike with an attack that has this weapon-special, pictured lua error happens. This occurs in 1.13.x but not 1.12.x, if you have any idea what the error msg means please tell me.
the weapon-special:

Code: Select all

#define WEAPON_SPECIAL_EXI_ASSASSINATE
    [dummy]
        id=exi_assasinate
        name= _ "assasination"
        description= _ "This attack has a 3% chance per level difference to immediately kill a lower level enemy."
    [/dummy]
[/specials]
[/attack]
[event]
    name=attacker_hits
    first_time_only=no
    id=exi_assasinate1
    [filter_attack]
        special=exi_assasinate
    [/filter_attack]
    [if]
        [have_unit]
            x,y=$x2,$y2
            [not]
                side=side_number
            [/not]
        [/have_unit]
        [then]
            [if]
                [variable]
                    name=unit.level
                    greater_than=$second_unit.level
                [/variable]
                [then]
                    [set_variable]
                        name=leveldiff
                        value=$unit.level
                    [/set_variable]
                    [set_variable]
                        name=leveldiff
                        add=-$second_unit.level
                    [/set_variable]
                    [set_variable]
                        name=random
                        rand=1..100
                    [/set_variable]
                    [set_variable]
                        name=limit
                        value=3
                    [/set_variable]
                    [set_variable]
                        name=limit
                        multiply=$leveldiff
                    [/set_variable]
                    [if]
                        [variable]
                            name=random
                            less_than_equal_to=$limit
                        [/variable]
                        [then]
                            [set_variable]
                                name=exp
                                value=8
                            [/set_variable]
                            [set_variable]
                                name=exp
                                multiply=$second_unit.level
                            [/set_variable]
                            [set_variable]
                                name=exp
                                add=-$second_unit.level
                            [/set_variable]
                            [if]
                                [variable]
                                    name=exp
                                    numerical_equals=0
                                [/variable]
                                [then]
                                    [set_variable]
                                        name=exp
                                        value=4
                                    [/set_variable]
                                [/then]
                            [/if]
                            [unstore_unit]
                                variable=second_unit
                                red=255
                                text= _ "fatality!"
								{COLOR_HARM}
                                find_vacant=no
                            [/unstore_unit]
                            [kill]
                                x,y=$x2,$y2
                                animate=yes
                                fire_event=yes
                            [/kill]
                            [set_variable]
                                name=unit.experience
                                add=$exp
                            [/set_variable]
                            [unstore_unit]
                                variable=unit
                            [/unstore_unit]
                        [/then]
                    [/if]
                    [clear_variable]
                        name=random
                    [/clear_variable]
                    [clear_variable]
                        name=leveldiff
                    [/clear_variable]
                    [clear_variable]
                        name=exp
                    [/clear_variable]
                    [clear_variable]
                        name=limit
                    [/clear_variable]
                [/then]
            [/if]
        [/then]
    [/if]
[/event]
[event]
    name=defender_hits
    first_time_only=no
    id=exi_assasinate2
    [filter_second_attack]
        special=exi_assasinate
    [/filter_second_attack]
    [if]
        [have_unit]
            x,y=$x1,$y1
            [not]
                side=side_number
            [/not]
        [/have_unit]
        [then]
            [if]
                [variable]
                    name=second_unit.level
                    greater_than=$unit.level
                [/variable]
                [then]
                    [set_variable]
                        name=leveldiff
                        value=$second_unit.level
                    [/set_variable]
                    [set_variable]
                        name=leveldiff
                        add=-$unit.level
                    [/set_variable]
                    [set_variable]
                        name=random
                        rand=1..100
                    [/set_variable]
                    [set_variable]
                        name=limit
                        value=3
                    [/set_variable]
                    [set_variable]
                        name=limit
                        multiply=$leveldiff
                    [/set_variable]
                    [if]
                        [variable]
                            name=random
                            less_than_equal_to=$limit
                        [/variable]
                        [then]
                            [set_variable]
                                name=exp
                                value=8
                            [/set_variable]
                            [set_variable]
                                name=exp
                                multiply=$unit.level
                            [/set_variable]
                            [set_variable]
                                name=exp
                                add=-$unit.level
                            [/set_variable]
                            [if]
                                [variable]
                                    name=exp
                                    numerical_equals=0
                                [/variable]
                                [then]
                                    [set_variable]
                                        name=exp
                                        value=4
                                    [/set_variable]
                                [/then]
                            [/if]
                            [unstore_unit]
                                variable=unit
                                red=255
                                text= _ "fatality !"
								{COLOR_HARM}
                                find_vacant=no
                            [/unstore_unit]
                            [kill]
                                x,y=$x1,$y1
                                animate=yes
                                fire_event=yes
                            [/kill]
                            [set_variable]
                                name=second_unit.experience
                                add=$exp
                            [/set_variable]
                            [unstore_unit]
                                variable=second_unit
                            [/unstore_unit]
                        [/then]
                    [/if]
                    [clear_variable]
                        name=random
                    [/clear_variable]
                    [clear_variable]
                        name=leveldiff
                    [/clear_variable]
                    [clear_variable]
                        name=exp
                    [/clear_variable]
                    [clear_variable]
                        name=limit
                    [/clear_variable]
                [/then]
            [/if]
        [/then]
    [/if]
[/event]
[+attack]
[+specials]
#enddef
User avatar
Xara
Posts: 270
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: Help me to identify this error

Post by Xara »

How about moving the [event] tags away, to load them independently. I suspect the error is from the [+attack][+special], or because you loaded the events for multiple times.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

Did the seperation, has not brought anything.
User avatar
Xara
Posts: 270
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: Help me to identify this error

Post by Xara »

It says it's some eval error. So maybe change this:

Code: Select all

                    [set_variable]
                        name=leveldiff
                        add=-$unit.level
                    [/set_variable]
to

Code: Select all

                    [set_variable]
                        name=leveldiff
                        sub=$unit.level
                    [/set_variable]
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

That did not fix it either. Still getting the very same error.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Help me to identify this error

Post by zookeeper »

side=side_number
Missing the $.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

Ah, thank you man. That fixes it.
Well, if you happent to have any spare time, can you look into this .cfg ? its the ranged attacks component that i have used in my addon, functions correctly in 1.12 but always deals 1 damage in 1.13, whatever may be the cause for that.
Attachments
ranged-attacks.cfg
(24.04 KiB) Downloaded 254 times
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Help me to identify this error

Post by zookeeper »

That's almost 1000 lines of code, you really need to narrow it down a lot more.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

Deconstructing that may take a while, i have noticed resmult variable floating in the open via :inspect so im suspecting the issue is related resistance calculation.

Have gotten another one.
unknownfilter.png
The unit performs an attack using this weapon-special, at turn end when the damage gets applied to unit that got set on fire, the message pictured above comes up. I have noticed that the ability keeps functioning as intended despite the message.

Code: Select all

#define WEAPON_SPECIAL_EXI_IGNITES
    [dummy]
        id=exi_ignition
        name= _ "ignites"
        name_inactive= _ "ignites"
        description= _ "this attack ignites the opponent, setting it on fire. Burning units are dealt 9 fire damage every turn until they are cared for an healer or seek help in an village. The flames can kill a unit, the attacker that incinerated the unit gets the experience."
        description_inactive= _ "this attack ignites the opponent, setting it on fire. Burning units are dealt 9 fire damage every turn until they are cared for an healer or seek help in an village. The flames can kill a unit, the attacker that incinerated the unit gets the experience."
    [/dummy]
#enddef

#its handled via an event

#define EXI_IGNITE_EVENTS
	[event]
		id=ignite_appliance
        name=side turn
        first_time_only=no
	        [store_unit]
            [filter]
			    side=$side_number
                [filter_wml]
                    [status]
                        ignited=yes
                    [/status]
                [/filter_wml]
				[filter_location]
	    	        [not]
                        terrain=*^V*
				    [/not]
                [/filter_location]
                [filter_adjacent]
                    ability=exi_healing
				    is_enemy=no
					count=0
                [/filter_adjacent]
            [/filter]
            variable=ignite_dmg_store
        [/store_unit]

        {FOREACH ignite_dmg_store i}

		[if]
            [variable]
                name=$ignite_dmg_store.hitpoints
                less_than="$(9*$($ignite_dmg_store.resistance.fire)/100)"
            [/variable]
	        [then]
	            [harm_unit]
                    [filter]
                        id=$ignite_dmg_store[$i].id
                    [/filter]
                    amount=9
                    damage_type=fire
                    fire_event=yes
                    kill=yes
                    animate=yes
		            sound=flame-big.ogg
                [/harm_unit]
		    [/then]
		[/if]

        {NEXT i}

        {CLEAR_VARIABLE ignite_dmg_store}
	[/event]
    [event]
	    id=ignite_clearance
        name=side turn
        first_time_only=no
        [store_unit]
            [filter]
			    side=$side_number
                [filter_wml]
                    [status]
                        ignited=yes
                    [/status]
                [/filter_wml]
                [filter_adjacent]
                    ability=exi_healing
				    is_enemy=no
					count=1-6
                [/filter_adjacent]
                [or]
                    [filter_wml]
                        [status]
                            ignited=yes
                        [/status]
                    [/filter_wml]
                    side=$side_number
                    [filter_location]
                        terrain=*^V*
                    [/filter_location]
                [/or]
            [/filter]
            variable=ignite_store
        [/store_unit]

        {FOREACH ignite_store i}

            {CLEAR_VARIABLE ignite_store[$i].status.ignited}

            [unstore_unit]
                variable=ignite_store[$i]
            [/unstore_unit]

            [remove_unit_overlay]
                x,y=$ignite_store[$i].x,$ignite_store[$i].y
                image=misc/ignitev2.png
            [/remove_unit_overlay]

        {NEXT i}

        {CLEAR_VARIABLE ignite_store}
    [/event]
    [event]
	    id=ignite_apply_on_attack
        name=attacker hits
        first_time_only=no
        [filter_attack]
            special=exi_ignition
        [/filter_attack]
		[if]
            [filter]
		        x,y=$x2,$y2
                [not]
                    [filter_wml]
                        [status]
                            ignited="yes"
                        [/status]
                    [/filter_wml]
                [/not]
            [/filter]
		    [then]
                {VARIABLE second_unit.status.ignited "yes"}

                [unstore_unit]
                    variable=second_unit
                [/unstore_unit]

                [unit_overlay]
                    x,y=$second_unit.x,$second_unit.y
                    image=misc/ignitev2.png
                [/unit_overlay]
		    [/then]
		[/if]
    [/event]
    [event]
	    id=ignite_apply_on_defend
        name=defender hits
        first_time_only=no
        [filter_second_attack]
            special=exi_ignition
        [/filter_second_attack]
		[if]
            [filter]
		        x,y=$x1,$y1
                [not]
                    [filter_wml]
                        [status]
                            ignited="yes"
                        [/status]
                    [/filter_wml]
                [/not]
            [/filter]
		    [then]
                {VARIABLE unit.status.ignited "yes"}

                [unstore_unit]
                    variable=unit
                [/unstore_unit]

                [unit_overlay]
                    x,y=$unit.x,$unit.y
                    image=misc/ignitev2.png
                [/unit_overlay]
		    [/then]
		[/if]
    [/event]
#enddef
User avatar
Xara
Posts: 270
Joined: December 26th, 2014, 12:23 am
Location: Beijing

Re: Help me to identify this error

Post by Xara »

[filter] doesn't work in [if]. The tag is probably ignored.
It pronounces Sha'ha, not Zara.

Feedback Thread of my Add-ons
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

cleaveerr.png
Whenever an unit with this weapon-special makes an attack pictured comes up.

Code: Select all

#has an component
#define CLEAVE_DAMAGE_HEX NUMBER
    [store_unit]
        [filter]
            x=$loc_store[{NUMBER}].x
            y=$loc_store[{NUMBER}].y
        [/filter]
        kill=no
        variable=cleave_defender_store
    [/store_unit]
    [if]
        [variable]
            name=cleave_defender_store.status.petrified
            not_equals=yes
        [/variable]
        [then]
            [if]
                [have_unit]
                    find_in=cleave_defender_store
                    [filter_adjacent]
                        is_enemy=no
						[and]
							ability=exi_resurrects
							[or]
								ability=exi_resurrects_pirl
							[/or]
						[/and]
                    [/filter_adjacent]
                [/have_unit]
                [then]
                    [store_unit]
                        [filter]
                            x=$loc_store[{NUMBER}].x
                            y=$loc_store[{NUMBER}].y
                        [/filter]
                        kill=no
                        variable=awakememo2
                    [/store_unit]
                [/then]
                [else]
                    {CLEAR_VARIABLE awakememo2}
                [/else]
            [/if]
            [harm_unit]
                [filter]
                    x=$cleave_defender_store.x
                    y=$cleave_defender_store.y
			    [filter_side]
                    [enemy_of]
                        side=$unit.side
                    [/enemy_of]
                [/filter_side]
                [/filter]
                amount=$tmp_cleave_damage
                alignment=$unit_with_cleave.alignment
                damage_type=$tmp_cleave_attack_type
                kill=yes
                fire_event=yes
                animate=yes
            [/harm_unit]
            [if]
                [variable]
                    name=awakememo2.hitpoints
                    equals=1
                [/variable]
                [else]
                    [if]
                        [variable]
                            name=awakememo2.hitpoints
                            less_than_equal_to=0
                        [/variable]
                        [then]
                            {VARIABLE awakememo2.hitpoints 1}
                            [if]
                                [variable]
                                    name=awakememo2.gender
                                    equals=female
                                [/variable]
                                [then]
                                    [unstore_unit]
                                        variable=awakememo2
                                        find_vacant=no
                                        text= _ "resurrected"
                                        {COLOR_HEAL}
                                    [/unstore_unit]
                                [/then]
                                [else]
                                    [unstore_unit]
                                        variable=awakememo2
                                        find_vacant=no
                                        text= _ "resurrected"
                                        {COLOR_HEAL}
                                    [/unstore_unit]
                                [/else]
                            [/if]
                        [/then]
                    [/if]
                [/else]
            [/if]
            [if]
                [have_unit]
                    x=$cleave_defender_store.x
                    y=$cleave_defender_store.y
                [/have_unit]
                [else]
                    {VARIABLE gimmexp $cleave_defender_store[$i].level}
                    {VARIABLE_OP gimmexp multiply 8}
                    {VARIABLE_OP unit.experience add $gimmexp}
                    {CLEAR_VARIABLE gimmexp}
                    [unstore_unit]
                        variable=unit
                        find_vacant=no
                    [/unstore_unit]
                [/else]
            [/if]
        [/then]
    [/if]
    [clear_variable]
        name=cleave_defender_store
    [/clear_variable]
#enddef

#the special itself
#define WEAPON_SPECIAL_EXI_CLEAVE
    [dummy]
        id=exi_cleave
        name= _ "cleave"
		name_inactive= _ "cleave"
        description= _ "When this unit strikes during offense, units that are adjacent to both attacker and defender at the same time are hurt aswell for a 1/3 of the damage. If the attacker is slowed, units adjacent to both attacker and defender will get hurt for 1/4 of the damage instead."
    	active_on=offense
	[/dummy]
[/specials]
[/attack]
	[event]
		name=attacker_hits
		first_time_only=no
		id=exi_cleave_event
		[filter_attack]
			special=exi_cleave
		[/filter_attack]
		{INCORPORATE_EFFECTS}
		[store_unit]
			variable=loc_store
			[filter]
				[filter_adjacent]
					x,y=$x2,$y2
				[/filter_adjacent]
				[filter_adjacent]
					x,y=$x1,$y1
				[/filter_adjacent]
			[/filter]
		[/store_unit]
		[store_unit]
			variable=unit_with_cleave
			[filter]
				id=$unit.id
			[/filter]
		[/store_unit]
		# Grab the attack's raw power and attack type - changed to get it from automatically stored variables
		{VARIABLE tmp_cleave_damage $weapon.damage}
		{VARIABLE tmp_cleave_attack_type $weapon.type}
		# Divide by three; four if the user is slowed
		[if]
			[variable]
				name=unit_with_cleave.status.slowed
				not_equals=yes
			[/variable]
			[then]
				[set_variable]
					name=tmp_cleave_damage
					divide=3
				[/set_variable]
			[/then]
			[else]
				[set_variable]
					name=tmp_cleave_damage
					divide=4
				[/set_variable]
			[/else]
		[/if]
		# Round down
		[set_variable]
			name=tmp_cleave_damage
			round=floor
		[/set_variable]
		# Deal the damage
		[switch]
			variable=loc_store.length
			[case]
				value=1
				{CLEAVE_DAMAGE_HEX 0}
			[/case]
			[case]
				value=2
				{CLEAVE_DAMAGE_HEX 1}
				{CLEAVE_DAMAGE_HEX 0}
			[/case]
		[/switch]
		[clear_variable]
			name=loc_store,unit_with_cleave,tmp_cleave_damage,tmp_cleave_attack_type
		[/clear_variable]
	[/event]
	[event]
		name=defender_hits
		first_time_only=no
		id=exi_cleave_event
		[filter_second_attack]
			special=exi_cleave
		[/filter_second_attack]
		[store_unit]
			variable=loc_store
			[filter]
				[filter_adjacent]
					x,y=$x2,$y2
				[/filter_adjacent]
				[filter_adjacent]
					x,y=$x1,$y1
				[/filter_adjacent]
			[/filter]
		[/store_unit]
		[store_unit]
			variable=unit_with_cleave
			[filter]
				id=$second_unit.id
			[/filter]
		[/store_unit]
		# Grab the attack's raw power and attack type - same here
		{VARIABLE tmp_cleave_damage $second_weapon.damage}
		{VARIABLE tmp_cleave_attack_type $second_weapon.type}
		# Divide by three; four if the user is slowed
		[if]
			[variable]
				name=unit_with_cleave.status.slowed
				equals=yes
			[/variable]
			[then]
				[set_variable]
					name=tmp_cleave_damage
					divide=4
				[/set_variable]
			[/then]
			[else]
				[set_variable]
					name=tmp_cleave_damage
					divide=3
				[/set_variable]
			[/else]
		[/if]
		# Round down
		[set_variable]
			name=tmp_cleave_damage
			round=floor
		[/set_variable]
		# Deal the damage
		[switch]
			variable=loc_store.length
			[case]
				value=1
				{CLEAVE_DAMAGE_HEX 0}
			[/case]
			[case]
				value=2
				{CLEAVE_DAMAGE_HEX 1}
				{CLEAVE_DAMAGE_HEX 0}
			[/case]
		[/switch]
		[clear_variable]
			name=loc_store,unit_with_cleave,tmp_cleave_damage,tmp_cleave_attack_type_type
		[/clear_variable]
	[/event]
[+attack]
[+specials]
#enddef
getridofthis.png
getridofthis.png (33.57 KiB) Viewed 4747 times
Another issue. To get rid of that imagenotfound, how to configure and use an custom race icon to be displayed there ?

jynxabilerror.png
When the curse weapon-special is applied through an attack this error comes.The part where its supposed get cured by village does not happen. Also when :inspect have noticed variable is duplicating itself per turn per unit.

Code: Select all

#note its the same as ageless era curse

#define EXI_MACRO_MEMO_DEFENSE UNIT TERRAIN
    [store_unit]
        [filter]
            x=${UNIT}.x
            y=${UNIT}.y
        [/filter]
        variable=unit_memo_def
    [/store_unit]
    [set_variable]
        name=unit_memo_def.variables.memo_def.{TERRAIN}
        value=${UNIT}.defense.{TERRAIN}
    [/set_variable]
    [unstore_unit]
        variable=unit_memo_def
    [/unstore_unit]

    {CLEAR_VARIABLE unit_memo_def}
#enddef

#define EXI_MACRO_DECREASE_DEFENSE UNIT TERRAIN AMOUNT MAX_DEF

    {EXI_MACRO_MEMO_DEFENSE ({UNIT}) ({TERRAIN})}

    [store_unit]
        [filter]
            x,y=${UNIT}.x,${UNIT}.y
        [/filter]
        variable=cursed_unit
    [/store_unit]

    [set_variable]
        name=limit_for_addition
        value={MAX_DEF}
    [/set_variable]
    [set_variable]
        name=limit_for_addition
        add={AMOUNT}
    [/set_variable]
    [if]
        [variable]
            name=cursed_unit.defense.{TERRAIN}
            greater_than=$limit_for_addition
        [/variable]
        [or]
            [variable]
                name=cursed_unit.defense.{TERRAIN}
                equals=$empty
            [/variable]
        [/or]
        [then]
            [set_variable]
                name=cursed_unit.defense.{TERRAIN}
                value={MAX_DEF}
            [/set_variable]
        [/then]
        [else]
            [if]  #This is to handle negative defenses.
                [variable]
                    name=cursed_unit.defense.{TERRAIN}
                    greater_than=0
                [/variable]
                [then]
                    [set_variable]
                        name=cursed_unit.defense.{TERRAIN}
                        add={AMOUNT}
                    [/set_variable]
                [/then]
                [else]
                    [set_variable]
                        name=cursed_unit.defense.{TERRAIN}
                        add=-{AMOUNT}
                    [/set_variable]
                [/else]
            [/if]
        [/else]
    [/if]
    [unstore_unit]
        variable=cursed_unit
    [/unstore_unit]

    {CLEAR_VARIABLE limit_for_addition}
    {CLEAR_VARIABLE cursed_unit}
#enddef

#define EXI_MACRO_CURSE UNIT AMOUNT

    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) deep_water ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) shallow_water ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) reef ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) swamp_water ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) flat ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) sand ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) forest ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) hills ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) mountains ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) village ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) castle ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) cave ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) frozen ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) unwalkable ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) impassable ({AMOUNT}) 90}
    {EXI_MACRO_DECREASE_DEFENSE ({UNIT}) fungus ({AMOUNT}) 90}
#enddef

#define EXI_MACRO_UNCURSE UNIT

    [set_variable]
        name={UNIT}.defense.deep_water
        value=${UNIT}.variables.memo_def.deep_water
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.shallow_water
        value=${UNIT}.variables.memo_def.shallow_water
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.reef
        value=${UNIT}.variables.memo_def.reef
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.swamp_water
        value=${UNIT}.variables.memo_def.swamp_water
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.flat
        value=${UNIT}.variables.memo_def.flat
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.sand
        value=${UNIT}.variables.memo_def.sand
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.forest
        value=${UNIT}.variables.memo_def.forest
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.hills
        value=${UNIT}.variables.memo_def.hills
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.mountains
        value=${UNIT}.variables.memo_def.mountains
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.village
        value=${UNIT}.variables.memo_def.village
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.castle
        value=${UNIT}.variables.memo_def.castle
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.cave
        value=${UNIT}.variables.memo_def.cave
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.frozen
        value=${UNIT}.variables.memo_def.frozen
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.unwalkable
        value=${UNIT}.variables.memo_def.unwalkable
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.impassable
        value=${UNIT}.variables.memo_def.impassable
    [/set_variable]
    [set_variable]
        name={UNIT}.defense.fungus
        value=${UNIT}.variables.memo_def.fungus
    [/set_variable]

    [unstore_unit]
        variable={UNIT}
    [/unstore_unit]
#enddef

#define WEAPON_SPECIAL_EXI_HEXER
    [dummy]
        id=exi_hexer
        name= _ "hex"
        name_inactive= _ "hex"
        description= _ "Target unit gets a 15% defense penalty on every terrain until it is cured by a village.

Does not affect the undead or leaders, and the defense value can't sink lower than 10%."
        apply_to=opponent
    [/dummy]
    # wmlxgettext: [specials]
[/specials]
# wmlxgettext: [attack]
[/attack]

[event]
    name=turn refresh
    first_time_only=no
    id=exi_hex_turn_refresh
    [store_unit]
        [filter]
            [not]
                [filter_wml]
                    [variables]
                        cursed=yes
                    [/variables]
                [/filter_wml]
            [/not]
            [and]
                [not]
                    [filter_wml]
                        [variables]
                            cursed=no
                        [/variables]
                    [/filter_wml]
                [/not]
            [/and]
        [/filter]
        variable=add_cursed_stat
        mode=append
    [/store_unit]
    [while]
        [variable]
            name=j
            less_than=$add_cursed_stat.length
        [/variable]
        [do]
            [set_variable]
                name=add_cursed_stat[$j].variables.cursed
                value=no
            [/set_variable]
            [unstore_unit]
                variable=add_cursed_stat[$j]
            [/unstore_unit]
            [set_variable]
                name=j
                add=1
            [/set_variable]
        [/do]
    [/while]
    {CLEAR_VARIABLE j}
    {CLEAR_VARIABLE add_cursed_stat}
[/event]

[event]
    name=attack
    first_time_only=no
    id=exi_hex_attack1
    [filter_attack]
        special=exi_hexer
    [/filter_attack]
    [filter_second]
        canrecruit=no
    [/filter_second]
    [set_variable]
        name=def_cursed_status_before
        value=$second_unit.variables.cursed|
    [/set_variable]
[/event]
[event]
    name=attack
    first_time_only=no
    id=exi_hex_attack2
    [filter_second_attack]
        special=exi_hexer
    [/filter_second_attack]
    [filter]
        canrecruit=no
    [/filter]
    [set_variable]
        name=att_cursed_status_before
        value=$unit.variables.cursed|
    [/set_variable]
[/event]

[event]
    name=attacker hits
    first_time_only=no
    id=exi_hex_attacker_1
    [filter_attack]
        special=exi_hexer
    [/filter_attack]
    [filter_second]
        canrecruit=no
        [not]
            [filter_wml]
                [status]
                    not_living=yes
                [/status]
            [/filter_wml]
        [/not]
    [/filter_second]

    [set_variable]
        name=second_unit.variables.cursed
        value=yes
    [/set_variable]
    [unstore_unit]
        variable=second_unit
    [/unstore_unit]
[/event]

[event]
    name=defender hits
    first_time_only=no
    id=exi_hex_defender_1
    [filter_second_attack]
        special=exi_hexer
    [/filter_second_attack]
    [filter]
        canrecruit=no
        [not]
            [filter_wml]
                [status]
                    not_living=yes
                [/status]
            [/filter_wml]
        [/not]
    [/filter]

    [set_variable]
        name=unit.variables.cursed
        value=yes
    [/set_variable]
    [unstore_unit]
        variable=unit
    [/unstore_unit]
[/event]
# at the end of the fight, the defense is decreased
# if the unit got hit by the curse attack
[event]
    name=attack end
    first_time_only=no
    [filter_attack]
        special=exi_hexer
    [/filter_attack]
    [filter_second]
        canrecruit=no
    [/filter_second]
    id=exi_hex_attacker_2
    [if]
        [variable]
            name=second_unit.variables.cursed
            not_equals=$def_cursed_status_before
        [/variable]
        [and]
            [variable]
                name=def_cursed_status_before
                not_equals=yes
            [/variable]
        [/and]
        [then]
            {EXI_MACRO_CURSE second_unit 15}
            [unit_overlay]
                x,y=$second_unit.x,$second_unit.y
                image="misc/curse.png"
            [/unit_overlay]
            [set_variable]
                name=def_cursed_status_before
                value=yes
            [/set_variable]
        [/then]
    [/if]
[/event]
[event]
    name=attack end
    first_time_only=no
    id=exi_hex_defender_2
    [filter_second_attack]
        special=exi_hex
    [/filter_second_attack]
    [filter]
        canrecruit=no
    [/filter]
    [if]
        [variable]
            name=unit.variables.cursed
            not_equals=$att_cursed_status_before
        [/variable]
        [and]
            [variable]
                name=att_cursed_status_before
                not_equals=yes
            [/variable]
        [/and]
        [then]
            {EXI_MACRO_CURSE unit 15}
            [unit_overlay]
                x,y=$unit.x,$unit.y
                image="misc/curse.png"
            [/unit_overlay]
            [set_variable]
                name=att_cursed_status_before
                value=yes
            [/set_variable]
        [/then]
    [/if]
[/event]

[event]
    name=turn refresh
    first_time_only=no
    id=exi_hex_turn_refresh_heal
    [store_locations]
        [filter]
            side=$side_number
            [filter_wml]
                [variables]
                    cursed=yes
                [/variables]
            [/filter_wml]
        [/filter]
        variable=uncursed_by_village_on
        mode=append
    [/store_locations]

    [while]
        [variable]
            name=i
            less_than=$uncursed_by_village_on.length
        [/variable]
        [do]
            [if]
                [variable]
                    name=uncursed_by_village_on[$i].terrain
                    contains=V
                [/variable]
                [then]
                    [store_unit]
                        [filter]
                            x=$uncursed_by_village_on[$i].x
                            y=$uncursed_by_village_on[$i].y
                        [/filter]
                        variable=unit_to_uncurse_on_village
                        mode=append
                    [/store_unit]
                [/then]
            [/if]
            [set_variable]
                name=i
                add=1
            [/set_variable]
        [/do]
    [/while]
    {CLEAR_VARIABLE i}

    [while]
        [variable]
            name=j
            less_than=$unit_to_uncurse_on_village.length
        [/variable]
        [do]
            [set_variable]
                name=unit_to_uncurse_on_village[$j].variables.cursed
                value=no
            [/set_variable]
            [unstore_unit]
                variable=unit_to_uncurse_on_village[$j]
            [/unstore_unit]

            {EXI_MACRO_UNCURSE unit_to_uncurse_on_village[$j]}

            [remove_unit_overlay]
                x,y=$unit_to_uncurse_on_village[$j].x,$unit_to_uncurse_on_village[$j].y
                image="misc/curse.png"
            [/remove_unit_overlay]

            [set_variable]
                name=j
                add=1
            [/set_variable]
        [/do]
    [/while]
    {CLEAR_VARIABLE j}
    {CLEAR_VARIABLE unit_to_uncurse_on_village}
    {CLEAR_VARIABLE uncursed_by_village_on}
[/event]

[event]
    name=advance
    first_time_only=no
    id=exi_hex_advance
    [filter]
        [filter_wml]
            [variables]
                cursed=yes
            [/variables]
        [/filter_wml]
    [/filter]
    {EXI_MACRO_UNCURSE unit}
    {MODIFY_UNIT (x,y=$unit.x,$unit.y) variables.cursed no}
    [remove_unit_overlay]
        x,y=$unit.x,$unit.y
        image="misc/curse.png"
    [/remove_unit_overlay]
[/event]
[+attack]
[+specials]
#enddef
Whats an applicable way of creating such an ability. Seemingly doesnt work, or atleast not with local player.

Code: Select all

#define ABILITY_EXI_TRUESIGHT
    [dummy]
        id=exi_truesight
        name= _ "true sight"
	description= _ "this unit can detect invisible enemies within a radius of 3 hexes around itself."
    [/dummy]
    [/abilities]
    [event]
        name=moveto
        first_time_only=no
		[filter]
			ability=exi_truesight
        [/filter]
		[store_unit]
			[filter]
				[filter_side]
					[not]
						[allied_with]
							x,y=$x1,$y1
						[/allied_with]
					[/not]
				[/filter_side]
                [filter_location]
					x,y=$x1,$y1
                    radius=3
                [/filter_location]
			[/filter]
			variable=unitsstored
			kill=no
		[/store_unit]
		{VARIABLE unitsstored.status.hidden no}
        [unstore_unit]
            variable=unitsstored
            find_vacant=no
        [/unstore_unit]
    [/event]
    [+abilities]
#enddef
Tad_Carlucci
Inactive Developer
Posts: 503
Joined: April 24th, 2016, 4:18 pm

Re: Help me to identify this error

Post by Tad_Carlucci »

About your first issue where awakememo2 does not contain a stored unit

The if logic determining whether to store or clear awakememo2 does not guard the unstore. You need to re-think the section to use either one if to guard it all, or the same if at each location. I can't tell you which because I don't know your intentions.
I forked real life and now I'm getting merge conflicts.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

awakememo2 is used to preserve the affected unit(s) from being killed in the event, if an unit with resurrects ability is adjacent to the affected unit of same side. Without this, the affected unit will simply incorrectly die despite being adjacent to an unit that can otherwise resurrect him, or so the original text of this ability claimed.

mentorerror.png
mentorerror.png (125.32 KiB) Viewed 4687 times
got another one. pictured message comes at turn end whenever an friendly unit is adjacent to an unit with this ability. the ability otherwise keeps to function normally.

Code: Select all


#define ABILITY_EXI_MENTOR
    [dummy]
        id=exi_mentor
        name= _ "mentor"
        description= _ "this unit's ability to preserve and provide knowledge gives friendly adjacent units of lesser level free experience, at the begin of it's side turn.

Level 0 units gain 8xp, Level 1 units gain 6 xp, Level 2 units gain 4 xp and Level 3 units gain 2xp per turn."
    [/dummy]
#enddef
#define EXI_MENTOR_EVENT
[event]
	name=side turn end
	first_time_only=no
    id=exi_clearing_xp
	[store_unit]
		[filter]
			side=$side_number
			[filter_wml]
			    [variables]
				    teached_counter=1
				[/variables]
			[/filter_wml]
		[/filter]
		variable=to_be_teached_refresh
	[/store_unit]

	{FOREACH to_be_teached_refresh i}
		[if]
			[variable]
				name=$to_be_teached_refresh[$i].variables.teached_counter
				value=1
			[/variable]
			[then]
				{VARIABLE to_be_teached_refresh[$i].variables.teached_counter 0}
			[/then]
			[unstore_unit]
				variable=to_be_teached_refresh[$i]
			[/unstore_unit]
		[/if]
	{NEXT i}

	{CLEAR_VARIABLE to_be_teached_refresh}
[/event]
[event]
	name=side turn
	first_time_only=no
	id=exi_getting_xp
	[store_unit]
		[filter]
			side=$side_number
			[filter_adjacent]
			    ability=exi_mentor
				is_enemy=no
				count=1
			[/filter_adjacent]
		[/filter]
		variable=to_be_teached
	[/store_unit]

	{FOREACH to_be_teached j}

			[if]
			    [variable]
			     	name=to_be_teached[$j].experience
			        less_than_equal_to=$to_be_teached[$j].max_experience
                [/variable]
				[and]
		        [variable]
		        	name=to_be_teached[$j].level
	        		equals=0
	    	    [/variable]
				[/and]
				[and]
			    [variable]
			    	name=$to_be_teached[$j].variables.teached_counter
		     		value=0
		    	[/variable]
                [/and]
                [then]
                    {VARIABLE to_be_teached[$j].variables.teached_counter 1}
                    {VARIABLE_OP to_be_teached[$j].experience add 8}
					[unstore_unit]
						variable=to_be_teached[$j]
						text= _ "+8 exp"
						red,green,blue=0,200,255
					[/unstore_unit]						
                [/then]
			[/if]
			[if]
			    [variable]
			     	name=to_be_teached[$j].experience
			        less_than_equal_to=$to_be_teached[$j].max_experience
                [/variable]
                [and]
		        [variable]
		        	name=to_be_teached[$j].level
	        		equals=1
	    	    [/variable]
				[/and]
				[and]
			    [variable]
			    	name=$to_be_teached[$j].variables.teached_counter
		     		value=0
		    	[/variable]
                [/and]
                [then]
                    {VARIABLE to_be_teached[$j].variables.teached_counter 1}
                    {VARIABLE_OP to_be_teached[$j].experience add 6}
					[unstore_unit]
						variable=to_be_teached[$j]
						text= _ "+6 exp"
						red,green,blue=0,200,255
					[/unstore_unit]
                [/then]
			[/if]
			[if]
			    [variable]
			     	name=to_be_teached[$j].experience
			        less_than_equal_to=$to_be_teached[$j].max_experience
                [/variable]
				[and]
		        [variable]
		        	name=to_be_teached[$j].level
	        		equals=2
	    	    [/variable]
				[/and]
				[and]
			    [variable]
			    	name=$to_be_teached[$j].variables.teached_counter
		     		value=0
		    	[/variable]
                [/and]
                [then]
                    {VARIABLE to_be_teached[$j].variables.teached_counter 1}
                    {VARIABLE_OP to_be_teached[$j].experience add 4}
					[unstore_unit]
						variable=to_be_teached[$j]
						text= _ "+4 exp"
						red,green,blue=0,200,255
					[/unstore_unit]
                [/then]
			[/if]
			[if]
			    [variable]
			     	name=to_be_teached[$j].experience
			        less_than_equal_to=$to_be_teached[$j].max_experience
                [/variable]
				[and]
		        [variable]
		        	name=to_be_teached[$j].level
	        		equals=3
	    	    [/variable]
				[/and]
				[and]
			    [variable]
			    	name=$to_be_teached[$j].variables.teached_counter
		     		value=0
		    	[/variable]
                [/and]
                [then]
                    {VARIABLE to_be_teached[$j].variables.teached_counter 1}
                    {VARIABLE_OP to_be_teached[$j].experience add 2}
				    [unstore_unit]
						variable=to_be_teached[$j]
						text= _ "+2 exp"
						red,green,blue=0,200,255
					[/unstore_unit]
                [/then]
			[/if]
		{NEXT j}
        {CLEAR_VARIABLE to_be_teached}

	#{CLEAR_VARIABLE to_be_teached_refresh}
[/event]
#enddef
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: Help me to identify this error

Post by zookeeper »

That error exactly specifies what the problem is. You have an [unstore_unit] in an [if].
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Help me to identify this error

Post by Eagle_11 »

I have to filter out the vanilla firststrike special so it doesnt get overriden by this, why does that [and][not] work, how should it be like ?

Code: Select all

#define SPECIAL_NOTES_EXI_BANNERBEARER_ELF
_" 
This unit is wearing the proud banner of the elven host, and as such all allied units adjacent to this unit receive the ability to strike the first blow in melee, even when defending."#enddef
#define ABILITY_EXI_BANNERBEARER_ELF
    [dummy]
        id=exi_bannerbearer_elf
        name= _ "banner of initiative"
        description= _ "all adjacent friendly units will strike first in melee combat, even when defending."
    [/dummy]
[/abilities]
	[event]
		name=side turn
		first_time_only=no
		[store_unit]
			[filter]
				[filter_wml]
				    [variables]
						initiatived_counter=1
					[/variables]
				[/filter_wml]
			[/filter]
			variable=initiative_refresh
		[/store_unit]

		{FOREACH initiative_refresh i}
			{CLEAR_VARIABLE initiative_refresh[$i].attack.specials.firststrike }
			{VARIABLE initiative_refresh[$i].variables.initiatived_counter 0}
			[unstore_unit]
				variable=initiative_refresh[$i]
			[/unstore_unit]
		{NEXT i}

		[store_unit]
			[filter]
				side=$side_number
				[filter_adjacent]
				    ability=exi_bannerbearer_elf
					is_enemy=no
				[/filter_adjacent]
				[filter_wml]
					[attack]
						range=melee
						#why does this bug the whole...
						[and]
							[not]
								special=firststrike
							[/not]
						[/and]
					[/attack]
				[/filter_wml]
			[/filter]
			variable=initiatived
		[/store_unit]

		{FOREACH initiatived i}
			[if]
				[variable]
					name=initiatived[$i].attack.specials.firststrike.id
					not_equals="firststrike_init"
				[/variable]
				[then]
					{VARIABLE initiatived[$i].variables.initiatived_counter 1}
					{VARIABLE initiatived[$i].attack.specials.firststrike.id firststrike_init}
					{VARIABLE initiatived[$i].attack.specials.firststrike.name "first strike (initiative)"}
					{VARIABLE initiatived[$i].attack.specials.firststrike.description  "this unit has been affected by an banner of initiative, and will always strike first with this attack, even if they are defending.

This spec will get removed upon attack completion or at begin of next turn."}
					[unstore_unit]
						variable=initiatived[$i]
					[/unstore_unit]
				[/then]
			[/if]
		{NEXT i}
	[/event]
    [event]
        name=attack_end
        first_time_only=no
		[store_unit]
			[filter]
			    x,y=$x1,$y1
				[filter_wml]
				    [variables]
						initiatived_counter=1
					[/variables]
					[attack]
						range=melee
					[/attack]					
				[/filter_wml]
			[/filter]
			variable=initiative_offense
		[/store_unit]
        {FOREACH initiative_offense i}
			{CLEAR_VARIABLE initiative_offense[$i].attack.specials.firststrike}
			{VARIABLE initiative_offense[$i].variables.initiatived_counter 0}
			[unstore_unit]
				variable=initiative_offense[$i]
			[/unstore_unit]
		{NEXT i}
    [/event]
[+abilities]
#enddef
nevermind i just managed to, its supposed to be:

Code: Select all

				[filter_wml]
					[attack]
						range=melee
						#[and]
							[not]
								[specials]
									[firststrike]
										id=firststrike
									[/firststrike]
								[/specials]
							[/not]
						#[/and]
					[/attack]
				[/filter_wml]
Post Reply