Skip to content
Snippets Groups Projects
Commit fa93a4cc authored by DarkGod's avatar DarkGod
Browse files

The damDesc talents function can now take a list of damage types and aggregate...

The damDesc talents function can now take a list of damage types and aggregate damage types can themselves define this list too
parent d39ffed4
No related branches found
No related tags found
No related merge requests found
......@@ -1210,6 +1210,48 @@ function string.fromTable(src, recurse, offset, prefix, suffix, sort, key_recurs
return prefix..table.concat(tt, offset)..suffix, tt
end
--- Returns the Levenshtein distance between the two given strings
function string.levenshtein_distance(str1, str2)
local len1 = string.len(str1)
local len2 = string.len(str2)
local matrix = {}
local cost = 0
-- quick cut-offs to save time
if (len1 == 0) then
return len2
elseif (len2 == 0) then
return len1
elseif (str1 == str2) then
return 0
end
-- initialise the base matrix values
for i = 0, len1, 1 do
matrix[i] = {}
matrix[i][0] = i
end
for j = 0, len2, 1 do
matrix[0][j] = j
end
-- actual Levenshtein algorithm
for i = 1, len1, 1 do
for j = 1, len2, 1 do
if (str1:byte(i) == str2:byte(j)) then
cost = 0
else
cost = 1
end
matrix[i][j] = math.min(matrix[i-1][j] + 1, matrix[i][j-1] + 1, matrix[i-1][j-1] + cost)
end
end
-- return the last value - this is the Levenshtein distance
return matrix[len1][len2]
end
-- Split a string by the given character(s)
function string.split(str, char, keep_separator)
char = lpeg.P(char)
......
......@@ -255,20 +255,22 @@ newBirthDescriptor{
power_source = {arcane=true},
stats = { mag=5, wil=3, cun=1, },
talents_types = {
["spell/conveyance"]={true, 0.3},
["spell/divination"]={true, 0.3},
["spell/necrotic-minions"]={true, 0.3},
["spell/advanced-necrotic-minions"]={false, 0.3},
["spell/shades"]={false, 0.3},
["spell/necrosis"]={true, 0.3},
["spell/nightfall"]={true, 0.3},
["spell/master-of-bones"]={true, 0.3},
["spell/master-of-flesh"]={true, 0.3},
["spell/master-necromancer"]={true, 0.3},
["spell/grave"]={true, 0.3},
["spell/glacial-waste"]={true, 0.3},
["spell/rime-wraith"]={true, 0.3},
["spell/nightfall"]={true, 0.3},
["spell/dreadmaster"]={true, 0.3},
["spell/age-of-dusk"]={true, 0.3},
["spell/death"]={true, 0.3},
["spell/animus"]={true, 0.3},
["spell/eradication"]={true, 0.3},
["spell/spectre"]={true, 0.3},
["spell/necrosis"]={true, 0.3},
["cunning/survival"]={true, 0.0},
},
unlockable_talents_types = {
["spell/ice"]={false, 0.2, "mage_cryomancer"},
},
birth_example_particles = {
"necrotic-aura",
function(actor)
......
......@@ -4281,3 +4281,15 @@ newDamageType{
return (realdam1 or 0) + (realdam2 or 0)
end,
}
-- Cold/Darkness damage
newDamageType{
name = "frostdusk", type = "FROSTDUSK", text_color = "#BLUE#",
damdesc_split = { {DamageType.TEMPORAL, 0.5}, {DamageType.DARKNESS, 0.5} },
projector = function(src, x, y, type, dam, state)
state = initState(state)
useImplicitCrit(src, state)
DamageType:get(DamageType.TEMPORAL).projector(src, x, y, DamageType.COLD, dam / 2, state)
DamageType:get(DamageType.DARKNESS).projector(src, x, y, DamageType.DARKNESS, dam / 2, state)
end,
}
......@@ -93,8 +93,27 @@ damDesc = function(self, type, dam)
-- Increases damage
if self.inc_damage then
local inc = self:combatGetDamageIncrease(type)
dam = dam + (dam * inc / 100)
if _G.type(type) == "string" then
local dt = DamageType:get(type)
if dt.damdesc_split then
if _G.type(dt.damdesc_split) == "function" then
type = dt.damdesc_split(self, type, dam)
else
type = dt.damdesc_split
end
end
end
if _G.type(type) == "table" then
local basedam = dam
for _, ds in ipairs(type) do
local inc = self:combatGetDamageIncrease(ds[1])
dam = dam + (basedam * inc / 100) * ds[2]
end
else
local inc = self:combatGetDamageIncrease(type)
dam = dam + (dam * inc / 100)
end
end
return dam
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment