Jump to content

Recommended Posts

Hello!

I've done quite a bit of reading and trial and error to try and find answers to a particular problem I'm having with no success, so I'm hoping to turn to the community at large with a bit of a puzzle.

A character I'm crearting will come with a weapon of his own that will drop itself if picked up by a different character. Works great for its intended user, but if I test it with another character it doesn't drop the item as intended. It creates two instances of the same weapon; one on the ground and one in the attempted inventory slot. Picking up either one impacts the other, so I'm guessing it isn't emoving the object from my inventory when it drops?

The log tells me nothing and I've tried a few different ways of removing the item from the inventory, bar deleting it completely and spawning another, to no success. It doesn't crash, it just...doesn't act as intended, so I've attached more or less everything. Here is the most relevant code I can think of, though, from the weapon's prefab.

Inside fn()

inst:ListenForEvent("onputininventory", worthy)
local function worthy(inst, owner)
	if not owner:HasTag("worthy") and owner.components.inventory ~= nil then 
		owner.components.inventory:DropItem(inst, nil, true)
	end
end

 

Landon.zip

Edited by MobileOdle

You should take a look on Guts the black swordsman mod.
He have the berserker armor that as long as the mod is enabled, even if theres no one using guts, its craftable by anyone, but only him can actually pickup the armor from the ground.
Any other character trying to pick it up instantly drops it and say that they cant get this.

Edited by Kunomori

That was a good suggestion, got me where I needed to go!

 

Instead of ListenForEvent, he used this. It called, more or less, the same function except with a DoTaskInTime(0). I'd put the rest of his code here, but I'm not sure if that would be frowned upon.

AddPrefabPostInit("grenade", BerserkOnlyPostInit)

 

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...