• 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 Damage spell

Nith

New Member
Joined
Jan 11, 2009
Messages
13
Reaction score
0
good day, Could you help me on this?. I would like the damage to be fixed and not variable. this is supposed to hit 3 damage, but hit up to 15.

I have disabled the storages to see where that extra damage is coming from, but I can't find it.

I use The Forgotten Server, version 0.3.6 (Crying Damson) - Protocol 8.54

Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_FIREWORK_YELLOW)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_NONE )
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_EFEITO80)

function onGetFormulaValues2(cid, level)
    local alma = 0 ---getPlayerStorageValue(cid,60032)
    local elemento = 0 ---getPlayerStorageValue(cid,60005)
    local nspell = 0 ---getPlayerStorageValue(cid,70136)
    local arma = getPlayerStorageValue(cid,60263) --- is 2
    local base = 1 ---
    local buff = 0 ---getPlayerStorageValue(cid,62061)
    local result = alma + elemento + nspell + arma + base + buff
    return -result, -result
end

local arr1 = {
{0, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
}

local arr2 = {
{0, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
}


local area1 = createCombatArea(arr1)
local area2 = createCombatArea(arr2)

setCombatArea(combat1, area1)
setCombatArea(combat2, area2)

local function onCastSpell1(parameters)
    doCombat(parameters.cid, parameters.combat1, parameters.var)
end
local function onCastSpell2(parameters)
    doCombat(parameters.cid, parameters.combat2, parameters.var)
end

setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

function onCastSpell(cid, var)  

   local parameters = { cid = cid, var = var, combat1 = combat1, combat2 = combat2}
   if getPlayerStorageValue(cid,62054) == 1 then
      if getPlayerStorageValue(cid,70141) == 1 then
         if getPlayerStorageValue(cid,70143) == 1000 and getPlayerStorageValue(cid,70142) < 10 then
            setPlayerStorageValue(cid,70143,0)
            setPlayerStorageValue(cid,70142, getPlayerStorageValue(cid,70142)+1)
            onCastSpell1(parameters)
            addEvent(onCastSpell2, 800, parameters)
         elseif getPlayerStorageValue(cid,70143) < 1000 and  getPlayerStorageValue(cid,70142) < 10 then
            onCastSpell1(parameters)
            addEvent(onCastSpell2, 800, parameters)
            setPlayerStorageValue(cid,70143, getPlayerStorageValue(cid,70143)+1)
        elseif getPlayerStorageValue(cid,70143) == 0 and getPlayerStorageValue(cid,70142) == 10 then
            onCastSpell1(parameters)
            addEvent(onCastSpell2, 800, parameters)
         end
      else
         doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "(I)you don't have that magic - (P)voce nao tem essa magia - (E)no tienes este hechizo")
      end
   else
      doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "(I)you need a magic glove - (P)voce precisa de uma luva magica - (E)necesitas un guante magico")
   end  
return true
end

21.png
 

leo139

New Member
Joined
Dec 23, 2012
Messages
2
Solutions
1
Reaction score
1
Try it like this.


Lua:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_EFFECT, CONST_ME_FIREWORK_YELLOW)
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_NONE )
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_BOLT)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, CONST_ME_EFEITO80)

function onGetFormulaValues2(cid, level)
    local alma = 0 ---getPlayerStorageValue(cid,60032)
    local elemento = 0 ---getPlayerStorageValue(cid,60005)
    local nspell = 0 ---getPlayerStorageValue(cid,70136)
    local arma = getPlayerStorageValue(cid,60263) --- is 2
    local base = 1 ---
    local buff = 0 ---getPlayerStorageValue(cid,62061)
    local result = alma + elemento + nspell + arma + base + buff
    return -result, -result
end
setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues2")

local arr1 = {
{0, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
}

local arr2 = {
{0, 1, 1, 1, 0},
{0, 1, 1, 1, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 0, 0, 0},
{0, 0, 2, 0, 0},
}

local area1 = createCombatArea(arr1)
local area2 = createCombatArea(arr2)

setCombatArea(combat1, area1)
setCombatArea(combat2, area2)

function onCastSpell(cid, var) 
   if getPlayerStorageValue(cid,62054) == 1 then
      if getPlayerStorageValue(cid,70141) == 1 then
         if getPlayerStorageValue(cid,70143) == 1000 and getPlayerStorageValue(cid,70142) < 10 then
            setPlayerStorageValue(cid,70143,0)
            setPlayerStorageValue(cid,70142, getPlayerStorageValue(cid,70142)+1)
            doCombat(cid, combat1, var)
            addEvent(doCombat, 800, cid, combat2, var)
         elseif getPlayerStorageValue(cid,70143) < 1000 and  getPlayerStorageValue(cid,70142) < 10 then
            doCombat(cid, combat1, var)
            addEvent(doCombat, 800, cid, combat2, var)
            setPlayerStorageValue(cid,70143, getPlayerStorageValue(cid,70143)+1)
        elseif getPlayerStorageValue(cid,70143) == 0 and getPlayerStorageValue(cid,70142) == 10 then
            doCombat(cid, combat1, var)
            addEvent(doCombat, 800, cid, combat2, var)
         end
      else
         doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "(I)you don't have that magic - (P)voce nao tem essa magia - (E)no tienes este hechizo")
      end
   else
      doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "(I)you need a magic glove - (P)voce precisa de uma luva magica - (E)necesitas un guante magico")
   end 
return true
end
 
OP
OP
Nith

Nith

New Member
Joined
Jan 11, 2009
Messages
13
Reaction score
0
excuse me, keep hitting 15 damage. I should hit 3 damage: base = 1 + arma = 60263 (value=2)
and.... the magic level of the caster is 0


333333.png
 

Ascuas Funkeln

Rakkedo Game
Joined
Apr 14, 2013
Messages
516
Solutions
30
Reaction score
268
Location
Poland
GitHub
AscuasFunkeln
excuse me, keep hitting 15 damage. I should hit 3 damage: base = 1 + arma = 60263 (value=2)
and.... the magic level of the caster is
1. U operate dmg by storages, then to easy work do something like this:
Ofc u can all time check/change storages at database, but i think preparing item to fast checking its good for future work.(then you dont need all time open database to finding storages)

Create item, talkaction or whatever u want(item is better for me xD), and And paste this.

Lua:
function onUse(player, item, fromPosition, itemEx, toPosition, opcode, buffer)
    local alma = player:getStorageValue(60032)
    local elemento = player:getStorageValue(60005)
    local nspell = player:getStorageValue(70136)
    local arma = player:getStorageValue(60263)
    local buff = player:getStorageValue(62061)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "alma - " .. alma)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "elemento - " .. elemento)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE,"nspell - " ..  nspell)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "arma - " .. arma)
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "buff - " .. buff)
                    return true
                        end
Then check if you storages are correctly value, i mean.. values than u think storages have...
U set up this storages before in any way? If no value of it is -1.

Anyway This mess... :|
 
Last edited:
Top