Dolorre Posted December 13, 2014 Share Posted December 13, 2014 This is my first time making a mod, and while I have been able to get everything else working, I cannot get the item to be able to ignite things. I looked at the lighter and torch for help, and I think the part that lets the item ignite things is this: inst:AddComponent("weapon") inst.components.weapon:SetDamage(TUNING.LIGHTER_DAMAGE) inst.components.weapon:SetAttackCallback( function(attacker, target) if target.components.burnable then if math.random() < TUNING.LIGHTER_ATTACK_IGNITE_PERCENT*target.components.burnable.flammability then target.components.burnable:Ignite() end end end ) In the torch version, the TUNING.LIGHTER_DAMAGE is replaced with TUNING.TORCH_DAMAGE, and the TUNING.LIGHTER_ATTACK_IGNITE_PERCENT is replaced with TUNING.TORCH_ATTACK_IGNITE_PERCENT. My item in the code is referred to as "hat_vat." Could someone please help me with the code so my item ignites things? I'll keep trying to mess with the code, but this is stumping me. Thanks! Dolorre Link to comment Share on other sites More sharing options...
Dolorre Posted December 13, 2014 Author Share Posted December 13, 2014 I found the tuning part of the code, and what numbers they represented (if that makes any sense). It didn't do anything, and I can't get it to work. Here's all of my code:local assets={ Asset("ANIM", "anim/hat_vat.zip"), Asset("ATLAS", "images/inventoryimages/hat_vat.xml")}local prefabs = {}local function onpickup(inst, owner) inst:RemoveComponent("cooker") inst.Light:Enable(false)endlocal function ondrop(inst, owner) inst:AddComponent("cooker") inst.Light:Enable(true)endlocal function onequip(inst, owner) inst.components.burnable:Ignite() owner.AnimState:OverrideSymbol("swap_hat", "hat_vat", "swap_hat") owner.AnimState:Show("HAT") owner.AnimState:Show("HAT_HAIR") owner.AnimState:Hide("HAIR_NOHAT") owner.AnimState:Hide("HAIR") if owner:HasTag("player") then owner.AnimState:Hide("HEAD") owner.AnimState:Show("HEAD_HAIR") end local light = inst.entity:AddLight() light:SetFalloff(0.4) light:SetIntensity(.7) light:SetRadius(2.5) light:SetColour(180/255, 195/255, 150/255) light:Enable(true)endlocal function onunequip(inst,owner) inst.components.burnable:Extinguish() owner.components.combat.damage = owner.components.combat.defaultdamage owner.AnimState:Hide("HAT") owner.AnimState:Hide("HAT_HAIR") owner.AnimState:Show("HAIR_NOHAT") owner.AnimState:Show("HAIR") if owner:HasTag("player") then owner.AnimState:Show("HEAD") owner.AnimState:Hide("HEAD_HAIR") end inst.Light:Enable(false)endlocal function fn(Sim) local inst = CreateEntity() local trans = inst.entity:AddTransform() local anim = inst.entity:AddAnimState() anim:SetBank("featherhat") anim:SetBuild("hat_vat") anim:PlayAnimation("anim") local minimap = inst.entity:AddMiniMapEntity() minimap:SetIcon("lighter.png") inst:AddComponent("weapon") inst.components.weapon:SetDamage(17) inst.components.weapon:SetAttackCallback( function(attacker, target) if target.components.burnable then if math.random() < .5*target.components.burnable.flammability then target.components.burnable:Ignite() end end end ) MakeInventoryPhysics(inst) inst:AddTag("irreplaceable") inst:AddTag("hat") inst:AddComponent("inventoryitem") inst.components.inventoryitem.atlasname = "images/inventoryimages/hat_vat.xml" inst:AddComponent("equippable") inst.components.equippable.equipslot = EQUIPSLOTS.HEAD inst:AddComponent("inspectable") inst:AddComponent("lighter") inst:AddComponent("heater") inst.components.heater.equippedheat = 5 inst:AddComponent("burnable") inst.components.burnable.canlight = false inst.components.burnable.fxprefab = nil --inst.components.burnable:AddFXOffset(Vector3(0,1.5,-.01)) inst.components.equippable:SetOnPocket( onpickup ) inst.components.inventoryitem:SetOnDroppedFn( ondrop ) inst.components.equippable:SetOnEquip( onequip ) inst.components.equippable:SetOnUnequip( onunequip ) return instendreturn Prefab( "common/inventory/hat_vat", fn, assets)If anyone can help me get this item to ignite things (like trees) I would be most grateful! Dolorre Link to comment Share on other sites More sharing options...
Mobbstar Posted December 13, 2014 Share Posted December 13, 2014 The stuff you found is for combat, you use the "lighter" component for hand-held items. If you want it to cause fire around it, try the "propagator" component, Link to comment Share on other sites More sharing options...
Dolorre Posted December 13, 2014 Author Share Posted December 13, 2014 I can't get the propagator to work, but that's okay. I think it adds more of a challenge if you have to make a torch to set things on fire Thanks for trying, though! Link to comment Share on other sites More sharing options...
Mobbstar Posted December 13, 2014 Share Posted December 13, 2014 I didn't explain how to use that component, did I... You can have it spread fire at all times by adding thisinst.components.propagator.currentheat = 100inst.components.propagator.decayrate = 0inst.components.propagator.flashpoint = 1000inst.components.propagator:StartSpreading()Additionally, there are propagaterange and heatoutput variables. If a thing with propagator (e.g. trees) gets close to something with high propagator heat, it heats up itself and eventually combusts. Link to comment Share on other sites More sharing options...
Dolorre Posted December 14, 2014 Author Share Posted December 14, 2014 I wanted the hat to act like Willow's lighter, but I nixed that idea. Any proper pyro would be fine with making their own fire-starting devise XD Thanks for the info, though! I might play around with that. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.
Please be aware that the content of this thread may be outdated and no longer applicable.