#textdomain wesnoth-Genesis

#define SLIGHTLY_DARK_INDOORS
    [time]
        id=slightly_dark_indoors
        name= _ "Indoors"
        image=misc/time-schedules/schedule-indoors.png
        lawful_bonus=0
        red=-15
        green=-10
        blue=0
    [/time]
#enddef

#define LESS_DARK_INDOORS
    [time]
        id=slightly_dark_indoors
        name= _ "Indoors"
        image=misc/time-schedules/schedule-indoors.png
        lawful_bonus=0
        red=-25
        green=-20
        blue=-10
    [/time]
#enddef

#define DARK_INDOORS
    [time]
        id=dark_indoors
        name= _ "Indoors"
        image=misc/time-schedules/schedule-indoors.png
        lawful_bonus=-25
        red=-50
        green=-40
        blue=-25
    [/time]
#enddef

#define DAWN_NO_SOUND
    [time]
        id=dawn
        name= _ "Dawn"
        image=misc/time-schedules/default/schedule-dawn.png
        red=-20
        green=-20
    [/time]
#enddef

#define DUSK_NO_SOUND
    [time]
        id=dusk
        name= _ "Dusk"
        image=misc/time-schedules/default/schedule-dusk.png
        green=-20
        blue=-20
    [/time]
#enddef

#define LIMBO
    [time]
        id=limbo
        name= _ "Limbo"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=0
        red=0
        green=0
        blue=0
    [/time]
#enddef

#define ETERNALDARKSWAMP
    [time]
        id=eternaldark1
        name= _ "Eternal Darkness"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=-25
        red=-50
        green=-30
        blue=-40
    [/time]
#enddef

#define ETERNALDARKDREAM
    [time]
        id=eternaldark2
        name= _ "Eternal Darkness"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=-25
        red=-100
        green=-80
        blue=-50
    [/time]
#enddef

#define ETERNALDARK
    [time]
        id=eternaldark
        name= _ "Eternal Darkness"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=-30
        red=-45
        green=-45
        blue=-15
    [/time]
#enddef

#define BLOODMOON
    [time]
        id=eternaldark
        name= _ "Blood Moon"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=-30
        red=-40
        green=-65
        blue=-35
    [/time]
#enddef

#define ETERNALDARK2
    [time]
        id=eternaldark2
        name= _ "Eternal Darkness"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=-40
        red=-60
        green=-60
        blue=-15
    [/time]
#enddef

#define ETERNALDARK3
    [time]
        id=eternaldark3
        name= _ "Eternal Darkness"
        image=misc/time-schedules/after-the-fall/6shortdark.png
        lawful_bonus=-50
        red=-70
        green=-70
        blue=-25
    [/time]
#enddef

#define VOID
    [time]
        id=void
        name= _ "Void"
        image=misc/schedule-underground.png
        lawful_bonus=-100
        red=-110
        green=-110
        blue=-60
    [/time]
#enddef

#define EXTENDED_TIME2
    {DAWN}
    {DAWN_NO_SOUND}
    {MORNING}
    {MORNING}
    {MIDDAY}
    {MIDDAY}
    {AFTERNOON}
    {AFTERNOON}
    {DUSK}
    {DUSK_NO_SOUND}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {MIDNIGHT}
    {MIDNIGHT}
    {SECOND_WATCH}
    {SECOND_WATCH}
#enddef

#define EXTENDED_TIME3
    {DAWN}
    {DAWN_NO_SOUND}
    {DAWN_NO_SOUND}
    {MORNING}
    {MORNING}
    {MORNING}
    {MIDDAY}
    {MIDDAY}
    {MIDDAY}
    {AFTERNOON}
    {AFTERNOON}
    {AFTERNOON}
    {DUSK}
    {DUSK_NO_SOUND}
    {DUSK_NO_SOUND}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
#enddef

#define EXTENDED_TIME3_AFTERNOON
    {EXTENDED_TIME3}
    current_time=9
#enddef

#define EXTENDED_TIME3_DUSK
    {EXTENDED_TIME3}
    current_time=12
#enddef

#define EXTENDED_TIME3_MORNING
    {EXTENDED_TIME3}
    current_time=3
#enddef

#define EXTENDED_TIME5
    {DAWN}
    {DAWN_NO_SOUND}
    {DAWN_NO_SOUND}
    {MORNING}
    {MORNING}
    {MORNING}
    {MORNING}
    {MORNING}
    {MIDDAY}
    {MIDDAY}
    {MIDDAY}
    {AFTERNOON}
    {AFTERNOON}
    {AFTERNOON}
    {AFTERNOON}
    {AFTERNOON}
    {DUSK}
    {DUSK_NO_SOUND}
    {DUSK_NO_SOUND}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {FIRST_WATCH}
    {MIDNIGHT}
    {MIDNIGHT}
    {MIDNIGHT}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
    {SECOND_WATCH}
#enddef


#textdomain wesnoth-Genesis

#define DELAY TIME
    [delay]
		time={TIME}
	[/delay]
#enddef

#define FLOAT_TEXT UNIT_ID COLOR TEXT
	[store_unit]
		[filter]
			id={UNIT_ID}
		[/filter]
		variable=temp_unit
	[/store_unit]
	[floating_text]
		x,y=$temp_unit.x,$temp_unit.y
		text="" + _ {TEXT} + ""
	[/floating_text]
	{CLEAR_VARIABLE temp_unit}
#enddef

#define FLOAT_TEXT_LOC X Y COLOR TEXT
	[floating_text]
		x,y={X},{Y}
		text="" + _ {TEXT} + ""
	[/floating_text]
#enddef

#define FLASH_RED_EXTREME ACTION_WML
    # Flash the screen momentarily red.
    {COLOR_ADJUST 67 0 0}
    {COLOR_ADJUST 100 0 0}
	{COLOR_ADJUST 133 0 0}
	{COLOR_ADJUST 167 0 0}
	{COLOR_ADJUST 200 0 0}
    {ACTION_WML}
	{COLOR_ADJUST 167 0 0}
	{COLOR_ADJUST 100 0 0}
    {COLOR_ADJUST 33 0 0}
    {COLOR_ADJUST 0 0 0}
#enddef

#define FLASH_DARK ACTION_WML
# turns the screen black and also hides all units (momentarily)
    {COLOR_ADJUST -67 -67 -67}
	{DELAY 100}
    {COLOR_ADJUST -100 -100 -100}
	{DELAY 100}
	{COLOR_ADJUST -133 -133 -133}
	{DELAY 100}
	{COLOR_ADJUST -167 -167 -167}
	{DELAY 100}
	{COLOR_ADJUST -200 -200 -200}
	[hide_unit]
		[filter]
		[/filter]
	[/hide_unit]
    {ACTION_WML}
	{COLOR_ADJUST -167 -167 -167}
	{DELAY 100}
	{COLOR_ADJUST -100 -100 -100}
    {DELAY 100}
	{COLOR_ADJUST -33 -33 -33}
    {DELAY 100}
	{COLOR_ADJUST 0 0 0}
	[unhide_unit]
		[filter]
		[/filter]
	[/unhide_unit]
#enddef

#define FADE_SCREEN
# turns the screen black and also hides all units
    {COLOR_ADJUST -33 -33 -33}
    {DELAY 100}
	{COLOR_ADJUST -67 -67 -67}
	{DELAY 100}
	{COLOR_ADJUST -100 -100 -100}
	{DELAY 100}
	{COLOR_ADJUST -133 -133 -133}
	{DELAY 100}
	[hide_unit]
		[filter]
		[/filter]
	[/hide_unit]
	{COLOR_ADJUST -167 -167 -167}
	{DELAY 100}
	{COLOR_ADJUST -200 -200 -200}
	{DELAY 100}
	{COLOR_ADJUST -233 -233 -233}
	{DELAY 100}
	{COLOR_ADJUST -255 -255 -255}
#enddef
#define UNFADE_SCREEN
# turns the screen back to normal
	{COLOR_ADJUST -233 -233 -233}
    {DELAY 100}
	{COLOR_ADJUST -200 -200 -200}
	{DELAY 100}
	{COLOR_ADJUST -167 -167 -167}
	{DELAY 100}
	{COLOR_ADJUST -133 -133 -133}
	{DELAY 100}
	[unhide_unit]
		[filter]
		[/filter]
	[/unhide_unit]
	{COLOR_ADJUST -100 -100 -100}
	{DELAY 100}
	{COLOR_ADJUST -67 -67 -67}
	{DELAY 100}
	{COLOR_ADJUST -33 -33 -33}
	{DELAY 100}
	{COLOR_ADJUST 0 0 0}
#enddef

#define WHITE_SCREEN
# turns the screen bright
    {COLOR_ADJUST 33 33 33}
    {DELAY 100}
	{COLOR_ADJUST 67 67 67}
	{DELAY 100}
	{COLOR_ADJUST 100 100 100}
	{DELAY 100}
	{COLOR_ADJUST 133 133 133}
	{DELAY 100}
	{COLOR_ADJUST 167 167 167}
	{DELAY 100}
	{COLOR_ADJUST 200 200 200}
	{DELAY 100}
	{COLOR_ADJUST 233 233 233}
	{DELAY 100}
	{COLOR_ADJUST 255 255 255}
#enddef

#define UNWHITE_SCREEN
# turns the screen back to normal
    {COLOR_ADJUST 233 233 233}
    {DELAY 100}
	{COLOR_ADJUST 200 200 200}
	{DELAY 100}
	{COLOR_ADJUST 167 167 167}
	{DELAY 100}
	{COLOR_ADJUST 133 133 133}
	{DELAY 100}
	{COLOR_ADJUST 100 100 100}
	{DELAY 100}
	{COLOR_ADJUST 67 67 67}
	{DELAY 100}
	{COLOR_ADJUST 33 33 33}
	{DELAY 100}
	{COLOR_ADJUST 0 0 0}
#enddef

#define RECALL_ESTHER X Y
	[recall]
		id=Esther
		x,y={X},{Y}
	[/recall]
#enddef

#define RECALL_YUMI X Y
	[recall]
		id=Yumi
		x,y={X},{Y}
	[/recall]
#enddef

#define RECALL_ARYEL X Y
	[recall]
		id=Aryel
		x,y={X},{Y}
	[/recall]
#enddef

#define RECALL_TALYA X Y
	[recall]
		id=Talya
		x,y={X},{Y}
	[/recall]
#enddef

#define RECALL_YUMI_NOLOC
	[recall]
		id=Yumi
	[/recall]
#enddef

#define RECALL_ARYEL_NOLOC
	[recall]
		id=Aryel
	[/recall]
#enddef

#define RECALL_TALYA_NOLOC
	[recall]
		id=Talya
	[/recall]
#enddef

#define QUAKE_FIXED SOUND
    # Visuals and sound for an earth tremor.
    [sound]
        name={SOUND}
    [/sound]
    [scroll]
        x=15
        y=0
    [/scroll]
	{DELAY 100}
    [scroll]
        x=-30
        y=0
    [/scroll]
	{DELAY 100}
    [scroll]
        x=15
        y=15
    [/scroll]
	{DELAY 100}
    [scroll]
        x=0
        y=-30
    [/scroll]
	{DELAY 100}
    [scroll]
        x=0
        y=15
    [/scroll]
	{DELAY 100}
#enddef

#define TURN_UNIT5 ID
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=se
	[/modify_unit]
	{DELAY 300}
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=sw
	[/modify_unit]
	{DELAY 300}
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=se
	[/modify_unit]
	{DELAY 300}
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=sw
	[/modify_unit]
	{DELAY 300}
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=se
	[/modify_unit]
	{DELAY 500}
#enddef
#define TURN_UNIT3 ID
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=se
	[/modify_unit]
	{DELAY 300}
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=sw
	[/modify_unit]
	{DELAY 300}
	[modify_unit]
		[filter]
			id={ID}
		[/filter]
		facing=se
	[/modify_unit]
	{DELAY 500}
#enddef


#textdomain wesnoth-Genesis

#define OBJECTIVE_VICTORY _TEXT
    [objective]
        description={_TEXT}
        condition=win
    [/objective]
#enddef

#define OBJECTIVE_DEFEAT _TEXT
    [objective]
        description={_TEXT}
        condition=lose
    [/objective]
#enddef

#define OBJECTIVE_CARRYOVER
    [gold_carryover]
        bonus,carryover_percentage=yes,40
    [/gold_carryover]
#enddef

#define OBJECTIVE_CARRYOVER_NO_BONUS
    [gold_carryover]
        bonus,carryover_percentage=no,40
    [/gold_carryover]
#enddef

#define OBJECTIVE_NO_CARRYOVER
    [gold_carryover]
        bonus,carryover_percentage=no,0
    [/gold_carryover]
#enddef

#define OBJECTIVE_FULL_CARRYOVER
    [gold_carryover]
        bonus,carryover_percentage=no,100
    [/gold_carryover]
#enddef

#define OBJECTIVE_NOTE _TEXT
    [note]
        description={_TEXT}
    [/note]
#enddef

#define MESSAGE_NOT_ENOUGH_GOLD
    [message]
        speaker=narrator
        message= _ "You do not have enough gold!"
    [/message]
#enddef


#textdomain wesnoth-Genesis

#define ABILITY_BLACK_BODY
    [dummy]
        id=gns_black_body
        name= _ "black body"
        description= _"This unit is immune to all regular damage."
    [/dummy]
#enddef
#define GNS_BLACK_BODY TYPE
	[event]
        name=attacker hits
        first_time_only=no
		[filter_second]
            type={TYPE}
			ability=gns_black_body
		[/filter_second]
		[if]
			[variable]
				name=second_unit.hitpoints
				greater_than=1
			[/variable]
			[then]
				[heal_unit]
					[filter]
						x,y=$x2,$y2
					[/filter]
					amount=$damage_inflicted
					animate=yes
					restore_statuses=no
				[/heal_unit]
			[/then]
		[/if]
	[/event]
	[event]
        name=defender hits
        first_time_only=no
		[filter]
            type={TYPE}
			ability=gns_black_body
		[/filter]
		[if]
			[variable]
				name=unit.hitpoints
				greater_than=1
			[/variable]
			[then]
				[heal_unit]
					[filter]
						x,y=$x1,$y1
					[/filter]
					amount=$damage_inflicted
					animate=yes
					restore_statuses=no
				[/heal_unit]
			[/then]
		[/if]
	[/event]
#enddef


#textdomain wesnoth-Genesis

#define UNDEAD_RECRUITS
    recruit=Ghost,Skeleton,Skeleton Archer
#enddef

#define ETHEA_ENEMY_SIDE
    team_name=etheademon
    user_team_name= _ "team_name^Ethea"
    color=ethea
    controller=ai
#enddef

#define YUURE_SIDE
    team_name=yuure
    user_team_name= _ "team_name^Yuure"
    color=yuure
    controller=ai
    no_leader=yes
#enddef

#define BLACK_DEMON_SIDE
    team_name=blackdemon
    user_team_name= _ "team_name^Black Demons"
    color=black
    controller=ai
    no_leader=yes
#enddef

#define AGGRESSIVE_SIDE
    [ai]
        aggression=1
        caution=0
        grouping=false
    [/ai]
#enddef

#define DEFENSIVE_SIDE
    [ai]
        aggression=0
        caution=1
    [/ai]
#enddef

#define NO_GOLD_SIDE
    income=-2
    gold=0
    village_gold=0
    village_support=0
#enddef

#define NO_INCOME_SIDE
    income=-2
    village_gold=0
    village_support=0
#enddef

[color_range]
    id=ethea
    name= _ "team_color^Yellow"
    rgb=E6CB00,FFFFFF,211900,FFEA00
[/color_range]

[color_range]
    id=yuure
    name= _ "team_color^Midnight"
    rgb=1e0060,FFFFFF,060030,3f0075
[/color_range]

[color_range]
    id=grey
    rgb=A3A3A3,FFFFFF,141414,E0E0E0
    name= _ "Grey"
    default=yes
[/color_range]


#textdomain wesnoth-Genesis

#define PLAY_SOUND _NAME
    [sound]
        name={_NAME}
    [/sound]
#enddef

#define SOUND_LIST:IMP_HIT
{SOUND_LIST:OGRE_HIT}#enddef

#define SOUND_LIST:IMP_DIE
{SOUND_LIST:OGRE_DIE}#enddef


#textdomain wesnoth-Genesis

#define SPAWN_ID_NAME TYPE_LIST SIDE X Y ID GENDER NAME
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            id={ID}
            side={SIDE}
            x,y={X},{Y}
            random_traits=no
            name={NAME}
            gender={GENDER}
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define GUARDIAN_ID_NAME TYPE_LIST SIDE X Y ID GENDER NAME
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            id={ID}
            side={SIDE}
            x,y={X},{Y}
            random_traits=no
            name={NAME}
            gender={GENDER}
            ai_special=guardian
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef
#define GUARDIAN_ID TYPE_LIST SIDE X Y ID GENDER

    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            id={ID}
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            generate_name=yes
            gender={GENDER}
            ai_special=guardian
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define GUARDIAN_UNIT TYPE_LIST SIDE X Y
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            id=spawn_{X}_{Y}
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            random_gender=yes
            generate_name=yes
            ai_special=guardian
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define GUARDIAN_NOID TYPE_LIST SIDE X Y
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            generate_name=yes
            random_gender=yes
            ai_special=guardian
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define SPAWN_ID TYPE_LIST SIDE X Y ID GENDER
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            id={ID}
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            generate_name=yes
            gender={GENDER}
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define SPAWN TYPE_LIST SIDE X Y
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            id=spawn_{X}_{Y}
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            random_gender=yes
            generate_name=yes
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define SPAWN_NOID TYPE_LIST SIDE X Y
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            random_gender=yes
            generate_name=yes
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef

#define SPAWN_NOID_NONAME TYPE_LIST SIDE X Y
    [set_variable]
        name=spawn_gen.type
        rand={TYPE_LIST}
    [/set_variable]
    [set_variable]
        name=spawn_gen.facing
        rand="sw,se,n,s,nw,ne"
    [/set_variable]

    [set_variables]
        name=spawn_gen
        mode=merge
        [value]
            side={SIDE}
            x,y={X},{Y}
            random_traits=yes
            random_gender=yes
            generate_name=no
        [/value]
    [/set_variables]

    [unstore_unit]
        find_vacant=yes
        variable=spawn_gen
    [/unstore_unit]

    {CLEAR_VARIABLE spawn_gen}
#enddef
#define RADIAL_SPAWN TYPES SIDE X Y R

    [store_locations]
        x,y={X},{Y}
        radius={R}
        variable=spawn_points
    [/store_locations]

    [set_variable]
        name=tmp
        rand=0..$($spawn_points.length-1)
    [/set_variable]

    [set_variable]
        name=x_loc
        value=$spawn_points[$tmp].x
    [/set_variable]

    [set_variable]
        name=y_loc
        value=$spawn_points[$tmp].y
    [/set_variable]

    {SPAWN_NOID ({TYPES}) ({SIDE}) ($x_loc|) ($y_loc|)}

    [clear_variable]
        name=x_loc,y_loc,spawn_points,tmp
    [/clear_variable]
#enddef

#define ADVANCED_RESPAWN TYPES SIDE X Y R FREQUENCY COND_VAR
    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [variable]
                name={COND_VAR}
                numerical_not_equals=0
            [/variable]
        [/filter_condition]

        [store_locations]
            x,y={X},{Y}
            radius={R}
            variable=spawn_points
        [/store_locations]

        [set_variable]
            name=tmp
            rand=0..$($spawn_points.length-1)
        [/set_variable]

        [set_variable]
            name=x_loc
            value=$spawn_points[$tmp].x
        [/set_variable]

        [set_variable]
            name=y_loc
            value=$spawn_points[$tmp].y
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            rand=1..100
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            modulo={FREQUENCY}
        [/set_variable]

        [if]
            [variable]
                name=chance_to_continue
                numerical_equals=0
            [/variable]
            [then]
                {SPAWN_NOID ({TYPES}) ({SIDE}) ($x_loc|) ($y_loc|)}
            [/then]
        [/if]
        [clear_variable]
            name=chance_to_continue,x_loc,y_loc,spawn_points,tmp
        [/clear_variable]
    [/event]
#enddef

#define RESPAWN_POINT_RANDOM TYPES SIDE X1 X2 Y1 Y2 FREQUENCY
    [event]
        name=new turn
        first_time_only=no

        [set_variable]
            name=x_loc
            rand={X1}..{X2}
        [/set_variable]

        [set_variable]
            name=y_loc
            rand={Y1}..{Y2}
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            rand=1..100
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            modulo={FREQUENCY}
        [/set_variable]

        [if]
            [variable]
                name=chance_to_continue
                numerical_equals=0
            [/variable]
            [then]
                {SPAWN_NOID ({TYPES}) ({SIDE}) ($x_loc|) ($y_loc|)}
            [/then]
        [/if]
        [clear_variable]
            name=chance_to_continue,x_loc,y_loc
        [/clear_variable]
    [/event]
#enddef

#define RESPAWN_POINT_RANDOM_NONAME TYPES SIDE X1 X2 Y1 Y2 FREQUENCY
    [event]
        name=new turn
        first_time_only=no

        [set_variable]
            name=x_loc
            rand={X1}..{X2}
        [/set_variable]

        [set_variable]
            name=y_loc
            rand={Y1}..{Y2}
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            rand=1..100
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            modulo={FREQUENCY}
        [/set_variable]

        [if]
            [variable]
                name=chance_to_continue
                numerical_equals=0
            [/variable]
            [then]
                {SPAWN_NOID_NONAME ({TYPES}) ({SIDE}) ($x_loc|) ($y_loc|)}
            [/then]
        [/if]
        [clear_variable]
            name=chance_to_continue,x_loc,y_loc
        [/clear_variable]
    [/event]
#enddef

#define RESPAWN_POINT TYPES SIDE X Y FREQUENCY
    [event]
        name=new turn
        first_time_only=no

        [set_variable]
            name=chance_to_continue
            rand=1..100
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            modulo={FREQUENCY}
        [/set_variable]

        [if]
            [variable]
                name=chance_to_continue
                numerical_equals=0
            [/variable]
            [then]
                {SPAWN_NOID ({TYPES}) ({SIDE}) ({X}) ({Y})}
            [/then]
        [/if]
        [clear_variable]
            name=chance_to_continue
        [/clear_variable]
    [/event]
#enddef
#define RESPAWN_POINT_CONDITIONAL_RANDOM TYPES SIDE X1 X2 Y1 Y2 FREQUENCY COND_VAR
    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [variable]
                name={COND_VAR}
                numerical_not_equals=0
            [/variable]
        [/filter_condition]

        [set_variable]
            name=x_loc
            rand={X1}..{X2}
        [/set_variable]

        [set_variable]
            name=y_loc
            rand={Y1}..{Y2}
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            rand=1..100
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            modulo={FREQUENCY}
        [/set_variable]

        [if]
            [variable]
                name=chance_to_continue
                numerical_equals=0
            [/variable]
            [then]
                {SPAWN_NOID ({TYPES}) ({SIDE}) ($x_loc|) ($y_loc|)}
            [/then]
        [/if]
        [clear_variable]
            name=chance_to_continue,x_loc,y_loc
        [/clear_variable]
    [/event]
#enddef
#define RESPAWN_POINT_CONDITIONAL TYPES SIDE X Y FREQUENCY COND_VAR
    [event]
        name=new turn
        first_time_only=no

        [filter_condition]
            [variable]
                name={COND_VAR}
                numerical_not_equals=0
            [/variable]
        [/filter_condition]

        [set_variable]
            name=chance_to_continue
            rand=1..100
        [/set_variable]

        [set_variable]
            name=chance_to_continue
            modulo={FREQUENCY}
        [/set_variable]

        [if]
            [variable]
                name=chance_to_continue
                numerical_equals=0
            [/variable]
            [then]
                {SPAWN_NOID ({TYPES}) ({SIDE}) ({X}) ({Y})}
            [/then]
        [/if]
        [clear_variable]
            name=chance_to_continue
        [/clear_variable]
    [/event]
#enddef
#define SPAWN_POINT TYPES SIDE X Y
    [event]
        name=prestart
        {SPAWN ({TYPES}) ({SIDE}) ({X}) ({Y})}
    [/event]
#enddef


#textdomain wesnoth-Genesis

#define TRAIT_SPIRIT
    [trait]
        id=spirit
        availability="musthave"
        male_name= _ "spirit"
        female_name= _ "female^spirit"
        description= _ "Immune to drain, poison, and plague"
        [effect]
            apply_to=status
            add=not_living
        [/effect]
    [/trait]
#enddef


#textdomain wesnoth-Naia
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

# Add-ons may ship a local snapshot of Naia. If that is the case, they must
# define NAIA_EMBEDDED with the add-on's folder name before including this
# loader file so that WML and Lua path references will point to the snapshot
# instead of a non-existent default path.

#ifndef NAIA_EMBEDDED

#define NAIA_PREFIX
~add-ons/Naia#enddef
#define NAIA_BINARY_PATH
data/add-ons/Naia#enddef

#else

#define NAIA_PREFIX
~add-ons/{NAIA_EMBEDDED}/Naia#enddef
#define NAIA_BINARY_PATH
data/add-ons/{NAIA_EMBEDDED}/Naia#enddef

#endif

[binary_path]
    path={NAIA_BINARY_PATH}
[/binary_path]

#define LN _PATH
{{NAIA_PREFIX}/{_PATH}}#enddef

#define NAIA_VERSION
"{LN dist/VERSION}"#enddef

{./core/i18n.cfg}

#ifndef __WMLUNITS__
{./terrain-graphics/}
{./terrain.cfg}
#endif

#ifndef EDITOR

{./core/debug.cfg}
{./core/display.cfg}
{./core/events.cfg}
{./core/variables.cfg}
{./core/variables-math.cfg}
{./core/variables-persistent.cfg}

{./macros/}

[units]
    {./units/}
[/units]

#ifndef __WMLUNITS__

{./ai/}

[lua]
    code="wesnoth.dofile((...).prefix .. '/Naia.lua', ...)"
    [args]
        version={NAIA_VERSION}
        prefix={NAIA_PREFIX}
        [init]
            {AMLA_MENU}
        [/init]
    [/args]
[/lua]

#endif

#else

[editor_group]
    id = "wesnoth-UMC-Naia"
    name = _ "Project Ethea"
    icon = "group_custom"
[/editor_group]

#endif

# wmllint: general spellings Goliath shaxthal shaxthals verlissh verlisshi
# wmllint: general spellings Zhangor Althurin Asthorgar Irdya Quenoth Merthiaal
# wmllint: general spellings Armageddon golem golems goliath magus Uria demoness
# wmllint: general spellings demonesses imp Inferno Adavyan Mindraider Psy
# wmllint: general spellings faerie faeries gutwrencher razerman longbowman
# wmllint: general spellings crossbowman hellhound Aragwaith Aragwaithi
# wmllint: general spellings arcanister runemaster runesmith
# wmllint: general spellings Rythé Rythénian Rythénians Argazar argazars
# wmllint: general spellings strongbow longswordsmen headhunter
# wmllint: general spellings soulhunter rayblade wyrm noctum ensnare
# wmllint: general spellings biomechanical biomechanicals touchplate touchgem
# wmllint: general spellings lorekeeper lorekeepers Irdyan facemask wisemen
# wmllint: general spellings firestick loremaster loremasters dreadcrafter
# wmllint: general spellings dreadcrafters spellcaster spellcasters nyx
# wmllint: general spellings unliving elven elvenkind marchlands un-death

# wmllint: general spellings amidst amongst onwards orchestrator
# wmllint: general spellings single-handedly glyphs mayhap 'Tis
# wmllint: general spellings saurians unexperienced reknit

# wmllint: general spellings AMLAs


#textdomain wesnoth-Naia
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2019 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

#--------------------------------------------------------------------------#
#                          BASE LAYER TERRAINS                             #
#--------------------------------------------------------------------------#

#
# Cave terrains
#

[terrain_type]
    id=wasteland
    name= _ "Wasteland"
    symbol_image=wasteland
    string=Uzw
    aliasof=Ut
    editor_group=wesnoth-UMC-Naia
[/terrain_type]

[terrain_type]
    symbol_image=volcanic-abyss
    id=abyss-volcanic
    name={I18N:TERRAIN_CHASM}
    editor_name= _ "Volcanic Abyss"
    string=Qxv
    aliasof=Qt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

#
# Shaxthal hive terrains
#

[terrain_type]
    id=dark-hive-floor
    name= _ "Dark Hive"
    symbol_image=dark-hive/floor
    string=Yhr
    aliasof=Gt
    editor_group=wesnoth-UMC-Naia
[/terrain_type]

[terrain_type]
    id=dark-hive-surface
    name= _ "Dark Hive"
    symbol_image=dark-hive/surface
    string=Yhs
    aliasof=Gt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=dark-hive-lair
    name= _ "Dark Hive"
    symbol_image=dark-hive/lair
    string=Yhl
    aliasof=Gt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

#--------------------------------------------------------------------------#
#                         OVERLAY LAYER TERRAINS                           #
#--------------------------------------------------------------------------#

#
# Decoration/item terrains
#

[terrain_type]
    id=overlay-great-tree-snow
    name={I18N:TERRAIN_GREAT_TREE}
    editor_name= _ "Snowy Great Tree"
    symbol_image=tile-icons/great-tree-snowy
    string=^Feza
    default_base=Aa
    aliasof=_bas,Ft
    mvt_alias=-,_bas,Ft
    editor_group=wesnoth-UMC-Naia
[/terrain_type]

[terrain_type]
    id=overlay-great-tree-oak-dead
    name={I18N:TERRAIN_GREAT_TREE}
    editor_name= _ "Dead Great Oak Tree"
    symbol_image=tile-icons/great-tree-oak-dead
    string=^Fezo
    default_base=Gd
    aliasof=_bas,Ft
    mvt_alias=-,_bas,Ft
    editor_group=wesnoth-UMC-Naia
[/terrain_type]

[terrain_type]
    id=overlay-banner-uria
    editor_name= _ "Banner (Uria)"
    symbol_image=tile-icons/banner-uria-wall
    string=^Ebur
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-banner-merthiaal
    editor_name= _ "Banner (Merthiaal)"
    symbol_image=tile-icons/banner-yechnagoth-wall
    string=^Ebme
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-statue-adavyan
    editor_name= _ "Statue (Adavyan)"
    symbol_image=tile-icons/statue-adavyan
    string=^Eza
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-stone-wall-moss-se
    symbol_image=void/void
    editor_image=tile-icons/overlay-moss-se
    editor_name= _ "Wall Moss"
    string=^Xzm/
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-stone-wall-moss-sw
    symbol_image=void/void
    editor_image=tile-icons/overlay-moss-sw
    editor_name= _ "Wall Moss"
    string=^Xzm\
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

#
# Gates (1.12)
#

[terrain_type]
    id=overlay-gate-se
    editor_name= _ "Gate"
    symbol_image=../scenery/gate-rusty-se
    string=^Z/
    aliasof=-, _bas, Xt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-gate-sw
    editor_name= _ "Gate"
    symbol_image=../scenery/gate-rusty-sw
    string=^Z\
    aliasof=-, _bas, Xt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

#
# Gates (1.14)
#

[terrain_type]
    symbol_image=void/void
    editor_image=tile-icons/gate-golden-sw-tile
    id=portal_gate_golden_sw
    name={I18N:TERRAIN_GATE}
    editor_name= _ "Event Gate"
    string=^Zz\
    aliasof=_bas,Xt
    mvt_alias=Xt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    symbol_image=void/void
    editor_image=tile-icons/gate-golden-se-tile
    id=portal_gate_golden_se
    name={I18N:TERRAIN_GATE}
    editor_name= _ "Event Gate"
    string=^Zz/
    aliasof=_bas,Xt
    mvt_alias=Xt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    symbol_image=void/void
    editor_image=tile-icons/gate-golden-n-tile
    id=portal_gate_golden_n
    name={I18N:TERRAIN_GATE}
    editor_name= _ "Event Gate"
    string=^Zz|
    aliasof=_bas,Xt
    mvt_alias=Xt
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    symbol_image=void/void
    editor_image=tile-icons/gate-golden-open-sw-tile
    id=portal_gate_golden_open_sw
    name={I18N:TERRAIN_GATE}
    editor_name= _ "Open Event Gate"
    string=^Zz\o
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    symbol_image=void/void
    editor_image=tile-icons/gate-golden-open-se-tile
    id=portal_gate_golden_open_se
    name={I18N:TERRAIN_GATE}
    editor_name= _ "Open Event Gate"
    string=^Zz/o
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    symbol_image=void/void
    editor_image=tile-icons/gate-golden-open-n-tile
    id=portal_gate_golden_open_n
    name={I18N:TERRAIN_GATE}
    editor_name= _ "Open Event Gate"
    string=^Zz|o
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

#
# Shaxthal hive overlays
#

[terrain_type]
    id=overlay-pit
    editor_name= _ "Hive Cell"
    name= _ "Dark Hive"
    symbol_image=dark-hive/pit-2
    string=^Xp
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

#
# Special
#

[terrain_type]
    id=overlay-flat
    editor_name= _ "Flat Overlay"
    symbol_image=void/void
    editor_image=tile-icons/overlay-flat
    string=^Gov
    aliasof=Gt
    submerge=0.0
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-rough
    editor_name= _ "Rough Overlay"
    symbol_image=void/void
    editor_image=tile-icons/overlay-rough
    string=^Uov
    aliasof=Ut
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]

[terrain_type]
    id=overlay-fakeshroud
    editor_name= _ "Fake Shroud"
    symbol_image=void/void
    editor_image=tile-icons/fake-shroud
    string=^Zok
    aliasof=_bas
    editor_group=wesnoth-UMC-Naia
    hide_help=yes
[/terrain_type]


# wmllint: no translatables

# wmlindent: start ignoring
#define NPC_BIRD_UNIT_TYPES
Crow,Falcon,Shaxthal Razorbird,Shaxthal Thunderbird,Shaxthal Worm#enddef
# wmlindent: stop ignoring

#define NPC_BIRD_BEHAVIOR _SIDE_NUMBER _X1 _X2 _Y1 _Y2
    [event]
        name="side "+{_SIDE_NUMBER}+" turn refresh"
        first_time_only=no
        [npc_bird_behavior]
            types={NPC_BIRD_UNIT_TYPES}

            x1={_X1}
            y1={_Y1}

            x2={_X2}
            y2={_Y2}
        [/npc_bird_behavior]
    [/event]
#enddef

#define NPC_BIRD_BEHAVIOR_WHOLE_MAP _SIDE_NUMBER
    {NPC_BIRD_BEHAVIOR {_SIDE_NUMBER} () () () ()}
#enddef


# wmllint: no translatables

#
# Code taken from the AI Modification Demos add-on by mattsc.
#

#
# Boss AI targeting engine code.
#
# _TARGETS_LIST must be a valid Lua list.
#
#define AI_BOSS_TARGETING_ENGINE _TARGETS_LIST
    [engine]
        name="lua"
        code= <<
            local ai = ...
            return wesnoth.require(">>+{NAIA_PREFIX}+<</ai/priority_target_engine.lua").init(ai)
        >>
    [/engine]
    [modify_ai]
        # wmllint: no-syntax-rewrite
        action=add
        path="stage[main_loop].candidate_action[]"
        [candidate_action]
            engine=lua
            name=change_attacks_aspect
            id=change_attacks_aspect
            max_score=999999
            evaluation="return (...):change_attacks_aspect("+{_TARGETS_LIST}+")"
            execution="(...):change_attacks_aspect()"
        [/candidate_action]
    [/modify_ai]
#enddef


# wmllint: no translatables

#define IS_HOSTILE_NPC
    {ai/aliases/stable_singleplayer.cfg}
    [ai]
        {AI_SIMPLE_ALWAYS_ASPECT aggression       1.0}
        {AI_SIMPLE_ALWAYS_ASPECT leader_value     0.0}
        {AI_SIMPLE_ALWAYS_ASPECT village_value    0.0}
        {AI_SIMPLE_ALWAYS_ASPECT grouping         no }
        {AI_SIMPLE_ALWAYS_ASPECT caution          0.0}
        {AI_SIMPLE_ALWAYS_ASPECT simple_targeting yes}
    [/ai]
#enddef

#define TEAM_AI_KAMIKAZE
    {ai/aliases/stable_singleplayer.cfg}

    [ai]
        [goal]
            [criteria]
                canrecruit=yes
            [/criteria]
            value=7.0
        [/goal]

        {AI_SIMPLE_ALWAYS_ASPECT aggression 9.0}
        {AI_SIMPLE_ALWAYS_ASPECT caution    0.0}
        {AI_SIMPLE_ALWAYS_ASPECT grouping   no}

        {AI_NO_SCOUTS}
    [/ai]
#enddef


# wmllint: no translatables

#
# AI utility macros
#

#define AI_RECRUITMENT_ALWAYS_ASPECT _LIMITS
    [aspect]
        id=recruitment
        [facet]
            [value]
                name=ai_default::recruitment
                {_LIMITS}
            [/value]
        [/facet]
    [/aspect]
#enddef

#define AI_RECRUIT_LIMIT _TYPE _MAX
    [limit]
        type={_TYPE}
        max={_MAX}
    [/limit]
#enddef

#
# Single value ToD-based aspects.
#

#define AI_SIMPLE_UTBS_DAY_ASPECT _ASPECT_ID _VALUE
    {AI_SIMPLE_ASPECT_FOR_TIME_OF_DAY {_ASPECT_ID} day      morning1,midday1,afternoon1,morning2,midday2,afternoon2 {_VALUE} }
#enddef

#define AI_SIMPLE_UTBS_TWILIGHT_ASPECT _ASPECT_ID _VALUE
    {AI_SIMPLE_ASPECT_FOR_TIME_OF_DAY {_ASPECT_ID} twilight dawn1,dusk1,dawn2,dusk2 {_VALUE} }
#enddef

#define AI_SIMPLE_UTBS_NIGHT_ASPECT _ASPECT_ID _VALUE
    {AI_SIMPLE_ASPECT_FOR_TIME_OF_DAY {_ASPECT_ID} night    short_dark,long_dark1,long_dark2,long_dark3,long_dark4 {_VALUE} }
#enddef

#define AI_SIMPLE_UTBS_TOD_ASPECT _ASPECT_ID _DAY_VALUE _TWILIGHT_VALUE _NIGHT_VALUE
    {AI_SIMPLE_UTBS_DAY_ASPECT      {_ASPECT_ID} {_DAY_VALUE} }
    {AI_SIMPLE_UTBS_TWILIGHT_ASPECT {_ASPECT_ID} {_TWILIGHT_VALUE} }
    {AI_SIMPLE_UTBS_NIGHT_ASPECT    {_ASPECT_ID} {_NIGHT_VALUE}    }
#enddef

#
# Multiple value ToD-based aspects.
#

#define AI_SIMPLE_UTBS_DAY_ASPECT_VALUE _ASPECT_ID _VALUE
    {AI_SIMPLE_ASPECT_FOR_TIME_OF_DAY_VALUE {_ASPECT_ID} day morning1,midday1,afternoon1,morning2,midday2,afternoon2 {_VALUE} }
#enddef

#define AI_SIMPLE_UTBS_TWILIGHT_ASPECT_VALUE _ASPECT_ID _VALUE
    {AI_SIMPLE_ASPECT_FOR_TIME_OF_DAY {_ASPECT_ID} twilight dawn1,dusk1,dawn2,dusk2 {_VALUE} }
#enddef

#define AI_SIMPLE_UTBS_NIGHT_ASPECT_VALUE _ASPECT_ID _VALUE
    {AI_SIMPLE_ASPECT_FOR_TIME_OF_DAY {_ASPECT_ID} night short_dark,long_dark1,long_dark2,long_dark3,long_dark4 {_VALUE} }
#enddef

#define AI_SIMPLE_UTBS_TOD_ASPECT_VALUE _ASPECT_ID _DAY_VALUE _TWILIGHT_VALUE _NIGHT_VALUE
    {AI_SIMPLE_UTBS_DAY_ASPECT_VALUE      {_ASPECT_ID} {_DAY_VALUE} }
    {AI_SIMPLE_UTBS_TWILIGHT_ASPECT_VALUE {_ASPECT_ID} {_TWILIGHT_VALUE} }
    {AI_SIMPLE_UTBS_NIGHT_ASPECT_VALUE    {_ASPECT_ID} {_NIGHT_VALUE}    }
#enddef

#
# Micro AI-related utility macros
#

# wmllint: unbalanced-on
# wmlindent: start ignoring
# wmlxgettext: [side]

#define SIDE_MICRO_AI _SIDE _AI_TYPE _WML
    [/side]
    [event]
        name=prestart
        [micro_ai]
            side={_SIDE}
            ai_type={_AI_TYPE}
            action=add
            {_WML}
        [/micro_ai]
    [/event]
    [+side]
#enddef

# wmlxgettext: [/side]
# wmlindent: stop ignoring
# wmllint: unbalanced-off


#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

#define BUG _MESSAGE
    [bug]
        message={_MESSAGE}
    [/bug]
#enddef

#define BUG_ON _CONDITION _MESSAGE
    [bug]
        message={_MESSAGE}
        [condition]
            {_CONDITION}
        [/condition]
    [/bug]
#enddef

#define DIE _MESSAGE
    [bug]
        message={_MESSAGE}
        may_ignore=no
    [/bug]
#enddef

#define DIE_ON _CONDITION _MESSAGE
    [bug]
        message={_MESSAGE}
        may_ignore=no
        [condition]
            {_CONDITION}
        [/condition]
    [/bug]
#enddef

#
# Quick mid-event gamestate inspector invocation macro.
# Only useful for internal debugging, so it's not used in published code.
#
#define !
    #warning Inspector call
    [inspect][/inspect]
#enddef

#define LOG_NAIA_ERR _MSG
    {ERROR ("[Naia] "+{_MSG})}
#enddef

#define LOG_NAIA_WRN _MSG
    {WARNING ("[Naia] "+{_MSG})}
#enddef

#define LOG_NAIA_WARN _MSG
    {WARNING ("[Naia] "+{_MSG})}
#enddef

#define LOG_NAIA _MSG
    {LOG ("[Naia] "+{_MSG})}
#enddef

#ifdef DEBUG
#define LOG_NAIA_DBG _MSG
    {DEBUG ("[Naia] "+{_MSG})}
#enddef
#else
#define LOG_NAIA_DBG _MSG
    {LOG ({_MSG})}
#enddef
#endif


#textdomain wesnoth-Naia
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

[color_range]
    id=cyan
    name= _ "team_color^Cyan"
    rgb=00BEBE,00EEEE,333333,00EEEE
[/color_range]

[color_range]
    id=yellow
    name= _ "team_color^Yellow"
    rgb=EEE000,FFFFFF,100F00,FFF000
[/color_range]

[color_range]
    id=pink
    name= _ "team_color^Pink"
    rgb=FFAAFF,FFEEFF,503750,DD88DD
[/color_range]

[color_palette]
    shaxthal_drone_base=AEDCFF,8680FF,306287,503669,171745,1C0821
    shaxthal_drone_surface=D7BE8C,B0974C,675C22,4D3B59,442626,211313
    shaxthal_drone_brown=E0E0E8,AEA79B,8F6659,503669,171745,1C0821
    shaxthal_drone_purple=BDD2D3,AF81DE,306287,503669,171745,1C0821
    shaxthal_drone_cyan=AEDCFF,8DAAA0,306287,503669,171745,1C0821
[/color_palette]


#
# WML events library
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2019 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

#
# Dispatches a new event while passing the current primary unit/attack and
# secondary unit/attack without changes.
#
# NOTE: Both the primary and secondary unit must exist on the map.
#
#define EVENT_FORWARD_DISPATCH _EVENT_NAME
    [fire_event]
        name={_EVENT_NAME}

        [primary_unit]
            x,y=$x1,$y1
        [/primary_unit]
        [insert_tag]
            name="primary_attack"
            variable="weapon"
        [/insert_tag]

        [secondary_unit]
            x,y=$x2,$y2
        [/secondary_unit]
        [insert_tag]
            name="secondary_attack"
            variable="second_weapon"
        [/insert_tag]
    [/fire_event]
#enddef

#define EVENT_FORWARD_DISPATCH_SIMPLE _EVENT_NAME
    [fire_event]
        name={_EVENT_NAME}

        [primary_unit]
            x,y=$x1,$y1
        [/primary_unit]

        [secondary_unit]
            x,y=$x2,$y2
        [/secondary_unit]
    [/fire_event]
#enddef

#
# Dispatches a new event while passing the current primary unit/attack and
# secondary unit/attack swapped - meaning primary becomes secondary and
# secondary becomes primary.
#
# NOTE: Both the primary and secondary unit must exist on the map.
#
#define EVENT_INVERSE_DISPATCH _EVENT_NAME
    [fire_event]
        name={_EVENT_NAME}

        [secondary_unit]
            x,y=$x1,$y1
        [/secondary_unit]
        [insert_tag]
            name="secondary_attack"
            variable="weapon"
        [/insert_tag]

        [primary_unit]
            x,y=$x2,$y2
        [/primary_unit]
        [insert_tag]
            name="primary_attack"
            variable="second_weapon"
        [/insert_tag]
    [/fire_event]
#enddef

#define EVENT_INVERSE_DISPATCH_SIMPLE _EVENT_NAME
    [fire_event]
        name={_EVENT_NAME}

        [secondary_unit]
            x,y=$x1,$y1
        [/secondary_unit]

        [primary_unit]
            x,y=$x2,$y2
        [/primary_unit]
    [/fire_event]
#enddef

#
# Global events need to be added to a [campaign] tag. The problem is, because
# of the Ethea phase 1 campaigns' structure, the last defined [campaign] is not
# necessarily the one that's being started -- it'll always be the last one
# instead. Therefore the [+campaign] approach will not work.
#
# We use a simple kludge to get around this by having events be injected
# directly by Lua. Note that this allows using pretty much any event WML at
# this point, not just [event]s, but we should probably avoid getting too
# clever here since the UI has not been fully initialized at this point.
#
# IMPORTANT NOTE:
#
# Do bear in mind that any code included here is executed every time the game
# is set up, before preload. Therefore, if you do not include unique
# identifiers for each event defined, they WILL stack up forever.
#
#define GLOBAL_EVENTS _CODE
    [lua]
        code="global_run_wml(...)"
        [args]
            {_CODE}
        [/args]
    [/lua]
#enddef


#
# i18n/mainline strings library
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

#textdomain wesnoth

#define I18N:YES
    _"Yes" #enddef
#define I18N:NO
    _"No" #enddef

#textdomain wesnoth-lib

#define I18N:TERRAIN_SHROUD
    _"Shroud" #enddef
#define I18N:TERRAIN_FOG
    _ "Fog" #enddef
#define I18N:TERRAIN_VOID
    _ "Void" #enddef
#define I18N:TERRAIN_CHASM
    _ "Chasm" #enddef
#define I18N:TERRAIN_ROAD
    _ "Road" #enddef
#define I18N:TERRAIN_FLAT
    _ "Flat" #enddef
#define I18N:TERRAIN_CAVE
    _ "Cave" #enddef
#define I18N:TERRAIN_CASTLE
    _ "Castle" #enddef
#define I18N:TERRAIN_KEEP
    _ "Keep" #enddef
#define I18N:TERRAIN_IMPASSABLE
    _ "Impassable" #enddef
#define I18N:TERRAIN_UNWALKABLE
    _ "Unwalkable" #enddef
#define I18N:TERRAIN_ROCKBOUND_CAVE
    _ "Rockbound Cave" #enddef
#define I18N:TERRAIN_STONE_WALL
    _ "Stone Wall" #enddef
#define I18N:TERRAIN_GATE
    _ "Gate" #enddef
#define I18N:TERRAIN_GREAT_TREE
    _ "Great Tree" #enddef

#textdomain wesnoth-units

#define I18N:ATTACK_BOW
    _ "bow" #enddef
#define I18N:ATTACK_CROSSBOW
    _ "crossbow" #enddef
#define I18N:ATTACK_DAGGER
    _ "dagger" #enddef
#define I18N:ATTACK_LONGSWORD
    _ "longsword" #enddef
#define I18N:ATTACK_SHORT_SWORD
    _ "short sword" #enddef
#define I18N:ATTACK_CLUB
    _ "club" #enddef
#define I18N:ATTACK_JAVELIN
    _ "javelin" #enddef
#define I18N:ATTACK_BATTLE_AXE
    _ "battle axe" #enddef
#define I18N:ATTACK_MORNING_STAR
    _ "morning star" #enddef
#define I18N:ATTACK_STAFF
    _ "staff" #enddef
#define I18N:ATTACK_FIST
    _ "fist" #enddef
#define I18N:ATTACK_SWORD
    _ "sword" #enddef
#define I18N:ATTACK_SPEAR
    _ "spear" #enddef
#define I18N:ATTACK_AXE
    _ "axe" #enddef
#define I18N:ATTACK_FIREBALL
    _ "fireball" #enddef
#define I18N:ATTACK_CLAWS
    _ "claws" #enddef
#define I18N:ATTACK_FIRE_BREATH
    _ "fire breath" #enddef
#define I18N:ATTACK_FIRE_CLAWS
    _ "fire claws" #enddef
#define I18N:ATTACK_WATER_SPRAY
    _ "water spray" #enddef
#define I18N:ATTACK_FANGS
    _ "fangs" #enddef
#define I18N:ATTACK_TOUCH
    _ "touch" #enddef
#define I18N:ATTACK_WAIL
    _ "wail" #enddef
#define I18N:ATTACK_CRUSH
    _ "crush" #enddef
#define I18N:ATTACK_TAIL
    _ "tail" #enddef
#define I18N:ATTACK_TENTACLE
    _ "tentacle" #enddef
#define I18N:ATTACK_WEB
    _ "web" #enddef
#define I18N:CHILL_TEMPEST
    _ "chill tempest" #enddef
#define I18N:ATTACK_ENTANGLE
    _ "entangle" #enddef
#define I18N:ATTACK_ENSNARE
    _ "ensnare" #enddef
#define I18N:ATTACK_FAERIE_TOUCH
    _ "faerie touch" #enddef
#define I18N:ATTACK_FAERIE_FIRE
    _ "faerie fire" #enddef
#define I18N:ATTACK_THORNS
    _ "thorns" #enddef
#define I18N:ATTACK_GOSSAMER
    _ "gossamer" #enddef


#
# WML variable operations library
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

############################################################################
#                           ARITHMETIC OPERATIONS                          #
############################################################################

#
# _VAR += _OPERAND
#

#define VARIABLE_ADD _VAR _OPERAND
    [set_variable]
        name={_VAR}
        add={_OPERAND}
    [/set_variable]
#enddef

#
# _VAR -= _OPERAND
#

#define VARIABLE_MINUS _VAR _OPERAND
    [set_variable]
        name={_VAR}
        sub={_OPERAND}
    [/set_variable]
#enddef

#define VARIABLE_MIN _VAR _OPERAND
    {VARIABLE_MINUS {_VAR} {_OPERAND}}
#enddef

#
# _VAR *= _OPERAND
#

#define VARIABLE_MULTIPLY _VAR _OPERAND
    [set_variable]
        name={_VAR}
        multiply={_OPERAND}
    [/set_variable]
#enddef

#define VARIABLE_MUL _VAR _OPERAND
    {VARIABLE_MULTIPLY {_VAR} {_OPERAND}}
#enddef

#
# _VAR /= _OPERAND
#

#define VARIABLE_DIVIDE _VAR _OPERAND
    [set_variable]
        name={_VAR}
        divide={_OPERAND}
    [/set_variable]
#enddef

#define VARIABLE_DIV _VAR _OPERAND
    {VARIABLE_DIVIDE   {_VAR} {_OPERAND}}
#enddef

#
# _VAR %= _OPERAND
#

#define VARIABLE_MODULO _VAR _OPERAND
    [set_variable]
        name={_VAR}
        modulo={_OPERAND}
    [/set_variable]
#enddef

#define VARIABLE_MOD _VAR _OPERAND
    {VARIABLE_MODULO   {_VAR} {_OPERAND}}
#enddef

#
# _VAR *= -1
#

#define VARIABLE_NEG _VAR
    [set_variable]
        name={_VAR}
        multiply=-1
    [/set_variable]
#enddef

#
# ++_VAR
#

#define VARIABLE_INC _VAR
    [set_variable]
        name={_VAR}
        add=1
    [/set_variable]
#enddef

#
# --_VAR
#

#define VARIABLE_DEC _VAR
    [set_variable]
        name={_VAR}
        sub=1
    [/set_variable]
#enddef

############################################################################
#                           COMPARISON OPERATORS                           #
############################################################################

#
# _VAR == _VALUE
#

#define VARIABLE_NUMERICAL_EQUALS _VAR _VALUE
    [variable]
        name={_VAR}
        numerical_equals={_VALUE}
    [/variable]
#enddef

#
# _VAR != _VALUE
#

#define VARIABLE_NUMERICAL_NOT_EQUALS _VAR _VALUE
    [variable]
        name={_VAR}
        numerical_not_equals={_VALUE}
    [/variable]
#enddef

#
# _VAR < _VALUE
#

#define VARIABLE_NUMERICAL_LESS_THAN _VAR _VALUE
    [variable]
        name={_VAR}
        less_than={_VALUE}
    [/variable]
#enddef

#
# _VAR > _VALUE
#

#define VARIABLE_NUMERICAL_GREATER_THAN _VAR _VALUE
    [variable]
        name={_VAR}
        greater_than={_VALUE}
    [/variable]
#enddef

#
# _VAR <= _VALUE
#

#define VARIABLE_NUMERICAL_LESS_THAN_OR_EQUAL _VAR _VALUE
    [variable]
        name={_VAR}
        less_than_equal_to={_VALUE}
    [/variable]
#enddef

#
# _VAR >= _VALUE
#

#define VARIABLE_NUMERICAL_GREATER_THAN_OR_EQUAL _VAR _VALUE
    [variable]
        name={_VAR}
        greater_than_equal_to={_VALUE}
    [/variable]
#enddef

#
# _VAR % 2 == 0
#

#define VARIABLE_IS_EVEN _VAR
    [variable_is_even]
        name={_VAR}
    [/variable_is_even]
#enddef

#
# _VAR % 2 != 0
#

#define VARIABLE_IS_ODD _VAR
    [not]
        [variable_is_even]
            name={_VAR}
        [/variable_is_even]
    [/not]
#enddef

#
# _VAR >= _BOTTOM && _VAR <= _TOP
#

#define VARIABLE_NUMERICAL_IN_RANGE _VAR _BOTTOM _TOP
    [variable]
        name={_VAR}
        greater_than_equal_to={_BOTTOM}
    [/variable]
    [variable]
        name={_VAR}
        less_than_equal_to={_TOP}
    [/variable]
#enddef

#
# _VAR.x == _X && _VAR.y == _Y
#

#define VARIABLE_POS_EQUALS _VAR _X _Y
    [position_equals]
        variable={_VAR}
        x={_X}
        y={_Y}
    [/position_equals]
#enddef


#
# Persistent WML variable operations library
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2012 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

# NOTE: Needs to match PERSISTENT_NS_NAIA in /lua/persistent.lua
#define PERSISTENT_NS_NAIA
	"Project_Ethea.Naia" #enddef

#define READ_GLOBAL_INTO_VARIABLE _FROM_GLOBAL_ID _TO_VAR_ID
#arg NAMESPACE
	{PERSISTENT_NS_NAIA}
#endarg
	[get_global_variable]
		namespace={NAMESPACE}

		from_global={_FROM_GLOBAL_ID}
        to_local={_TO_VAR_ID}
	[/get_global_variable]
#enddef

#define WRITE_VARIABLE_INTO_GLOBAL _FROM_VAR_ID _TO_GLOBAL_ID
#arg NAMESPACE
	{PERSISTENT_NS_NAIA}
#endarg
#arg IMMEDIATE
	yes
#endarg
	[set_global_variable]
		namespace={NAMESPACE}
		immediate={IMMEDIATE}

		from_local={_FROM_VAR_ID}
		to_global={_TO_GLOBAL_ID}
	[/set_global_variable]
#enddef

#define GLOBAL_TABLE:OPEN
#arg NAMESPACE
	{PERSISTENT_NS_NAIA}
#endarg
	[global_table]
		namespace={NAMESPACE}
#enddef

#define GLOBAL_TABLE:READ _KEY
	[read]
		key={_KEY}
	[/read]
#enddef

#define GLOBAL_TABLE:WRITE _KEY
	[write]
		key={_KEY}
	[/write]
#enddef

#define GLOBAL_TABLE:DELETE _KEY
	[delete]
		key={_KEY}
	[/delete]
#enddef

#define GLOBAL_TABLE:CLOSE
	[/global_table]
#enddef


#
# WML variable operations library
#
# codename Naia - Project Ethea phase 1 campaigns shared library
# Copyright (C) 2006 - 2023 by Iris Morelle <shadowm@wesnoth.org>
#
# See COPYING for usage terms.
#

#define VARIABLE_FROM_STRLEN _VAR _VALUE
    [set_variable]
        name={_VAR}
        string_length={_VALUE}
    [/set_variable]
#enddef

#define VARIABLE_RANDOM _VAR _VALUE
    [set_variable]
        name={_VAR}
        rand={_VALUE}
    [/set_variable]
#enddef

#define VARIABLE_DEFAULT _VAR _VALUE
    [variable_default]
        name={_VAR}
        value={_VALUE}
    [/variable_default]
#enddef

#define VARIABLE_COPY _VAR_DST _VAR_SRC
    [set_variable]
        name={_VAR_DST}
        to_variable={_VAR_SRC}
    [/set_variable]
#enddef

#define VARIABLE_ARRAY_COPY _ARRAY_DST _ARRAY_SRC
    [set_variables]
        name={_ARRAY_DST}
        mode=replace
        to_variable={_ARRAY_SRC}
    [/set_variables]
#enddef

#define VARIABLE_IF_ELSE _VAR _VALUE_IF _VALUE_ELSE _COND
    [if]
        {_COND}
        [then]
            [set_variable]
                name={_VAR}
                value={_VALUE_IF}
            [/set_variable]
        [/then]
        [else]
            [set_variable]
                name={_VAR}
                value={_VALUE_ELSE}
            [/set_variable]
        [/else]
    [/if]
#enddef

#define VARIABLE_EVAL_CONDITIONAL _VAR _COND
    [set_conditional_variable]
        name={_VAR}
        [condition]
            {_COND}
        [/condition]
    [/set_conditional_variable]
#enddef

#define VARIABLE_LEXICAL_EQUALS _VAR _VALUE
    [variable]
        name={_VAR}
        equals={_VALUE}
    [/variable]
#enddef

#define VARIABLE_LEXICAL_NOT_EQUALS _VAR _VALUE
    [variable]
        name={_VAR}
        not_equals={_VALUE}
    [/variable]
#enddef

#define VARIABLE_LEXICAL_CONTAINS _VAR _VALUE
    [variable]
        name={_VAR}
        contains={_VALUE}
    [/variable]
#enddef

#define VARIABLE_LEXICAL_IN _VAR _VALUES
    [variable_in]
        name={_VAR}
        values={_VALUES}
    [/variable_in]
#enddef

#define VARIABLE_BOOLEAN_EQUALS _VAR _VALUE
    [variable]
        name={_VAR}
        boolean_equals={_VALUE}
    [/variable]
#enddef

#define VARIABLE_BOOLEAN_NOT_EQUALS _VAR _VALUE
    [variable]
        name={_VAR}
        boolean_not_equals={_VALUE}
    [/variable]
#enddef

#define VARIABLE_ARRAY_EMPTY VAR_ID
    [variable]
        name={VAR_ID}+".length"
        numerical_equals=0
    [/variable]
#enddef

#define VARIABLE_ARRAY_NOT_EMPTY VAR_ID
    [variable]
        name={VAR_ID}+".length"
        numerical_not_equals=0
    [/variable]
#enddef

#
# ConditionalWML that always yields a true value.
#
#define TRUE
    [true][/true]
#enddef

#
# ConditionalWML that always yields a false value.
#
#define FALSE
    [false][/false]
#enddef


#textdomain wesnoth-Naia

#
# Implementation of event-based unit abilities.
#

#define ABILITY_TESTAMENT_EVENTS
    [event]
        id=ua_testament:death_handler
        name=die
        first_time_only=no
        [filter]
            ability=testament
        [/filter]

        [store_unit]
            [filter]
                [filter_adjacent]
                    x,y=$x1,$y1
                [/filter_adjacent]

                [filter_side]
                    [allied_with]
                        side=$unit.side
                    [/allied_with]
                [/filter_side]

                formula="(self.hitpoints < self.max_hitpoints * 0.50)"
            [/filter]

            kill=no
            variable=temp_UA_TESTAMENT_targets
        [/store_unit]

        [foreach]
            array=temp_UA_TESTAMENT_targets
            [do]
                {VARIABLE temp_UA_TESTAMENT_heal_amount "$(round($this_item.max_hitpoints * 0.50 - $this_item.hitpoints))"}
                {VARIABLE this_item.hitpoints "$($this_item.max_hitpoints * 0.50)"}

                [unstore_unit]
                    find_vacant=no
                    variable=this_item
                    text=$temp_UA_TESTAMENT_heal_amount
                    {COLOR_HEAL}
                [/unstore_unit]
            [/do]
        [/foreach]

        [ua_testament_terraform][/ua_testament_terraform]

        {CLEAR_VARIABLE temp_UA_TESTAMENT_heal_amount,temp_UA_TESTAMENT_targets}
    [/event]
#enddef


#textdomain wesnoth-Naia

# wmlindent: start ignoring

# wmllint: unbalanced-on

#
# Used as a convenience wrapper to include ability implementation details in
# unit type definitions without copy-pasting the close-reopen tag boilerplate.
# This requires that the macro actually holding the event WML for the ability
# is named ABILITY_<suffix>_EVENTS:
#
#   [dummy]
#      id=awesome_aura
#   [/dummy]
#
#   {ABILITY_EVENTS AWESOME_AURA} # includes ABILITY_AWESOME_AURA_EVENTS
#
#define ABILITY_EVENTS _SUFFIX
    # wmlxgettext: [abilities]
    [/abilities]
    {ABILITY_{_SUFFIX}_EVENTS}
    [+abilities]
    # wmlxgettext: [/abilities]
#enddef

# wmllint: unbalanced-off

# all forest terrains (tree, mushroom)
#define VEGETATED_TERRAINS
*^F*, *^Uf, *^Ufi #enddef

#define NOTES_VEGETATED_TERRAINS
    "

"+_ "Note: Vegetated terrains include forest, great tree, and mushroom grove hexes."#enddef

# wmlindent: stop ignoring

#define ABILITY_OBSCURE
    [illuminates]
        id=obscure
        value=-25
        min_value=-25
        cumulative=no
        name= _ "obscures"
        description= _ "This unit darkens the surrounding area, making chaotic units fight better, and lawful units fight worse.

Any units adjacent to this unit will fight as if it were dusk when it is day, and as if it were night when it is dusk."
        special_note={SPECIAL_NOTE_OBSCURE}
        affect_self=yes
    [/illuminates]
#enddef

#define ABILITY_SYLVAN_SPARK
    [regenerate]
        value=5
        id=sylvan_spark
        name= _ "sylvan spark"
        description=_ "While in vegetated terrains, the unit will heal itself 5 HP per turn. If it is poisoned, it will remove the poison instead of healing."+{NOTES_VEGETATED_TERRAINS}
        special_note={SPECIAL_NOTE_SYLVAN_SPARK}
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain={VEGETATED_TERRAINS}
            [/filter_location]
        [/filter_self]
        poison=cured
    [/regenerate]
#enddef

#
# Protection
#

#define ABILITY_PROTECTION
    [resistance]
        id=protection
        add=20
        max_value=50
        apply_to=blade,pierce,impact,fire,cold,arcane
        name= _ "protection"
        description= _ "Adjacent units of lower level from this side receive a +20% bonus to all resistances (up to a maximum of 50%)."
        affect_self=no
        [filter_base_value]
            less_than=50
        [/filter_base_value]
        [affect_adjacent]
            [filter]
                formula="level < other.level"
            [/filter]
        [/affect_adjacent]
    [/resistance]
#enddef

#
# Terror
#

#define ABILITY_TERROR
    [leadership]
        id=terror
        value="(-(15 * (level - other.level) + 15))"
        cumulative=no
        name= _ "terror"
        description= _ "This unit can frighten enemy units that are next to it, making them fight worse.

Adjacent enemy units of lower level will do less damage in battle. When an enemy unit of lower level is adjacent and engages in combat, its attacks do 15% less damage times the difference in their levels + 15%."
        special_note={SPECIAL_NOTE_PROTECTION}
        affect_self=no
        affect_allies=no
        affect_enemies=yes
        [affect_adjacent]
            [filter]
                formula="level < other.level"
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_BORE
    [hides]
        id=bore
        name= _ "bore"
        female_name= _ "female^bore"
        description= _ "If somehow forced to move into cave or stone walls, this unit can hide inside them and deal 50% more damage on defense.

Enemy units cannot see this unit while it is inside walls, except if they have units next to it. Any enemy unit that first discovers this unit immediately loses all its remaining movement."
        special_note={SPECIAL_NOTE_BORE}
        affect_self=yes
        [filter]
            [filter_location]
                terrain=Xo*,Xo*^*,Xu*,Xu*^*
            [/filter_location]
        [/filter]
    [/hides]

    [damage]
        id=bore_ws
        active_on=defense
        apply_to=self
        [filter_self]
            [filter_location]
                terrain=Xo*,Xo*^*,Xu*,Xu*^*
            [/filter_location]
        [/filter_self]
        value="( base_value * 1.5 )"
    [/damage]
#enddef

#define ABILITY_ZEAL
    [resistance]
        id=zeal
        name= _ "zeal"
        female_name= _ "female^zeal"
        description= _ "The zeal of this unit inspires adjacent units to resist enemy attacks better and deal increased damage.

Adjacent own units of lower level will receive a +30% bonus to their resistances while defending, up to a maximum of 60% for non-arcane damage, or 30% for arcane damage. They will also deal 15% more damage times the difference in their levels on both defense and offense."
        special_note={SPECIAL_NOTE_ZEAL}
        affect_self=no
        apply_to=blade,pierce,impact,fire,cold
        add=30
        max_value=60
        [filter_base_value]
            less_than=60
        [/filter_base_value]
        [affect_adjacent]
            [filter]
                formula="level < other.level"
            [/filter]
        [/affect_adjacent]
    [/resistance]

    [resistance]
        id=zeal_res_arcane
        affect_self=no
        apply_to=arcane
        add=30
        max_value=30
        [filter_base_value]
            less_than=30
        [/filter_base_value]
        [affect_adjacent]
            [filter]
                formula="level < other.level"
            [/filter]
        [/affect_adjacent]
    [/resistance]

    [leadership]
        id=zeal_dmg_bonus
        affect_self=no
        value="(15 * (level - other.level))"
        cumulative=no
        [affect_adjacent]
            [filter]
                formula="level < other.level"
            [/filter]
        [/affect_adjacent]
    [/leadership]
#enddef

#define ABILITY_TESTAMENT
    [dummy]
        id=testament
        name= _ "testament"
        description= _ "Upon the death of this unit, any wounded adjacent allies below 50% of their total HP will be healed back to said amount, although any negative status effects will not be removed. Additionally, if the unit is standing on clear walkable ground without any obstructions on it, a suitable testament to its existence will take its place."
        special_note={SPECIAL_NOTE_TESTAMENT}
    [/dummy]

    {ABILITY_EVENTS TESTAMENT}
#enddef

#define ABILITY_ENERGIZE_515
    {ABILITY_ENERGIZE:DEFINE energize_515
        5 15 40
        ( _ "energize+5/15%")
        ( _ "This unit heals adjacent allied units possessing the ‘biomechanical’ trait by 5 HP at the start of every turn, and grants them a 15% resistance bonus (up to a maximum of 40%).")
    }
#enddef

#define ABILITY_ENERGIZE_1030
    {ABILITY_ENERGIZE:DEFINE energize_1030
        10 30 70
        ( _ "energize+10/30%")
        ( _ "This unit heals adjacent allied units possessing the ‘biomechanical’ trait by 10 HP at the start of every turn, and grants them a 30% resistance bonus (up to a maximum of 70%).")
    }
#enddef

#define ABILITY_ENERGIZE:DEFINE _ID _HEAL_VAL _RES_VAL _RES_MAX _NAME _DESCRIPTION
    [heals]
        id={_ID}
        name={_NAME}
        description={_DESCRIPTION}
        special_note={SPECIAL_NOTE_ENERGIZE}
        value={_HEAL_VAL}
        affect_allies=yes
        affect_self=no
        poison=slowed
        {ABILITY_ENERGIZE:CONDITIONS}
    [/heals]

    [resistance]
        id={_ID}+"_protection"
        add={_RES_VAL}
        max_value={_RES_MAX}
        apply_to=blade,pierce,impact,fire,cold,arcane
        affect_allies=yes
        affect_self=no
        [filter_base_value]
            less_than={_RES_MAX}
        [/filter_base_value]
        {ABILITY_ENERGIZE:CONDITIONS}
    [/resistance]
#enddef

#define ABILITY_ENERGIZE:CONDITIONS
    [affect_adjacent]
        [filter]
            trait=biomechanical
        [/filter]
    [/affect_adjacent]
#enddef

############################################################################
#                                                                          #
#                      UNIQUE UNIT OR AMLA ABILITIES                       #
#                                                                          #
############################################################################

#define ABILITY_SYLVAN_ESSENCE
    [heals]
        value=8
        id=sylvan_essence_healing_and_curing
        name= _ "sylvan essence"
        description= _ "This unit can heal and cure friendly units on adjacent hexes every turn, to a base maximum of 8 HP. In vegetated terrains, it will conceal itself from its enemies. It can also regenerate (but not unpoison) 3 HP per-turn, but only on vegetated terrains."+{NOTES_VEGETATED_TERRAINS}
        special_note={SPECIAL_NOTE_SYLVAN_ESSENCE}
        affect_allies=yes
        affect_self=no
        poison=cured
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
    [hides]
        id=sylvan_essence_conceal
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain={VEGETATED_TERRAINS}
            [/filter_location]
        [/filter_self]
    [/hides]
    [regenerate]
        value=3
        # NOTE: AtS has special knowledge of this id (macros/amla-elynia.cfg)
        id=sylvan_essence_selfheal_L0
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain={VEGETATED_TERRAINS}
            [/filter_location]
        [/filter_self]
    [/regenerate]
#enddef

#define ABILITY_SYLVAN_ESSENCE_UNION
    [illuminates]
        id=sylvan_essence_illum
        value=25
        max_value=25
        cumulative=no
        name= _ "sylvan essence"
        description=_"This unit illuminates the surrounding area, making lawful units fight better, and chaotic units fight worse. Any units adjacent to this unit will fight as if it were dusk when it is night, and as if it were day when it is dusk.

The unit also can heal and cure friendly units on adjacent hexes every turn, to a base maximum of 8 HP. In vegetated terrains, it will conceal itself from its enemies. It can also regenerate (but not unpoison) 4 HP per-turn, but only in vegetated terrains."+{NOTES_VEGETATED_TERRAINS}
        special_note={SPECIAL_NOTE_SYLVAN_ESSENCE}
        affect_self=yes
    [/illuminates]
    [heals]
        value=8
        id=sylvan_essence_healing
        affect_allies=yes
        affect_self=no
        poison=cured
        [affect_adjacent]
            adjacent=n,ne,se,s,sw,nw
        [/affect_adjacent]
    [/heals]
    [hides]
        id=sylvan_essence_conceal
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain={VEGETATED_TERRAINS}
            [/filter_location]
        [/filter_self]
    [/hides]
    [regenerate]
        value=4
        id=sylvan_essence_selfheal
        affect_self=yes
        [filter_self]
            [filter_location]
                terrain={VEGETATED_TERRAINS}
            [/filter_location]
        [/filter_self]
    [/regenerate]
#enddef


#textdomain wesnoth-Naia

#define AMLA_MENU
    [set_menu_item]
        id=amla_menu
        description= _ "Unit Advancements"
        image="icons/menu-advancements.png"
        synced=no

        [show_if]
            [have_unit]
                x,y=$x1,$y1
                lua_function="naia_amla_menu_check"
            [/have_unit]
        [/show_if]

        [command]
            [amla_list]
                x,y=$x1,$y1
            [/amla_list]
        [/command]
    [/set_menu_item]
#enddef

#define EFFECT_INCREASE_REQ_EXPERIENCE _AMOUNT
    [effect]
        apply_to=max_experience
        increase={_AMOUNT}
    [/effect]
#enddef

#define EFFECT_FULLHEAL
    [effect]
        apply_to=hitpoints
        heal_full=yes
    [/effect]
    [effect]
        apply_to=status
        remove=poisoned
    [/effect]
    [effect]
        apply_to=status
        remove=slowed
    [/effect]
#enddef

#define CHARACTER_AMLA _ID _REQUIRES _ICON _DESCRIPTION _EFFECTS
    [advancement]
        id={_ID}
        image={_ICON}
        require_amla={_REQUIRES}
        max_times=1
        major_amla=yes
        description={_DESCRIPTION}+" "+_"‹Max XP +15%›"

        {EFFECT_INCREASE_REQ_EXPERIENCE 15%}
        {EFFECT_FULLHEAL}

        {_EFFECTS}
    [/advancement]
#enddef

#define DISABLE_AMLA_WITH _EXCLUDE_LIST
    [+advancement]
        exclude_amla={_EXCLUDE_LIST}
    [/advancement]
#enddef

# This is an alternative version of the mainline AMLA that doesn't increase the
# overall XP requirement more than regular upgrade AMLAs, so as to prevent
# their XP pool from growing to the point it becomes impractical to keep
# leveling them up once the rest of the tree becomes available later on.
#define AMLA_VITALITY
    {CHARACTER_AMLA
    amla_vitality
    ()
    icons/amla-default.png ( _ "Vitality: hitpoints +3")
    (
        [effect]
            apply_to=hitpoints
            increase_total=3
            heal_full=yes
        [/effect]
    )}

    [+advancement]
        major_amla=no
        max_times=100
    [/advancement]
#enddef


#textdomain wesnoth-Naia

#define GENERIC_SWORD_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-175

        [frame]
            image={IMAGE}:350
        [/frame]

        {SOUND:HIT_AND_MISS {SOUND_LIST:SWORD_SWISH} {SOUND_LIST:MISS} -100}
    [/attack_anim]
#enddef

#define GENERIC_AXE_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-200

        [frame]
            image={IMAGE}:400
        [/frame]

        {SOUND:HIT_AND_MISS axe.ogg {SOUND_LIST:MISS} -100}
    [/attack_anim]
#enddef

#define GENERIC_SPEAR_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-175

        [frame]
            image={IMAGE}:325
            offset=0.0~0.1:75,0.1~0.9:100,0.9~0.0:125
        [/frame]

        {SOUND:HIT_AND_MISS spear.ogg spear-miss.ogg -75}
    [/attack_anim]
#enddef

#define GENERIC_CLUB_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-175

        [frame]
            image={IMAGE}:350
        [/frame]

        {SOUND:HIT_AND_MISS club.ogg {SOUND_LIST:MISS} -75}
    [/attack_anim]
#enddef

#define GENERIC_STAFF_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-125

        [frame]
            image={IMAGE}:300
        [/frame]

        {SOUND:HIT_AND_MISS staff.ogg staff-miss.ogg -125}
    [/attack_anim]
#enddef

#define GENERIC_MACE_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-175

        [frame]
            image={IMAGE}:350
        [/frame]

        {SOUND:HIT_AND_MISS mace.wav {SOUND_LIST:MISS} -75}
    [/attack_anim]
#enddef

#define GENERIC_FLAIL_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-225
        offset=0.0~0.8:225,0.8~0.0:175

        [frame]
            image={IMAGE}:400
        [/frame]

        {SOUND:HIT_AND_MISS flail.ogg flail-miss.ogg -125}
    [/attack_anim]
#enddef

#define GENERIC_BOW_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-350
        missile_start_time=-150

        [missile_frame]
            duration=150
            image="projectiles/missile-n.png"
            image_diagonal="projectiles/missile-ne.png"
        [/missile_frame]

        [frame]
            image={IMAGE}:500
        [/frame]

        {SOUND:HIT_AND_MISS bow.ogg bow-miss.ogg -225}
    [/attack_anim]
#enddef

#define GENERIC_JAVELIN_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-200
        missile_start_time=-150

        [missile_frame]
            duration=150
            image="projectiles/spear-n.png"
            image_diagonal="projectiles/spear-ne.png"
        [/missile_frame]

        [frame]
            image={IMAGE}:350
            sound={SOUND_LIST:THROW}
        [/frame]

        {SOUND:HIT spear.ogg 0}
    [/attack_anim]
#enddef

#define GENERIC_CROSSBOW_ANIM FILTER IMAGE
    [attack_anim]
        [filter_attack]
            {FILTER}
        [/filter_attack]

        start_time=-400
        missile_start_time=-150

        [missile_frame]
            duration=150
            image="projectiles/missile-n.png"
            image_diagonal="projectiles/missile-ne.png"
        [/missile_frame]

        [frame]
            image={IMAGE}:500
        [/frame]

        {SOUND:HIT_AND_MISS crossbow.ogg crossbow-miss.ogg -275}
    [/attack_anim]
#enddef

#define GENERIC_MOUNTED_SPEAR_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-250
        horse_sound_start_time=-250

        [frame]
            image={IMAGE}:400
            offset=0.0~0.1:150,0.1~0.9:100,0.9~0.0:150
        [/frame]

        [horse_sound_frame]
            sound=horse-canter.wav
        [/horse_sound_frame]

        {SOUND:HIT_AND_MISS spear.ogg spear-miss.ogg -75}
    [/attack_anim]
#enddef

#define GENERIC_MOUNTED_SWORD_ANIM NAME IMAGE
    [attack_anim]
        [filter_attack]
            name={NAME}
        [/filter_attack]

        start_time=-250
        horse_sound_start_time=-250

        [frame]
            image={IMAGE}:400
        [/frame]

        [horse_sound_frame]
            sound=horse-canter.wav
        [/horse_sound_frame]

        {SOUND:HIT_AND_MISS {SOUND_LIST:SWORD_SWISH} {SOUND_LIST:MISS} -100}
    [/attack_anim]
#enddef


#textdomain wesnoth-Naia

#define MISSILE_FRAME_ETHEREAL_BLAST
    missile_start_time=-50
    [missile_frame]
        image="projectiles/chaosmissile-n.png"
        image_diagonal="projectiles/chaosmissile-ne.png"
        halo="halo/chaos-halo[1~8,9].png:[25*8,50]"
        halo_x,halo_y=10,-2
    [/missile_frame]
#enddef

#define MISSILE_FRAME_ENERGY_SHOCK
    missile_start_time=-200
    [missile_frame]
        image="projectiles/energybeam-n.png"
        image_diagonal="projectiles/energybeam-ne.png"
        halo="halo/chaos-halo[1~8,9].png:[25*8,50]"
        halo_x,halo_y=10,-2
    [/missile_frame]
#enddef

#define MISSILE_FRAME_BOLAS
    missile_start_time=-150
    [missile_frame]
        duration=150
        image=projectiles/bolas-n.png
        image_diagonal=projectiles/bolas-ne.png
    [/missile_frame]
#enddef

#define MISSILE_FRAME_INFERNAL_CHILL
    missile_start_time=-150
    [missile_frame]
        duration=150
        image="projectiles/whitemissile-n.png"
        image_diagonal="projectiles/whitemissile-ne.png"
    [/missile_frame]
#enddef

#define MISSILE_FRAME_SLIME
    missile_start_time=-150
    [missile_frame]
        duration=150
        image="projectiles/slime-glob.png"
        image_diagonal="projectiles/slime-glob.png"
    [/missile_frame]
#enddef

#define MELEE_FRAME_FIRE_AURA _MELEE_FRAME _BASE_FRAME _SOUND
    start_time=-150
    [if]
        hits=no
        [frame]
            duration=50
            image={_BASE_FRAME}
        [/frame]
        [frame]
            duration=200
            image={_MELEE_FRAME}
            sound={SOUND_LIST:MISS}
        [/frame]
        [frame]
            duration=200
            image={_BASE_FRAME}
        [/frame]
    [/if]
    [else]
        hits=yes
        [frame]
            duration=50
            halo=projectiles/fire-burst-small-1.png
            image={_BASE_FRAME}
            sound={_SOUND}
        [/frame]
        [frame]
            halo="projectiles/fire-burst-small-[1~4].png:50"
            image={_MELEE_FRAME}
        [/frame]
        [frame]
            halo="projectiles/fire-burst-small-[5~8].png:50"
            image={_BASE_FRAME}
        [/frame]
    [/else]
#enddef

#define BURST_FRAME_FAERIE_MYSTIC_FIRE
    burst_start_time=0
    burst_offset=0.8~1.0

    [burst_frame][/burst_frame]
    [burst_frame]
        image="projectiles/fire-burst-small-[1~8].png:75"
    [/burst_frame]
#enddef

#define MISSILE_FRAME_FAERIE_MYSTIC_FIRE
    specialfx_auto_vflip=false
    specialfx_start_time=-331

    [specialfx_frame]
        halo="halo/saurian-magic-halo-[1~7].png:50"
    [/specialfx_frame]

    {MISSILE_FRAME_FIRE_BREATH 12,-39 12,19 25,-26 27,19}
#enddef

# _RIMG : reaction frame image
# _BIMG : base frame image
# _RSND : hit sound/soundlist
#define FLYING_DEFENSE_ANIM _RIMG _BIMG _RSND
    [defend]
        [if]
            hits=miss
            offset=0.0~-0.15,-0.15~0.0
        [/if]
        start_time=-126
        [frame]
            duration=1
            image={_BIMG}
        [/frame]
        [frame]
            duration=100
            image={_RIMG}
        [/frame]
        [if]
            hits=hit
            [frame]
                duration=150
                image={_RIMG}
                sound={_RSND}
            [/frame]
        [/if]
        [else]
            hits=miss,kill
            [frame]
                duration=150
                image={_RIMG}
            [/frame]
        [/else]
        [frame]
            duration=1
            image={_BIMG}
        [/frame]
    [/defend]
#enddef

#define MISSILE_FRAME_TORPEDO
    missile_start_time=-150
    [missile_frame]
        duration=150
        image="projectiles/flash-cannon-n.png"
        image_diagonal="projectiles/flash-cannon-ne.png"
    [/missile_frame]
#enddef

#define NOCTUM_BEAM_ANIMATION
    offset=0.0

    beam_auto_vflip=no
    beam_start_time=-400
    beam_offset=1.0
    beam_halo_y=20

    beam_halo_mod="~O(0.8)"

    [beam_frame]
        halo="halo/darkness-beam-[1~7,6~1].png:[30*6,130,70*6]"
    [/beam_frame]
#enddef

#define BOSS_EXPLOSION_FRAME _NUM _START_TIME _X _Y
    explosion_{_NUM}_start_time={_START_TIME}
    explosion_{_NUM}_auto_hflip=no
    explosion_{_NUM}_auto_vflip=no
    [explosion_{_NUM}_frame]
        halo="projectiles/fireball-impact-[1,1~16].png:50"
        halo_x,halo_y={_X},{_Y}
    [/explosion_{_NUM}_frame]
#enddef

#define BOSS_BURST_FRAME _NUM _START_TIME _X _Y
    flame_burst_{_NUM}_start_time={_START_TIME}
    flame_burst_{_NUM}_auto_hflip=no
    flame_burst_{_NUM}_auto_vflip=no
    [flame_burst_{_NUM}_frame]
        halo="halo/flame-burst-[1~8].png:100"
        halo_x,halo_y={_X},{_Y}
    [/flame_burst_{_NUM}_frame]
#enddef

#define BOSS_BURST_FRAME_IMAGE_MOD _NUM _MOD
    flame_burst_{_NUM}_halo_mod={_MOD}
#enddef


#textdomain wesnoth-Naia

# The pop-up message that appears when the players encounters
# an enemy boss in the RPG scenarios. Made it a macro to keep it easier
# to modify across the entire campaign.
#define BOSS_POPUP
    [print]
        text= _ "Enemy boss sighted!"
        red,green,blue=255,127,0
        size=32
        duration=1500
    [/print]
#enddef

#define BOSS_MUSIC
    [music]
        name=vengeful.ogg
        immediate=yes
        append=no
    [/music]
    [music]
        name=ambuscade.ogg
        immediate=yes
        play_once=yes
    [/music]
#enddef

#define BOSS_AMBIENTANCE
    {BOSS_MUSIC}

    {BOSS_POPUP}
#enddef

#define BOSS_AMBIENTANCE_LOOPING
    {REPLACE_SCENARIO_MUSIC "ambuscade-loop.ogg"}
    {INCIDENTAL_MUSIC       "ambuscade-begin.ogg"}

    {BOSS_POPUP}
#enddef

#define BOSS_UNIT_OVERLAY
    overlays=misc/boss-icon.png
#enddef

#define IS_BOSS
    {BOSS_UNIT_OVERLAY}
    random_traits=no
#enddef

#define BOSS_BOOST _HITPOINTS_INCREASE _MELEE_DMG_INCREASE _MELEE_STRIKES_INCREASE _RANGED_DMG_INCREASE _RANGED_STRIKES_INCREASE
    [object]
        silent=yes
        [effect]
            apply_to=hitpoints
            increase_total={_HITPOINTS_INCREASE}
        [/effect]
        [effect]
            apply_to=attack
            range=melee
            increase_damage={_MELEE_DMG_INCREASE}
            increase_attacks={_MELEE_STRIKES_INCREASE}
        [/effect]
        [effect]
            apply_to=attack
            range=ranged
            increase_damage={_RANGED_DMG_INCREASE}
            increase_attacks={_RANGED_STRIKES_INCREASE}
        [/effect]
    [/object]
#enddef


#textdomain wesnoth-Naia

#define FULLSCREEN_CUTSCENE_UI
    theme=Cutscene_Minimal
#enddef

#define CUTSCENE_UI
    theme=Cutscene
#enddef

#define SET_THEME _THEME
    [change_theme]
        {_THEME}
    [/change_theme]
#enddef

#define RESET_THEME
    [change_theme][/change_theme]
#enddef

#define CLEAR_LABELS
    [clear_map_labels][/clear_map_labels]
#enddef

# Macro to remove a custom context menu item.

#define REMOVE_MENU_ITEM _ID
    [clear_menu_item]
        id={_ID}
    [/clear_menu_item]
#enddef

# Lock/unlock user-driven viewport scrolling with the keyboard
# or mouse (i.e. for cutscenes).

#define LOCK_VIEW
    [lock_view][/lock_view]
#enddef

#define UNLOCK_VIEW
    [unlock_view][/unlock_view]
#enddef

#
# Turns a view scrolling action into an instantaneous warp. It
# should be included within the scrolling action WML node.
#

#define WARP
    immediate=yes
#enddef


#textdomain wesnoth-Naia

#define ITEM_GOAL _X _Y
    [item]
        # The ~NOP() image function is intended as a tag to prevent other stacked
        # blank-hex items on the same hex from being removed by ITEM_REMOVE_GOAL.
        image="misc/blank-hex.png~NOP()"
        halo="misc/goal-highlight.png:1500,misc/blank-hex.png:1500"
        x={_X}
        y={_Y}
    [/item]
#enddef

#define ITEM_REMOVE_GOAL _X _Y
    [remove_item]
        image="misc/blank-hex.png~NOP()"
        x={_X}
        y={_Y}
    [/remove_item]
#enddef

#define ITEM_TOUCHPLATE _X _Y
#arg COLOR
brightgreen #endarg
    [item]
        x={_X}
        y={_Y}
        halo="items/touchplate.png~RC(ellipse_red>"+{COLOR}+")~O([5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100]%):[1600,10*18,640],items/touchplate.png~RC(ellipse_red>"+{COLOR}+")~O([95,90,85,80,75,70,65,60,55,50,45,40,35,30,25,20,15,10]%):[10*18]"
    [/item]
#enddef

# Shared graphics declaration for a crystal glyph that does nothing; use OBJ_*_GLYPH macros
# if you want an interactive object, instead.

# wmlindent: start ignoring
#define _NAIA_CRYSTAL_GLYPH_HALO
halo/glyph-halo.png~O(0.[4,48,54,48]):[500,200*3] #enddef
# wmlindent: stop ignoring

#define ITEM_CRYSTAL_GLYPH _X _Y
    [item]
        x={_X}
        y={_Y}
        image=items/crystal-glyph.png
        halo={_NAIA_CRYSTAL_GLYPH_HALO}
    [/item]
#enddef
#define ITEM_CRYSTAL_GLYPH_POWERUP _X _Y
    [item]
        x={_X}
        y={_Y}
        image=items/crystal-glyph-powerup.png
        halo={_NAIA_CRYSTAL_GLYPH_HALO}
    [/item]
#enddef
#define ITEM_CRYSTAL_GLYPH_MESSAGE _X _Y
    [item]
        x={_X}
        y={_Y}
        image=items/crystal-glyph-message.png
        halo={_NAIA_CRYSTAL_GLYPH_HALO}
    [/item]
#enddef
#define ITEM_CRYSTAL_GLYPH_GATE _X _Y
    [item]
        x={_X}
        y={_Y}
        image=items/crystal-glyph-gate.png
        halo={_NAIA_CRYSTAL_GLYPH_HALO}
    [/item]
#enddef

#define MSG_GLYPH _MESSAGE
    [message]
        speaker=narrator
        image=items/crystal-glyph-message.png
        caption= _ "Crystal Glyph"
        message={_MESSAGE} # wmllint: ignore
    [/message]
#enddef

# wmllint: local spelling unslowed

#define OBJ_HEALING_GLYPH _X _Y
#arg CONDITIONS
#endarg

    {ITEM_CRYSTAL_GLYPH {_X} {_Y} }

    [event]
        id=OBJ_HEALING_GLYPH_prestart_control_eh
        name=prestart

        {VARIABLE OBJ_HEALING_GLYPH_verbose yes}
    [/event]

    [event]
        id=OBJ_HEALING_GLYPH_victory_control_eh
        name=victory

        {CLEAR_VARIABLE OBJ_HEALING_GLYPH_verbose}
    [/event]

    [event]
        id="OBJ_HEALING_GLYPH_impl_"+{_X}+"_"+{_Y} # wmllint: ignore
        name=moveto
        first_time_only=no
        [filter]
            side=1
            x={_X}
            y={_Y}
        [/filter]
        [filter_condition]
            {CONDITIONS}
        [/filter_condition]

        [redraw][/redraw]

        [if]
            [variable]
                name=OBJ_HEALING_GLYPH_verbose
                boolean_equals=yes
            [/variable]
            #
            # Using a macro here so wmllint stops trying to remove the translation marks
            #
            [then]
                {VARIABLE temp_OBJ_HEALING_GLYPH_msg (_"Do you wish to be healed?"+"

"+_"This magic glyph will completely restore this unit’s health. It will also unslow and cure it of poison, if applicable."+"

"+
                _"Note: this glyph may be used only once; afterwards, it will fade out."+"")}
                {VARIABLE OBJ_HEALING_GLYPH_verbose no}
            [/then]
            [else]
                {VARIABLE temp_OBJ_HEALING_GLYPH_msg (_"Do you wish to be healed?"+"

"+
                _"Note: this glyph may be used only once; afterwards it will fade out."+"")}
            [/else]
        [/if]

        [message]
            speaker=narrator
            caption= _ "Crystal Glyph of Health"
            image=items/crystal-glyph.png
            message=$temp_OBJ_HEALING_GLYPH_msg
            [option]
                label={I18N:YES}
                [command]
                    [remove_item]
                        x,y=$x1,$y1
                    [/remove_item]

                    [remove_terrain_overlays]
                        x,y=$x1,$y1
                    [/remove_terrain_overlays]

                    [heal_unit]
                        [filter]
                            x,y=$x1,$y1
                        [/filter]
                        amount="full"
                        animate=yes
                        restore_statuses=yes
                    [/heal_unit]

                    [sound]
                        name=heal.wav
                    [/sound]

                    [set_variables]
                        mode=merge
                        name=unit
                        [literal]
                            moves=0
                        [/literal]
                    [/set_variables]

                    [unstore_unit]
                        variable=unit
                        male_text= _ "healed"
                        female_text= _ "female^healed"
                        {COLOR_HEAL}
                    [/unstore_unit]

                    [redraw][/redraw]

                    [remove_event]
                        id="OBJ_HEALING_GLYPH_impl_"+{_X}+"_"+{_Y} # wmllint: ignore
                    [/remove_event]

                    [transient_message]
                        caption= _ "Crystal Glyph of Health"
                        image=items/crystal-glyph.png
                        message= _ "The unit is fully healed, cured and unslowed."
                    [/transient_message]
                [/command]
            [/option]
            [option]
                label={I18N:NO}
                [command]
                    [allow_undo][/allow_undo]
                [/command]
            [/option]
        [/message]

        {CLEAR_VARIABLE temp_OBJ_HEALING_GLYPH_msg}
    [/event]
#enddef

#define GATE_GLYPH_ACTIONS _TARGET_X _TARGET_Y
    [redraw][/redraw]

    [message]
        speaker=narrator
        image="items/crystal-glyph-gate.png"
        sound="magic-3.ogg"
        message= _ "Access granted."
    [/message]

    [remove_item]
        x,y=$x1,$y1
    [/remove_item]

    {REMOVE_EVENT_BARRIER ("*^Zz\,*^Zz/,*^Zz|") ({_TARGET_X}) ({_TARGET_Y})}
#enddef

#define GATE_GLYPH _GLYPH_X _GLYPH_Y _TARGET_X _TARGET_Y
    {ITEM_CRYSTAL_GLYPH_GATE ({_GLYPH_X}) ({_GLYPH_Y})}

    [event]
        name=moveto
        [filter]
            side=1
            x={_GLYPH_X}
            y={_GLYPH_Y}
        [/filter]

        {LOCK_VIEW}

        {GATE_GLYPH_ACTIONS ({_TARGET_X}) ({_TARGET_Y})}

        {UNLOCK_VIEW}
    [/event]
#enddef

# wmllint: markcheck off
# wmllint: display on

#define PICK_UP _IMG _X _Y _CAN_USE_SUF _FOUND_MSG _CANNOT_USE_MSG _OBJECT_CODE_AND_ACTIONS
#arg PLAYER_SIDES
    1
#endarg
#arg ITEM_SOUND
#endarg
#arg REMOVE_MAP_ITEM
    yes
#endarg

    [item]
        image={_IMG}
        x={_X}
        y={_Y}
    [/item]

    [event]
        id="PICK_UP:"+{_X}+"_"+{_Y}
        name=moveto
        first_time_only=no
        [filter]
            side={PLAYER_SIDES}
            x={_X}
            y={_Y}
        [/filter]

        [message]
            speaker=unit
            {UNIT_SPEAKS_FOR_UNDEAD_MINION (
                side=$unit.side
                canrecruit=yes
            )}
            scroll=no
            message={_FOUND_MSG}
        [/message]

        [if]
            [have_unit]
                {_CAN_USE_SUF}
                x,y=$x1,$y1
            [/have_unit]
            [else]
                [message]
                    speaker=unit
                    {UNIT_SPEAKS_FOR_UNDEAD_MINION (
                        side=$unit.side
                        canrecruit=yes
                    )}
                    scroll=no
                    message={_CANNOT_USE_MSG}
                [/message]

                [return][/return]
            [/else]
        [/if]

        [item_prompt]
            sound={ITEM_SOUND}
            [then]
                {_OBJECT_CODE_AND_ACTIONS}

                {VARIABLE temp_PU_remove_map_item {REMOVE_MAP_ITEM}}

                [if]
                    {VARIABLE_BOOLEAN_EQUALS temp_PU_remove_map_item yes}
                    [then]
                        [remove_item]
                            x,y=$x1,$y1
                        [/remove_item]
                    [/then]
                [/if]

                {CLEAR_VARIABLE temp_PU_remove_map_item}

                #
                # Never run this handler again.
                #

                [remove_event]
                    id="PICK_UP:"+{_X}+"_"+{_Y}
                [/remove_event]
            [/then]
        [/item_prompt]
    [/event]
#enddef

# wmllint: display off
# wmllint: markcheck on


#textdomain wesnoth-Naia

#define OBJECTIVES _OBJECTIVES
    [objectives]
        side=1
        {_OBJECTIVES}
    [/objectives]
#enddef

#define OBJECTIVE_VICTORY _TEXT
    [objective]
        description={_TEXT}
        condition=win
    [/objective]
#enddef

#define OBJECTIVE_VICTORY_END_OF_TURNS
    [objective]
        description= _ "Resist until the end of turns"
        condition=win
        show_turn_counter=yes
    [/objective]
#enddef

#define OBJECTIVE_DEFEAT _TEXT
    [objective]
        description={_TEXT}
        condition=lose
    [/objective]
#enddef

#define OBJECTIVE_OPTIONAL _TEXT
    [objective]
        {ALTERNATIVE_OBJECTIVE_CAPTION}
        description={_TEXT} # wmllint: ignore
        condition=win
    [/objective]
#enddef

#define OBJECTIVE_SHOW_IF _COND
    [+objective]
        [show_if]
            {_COND}
        [/show_if]
    [/objective]
#enddef

#define OBJECTIVE_CARRYOVER
    [gold_carryover]
        bonus,carryover_percentage=yes,40
    [/gold_carryover]
#enddef

#define OBJECTIVE_CARRYOVER_SHOW_IF _COND
    [+gold_carryover]
        [show_if]
            {_COND}
        [/show_if]
    [/gold_carryover]
#enddef

#define OBJECTIVE_CARRYOVER_NO_BONUS
    [gold_carryover]
        bonus,carryover_percentage=no,40
    [/gold_carryover]
#enddef

#define OBJECTIVE_NO_CARRYOVER
    [gold_carryover]
        bonus,carryover_percentage=no,0
    [/gold_carryover]
#enddef

#define OBJECTIVE_FULL_CARRYOVER
    [gold_carryover]
        bonus,carryover_percentage=no,100
    [/gold_carryover]
#enddef

#define OBJECTIVE_NOTE _TEXT
    [note]
        description={_TEXT}
    [/note]
#enddef

#define OBJECTIVE_NOTE_SHOW_IF _COND
    [+note]
        [show_if]
            {_COND}
        [/show_if]
    [/note]
#enddef

#define NO_UNIT_CARRYOVER_NOTE
    {OBJECTIVE_NOTE ( _ "You will not be able to recall any units from this scenario later")}
#enddef


#textdomain wesnoth-Naia
#
# Lua versions of mainline WML macros to reduce the campaign's WML footprint
# (memory and disk usage).
#
# See lua/optimizations.lua.
#

#undef QUAKE
#define QUAKE _SOUND
    [quake]
        sound={_SOUND}
    [/quake]
#enddef

#undef FADE_TO_BLACK
#define FADE_TO_BLACK
    [fade_to_black][/fade_to_black]
#enddef

#undef FADE_IN
#define FADE_IN
    [fade_in][/fade_in]
#enddef


#textdomain wesnoth-Naia

#ifver WESNOTH_VERSION >= 1.15.0

#undef SPECIAL_NOTES
#textdomain wesnoth-help
#define SPECIAL_NOTES
    "

"+_"Special Notes:"#enddef
#textdomain wesnoth-Naia

#endif