Get the Desktop App for Battle.net Now
- All your games in 1 place
- Log in once
- Automatic game updates
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.
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.
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.
If the button is released, we deactivate the button information again.
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.
Now, we only require the ordering logic. We throw the coordinates, the mouse button and the player as parameters into it.
One more thing!
Left clicks naturally create selection boxes, so you might want to use this to disable them:
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:
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.
Edited by Ahli on 4/13/2013 4:35 AM PDT
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.
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.