• 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] How to make a simple spell script.

great tutorial, how can i call a second spell with the first one, like
Code:
function onCast
call exori vis
 
Hey, i get this error when i start the server.

{Warning - spell::configurespell] Wrong voaction name: Sorcerer

This is my script

<instant group="attack" spellid="1111" name="Holy wrath" words="exevo gran mas wrath" lvl="8" mana="10" prem="0" selftarget="1" cooldown="2000" groupcooldown="2000" needlearn="0" script="attack/holy wrath.lua">
<vocation name=" Sorcerer"/>
</instant>


And this is the spell script.

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_YELLOW_RINGS)

function onGetFormulaValues(cid, level, maglevel)
min = -(level * 2 + maglevel * 3) * 2
max = -(level * 4 + maglevel * 6) * 2
return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local rr1 = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 1, 1, 1, 0},
{1, 1, 1, 1, 1, 1, 1},
{1, 1, 1, 3, 1, 1, 1},
{1, 1, 1, 1, 1, 1, 1},
{0, 1, 1, 1, 1, 1, 0},
{0, 0, 1, 1, 1, 0, 0}
}

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

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


please help, this is my first script ever made :)
 
Really nice topic, but How to do that:

If the Player are Premium Account he'll hit or heal 20% more, with the same spells.

Exemple: Premium player do an "exori" he hit 120 on a monster. The normal player do an "exori" he hit 100 on the same monster.
 
Really nice topic, but How to do that:

If the Player are Premium Account he'll hit or heal 20% more, with the same spells.

Exemple: Premium player do an "exori" he hit 120 on a monster. The normal player do an "exori" he hit 100 on the same monster.

Well i think you should edit sources for that or change every spell script and try to add lines but i can't say if that would work, maybe when i have some time i could try it myself..

@iwantlearlua
I don't get what you say!

@optus
You're welcome! I like to help other peoples.

@neffz
Look at the error it says that your vocation or something is wrong and if you looked at the XML part
You got: <vocation name=" Sorcerer"/>
You got 1 space too much it should be:
<vocation name="Sorcerer"/>

Then you got it, also remember when your sorcerer is promoted he wouldn't be able to cast that spell anymore.
 
Hey do u know a mega frigo or mega vis spell ?? can u make 1 for you its so simple but for me is too hard pls if u can help me i will repp you thx
 
Last edited:
After a advanced tutorial you are still asking me to change the damage formula of 1 existing spell with another name? I won't do things for rep+ especially if you haven't learn anything of it.. I already gave you a explanation in PM.. I don't even think you readed it at all, if you do explain to me wich you didn't understand..
 
On the local condition why did you put :
addDamageCondition(condition, 1, 5000, -20)
like 3 times isnt enough to put it once ?
Another thing How can I put the time of the condition effect ? like If I want it to last for 2 minutes or 3 ? Thanks :D
Great tut btw :)
 
On the local condition why did you put :
addDamageCondition(condition, 1, 5000, -20)
like 3 times isnt enough to put it once ?
Another thing How can I put the time of the condition effect ? like If I want it to last for 2 minutes or 3 ? Thanks :D
Great tut btw :)

Lua:
addDamageCondition(condition, 1, 5000, -20)
Like i said in my tutorial i've forgot that number 1 means if i am right, it means the amount of times it happens
5000 is the interval, how much miliseconds till the next hit.

Lua:
addDamageCondition(condition, 10, 5000, -20)
Now it does, each 5 seconds 20 damage, about 10 times.
5 x 10 seconds is = 50 seconds
2 minutes = 120 seconds = 24 times IF it takes 5 seconds each.
3 minutes = 180 seconds = 36 times IF it takes 5 seconds each.


The reason i put 3x so you can see that it works either and you can edit so it gets stronger or weaker after every hit.
Lua:
addDamageCondition(condition, 1, 5000, -20)


Thanks if you have any questions you know where to find me!
 
Last edited:
Well , I want to make something like when I atk a Distance spell it damages as your lvl then make condition to keep damages the same amout of ur lvl hit for like 1 min like if im lvl 500 when I atk this spell as if I'm poisoned you with the same damage as my lvl number for lvl 483 it should hit you 483 every 2 seconds till the minute or the 2 minutes of the spell ends with the style of the drown shape so as I learned from you I made this code but as I'm beginner it doesn't work idk why Here is my code :
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, 256)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 1)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 35)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1 + maglevel * 0) * 1
max = -(level * 1 + maglevel * 0) * 1
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local condition = createConditionObject(32768)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 1, 2000, "onGetFormulaValues")
addDamageCondition(condition, 1, 2000, "onGetFormulaValues")
addDamageCondition(condition, 1, 2000, "onGetFormulaValues")
setCombatCondition(combat, condition)
function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
 
Well , I want to make something like when I atk a Distance spell it damages as your lvl then make condition to keep damages the same amout of ur lvl hit for like 1 min like if im lvl 500 when I atk this spell as if I'm poisoned you with the same damage as my lvl number for lvl 483 it should hit you 483 every 2 seconds till the minute or the 2 minutes of the spell ends with the style of the drown shape so as I learned from you I made this code but as I'm beginner it doesn't work idk why Here is my code :
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, 256)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 1)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, 35)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 1 + maglevel * 0) * 1
max = -(level * 1 + maglevel * 0) * 1
    return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
local condition = createConditionObject(32768)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 1, 2000, "onGetFormulaValues")
addDamageCondition(condition, 1, 2000, "onGetFormulaValues")
addDamageCondition(condition, 1, 2000, "onGetFormulaValues")
setCombatCondition(combat, condition)
function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

well first of all, I'm happy to see someone teaching spells yourself following mine tutorial =)
And the second thing is if you post a script i do recommend using code or lua tags
and the last thing is always tell wich distro you are using..

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_LOSEENERGY)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

function onGetFormulaValues(cid, level, maglevel)
min = - level * 1
max = - level * 1
return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local shortcut = { -- Do not change anything here this is just shortcut i only recommend reading it to try to find out what it means i only recommend editing the minute so you can easy edit the duration of spell.
target = getCreatureTarget(cid), -- This means get the CreatureID of your target.
targetlevel = getPlayerLevel(shortcut.target), -- This means find the level of your target, I only wonders what happens if used on monster..
minute = 1
}

function formula(cid, var, targetpos, target, targetlevel) -- Neither edit this, this is just the formula
doCreatureAddHealth(shortcut.target, -shortcut.targetlevel)
end

local condition = createConditionObject(CONDITION_DROWN)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 30 * shortcut.minute, 2000, formula) -- You only need one unless you want it does different kind of damages..
setCombatCondition(combat, condition)

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

What did you done wrong?
- Haven't using enter or tabs(It's not needed but it is easier to read your own script).
- I also noticed you used numbers wich makes scripts shorter wich is good! but its also hard to find out from your head what it was, so i recommend using the words for beginners except spell effect numbers they are very easy to remember especially if you made a lot of spell packages....
- You need another formula if the damage is difference like yourlevel and targetlevel, Except their the same level but how can you expect that..
- You could edit more then the numbers of formula..
- With advanced spells/formulas i recommend also some experience with LUA (i should make a tut of that either).
- Why not using numbers as beginner?

Because if i want i can use this
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_LOSEENERGY)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

or a very short mode(It's already 100 characters shorter even if it doesn't looks like that)
Code:
local s.c = s.e
s.d(s.c, 1, 256)
s.d(s.c, 2, 1)
s.d(s.c, 3, 35)

local s = {
c = combat,
d = setCombatParam
e = createCombatObject()

But if that spell file is called like "anothercustomspell.lua"
Then you had to also check spells.lua with ctrl+f wich is waste of effort
or even worse check in-game either.. (especially if your serv is off or not even fixed).
thats why i use the another way so i can easy find out what my spell is.

Afterall, Good luck
I hope you learned something from this..
I haven't tested but if i am right it should work.
And you made a quite nice try for a beginner, If you haven't downloaded notepad++ yet i recommend it, You can read it easier there, And if you paste a Lua file there you cannot see it unless you do: syntaxis > L > Lua (google it or check first post)
if you have any questions ask it here


Animera
 
Last edited:
Firstly , I would like to thank you for your great effort + Rep ! But I found a problem when I put the spell on the server I found that when I cast the word of the spell it comes with yellow font as if its normal chatting word or something although I have the system that makes the rl name of spell appears with orange when the casting word is being said then I tried to know the reason I found some errors on the black screen of the running of the OT and here is what it says :
[Error - Spell Interface]
data/spells/attack/scripts/Water Drown.lua
Description :
<luaGetCreatureTarget> Creature not Found
[Error - Spell Interface]
data/spells/attack/scripts/Water Drown.lua
Description :
data/spells/attack/scripts/Water Drown.lua:16:attempt to index global 'shortcut' <a nil value>
[Warning-Event :: LoadScript] Cannot Load Script <data/spells/attack/scripts/Water Drown.lua>
So what is this Error ? :D
Second thing in your last post you were saying somethings about the target level why we want to know the target level ? the spell depends on the one who attacks it not on the target level like if I'm lvl 500 I atk with 500 each 2 sec regardless the enemies level + Final point I want the losing point due to this spell comes with the colour of the frigo hit and without the frigo effect this is possible ? . Thank you again :)
 
Last edited:
No problem you're welcome
well we need 2 checkers 1 is checking your level for attack(your formula)
mine formula checks the level of the conditiondamage

cuz i understand the followed thing: if a level 250 uses the atk to a level 218 it does 250 damage the first time then 2-3 minutes every 2 seconds 218 damage right??

And in the error it said something about the shortcut in line16(wich you can easy see on notepad, however before i posted this script i already feeled it that it couldn't read it so i edited it

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_DROWNDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_LOSEENERGY)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
setCombatParam(combat, COMBAT_PARAM_HITEFFECT, CONST_ME_LOSEENERGY)

function onGetFormulaValues(cid, level, maglevel)
min = - level * 1
max = - level * 1
return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local shortcut = { -- Do not change anything here this is just shortcut i only recommend reading it to try to find out what it means i only recommend editing the minute so you can easy edit the duration of spell.
target = getCreatureTarget(cid), -- This means get the CreatureID of your target.
targetlevel = getPlayerLevel(getCreatureTarget(cid)), -- This means find the level of your target, I only wonders what happens if used on monster..
minute = 1
}

function formula(cid, var, targetpos, target, targetlevel) -- Neither edit this, this is just the formula
doCreatureAddHealth(shortcut.target, -shortcut.targetlevel)
end

local condition = createConditionObject(CONDITION_DROWN)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 30 * shortcut.minute, 2000, formula) -- You only need one unless you want it does different kind of damages..
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
return doCombat(cid, combat, var)
end
 
Last edited:
Back
Top