• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua change dps for monsters

T

Tibia Demon

Guest
can someone help me convert this to check dps for monsters instead of players
i want to test monsters by (/summon) and attack dummy to get the dps
Lua:
local creatureevent = CreatureEvent("onHealthChange_Training_Dummy")

local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(playerID, monsterID)
    local player = Player(playerID)
    if player then
        player:say("Your DPS is " .. (math.floor((DPS_info[monsterID][playerID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY, false, player)
    end
    DPS_info[monsterID][playerID] = nil
end

function creatureevent.onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not Player(creature) then
        return false
    end
    
    local monsterID = monster:getId()
    local playerID = creature:getId()
    
    if not DPS_info[monsterID] then
        DPS_info[monsterID] = {}
    end
    
    if not DPS_info[monsterID][playerID] then
        addEvent(send_dps_info, dps_check_time * 1000, playerID, monsterID)
    end

    DPS_info[monsterID][playerID] = (DPS_info[monsterID][playerID] or 0) + primaryDamage + secondaryDamage
    monster:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS, creature)
    return false
end

creatureevent:register()
 
Solution
can someone help me convert this to check dps for monsters instead of players
i want to test monsters by (/summon) and attack dummy to get the dps
Lua:
local creatureevent = CreatureEvent("onHealthChange_Training_Dummy")

local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(playerID, monsterID)
    local player = Player(playerID)
    if player then
        player:say("Your DPS is " .. (math.floor((DPS_info[monsterID][playerID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY, false, player)
    end
    DPS_info[monsterID][playerID] = nil
end

function creatureevent.onHealthChange(monster...
can someone help me convert this to check dps for monsters instead of players
i want to test monsters by (/summon) and attack dummy to get the dps
Lua:
local creatureevent = CreatureEvent("onHealthChange_Training_Dummy")

local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(playerID, monsterID)
    local player = Player(playerID)
    if player then
        player:say("Your DPS is " .. (math.floor((DPS_info[monsterID][playerID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY, false, player)
    end
    DPS_info[monsterID][playerID] = nil
end

function creatureevent.onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    if not Player(creature) then
        return false
    end
 
    local monsterID = monster:getId()
    local playerID = creature:getId()
 
    if not DPS_info[monsterID] then
        DPS_info[monsterID] = {}
    end
 
    if not DPS_info[monsterID][playerID] then
        addEvent(send_dps_info, dps_check_time * 1000, playerID, monsterID)
    end

    DPS_info[monsterID][playerID] = (DPS_info[monsterID][playerID] or 0) + primaryDamage + secondaryDamage
    monster:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS, creature)
    return false
end

creatureevent:register()
Should work.
Lua:
local creatureevent = CreatureEvent("onHealthChange_Training_Dummy")

local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(creatureID, monsterID)
    local creature = Creature(creatureID)
    if creature then
        creature:say("Your DPS is " .. (math.floor((DPS_info[monsterID][creatureID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY)
    end
    DPS_info[monsterID][creatureID] = nil
end

function creatureevent.onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    local monsterID = monster:getId()
    local creatureID = creature:getId()
    
    if not DPS_info[monsterID] then
        DPS_info[monsterID] = {}
    end
    
    if not DPS_info[monsterID][creatureID] then
        addEvent(send_dps_info, dps_check_time * 1000, creatureID, monsterID)
    end

    DPS_info[monsterID][creatureID] = (DPS_info[monsterID][creatureID] or 0) + primaryDamage + secondaryDamage
    monster:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS, creature)
    return false
end

creatureevent:register()
 
Solution
work 100%
i have one question
are the calculations correct? it look strange
test with local dps_check_time = 1
Code:
Undead Dragon: Your DPS is 856.
Undead Dragon: Your DPS is 648.
Undead Dragon: Your DPS is 529.
Undead Dragon: Your DPS is 631.
Undead Dragon: Your DPS is 420.
Undead Dragon: Your DPS is 379.
Undead Dragon: Your DPS is 473.
Undead Dragon: Your DPS is 297.
Undead Dragon: Your DPS is 342.
Undead Dragon: Your DPS is 309.
test with local dps_check_time = 5
Code:
Undead Dragon: Your DPS is 260.
Undead Dragon: Your DPS is 206.
Undead Dragon: Your DPS is 270.
Undead Dragon: Your DPS is 86.
Undead Dragon: Your DPS is 262.
Undead Dragon: Your DPS is 174.
Undead Dragon: Your DPS is 156.
Undead Dragon: Your DPS is 156.
Undead Dragon: Your DPS is 232.
Undead Dragon: Your DPS is 269.
Undead Dragon: Your DPS is 107.
Undead Dragon: Your DPS is 466.
Undead Dragon: Your DPS is 86.
test with local dps_check_time = 600
Code:
Undead Dragon: Your DPS is 155.
Undead Dragon: Your DPS is 177.
Undead Dragon: Your DPS is 194.
Undead Dragon: Your DPS is 143.
Undead Dragon: Your DPS is 183.
Undead Dragon: Your DPS is 147.
Undead Dragon: Your DPS is 192.
Undead Dragon: Your DPS is 156.
 
work 100%
i have one question
are the calculations correct? it look strange
test with local dps_check_time = 1
Code:
Undead Dragon: Your DPS is 856.
Undead Dragon: Your DPS is 648.
Undead Dragon: Your DPS is 529.
Undead Dragon: Your DPS is 631.
Undead Dragon: Your DPS is 420.
Undead Dragon: Your DPS is 379.
Undead Dragon: Your DPS is 473.
Undead Dragon: Your DPS is 297.
Undead Dragon: Your DPS is 342.
Undead Dragon: Your DPS is 309.
test with local dps_check_time = 5
Code:
Undead Dragon: Your DPS is 260.
Undead Dragon: Your DPS is 206.
Undead Dragon: Your DPS is 270.
Undead Dragon: Your DPS is 86.
Undead Dragon: Your DPS is 262.
Undead Dragon: Your DPS is 174.
Undead Dragon: Your DPS is 156.
Undead Dragon: Your DPS is 156.
Undead Dragon: Your DPS is 232.
Undead Dragon: Your DPS is 269.
Undead Dragon: Your DPS is 107.
Undead Dragon: Your DPS is 466.
Undead Dragon: Your DPS is 86.
test with local dps_check_time = 600
Code:
Undead Dragon: Your DPS is 155.
Undead Dragon: Your DPS is 177.
Undead Dragon: Your DPS is 194.
Undead Dragon: Your DPS is 143.
Undead Dragon: Your DPS is 183.
Undead Dragon: Your DPS is 147.
Undead Dragon: Your DPS is 192.
Undead Dragon: Your DPS is 156.
It'll be kinda spammy, but I added a 'total damage' text.

Then you can do the math yourself, whenever it resets.
Total_Damage / dps_check_time = DPS

Lua:
local creatureevent = CreatureEvent("onHealthChange_Training_Dummy")

local dps_check_time = 5 -- how long in seconds until DPS is shown to player
local DPS_info = {}

local function send_dps_info(creatureID, monsterID)
    local creature = Creature(creatureID)
    if creature then
        creature:say("Your DPS is " .. (math.floor((DPS_info[monsterID][creatureID] / dps_check_time) + 0.5)) .. ".", TALKTYPE_MONSTER_SAY)
    end
    DPS_info[monsterID][creatureID] = nil
end

function creatureevent.onHealthChange(monster, creature, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    local monsterID = monster:getId()
    local creatureID = creature:getId()
    
    if not DPS_info[monsterID] then
        DPS_info[monsterID] = {}
    end
    
    if not DPS_info[monsterID][creatureID] then
        addEvent(send_dps_info, dps_check_time * 1000, creatureID, monsterID)
    end

    DPS_info[monsterID][creatureID] = (DPS_info[monsterID][creatureID] or 0) + primaryDamage + secondaryDamage
    creature:say("Total Damage: " .. DPS_info[monsterID][creatureID], TALKTYPE_MONSTER_SAY) -- to see total damage.
    monster:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS, creature)
    return false
end

creatureevent:register()
 
Back
Top