Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 10.61 KB | None | 0 0
  1. -------------------------------------------------
  2. --         Put your Lua functions here.        --
  3. --                                             --
  4. -- Note that you can also use external Scripts --
  5. -------------------------------------------------
  6.  
  7. function monkAttack()
  8.     km.attackCommands = {}
  9.  
  10.     table.insert(km.attackCommands, "quickdismount")
  11.     local tar = tmp.target
  12.     local t = cdb.chars[tar:title()]
  13.  
  14.     local kai = tonumber(gmcp.Char.Vitals.kai)
  15.  
  16.     monkBlackout(t, tar)
  17.  
  18. --  if t.defs.shielded then
  19. --      table.insert(km.attackCommands, "sck "..tar)
  20. --  else
  21.         if not monkFitness(t, tar) then
  22.         if not monkKaiPush(t, tar) then
  23.         if not monkKaido(t, tar) then
  24.             monkCombo(t, tar)  
  25.             monkTelepathy(t, tar)
  26.         end
  27.         end
  28.         end
  29. --  end
  30.  
  31.     if affs.diag then
  32.         km.attackCommands = {"diagnose",}
  33.     end
  34.  
  35.     if #gmcp.Room.Players >= 3 then
  36.         table.insert(km.attackCommands, 1, "get body")
  37.     end
  38.  
  39.     table.insert(km.attackCommands, 1, "kipup")
  40.     parry()
  41.     table.insert(km.attackCommands, 2, "guard "..defs.parry.limb)
  42.  
  43.     if o.vitals.wield_left ~= "empty" then
  44.         send("wear buckler234212")
  45.         send("secure left")
  46.     end
  47.     if o.vitals.wield_right ~= "empty" then
  48.         send("secure right")
  49.     end
  50.  
  51.     if #inv.pipes.filled == 0 then send("pipelist") end
  52.     if #inv.pipes.filled < 3 then
  53.         local pipeTypes = {"elm", "valerian", "skullcap",}
  54.         for _,v in ipairs(pipeTypes) do
  55.             if not table.contains(inv.pipes.filled, v) then
  56.                 table.insert(km.attackCommands, 2, "put "..v.." in emptypipe"..o.config_sep.."outc "..v)
  57.             end
  58.         end
  59.     end
  60.  
  61. --  if defs.active.kai_recursion and not defs.active.kai_boost then table.insert(km.attackCommands, "kai boost") end
  62.  
  63.     if o.stats.mounted then send("quickdismount") end
  64. --  table.insert(km.attackCommands, "combo "..tar.." jpk ucp ucp")
  65.  
  66.     if #km.attackCommands >= 10 then send("pipelist") end
  67. --  if #km.attackCommands < 10 then table.insert(km.attackCommands, "guard right arm") end
  68.     local queueCommand = table.concat(km.attackCommands, o.config_sep)
  69.     if km.beheading then queueCommand = "" end
  70.     send("qeb "..queueCommand)
  71.  
  72. end
  73.  
  74. function monkFitness(t, tar)
  75.  
  76.     if fs.cd.fitness then return false end
  77.  
  78.     if affs.current.asthma
  79.     and affs.current.slickness
  80.     and affs.current.anorexia
  81.     and (affs.current.paresis or affs.current.stupidity or affs.current.impatience)
  82.     then
  83.         table.insert(km.attackCommands, "fitness")
  84.         return true
  85.     end
  86.  
  87.     return false
  88.  
  89. end
  90.  
  91. function monkKaiPush(t, tar)
  92.  
  93.     if fs.cd.mindPush then return false end
  94.  
  95.     local affList = {}
  96.  
  97.     for aff, v in pairs(affs.current) do
  98.         if table.contains(affs.lib.tree, aff) and v and aff ~= "hidden" then
  99.             table.insert(affList, aff)
  100.         end
  101.     end
  102.  
  103.     if #affList > 3
  104.     or (t.class == "syssin" and (affs.current.hypochondria or affs.current.hypersomnia or affs.current.impatience or affs.current.confusion))
  105.     then
  106.         cecho("\n<cyan>Mind Push dat bitch!")
  107.         table.insert(km.attackCommands, "mind push "..tar)
  108.         return true
  109.     end
  110.  
  111.     return false
  112.  
  113. end
  114.  
  115. function monkKaido(t, tar)
  116.  
  117.     local kai = tonumber(gmcp.Char.Vitals.kai)
  118.  
  119.     if kai >= 40 and ((t.affs.left_leg_damaged and t.restoring ~= "left leg") or (t.affs.right_leg_damaged and t.restoring ~= "right leg")) then
  120.         local brokenLimbs = checkBrokenLimbs(t)
  121.         if brokenLimbs < 2 or (brokenLimbs < 3 and not t.traits.prone) then
  122.             table.insert(km.attackCommands, "kai cripple "..tar)
  123.             return true
  124.         end
  125.     end
  126.  
  127.     if kai >= 20 and km.kai_strike_target and not (t.affs.kai_strike_left_leg or t.affs.kai_strike_right_leg or t.affs.kai_stright_left_arm or t.affs.kai_stright_right_arm) then
  128.         local what = km.kai_strike_target
  129.         table.insert(km.attackCommands, "kai strike "..tar.." "..what)
  130.         return true
  131.     end
  132.  
  133.     return false
  134.  
  135. end
  136.  
  137. function checkBrokenLimbs(t)
  138.  
  139.     local numberOfBreaks = 0
  140.  
  141.     local limbs = {
  142.         "left_leg_broken",
  143.         "left_arm_broken",
  144.         "right_leg_broken",
  145.         "right_arm_broken",
  146.     }
  147.     for _, limb in ipairs(limbs) do
  148.         if t.affs[limb] then
  149.             numberOfBreaks = numberOfBreaks + 1
  150.         end
  151.     end
  152.     return numberOfBreaks
  153.  
  154. end
  155.  
  156. function monkTelepathy(t, tar)
  157.  
  158.     if t.class == "Shapeshifter" then return false end
  159.  
  160.     if affs.current.right_leg_broken and affs.current.left_leg_broken then return end
  161.  
  162.     local afflictions = {
  163.         "indifference",
  164.         "paresis",
  165.         "stupidity",
  166.  
  167.     }
  168.  
  169.     local useAff = "indifference"
  170.     for _, aff in ipairs(afflictions) do
  171.         if aff == "paresis" and t.affs.paralysis then
  172.         elseif not t.affs[aff] then
  173.             useAff = aff
  174.             break
  175.         end
  176.     end
  177.     local affCmds = {
  178.         ["indifference"] = "mind indifference "..tar,
  179.         ["stupidity"] = "mind stupidity "..tar,
  180.         ["paresis"] = "mind paralyse "..tar,
  181.     }
  182.     local cmd = affCmds[useAff]
  183.  
  184.     table.insert(km.attackCommands, cmd)
  185.  
  186. end
  187.  
  188. function monkBlackout(t, tar)
  189.  
  190.     if km.shouldBlackout then
  191.         table.insert(km.attackCommands, "mind blackout")
  192.         return true
  193.     end
  194.  
  195.     return false
  196.  
  197. end
  198.  
  199. function monkCombo(t, tar)
  200.  
  201.     if gmcp.Char.Vitals.mounted ~= "0" then
  202.         table.insert(km.attackCommands, "quickdismount")
  203.     end
  204.  
  205.     local stance = "tgs"
  206.     local limb = monkTarget(t, tar)
  207.     local secondaryLimb = monkSecondaryTarget(t, tar)
  208.  
  209.     local kicks = {
  210.         ["right arm"] = "mnk right",
  211.         ["left arm"] = "mnk left",
  212.         ["right leg"] = "snk right",
  213.         ["left leg"] = "snk left",
  214.         ["torso"] = "sdk",
  215.         ["head"] = "wwk",
  216.     }
  217. --[[
  218.     local punches = {
  219.         ["right arm"] = "spp right spp right",
  220.         ["left arm"] = "spp left spp left",
  221.         ["right leg"] = "hfp right hfp right",
  222.         ["left leg"] = "hfp left hfp left",
  223.         ["torso"] = "hkp hkp",
  224.         ["head"] = "ucp ucp",
  225.     }
  226. --]]
  227. --[[]]
  228.     local punches = {
  229.         ["right arm"] = "jbp jbp",
  230.         ["left arm"] = "jbp jbp",
  231.         ["right leg"] = "jbp jbp",
  232.         ["left leg"] = "jbp jbp",
  233.         ["torso"] = "jbp jbp",
  234.         ["head"] = "jbp jbp",
  235.     }
  236. --]]
  237.  
  238.     local kick = kicks[limb]
  239.  
  240.     if t.affs.left_arm_damaged and t.affs.right_arm_damaged and not t.affs.numb_arms then
  241.         kick = "cmk"
  242.     end
  243.  
  244.     local cmd = "combo "..tar.." "..kick.." "..punches[secondaryLimb]
  245.  
  246.     if t.traits.prone and not t.affs.impaled and kick ~= "cmk" then
  247.         cmd = cmd:gsub("mnk right", "wrt right arm"):gsub("mnk left", "wrt left arm"):gsub("snk right", "wrt right leg"):gsub("snk left", "wrt left leg")
  248.         cmd = cmd:gsub("wwk", "wrt ##"):gsub("sdk", "wrt ##")
  249.         local limbs = {"left_leg_broken", "right_leg_broken", "right_arm_broken", "left_arm_broken", }
  250.         local wrtTar = "head"
  251.         for i, v in ipairs(limbs) do
  252.             if not t.affs[v] then
  253.                 wrtTar = v:gsub("_broken", ""):gsub("_", " ")
  254.                 break
  255.             end
  256.         end
  257.         cmd = cmd:gsub("##", wrtTar)
  258.     end
  259.  
  260.  
  261.        
  262.  
  263.     if ((t.affs.left_leg_damaged and t.restoring ~= "left leg") or (t.affs.right_leg_damaged and t.restoring ~= "right leg") or (t.affs.left_leg_mangled or t.affs.right_leg_mangled)) then
  264.         if not t.traits.prone then
  265.             cmd = cmd:gsub("mnk", "swk"):gsub("snk", "swk"):gsub("sdk", "swk"):gsub("wwk", "swk"):gsub("wrt", "swk")
  266.         else
  267. --          cmd = cmd:gsub("spp", "ucp"):gsub("hfp", "ucp"):gsub("hkp","ucp")
  268.         end
  269.     end
  270.  
  271.     if t.defs.shielded then
  272.         cmd = cmd:gsub("mnk", "sck"):gsub("snk", "sck"):gsub("sdk", "sck"):gsub("wwk", "sck"):gsub("wrt", "sck"):gsub("swk", "sck")
  273.     end
  274.  
  275.     if  t.traits.tumbling then
  276.         cmd = cmd:gsub("mnk", "slt"):gsub("snk", "slt"):gsub("sdk", "slt"):gsub("wwk", "slt"):gsub("wrt", "slt")
  277.     end
  278.  
  279.     if t.traits.prone and t.affs.head_mangled and not t.defs.shielded and ((t.affs.right_arm_broken and t.affs.left_arm_broken) or km.sapienceParry ~= "head") then
  280.         cmd = "combo "..tar.." axk ucp ucp"
  281.     end
  282.  
  283.     table.insert(km.attackCommands, "target "..secondaryLimb)
  284.     table.insert(km.attackCommands, stance)
  285.     table.insert(km.attackCommands, cmd)
  286.    
  287.  
  288. end
  289.  
  290. function monkLimbTargets()
  291.    
  292.     local limbs = {
  293.  
  294.         "right leg",
  295.         "left leg",
  296. --      "head",
  297.         "right arm",
  298.         "left arm",
  299.         "head",
  300.         "torso",
  301.     }
  302.    
  303.     return limbs
  304.    
  305. end
  306.  
  307. function monkTarget(t, tar)
  308.  
  309.     if not tar then tar = tmp.target end
  310.     if not t then t = cdb.chars[tar:title()] end
  311.  
  312.     local limbs = monkLimbTargets()
  313.  
  314.     local tlimbs = {}
  315.     for limb, damage in pairs(t.limbs) do
  316.         table.insert(tlimbs, { ["limb"] = limb, ["damage"] = damage})
  317.     end
  318.  
  319.     table.sort(tlimbs, function (a, b) return a.damage > b.damage end)
  320.  
  321.     local parry = tlimbs[1].limb:gsub("_", " ")
  322.  
  323.     --[[
  324.         if t.restoring == parry then
  325.             if tlimbs[1].damage < 30 then
  326.                 parry = tlimbs[2].limb:gsub("_", " ")
  327.             end
  328.         end
  329.     --]]
  330.  
  331.     local lastParry = t.lastParry or nil
  332.     parry = lastParry or parry
  333.  
  334.     local canParry = not (t.affs.numb_arms or (t.affs.left_arm_broken and t.affs.right_arm_broken) or t.affs.paresis or t.affs.paralysis)
  335.    
  336.     local targetLimb = ""
  337.     for _, limb in ipairs(limbs) do
  338.         if not canParry and limb == "head" and not t.affs[limb:gsub(" ","_").."_mangled"] then
  339.             targetLimb = limb
  340.             break
  341.         end
  342.  
  343.         if not canParry and not t.affs[limb:gsub(" ","_").."_mangled"] then
  344.             targetLimb = limb
  345.             break
  346.         end
  347.  
  348.         if limb == "head" and limb ~= lastParry and parry ~= limb and not t.affs[limb:gsub(" ","_").."_mangled"]
  349.         and t.restoring ~= limb
  350.         then
  351.             targetLimb = limb
  352.             break
  353.         end
  354.  
  355.         if limb ~= lastParry and (not t.affs[limb:gsub(" ","_").."_mangled"] and parry ~= limb and t.restoring ~= limb)
  356.  
  357.         then
  358.             targetLimb = limb
  359.             break
  360.         end
  361.     end
  362.  
  363.     return targetLimb
  364.  
  365. end
  366.  
  367.  
  368. function monkSecondaryTarget(t, tar)
  369.  
  370.     if not tar then tar = tmp.target end
  371.     if not t then t = cdb.chars[tar:title()] end
  372.  
  373.     local limbs = monkLimbTargets()
  374.  
  375.     local tlimbs = {}
  376.     for limb, damage in pairs(t.limbs) do
  377.         table.insert(tlimbs, { ["limb"] = limb, ["damage"] = damage})
  378.     end
  379.  
  380.     table.sort(tlimbs, function (a, b) return a.damage > b.damage end)
  381.  
  382.     local parry = tlimbs[1].limb:gsub("_", " ")
  383.  
  384.     --[[
  385.         if t.restoring == parry then
  386.             if tlimbs[1].damage < 30 then
  387.                 parry = tlimbs[2].limb:gsub("_", " ")
  388.             end
  389.         end
  390.     --]]
  391.  
  392.     local lastParry = t.lastParry or nil
  393.     parry = lastParry or parry
  394.  
  395.     local canParry = not (t.affs.numb_arms or (t.affs.left_arm_broken and t.affs.right_arm_broken) or t.affs.impaled or t.affs.paresis or t.affs.paralysis)
  396.    
  397.     local targetLimb = ""
  398.  
  399.     local kickLimb = monkTarget(t, tar)
  400.     for _, limb in ipairs(limbs) do
  401.         if limb == kickLimb then
  402.         else
  403.         if not canParry and limb == "head" and not t.affs[limb:gsub(" ","_").."_mangled"] then
  404.             targetLimb = limb
  405.             break
  406.         end
  407.  
  408.         if not canParry and not t.affs[limb:gsub(" ","_").."_mangled"] then
  409.             targetLimb = limb
  410.             break
  411.         end
  412.  
  413.         if limb == "head" and limb ~= lastParry and parry ~= limb and not t.affs[limb:gsub(" ","_").."_mangled"]
  414.         and t.restoring ~= limb
  415.         then
  416.             targetLimb = limb
  417.             break
  418.         end
  419.  
  420.         if limb ~= lastParry and (not t.affs[limb:gsub(" ","_").."_mangled"] and parry ~= limb and t.restoring ~= limb)
  421.  
  422.         then
  423.             targetLimb = limb
  424.             break
  425.         end
  426.         end
  427.     end
  428.  
  429.     return targetLimb
  430.  
  431. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement