Ability damage equal to number of units

Level 3
Joined
Mar 22, 2020
Messages
41
Hi all, i was wondering if there is any way to set the damage done by an ability to be based on the number of units controlled (for example: 10 x number of unit). i've been trying since two days but i still cant find a solution (if any)
 
Level 13
Joined
Nov 4, 2006
Messages
1,218
you need to track the number of units owned in a variable and then deal damage with a trigger function, use arithmetic to do e.g. 10x your variable

what have you tried so far? care to share your triggers?
 
Level 12
Joined
Jan 30, 2020
Messages
876
Hello there !

I found out that some of the new natives to set real values fields of abilities have been added to GUI.

You could try something like that :
  • Set Ability Damage
    • Events
      • Unit - A unit owned by Player 1 (Red) Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • Ability - Set Ability: (Unit: (Casting unit)'s Ability with Ability Code: Shadow Strike)'s Real Level Field: Damage ('Hbz2') of Level: (Level of Shadow Strike for (Triggering unit)) to (10.00 x (Real((Count non-structure units controlled by Player 1 (Red) (Exclude incomplete units)))))
 
Level 3
Joined
Mar 22, 2020
Messages
41
you need to track the number of units owned in a variable and then deal damage with a trigger function, use arithmetic to do e.g. 10x your variable

what have you tried so far? care to share your triggers?

I'll add i picture of what i did (or at least the useful part, because then i tried to do something totally different) it seems pretty useless to me, mainly because i need to:

- Add to the variable only summoned units (Im creating an illusionist and wanted to make a spell that deal dmg based on number of illusion created) owned by a specific player

- Since i want to play this online, and there may be multiple copies of the same hero, i need that the trigger count only summoned units from the player that summoned them




(Shatter is the name of the ability)
 

Attachments

  • Shatter.png
    Shatter.png
    6 KB · Views: 28
Level 3
Joined
Mar 22, 2020
Messages
41
Hello there !

I found out that some of the new natives to set real values fields of abilities have been added to GUI.

You could try something like that :
  • Set Ability Damage
    • Events
      • Unit - A unit owned by Player 1 (Red) Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • Ability - Set Ability: (Unit: (Casting unit)'s Ability with Ability Code: Shadow Strike)'s Real Level Field: Damage ('Hbz2') of Level: (Level of Shadow Strike for (Triggering unit)) to (10.00 x (Real((Count non-structure units controlled by Player 1 (Red) (Exclude incomplete units)))))
This is really close to want i need but, as i said i need to count only summoned units and should work for any player (using their own summoned units)
I'll give it a try tho, where did you get "count units" part ?
 
Level 12
Joined
Jan 30, 2020
Messages
876
If you read the trigger carefully you will notice the Real() so you first need to use conversion integer to real.

I am not used to GUI in all fairness, maybe there is a way to add summoned units.*

EDIT oh and for any player, just add them thats all.
It was just an example i made quickly because I had WE opened on a new map :)

EDIT 2: I am not sure but maybe "count living units owned by player" would include summoned unit.

EDIT 3 never mind, I just read your other messages, it seems you only want to account for summoned units. This should be doable with a pick and unit type comparison with "UNIT_TYPE_SUMMONED".

EDIT 4 : sorry for so many edits.

Try this :

  • Set Ability Damage
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • Ability - Set Ability: (Unit: (Casting unit)'s Ability with Ability Code: Shadow Strike)'s Real Level Field: Damage ('Hbz2') of Level: (Level of Shadow Strike for (Casting unit)) to (10.00 x (Real((Number of units in (Units owned by (Owner of (Casting unit)) matching (((Casting unit) is Summoned) Equal to True).)))))
Of course as you've noticed I used shadow strike ability because it has a damage field...
 
Last edited:
Level 3
Joined
Mar 22, 2020
Messages
41
If you read the trigger carefully you will notice the Real() so you first need to use conversion integer to real.

I am not used to GUI in all fairness, maybe there is a way to add summoned units.*

EDIT oh and for any player, just add them thats all.
It was just an example i made quickly because I had WE opened on a new map :)

EDIT 2: I am not sure but maybe "count living units owned by player" would include summoned unit.

EDIT 3 never mind, I just read your other messages, it seems you only want to account for summoned units. This should be doable with a pick and unit type comparison with "UNIT_TYPE_SUMMONED".

EDIT 4 : sorry for so many edits.

Try this :

  • Set Ability Damage
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • Ability - Set Ability: (Unit: (Casting unit)'s Ability with Ability Code: Shadow Strike)'s Real Level Field: Damage ('Hbz2') of Level: (Level of Shadow Strike for (Casting unit)) to (10.00 x (Real((Number of units in (Units owned by (Owner of (Casting unit)) matching (((Casting unit) is Summoned) Equal to True).)))))
Of course as you've noticed I used shadow strike ability because it has a damage field...
I dont get the "Real()" part, can u explain what it is ? how do i do it ?

Edit: Dont worry about edits :3
 
Level 12
Joined
Jan 30, 2020
Messages
876
Number of units is an integer.
But when making the trigger in GUI, the new damage you want to set is a real value.
If you try to set a real value the editor won't let you access the values returning an integer, and the number of units that are summoned for the player is an integer.

So be able to access the "Number of units", you have to tell the trigger editor that you are looking for an integer converted to real rather than a real when you are setting up the new damage.

If you just search in the real values choices, there will be no "number of units" because it is not a real value ^^
 
Level 3
Joined
Mar 22, 2020
Messages
41
Number of units is an integer.
But when making the trigger in GUI, the new damage you want to set is a real value.
If you try to set a real value the editor won't let you access the values returning an integer, and the number of units that are summoned for the player is an integer.

So be able to access the "Number of units", you have to tell the trigger editor that you are looking for an integer converted to real rather than a real when you are setting up the new damage.

If you just search in the real values choices, there will be no "number of units" because it is not a real value ^^
I understood out less than half of what you said xD
you can explain to me step by step how to do it ?
Im not very smart with triggers ^^'
 
Level 12
Joined
Jan 30, 2020
Messages
876
Well first of all, understand I am not comfortable with GUI triggers :D

But the way it works is this.

When you're in the trigger editor and you chose let's say a real value you want to assign like the damage.
But we want to set the dame to the number of summoned units x 10

Problem is the damage is a real number
and the number of summoned units is an integer

So when you will search for what to put in the value of the damage of the ability, when you will do arithmetic to make a multiplication, for the trigger editor it will still be real values so once you chose 10 for left number, then the multiplication, you will be stuck because it won't offer you to select "number of units". So you first need to chose "convert integer to real, then inside the value will be an integer, and in integer values the trigger editor will let you use "number of units...."

I know it can be confusing, but being able to use integer values in real numbers is what is called type casting, and Jass / GUI do not support this. Thats why you have to use the conversion.

By the way, sorry, but as shadowstrike is a hero ability, it has made the trigger even more complicated because you usually set the damage for the level of the ability that your hero has.

If you use a unit ability with some damage, it will be easier because unit abilities don't have a level.

Wooo....

Sounds much more complicated when you have to explain every little bit :D
 
Level 3
Joined
Mar 22, 2020
Messages
41
Well first of all, understand I am not comfortable with GUI triggers :D

But the way it works is this.

When you're in the trigger editor and you chose let's say a real value you want to assign like the damage.
But we want to set the dame to the number of summoned units x 10

Problem is the damage is a real number
and the number of summoned units is an integer

So when you will search for what to put in the value of the damage of the ability, when you will do arithmetic to make a multiplication, for the trigger editor it will still be real values so once you chose 10 for left number, then the multiplication, you will be stuck because it won't offer you to select "number of units". So you first need to chose "convert integer to real, then inside the value will be an integer, and in integer values the trigger editor will let you use "number of units...."

I know it can be confusing, but being able to use integer values in real numbers is what is called type casting, and Jass / GUI do not support this. Thats why you have to use the conversion.

By the way, sorry, but as shadowstrike is a hero ability, it has made the trigger even more complicated because you usually set the damage for the level of the ability that your hero has.

If you use a unit ability with some damage, it will be easier because unit abilities don't have a level.

Wooo....

Sounds much more complicated when you have to explain every little bit :D
It doesnt work :(

(Thanks for the explanation anyway <3)
 

Attachments

  • Shatter.png
    Shatter.png
    8.6 KB · Views: 25
Level 12
Joined
Jan 30, 2020
Messages
876
Hello there.

I wonder why this wouldn't work. I don't see a single reason.

Maybe try to add an action after the main action that reads the real value.

Or maybe the ability you based shatter on does not have a real field called "Damage" ?

This is really confusing. I will do a test on my side.
 
Level 12
Joined
Jan 30, 2020
Messages
876
Ok that is really strange.

I initially thought we were using the wrong real value so I chose one that was definitely in shadow strike in my test map : Initial Damage, and indeed the initial damage has not changed.

The only explanation I can think of is that.... the new function does not work !

Dam they could at least test the functions they implement, especially if they add it to GUI !!!!

EDIT : yes thats really disappointing when you thing you have found a way to do something impossible and then suddenly it does not work for some stupid reason ....

EDIT 2 : Now we are not completely stuck

You could still use a similar event but the "finishes casting an ability" so that it fires when your unit has actually already cast the ability.

Then count the number of summoned units and give this value to an integer variable

Then reduce the Hit Points of the target by that number x 10 (or 50 like in your screenshot)
 
Last edited:

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
Everything is indexed starting at 0 with these new natives which means that level 1 is actually level 2. So when you say "level of ability being cast" you're actually saying "level of ability being cast + 1". Or in this case, level of Shatter is really 1 level higher than it should be. An easy solution is to subtract 1 from the level, so: "Level of ability being cast - 1" or "Level of Shatter - 1".

Along with that it's also likely that the chosen Damage field is incorrect. Here's just a few of the different Damage fields:
  • Actions
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Uin1') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Htb1') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Osh1') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Nfd3') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Ucs1') of Level: 0 to 1000.00
See the Rawcodes ('Uin1'), ('Htb1'), etc... those are specific to each ability that deals damage. The one that Macadamia referenced was specific to Shadow Strike, but if your ability isn't based on Shadow Strike then this won't work.

So the question is, what ability is Shatter based on @Meetius?

And what is it's Damage field rawcode? (Press Control + D in the Object Editor to view Raw data)
I have an example of this in the picture I attached below, it displays the rawcode for Storm Bolt's Damage field which is 'Htb1'.
 

Attachments

  • Damage field example.png
    Damage field example.png
    116.3 KB · Views: 48
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
876
Wow @Uncle don't tell me they didn't shift the level number with the GUI version.....

The trigger I made to test with a lev 10 Maiev with lev 3 ShadowStrike is this one :
  • Boost Shadowstrike
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shadow Strike
    • Actions
      • Ability - Set Ability: (Unit: (Casting unit)'s Ability with Ability Code: Shadow Strike)'s Real Level Field: Initial Damage ('Esh5') of Level: (Level of Shadow Strike for (Casting unit))) to 1000.00
It didn't work. So after reading your message I converted the trigger to custom text, and guess what ?

You were right, the stupid BJ function used by GUI is :
JASS:
function BlzSetAbilityRealLevelFieldBJ takes ability whichAbility, abilityreallevelfield whichField, integer level, real value returns nothing
    set bj_lastInstObjFuncSuccessful = BlzSetAbilityRealLevelField(whichAbility, whichField, level, value)
endfunction

They didn't even adapt the level number like they usually do for things like player number !!!!

After retrieving 1 to the level number, of course now it works....

I can't believe they messed up this.
I mean it's just as bad as the option in JassHelper that DISABLES vJass when you check it instead of enabling it......

These kind of mess ups are a disaster because they will make so many GUI users waste hours trying to solve problems they finally won't be able to solve until someone who uses Jass or LUA will tell them...

@Meetius : well now Uncle found out, you can use the same trigger but you need to retrieve 1 to the level number, and make sure the ability real field is exactly the same as the one you will find in the list offered by the trigger editor.

Again, thanks @Uncle , I should have knowned better and convert the trigger to GUI then look up for the BJ function, I just couldn't believe they would mess that up... I guess you save the day !!!
 

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
Yeah, it's a big mess. You'd think Reforged would've addressed this stuff by now but they're still working on campaign fixes... And the longer they wait the worse it gets. People will fill their maps with these workarounds, and then a year later blizzard will address the issue and break everything, AGAIN. It's insane.
 
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
876
Indeed.
Anyways thank god you were around, now OP will be able to solve this.

And you are so right, when they will fix their bugs, all maps that had to use workarounds to function properly will suddenly become broken

I can't believe they waste all their resources on the campaigns when the modding community is what keeps the game alive... this is beyond my comprehension.
 
Level 3
Joined
Mar 21, 2020
Messages
35
Something like this?

*note: if you check the Unit Ability Level integer field you have to do -1 (levels don't start at 0)
1. Create 2 global integer variables called "count" and "damage"
2. Copy/paste this trigger:
  • trig
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units owned by Player 1 (Red).) and do (Actions)
        • Loop - Actions
          • Set VariableSet count = (count + 1)
      • Game - Display to (All players) the text: (Units counted: + (String(count)))
      • Game - Display to (All players) the text: (Count multiplied: + (String(count)))
      • Game - Display to (All players) the text: (Ability damage: + (String((Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Damage ('Ucs1'), of Level: ((Level of (Ability being cast) for (Triggering unit)) - 1)))))
      • Set VariableSet damage = ((Integer((Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Damage ('Ucs1'), of Level: ((Level of (Ability being cast) for (Triggering unit)) - 1)))) x (count x 2))
      • Game - Display to (All players) the text: (Damage: + (String(damage)))
      • Unit - Set life of (Target unit of ability being cast) to ((Life of (Target unit of ability being cast)) - (Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field Damage ('Hbz2'), of Level: 1))
      • Set VariableSet count = 0
3. Depending on what kind of ability you're using it on (AoE, targeted, etc) you might want to use a damage engine to call on dmg events more easily
 

Attachments

  • dmgcount.w3m
    17.2 KB · Views: 23

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
@lil apex
There's no reason to set the life of the target. Also, that's not a good method for dealing damage because if the unit dies from the life loss it won't have a "killer" and therefore no kill credit is given. If you want to damage a unit there's an action made for it, something like "Cause unit to damage target". But like I said, in this case it's completely unnecessary to deal damage/set life as the ability itself will deal the damage.

Not only that, that specific Damage Field might not be used by the ability he's using. I went over this in my post above, you need to make sure the Rawcodes match based on the ability you're using.
 
Last edited:
Level 3
Joined
Mar 22, 2020
Messages
41
Everything is indexed starting at 0 with these new natives which means that level 1 is actually level 2. So when you say "level of ability being cast" you're actually saying "level of ability being cast + 1". Or in this case, level of Shatter is really 1 level higher than it should be. An easy solution is to subtract 1 from the level, so: "Level of ability being cast - 1" or "Level of Shatter - 1".

Along with that it's also likely that the chosen Damage field is incorrect. Here's just a few of the different Damage fields:
  • Actions
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Uin1') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Htb1') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Osh1') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Nfd3') of Level: 0 to 1000.00
    • Ability - Set Ability: (Unit: (Triggering unit)'s Ability with Ability Code: (Ability being cast))'s Real Level Field: Damage ('Ucs1') of Level: 0 to 1000.00
See the Rawcodes ('Uin1'), ('Htb1'), etc... those are specific to each ability that deals damage. The one that Macadamia referenced was specific to Shadow Strike, but if your ability isn't based on Shadow Strike then this won't work.

So the question is, what ability is Shatter based on @Meetius?

And what is it's Damage field rawcode? (Press Control + D in the Object Editor to view Raw data)
I have an example of this in the picture I attached below, it displays the rawcode for Storm Bolt's Damage field which is 'Htb1'.
Hi, first of all thanks for helping me.
To answer your question, Shatter is made out of the Lightning bolt spell :)
 
Level 12
Joined
Jan 30, 2020
Messages
876
Hello there.

@Meetius : you mean Storm Bolt, right ? If I remember correctly Lightning Bolt is a Wow spell, no ?

I attached my test map, I gave a Shatter ability to Maiev based on StormBoilt with the appropriate real field.

It works great but with 1 downside : the tooltip of the ability does not change even if the damage does.

So you will have to change the tooltip manually for each level everytime the damage is changed.
 

Attachments

  • Test.w3x
    11.2 KB · Views: 21
Level 3
Joined
Mar 22, 2020
Messages
41
Hello there.

@Meetius : you mean Storm Bolt, right ? If I remember correctly Lightning Bolt is a Wow spell, no ?

I attached my test map, I gave a Shatter ability to Maiev based on StormBoilt with the appropriate real field.

It works great but with 1 downside : the tooltip of the ability does not change even if the damage does.

So you will have to change the tooltip manually for each level everytime the damage is changed.

I dont know for sure what i meant, to be clear i mean the Far Seer ability
I'll try your test map now :D
 
Level 12
Joined
Jan 30, 2020
Messages
876
Hope you will be able to.

I am stuck with testing at the moment battlenet servers seem overloaded for me so it refuses to start maps from WE.

EDIT : you mean you use chain lightning ??? For this ability the real value field will be Ocl1 - Damage per Target
 
Last edited:
Level 3
Joined
Mar 22, 2020
Messages
41
Hope you will be able to.

I am stuck with testing at the moment battlenet servers seem overloaded for me so it refuses to start maps from WE.

EDIT : you mean you use chain lightning ??? For this ability the real value field will be Ocl1 - Damage per Target
Yep, same for me, cant test for the same reason... :(
Anyway, yes, i used chain lightning but I didn't remember what the name was in English xD
 
Level 3
Joined
Mar 22, 2020
Messages
41
Should be ok, just use the proper Real Value field that I just mentioned and it should work great.
Okay, i'll try and let you know :D
Anyway, i was wondering, there is a list (or something like that) that i can use to see which "code" i should use for each kind of damage/spell ?

Edit: Wonderful, it works, im so happy you cant even imagine it. Thanks very very much <3

Edit 2: Now, how can I make summoned units die when cast the spell ? ^^'
 
Last edited:
Level 12
Joined
Jan 30, 2020
Messages
876
Hehe.

Well as you can compare the unit classification with UNIT_TYPE-SUMMONED, it would be easy to pick all units belonging to a player with that condition and then remove every picked unit.

Not in front on WE right now, but I believe this is easy to do in the GUI editor.
 

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
Pick every unit owned by triggering player matching matching unit classification equal to summoned.

You can also add the summoned units to a Unit Group to have more control over it.
  • Events:
  • A unit spawns a summoned unit
  • Conditions:
  • Unit-type of summoned unit equal to Water Elemental
  • Actions:
  • Add summoned unit to SummonUnitGroup
This allows you to control which types of summoned units are being tracked. Then you can do "Pick every unit in SummonUnitGroup and kill picked unit". Make sure to clear the Unit Group of the summoned units once you kill them.
 
Level 3
Joined
Mar 22, 2020
Messages
41

Attachments

  • Shatter 2.png
    Shatter 2.png
    13.4 KB · Views: 15
Level 3
Joined
Mar 22, 2020
Messages
41
Pick every unit owned by triggering player matching matching unit classification equal to summoned.

You can also add the summoned units to a Unit Group to have more control over it.
  • Events:
  • A unit spawns a summoned unit
  • Conditions:
  • Unit-type of summoned unit equal to Water Elemental
  • Actions:
  • Add summoned unit to SummonUnitGroup
This allows you to control which types of summoned units are being tracked. Then you can do "Pick every unit in SummonUnitGroup and kill picked unit". Make sure to clear the Unit Group of the summoned units once you kill them.
This is an easy way and it works for sure but, there other heroes with a "summon ability" (other than more than one player ^^') so it doesnt work as i want it to work :c
 
Level 12
Joined
Jan 30, 2020
Messages
876
Well I understand, in your map you have 2 opposing heroes using their spawned units as pawns.

Even if you end up with several heroes, you have 2 options : use @Uncle method and use 1 group per hero.

Or "mark" your summoned units with a number by setting their unit user data, and when it comes to removing, use that unit user data value in a condition to check if it should be removed.

Hope it doesn't sound too vague.

EDIT : sorry confused myself with the map :D
 
Level 3
Joined
Mar 22, 2020
Messages
41
Well I understand, in your map you have 2 opposing heroes using their spawned units as pawns.

Even if you end up with several heroes, you have 2 options : use @Uncle method and use 1 group per hero.

Or "mark" your summoned units with a number by setting their unit user data, and when it comes to removing, use that unit user data value in a condition to check if it should be removed.

Hope it doesn't sound too vague.

EDIT : sorry confused myself with the map :D
My map is even more complex than this, its an arena with four team, each team have up to four player (but a single hero can be chosen only once per team).
That said, since making 16 groups seems a bit too much (xD), how this "mark" this works ? do you mind explaining it to me ? ^^'
 

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
My map is even more complex than this, its an arena with four team, each team have up to four player (but a single hero can be chosen only once per team).
That said, since making 16 groups seems a bit too much (xD), how this "mark" this works ? do you mind explaining it to me ? ^^'
You make 1 Group with an Array. SummonUnitGroup[1] belongs to Player 1, SummonunitGroup[2] belongs to Player 2, etc...
 
Level 12
Joined
Jan 30, 2020
Messages
876
Its just a value you can give to the unit that is not related to the fields you find in the object editor, its called UnitUserData and I believe you can set any integer value yo a unit that way.

Let's say you have 16 heroes in total, well when the units are summoned, just change their UnitUserData to the number of the hero and then you can access this number at any time.

OK just had a look in trigger editor, the UnitUserData is actually called Unit - Custom Value in GUI
 
Level 3
Joined
Mar 22, 2020
Messages
41
Its just a value you can give to the unit that is not related to the fields you find in the object editor, its called UnitUserData and I believe you can set any integer value yo a unit that way.

Let's say you have 16 heroes in total, well when the units are summoned, just change their UnitUserData to the number of the hero and then you can access this number at any time.

OK just had a look in trigger editor, the UnitUserData is actually called Unit - Custom Value in GUI
And then how do i call a specific number ?
 
Level 12
Joined
Jan 30, 2020
Messages
876
You call that number when you pick every summoned unit : you read the custom value and if it matches your hero number then you remove the unit

EDIT as for setting the custom value, just use something like that (in that example I set it to the player owning the summoning unit number, but if there are several heroes, maybe you could set the custom values of the heroes first and then give the summoned unit the same custom value as the hero.
  • Set Ability Damage
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • Unit - Set the custom value of (Summoned unit) to (Player number of (Owner of (Summoning unit))
EDIT 2 : you could even use the heroes Unit Ids as custom values for the summoned units, thats an idea that just popped up ^^
 
Last edited:
Level 3
Joined
Mar 22, 2020
Messages
41
You call that number when you pick every summoned unit : you read the custom value and if it matches your hero number then you remove the unit

EDIT as for setting the custom value, just use something like that (in that example I set it to the player owning the summoning unit number, but if there are several heroes, maybe you could set the custom values of the heroes first and then give the summoned unit the same custom value as the hero.
  • Set Ability Damage
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
    • Actions
      • Unit - Set the custom value of (Summoned unit) to (Player number of (Owner of (Summoning unit))
EDIT 2 : you could even use the heroes Unit Ids as custom values for the summoned units, thats an idea that just popped up ^^
But i still dont understand how to call a specific number ^^'
There is a trigger that can do it ? Something like the "Pick every unit in a group" trigger ?
 

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
Here's how to do the Unit Group stuff.
SummonGroup is a Unit Group variable with an Array.
  • Add To Group
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Summoned unit)) Equal to Water Elemental (Level 1)
          • (Unit-type of (Summoned unit)) Equal to Water Elemental (Level 2)
          • (Unit-type of (Summoned unit)) Equal to Water Elemental (Level 3)
    • Actions
      • Unit Group - Add (Summoned unit) to SummonGroup[(Player number of (Triggering player))]
  • Kill Summons
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kill Summons
    • Actions
      • Unit Group - Pick every unit in SummonGroup[(Player number of (Triggering player))] and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
  • Summon Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SummonGroup[(Player number of (Triggering player))].) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from SummonGroup[(Player number of (Triggering player))].

And for Macadamia's method, I think a Unit Indexer is what you'd want to use here, it's very GUI friendly.
GUI Unit Indexer 1.4.0.0
 

Attachments

  • Summon Group.w3m
    17.5 KB · Views: 22
Level 12
Joined
Jan 30, 2020
Messages
876
Honestly, one day I should start looking at these utilities people have worked hard to provide to the community.

I have the feeling reinventing the wheel over and over again like I have done for months is not the most efficient way to do things :)

EDIT : yes, the problem with using the unit "custom value" is that you can only use a single integer, so once you dedicate it to one thing, thats over, unless you'd start to do complex operations on that integer, that really becomes counter productive in the long run.
This is exactly why a unit indexer becomes relevant.
 
Level 3
Joined
Mar 22, 2020
Messages
41
Here's how to do the Unit Group stuff.
SummonGroup is a Unit Group variable with an Array.
  • Add To Group
    • Events
      • Unit - A unit Spawns a summoned unit
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Summoned unit)) Equal to Water Elemental (Level 1)
          • (Unit-type of (Summoned unit)) Equal to Water Elemental (Level 2)
          • (Unit-type of (Summoned unit)) Equal to Water Elemental (Level 3)
    • Actions
      • Unit Group - Add (Summoned unit) to SummonGroup[(Player number of (Triggering player))]
  • Kill Summons
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Kill Summons
    • Actions
      • Unit Group - Pick every unit in SummonGroup[(Player number of (Triggering player))] and do (Actions)
        • Loop - Actions
          • Unit - Kill (Picked unit)
  • Summon Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • ((Triggering unit) is in SummonGroup[(Player number of (Triggering player))].) Equal to True
    • Actions
      • Unit Group - Remove (Triggering unit) from SummonGroup[(Player number of (Triggering player))].

And for Macadamia's method, I think a Unit Indexer is what you'd want to use here, it's very GUI friendly.
GUI Unit Indexer 1.4.0.0
I still don't know how to create such a thing (I just copied / pasted it from your map to mine xD) but it worked :D
Thanks a lot :D
 

Uncle

Warcraft Moderator
Level 34
Joined
Aug 10, 2018
Messages
3,622
No problem.

The triggers are all there, maybe you can reverse engineer them. It's really just a matter of knowing where everything is located, which you can find out by clicking on the fields.
 
Top