Hotkeys and Animate units at will (solved). Now: Choose weapon used in attack..
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.
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Hotkeys and Animate units at will (solved). Now: Choose weapon used in attack..
Hello to all.
My request is simple:
Are there any "Hotkey" system/macro in the WML ?
For exemple, by pressing some Key combinations (ctrl+shift+A for exemple), being able to trigger some predefined events/macos.
Your help will be allways thankfully welcome.
Thanks for reading me.
Friendly yours,
Retributive.
My request is simple:
Are there any "Hotkey" system/macro in the WML ?
For exemple, by pressing some Key combinations (ctrl+shift+A for exemple), being able to trigger some predefined events/macos.
Your help will be allways thankfully welcome.
Thanks for reading me.
Friendly yours,
Retributive.
Last edited by Retributive on August 14th, 2019, 9:48 pm, edited 3 times in total.
- Pentarctagon
- Project Manager
- Posts: 5565
- Joined: March 22nd, 2009, 10:50 pm
- Location: Earth (occasionally)
Re: Hotkeys ?
You probably want [set_menu_item]'s [default_hotkey], with
use_hotkey=only
.99 little bugs in the code, 99 little bugs
take one down, patch it around
-2,147,483,648 little bugs in the code
take one down, patch it around
-2,147,483,648 little bugs in the code
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: Hotkeys ?
Thank you, Pentarctagon.
That was very useful, exactly what I was looking for !
Now I need to find macros to "provoke" an unit's "Death" and various "Animations"..
For exemple, I want to use a hotkey and the unit dies (with animations) or attacks (with animations), etc..
So far, I am able to "Teleport" it in a remote corner of the map, but not to kill it.
Setting the "hitpoints" (with "MODIFY_UNIT") to 0 doesn't work.. No clues about triggering the animations though..
But I only know this page:
https://www.wesnoth.org/macro-reference.xhtml
Maybe there is a more complete reference somewhere ?..
Friendly yours,
Retributive.
That was very useful, exactly what I was looking for !
Now I need to find macros to "provoke" an unit's "Death" and various "Animations"..
For exemple, I want to use a hotkey and the unit dies (with animations) or attacks (with animations), etc..
So far, I am able to "Teleport" it in a remote corner of the map, but not to kill it.
Setting the "hitpoints" (with "MODIFY_UNIT") to 0 doesn't work.. No clues about triggering the animations though..
But I only know this page:
https://www.wesnoth.org/macro-reference.xhtml
Maybe there is a more complete reference somewhere ?..
Friendly yours,
Retributive.
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: Hotkeys ?
Managed to get the unit killed on hotkey:
Code: Select all
[set_menu_item]
id=KILL_UNIT
use_hotkey=only
[default_hotkey]
key="A"
ctrl=yes
shift=yes
[/default_hotkey]
[filter_location]
x=$x1
y=$y1
[/filter_location]
[command]
[harm_unit]
[filter]
x=$x1
y=$y1
[/filter]
amount=1000
animate=yes
[/harm_unit]
[/command]
[/set_menu_item]
Last edited by Retributive on August 10th, 2019, 5:36 pm, edited 1 time in total.
Re: Hotkeys ?
There already is hotkey for that - shift k.
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: Hotkeys ?
Thank you, Ravana, but it is only in "Debug" mode..
To "provoque" an attack animation, I am testing the "[do_command]" + "[attack]" tags, but it seems to require a "[destination]" unit to function...
Like this:
.. but it doesn't work..
To "provoque" an attack animation, I am testing the "[do_command]" + "[attack]" tags, but it seems to require a "[destination]" unit to function...
Like this:
Code: Select all
[command]
[do_command]
[attack]
weapon=0
defender_weapon=0
[source]
x,y=$x1,$y1
[/source]
[destination]
id=other # A hidden unit ID
[/destination]
[/attack]
[/do_command]
[/command]
Re: Hotkeys ?
[do_command] is designed for simulating user input. I believe that is not what you need.
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: Hotkeys ?
Thank you, Ravana.
I think I'm gonna look into this part:
Located here:
https://wiki.wesnoth.org/LuaWML/Units#wesnoth.effects
I think I'm gonna look into this part:
Code: Select all
...wesnoth.create_animator
(Version 1.13.7 and later only)
wesnoth.create_animator()
Returns an object that can be used to set up and run an animation. The object has three methods:
animator:run()
Runs the animation. (Version 1.15.0 and later only) Implicitly clears the animator.
...
https://wiki.wesnoth.org/LuaWML/Units#wesnoth.effects
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: Hotkeys ?
Figured it out:
It comes inside a "[set_menu_item]" :
It was that simple (found sample codes somewhere in the forums), but there is not (to my knowledge) a list of the usable "flag"s. So I used this page here:
https://units.wesnoth.org/1.5.10/animations.html
Most of the time you only have "attack" or "defend", for some reason "death", "standing" and "idle" don't work (didn't test the others..).
I struggled because I was putting the "[filter]" tag before the "flag". You have to put it after.
All I need to do is find a way to choose the facing of the attack, and I'm done (for now )
All my thanks to Ravana and Pentarctagon for their advices and helps!
Friendly yours,
Retributive.
Code: Select all
[command]
[animate_unit]
flag=attack
[filter]
id=$unit.id # I use a variable in the "select" "[event]"
[/filter]
[/animate_unit]
[/command]
Code: Select all
[set_menu_item]
id=unit_attacks # or whatever unique lowercase ID
use_hotkey=only
[default_hotkey]
key="A" # or any key you want
ctrl=yes
shift=yes # you can add "alt" too
[/default_hotkey]
[command]
# do your thing here
[/command]
[/set_menu_item]
https://units.wesnoth.org/1.5.10/animations.html
Most of the time you only have "attack" or "defend", for some reason "death", "standing" and "idle" don't work (didn't test the others..).
I struggled because I was putting the "[filter]" tag before the "flag". You have to put it after.
All I need to do is find a way to choose the facing of the attack, and I'm done (for now )
All my thanks to Ravana and Pentarctagon for their advices and helps!
Friendly yours,
Retributive.
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: [SOLVED] Hotkeys and Animate units at will.
Quick update:
I had trouble triggering the animations in the desired directions (6 hotkeys -> 6 different directions).
The unit strikes automatically in direction where it entered the last Hex on its last movement.
ie: If it entered from the south-ouest side, it will automatically attack towards the north-est direction.
I solved it that (brutal and inelegant) way:
If someone knows a better solution, he is welcome to share..
Friendly yours,
Retributive.
I had trouble triggering the animations in the desired directions (6 hotkeys -> 6 different directions).
The unit strikes automatically in direction where it entered the last Hex on its last movement.
ie: If it entered from the south-ouest side, it will automatically attack towards the north-est direction.
I solved it that (brutal and inelegant) way:
Code: Select all
[command] # I created 6 Hotkeys for the six directions of attack
[animate_unit]
flag=attack
[filter]
id=$unit.id # I use a variable in the "select" "[event]"
[/filter]
[facing]
[filter] # I created 6 units ID-ed from the 6 directions, in the outter void zone border Hexes of the map.
id=north # That way the unit is attacking in the desired direction while setting the "facing" "filter" to the desired ID.
[/filter] # The 6 dum units being hidden of course. "north" being the ID of the northern dum unit.
[/facing] # All the filters with coordonates I tried ("[filter] x,y=$x1,($y1+1) [/filter]" for example), did not work.
[/animate_unit]
[/command]
Friendly yours,
Retributive.
Re: [SOLVED] Hotkeys and Animate units at will.
Unit has facing attribute, it is not replay safe, but could work here to update that before animation.
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: [SOLVED] Hotkeys and Animate units at will.
"[modify_unit]+facing=" works perfectly, thank you Ravana !
-
- Posts: 47
- Joined: February 20th, 2009, 12:45 pm
- Location: Bordeaux, FRANCE.
Re: [SOLVED] Hotkeys and Animate units at will.
I am having issues definig the attack used for the animation, I am trying this code:
..but I don't always get the same attack every trigger..
How can I achieve that ?
I simply copied the code from the "Scepter of Fire"'s scenario "6_Towards_the_Caves.cfg" below..Without the "[animate]" and the "[facing]" parts. Are they needed for the animation to correctly function ?
Any advice will be welcome, as usual
Code: Select all
[animate_unit]
flag=attack
[filter]
id=$unit.id
[/filter]
[primary_attack]
name=$unit.attack[0].name # Tested: this is the name of the first attack of the unit
[/primary_attack]
[/animate_unit]
How can I achieve that ?
I simply copied the code from the "Scepter of Fire"'s scenario "6_Towards_the_Caves.cfg" below..
Code: Select all
[animate_unit]
flag=attack
[filter]
id=Thursagan
[/filter]
[primary_attack]
name=hammer
[/primary_attack]
hits=yes
[facing]
[filter]
id=Durstorn
[/filter]
[/facing]
[animate]
flag=defend
[filter]
id=Durstorn
[/filter]
hits=yes
text= _ "<i>Thud!</i>"
red=255
green=0
blue=0
[facing]
[filter]
id=Thursagan
[/filter]
[/facing]
[/animate]
[/animate_unit]
Any advice will be welcome, as usual