oen432
Legendary OT User
Is it showing current DPS?Doesn't seem to be the issue, I am using fresh tfs database and tried with different characters, Also cleared the storages atplayer_storage
but still doesn't show damage record.
Is it showing current DPS?Doesn't seem to be the issue, I am using fresh tfs database and tried with different characters, Also cleared the storages atplayer_storage
but still doesn't show damage record.
As long as you deal damage in 1 second duration, it's included in your DPS (for whatever combo you just used) because you just dealt X damage in 1 second, no matter at which point of that second. If you want to calculate DPS for your weapon damage or spell damage, then it would be calculated differently ((minDamage + maxDamage) / 2 / speed, where speed is Attack Speed or Spells cooldown).Great script, thank you.
Just a doubt, because shouldn't a DPS calculator split the damage on lets say 30 seconds and during that past time calculate the damage per second?
because now it prints every 1 second and the last damage during that time, right?
had the same issue the values was written in negative even he added player_dps * -1 but it should be added like thisIt works but it doesn't show new DPS record, I didn't edit it at all just copied everything to latest TFS, will never get new record for negative values it your issue like mine this should work proberly.
DPS_STORAGE = 26545
PLAYER_DPS = {}
PLAYER_EVENTS = {}
function ReadDPS(pid, cid)
local player = Player(pid)
local target = Monster(cid)
if player and target then
if PLAYER_DPS[pid] < 1 then
PLAYER_DPS[pid] = PLAYER_DPS[pid] * -1
end
if PLAYER_DPS[pid] > player:getStorageValue(DPS_STORAGE) then
player:setStorageValue(DPS_STORAGE, PLAYER_DPS[pid])
target:say(string.format("New Record! DPS: %d", PLAYER_DPS[pid]), TALKTYPE_MONSTER_SAY, false, player, target:getPosition())
else
target:say(string.format("DPS: %d", PLAYER_DPS[pid]), TALKTYPE_MONSTER_SAY, false, player, target:getPosition())
end
PLAYER_DPS[pid] = 0
PLAYER_EVENTS[pid] = nil
end
end
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
if not creature then return primaryDamage, primaryType, secondaryDamage, secondaryType end
if not attacker then return primaryDamage, primaryType, secondaryDamage, secondaryType end
if creature:isMonster() and attacker:isPlayer() then
if creature:getName() == "Training Monk" then
local damage = primaryDamage + secondaryDamage
local pid = attacker:getId()
if not PLAYER_DPS[pid] then PLAYER_DPS[pid] = 0 end
PLAYER_DPS[pid] = PLAYER_DPS[pid] + damage
if not PLAYER_EVENTS[pid] then
PLAYER_EVENTS[pid] = addEvent(ReadDPS, 1000, pid, creature:getId())
end
end
end
return primaryDamage, primaryType, secondaryDamage, secondaryType
end
if PLAYER_DPS[pid] < 1 then PLAYER_DPS[pid] = PLAYER_DPS[pid] * -1 end
tried to do that worked till server restarted and values came negative again, i didn't understand the reason but with this if statement worked well.Remove this linePLAYER_DPS[pid] = PLAYER_DPS[pid] * -1
if PLAYER_DPS[pid] < 1 then PLAYER_DPS[pid] = PLAYER_DPS[pid] * -1 end
The thing is, TFS is using negative values when you deal damage, that's why I had dps * -1 so it won't be throwing DPS text with negative values. For me it was always working, maybe some TFS versions have a bug or someone made spells damage calculation not returning negative values which is causing damage to be positive values.I don't get whatwould do here @Shadow_,Lua:if PLAYER_DPS[pid] < 1 then PLAYER_DPS[pid] = PLAYER_DPS[pid] * -1 end
so if player_dps is 0, you multiple it with -1? and its value becomes 0? ...
or if the player_dps is -1, and you multiple it with -1 it will become +1 because double negatives becomes positive.
its all confusing, what is that line doing?
ChangeHey, ive done this by 1:1 step and dps wont appear.
Any suggestions? (otservBR TFS 1.3)
PLAYER_DPS[pid] = PLAYER_DPS[pid] * -1
toif PLAYER_DPS[pid] < 1 then
PLAYER_DPS[pid] = PLAYER_DPS[pid] * -1
end
Add beforewhere do I exactly set the step 7?
6. Find function Creature: onTargetCombat(target) (found already)
7. Add before return RETURNVALUE_NOERROR
return true