Lionlucas Posted April 6 Share Posted April 6 In a character mod, I have a shuriken prefab with a projectile component. The item works completely fine except that whenever the shuriken misses its target, the shuriken just keeps going! The only thing that changes when the projectile misses is that the item plays the idle animation and you can pick up the item (but that's probably just because I have an ondropped function). If you pick up the item and then drop it again, the projectile will keep moving. the print functions in the OnMiss function always run correctly when it misses, but nothing happens other than what happens in the OnMiss function. Can someone help me? Here is my code in the prefab (i mostly just took the code from the boomerang): local assets = { Asset("ANIM", "anim/shuriken.zip"), Asset("ATLAS", "images/shuriken.xml"), Asset("IMAGE", "images/shuriken.tex") } local function OnThrown(inst, owner, target) if target ~= owner then owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_throw") end inst.AnimState:PlayAnimation("spin", true) inst.components.inventoryitem.pushlandedevents = false end local function OnDropped(inst) inst.AnimState:PlayAnimation("idle") inst.components.inventoryitem.pushlandedevents = true inst:PushEvent("on_landed") end local function OnUnequip(inst, owner) owner.AnimState:Hide("ARM_carry") owner.AnimState:Show("ARM_normal") local skin_build = inst:GetSkinBuild() if skin_build ~= nil then owner:PushEvent("unequipskinneditem", inst:GetSkinName()) end end local function OnEquip(inst, owner) local skin_build = inst:GetSkinBuild() if skin_build ~= nil then owner:PushEvent("equipskinneditem", inst:GetSkinName()) owner.AnimState:OverrideItemSkinSymbol("swap_object", skin_build, "shuriken", inst.GUID, "idle" ) else owner.AnimState:OverrideSymbol("swap_object", "shuriken", "idle") end owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") end local function OnMiss(inst, owner, target) print(inst) print(owner) print(target) OnDropped(inst) end local function OnHit(inst, owner, target) OnDropped(inst) if target ~= nil and target:IsValid() and target.components.combat then local impactfx = SpawnPrefab("impact") if impactfx ~= nil then local follower = impactfx.entity:AddFollower() follower:FollowSymbol(target.GUID, target.components.combat.hiteffectsymbol, 0, 0, 0) impactfx:FacePoint(inst.Transform:GetWorldPosition()) end end end local function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) RemovePhysicsColliders(inst) inst.AnimState:SetBank("shuriken") inst.AnimState:SetBuild("shuriken") inst.AnimState:PlayAnimation("idle") inst:AddTag("thrown") inst:AddTag("weapon") inst:AddTag("projectile") inst.entity:SetPristine() MakeInventoryFloatable(inst, "small", 0, 1) if not TheWorld.ismastersim then return inst end inst:AddComponent("weapon") inst.components.weapon:SetDamage(TUNING.BOOMERANG_DAMAGE * 1.5) inst.components.weapon:SetRange(TUNING.BOOMERANG_DISTANCE, TUNING.BOOMERANG_DISTANCE+2) inst:AddComponent("inspectable") inst:AddComponent("projectile") inst.components.projectile:SetSpeed(1) inst.components.projectile:SetHoming(false) inst.components.projectile:SetCanCatch(false) inst.components.projectile:SetRange(TUNING.BOOMERANG_DISTANCE) inst.components.projectile:SetOnThrownFn(OnThrown) inst.components.projectile:SetOnHitFn(OnHit) inst.components.projectile:SetOnMissFn(OnMiss) inst:AddComponent("inventoryitem") inst.components.inventoryitem:SetOnDroppedFn(OnDropped) inst.components.inventoryitem.imagename = "shuriken" inst.components.inventoryitem.atlasname = "images/shuriken.xml" inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) MakeHauntableLaunch(inst) return inst end return Prefab("shuriken", fn, assets) Another small problem, but not as important is that the object dosen't appear in the player's hand, but I know this is just because I don't know how the functions work but maybe someone can tell me how OverrideItemSkinSymbol and OverrideSymbol works 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