Give items when unit is created...

Status
Not open for further replies.
Level 5
Joined
Oct 6, 2010
Messages
85
I'm making a hero arena map and I want to give a player a special item depending on the hero that they chose. I don't want to end up with 50 triggers if you know what I mean.

I have 12 different players and each player has an altar. They train their hero which is one of: Paladin, Rogue, Ranger, Warrior, Mage, Death Knight, Healer, Warlock, Shaman and Knight. When the hero is made an item appears next to them to make sure they are well equipped.
 
Level 13
Joined
Sep 13, 2010
Messages
550
you should use somekind like this:
  • Untitled Trigger 002
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer B) from 1 to AMOUNT, do (Actions)
        • Loop - Actions
          • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Trained unit)) Equal to (==) ANYUNITTYPE[(Integer B)]
            • Then - Actions
              • Do Multiple ActionsFor each (Integer A) from 1 to AMOUNT, do (Actions)
                • Loop - Actions
                  • Item - Create ITEMTYPES[((Integer A) + ((Integer B) * 100 ))] at (Position of (Trained unit))
                  • Hero - Give (Last created item) to (Trained unit) <-- Just a suggestion
            • Else - Actions
Set up variables, remove leaks then I'm sure it will work.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
If your map trains the hero at instant rate, use this Event:
  • Unit - A unit Sells a unit
If not, use geries' Event

Full Trigger System:
  • Pick
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Sold unit)) Equal to Alchemist
        • Then - Actions
          • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
          • Hero - Create Claws of Attack +15 and give it to (Sold unit)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Naga Sea Witch
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Crown of Kings +5 and give it to (Sold unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Tinker
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Kelen's Dagger of Escape and give it to (Sold unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Beastmaster
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Mask of Death and give it to (Sold unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Dark Ranger
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Orb of Frost and give it to (Sold unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Firelord
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Ring of Protection +5 and give it to (Sold unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Pandaren Brewmaster
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Blood Key and give it to (Sold unit)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Unit-type of (Sold unit)) Equal to Pit Lord
            • Then - Actions
              • Player - Make (Unit-type of (Sold unit)) Unavailable for training/construction by (Owner of (Sold unit))
              • Hero - Create Cheese and give it to (Sold unit)
            • Else - Actions
This trigger detects what hero is trained/bought
Then, give the item accordingly
The "Make unit unavailable for training" action is an option
It's just to avoid the player choosing the same hero again
Test map attached
Unknown Bug: If you choose other heroes first, leaving Panda alone, he can't be chosen. The requirement is "Default string". Therefore if you want to fully test all the heroes' difference in item, you should choose Panda first.
 

Attachments

  • Simple Item Giving System.w3x
    13.3 KB · Views: 34
Status
Not open for further replies.
Top