HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Help me ! About : Auto Cast Spell

03-17-2005, 09:17 AM#1
chien86
This is 2 my trigger:

Trigger 1 : learn
Event
unit learn skill
Con
learn hero skill equal to "A spell"
Action
trigger turn on "ActionTrigger"

Trigger 2 : ActionTrigger
Even
Every 2 second of game time
Con
none
Action
Pick every unit in "My Hero" within 400 range and do action
if picked unit has buff "A's Buff Spell" equal False then
Create 1 "Caster Spell" at Pos(My hero) .....
Order Last created unit To "A spell" To Picked Unit
ok !!!
I start this map and train 1 Hero
my auto spell has no problem ......
But when I train more 1 or 2 or 3 ...... Hero. Alway has 1 Hero(the last hero) can auto cast spell

Then I want to ask how to make my trigger on muti unit(when train or create it ) ?
03-17-2005, 10:07 AM#2
Anitarf
Well, that's because your trigger only checks units around a single hero, and that hero is the last one to learn the skill.

Instead of MyHero being a normal unit variable, you should turn it into a unit variable array. Then you also need an integer, let's name it NumberOfHeroes.

Now, make the following trigger:
Code:
Events:
    A unit enters playable map area
Conditions:
    (entering unit is a hero) equal to true
Actions:
    Set NumberOfHeroes = NumberOfHeroes + 1
    Set MyHero[NumberOfHeroes] = (entering unit)
With this trigger, you will have all the heroes you train in your map set to this variable array.

Now for the spell's trigger:

Code:
Events:
    Every 2 seconds of game-time
Conditions:
Actions:
    For each integer A from 1 to NumberOfHeroes do actions
        Loop - Actions:
            If - Then - Else multiple functions:
                If - conditions:
                    (level of (spell A) for MyHero[(Integer A)]) greater than 0
                Then - actions:
                     [i]Pick every unit in "My Hero" within 400 range and do action
                     if picked unit has buff "A's Buff Spell" equal False then
                     Create 1 "Caster Spell" at Pos(My hero) .....
                     Order Last created unit To "A spell" To Picked Unit[/i]
                Else - actions:
                    do nothing
By the way, what does your spell A do? Right now you are casting it on every unit around the hero, creating a bunch of casters and creating memory leaks. It would be a lot simpler if you could find an Area of Effect spell that does the same thing, because you would need to cast that spell only once at the position of the hero to get the same, or at least similar effect.
03-17-2005, 01:08 PM#3
chien86
First , thanks you about that !!! :-)
Second , this my example, not real spell. I post this to know how to make it on muti unit !
I made so much spell like this example, and now i think your trigge will help me to comple these spell.
And the third : ...... Thanks you so much ! hehehe
Help me ! About : Auto Cast Spell - Wc3C.net