• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Little help with attack damage

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?
 
Afaik, you cannot change it through XML the way you are suggesting.

You could make an onStatsChange check and increase the amount of damage you do based on your resetcount like that - or you could change it in sources (harder to add, but less buggy, cleaner and less resource-intensive).
 
Hmm, onStatsChange is a source built-in function? i was checking lua functions for things like that and still nothing...

but i'll try to do it that way, thanks anyway :), still needing help if someone could help me ;p

---edit----
should it be something like this?
Code:
onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and attacker == cid then
		COMBAT_PHYSICALDAMAGE = COMBAT_PHYSICALDAMAGE + COMBAT_PHYSICALDAMAGE*((db.getResult("SELECT `reset` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";"))/2
	end
end
 
Last edited:
Hmm, onStatsChange is a source built-in function? i was checking lua functions for things like that and still nothing...

but i'll try to do it that way, thanks anyway :), still needing help if someone could help me ;p

---edit----
should it be something like this?
LUA:
onStatsChange(cid, attacker, type, combat, value)
	if type == STATSCHANGE_HEALTHLOSS and attacker == cid then
		COMBAT_PHYSICALDAMAGE = COMBAT_PHYSICALDAMAGE + COMBAT_PHYSICALDAMAGE*((db.getResult("SELECT `reset` FROM `players` WHERE `id`= "..getPlayerGUID(cid)..";"))/2
	end
end

First, use LUA tags instead of CODE tags - makes it much easier to read.
Second, you need to set a storage value which clears after the real hit so it doesn't infintely increase the damage dealt.
Third, what if they do fire damage or another type of damage?
Fourth, you're misunderstanding the parameter 'attacker' and most likely misusing 'cid' if you're trying to do this the way I think you are.

Not sure exactly what attacker returns since I'm not at my home computer, but try this:
LUA:
onStatsChange(cid, attacker, type, combat, value)
   local storage = 13337
   if((type == STATSCHANGE_HEALTHLOSS) and (isPlayer(attacker.uid)) and (getPlayerStorageValue(attacker.uid, 13337) ~= -1) then
      value = value -- +however much extra you want to add, not sure if that database query is correct or not
      doPlayerSetStorageValue(attacker.uid, 13337, 1)
   else
      if(isPlayer(attacker.uid)) then
         doPlayerSetStorageValue(attacker.uid, 13337, -1)
      end
      return true
   end
end
 
Last edited by a moderator:
Back
Top