• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Spell] Summoning

Status
Not open for further replies.
Level 4
Joined
Sep 12, 2008
Messages
111
Summoned units are attached to caster.

For example
Caster #1 summons Unit #1 and #2
Caster #2 summons Unit #3

If caster dies, any summons caster did dies too.

For example
Caster #2 dies, Unit #3 dies

How do I attach the units to the caster? I'm using AIDS. Thanks :)
 
Level 17
Joined
Mar 21, 2011
Messages
1,611
unit casts spell
integer = custom value of triggering unit
create summon
summon[integer] = last created unit
add triggering unit to summonGroup


Unit dies
if unit is in summonGroup
set integer = custom value of triggering unit
kill summon[integer]



that's how i would do it, however i dont know how your indexer works (if it uses custom value). i always use bribes unit indexer
 
Level 12
Joined
Mar 24, 2011
Messages
1,082
Well... you can imagine it as 2D table, like MS excel ... with rolls and columns. You can store Data in it and call that Data by roll and column.

One of the biggest pros is that you can use Unit Handle as a parameter so you wont need indexing to access it.
Another big pro is that you can store ANY Data in it.

Here is an example:
We have a variable of type integer with an array. It will look like Integer[Array]
You can do Integer[Array] = SomeInteger, if you try to do Integer[Array] = SomeReal you will get an error (This is impossible in GUI but in JASS you can write anything)
With a hashtable you got Cell[Roll][Column] = Data
You can do Cell[1][1] = SomeInteger, Cell[2][1] = SomeUnit, Cell[3][1] = SomeAbility

Another pro is thet you can pass a unit Handle as Roll/Column, which will corespont to only 1 Roll/Column



So if you use rolls for CasterUnit and colums for SummonedUnit
And the storage for summons will actualy start from 2 because we want to keep track of the number of summons.
You will have :
Actions
Spawn SummonedUnit
Set NumberOfSummons = ( Get Cell from hashtable [Handle of Caster Unit] [1] ) + 1
Cell[Handle of Caster Unit][NumberOfSummons] = Last created unit


You will need a trigger to get rid of dead summons which are taking space

You will need another trigger
Event
Unit - Dies
Condition
Unit type of triggering unit == Summoner
Action
For loop LoopInt from 2 to ( Get Cell from Hashtable [Handle of Triggering unit] [1])
Kill Unit (Get Cell from hashtable [Handle of Triggering unit] [LoopInt])

{Notice that counting NumberOfMonsters starts from 2, this is because Cell Column is reserved for the actual integer}

Note: The code does not look like this neither in GUI or JASS, it just helps to explain as I assume you are familiar with Arrayed Variables because you use an indexing system...
Note: I am not sure if counting in hashtables starts from 1 instead of 0...
 
Status
Not open for further replies.
Top