If you want to see the inner workings, see below.
To explain, Corpathus starts off with +4 physical crit. On scoring a kill, it gets +2 crit and +4 crit power, on a crit it gets half of that. Each time this occurs, if it has 30 or more crit bonus, it'll have a % chance equal to 80% of the crit bonus (so at 30, you have a 24% chance) to trigger the summon. When this happens, the crit resets to 6, crit power to 0, and a Vilespawn will be created in a nearby tile.
Code: Select all
newEntity{ base = "BASE_LONGSWORD", define_as="CORPUS",
power_source = {unknown=true, technique=true},
unique = true,
name = "Corpathus", image = "object/artifact/corpus.png",
unided_name = "bound sword",
moddable_tile = "special/%s_corpus",
moddable_tile_big = true,
desc = [[Thick straps encircle this blade. Jagged edges like teeth travel down the blade, bisecting it. It fights to overcome the straps, but lacks the strength.]],
level_range = {20, 30},
rarity = 250,
require = { stat = { str=40, }, },
cost = 300,
material_level = 4,
combat = {
dam = 40,
apr = 12,
physcrit = 4,
dammod = {str=1,},
melee_project={[DamageType.DRAINLIFE] = 18},
special_on_kill = {desc="grows dramatically in power", fct=function(combat, who, target)
local o, item, inven_id = who:findInAllInventoriesBy("define_as", "CORPUS")
if not o or not who:getInven(inven_id).worn then return end
who:onTakeoff(o, inven_id, true)
o.combat.physcrit = (o.combat.physcrit or 0) + 2
o.wielder.combat_critical_power = (o.wielder.combat_critical_power or 0) + 4
who:onWear(o, inven_id, true)
if not rng.percent(o.combat.physcrit*0.8) or o.combat.physcrit < 30 then return end
o.summon(o, who)
end},
special_on_crit = {desc="grows in power", on_kill=1, fct=function(combat, who, target)
local o, item, inven_id = who:findInAllInventoriesBy("define_as", "CORPUS")
if not o or not who:getInven(inven_id).worn then return end
who:onTakeoff(o, inven_id, true)
o.combat.physcrit = (o.combat.physcrit or 0) + 1
o.wielder.combat_critical_power = (o.wielder.combat_critical_power or 0) + 2
who:onWear(o, inven_id, true)
if not rng.percent(o.combat.physcrit*0.8) or o.combat.physcrit < 30 then return end
o.summon(o, who)
end},
},
summon=function(o, who)
o.cut=nil
o.combat.physcrit=6
o.wielder.combat_critical_power = 0
game.logSeen(who, "Corpathus bursts open, unleashing a horrific mass!")
local x, y = util.findFreeGrid(who.x, who.y, 5, true, {[engine.Map.ACTOR]=true})
local NPC = require "mod.class.NPC"
local m = NPC.new{
type = "horror", subtype = "eldritch",
display = "h",
name = "Vilespawn", color=colors.GREEN,
image="npc/horror_eldritch_oozing_horror.png",
desc = "This mass of putrid slime burst from Corpathus, and seems quite hungry.",
body = { INVEN = 10, MAINHAND=1, OFFHAND=1, },
rank = 2,
life_rating = 8, exp_worth = 0,
life_regen=0,
max_vim=200,
max_life = resolvers.rngavg(50,90),
infravision = 20,
autolevel = "dexmage",
ai = "summoned", ai_real = "tactical", ai_state = { talent_in=2, ally_compassion=0},
stats = { str=15, dex=18, mag=18, wil=15, con=10, cun=18 },
level_range = {10, nil}, exp_worth = 0,
silent_levelup = true,
combat_armor = 0, combat_def = 24,
combat = { dam=resolvers.rngavg(10,13), atk=15, apr=15, dammod={mag=0.5, dex=0.5}, damtype=engine.DamageType.BLIGHT, },
resists = { [engine.DamageType.BLIGHT] = 100, [engine.DamageType.NATURE] = -100, },
on_melee_hit = {[engine.DamageType.DRAINLIFE]=resolvers.mbonus(10, 30)},
melee_project = {[engine.DamageType.DRAINLIFE]=resolvers.mbonus(10, 30)},
resolvers.talents{
[who.T_DRAIN]={base=1, every=7, max = 10},
[who.T_SPIT_BLIGHT]={base=1, every=6, max = 9},
[who.T_VIRULENT_DISEASE]={base=1, every=9, max = 7},
[who.T_BLOOD_FURY]={base=1, every=8, max = 6},
},
resolvers.sustains_at_birth(),
faction = who.faction,
summoner = who, summoner_gain_exp=true,
}
m:resolve()
game.zone:addEntity(game.level, m, "actor", x, y)
end,
wielder = {
inc_damage={[DamageType.BLIGHT] = 5,},
combat_critical_power = 0,
cut_immune=-0.25,
max_vim=20,
},
}