• 🏆 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!

v1.2f Timed Bomb

  • Like
Reactions: Oljin and baassee
The caster throws a bomb that is speeding towards the targeted unit and hit with precision. After the bomb lands on the targeted unit, it is hidden around the targeted unit's body part, making them panic and hard to find it. If the targeted unit is lucky enough to find the bomb before the timer goes off, the bomb is defused.

Level 1 - 50 damage | 8 seconds timer | 300 AOE | 18% chance to defuse
Level 2 - 75 damage | 7 seconds timer | 400 AOE | 17% chance to defuse
Level 3 - 100 damage | 6 seconds timer | 500 AOE | 16% chance to defuse
Level 4 - 125 damage | 5 seconds timer | 600 AOE | 15% chance to defuse


  • TB Setup
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set BaseChanceTB = 81
      • Set ChancePerLevelTB = 1
      • Set BaseDamageTB = 25.00
      • Set DamagePerLevelTB = 25.00
      • Set BaseDurationTB = 9.00
      • Set DurationPerLevelTB = 1.00
      • Set AOE_TB = 400.00
      • Set ExplodeSFX_TB = Objects\Spawnmodels\Other\NeutralBuildingExplosion\NeutralBuildingExplosion.mdl
      • Set MissedMessageTB = DEFUSE
      • Set TimedBomb = Timed Bomb
  • TB Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Timed Bomb
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KeyTB2 Equal to 0
        • Then - Actions
          • Trigger - Turn on TB Loop <gen>
        • Else - Actions
      • Set KeyTB2 = (KeyTB2 + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KeyTB2 Greater than KeyMaxTB
        • Then - Actions
          • Set KeyTB[KeyTB2] = KeyTB2
          • Set KeyMaxTB = KeyTB2
        • Else - Actions
      • Set KeyArrayTB = KeyTB[KeyTB2]
      • Set CasterTB[KeyArrayTB] = (Triggering unit)
      • Set TargetTB[KeyArrayTB] = (Target unit of ability being cast)
      • Set AbilityLevelTB = (Level of TimedBomb for CasterTB[KeyArrayTB])
      • Set DurationTB[KeyArrayTB] = (BaseDurationTB - (DurationPerLevelTB x (Real(AbilityLevelTB))))
      • Set DamageTB[KeyArrayTB] = (BaseDamageTB + (DamagePerLevelTB x (Real(AbilityLevelTB))))
      • Set ChanceTB[KeyArrayTB] = (BaseChanceTB + (ChancePerLevelTB x AbilityLevelTB))
  • TB Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer LoopingIntegerTB) from 1 to KeyTB2, do (Actions)
        • Loop - Actions
          • Set KeyArrayTB = KeyTB[LoopingIntegerTB]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • DurationTB[KeyArrayTB] Greater than 0.00
            • Then - Actions
              • Set DurationTB[KeyArrayTB] = (DurationTB[KeyArrayTB] - 0.03)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (TargetTB[KeyArrayTB] is alive) Equal to True
                • Then - Actions
                  • Set PercentageTB = (Random integer number between 1 and 100)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • PercentageTB Less than or equal to ChanceTB[KeyArrayTB]
                    • Then - Actions
                      • Set TargetLocTB = (Position of TargetTB[KeyArrayTB])
                      • Special Effect - Create a special effect at TargetLocTB using ExplodeSFX_TB
                      • Special Effect - Destroy (Last created special effect)
                      • Custom script: set bj_wantDestroyGroup = true
                      • Unit Group - Pick every unit in (Units within AOE_TB of TargetLocTB matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is Magic Immune) Equal to False) and ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of Cast and do (Actions)
                        • Loop - Actions
                          • Unit - Cause CasterTB[KeyArrayTB] to damage (Picked unit), dealing DamageTB[KeyArrayTB] damage of attack type Spells and damage type Normal
                      • Custom script: call RemoveLocation(udg_TargetLocTB)
                    • Else - Actions
                      • Floating Text - Create floating text that reads MissedMessageTB above TargetTB[KeyArrayTB] with Z offset 0.00, using font size 10.00, color (0.00%, 100.00%, 0.00%), and 0.00% transparency
                      • Floating Text - Set the velocity of (Last created floating text) to 200.00 towards 90.00 degrees
                      • Floating Text - Change (Last created floating text): Disable permanence
                      • Floating Text - Change the lifespan of (Last created floating text) to 1.50 seconds
                      • Floating Text - Change the fading age of (Last created floating text) to 0.75 seconds
                • Else - Actions
              • Set KeyTB[LoopingIntegerTB] = KeyTB[KeyTB2]
              • Set KeyTB[KeyTB2] = KeyArrayTB
              • Set KeyTB2 = (KeyTB2 - 1)
              • Set LoopingIntegerTB = (LoopingIntegerTB - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • KeyTB2 Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
v1.00
- First release

v1.1
- Separates the INIT trigger and the Spell Trigger
- Use only one removing TargetLoc leak Action
- Changed SuccessChance variable to Integer

v1.2f
- Remake the formula damage
- Triggers now are heavily optimized than before
- Hashtable was changed to Indexing (to stack the bombs upon casting on 1 unit)
- The timer floating text has been removed
- Fixed some tooltips
- Re-separation of unused triggers
- Comments are given only in the Setup Trigger


Feedbacks/Comments/Constructive Criticism is needed, thank you.

NOTE: This is my first indexing try, hope I can improve the indexing method :)

Keywords:
indexing, defskull, bomb, MUI, timed, explosion, chance, delay, wait, detonate, explode.
Contents

Timed Bomb (Map)

Reviews
Approved. The floating text can be seen even for players that have the area masked. Maybe there could be some sort of indication that a unit has a timed bomb attached to it. Suggested changes Improve the tooltip Do "KeyTB2 Equal to 0"...

Moderator

M

Moderator

Reviewed by Maker, Timed Bomb v1.2f, 17th Feb 2012

Approved.

The floating text can be seen even for players that have the area masked.
Maybe there could be some sort of indication that a unit has a timed bomb attached to it.

Suggested changes
  • Improve the tooltip
  • Do "KeyTB2 Equal to 0" comparison only when you subtract from KeyTB2
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
It is MUI and there seems to be no leaks.

Use the location:
  • Unit - Order (Picked unit) to Patrol To (Center of Region 001 <gen>)
Create a separate trigger for this or remove it, it does not belong to the spell:
  • Selection - Select The Joker 0001 <gen> for Player 1 (Red)
Same goes for the patrolling thing, do them in some other trigger, that does not belong to the spell.
You set the triggering unit into a variable in BT cast, but then after that you use a function to get the triggering unit. Use the variable.
Set the level of ability into a variable and use the variable.
You could store the target unit's handle id into a variable and use the variable to store the data.
This check
  • (Number of units in GroupBT) Greater than 0
should be after
  • Unit Group - Remove (Picked unit) from GroupBT
You only need to have this once
  • Custom script: call RemoveLocation(udg_TargetLoc)
Not in both THEN and ELSE. Move it to be the last action inside the unit group loop.
Forgot to use a variable for the hash:
  • Hashtable - Save (Duration - 1.00) as (Key Duration) of (Key (Picked unit)) in (Last created hashtable)
Why is succes chance a real?
You could store the handle id of picked unit into a variable and use that instead of constantly using a function to get it.
Make the tooltip text (normal and extended) more like in Blizzard's abilities.
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
This is neat I must say yet there are a few flaws.

Serperate the map's init trigger with the triggers' init trigger. The selecting, the moving dummies, the point, move all that into another trigger and create the hash at map init.

Gosh I hate hashtables so this is how it goes. This spell cannot stack onto the same unit twice or more as the parent key "of target unit" will be overwritten and due to that, the previous instance will be lost.

You can always check if the loop is already on as you did in the loop when you checked the amount of units.

This only supports integers, not real values to the duration. Why not make it even better and support values above 0.03?

The pickedloc is not necessary. Just create the special effect attached to the picked units' origin.

Else you got my approval.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
It is MUI and there seems to be no leaks.

Use the location:
  • Unit - Order (Picked unit) to Patrol To (Center of Region 001 <gen>)
Create a separate trigger for this or remove it, it does not belong to the spell:
  • Selection - Select The Joker 0001 <gen> for Player 1 (Red)
Same goes for the patrolling thing, do them in some other trigger, that does not belong to the spell.
You set the triggering unit into a variable in BT cast, but then after that you use a function to get the triggering unit. Use the variable.
Set the level of ability into a variable and use the variable.
You could store the target unit's handle id into a variable and use the variable to store the data.
This check
  • (Number of units in GroupBT) Greater than 0
should be after
  • Unit Group - Remove (Picked unit) from GroupBT
You only need to have this once
  • Custom script: call RemoveLocation(udg_TargetLoc)
Not in both THEN and ELSE. Move it to be the last action inside the unit group loop.
Forgot to use a variable for the hash:
  • Hashtable - Save (Duration - 1.00) as (Key Duration) of (Key (Picked unit)) in (Last created hashtable)
Why is succes chance a real?
You could store the handle id of picked unit into a variable and use that instead of constantly using a function to get it.
Make the tooltip text (normal and extended) more like in Blizzard's abilities.

This is neat I must say yet there are a few flaws.

Serperate the map's init trigger with the triggers' init trigger. The selecting, the moving dummies, the point, move all that into another trigger and create the hash at map init.

Gosh I hate hashtables so this is how it goes. This spell cannot stack onto the same unit twice or more as the parent key "of target unit" will be overwritten and due to that, the previous instance will be lost.

You can always check if the loop is already on as you did in the loop when you checked the amount of units.

This only supports integers, not real values to the duration. Why not make it even better and support values above 0.03?

The pickedloc is not necessary. Just create the special effect attached to the picked units' origin.

Else you got my approval.

This check
  • (Number of units in GroupBT) Greater than 0
should be after
  • Unit Group - Remove (Picked unit) from GroupBT

How do I actually do this ?
Re-trigger the conditions back at the starting point ?
Because that unit group action is in the Else function

Gosh I hate hashtables so this is how it goes. This spell cannot stack onto the same unit twice or more as the parent key "of target unit" will be overwritten and due to that, the previous instance will be lost.
What does this means ?
Unstackable, as... ?

Further changelogs will be made, time to hit the hay
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
You could make it stackable with hashtables also. Just don't overwrite the key or flush the child hashtable if another instance is still going on.

You could update a stack count value for each unit and then use keys tied to the stack count. Concatenate the keys like:

count = LoadInteger( hash , id , StringHash("count"))
SaveReal( hash , id , StringHash("duration" + I2S(count)) , duration )
SaveInteger( hash , id , StringHash("count") , count + 1 )

This way keys for the first instance will be xxx0, for second instance xxx1 and so on. In the unit group loop, loop from 0 to count for each unit.

Though indexing is a viable alternative.
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
great now you're doin it bro!...

but some things I noticed...you cant cast this spell on the same target coz it will bug...I mean you can but it will bug...

solution;
1. Make a dummy unit and store everthing to it then do this...
  • Unit Group - Add (Last created unit) to GroupBT
2. Make a condition if value of hashtable exist, like this...then put the actions in the 'ELSE' part...
  • ((Key Duration) is stored as a Real of (Key (Target unit of ability being cast)) in HashBT) Equal to True
other than that, good job 5/5
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
Proper indexing isn't hard at all to learn, just view Hanky's Dynamic Indexing Template in the spell section. Hashtables are useful when the parent key cannot be overwritten, in this case it can and therefore it may have unlimited instances yet it bugs which indexing wouldn't do.

And don't tell me indexing is those noobs we have in the spell section just having an integer variable setting + 1 every single cast, that sure is rubbish and I'm going so much OT right now but if you want a great spell, watch D4RK_G4ND4LF's spells. He got a proper indexing technique with a great recycling, not the most common one but hey, he's one of the best I've seen so far even if he doesn't code vJASS. He is like Paladon was and said once: "What you can make in vJASS, I can make in GUI."
 
Level 22
Joined
Nov 14, 2008
Messages
3,256
like what I said in the other trigger, you cant cast a spell at the same time from the same unit even if cooldown is zero or 0.01...if Im wrong then I stand corrected...

it doesnt matter as spells can be traveling/being active during a period which the spell can be re-casted and if you are stupid enough to use the same key of the caster as parent key then the first instance will bug

that's what we are trying to say with our "MUI" talk
 
Level 29
Joined
Mar 10, 2009
Messages
5,016
it doesnt matter as spells can be traveling/being active during a period which the spell can be re-casted and if you are stupid enough to use the same key of the caster as parent key then the first instance will bug

that's what we are trying to say with our "MUI" talk

Good thing though that I am now aware of the bug that you mention, :)...peace bro!...

Off topic finished...
 
Level 5
Joined
May 13, 2012
Messages
66
lols whats with the %chance to defuse? It would be better if had a dummy invisibility ability that gets removed whenever a enemy unit gets within 100aoe (bomb becomes visible) if its explosion aoe is 250.

-my suggestion of a realistic Modern Warfare spell.
 
Top