• 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.

[Spell] Mana regeneration by dying unit passive

Status
Not open for further replies.
Level 5
Joined
Feb 18, 2016
Messages
96
I trying to make a passive ability that generates an aura with a specific range and gives enemy units a buff. Thats work but i want to every time enemy unit with <buff> dies the hero regenerates himself the x% of the maximum mana but it does not work because dying unit does not have buffs
There is another way to do it?



Also sorry for bad english
 
Level 8
Joined
Jan 28, 2016
Messages
486
Yes there is. Instead of using an aura that affects enemies, use a passive (Eg: Evasion). Then use triggers to pick every unit in range of the dying unit and if it has that ability (by checking if the level of the ability is greater than zero), add X% of dying unit's max mana. My trigger explains this better.

  • Sadist
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • Set TempPoint = (Position of (Triggering unit))
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 900.00 of TempPoint) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Sadist for (Picked unit)) Greater than 0
              • ((Picked unit) belongs to an ally of (Owner of (Triggering unit))) Equal to False
            • Then - Actions
              • Set TempReal = (0.50 x (Max mana of (Triggering unit)))
              • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) + TempReal)
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempPoint)
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
One way to check if the dying unit has a buff is to not use the event of when a unit dies.
Instead, you use the event of when a unit takes fatal damage. (This doesnt exist by default but should be easily implementable using a DDS.)

However, if I understand the ability, you want this:
"Whenever a nearby emeny unit dies, you regain x% of the dying unit's max mana."
In that case, it is indeed not really nice to use an aura, because you wont affect the enemy units, you only affect the caster/source.
So you can indeed use evasion or attribute bonus or whatever, set the data to 0 (aka 0 stats bonus, 0 chance to evade, etc) and check if there is a nearby enemy unit with that ability whenever a unit dies.
 
Level 8
Joined
Apr 8, 2009
Messages
499
No need for a DDS I think,

  • Your Trigger
    • Events
      • Unit - EnemyUnit_WithDebuff <gen> Takes damage
    • Conditions
      • ((Triggering unit) has buff YourBuff) Equal to True
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Damage taken) Greater than or equal to (Life of (Triggering unit))
        • Then - Actions
          • -------- Replenish mana here for your unit --------
        • Else - Actions
Would need a form of unit indexing, but that shouldn't be too hard ;)

And this'd work because the "unit takes damage" event triggers before it ACTUALLY takes damage, hence the buff detection would work and all!
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
"No need for a DDS I think"
"Instead make your own DDS, shouldnt be too hard ;)"

Just use a damn DDS.
I am ussually against using it because it really isnt that nice.
But that cant be blamed on the people who made one, but rather on the WC3 API.

On the other hand, on the approach I explained, you wont need a DDS nor create one yourself.
You just need the right direction.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Make a unit group for all the units with the ability. (Add them when they learn the ability or when they spawn on the map if they always have the ability). Then, whenever a unit dies, check their distance to each unit in that group. I'd base the ability off of attribute bonus since a unit can have any number of them and it displays an icon and tooltip.


  • Collect Units
  • Events
    • Unit - A unit enters <Playable map area>
  • Conditions
    • Unit type of (Triggering Unit) Equal to (Mana Dude)
  • Actions
    • Unit Group - Add (Triggering unit) to manaDudesGroup
  • Regenerate Mana
  • Events
    • Unit - A unit dies
  • Conditions
  • Actions
    • Unit Group - Pick every unit in (manaDudesGroup) and do (Multiple Actions):
      • Set tempPoint1 = Position of (Triggering Unit)
      • Set tempPoint2 = Position of (Picked Unit)
      • If
        • Conditions
          • Distance between (tempPoint1) and (tempPoint2) Less than 650
        • Then
          • Unit - Set mana of (Picked unit) to (Mana of (Picked unit) + 20)
        • Else
      • Custom script: call RemoveLocation(udg_tempPoint1)
      • Custom script: call RemoveLocation(udg_tempPoint2)
EDIT:
I want to note that making your own DDS is a TON of work bound to be riddled with bugs as you slowly work with it. Either that or it will be very primitive in terms of what you can do with it. I made one in my own map and it has been lots of work to slowly build it up. I don't regret it because I wanted to learn how they work, anyway, but it's not an easy path to take. Using the distance check and ability check instead of using an aura is the easiest way to make this work.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Never said to make a DDS. Unit indexing isn't really DDS :|
How do you detect the damage event? You can't do that without making a DDS yourself or by having a one-off damage system which adds a lot of overhead for one ability.

I am not sure how unit indexing is used in your trigger.
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
You have to make that "unit takes damage" event generic.
The generic event doesnt exist, so you have to put it on all units on the map, because all units are viable dead units.
Then you have to make a recycler so you wont leak the events because of shitty event API.
Then you have created a vanilla DDS.

Damage modification is just an addon.
 
Level 8
Joined
Apr 8, 2009
Messages
499
How do you detect the damage event? You can't do that without making a DDS yourself or by having a one-off damage system which adds a lot of overhead for one ability.

I am not sure how unit indexing is used in your trigger.

It might not neccesarily be unit indexing, mispoken cause that's where I place all triggers concerning problems like this.
(And in all honesty, a unit indexer is still not a DDS, and a unit indexer is still kind of mandatory in almost all types of map. Just my opinion though.)

Basicly, 2 triggers.
1 that runs at map init
Pick all units in playable map, add event to your ability trigger "event - picked unit takes damage"
1 that runs whenever a unit enters the map
Add event to your ability trigger, "event - triggering unit takes damage"

There.


You have to make that "unit takes damage" event generic.
The generic event doesnt exist, so you have to put it on all units on the map.

Yes it's not a generic event, Yes you have to put it on all of them--- and that's hella easy to do.
 
Level 12
Joined
May 22, 2015
Messages
1,051
It might not neccesarily be unit indexing, mispoken cause that's where I place all triggers concerning problems like this.
(And in all honesty, a unit indexer is still not a DDS, and a unit indexer is still kind of mandatory in almost all types of map. Just my opinion though.)

Basicly, 2 triggers.
1 that runs at map init
Pick all units in playable map, add event to your ability trigger "event - picked unit takes damage"
1 that runs whenever a unit enters the map
Add event to your ability trigger, "event - triggering unit takes damage"

There.




Yes it's not a generic event, Yes you have to put it on all of them--- and that's hella easy to do.
You can get by without unit indexing if you use hashtables, but I agree that that ability as a programmer is necessary for very many effects. It's basically just the ability to attach data to specific units, and unit indexing and hashtables both allow that.

I guess it's easy to set up the base triggers for this, but I don't think it is easier than just checking the distance. I realised a buff will force it to not be MUI, anyway, so making my triggers not MUI makes it even more simple (just check distance to the specific unit and don't bother adding units to a unit group, etc.).

Building a DDS like this also adds a lot of overhead if you don't reuse it properly.
 
Level 8
Joined
Apr 8, 2009
Messages
499
You can get by without unit indexing if you use hashtables, but I agree that that ability as a programmer is necessary for very many effects. It's basically just the ability to attach data to specific units, and unit indexing and hashtables both allow that.

I guess it's easy to set up the base triggers for this, but I don't think it is easier than just checking the distance. I realised a buff will force it to not be MUI, anyway, so making my triggers not MUI makes it even more simple (just check distance to the specific unit and don't bother adding units to a unit group, etc.).

Building a DDS like this also adds a lot of overhead if you don't reuse it properly.

Yep, agreed!
And checking distance would probably be easier to trigger.
I just prefer my method because I have way too many abilities where a unit takes damage, saves me time ;)
 
Level 8
Joined
Apr 8, 2009
Messages
499
You forget the cleanup.
So for every unit that gets created and dies, you leak memory because of the events... and the unit wouldnt be properly cleaned because it is still in use (iirc).
So, its not that easy to make a vanilla DDS.

I get your point and ideally you'd clean up the leaks, but in practice--- how many units would it take to create a noticable effect ;)?
 
Level 24
Joined
Aug 1, 2013
Messages
4,658
Q: How many drups of water would it take to fill a cup?
A: Depends on how many water cranes are drupping in it.

"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"my map starts leaking"
next time:
"i give up, there are too many things that leak"
 
Level 8
Joined
Apr 8, 2009
Messages
499
Q: How many drups of water would it take to fill a cup?
A: Depends on how many water cranes are drupping in it.

"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"The leak wont be noticeable."
next time:
"my map starts leaking"
next time:
"i give up, there are too many things that leak"

We both know the amount of 'drops' required in this case is massive.
We both read the points the other made, and that's all there to it.
No need for childish comments like these.
 
Status
Not open for further replies.
Top