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

[LUA] Script keeps making unit a hero

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,338
Hi,

Edit: Ok I figured it out. For some really odd reason, if I use a custom id like "N00X", where X is a number, it automatically converts the unit into a hero. Why on earth does it do that?

Edit2: So Warcraft assumes that if the id of something starts with a capital letter, it must be a hero. Why is that?

I keep trying to make custom units off of other units (e.g. footman) but they keep coming out as heroes. I am not trying to make heroes...

JASS:
    //! i setobjecttype("units")        
    //! i createobject("hfoo", "N001")   
    //! i makechange(current,"unam","Librarian")

But strangely this script does not make it a hero. They look exactly the same to me...

JASS:
    //! i setobjecttype("units")        
    //! i createobject("hfoo","h005")   
    //! i makechange(current,"unam","Soldier")
 
Last edited:
Edit: Ok I figured it out. For some really odd reason, if I use a custom id like "N00X", where X is a number, it automatically converts the unit into a hero. Why on earth does it do that?

Edit2: So Warcraft assumes that if the id of something starts with a capital letter, it must be a hero. Why is that?

WC3 uses the First letter to determine hero or non hero. It is hardcoded to do this and can't be changed to my knowledge.
Even the native IsHeroUnitId takes integer unitId returns boolean checks to see if a unit is a hero by simply checking if the first letter of its raw data is caps. You can write your own method to check the id and it will give you the same result. You think they would've used a boolean attached to that unit id instead but who knows why they did what they did.
Just change N to n and it will be fine as long as n isn't used for something else.
 
Status
Not open for further replies.
Top