Advertisement
Guest User

Untitled

a guest
Jul 22nd, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.31 KB | None | 0 0
  1. local hands = {"left","right"}
  2. kbs.buffs = kbs.buffs or {
  3. blunt = 0,
  4. cutting = 0,
  5. magical = 0,
  6. cold = 0,
  7. psychic = 0,
  8. asphyxiation = 0,
  9. poison = 0,
  10. electrical = 0,
  11. fire = 0,
  12. divinus = 0,
  13. excorable = 0
  14. }
  15.  
  16. function kbs.bestAttack(name)
  17. local weaknesses = unpack(bdbGet(name))
  18. local bestattack = nil
  19. local maxdmg = 0
  20. if kbs.wonderwand then
  21. for k, v in pairs(kbs.buffs) do
  22. damage = (weaknesses[k] or 1)*(1+(v*.03))
  23. if damage>=maxdmg then
  24. bestattack = k
  25. maxdmg = damage
  26. end
  27. end
  28. return(bestattack)
  29. else
  30. for k, attack in pairs(kbs.attacks) do
  31. local damage = 0
  32. for type, percent in pairs(attack.types) do
  33. damage = damage+percent*weaknesses[type]*(1+(kbs.buffs[type]*.03))
  34. end
  35. if damage>maxdmg then
  36. bestattack = k
  37. maxdmg = damage
  38. end
  39. end
  40. end
  41. return kbs.attacks[bestattack]
  42. end
  43.  
  44.  
  45. function kbs.tryAttack()
  46. local beast = true
  47. kbs.updateTarget()
  48. if kbs.bashing and
  49. kbs.target and
  50. kbs.canAttack() then
  51. if kbs.shielded == gmcp.Room.Info.num then
  52. if kbs.beasthere and gmcp.Char.Vitals.beastbal == "1" then
  53. send("beast order attack "..kbs.target,false)
  54. kbs.shielded = false
  55. beast=false
  56. elseif kbs.raze then
  57. for index, weapon in ipairs(raze.weapon) do
  58. if not kbs.wielded[weapon] then
  59. send("wield "..weapon.." "..hands[index],false)
  60. end
  61. end
  62. if raze.kata then
  63. send("kata perform "..kbs.target.." "..raze.att,false)
  64. else
  65. send(raze.att.." "..kbs.target,false)
  66. if raze.secondary then
  67. send(raze.secondary.." "..kbs.target,false)
  68. end
  69. end
  70. else
  71. return
  72. end
  73. end
  74. if kbs.raze and kbs.beasthere and gmcp.Char.Vitals.beastbal == "1" and beast then
  75. send("beast order attack "..kbs.target,false)
  76. end
  77. if kbs.wonderwand then
  78.  
  79. local damagetype = kbs.bestAttack(kbs.targetname)
  80. if damagetype~=kbs.currentWand then
  81. send("wonderwand tune "..damagetype)
  82. kbs.currentWand = damagetype
  83. end
  84. send("wonderwand point "..kbs.target)
  85. else
  86. local attack = kbs.bestAttack(kbs.targetname)
  87. for index, weapon in ipairs(attack.weapon) do
  88. if not kbs.wielded[weapon] then
  89. send("wield "..weapon.." "..hands[index])
  90. end
  91. end
  92. if attack.kata then
  93. send("kata perform "..kbs.target.." "..attack.att,false)
  94. else
  95. send(attack.att.." "..kbs.target,false)
  96. if attack.secondary then
  97. send(attack.secondary.." "..kbs.target,false)
  98. end
  99. end
  100. end
  101. sendGMCP([[IRE.Target.Set "]]..kbs.target..[["]])
  102. tempTimer(0.1,[[send(" ",false)]])
  103. end
  104. end
  105.  
  106.  
  107. function kbs.canAttack()
  108. if mm.bals.equilibrium and mm.bals.balance and
  109. gmcp.Char.Vitals.right_arm == "1" and
  110. gmcp.Char.Vitals.left_arm == "1" and
  111. gmcp.Char.Vitals.right_leg == "1" and
  112. gmcp.Char.Vitals.left_leg == "1" and
  113. gmcp.Char.Vitals.psisub ~= "0" and
  114. gmcp.Char.Vitals.psisuper ~= "0" and
  115. gmcp.Char.Vitals.psiid ~= "0" and
  116. (mm.defc.trueblind or not mm.affl.blind) and
  117. not mm.affl.aeon and
  118. not mm.affl.tangle and
  119. not mm.affl.prone and
  120. -- not mm.affl.paralysis and
  121. (not mm.affl.crippledleftleg or not mm.affl.crippledrightleg) and
  122. not mm.affl.crippledleftarm and
  123. not mm.affl.crippledrightarm then
  124. return true
  125. end
  126. return false
  127. end
  128.  
  129. registerAnonymousEventHandler("target_found","kbs.tryAttack")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement