• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Custom UI cast button

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,852
Hello, I wanna add to my map a menu with buttons (apart of the normal UI) that I click and then I cast an spell, the thing is, how can I do it for spells with target?
I was thinking something like:
Press Button>Select a dummy caster>Force UI Key>Cast the spell>Deselect the dummy caster
But I think that is an odd solution, what do you think?
 
Level 39
Joined
Feb 27, 2007
Messages
5,010
Select a dummy caster>Force UI Key
There will be a delay between these two steps you'll have to overcome. Selecting the unit and immediately forcing the UI key will fail - it will force the previously selected unit to invoke the hotkey because there is a frame delay when updating selection before ForceUIKey can work. A 0.00 timeout timer will not avoid this, it has to be some finite time but I've not been able to determine exactly how long. Intuition is 1 actual game frame (at whatever FPS it's running at) or one internal frame of 1/0.03 but I don't know.
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
There will be a delay between these two steps you'll have to overcome. Selecting the unit and immediately forcing the UI key will fail - it will force the previously selected unit to invoke the hotkey because there is a frame delay when updating selection before ForceUIKey can work. A 0.00 timeout timer will not avoid this, it has to be some finite time but I've not been able to determine exactly how long. Intuition is 1 actual game frame (at whatever FPS it's running at) or one internal frame of 1/0.03 but I don't know.
Yes, that is also why I don't consider this a good solution.
 
Level 12
Joined
Mar 13, 2020
Messages
421
or you Could do something like wow With his Default Ui Page up and hide all Abilitys and give the feeling of a Second Page of 12 and give the Frame Button „Page Up“ a Hotkey like Shift so it would give you 24 Command Buttons

For example Q W E R etc
Hotkeys
And Then
Shift Pressed Q W E R etc

That would give it some Gameplay Skill and Benefits the Skilled players

P.s Just Brainstorming some Option its Just Gameplay Design and would take work ;)
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
or you Could do something like wow With his Default Ui Page up and hide all Abilitys and give the feeling of a Second Page of 12 and give the Frame Button „Page Up“ a Hotkey like Shift so it would give you 24 Command Buttons

For example Q W E R etc
Hotkeys
And Then
Shift Pressed Q W E R etc

That would give it some Gameplay Skill and Benefits the Skilled players

P.s Just Brainstorming some Option its Just Gameplay Design and would take work ;)
The thing is I don't wanna add more options for the same unit (I can do that with a spellbook), I wanna make it like it seems a "omniscient being" is casting the ability, for example in Starcraft II: Legacy of the Void with the Spear of Adun.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
or you Could do something like wow With his Default Ui Page up and hide all Abilitys and give the feeling of a Second Page of 12 and give the Frame Button „Page Up“ a Hotkey like Shift so it would give you 24 Command Buttons

For example Q W E R etc
Hotkeys
And Then
Shift Pressed Q W E R etc

That would give it some Gameplay Skill and Benefits the Skilled players

P.s Just Brainstorming wach Option is Just Gameplay Design and would take work ;)
You beat me to it :D

Alternatively, you could avoid the custom UI and have it all be managed on the command card. For example, you'd use a page system similar to how item bag systems work which divides the abilities across multiple pages. You then use OS_Keys and make it so on key press 1 you show abilities on "page 1", then on key press 2 you hide the previously shown abilities and show abilities on "page 2", etc.

You could even allow the player to create their own custom pages, but you'd probably want some custom UI to manage that.

Edit: The "omniscient being" thing is possible but it won't be very responsive. Maybe you could trigger ALL of the targeted abilities and instead make your own ability targeting system with mouse events. Then you can avoid the Force Hotkey issue, and introduce a new issue, mouse events 😅.

Edit 2: Check this out: Custom Ability Button System
 
Last edited:
Level 12
Joined
Mar 13, 2020
Messages
421
You beat me to it :D

Alternatively, you could avoid the custom UI and have it all be managed on the command card. For example, you'd use a page system similar to how item bag systems work which divides the abilities across multiple pages. You then use OS_Keys and make it so on key press 1 you show abilities on "page 1", then on key press 2 you hide the previously shown abilities and show abilities on "page 2", etc.

You could even allow the player to create their own custom pages, but you'd probably want some custom UI to manage that.

Edit: The "omniscient being" thing is possible but it won't be very responsive. Maybe you could trigger ALL of the targeted abilities and instead make your own ability targeting system with mouse events. Then you can avoid the Force Hotkey issue, and introduce a new issue, mouse events 😅.

Edit 2: Check this out: Custom Ability Button System
Yeah had couple of breaks from Wc3 Modding.. nice to See you are still Around helping People out ;)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,537
I saw it, but I don't understand it well, I need that @Tasyen explains me.
It's basically the same system that World of Warcraft / most MMO's use.

You left click a unit to make it your target. Once you have a target selected you can press a custom UI button/hotkey to cast it's associated spell on that selected unit.

In order to have custom hotkeys you need to use the OS_Key functions which allow you to detect when a user presses any key. Then in response to a key press you can either order a Dummy unit to cast your spell or order the player's Hero to do it. I believe Tasyen's system orders the Hero to do it and manages the ability this way (adding it/showing it/putting it on cooldown).

But you don't have to design your system exactly this way.

Another method I've been using:
  • I created 26 Channel abilities which are added to and then disabled + hidden from my Hero(s). They have hotkeys ranging from A to Z and each have a unique Base Order Id. I make sure these abilities have no Follow Through Time and don't Disable the hero, they're simply meant to act as a Button/Hotkey to fire my spell triggers (aka functions).
  • Regarding spell triggers, this method basically requires me to code ALL of my spell effects myself so that I'm in full control of everything.
  • I then link the Channel abilities to my spell triggers as needed. This can be done with a 2d table in Lua or you can use a Hashtable in Jass. For example: Hero learns Fireball -> The player links Fireball to the Q hotkey ability (you could use custom UI for this) -> I enable the Q ability for the Hero. Now the system knows that when that Hero finishes casting the Q ability it should run the Fireball spell trigger.
  • I then use custom UI to display the ability icon, button, cooldown, tooltip, manage the hotkey mapping (linking), etc.
There's a bit more to it than that but that's the general idea.
 
Last edited:
Level 24
Joined
Jun 26, 2020
Messages
1,852
It's basically the same system that World of Warcraft / most MMO's use.

You left click a unit to make it your target. Once you have a target selected you can press a custom UI button/hotkey to cast it's associated spell on that selected unit.

In order to have custom hotkeys you need to use the OS_Key functions which allow you to detect when a user presses any key. Then in response to a key press you can either order a Dummy unit to cast your spell or order the player's Hero to do it. I believe Tasyen's system orders the Hero to do it and manages the ability this way (adding it/showing it/putting it on cooldown).

But you don't have to design your system exactly this way.

Another method I've been using:
  • I created 26 Channel abilities which are added to and then disabled + hidden from my Hero(s). They have hotkeys ranging from A to Z and each have a unique Base Order Id. I make sure these abilities have no Follow Through Time and don't Disable the hero, they're simply meant to act as a Button/Hotkey to fire my spell triggers (aka functions).
  • Regarding spell triggers, this method basically requires me to code ALL of my spell effects myself so that I'm in full control of everything.
  • I then link the Channel abilities to my spell triggers as needed. This can be done with a 2d table in Lua or you can use a Hashtable in Jass. For example: Hero learns Fireball -> The player links Fireball to the Q hotkey ability (you could use custom UI for this) -> I enable the Q ability for the Hero. Now the system knows that when that Hero finishes casting the Q ability it should run the Fireball spell trigger.
  • I then use custom UI to display the ability icon, button, cooldown, tooltip, manage the hotkey mapping (linking), etc.
There's a bit more to it than that but that's the general idea.
Hmmm.
 
I saw it, but I don't understand it well, I need that @Tasyen explains me.
That is a demo map for a feature creeped Lua System I wrote years ago (It might not work right of the box in V1.32+).
The system creates a new UI to show many abilities which all can be ordered without orderId conflicts, supporting charges, the buttons could be moved and stuff I don't know right now.
It was built for the other kind of targeting in which your hero is fixed and everything is used onto the current Selected Unit. Which saves many clicks compared to default Warcraft 3 control in which you have to confirm/retarget with every order. Point click abilties are ordered on release on the current Mouse Pos.

Each orderid has an setup how the button/system will behave. Some skills need custom handling :( . Then you also need to tell the system which order the ability uses (should be done for most default non-item skills). And finally you need to say which unit is using this and what abilities the unit uses for each button or a list of abilities.
 
Level 9
Joined
Mar 26, 2017
Messages
376
I have made a spell which does something like 'Telekenesis' from Dota, but rather it (near) instantly prompts a crosshairs to select where you want to move the unit to. But it works fully smooth :D. It is however quite complicated.
Mind you this is on one Hero itself, and not with Custom UI.

-At t=0, it hides the 'dummy' ability and unhides a second targeting ability on the Hero
-t=0.04 Force UI Key, thus bringing up the crosshairs (.03 is too short and sometimes bugs out)
=t=0.10 It activates a trigger that 'ends' the ability under the following conditions: EVENT_PLAYER_MOUSE_UP, EVENT_PLAYER_UNIT_DESELECTED, OSKEY_ESCAPE
-t=0.11 and t=0.21 Check if current casting order is equal to the dummy ability. If not it 'ends' the ability.
-Another timer is started that 'ends' the ability after holding crosshairs for too long.
-Ending means it unhides dummy ability, and hides second ability
-If the second ability is used on a target, it fires the actual spell effect

I'm not to sure if using custom UI buttons would give extra delay time as compared to casting an ability from the command card.
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
That is a demo map for a feature creeped Lua System I wrote years ago (It might not work right of the box in V1.32+).
The system creates a new UI to show many abilities which all can be ordered without orderId conflicts, supporting charges, the buttons could be moved and stuff I don't know right now.
It was built for the other kind of targeting in which your hero is fixed and everything is used onto the current Selected Unit. Which saves many clicks compared to default Warcraft 3 control in which you have to confirm/retarget with every order. Point click abilties are ordered on release on the current Mouse Pos.

Each orderid has an setup how the button/system will behave. Some skills need custom handling :( . Then you also need to tell the system which order the ability uses (should be done for most default non-item skills). And finally you need to say which unit is using this and what abilities the unit uses for each button or a list of abilities.
I tested the map and doing what it says, but don't happen anything, even give me errors like "indexing a nil value" when I wrote what it suggested me.
 
Status
Not open for further replies.
Top