• 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] X-OMG-X needs your help!

Status
Not open for further replies.
Okay im working an "advanced" spell. At least, advanced to me. It works properly now but its not MUI or even MPI. Do you have any advices? Im searching the easiest way to make the spell MUI.
  • Chaos Sphere
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chaos Sphere
    • Actions
      • Set RT_Caster = (Triggering unit)
      • Set RT_Position = (Position of RT_Caster)
      • Set RT_Distance = 350.00
      • Set RT_DamageDealt = ((Level of Chaos Sphere for RT_Caster) x 80)
      • For each (Integer RT_Integer) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy (Chaos) for (Owner of RT_Caster) at RT_Position facing ((Real(RT_Integer)) x 90.00) degrees
          • Set RT_Dummy[RT_Integer] = (Last created unit)
          • Unit - Turn collision for RT_Dummy[RT_Integer] Off
          • Unit - Add a 3.50 second Generic expiration timer to RT_Dummy[RT_Integer]
          • Set RT_InvisibleFade[RT_Integer] = 100.00
          • Set RT_Offset[RT_Integer] = (RT_Position offset by RT_Distance towards ((Real(RT_Integer)) x 90.00) degrees)
          • Special Effect - Create a special effect at RT_Offset[RT_Integer] using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
          • Special Effect - Destroy (Last created special effect)
  • Chaos SphereRun
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer RT_Integer) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set RT_DummyPos[RT_Integer] = (Position of RT_Dummy[RT_Integer])
          • Set RT_Offset[RT_Integer] = (RT_DummyPos[RT_Integer] offset by 8.00 towards ((Real(RT_Integer)) x 90.00) degrees)
          • Set RT_DistanceMoving[RT_Integer] = (Distance between RT_DummyPos[RT_Integer] and RT_Position)
          • Set RT_FlyingHeight[RT_Integer] = ((Current flying height of RT_Dummy[RT_Integer]) - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RT_DistanceMoving[RT_Integer] Less than or equal to RT_Distance
            • Then - Actions
              • Destructible - Pick every destructible within 125.00 of RT_DummyPos[RT_Integer] and do (Actions)
                • Loop - Actions
                  • Destructible - Kill (Picked destructible)
              • Unit - Move RT_Dummy[RT_Integer] instantly to RT_Offset[RT_Integer]
              • Animation - Change RT_Dummy[RT_Integer]'s size to ((RT_DistanceMoving[RT_Integer] + 3.00)%, (RT_DistanceMoving[RT_Integer] + 3.00)%, (RT_DistanceMoving[RT_Integer] + 3.00)%) of its original size
              • Animation - Change RT_Dummy[RT_Integer] flying height to RT_FlyingHeight[RT_Integer] at 0.00
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RT_InvisibleFade[RT_Integer] Greater than or equal to 0.00
                • Then - Actions
                  • Set RT_InvisibleFade[RT_Integer] = (RT_InvisibleFade[RT_Integer] - 3.00)
                  • Animation - Change RT_Dummy[RT_Integer]'s vertex coloring to (100.00%, 100.00%, 100.00%) with RT_InvisibleFade[RT_Integer]% transparency
                • Else - Actions
            • Else - Actions
              • Set RT_UnitGroup[RT_Integer] = (Units within 250.00 of RT_DummyPos[RT_Integer] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of RT_Caster)) Equal to True)))
              • Unit Group - Pick every unit in RT_UnitGroup[RT_Integer] and do (Actions)
                • Loop - Actions
                  • Unit - Cause RT_Caster to damage (Picked unit), dealing (Real(RT_DamageDealt)) damage of attack type Spells and damage type Normal
                  • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Unit - Remove RT_Dummy[RT_Integer] from the game
              • Special Effect - Create a special effect at RT_DummyPos[RT_Integer] using Abilities\Spells\Undead\Darksummoning\DarkSummonTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set RT_DistanceMoving[RT_Integer] = 0.00
              • Set RT_FlyingHeight[RT_Integer] = 0.00
              • Set RT_InvisibleFade[RT_Integer] = 100.00
              • Set RT_Caster = No unit
              • Set RT_Dummy[RT_Integer] = No unit
              • Custom script: call RemoveLocation(udg_RT_DummyPos[udg_RT_Integer])
              • Custom script: call RemoveLocation(udg_RT_Offset[udg_RT_Integer])
              • Custom script: call DestroyGroup(udg_RT_UnitGroup[udg_RT_Integer])
~x-omg-x
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
"Chaos Sphere"? O_O
Looks a lot like my "Chaotic Sphere" xD

If you don't want to use hashtables, you will need to use indexing.
Here's the simple way:
Use arrays for all the variables and create another one called "value" (or something like that), increase this value for every dummy (when value = 8000, set value = 0).
then give the dummy the custom value "[Value]" and save all the variables as Variable[Value].
Put the dummy inside a unit group and in your other trigger do:

Unit Group - pick every unit in [Dummies]
do: set all variables = variable[Custom value of picked unit)
and do your actions.

Lol, this is probably not understandable at all xD
So I just created a little example (for a pushback), I think that's the only way to explain it.

Edit: I would use hashtables myself, but some people don't seem to like them :p
 

Attachments

  • IndexingDemo.w3x
    20.1 KB · Views: 49
Your way to do it seems understandable and maybe the best way to do it sometimes, but i dont think hashtables is a problem. If i make a spell with hashtables, i maybe can figure out why the hell other people use them :p

[EDIT]

Checked your "Chaotic Sphere" out, and i have to say that it looks pretty nice. I also have to say that it uses some of the same effects, but the spell is nothing like mine ;) I can give you a link to my spell when its done.
 
RT_Position doesnt get removed again

Thanks for noticing :D

[EDIT]

Okay i think im understanding how to use hashtables on units/strings/reals/integers now. I just dont get how to use it for unitgroups.


  • Chaos Sphere
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Chaos Sphere
    • Actions
      • Set RT_Caster = (Triggering unit)
      • Set RT_Position = (Position of RT_Caster)
      • Set RT_Distance = 350.00
      • Set RT_DamageDealt = ((Level of Chaos Sphere for RT_Caster) x 80)
      • Hashtable - Create a hashtable
      • Set RT_Hashtable = (Last created hashtable)
      • For each (Integer RT_Integer) from 1 to 4, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Dummy (Chaos) for (Owner of RT_Caster) at RT_Position facing ((Real(RT_Integer)) x 90.00) degrees
          • Set RT_Dummy[RT_Integer] = (Last created unit)
          • Unit Group - Add RT_Dummy[RT_Integer] to RT_Hashgroup
          • Unit - Turn collision for RT_Dummy[RT_Integer] Off
          • Unit - Add a 3.50 second Generic expiration timer to RT_Dummy[RT_Integer]
          • Set RT_InvisibleFade[RT_Integer] = 100.00
          • Set RT_Offset[RT_Integer] = (RT_Position offset by RT_Distance towards ((Real(RT_Integer)) x 90.00) degrees)
          • Special Effect - Create a special effect at RT_Offset[RT_Integer] using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
          • Special Effect - Destroy (Last created special effect)
      • Unit Group - Pick every unit in RT_Hashgroup and do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle OfRT_Hashgroup as (Key unitgroup) of (Key (Picked unit)) in (Last created hashtable)
  • Chaos SphereRun
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set RT_Hashgroup = (Load (Key unitgroup) of (Key (Picked unit)) in (Last created hashtable))
      • For each (Integer RT_Integer) from 1 to 4, do (Actions)
        • Loop - Actions
          • Set RT_DummyPos[RT_Integer] = (Position of RT_Dummy[RT_Integer])
          • Set RT_Offset[RT_Integer] = (RT_DummyPos[RT_Integer] offset by 8.00 towards ((Real(RT_Integer)) x 90.00) degrees)
          • Set RT_DistanceMoving[RT_Integer] = (Distance between RT_DummyPos[RT_Integer] and RT_Position)
          • Set RT_FlyingHeight[RT_Integer] = ((Current flying height of RT_Dummy[RT_Integer]) - 1.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • RT_DistanceMoving[RT_Integer] Less than or equal to RT_Distance
            • Then - Actions
              • Destructible - Pick every destructible within 125.00 of RT_DummyPos[RT_Integer] and do (Actions)
                • Loop - Actions
                  • Destructible - Kill (Picked destructible)
              • Unit - Move RT_Dummy[RT_Integer] instantly to RT_Offset[RT_Integer]
              • Animation - Change RT_Dummy[RT_Integer]'s size to ((RT_DistanceMoving[RT_Integer] + 3.00)%, (RT_DistanceMoving[RT_Integer] + 3.00)%, (RT_DistanceMoving[RT_Integer] + 3.00)%) of its original size
              • Animation - Change RT_Dummy[RT_Integer] flying height to RT_FlyingHeight[RT_Integer] at 0.00
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • RT_InvisibleFade[RT_Integer] Greater than or equal to 0.00
                • Then - Actions
                  • Set RT_InvisibleFade[RT_Integer] = (RT_InvisibleFade[RT_Integer] - 3.00)
                  • Animation - Change RT_Dummy[RT_Integer]'s vertex coloring to (100.00%, 100.00%, 100.00%) with RT_InvisibleFade[RT_Integer]% transparency
                • Else - Actions
            • Else - Actions
              • Set RT_UnitGroup[RT_Integer] = (Units within 250.00 of RT_DummyPos[RT_Integer] matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of RT_Caster)) Equal to True)))
              • Unit Group - Pick every unit in RT_UnitGroup[RT_Integer] and do (Actions)
                • Loop - Actions
                  • Unit - Cause RT_Caster to damage (Picked unit), dealing (Real(RT_DamageDealt)) damage of attack type Spells and damage type Normal
                  • Special Effect - Create a special effect at (Position of (Picked unit)) using Abilities\Spells\Undead\AnimateDead\AnimateDeadTarget.mdl
                  • Special Effect - Destroy (Last created special effect)
              • Unit - Remove RT_Dummy[RT_Integer] from the game
              • Special Effect - Create a special effect at RT_DummyPos[RT_Integer] using Abilities\Spells\Undead\Darksummoning\DarkSummonTarget.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set RT_DistanceMoving[RT_Integer] = 0.00
              • Set RT_FlyingHeight[RT_Integer] = 0.00
              • Set RT_InvisibleFade[RT_Integer] = 100.00
              • Set RT_Caster = No unit
              • Set RT_Dummy[RT_Integer] = No unit
              • Custom script: call RemoveLocation(udg_RT_DummyPos[udg_RT_Integer])
              • Custom script: call RemoveLocation(udg_RT_Offset[udg_RT_Integer])
              • Custom script: call DestroyGroup(udg_RT_UnitGroup[udg_RT_Integer])
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Use a global group for the loop trigger.

This is unnecessary.
  • Unit Group - Pick every unit in RT_Hashgroup and do (Actions)
  • Loop - Actions
  • Hashtable - Save Handle OfRT_Hashgroup as (Key unitgroup) of (Key (Picked unit)) in (Last created hashtable)
  • Set RT_Hashgroup = (Load (Key unitgroup) of (Key (Picked unit)) in (Last created hashtable))
Instead of this, use "Pick every unit in RT_Hashgroup"

You're not really saving/loadin anything from the hashtable now.
 
Allright i have to say, im totally blank on how to use it on unitgroups.
Below i have wrote what im trying to do. Then edit the lines to what it have to be. If i know how to make it work, i can do it by myself.

Im adding the dummies to the group.
Im saving the group with ? key.
--Next trigger--
Im loading the group.
Im picking all the units.
Im changing everything in my coding to (Picked Unit).


But. When reading your (Maker) post above, i was getting really blank.
My pick every unit was unnecessary. So im just saving the group. ~Understandable
Then you advice to pick every unit in the variable-group. Why save it then? ~Ununderstandable
If i keep being blank about how to use it, i maybe should do what ap0calypse said, just untill i know how to use hashtables properly.
 
In the first trigger use some unit to to a unit group:

  • Unit Group - Add (Triggering unit) to AoF_Group
In the loop trigger:

  • Loop trigger
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in AoF_Group and do (Actions)
        • Loop - Actions
          • Set Temp_Unit_1 = (Picked unit)
          • ...

Okay im understanding now, i just cant see how the hashtables is a part of this :p Thanks for all your time, as it takes some time to learn new things ;)
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
You can save values such as:
  • Set RT_InvisibleFade[RT_Integer] = 100.00
Like this:
  • Hashtable - Save 100.00 as (Key fade) of (Key (Last created unit)) in My_Hash
Now you've bound that value to that unit, kind of like what indexing does.

Then you can load that value in the loop when you need to check it.

  • Set Temp_Real_1 = (Load (Key fade) of (Key (Picked unit)) from My_Hash)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Real_1 Greater than or equal to 0.00
 
You can save values such as:
  • Set RT_InvisibleFade[RT_Integer] = 100.00
Like this:
  • Hashtable - Save 100.00 as (Key fade) of (Key (Last created unit)) in My_Hash
Now you've bound that value to that unit, kind of like what indexing does.

Then you can load that value in the loop when you need to check it.

  • Set Temp_Real_1 = (Load (Key fade) of (Key (Picked unit)) from My_Hash)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Temp_Real_1 Greater than or equal to 0.00
Yea i did understand its usefulness in such things, but in unitgroups? Does it mean that there isnt any need for hashtables for my unitgroup? If it does, then there isnt any problem. Ofc i can save my effects in hashtables, i will surely do, but if there isnt any need for hashtables for the unit group then its fine for me ;)
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
Yea i did understand its usefulness in such things, but in unitgroups? Does it mean that there isnt any need for hashtables for my unitgroup? If it does, then there isnt any problem. Ofc i can save my effects in hashtables, i will surely do, but if there isnt any need for hashtables for the unit group then its fine for me ;)
No, you don't need to save the unit group in the hashtable ;)
You use the hashtable for saving:
- Target (not required for some spells)
- Values (such as damage, distance, angle, ...).
- Caster (not required for some spells)
In some cases you do save a unit group, in my spell (chaotic Sphere), I do it because otherwise a unit will get hit multiple times by the shockave (because the shockwave moves with about 35 range and deals damage to everyone within 150 range, it would hit a unit 4-5 times, so I add him to a group that he already received damage).

Good luck with the spell ;)

(on a side-note: I use hashtables a lot, even though they're less efficient, they're really useful, easy to use and I've never experienced any problems with them).
 
Allright. Then i have misunderstood this comment
I'd just use hashtables. Add the dummies to a unit group, and in the loop trigger pick all units in that group. Save whatever values you need to the hashtable.

Anyways, thanks for your help everybody. I didnt only get feedback on my coding, but also learned a whole new way to code :D. I will probably be using some hashtables in the following spells/systems i make ;)
 
Level 25
Joined
Jun 5, 2008
Messages
2,573
Afaik hashtables are perfect if you know how to use them.

Meaning, you don't have to use (Key of) for storing things, especialy if you use JASS, since you could imply some hybrid of Indexing+hashtables in there to allow a unit to cast spell infinite amount of times and never get bugged.
 
Okay i think i will stick to the indexing without hashtables for now.
But i need a little bit help with the coding. How do you put an array into an array? :p
Im using 4 dummies in my triggers so there will be 4 positions, 4 offsets, 4 distances and so on. So how will the indexing work when im doing it like this? Will i have to make 4 different variables or is there a smarter way to do it? Thanks alot to you guys that helped me, i have improved my knowledge by alot in this single thread.
 
Ehh, can't you just do it the way I showed you, or follow Kingz' advice and use his indexing (or hanky's).
You know, set the custom value of the dummy to [Value] and add the dummy to a unit group.
Then set the variables to Variable[Value], etc...

Then it wont work as i have to control 4 units at a time (I used ForeachInteger). Now im using unitgroups and if i put a ForeachInteger into the unitgroup it just will screws up and does the same 4 times each unit.
I did try to change everything to [Value] instead of [Integer] in the unitgroup triggers, but then it just creates the dummies and does nothing after that, as i did say would happen. I did also check hanky's indexing and what his indexing does still doesnt help me anywhere, as it still wont work with all my 4 dummies. Is it possible to add an array to the integer im using and then still use my ForeachInteger? Or do you have any ideas about how to make the unitgroup function somehow like the ForeachInteger?
 
Status
Not open for further replies.
Top