Detect custom unit class

qqqbbb

Prince
Joined
Sep 25, 2010
Messages
530
I have this code in my mod
Code:
if pUnit:GetUnitClassType() == GameInfoTypes.UNITCLASS_TEST then 
	print("custom unit class")
end
but it does not fire for some reason. The new unit class is in database, game spawns units of this class without problems. Any ideas?
 
This is my code:
Code:
Events.RunCombatSim.Add (function (attackingPlayer, attackingUnit, attackingUnitDamage, attackingUnitFinalDamage, attackingUnitMaxHitPoints, defendingPlayer, defendingUnit, defendingUnitDamage, defendingUnitFinalDamage, defendingUnitMaxHitPoints)
    local pAttackingPlayer = Players[attackingPlayer];
    local pDefendingPlayer = Players[defendingPlayer];
    local pAttackUnit = pAttackingPlayer:GetUnitByID(attackingUnit);
    local pDefendUnit = pDefendingPlayer:GetUnitByID(defendingUnit);

    if pDefendUnit:GetUnitClassType() == GameInfoTypes.UNITCLASS_TEST then 
        print("custom unit class");
    end
end )
If I replace UNITCLASS_TEST with any vanilla unit class it works but it does not with my custom unit class.
 
Back
Top Bottom