• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Trigger] How to detect type of unit that is being trained?

Status
Not open for further replies.
Level 8
Joined
Apr 23, 2011
Messages
322
  • Footman
    • Events
      • Unit - A unit Begins training a unit
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Barracks
    • Actions
      • Set RatGroup = (Units in Barracks training start <gen> matching ((((Matching unit) is alive) Equal to True) and (((Unit-type of (Matching unit)) Equal to Recruit [1]) and (((Percentage life of (Matching unit)) Greater than or equal to 75.00) and ((Percentage mana of (Matchi
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Real((Number of units in RatGroup))) Greater than or equal to 1.00
          • (Real((Level of 444Helmets for Warehouse 0330 <gen>))) Greater than or equal to 2.00
          • (Real((Level of 444Shields for Warehouse 0330 <gen>))) Greater than or equal to 2.00
          • (Real((Level of 444Swords for Warehouse 0330 <gen>))) Greater than or equal to 2.00
          • (Real((Level of 444Metal Plates for Warehouse 0330 <gen>))) Greater than or equal to 6.00
        • Then - Actions
          • Unit - Remove (Random unit from RatGroup) from the game
          • Unit - Set level of 444Helmets for Warehouse 0330 <gen> to ((Integer((Real((Level of 444Helmets for Warehouse 0330 <gen>))))) - 1)
          • Unit - Set level of 444Shields for Warehouse 0330 <gen> to ((Integer((Real((Level of 444Shields for Warehouse 0330 <gen>))))) - 1)
          • Unit - Set level of 444Swords for Warehouse 0330 <gen> to ((Integer((Real((Level of 444Swords for Warehouse 0330 <gen>))))) - 1)
          • Unit - Set level of 444Metal Plates for Warehouse 0330 <gen> to ((Integer((Real((Level of 444Metal Plates for Warehouse 0330 <gen>))))) - 5)
        • Else - Actions
          • Custom script: call IssueImmediateOrderById(GetTriggerUnit(), 851976)
          • Set tempforce = (Player group((Owner of Barracks 0200 <gen>)))
          • Game - Display to tempforce the text: Insufficient resour...
          • Custom script: call DestroyForce(udg_tempforce)
      • Custom script: call DestroyGroup (udg_RatGroup)

Everything works perfectly except one thing...the trigger doesn't make any difference between units that are about to be trained.(Footman, Archer, etc.=all are the same=bad)
So, I need a way to detect that unit's type

I also found something (hail google) that might work, but I have no idea how to use it
[triggger]Custom script: GetTrainedUnitType()
[/trigger]
 
Last edited:
Level 8
Joined
Apr 23, 2011
Messages
322
"Event Response - Trained Unit-Type".
I detect unit type of a unit whose training begins
source for "GetTrainedUnitType()" line
Bomber7" said:
Having googled this issue and come upon this thread, I decided to answer. There is in fact a native called GetTrainedUnitType() which does exactly what you're looking for. It returns the unit type in integer form. I know the native says "TrainedUnit" but it works for units that are in the process of being trained.
http://www.thehelper.net/threads/unit-type-of-training-unit.144467/
 
Status
Not open for further replies.
Top