[Log in / Register]
| News | Chat | Pastebin | Donations | Tutorials | Rules | Forums |
| Maps | Skins | Icons | Models | Spells | Tools | Jass | Packs | Hosted Projects | Starcraft II Modding | Starcraft II Resources | Galaxy Wiki |
(Keeps Hive Alive)
Go Back   The Hive Workshop > Warcraft III Modding > WarCraft III Tutorials > Trigger (GUI) Editor Tutorials


Trigger (GUI) Editor Tutorials Contains tutorials concerning the usage of GUI features.
Read the Rules before posting.

Reply
 
Thread Tools
Old 08-05-2012, 04:56 AM   #1 (permalink)
Registered User Almia
Oh Data Structures <3
 
Almia's Avatar
 
Join Date: Apr 2012
Posts: 3,005
Almia is a name known to all (654)Almia is a name known to all (654)
Charged Ability Tutorial

Charged Ability Tutorial
By:
Radamantus
What is this?
Answer:
This is a tutorial of how to make an ability with a charge.This allows you to cast the ability many times even without cooldown but has limits and allows you to not duplicate a spell many times and use the action "Add blahblah to blahblah"
and"Set Level of blahblah to blahblah".
How can we make it?
Answer:
The ability triggers include of 4 parts:Initialization,Learn,Cast,Loop.
We will start first in Initialization

We create first the hastable,either of the two you can use:
Hashtable - Create a hashtable
Set Hash = (Last Created Hashtable)

or

Custom script : set udg_Hash = InitHashtable()

There we have it.

Now,we will use some configuration for our spell.

We will start first with the charges color.

I will choose 4 charges as a max charge so that we could use the colors red,orange,yellow,green and if empty black.If you want other colors go here:
Warcraft III Color Tags And Linebreaks

-------- GENERAL --------
-------- Determines the max charges --------
Set MaxCharges = 4
-------- Determines the color of charges --------
-------- if 0(Black) --------
Set Color[0] = |c00000000
-------- if 1(Red) --------
Set Color[1] = |c00FF0000
-------- if 2(Orange) --------
Set Color[2] = |c00FF7F00
-------- if 3(Yellow) --------
Set Color[3] = |c00FFFF00
-------- if 4(Green) --------
Set Color[4] = |c0000FF00

There you have it.Next we will use the Floating Text.I will use letter "I" so that we could easily see the Charges.

-------- Determines the text for the charges --------
-------- if 0 --------
Set ChargeText[0] = (Color[0] + I I I I|r)
-------- if 1 --------
Set ChargeText[1] = (Color[1] + (I|r + (Color[0] + I I I|r)))
-------- if 2 --------
Set ChargeText[2] = (Color[2] + (I I|r + (Color[0] + I I|r)))
-------- if 3 --------
Set ChargeText[3] = (Color[3] + (I I I|r + (Color[0] + I|r)))
-------- if 4 --------
Set ChargeText[4] = (Color[4] + I I I I|r)

There,so the charges will look like this:

I I I I
I I I I
I I I I
I I I I
I I I I


After that,we will use the time to make a new charge.Lets use 5 as a cooldown.
Set ChargeCooldown = 5.00

Now,Let's Put the Starting Charge when learned and the charge number when the learner dies.

Set StartingCharge = 1

We are now finish with the Initialization,The trigger will look like this

Initialization
Events
Map Initialization
Conditions
Actions
Custom script : set udg_Hash = InitHashtable()
-------- GENERAL --------
-------- Determines the max charges --------
Set MaxCharges = 4
-------- Determines the color of charges --------
-------- if 0(Black) --------
Set Color[0] = |c00000000
-------- if 1(Red) --------
Set Color[1] = |c00FF0000
-------- if 2(Orange) --------
Set Color[2] = |c00FF7F00
-------- if 3(Yellow) --------
Set Color[3] = |c00FFFF00
-------- if 4(Green) --------
Set Color[4] = |c0000FF00
-------- Determines the text for the charges --------
-------- if 0 --------
Set ChargeText[0] = (Color[0] + I I I I|r)
-------- if 1 --------
Set ChargeText[1] = (Color[1] + (I|r + (Color[0] + I I I|r)))
-------- if 2 --------
Set ChargeText[2] = (Color[2] + (I I|r + (Color[0] + I I|r)))
-------- if 3 --------
Set ChargeText[3] = (Color[3] + (I I I|r + (Color[0] + I|r)))
-------- if 4 --------
Set ChargeText[4] = (Color[4] + I I I I|r)
-------- Determines the charge cooldown --------
Set ChargeCooldown = 5.00
-------- Determines the starting charge --------
Set StartingCharge = 1

Now let's conclude with the Learn Trigger.This is the shortest trigger here.

Let's make the events and conditions.
Learn
Events
Unit - A unit Learns a skill
Conditions
(Learned Hero Skill) Equal to (Your Ability)

After that,we will put some important variables.Let's Start with the key(hashtable)

Set Learner = (Learning Hero)
Custom script: set udg_LearnerKey = GetHandleId(udg_Learner)

Now,let's save the variables to the key.

-------- Saving --------
Hashtable - Save (CurrentCharges + StartingCharge) as 0 of LearnerKey in Hash
Hashtable - Save Timer as 2 of LearnerKey in Hash

The timer will be used for the looping action of the cooldown.

Next,let's start the loop.

-------- Starting Loops --------
Unit Group - Add Learner to LoopGroup
Trigger - Turn on Loop <gen>

Now we are finish with the Learn Trigger,2 more triggers to go!

Here is what the trigger will look like:

Learn
Events
Unit - A unit Learns a skill
Conditions
(Learned Hero Skill) Equal to (Your Ability)
Actions
Set Learner = (Learning Hero)
Custom script: set udg_LearnerKey = GetHandleId(udg_Learner)
-------- Saving --------
Hashtable - Save (CurrentCharges + StartingCharge) as 0 of LearnerKey in Hash
Hashtable - Save Timer as 2 of LearnerKey in Hash
-------- Starting Loops --------
Unit Group - Add Learner to LoopGroup
Trigger - Turn on Loop <gen>

Now let's start with the Loop.

So first let's start the loop event.

You could use either 0.03 or 0.04,but ill prefer 0.04.

Loop
Events
Time - Every 0.04 seconds of game-time

Now, for the actions.Let's first pick the group

Unit Group - Pick every unit in LoopGroup and do (Actions)
Loop - Actions

Now,let's load the variables,but first we will create the key.

Set Picked = (Picked Unit)
Custom script : set udg_PickedKey = GetHandleId(udg_Picked)

Now,Loading Variables

-------- Load --------
Set CurrentCharges = (Load 0 of PickedKey from Hash)
Set Timer = (Load 2 of PickedKey from Hash)

Let's Check if the Picked Unit is Alive,if alive then:
-------- Checking --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked is alive) Equal To True
Then - Actions

Now,let's put the actions for the Then Actions.We will start first with the floating text

Then - Actions
-------- Destroying the currently created floating text --------
-------- (That means in the last loop) --------
Floating Text - Destroy (Load (Key FTXT) of PickedKey in HashIf the label is not found, this function returns NULL.)
-------- Creating Floating Text --------
Floating Text - Create floating text that reads ChargeText[CurrentCharges] above Picked with Z offset 0.00, using font size 15.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
-------- Saving the Floating Text so that we could destroy it on the next Loop. --------
Hashtable - Save Handle Of(Last created floating text) as (Key FTXT) of PickedKey in Hash

There we have it,next we will hide the Floating Text from the Enemies so they wont know that you have any charges left.

Set Enemies = (All enemies of (Owner of Picked))
-------- Hiding Floating Text --------
Floating Text - Hide (Last created floating text) for Enemies
-------- Clean Leak --------
Custom script : call DestroyForce(udg_Enemies)

Now,lets conclude with the charge cooldown.

-------- Adding Charge --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Timer Greater than or equal to ChargeCooldown
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrentCharges Less than MaxCharges
Then - Actions
-------- Because it is less than the max,we will add one --------
Hashtable - Save (CurrentCharges + 1) as 0 of PickedKey in Hash
Else - Actions
-------- Reset Timer --------
Hashtable - Save (Timer x 0.00) as 2 of PickedKey in Hash
Else - Actions
-------- Saving Timer --------
Hashtable - Save (Timer + 0.04) as 2 of PickedKey in Hash

Now,lets make the Else Actions of the Main If/Then/Else

Else - Actions
-------- Destroys Floating Text --------
Floating Text - Destroy (Load (Key FTXT) of PickedKey in HashIf the label is not found, this function returns NULL.)
-------- Turns Charges to 1 --------
Hashtable - Save StartingCharge as 0 of PickedKey in Hash

Note:Don't Clean the child hastables or else it will bug!

End of Loop Trigger:
Loop
Events
Time - Every 0.04 seconds of game-time
Conditions
Actions
Unit Group - Pick every unit in LoopGroup and do (Actions)
Loop - Actions
Set Picked = (Picked Unit)
Custom script : set udg_PickedKey = GetHandleId(udg_Picked)
-------- Load --------
Set CurrentCharges = (Load 0 of PickedKey from Hash)
Set Timer = (Load 2 of PickedKey from Hash)
-------- Checking --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Picked is alive) Equal To True
Then - Actions
-------- Destroying the currently created floating text --------
-------- (That means in the last loop) --------
Floating Text - Destroy (Load (Key FTXT) of PickedKey in HashIf the label is not found, this function returns NULL.)
-------- Creating Floating Text --------
Floating Text - Create floating text that reads ChargeText[CurrentCharges] above Picked with Z offset 0.00, using font size 15.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency
-------- Saving the Floating Text so that we could destroy it on the next Loop. --------
Hashtable - Save Handle Of(Last created floating text) as (Key FTXT) of PickedKey in Hash
Set Enemies = (All enemies of (Owner of Picked))
-------- Hiding Floating Text --------
Floating Text - Hide (Last created floating text) for Enemies
-------- Clean Leak --------
Custom script : call DestroyForce(udg_Enemies)
-------- Adding Charge --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Timer Greater than or equal to ChargeCooldown
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrentCharges Less than MaxCharges
Then - Actions
-------- Because it is less than the max,we will add one --------
Hashtable - Save (CurrentCharges + 1) as 0 of PickedKey in Hash
Else - Actions
-------- Reset Timer --------
Hashtable - Save (Timer x 0.00) as 2 of PickedKey in Hash
Else - Actions
-------- Saving Timer --------
Hashtable - Save (Timer + 0.04) as 2 of PickedKey in Hash
Else - Actions
-------- Destroys Floating Text --------
Floating Text - Destroy (Load (Key FTXT) of PickedKey in HashIf the label is not found, this function returns NULL.)
-------- Turns Charges to 1 --------
Hashtable - Save StartingCharge as 0 of PickedKey in Hash

Now let's Start with the Cast Trigger

First we will put the events and conditions.

Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to (Your Ability)

Then The Actions of the Trigger

We will start first with loading and setting important variables.

-------- Variables --------
Set Caster = (Triggering unit)
Custom script: set udg_CasterKey = GetHandleId(udg_Caster)
Set CurrentCharges = (Load 0 of CasterKey from Hash)

Now,let's check if the charges is not 0 or empty.

If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrentCharges Greater than 0

Now for the Then Actions

Then - Actions
-------- Decrease a charge --------
-------- But first we will check if the charges is greater than 0 so it wont bug --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Current Charges Greater than 0
Then - Actions
Hashtable - Save (CurrentCharges - 1 ) as 0 of CasterKey in Hash
Else - Actions

Now for the Else Actions for the Main If/Then/Else

Else - Actions
-------- Disables casting --------
Set Levels = (Level of (Your Ability) for Caster)
Unit - (Your Ability) from Caster
Unit - Add (Your Ability) to Caster
Unit - Set level of (Your Ability) for Caster to Levels
-------- Text that Indicates you have no more charges left. -------
Set Self = (Player group(Triggering Player))
Game - Display to Self the text: |cffffcc00No More Charges Left.
Custom script: call DestroyForce(udg_Self)

Now we are done with the Cast Trigger.

Here is the overall trigger:

Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to (Your Ability)
Actions
-------- Variables --------
Set Caster = (Triggering unit)
Custom script: set udg_CasterKey = GetHandleId(udg_Caster)
Set CurrentCharges = (Load 0 of CasterKey from Hash)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
CurrentCharges Greater than 0
Then - Actions
-------- Decrease a charge --------
-------- But first we will check if the charges is greater than 0 so it wont bug --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Current Charges Greater than 0
Then - Actions
Hashtable - Save (CurrentCharges - 1 ) as 0 of CasterKey in Hash
Else - Actions
Else - Actions
-------- Disables casting --------
Set Levels = (Level of (Your Ability) for Caster)
Unit - (Your Ability) from Caster
Unit - Add (Your Ability) to Caster
Unit - Set level of (Your Ability) for Caster to Levels
-------- Text that Indicates you have no more charges left. -------
Set Self = (Player group(Triggering Player))
Game - Display to Self the text: |cffffcc00No More Charges Left.
Custom script: call DestroyForce(udg_Self)

For the Demo Map:

Shadow Shroud v7

Ask any questions if you wanted to.
Almia is offline   Reply With Quote
Old 08-05-2012, 09:57 AM   #2 (permalink)
Registered User Almia
Oh Data Structures <3
 
Almia's Avatar
 
Join Date: Apr 2012
Posts: 3,005
Almia is a name known to all (654)Almia is a name known to all (654)
Notes:
Ability icons for the charges are very complex and uses MANY gui triggers and Jass Codes.
I Prefer to use this one for a charged spell due to that this is easier than icon replacement.
Almia is offline   Reply With Quote
Old 08-06-2012, 01:23 PM   #3 (permalink)
Forum Moderator Magtheridon96
JESUS MAN
 
Magtheridon96's Avatar
Resource Moderator
 
Join Date: Dec 2008
Posts: 5,700
Magtheridon96 has a brilliant future (1810)
Merit Badge - Level 0: This user has proven to be extremely valuable to the Warcraft III Modding Community. 
^No, it's just an array of abilities that you have to add and remove.
__________________
Magtheridon96 is offline   Reply With Quote
Old 08-06-2012, 01:38 PM   #4 (permalink)
Registered User Chaosy
Mr. GUI
 
Chaosy's Avatar
 
Join Date: Jun 2011
Posts: 1,761
Chaosy is just really nice (392)Chaosy is just really nice (392)Chaosy is just really nice (392)Chaosy is just really nice (392)Chaosy is just really nice (392)
PayPal Donor: This user has donated to The Hive. 
My bad just checked the name, but then its good :)

my bad
There is allready a tutorial about this actually, it shows how to use a knockback spell with hashtables and thats basicly the same thing as charge

Hashtables and MUI

Last edited by Chaosy; 08-10-2012 at 09:32 AM.
Chaosy is online now   Reply With Quote
Old 08-10-2012, 08:54 AM   #5 (permalink)
Registered User Almia
Oh Data Structures <3
 
Almia's Avatar
 
Join Date: Apr 2012
Posts: 3,005
Almia is a name known to all (654)Almia is a name known to all (654)
Uhmm,about that sir,its not about the spell with "charging" or some sort of knockback.It is about an ability just like items with limits

Please read how the spell works first.

About that Mag,it will take me 10 triggers and repeating them due to the icons.It will be a pain in the object editor
Almia is offline   Reply With Quote
Old 08-10-2012, 09:32 AM   #6 (permalink)
Registered User Chaosy
Mr. GUI
 
Chaosy's Avatar
 
Join Date: Jun 2011
Posts: 1,761
Chaosy is just really nice (392)Chaosy is just really nice (392)Chaosy is just really nice (392)Chaosy is just really nice (392)Chaosy is just really nice (392)
PayPal Donor: This user has donated to The Hive. 
sorry my bad :P
Chaosy is online now   Reply With Quote
Old 08-21-2012, 10:13 PM   #7 (permalink)
Forum Moderator PurgeandFire
ʕ•͡ᴥ•ʔ
 
PurgeandFire's Avatar
Resource & Tutorial Moderator
 
Join Date: Nov 2006
Posts: 3,548
PurgeandFire has much of which to be proud (1103)PurgeandFire has much of which to be proud (1103)PurgeandFire has much of which to be proud (1103)PurgeandFire has much of which to be proud (1103)PurgeandFire has much of which to be proud (1103)
Nice job. Everything seems in order to me. Sorry for the late response.

~Approved.
PurgeandFire is offline   Reply With Quote
Old 09-25-2012, 08:57 AM   #8 (permalink)
Registered User neku99
Forgot how to vJASS
 
neku99's Avatar
 
Join Date: Sep 2009
Posts: 394
neku99 has little to show at this moment (34)neku99 has little to show at this moment (34)neku99 has little to show at this moment (34)neku99 has little to show at this moment (34)
whoa I've been figuring out how to do this, finally ahahahha thanks for this :3 rep+!!!!!
__________________
neku99 is offline   Reply With Quote
Old 11-19-2012, 02:45 AM   #9 (permalink)
Registered User ExecutorWar
Learning C++
 
ExecutorWar's Avatar
 
Join Date: Nov 2012
Posts: 113
ExecutorWar has little to show at this moment (20)ExecutorWar has little to show at this moment (20)ExecutorWar has little to show at this moment (20)
Haha! this one is too complex for me. But later on i guess this will be useful. I got so many ideas about charged spells :)
__________________
ExecutorWar is offline   Reply With Quote
Reply

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


All times are GMT. The time now is 05:40 PM.





Powered by vBulletin
Copyright 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.5.1 PL2
Copyright © Ralle