• 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 Attack damage base increase

Guiaki

Member
Joined
Jan 3, 2011
Messages
137
Reaction score
8
Hey, is there anyway to make a higher hitting damage with lua?

i have a reset system in my otserv, i wanted that when you reset you attack like +200 hit each attack or something with percent of your health/mana or even percent extra of your actual hitting?

as you can see in vocations.xml there is formula meleeDamage="1.0", is there anyway that i could change this to formula meleeDamage="1.0+reset/100" or something like that? or put in the reset script a code that will set your attack to be higher?

Icy told me i needed to use onStatsChange, but i don't know how to use it, i tought it woud be like this

Code:
onStatsChange(cid, attacker, type, combat, value)
        local reset = getReset(cid)
	if type == STATSCHANGE_HEALTHLOSS and attacker == cid then
		COMBAT_PHYSICALDAMAGE = COMBAT_PHYSICALDAMAGE + COMBAT_PHYSICALDAMAGE*(reset/5+1)
	end
end

I wanted that, when a player attack, the damage he will deal will be 20% extra * reset, the formula for this is (reset/5+1), but the thing is, if there is a way to change that to a meeledamage like in the vocation xml would be better, instead of changing every spell.

If someone just could tell me what i needed to do or how to use the onStatsChange, i would be glad

-----------EDIT--------------
For those who want the code its here:
Code:
function onStatsChange(cid, attacker, type, combat, value)
	local reset = getReset(cid)
	if type == STATSCHANGE_HEALTHLOSS then
		if combat == COMBAT_PHYSICALDAMAGE then
			if reset > 0 then
				local value = (value + value*((reset/5) + 1))
				doTargetCombatHealth(attacker, cid, combat, -value, -value, CONST_ME_DRAWBLOOD)
				return false
			end
		end
	end
	return true
end

The script was made by DarkHaos, thanks to him

add in creaturescripts.xml
Code:
 <event type="statschange" name="damageBaseIncrease" event="script" value="YOURSCRIPTNAME.lua"

add in login.lua
Code:
registerCreatureEvent(cid, "damageBaseIncrease")
 
Last edited:
not sure if it will work:
Lua:
function onStatsChange(cid, attacker, type, combat, value)
    local reset = getReset(cid)
	if type == STATSCHANGE_HEALTHLOSS then
		if combat == COMBAT_PHYSICALDAMAGE then
			if reset > 0  then
				return value = (value + value*((reset/5) + 1)) and true
			else
				return value and true
			end
		end
	end
end
 
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	local reset = getReset(cid)
	if type == STATSCHANGE_HEALTHLOSS then
		if combat == COMBAT_PHYSICALDAMAGE then
			if reset > 0 then
				local value = (value + value*((reset/5) + 1))
				doTargetCombatHealth(attacker, cid, combat, -value, -value, CONST_ME_DRAWBLOOD)
				return false
			end
		end
	end
	return true
end
 
Hey, thanks but its not working :S it don't results in error but it doesn't work ;/
-----edit-----
nvm, it works xD thanksss!!!
 
Last edited:
Register it at login.lua with:
Lua:
registerCreatureEvent(cid, "damageBaseIncrease")

And this at creaturescript.xml
XML:
	<event type="statschange" name="damageBaseIncrease" event="script" value="YOURSCRIPTNAME.lua"/>
 
I need help fast!! please, it worked and everthing but keeps popping up this in console:
[ERORR - CretureEvent::executeStatsChange] Call stack overflow.
 
Lua:
function onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and combat == COMBAT_PHYSICALDAMAGE and getCreatureStorage(cid, 5) == -1 then
		local reset = getReset(cid)
		if reset > 0 then
			value = value * (1 + reset / 5)
			doCreatureSetStorage(cid, 5, 1)
			doTargetCombatHealth(attacker, cid, COMBAT_PHYSICALDAMAGE, -value, -value, CONST_ME_NONE)
			doCreatureSetStorage(cid, 5)
			return
		end
	end
	return true
end
also corrected the formula
 
okay, it works but not in the way I wanted, it corrected the problem of the infinite looping, but if a monster attack me it will hit me a extra damage based on my resets, how can i change that?
 
Back
Top