# [Trigger]Random Spell Casting

#### SuperCoke

Level 4
So i'm currently attempting to make a TD, and one of the towers has a percentage chance to cast 3 different spells.

I've gotten the spell casting to work properly, problem is i can't figure out how to remove the dummy for the spell casting, could anyone help me with this?

Here's one of the spells, they're all based off each other with different chances..

• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (Random integer number between 1 and 20) Equal to 20
• Then - Actions
• Unit - Create 1 Spell Monolith Dummy for (Owner of (Attacking unit)) at ((Position of (Attacking unit)) offset by (0.00, 0.00)) facing (Position of (Attacking unit))
• Set monolith_dummy[(Player number of (Owner of (Attacking unit)))] = (Last created unit)
• Unit - Order (Last created unit) to Special Archimonde - Finger Of Death (Attacked unit)
• Wait 2.00 seconds
• Unit - Remove monolith_dummy[(Player number of (Owner of (Attacking unit)))] from the game
• Else - Actions

#### Meticulous

Level 11
• Unit - Add expiration timer

P.S. it's better to use a single dummy unit and not remove it at all. Like this.

#### defskull

Level 33
Just add the expiration timer for up to 0.50 ~ 1.00 second, it should work.

This function is to have your dummy a "limited time duration" for it to live on that map.

Once it has passed a certain time (you set it at the action), it will die automatically.

You do notice 1 ~ 20 Equal to 20 = 0.05 = 5% chance for that spell to occur ? (leaving your other 2 spells to occur at most 95% of the time)

Whereas you want an approximate of 33% chance to occur for the 3 spells, right ?

It should be 1 ~ 100 Less than or Equal to 33

And in the Else branch, it should be 1 ~ 66 Less than or Equal to 33

Thus, making all your spells nearly equivalent chance to occur.

#### SuperCoke

Level 4
Just add the expiration timer for up to 0.50 ~ 1.00 second, it should work.

This function is to have your dummy a "limited time duration" for it to live on that map.

Once it has passed a certain time (you set it at the action), it will die automatically.

You do notice 1 ~ 20 Equal to 20 = 0.05 = 5% chance for that spell to occur ? (leaving your other 2 spells to occur at most 95% of the time)

Whereas you want an approximate of 33% chance to occur for the 3 spells, right ?

It should be 1 ~ 100 Less than or Equal to 33

And in the Else branch, it should be 1 ~ 66 Less than or Equal to 33

Thus, making all your spells nearly equivalent chance to occur.

Actually, i set them to different percentages because the 5% spell does high amounts of damage, and i wanted to make it rare, and it's not constant spell casting, it gives the tower a chance to cast the spells.

But thanks for the help guys, fixed it