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

Random Spells Trigger

Status
Not open for further replies.
Level 3
Joined
May 30, 2008
Messages
32
Hi I'm trying to make it when a unit use an ability then trigger will fire, and cast the random Viarable Spells let me give u an excample.

First trigger for random spells

  • random spells
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RandomSpell[1] = Breath of Fire
      • Set RandomSpell[1] = Blizzard
Second trigger when an unit cast an ability.

  • Random Spells test
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to a hell hound
    • Actions
Question is what should I put on Action Let me give u an excample it work for Unit. Look below it for unit only.

  • random spawner
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RandomSpawn[1] = a slime
      • Set RandomSpawn[2] = a rat
      • Set RandomSpawn[3] = a dire wolf
      • Set RandomSpawn[4] = a rat man
      • Set RandomSpawn[5] = a hell hound
      • Set RandomSpawn[6] = a rat mage
      • Set RandomSpawn[7] = a silver serpent
      • Set RandomSpawn[8] = a rat archer
      • Set RandomSpawn[9] = a barracoon
Look below it random spawn.

  • Randomness
    • Events
      • Unit - A unit owned by Player 12 (Brown) Dies
    • Conditions
    • Actions
      • Unit - Create 1 RandomSpawn[(Random integer number between 1 and 9)] for Player 12 (Brown) at (Random point in Spawn a <gen>) facing Default building facing degrees

Ok I want a trigger similar like it spawn Unit but it will give me random to fire off one for spells on specific Unit.

I know how to add what unit to make the spell cast off from, But i just want to know how to make a simple trigger like this in action for spells random when use an ability.

  • Randomness
    • Events
      • Unit - A unit owned by Player 12 (Brown) Dies
    • Conditions
    • Actions
      • Unit - Create 1 RandomSpawn[(Random integer number between 1 and 9)] for Player 12 (Brown) at (Random point in Spawn a <gen>) facing Default building facing degrees
 
Level 2
Joined
Jan 29, 2009
Messages
21
First of , arrays start at 0, not 1. So an array of size 9 goes from 0 - 8 (so basically your arrays are 1 size too big / you wont ever get the last effect)

To do what you're thinking of is pretty simple (I think)

Have an array of abilities, and set each index to your desired random ability, then create a dummy unit at the position of the caster. Then:

  • Actions:
    • Set temp = (Target Point of Ability Being Cast) <or target of ability, or just position of caster, etc>
    • Set X = (Random Integer between 0 and 8)
    • Unit - Add Ability[X] to (Dummy_Unit)
    • Unit - Set Level of Ability[X] to (Level of (Ability Being Cast) for (Triggering Unit)
(This is the part that sucks with GUI, if you are willing to use JASS you can just have an array of order strings from 0 to 8 and reference that, but if not you need a nested if statement that if X is 0 issue this order, if its 1 issue this order, etc.)
 
Level 3
Joined
May 30, 2008
Messages
32
How I get This and what viarable is Set Temp,

(Target Point of Ability Being Cast) <-------- I can't find this...


what vairable is Set X,

What Vairable is this (Dummy_Unit)

what I mean by Viarable is what u set it to like unit, hero, ability, etc
 
Level 3
Joined
May 30, 2008
Messages
32
ok I got most of it then there 1 part I can't get it right is when he said to make this.

  • Set temp = (Target Point of Ability Being Cast) <or target of ability, or just position of caster, etc>
  • Set X = (Random Integer between 0 and 8)
  • Unit - Add Ability[X] to (Dummy_Unit)
  • Unit - Set Level of Ability[X] to (Level of (Ability Being Cast) for (Triggering Unit)
Ok the bottom one I can't get right it is this one.

  • Unit - Set Level of Ability[X] to (Level of (Ability Being Cast) for (Triggering Unit)
The best I can do is this.


  • Random Spells test Copy Copy 2
    • Events
      • Unit - A unit owned by Player 12 (Brown) Starts the effect of an ability
    • Conditions
      • (Unit-type of (Casting unit)) Equal to a hell hound
    • Actions
      • Set Temp = (Target point of ability being cast)
      • Set X = (Random integer number between 0 and 8)
      • Unit - Add RandomSpell to Dummy_unit
      • Unit - Set level of RandomSpell for (Triggering unit) to (Level of RandomSpell for (Triggering unit))
Look at my bottom and his excample can anybody explain how to get that bottom one right.
I don't know if I got this right.
 
Level 3
Joined
May 30, 2008
Messages
32
So Blizzard overwrites Breath of Fire.

Zapper, you need to make RandomSpell an array variable.

Triggers - Variables and Arrays

Ok none of this is working can anybody else help me make a simple trigger or help me explain how.

Yes I did change that same array it now at

  • random spells
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set RandomSpell[0] = Black Arrow
      • Set RandomSpell[1] = Battle Roar
      • Set RandomSpell[2] = Breath of Fire
      • Set RandomSpell[3] = Silence
      • Set RandomSpell[4] = Doom
      • Set RandomSpell[5] = Cripple
      • Set RandomSpell[6] = Purge
      • Set RandomSpell[7] = Shockwave (Neutral Hostile)
      • Set RandomSpell[8] = Corrosive Breath
 
Level 2
Joined
Jan 29, 2009
Messages
21
Instead of this:

  • Actions:
    • Unit - Add Ability[X] to (Dummy_Unit)
    • Unit - Set Level of Ability[X] to (Level of (Ability Being Cast) for (Triggering Unit)
you need to do this:

  • Actions:
    • Unit - Create 1 Dummy at Temp facing 0
    • Set Dummy_Unit = (Last Created Unit)
    • Unit - Add Ability[X] to Dummy_Unit
    • Unit - Add a 2 second Generic Expiration timer to Dummy_Unit
    • Unit - Set Level of Ability[X] for Dummy_Unit to (Level of (Ability Being Cast) for (Triggering Unit))
    • Unit - Order Dummy_Unit to -spell- temp
for Unit - Order Dummy_Unit to -spell- temp, you have to create a series of if statements that says

  • Actions:
    • If Ability[X] = Blizzard
      • Unit - Order Dummy_Unit to (Human Archmage - Blizzard) temp
    • Else
      • If Ability[X] = Rain of Fire
        • ....Etc
EDIT: If you want to make a random ability, you should have every ability have a similar type of target. For example, cripple targets a unit but Silence is an area, how do you expect the computer to know which unit or area you want to effect if the ability that triggers it can only have one kind of target? (IE a point or a unit)

Unless you want to ADD the ability to the casting unit (not actually cast it), which in that case would be completely different.
 
Level 11
Joined
Nov 15, 2007
Messages
781
I think he's just trying to add abilities, not have an ability randomly cast.

Also,

First of , arrays start at 0, not 1. So an array of size 9 goes from 0 - 8 (so basically your arrays are 1 size too big / you wont ever get the last effect)

Are you sure about this? When I use integer[player number of x player] it always works.
 
Level 7
Joined
Jul 20, 2008
Messages
377
Arrays are just declared for the max size but only initialized up to (n-1) where n is the size of the array you specified in the editor. Yes, they start at 0.

So basically, when you go over whatever you defined the size to be, you're technically not going out of array bounds. The extra slots were pre-declared, but just unused.
 
Level 2
Joined
Jan 29, 2009
Messages
21
To add the ability to the casting unit:
  • Actions:
    • Set X = Random Integer between 0 and 8
    • Unit - Add Ability[X] to (Triggering Unit)
    • -----If you want the ability to retain its level (if it even has levels)-----
    • Unit - Set Level of Ability[X] for Dummy_Unit to (Level of (Ability Being Cast) for (Triggering Unit))
    • -----If you want to remove the ability that the unit initially cast to get the random ability-----
    • Unit - Remove (Ability Being Cast) from (Triggering Unit)
 
Status
Not open for further replies.
Top