• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help ME!!!!

Status
Not open for further replies.
Level 4
Joined
Jan 3, 2005
Messages
91
The problem about wc3 is that you can only really monitor the arrow keys (key pressing, holding, releasing) and you can detect abilities (activated via hotkeys). Also you can use the F1 to F8 keys with selection events..

You can change the hotkeys locally on your computer, but that doesn't count for other computers..

klovadis
 
Level 3
Joined
Jan 10, 2005
Messages
72
This is to make your unit move with arrows...

It's not so complicated. You only need couple of vars and triggers.
Ok, lets beggin.
1. Create variable named (name it whatever you like) 'move_offset'. The type of var should be 'real' and set it to which ever value you like (I recomend 150). The value you've set is how much unit will move from current position when pressing corresponding key.

2. Create following triggers. Change 'unit_here' with unit that will move by keyboard.

JASS:
Key Left
    Events
        Player - Player 1 (Red) Presses the Left Arrow key
    Conditions
    Actions
        Unit - Order unit_here to Move To ((Position of unit_here) offset by ((0.00 - move_offset), 0.00))

Key Right
    Events
        Player - Player 1 (Red) Presses the Right Arrow key
    Conditions
    Actions
        Unit - Order unit_here to Move To ((Position of unit_here) offset by ((0.00 + move_offset), 0.00))

Key Up
    Events
        Player - Player 1 (Red) Presses the Up Arrow key
    Conditions
    Actions
        Unit - Order unit_here to Move To ((Position of unit_here) offset by (0.00, (0.00 + move_offset)))

Key Down
    Events
        Player - Player 1 (Red) Presses the Down Arrow key
    Conditions
    Actions
        Unit - Order unit_here to Move To ((Position of unit_here) offset by (0.00, (0.00 - move_offset)))
The function type of function after 'Move To' is 'Point with Offset'.


That's it, I hope it helps ;)
 
Level 3
Joined
Jan 10, 2005
Messages
72
You're welcome, glad to help :)

Btw, can you tell me how you did the 2nd, because I used one rather looong solution, so I wanna see if there's more simple one (I somehow always find the hardest and longest solutions to problems :p )
 
Level 8
Joined
Jun 2, 2005
Messages
96
My solution is not considered as a solution. I just changed 150 to 1000. I understood that for example if there is 400 in front of you and if your variable is 500 it tries to find another way to go there because the distance infront of you isn't enough. So adjust it as your needs.
Can you tell me your one because mine one isn't a good solution.
By the way Azeroth Grand Prix's is too complicated. There are handwritten triggers so you can't do it in your map. At least ı can't
 
Level 3
Joined
Jan 10, 2005
Messages
72
I know about changing offset lol, I told you that in trigger post above :)
But I also used Jass to make unit move while you hold key down, and I was interested if there's a shorter solution
 
Level 4
Joined
Jan 3, 2005
Messages
91
hmm a bit a half-harted solution. This won't allow you to keep walking in one direction by holding one key. It also doesn't allow walking north-east, south-east, ..

If you want to work exactly, you should make 4 boolean variables, each for one direction (i.e. Key_Left, Key_Right, ..). If a player presses a key, you set the linked boolean to true, as soon as the player releases that key, set its bool to false.

Then you need a countdown timer (I'll call it mTimer) and a trigger (Call it "Movement Trigger"), that has the event "A Timer [mTimer] expires" and the condition (real) "Remaining Time for [mTimer] == 0". Add each of the key related events/triggers at the end the line "Run [Movement Trigger] checking conditions."

Now in this movement trigger, add for every direction (8) an IF/THEN/ELSE condition asking for the special set of keys that must be pressed to move into that direction. The THEN action orders the unit to move there, activates the "mTimer" to count-down and skipps remaining actions (this saves pc capacity).

The distance between where you send your unit and its actual position and the countdown time depend on your units movement speed and the duration of 1 animation cycle of the "walk" animation. The distance is less important than the animation duration, try adjusting the countdown time first. (You should store both into variables so you can adjust them more easily.)

Moving units diagonally works by multiplying both x and y distances with the squareroot of 2, thus about 1.4142. Use -1.4142 on the coordinates you need to flip. The correct line should look like this:

Unit - Order unit_here to Move To ((Position of unit_here) offset by ((1.4142 * move_offset), (1.4142 * move_offset)))


When used correctly, this allows you to smoothly move your unit across a world. Since the move_offset (= distance) is rather small and the triggers check quite often, you don't have your unit walk over all the map because it had been ordered to walk over a river. Can be seen in my bomberman map.


klovadis
 
Status
Not open for further replies.
Top