Hello.
This will equip stone skin amulet (SSA) if one of conditions happens:
1. If your health % is lower or equal than "CONFIG.HealthPC.Equip".
2. If Bot detect a message that you received X damage or more. You must have the channel that shows up damage messages showing up. It's usually Server Log or Default.
This will also unequip if your health % is higher or equal than "CONFIG.HealthPC.Unequip" AND if you didn't received damage to equip it in last 4 seconds, but only if equipped due to damage msg!
This will equip stone skin amulet (SSA) if one of conditions happens:
1. If your health % is lower or equal than "CONFIG.HealthPC.Equip".
2. If Bot detect a message that you received X damage or more. You must have the channel that shows up damage messages showing up. It's usually Server Log or Default.
This will also unequip if your health % is higher or equal than "CONFIG.HealthPC.Unequip" AND if you didn't received damage to equip it in last 4 seconds, but only if equipped due to damage msg!
local CONFIG = {
SSA_ID = 3081,
HealthPC = {
Equip = 50, -- Equip SSA if your health % (hp%) is lower or equal than this value.
Unequip = 90, -- Unequip SSA if your health % (hp%) is HIGHER or equal than this value. It will not unequip if you received damage to equip it in last 4 seconds.
},
DamageEquip = 150, -- Equips SSA if you receive this damage or more from an attack.
}
if connected() then
local health_pc = hppc()
local amulet = neck()
if LAST_DAMAGE_TIME == nil then
LAST_DAMAGE_TIME = 0
end
if health_pc <= CONFIG.HealthPC.Equip and (amulet.id == 0 or amulet.id ~= CONFIG.SSA_ID) then
moveitems(CONFIG.SSA_ID, 'neck', '', 100)
wait(300, 500)
elseif health_pc >= CONFIG.HealthPC.Unequip and amulet.id == CONFIG.SSA_ID then
if CONFIG.DamageEquip == 0 or LAST_DAMAGE_TIME == 0 or (runningtime() - LAST_DAMAGE_TIME) >= 4 then
moveitems(CONFIG.SSA_ID, '', 'neck', 100)
wait(300, 500)
end
elseif amulet.id == 0 or amulet.id ~= CONFIG.SSA_ID then
local Messages = getnewmessages()
if type(Messages) == 'table' then
local REGEX_DMG_TAKEN = '^You lose (%d+) (%l+) due to an attack by ?a?n? (.-)%.$'
for _, msg in ipairs(Messages) do
if (msg.sender == nil or msg.sender == '') and (msg.channel == 'Default' or msg.channel == 'Server Log') then
local dmgAmount, dmgType, dmgCreature = msg.content:match(REGEX_DMG_TAKEN)
if dmgAmount >= CONFIG.DamageEquip then
LAST_DAMAGE_TIME = runningtime()
moveitems(CONFIG.SSA_ID, 'neck', '', 100)
wait(300, 500)
end
end
end
end
end
end