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

GetUnitLevel not getting unit level?

Status
Not open for further replies.
Level 13
Joined
Jul 26, 2008
Messages
1,009
So I know Warcraft III's engine is known for strange bugs and glitches.

I've recently ran into 2 odd glitches. One is where I have a unit that was attacking my hero and those units were doing 0 damage.

I didn't really change anything, (and the damage types were default) and the problem seems to have corrected itself.

I'm also having another odd bug where I can't see the Starfall Target effect except on Starfall itself. This goes for all spell graphics like it, such as blizzard and rain of fire. I assume this is local to my machine, so I haven't fret about it.

But the most perplexing issue right now is that no matter what I do, when I reference a units level in JASS using "GetUnitLevel(unit whichUnit)" it always returns 1. I go to the Level in the Unit (Non-Hero Unit's) Object Editor data and it's set clearly to the right number. I've checked other maps with this trigger and they work fine.

So I have no idea why it's suddenly messing up in the map I have.
It had worked previously, and never had been an issue.
 
Level 12
Joined
Mar 13, 2012
Messages
1,121
For your issues, please upload the testmap depicting them, then we can see whether it has to do with your local wc3 installation or whether it is global.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
do call BJDebugMsg("unit name = " + GetUnitName(whichUnit))

If the game displays "unit name = " then you do not have a unit.
If it displays "unit name = footman" (or whatever) then there is something going wrong that I cannot think of at this moment
 
Level 13
Joined
Jul 26, 2008
Messages
1,009
Alright go ahead and take a look, let me know if you see the issue. The trigger pointing to the Unit Level is the Bounty System, however no matter where I put the BJDebug for this it returns the level as 1.

I've done a BJDebug that shows both the Unit Name, and the Unit Level, and the name displays properly while the Level shows up as 1.
 

Attachments

  • Siege Home.w3x
    851.8 KB · Views: 35
Level 13
Joined
Jul 26, 2008
Messages
1,009
Thanks! That was what it was. I don't know why I set the Unit Level so low. I must've confused it with Hero Level.

Max Hero Level is 1 because the game type doesn't rely on the WC3 Leveling system. So I decided to disable it all together instead of changing all EXP factors to 0. Though I'm not sure what kind of bugs that could create. (Hopefully none)
 
Level 3
Joined
Dec 14, 2014
Messages
16
Max Hero Level is 1 because the game type doesn't rely on the WC3 Leveling system. So I decided to disable it all together instead of changing all EXP factors to 0. Though I'm not sure what kind of bugs that could create. (Hopefully none)

You can use triggers to disable Warcraft's XP gain and replace it with your own. The function is SuspendHeroXP(unit u, boolean disabled) in JASS (not sure about a GUI equivalent).

I use it like this to stop all Heroes experience gain from WC3's system (code in Zinc):
JASS:
// Suspend all experience gain
trigger t = CreateTrigger();
TriggerRegisterEnterRectSimple(t, GetWorldBounds());
TriggerAddAction(t, function(){
    unit u = GetEnteringUnit();
    if (IsUnitType(u, UNIT_TYPE_HERO)){
        SuspendHeroXP(u, true);
    }
    u = null;
});
t = null;
 
Last edited:
Status
Not open for further replies.
Top