Tutorial Sliding on Ice

Komaqtion

You can change this now in User CP.
Reaction score
469
Sliding on Ice


Ok, so I wrote this for someone on the forum, but it became so long, that I thought I'd post it here XD

Ok, well first open op you Trigger Editor :D

Variables

Unit-Group

Then we're gonna make the variables as a first step...
So press Ctrl + B and a small window will pop up.
Now press Ctrl + N and another smaller window will pop up.
Now we're creating a variable, so first type in the name of it... It's easier if you write exactly what I wrote, Temp_Group.
Then, in the drop down below the name, select Unit-Group and click ok, and you've created a Unit-Group variable ;)

Point

Now press Ctrl + N again and instead type TempPoint and in the drop down select Point.
Then do the same again, but type TempPoint2 instead as the name, and select Point again :D

So now we're done with the variables, and gonna start with the trigger.
So first create a new trigger (Ctrl + T), and name it something... Mine is named "Slide on Ice" ;)

Event

Then Ctrl + E to create an event for this, and select the event, Time - Periodic Event.
Then change the blue word to 0.03 and click ok.

It should look like this now:
Trigger:
  • Slide on Ice
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions


Actions

Setting up

Now we've gotten to the actions :D

So press Ctrl + R to create a new action, and in the drop down select "Set Variable".

Here change the red word "Variable" to your newly created Unit-Group variable, Temp_Group.
Then change the (now) red word "Value" to "Units In Region Matching Condition".


Now click the red "Condition", and the there should be a drop down saying Boolean Comparison...
Click the first blue part "(Triggering unit) is A structure", and change (Triggering unit) to (Matching unit).
Click "Ok", and now change "True" to "False", and click "Ok" till you get back to the Trigger Editor.
Now it should look like this:

Trigger:
  • Slide on Ice
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to False))


Unit-Group

Now we're going to make a Unit-Group loop from this unit group which was just set.
So create a new action, and select:

Unit Group - Pick Every Unit In Unit Group And Do Multiple Actions

Now change the blue part here, to your newly created Unit Group variable, Temp_Group.
Click "Ok", and now Right-Click this:
Code:
Unit Group - Pick every unit in Temp_Group and do (Actions)
    [COLOR="Red"]Loop - Actions[/COLOR]

And select "New Action" and select "Set Variable"... Now we're going to set the "TempPoint" variable. So select that one where it says "Variable" (in red).

Now click the drop down menu, and select "Position of Unit", and change the blue "Triggering unit" to "Picked unit".
Click "Ok", and now we need to check if the unit we picked is actually on ice, so we're going to use the action called:
"If / Then / Else, Multiple Functions"

If / Then / Else

Click "Ok" and now Right-Click where it says "If - Conditions":

Code:
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    [COLOR="Red"]If - Conditions[/COLOR]
    Then - Actions
    Else - Actions

Now select the condition, "Or - Multiple Conditions"... This is only needed if you want units to be able to slide on different kinds of terrain.
Now Right-Click where it says "Conditions" and create a new condition and change it to (In the drop down menu) Terrain-Type comparison.

It should look something like this.
(Terrain-type at (Center of (Playable map area))) Equal to Lordaeron Summer - Dirt

Here you should change (Center of (Playable map area)) to the newly set variable, TempPoint, and also Lordaeron Summer - Dirt to Icecrown Glacier - Ice.
Now do the same again, (If you want multiple terrain-types) but just change the "Lordaeron Summer - Dirt" to something else, like maybe Icecrown Glacier - Dark Ice.
If you don't want multiple terrain-types, just skip the "Or" condition and just create the condition itself ;)


Now you should Right-Click where it says "Then - Actions" create another one of the "Set Variable" action.
Here, you're going to set TempPoint2 as the (In red) "Variable", and the (Now also red) "Value" to the thing called "Point With Polar Offset".

Now change (Center of (Playable map area)) to TempPoint, and change 256.00 to 10.
Now click the 0.00, and beside where it says "Function", click the drop down menu.
Go down to Unit - Facing Angle, and change this to Facing of (Picked unit)
Click ok till you come back to the Trigger Editor.

Now it should look like this:
Trigger:
  • Slide on Ice
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to False))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at TempPoint) Equal to Icecrown Glacier - Ice
                  • (Terrain type at TempPoint) Equal to Icecrown Glacier - Dark Ice
            • Then - Actions
              • Set TempPoint2 = (TempPoint offset by 10.00 towards (Facing of (Picked unit)) degrees)



Hope it does for you :D

Custom Script

Now it's only 5 actions left, and all of them are called "Custom Script", and here you just write with your keyboard, so as long as you copy what I've written, you should be fine:D

So create a new action, and in the drop down, select Custom Script.
Now click the red ""Script Code" and copy this:

call SetUnitX(GetEnumUnit(),GetLocationX(udg_TempPoint2))

then create another one of this action, and copy this:

call SetUnitY(GetEnumUnit(),GetLocationY(udg_TempPoint2))


Leak Cleaning


call RemoveLocation(udg_TempPoint2)

And then you should Right-Click this line:

Code:
[COLOR="Red"]If (All Conditions are True) then do (Then Actions) else do (Else Actions)[/COLOR]
    If - Conditions
        Or - Any (Conditions) are true
            Conditions
                (Terrain type at TempPoint) Equal to Icecrown Glacier - Ice
                (Terrain type at TempPoint) Equal to Icecrown Glacier - Dark Ice
    Then - Actions
        Set TempPoint2 = (TempPoint offset by 10.00 towards (Facing of (Picked unit)) degrees)
        Custom script:   call SetUnitX(GetEnumUnit(),GetLocationX(udg_TempPoint2))
        Custom script:   call SetUnitY(GetEnumUnit(),GetLocationY(udg_TempPoint2))
        Custom script:   call RemoveLocation(udg_TempPoint2)
    Else - Actions

And then create this Custom Script:

call RemoveLocation(udg_TempPoint)

(This was because we needed this line to end up below then "If / Then / Else" action :D)

Now you're going to Right-Click this:

Code:
[COLOR="Red"]Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)[/COLOR]
    Loop - Actions

And create another "Custom Script" action, and copy this:

call DestroyGroup(udg_Temp_Group)

And now it should look like this:

Trigger:
  • Slide on Ice
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set Temp_Group = (Units in (Playable map area) matching (((Matching unit) is A structure) Equal to False))
      • Unit Group - Pick every unit in Temp_Group and do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • (Terrain type at TempPoint) Equal to Icecrown Glacier - Ice
                  • (Terrain type at TempPoint) Equal to Icecrown Glacier - Dark Ice
            • Then - Actions
              • Set TempPoint2 = (TempPoint offset by 10.00 towards (Facing of (Picked unit)) degrees)
              • Custom script: call SetUnitX(GetEnumUnit(),GetLocationX(udg_TempPoint2))
              • Custom script: call SetUnitY(GetEnumUnit(),GetLocationY(udg_TempPoint2))
              • Custom script: call RemoveLocation(udg_TempPoint2)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_TempPoint)
      • Custom script: call DestroyGroup(udg_Temp_Group)


And you're done :D

Now you just need to put the terrain, Icecrown Glacier - Ice (Or if you used the "Or" condition, any of those terrains) somewhere on the map, and the units should slide ;)

Good luck :D
 

Attachments

  • Slide on Ice, by Komaqtion!.w3x
    14.3 KB · Views: 247

Tom_Kazansky

--- wraith it ! ---
Reaction score
157
Set Temp_Group = (Units in (Playable map area) matching ((Terrain type at (Position of (Matching unit))) Equal to Icecrown Glacier - Ice))

that point leaks, also every 0.01s -> many point leak :rolleyes:, about 100 times number of units in map I guess :eek:

also I think 0.04 is good enough ;)
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Points in conditions don't leak, do they ??? :S

And since it's GUI, it's only 0.27 still right ??? :S
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
TriggerSleepAction is 0.27 second, but this is TriggerRegisterTimerEvent(..), like timer..

Using Jass will more easy to manipulate it...
 

Komaqtion

You can change this now in User CP.
Reaction score
469
Oh, yeah sorry... Mixed them up XD

Changed to 0.03..

And I didn't do this in JASS, because JASS is just copy-paste, so then this would be a system in that case almost, right :p
 

Dinowc

don't expect anything, prepare for everything
Reaction score
223
you should also enable steering
it's easy

I already made that for someone long time ago

here I've found it

since it is in GUI, it's not perfect but :p (uses custom value)
 

Azlier

Old World Ghost
Reaction score
461
>What do you mean "steering" ??

While the unit is sliding, you tell him to move somewhere. He turns to face that direction.

>Points in conditions don't leak, do they ??? :S

They do. Which means this leaks insanely.

>Changed to 0.03..

...Where? I still see 0.01.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
You can change direction... Just Right-Click, and you change direction :D

Oh, haven't uploaded the new yet XD Sorry :( Will change the leak too then :D
 

D.V.D

Make a wish
Reaction score
73
There already is a tutorial made for sliding units in GUI and there already is a system for it too so this is basically just a repeat.
 

Romek

Super Moderator
Reaction score
963
You're not explaining anything that you're doing; only describing it.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top