Random Spell Cast - Help

Level 3
Joined
May 21, 2009
Messages
37
I need a spell that when cast, it will cast a random spell from a list.
For example: A unit casts "Elemental Attack" on another unit. The spell has 25% chance to cast a lightning (damage the unit), 25% chance to deal damage over time to that unit, 25% chance to slow the unit, and 25% chance to stun the unit ( just one at a time). I hope you understood my problem, sorry for my English.
 
Level 13
Joined
Feb 18, 2009
Messages
1,382
Make a randomize trigger.
It is something like
For each integer 1-4 do actions
If/then/else
Number is 1
then
Do your actions
else
if/then/else
if number is 2
then do actions
else.

And so on.
Sorry for not remembering triggers excact name, but sometimes Maker or Pharaoh comes by, and they'll show you :)
There is a solution.
 
Ok, let's see :)
First, you need to set an array with the 4 abilities' strings/Order Id's. To find the Order Id of an ability, go to the ability and scroll to Text - Order String - Use/Turn on. So, the "Ability[]" variable is a String-type variable.
We will use a custom script for saving time.
  • Trigger1
  • Events
    • Map Initialization
  • Conditions
  • Actions
    • Set Ability[1] = chainglightning
    • Set Ability[2] = shadowstrike
    • Set Ability[3] = cripple
    • Set Ability[4] = thunderbolt
As you can see, I used Chain Lightning, Shadow Strike, Cripple and Storm Bolt.
  • Trigger2
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Elemental Attack
  • Actions
    • Set Point1 = (Position of (Target unit of ability being cast))
    • Unit - Create 1 dummy for (Owner of (Triggering unit)) at Point1 facing default building degrees
    • Unit - Add 2.00 seconds generic expiration timer to (Last created unit)
    • Set RandomInteger = (Random integer number between 1 and 4)
    • Custom script: call IssueTargetOrder (GetLastCreatedUnit(), udg_Ability[udg_RandomInteger], GetSpellTargetUnit())
    • Custom script: call RemoveLocation (udg_Point1)
Notice, the dummy must already have the abilities for this trigger to work in this state.
 
Last edited:
Top