An ability question

Status
Not open for further replies.
Level 8
Joined
Dec 29, 2006
Messages
359
I recently started getting back into editing campaigns and such, and im trying to make an ability and its giving me some trouble. The idea behind the ability is that its a low mana cost spell that gives the targeted unit (friendly or hostile) a permanent buff that makes it spawn units when it dies, under the control of the one who applied the buff. I tried basing a spell off of firebolt, removing the damage, and triggering it to where it would give the Spawn Spiderlings buff to the targeted unit, but it didnt work. Any ideas?
 
Level 8
Joined
Dec 29, 2006
Messages
359
Wow, thanks for putting up this map, it helps a lot. One thing though, what exactly is a hashtable? I just got back into WC3 and this is the first im seeing them.
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
A hashtable is about the same as a variable with an array.
With the exception that it has 2 arrays.

So let's so you've got a variable "Var", then with a hashtable it looks like this: Var[1][2] (with each array being independant of eachother).

Another exception is that usual arrays are capable of storing 2^13 bits, that means the maximum array of a normal arrayed variable is 8192 (anything above Var[8192] would fail).
This would ruin everything a hashtable does, as we store the ID of an object (every object has it's own unique ID in the game, this number is very high).

So now we can store Var[1][Object ID] or Var[2][Object ID] etc...
Now we've got a single variable for all objects on the map, with extra space for additional values.

Eventually, when used in spells it becomes something like this:

Var[Damage][Unit ID]
Var[AoE][Unit ID]
Var[Target][Unit ID]

And that's how we create MUI (caster = Unit ID, the variables are stored for different casters -> they don't get mixed up).
(MUI: Multi-Unit Instanceable, when every unit on the map can cast the same spell at the same time without bugging).


I hope you got all of this and it wasn't too boring (and that everything's correct, since I'm not 100% sure of that xD)


Edit: more can be found here, in case you want to master hashtables yourself.
 
Level 8
Joined
Dec 29, 2006
Messages
359
I see, ill have to check that tutorial out, its seems like hastables are really usefull, but i digress, +rep to you both :)
 
Level 8
Joined
Dec 29, 2006
Messages
359
Maker, your system worked originally, but i modified it slightly to fit my needs. Now, however, it wont work, and I cant see where I went wrong. Since the ability is going to be a hero ability, its going to have 3 levels of course, level 1 will spawn 1 unit, level 2, 2 units, and level 3, 3 units. To compensate for this, I changed the triggers like this:

  • Inject Swarmlings
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Inject Swarmlings
    • Actions
      • Hashtable - Save Handle Of(Owner of (Triggering unit)) as (Key owner) of (Key (Target unit of ability being cast)) in Hashtable
      • Unit Group - Add (Target unit of ability being cast) to deathgroup
  • Swarmlings Spawn
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in deathgroup) Equal to True
    • Actions
      • Set Temp_Point = (Position of (Triggering unit))
      • Set swarmlingsint = (Level of Inject Swarmlings for Mygalomorphae 0001 <gen>)
      • Unit - Create swarmlingsint Swarmling for (Load (Key owner) of (Key (Triggering unit)) in Hashtable) at Temp_Point facing Default building facing degrees
      • Special Effect - Create a special effect at Temp_Point using Abilities\Spells\Items\AIem\AIemTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: call RemoveLocation(udg_Temp_Point)
      • Hashtable - Clear all child hashtables of child (Key (Triggering unit)) in Hashtable
      • Unit Group - Remove (Triggering unit) from deathgroup
Just to be clear, the Mygalomorphae is the hero that knows the ability, and she is the only one on the map, or that will ever be on the map for that matter, since it is a single player campaign. However, it stopped working when i made the changes. I cant see where i went wrong, did my changes somehow interfere with hashtables or something?
 
Level 8
Joined
Dec 29, 2006
Messages
359
no, i havent initialized hashtables, is that simply done by creating a hashtable? Also, where in the trigger should i initialize them? I mean, i know it should be in the beginning somewhere, but should it be at the beginning of one of those triggers or in a different trigger entirely?
 
Status
Not open for further replies.
Top