- Joined
- Apr 24, 2012
- Messages
- 5,113
Charged Ability Tutorial
|
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: [trigger=] Hashtable - Create a hashtable Set Hash = (Last Created Hashtable)[/trigger] or [trigger=] Custom script : set udg_Hash = InitHashtable()[/trigger] 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: http://www.hiveworkshop.com/forums/...278/warcraft-iii-color-tags-linebreaks-31386/ [trigger=] -------- 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[/trigger] There you have it.Next we will use the Floating Text.I will use letter "I" so that we could easily see the Charges. [trigger=] -------- 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)[/trigger] 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. [trigger=] Set ChargeCooldown = 5.00[/trigger] Now,Let's Put the Starting Charge when learned and the charge number when the learner dies. [trigger=] Set StartingCharge = 1[/trigger] We are now finish with the Initialization,The trigger will look like this [trigger=]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[/trigger] Now let's conclude with the Learn Trigger.This is the shortest trigger here. Let's make the events and conditions. [trigger=]Learn Events Unit - A unit Learns a skill Conditions (Learned Hero Skill) Equal to (Your Ability)[/trigger] After that,we will put some important variables.Let's Start with the key(hashtable) [trigger=] Set Learner = (Learning Hero) Custom script: set udg_LearnerKey = GetHandleId(udg_Learner)[/trigger] Now,let's save the variables to the key. [trigger=] -------- Saving -------- Hashtable - Save (CurrentCharges + StartingCharge) as 0 of LearnerKey in Hash Hashtable - Save Timer as 2 of LearnerKey in Hash[/trigger] The timer will be used for the looping action of the cooldown. Next,let's start the loop. [trigger=] -------- Starting Loops -------- Unit Group - Add Learner to LoopGroup Trigger - Turn on Loop <gen>[/trigger] Now we are finish with the Learn Trigger,2 more triggers to go! Here is what the trigger will look like: [trigger=]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>[/trigger] 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. [trigger=]Loop Events Time - Every 0.04 seconds of game-time[/trigger] Now, for the actions.Let's first pick the group [trigger=] Unit Group - Pick every unit in LoopGroup and do (Actions) Loop - Actions[/trigger] Now,let's load the variables,but first we will create the key. [trigger=] Set Picked = (Picked Unit) Custom script : set udg_PickedKey = GetHandleId(udg_Picked)[/trigger] Now,Loading Variables [trigger=] -------- Load -------- Set CurrentCharges = (Load 0 of PickedKey from Hash) Set Timer = (Load 2 of PickedKey from Hash)[/trigger] Let's Check if the Picked Unit is Alive,if alive then: [trigger=] -------- Checking -------- If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions (Picked is alive) Equal To True Then - Actions[/trigger] Now,let's put the actions for the Then Actions.We will start first with the floating text [trigger=] 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[/trigger] There we have it,next we will hide the Floating Text from the Enemies so they wont know that you have any charges left. [trigger=] 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)[/trigger] Now,lets conclude with the charge cooldown. [trigger=] -------- 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[/trigger] Now,lets make the Else Actions of the Main If/Then/Else [trigger=] 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[/trigger] Noteon't Clean the child hastables or else it will bug! End of Loop Trigger: [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[/trigger] Now let's Start with the Cast Trigger First we will put the events and conditions. [trigger=]Cast Events Unit - A unit Starts the effect of an ability Conditions (Ability being cast) Equal to (Your Ability)[/trigger] Then The Actions of the Trigger We will start first with loading and setting important variables. [trigger=] -------- Variables -------- Set Caster = (Triggering unit) Custom script: set udg_CasterKey = GetHandleId(udg_Caster) Set CurrentCharges = (Load 0 of CasterKey from Hash)[/trigger] Now,let's check if the charges is not 0 or empty. [trigger=] If (All Conditions are True) then do (Then Actions) else do (Else Actions) If - Conditions CurrentCharges Greater than 0[/trigger] Now for the Then Actions [trigger=] 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[/trigger] Now for the Else Actions for the Main If/Then/Else [trigger=] 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)[/trigger] Now we are done with the Cast Trigger. Here is the overall trigger: [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)[/trigger] For the Demo Map: http://www.hiveworkshop.com/forums/spells-569/shadow-shroud-v7-219496/ Ask any questions if you wanted to. |