Randomly damage units in group

TheSpoon

New Member
Reaction score
10
Hello, I'm trying to find a way so that individual units in a unit group will be damaged at random intervals.

So something like..
For every 2 to 7 seconds a unit spends in the unit group, the unit will receive 200 damage.

For various other reasons, I don't want to do random damage every second. So don't suggest that.

Thanks in advance!
 

Manix

Well-Known Member
Reaction score
29
I dont rly get your idea but I suggest you changing the custom value upon entry and changing it after the unit has left the group?

In other words, when you're adding the unit to the group change it's custom value to like 1 or something and with your damaging trigger do like pick all units in your_unit_group and do > if custom value of unit = 1 then damage

idk if that's what you wanna do :/

EDIT: perhaps you can give me some more details so I can help you ^^
 

Hellohihi

New Member
Reaction score
42
Trigger:
  • Events
    • Time - Every (Random real number between 2.00 and 7.00) seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in damagegroup and do (Actions)
        • Loop - Actions
          • Unit - Cause YourDamageDealer to damage (Picked unit), dealing 200.00 damage of attack type Spells and damage type Normal
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 200.00)


Trigger:
  • Events
    • Time - Every (Random real number between 2.00 and 7.00) seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in damagegroup and do (Actions)
        • Loop - Actions
          • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - 200.00)


Either one of them will do, your preferences.

And you dont have to destroy the group. Because you will probably be recylcing and reusing it.
 

TheSpoon

New Member
Reaction score
10
Sadly that is not what I want.
That will damage every unit simultaneously in the group every 2 to 7 seconds.
I would each individual unit to be damaged every 2 to 7 seconds, so they don't all go off at the same time,
a sort of random effect if you get me?

I'll try re-explain this.
My hero creates a circular region around him in his spell (Done this bit)
The enemy units in the region will be inside my unit group (Done)
Now, all the enemies in the unit group will be randomly damaged every 2 to 7 seconds. (Can't do!)

I do not want them all to be damaged together, like hellohihi suggested.
I somehow want an individual sort of ' random timer' on each of them.
 
Reaction score
54
This calls for JASS coders. Since I have no real idea, I'll post an erroneous JASS code function to attract their attention:
Trigger:
  • Unit Group - Pick every unit in (Your Damage Group) and do (Actions)
    • Loop - Actions
      • Custom Script : DealDamage();


JASS:
function DealDamage takes nothing returns nothing
    call SetUnitLifeBJ( GetEnumUnit(), ( GetUnitStateSwap(UNIT_STATE_LIFE, GetEnumUnit()) - 1 ) )
    call TimerStart( CreateTimerBJ(false, GetRandomReal(2.00, 7.00)), 0.00, true, function DealDamage )
endfunction
 

TheSpoon

New Member
Reaction score
10
You might have to do a bit more than just post an 'erroneous' code,
I don't have much experience with JASS :C

I'd also like to try avoid it,
Because I want to do a lot more than just damage it xD
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top