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

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

Post by zookeeper »

It's an engine bug that's being looked into, although I don't really know the specifics myself.
User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

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

Post by Sapient »

Interesting. Is there a workaround? What is the issue ID number?
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
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

Fixed regression where unit filters in [disable] weapon specials would not match the attacking unit.
Thanks to this, its now disabling for adjacent hex attacks properly again. However spawned an new issue:
The ranged attacks component now fetches disabled ranged attack of unit.
The [not] special_active=disable there seems to have stopped taking effect.

I have also noticed another issue the [filter_vision] visible=yes not taking effect.

Code: Select all

#define RANGED_ATTACK_EVENTS
[event]
	name=start
	id=rangedattackgivingevent

	[set_menu_item]
	    id=ranged_attack
	    description= _ "Ranged Attack"
	    [show_if]
	        [have_unit]
	            x,y=$x1|,$y1|
				[filter_side]
				    [not]
						[allied_with]
							side=$side_number|
						[/allied_with]
					[/not]
				[/filter_side]
				[filter_vision]
					visible=yes
				[/filter_vision]
	        [/have_unit]
	    [/show_if]

	[command]
        [store_unit]
            [filter]
                x,y=$x1|,$y1|
            [/filter]
            variable=dudegettingattacked
        [/store_unit]
        [store_unit]
            [filter]
                side=$side_number
				[has_attack]
					range=ranged
					[not]
						special_active=disable
					[/not]
				[/has_attack]
            [/filter]
            variable=temp3
        [/store_unit]
	...
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

Re: Eagle WML Questions: Disable recruit on a castle hex

Post by Eagle_11 »

I would like to do an major tweak to my rush mod. When having recruited an unit on one castle hex, further recruiting on that hex will be disabled until next turn of that side who has recruited an unit there. That way im seeking to prevent the issue where you can recruit and send out all units on the hex furthest towards the inside of the map, for maps where castles have odd or large shapes.
Firstly i would like to ask if such a thing is technically possible at all, if its possible to do can you give me idea on how to accomplish this.

One method i can think about would involve defining an fake castle terrain, which looks and functions the same as regular castle except cannot be recruited on,
then detect whenever a unit gets recruited morph that tile into this fake castle(just so it cant get recruited on) and morph it back to regular castle tile at side turn end.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

I remember this being functioning, turns out it doesnt as of current, what has changed ?

Code: Select all

#ifdef MULTIPLAYER
[modification]
    id=EXI_Scout_for_Knalgan
    name=_"Recruit Scouts"
    description=_"If this mod is on, then Knalgan Alliance can recruit Scout unit in addition to their recruit list. Works only with default era.

version 1.0 by Eagle 11"
    require_modification=no
	[event]
		name=start
		first_time_only=yes
		{VARIABLE leaders_knalgans "Dwarvish Steelclad,Dwarvish Thunderguard,Dwarvish Stalwart,Rogue,Trapper"}
		[store_unit]
			[filter]
				side=$unit.side
				canrecruit=yes
			[/filter]
			variable=stored_leaders
		[/store_unit]
		{FOREACH stored_leaders i}
		[if]
			[variable]
				name=leaders_knalgans
				contains=$stored_leaders[$i].type
			[/variable]	
			[then]
				[allow_recruit]
					side=$stored_leaders[$i].side
					type=Dwarvish Scout
				[/allow_recruit]
			[/then]
		[/if]
		{NEXT i}
		{CLEAR_VARIABLE stored_leaders,leaders_knalgans}
	[/event]
[/modification]
#endif
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

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

Post by Ravana »

You havent stored anything into $unit variable.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

simply omitting side= was enough to fix it, thanks.
White Mage and Red Mage can be leader for both Loyalist and Rebels, this extra unit supposed to available only for Rebels. Give me a way to filter out Loyalist Mage leaders.

Code: Select all

	[modification]
		id=EXI_Hunter_for_Rebels
		name=_"Extra Recruit: Elvish Hunter"
		description=_"If this mod is on, then Rebels can recruit Elvish Hunter unit in addition to their recruit list. Works only with default era.

version 1.0 by Eagle 11"
		require_modification=no

		[event]
			name=start
			first_time_only=yes
			{VARIABLE leaders_rebels "Elvish Captain,Elvish Hero,Elvish Ranger,Elvish Marksman,Elvish Druid,Elvish Sorceress,White Mage,Red Mage,Elder Wose"}
			[store_unit]
				[filter]
					canrecruit=yes
				[/filter]
				variable=stored_leaders
			[/store_unit]
			{FOREACH stored_leaders i}
			[if]
				[variable]
					name=leaders_rebels
					contains=$stored_leaders[$i].type
				[/variable]		
				[then]	
					[allow_recruit]
						side=$stored_leaders[$i].side
						type=Elvish Hunter
					[/allow_recruit]
				[/then]
			[/if]
			{NEXT i}
			{CLEAR_VARIABLE stored_leaders,leaders_rebels}
		[/event]
	[/modification]
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

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

Post by Ravana »

Compare side.faction with faction id.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

Can i have an usage example of that ? should write it as varname.side.faction or just .faction ?
User avatar
Ravana
Forum Moderator
Posts: 2949
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

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

Post by Ravana »

It is 1.13.7/8+, so no idea if there are any examples yet. Store side, and then you should find it.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

Ive done it looking at hornshark island code instead.
New question: This code causes pictured error messages whenever an Spearman levels. What to do about it ?

Code: Select all

		[event]
			name=pre advance
			first_time_only=no
			id=spearcannotblade
			[filter]
				type=Spearman
				x,y=$x1,$y1
			[/filter]
			{VARIABLE unit_advance_spearman yes}
			[if]
				[variable]
					name=unit_advance_spearman
					equals=yes
				[/variable]
				[then]
					{ADVANCE_UNIT x,y=$x1,$y1 "Pikeman,Javelineer"}
					{CLEAR_VARIABLE unit_advance_spearman}
					{CLEAR_VARIABLE unit.underlying_id,unit.id} 
				[/then]
			[/if]
		[/event]
yetanother.png
gfgtdf
Developer
Posts: 1432
Joined: February 10th, 2013, 2:25 pm

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

Post by gfgtdf »

well you get an infinite recursion, your event invokes an advcenemnt which then agian fires your event which then again triggers the advancement, which then again fires our event...

Your code doesn't really make sense in the first place, you set unit_advance_spearman to yes and then filter on it immidiateley after which will always execute the code in [then]
Scenario with Robots SP scenario (1.11/1.12), allows you to build your units with components, PYR No preperation turn 1.12 mp-mod that allows you to select your units immideately after the game begins.
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

I was trying to access an unit's advances_to= on the fly to be manipulated.
Settled for the traditional method of defining unit and morphing recruited into that variant instead. Still would like to know how to change an unit's advances_to field, if there is an method.

edit: can be done easily

Code: Select all

		[event]
			name=recruit,recall
			id=magecannotheal
			[filter]
				type=Mage
				x,y=$x1,$y1
			[/filter]
			{MODIFY_UNIT x,y=$x1,$y1    advances_to (Red Mage,Grey Mage)}
		[/event]
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

This used to function, but no longer. What needs to be changed ? Nevermind, after taking a look into wml wiki got it.

Code: Select all

#define WEAPON_SPECIAL_EXI_RAIN_OF_ARROWS
    [attacks]
        id=exi_rainofarrows
        name=_"rain of arrows"
        name_inactive=_"rain of arrows"
        description=_"If enemy cant retaliate at range, number of shots fired increases by half the amount."
        description_inactive=_"If enemy cant retaliate at range, number of shots fired increases by half the amount."
	    multiply=1.5
	    active_on=offense
        apply_to=self
		cumulative=yes
        [filter_opponent]
			[not]
				[has_attack]
					range=ranged
				[/has_attack]
			[/not]
        [/filter_opponent]
    [/attacks]
#enddef
User avatar
Eagle_11
Posts: 759
Joined: November 20th, 2013, 12:20 pm

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

Post by Eagle_11 »

an random question: how exactly does faction_from_recruit function ? if given spearman, elf fighter and mage will it do an coinflip to decide rebel or loyalist since mage is available to both ? :p

edit: i need to understand why the filter_opponent here is not taking effect.

Code: Select all

    [damage]
        id=exi_charge
        name=_"charge (cautious)"
        description=_"When used offensively, this attack deals 50% more damage to the target. It also causes this unit to take 50% more damage from the target’s counterattack.

Opponents in Swamp, Deep Water, Mountains, Reefs, Chasm, Lava or Volcano tiles cannot be charged using this weapon-special."
        multiply=1.5
        apply_to=both
        active_on=offense
		[filter_self]
            [filter_adjacent]
                is_enemy=no
                ability=exi_seneschal
				count=0
            [/filter_adjacent]
        [/filter_self]
		[filter_opponent]
			[filter_location]
				[not]
					terrain=Wo*,Ss*,Sm,M*,F*,Q*
				[/not]
			[/filter_location]
		[/filter_opponent]
    [/damage]
inside Islanders faction have this special, which was incorrectly taking effect irrevelant if opponent is chaotic or not. In a attempt to rewrite it has turned into such, now it does take effect but only when an unit(any unit on the board) dies, despite using attacker/defender hits events. The purpose of rewrite was to make use of special_active= key to easily filter it out.

Code: Select all

#define WEAPON_SPECIAL_EXI_BLESSED
    [damage]
        id=exi_blessed
        name= _ "blessed"
        description= _ "When this attack is used against opponents of chaotical alignment, the target takes extra arcane damage equal to 1/3 the damage of this attack."
		multiply=1.0
		apply_to=self
		[filter_opponent]
			alignment=chaotic
		[/filter_opponent]
	[/damage]
#enddef
#define SPECIAL_NOTES_EXI_BLESSED
_" This unit has an attack that deals extra damage of type arcane, aslong the opponent is of chaotic alignment."#enddef

#define EXI_BLESSED_EVENT
    [event]
        name=attacker hits
        first_time_only=no
        [filter_attacker]
			[filter_weapon]
				special_active=exi_blessed
			[/filter_weapon]
        [/filter_attacker]
        [if]
            [variable]
                name=second_unit.hitpoints
                less_than="$(weapon.damage*$($second_unit.resistance.arcane)/100)"
            [/variable]
			[then]
				[harm_unit]
					[filter]
						x,y=$x2,$y2
					[/filter]
					[filter_second]
						x,y=$x1,$y1
					[/filter_second]
					amount="$($weapon.damage/3)"
					damage_type=arcane
					fire_event=yes
					experience=no
					kill=yes
					animate=yes
					sound={SOUND_LIST:HOLY}
				[/harm_unit]
				[fire_event]
					name=force respec
					[primary_unit]
						id=$unit.id
					[/primary_unit]
				[/fire_event]
			[/then]
			[else]
			[/else]
        [/if]
    [/event]
    [event]
        name=defender hits
        first_time_only=no
        [filter_defender]
			[filter_weapon]
				special_active=exi_blessed
			[/filter_weapon]
        [/filter_defender]
        [if]
            [variable]
                name=unit.hitpoints
                less_than="$(weapon.damage*$($unit.resistance.arcane)/100)"
            [/variable]
            [then]
                [harm_unit]
                    [filter]
                        x,y=$x1,$y1
                    [/filter]
                    [filter_second]
                        x,y=$x2,$y2
                    [/filter_second]
                    amount="$($weapon.damage/3)"
                    damage_type=arcane
                    fire_event=yes
                    experience=yes
                    kill=yes
                    animate=yes
					sound={SOUND_LIST:HOLY}
                [/harm_unit]
                [store_unit]
                    [filter]
                        id=$second_unit.id
                    [/filter]
                    variable=respecer
                [/store_unit]
                {VARIABLE respecer.variables.may_need_respec yes}
                [unstore_unit]
                    variable=respecer
                    find_vacant=no
                [/unstore_unit]
            [/then]
            [else]
            [/else]
        [/if]
    [/event]
#enddef
Post Reply