adding to the right click menu

The place to post your WML questions and answers.

Moderator: Forum Moderators

Forum rules
  • Please use [code] BBCode tags in your posts for embedding WML snippets.
  • To keep your code readable so that others can easily help you, make sure to indent it following our conventions.
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

adding to the right click menu

Post by zengetsu88 »

I need help...

How can I add a command or function to the right click drop down menu that you get when right clicking a unit?
I want to be able to execute an attack from a specific unit without targeting another unit... and the only way I could think of is right clicking the unit, and clicking the added command for that unit to execute its attack... Any information would be great...

I'm kinda new to WML so please put script examples for me....
and if there is another way for me to achieve the same principle in a simpler way please... I'm all ears...
all my stuff is for multiplayer... NOT CAMPAIGN... i know that effects some code...
Thanks for any help...
my logic is sound
User avatar
Ken_Oh
Moderator Emeritus
Posts: 2178
Joined: February 6th, 2006, 4:03 am
Location: Baltimore, Maryland, USA

Re: adding to the right click menu

Post by Ken_Oh »

Look at set_menu_item in RefernceWML. If A New Land is still mainline, then look at how it is done there. Otherwise, there are plenty of examples in add-on content (like Brotherhood of Light).
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: adding to the right click menu

Post by zengetsu88 »

okay that helped a ton...
I have researched the set_menu_item a lot... but I still can't figure out where I will be putting the script... and I can't figure out if there is a way to make it so that the command will only appear to the user of the unit and not the other player...
my logic is sound
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: adding to the right click menu

Post by Luke the Flaming »

Untested (but it should work... in single player it surely would; but I've never tried in multiplayer).

Put it somewhere into [event] with name=start.

Code: Select all

        [set_menu_item]
            id=grid_break_attack
            image=blank.png   # Or any image you'll like to create for this purpose 
                              # (I suggest to make it 16 x 16 or so).
            description= _ "Grid Break attack!"
                 [show_if]
                     [have_unit]
                         type=zengetsu   # Or whatever it is called the kind of 
                                         # unit with the Grid Break attack.
                         side=$side_number   # So if the current playing side is not the
                                             # one of the unit, the button is not dispalyed.
                             [filter_location]
                                 x,y=$x1,$y1
                             [/filter_location]
                     [/have_unit]
                 [/show_if]
                 [command]
                     # The whole Grid Break attack stuff goes here.
                 [/command]
        [/set_menu_item]
O, Wind, if Winter comes, can Spring be far behind?
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: adding to the right click menu

Post by zengetsu88 »

Alright time for me to actually focus on this one... I tried your script and it didn't seem to work but I am playing with it...
this part is essential because I will be using it for more than grid break... I would like to make a ghetto recruiting ability with it... and an active healing ability... that will come later though...

When I tried this script the command never even appeared... my only guess is that I have it in the wrong place (I have it on the unit with Grid break)...
my logic is sound
User avatar
Pentarctagon
Project Manager
Posts: 5730
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding to the right click menu

Post by Pentarctagon »

[filter_location] goes outside of the [show_if]
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
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: adding to the right click menu

Post by Luke the Flaming »

zengetsu88 wrote:When I tried this script the command never even appeared... my only guess is that I have it in the wrong place (I have it on the unit with Grid break)...
If it is in the unit, which name have you given to the [event]? Since it is going to be included in the scenario when the first unit of that type appear, if it is name=start it will never work (since itis included once the moment to fire it has already expired). Try with:

Code: Select all

[event]
    name=select 
        [filter] 
            type=zengetsu 
        [/filter]
etc...
Pentarctagon wrote:[filter_location] goes outside of the [show_if]
Why? Don't we want the zengetsu unit in the exact position where you right click (to display the option of the special attack)?
O, Wind, if Winter comes, can Spring be far behind?
User avatar
Pentarctagon
Project Manager
Posts: 5730
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding to the right click menu

Post by Pentarctagon »

right, my bad :oops:
though it turns out that you don't even need the [filter_location], i was able to get a menu item to show up only over a mage with just this:

Code: Select all

[show_if]
[have_unit]
type=Mage
side=$side_number
x,y=$x1,$y1
[/have_unit]
[/show_if]
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
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: adding to the right click menu

Post by zengetsu88 »

Okay I got it to work... The menu item shows up but time to get more complicated...

I only want it to show up if the units dot is green or yellow (the little dot above their head that means their status is still active...) and I don't want it to show up if that unit's do is red...

and finally how do I make the command or action like an attack and use up all the movement points by using it (turns the dot red)
my logic is sound
User avatar
Pentarctagon
Project Manager
Posts: 5730
Joined: March 22nd, 2009, 10:50 pm
Location: Earth (occasionally)

Re: adding to the right click menu

Post by Pentarctagon »

zengetsu wrote:and finally how do I make the command or action like an attack and use up all the movement points by using it (turns the dot red)
store the unit, {VARIABLE var_name.moves 0}, unstore unit.
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
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: adding to the right click menu

Post by Luke the Flaming »

zengetsu88 wrote:I only want it to show up if the units dot is green or yellow (the little dot above their head that means their status is still active...) and I don't want it to show up if that unit's do is red...

Code: Select all

                 [show_if]
                     [have_unit]
                         type=zengetsu   # Or whatever it is called the kind of 
                                         # unit with the Grid Break attack.
                         side=$side_number   # So if the current playing side is not the
                                             # one of the unit, the button is not dispalyed.
                         [not]
                             moves=0   # The "red dot".
                         [/not]
                         [not]
                             attacks_left=0   # You probably do not want the unit to attack 
                                              # normally AND with the special attack in the 
                                              # same turn, don't you?
                         [/not]
                         x,y=$x1,$y1
                     [/have_unit]
                 [/show_if]
O, Wind, if Winter comes, can Spring be far behind?
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: adding to the right click menu

Post by zengetsu88 »

the moves used up thing works but the only show if moves or attacks thing does not...

more details...
How do I add an animation to the unit is using the attack

I have this animation sequence
Spoiler:
but im not entirely sure how to use it or where to put it...

other than that I think I've got everything worked out
my logic is sound
User avatar
zengetsu88
Posts: 72
Joined: March 29th, 2010, 7:25 pm
Location: This Universe

Re: adding to the right click menu

Post by zengetsu88 »

okay ignore the animation thing... I still can't get this to work right...

I don't want the menu item to show if the units moves are done... I already have it so that the units little dot turns red/the unit has no more moves left when you use the menu item/ability...
I have tried using the not tags inside the show_if tags but that just removes the menu item entirely...
my logic is sound
User avatar
Luke the Flaming
Posts: 215
Joined: October 18th, 2006, 6:25 pm

Re: adding to the right click menu

Post by Luke the Flaming »

I forgot that values like "moves" and "attacks_left" aren't keys of the Standard Unit Filter, but need a [filter_wml] tag to be valid.

Code: Select all

                 [show_if]
                     [have_unit]
                         type=zengetsu   # Or whatever it is called the kind of 
                                         # unit with the Grid Break attack.
                         side=$side_number
                         [filter_wml]
                             [not]
                                 moves=0
                             [/not]
                             [not]
                                 attacks_left=0
                             [/not]
                         [/filter_wml]
                         x,y=$x1,$y1
                     [/have_unit]
                 [/show_if]
O, Wind, if Winter comes, can Spring be far behind?
User avatar
zookeeper
WML Wizard
Posts: 9742
Joined: September 11th, 2004, 10:40 pm
Location: Finland

Re: adding to the right click menu

Post by zookeeper »

Luke the Flaming wrote:I forgot that values like "moves" and "attacks_left" aren't keys of the Standard Unit Filter, but need a [filter_wml] tag to be valid.

Code: Select all

                 [show_if]
                     [have_unit]
                         type=zengetsu   # Or whatever it is called the kind of 
                                         # unit with the Grid Break attack.
                         side=$side_number
                         [filter_wml]
                             [not]
                                 moves=0
                             [/not]
                             [not]
                                 attacks_left=0
                             [/not]
                         [/filter_wml]
                         x,y=$x1,$y1
                     [/have_unit]
                 [/show_if]
You also can't use [not] inside a [filter_wml]. You need two [not]s, each containing a [filter_wml].
Post Reply