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

Super spell system pseudo code

Colandus

Advanced OT User
Senator
Joined
Jun 6, 2007
Messages
2,434
Solutions
19
Reaction score
219
Location
Sweden
yo im about to make a spell system.......

there will be several options to make spell creations muuuch easier and muuuch more effective.... way more possibilities will be available


this is the part i'd like to show y'all and have comments about::

PROTOTYPE #1
Lua:
-- create variables a-z and A-Z starting from 2
createVars(2, {"a","z"}, {"a","z",string.upper})
-- it will automatically create variables for you of the kind:
-- a = 3  b = 4  c = 5  d = 6  etc... until z and then from A to Z starting from about 28 or whatever it is

local area = {
	{V,y,z,A,B,C,D},
	{U,x,i,j,k,l,E},
	{T,w,h,a,b,m,F},
	{S,v,g,1,c,n,G},
	{R,u,f,e,d,o,H},
	{Q,t,s,r,q,p,I},
	{P,O,N,M,L,K,J}
}
-- then on this one it will create a spell area using those variables...  although we only use A-V here and not A-Z

it may look confusing, but once you grasp it you will find it being the most simple way to make animated spells... however what it will do is to spin around the player..... i cannot make a video otherwise i would have demonstrated it!!

i figured though, to make the very same thing there is an easier way. but not as customizable:

PROTOTYPE #2
Lua:
local area = [[
.>>>>>v
^^>>>vv
^^>>>vv
^^^Evvv
^^^<<vv
^^<<<<v
^<<<<<<
]]

E means East, which is the player centerpos, and that it is East means that it will start from the "letter" east of it (the "v")... How this will work is that it will cast the spell in the order of the "marks"... the dot (.) means the spell end there.

So e.g. this:
E>>v
.<<<

Will first do the spell to players x + 1 and then x + 2, then x + 3
and then as it is "v" it will go down, meaning it will be at x + 3 and y + 1
and then going to x + 2 and y + 1
then to x + 1 and y +1

and finally to y + 1 only (x + 0)

This would cause an infinite loop >< (I'm still thinking if I should let it be that way, and let the spell have an X amount of loop times, so we could make it "infinite" and then end it after e.g. 30 casts"


Any questions? :D You can request features for the spell system here too... It will be very powerful and this is only a minor part of it.
 
Last edited:
i like your first prototype better. and i have a question about it. if you place say 5 'a' all of them will be executed at the same time? so could you do something like this

local area = {
{V,y,z,A,B,C,D},
{U,b,b,b,b,b,E},
{T,b,a,a,a,b,F},
{S,b,a,1,a,b,G},
{R,b,a,a,a,b,H},
{Q,b,b,b,b,b,I},
{P,O,N,M,L,K,J}

also what happens if you skip letters?
 
yes they will be executed at once... if we only focus at the a's and b's in your area, it would first execute the a area just as if it was in its own area in normal spell system and then b...

skipping will do just as normal spells, but it should be 0's for empty.. or if possible just a space, i think it would count as nil and work that way not sure though... but it will be very configureable so you can give instructions to the spell what to do on each "a" which actually is a number (the reason i used variables is because it would be confusing after reaching over 9... 10 11 etc would take off the structure)...

so it could as well be like this:
local area = {
{0,0,5,5,5,0,0},
{0,5,4,3,4,5,0},
{5,4,3,2,3,4,5},
{5,3,2,1,2,3,5},
{5,4,3,2,3,4,5},
{0,5,4,3,4,5,I},
{0,0,5,5,5,0,0}
}

and you will also be able to set the options for each number (area)..
so it would be like:

Lua:
local areaOptions = {
    -- default one will apply to all numbers (areas) so if we want them to share options we don't need to repeat in everyone of them...
    default = {
        -- whatever you want... you could e.g. use "effect = some_effect" and it will be applied to every area (unless they have their own effect)
    },
    [1] = {
        player = true, -- tell the script this is where the player is
        effect = CONST_ME_FIREAREA,
        animation = CONST_ANI_SPEAR
    },
    [2] = {
        -- we do not have "player = true" here, there is only 1 player pos...
        effect = Whatever_effect --- now we do whatever it should be to the spell...
    }
}

local spell = CSpellSystem.new()
spell:registerArea(area, areaOptions)

or... would it be better this way ? seeing tables could be slightly confusing... but i believe it's easier to remember keys than function names... so you wouldn't have to copy paste from other scripts all the times and learn them instead!! however second version:
Lua:
local CArea = CArea:new()
CArea:set(area) -- whichever area we created...

CArea:setEffect(1, CONST_ME_FIREAREA) -- this would set effect to the area with number "1" in the area array...
-- then we add other attributes etc....

local spell = CSpellSystem.new()
spell:setArea(CArea)


Open for suggestions :)
 
LoL, people are too stupid to understand basic spell system of otserv/tfs, do you really think they'll learn urs? :D
 
how do you mean fallen ? to create the system or what? cuz i already know how to :p I just wanna be sure how the spells should be created...
 
thanks for clarifying that.

local areaOptions = {
-- default one will apply to all numbers (areas) so if we want them to share options we don't need to repeat in everyone of them...
default = {
-- whatever you want... you could e.g. use "effect = some_effect" and it will be applied to every area (unless they have their own effect)
},
[1] = {
player = true, -- tell the script this is where the player is
effect = CONST_ME_FIREAREA,
animation = CONST_ANI_SPEAR
},
[2] = {
-- we do not have "player = true" here, there is only 1 player pos...
effect = Whatever_effect --- now we do whatever it should be to the spell...
}
}

local spell = CSpellSystem.new()
spell:registerArea(area, areaOptions)

looks better then the second version if you ask me. and tables are easy to read.

i got another question. what if you want lets just say an exori area effect. but you want it to repeat twice what would you do then? you would need another table?

i think it would be awesome if you could make it like this.

local area = {
{ab,ab,ab},
{ab,2,ab},
{ab,ab,ab}
}

then it would hit area 'a' delay and hit area 'b' or would you need to do this

instead of needing to do this

local area1 = {
{a,a,a},
{a,2,a},
{a,a,a}
}


local area2 = {
{b,b,b},
{b,2,b},
{b,b,b}
}
 
no you just need the same area normally and you could do something like repeat = 2, delay = 1000 in attributes I think I had that in my last Spell system I made but lost it :p
 
but that wouldn't work if you wanted something like

local area = {
{b ,0 ,a ,ab,a,0 ,b},
{0 ,ab,0 ,b ,0,ab,0},
{a ,0 ,b ,b ,b,0 ,a},
{ab,b ,b ,1 ,b,b,ab},
{a ,0 ,b ,b ,b,0 ,a},
{0 ,ab,0 ,b ,0,ab,0},
{b ,0, a ,ab,a,0 ,b}
}

with 'a' making circle and then later 'b' making a * pattern.
 
yes i had that in my old spell system too :p but seeing those are just variables "a" and "b" you can't just write "ab"... in my last system i used arrays like {a, b} but im trying to figure a smarter way..... its kinda tricky xD cuz it looks so messy when you do it that way! as you can see clearly in your area heh
 
ya my spell area does look like a mess in that post. i made it and i can hardly tell what shapes it is making. well sort of a little jump around you could do this.


c = {a,b}
local area = {
{b,0,a,c,a,0,b},
{0,c,0,b,0,c,0},
{a,0,b,b,b,0,a},
{c,b,b,1,b,b,c},
{a,0,b,b,b,0,a},
{0,c,0,b,0,c,0},
{b,0,a,c,a,0,b}
}

but still i suppose that wouldnt be the best way to go about it. i hope you can figure something out.
 
The formula values thingy would look something like this:
Lua:
function damageFormula(cid, sqmFromCenter)
	local level = getPlayerLevel(cid)
	local magicLevel = getPlayerMagicLevel(cid)
	
	local dR = sqmFromCenter ^ 2.784 + (sqmFromCenter * 10) ^ 1.34
	local minV = 10 * 0.090 ^ magicLevel *  - dR
	--local maxV - dR
	return minV, maxV
end

spell:setSpellValuesCallback(damageFormula)
(the code was unfinished, but you get the point)

Based on the idea that I always use for my spells, to reduce the damage the further out the spell goes. "sqmFromCenter" is the number of squares that the spell is away from center or caster. This way we can include it to our formula to let it affect the damage!

There might also be other variables added once I figure what will be needed...


And yes soul, I'll do my best thinking of a solution! That's also why I made this thread, for you guys to help me out :p
 
Lua:
if confused = 1
do exitThread

no point in coming here and posting that. the thread makes sense as long as your not an i-d-10-t.

i love that idea for the new spell damage function. especially with less damage the further from the source. atm the damage functions suck for TFS they dont allow enough customization if you ask me.
 
I was also thinking of something like "lastExecution" or something, as another variable for formulas, that will show in seconds when you last executed the spell... Not sure if it will be useful but I thought maybe like the spell maker would like to make an increased damage if the spell hasn't been used for sometime, or decrease if it's used within x seconds... To use it in the formula to reduce damage if used between 10 second rage, so e.g. if I use a spell, then again after 3 seconds, maybe it's a very powerful spell and is supposed to be powerful but will become overpowered if spammed, so maybe we want to make it damage less when used not to strategic or whatever! :p


2000th post! hEHEH :D
 
Back
Top