vine96
Member
- Joined
- Nov 17, 2012
- Messages
- 82
- Reaction score
- 9
Hello everyone!
I madding one script to upgrade the wands e rods, it is functional. I made using the storages, but... how i simplify this code, is possible?
I madding one script to upgrade the wands e rods, it is functional. I made using the storages, but... how i simplify this code, is possible?
Post automatically merged:
Lua:
local min = 100
local max = 100
local storage = 722656
local aumento = 10
local function getMinDamage(level, magLevel)
local min = ((level * 1.05) + (magLevel * 1.00))
local naturalDamage = math.random(-30,45)
min = min + naturalDamage
if min < 1100 then
--min = 1100
end
return math.floor(min)
end
local function getMaxDamage(level, magLevel)
local max = ((level * 1.05) + (magLevel * 1.00))
local naturalDamage = math.random(-20,45)
max = max + naturalDamage
if max < 1100 then
--max = 1100
end
return math.ceil(max)
end
local effects = {
[10] = {dist = CONST_ANI_ICE, hit = CONST_ME_ICEATTACK, dmg = COMBAT_ICEDAMAGE},
[11] = {dist = CONST_ANI_EARTH, hit = CONST_ME_CARNIPHILA, dmg = COMBAT_POISONDAMAGE},
[12] = {dist = CONST_ANI_HOLY, hit = CONST_ME_HOLYDAMAGE, dmg = COMBAT_HOLYDAMAGE},
[13] = {dist = CONST_ANI_ENERGYBALL, hit = CONST_ME_PURPLEENERGY, dmg = COMBAT_ENERGYDAMAGE},
[14] = {dist = CONST_ANI_CAKE, hit = CONST_ME_CAKE, dmg = COMBAT_DROWNDAMAGE},
[15] = {dist = CONST_ANI_FIRE, hit = CONST_ME_FIREATTACK, dmg = COMBAT_FIREDAMAGE},
[16] = {dist = CONST_ANI_SUDDENDEATH, hit = CONST_ME_MORTAREA, dmg = COMBAT_DEATHDAMAGE}
}
function onUseWeapon(cid, var)
local level, magLevel = getPlayerLevel(cid), getPlayerMagLevel(cid)
--local min, max = getMinDamage(level, magLevel), getMaxDamage(level, magLevel)
local sto = getCreatureStorage(cid, storage)
if not effects[sto] then
sto = 14;
end
local target = variantToNumber(var)
if isCreature(target) then
doSendDistanceShoot(getThingPos(cid), getThingPos(target), effects[sto].dist)
if (getPlayerStorageValue(cid, 55001) > 0 and getPlayerStorageValue(cid, 55001) < 2) then
contaMin = min + (min/100) * aumento
contaMax = max + (max/100) * aumento
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 1 and getPlayerStorageValue(cid, 55001) < 3) then
contaMin = min + (min/100) * (aumento*2)
contaMax = max + (max/100) * (aumento*2)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 2 and getPlayerStorageValue(cid, 55001) < 4) then
contaMin = min + (min/100) * (aumento*3)
contaMax = max + (max/100) * (aumento*3)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 3 and getPlayerStorageValue(cid, 55001) < 5) then
contaMin = min + (min/100) * (aumento*4)
contaMax = max + (max/100) * (aumento*4)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 4 and getPlayerStorageValue(cid, 55001) < 6) then
contaMin = min + (min/100) * (aumento*5)
contaMax = max + (max/100) * (aumento*5)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 5 and getPlayerStorageValue(cid, 55001) < 7) then
contaMin = min + (min/100) * (aumento*6)
contaMax = max + (max/100) * (aumento*6)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 6 and getPlayerStorageValue(cid, 55001) < 8) then
contaMin = min + (min/100) * (aumento*7)
contaMax = max + (max/100) * (aumento*7)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 7 and getPlayerStorageValue(cid, 55001) < 9) then
contaMin = min + (min/100) * (aumento*8)
contaMax = max + (max/100) * (aumento*8)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 8 and getPlayerStorageValue(cid, 55001) < 10) then
contaMin = min + (min/100) * (aumento*9)
contaMax = max + (max/100) * (aumento*9)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
elseif (getPlayerStorageValue(cid, 55001) > 9 and getPlayerStorageValue(cid, 55001) < 11) then
contaMin = min + (min/100) * (aumento*10)
contaMax = max + (max/100) * (aumento*10)
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -contaMin, -contaMax, effects[sto].hit)
else
doAreaCombatHealth(cid, effects[sto].dmg, getThingPos(target), 0, -min, -max, effects[sto].hit)
end
end
return true
end