• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Solved] How to get to unit's race field?

Level 7
Joined
Sep 10, 2022
Messages
93
Well, generally I want to add a special trait to the unit, depending on their race, so I thought it would be easy because we have the field "Stats-Race". But if these are the circumstances, I’ll do it differently.
 
Level 4
Joined
Feb 1, 2024
Messages
41
Actually there's a Race comparison in Condition section with 5 races. I tested it out and believe the following trigger may help you to detect:


  • Race
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Race of (Triggering unit)) Equal to Human
        • Then - Actions
          • Game - Display to (All players) the text: Human
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Triggering unit)) Equal to Orc
            • Then - Actions
              • Game - Display to (All players) the text: Orc
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Race of (Triggering unit)) Equal to Undead
                • Then - Actions
                  • Game - Display to (All players) the text: Undead
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Race of (Triggering unit)) Equal to Night Elf
                    • Then - Actions
                      • Game - Display to (All players) the text: Night Elf
                    • Else - Actions
                      • Game - Display to (All players) the text: Demon


Note that Neutral units such as Chicken, Firelord, Lady Vashj is classified as Demon. This also corresponds if you customize their race in the Object Editor.
 
Level 7
Joined
Sep 10, 2022
Messages
93
Actually there's a Race comparison in Condition section with 5 races. I tested it out and believe the following trigger may help you to detect:


  • Race
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Race of (Triggering unit)) Equal to Human
        • Then - Actions
          • Game - Display to (All players) the text: Human
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Race of (Triggering unit)) Equal to Orc
            • Then - Actions
              • Game - Display to (All players) the text: Orc
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Race of (Triggering unit)) Equal to Undead
                • Then - Actions
                  • Game - Display to (All players) the text: Undead
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Race of (Triggering unit)) Equal to Night Elf
                    • Then - Actions
                      • Game - Display to (All players) the text: Night Elf
                    • Else - Actions
                      • Game - Display to (All players) the text: Demon


Note that Neutral units such as Chicken, Firelord, Lady Vashj is classified as Demon. This also corresponds if you customize their race in the Object Editor.
Yeah, I saw the Race Comparison, but there are no "Creep, Common or Other" like in "Stats-Race". Except for 4 default races, there are only demons...
 
Level 7
Joined
Sep 10, 2022
Messages
93
If you're not using it for anything else, you could use the Point Value stat and say e.g. 1 = human, 2 = orc etc., and point value is something you can get with an integer comparison, so that's useful
I saw this field, but What is this field responsible for? I can see many units have value "100" in it.

UPD: I found a thread here, and read it. Thank you, it will be useful.
 
Last edited:
Level 21
Joined
Aug 29, 2012
Messages
860
I believe it's used for the scorescreen? But it's quite irrelevant and it's a convenient way to assign a value to an unit type that you can retrieve to do other stuff later :)

Edit: unlike custom value, I think we don't have a function "set point value" (at least in GUI), so that's a limiting factor
 
Level 20
Joined
Feb 27, 2019
Messages
599
Theres also RACE_OTHER but its hidden in GUI for whatever reason.
Maybe this will help.
  • Untitled Trigger 002
    • Events
      • Player - Player 1 (Red) Selects a unit
    • Conditions
    • Actions
      • Custom script: local integer a = 0
      • Custom script: local integer b = 20
      • Custom script: loop
      • Custom script: set a = a + 1
      • Custom script: if GetUnitRace(GetTriggerUnit()) == ConvertRace(a) then
      • Custom script: call DisplayTextToForce( GetPlayersAll(), I2S(a) )
      • Custom script: endif
      • Custom script: exitwhen a > b
      • Custom script: endloop
Human = ConvertRace(1)
Orc = ConvertRace(2)
Undead = ConvertRace(3)
Night Elf = ConvertRace(4)
Demon = ConvertRace(5)
Other = ConvertRace(7)
Creep = ConvertRace(8)
Commoner = ConvertRace(9)
Critter = ConvertRace(10)
Naga = ConvertRace(11)
Unknown = null
 
Last edited:
Top