Thoong Posted November 20, 2014 Share Posted November 20, 2014 (edited) i try to make it spawn a hound tooth but it doesn't. here the script.local assets={Asset("ANIM", "anim/shuriken.zip"),Asset("ANIM", "anim/swap_shuriken.zip"), Asset("ATLAS", "images/inventoryimages/shuriken.xml"), Asset("IMAGE", "images/inventoryimages/shuriken.tex"),} local prefabs ={ "houndstooth",}local delchance = 0.5local dropchance = 0.5local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_shuriken", "swap_shuriken") owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") endlocal function OnDropped(inst) inst.AnimState:PlayAnimation("ground")endlocal function OnUnequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") endlocal function OnThrown(inst, owner, target) if target ~= owner then owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw") end inst.AnimState:PlayAnimation("spin_loop", true)endlocal function OnHit(inst, owner, target) local impactfx = SpawnPrefab("impact") if impactfx then local follower = impactfx.entity:AddFollower() follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0 ) impactfx:FacePoint(inst.Transform:GetWorldPosition()) end if math.random() < delchance then OnDropped(inst) else if math.random() < dropchance then local dropdead = SpawnPrefab("houndstooth") local pt = inst:GetPosition() dropdead.Transform:SetPosition(pt.x, pt.y, pt.z) inst:Remove() end inst:Remove() endendlocal function fn(Sim)local inst = CreateEntity()local trans = inst .entity:AddTransform()local anim = inst.entity:AddAnimState() MakeInventoryPhysics(inst) RemovePhysicsColliders(inst) anim:SetBank("shuriken") anim:SetBuild("shuriken") anim:PlayAnimation("ground") anim:SetRayTestOnBB(true); inst:AddTag("projectile") inst:AddTag("thrown") inst:AddComponent("weapon") inst.components.weapon:SetDamage(50) inst.components.weapon:SetRange(10, 15) ------ inst:AddComponent("inspectable") inst:AddComponent("projectile") inst.components.projectile:SetSpeed(25) inst.components.projectile:SetOnThrownFn(OnThrown) inst.components.projectile:SetOnHitFn(OnHit) inst:AddComponent("stackable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "shuriken" inst.components.inventoryitem.atlasname = "images/inventoryimages/shuriken.xml" inst.components.inventoryitem:SetOnDroppedFn(OnDropped) inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) inst.components.equippable.equipstack = true return instendreturn Prefab( "common/inventory/shuriken", fn, assets) Thank you :3 Edited November 21, 2014 by Thoong Link to comment https://forums.kleientertainment.com/forums/topic/44523-need-helpprefab-not-spawn/ Share on other sites More sharing options...
Mobbstar Posted November 20, 2014 Share Posted November 20, 2014 you have to set the tooths position to the shuriken, or where ever you want it spawn at.dropdead.Transform:SetPosition()I think you can comment the "if dropdead then" out, since it only runs when that variable is true anyways.math.random() return something from 0 to 1 (excluding 1 itself). Thus the chance should be a decimal digit. Link to comment https://forums.kleientertainment.com/forums/topic/44523-need-helpprefab-not-spawn/#findComment-571409 Share on other sites More sharing options...
Thoong Posted November 20, 2014 Author Share Posted November 20, 2014 you have to set the tooths position to the shuriken, or where ever you want it spawn at.dropdead.Transform:SetPosition()I think you can comment the "if dropdead then" out, since it only runs when that variable is true anyways.math.random() return something from 0 to 1 (excluding 1 itself). Thus the chance should be a decimal digit. Thank a lot m8, It help me a lot. Link to comment https://forums.kleientertainment.com/forums/topic/44523-need-helpprefab-not-spawn/#findComment-571418 Share on other sites More sharing options...
Thoong Posted November 21, 2014 Author Share Posted November 21, 2014 oh gosh.Mobbstar pls help me again. The first "dropdead" spawned. And when it spawn for the second it will stacked up and move to the last prefab I don't even know how to fix this.Please help me again :3 (It's there about DLC things?) Link to comment https://forums.kleientertainment.com/forums/topic/44523-need-helpprefab-not-spawn/#findComment-571927 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