willdu
Active Member
- Joined
- Mar 11, 2017
- Messages
- 91
- Reaction score
- 25
That was my OTclient auto healing (candboy)
But this shits always fail and let me to die
I'm trying to make it better, but i'm not expirient enough.
I've tried to start with this:
But doing so, i broke the bot, only shows AFK
Not shows everything like before
Code:
-- Auto Healing Logic
SupportModule.AutoHeal = {}
AutoHeal = SupportModule.AutoHeal
local nextHeal = {}
local settings = {
[RestoreType.cast] = 'AutoHeal',
[RestoreType.item] = 'AutoHealthItem'
}
function AutoHeal.onHealthChange(player, health, maxHealth, oldHealth, restoreType)
local Panel = SupportModule.getPanel()
if not Panel:getChildById(settings[restoreType]):isChecked() then
return -- has since been unchecked
end
local itemHealthValue = Panel:getChildById('ItemHealthBar'):getValue()
local item = Panel:getChildById('CurrentHealthItem'):getItem()
local lowSpellText = Panel:getChildById('HealSpellText'):getText()
local lowHealthValue = Panel:getChildById('HealthBar'):getValue()
local lowManaValue = Panel:getChildById('ManaBar'):getValue()
if (player:getHealthPercent() < itemHealthValue and item) and restoreType == RestoreType.item then
if player:hasState(PlayerStates.Pz) then
return Helper.safeDelay(8000, 12000)
end
Helper.safeUseInventoryItemWith(item:getId(), player, BotModule.isPrecisionMode())
Helper.safeDelay(2000, 3000)
elseif (player:getHealthPercent() < lowHealthValue and player:getManaPercent() >= lowManaValue) and restoreType == RestoreType.cast then
if player:hasState(PlayerStates.Pz) then
return Helper.safeDelay(8000, 12000)
end
g_game.talk(lowSpellText)
Helper.safeDelay(2000, 3000)
end
end
function AutoHeal.executeCast(player, health, maxHealth, oldHealth)
AutoHeal.onHealthChange(player, health, maxHealth, oldHealth, RestoreType.cast)
end
function AutoHeal.ConnectCastListener(listener)
if g_game.isOnline() then
local player = g_game.getLocalPlayer()
addEvent(AutoHeal.onHealthChange(player, player:getHealth(),
player:getMaxHealth(), player:getHealth(), RestoreType.cast))
end
connect(LocalPlayer, { onHealthChange = AutoHeal.executeCast })
end
function AutoHeal.DisconnectCastListener(listener)
disconnect(LocalPlayer, { onHealthChange = AutoHeal.executeCast })
end
function AutoHeal.executeItem(player, health, maxHealth, oldHealth)
AutoHeal.onHealthChange(player, health, maxHealth, oldHealth, RestoreType.item)
end
function AutoHeal.ConnectItemListener(listener)
if g_game.isOnline() then
local player = g_game.getLocalPlayer()
addEvent(AutoHeal.onHealthChange(player, player:getHealth(),
player:getMaxHealth(), player:getHealth(), RestoreType.item))
end
connect(LocalPlayer, { onHealthChange = AutoHeal.executeItem })
end
function AutoHeal.DisconnectItemListener(listener)
disconnect(LocalPlayer, { onHealthChange = AutoHeal.executeItem })
end
But this shits always fail and let me to die
I'm trying to make it better, but i'm not expirient enough.
I've tried to start with this:
Code:
-- Auto Healing Logic
SupportModule.AutoHeal = {}
AutoHeal = SupportModule.AutoHeal
local nextHeal = {}
local settings = {
[RestoreType.cast] = 'AutoHeal',
[RestoreType.item] = 'AutoHealthItem'
}
function AutoHeal.onHealthChange(player, health, maxHealth, oldHealth, restoreType)
local Panel = SupportModule.getPanel()
if not Panel:getChildById(settings[restoreType]):isChecked() then
return -- has since been unchecked
end
local itemHealthValue = Panel:getChildById('ItemHealthBar'):getValue()
local lowHealthValue = Panel:getChildById('HealthBar'):getValue()
if(player:getHealthPercent() <= itemHealthValue and itemHealthValue < lowHealthValue) then
HealItem(player)
else (player:getHealthPercent() <= lowHealthValue and itemHealthValue > lowHealthValue) then
HealSpell(player)
end
end
function HealItem(player)
local item = Panel:getChildById('CurrentHealthItem'):getItem()
if (player:getHealthPercent() < itemHealthValue and item) and restoreType == RestoreType.item then
if player:hasState(PlayerStates.Pz) then
return Helper.safeDelay(8000, 12000)
end
Helper.safeUseInventoryItemWith(item:getId(), player, BotModule.isPrecisionMode())
Helper.safeDelay(2000, 3000)
end
end
function HealSpell(player)
local lowManaValue = Panel:getChildById('ManaBar'):getValue()
local lowSpellText = Panel:getChildById('HealSpellText'):getText()
if (player:getHealthPercent() < lowHealthValue and player:getManaPercent() >= lowManaValue) and restoreType == RestoreType.cast then
if player:hasState(PlayerStates.Pz) then
return Helper.safeDelay(8000, 12000)
end
g_game.talk(lowSpellText)
Helper.safeDelay(2000, 3000)
end
end
function AutoHeal.executeCast(player, health, maxHealth, oldHealth)
AutoHeal.onHealthChange(player, health, maxHealth, oldHealth, RestoreType.cast)
end
function AutoHeal.ConnectCastListener(listener)
if g_game.isOnline() then
local player = g_game.getLocalPlayer()
addEvent(AutoHeal.onHealthChange(player, player:getHealth(),
player:getMaxHealth(), player:getHealth(), RestoreType.cast))
end
connect(LocalPlayer, { onHealthChange = AutoHeal.executeCast })
end
function AutoHeal.DisconnectCastListener(listener)
disconnect(LocalPlayer, { onHealthChange = AutoHeal.executeCast })
end
function AutoHeal.executeItem(player, health, maxHealth, oldHealth)
AutoHeal.onHealthChange(player, health, maxHealth, oldHealth, RestoreType.item)
end
function AutoHeal.ConnectItemListener(listener)
if g_game.isOnline() then
local player = g_game.getLocalPlayer()
addEvent(AutoHeal.onHealthChange(player, player:getHealth(),
player:getMaxHealth(), player:getHealth(), RestoreType.item))
end
connect(LocalPlayer, { onHealthChange = AutoHeal.executeItem })
end
function AutoHeal.DisconnectItemListener(listener)
disconnect(LocalPlayer, { onHealthChange = AutoHeal.executeItem })
end
But doing so, i broke the bot, only shows AFK
Not shows everything like before