Advertisement
cnl_cnl_cnl

Untitled

Dec 2nd, 2022
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.75 KB | None | 0 0
  1. local best_match_k
  2. local best_match_v
  3. local saving_spell = u.sumAffectSavingSpell()
  4.  
  5.  
  6. --local base = -32
  7. local saving_spell_adj = saving_spell.class + saving_spell.spell
  8. local weapon_adj = 0
  9. if
  10. u.wield() == "Sphairai of Ruptured Souls" or
  11. u.wield() == "a knotted beech staff"
  12. then weapon_adj = -1
  13. end
  14.  
  15. local target = -31 - saving_spell_adj - weapon_adj
  16.  
  17. --cecho("<orange>target: "..target.."\n")
  18.  
  19. local currentSpell = u.spellSave()
  20.  
  21. for k,v in pairs(cnl_mb.eqset) do
  22. if not best_match_k then
  23. best_match_k = k
  24. best_match_v = v
  25. elseif best_match_v <= target then
  26. if v <= target and v > best_match_v then
  27. best_match_k = k
  28. best_match_v = v
  29. end
  30. elseif v < best_match_v then
  31. best_match_k = k
  32. best_match_v = v
  33. end
  34. end
  35.  
  36. if u.spellSave() == best_match_v + weapon_adj + saving_spell_adj then
  37. --cecho("<green>Already equipped\n")
  38. return false
  39.  
  40. else
  41. -- if we've received at least 1 affects update since we last changed eq
  42. if (cnl_mb.eqset_affectsId or 0) < m.pc_affects_id then
  43. cecho("<red>Changing time\n")
  44. cecho(u.spellSave().."\n")
  45. cecho(best_match_v.."\n")
  46. cecho(weapon_adj.."\n")
  47. cecho(saving_spell_adj.."\n")
  48. cnl_mb.doAction("eqset wear "..best_match_k);
  49. cnl_mb.eqset_affectsId = m.pc_affects_id
  50. return true
  51. end
  52.  
  53. -- fix affects id tracking if somehow it got screwed up (reconnects?)
  54. if cnl_mb.eqset_affectsId > m.pc_affects_id then
  55. cnl_mb.eqset_affectsId = m.pc_affects_id or 0
  56. end
  57.  
  58. return false
  59. end
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement