PanAzej Posted March 25, 2016 Share Posted March 25, 2016 I'm in dire need of assistance! How is the 'fade' effect on dead/destroyed things handled? I'd like to add this effect for my item, but I don't know how to do it. You know, this effect: It doesn't seem to be related to creature animations, because spriter/krane doesn't show/unpack these anims, so it's probably done in a different way. The second thing I have problem with is: I'd like to make a deployable item that isn't consumed upon being deployed. I tried to make a custom action: -- Make a special action for stickybomb launcher local STICKYBOMBING = GLOBAL.Action({ priority= -10 }) STICKYBOMBING.str = "Set Up" STICKYBOMBING.id = "STICKYBOMBING" STICKYBOMBING.fn = function(act) if act.invobject and act.invobject.prefab == "stickybomblauncher" and act.invobject.components.deployable and act.invobject.components.deployable:CanDeploy(act.pos) then local obj = act.doer.components.inventory or act.doer.components.container if obj then if obj.components.deployable:Deploy(act.pos, act.doer) then return true else act.doer.components.inventory:GiveItem(obj) end end end end AddAction(STICKYBOMBING) local stickybombing_handler = ActionHandler(ACTIONS.STICKYBOMBING, "dolongaction") AddStategraphActionHandler("wilson", stickybombing_handler) AddComponentAction("SCENE", "inventoryitem", function(inst, doer, pos, actions, right) if right and inst:HasTag("stickybomblauncher") and inst.replica.inventoryitem ~= nil and inst.replica.inventoryitem:CanDeploy(pos) then table.insert(actions, ACTIONS.STICKYBOMBING) end end) AddStategraphActionHandler("wilson_client", stickybombing_handler) It doesn't matter what priority it is, Deploy is always used instead. I tried to edit "Deploy" in deployable component, but I failed miserably at that as well. Welp. Maybe there's a different, better way to do that? Any help is welcome! Link to comment Share on other sites More sharing options...
Muche Posted March 25, 2016 Share Posted March 25, 2016 (edited) A pinecone's deployment is set up this way: local function plant(inst, growtime) local sapling = SpawnPrefab("pinecone_sapling") sapling:StartGrowing() sapling.Transform:SetPosition(inst.Transform:GetWorldPosition()) sapling.SoundEmitter:PlaySound("dontstarve/wilson/plant_tree") inst:Remove() end local function ondeploy(inst, pt, deployer) inst = inst.components.stackable:Get() inst.Physics:Teleport(pt:Get()) local timeToGrow = GetRandomWithVariance(TUNING.PINECONE_GROWTIME.base, TUNING.PINECONE_GROWTIME.random) plant(inst, timeToGrow) --... end local function fn() --... inst:AddComponent("deployable") inst.components.deployable:SetDeployMode(DEPLOYMODE.PLANT) inst.components.deployable.ondeploy = ondeploy --... end I'd guess removing the inst:Remove() from plant() should not consume it. Although, looking at DEPLOY action's call of inventory:RemoveItem(act.invobject), they seem to be interconnected. That component action doesn't seem to be set up correctly. SCENE collector function receives (inst, doer, actions, right) arguments, not (inst, doer, pos, actions, right) (that POINT collector function receives). Can you try this (in addition to not calling inst:Remove() within your stickybomblauncher's deployable.ondeploy: -- Make a special action for stickybomb launcher local STICKYBOMBING = GLOBAL.Action({ priority= 10 }) STICKYBOMBING.str = "Set Up" STICKYBOMBING.id = "STICKYBOMBING" STICKYBOMBING.fn = function(act) if act.invobject and act.invobject.prefab == "stickybomblauncher" and act.invobject.components.deployable and act.invobject.components.deployable:CanDeploy(act.pos) then if act.invobject.components.deployable:Deploy(act.pos, act.doer) then return true end end end AddAction(STICKYBOMBING) local stickybombing_handler = ActionHandler(ACTIONS.STICKYBOMBING, "dolongaction") AddStategraphActionHandler("wilson", stickybombing_handler) AddComponentAction("POINT", "deployable", function(inst, doer, pos, actions, right) if right and inst:HasTag("stickybomblauncher") and inst.replica.inventoryitem ~= nil and inst.replica.inventoryitem:CanDeploy(pos) then table.insert(actions, ACTIONS.STICKYBOMBING) end end) AddStategraphActionHandler("wilson_client", stickybombing_handler) Edited March 25, 2016 by Muche Link to comment Share on other sites More sharing options...
PanAzej Posted March 25, 2016 Author Share Posted March 25, 2016 (edited) 3 hours ago, Muche said: Can you try this (in addition to not calling inst:Remove() within your stickybomblauncher's deployable.ondeploy: -- Make a special action for stickybomb launcher local STICKYBOMBING = GLOBAL.Action({ priority= 10 }) STICKYBOMBING.str = "Set Up" STICKYBOMBING.id = "STICKYBOMBING" STICKYBOMBING.fn = function(act) if act.invobject and act.invobject.prefab == "stickybomblauncher" and act.invobject.components.deployable and act.invobject.components.deployable:CanDeploy(act.pos) then if act.invobject.components.deployable:Deploy(act.pos, act.doer) then return true end end end AddAction(STICKYBOMBING) local stickybombing_handler = ActionHandler(ACTIONS.STICKYBOMBING, "dolongaction") AddStategraphActionHandler("wilson", stickybombing_handler) AddComponentAction("POINT", "deployable", function(inst, doer, pos, actions, right) if right and inst:HasTag("stickybomblauncher") and inst.replica.inventoryitem ~= nil and inst.replica.inventoryitem:CanDeploy(pos) then table.insert(actions, ACTIONS.STICKYBOMBING) end end) AddStategraphActionHandler("wilson_client", stickybombing_handler) Thank you very much! It works perfectly! Yeah, inst:Remove() was the first thing I got rid of when trying to make it so item doesn't get deleted. It seems that it's meant to remove it on top of removing the second time within action itself to make it 100% sure item gets destroyed. Demoman is one bloody happy lad now. Edited March 25, 2016 by PanAzej Link to comment Share on other sites More sharing options...
Neu7ral Posted March 25, 2016 Share Posted March 25, 2016 4 minutes ago, PanAzej said: Damn, looks so awesome! Link to comment Share on other sites More sharing options...
Muche Posted March 25, 2016 Share Posted March 25, 2016 Regarding the fade out animation, components/health.lua|SetVal() uses ErodeAway, defined in simutil.lua, which in turn calls inst.AnimState:SetErosionParams(erode_amount, 0.1, 1.0). Link to comment Share on other sites More sharing options...
PanAzej Posted March 27, 2016 Author Share Posted March 27, 2016 On 24.03.2016 at 8:39 PM, Neutral_Steve said: Damn, looks so awesome! On 24.03.2016 at 9:11 PM, Muche said: Regarding the fade out animation, components/health.lua|SetVal() uses ErodeAway, defined in simutil.lua, which in turn calls inst.AnimState:SetErosionParams(erode_amount, 0.1, 1.0). Oh, so it's related to health component! Thank you so much once again! I got most of the things working by now, mod should be released next week, I think Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now