Jump to content

Recommended Posts

Hi! for a mod character I'm working on, one of her craftable weapons is a single use syringe, that's supposed to drop a food item after it breaks. It breaks after hitting an enemy once.

Is there a way to make it so rather than just deleting the item when its broken, it spawns another item first? Either in inventory, or on the ground.

Thank you for any help.

9 minutes ago, Meepenator said:

spear1.lua used a spear for example but everything you need is here, it'll spawn whatever prefab you replace it with at the owner's feet and die in 1 use.

Thank you so much for that.

One small thing I didn't put though is what enemy. No matter what it hits it'll always spawn the thing i.e spiders, walls, lure plants doesn't matter, but idk if you care about that lol

10 minutes ago, PocketPossum said:

Thank you so much for that.

 

19 minutes ago, Meepenator said:

One small thing I didn't put though is what enemy. No matter what it hits it'll always spawn the thing i.e spiders, walls, lure plants doesn't matter, but idk if you care about that lol

 

Uh, my only preference is like, having it drop specific items if it hits players instead of enemies.
Which, if I wanna do that, would it be something like this?
 

local function onattack_spear1(inst, owner, target)
		if target:HasTag ("valkyrie") then 
					local spearspawn =	SpawnPrefab("wathgrithr_blood")	--spawn whatever item you want here!
					if spearspawn ~= nil then       
						spearspawn.Transform:SetPosition(owner.Transform:GetWorldPosition())
						end
		elseif target:HasTag ("pyromaniac") then
					local spearspawn =	SpawnPrefab("willow_blood")	--spawn whatever item you want here!
					if spearspawn ~= nil then       
						spearspawn.Transform:SetPosition(owner.Transform:GetWorldPosition())
						end
		else
					local spearspawn =	SpawnPrefab("spear")	--spawn whatever item you want here!
					if spearspawn ~= nil then       
						spearspawn.Transform:SetPosition(owner.Transform:GetWorldPosition())
						end
		end
end

 

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...