HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Using the Keyboard

03-28-2004, 08:50 PM#1
PhantasyDreamer
Here is one of the first tutorial on how using the Keyboard to make a game that don't necessarly use the mouse.

Content:-Hot keys(events)
-Using arrows to make a unit move in the map
-point with offset
-camera
-How to use Esc hotkey
-How to use F1, F2, F3, F4, F5 and F8 hotkey
-Having more option
-Download

Event: First thing you must know if you want to create a game that will be playable with the arrow and other keys is that all the hotkeys are the trigger's event. There are two kinds of hotkeys event: The event that can only occurs when you press the hotkeys(esc, F1, F2, F3 etc...) and the events that occurs when you press or release the hotkey(the arrow key).

Using arrow to make a unit move in the map: To do this you need 8 triggers, that means two for every direction. The first trigger is the one that make the unit move when you press the arrow key. The second is the one the stop the unit. To make the unit move in a direction he can face, you must use the point with offset.
-Point with offset: What are they? They are distance between two points. Example, an attack is usually 120 points and a spell can be like 600 or 800(target range). X,Y are two set how far or in which direction the order is given.
So to make the unit move up, the action should be:
Action: Issue order unit'x' to move(position of Unit'x' offset by O;size of the map(example 99999))(to move down would be 0;-99999, left -99999;0, right 99999;0)
-Camera: Make sure the camera is lock on the unit or it will make the game really bad. To make it simply use a trigger like:
Event: periodic event: every 0.1o sec of the game
action: Lock camera to Hero over 0 sec using default rotation or whatever you want.

Now your unit can go right left down and up but you will need to make him stop going in a direction. Now you must create four other triggers to stop running.

Event: Player one release an arrow
Action:Unit Issue order with no target to stop.

Ok now we are nearly done with the arrow keys! But if you try it, every time you release an arrow the hero stop(that mean if you are going straight and than right, if you release up, your unit will stop even if you are going right)

So how do we change this? Easy, you only have to make all the stop trigger not in the initiation, create a trigger that close all those stop trigger and turn on the right stop trigger every time he press an arrow.

Bit hard to understand here's an example:
Trigger name: Up

Event: Player press up
Action:
-Order unit to move(like i did explain)
-run the trigger that turn off all the stop trigger
-turn on stop up.

Trigger name: Stop up(or left or right or down)

Event unit release up
Action: Unit issue order to stop

Trigger name: Close everything
event:no event(must be run)
Action: turn off Stop up, Stop down, Stop right, Stop left

Ok and now you got a nearly perfect working arrow system
Attached is an example of it.


Esc hotkey: Now that you can move throught your map with your arrow you want to make other thing! The esc event is really easy to use just make an event Player 1 skip a cinematic and add the action you like.

More advanced hotkeys: F1, F2, F3, F4, F5 and F8

These event are somekinda weird but... How it works:
First your hero must not be a player one unit and create a trigger that select your hero every 0.10 or bit more of the game.(these hotkey are not perfect but works)
Then you can start working on the triggers for reals!!!
How does triggers works?
Simple the event of those triggers are: Player one select a unit(F1,F2,F3,F4 and F5 must be an hero(that means you must select an hero to make the action occurs) and F8 must be an idle worker)
I don't know if you understand how it works I will try to explain it better. So you must create hero that when selected(when you press F1, F2, F3, F4, F5 and F8) an action will come. So, if you want to make f1 been a spell, create an hero, change his name, icon and model to the spell icon and name you want(there shouldnt be any model) and then you have your spell.

Having more options: Now you can even decide to add more ability or function by changing the team of the hero or unit. Like every event are made from the selection of hero or unit that you own, if you change the unit you own, you can have new function.

Download:
Attached is an example that I am working on. I don't want anybody to copy it. I am only showing it to give you an example. You can inspire something from it but you cannot steal it.

Please give me credits if it inspired you, give me comments or ask me questions, i will be glad to answer them.

PhantasyDreamer
Attached Files
File type: w3xSYSTEM_1.w3x (59.2 KB)
File type: w3xMOVING.w3x (18.3 KB)
05-14-2004, 12:24 AM#2
johnfn
This is a pretty good tutorial with a few minor grammer mistakes. I think what you need is more examples. I personally dont see what using the keyboard in wc3 could do good for you.
05-14-2004, 01:16 AM#3
Aznwhore
one problem about the trigger for moving up and down, however, wouldn't the offset bring the unit to the center of whatever direction it is directed towards?
i.e. move up: the unit would go toward the top center

EDIT: I think i might understand what you meant but can you give a more descriptive way of making the "Move up" trigger? i didn't quite understand it
05-14-2004, 01:17 AM#4
linkmaster23
Notice how he complains about grammar and spells the word grammar, 'grammer'. >:P
05-14-2004, 01:43 AM#5
johnfn
Lol. At the risk of spam-posting, I've done that before (allthough last time it was worse, I misspelled sentance - And not suprisingly I do it again- as well and i was still criticising the guys grammar).

The F# hotkeys are something Ive never heard of. Constant selection is a bit of a pain but there is always the 'alt' key...
05-14-2004, 01:52 AM#6
linkmaster23
Sigh, Sentence not sentance... >:P
05-16-2004, 09:49 AM#7
PhantasyDreamer
Ok there is lots of answer, thought this file was lost somewhere:P

Ok so I made a few trigger mistake in my tutorial.
This is bit more complex than I tought and doesn't look perfect(the control is prefect while).

So the mistake I made was that when you are on a real map, if you give a unit the order to go north( Unit- Issue order Hero to move offset 0,0 99999,0), if there are obstacles in front of him, he will have the order to reach a certain point in the map and will stop going north...

So to change this you must make something much more complex
Press up:
Event:Player 1 press up
Action:Run stop every stop
Turn up trigger goes up
Turn on stop up
Goes up:
Event: every .10 of the game
Action: Unit issue order to move 0,0 100,0

Stop up:
Event: Player one release up
Action: Unit issue to stop
Turn off Goes up

Stop every stop:
Event: No event
Action: Turn off Stop up, stop right, left and down

Now you must make goes down, left and right; Press down, right and left; Stop down right and left.

The only problem is that the unit animation have to many order at the time and the caractere often move with moving his legs:S

The major reason to use this system is that it allow you to add so many new system you couldnt add before and that it bring a much better gameplay
06-26-2004, 11:57 AM#8
Dragon_Crusader
I thought u might consider trying to make a trigger with left, right,... arrow when u finish it convert the trigger to custom script and change the parameters of 'Left Arrow' to another button, although i don't know the parameters of other buttons I hope I'm of any use to u all. Btw thx for your nice tutorial PhantasyDreamer
07-05-2004, 09:53 PM#9
Kelna2
Insted of doing the position on the map why not use a polar offset of the hero?
07-12-2004, 10:03 AM#10
Deathwing1989
Hey guys, I've got a serious problem here. It's about the ESC key. Here's my problem:
I've got a cinematic running and when I say Player 1 skips cinematic and then add something else, the first trigger doesn't switch off! It continues to run though the other trigger is switched on too. I tried with Trigger-turn off but this doesn't work cause it just prevents the trigger to run again but it doesn't stops it to finish at the moment. Somebody please help!
07-12-2004, 03:48 PM#11
PhantasyDreamer
Quote:
Originally Posted by Deathwing1989
Hey guys, I've got a serious problem here. It's about the ESC key. Here's my problem:
I've got a cinematic running and when I say Player 1 skips cinematic and then add something else, the first trigger doesn't switch off! It continues to run though the other trigger is switched on too. I tried with Trigger-turn off but this doesn't work cause it just prevents the trigger to run again but it doesn't stops it to finish at the moment. Somebody please help!
This is pretty simple. You must make something so, when you press esc, you skip the remaining action of the cinematic and just keep the game how it would be if the cinematic had just be complete. So you can make something like this:

Trigger 1: Event: cin skip
actions: turn on a dummy trigger

trigger 2(your cinematic): you must add the following action between all you wait action: If dummy trigger is on then skip remaining action, turn off dummy and run the trigger that will set how your things gonna be after the cin, else do nothing

and that is it
07-12-2004, 05:07 PM#12
Deathwing1989
Man, are you sure about this? Isn't there a better way? Cause there is a mistake- If..... then....... else isn't "do nothing" but the rest of the actions that have to pass. Here it is:
Actions:
............
............
............
wait 1 sec.
If...............
If dummy is on
then skip remaining actions
turn off dummy
run triger................
else (and here I've gotta put the whole stuff that will pass if this condition is false, if the player doesn't press the ESC button)
.................................
................................
.................................
.................................

.................................
,............................
...........................
................................. (These are the actions that have to be skipped if the condition is true)...
So it looks to me that if I have a big trigger and I have a lot of wait actions, man!, this is gonna be a great mess......
Sorry if I didn't get you right and I'll apreciate it if you tell me if I'm wrong. Cause off with my mind about that cin skip :(
09-09-2004, 08:14 PM#13
Daelin
My old pal writes a tutorial... I'm proud of him :D.
12-05-2004, 09:52 PM#14
koolmunkie
aright i found a problem, how do i make da hero go southwest or diagonal? o_O
12-07-2004, 02:06 PM#15
Kalvorod
What you can do instead, is by using polar offset (for those of you who never passed highschool geometry it means Direction,distance) you could make UP move you forward (Current Offset, 10) BACK move you back (Current Offset,-10) RIGHT and LEFT turn you (Current Offset+-10, 0).

I am now thinking of using this to make an Air Combat game, would there be anyway to make the UP arrow cause them to desend and DOWN arrow to raise?

If anyone wants to help me on this map, It's fine by me.


Edit: The ideas are pouring into my head as I type this. Each fighter would have a constent move Every .1seconds Move-(Current Offset, 20). Using the hero options I could have F#'s activate skills, such as evade and land, or missles and machine gun. If anyone knows where to get a good plane model (the starcraft ones will do if there are no others).