HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

arrow key movement

07-04-2006, 01:35 PM#1
Xios
hi guys im making a multiplayer rpg map and i need to make it so when you hold down the up arrow you walk forward untill you release it, left arrow rotates you untill you release it.
also is there a way that they work together at the same time, e.g walk in a circle by pressing up and left.


this is what i got already:

Trigger:
press up
Collapse Events
Player - Player 1 (Red) Presses the Up Arrow key
Conditions
Collapse Actions
Trigger - Run up move <gen> (checking conditions)

Trigger:
up move
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Move To ((Position of (Picked unit)) offset by (0.00, 30.00))

Trigger:
up stop
Collapse Events
Player - Player 1 (Red) Releases the Up Arrow key
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Stop
07-04-2006, 02:07 PM#2
iNfraNe
What you must do is:
Trigger:
press up
Collapse Events
Player - Player 1 (Red) Presses the Up Arrow key
Conditions
Collapse Actions
Trigger - Enable up move <gen>

Trigger:
up move // disabled
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Move To ((Position of (Picked unit)) offset by (0.00, 30.00))
Trigger:
up stop
Collapse Events
Player - Player 1 (Red) Releases the Up Arrow key
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Stop
Trigger - Disable up move <gen>
However, this all still needs some work seeing it leaks memory and it would be a hell lot easier to use variables like "hero" here. But I dont have the time for the moment to write it. Hope this helps a bit.

P.S. it also moves the unit always to the top, not matter where it is facing, use polar projection for that.
07-04-2006, 02:21 PM#3
Xios
Quote:
Originally Posted by iNfraNe
What you must do is:
Trigger:
press up
Collapse Events
Player - Player 1 (Red) Presses the Up Arrow key
Conditions
Collapse Actions
Trigger - Enable up move
Trigger - Enable up stop<gen>
i think you will need to enable up stop aswell, seeing as you disabled it.

also you say it moves it to the top, i want it to move forwards, the way it is facing.


i think about the polar offset ive messed with it and came up with this.

Trigger:
Untitled Trigger 003
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse Unit Group - Pick every unit in (Units in (Playable map area) owned by Player 1 (Red)) and do (Actions)
Collapse Loop - Actions
Unit - Order (Picked unit) to Move To ((Position of (Picked unit)) offset by 256.00 towards (Facing of (Picked unit)) degrees)
07-04-2006, 03:41 PM#4
The)TideHunter(
Use this:
It should work well.

Trigger:
Enable Up
Collapse Events
Player - Player 1 (Red) Presses the Up Arrow key
Conditions
Collapse Actions
Set Up = True
Set Down = False

Trigger:
Enable Down
Collapse Events
Player - Player 1 (Red) Presses the Down Arrow key
Conditions
Collapse Actions
Set Down = True
Set Up = False

Trigger:
Enable Left
Collapse Events
Player - Player 1 (Red) Presses the Left Arrow key
Conditions
Collapse Actions
Set Left = True
Set Right = False

Trigger:
Enable Right
Collapse Events
Player - Player 1 (Red) Presses the Right Arrow key
Conditions
Collapse Actions
Set Right = True
Set Left = False

Trigger:
Disable Up
Collapse Events
Player - Player 1 (Red) Releases the Up Arrow key
Conditions
Collapse Actions
Set Up = False

Trigger:
Disable Down
Collapse Events
Player - Player 1 (Red) Releases the Down Arrow key
Conditions
Collapse Actions
Set Down = False

Trigger:
Disable Left
Collapse Events
Player - Player 1 (Red) Releases the Left Arrow key
Conditions
Collapse Actions
Set Left = False

Trigger:
Disable Right
Collapse Events
Player - Player 1 (Red) Releases the Right Arrow key
Conditions
Collapse Actions
Set Right = False

Trigger:
Move Up
Collapse Events
Time - Every 0.10 seconds of game time
Collapse Conditions
Up Equal to True
Collapse Actions
Set TempPoint = (Position of MovingUnit)
Set TempPoint2 = (TempPoint offset by 50.00 towards (Facing of MovingUnit) degrees)
Unit - Order MovingUnit to Move To TempPoint2
Custom Sctipt: call RemovePoint(udg_TempPoint)
Custom Sctipt: call RemovePoint(udg_TempPoint2)

Trigger:
Move Down
Collapse Events
Time - Every 0.10 seconds of game time
Collapse Conditions
Down Equal to True
Collapse Actions
Set TempPoint = (Position of MovingUnit)
Set TempPoint2 = (TempPoint offset by 50.00 towards ((Facing of MovingUnit) + 180.00) degrees)
Unit - Order MovingUnit to Move To TempPoint2
Custom Sctipt: call RemovePoint(udg_TempPoint)
Custom Sctipt: call RemovePoint(udg_TempPoint2)

Trigger:
Slide Left
Collapse Events
Time - Every 0.10 seconds of game time
Collapse Conditions
Left Equal to True
Collapse Actions
Unit - Make MovingUnit face ((Facing of MovingUnit) - 10.00) over 0.00 seconds

Trigger:
Slide Right
Collapse Events
Time - Every 0.10 seconds of game time
Collapse Conditions
Right Equal to True
Collapse Actions
Unit - Make MovingUnit face ((Facing of MovingUnit) + 10.00) over 0.00 seconds



Yes.... alot of triggers.

EDIT: I Made temppoints but forgot to delete them
07-04-2006, 03:45 PM#5
Xios
mabie you should put that as a tutorial so newbies like me can learn, not just copy it!
07-04-2006, 03:51 PM#6
dvdgstwrt
Wait Stop - go back turn around, left my arrow....

Actually there is an RPG system Download map which has stuff like this: http://www.wc3campaigns.net/showthread.php?t=82622

In case that link don't work.

Go to Resources/Demo Maps/Systems the map in question is called RPG System -ver 1

The Author has made a very nice arrow key movement system (along with other things) and his triggers are explained very well with comments.

Special note - Although the save claims to not work it does - It would appear that the Author of the Map updated the ability but didn't update the tool tip.
07-04-2006, 04:18 PM#7
Alevice
I would suggest for displacement use powers of 2, as that is the grid base.

And since you can't be up and down, or left and right at the same time, I suggest simplifying like:

Trigger:
Collapse Move Up/Down
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Set TempPoint = (Position of MovingUnit)
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Up Equal to True
Collapse Then - Actions
Set TempPoint2 = (TempPoint offset by 64.00 towards (Facing of MovingUnit) degrees)
Unit - Order MovingUnit to Move To TempPoint2
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Down Equal to True
Collapse Then - Actions
Set TempPoint2 = (TempPoint offset by 64.00 towards (Facing of MovingUnit)+ 180.00 degrees)
Unit - Order MovingUnit to Move To TempPoint2
Else - Actions
Collapse
Custom Script: call RemovePoint(udg_TempPoint)
Custom Script: call RemovePoint(udg_TempPoint2)

Trigger:
Slide Left/Right
Collapse Events
Time - Every 0.10 seconds of game time
Conditions
Collapse Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Left Equal to True
Collapse Then - Actions
Unit - Make MovingUnit face ((Facing of MovingUnit) - 22.50) over 0.00 seconds
Collapse Else - Actions
Collapse If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Collapse If - Conditions
Right Equal to True
Collapse Then - Actions
Unit - Make MovingUnit face ((Facing of MovingUnit) + 22.50) over 0.00 seconds
Else - Actions
07-04-2006, 05:58 PM#8
The)TideHunter(
I made it so you cant go up and down at the same time anyway.
Look at the Enable triggers, the disable the opposite movement.
07-04-2006, 06:16 PM#9
Alevice
Yeah, I get that, but I think 2 triggers are better than 4, don't you think ;P
07-04-2006, 06:24 PM#10
The)TideHunter(
I think yes, but its not actually better.
Using alot of code in a trigger with a IF is not as good as a single bit of code with no IF.
Its alot slower.
07-04-2006, 06:40 PM#11
Alevice
Unless the condition section is evaluated a lot faster than any conditions within the action section, I don't see the real speed improvement at all, particularly when in your triggers your 4 IFs (conditions) statements are ALWAYS evaluated . In mine, if left is true, it doesn't bother to check if right is true.

Besides, only one action is actually executed within the ifs. (EDIT: which it shouldn't, damn *goes to fix*)