public static bool CanCastHackHaveEnoughPower(WoWSpell spell, WoWUnit unit) { #if USE_LUA_POWERCHECK string usablecmd = string.Format("return IsUsableSpell(\"{0}\")", spell.Name); List<string> ret = Lua.GetReturnValues(usablecmd); if ( ret == null || !ret.Any()) { if (SingularSettings.DebugSpellCanCast) Logger.WriteFile( "CanCast[{0}]: IsUsable check failed with null", spell.Name); return false; } if (ret[0] != "1") { if (SingularSettings.DebugSpellCanCast) { uint currentPower = Me.CurrentPower; string ptype = Me.PowerType.ToString(); if (Me.Class == WoWClass.Druid) { if (Me.Shapeshift == ShapeshiftForm.Cat || Me.Shapeshift == ShapeshiftForm.Bear || Me.Shapeshift == ShapeshiftForm.DireBear) { if (Me.HealingSpellIds.Contains(spell.Id)) { ptype = "Mana"; currentPower = Me.CurrentMana; } else if (spell.PowerCost >= 100) { ptype = "Mana"; currentPower = Me.CurrentMana; } } } if (ret.Count() > 1 && ret[1] == "1") Logger.WriteFile( "CanCast[{0}]: insufficient power ({1} cost={2} have={3})", spell.Name, ptype, spell.PowerCost, currentPower); else Logger.WriteFile( "CanCast[{0}]: not usable atm ({1} cost={2} have={3})", spell.Name, ptype, spell.PowerCost, currentPower); } return false; } #elif PRE_WOD bool formSwitch = false; uint currentPower = Me.CurrentPower; if (Me.Class == WoWClass.Druid) { if (Me.Shapeshift == ShapeshiftForm.Cat || Me.Shapeshift == ShapeshiftForm.Bear || Me.Shapeshift == ShapeshiftForm.DireBear) { if (spell.IsHeal()) { formSwitch = true; currentPower = Me.CurrentMana; } else if (spell.PowerCost >= 100) { formSwitch = true; currentPower = Me.CurrentMana; } } } if (currentPower < (uint)spell.PowerCost) { if (SingularSettings.DebugSpellCasting) Logger.WriteFile( "CanCast[{0}]: insufficient power (need {1:F0}, have {2:F0} {3})", spell.Name, spell.PowerCost, currentPower, formSwitch ? "Mana in Form" : Me.PowerType.ToString()); return false; } #else if (!spell.CanCast) { return false; } #endif return true; }