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

Solved Some script questions

Byte

* * * * *
Joined
Jul 23, 2013
Messages
130
Reaction score
19
Location
???
There's a few things I've been wanting to ask since I can't seem to figure them out on my own.

1. I have successfully created a mana rune. However, I want to be able to use it on itself and give the mana to me. (e.j. right-click on it, then left-click on it), instead of having to aim it at my character. I tried doing "needtarget=0" and "selftarget=1" but neither worked.

2. On a similar topic, I want to make a rune that heals both hp and mana.

manarune.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_MANADRAIN)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
--setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 2.5, -30, 2.5, 0)

function onGetFormulaValues(cid, level, maglevel)
    min = (level * 100000 + maglevel * 3) * 1.5
    max = (level * 100000 + maglevel * 3) * 2.0
   
    if min < 200 then
        min = 200
    end

    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

ultimate_healing_rune.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_TARGETCASTERORTOPMOST, 1)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, 0)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
--setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 2.5, -30, 2.5, 0)

function onGetFormulaValues(cid, level, maglevel)
    min = (level * 2 + maglevel * 3) * 1.5
    max = (level * 2 + maglevel * 3) * 2.0
   
    if min < 200 then
        min = 200
    end

    return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

3. I want to modify ultimate explosion damage so that the damage depends on your level ONLY (Disregard mlvl) and that the damage has little to no fluctuation (e.j. damage is now 1000-6000, and I want it to be just 6000 or 5000-6000) How can I do this?

There's this combat formula that I don't quite understand.
ultimate_explosion.lua
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.92, -0, -3.0, -0)

arr = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end


I know I'm asking a lot but believe me, I wouldn't be asking if I hadn't already tried to do it myself. I always try to figure it out myself and understand the scripts before asking. Thank you for your time.
 
Use function onGetFormulaValues(cid, level, maglevel) like the uh for the ue, this way you can set the damage to level only.
To be able to use the rune on itself, add the script in actions (function onUse(cid, item, fromPosition, itemEx, toPosition)) and use doCreatureAddHealth and doPlayerAddMana to add the healing.
Without using a combat, so that will look like this
Code:
local min = (getPlayerLevel(cid) * 100000 + getPlayerMagLevel(cid) * 3) * 1.5
local max = (getPlayerLevel(cid) * 100000 + getPlayerMagLevel(cid) * 3) * 2.0

if min < 200 then
     min = 200
end

doCreatureAddHealth(cid, math.random(min, max))
doPlayerAddMana(cid, math.random(min, max))
Add exhaustion condition for the exhaustion like potions have.
 
Hmm, I can't get it to work (I'm probably doing something wrong)

I have this in actions\scripts\manarune.lua
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local min = (getPlayerLevel(cid) * 100000 + getPlayerMagLevel(cid) * 3) * 1.5
local max = (getPlayerLevel(cid) * 100000 + getPlayerMagLevel(cid) * 3) * 2.0

if min < 200 then
     min = 200
end

doCreatureAddHealth(cid, math.random(min, max))
doPlayerAddMana(cid, math.random(min, max))

    return min, max
end

and this in actions.xml
Code:
<action itemid="2270" script="manarune.lua"/>

Do I need to keep the script in healing/spells? Or did I just mess up on the script in actions?
 
Change return min, max to return true.
Also add an exhaustion condition.

Above function onUse
Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_POTION)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)

Under function onUse
Code:
if hasCondition(cid, CONDITION_EXHAUST_POTION) then
     doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
     return true
end

doAddCondition(cid, exhaust)
 
Still isn't working :/

new script:
Code:
local exhaust = createConditionObject(CONDITION_EXHAUST_POTION)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)

function onUse(cid, item, fromPosition, itemEx, toPosition)

if hasCondition(cid, CONDITION_EXHAUST_POTION) then
     doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
     return true
end

doAddCondition(cid, exhaust)
local min = (getPlayerLevel(cid) * 100000 + getPlayerMagLevel(cid) * 3) * 1.5
local max = (getPlayerLevel(cid) * 100000 + getPlayerMagLevel(cid) * 3) * 2.0

if min < 200 then
     min = 200
end

doCreatureAddHealth(cid, math.random(min, max))
doPlayerAddMana(cid, math.random(min, max))

    return true
end
 
Make sure the ids are removed in spells.xml, if the rune still doesn't work, explain what happens and if you get errors.
 
Oh never mind it does work. But, it does not show the blue magic effect. How can I add that? Also it doesn't use up the charges. Finally, how can I reduce how fast you get exhausted?
 
Time is in milliseconds, so 1000 = 1 second
Code:
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1000)

Magic effect
Code:
doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)

Remove the charges
Code:
if item.type > 1 then
     doChangeTypeItem(item.uid, item.type-1)
else
     doRemoveItem(item.uid)
end
 
Alright now it's working perfectly. One last thing. :p I didn't quite understand what you wanted me to do regarding the UE. I tried several things and none worked. The ue either did no damage or just did nothing period. I even got to the point to where it was healing the monsters instead lol.

Anyway here's my current ue script. Help me fix it? :)
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_EXPLOSIONAREA)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.92, -0, -3.0, -0)

function onGetFormulaValues(cid, level, maglevel)
    min = (level * 2 + maglevel * 3) * 1.5
    max = (level * 2 + maglevel * 3) * 2.0
   
    if min < 200 then
        min = 200
    end

    return min, max
end

arr = {
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {1, 1, 1, 1, 1, 3, 1, 1, 1, 1, 1},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0},
    {0, 0, 1, 1, 1, 1, 1, 1, 1, 0, 0},
    {0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0},
    {0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
}

local area = createCombatArea(arr)
setCombatArea(combat, area)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
 
Remove
Code:
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.92, -0, -3.0, -0)

You forgot to add
Code:
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

Change
Code:
return min, max
To
Code:
return -min, -max

- means damage.
 
Back
Top