I'm trying to retrieve the Demigods level to give them the ability to crit on specific abilities after level 19 (I have a highly modified game that goes up to level 30).
#################################################################################################################
# Fireball
#################################################################################################################
function Fireball(abilityDef, unit, params)
if unit:IsDead() or params.Targets[1]:IsDead() then
return
end
local unitpos = unit:GetPosition()
local bonepos = unit:GetPosition('sk_TorchBearer_Staff_Muzzle_REF')
local targpos = params.Targets[1]:GetPosition()
local direction = VNormal(targpos-bonepos)
local projpos = VDiff(bonepos, unitpos)
local proj = unit:CreateProjectile('/projectiles/Fireball03/Fireball03_proj.bp', projpos[1], projpos[2], projpos[3], direction[1], direction[2], direction[3])
local damage = abilityDef.DamageAmt
if Validate.HasAbility(unit,'HEMA01FireandIce') then
damage = damage + unit.AbilityData.FireballDamage
end
local herolevel = unit:GetAIBrain().Score.HeroLevel
if herolevel > 19 then
Abil.AddAbility(unit, 'HEMA01FireballBuff', true)
end
local damageTable = {
Radius = abilityDef.DamageRadius or 0,
Type = 'SpellFire',
DamageAction = abilityDef.Name,
DamageFriendly = false,
CollideFriendly = false,
Amount = damage,
CanCrit = true,
CanCritFrom = {HEMA01FireballBuff = true},
CanBackfire = false,
CanDamageReturn = false,
CanBeEvaded = false,
IgnoreDamageRangePercent = true,
CanMagicResist = true,
ArmorImmune = true,
}
if proj and not proj:BeenDestroyed() then
proj:PassDamageData(unit,damageTable)
end
proj:SetNewTarget(params.Targets[1])
proj:SetVelocityVector(direction * 30)
proj:TrackTarget(true)
if herolevel > 19 then
Abil.RemoveAbility(unit, 'HEMA01FireballBuff', true)
end
end
AbilityBlueprint {
Name = 'HEMA01FireballBuff',
AbilityType = 'WeaponCrit',
CritChance = 100,
CritMult = 1.2,
}
But I'm having absolutely no luck. Any ideas?