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

Umm no I didn't mean that I meant it depends on the user's level like If I'm lvl 423 and I atked this spell I should damage with it 423 so it motivates the players to get more lvls to damage more ! + I tried this now it loads this time and atk but just atk 1 hit I guess there is a wrong with the condition so could you check it again ? I'm sorry I really appreciate your great effort (Y)
 
Oh sorry edited it, And yeah ive found it ive forgot to put the dots dunno why but its needed sometimes to read something x.x its like a menu with subclasses those shortcut.X etc. now if i am right it does now.
i also saw your other topic does it also need same amount of time exhaust?(but still able to cast other spells and shit)?
also test this script.. I think it should work now..
PHP:
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")
		
function onCastSpell(cid, var)
local formula = getPlayerLevel(getCreatureTarget(cid))    
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..
mylevel = getPlayerLevel(cid) -- Your own level
}

function condition()
local storage = 6402
local delay = 60 -- seconds
    if isPlayer(cid) == TRUE then 
        if exhaustion.check(cid, storage) then 
			doPlayerSendCancel(cid, "You cannot cast it again, untill the condition has worked out.")
			doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
            return FALSE 
        else 
			exhaustion.set(cid, storage, delay)
			doCreatureAddHealth(cid, -formula)
	end
			for i = 1, 30 do
			addEvent(condition, i * 2000)
	end
	return doCombat(cid, combat, var)
end
end
end
 
Last edited:
dude how do i do the orange effect thing! when u say the spell the spell text comes out as orange! how do u do that?
 
i have this
"(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -100, -1, -120, 7, 7, 2.3, 3.0)"

what do the numbers stand for?
 
They are confusing so its hard to tell for me just experiment or use mine formula..

Updates topic, since new layout doesn't support
Lua:
It's now clear again!
 
I was wondering if you knew how to make mage weapons like rods and wands and stuff... I would really appreciate a tutorial on this. This thread was amazingly helpful
 
using tfs 0.3.6pl1
this script:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1495)

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

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 1, 1000, -2000)
addDamageCondition(condition, 1, 1000, -2000)
addDamageCondition(condition, 1, 1000, -2000)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
Does no damage on cast (obviously), but creates enegy bomb, and after short while start ticking 30 dmg on the monster standing inside. after leaving the energy fields in the bomb, the target recieve additional 30 damage and then the energy condition is gone.


this script:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1495)

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

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 10, 5000, -200)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
Does almost same. the difference is that the target will start taking 30 damage after 5000 miliseconds, and it will take 30 damage every 1000 miliseconds.


I've been trixing with spells alot, the only "tick" damage i got working somehow in past experience is posion.
Maybe you can teach me something here, it would be really cool if this stuff actually worked.
 
Very good tutorial!

I justt got 1problem, i want to make a spell like exevo gran mas frigo but it need to make throwing knifes.

So instead of setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ASSASSIN)
It should do a throwing knife,how can i do this?
 
Very good tutorial!

I justt got 1problem, i want to make a spell like exevo gran mas frigo but it need to make throwing knifes.

So instead of setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ASSASSIN)
It should do a throwing knife,how can i do this?

Throwing knifes are distance effect, not a area effect. Check the list please maybe the light bulb goes on ;)


using tfs 0.3.6pl1
this script:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1495)

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

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 1, 1000, -2000)
addDamageCondition(condition, 1, 1000, -2000)
addDamageCondition(condition, 1, 1000, -2000)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
Does no damage on cast (obviously), but creates enegy bomb, and after short while start ticking 30 dmg on the monster standing inside. after leaving the energy fields in the bomb, the target recieve additional 30 damage and then the energy condition is gone.


this script:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_ENERGYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_ENERGYHIT)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)
setCombatParam(combat, COMBAT_PARAM_CREATEITEM, 1495)

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

local condition = createConditionObject(CONDITION_ENERGY)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 10, 5000, -200)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end
Does almost same. the difference is that the target will start taking 30 damage after 5000 miliseconds, and it will take 30 damage every 1000 miliseconds.


I've been trixing with spells alot, the only "tick" damage i got working somehow in past experience is posion.
Maybe you can teach me something here, it would be really cool if this stuff actually worked.

It is because your spell gives him a condition.. But the energy boms you casted are just regular energy fields the fields and the script aren't linked together..
What could be possible is to create another item id with energy field and put custom conditions in items.xml and let the script create that x of item.


I was wondering if you knew how to make mage weapons like rods and wands and stuff... I would really appreciate a tutorial on this. This thread was amazingly helpful

Thank you all, Soon i make more tutorials, just tell me what you want, whenever i feel too and have time i will make it.



DO NOT FEED THE NEW GENERATION WITH FIXED SCRIPTS, TEACH THEM TO MAKE SCRIPTS
LET THEM IMAGINATION FLOW AND CREATE SOMETHING ORIGINAL

SO MUCH RESPECT FOR THOSE WHO WANTS TO LEARN, YOU GUYS ARE MY MOTIVATION TO WRITE TUTORIALS LIKE THIS :)
 
Well i know it's distance effect but i saw a spell like this :
http://tinypic.com/r/iemtk7/8

And i'm trying to learn how to do those throwing knifes so i wanted to ask some little information how that would be possible :)

I got one spell which is similiar, Try to experiment with it. If you have any questions feel free to ask!

Code:
local acombat = createCombatObject()

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, 9)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_EARTH)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.5, -150, -1.1, -150)

local arr = {
   {0, 0, 1, 1, 1, 0, 0},
   {0, 1, 0, 0, 0, 1, 0},
   {1, 0, 0, 0, 0, 0, 1},
   {1, 0, 0, 3, 0, 0, 1},
   {1, 0, 0, 0, 0, 0, 1},
   {0, 1, 0, 0, 0, 1, 0},
   {0, 0, 1, 1, 1, 0, 0}
   }
  
local area = createCombatArea(arr)
setCombatArea(acombat, area)

function onTargetTile(cid, pos)
doCombat(cid,combat,positionToVariant(pos))
end

setCombatCallback(acombat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")

function onCastSpell(cid, var)
return doCombat(cid, acombat, var)
end
 
Thanks it was style i was looking for,since i'm kinda new with scripting i would like to ask what this part means,i mean what it do to the script :)

function onTargetTile(cid, pos)
doCombat(cid,combat,positionToVariant(pos))
end

setCombatCallback(acombat, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
 
Okey,well i got 1more question:

If i want to make the spel repeat himself,for example u say 1x spell but it will attack 3x,somekind of a repeatparam i tried this but i get this error..

Script :
local repeatAmount = 3

local acombat = createCombatObject()
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_THROWINGKNIFE)
function onGetFormulaValues(cid, level, maglevel)
min = -(level * 10 + maglevel * 8) * 2
max = -(level * 10 + maglevel * 8) * 2
return min, max
end
setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local arr = {
{0, 0, 1, 1, 1, 0, 0},
{0, 1, 1, 0, 1, 1, 1},
{0, 0, 0, 1, 0, 0, 0},
{0, 0, 0, 1, 0, 1, 0},
{1, 0, 0, 3, 0, 0, 1},
{0, 1, 0, 1, 0, 1, 0},
{0, 0, 0, 1, 0, 0, 0},
{1, 1, 1, 0, 1, 1, 1},
{0, 0, 1, 1, 1, 0, 0},
}
local area = createCombatArea(arr)
setCombatArea(acombat, area)

function onCastSpell(cid, pos)
doCombat(cid,combat,positionToVariant(pos))
end

setCombatCallback(acombat, CALLBACK_PARAM_TARGETTILE, "onCastSpell")

function onCastSpell(cid, var)
return doCombat(cid, acombat, var)

end

function onCastSpell(cid, var)
for i = 0, repeatAmount-1 do
addEvent(castSpell, 300 * i, cid, var)
end
return true
end

ERROR :
[28/07/2014 19:26:46] [Error - Spell Interface]
[28/07/2014 19:26:46] data/spells/scripts/attack/Exevo gran mas mas frigo.lua:eek:nCastSpell
[28/07/2014 19:26:46] Description:
[28/07/2014 19:26:46] (luaAddEvent) Callback parameter should be a function.

Also i was wondering how to add a 2nd wave in the spell as u can see if will now shoot throwing knifes at the places,but if i want fe it ue's holy area in my 2x2 area together with the throwing knifes how u set that up?
 
Last edited:
Try to edit this script:
Code:
local repeatAmount = 3
 
 
local deathFlamesArea = {createCombatArea({
 {0, 1, 0},
 {1, 2, 1},
 {0, 1, 0}
 }),createCombatArea({
 {0, 1, 1, 1, 0},
 {1, 1, 0, 1, 1},
 {1, 0, 2, 0, 1},
 {1, 1, 0, 1, 1},
 {0, 1, 1, 1, 0}
 }),createCombatArea({
 {0, 0, 1, 1, 1, 0, 0},
 {0, 1, 0, 0, 0, 1, 0},
 {1, 0, 0, 0, 0, 0, 1},
 {1, 0, 0, 2, 0, 0, 1},
 {1, 0, 0, 0, 0, 0, 1},
 {0, 1, 0, 0, 0, 1, 0},
 {0, 0, 1, 1, 1, 0, 0}
 })
 
}
 local bigFlamesArea = createCombatArea({
 {0, 0, 1, 1, 1, 1, 1, 0, 0},
 {0, 1, 1, 0, 0, 0, 1, 1, 0},
 {1, 1, 0, 0, 0, 0, 0, 1, 1},
 {1, 0, 0, 0, 0, 0, 0, 0, 1},
 {1, 0, 0, 0, 2, 0, 0, 0, 1},
 {1, 0, 0, 0, 0, 0, 0, 0, 1},
 {1, 1, 0, 0, 0, 0, 0, 1, 1},
 {0, 1, 1, 0, 0, 0, 1, 1, 0},
 {0, 0, 1, 1, 1, 1, 1, 0, 0}
})
 local deathFlames = {}
for k, area in ipairs(deathFlamesArea) dodeathFlames[k] = createCombatObject()setCombatParam(deathFlames[k], COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)setCombatParam(deathFlames[k], COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKE)setCombatFormula(deathFlames[k], COMBAT_FORMULA_LEVELMAGIC, -12.593, -50, -13.929, -100)
 setCombatArea(deathFlames[k], area)end
 
local bigFlames = createCombatObject()setCombatParam(bigFlames, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)setCombatParam(bigFlames, COMBAT_PARAM_EFFECT, CONST_ME_GROUNDSHAKER)setCombatFormula(bigFlames, COMBAT_FORMULA_LEVELMAGIC, -13.766, -50, -12.241, -100)
 setCombatArea(bigFlames, bigFlamesArea)
 
function onTargetTile(cid, pos)doSendDistanceShoot(getCreaturePosition(cid), pos, CONST_ANI_WHIRLWINDAXE)end
setCombatCallback(bigFlames, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
 local function castSpellDelay(p)
 if(isCreature(p[1]) == TRUE) then
 doCombat(unpack(p))end
end
 function onCastSpell(cid, var)
 for i = 0, repeatAmount - 1 do
 for k, combat in ipairs(deathFlames) doaddEvent(castSpellDelay, (150 * k) + #deathFlames * 150 * i + 700 * i, {cid, combat, var})end
 addEvent(castSpellDelay, (150 * #deathFlames) + #deathFlames * 150 * i + 700 * i, {cid, bigFlames, var})end
 return LUA_NO_ERROR
end

Also try to use code tags its easier to see..
 
Back
Top