rons0n Posted March 5, 2015 Share Posted March 5, 2015 (edited) So It looks like most mods use this to make certain items character specific: inst:AddComponent("characterspecific") inst.components.characterspecific:SetOwner("whatever")In which I also use for my characters, But this seems to be no longer working. Tested with various character who also have this implemented also resulted in the same effect. Did something happen and is there a workaround? Edited March 5, 2015 by rons0n Link to comment Share on other sites More sharing options...
rezecib Posted March 5, 2015 Share Posted March 5, 2015 @rons0n, Well, what kind of behavior do you want for character-specificity? As far as I know the "characterspecific" tag only figures into the system for dropping items when you leave that are characterspecific to other players. Some examples of different behaviors you might want:- Cannot be picked up by other characters (maybe not even visible to other players)- Cannot be used/equipped by other characters- Can be used/equipped equipped by other characters, but with some penalty that makes it generally not worthwhile (e.g. taking damage while equipped) I don't believe there's any built-in system for handling these things, so you have to implement them yourself. 1 Link to comment Share on other sites More sharing options...
rons0n Posted March 5, 2015 Author Share Posted March 5, 2015 (edited) @rezecib, Drats! I was hoping it was built in, thats how I usually figure things out. Isn't there anything in Waxwell journal that can help me? Since that journal cannot be used by other people but Maxwell himself(Atleast for the mod). Guess I can't spot it. But yes, the first two things you mentioned are the behaviors that I wanted to implement to my items. I was hoping for "Just check within characters so-and-so and do that." Haha. Edited March 5, 2015 by rons0n Link to comment Share on other sites More sharing options...
rezecib Posted March 5, 2015 Share Posted March 5, 2015 @rons0n, Well, if you look at the modmain of More DST Characters, I wrote in the check for Maxwell as a patch, the game doesn't check yet by default (although it's likely Klei will add such a check when they add Maxwell officially). Only characters with a reader component could read the book anyway, so it was mainly Wickerbottom who could use it until I added the check. You could try something like this: (this should make it get dropped when someone tries to pick it up)inst.components.inventoryitem.onpickedupfn = function(inst, player) if player.prefab ~= "mymodchar" then player.components.inventory:DropItem(inst, true, true) player.components.talker:Say("It seems to slip right out of my hands!") endend 1 Link to comment Share on other sites More sharing options...
rons0n Posted March 5, 2015 Author Share Posted March 5, 2015 @rezecib, This goes into the local function fn() within the item file right? I tried this: inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "myitem" inst.components.inventoryitem.atlasname = "images/inventoryimages/myitem.xml" inst.components.inventoryitem:SetOnDroppedFn(OnDropped) inst.components.inventoryitem.onpickedupfn = function(inst, player) if player.prefab ~= "thecharacter" then player.components.inventory:DropItem(inst, true, true) player.components.talker:Say("It seems to slip right out of my hands!") endendAnd when that didn't work, I tweaked it a bit and still got the same results.But nothing seems to have changed. Link to comment Share on other sites More sharing options...
rezecib Posted March 5, 2015 Share Posted March 5, 2015 @rons0n, Oops, it should be onpickupfn 1 Link to comment Share on other sites More sharing options...
rons0n Posted March 5, 2015 Author Share Posted March 5, 2015 @rezecib, I also tried that and did not prevail sadly. local prefabs ={}local function OnUsed (inst) inst:Remove()endlocal function OnFinished(inst) inst.AnimState:PlayAnimation("used") inst:ListenForEvent("animover", inst.Remove)endlocal function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_knifethrow", "swap_knifethrow") owner.AnimState:Show("ARM_carry") owner.AnimState:Hide("ARM_normal") endlocal function OnDropped(inst) inst.AnimState:PlayAnimation("idle")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_return") end inst.AnimState:PlayAnimation("spin_loop", true)endlocal function OnCaught(inst, catcher) if catcher then if catcher.components.inventory then if inst.components.equippable and not catcher.components.inventory:GetEquippedItem(inst.components.equippable.equipslot) then catcher.components.inventory:Equip(inst) else catcher.components.inventory:GiveItem(inst) end catcher:PushEvent("catch") end endendlocal function ReturnToOwner(inst, owner) if owner and not (inst.components.finiteuses and inst.components.finiteuses:GetUses() < 1) then owner.SoundEmitter:PlaySound("dontstarve/wilson/boomerang_return") inst.components.projectile:Throw(owner, owner) endendlocal function OnHit(inst, owner, target) if owner == target or owner:HasTag("playerghost") then OnDropped(inst) else ReturnToOwner(inst, owner) end 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()) endendlocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) RemovePhysicsColliders(inst) inst:AddTag("knifethrow") if not TheWorld.ismastersim then return inst end inst.AnimState:SetBank("knifethrow") inst.AnimState:SetBuild("knifethrow") inst.AnimState:PlayAnimation("idle") inst.AnimState:SetRayTestOnBB(true) inst:AddTag("projectile") inst:AddTag("thrown") inst:AddComponent("weapon") inst.components.weapon:SetDamage(66) inst.components.weapon:SetRange(TUNING.BOOMERANG_DISTANCE, TUNING.BOOMERANG_DISTANCE+2) ------- inst:AddComponent("inspectable") inst:AddComponent("projectile") inst.components.projectile:SetSpeed(10) inst.components.projectile:SetCanCatch(true) inst.components.projectile:SetOnThrownFn(OnThrown) inst.components.projectile:SetOnHitFn(OnHit) inst.components.projectile:SetOnMissFn(ReturnToOwner) inst.components.projectile:SetOnCaughtFn(OnCaught) inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "knifethrow" inst.components.inventoryitem.atlasname = "images/inventoryimages/knifethrow.xml" inst.components.inventoryitem:SetOnDroppedFn(OnDropped) inst.components.inventoryitem.onpickupfn = function(inst, player) if player.prefab ~= "shiki" then player.components.inventory:DropItem(inst, true, true) player.components.talker:Say("It seems to slip right out of my hands!") endend inst:AddComponent("characterspecific") inst.components.characterspecific:SetOwner("shiki") inst:AddComponent("equippable") inst.components.equippable:SetOnEquip(OnEquip) inst.components.equippable:SetOnUnequip(OnUnequip) inst:AddComponent("finiteuses") inst.components.finiteuses:SetMaxUses(90) inst.components.finiteuses:SetUses(90) inst.components.finiteuses:SetOnFinished(OnUsed) MakeHauntableLaunch(inst) AddHauntableCustomReaction(inst, function(inst, haunter) local target = FindEntity(inst, 25, function(guy) return not guy:HasTag("playerghost") and guy.components.combat end) if target and math.random() <= TUNING.HAUNT_CHANCE_HALF then inst.components.projectile:Throw(haunter, target, haunter) inst.components.hauntable.hauntvalue = TUNING.HAUNT_SMALL return true end return false end, true, false, true) return instendreturn Prefab("common/inventory/knifethrow", fn, assets)Seems like anyone can still freely grab and use the knife, maybe theres something odd in my prefab? Link to comment Share on other sites More sharing options...
DarkXero Posted March 6, 2015 Share Posted March 6, 2015 Well, it actually doesn't go to your inventory, it goes into your active tool slot, onpickup doesn't cover that one.Try holding something else that is not a knife, and then try picking up the knife, and you will see. Try: inst.components.inventoryitem.onputininventoryfn = function(inst, player) if player.prefab ~= "shiki" then inst:DoTaskInTime(0.1, function() player.components.inventory:DropItem(inst) player.components.talker:Say("It seems to slip right out of my hands!") end) end endThe DoTaskInTime is needed or else you will dupe the item. 1 Link to comment Share on other sites More sharing options...
rons0n Posted March 6, 2015 Author Share Posted March 6, 2015 @DarkXero, Thanks DarkXero, this is what I was looking after. Thanks for helping me you two! Now my characters can be nerfed into oblivion so I can continue balancing them out! If anything happens though I'll make sure to say something in this thread. Yet again, thank y'all! Link to comment Share on other sites More sharing options...
rons0n Posted March 19, 2015 Author Share Posted March 19, 2015 Is it me or I'm just necro'ing my old threads all over the place. Anyway @DarkXero your code worked wonderfully but after messing with it for a bit i got bumped into an error.Whenever my specific item goes into my backpack(maybe containers too idk), my game crashes completely. Is there a remedy for that? Link to comment Share on other sites More sharing options...
SenL Posted March 19, 2015 Share Posted March 19, 2015 Can you post the error log? Link to comment Share on other sites More sharing options...
DarkXero Posted March 19, 2015 Share Posted March 19, 2015 Well, in the RoG test branch this gets kinda fixed, the item will go to your backpack and won't drop from it, but no crashes. You can try including:inst.components.inventoryitem.cangoincontainer = false Link to comment Share on other sites More sharing options...
rons0n Posted March 21, 2015 Author Share Posted March 21, 2015 (edited) So it looks like the Dev Team themselves fixed the issue today Though I may be blind but I cannot see that in the recent update notes. Just want to say thanks. /kill thread please I wish my threads didnt bump anymore... Edited March 21, 2015 by rons0n 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