HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Consistently moving a unit in a specific direction

06-28-2007, 10:01 AM#1
Gerk
I've been doing some map/concept brainstorming, perhaps a bit on the over-idealistic side, and was wondering how one would go about doing the action stated in the thread's topic/title. That's to say, like, I hold the down arrow and my character runs directly south, stopping when they hit a wall.

I took a close look down on Blizzard's scenario map Azeroth Grand Prix to perhaps gain a better understanding of the action (in which your kart can move directly forward with the push/hold of a button and will impact walls, etc.)...but the meat of it is and was all but foreign to me.

Anyone have an idea/clues?
06-28-2007, 11:01 AM#2
Pyrogasm
hWell. That'd be a Triggers and Scripts question, and as such I shall move it.

More pertainent to your question, you would need to set up 8 triggers. 2 to detetect when a player presses/releases the up key, 2 for the right key, etc.

Then, you'll have every player's "kart" in a parallel array to its owning player's player number (AKA: "Karts[8]" belongs to Player 8), and when a player triggers an event, you'll add his kart to a unit-group (and remove it when he depresses the key) and then set up forward/back triggers like so:
Example Forward Trigger:
Collapse Events
Time - Every 0.03 seconds of game-time
Collapse Conditions
(Forward_Group is empty) equal to false
Collapse Actions
Collapse Unit Group - Pick every unit in Forward_Group and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are true) then do (Then actions) else do (Else actions)
Collapse If - Conditions
((Picked Unit) is in Backwards_Group) equal to false
----- To assure that a unit can't go backwards and forwards at the same time -----
Collapse Then - Actions
Set MovePoint1 = Position of (Picked Unit)
Set MovePoint2 = MovePoint1 offset by 15.00 towards (Facing of (Picked Unit)) degrees
Unit - Move (Picked Unit) instantly to MovePoint2
Custom script: call RemoveLocation(udg_MovePoint1)
Custom script: call RemoveLocation(udg_MovePoint2)
Else - Actions
And turning triggers like so:
Example Right Trigger:
Collapse Events
Time - Every 0.03 seconds of game-time
Collapse Conditions
(Right_Group is empty) equal to false
Collapse Actions
Collapse Unit Group - Pick every unit in Forward_Group and do (Actions)
Collapse Loop - Actions
Collapse If (All Conditions are true) then do (Then actions) else do (Else actions)
Collapse If - Conditions
((Picked Unit) is in Left_Group) equal to false
----- To assure that a unit cannot turn right and left at the same time -----
Collapse Then - Actions
Unit - Make (Picked Unit) face ((Facing of (Picked Unit)) - 5.00) degrees over 0.00 seconds
Obviously replacing all relevant math numbers with the appropriate ones for each direction.
06-28-2007, 08:11 PM#3
Gerk
Thank you very much. :)

But wouldn't a trigger firing off every 0.03 seconds of gametime absolutely destroy the system? @_@
06-28-2007, 09:20 PM#4
iNfraNe
Yes, windows will crash and your computer will catch fire.

For the 50000th time, the actions you do in the period of the trigger are what matters to speed. So, what your question should be is: doesnt moving alot of units around every 0.03 seconds slow down wc3.

Then the answer would be yes. Alot of units will slow it down, because it is using SetUnitPosition. This can be avoided by using SetUnitX / SetUnitY.
06-29-2007, 08:04 AM#5
Gerk
Quote:
Originally Posted by iNfraNe
For the 50000th time-

Stop. Relax. It was an inquiry posed in earnest.

Thanks for the answer itself, however.