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

Wand problem

Trison

New Member
Joined
Mar 8, 2014
Messages
14
Reaction score
0
Hello guys,
Can you help me with 1 script? I have no idea how to fix it. I need to change type of damage for diffrent vocations with the same wand, it is not the ptoblem. Problem is I have no idea how to change attack range for diffrent vocations. I wrote this and I have no idea what next:

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)

function onGetFormulaValues(cid, level, skill, attack, factor)
    min = -100
    max = -175
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onGetFormulaValues2(cid, level, skill, attack, factor)
    local fist = getPlayerSkillLevel(cid, 0)
    min = - fist
    max = - 1.5 * fist
    return min, max
end
setCombatCallback(combat2, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues2")

function onUseWeapon(cid, var)
    local pozycja = getCreaturePosition(cid)
    local cel = getCreatureTarget(cid)
    local pozycja2 = getCreaturePosition(cel)

    if getPlayerVocation(cid) == 4 then
        return doCombat(cid, combat, var)
    else
        return doCombat(cid, combat2, var)
              -- I need to change range for combat 2, in items.xml I set 3 range
    end
end
Any ideas?
 
you might aswell make it like this

Code:
<wand id="7958" level="1" mana="1" min="100" max="175" type="holy" event="function" value="default"> <!-- item name here -->
        <vocation id="1"/>
        <vocation id="2"/>
    </wand>
 
I'm not a newbie. I have only problem with weapon range. Well, I can set it in items.xml but I need diffrent effects (also range) for diffrent vocations. In my script 1 voc attacks with holy and another attacks with physical, but both have the same range from items.xml. Here's my problem. I think you can understand me now.
 
Try:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
 
local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
 
function onGetFormulaValues(cid, level, skill, attack, factor)
    min = -100
    max = -175
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")
 
function onGetFormulaValues2(cid, level, skill, attack, factor)
    local fist = getPlayerSkillLevel(cid, 0)
    min = - fist
    max = - 1.5 * fist
    return min, max
end
setCombatCallback(combat2, CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues2")
 
function onUseWeapon(cid, var)
    local pozycja = getCreaturePosition(cid)
    local cel = getCreatureTarget(cid)
    local pozycja2 = getCreaturePosition(cel)
 
    if getPlayerVocation(cid) == 4 then
        doCombat(cid, combat, var)
        setItemShootRange(item.uid, 4)
    else
        doCombat(cid, combat2, var)
        setItemShootRange(item.uid, 3)
    end
end
 
Code:
-- by andu for trison
-- config --
local config = {
    [1] = {voc = 1, formula = 1, range = 4, shotEffect = CONST_ANI_HOLY, damageType = COMBAT_HOLYDAMAGE},
    [2] = {voc = 2, formula = 2, range = 3, shotEffect = CONST_ANI_DEATH, damageType = COMBAT_DEATHDAMAGE},
    [3] = {voc = 3, formula = 3, range = 5, shotEffect = CONST_ANI_EARTH, damageType = COMBAT_EARTHDAMAGE},
    [4] = {voc = 15, formula = 4, range = 3, shotEffect = CONST_ANI_REDSTAR, damageType = COMBAT_PHYSICALDAMAGE}
}

-- damage formula cfg --
local function getDamageFormula(cid)
    local formulas = {
        [1] = {
            min = -10
            max = -(getPlayerSkillLevel(cid, SKILL_FIST) * 5 + 10)
        },
        [2] = {
            min = -40
            max = -50    
        },
        [3] = {
            min = -0
            max = -getPlayerLevel(cid) * 5
        },
        [4] = {
            min = -40
            max = -getPlayerMagLevel(cid, false) * 3.5
        }
    }
    return formulas
end

-- core, dont touch --
function onUseWeapon(cid, var)
    local damage = getDamageFormula(cid)
    local voc, tar = getPlayerVocation(cid), getCreatureTarget(cid)
    local pos, tos = getCreaturePosition(cid), getCreaturePosition(tar)
    for i = 1, #config do
        if voc == config[i].voc then
            if getDistanceBetween(pos, tos) <= config[i].range then
                doSendDistanceShoot(pos, tos, config[i].shotEffect)
                doTargetCombatHealth(cid, tar, config[i].damageType, damage[(config[i].formula)].min, damage[(config[i].formula)].max, CONST_ME_NONE)
            end
        end
    end
    return true
end
 
Looks very nice, but range is from in the items.xml, if i delete range from there it is set to 1. I have no idea why it works like this. I added "," after every "min" because there was an error in console (something about to close "}" at line 13 but it was closed). This script looks really good and should work.. Any ideas?

#Edit
I changed range in items.xml to 10 and it works. So range in items.xml have to be >= as in the script. Thanks for help Andu, you are the best.
 
Last edited:
Back
Top