Dummy DPS npc

07/14/2022 22:51 chimot#1
hi, anyone have lua script for Dummy DPS npc?
07/25/2022 13:51 linian#2
require( "common" )

MemBlock = {}

function DpsDummy(Handle, MapIndex)
cExecCheck "DpsDummy"
local Var = MemBlock[Handle]

if Var == nil then -- 처음 리젠되었음
MemBlock[Handle] = {}
Var = MemBlock[Handle]
Var.Handle = Handle
Var.MapIndex = MapIndex
Var.CurSec = cCurrentSecond()
Var.Sec1 = 0
Var.Sec2 = 0
Var.I = 0
Var.MaxHP = cObjectHP( Handle )
end

local hp = cObjectHP( Handle )

if Var.MaxHP ~= hp and Var.I == 0 then
Var.Sec1 = cCurrentSecond()
Var.Sec2 = cCurrentSecond()
Var.I = 1
end

local DPS = (Var.MaxHP - hp) / (Var.CurSec - Var.Sec1)

if Var.I == 1 then
if Var.Sec2 + 1 < cCurrentSecond() then
cNPCChatTest ( Handle, "DPS: " .. (string.format("%.2f" , DPS) ))
Var.Sec2 = cCurrentSecond()
end
end

if Var.MaxHP == hp and Var.I == 1 then
Var.I = 0
end

if Var.CurSec + 0.5 > cCurrentSecond() then
return
else
Var.CurSec = cCurrentSecond()
end
end