ForestDragon's WML questions

The place to post your WML questions and answers.

Moderators: Forum Moderators, Developers

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
Post Reply
User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » March 28th, 2017, 4:37 pm

Ravana wrote:Do not modify unit before unstoring it.
thanks!
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » March 28th, 2017, 5:51 pm

some more progress:
the 'previously imprisoned unit are revived when activating the menu' bug doesn't appear anymore, and the free unit menu gives back ZoC, but it doesn't change max_moves for some reason, which is currently the main problem, in my opinion.

Code: Select all

[modification]
    id=Imprisonment_Mod
    name="Imprisonment/Capture Mod"
    description="allows players to imprison/capture enemy units if there are at least 2 units next to the enemy (the amount is customizable)

there are multiple ways to imprison units: 

cage: doesn't allow movement/attacking, decreases defense on all terrain by 20%, removes ZoC, but allows retaliation. costs <4 multiplied by unit level> gold

shackles (not implemented): disallows attacking and allows the unit to be dragged, but allows retaliation/movement. costs <2 multiplied by unit level> gold

spirit bind (not implemented): unit can move/attack/etc. freely, but is unable to move farther than a certain range from a unit it's bound to.

made by ForestDragon."
    require_modification=no
     [event]
    # is used to show icon in status bar
         name=preload
         first_time_only=no
         id=show_imprisoned
         [lua]
             code=<<
                 local _ = wesnoth.textdomain "wesnoth-imprisoned"
                 local old_unit_status = wesnoth.theme_items.unit_status
                 function wesnoth.theme_items.unit_status()
                     local u = wesnoth.get_displayed_unit()
                     if not u then return {} end
                     local s = old_unit_status()
                     if u.status.imprisoned then
                         table.insert(s, { "element", {
                             image = "items/cage.png~SCALE(20,20)",
                             tooltip = _"imprisoned: This unit is imprisoned. It cannot move, or attack, has no ZoC, and it's defense on all mainline types of terrain is reduced by 20, but the unit can still retaliate"
                         } })
                     end
                     return s
                 end
             >>
         [/lua]
    [/event]
[event]
  name=prestart
  [set_menu_item]
    id=imprison
    description="Imprison unit"
    image=items/cage.png~SCALE(20,20)
#    image=".png"
#    [default_hotkey]
#      key="~"
#    [/default_hotkey]
	[show_if]
		[have_unit]
#                    [filter_adjacent]
#                       side=$side_number
#                       amount=2-6
#                    [/filter_adjacent]
                    [filter_wml]
                     [not]
                      [status]
                        imprisoned=yes
                      [/status]
                     [/not]
                    [/filter_wml]
                [filter_side]
                    [enemy_of]
                        side=$side_number
                    [/enemy_of]
                [/filter_side]
                        x=$x1
                        y=$y1
		[/have_unit]
		[have_unit]
                    [filter_location]
                        x=$x1
                        y=$y1
                        radius=1
                    [/filter_location]
                       side=$side_number
                       amount=2-6
		[/have_unit]
        [/show_if]		    
    [command]
	[message]
		speaker=narrator
		image=portraits/tomb-guardian.png
		caption="Imprisonment"
                message="How do you want to imprison this enemy?"
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Return To Game"}
			[command]
#    {EXP_UNSTORE}
                         [/command]
		[/option]
                [option]
                        
			message=  {MENU_IMG_TXT "items/cage.png" "Cage"}
			[command]
                                    [unit_overlay]
                                        x,y=$x1,$y1
                                        image=items/cage.png
                                    [/unit_overlay]
		[store_unit]
		    [filter]
		       x=$x1
		       y=$y1
		     [/filter]
		     kill=no
		     variable=unit
		[/store_unit]
        [modify_unit]
            [filter]
               x,y=$x1,$y1
            [/filter]
            [status]
                imprisoned=yes
            [/status]
        [/modify_unit]
        [set_variable]
           name=[$unit.id]_max_moves
           value=$unit.max_moves
        [/set_variable]
        [set_variable]
           name=[$unit.id]_zoc
           value=$unit.zoc
        [/set_variable]
        [object]
            silent=yes
#            duration=turn
            [filter]
                find_in=unit
            [/filter]
            [effect]
                apply_to=attack
                attack_weight=0.0
            [/effect]
           [effect]
                apply_to=movement
                set=0
            [/effect]
            [effect]
                apply_to=zoc
                value=no
            [/effect]
                    [effect]
                        apply_to=defense
			replace=no
		      [defense]
			deep_water=20
        		shallow_water=20
        		swamp_water=20
        		reef=20
        		flat=20
        		sand=20
        		forest=20
        		hills=20
        		mountains=20
        		village=20
        		castle=20
        		cave=20
        		frozen=20
        		unwalkable=20
        		fungus=20
		      [/defense]
                    [/effect]
        [/object]
        [unstore_unit]
            variable=impunit
	    text="captured"
            {COLOR_HARM}
            find_vacant=no
        [/unstore_unit]
                         [/command]
		[/option]
	[/message]            
    [/command]    
  [/set_menu_item]  
  [set_menu_item]
    id=free
    description="free unit"
#    image=".png"
#    [default_hotkey]
#      key="~"
#    [/default_hotkey]
	[show_if]
		[have_unit]
                    [filter_adjacent]
                       side=$side_number
                    [/filter_adjacent]
                    [filter_wml]
                      [status]
                        imprisoned=yes
                      [/status]
                    [/filter_wml]
                        x=$x1
                        y=$y1
                [/have_unit]
        [/show_if]		    
    [command]
            [modify_unit]
              [filter]
                 x,y=$x1,$y1
              [/filter]
              [status]
                imprisoned=no
              [/status]
            [/modify_unit]
            [object]
                silent=yes
                sort=potion-like
                [filter]
                   find_in=unit
                [/filter]
            [effect]
                apply_to=attack
                attack_weight=1
            [/effect]
                    [effect]
                        apply_to=defense
			replace=no
		      [defense]
			deep_water=-20
        		shallow_water=-20
        		swamp_water=-20
        		reef=-20
        		flat=-20
        		sand=-20
        		forest=-20
        		hills=-20
        		mountains=-20
        		village=-20
        		castle=-20
        		cave=-20
        		frozen=-20
        		unwalkable=-20
        		fungus=-20
		      [/defense]
                    [/effect]
#            [effect]
#                apply_to=movement
#                set=$[$impunit.id]_max_moves|
#            [/effect]
#            [effect]
#                apply_to=zoc
#                set=$[$impunit.id]_zoc|
#            [/effect]
            [/object]
		[store_unit]
			[filter]
                            x,y=$x1,$y1
			[/filter]
			variable=unit
                        kill=no
                [/store_unit]
          {VARIABLE unit.zoc $[$unit.id]_zoc|}
          {VARIABLE unit.max_moves $[$unit.id]_max_moves|}
          {VARIABLE unit.moves $[$unit.id]_max_moves|}
    	  {CLEAR_VARIABLE [$unit.id]_max_moves}
	  {CLEAR_VARIABLE [$unit.id]_zoc}
        [unstore_unit]
            variable=unit
	    text="free"
            {COLOR_HEAL}
            find_vacant=no
        [/unstore_unit]
                                    [remove_unit_overlay]
                                        x,y=$x1,$y1
                                        image=items/cage.png
                                    [/remove_unit_overlay]
    [/command]    
  [/set_menu_item]  
[/event]
[/modification]
EDIT: made the unit filter actually work
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » March 28th, 2017, 6:58 pm

the 'previously imprisoned unit are revived when activating the menu' bug doesn't appear anymore
Well yes, you removed the part where you assigned the variable that was unstored. Now you unstore undefined variable.
but it doesn't change max_moves for some reason, which is currently the main problem, in my opinion.
Yes, zookeeper already addressed that part.

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » March 28th, 2017, 7:00 pm

Ravana wrote:Yes, zookeeper already addressed that part.
not quite. I still don't know what to do.
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

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

Re: ForestDragon's WML questions

Post by Ravana » March 28th, 2017, 7:14 pm

Even if WML syntax allowed what you have written there, it would result in invalid saves.

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » March 29th, 2017, 6:29 am

i fixed the filter issue, and managed to work around the movement recovery issue by adding 99 to unit's movement costs. case closed.
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 29th, 2017, 3:25 pm

ok, so, here are a few questions I have:

1.I want to store randomly 1 unit out of multiple.
2.How to add a filter (or something similar with variables) to check if a variable doesn't exist?
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
Sapient
Inactive Developer
Posts: 4453
Joined: November 26th, 2005, 7:41 am
Contact:

Re: ForestDragon's WML questions

Post by Sapient » June 29th, 2017, 3:50 pm

ForestDragon wrote: 1.I want to store randomly 1 unit out of multiple.

Code: Select all

   # assuming $multiple_units.length > 0
  {RANDOM "0..$($multiple_units.length-1)"}
  [set_variables]
    name=single_unit
    to_variable=multiple_units[$random]
  [/set_variables]
ForestDragon wrote: 2.How to add a filter (or something similar with variables) to check if a variable doesn't exist?

Code: Select all

  [filter_condition]
    [variable]
      name=my_variable
      equals=$empty
    [/variable]
  [/filter_condition]
http://www.wesnoth.org/wiki/User:Sapient... "Looks like your skills saved us again. Uh, well at least, they saved Soarin's apple pie."

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » June 29th, 2017, 4:16 pm

thanks!
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » October 29th, 2017, 6:18 pm

Ok, I'm back here. So, the current question is, how to filter whether a unit is resting or not?
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
Argesilao
Posts: 58
Joined: August 28th, 2016, 7:29 pm
Location: Here

Re: ForestDragon's WML questions

Post by Argesilao » October 29th, 2017, 7:38 pm

There is a Unit State value called resting

resting: whether the unit has not moved yet this turn. Used to decide whether to give the unit rest healing. Note that this can be true even if moves is not equal to max_moves.

So I think you can use it inside a filter_wml tag

You can find more information at:

https://wiki.wesnoth.org/SingleUnitWML
Author and Maintainer of the unofficial campaigns: A Little Adventure, A Magicians Tale, The Three Sisters Saga, Epic Between the Tides

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » October 29th, 2017, 7:39 pm

ok, thanks!
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » November 25th, 2017, 6:35 pm

ok, so, another WML question: while porting XP Bank to 1.13.10, the $exp_stored_[$side_number]| variable seems to no longer appear. does anyone happen to know due to which changes in the 1.13.x series has part of my code become obsolete? oh, and here's the file:

Code: Select all

[modification]
    id=XP_Bank_Mod
    name="XP Bank Mod"
    description="allows players to deposit xp from units, storing it into thier XP bank, and give it to other units, it is useful for quickly leveling up units, take back the experience wasted by high-level units, and when an experienced unit is about to die.

made by ForestDragon."
    require_modification=no
    type=hybrid
    [options]
#        [checkbox]
#            id=XP_bank_loot_enabled
#            default=no
#            name="XP bank looting enabled"
#            description="When killing an enemy , the killer's side get a percentage of the defeated unit's exp as stored exp for themselves."
#        [/checkbox]
#        [checkbox]
#            id=XP_bank_loot_enabled
#            default=no
#            name="XP bank prevent almost defeated side to defy"
#            description="players cannot deposit/withdraw exp while there is an enemy unit next to their leader, mostly to prevent players that are about to lose from being able to give it all to their units, thus having the victorious side gain nothing"
#        [/checkbox]
#        [slider]
#            id=XP_bank_loot
#            default=50
#            min=0
#            max=100
#            step=25
#            name="XP bank looting"
#            description="The percentage of XP stolen."
#        [/slider]
        [checkbox]
            id=XP_bank_advance_filter
            default=no
            name="XP bank: is advancement filter enabled by default?"
            description="whether the option of choosing between advancing a unit and storing all of his experience is turned on by default."
        [/checkbox]
        [slider]
            id=XP_bank_start
            default=0
            min=0
            max=100
            step=10
            name="XP bank head-start"
            description="you get some exp in your bank at the beginning."
        [/slider]
    [/options]
[event]
#  id=bankstart
  name=prestart
	[if]
	    [variable]
                name=exp_assigned
                not_equals=yes
            [/variable]
            [then]
        {VARIABLE exp_stored_[1] $XP_bank_start}
        {VARIABLE exp_stored_[2] $XP_bank_start}
        {VARIABLE exp_stored_[3] $XP_bank_start}
        {VARIABLE exp_stored_[4] $XP_bank_start}
        {VARIABLE exp_stored_[5] $XP_bank_start}
        {VARIABLE exp_stored_[6] $XP_bank_start}
        {VARIABLE exp_stored_[7] $XP_bank_start}
        {VARIABLE exp_stored_[8] $XP_bank_start}
        {VARIABLE exp_stored_[9] $XP_bank_start}
        {VARIABLE advance_filter_[1] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[2] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[3] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[4] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[5] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[6] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[7] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[8] $XP_bank_advance_filter}
        {VARIABLE advance_filter_[9] $XP_bank_advance_filter}
[set_variable]
 name=exp_assigned
 value=yes
[/set_variable]
            [/then]
            [else]
            [/else]
         [/if]
#        [if]
#            [variable]
#                name=XP_bank_loot_enabled
#                equals=yes
#            [/variable]
#            [then]
#                                    [set_variable]
#                                        name=lootable
#                                        add=1
#                                    [/set_variable]
#
#            [/then]
#        [/if]  
  [set_menu_item]
    id=xpbank
    description="XP bank"
#    image=".png"
#    [default_hotkey]
#      key="~"
#    [/default_hotkey]
	[show_if]
		[have_unit]
                        x=$x1
                        y=$y1
			side=$side_number
		[/have_unit]
           [and]
             [not]
            [have_unit]	
                [filter_side]
                    [enemy_of]
                        side=$side_number
                    [/enemy_of]
                [/filter_side]
                [filter_location]
                x="$x1"
                y="$y1"
                radius=1
                [/filter_location]
                count=2-6
            [/have_unit]
             [/not]
           [/and]
        [/show_if]		    
    [command]
		[store_unit]
			[filter]
                            x,y=$x1,$y1
			[/filter]
			variable=exp_unit
		[/store_unit]
#    {EXP_STORE}
#[set_variable]
#  name=exp_stored_[$side_number]
# value=$exp_stored_$side_number
# value=exp_stored_$side_number
#[/set_variable]
	[message]
		speaker=narrator
		image=portraits/tomb-guardian.png
		caption="XP bank"
                message="you have currently $exp_stored_[$side_number]| exp stored in the bank."
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Return To Game"}
			[command]
#    {EXP_UNSTORE}
                         [/command]
		[/option]
                [option]
                        
			message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "Deposit from this unit"}
			[command]
          [message]
            speaker=narrator
            image=portraits/tomb-guardian.png
            caption="XP bank"
#            image="items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)"
            message="Type in the amount of exp to deposit, type 0 if you dont want to deposit any exp from this unit. there is currently $exp_stored_[$side_number]| exp in the bank. this unit currently has $exp_unit.experience| experience. (note: if you type in more xp than the unit has, nothing will happen)"
            
            [text_input]
              variable=exp_deposit
            [/text_input]
          [/message]                         
	[if]
	    [variable]
                name=exp_deposit
                greater_than=0
            [/variable]
            [and]
	    [variable]
                name=exp_deposit
                less_than_equal_to=$exp_unit.experience
            [/variable]
            [/and]
            [then]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
[set_variable]
 name=exp_stored_[$side_number]
 add=$exp_deposit
[/set_variable]
                [modify_unit]
                      [filter]
			x,y=$x1,$y1
                      [/filter]
                      experience="$($exp_unit.experience - $exp_deposit)"
                [/modify_unit]
#    {EXP_UNSTORE}
            [/then]
	[else]
#	    [variable]
#                name=exp_deposit
#                greater_than=$exp_unit.experience
#            [/variable]
#            [then]
#	[message]            
#            speaker=narrator
#            image=portraits/tomb-guardian.png
#            caption="XP bank"
#            message="sorry, but this unit doesn't have this much exp."
#	[/message]            
#    {EXP_UNSTORE}
#            [/then]
	[/else]                                            
#	[else]
#	[/else]                                            
	[/if]                                            
                         [/command]
		[/option]
                  [option]
               message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "Deposit All"}
               [command]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
                       [delay]
                         time=75
                       [/delay]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
                       [delay]
                         time=75
                       [/delay]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
                       [delay]
                         time=75
                       [/delay]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
                       [delay]
                         time=75
                       [/delay]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
                       [delay]
                         time=75
                       [/delay]
                  [store_unit]
                     [filter]
                        side=$side_number
             [not]
             [filter_adjacent]	
                [filter_side]
                    [enemy_of]
                        side=$side_number
                    [/enemy_of]
                [/filter_side]
                count=2-6
             [/filter_adjacent]
             [/not]
                     [/filter]
                     variable=exp_drained_unit
                  [/store_unit]
                  {FOREACH exp_drained_unit i}
                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit[$i].experience"
                  [/set_variable]
                  {VARIABLE exp_drained_unit[$i].experience 0}
                  [unstore_unit]
                     variable=exp_drained_unit[$i]
                     find_vacant=no
                  [/unstore_unit]
                  {NEXT i}
                  {CLEAR_VARIABLE exp_drained_unit}
               [/command]
            [/option]
	                [option]                        
			message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "Withdraw"}
			[command]
          [message]
            speaker=narrator
            image=portraits/tomb-guardian.png
            caption="XP bank"
#            image="items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)"
            message="Type in the amount of exp to withdraw, type 0 if you dont want to withdraw exp to this unit. there is currently $exp_stored_[$side_number]| exp in the bank (note: if you type in more xp than there is in the bank, nothing will happen)"
            
            [text_input]
              variable=exp_withdraw
            [/text_input]
            
          [/message]
          
	[if]
	    [variable]
                name=exp_withdraw
                greater_than=0
            [/variable]
            [and]
            [not]
	    [variable]
                name=exp_withdraw
                greater_than=$exp_stored_[$side_number]
            [/variable]
            [/not]
            [/and]
            [then]
                     [sound]
			name=magic-holy-1.ogg
		       [/sound]
                [modify_unit]
                      [filter]
			x,y=$x1,$y1
                      [/filter]
                      experience="$($exp_unit.experience + $exp_withdraw)"
                [/modify_unit]
#    {EXP_UNSTORE}
[set_variable]
 name=exp_stored_[$side_number]
 sub=$exp_withdraw
[/set_variable]
            [/then]
	[else]
#	    [variable]
#                name=exp_withdraw
#                greater_than=$exp_stored_[$side_number]
#            [/variable]
#            [then]
#	[message]            
#            speaker=narrator
#            image=portraits/tomb-guardian.png
#            caption="XP bank"
#            message="sorry, but you only have $exp_stored_[$side_number]| exp in your bank."
#	[/message]            
#    {EXP_UNSTORE}
#            [/then]
	[/else]                                            
	[/if]                                            
#	[/message]            
                         [/command]
		[/option]
                [option]
                        
			message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "(currently set to <span color='#cccc33'>$advance_filter_[$side_number]|</span> for your side) Toggle advancement filtering (whether you want to see the option to either level up a unit, or deposit it's exp before leveling up)"}
			[command]
	[if]
	    [variable]
                name=advance_filter_[$side_number]
                equals=yes
            [/variable]
            [then]
[set_variable]
 name=advance_filter_[$side_number]
 value=no
[/set_variable]
            [/then]
            [else]
[set_variable]
 name=advance_filter_[$side_number]
 value=yes
[/set_variable]
            [/else]
	[/if]
                         [/command]
		[/option]
	[/message]            
    [/command]    
  [/set_menu_item]  
[set_menu_item]
        description=_ "Send some xp to this side"
        id="send_xp"
#        image="misc/cross-white.png"
        [show_if]
            [have_unit]	
                [filter_side]
                    [allied_with]
                        side=$side_number
                    [/allied_with]
                [/filter_side]
                canrecruit="yes"
                x="$x1"
                y="$y1"
            [/have_unit]
            [and]
              [not]
                [have_unit]	
                   x="$x1"
                   y="$y1"
                   side=$side_number
                 [/have_unit]
              [/not]
            [/and]
        [/show_if]
		  [command]
[store_unit]
[filter]
   x=$x1
   y=$y1
[/filter]
variable=thisleader
kill=no
[/store_unit]
            [message]
                caption=_ "XP Bank"
                image=portraits/tomb-guardian.png
                speaker="narrator"
                message="Type in the amount of exp to send to side $this_leader.side|, type 0 if you dont want to send any exp to this side. there is currently $exp_stored_[$side_number]| exp in your the bank, and there is currently $exp_stored_[$thisleader.side]| exp in your ally's bank. (note: if you type in more xp than there is in your bank, nothing will happen)"
            
            [text_input]
              variable=exp_send
            [/text_input]
            [/message]
	[if]
	    [variable]
                name=exp_send
                greater_than=0
            [/variable]
            [and]
	    [variable]
                name=exp_send
                less_than_equal_to=$exp_stored_[$side_number]
            [/variable]
            [/and]
            [then]
                     [sound]
			name=magic-faeriefire-miss.ogg
		       [/sound]
[set_variable]
 name=exp_stored_[$side_number]
 sub=$exp_send
[/set_variable]
[set_variable]
 name=exp_stored_[$thisleader.side]
 add=$exp_send
[/set_variable]
#					[message]
#					speaker=narrator
#                                        side_for=!,$side_number|,$thisleader.side|
#					message=_" Player $side_number| has sent player $exp_stored[$thisleader.side]| $exp_send| xp."
#					[/message]
					[message]
     					speaker=narrator
                                        caption=_ "XP Bank"
                                        image=portraits/tomb-guardian.png
                                        side_for=$side_number
					message=_"You have sent player $exp_stored[$thisleader.side]| $exp_send| xp."
					[/message]
					[message]
					speaker=narrator
                                        caption=_ "XP Bank"
                                        image=portraits/tomb-guardian.png
                                        side_for=$thisleader.side
                                        message=_" Player $side_number| has sent you $exp_send| xp."
					[/message]
            [/then]
	[else]
	[/else]                                            
	[/if]                                            
     [/command]
[/set_menu_item]
[/event]
[event]
  name=advance
  first_time_only=no
  [filter]
   [filter_side]
       controller=human
   [/filter_side]
  [/filter]
        [if]
	    [variable]
                name=advance_filter_[$side_number]
                equals=yes
            [/variable]
            [then]
					[message]
     					speaker=narrator
                                        caption=_ "XP Bank"
                                        image=portraits/tomb-guardian.png
                                        side_for=$unit.side
					message=_"Do you want $unit.name| the $unit.type| to level up as usual, or deposit all his/her exp to prevent him/her from doing so to save the exp for something else?"
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Level up"}
			[command]
                         [/command]
		[/option]
                [option]
                        
			message=  {MENU_IMG_TXT "items/holy-water.png~BLIT(halo/elven/shaman-heal-halo-4.png)" "Deposit all of the unit's exp"}
			[command]
                     [sound]
			name=magic-faeriefire-miss.ogg
		      [/sound]
                  [store_unit]
                     [filter]
                         id=$unit.id
                     [/filter]
                     variable=exp_drained_unit
                  [/store_unit]
                  [set_variable]
                      name=exp_stored_[$side_number]
                      add="$exp_drained_unit.experience"
                  [/set_variable]
                  {VARIABLE exp_drained_unit.experience 0}
                  [unstore_unit]
                     variable=exp_drained_unit
                     find_vacant=no
                  [/unstore_unit]
                  {CLEAR_VARIABLE exp_drained_unit}
                         [/command]
		[/option]
					[/message]
            [/then]
	[/if]
[/event]
[/modification]
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

User avatar
Pentarctagon
Forum Administrator
Posts: 3627
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: ForestDragon's WML questions

Post by Pentarctagon » November 25th, 2017, 6:37 pm

Have you checked the changes listed in this thread? Also, is there anything in your error log?
99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code

User avatar
ForestDragon
Posts: 1496
Joined: March 6th, 2014, 1:32 pm

Re: ForestDragon's WML questions

Post by ForestDragon » November 25th, 2017, 6:38 pm

Pentarctagon wrote:Have you checked the changes listed in this thread?
Thanks! :) EDIT: I couldn't find anything relevant there.
Co-creator of Era of Magic
Creator of Tale of Alan (1.12 abandoned),The Golden Age (1.12/1.13, abandoned),XP Bank (1.14),Alliances Mod(1.14), with a large add-on in development
"Real life is like a hyper-realistic VR game, but with permadeath and boring gameplay"

Post Reply