Spell Power Draft (GUI)

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
Power Draft
By KaerfNomekop (First submission :D)
378754_316348701708715_100000007635796_1271752_157937047_n.jpg

Description:
Code:
Strikes the target with magic energy, dealing damage. Every second that this spell
is not in cooldown reduces this damage by 5, to a maximum reduction of 50.

Level 1 - 100 base damage.
Level 2 - 150 base damage.
Level 3 - 200 base damage.
Level 4 - 250 base damage.

Cooldown: 2 seconds
Manacost: 35/40/45/50

Info:
This spell was made for spamming (thus the low cooldown and manacost).
Pros:
  • Made in GUI, so it's easy to understand.
  • MUI - uses hashtables.
  • Customizable - Maximum/minimum damage, interval between damage reductions, damage reduction amount, floating text, cooldown, manacost, effect and spell name can all be changed.
  • Easy to duplicate - just copy the triggers and change the variables.
  • Uses a periodic trigger, so it's more accurate.
  • AFAIK, does not leak.

Cons:
  • Made in GUI, so it's hugely inefficient.
  • Uses hashtables, so it might be a tiny bit complicated. Ok, so maybe it's a little bit complicated.
  • Uses a periodic trigger. May reduce performance.
  • May contain leaks.
  • Has no missile art.
  • Lacks a nice backstory.
  • Has 6 cons versus 6 pros.


Trigger Code:
Trigger:
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- Using the hashtable makes the spell MUI. --------
      • Hashtable - Create a hashtable
      • Set Hashtable = (Last created hashtable)
      • -------- Whether or not floating text is displayed. --------
      • Set DisplayTextBoolean = True
      • -------- For the rest of the globals, the array index is the level, i.e. Cooldown[1] is the cooldown for level 1. --------
      • -------- Increase/decrease the array sizes to suit the number of levels. --------
      • -------- Cooldown of the spell. --------
      • Set Cooldown[1] = 2.00
      • Set Cooldown[2] = 2.00
      • Set Cooldown[3] = 2.00
      • Set Cooldown[4] = 2.00
      • -------- Interval between reduction of damage. --------
      • Set Interval[1] = 1.00
      • Set Interval[2] = 1.00
      • Set Interval[3] = 1.00
      • Set Interval[4] = 1.00
      • -------- Reduction of damage that occurs at every interval. --------
      • Set Reduction[1] = 5.00
      • Set Reduction[2] = 5.00
      • Set Reduction[3] = 5.00
      • Set Reduction[4] = 5.00
      • -------- Maximum damage that the spell deals. --------
      • Set DamageMax[1] = 100.00
      • Set DamageMax[2] = 150.00
      • Set DamageMax[3] = 200.00
      • Set DamageMax[4] = 250.00
      • -------- Minimum damage that the spell deals. Reduction happens at every interval until this value is reached. --------
      • Set DamageMin[1] = 50.00
      • Set DamageMin[2] = 100.00
      • Set DamageMin[3] = 150.00
      • Set DamageMin[4] = 200.00

Trigger:
  • Learn
    • Events
      • Unit - A unit Learns a skill
    • Conditions
      • (Learned Hero Skill) Equal to Power Draft
    • Actions
      • Set TempInt = (Level of Power Draft for (Triggering unit))
      • Hashtable - Save DamageMax[TempInt] as (Key (Triggering unit)) of (Key PowerDraftDamage) in Hashtable
      • Hashtable - Save 0.00 as (Key (Triggering unit)) of (Key PowerDraftTime) in Hashtable
      • Unit Group - Add (Triggering unit) to PowerDraftGroup

Trigger:
  • Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Power Draft
    • Actions
      • Set TempInt = (Level of Power Draft for (Triggering unit))
      • Set TempInt2 = (Integer((Load (Key (Triggering unit)) of (Key PowerDraftDamage) from Hashtable)))
      • -------- Floating text displays the damage dealt. Set DisplayTextBoolean to "false" to disable this. --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DisplayTextBoolean Equal to True
        • Then - Actions
          • Set TempPoint = (Position of (Target unit of ability being cast))
          • Floating Text - Create floating text that reads ((String(TempInt2)) + !) at TempPoint with Z offset 0.00, using font size 10.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
          • Floating Text - Set the velocity of (Last created floating text) to 64.00 towards 90.00 degrees
          • Floating Text - Change (Last created floating text<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" class="smilie smilie--sprite smilie--sprite3" alt=":(" title="Frown :(" loading="lazy" data-shortname=":(" /> Disable permanence
          • Floating Text - Change the lifespan of (Last created floating text) to 5.00 seconds
          • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
          • Custom script: call RemoveLocation(udg_TempPoint)
        • Else - Actions
      • Unit - Cause (Triggering unit) to damage (Target unit of ability being cast), dealing (Real(TempInt2)) damage of attack type Spells and damage type Magic
      • Unit Group - Remove (Triggering unit) from PowerDraftGroup
      • Wait Cooldown[TempInt] seconds
      • Hashtable - Save 0.00 as (Key (Triggering unit)) of (Key PowerDraftTime) in Hashtable
      • Hashtable - Save DamageMax[TempInt] as (Key (Triggering unit)) of (Key PowerDraftDamage) in Hashtable
      • Unit Group - Add (Triggering unit) to PowerDraftGroup

Trigger:
  • Reduction
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • (Number of units in PowerDraftGroup) Greater than 0
    • Actions
      • Unit Group - Pick every unit in PowerDraftGroup and do (Actions)
        • Loop - Actions
          • Set TempInt = (Level of Power Draft for (Picked unit))
          • Set TempReal = (Load (Key (Picked unit)) of (Key PowerDraftTime) from Hashtable)
          • Set TempReal2 = (Load (Key (Picked unit)) of (Key PowerDraftDamage) from Hashtable)
          • Hashtable - Save (TempReal + 0.05) as (Key (Picked unit)) of (Key PowerDraftTime) in Hashtable
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • TempReal Equal to Interval[TempInt]
            • Then - Actions
              • Hashtable - Save 0.00 as (Key (Picked unit)) of (Key PowerDraftTime) in Hashtable
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempReal2 Greater than DamageMin[TempInt]
                • Then - Actions
                  • Hashtable - Save (TempReal2 - Reduction[TempInt]) as (Key (Picked unit)) of (Key PowerDraftDamage) in Hashtable
                • Else - Actions
            • Else - Actions

Changelog:
29/11/2011, 0005 - v1.0 First release.
05/12/2011, 2322 - v1.1 Changed interval, added a condition to Reduction trigger.
 

Attachments

  • Power Draft.w3x
    26.3 KB · Views: 424
  • Power Draft 1.1.w3x
    26.4 KB · Views: 497

Dirac

22710180
Reaction score
147
  • Instead of having 1 array index per level (like you do on the first trigger) make the user use equations, add variables such as "damage per level" and "base damage" instead
  • You don't need hashtables for this, only any GUI indexing system, or even, any indexing system
  • 0.01 second timer, way too fast, use 0.1, if this were JASS you wouldn't need a periodic timer at all.
  • The description has 1 typo: "this" damage -> "it's" damage or "damage done by Power Draft"
  • It leaks a hashtable, but that can't be avoided in GUI
 

Dirac

22710180
Reaction score
147
Creating a new hashtable per spell causes a leak and takes you closer to the 255 limit
In JASS only 1 hashtable is used for every purpose.
 

Sgqvur

FullOfUltimateTruthsAndEt ernalPrinciples, i.e shi
Reaction score
62
>In JASS only 1 hashtable is used for every purpose.

I suppose you mean in your jass scripts.

But you shouldn't generalize it. Even dota (a map with huge script) uses at least 2 hashtables (read it somewhere [perhaps in the global section =)]).

Edit:
Nope actually the 6.72f version of dota uses exactly 2 hashtables.
 

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
What I don't get is why anyone would even think gui has to use a ton of different hashtables, before I stopped working on my rpg my hashtable stored everything from unit stats to ability information in one, and threat or "AI" targeting algorithm inputs in another without any problems, he should just make it so the integers used to save the information can be edited via a variable, so they don't overlap with other spells

Also pkmnfrk...
To reduce lag add an if then else statement in the periodic to turn it off if there are no units in the group, and turn it on when u add units to it, so its not always running, and as I believe someone said earlier, u should increase the interval, maybe to 0.02 - 0.04
 

KaerfNomekop

Swim, fishies. Swim through the veil of steel.
Reaction score
612
Instead of having 1 array index per level (like you do on the first trigger) make the user use equations, add variables such as "damage per level" and "base damage" instead
On certain occasions, an equation can't be found. Other times you're too lazy to find them or just aren't capable of thinking it out. Either way it saves time and can be changed easily.

You don't need hashtables for this, only any GUI indexing system, or even, any indexing system
It leaks a hashtable, but that can't be avoided in GUI
I never liked indexing systems. Maybe because I once tried (and failed) to make one when I was first dabbling in the editor. Anyway the hashtable is used for dozens of other spells.

0.01 second timer, way too fast, use 0.1, if this were JASS you wouldn't need a periodic timer at all.
To reduce lag add an if then else statement in the periodic to turn it off if there are no units in the group, and turn it on when u add units to it, so its not always running, and as I believe someone said earlier, u should increase the interval, maybe to 0.02 - 0.04
Interval reduced to 0.05, condition added.

The description has 1 typo: "this" damage -> "it's" damage or "damage done by Power Draft"
Clarificatoin please?

he should just make it so the integers used to save the information can be edited via a variable, so they don't overlap with other spells
I don't use simple integers, I use Key(String). Correct me if I'm wrong, but I'm quite sure that's unique to every string so there shouldn't be any overlaps.
 

Attachments

  • Power Draft 1.1.w3x
    26.4 KB · Views: 390

GFreak45

I didnt slap you, i high 5'd your face.
Reaction score
130
I don't use simple integers, I use Key(String). Correct me if I'm wrong, but I'm quite sure that's unique to every string so there shouldn't be any overlaps.

Ahh just noticed that, ya u shouldnt have a problem with overlaps, so i would let them choose what hashtable to sue for it rather than using a new one

ps. I cant see where you added the condition and all that, did you update the code to show that?

EDIT:

I see it now and that would help but thats not what i was meaning, i was meaning do something like this at the end of it:

Trigger:
  • Actions
    • If (Conditions), Then (Do Actions, Else (Do Else Actions)
      • If - Conditions
        • Number of Units in group is equal to 0
      • Then - Actions
        • Trigger - Turn off this trigger
      • Else - Actions


then from there you turn on the trigger when you add units to it
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top