DamageLib
Damage Library for accurate damage calculations.
Properties
slot
: SpellSlot
Functions
GetDamageFunctionMap
DamageLib.GetDamageFunctionMap()
→ unordered_map<hash, fun(source: AIBaseHero, bRawDamage: boolean, stage: integer): float>
Returns <hash, function> map with functions which calculate spell damage.
You can extend our DamageLib with missing damage calculations for your champion script or overwrite existing ones if you think it will improve it.
Function must accept (source: AIBaseHero, bRawDamage: boolean, stage: integer) parameters and return float (damage).
local LuxLightBindingSpellDataHash = Game.spelldataHash("LuxLightBinding") -- Spell Data hash is used as key for damageMap
local damageMap = DamageLib.GetDamageFunctionMap()
damageMap[LuxLightBindingSpellDataHash] = function(source, target, bRawDamage, stage)
rawDamage = 100
return bRawDamage and rawDamage or DamageLib.CalculateMagicalDamage(source, target, rawDamage)
end
GetSpellDamage
DamageLib.GetSpellDamage(
spellHash
: number - unsigned,
source
: AIHeroClient,
target
: AIBaseClient,
bRawDamage
: boolean,
stage
: number - integer,
slot
: SpellSlot
)
→ float
Argument | Type | Description |
---|---|---|
spellHash | number - unsigned | spelldataHash of the given spell. |
source | AIHeroClient | Source unit. |
target | AIBaseClient | Target unit. |
bRawDamage | boolean | Return raw damage if true. |
stage | number - integer | Return damage of certain stage, if spell supports multiple stages. |
slot | SpellSlot | SpellSlot of the given spell. |
Returns calculated damage of the given spell.
GetSpellDamage
DamageLib.GetSpellDamage(
spellName
: string,
source
: AIHeroClient,
target
: AIBaseClient,
bRawDamage
: boolean,
stage
: number - integer
)
→ float
Argument | Type | Description |
---|---|---|
spellName | string | Name of the given spell. |
source | AIHeroClient | Source unit. |
target | AIBaseClient | Target unit. |
bRawDamage | boolean | Return raw damage if true. |
stage | number - integer | Return damage of certain stage, if spell supports multiple stages. |
Returns calculated damage of the given spell.
CalculateAutoAttackDamage
DamageLib.CalculateAutoAttackDamage(
source
: AIBaseClient,
target
: AIBaseClient
)
→ float
Argument | Type | Description |
---|---|---|
source | AIBaseClient | Source unit. AA damage will be taked from this unit. |
target | AIBaseClient | Target unit |
Returns calculated auto attack damage including various modifiers (armor, resistances, empowerments etc).
CalculatePhysicalDamage
DamageLib.CalculatePhysicalDamage(
source
: AIBaseClient,
target
: AIBaseClient,
amount
: float
)
→ float
Argument | Type | Description |
---|---|---|
source | AIBaseClient | Source unit |
target | AIBaseClient | Target unit |
amount | float | Raw damage |
Returns calculated physical damage including various modifiers (armor, resistances, empowerments etc).
CalculateMagicalDamage
DamageLib.CalculateMagicalDamage(
source
: AIBaseClient,
target
: AIBaseClient,
amount
: float
)
→ float
Argument | Type | Description |
---|---|---|
source | AIBaseClient | Source unit |
target | AIBaseClient | Target unit |
amount | float | Raw damage |
Returns calculated magical damage including various modifiers (armor, resistances, empowerments etc).
Examples
local LuxLightBindingSpellDataHash = Game.spelldataHash("LuxLightBinding") -- Spell Data hash is used as key for damageMap
local LuxLightBindingHash = Game.fnvhash("LuxLightBinding") -- FNV hash is used by AIBaseClient:GetSpellSlot(spellHash) function
local TotalDamageHash = Game.fnvhash("TotalDamageTT") -- FNV hash is used to access tooltip property with SpellBookEntry:GetCalculateInfo(...)
local damageMap = DamageLib.GetDamageFunctionMap()
damageMap[LuxLightBindingSpellDataHash] = function(source, target, bRawDamage, stage)
local slot = source:GetSpellSlot(LuxLightBindingHash) -- This uses fnv hash
if slot == SpellSlot.NullSlot then
return 0
end
local entry = source:GetSpellEntry(slot)
if not entry or not entry:IsValid() then
return 0
end
local rawDamage = entry:GetCalculateInfo(source, TotalDamageHash, slot)
if bRawDamage or not target or not target:IsValid() then
return rawDamage
end
return DamageLib.CalculateMagicalDamage(source, target, rawDamage)
end
local Q = SDKSpell.Create(SpellSlot.Q, 1300, DamageType.Magical)
print("Q Damage", Q:GetDamage(Game.localPlayer)) -- This will use our custom damage calc function