Ryuu
I am back with Chocolate (:
- Reaction score
- 64
Flare's GUI MUI method is used.
GUI
GUI
First off, define which event you need. Will it be when you cast a spell and you slide to the target point? In this tutorial I'll be using the 'starts the effect of an ability' event.
The condition below checks if the unit casts the 'slide' spell.
So now that you initialized the trigger, we got to start with the core part - the actions.
This is what your trigger should look like for the time being:
First off, we need to set variables to use them for later. These variables are needed:
Usually after we initialize variables, we set them in the trigger. However in this case, since we are doing a MUI sliding, we got initialize the MUI section first. The following action checks if the CustomValue variable reaches 100; if it does reach 100 or higher, it recycles the indices so that the spell actually becomes MUI.
Then we set the variables. Notice in the following code that I use CustomValue as the index for our array variables. This fulfills the purpose of having a CustomValue variable, making our spell MUI.
Now that we set our variables, we need to give one of our units the custom value CustomValue. This also fulfills the purpose of making our spell MUI. However do realise that you don't have to have a model-less dummy unit for our spell. All we need is a peasant. I rather you choose the frog.
Also, if you don't want our unit to be seen, you can specify a hidden region in our map or just give our unit no model.
Next we need to give him the custom value, and add him to our unit group.
The last action, simply removing leaks.
We're done for this initialization trigger.
This is what your trigger should look like:
Now that we're done with our initialization trigger, it's time we really go in to our core trigger. Create a new trigger, with the event:
You can change the above value to your liking. However don't go above 0.04, it will be quite unrealistic.
Next off we need to specify the conditions. The following condition checks if anyone even cast the 'Slide' spell. Because if this trigger is running unused for a long period, the game might get laggy.
Now the actions. Before doing anything we need to use the ForGroup call.
Translated to GUI is this:
The following action is probably useless but it can save you a lot of time. Instead of referring back to '(Custom value of (Picked unit))' for the entire trigger, you can just refer back to the TmpInteger variable.
The following action checks if the slider is dead. Because we don't want sliding corpses.
Under 'Else - Actions', set the following variables. The following actions are 'setups' for the main action. The '15' in the second action is the speed of sliding. Basically it moves every 15 units per 0.03 second.
The following actions check if the unit has reached its point. There are also leak removals because we are going to recycle the variables, hence we can't leave any of them lying around.
Getting out of the If/Then/Else, we need to remove the leaks.
That's it! You're done with your GUI sliding.
Your second trigger should look like this:
GUI sliding triggers
Trigger:
- Events
- Unit - A unit Starts the effect of an ability
The condition below checks if the unit casts the 'slide' spell.
Trigger:
- Conditions
- (Ability being cast) Equal to Slide
So now that you initialized the trigger, we got to start with the core part - the actions.
This is what your trigger should look like for the time being:
Trigger:
- Slide Init
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- (Ability being cast) Equal to Slide
- Actions
- Events
First off, we need to set variables to use them for later. These variables are needed:
1. CustomValue (Integer Non-array Variable)
2. SlidePoint (Point Array Variable)
3. Slider (Unit Array Variable)
4. SlideOffset (Point Array Variable)
5. UnitGroup (Unit Group Non-array Variable)
6. TmpInteger (Integer Non-array Variable)
7. MovedRange (Real Array Variable)
8. TargetPoint (Point Array Variable)
9. StartPoint (Point Array Variable)
2. SlidePoint (Point Array Variable)
3. Slider (Unit Array Variable)
4. SlideOffset (Point Array Variable)
5. UnitGroup (Unit Group Non-array Variable)
6. TmpInteger (Integer Non-array Variable)
7. MovedRange (Real Array Variable)
8. TargetPoint (Point Array Variable)
9. StartPoint (Point Array Variable)
Usually after we initialize variables, we set them in the trigger. However in this case, since we are doing a MUI sliding, we got initialize the MUI section first. The following action checks if the CustomValue variable reaches 100; if it does reach 100 or higher, it recycles the indices so that the spell actually becomes MUI.
Trigger:
- Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- CustomValue Less than 100
- Then - Actions
- Set CustomValue = (CustomValue + 1)
- Else - Actions
- Set CustomValue = 1
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Then we set the variables. Notice in the following code that I use CustomValue as the index for our array variables. This fulfills the purpose of having a CustomValue variable, making our spell MUI.
Trigger:
- Actions
- Set Slider[CustomValue] = (Triggering unit)
- Set StartPoint[CustomValue] = (Position of Slider[CustomValue])
- Set SlidePoint[CustomValue] = (Position of Slider[CustomValue])
- Set TargetPoint[CustomValue] = (Target point of ability being cast)
Now that we set our variables, we need to give one of our units the custom value CustomValue. This also fulfills the purpose of making our spell MUI. However do realise that you don't have to have a model-less dummy unit for our spell. All we need is a peasant. I rather you choose the frog.
Also, if you don't want our unit to be seen, you can specify a hidden region in our map or just give our unit no model.
Trigger:
- Actions
- Unit - Create 1 Frog (No model) for (Owner of Slider[CustomValue]) at SlidePoint[CustomValue] facing Default building facing degrees
Next we need to give him the custom value, and add him to our unit group.
Trigger:
- Actions
- Unit - Set the custom value of (Last created unit) to CustomValue
- Unit Group - Add (Last created unit) to UnitGroup
The last action, simply removing leaks.
Trigger:
- Custom script: call RemoveLocation(udg_SlidePoint[udg_CustomValue])
We're done for this initialization trigger.
This is what your trigger should look like:
Trigger:
- Slide Init
- Events
- Unit - A unit Starts the effect of an ability
- Conditions
- (Ability being cast) Equal to Slide
- Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- CustomValue Less than 100
- Then - Actions
- Set CustomValue = (CustomValue + 1)
- Else - Actions
- Set CustomValue = 1
- If - Conditions
- Set Slider[CustomValue] = (Triggering unit)
- Set StartPoint[CustomValue] = (Position of Slider[CustomValue])
- Set SlidePoint[CustomValue] = (Position of Slider[CustomValue])
- Set TargetPoint[CustomValue] = (Target point of ability being cast)
- Unit - Create 1 Frog for (Owner of Slider[CustomValue]) at SlidePoint[CustomValue] facing Default building facing degrees
- Unit - Set the custom value of (Last created unit) to CustomValue
- Unit Group - Add (Last created unit) to UnitGroup
- Custom script: call RemoveLocation(udg_SlidePoint[udg_CustomValue])
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Events
Now that we're done with our initialization trigger, it's time we really go in to our core trigger. Create a new trigger, with the event:
Trigger:
- Events
- Time - Every 0.03 seconds of game time
You can change the above value to your liking. However don't go above 0.04, it will be quite unrealistic.
Next off we need to specify the conditions. The following condition checks if anyone even cast the 'Slide' spell. Because if this trigger is running unused for a long period, the game might get laggy.
Trigger:
- Conditions
- CustomValue Greater than 0
Now the actions. Before doing anything we need to use the ForGroup call.
Translated to GUI is this:
Trigger:
- Actions
- Unit Group - Pick every unit in UnitGroup and do (Actions)
- Loop - Actions
- Unit Group - Pick every unit in UnitGroup and do (Actions)
The following action is probably useless but it can save you a lot of time. Instead of referring back to '(Custom value of (Picked unit))' for the entire trigger, you can just refer back to the TmpInteger variable.
Trigger:
- Actions
- Set TmpInteger = (Custom value of (Picked unit))
The following action checks if the slider is dead. Because we don't want sliding corpses.
Trigger:
- Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Slider[TmpInteger] is dead) Equal to True
- Then - Actions
- Unit - Remove (Picked unit) from the game
- Else - Actions
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Under 'Else - Actions', set the following variables. The following actions are 'setups' for the main action. The '15' in the second action is the speed of sliding. Basically it moves every 15 units per 0.03 second.
Trigger:
- Actions
- Set SlidePoint[TmpInteger] = (Position of Slider[TmpInteger])
- Set SlideOffset[TmpInteger] = (SlidePoint[TmpInteger] offset by 15.00 towards (Angle from SlidePoint[TmpInteger] to TargetPoint[TmpInteger]) degrees)
The following actions check if the unit has reached its point. There are also leak removals because we are going to recycle the variables, hence we can't leave any of them lying around.
Trigger:
- Actions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- MovedRange[TmpInteger] Less than (Distance between StartPoint[TmpInteger] and TargetPoint[TmpInteger])
- Then - Actions
- Unit - Move Slider[TmpInteger] instantly to SlideOffset[TmpInteger]
- Set MovedRange[TmpInteger] = (MovedRange[TmpInteger] + 15.00)
- Custom script: call RemoveLocation(udg_SlidePoint[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_SlideOffset[udg_TmpInteger])
- Else - Actions
- Unit - Remove (Picked unit) from the game
- Unit - Order Slider[TmpInteger] to Stop
- Set Slider[TmpInteger] = No unit
- If - Conditions
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
Getting out of the If/Then/Else, we need to remove the leaks.
Trigger:
- Actions
- Custom script: call RemoveLocation(udg_SlidePoint[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_SlideOffset[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_StartPoint[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_TargetPoint[udg_TmpInteger])
That's it! You're done with your GUI sliding.
Your second trigger should look like this:
Trigger:
- Slide
- Events
- Time - Every 0.03 seconds of game time
- Conditions
- CustomValue Greater than 0
- Actions
- Unit Group - Pick every unit in UnitGroup and do (Actions)
- Loop - Actions
- Set TmpInteger = (Custom value of (Picked unit))
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- (Slider[TmpInteger] is dead) Equal to True
- Then - Actions
- Unit - Remove (Picked unit) from the game
- Else - Actions
- Set SlidePoint[TmpInteger] = (Position of Slider[TmpInteger])
- Set SlideOffset[TmpInteger] = (SlidePoint[TmpInteger] offset by 15.00 towards (Angle from SlidePoint[TmpInteger] to TargetPoint[TmpInteger]) degrees)
- If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- If - Conditions
- MovedRange[TmpInteger] Less than (Distance between StartPoint[TmpInteger] and TargetPoint[TmpInteger])
- Then - Actions
- Unit - Move Slider[TmpInteger] instantly to SlideOffset[TmpInteger]
- Set MovedRange[TmpInteger] = (MovedRange[TmpInteger] + 15.00)
- Custom script: call RemoveLocation(udg_SlidePoint[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_SlideOffset[udg_TmpInteger])
- Else - Actions
- Unit - Remove (Picked unit) from the game
- Unit - Order Slider[TmpInteger] to Stop
- Set Slider[TmpInteger] = No unit
- If - Conditions
- Custom script: call RemoveLocation(udg_SlidePoint[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_SlideOffset[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_StartPoint[udg_TmpInteger])
- Custom script: call RemoveLocation(udg_TargetPoint[udg_TmpInteger])
- If - Conditions
- Loop - Actions
- Unit Group - Pick every unit in UnitGroup and do (Actions)
- Events
GUI sliding triggers
Code:
Slide Init
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Slide
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CustomValue Less than 100
Then - Actions
Set CustomValue = (CustomValue + 1)
Else - Actions
Set CustomValue = 1
Set Slider[CustomValue] = (Triggering unit)
Set StartPoint[CustomValue] = (Position of Slider[CustomValue])
Set SlidePoint[CustomValue] = (Position of Slider[CustomValue])
Set TargetPoint[CustomValue] = (Target point of ability being cast)
Unit - Create 1 Frog for (Owner of Slider[CustomValue]) at SlidePoint[CustomValue] facing Default building facing degrees
Unit - Set the custom value of (Last created unit) to CustomValue
Unit Group - Add (Last created unit) to UnitGroup
Custom script: call RemoveLocation( udg_SlidePoint[udg_CustomValue] )
Code:
Slide
Events
Time - Every 0.03 seconds of game time
Conditions
CustomValue Greater than 0
Actions
Unit Group - Pick every unit in UnitGroup and do (Actions)
Loop - Actions
Set TmpInteger = (Custom value of (Picked unit))
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Slider[TmpInteger] is dead) Equal to True
Then - Actions
Unit - Remove (Picked unit) from the game
Else - Actions
Set SlidePoint[TmpInteger] = (Position of Slider[TmpInteger])
Set SlideOffset[TmpInteger] = (SlidePoint[TmpInteger] offset by 15.00 towards (Angle from SlidePoint[TmpInteger] to TargetPoint[TmpInteger]) degrees)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
MovedRange[TmpInteger] Less than (Distance between StartPoint[TmpInteger] and TargetPoint[TmpInteger])
Then - Actions
Unit - Move Slider[TmpInteger] instantly to SlideOffset[TmpInteger]
Set MovedRange[TmpInteger] = (MovedRange[TmpInteger] + 15.00)
Custom script: call RemoveLocation(udg_SlidePoint[udg_TmpInteger])
Custom script: call RemoveLocation(udg_SlideOffset[udg_TmpInteger])
Else - Actions
Unit - Remove (Picked unit) from the game
Unit - Order Slider[TmpInteger] to Stop
Set Slider[TmpInteger] = No unit
Custom script: call RemoveLocation(udg_SlidePoint[udg_TmpInteger])
Custom script: call RemoveLocation(udg_SlideOffset[udg_TmpInteger])
Custom script: call RemoveLocation(udg_StartPoint[udg_TmpInteger])
Custom script: call RemoveLocation(udg_TargetPoint[udg_TmpInteger])