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

item required for training unit

Status
Not open for further replies.
Here is a test map:
  • Pick
    • Events
      • Unit - A unit Acquires an item
      • Unit - A unit Loses an item
    • Conditions
      • (Item-type of (Item being manipulated)) Equal to Troop Ability
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • Custom script: if GetTriggerEventId() == EVENT_PLAYER_UNIT_PICKUP_ITEM then
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Load (Key dummy) of (Key (Triggering unit)) in Hash) Equal to No unit
        • Then - Actions
          • Set Point1 = (Position of (Triggering unit))
          • Unit - Create 1 Troop Ability for (Owner of (Triggering unit)) at Point1 facing Default building facing degrees
          • Unit - Hide (Last created unit)
          • Hashtable - Save Handle Of(Last created unit) as (Key dummy) of (Key (Triggering unit)) in Hash
          • Custom script: call RemoveLocation (udg_Point1)
        • Else - Actions
      • Custom script: else
      • Set Load = (Load (Key dummy) of (Key (Triggering unit)) in Hash)
      • Unit - Kill Load
      • Custom script: call RemoveSavedHandle (udg_Hash, GetHandleId (GetTriggerUnit()), StringHash("dummy"))
      • Custom script: endif
Reminder: This can only be MPI, not MUI. If you want it MUI, let me know, there is another way to do so.
 

Attachments

  • Requirement.w3x
    17.4 KB · Views: 70
Level 13
Joined
Sep 24, 2007
Messages
1,023
Forgive me but I dont really know the difference between those two. Mind in lighting me?

Looked at the map and I think I might have not have been clear about what I was trying to do. So let me straighten it out


What I am trying to do is have the items being a type of resource

So it has a charge and when you click to the train a unit it removes x amount of charges from the item stack. Is this possible?
 
  • Pick
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Charges remaining in (Item carried by (Triggering unit) of type Troop Ability)) Less than 1
        • Then - Actions
          • Game - Display to (Player group((Owner of (Triggering unit)))) the text: You may not train t...
          • Custom script: call IssueImmediateOrderById (GetTriggerUnit(), 851976)
        • Else - Actions
          • Item - Set charges remaining in (Item carried by (Triggering unit) of type Troop Ability) to ((Charges remaining in (Item carried by (Triggering unit) of type Troop Ability)) - 1)
The only problem is that if you have several units in the queue, they won't be stopped from being trained. You can't do that anyway, removing units from training queue. The trigger works only when you are issuing a new, single training. It's the best and only way. ;[
 
There is no difference, the units in the queue can be added, before the actual check of the charges and, if the charges are 4 and you try to train the 5th/6th unit, nothing will happen. There is a possibility that I can detect the order and then use an integer to increase and decrease when the unit is finally trained, but I will try it tomorrow. ;p
 
Status
Not open for further replies.
Top