Warcraft III resources & community, 2003–2006 · archived

Help ME!!!!

15 posts
#1

Help ME!!!!

I want my hero to move with a-w-s-d keys. How do i do it please help me
#2
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
#3
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.

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 ;)
#4
Thanks for answering but i still have few problems


-It isnt going left right or down, it only goes up
-I want unit not to stop when ı press, it goes a while and stops
#5
First 1 is done. It was my fault but can u answer the 2nd one?
#6
i did the 2nd one too. Thank you, you really helped me. :wink:
#7
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 )
#8
Open the map Azeroth Grand Prix, u can see it in there
#9
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
#10
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
#11
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
#12
I'm not that much smart :)

"Add each of the key related events/triggers at the end the line "Run [Movement Trigger] checking conditions." "

I didn't understand this part...
#13
Ok thank you i did it, now i can go any directions but i didn't understand what is timer used for in here...
#14
you can have fpsmod. and take trigger from blademaster mod (maps)!!!
#15
Another problem;

Player will enter his/her name and hero's name will be replaced with it...Can you tell me how?