• 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.

[Trigger] Help Storing a spell list as Integer Variable!

Status
Not open for further replies.
Level 2
Joined
Apr 15, 2008
Messages
17
I am trying to cause a unit to learn certain, predefined spells and levels when a different spell is cast. Setting the variables wont be a problem.. Just applying them could be.
I've come to the conclusion that storing the information as an Integer would be the easiest way to do it.

Heres a dummy trigger to sorta explain what i mean
  • dummy spell
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpellList[(Player number of (Owner of (Casting unit)))] Equal to 100
        • Then - Actions
          • -------- Cause the unit to learn Spell 1 at Level 1 --------
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpellList[(Player number of (Owner of (Casting unit)))] Equal to 342
        • Then - Actions
          • -------- Cause the unit to learn Spell 1 at Level 3 --------
          • -------- Cause the unit to learn Spell 2 at Level 4 --------
          • -------- Cause the unit to learn Spell 3 at Level 2 --------
        • Else - Actions
the variable is an integer array (to cater for each player also).
SpellList [a] = xyz

'a' represents the player number
'x' represents the level of spell 1
'y' represents the level of spell 2
'z' represents the level of spell 3
Spell 1 has 9 levels.
Spell 2 has 5 levels.
Spell 3 has 5 levels.
and a value of 0 indicates no spells.

The problem i have is when i want to apply the spells to a unit. Do i have to do an individual If/Then/Else for each possible combination (1 through to 955)? Or is there a way i can apply the spells using less triggers.
 
Level 2
Joined
Apr 15, 2008
Messages
17
Sorry, i should have added more information to my original post.
The unit the spells should be added to has multiple forms, changed by adding and removing units. I have already got the held items down pat.. I just need to be able to store the spells that the unit already knows, and then re-apply them to the unit when it returns to the form that uses said spells.
So adding the spellid would require some check to see what spells it already has to then re-add them.
Understand?
 
Since Blizz's SaveAbilityHandle doesn't work we have to do that in other way ;O

Abilities are basically treaten as integers for war3 engine. You can even Ctrl + D your obejct editor to see rawcodes everywhere. However, if you don't want to write all the rawcodes in custom scripts (although this eway you get the integer immidiately), you can always use Ability-type variable and do the following:

  • Set Ability = Endurance Aura
  • Custom script: set udg_AbilityID = udg_Ability
This piece will automaticaly get the rawcode of Endurance Aura ability. Now, since you got an integer.. you are able to just save that integer value in hashtable via Save Integer and later, to load that ability use Load Integer.

  • Set AbilityID = Load Integer(stuff here from somehash)
  • Custom script: call UnitAddAbility(u, udg_AbilityID)
  • // to remove
  • Custom script: call UnitRemoveAbility(u, udg_AbilityID)
Where 'u' defines a unit you want add given ability to.

Variables:
- AbilityID -> integer
- Ability -> ability
 
Level 2
Joined
Apr 15, 2008
Messages
17
I've not used Hashtables, nor Custom Script before.
The way you explained Spinnaker confuses me, but doesn't appear to add the ability at a set level, but rather add the ability from level 1.
 
Status
Not open for further replies.
Top