Advertisement
Guest User

HealthPoint

a guest
Dec 23rd, 2015
2
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.19 KB | None | 0 0
  1. local HealthPoint = {}
  2.  local pNPC = loadSharedAPI("pnpc")
  3.  local graphX = loadSharedAPI("graphX")
  4.  
  5.  
  6.  function HealthPoint.onInitAPI() --Is called when the api is loaded by loadAPI.
  7.         registerEvent(HealthPoint, "onLoop", "assign", true) --Register the loop event
  8.         registerEvent(HealthPoint, "onNPCKill", "onNPCKill", true) --Register the damage event      
  9. end
  10.  
  11.  
  12.  -- Health --
  13.  -- Change these values corresponding to the id inside the [] to change the enemy's health --
  14.   HealthPoint.npcHealth = {}
  15.   HealthPoint.npcHealth[1] = 3
  16.   HealthPoint.npcHealth[2] = 3
  17.   HealthPoint.npcHealth[3] = 3
  18.   HealthPoint.npcHealth[8] = 3
  19.   HealthPoint.npcHealth[17] = 3
  20.   HealthPoint.npcHealth[18] = 3
  21.   HealthPoint.npcHealth[27] = 3
  22.   HealthPoint.npcHealth[28] = 3
  23.   HealthPoint.npcHealth[29] = 3
  24.   HealthPoint.npcHealth[47] = 3
  25.   HealthPoint.npcHealth[50] = 3
  26.   HealthPoint.npcHealth[51] = 3
  27.   HealthPoint.npcHealth[52] = 3
  28.   HealthPoint.npcHealth[55] = 3
  29.   HealthPoint.npcHealth[71] = 3
  30.   HealthPoint.npcHealth[77] = 3
  31.   HealthPoint.npcHealth[89] = 3
  32.   HealthPoint.npcHealth[93] = 3
  33.   HealthPoint.npcHealth[117] = 3
  34.   HealthPoint.npcHealth[118] = 3
  35.   HealthPoint.npcHealth[119] = 3
  36.   HealthPoint.npcHealth[120] = 3
  37.   HealthPoint.npcHealth[125] = 3
  38.   HealthPoint.npcHealth[126] = 3
  39.   HealthPoint.npcHealth[127] = 3
  40.   HealthPoint.npcHealth[128] = 3
  41.   HealthPoint.npcHealth[162] = 3
  42.   HealthPoint.npcHealth[163] = 3
  43.   HealthPoint.npcHealth[203] = 3
  44.   HealthPoint.npcHealth[204] = 3
  45.   HealthPoint.npcHealth[205] = 3
  46.   HealthPoint.npcHealth[232] = 3
  47.   HealthPoint.npcHealth[233] = 3
  48.   HealthPoint.npcHealth[234] = 3
  49.   HealthPoint.npcHealth[235] = 3
  50.   HealthPoint.npcHealth[236] = 3
  51.   HealthPoint.npcHealth[242] = 3
  52.   HealthPoint.npcHealth[243] = 3
  53.   HealthPoint.npcHealth[245] = 3
  54.   HealthPoint.npcHealth[270] = 3
  55.   HealthPoint.npcHealth[271] = 3
  56.   HealthPoint.npcHealth[275] = 3
  57.  
  58.  -- Jump Damage --
  59.   HealthPoint.jumpDamage = {}
  60.   HealthPoint.jumpDamage[1] = 1
  61.   HealthPoint.jumpDamage[2] = 1
  62.   HealthPoint.jumpDamage[3] = 1
  63.   HealthPoint.jumpDamage[8] = 1
  64.   HealthPoint.jumpDamage[17] = 1
  65.   HealthPoint.jumpDamage[18] = 1
  66.   HealthPoint.jumpDamage[27] = 1
  67.   HealthPoint.jumpDamage[28] = 1
  68.   HealthPoint.jumpDamage[29] = 1
  69.   HealthPoint.jumpDamage[47] = 1
  70.   HealthPoint.jumpDamage[50] = 1
  71.   HealthPoint.jumpDamage[51] = 1
  72.   HealthPoint.jumpDamage[52] = 1
  73.   HealthPoint.jumpDamage[55] = 1
  74.   HealthPoint.jumpDamage[71] = 1
  75.   HealthPoint.jumpDamage[77] = 1
  76.   HealthPoint.jumpDamage[89] = 1
  77.   HealthPoint.jumpDamage[93] = 1
  78.   HealthPoint.jumpDamage[117] = 1
  79.   HealthPoint.jumpDamage[118] = 1
  80.   HealthPoint.jumpDamage[119] = 1
  81.   HealthPoint.jumpDamage[120] = 1
  82.   HealthPoint.jumpDamage[125] = 1
  83.   HealthPoint.jumpDamage[126] = 1
  84.   HealthPoint.jumpDamage[127] = 1
  85.   HealthPoint.jumpDamage[128] = 1
  86.   HealthPoint.jumpDamage[162] = 1
  87.   HealthPoint.jumpDamage[163] = 1
  88.   HealthPoint.jumpDamage[203] = 1
  89.   HealthPoint.jumpDamage[204] = 1
  90.   HealthPoint.jumpDamage[205] = 1
  91.   HealthPoint.jumpDamage[232] = 1
  92.   HealthPoint.jumpDamage[233] = 1
  93.   HealthPoint.jumpDamage[234] = 1
  94.   HealthPoint.jumpDamage[235] = 1
  95.   HealthPoint.jumpDamage[236] = 1
  96.   HealthPoint.jumpDamage[242] = 1
  97.   HealthPoint.jumpDamage[243] = 1
  98.   HealthPoint.jumpDamage[245] = 1
  99.   HealthPoint.jumpDamage[270] = 1
  100.   HealthPoint.jumpDamage[271] = 1
  101.   HealthPoint.jumpDamage[275] = 1
  102.  
  103.  -- Spinjump Damage --
  104.   HealthPoint.spinjumpDamage = {}
  105.   HealthPoint.spinjumpDamage[1] = 1
  106.   HealthPoint.spinjumpDamage[2] = 1
  107.   HealthPoint.spinjumpDamage[3] = 1
  108.   HealthPoint.spinjumpDamage[8] = 1
  109.   HealthPoint.spinjumpDamage[17] = 1
  110.   HealthPoint.spinjumpDamage[18] = 1
  111.   HealthPoint.spinjumpDamage[27] = 1
  112.   HealthPoint.spinjumpDamage[28] = 1
  113.   HealthPoint.spinjumpDamage[29] = 1
  114.   HealthPoint.spinjumpDamage[47] = 1
  115.   HealthPoint.spinjumpDamage[50] = 1
  116.   HealthPoint.spinjumpDamage[51] = 1
  117.   HealthPoint.spinjumpDamage[52] = 1
  118.   HealthPoint.spinjumpDamage[55] = 1
  119.   HealthPoint.spinjumpDamage[71] = 1
  120.   HealthPoint.spinjumpDamage[77] = 1
  121.   HealthPoint.spinjumpDamage[89] = 1
  122.   HealthPoint.spinjumpDamage[93] = 1
  123.   HealthPoint.spinjumpDamage[117] = 1
  124.   HealthPoint.spinjumpDamage[118] = 1
  125.   HealthPoint.spinjumpDamage[119] = 1
  126.   HealthPoint.spinjumpDamage[120] = 1
  127.   HealthPoint.spinjumpDamage[125] = 1
  128.   HealthPoint.spinjumpDamage[126] = 1
  129.   HealthPoint.spinjumpDamage[127] = 1
  130.   HealthPoint.spinjumpDamage[128] = 1
  131.   HealthPoint.spinjumpDamage[162] = 1
  132.   HealthPoint.spinjumpDamage[163] = 1
  133.   HealthPoint.spinjumpDamage[203] = 1
  134.   HealthPoint.spinjumpDamage[204] = 1
  135.   HealthPoint.spinjumpDamage[205] = 1
  136.   HealthPoint.spinjumpDamage[232] = 1
  137.   HealthPoint.spinjumpDamage[233] = 1
  138.   HealthPoint.spinjumpDamage[234] = 1
  139.   HealthPoint.spinjumpDamage[235] = 1
  140.   HealthPoint.spinjumpDamage[236] = 1
  141.   HealthPoint.spinjumpDamage[242] = 1
  142.   HealthPoint.spinjumpDamage[243] = 1
  143.   HealthPoint.spinjumpDamage[245] = 1
  144.   HealthPoint.spinjumpDamage[270] = 1
  145.   HealthPoint.spinjumpDamage[271] = 1
  146.   HealthPoint.spinjumpDamage[275] = 1
  147.  
  148.  -- Projectile Damage --
  149.   HealthPoint.projectileDamage = {}
  150.   HealthPoint.projectileDamage[1] = 1
  151.   HealthPoint.projectileDamage[2] = 1
  152.   HealthPoint.projectileDamage[3] = 1
  153.   HealthPoint.projectileDamage[8] = 1
  154.   HealthPoint.projectileDamage[17] = 1
  155.   HealthPoint.projectileDamage[18] = 1
  156.   HealthPoint.projectileDamage[27] = 1
  157.   HealthPoint.projectileDamage[28] = 1
  158.   HealthPoint.projectileDamage[29] = 1
  159.   HealthPoint.projectileDamage[47] = 1
  160.   HealthPoint.projectileDamage[50] = 1
  161.   HealthPoint.projectileDamage[51] = 1
  162.   HealthPoint.projectileDamage[52] = 1
  163.   HealthPoint.projectileDamage[55] = 1
  164.   HealthPoint.projectileDamage[71] = 1
  165.   HealthPoint.projectileDamage[77] = 1
  166.   HealthPoint.projectileDamage[89] = 1
  167.   HealthPoint.projectileDamage[93] = 1
  168.   HealthPoint.projectileDamage[117] = 1
  169.   HealthPoint.projectileDamage[118] = 1
  170.   HealthPoint.projectileDamage[119] = 1
  171.   HealthPoint.projectileDamage[120] = 1
  172.   HealthPoint.projectileDamage[125] = 1
  173.   HealthPoint.projectileDamage[126] = 1
  174.   HealthPoint.projectileDamage[127] = 1
  175.   HealthPoint.projectileDamage[128] = 1
  176.   HealthPoint.projectileDamage[162] = 1
  177.   HealthPoint.projectileDamage[163] = 1
  178.   HealthPoint.projectileDamage[203] = 1
  179.   HealthPoint.projectileDamage[204] = 1
  180.   HealthPoint.projectileDamage[205] = 1
  181.   HealthPoint.projectileDamage[232] = 1
  182.   HealthPoint.projectileDamage[233] = 1
  183.   HealthPoint.projectileDamage[234] = 1
  184.   HealthPoint.projectileDamage[235] = 1
  185.   HealthPoint.projectileDamage[236] = 1
  186.   HealthPoint.projectileDamage[242] = 1
  187.   HealthPoint.projectileDamage[243] = 1
  188.   HealthPoint.projectileDamage[245] = 1
  189.   HealthPoint.projectileDamage[270] = 1
  190.   HealthPoint.projectileDamage[271] = 1
  191.   HealthPoint.projectileDamage[275] = 1
  192.  
  193.  -- Tail Damage --
  194.   HealthPoint.tailDamage = {}
  195.   HealthPoint.tailDamage[1] = 1
  196.   HealthPoint.tailDamage[2] = 1
  197.   HealthPoint.tailDamage[3] = 1
  198.   HealthPoint.tailDamage[8] = 1
  199.   HealthPoint.tailDamage[17] = 1
  200.   HealthPoint.tailDamage[18] = 1
  201.   HealthPoint.tailDamage[27] = 1
  202.   HealthPoint.tailDamage[28] = 1
  203.   HealthPoint.tailDamage[29] = 1
  204.   HealthPoint.tailDamage[47] = 1
  205.   HealthPoint.tailDamage[50] = 1
  206.   HealthPoint.tailDamage[51] = 1
  207.   HealthPoint.tailDamage[52] = 1
  208.   HealthPoint.tailDamage[55] = 1
  209.   HealthPoint.tailDamage[71] = 1
  210.   HealthPoint.tailDamage[77] = 1
  211.   HealthPoint.tailDamage[89] = 1
  212.   HealthPoint.tailDamage[93] = 1
  213.   HealthPoint.tailDamage[117] = 1
  214.   HealthPoint.tailDamage[118] = 1
  215.   HealthPoint.tailDamage[119] = 1
  216.   HealthPoint.tailDamage[120] = 1
  217.   HealthPoint.tailDamage[125] = 1
  218.   HealthPoint.tailDamage[126] = 1
  219.   HealthPoint.tailDamage[127] = 1
  220.   HealthPoint.tailDamage[128] = 1
  221.   HealthPoint.tailDamage[162] = 1
  222.   HealthPoint.tailDamage[163] = 1
  223.   HealthPoint.tailDamage[203] = 1
  224.   HealthPoint.tailDamage[204] = 1
  225.   HealthPoint.tailDamage[205] = 1
  226.   HealthPoint.tailDamage[232] = 1
  227.   HealthPoint.tailDamage[233] = 1
  228.   HealthPoint.tailDamage[234] = 1
  229.   HealthPoint.tailDamage[235] = 1
  230.   HealthPoint.tailDamage[236] = 1
  231.   HealthPoint.tailDamage[242] = 1
  232.   HealthPoint.tailDamage[243] = 1
  233.   HealthPoint.tailDamage[245] = 1
  234.   HealthPoint.tailDamage[270] = 1
  235.   HealthPoint.tailDamage[271] = 1
  236.   HealthPoint.tailDamage[275] = 1
  237.  
  238.  -- Link Attack Damage --
  239.   HealthPoint.linkDamage = {}
  240.   HealthPoint.linkDamage[1] = 1
  241.   HealthPoint.linkDamage[2] = 1
  242.   HealthPoint.linkDamage[3] = 1
  243.   HealthPoint.linkDamage[8] = 1
  244.   HealthPoint.linkDamage[17] = 1
  245.   HealthPoint.linkDamage[18] = 1
  246.   HealthPoint.linkDamage[27] = 1
  247.   HealthPoint.linkDamage[28] = 1
  248.   HealthPoint.linkDamage[29] = 1
  249.   HealthPoint.linkDamage[47] = 1
  250.   HealthPoint.linkDamage[50] = 1
  251.   HealthPoint.linkDamage[51] = 1
  252.   HealthPoint.linkDamage[52] = 1
  253.   HealthPoint.linkDamage[55] = 1
  254.   HealthPoint.linkDamage[71] = 1
  255.   HealthPoint.linkDamage[77] = 1
  256.   HealthPoint.linkDamage[89] = 1
  257.   HealthPoint.linkDamage[93] = 1
  258.   HealthPoint.linkDamage[117] = 1
  259.   HealthPoint.linkDamage[118] = 1
  260.   HealthPoint.linkDamage[119] = 1
  261.   HealthPoint.linkDamage[120] = 1
  262.   HealthPoint.linkDamage[125] = 1
  263.   HealthPoint.linkDamage[126] = 1
  264.   HealthPoint.linkDamage[127] = 1
  265.   HealthPoint.linkDamage[128] = 1
  266.   HealthPoint.linkDamage[162] = 1
  267.   HealthPoint.linkDamage[163] = 1
  268.   HealthPoint.linkDamage[203] = 1
  269.   HealthPoint.linkDamage[204] = 1
  270.   HealthPoint.linkDamage[205] = 1
  271.   HealthPoint.linkDamage[232] = 1
  272.   HealthPoint.linkDamage[233] = 1
  273.   HealthPoint.linkDamage[234] = 1
  274.   HealthPoint.linkDamage[235] = 1
  275.   HealthPoint.linkDamage[236] = 1
  276.   HealthPoint.linkDamage[242] = 1
  277.   HealthPoint.linkDamage[243] = 1
  278.   HealthPoint.linkDamage[245] = 1
  279.   HealthPoint.linkDamage[270] = 1
  280.   HealthPoint.linkDamage[271] = 1
  281.   HealthPoint.linkDamage[275] = 1
  282.  
  283.   -- Thrown Damage --
  284.   HealthPoint.thrownDamage = {}
  285.   HealthPoint.thrownDamage[1] = 1
  286.   HealthPoint.thrownDamage[2] = 1
  287.   HealthPoint.thrownDamage[3] = 1
  288.   HealthPoint.thrownDamage[8] = 1
  289.   HealthPoint.thrownDamage[17] = 1
  290.   HealthPoint.thrownDamage[18] = 1
  291.   HealthPoint.thrownDamage[27] = 1
  292.   HealthPoint.thrownDamage[28] = 1
  293.   HealthPoint.thrownDamage[29] = 1
  294.   HealthPoint.thrownDamage[47] = 1
  295.   HealthPoint.thrownDamage[50] = 1
  296.   HealthPoint.thrownDamage[51] = 1
  297.   HealthPoint.thrownDamage[52] = 1
  298.   HealthPoint.thrownDamage[55] = 1
  299.   HealthPoint.thrownDamage[71] = 1
  300.   HealthPoint.thrownDamage[77] = 1
  301.   HealthPoint.thrownDamage[89] = 1
  302.   HealthPoint.thrownDamage[93] = 1
  303.   HealthPoint.thrownDamage[117] = 1
  304.   HealthPoint.thrownDamage[118] = 1
  305.   HealthPoint.thrownDamage[119] = 1
  306.   HealthPoint.thrownDamage[120] = 1
  307.   HealthPoint.thrownDamage[125] = 1
  308.   HealthPoint.thrownDamage[126] = 1
  309.   HealthPoint.thrownDamage[127] = 1
  310.   HealthPoint.thrownDamage[128] = 1
  311.   HealthPoint.thrownDamage[162] = 1
  312.   HealthPoint.thrownDamage[163] = 1
  313.   HealthPoint.thrownDamage[203] = 1
  314.   HealthPoint.thrownDamage[204] = 1
  315.   HealthPoint.thrownDamage[205] = 1
  316.   HealthPoint.thrownDamage[232] = 1
  317.   HealthPoint.thrownDamage[233] = 1
  318.   HealthPoint.thrownDamage[234] = 1
  319.   HealthPoint.thrownDamage[235] = 1
  320.   HealthPoint.thrownDamage[236] = 1
  321.   HealthPoint.thrownDamage[242] = 1
  322.   HealthPoint.thrownDamage[243] = 1
  323.   HealthPoint.thrownDamage[245] = 1
  324.   HealthPoint.thrownDamage[270] = 1
  325.   HealthPoint.thrownDamage[271] = 1
  326.   HealthPoint.thrownDamage[275] = 1
  327.  
  328.  
  329.  ----------------------------------------------------------------------------------------------
  330.  ---                            THE ACTUAL CODE STUFF                                       ---
  331.  ----------------------------------------------------------------------------------------------
  332.  
  333.  
  334.  
  335.  
  336.  ----------------------------------------------------------------------------------------------
  337.  ---                                 DAMAGE INPUT                                           ---
  338.  ----------------------------------------------------------------------------------------------
  339.  
  340.  function HealthPoint.onNPCKill(eventObj, killedNPC, killReason)
  341.  
  342.     if HealthPoint.npcHealth[killedNPC.id] ~= nil  then
  343.         local wrappedNPC = pNPC.wrap(killedNPC)
  344.            
  345.             if wrappedNPC.data.hit > 1 and wrappedNPC.data.hit > HealthPoint.jumpDamage[wrappedNPC.id] and killReason == 1 then
  346.                 eventObj.cancelled = true
  347.                 wrappedNPC:mem(0x156, FIELD_WORD, 20)
  348.                 wrappedNPC.data.hit = wrappedNPC.data.hit - HealthPoint.jumpDamage[wrappedNPC.id]
  349.  
  350.          
  351.             elseif wrappedNPC.data.hit > 1 and wrappedNPC.data.hit > HealthPoint.projectileDamage[wrappedNPC.id] and killReason == 3 then
  352.                 eventObj.cancelled = true
  353.                 wrappedNPC:mem(0x156, FIELD_WORD, 20)
  354.                 wrappedNPC.data.hit = wrappedNPC.data.hit - HealthPoint.projectileDamage[wrappedNPC.id]
  355.          
  356.          
  357.             elseif wrappedNPC.data.hit > 1 and wrappedNPC.data.hit > HealthPoint.thrownDamage[wrappedNPC.id] and   (killReason == 4 or killReason == 5) then
  358.                 eventObj.cancelled = true
  359.                 wrappedNPC:mem(0x156, FIELD_WORD, 20)
  360.                 wrappedNPC.data.hit = wrappedNPC.data.hit - HealthPoint.thrownDamage[wrappedNPC.id]
  361.          
  362.          
  363.             elseif wrappedNPC.data.hit > 1 and wrappedNPC.data.hit > HealthPoint.tailDamage[wrappedNPC.id] and killReason == 7 then
  364.                 eventObj.cancelled = true
  365.                 wrappedNPC:mem(0x156, FIELD_WORD, 20)
  366.                 wrappedNPC.data.hit = wrappedNPC.data.hit - HealthPoint.tailDamage[wrappedNPC.id]
  367.          
  368.          
  369.             elseif wrappedNPC.data.hit > 1 and wrappedNPC.data.hit > HealthPoint.spinjumpDamage[wrappedNPC.id] and killReason == 8 then
  370.                  eventObj.cancelled = true
  371.                  wrappedNPC:mem(0x156, FIELD_WORD, 20)
  372.                  wrappedNPC.data.hit = wrappedNPC.data.hit - HealthPoint.spinjumpDamage[wrappedNPC.id]
  373.  
  374.  
  375.             elseif wrappedNPC.data.hit > 1 and wrappedNPC.data.hit > HealthPoint.linkDamage[wrappedNPC.id] and killReason == 10 then
  376.                  eventObj.cancelled = true
  377.                  wrappedNPC:mem(0x156, FIELD_WORD, 20)
  378.                  wrappedNPC.data.hit = wrappedNPC.data.hit - HealthPoint.linkDamage[wrappedNPC.id]
  379.          
  380.          
  381.             end
  382.     end
  383.  end
  384.  
  385.  
  386.  
  387.  ----------------------------------------------------------------------------------------------
  388.  ---                              HEALTH ASSIGNMENT                                         ---
  389.  ----------------------------------------------------------------------------------------------
  390.  
  391.  function HealthPoint.assign()
  392.     for k,v in pairs(NPC.get()) do
  393.     local n = pNPC.wrap(v);
  394.    
  395.         if n.data.hit == nil then
  396.             if HealthPoint.npcHealth[n.id] ~= nil  then
  397.                 n.data.hit = HealthPoint.npcHealth[n.id]
  398.  
  399.             end
  400.         end
  401.        
  402.         if n.data.hp == nil then
  403.             if HealthPoint.npcHealth[n.id] ~= nil then
  404.                 n.data.hp = HealthPoint.npcHealth[n.id]
  405.  
  406.             end
  407.         end
  408.        
  409.         if n.data.hpmax == nil then
  410.             if HealthPoint.npcHealth[n.id] ~= nil then
  411.                 n.data.hpmax = HealthPoint.npcHealth[n.id]
  412.             end
  413.         end
  414.        
  415.         if n ~= nil and HealthPoint.healthbar then
  416.             if n:mem(0x12A, FIELD_WORD) ~= 0 and n.data.hp ~= nil then
  417.                 graphX.boxLevel (n.x-8,n.y-6, 32, 8,  0xFFFFFFF55)
  418.                 graphX.boxLevel (n.x-7,n.y-5, 30, 6,  0x00000055)
  419.                 graphX.boxLevel (n.x-7,n.y-5, n.data.hp/n.data.hpmax*30, 6,  0xFFF05BFF)
  420.                 graphX.boxLevel (n.x-7,n.y-5, n.data.hit/n.data.hpmax*30, 6,  0xF61818FF)
  421.  
  422.             end
  423.         end
  424.  
  425.  
  426.  
  427.         if n.data.hp ~= nil then
  428.             if n.data.hp > n.data.hit then
  429.                 n.data.hp = n.data.hp -0.02
  430.             end
  431.             if n.data.hit > n.data.hpmax then
  432.                 n.data.hit = n.data.hpmax
  433.             end
  434.         end
  435.     end
  436.  end
  437.  return HealthPoint
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement