• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Why won't this trigger(GUI) damage units?

Status
Not open for further replies.
Level 5
Joined
Jan 23, 2014
Messages
152
This trigger is the damage part of my spell, and is initially off
  • Laser Damage
    • Events
      • Time - Every 0.60 seconds of game time
    • Conditions
    • Actions
      • Set LaserDmgGrp = (Units within 600.00 of LTarget matching (((Matching unit) belongs to an enemy of (Owner of LCaster)) Equal to True))
      • Unit Group - Pick every unit in LaserDmgGrp and do (Actions)
        • Loop - Actions
          • Unit - Cause LCaster to damage (Picked unit), dealing (300.00 + ((Real((Level of Laser Laser for LCaster))) x (Real((Agility of LCaster (Exclude bonuses)))))) damage of attack type Magic and damage type Normal
      • Custom script: call DestroyGroup (udg_LaserDmgGrp)
LCaster = casting unit
LTarget = target point of ability being cast
 
Level 11
Joined
Dec 19, 2012
Messages
411
For me i would get the spell work than start making it MUI, making a spell MUI before testing it isn't work perfectly is pointless (for me).

You could try separate the condition inside the loop-actions? Because sometime set the unit group followed condition(s) spoil the function...(I not too sure)
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
The thing with MUI is that it's a different approach. If you first make a non-MUI spell and then convert it, then you need to do some debugging anyway. It's easier in the long term to make the whole thing at first and then try if it works.
If you are unsure whether some things can be done, then make small tests.
This streamlines the creation of any kind of code.

Idea>(proof of concept>)Creation>Testing
 
Level 5
Joined
Jan 23, 2014
Messages
152
Ok thanks for the tip. But how do I make this MUI? Should I use hashtables?
 
Level 5
Joined
Feb 22, 2013
Messages
161
Hashtables are ideal for GUI, however there are other ways for GUI.. User-preference suggests the way you go about triggering an MUI spell
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I would use an indexed array for any of the casters.

For an indexed array you need

The array itself, in your case a unit array(Unit)
and an integer that tells how many units are in the array.(Count)

Then to add to array you do something like
set Count = Count + 1
set Unit[Count] = someunitthatyouwanttoadd

But I think it might be easier for you to just use a hashtable as it is.
If you really want, then I can explain indexed arrays in depth to you, but only then.
Indexed arrays are more efficient if used right, while hashtables are easier to use.
 
Level 5
Joined
Jan 23, 2014
Messages
152
Yes please explain I wanna learn more about the WE. And what's the plus one for in the count variable?
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
I'll assume that the unit group you use automatically removes any units that finish/stop casting.

The basic idea behind indexed arrays is that you have an array for every kind of data that you want to store (caster,target,damage)
Each triplet(caster + target + damage) is called an "instance" of the spell.

So the counter variable tells how many instances are active. At first it is 0.

Whenever someone casts the ability, then you do something like this:

set Count = Count + 1 (More units are channelling the spell than before)
set Caster[Count] = Triggering unit
set Target[Count] = Target
set Damage[Count] = SomeValue(whatever you want it to be)

Now you've effectively assigned a new instance of the spell.
But what about when they end?
First you need to know which one ended.
LoopInt is the integer that you use for the loop.
YourUnit is the unit that ended casting.

Loop from 1 to Count
Every time check if Caster[LoopInt] is YourUnit
When you find the caster/When Caster[LoopInt] = YourUnit, then you need to somehow remove the unit from the array.
Without much explanation, I can simply say that it's easiest to swap the unit with the last one and reduce Count, so:

set Caster[LoopInt] = Caster[Count]
set Target[LoopInt] = Target[Count]
set Damage[LoopInt] = Damage[Count]

Meanwhile you would also have a periodic trigger to deal the damage, but that's very simple:
Loop from 1 to Count
Every time make Caster deal Damage to Target

Do you get the picture?

I remember there is one tutorial in here for that http://www.hiveworkshop.com/forums/trigger-gui-editor-tutorials-279/visualize-dynamic-indexing-241896/
I've also written up a short(bad) tutorial myself:This
 
Level 5
Joined
Jan 23, 2014
Messages
152
Yeah! I totally got it. Thank you so much!
One thing, in this one:
set Count = Count + 1 (More units are channelling the spell than before)
should the underlined count be 0?
 
Status
Not open for further replies.
Top