[Solved] Trigger To Give Items To Heroes When Trained

Level 9
Joined
Mar 28, 2008
Messages
476
Looking to create a trigger similar to the Melee Game trigger that gives Town Portal to trained heroes, but I want it to be a random item from a specific item pool that I've created.
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
How have you defined the pool of items? That's the only part of the trigger that might be complicated. The rest is:
  • Events
    • Unit - A unit enters (Playable Map Area)
  • Conditions
    • ((Triggering Unit) is a Hero) equal to True
    • ((Triggering Unit) is in GIVEN_AN_ITEM_ALREADY) equal to False
  • Actions
    • Unit Group - Add (Triggering Unit) to GIVEN_AN_ITEM_ALREADY
    • //create item from pool and give to the unit
You can also do this with the Trained Unit event but I wasn't sure if that would trigger on hero revive. This definitely WILL trigger on hero revive, so I've added the unit group check to prevent a unit from getting more than 1 free item. This means it would also work for a trigger spawning the unit onto the map, in case that happens for some reason.
 
Level 9
Joined
Mar 28, 2008
Messages
476
((Triggering Unit) is in GIVEN_AN_ITEM_ALREADY) equal to False
Is this line referring to a region? I'm having trouble finding this line in the conditions.

Ok I realise this is a custom variable unit group. I've not played with variables yet so I want to make sure I get this right. Do I just give it the name, or do I need to edit/add other things to this variable?

1741500022489.png



I'm also a bit special and can't figure out how to create an item pool. I thought I did, but I guess not.
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
A unit can only "Enter the map" once as far as I know. I suppose it could go out of bounds then come back, but then maybe just use (Entire map) instead of (Playable map area) to avoid that.

Or better yet in this case:
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • ((Trained unit) is a Hero) Equal to True
That might not work for Taverns that sell units, though.
 
Level 9
Joined
Mar 28, 2008
Messages
476
A unit can only "Enter the map" once as far as I know. I suppose it could go out of bounds then come back, but then maybe just use (Entire map) instead of (Playable map area) to avoid that.

Or better yet in this case:
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • ((Trained unit) is a Hero) Equal to True
That might not work for Taverns that sell units, though.

I might give this a try.
I'm just having issue figuring out how to make an item pool. I thought I knew, but I can't seem to find what I was looking for.
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I might give this a try.
I'm just having issue figuring out how to make an item pool. I thought I knew, but I can't seem to find what I was looking for.
Pyro will likely suggest something better, but here's the quick and dirty way:
  • Events
    • Map initialization
  • Conditions
  • Actions
    • Set Variable Item_Drop[1] = ...
    • Set Variable Item_Drop2[] = ...
    • Set Variable Item_Drop3[] = ...
  • Events
    • Unit - A unit Finishes training a unit
  • Conditions
    • ((Trained unit) is a Hero) Equal to True
  • Actions
    • Set Variable RNG = (Random integer number between 1 and 3)
    • Item - Create Item_Drop[RNG] and give to (Trained unit)
Item_Drop = Item (array).
RNG = Integer.
The create action is called "give item to hero" or something along those lines, doesn't actually require it to be a Hero though (dumb name).
 
Level 9
Joined
Mar 28, 2008
Messages
476
The create action is called "give item to hero" or something along those lines, doesn't actually require it to be a Hero though (dumb name).
Okay it's this line I'm having issues with. Im in the Item Create actions but can't find "give item to hero" or anything related to "give".
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
Do I just give it the name, or do I need to edit/add other things to this variable?
Sometimes you will want to add a default value or make the variable an array. You are free to name them whatever you want, it makes no difference. I use capitals and underscores to show it's a variable clearly in text, as your chain of confusion to understanding shows it can be useful.
Pyro will likely suggest something better, but here's the quick and dirty way:
wc3c had my itempools tutorial and I've never remade it, but really there's not much unique material to cover. Instead I can link MindWorkX's Itempools Guide. More trouble than it's worth for someone inexperienced, but you'd be able to implement them in GUI quite easily if you needed to. I think you've got the best solution for Grish.
A unit can only "Enter the map" once as far as I know.
I just tested. Revivable heroes re-trigger an "enters region" event they moment their revive finishes and become controllable. Current patch. (I altered what I wrote here because I had another trigger with the wrong event giving me wrong information).
 
Last edited:
Top