• 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] periodically damage units in area

Status
Not open for further replies.
Level 6
Joined
Jun 20, 2005
Messages
108
I'm having problems with this new spell I'm making. It should damage surrounding units by 3% of its total hit points each second, for 20 seconds.

Here's the first version of the spell, but it obviously doesn't work because something might overlap the "triggering unit":

  • Actions
    • Set L_POINT = (Target point of ability being cast)
    • For each (Integer A) from 1 to 20, do (Actions)
      • Loop - Actions
        • Set L_UGROUP = (Units within 500.00 of L_POINT matching (((((Matching unit) is A Hero) Equal to True) and ((Level of Invulnerable (Neutral) for (Matching unit)) Not equal to 1)) and (((Matching unit) belongs to an enemy of (Owner of (Triggering unit))) Equal to True)))
        • Unit Group - Pick every unit in L_UGROUP and do (Actions)
          • Loop - Actions
            • Unit - Set life of (Matching unit) to ((Life of (Matching unit)) - ((Max life of (Matching unit)) x 0.03))
so, how could I make this MUI? I tried a simle jass code with local variables and so, but When it reaches the unit group, i can't call the local variables from another function.

Thanks for you help
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
You attach the unit onto a timer via a handle system like the tables of handle vars. You then get that timer and the unit from it when it expires and run your damage actions. After the timer has fired 20 times (you also store that onto the timer) you then recycle it or destroy it.

You could also use a list system, where you use 1 timer fireing every second to loop through all current instances of that spell being cast. When the spell is cast, you add the instance onto the end of the list. Each instance stores the unit and the number of times it has run. If it reaches 20 times, you then remove that instance and replace it with that from the top of the list and deallocate that. The list is an array. If the spell has no instances you pause the timer until it is cast again appon which you resume the timer. This method will keep 100% time accurate, and be highly efficent as well as MUI. However it will mean that the effect will run exactly at the same time for all units casting it (minor timing problem hardly noticable).

I would advise method 2.
Also you should add code to credit the kills made by the spell to the killing unit by not allowing you to reduce health below 0.405 and then killing the unit via dealing damage to it.
 
Status
Not open for further replies.
Top