• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Bomb v1.01

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Hi guys!

First of all, here is the description:

The Mortar Team shoots out a bomb with destructive force, dealing damage to units near the impact location and knocks them back into air at the same time. When the units land they take additional damage. Also destroys trees.
Level 1 - 100 impact damage, 20 landing damage.
Level 2 - 200 impact damage, 40 landing damage.
Level 3 - 300 impact damage, 60 landing damage.


The bomb flies in a parabola as well as the knockbacked units.

I imported the explosion model cuz I didn't find anything that could fit with this. Thanks to WILL THE ALMIGHTY for his awesome model!

  • Bomb
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bomb
    • Actions
      • -------- Here we set the variables: --------
      • Set Key = (Key (Triggering unit))
      • -------- The casting unit: --------
      • Set Bomb_Caster = (Triggering unit)
      • -------- Position of the casting unit: --------
      • Set Bomb_Point = (Position of Bomb_Caster)
      • -------- Target point of the spell: --------
      • Set Bomb_Target = (Target point of ability being cast)
      • -------- The angle from the caster to the target: --------
      • Set Bomb_Angle = (Angle from Bomb_Point to Bomb_Target)
      • -------- The distance between the caster and the target: --------
      • Set Bomb_MaxDistance = (Distance between Bomb_Point and Bomb_Target)
      • -------- The maximum heigth that the bomb reaches while flying (the heigth of the top of the parabola) --------
      • Set Bomb_MaxHeight = 500.00
      • -------- Every 0.03 seconds the bomb will moves the distance you set below: --------
      • Set Bomb_Speed = 20.00
      • -------- Leave it as false --------
      • Set Bomb_KnockbackOn = False
      • -------- The damage the bomb deals: --------
      • Set Bomb_Damage = ((Real((Level of Bomb for Bomb_Caster))) x 100.00)
      • -------- And finally we create the dummy unit (the bomb): --------
      • Unit - Create 1 Bomb Dummy for (Owner of Bomb_Caster) at Bomb_Point facing Default building facing degrees
      • Set Bomb_Dummy = (Last created unit)
      • Unit - Add Crow Form to Bomb_Dummy
      • Unit - Remove Crow Form from Bomb_Dummy
      • Unit Group - Add Bomb_Caster to Bomb_Group
      • -------- These will store the data we set in a hashtable: --------
      • Hashtable - Save Handle OfBomb_Caster as 0 of Key in Bomb_Hash
      • Hashtable - Save Handle OfBomb_Point as 1 of Key in Bomb_Hash
      • Hashtable - Save Handle OfBomb_Target as 2 of Key in Bomb_Hash
      • Hashtable - Save Bomb_Angle as 3 of Key in Bomb_Hash
      • Hashtable - Save Bomb_MaxDistance as 4 of Key in Bomb_Hash
      • Hashtable - Save Bomb_MaxHeight as 5 of Key in Bomb_Hash
      • Hashtable - Save Bomb_Speed as 6 of Key in Bomb_Hash
      • Hashtable - Save Bomb_KnockbackOn as 7 of Key in Bomb_Hash
      • Hashtable - Save Handle OfBomb_Dummy as 8 of Key in Bomb_Hash
      • Hashtable - Save Bomb_Damage as 10 of Key in Bomb_Hash
      • Trigger - Turn on Bomb Loop <gen>
  • Bomb Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in Bomb_Group and do (Actions)
        • Loop - Actions
          • Set Key = (Key (Picked unit))
          • -------- These are the values we use both in the bomb and the knockback part. --------
          • Set Bomb_Caster = (Load 0 of Key in Bomb_Hash)
          • Set Bomb_KnockbackOn = (Load 7 of Key from Bomb_Hash)
          • Set Bomb_MaxDistance = (Load 4 of Key from Bomb_Hash)
          • Set Bomb_Damage = (Load 10 of Key from Bomb_Hash)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Bomb_KnockbackOn Equal to False
            • Then - Actions
              • -------- And these are only for the bomb part. --------
              • Set Bomb_Point = (Load 1 of Key in Bomb_Hash)
              • Set Bomb_Target = (Load 2 of Key in Bomb_Hash)
              • Set Bomb_Angle = (Load 3 of Key from Bomb_Hash)
              • Set Bomb_MaxHeight = (Load 5 of Key from Bomb_Hash)
              • Set Bomb_Speed = (Load 6 of Key from Bomb_Hash)
              • Set Bomb_Dummy = (Load 8 of Key in Bomb_Hash)
              • Set Bomb_Distance = (Load 9 of Key from Bomb_Hash)
              • -------- Every 0.03 seconds this increases the distance traveled and moves the bomb dummy --------
              • Set Bomb_Distance = (Bomb_Distance + Bomb_Speed)
              • Hashtable - Save Bomb_Distance as 9 of Key in Bomb_Hash
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Bomb_Distance Less than or equal to Bomb_MaxDistance
                • Then - Actions
                  • Set tempPoint = (Bomb_Point offset by Bomb_Distance towards Bomb_Angle degrees)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Terrain pathing at tempPoint of type Flyability is off) Equal to False
                    • Then - Actions
                      • Unit - Move Bomb_Dummy instantly to tempPoint
                    • Else - Actions
                  • -------- This is the formula for the parabola. Don't change it! --------
                  • Custom script: set udg_Bomb_Height = 4*udg_Bomb_MaxHeight*udg_Bomb_Distance*(udg_Bomb_MaxDistance-udg_Bomb_Distance)/(udg_Bomb_MaxDistance*udg_Bomb_MaxDistance)
                  • Animation - Change Bomb_Dummy flying height to Bomb_Height at 0.00
                  • Custom script: call RemoveLocation(udg_tempPoint)
                • Else - Actions
                  • -------- When the bomb lands, we create a nice effect, deal damage and prepare for the knockback part --------
                  • -------- This switches between the bomb flying and the knockback part --------
                  • Hashtable - Save True as 7 of Key in Bomb_Hash
                  • Unit - Remove Bomb_Dummy from the game
                  • Special Effect - Create a special effect at Bomb_Target using war3mapImported\NewMassiveEX.mdx
                  • Special Effect - Destroy (Last created special effect)
                  • Destructible - Pick every destructible within 300.00 of Bomb_Target and do (Actions)
                    • Loop - Actions
                      • Destructible - Kill (Picked destructible)
                  • -------- Here we set the parameters of the knockback, you can change everything here that used in the bomb flying part, just copy them from the first trigger --------
                  • Set Bomb_MaxHeight = 300.00
                  • Set Bomb_Speed = 15.00
                  • Hashtable - Save Bomb_MaxHeight as 5 of Key in Bomb_Hash
                  • Hashtable - Save Bomb_Speed as 6 of Key in Bomb_Hash
                  • Set Bomb_KnockbackGroup = (Units within 300.00 of Bomb_Target matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of Bomb_Caster)) Equal to True) and ((((Matching unit) is in B
                  • Hashtable - Save Handle OfBomb_KnockbackGroup as 11 of Key in Bomb_Hash
                  • Custom script: call RemoveLocation(udg_Bomb_Point)
                  • Unit Group - Pick every unit in Bomb_KnockbackGroup and do (Actions)
                    • Loop - Actions
                      • -------- Yes, I use another hashtable for easier configuration and for a clear code. --------
                      • -------- So, we store everything what we don't want to modify in the knockback part. --------
                      • Unit - Cause Bomb_Caster to damage (Picked unit), dealing Bomb_Damage damage of attack type Spells and damage type Fire
                      • Set Knockback_Key = (Key (Picked unit))
                      • Set Bomb_Point = (Position of (Picked unit))
                      • Set Bomb_Angle = (Angle from Bomb_Target to Bomb_Point)
                      • Set Bomb_MaxDistance = (500.00 - (Distance between Bomb_Point and Bomb_Target))
                      • Unit - Turn collision for (Picked unit) Off
                      • Unit - Add Crow Form to (Picked unit)
                      • Unit - Remove Crow Form from (Picked unit)
                      • Hashtable - Save Handle OfBomb_Point as 1 of Knockback_Key in Bomb_KnockbackHash
                      • Hashtable - Save Bomb_MaxDistance as 2 of Knockback_Key in Bomb_KnockbackHash
                      • Hashtable - Save Bomb_Angle as 3 of Knockback_Key in Bomb_KnockbackHash
                      • -------- We also need a debug group that checks if the unit was hit by another bomb before, so it doesn't cause bugs. --------
                      • Unit Group - Add (Picked unit) to Bomb_DebugGroup
                  • Custom script: call RemoveLocation(udg_Bomb_Target)
            • Else - Actions
              • -------- And again, we set the constant values for the knockback: --------
              • Set Bomb_MaxHeight = (Load 5 of Key from Bomb_Hash)
              • Set Bomb_Speed = (Load 6 of Key from Bomb_Hash)
              • -------- And now the knockback begins, it works the same way as the bomb movement. --------
              • Set Bomb_KnockbackGroup = (Load 11 of Key in Bomb_Hash)
              • Unit Group - Pick every unit in Bomb_KnockbackGroup and do (Actions)
                • Loop - Actions
                  • Set Knockback_Key = (Key (Picked unit))
                  • -------- And there are the values that changes with every unit: --------
                  • Set Bomb_Point = (Load 1 of Knockback_Key in Bomb_KnockbackHash)
                  • Set Bomb_MaxDistance = (Load 2 of Knockback_Key from Bomb_KnockbackHash)
                  • Set Bomb_Angle = (Load 3 of Knockback_Key from Bomb_KnockbackHash)
                  • Set Bomb_Distance = (Load 4 of Knockback_Key from Bomb_KnockbackHash)
                  • Set Bomb_Distance = (Bomb_Distance + Bomb_Speed)
                  • Hashtable - Save Bomb_Distance as 4 of Knockback_Key in Bomb_KnockbackHash
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Bomb_Distance Less than or equal to Bomb_MaxDistance
                    • Then - Actions
                      • Set tempPoint = (Bomb_Point offset by Bomb_Distance towards Bomb_Angle degrees)
                      • -------- This checks the pathability to units don't go out the map. --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Terrain pathing at tempPoint of type Flyability is off) Equal to False
                        • Then - Actions
                          • Unit - Move (Picked unit) instantly to tempPoint
                        • Else - Actions
                      • -------- This is the formula for the parabola. Don't change it! --------
                      • Custom script: set udg_Bomb_Height = 4*udg_Bomb_MaxHeight*udg_Bomb_Distance*(udg_Bomb_MaxDistance-udg_Bomb_Distance)/(udg_Bomb_MaxDistance*udg_Bomb_MaxDistance)
                      • Animation - Change (Picked unit) flying height to Bomb_Height at 0.00
                      • -------- Removing the locations: --------
                      • Custom script: call RemoveLocation(udg_tempPoint)
                    • Else - Actions
                      • Set tempPoint = (Position of (Picked unit))
                      • Unit - Turn collision for (Picked unit) On
                      • -------- If the unit landed in deep water this will instantly kill it. --------
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Terrain pathing at tempPoint of type Walkability is off) Equal to True
                          • (Terrain pathing at tempPoint of type Floatability is off) Equal to False
                        • Then - Actions
                          • Unit - Cause Bomb_Caster to damage (Picked unit), dealing 1000000000.00 damage of attack type Chaos and damage type Normal
                        • Else - Actions
                      • -------- Here we create an effect for the units that landed and deal damage to them. --------
                      • Unit - Cause Bomb_Caster to damage (Picked unit), dealing (Bomb_Damage / 5.00) damage of attack type Spells and damage type Normal
                      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Other\Volcano\VolcanoDeath.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • -------- Then some clearing and we are done! --------
                      • Unit Group - Remove (Picked unit) from Bomb_KnockbackGroup
                      • Unit Group - Remove (Picked unit) from Bomb_DebugGroup
                      • Custom script: call RemoveLocation(udg_Bomb_Point)
                      • Custom script: call RemoveLocation(udg_tempPoint)
                      • Hashtable - Clear all child hashtables of child Knockback_Key in Bomb_KnockbackHash
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in Bomb_KnockbackGroup) Equal to 0
                • Then - Actions
                  • Custom script: call DestroyGroup(udg_Bomb_KnockbackGroup)
                  • Unit Group - Remove Bomb_Caster from Bomb_Group
                  • Hashtable - Clear all child hashtables of child Key in Bomb_Hash
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in Bomb_Group) Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
Keywords:
bomb, explosion, boom, knockback, parabola, fly, mortar team, hashtable
Contents

Bomb (Map)

Reviews
12th Dec 2015 IcemanBo: For too long time as NeedsFix. Rejected. Bribe: Your code is an absolute mess and the best I can tell is leaking tons and tons of locations. The problem with it being such a mess is that you can't even see where you're...

Moderator

M

Moderator

12th Dec 2015
IcemanBo: For too long time as NeedsFix. Rejected.

Bribe:

Your code is an absolute mess and the best I can tell is leaking tons and tons of locations. The problem with it being such a mess is that you can't even see where you're supposed to remove each location, destroy each group, because you save them all into hashtables and I have no idea where they pop up again.
 
Level 10
Joined
Apr 25, 2009
Messages
296
0.03 is preferred over .02, its more efficient and won't have a major effect visually.

  • (Load 9 of Key from Bomb_Hash) Less than or equal to (Load 4 of Key from Bomb_Hash)
Why not set the variable before the condition, so that you don't call it as many times?

This is your parabola without the BJs:
  • set udg_Bomb_Height = 4*LoadReal(udg_Bomb_Hash, udg_Key, 5)*udg_Bomb_Distance*(LoadReal(udg_Bomb_Hash, udg_Key, 4)-udg_Bomb_Distance)/Pow(LoadReal(udg_Bomb_Hash, udg_Key, 4), 2.00)
============================================

  • Set Bomb_KnockbackOn = False
  • Set Bomb_Speed = 15.00
  • Set Bomb_MaxHeight = 500.00
Instead of setting the values as variables and then saving the variables, why not directly save them in the hashtable?

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in Bomb_Group) Equal to 0
    • Then - Actions
      • Trigger - Turn off (This trigger)
    • Else - Actions
Instead of checking this condition every loop, perhaps move it so that you only check this when a unit is removed from the unit group?

================================

  • Set Bomb_KnockbackGroup = (Units within 300.00 of (Load 2 of Key in Bomb_Hash) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of (Load 0 of Key in Bomb_Hash))) Equal to Tr
  • Hashtable - Save Handle OfBomb_KnockbackGroup as 11 of Key in Bomb_Hash
  • Unit Group - Pick every unit in (Load 11 of Key in Bomb_Hash) and do (Actions)
    • Loop - Actions
Instead of loading the hashtable, use the Bomb_KnockbackGroup variable.

  • Unit - Remove (Load 8 of Key in Bomb_Hash) from the game
If I'm correct, Explode Unit is preferred over Remove Unit
 
Level 3
Joined
Feb 1, 2010
Messages
16
0.03 is preferred over .02, its more efficient and won't have a major effect visually.

  • (Load 9 of Key from Bomb_Hash) Less than or equal to (Load 4 of Key from Bomb_Hash)
Why not set the variable before the condition, so that you don't call it as many times?

This is your parabola without the BJs:
  • set udg_Bomb_Height = 4*LoadReal(udg_Bomb_Hash, udg_Key, 5)*udg_Bomb_Distance*(LoadReal(udg_Bomb_Hash, udg_Key, 4)-udg_Bomb_Distance)/Pow(LoadReal(udg_Bomb_Hash, udg_Key, 4), 2.00)
============================================

  • Set Bomb_KnockbackOn = False
  • Set Bomb_Speed = 15.00
  • Set Bomb_MaxHeight = 500.00
Instead of setting the values as variables and then saving the variables, why not directly save them in the hashtable?

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in Bomb_Group) Equal to 0
    • Then - Actions
      • Trigger - Turn off (This trigger)
    • Else - Actions
Instead of checking this condition every loop, perhaps move it so that you only check this when a unit is removed from the unit group?

================================

  • Set Bomb_KnockbackGroup = (Units within 300.00 of (Load 2 of Key in Bomb_Hash) matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is dead) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of (Load 0 of Key in Bomb_Hash))) Equal to Tr
  • Hashtable - Save Handle OfBomb_KnockbackGroup as 11 of Key in Bomb_Hash
  • Unit Group - Pick every unit in (Load 11 of Key in Bomb_Hash) and do (Actions)
    • Loop - Actions
Instead of loading the hashtable, use the Bomb_KnockbackGroup variable.

  • Unit - Remove (Load 8 of Key in Bomb_Hash) from the game
If I'm correct, Explode Unit is preferred over Remove Unit

1. Changed.
2. I didn't know that, thanks +rep.
3. Just to be more clearly.
4-5. Changed too.
6. What's the difference between them?


Also I think I removed all leaks from the code.
 
Last edited:
  • Custom script: set udg_Bomb_Height = 4*LoadReal(udg_Bomb_Hash, udg_Key, 5)*udg_Bomb_Distance*(LoadReal(udg_Bomb_Hash, udg_Key, 4)-udg_Bomb_Distance)/Pow(LoadReal(udg_Bomb_Hash, udg_Key, 4), 2.00)
Don't use Pow(x,2)
Just do something like x * x (It's faster and more efficient)
Also, make sure you save the real (udg_Key,4) into a variable since you're using it several times.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
- It destroys trees before the bomb lands
- Last created unit is fine instead of Bomb_Dummy
- Unit Group - Add TriggeringUnit to Bomb_Group is fine
- You really dont need this >>> (Number of units in Bomb_Group) Equal to 1
- You should really practice to Load the hashtable in a variable in the loop trigger for better reading
 
Top