• 🏆 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!

[LUA] Script keeps making unit a hero

Status
Not open for further replies.
Level 15
Joined
Aug 7, 2013
Messages
1,337
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:
Level 29
Joined
Oct 24, 2012
Messages
6,543
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