public static double GetAttackRate(Hero unit)
{
try
{
var attackSpeed = GetAttackSpeed(unit);
double attackBaseTime;
if (!AttackRateDictionary.TryGetValue(unit.Handle, out attackBaseTime))
{
attackBaseTime =
Game.FindKeyValues(unit.StoredName() + "/AttackRate", KeyValueSource.Hero).FloatValue;
AttackRateDictionary.Add(unit.Handle, attackBaseTime);
}
Ability spell = null;
if (
!unit.HasModifiers(
new[]
{
"modifier_alchemist_chemical_rage", "modifier_terrorblade_metamorphosis",
"modifier_lone_druid_true_form", "modifier_troll_warlord_berserkers_rage"
},
false))
{
return attackBaseTime / (1 + (attackSpeed - 100) / 100);
}
switch (unit.ClassID)
{
case ClassID.CDOTA_Unit_Hero_Alchemist:
spell = unit.Spellbook.Spells.First(x => x.StoredName() == "alchemist_chemical_rage");
break;
case ClassID.CDOTA_Unit_Hero_Terrorblade:
spell = unit.Spellbook.Spells.First(x => x.StoredName() == "terrorblade_metamorphosis");
break;
case ClassID.CDOTA_Unit_Hero_LoneDruid:
spell = unit.Spellbook.Spells.First(x => x.StoredName() == "lone_druid_true_form");
break;
case ClassID.CDOTA_Unit_Hero_TrollWarlord:
spell = unit.Spellbook.Spells.First(x => x.StoredName() == "troll_warlord_berserkers_rage");
break;
}
if (spell == null)
{
return attackBaseTime / (1 + (attackSpeed - 100) / 100);
}
attackBaseTime = spell.GetAbilityData("base_attack_time");
return attackBaseTime / (1 + (attackSpeed - 100) / 100);
}
catch (KeyValuesNotFoundException)
{
if (!Utils.SleepCheck("Ensage.Common.DemoModeWarning"))
{
return 0;
}
Utils.Sleep(10000, "Ensage.Common.DemoModeWarning");
Console.WriteLine(@"[[Please do not use demo mode for testing assemblies]]");
return 0;
}
}