• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Esdo's "Dwarven Grenade" spell v1.2a

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
  • Like
Reactions: EyeCandy
Dwarven Grenade:

To pull the pin out of the grenade, press "Q". That will start a random fuse timer with ranges from 4 to 10. The remaining timer before the grenade explodes is displayed above the grenade. After the grenade is primed, the caster unit gains another spell, called "Shoot Grenade". This new spell can be used to throw the grenade at a target location. The grenade will only explode when the prime timer runs out, and it doesn't matter if it was thrown or not. The spell enters cooldown when the grenade explodes. This is just like a "real-life" grenade!

My first spell!

Full GUI, MUI, Lagless, Leakless.

I hope you enjoy.

Code:

  • DwarvenGrenadeConfig
    • Events
      • Map initialization
    • Conditions
    • Actions
      • -------- DmgLvL is the extra amount of damage dealt per spell level. --------
      • Set DwarvenGrenade_Damage = 500.00
      • Set DwarvenGrenade_DmgLvL = 100.00


  • DwarvenGrenadeAct
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Dwarven Grenade
    • Actions
      • Set DwarvenGrenade_Index = (DwarvenGrenade_Index + 1)
      • Set DwarvenGrenade_IsPrimed[DwarvenGrenade_Index] = True
      • Set DwarvenGrenade_Caster[DwarvenGrenade_Index] = (Triggering unit)
      • Set DwarvenGrenade_CasterPoint = (Position of (DwarvenGrenade_Caster[DwarvenGrenade_Index]))
      • Unit - Remove Dwarven Grenade from DwarvenGrenade_Caster[DwarvenGrenade_Index]
      • Unit - Add Shoot Grenade to DwarvenGrenade_Caster[DwarvenGrenade_Index]
      • Unit - Create 1 Grenade for (Owner of DwarvenGrenade_Caster[DwarvenGrenade_Index]) at DwarvenGrenade_CasterPoint facing Default building facing degrees
      • Set DwarvenGrenade_Bomb[DwarvenGrenade_Index] = (Last created unit)
      • Set DwarvenGrenade_Thrown[DwarvenGrenade_Index] = False
      • Set DwarvenGrenade_Timer[DwarvenGrenade_Index] = (Real((Random integer number between 4 and 10)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DwarvenGrenadeFollow <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on DwarvenGrenadeFollow <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DwarvenGrenadeTimer <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on DwarvenGrenadeTimer <gen>
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (DwarvenGrenadeBoom <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on DwarvenGrenadeBoom <gen>
        • Else - Actions
      • Custom script: call RemoveLocation (udg_DwarvenGrenade_CasterPoint)



  • DwarvenGrenadeFollow
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DwarvenGrenade_LoopInteger) from 1 to DwarvenGrenade_Index, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: follow
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DwarvenGrenade_Thrown[DwarvenGrenade_LoopInteger] Equal to False
            • Then - Actions
              • Set DwarvenGrenade_FollowPoint = (Position of DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger])
              • Unit - Move DwarvenGrenade_Bomb[DwarvenGrenade_LoopInteger] instantly to DwarvenGrenade_FollowPoint
              • Custom script: call RemoveLocation (udg_DwarvenGrenade_FollowPoint)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DwarvenGrenade_Index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions



  • DwarvenGrenadeTimer
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DwarvenGrenade_LoopInteger) from 1 to DwarvenGrenade_Index, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: timer
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger] Greater than 0.00
            • Then - Actions
              • Set DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger] = (DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger] - 0.50)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger] Greater than 0.00
            • Then - Actions
              • Floating Text - Create floating text that reads (String(DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger], 1, 2)) above DwarvenGrenade_Bomb[DwarvenGrenade_LoopInteger] with Z offset 0.00, using font size 12.00, color (100.00%, 0.00%, 0.00%), and 0.00% transparency
              • Floating Text - Set the velocity of (Last created floating text) to 70.00 towards 110.00 degrees
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Change the fading age of (Last created floating text) to 0.20 seconds
              • Floating Text - Change the lifespan of (Last created floating text) to 0.40 seconds
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DwarvenGrenade_Index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions




  • DwarvenGrenadeBoom
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer DwarvenGrenade_LoopInteger) from 1 to DwarvenGrenade_Index, do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: boom
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (DwarvenGrenade_Bomb[DwarvenGrenade_LoopInteger] is alive) Equal to True
              • DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger] Less than or equal to 0.00
            • Then - Actions
              • Set DwarvenGrenade_IsPrimed[DwarvenGrenade_LoopInteger] = False
              • Set DwarvenGrenade_BlastPoint = (Position of DwarvenGrenade_Bomb[DwarvenGrenade_LoopInteger])
              • Unit - Kill DwarvenGrenade_Bomb[DwarvenGrenade_LoopInteger]
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units within 512.00 of DwarvenGrenade_BlastPoint) and do (Actions)
                • Loop - Actions
                  • Unit - Cause DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger] to damage (Picked unit), dealing (DwarvenGrenade_Damage + (DwarvenGrenade_DmgLvL x (Real(DwarvenGrenade_Level[DwarvenGrenade_LoopInteger])))) damage of attack type Spells and damage type Normal
              • Special Effect - Create a special effect at DwarvenGrenade_BlastPoint using Abilities\Spells\Other\Doom\DoomDeath.mdl
              • Special Effect - Destroy (Last created special effect)
              • Unit - Remove Shoot Grenade from DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger]
              • Unit - Add Dwarven Grenade to DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger]
              • Unit - Set level of Dwarven Grenade for DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger] to DwarvenGrenade_Level[DwarvenGrenade_LoopInteger]
              • Set DwarvenGrenade_ManaBefore = (Mana of DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger])
              • Unit - Set mana of DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger] to 100.00%
              • Trigger - Turn off DwarvenGrenadeAct <gen>
              • Unit - Order DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger] to Orc Troll Berserker - Berserk
              • Trigger - Turn on DwarvenGrenadeAct <gen>
              • Unit - Set mana of DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger] to DwarvenGrenade_ManaBefore
              • Set DwarvenGrenade_Bomb[DwarvenGrenade_LoopInteger] = DwarvenGrenade_Bomb[DwarvenGrenade_Index]
              • Set DwarvenGrenade_Caster[DwarvenGrenade_LoopInteger] = DwarvenGrenade_Caster[DwarvenGrenade_Index]
              • Set DwarvenGrenade_IsPrimed[DwarvenGrenade_LoopInteger] = DwarvenGrenade_IsPrimed[DwarvenGrenade_Index]
              • Set DwarvenGrenade_Thrown[DwarvenGrenade_LoopInteger] = DwarvenGrenade_Thrown[DwarvenGrenade_Index]
              • Set DwarvenGrenade_Timer[DwarvenGrenade_LoopInteger] = DwarvenGrenade_Timer[DwarvenGrenade_Index]
              • Set DwarvenGrenade_Index = (DwarvenGrenade_Index - 1)
              • Set DwarvenGrenade_LoopInteger = (DwarvenGrenade_LoopInteger - 1)
              • Custom script: call RemoveLocation (udg_DwarvenGrenade_BlastPoint)
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • DwarvenGrenade_Index Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions



  • DwarvenGrenadeArc
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Shoot Grenade
    • Actions
      • Custom script: local real Hyp
      • Custom script: local real SINE
      • Custom script: local real COSINE
      • Custom script: local real End_Z
      • Custom script: local real Distance
      • Custom script: local real Height
      • For each (Integer A) from 1 to 100, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to DwarvenGrenade_Caster[(Integer A)]
              • DwarvenGrenade_Thrown[(Integer A)] Equal to False
            • Then - Actions
              • Set DwarvenGrenade_Thrown[(Integer A)] = True
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BS_Skip Equal to 0
                • Then - Actions
                  • Trigger - Turn on DwarvenGrenadeLoop <gen>
                • Else - Actions
              • Set BS_Point[0] = (Position of (Triggering unit))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • DwarvenGrenade_Thrown[(Integer A)] Equal to True
                • Then - Actions
                • Else - Actions
              • Set BS_Point[1] = (Target point of ability being cast)
              • Set BS_Point[2] = (BS_Point[0] offset by 70.00 towards (Angle from BS_Point[0] to BS_Point[1]) degrees)
              • Set BS_MissileCount = 1
              • For each (Integer BS_MC) from 1 to BS_MissileCount, do (Actions)
                • Loop - Actions
                  • Set BS_Skip = (BS_Skip + 1)
                  • Set BS_Times = (BS_Times + 1)
                  • Set BS_On[BS_Times] = True
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Set BS_Hero[BS_Times] = (Triggering unit)
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Set BS_Angle[BS_Times] = (Angle from BS_Point[0] to BS_Point[1])
                  • Set BS_MaxDistance[BS_Times] = (Distance between BS_Point[1] and BS_Point[2])
                  • Set BS_DistanceToTravel[BS_Times] = BS_MaxDistance[BS_Times]
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Height of Arc is a fourth of range. if you will set this to a number and not a portion of distance, then missile will fly too high --------
                  • -------- at short distances and this will create a feel like it moves faster than usual. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Set BS_ArcHeight[BS_Times] = (BS_MaxDistance[BS_Times] x 0.25)
                  • Set BS_Level[BS_Times] = (Level of Shoot Grenade for (Triggering unit))
                  • Set BS_Damage[BS_Times] = ((Random real number between 150.00 and 200.00) + (50.00 x (Real(BS_Level[BS_Times]))))
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Change Area of Effect variable to true, if you want missile to hit multiple targets. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Set BS_AoE[BS_Times] = False
                  • Set BS_AoE_Radius[BS_Times] = 150.00
                  • Set BS_Range[BS_Times] = 1500.00
                  • Set BS_Colision[BS_Times] = 75.00
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Change 60 to unit "height" (not flying) to make caster aim in head. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Custom script: set udg_BS_StartZ[udg_BS_Times] = GetLocationZ(udg_BS_Point[0]) + 55
                  • Custom script: set End_Z = GetLocationZ(udg_BS_Point[1])
                  • Custom script: set Distance = DistanceBetweenPoints(udg_BS_Point[2],udg_BS_Point[1])
                  • Custom script: if udg_BS_StartZ[udg_BS_Times] >= End_Z then
                  • Custom script: set udg_BS_Up[udg_BS_Times] = false
                  • Custom script: set End_Z = ( End_Z + GetRandomReal(40.00, 85.00) )
                  • Custom script: set Height = ( udg_BS_StartZ[udg_BS_Times] - End_Z )
                  • Custom script: else
                  • Custom script: set udg_BS_Up[udg_BS_Times] = true
                  • Custom script: set End_Z = ( End_Z + GetRandomReal(60.00, 85.00) )
                  • Custom script: set Height = ( End_Z - udg_BS_StartZ[udg_BS_Times] )
                  • Custom script: endif
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Lets check if missile fly up or down. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Custom script: set Hyp = SquareRoot(( ( Distance * Distance ) + ( Height * Height ) ))
                  • Custom script: set SINE = ( Distance / Hyp )
                  • Custom script: set COSINE = ( Height / Hyp )
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- HYPSpeed is hypotinuse movement per time interval. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Set BS_HYPSpeed[BS_Times] = 40.00
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Because we know hypotinuse speed, SINE, COSINE, calculation of Height Speed and distance speed will calculate now. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Custom script: set udg_BS_Speed[udg_BS_Times] = ( udg_BS_HYPSpeed[udg_BS_Times] * SINE )
                  • Custom script: set udg_BS_SpeedZ[udg_BS_Times] = ( udg_BS_HYPSpeed[udg_BS_Times] * COSINE )
                  • Set BS_Missile[BS_Times] = DwarvenGrenade_Bomb[(Integer A)]
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- In Object Data dummy unit have no movement type. Like that it will not change height when get close to trees and nautrial buildings. --------
                  • -------- But it must to change height. Adding and Removing Storm Crown ability will help. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Unit - Add Storm Crow Form to (Last created unit)
                  • Unit - Remove Storm Crow Form from (Last created unit)
            • Else - Actions
      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
      • -------- Cleaning leaks --------
      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
      • Custom script: call RemoveLocation ( udg_BS_Point[0] )
      • Custom script: call RemoveLocation ( udg_BS_Point[1] )
      • Custom script: call RemoveLocation ( udg_BS_Point[2] )



  • DwarvenGrenadeLoop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BS) from 1 to BS_Times, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BS_On[BS] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BS_Range[BS] Less than or equal to 0.00
                • Then - Actions
                  • Set BS_On[BS] = False
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Starting Recycling Indexes --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • BS Less than BS_Times
                    • Then - Actions
                      • Set BS_On[BS] = BS_On[BS_Times]
                      • Set BS_On[BS] = BS_On[BS_Times]
                      • Set BS_Missile[BS] = BS_Missile[BS_Times]
                      • Set BS_Hero[BS] = BS_Hero[BS_Times]
                      • Set BS_Range[BS] = BS_Range[BS_Times]
                      • Set BS_Speed[BS] = BS_Speed[BS_Times]
                      • Set BS_HYPSpeed[BS] = BS_HYPSpeed[BS_Times]
                      • Set BS_SpeedZ[BS] = BS_SpeedZ[BS_Times]
                      • Set BS_StartZ[BS] = BS_StartZ[BS_Times]
                      • Set BS_Damage[BS] = BS_Damage[BS_Times]
                      • Set BS_Angle[BS] = BS_Angle[BS_Times]
                      • Set BS_Colision[BS] = BS_Colision[BS_Times]
                      • Set BS_Level[BS] = BS_Level[BS_Times]
                      • Set BS_MaxDistance[BS] = BS_MaxDistance[BS_Times]
                      • Set BS_DistanceToTravel[BS] = BS_DistanceToTravel[BS_Times]
                      • Set BS_Parabola[BS] = BS_Parabola[BS_Times]
                      • Set BS_ArcHeight[BS] = BS_ArcHeight[BS_Times]
                      • Set BS_AoE[BS] = BS_AoE[BS_Times]
                      • Set BS_Up[BS] = BS_Up[BS_Times]
                    • Else - Actions
                  • Set BS = (BS - 1)
                  • Set BS_Times = (BS_Times - 1)
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- End of Recycling Indexes --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Set BS_Skip = (BS_Skip - 1)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • BS_Skip Equal to 0
                    • Then - Actions
                      • Set BS_Times = 0
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
                  • Set BS_Point[3] = (Position of BS_Missile[BS])
                  • Set BS_Point[4] = (BS_Point[3] offset by BS_Speed[BS] towards BS_Angle[BS] degrees)
                  • Set BS_DistanceToTravel[BS] = (BS_DistanceToTravel[BS] - BS_Speed[BS])
                  • Unit - Move BS_Missile[BS] instantly to BS_Point[4]
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- If missile comes to black areas around map, than range seted to zero. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Playable map area) contains BS_Point[4]) Equal to False
                    • Then - Actions
                      • Set BS_Range[BS] = 0.00
                    • Else - Actions
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • -------- Missile traveled some range. Lets set remaining range. --------
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • Set BS_Range[BS] = (BS_Range[BS] - BS_HYPSpeed[BS])
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • -------- Need to check height of point where missile traveled to calculate debug height and make missile movement "real" --------
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • Custom script: set udg_BS_DebugZ[udg_BS] = GetLocationZ(udg_BS_Point[4])
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • -------- Height of missile will change at diferent way when it fly up/down. --------
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • BS_Up[BS] Equal to False
                        • Then - Actions
                          • Set BS_StartZ[BS] = (BS_StartZ[BS] - BS_SpeedZ[BS])
                        • Else - Actions
                          • Set BS_StartZ[BS] = (BS_StartZ[BS] + BS_SpeedZ[BS])
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • -------- Calculation of height that missile must have. --------
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • Set BS_Parabola[BS] = (((4.00 x BS_ArcHeight[BS]) / BS_MaxDistance[BS]) x ((BS_MaxDistance[BS] - BS_DistanceToTravel[BS]) x (BS_DistanceToTravel[BS] / BS_MaxDistance[BS])))
                      • Set BS_Debug[BS] = ((BS_StartZ[BS] - BS_DebugZ[BS]) + BS_Parabola[BS])
                      • Animation - Change BS_Missile[BS] flying height to BS_Debug[BS] at 0.00
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • -------- Missile flying height is zero and it hit the ground. --------
                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • BS_Debug[BS] Less than or equal to 0.00
                        • Then - Actions
                          • Set BS_Range[BS] = 0.00
                        • Else - Actions
                          • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                          • -------- Not zero yet? Pick units to damage someone. --------
                          • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                          • Set BS_Group[BS] = (Units within BS_Colision[BS] of BS_Point[4] matching (((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Mechanical) Equal to False)) and (((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) is dead) Equal to Fa
                          • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                          • -------- Someone is picked, then deal damage. --------
                          • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                            • If - Conditions
                              • (Number of units in BS_Group[BS]) Greater than 0
                            • Then - Actions
                              • Unit Group - Pick every unit in (Random 1 units from BS_Group[BS]) and do (Actions)
                                • Loop - Actions
                                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                                  • -------- I have seted height of unit to 85. It Must be diferent for units of diferent type. --------
                                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                    • If - Conditions
                                      • And - All (Conditions) are true
                                        • Conditions
                                          • BS_Debug[BS] Greater than or equal to 0.00
                                          • BS_Debug[BS] Less than or equal to 85.00
                                    • Then - Actions
                                      • Set BS_Range[BS] = 0.00
                                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                                      • -------- 75 to 85 is height of head of unit. Head may be diferent for all unit types. --------
                                      • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                        • If - Conditions
                                          • And - All (Conditions) are true
                                            • Conditions
                                              • BS_Debug[BS] Greater than or equal to 75.00
                                              • BS_Debug[BS] Less than or equal to 85.00
                                        • Then - Actions
                                          • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                                          • -------- Ten x damage at headshot! --------
                                          • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                                          • Floating Text - Create floating text that reads HEADSHOT! at BS_Point[3] with Z offset 120.00, using font size 15.00, color (100.00%, 50.00%, 50.00%), and 0.00% transparency
                                          • Floating Text - Set the velocity of (Last created floating text) to 100.00 towards BS_Angle[BS] degrees
                                          • Floating Text - Change (Last created floating text): Disable permanence
                                          • Floating Text - Change the lifespan of (Last created floating text) to 3.00 seconds
                                          • Floating Text - Change the fading age of (Last created floating text) to 2.00 seconds
                                        • Else - Actions
                                    • Else - Actions
                            • Else - Actions
                          • Custom script: call DestroyGroup ( udg_BS_Group[udg_BS] )
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • -------- Kill leaks. --------
                  • -------- ---------------------------------------------------------------------------------------------------------------------------------------------------------- --------
                  • Custom script: call RemoveLocation ( udg_BS_Point[3] )
                  • Custom script: call RemoveLocation ( udg_BS_Point[4] )
            • Else - Actions


Update History

Update 1.2a - Fixed a major bug where the spell's level reset after using it.
Update 1.2 - Optimized code. Added spell levels.
Update 1.1d - Optimized code to fix loop skipping. Added cooldown system.
Update 1.1c - Optimized codes for reduced lag.
Update 1.1a - Optimized codes. Timer fixed ( now only shows seconds before explosion every 0.5 second ).
Update 1.1 - Fixed a bug where grenades could be thrown twice. Added port instructions for using this spell in another map.


Credits

Esdo - Idea of the skill. Creator of the map.
NTWar ( At epicwar.com ) - Creator of the "Custom bullet arc" system, used in this map ( triggers "DwarvenGrenadeArc" and "DwarvenGrenadeArcLoop".


Keywords:
grenade, bomb, spell, skill, MUI, GUI, leakless, dwarven, explosion, dwarven bomb, boom, kaboom, magic, clockwerk, steampunk
Contents

Just another Warcraft III map (Map)

Reviews
12th Dec 2015 IcemanBo: Too long as NeedsFix. Rejected. 20:34, 3rd May 2014 BPower: http://www.hiveworkshop.com/forums/spells-569/esdos-dwarven-grenade-spell-v1-2a-249250/index2.html#post2521753

Moderator

M

Moderator

12th Dec 2015
IcemanBo: Too long as NeedsFix. Rejected.

20:34, 3rd May 2014
BPower:
http://www.hiveworkshop.com/forums/spells-569/esdos-dwarven-grenade-spell-v1-2a-249250/index2.html#post2521753
 
Had quick look on triggers.

- for what you use local integer in 1st trigger?
- read index/deindex methode in a tutorial. you will see what I mean (GUI-tutorial in my signature for example)
- if you have a loop from 1-100 you have to move the "RemoveLocation" action into the loop and not only once after the loop (in more than 1 trigger as I saw)
- one loop starts with 0, all others with 1
- do not use IntegerA for loop, use your own custom integer for it. it's more efficient, and your system should have it's own specific integer
- in first 3 trigger your variables are called something with "dwarven", in other triggers they have prefix "BS_" .. why?

These should be enough for next update. I see this is your first spell here, I wish you good luck with it! :csmile:

Don't surrender, almost no ressource is at it's best at first few uploads. It always take some time to optimize it. ;)
 
Level 5
Joined
Oct 2, 2013
Messages
95
Had quick look on triggers.

- for what you use local integer in 1st trigger?
- read index/deindex methode in a tutorial. you will see what I mean (GUI-tutorial in my signature for example)
- if you have a loop from 1-100 you have to move the "RemoveLocation" action into the loop and not only once after the loop (in more than 1 trigger as I saw)
- one loop starts with 0, all others with 1
- do not use IntegerA for loop, use your own custom integer for it. it's more efficient, and your system should have it's own specific integer
- in first 3 trigger your variables are called something with "dwarven", in other triggers they have prefix "BS_" .. why?

These should be enough for next update. I see this is your first spell here, I wish you good luck with it! :csmile:

Don't surrender, almost no ressource is at it's best at first few uploads. It always take some time to optimize it. ;)

Thanks for giving a look at it! Working on your suggestions right now.

The BS_ vars are from a "Arc Projectile System" from NFWar ( dunno if it is a HiveWorkshop user ). Good thing you noted that. I forgot about the system. Im gonna give him proper credit on the next release.

But hey i got one question for you, who knows how my system works.

I give every spell an "ID" that ranges from 0 to 100. That means I can have up to 101 of this spell's type cast at once, and the triggers will still work fine.

But that method forces me to use a bunch of "Periodic Event" triggers on a "For variable x from 1 to 100".

I want to know if that may cause any lag. The looping triggers.

Thanks!
 
On it's own a loop with 100 iterations is not a big deal at itself. But it's not needed here.

You should only loop from 1-MaxIndex.
If you read index tutorials where is explained how to solve this, and you will also be able to have more than 100 instances. (usually 100 is enough, but it will be also in a more efficient way)

Then it's also important what you do in your loop.
For example if you loop from 1-100 each 0.02 seconds and also create some unit groups in each iteration inside the loop, it might be to heavy operations in too short time.
 
Level 5
Joined
Oct 2, 2013
Messages
95
Updated the map.

I read the tutorial there. But I've read that the MAX index size an array variable could take is 8192. So, using that index method, and if the limit truly exists, one would only be able to cast the spell 8192 times before the triggers crashed. Changing the limit from 100 to 8192 in my map also caused heavy LAG.

But if the limit doesn't exist, why not to make a...

For RandomInt from "MaxIndex - (Quantity of spell indexes currently in use)" to "MaxIndex"...

So every time a spell starts it increases an integer counter for (Quantity of spell.... bla bla) and every time the sell ends, the counter decreases.

That way, the FOR would run on like 10 vars max, potentially decreasing memory usage.

I don't know if that would make any sense, and I'm kind of a noob in WE right now, but would that work?
 
Level 5
Joined
Oct 2, 2013
Messages
95
No you can only run 8192 instances at once, not at all. Of course you need a proper deindex for that.

And as I said dont loop from 1 to 100 but only from 1 to MaxIndex. As was did in your 2nd system "For each (Integer BS) from 1 to BS_Times, do (Actions)".

Read this: http://www.hiveworkshop.com/forums/...en-using-triggers-gui-233242/#Section 2 Ch 12

I read that tutorial. But there's a problem. In that spell, the duration is fixed, so the spell cast first will always be the first to end. In my system, the fuse timer is random, so the first spell cast may or may not be the first to end. If it isn't, that being if the second spell cast has a shorter fuse time, the trigger would crash.
 
Switch these around.
  • Set DwarvenGrenade_CasterPoint = (Position of (Triggering unit))
  • Set DwarvenGrenade_Caster[DwarvenGrenade_Index] = (Triggering unit)
And use DwarvenGrenade_Caster[DwarvenGrenade_Index] instead of triggering unit.

Store this in a variable and use the variable for efficiency.
  • (Last created floating text)
Anything used twice or more should be stored.

After decreasing this.
  • Set DwarvenGrenade_Index = (DwarvenGrenade_Index - 1)
You also need to decrease your looping integer or it skips a spell instance whenever a spell instance ends.

Don't use integer A / B. They are slower and less efficient than using your own custom integer.

Looping from 1 to 100 every time is very inefficient.

I don't see what you mean by this.
if the second spell cast has a shorter fuse time, the trigger would crash.

If it crashes because of that then this spell is not MUI.
 
Level 5
Joined
Oct 2, 2013
Messages
95
Switch these around.
  • Set DwarvenGrenade_CasterPoint = (Position of (Triggering unit))
  • Set DwarvenGrenade_Caster[DwarvenGrenade_Index] = (Triggering unit)
And use DwarvenGrenade_Caster[DwarvenGrenade_Index] instead of triggering unit.

Store this in a variable and use the variable for efficiency.
  • (Last created floating text)
Anything used twice or more should be stored.

After decreasing this.
  • Set DwarvenGrenade_Index = (DwarvenGrenade_Index - 1)
You also need to decrease your looping integer or it skips a spell instance whenever a spell instance ends.

Don't use integer A / B. They are slower and less efficient than using your own custom integer.

Looping from 1 to 100 every time is very inefficient.

I don't see what you mean by this.


If it crashes because of that then this spell is not MUI.

Those are all fixed, but whats up with storing last created text? Why should I? Thats the only thing you said that i didn't fix.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
The configuration trigger is lacking. You should add variables like ability, min/max explosion timeout, explosion aoe, used effects, ...

Instead of checking if the periodic triggers are on, you could do a simple integer comparison --> DwarvenGrenade_index == 1

The tooltips are lacking, you can use the blizzard default tooltip for spells as template.

Remove all game text meesages (boom, follow, ...)

You could merge for example the grenadeboom and grenadefollow trigger.

Why do you check wether the grenade is alive or not? If it would be dead, the deindexing wouldn't work.

Last created unit is not safe to use in this case. It could be any unit.
  • Unit - Add Storm Crow Form to (Last created unit)
Store in GrenadeArc TriggeringUnit into a variable. You can use a local unit variable via custom script. Please null this variable at the end of the trigger to avoid potential unit handle leaks.

I'm sure you don't need 4 variables of type point plus one point array for your code.

I didn't check the whole code, yet. I will once you fixed some of the issues I mentioned.
 
Top