Jump to content

Custom Character Trait Help: Burst into Flames upon Death.


Recommended Posts

I'm working on a character mod based on vampirism.  

 

Found here: http://steamcommunity.com/sharedfiles/filedetails/?id=371350734

 

A feature I'm interested in adding is either my corpse, or my items bursting into flames on death.  Ideally, I hope for any fire on death to spread, so all of my items than can turn to ash, turn to ash.

 

I'm very new to Lua, so any pointers in the right direction would be greatly appreciated!

Link to comment
Share on other sites

Hello! I'm new to coding but I think I can help you here.

What you want seems similar to how a fire hound dies. If we look in the hound's lua file, we'll see this code near the bottom (that defines what type of hound it is):

local function fnfire(Sim)	local inst = fncommon(Sim)	inst.AnimState:SetBuild("hound_red")	    MakeMediumFreezableCharacter(inst, "hound_body")    inst.components.freezable:SetResistance(4) --because fire    inst.components.combat:SetDefaultDamage(TUNING.FIREHOUND_DAMAGE)    inst.components.combat:SetAttackPeriod(TUNING.FIREHOUND_ATTACK_PERIOD)    inst.components.locomotor.runspeed = TUNING.FIREHOUND_SPEED    inst.components.health:SetMaxHealth(TUNING.FIREHOUND_HEALTH)    inst.components.lootdropper:SetChanceLootTable('hound_fire')	inst:ListenForEvent("death", function(inst)		inst.SoundEmitter:PlaySound("dontstarve/creatures/hound/firehound_explo", "explosion")	end)		return instend

This code doesn't seem to have the death explosion you're looking for. (The death file it mentions is for the sound effect only.) However, it mentions "fnfire" which refers specifically to the fire hounds. Looking more into this lua for that specific code reveals this: (located a bit further down, near the end)

local function fnfiredrop(Sim)	local inst = CreateEntity()	inst.entity:AddTransform()    MakeInventoryPhysics(inst)    MakeLargeBurnable(inst, 6+ math.random()*6)    MakeLargePropagator(inst)    inst.components.burnable:Ignite()    inst.persists = false    inst.components.burnable:SetOnExtinguishFn(function(inst) inst:Remove() end)    return instend

I believe the code you're looking for is here:

    inst.components.burnable:Ignite()

Which should burn the things around you. If not, the code above this one is the explosion / ignite code I believe you're looking for.

How you add this to a character, I'm not sure how that would work. I don't know of any after-death codes that work in DST?

I hope this works; please tell me if it does! :D

Link to comment
Share on other sites

Wow, I can't believe I forgot fire hounds do this.  Thanks for that.  I'm also interested in this line:

 

inst.components.lootdropper:SetChanceLootTable('hound_fire')

 

I'll post back with results when I get the chance. Thanks again!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...