Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local best_match_k
- local best_match_v
- local saving_spell = u.sumAffectSavingSpell()
- --local base = -32
- local saving_spell_adj = saving_spell.class + saving_spell.spell
- local weapon_adj = 0
- if
- u.wield() == "Sphairai of Ruptured Souls" or
- u.wield() == "a knotted beech staff"
- then weapon_adj = -1
- end
- local target = -31 - saving_spell_adj - weapon_adj
- --cecho("<orange>target: "..target.."\n")
- local currentSpell = u.spellSave()
- for k,v in pairs(cnl_mb.eqset) do
- if not best_match_k then
- best_match_k = k
- best_match_v = v
- elseif best_match_v <= target then
- if v <= target and v > best_match_v then
- best_match_k = k
- best_match_v = v
- end
- elseif v < best_match_v then
- best_match_k = k
- best_match_v = v
- end
- end
- if u.spellSave() == best_match_v + weapon_adj + saving_spell_adj then
- --cecho("<green>Already equipped\n")
- return false
- else
- -- if we've received at least 1 affects update since we last changed eq
- if (cnl_mb.eqset_affectsId or 0) < m.pc_affects_id then
- cecho("<red>Changing time\n")
- cecho(u.spellSave().."\n")
- cecho(best_match_v.."\n")
- cecho(weapon_adj.."\n")
- cecho(saving_spell_adj.."\n")
- cnl_mb.doAction("eqset wear "..best_match_k);
- cnl_mb.eqset_affectsId = m.pc_affects_id
- return true
- end
- -- fix affects id tracking if somehow it got screwed up (reconnects?)
- if cnl_mb.eqset_affectsId > m.pc_affects_id then
- cnl_mb.eqset_affectsId = m.pc_affects_id or 0
- end
- return false
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement