StarCraft® II

Diablo - Mortal Shroud's mouse UI basics

You might have played my map "Dia blo - Mortal Shroud" and wondered how to do that UI system. If you didn't, you might want to try it out.

I wrote this because xXdRaGoNrIdDeRXx asked me how I did my system. Because my implementation is not beginner friendly, I noted down the basics of it based on the code my map is currently using.

So, stay awhile and listen!

First, here are the goals that my concept tries to fulfill:

Mouse interface goals:
- Player can move with left/right mouse button
- Unit should follow the mouse movement
- Unit should keep running towards the mouse position even if you do not move the mouse
(-> Camera is locked on the unit -> mouse pointer on screen appears to move around -> requirement to calculate logical mouse position)

These are identical to the original control schemes used in Diablo by Blizzard, if I remember it correctly, and differ from the Diablo controls that OneTwo created in his video tutorials.

Design Concept:

In SC2 there are a few events that give us information about the user input:
- Mouse movement -> mouse point in world
- Mouse clicked down -> mouse point in world, mouse button is active
- Mouse clicked up -> mouse button is not active anymore

Also we know the position of our unit and implemented our camera in a way that it is always following our unit.

Using all of these information, we are able to implement what we wanted in our goals.

The "Mouse move" event gives us information of the current mouse point and the offset (value B - value A = offset from A towards B). If the player holds a button, we order the hero to that new position information.
The offset can be used to keep ordering the hero into a direction. As this could be the last input of the player before keeping to move into a direction, we start the trigger that handles that.

Trigger: Player moves mouse
C: left or right mouse button is hold down
-> save point of mouse in world
-> save offset from unit to mouse in world
C: left/right mouse button is active
-> execute action: ordering logic using the mouse point in the
world + active mouse button
-> start mouse timer trigger checking conditions

The mouse clicks give us the same information. In addition, we can set the button active, if pressed down. Make sure that you save the left and right mouse button state separate as you want to differentiate between those two to perform different actions with them.

Trigger: Player clicks left/right mouse button down
-> save info that left/right mouse button is active
-> save point of mouse in world
-> save offset from unit to mouse in world
-> execute action: ordering logic using the mouse point in the
world + clicked mouse button (see below)
-> start mouse timer trigger checking conditions

If the button is released, we deactivate the button information again.

Trigger: Player clicks left/right mouse button up
-> save info that left/right mouse button is NOT active

Then we use a trigger per player that we call "Mouse Timer". It's not really a timer, but it has the task to keep ordering the unit every now and then based on the hero-to-mouse-offset as long as we hold the correct mouse-button. This makes our unit keep running into a direction, if we just hold the button.
Because we start this trigger only after executing the ordering logic, we need to delay it a bit instead of executing the ordering logic directly again.
This trigger is a loop because we want to periodically start our order logic action which determines the action of our unit. The time we need to wait between each order is something you need to test in your map. For me, 0.25 game seconds on fastest game speed was ok. You should tinker with that value and try to find the setting that works best for you. Oh, also, waits use multiples of 0.0625, so 0.26 shouldn't change anything.

Trigger: Mouse Timer (this makes the unit follow the logical mouse
position while player isn't moving the mouse)
C: only allow 1 mouse timer per player active at a time
C: validate that the right/left mouse button is clicked
-> set marker to allow only 1 mouse timer active at a time per player
-> save the info, if this mouse timer uses left or right mouse button
-> wait 0.25 game seconds (you could use real time
and a lower value, too.)
-> While
C: mouse button used in this timer is still hold down
-> execute action: ordering logic using the unit's
position + saved offset from unit to mouse in
world + timer's button (see below)
-> wait 0.25 game seconds (same as before)
End While
-> clear marker that allows only 1 mouse timer active at
a time per player

Now, we only require the ordering logic. We throw the coordinates, the mouse button and the player as parameters into it.

Action: Ordering Logic (checks and executes the logic for the orders)
C: Unit is able to be ordered (not stunned, not uncommandable, not dead)
-> do your ability/spell/attack/move things based on the
information you have

Well, here it really depends on your map and what you are using
and how you expanded your control scheme.

A basic concept would be:
-> get the enemy units around the targeted point, get the closest
one of that unit group, then do your skill actions like order
to attack/shoot a projectile based on the button that is used
or picking up items or ordering to interact with objects/NPCs
-> if there was no enemy, order to move to that point

One more thing!
Left clicks naturally create selection boxes, so you might want to use this to disable them:
UI - Disable mouse drag selection for (All players)

Now the unit should be able to be move around and do whatever you implemented to enemy units, if you implemented everything correctly.

Further aspects I added into my system:

Of course you can add a ton of other things to make the system become better. I didn't include everything because I didn't want to fill 2-3 of these posts. But if you managed to get this working, you might want to tackle other aspects of a diablo mouse UI:

- add support of turning off the movement for merchant UI usage
- add shift button state to force ability executions/enemy unit scans
towards a direction/point instead
- add highlighting of units as another way to find a target unit
- ignoring of single events to avoid the mouse timer to freak out in
a certain situations
- add support of retargeting during spell animations
- movement only mode (during spells like whirlwind)
- add spells shooting projectiles/ordered units hitting targets via
collision detection
- add conditions to your spell executions like:
- energy costs / charge costs
- region that restricts spell usage
- distance to target point
- vision of target point
- vision in a straight line from unit towards target point
- target point is pathable
- pathing costs between unit's point and target point
- free space in a line without buildings that you can't
jump over (for leap skill)
- differences between mouse click orders and the ones
originating in the mouse timer
Make sure you always have a fallback action like move or turn,
if an ability couldn't be executed.

I hope you are able to understand and implement it using my design layout.
This is the actual system I developed and improved from 2010-2012 and use in my "Dia blo - Mortal Shroud" map, so check it out to see how it performs and experience it's quirks.

~ Ahli
Edited by Ahli on 4/13/2013 4:35 AM PDT
Reply Quote
This is very interesting and will be very usefull to me soon once I start making one of my ideas waiting. You're just in time. I guess if I have any questions I know where to go ;)
Reply Quote
What happened to the game?
Reply Quote
What happened to the game?

I'm transferring the map on NA to my account. Unfortunately this is only possible via deleting and republishing. It will block the name until next maintenance. Then I will republish the map on my account and release version 0.401 globally.

You can play on EU/SEA in the meantime.
Reply Quote
Thanks for sharing this with everyone.
Reply Quote

Please report any Code of Conduct violations, including:

Threats of violence. We take these seriously and will alert the proper authorities.

Posts containing personal information about other players. This includes physical addresses, e-mail addresses, phone numbers, and inappropriate photos and/or videos.

Harassing or discriminatory language. This will not be tolerated.

Forums Code of Conduct

Report Post # written by

Explain (256 characters max)
Submit Cancel