• 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] Tracking stacks for each unit

Status
Not open for further replies.
Level 2
Joined
Jan 23, 2014
Messages
14
Hi all

I tried to make a new unit called MySpecialUnit. This unit has a special ability which i called Stacks, it works like this if MySpecialUnit attacks another unit 9times, on 10th attack the attacked unit will explode and dies immediately. I made a global variable named SpellStacks and made a trigger like this

  • PassiveStackTrigger
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to MySpecialUnit
    • Actions
      • Set SpellStacks = (SpellStacks + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • SpellStacks Equal to 10
        • Then - Actions
          • Unit - Kill (Attacked unit)
          • Set SpellStacks = 0
        • Else - Actions
I made an instance of MySpecialUnit and tested it and everything went good. but my problem is that based on gameplay of my map there could be several instances of MySpecialUnit around the map attacking several units how can i track number of stacks each unit is made on it's target? should i make a big array (the size of maximum number of units i expect)? if so then how can i track index of every MySpecialUnit in that array?

and btw this Stacks thingy is shareable, i mean two MySpecialUnit can attack the same unit and each one do 5 attacks and then BOOM! so maybe a debuff system is my solution?
 
You dont need to index only the special units, but also all other units.

If "I" is index for attacking unit and "K" is index for attacked unit, you set K = K + 1, not the I.

An easy but not perfect methode would be to use the "custom value" of units as simple count. ( if it's not used already)

Custom value of all unit starts as 0. So if a unit gets attacked by MySpecialUnit you do:

If CustomValueOf(AttackedUnit) = 9 then kill attacked unit
Else set CustomValueOf(AttackedUnit) = CustomValueOf(AttackedUnit) + 1

You need to reset custom value to 0 for heroes I think, after they got revived.
_____________

Or you can use an other unit index methode. You can have a look in spell section for it.
 
Level 2
Joined
Jan 23, 2014
Messages
14
a very very useful comment. i think using the custom value for index and using array is better for my situation.
Thanks btw
 
Level 5
Joined
Jan 17, 2014
Messages
131
Look at what I made and tell me if this is what you want.

1st trigger:
  • Stacks Start Units
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Stacks <gen> the event (Unit - (Picked unit) Takes damage)
2nd trigger:
  • Stacks New Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Stacks <gen> the event (Unit - (Triggering unit) Takes damage)
3rd trigger:
  • Stacks
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to My Special Unit
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Stacks for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add Stacks to (Triggering unit)
          • Unit - Set level of Stacks for (Triggering unit) to 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Level of Stacks for (Triggering unit)) Greater than or equal to 1
                  • (Level of Stacks for (Triggering unit)) Less than 9
            • Then - Actions
              • Unit - Set level of Stacks for (Triggering unit) to ((Level of Stacks for (Triggering unit)) + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Stacks for (Triggering unit)) Equal to 9
                • Then - Actions
                  • Unit - Remove Stacks from (Triggering unit)
                  • Unit - Explode (Triggering unit)
                • Else - Actions
And if you want to make it when 2 MSUs are attacking 1 unit and for them to kill it they have to attack it 10 times each, make 2 different MSUs (example: MSU1, MSU2) and make each 1 apply a different ability (example: Stacks1, Stacks2). That is the most simple way I can come up with. Hope it helps.

Oh, by the way, I have attached a test map with 2 MSUs. You can check it out if you want. Good luck.
 

Attachments

  • Test Map.w3x
    16.6 KB · Views: 60
Last edited:

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
you need to learn how to make MUI spell (link), this is a simple work if you understand it..

Look at what I made and tell me if this is what you want.

1st trigger:
  • Stacks Start Units
    • Events
      • Time - Elapsed game time is 0.05 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in (Playable map area)) and do (Actions)
        • Loop - Actions
          • Trigger - Add to Stacks <gen> the event (Unit - (Picked unit) Takes damage)
2nd trigger:
  • Stacks New Units
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
    • Actions
      • Trigger - Add to Stacks <gen> the event (Unit - (Triggering unit) Takes damage)
3rd trigger:
  • Stacks
    • Events
    • Conditions
      • (Unit-type of (Damage source)) Equal to My Special Unit
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Stacks for (Triggering unit)) Less than 1
        • Then - Actions
          • Unit - Add Stacks to (Triggering unit)
          • Unit - Set level of Stacks for (Triggering unit) to 1
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • And - All (Conditions) are true
                • Conditions
                  • (Level of Stacks for (Triggering unit)) Greater than or equal to 1
                  • (Level of Stacks for (Triggering unit)) Less than 9
            • Then - Actions
              • Unit - Set level of Stacks for (Triggering unit) to ((Level of Stacks for (Triggering unit)) + 1)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Level of Stacks for (Triggering unit)) Equal to 9
                • Then - Actions
                  • Unit - Remove Stacks from (Triggering unit)
                  • Unit - Explode (Triggering unit)
                • Else - Actions
And if you want to make it when 2 MSUs are attacking 1 unit and for them to kill it they have to attack it 10 times each, make 2 different MSUs (example: MSU1, MSU2) and make each 1 apply a different ability (example: Stacks1, Stacks2). That is the most simple way I can come up with. Hope it helps.

Oh, by the way, I have attached a test map with 2 MSUs. You can check it out if you want. Good luck.

- use map initialization instead of elapsed time is 0.05
- you are leaking event, just use DDS
- this spell doesn't need dummy spell actually
 
Level 5
Joined
Jan 17, 2014
Messages
131
you need to learn how to make MUI spell (link), this is a simple work if you understand it..



- use map initialization instead of elapsed time is 0.05
- you are leaking event, just use DDS
- this spell doesn't need dummy spell actually

"- use map initialization instead of elapsed time is 0.05" - it doesn't make much difference whether it's map init or time elapsed
"- you are leaking event, just use DDS" - I am not leaking an event. If you look carefully, you will see that the first 2 triggers are the DD for the 3rd trigger.
"- this spell doesn't need dummy spell actually" - Maybe not, but I haven't put much thought into it and this is the first thing that came to mind.

Next time, please try the attached map before posting your comment.
 

Kazeon

Hosted Project: EC
Level 34
Joined
Oct 12, 2011
Messages
3,449
no, next time I will try to evade giving correction to people like you :p
- if you pick all unit inside the game, let's say there are 8000 units in the map, it will cause some lags after 0.05 seconds. and it's bad for any kind of game, that's why people always tried to do "preloads" so that lags could be evaded. if you pick the units at the map init it will increase the loading time and you could evade the in-game lag.

- if a unit dies, that dying unit takes damage event will still writen at the third trigger, you never remove it = leak

- i'm sorry for this part, I must have paid attention that this is just quick help
 
Level 5
Joined
Jan 17, 2014
Messages
131
no, next time I will try to evade giving correction to people like you :p
- if you pick all unit inside the game, let's say there are 8000 units in the map, it will cause some lags after 0.05 seconds. and it's bad for any kind of game, that's why people always tried to do "preloads" so that lags could be evaded. if you pick the units at the map init it will increase the loading time and you could evade the in-game lag.

- if a unit dies, that dying unit takes damage event will still writen at the third trigger, you never remove it = leak

- i'm sorry for this part, I must have paid attention that this is just quick help

Ok, fair enough. So, map init instead of time elapsed and remove unit form event after death. I'm not perfect, you know :p. But then again, who is?
 
Level 5
Joined
Jan 17, 2014
Messages
131
You are leaking events...What happens when the unit you have added to the Stacks trigger dies? The event just sits there...

Well, it's not like I can remove it and besides, it shouldn't cause any lag. And by the way, instead of criticizing my trigger you should post a corrected or better solution to DNA.h's problem. Why even post a comment if you're not going to be, or at least try to be helpful. Isn't that what this forum is about? So, if you please next time instead of just spamming, you may actually try to do something new, like thinking and maybe, just maybe, you could be of some assistance. Pointing out what others have already, is meaningless. In conclusion I can say only this: If you can help - please do, if you can't - please, please!, please!!! keep your comments to yourself.
 
Last edited:
Status
Not open for further replies.
Top