Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local shapes = {
- --name = {targeting,modifier,incompatibility,exceptions}
- projectile = {"either",1,{"wall","target","beam","self"},2},
- burst = {"either",0.25,{},3},
- zone = {"either",0.25,{},3},
- target = {"either",0.75,{},2},
- beam = {"either",0.33,{},2},
- self = {"self",1,{},3},
- rune = {"either",1.25,{},2},
- wall = {"either",0.75,{},2},
- aura = {"ally",0.10,{"all"},2},
- presence = {"enemy",0.10,{"all"},2},
- onCrit = {"either",0.66,{"onDeath","onKill","onFall"},1},
- onDeath = {"either",2,{"onCrit","onKill","onFall"},1},
- onKill = {"either",0.25,{"onDeath","onCrit","onFall"},1},
- onFall = {"either",0.33,{"onDeath","onKill","onCrit"},1}
- }
- local function checkSNames(tbl)
- for i,v in pairs(tbl) do -- Checks if the shape does not exist
- if shapes[v] == nil then
- if type(v) == "table" then
- tbl = v
- end
- error("Shape '"..v.."' does not exist in shape index")
- end
- end
- end
- local function shapeParse(...)
- local tArgs = {...}
- checkSNames(tArgs)
- local incomp = {}
- for k,val in pairs(tArgs) do -- Dumps incompatibilities into the incomp table
- if shapes[val][3] then
- for i,v in pairs(shapes[val][3]) do
- table.insert(incomp, v)
- end
- end
- end
- for i,v in pairs(incomp) do -- Reads incomp table and makes sure no names in tArgs match any names in incomp
- if v ~= "all" then
- for i=1,#tArgs do
- if v == tArgs[i] then
- return false
- end
- end
- elseif v == "all" and #tArgs > 1 then -- Checks for multiple shapes if there is an "all" tag and renders it incompatible
- return false
- end
- end
- return true
- end
- local function dmgCalc(baseDmg,...)
- local tArgs = {...}
- checkSNames(tArgs)
- if shapeParse(unpack(tArgs)) == false then
- error("Shapes aren't compatible")
- end
- for i,v in pairs(tArgs) do --Finds multiplier values and multiplies baseDmg by it.
- baseDmg = baseDmg*(shapes[v][2])
- end
- return math.ceil(baseDmg) --Being generous and rounding it to the highest value
- end
- local function procOrder(...)
- local tArgs = {...}
- checkSNames(tArgs)
- if not shapeParse(unpack(tArgs)) then
- error("Shapes aren't compatible")
- end
- local order = {}
- for i=#tArgs,1,-1 do
- table.insert(order, shapes[tArgs[i]][4], tArgs[i])
- end
- return order
- end
- local function newSpell(element,...)
- local tArgs = {...}
- checkSNames(tArgs)
- if not shapeParse(unpack(tArgs)) then
- error("Shapes aren't compatible")
- end
- return dmgCalc(element,...),unpack(procOrder(...))
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement