• 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!

Increase damage per storage

felipemko

New Member
Joined
Mar 2, 2010
Messages
173
Reaction score
3
Hi everyone,
You could help me? I need something like when a player do Quest or Task won a storage that increase % melee damage/distance damage and spell
 
@Elgenady Can you help me with a completation of this script? I use a critical system but when the critical the damage that return it is absurd when there is often storage that we put in the source

Example:
Player without damage from the storage that added in sources normaly hits 3000 and critical 4500 (max critical increase +50%) = its ok.
Player with +150% damage from the storage that added in sources normaly hits 4500 and get critical 20k+ (instead 4500+50% = 6750)

Lua:
local lvlcrit = 48913

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS)  then
        if (getPlayerStorageValue(attacker, lvlcrit)*0.85) >= math.random (0,1000) then
            local multiplier = isPlayer(cid) and 2.5 or 1.5
            dano = math.ceil(value*(multiplier))
            doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
            doSendMagicEffect(getCreaturePos(cid), 64)
        return false
        end
    end
return true
end
 
Last edited:
@Elgenady Can you help me with a completation of this script? I use a critical system but when the critical the damage that return it is absurd when there is often storage that we put in the source

Example:
Player without damage from the storage that added in sources normaly hits 3000 and critical 4500 (max critical increase +50%) = its ok.
Player with +150% damage from the storage that added in sources normaly hits 4500 and get critical 20k+ (instead 4500+50% = 6750)

Lua:
local lvlcrit = 48913

function onStatsChange(cid, attacker, type, combat, value)
    if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS)  then
        if (getPlayerStorageValue(attacker, lvlcrit)*0.85) >= math.random (0,1000) then
            local multiplier = isPlayer(cid) and 2.5 or 1.5
            dano = math.ceil(value*(multiplier))
            doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
            doSendMagicEffect(getCreaturePos(cid), 64)
        return false
        end
    end
return true
end
Let's start by printing to console some values, to see where the issue is.
Lua:
local lvlcrit = 48913

function onStatsChange(cid, attacker, type, combat, value)
	print("--------")
	if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS)  then
		if (getPlayerStorageValue(attacker, lvlcrit)*0.85) >= math.random (0,1000) then
			local multiplier = isPlayer(cid) and 2.5 or 1.5
			dano = math.ceil(value*(multiplier))
			print("value: " .. value)
			print("multiplier: " .. multiplier)
			print("dano: " .. dano)
			doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
			doSendMagicEffect(getCreaturePos(cid), 64)
			return false
		end
	end
	return true
end
 
Let's start by printing to console some values, to see where the issue is.
Lua:
local lvlcrit = 48913

function onStatsChange(cid, attacker, type, combat, value)
    print("--------")
    if isPlayer(attacker) and (not (attacker == cid)) and (type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS)  then
        if (getPlayerStorageValue(attacker, lvlcrit)*0.85) >= math.random (0,1000) then
            local multiplier = isPlayer(cid) and 2.5 or 1.5
            dano = math.ceil(value*(multiplier))
            print("value: " .. value)
            print("multiplier: " .. multiplier)
            print("dano: " .. dano)
            doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
            doSendMagicEffect(getCreaturePos(cid), 64)
            return false
        end
    end
    return true
end

There is, looks like sometime the damage accumulate



1621466985025.png1621467088598.png

but pay attention, when this damage accumulates they are the same attack, they are not followed
as below, all these return are from just 1 attack, not 5 in a row
1621467497883.png
 
Last edited:
There is, looks like sometime the damage accumulate



View attachment 58915View attachment 58916

but pay attention, when this damage accumulates they are the same attack, they are not followed
as below, all these return are from just 1 attack, not 5 in a row
View attachment 58917
Mmm gotcha.

So this is a feedback loop caused by returning the new damage and allowing it to go through the same statschange script as before.
Since it's going through a 2nd/3rd/4th time, it continues to multiply the damage everytime the critical 'hits'.

What we need to do is make sure that the system cannot infinitely loop the critical damage calculations.

So what we'll do is create a table to hold creature information, and verify if the damage needs to be multiplied, or applied to the creature.

Something like this, should work.
Lua:
local lvlcrit = 48913
local creatures = {}

function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
		if creatures[cid] and creatures[cid] == 1 then -- here we check if the damage was multiplied previously
			creatures[cid] = 0 -- if yes, we reset the check so the next damage to come through has a chance of being multiplied
			return true -- and here we say yes, do the damage
		end
		if isPlayer(attacker) and attacker ~= cid then
			if getPlayerStorageValue(attacker, lvlcrit) * 0.85 >= math.random (1000) then
				local multiplier = isPlayer(cid) and 2.5 or 1.5
				dano = math.ceil(value*(multiplier))
				doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255) -- we send the new damage to cid
				doSendMagicEffect(getCreaturePos(cid), 64)
				creatures[cid] = 1 -- here we hold the creature information, saying that the damage was multiplied
				return false -- we deny the original damage by returning false
			end
		end
	end
	return true
end
 
Mmm gotcha.

So this is a feedback loop caused by returning the new damage and allowing it to go through the same statschange script as before.
Since it's going through a 2nd/3rd/4th time, it continues to multiply the damage everytime the critical 'hits'.

What we need to do is make sure that the system cannot infinitely loop the critical damage calculations.

So what we'll do is create a table to hold creature information, and verify if the damage needs to be multiplied, or applied to the creature.

Something like this, should work.
Lua:
local lvlcrit = 48913
local creatures = {}

function onStatsChange(cid, attacker, type, combat, value)
    if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
        if creatures[cid] and creatures[cid] == 1 then -- here we check if the damage was multiplied previously
            creatures[cid] = 0 -- if yes, we reset the check so the next damage to come through has a chance of being multiplied
            return true -- and here we say yes, do the damage
        end
        if isPlayer(attacker) and attacker ~= cid then
            if getPlayerStorageValue(attacker, lvlcrit) * 0.85 >= math.random (1000) then
                local multiplier = isPlayer(cid) and 2.5 or 1.5
                dano = math.ceil(value*(multiplier))
                doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255) -- we send the new damage to cid
                doSendMagicEffect(getCreaturePos(cid), 64)
                creatures[cid] = 1 -- here we hold the creature information, saying that the damage was multiplied
                return false -- we deny the original damage by returning false
            end
        end
    end
    return true
end

The same thing
1621472184430.png
 
I restarted, i added the prints to your code to see the damages because dont work =/
I really have no idea how it's not working. xD

I added more prints, I guess.

Lua:
local lvlcrit = 48913
local creatures = {}

function onStatsChange(cid, attacker, type, combat, value)
	if not creatures[cid] then
		creatures[cid] = 0
	end
	print("------")
	print("cid: " .. cid)
	print("attacker: " .. attacker)
	if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
		print("creatures[cid] = " .. creatures[cid])
		if creatures[cid] and creatures[cid] == 1 then
			print("Critical damage delivered.")
			creatures[cid] = 0
			return true
		end
		if isPlayer(attacker) and attacker ~= cid then
			if getPlayerStorageValue(attacker, lvlcrit) * 0.85 >= math.random (1000) then
				print("Critical damage succeeded.")
				local multiplier = isPlayer(cid) and 2.5 or 1.5
				dano = math.ceil(value*(multiplier))
				doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
				doSendMagicEffect(getCreaturePos(cid), 64)
				creatures[cid] = 1
				print("initial value: " .. value)
				print("multiplier: " .. multiplier)
				print("damage to be applied: " .. dano)
				return false
			else
				print("Critical failed.")
			end
		else
			print("Not a player attacking.")
		end
	end
	return true
end
 
I really have no idea how it's not working. xD

I added more prints, I guess.

Lua:
local lvlcrit = 48913
local creatures = {}

function onStatsChange(cid, attacker, type, combat, value)
    if not creatures[cid] then
        creatures[cid] = 0
    end
    print("------")
    print("cid: " .. cid)
    print("attacker: " .. attacker)
    if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
        print("creatures[cid] = " .. creatures[cid])
        if creatures[cid] and creatures[cid] == 1 then
            print("Critical damage delivered.")
            creatures[cid] = 0
            return true
        end
        if isPlayer(attacker) and attacker ~= cid then
            if getPlayerStorageValue(attacker, lvlcrit) * 0.85 >= math.random (1000) then
                print("Critical damage succeeded.")
                local multiplier = isPlayer(cid) and 2.5 or 1.5
                dano = math.ceil(value*(multiplier))
                doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
                doSendMagicEffect(getCreaturePos(cid), 64)
                creatures[cid] = 1
                print("initial value: " .. value)
                print("multiplier: " .. multiplier)
                print("damage to be applied: " .. dano)
                return false
            else
                print("Critical failed.")
            end
        else
            print("Not a player attacking.")
        end
    end
    return true
end
1621475382586.png
 
Try this.
Lua:
local lvlcrit = 48913
local creatures = {}

function onStatsChange(cid, attacker, type, combat, value)
	if not creatures[cid] then
		creatures[cid] = 0
	end
	print("------")
	print("cid: " .. cid)
	print("attacker: " .. attacker)
	if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
		print("creatures[cid] = " .. creatures[cid])
		if creatures[cid] and creatures[cid] == 1 then
			print("Critical damage delivered.")
			creatures[cid] = 0
			return true
		end
		if isPlayer(attacker) and attacker ~= cid then
			if getPlayerStorageValue(attacker, lvlcrit) * 0.85 >= math.random (1000) then
				creatures[cid] = 1
				print("Critical damage succeeded.")
				local multiplier = isPlayer(cid) and 2.5 or 1.5
				dano = math.ceil(value*(multiplier))
				doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
				doSendMagicEffect(getCreaturePos(cid), 64)
				print("initial value: " .. value)
				print("multiplier: " .. multiplier)
				print("damage to be applied: " .. dano)
				return false
			else
				print("Critcal failed.")
			end
		else
			print("Not a player attacking.")
		end
	end
	return true
end
 
Try this.
Lua:
local lvlcrit = 48913
local creatures = {}

function onStatsChange(cid, attacker, type, combat, value)
    if not creatures[cid] then
        creatures[cid] = 0
    end
    print("------")
    print("cid: " .. cid)
    print("attacker: " .. attacker)
    if type == STATSCHANGE_HEALTHLOSS or type == STATSCHANGE_MANALOSS then
        print("creatures[cid] = " .. creatures[cid])
        if creatures[cid] and creatures[cid] == 1 then
            print("Critical damage delivered.")
            creatures[cid] = 0
            return true
        end
        if isPlayer(attacker) and attacker ~= cid then
            if getPlayerStorageValue(attacker, lvlcrit) * 0.85 >= math.random (1000) then
                creatures[cid] = 1
                print("Critical damage succeeded.")
                local multiplier = isPlayer(cid) and 2.5 or 1.5
                dano = math.ceil(value*(multiplier))
                doTargetCombatHealth(attacker, cid, combat, -dano, -dano, 255)
                doSendMagicEffect(getCreaturePos(cid), 64)
                print("initial value: " .. value)
                print("multiplier: " .. multiplier)
                print("damage to be applied: " .. dano)
                return false
            else
                print("Critcal failed.")
            end
        else
            print("Not a player attacking.")
        end
    end
    return true
end

It seems that "fixed" but the critics are not respecting the 50%, an attack that was supposed to be normal 4k and critical 6k, in fact it is being critical 12k. I'm testing in a training monk.

1621520055437.png

Like this, the correct damage 14373 but got on traijner 32339
Now its because the script from the topic when storage added more damage, without the storage the critical its ok, but when i add on character the critical damage is overpowered
 
Last edited:
Back
Top