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

Help with my Dodge Script (a few fixes)

Tecosan

Member
Joined
Oct 28, 2008
Messages
133
Reaction score
15
Hello, I'm trying to improve the well known script of Dodge.

It's pretty simple. Formerly, this script allows you to "avoid" part of the damage. It works as a new skill.
It reads x storage but that doesn't matter because the scripts works.

You have to skill up, so:
Storage X: 1
Storage X: 2 (the value of the storage is the skill level)

What I want to do is to increase the damage that you do if you have Dodge at level 100:
Please help me to fix my script.

PHP:
local lvldodge = 48902
local percent = 0.5
local chance_percent = 30
local extra_damage_percent = 250

function onStatsChange(cid, attacker, type, combat, value)
if type == STATSCHANGE_HEALTHLOSS and isCreature(attacker) then
if (getPlayerStorageValue(cid, lvldodge)*3) >= math.random (0,1000) then
value = math.ceil(value*(percent))
doTargetCombatHealth(attacker, cid, combat, -value, -value, 255)
doCreatureSay(cid, "DODGE", TALKTYPE_ORANGE_1)
if type ~= STATSCHANGE_HEALTHLOSS then
if getPlayerStorageValue(cid, lvldodge) == 100 and getPlayerStorageValue(cid, 71257) < 1 then
      if math.random(100) <= chance_percent then
         local dmg = value * (extra_damage_percent / 100)
         setPlayerStorageValue(cid, 71257, 1)
         doTargetCombatHealth(attacker, cid, type, -dmg, -dmg, 255)
         setPlayerStorageValue(cid, 71257, -1)
         doCreatureSay(cid, "CRITICAL", TALKTYPE_ORANGE_1)
         return false
      end
   end
end
end
end


return true
end
 
Honestly,I Would do it in Source, Game.cpp would be done much better than in lua, since dmgs and hits are handled mostly in source so would look terrible to see double DMG, or More dmg but different in text and Such but ya however here you are
Code:
doTargetCombatHealth(attacker, cid, combat, -value, -value, 255)
Line..10
Compare Those Lines..
line..17
Code:
 doTargetCombatHealth(attacker, cid, type, -dmg, -dmg, 255)

In the first one, you are returning the 3rd parameter as CombatType While in second its type, try
Code:
 local lvldodge = 48902
local percent = 0.5
local chance_percent = 30
local extra_damage_percent = 250

function onStatsChange(cid, attacker, type, combat, value)
if type == STATSCHANGE_HEALTHLOSS and isCreature(attacker) then
if (getPlayerStorageValue(cid, lvldodge)*3) >= math.random (0,1000) then
value = math.ceil(value*(percent))
doTargetCombatHealth(attacker, cid, combat, -value, -value, 255)
doCreatureSay(cid, "DODGE", TALKTYPE_ORANGE_1)
if type ~= STATSCHANGE_HEALTHLOSS then
if getPlayerStorageValue(cid, lvldodge) == 100 and getPlayerStorageValue(cid, 71257) < 1 then
  if math.random(100) <= chance_percent then
  local dmg = value * (extra_damage_percent / 100)
  setPlayerStorageValue(cid, 71257, 1)
  doTargetCombatHealth(attacker, cid, combat, -dmg, -dmg, 255)
  setPlayerStorageValue(cid, 71257, -1)
  doCreatureSay(cid, "CRITICAL", TALKTYPE_ORANGE_1)
  return false
  end
  end
end
end
end


return true
end

if it didn't Work, Then you can try
Code:
doCreatureAddHealth(cid,-dmg)
 
Back
Top