wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Tutorials > Trigger (GUI)/ AI editor Tutorials
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 02-25-2005, 01:37 PM   #1
Ant
User
 
Join Date: Jan 2003
Posts: 564

Submissions (1)

Ant will become famous soon enough (28)

Default Almighty Arrow Controls

Note: Basic Triggering knowledge required

TFT added a major feature in the map editor that was both easy to implement, and the only keydetect and keypress features in the map editor -- Arrow key detection. Now, just with a few triggers, you can create great keyboard movement (no more button mashing).

The arrow key event is under player events. Player - Keyboard Event.

There are only two parts in the arrow key event. One part is to detect when an arrow key has been PRESSED. The other part is to detect when an arrow key has been RELEASED.

Section 1 -- Press/Release detection
So you've created your dream map. Your almighty rat is ready to run around in a maze... or something... now all you need is KEYBOARD CONTROLS! To begin with, I'll start with some very good keyboard control practices to keep track with whether a key is pressed or released. Just use a variable to store data on when a key has been pressed or released... here's how you do it.

First, create a variable for each direction. Each arrow key, rather. So you should have variables "Up", "Down", "Left", and "Right". Let's just make them integers.

Begin Trigger
Event -- Player 1 Presses the Up Arrow Key
Action -- Set Up = 1
End trigger
Now that we have a trigger to store the arrow key being pressed, let's do one for it being RELEASED!
Begin Trigger
Event -- Player 1 Releases the Up Arrow Key
Action -- Set Up = 0

Now do the same for all the other arrow keys. So now when an arrow key is pressed its respective variable will turn to 1, and when it is released its respective variable will turn to 0.

Section 2 -- Isometric Movement
Now you want your almighty rat to move left when you press left, and stop moving left when you release it. Not only that, being a greedy turd, you want it to be able to move diagonally as well when you press TWO arrow keys. Have no fear! Mighty mouse is here!

Isometric movement is when you have a camera looking down, and your character can only move in 8 directions. Up, down, left, right, and the 4 diagonals.

First, create your movement triggers. You should have Eight of them in all, one for each direction. They should be something along these lines:

Event (Time - Periodic event) -- Every 0.20 seconds of time
Action -- Order unit to Move To Position of Unit offset by 200 towards 90 degrees.

This is action is under the action Unit - order unit to move to point. Order it to move to Point with Polar offset. The Unit should be the almighty rat, or whatever unit you want to move. Offset by 200 is how much the unit moves. Set it higher or lower depending on how fast your unit moves. Try to make it as precise as possible to make the game fluent. Towards 90 degress orders it to move towards a certain direction. If you want an isometric game, make 8 triggers changing only this field, making the degrees in increments of 45.

Once you are done making events and actions, you have all the actions for making the unit move in all 8 directions! Now we have to make conditions to make the unit move in whatever direction you want it to!

Event (Time - Periodic event) -- Every 0.20 seconds of time
Action -- Order unit to Move To Position of Unit offset by 200 towards 90 degrees.
Let's say this trigger makes the unit move UP. Set four conditions (Integer-comparison) as follows.
[i] Condition start [i]
Up = 1
Down = 0
Right = 0
Left = 0
[i] Condition end [i]
Now the trigger to move the unit up will only execute when the arrow key for up is held.
Now do the same for the other 8 triggers. If the trigger makes it move left, set the condition Left = 1 and the other conditions to = 0. If the trigger makes it move down-right, set the condition to Down = 1 and Right = 1 and all other conditions to = 0.

That does it for isometric arrow key movements! If you need help, feel free to PM me, but first be sure to search the forums. The camera commands are all there.

Section 3 -- Third Person controls
Mighty mouse is gone! Now it's Terrible Tank! Our very own third person action hero! You click and he moves... but clicking alone is not enough... you need ARROW KEY MOVEMENTS!

The difference between third person and isometric is that you can turn any angle, and move in any direction. So the Up arrow key makes you move forward, while the left and right arrow keys make you turn

Now, you have to make a trigger to move Terrible Tank forward! Much like the trigger for isometric movement:

Event (Time - Periodic event) -- Every 0.20 seconds of time
Conditions -- Up = 1
Down = 0
Left = 0
Right = 0
Action -- Order unit to Move To Position of Unit offset by 200 towards Facing of Unit degrees.

This time, we have changed <insert number here> to the facing of unit. This is under Unit - Facing angle
This trigger makes the unit move straight forward.

The terrible tank wouldn't be a terrorising threat if it couldn't turn. There are two types of turns the terrible tank can make. Stationary turns, and mobile turns. Unfortunately, the stationary turns and mobile turns all run on the SAME TURNING KEY! In the words of TillerMaN, "WHAT CAN I DEW!".

Fret not! Simply create a trigger like this!
Event (Time - Periodic event) -- Every 0.20 seconds of time
Conditions -- Up = 0
Down = 0
Left = 1
Right = 0
Action -- If (All conditions are True) then do (Then actions) else do (Else actions)
- If Conditions
Up = 1
- Then - Actions
Action -- Order unit to Move To Position of Unit offset by 200 towards Facing of Unit + 15 degrees.
- Else - Actions
Action -- Make Unit face Position of Unit offset by 100 towards Facing of Unit + 15 degrees over 0.1 seconds

Anytime you see (something + something), or (something - something), this field is under arithmetic.
You can change the 200 to the speed as you like it, and the Facing of Unit + 15 to facing of unit + any number. Also, this way you can make stationary turns faster or slower than mobile turns.

To create a trigger to moving and turning right, simply change the +'s to -'s to change left to right! Also make sure you change the conditions!

Turning is not very precise at high speeds, that's why the tank is a TANK.

Section 4 -- Finishing up
Now that you're done, you gotta try to make your arrow keys as sensitive as possible. Firstly, you gotta run the trigger everytime an arrow key is pressed, so you don't have to wait for the 0.20 seconds to finish before your trigger executes.

Action -- Run Trigger checking conditions.

That trigger is under the action Trigger - Run (checking conditions). Run every single trigger that could be executed when the up arrow key is pressed. Of course, if you did conditions properly, you can run EVERY movement trigger (checking conditions). Wouldn't hurt.

About periodic times.
Sometimes you may be tempted to put 0.01 periodic events to make your movement really fluid. I advise you to put nothing less than 0.15 seconds in your periodic trigger. Doing so will not only result in lag, but also in your unit jerking like hell. If you somehow can, go ahead. If you can't don't bother.

You can also create platform games and shooting games (sorta) with this system. Just modify the cameras a bit and get to work. Go search the forums for cameras.

If you need help, PM me. I'll be glad to help.
__________________
lolpanda
Ant is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 02-28-2005, 03:23 PM   #2
divine_peon
User


Respected User
 
Join Date: Jul 2005
Posts: 593

divine_peon is on a distinguished road (17)

Default

very nice tut ant. but i already now this through your map in draco's tutorial. heh.
__________________
divine_peon is offline   Reply With Quote
Old 03-18-2005, 03:19 PM   #3
DarthMora
 
Posts: n/a
Default

WAT are the variables?unit?order?
  Reply With Quote
Old 03-18-2005, 04:05 PM   #4
Ant
User
 
Join Date: Jan 2003
Posts: 564

Submissions (1)

Ant will become famous soon enough (28)

Default

Variables up, down, left, right, can be any variable you like, but I stated in the tutorial that they are integers. They can be reals, they should be booleans if you're really concern about memory space, but I like integers cause they can be used to take in more than two values.

I also stated in the tutorial what the order you give is. For the units, doesn't really matter does it -.-
__________________
lolpanda
Ant is offline   Reply With Quote
Old 04-04-2005, 07:46 PM   #5
MeTaCo
User
 
Join Date: Aug 2003
Posts: 80

MeTaCo has little to show at this moment (0)

Default

I have a major question! this is a simple foremost tut no doubt, but what if you want a player to trigger a unit to move with keyboard, BUT not allow the unit to move on mouse click? for example the map : Azurath grandprix, u can't clik in it, I suppose they set the movement of the unit to 0? using jass probably, but how can u make the unit still move? will the triggers u put in still work? :(
__________________

Oh yeh baby.. YoUr AsIaN mAsTuH!
MeTaCo is offline   Reply With Quote
Old 04-05-2005, 10:15 AM   #6
Ant
User
 
Join Date: Jan 2003
Posts: 564

Submissions (1)

Ant will become famous soon enough (28)

Default

It's simply replacing the triggers for ordering the unit to move to moving the unit itself. So instead of ordering unit to move to point, simply us the trigger Move Unit to point (facing direction) instantly.
__________________
lolpanda
Ant is offline   Reply With Quote
Old 05-19-2005, 10:31 AM   #7
Panzer_Buster
 
Posts: n/a
Default

Thanks alot. I have been looking for this kind of tut for a long time.

Big Thanks
  Reply With Quote
Old 06-05-2006, 12:14 PM   #8
Bob Frank
User
 
Join Date: May 2006
Posts: 4

Bob Frank has little to show at this moment (0)

Default

Gah! An you please give me step-by-step directions to this action:
Action -- If (All conditions are True) then do (Then actions) else do (Else actions)
I can't find the (All conditions are True) bit.
Bob Frank is offline   Reply With Quote
Old 06-05-2006, 01:14 PM   #9
Whitehorn
SPOON!
 
Whitehorn's Avatar


Respected User
 
Join Date: Sep 1983
Posts: 4,900

Submissions (114)

Whitehorn is a name known to all (510)Whitehorn is a name known to all (510)Whitehorn is a name known to all (510)Whitehorn is a name known to all (510)Whitehorn is a name known to all (510)

Default

Arrow keys! Are you left handed? Ergonomics, my friend.
__________________
My Wargame

Be excellent to each other.
Whitehorn is offline   Reply With Quote
Old 06-06-2006, 08:03 AM   #10
Bob Frank
User
 
Join Date: May 2006
Posts: 4

Bob Frank has little to show at this moment (0)

Default

Actually, I found out where that action was about two minutes after I posted, but I was pressed for time. I would have said thanks if somebody answered my question anyway, but I have no idea what you're rambling on about...
Bob Frank is offline   Reply With Quote
Old 06-07-2006, 12:14 PM   #11
Murloc Lover
Now with more slime
 
Murloc Lover's Avatar
 
Join Date: Apr 2003
Posts: 727

Murloc Lover will become famous soon enough (58)Murloc Lover will become famous soon enough (58)

Send a message via MSN to Murloc Lover
Default

Using Wads instead of arrows would be much more difficult...setting them as ability hotkeys could work.

Last edited by Murloc Lover : 06-07-2006 at 12:14 PM.
Murloc Lover is offline   Reply With Quote
Old 08-22-2006, 03:14 AM   #12
Kryis
User
 
Join Date: Aug 2006
Posts: 5

Kryis has little to show at this moment (1)

Send a message via AIM to Kryis
Default

Quote:
Fret not! Simply create a trigger like this!
Event (Time - Periodic event) -- Every 0.20 seconds of time
Conditions -- Up = 0
Down = 0
Left = 1
Right = 0
Action -- If (All conditions are True) then do (Then actions) else do (Else actions)
- If Conditions
Up = 1
- Then - Actions
Action -- Order unit to Move To Position of Unit offset by 200 towards Facing of Unit + 15 degrees.
- Else - Actions
Action -- Make Unit face Position of Unit offset by 100 towards Facing of Unit + 15 degrees over 0.1 seconds

Um I dont think you can have the conditions say Up = 0 and then have if it = 1 because that would just ignore it. Dont you just leave the Up variable out of the first condition
Kryis is offline   Reply With Quote
Old 11-09-2006, 05:43 AM   #13
RPGOD
User
 
Join Date: Nov 2006
Posts: 5

RPGOD has little to show at this moment (0)

Default

Probably the must useful question out of this whole bit of rambling Kryis.
RPGOD is offline   Reply With Quote
Old 11-10-2006, 05:01 PM   #14
RPGOD
User
 
Join Date: Nov 2006
Posts: 5

RPGOD has little to show at this moment (0)

Default

Ant, if you wouldn't mind, it would help ALOT of you post an example map. I'm having a bit of trouble getting this down pat. Thank you!
RPGOD is offline   Reply With Quote
Old 11-21-2006, 02:15 AM   #15
Feroc1ty
User
 
Join Date: Nov 2006
Posts: 304

Feroc1ty is on a distinguished road (14)

Default

Nice, but 4 triggers cointaining every 0.2 secs may cause lag problems.
Solution.
Trigger:
thingy
Collapse Events
Time - Elapsed game time is 0.20 seconds
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
up Equal to True
down Equal to False
left Equal to False
right Equal to False
Collapse Then - Actions
Custom script: your actions here // too lazy to put them in :P
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
up Equal to False
down Equal to True
left Equal to False
right Equal to False
Collapse Then - Actions
Custom script: your actions here // too lazy to put them in :P
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
up Equal to False
down Equal to False
left Equal to True
right Equal to False
Collapse Then - Actions
Custom script: your actions here // too lazy to put them in :P
Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
upEqual to False
down Equal to False
left Equal to False
right Equal to True
Collapse Then - Actions
Custom script: your actions here // too lazy to put them in :P
Else - Actions
Feroc1ty is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 05:58 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services