• 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 Creating Layered Spells on 9.8

Tacoseasoning

Member
Joined
Nov 10, 2014
Messages
35
Reaction score
12
Hey everyone... I recently started editing spells on my 9.8 server and... unfortunately the scripting is quite a bit different than the last time I edited spells. Can someone give me an idea of how to layer spells? E.G. I want to take the simple Exori spell and make it hit Once around me like normal, then one more time 1 square bigger all the way around ending with a bleed on anyone it hits. If anyone can give me an idea or where to start, or maybe a custom spell you all have made that I can check out and take notes off of.

THanks for any and all help in advance!
 
addEvent works like this:

addEvent(functionToUse, intervalInMilleSeconds, parameters after this...)

doCombat has 3 parameters (cid, combat, var)
Cid and Var is the same all the time, "combat" is the one that needs to be changed to make the spell different.

so addEvent(doCombat, 100, cid, combat, var) would trigger the combat after 100 ms
 
What do you mean? Are the magic effects different? Then you can just change it in the script.
If the types and damage of the combats should be the same, you can do it like this
Code:
local combats = {}
for x = 1, 5 do
     combats[x] = createCombatObject()
     setCombatParam(combats[x], COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
     setCombatParam(combats[x], COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
     setCombatFormula(combats[x], COMBAT_FORMULA_LEVELMAGIC, -8.0, -50, -7.0, -100)
end

local arr1 = {
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 1, 0, 0, 0, 2, 0, 0, 0, 1, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 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 1, 1, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}

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

local arrs = {arr1, arr2, arr3, arr4, arr5}
for x = 1, 5 do
     setCombatArea(combats[x], createCombatArea(arrs[x]))
end

function onCastSpell(cid, var)
     for x = 1, 5 do
         addEvent(doCombat, x * 100, cid, combats[x], var)
     end
     return true
end
If you have combats with different damage, types or effects you could just create more combats under eachother, call it combat1, combat2, etc.
Then for the table combats you can do it like this (add it under the combats like local arrs).
Code:
local combats = {combat1, combat2, combat3, combat4, combat5}
 
Last edited:
Awesome, thanks for the replies and assistance! One last thing, I have been working on this all day but can't figure it out. I'm trying to now make a target spell.... I've looked over other spells such as Whirlwind throw and exori vis, etc... I can't figure out what the actual command or line of script that is triggering the target part of the abilities. With this being said, I am trying to make a whirlwind throw that throws multiple times. In this case, I would want to use multiple combats, correct? would I also need to add events?
 
The target part is in spells.xml, so you can add it the same way. To create multiple attacks after eachother you can indeed use addEvent like I showed above, but then you don't need to use those arrs since it's not an area spell.
 
local distanceCombat = {}

distanceCombat[z] = createCombatObject()
setCombatParam(distanceCombat[z], COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(distanceCombat[z], COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(distanceCombat[z], COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
setCombatFormula(distanceCombat[z], COMBAT_FORMULA_LEVELMAGIC, -0.4, 0, -0.5, 0)


distanceCombat[x] = createCombatObject()
setCombatParam(distanceCombat[x], COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(distanceCombat[x], COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(distanceCombat[x], COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
setCombatFormula(distanceCombat[x], COMBAT_FORMULA_LEVELMAGIC, -0.4, 0, -0.5, 0)



distanceCombat[v] = createCombatObject()
setCombatParam(distanceCombat[v], COMBAT_PARAM_TYPE, COMBAT_DEATHDAMAGE)
setCombatParam(distanceCombat[v], COMBAT_PARAM_EFFECT, CONST_ME_MORTAREA)
setCombatParam(distanceCombat[v], COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_DEATH)
setCombatFormula(distanceCombat[v], COMBAT_FORMULA_LEVELMAGIC, -0.4, 0, -0.5, 0)







function onCastSpell(cid, var)
if(variantToNumber(var) ~= 0) then
return doCombat(cid, distanceCombat, var)end

addEvent(RunPart,400,distanceCombat,cid,var)
addEvent(RunPart,200,distanceCombat,cid,var)
RunPart(distanceCombat,cid,var)
return doCombat(cid, distanceCombatcombat, var)
end


This is what i have so far, and am unsuccessfull. What am I doing wrong?
 
Use code tags to post scripts
[ code]
Your scripts
[/code]

You can do it exactly like the one I posted, but then the damage, effects and types you want and without areas.
The target part can be done in spells.xml, so you don't need to add anything else in function onCastSpell.
 
oh, sweet. Thanks! I'll test this out at home. So basically if I were to take your spell for example... I would just remove the areas all together? What about the "for x = 1, 5 do" ??? do i still need that command just written differently?
 
The 5 stands for amount of combats, if you have 2 combats, change it to 2.

A for loop repeats things, 1, 5 means it will repeat eveything till the end 1, 2, 3, 4, 5 = 5x.
First time x means 1, second time x means 2, third time x means 3 etc.
combats[1] will be the first value in the table combats, combats[2] the second one etc, so it will get all 5 values in that table, same goes for the table arrs.

This btw adds the 5 values to the table
Code:
local combats = {}
for x = 1, 5 do
     combats[x] = createCombatObject()
     setCombatParam(combats[x], COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
     setCombatParam(combats[x], COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
     setCombatFormula(combats[x], COMBAT_FORMULA_LEVELMAGIC, -8.0, -50, -7.0, -100)
end
First it's an empty table, which looks like {}, then it adds 5 combats to that table.
 
OHHHHH!!!! HAHA! What does the 1 stand for? Thank you for all your help! I'm sorry for the dumb questions! When I get home, I will test this and see how it goes! Thank you again!

The 5 stands for amount of combats, if you have 2 combats, change it to 2.

A for loop repeats things, 1, 5 means it will repeat eveything till the end 1, 2, 3, 4, 5 = 5x.
First time x means 1, second time x means 2, third time x means 3 etc.
combats[1] will be the first value in the table combats, combats[2] the second one etc, so it will get all 5 values in that table, same goes for the table arrs.

This btw adds the 5 values to the table
Code:
local combats = {}
for x = 1, 5 do
     combats[x] = createCombatObject()
     setCombatParam(combats[x], COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
     setCombatParam(combats[x], COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
     setCombatFormula(combats[x], COMBAT_FORMULA_LEVELMAGIC, -8.0, -50, -7.0, -100)
end
First it's an empty table, which looks like {}, then it adds 5 combats to that table.


Wow this is helpful! Just to double check... when i say "for x = 1, 5 do" I'm saying... Use combat [x], 5 times?
 
Last edited by a moderator:
By using combats[x] = createCombatObject() you add the combats to the table combats.
combats[1] will be the first value in the table, combats[2] the second, combats[3] the third, combats[4] the fourth, combats[5] the firth.
So you add 5 values (which are combats) to the table called combats.

By using a for loop with for x = 1, 5 do, it will repeat it 5x, first time x is 1, second time x is 2, third time x is 3, fourth time x is 4, fifth time x is 5.
Example with a textmessage to make it more clear.
Code:
for x = 1, 5 do
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Result of x: "..x..".")
end
Ingame you will get 5 textmessages
Code:
Result of x: 1.
Result of x: 2.
Result of x: 3.
Result of x: 4.
Result of x: 5.
So if you do this
Code:
for x = 1, 5 do
     addEvent(doCombat, x * 100, cid, combats[x], var)
end
It's the same as doing this
Code:
addEvent(doCombat, 100, cid, combats[1], var)
addEvent(doCombat, 200, cid, combats[2], var)
addEvent(doCombat, 300, cid, combats[3], var)
addEvent(doCombat, 400, cid, combats[4], var)
addEvent(doCombat, 500, cid, combats[5], var)
But using loops will make the script shorter and load faster which is better for the server.
 
Awesome! Thanks for helping me out with this... I'm just now getting in to the whole scripting business and you're really helping! Even though we are labeling the first combat as [x], it is still known as 1 in the combat table, correct? so If in what I listed earlier as my script, i technically have combat [z] which is 1, combat[x] which is 2, and combat [v] which is 3 in the combat table?
 
If you use for x = 1, 5 do, the x will be 1, 2, 3, 4 and 5.
You can use a different name for the for loop, if you do for z = 1, 5 do, then z will be 1, 2, 3, 4 and 5.
 
Back
Top