Vindorable Posted June 30, 2016 Share Posted June 30, 2016 (edited) I'm trying to make an object throwable in DST. I've checked out the Throwable Rocks and Throwable Spears mods from the workshop but that is not what I'm after. The main reason for throwing things around is simply for fun! The object that I find closest (minus the damage portion) to what I'm after is Coconade from DS - Shipwrecked DLC. I tried copy/pasting some of the codes over but it doesn't work. Can anyone help me? Edited June 30, 2016 by Vindorable Link to comment https://forums.kleientertainment.com/forums/topic/68566-how-to-make-a-throwable-object/ Share on other sites More sharing options...
RyanandLink Posted June 30, 2016 Share Posted June 30, 2016 Try checking out the water balloon, it's something you can throw too! Link to comment https://forums.kleientertainment.com/forums/topic/68566-how-to-make-a-throwable-object/#findComment-788909 Share on other sites More sharing options...
WORLDSBIGGEST Posted July 1, 2016 Share Posted July 1, 2016 (edited) if you're looking at the shipwrecked files, it might also be worth looking at rawling or the silly monkey ball. From what I remember neither did any damage. Edited July 1, 2016 by WORLDSBIGGEST Link to comment https://forums.kleientertainment.com/forums/topic/68566-how-to-make-a-throwable-object/#findComment-789047 Share on other sites More sharing options...
Vindorable Posted July 1, 2016 Author Share Posted July 1, 2016 19 hours ago, RyanandLink said: Try checking out the water balloon, it's something you can throw too! Didn't know there is such a thing as water balloon in the game... but yes, that's exactly what I need and it works! Thank you so much 8 hours ago, WORLDSBIGGEST said: if you're looking at the shipwrecked files, it might also be worth looking at rawling or the silly monkey ball. From what I remember neither did any damage. Ahh yes those too but its already working for me now. Thanks anyways! Link to comment https://forums.kleientertainment.com/forums/topic/68566-how-to-make-a-throwable-object/#findComment-789111 Share on other sites More sharing options...
Vindorable Posted July 8, 2016 Author Share Posted July 8, 2016 (edited) Hello guys... sorry to bumb this topic again.. How do I set the range of the projectile? Here is my codes that I got from the water balloons. ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ local assets= { Asset("ANIM", "anim/test.zip"), Asset("ANIM", "anim/swap_test.zip"), Asset("ATLAS", "images/inventoryimages/test.xml"), Asset("IMAGE", "images/inventoryimages/test.tex"), } ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ local function OnHit(inst, attacker, target) SpawnPrefab("test").Transform:SetPosition(inst.Transform:GetWorldPosition()) inst:Remove() end local function onequip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_test", "swap_test") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function onunequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") end local function onthrown(inst) inst:AddTag("NOCLICK") inst.persists = false --inst.AnimState:PlayAnimation("spin_loop", true) -- commented out since there is no "spin_loop" animation inst.AnimState:PlayAnimation("idle") inst.Physics:SetMass(1) inst.Physics:SetCapsule(0.2, 0.2) inst.Physics:SetFriction(0) inst.Physics:SetDamping(0) inst.Physics:SetCollisionGroup(COLLISION.CHARACTERS) inst.Physics:ClearCollisionMask() inst.Physics:CollidesWith(COLLISION.WORLD) inst.Physics:CollidesWith(COLLISION.OBSTACLES) inst.Physics:CollidesWith(COLLISION.ITEMS) end local function ReticuleTargetFn() local player = ThePlayer local ground = TheWorld.Map local x, y, z --Attack range is 8, leave room for error --Min range was chosen to not hit yourself (2 is the hit range) for r = 6.5, 3.5, -.25 do x, y, z = player.entity:LocalToWorldSpace(r, 0, 0) if ground:IsPassableAtPoint(x, y, z) then return Vector3(x, y, z) end end return Vector3(x, y, z) end ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ local function init() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddSoundEmitter() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("test") inst.AnimState:SetBuild("test") inst.AnimState:PlayAnimation("idle") inst:AddComponent("reticule") inst.components.reticule.targetfn = ReticuleTargetFn inst.components.reticule.ease = true if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("locomotor") inst:AddComponent("complexprojectile") inst.components.complexprojectile:SetHorizontalSpeed(15) inst.components.complexprojectile:SetGravity(-35) inst.components.complexprojectile:SetLaunchOffset(Vector3(.25, 1, 0)) inst.components.complexprojectile:SetOnLaunch(onthrown) inst.components.complexprojectile:SetOnHit(OnHit) inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "test" inst.components.inventoryitem.atlasname = "images/inventoryimages/test.xml" inst:AddComponent("tradable") inst.components.tradable.goldvalue = 10 inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(onequip) inst.components.equippable:SetOnUnequip(onunequip) inst.components.equippable.equipstack = false MakeHauntableLaunchAndSmash(inst) return inst end ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ return Prefab( "common/objects/test", init, assets) ------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------------------ Edited July 8, 2016 by Vindorable Link to comment https://forums.kleientertainment.com/forums/topic/68566-how-to-make-a-throwable-object/#findComment-790863 Share on other sites More sharing options...
Vindorable Posted July 10, 2016 Author Share Posted July 10, 2016 Anybody?... Link to comment https://forums.kleientertainment.com/forums/topic/68566-how-to-make-a-throwable-object/#findComment-791410 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