@@ -395,7 +395,7 @@ public ILconstBool IsHeroUnitId(ILconstInt unitId) {
395395 return ILconstBool .instance (!rawcode .isEmpty () && Character .isUpperCase (rawcode .charAt (0 )));
396396 }
397397 public ILconstBool IsUnitIdType (ILconstInt unitId , IlConstHandle unitType ) {
398- return IsHeroUnitId ( unitId ) ;
398+ return ILconstBool . TRUE ;
399399 }
400400
401401 public ILconstBool UnitAddType (IlConstHandle unit , IlConstHandle unitType ) {
@@ -537,6 +537,8 @@ public ILconstBool UnitMakeAbilityPermanent(IlConstHandle unit, ILconstBool perm
537537 }
538538
539539 public ILconstInt IncUnitAbilityLevel (IlConstHandle unit , ILconstInt abilityId ) {
540+ UnitMock unitMock = unitOrNull (unit );
541+ if (unitMock == null || !unitMock .abilityLevels .containsKey (abilityId .getVal ())) return ILconstInt .create (0 );
540542 return SetUnitAbilityLevel (unit , abilityId , ILconstInt .create (GetUnitAbilityLevel (unit , abilityId ).getVal () + 1 ));
541543 }
542544
@@ -563,7 +565,12 @@ public ILconstInt GetHeroXP(IlConstHandle unit) {
563565
564566 public void SetHeroXP (IlConstHandle unit , ILconstInt xp , ILconstBool showEyeCandy ) {
565567 UnitMock unitMock = unitOrNull (unit );
566- if (unitMock != null ) unitMock .heroXp = xp ;
568+ if (unitMock != null ) {
569+ int oldLevel = unitMock .level .getVal ();
570+ unitMock .heroXp = xp ;
571+ unitMock .level = ILconstInt .create (Math .max (1 , xp .getVal () / 1000 + 1 ));
572+ unitMock .skillPoints = ILconstInt .create (unitMock .skillPoints .getVal () + Math .max (0 , unitMock .level .getVal () - oldLevel ));
573+ }
567574 }
568575
569576 public void AddHeroXP (IlConstHandle unit , ILconstInt xp , ILconstBool showEyeCandy ) {
0 commit comments