ForestDragon's WML questions

The place to post your WML questions and answers.

Moderator: Forum Moderators

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

Re: ForestDragon's WML questions

Post by ForestDragon »

Pentarctagon wrote:You didn't need to add .value it to XP_bank_start.
oh, ok. EDIT: works now, thanks! :D
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

I'm making yet another MP mod. So, I'm trying to store all sides' default team names, but it seems I messed something up with variables again. here's the current work-in-progress code of the mod:

Code: Select all

#define STORE_DEFAULT_ALLEGIANCE SIDE
  [store_side]
    side={SIDE}     
    variable=side{SIDE}_stored
  [/store_side]
#enddef
[modification]
    id=Alliances_Mod
    name="Alliance Mod"
    description="allows players to make/break alliances with eachother."
    require_modification=no
#    [options]
#    [/options]
[event]
  name=start

  {STORE_DEFAULT_ALLEGIANCE 1}
  {STORE_DEFAULT_ALLEGIANCE 2}
  {STORE_DEFAULT_ALLEGIANCE 3}
  {STORE_DEFAULT_ALLEGIANCE 4}
  {STORE_DEFAULT_ALLEGIANCE 5}
  {STORE_DEFAULT_ALLEGIANCE 6}
  {STORE_DEFAULT_ALLEGIANCE 7}
  {STORE_DEFAULT_ALLEGIANCE 8}
  {STORE_DEFAULT_ALLEGIANCE 9}
  [set_menu_item]
    id=alliance_menu
    description="Alliance Menu"
#    image=".png"
#    [default_hotkey]
#      key="~"
#    [/default_hotkey]
	[show_if]
		[have_unit]
                        x=$x1
                        y=$y1
			side=$side_number
			canrecruit=yes
		[/have_unit]
        [/show_if]		    
    [command]
	[message]
		speaker=narrator
		image=portraits/humans/transparent/marshal.png
		caption="Alliances Menu"
                message="What do you want?"
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Return To Game"}
			[command]
                         [/command]
		[/option]
                [option]                        
			message=  {MENU_IMG_TXT "icons/crossed_sword_and_hammer.png" "Break all your current alliances"}
			[command]
			 [modify_side]
			   side=$side_number
			   team_name=$side[$side_number]_stored.team_name
			 [/modify_side]
                         [/command]
		[/option]
	[/message]            
    [/command]    
  [/set_menu_item]  
  [set_menu_item]
        description=_ "Send alliance request to this side"
        id="send_request"
#        image="misc/cross-white.png"
        [show_if]
            [have_unit]	
                [filter_side]
		   [not]
                    [allied_with]
                        side=$side_number
                    [/allied_with]
		    [or]
		      controller=ai
		    [/or]
		   [/not]
                [/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]
                         [store_unit]
                            [filter]
                              side=$side_number
			      canrecruit=yes
                            [/filter]
                            variable=thisleader2
                            kill=no
                         [/store_unit]
	[message]
		speaker=narrator
		image=portraits/humans/transparent/marshal.png
#		for_side=$thisleader.side
		caption="Alliances Menu"
                message="player $side_number| ($thisleader2.name|) wants to ally with you."
                [option]
                        
			message=  {MENU_IMG_TXT "misc/red-x.png" "Decline"}
			[command]
               	          [message]
     		             speaker=narrator
 		             image=portraits/humans/transparent/marshal.png
            		     for_side=$side_number
		             caption="Alliances Menu"
                             message="player $thisleader.side| ($thisleader.name|) declined your alliance request."
               	          [/message]
                         [/command]
		[/option]
                [option]                        
			message=  {MENU_IMG_TXT "icons/crossed_sword_and_hammer.png" "Agree"}
			[command]
			 [modify_side]
			   side=$side_number
			   team_name=$side[$side_number]_stored.team_name|,alliance
#			   user_team_name="Alliance"
			 [/modify_side]
			 [modify_side]
			   side=$thisleader.side
			   team_name=$side[thisleader.side]_stored.team_name|,alliance
#			   user_team_name="Alliance"
			 [/modify_side]
               	          [message]
     		             speaker=narrator
 		             image=portraits/humans/transparent/marshal.png
            		     for_side=$side_number
		             caption="Alliances Menu"
                             message="player $thisleader.side| ($thisleader.name|) accepted your alliance request."
               	          [/message]
                         [/command]
		[/option]
	[/message]            
     [/command]
[/set_menu_item]
[/event]
[/modification]
User avatar
Pentarctagon
Project Manager
Posts: 5496
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: ForestDragon's WML questions

Post by Pentarctagon »

side{SIDE}_stored doesn't put it in an array. It means there are variables literally called side1_stored, side2_stored, etc. So rather than
$side[$side_number]_stored.team_name, I believe you would want $side$side_number|_stored.team_name.

Your modification, if meant only for MP, should also specify type=mp.
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: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

Pentarctagon wrote:side{SIDE}_stored doesn't put it in an array. It means there are variables literally called side1_stored, side2_stored, etc. So rather than
$side[$side_number]_stored.team_name, I believe you would want $side$side_number|_stored.team_name.
Works perfectly, thanks! :)
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

small question: is it possible to filter debug by using #ifdef? (to add debug-exclusive features, like add-on specific debug features)
User avatar
Ravana
Forum Moderator
Posts: 2933
Joined: January 29th, 2012, 12:49 am
Location: Estonia
Contact:

Re: ForestDragon's WML questions

Post by Ravana »

It is possible to check debug state during game at least.
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

Ravana wrote: April 6th, 2018, 2:39 pm It is possible to check debug state during game at least.
could you please explain what exactly do you mean?
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

Ravana wrote: April 6th, 2018, 2:52 pm https://wiki.wesnoth.org/LuaWML/Misc#we ... ame_config has debug key.
ok, thanks.
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

Does anyone know if there's a way to embed [terrain_graphics] into an event? (like the animated mausoleum, for instance)
User avatar
beetlenaut
Developer
Posts: 2813
Joined: December 8th, 2007, 3:21 am
Location: Washington State
Contact:

Re: ForestDragon's WML questions

Post by beetlenaut »

That question doesn't really make sense. [terrain_graphics] defines the look of some type of terrain. It doesn't perform any action. If you want some animated terrain to appear in an event, what you would have to do is create a custom terrain with [terrain_type] that corresponds to a [terrain_graphics] rule that sets the graphics you want, then switch to your custom terrain with the event. You would probably have to read up on terrain to get it working. You could also look at SotA. It has a fair amount of custom terrain (for a mainline campaign anyway), and some of it is animated.

([terrain_graphics] can also define the look of a specific tile, which is what is done for the mausoleum and campfire, but that probably won't help you in this case.)
Campaigns: Dead Water,
The Founding of Borstep,
Secrets of the Ancients,
and WML Guide
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

beetlenaut wrote: June 4th, 2018, 7:10 am That question doesn't really make sense. [terrain_graphics] defines the look of some type of terrain. It doesn't perform any action. If you want some animated terrain to appear in an event, what you would have to do is create a custom terrain with [terrain_type] that corresponds to a [terrain_graphics] rule that sets the graphics you want, then switch to your custom terrain with the event. You would probably have to read up on terrain to get it working. You could also look at SotA. It has a fair amount of custom terrain (for a mainline campaign anyway), and some of it is animated.

([terrain_graphics] can also define the look of a specific tile, which is what is done for the mausoleum and campfire, but that probably won't help you in this case.)
ok, thanks.
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: ForestDragon's WML questions

Post by zookeeper »

beetlenaut wrote: June 4th, 2018, 7:10 am That question doesn't really make sense. [terrain_graphics] defines the look of some type of terrain. It doesn't perform any action. If you want some animated terrain to appear in an event, what you would have to do is create a custom terrain with [terrain_type] that corresponds to a [terrain_graphics] rule that sets the graphics you want, then switch to your custom terrain with the event. You would probably have to read up on terrain to get it working. You could also look at SotA. It has a fair amount of custom terrain (for a mainline campaign anyway), and some of it is animated.

([terrain_graphics] can also define the look of a specific tile, which is what is done for the mausoleum and campfire, but that probably won't help you in this case.)
And if you don't want to actually create a custom terrain, you can create scenario-specific ([scenario][terrain_graphics]) rules (which is what the mausoleum is) and simply craft it so that it matches when you for example add the impassable overlay (or whichever non-visual change is most convenient) someplace in an event. That would be the easiest way to do it in some cases.
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

zookeeper wrote: June 4th, 2018, 9:36 am And if you don't want to actually create a custom terrain, you can create scenario-specific ([scenario][terrain_graphics]) rules (which is what the mausoleum is) and simply craft it so that it matches when you for example add the impassable overlay (or whichever non-visual change is most convenient) someplace in an event. That would be the easiest way to do it in some cases.
True, but I already added custom terrain (it's not that difficult, after all)
User avatar
ForestDragon
Posts: 1766
Joined: March 6th, 2014, 1:32 pm
Location: Ukraine

Re: ForestDragon's WML questions

Post by ForestDragon »

Hi. So, was working on implementing long-ranged attacks for AI (for my upcoming addon), and while the code works fine on 1.12.x, it fails to do so on the latest stable (1.14.2)
*removed*

EDIT: Nevermind, it works now.
Post Reply