• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Whisp Wheel - GUI - Leakfree

Whisp Wheels - GUI Tutorial
Introduction
Hey all, I've decided to post an Tutorial about Whisp Wheels.
Basics
What you need:
(Mark on monitor if you have it)
Brain and a sense of humor ( )
World Editor open ( )
Music on ( )
Alot of boredom or freetime (Alternatively wanna make an Escape) ( )
What you get:
A full Functional Whispwheel with even more coolness. :D

Whats a whisp wheel?:
A whisp wheel has atleast 2 Parts:
The basic unit (1) which is placed to the middle so other wheels can spin around.
The wheel part (2) is the spinning part around the wheel basic unit (1).
You can also do a wheel part spinning around the wheel part around the wheel unit, but thats something I will describe later.
wheelra0.png


Starting:
Well basicly open World Editor, create a new map, delete all triggers and add a new category. Call it Whisp Wheels.

Then do a Initial Trigger which call Whisp Wheels to start on Mapstart.

  • Event: Elapsed game time equal to 0.00
  • Condition:
  • Action:
We do this because we want them to trigger on map start, not on map load.

Please notice that placing too much wheels may delay the start and cause errors, so you can also add waits between intialising wheels so you don't have that problem.

What do we need now?​
Hmm I think we are ready... Oh wait this just began!

Now think again... A whisp wheel is atleast 2 unit on your map, but we have 0! (Or atleast 0 we need).

So lets place 2 units on map! One main unit (You can use a Scout Tower if you want ) and a part (Use a whisp maybe).

So we use this action:
  • Unit - Create 1 Scout Tower For Player1(Red) at (Center of(Rect))
Well this will work but its not leakfree... So we improve it abit.

Have you heared about Points and Leaks? I think you did! Now its time
to use leak removing!

So lets do this again! Add a new variable, call it Tmp_Loc.
  • General - Set Tmp_Loc = Center of(Rect)
  • Unit - Create 1 Scout Tower For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
What the Custom Script does? It removes the point from cache.
(Why udg_Tmp_Loc? It is Tmp_Loc I think?
Yes, but everything you do in GUI has been added a udg when you change it
into jass code (JASS is the code language, GUI is just an interface for that))

And ofcourse we do 2 part units aswell!
  • General - Set Tmp_Loc = Center of(Rect)
  • Unit - Create 1 Scout Tower For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • General - Set Tmp_Loc = Center of(Rect2)
  • Unit - Create 1 Whisp For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • General - Set Tmp_Loc = Center of(Rect3)
  • Unit - Create 1 Whisp For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • General - Set Tmp_Loc = Center of(Rect4)
  • Unit - Create 1 Whisp For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
Now we have same situation as in the picture above.
But how do we get them to spin?

Well we use firstly a trigger for every wheel, called WheelChanger.
Also do so! Just add a new trigger and call it WheelChanger.

This trigger will be your trigger which forces the Wheel Parts to spin around.

But how will we get them move around, not in a line?
And how can we handle unlimited parts with just using one system?

Well I did another picture for my idea, look at it carefully and think twice before you continue reading.

wheel2jn3.png


So my idea: I group the parts (because they can be endless, but
we have everytime just 1 unit to spin around.

Because we want to make this MUI GUI we need to array it. But thats not the problem.

So do 2 new variables:
Wheel_Parts ( Unitgroup, Arrayed )
Wheel_Mains ( Unit, Arrayed )

Well and maybe because we want to keep cache clear, we need following
variables (I will tell u soon why):

Tmp_Group (Unitgroup)
Tmp_Loc2 (Location)
Tmp_Real (Real)
Tmp_Real2 (Real)
Tmp_Unit

And now finally, we start working on the trigger!

WheelChanger
  • Event: Every 0.01 seconds of the game
  • Condition:
  • Actions:
This trigger needs to be initially off. So turn it initially off.

At next we need to set the new variables. So lets modify the start trigger.

  • General - Set Tmp_Loc = Center of(Rect)
  • Unit - Create 1 Scout Tower For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Set Wheel_Mains[1] = LastCreatedUnit
  • General - Set Tmp_Loc = Center of(Rect2)
  • Unit - Create 1 Whisp For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Unitgroup - Add (Last Created Unit) to Wheel_Parts[1]
  • General - Set Tmp_Loc = Center of(Rect3)
  • Unit - Create 1 Whisp For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Unitgroup - Add (Last Created Unit) to Wheel_Parts[1]
  • General - Set Tmp_Loc = Center of(Rect4)
  • Unit - Create 1 Whisp For Player1(Red) at Tmp_Loc
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Unitgroup - Add (Last Created Unit) to Wheel_Parts[1]
  • Trigger - Turn WheelChanger on
Now the unitgroup Wheel_Parts[1] has all parts of the Whisp Wheel Number1, and the WhispWheel1 Main unit is saved in Wheel_Mains[1].

We also add a Trigger - Turn WheelChanger on at last because we want to enable whisp wheel after starting him.

Back to WheelChanger, we have got 50% so far!

WheelChanger
  • Event: Every 0.01 seconds of the game
  • Condition:
  • Actions:
  • For Loop IndexA from 1 to *YourWheelCountHere* do (mulitply actions)
We gonna use this because we want to talk to EVERY whisp wheel, not just a single one.

WheelChanger
  • Event: Every 0.01 seconds of the game
  • Condition:
  • Actions:
  • For Loop IndexA from 1 to *YourWheelCountHere* do (mulitply actions)
  • Cutsom Script - set udg_Tmp_Group = CreateGroup()
  • General - Set Tmp_Group = Wheel_Parts[IntegerA]
  • Unitgroup - Pick every unit in Tmp_Group and do (mutiply actions)
  • Custom Script - call DestroyGroup(udg_Tmp_Group)
What we do here is avoiding leaks, saving the unitgroup into a new variable and clean the new variable after.

Now we talked to every unit iwth the pick each unit command, lets think about that the picked units are parts of the wheel.

WheelChanger
  • Event: Every 0.01 seconds of the game
  • Condition:
  • Actions:
  • For Loop IndexA from 1 to *YourWheelCountHere* do (mulitply actions)
  • General - Set Tmp_Unit = Wheel_Mains[IntegerA]
  • Cutsom Script - set udg_Tmp_Group = CreateGroup()
  • General - Set Tmp_Group = Wheel_Parts[IntegerA]
  • Unitgroup - Pick every unit in Tmp_Group and do (mutiply actions)
  • General - Set Tmp_Unit2 = PickedUnit
  • General - Set Tmp_Loc = Position of (Tmp_Unit2)
  • General - Set Tmp_Real = Angle between Tmp_Loc and Tmp_Loc2
  • General - Set Tmp_Real2 = Distance between Tmp_Loc and Tmp_Loc2
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Custom Script - call RemoveLocation(udg_Tmp_Loc2)
  • Custom Script - call DestroyGroup(udg_Tmp_Group)
What we did here is not that hard. We first setted every variable, then getting the Location of the Wheel Main unit. After that, we check the position of the wheel part. Now we can get distance and the degrees.

Now because we want it to move we add additionally a few lines of code to move those picked units forwards.

WheelChanger
  • Event: Every 0.01 seconds of the game
  • Condition:
  • Actions:
  • For Loop IndexA from 1 to *YourWheelCountHere* do (mulitply actions)
  • General - Set Tmp_Unit = Wheel_Mains[IntegerA]
  • Cutsom Script - set udg_Tmp_Group = CreateGroup()
  • General - Set Tmp_Group = Wheel_Parts[IntegerA]
  • Unitgroup - Pick every unit in Tmp_Group and do (mutiply actions)
  • General - Set Tmp_Unit2 = PickedUnit
  • General - Set Tmp_Loc = Position of (Tmp_Unit2)
  • General - Set Tmp_Real = Angle between Tmp_Loc and Tmp_Loc2
  • General - Set Tmp_Real2 = Distance between Tmp_Loc and Tmp_Loc2
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Custom Script - call RemoveLocation(udg_Tmp_Loc2)
  • General - Set Tmp_Real = Tmp_Real + *WHEELSPEED* (something low)
  • General - Set Tmp_Loc = Position of (Tmp_Unit2)
  • General - Set Tmp_Loc2 = Tmp_Loc offset Tmp_Real2 facing Tmp_Real
  • Unit - Move Tmp_unit2 into Tmp_Loc2
  • Custom Script - call RemoveLocation(udg_Tmp_Loc)
  • Custom Script - call RemoveLocation(udg_Tmp_Loc2)
  • Custom Script - call DestroyGroup(udg_Tmp_Group)
Done! look at it again, we juts change the angle and move the unit to that point! Is that that hard?

Note: I am NOT at home this was just written with head, DO NOT try to copy&paste this stuff!
 
Last edited:
Level 22
Joined
Jun 24, 2008
Messages
3,050
Well, try to right click the blank paper, at the top of the trigger, then right click it, and copy. Then paste it here on the hive, and then wrap Trigger tags. It will all look way better.

And if this should be tutorial-ish, try to remove un-neccecary "words" as JASS. It might confuse Noobs. You could add the addvanced stugg in red and the important stuff in green
 
Top