Authored by DarkGod
1 parent d39ffed4

### The damDesc talents function can now take a list of damage types and aggregate d…

`…amage types can themselves define this list too`
Showing with 87 additions and 12 deletions
 ... ... @@ -1210,6 +1210,48 @@ function string.fromTable(src, recurse, offset, prefix, suffix, sort, key_recurs 1210 1210 return prefix..table.concat(tt, offset)..suffix, tt 1211 1211 end 1212 1212 1213 +--- Returns the Levenshtein distance between the two given strings 1214 +function string.levenshtein_distance(str1, str2) 1215 + local len1 = string.len(str1) 1216 + local len2 = string.len(str2) 1217 + local matrix = {} 1218 + local cost = 0 1219 + 1220 + -- quick cut-offs to save time 1221 + if (len1 == 0) then 1222 + return len2 1223 + elseif (len2 == 0) then 1224 + return len1 1225 + elseif (str1 == str2) then 1226 + return 0 1227 + end 1228 + 1229 + -- initialise the base matrix values 1230 + for i = 0, len1, 1 do 1231 + matrix[i] = {} 1232 + matrix[i][0] = i 1233 + end 1234 + for j = 0, len2, 1 do 1235 + matrix[0][j] = j 1236 + end 1237 + 1238 + -- actual Levenshtein algorithm 1239 + for i = 1, len1, 1 do 1240 + for j = 1, len2, 1 do 1241 + if (str1:byte(i) == str2:byte(j)) then 1242 + cost = 0 1243 + else 1244 + cost = 1 1245 + end 1246 + 1247 + matrix[i][j] = math.min(matrix[i-1][j] + 1, matrix[i][j-1] + 1, matrix[i-1][j-1] + cost) 1248 + end 1249 + end 1250 + 1251 + -- return the last value - this is the Levenshtein distance 1252 + return matrix[len1][len2] 1253 +end 1254 + 1213 1255 -- Split a string by the given character(s) 1214 1256 function string.split(str, char, keep_separator) 1215 1257 char = lpeg.P(char) ... ...
 ... ... @@ -255,20 +255,22 @@ newBirthDescriptor{ 255 255 power_source = {arcane=true}, 256 256 stats = { mag=5, wil=3, cun=1, }, 257 257 talents_types = { 258 - ["spell/conveyance"]={true, 0.3}, 259 - ["spell/divination"]={true, 0.3}, 260 - ["spell/necrotic-minions"]={true, 0.3}, 261 - ["spell/advanced-necrotic-minions"]={false, 0.3}, 262 - ["spell/shades"]={false, 0.3}, 263 - ["spell/necrosis"]={true, 0.3}, 264 - ["spell/nightfall"]={true, 0.3}, 258 + ["spell/master-of-bones"]={true, 0.3}, 259 + ["spell/master-of-flesh"]={true, 0.3}, 260 + ["spell/master-necromancer"]={true, 0.3}, 265 261 ["spell/grave"]={true, 0.3}, 262 + ["spell/glacial-waste"]={true, 0.3}, 263 + ["spell/rime-wraith"]={true, 0.3}, 264 + ["spell/nightfall"]={true, 0.3}, 265 + ["spell/dreadmaster"]={true, 0.3}, 266 + ["spell/age-of-dusk"]={true, 0.3}, 267 + ["spell/death"]={true, 0.3}, 266 268 ["spell/animus"]={true, 0.3}, 269 + ["spell/eradication"]={true, 0.3}, 270 + ["spell/spectre"]={true, 0.3}, 271 + ["spell/necrosis"]={true, 0.3}, 267 272 ["cunning/survival"]={true, 0.0}, 268 273 }, 269 - unlockable_talents_types = { 270 - ["spell/ice"]={false, 0.2, "mage_cryomancer"}, 271 - }, 272 274 birth_example_particles = { 273 275 "necrotic-aura", 274 276 function(actor) ... ...
 ... ... @@ -4281,3 +4281,15 @@ newDamageType{ 4281 4281 return (realdam1 or 0) + (realdam2 or 0) 4282 4282 end, 4283 4283 } 4284 + 4285 +-- Cold/Darkness damage 4286 +newDamageType{ 4287 + name = "frostdusk", type = "FROSTDUSK", text_color = "#BLUE#", 4288 + damdesc_split = { {DamageType.TEMPORAL, 0.5}, {DamageType.DARKNESS, 0.5} }, 4289 + projector = function(src, x, y, type, dam, state) 4290 + state = initState(state) 4291 + useImplicitCrit(src, state) 4292 + DamageType:get(DamageType.TEMPORAL).projector(src, x, y, DamageType.COLD, dam / 2, state) 4293 + DamageType:get(DamageType.DARKNESS).projector(src, x, y, DamageType.DARKNESS, dam / 2, state) 4294 + end, 4295 +} ... ...
 ... ... @@ -93,8 +93,27 @@ damDesc = function(self, type, dam) 93 93 94 94 -- Increases damage 95 95 if self.inc_damage then 96 - local inc = self:combatGetDamageIncrease(type) 97 - dam = dam + (dam * inc / 100) 96 + if _G.type(type) == "string" then 97 + local dt = DamageType:get(type) 98 + if dt.damdesc_split then 99 + if _G.type(dt.damdesc_split) == "function" then 100 + type = dt.damdesc_split(self, type, dam) 101 + else 102 + type = dt.damdesc_split 103 + end 104 + end 105 + end 106 + 107 + if _G.type(type) == "table" then 108 + local basedam = dam 109 + for _, ds in ipairs(type) do 110 + local inc = self:combatGetDamageIncrease(ds[1]) 111 + dam = dam + (basedam * inc / 100) * ds[2] 112 + end 113 + else 114 + local inc = self:combatGetDamageIncrease(type) 115 + dam = dam + (dam * inc / 100) 116 + end 98 117 end 99 118 return dam 100 119 end ... ...