Jump to content

Recommended Posts

So I'm still fairly new to modding and all, but I understand the basics of making a character and adding items (adding functionality to the items however... not so much.) One of the characters we're making has multiple magic wands, a majority of which spawn prefabs. I already have the custom prefabs that they spawn when the wand is used but getting the wand to actually spawn the prefab is the challenging part for me. I think there is a "oncast" function but I'm unsure of how it works.

 

There are two wands that spawn things (they're both fairly similar [or should be]).  The first one would spawn a random amount of butterflies between 5-15 on the player's screen costing sanity. Something close to this can be done in-game using c_spawn but the butterflies are clustered together, which I'd want to avoid if possible.

 

 

The other wand spawns 5 modified Abigails in a circle around the player costing either health or sanity (maybe both). This would probably utilize the same spawning function as the other wand but the amount and placement of each ghost/prefab would be constant. 

 

 

(Looking at how Wickerbottom's books it uses a birdspawner of sorts. This could work as there is a butterflyspawner but it'd be prefered to spawn them in outright. Looking at the same book.lua file I'm only getting more confused on how it determines where the bird will spawn.)

 

Edit:

 

While looking at staff_tornado.lua which spawns in a tornado on use I found this:

local function spawntornado(staff, target, pos)local tornado = SpawnPrefab("tornado")tornado.WINDSTAFF_CASTER = staff.components.inventoryitem.ownerlocal spawnPos = staff:GetPosition() + TheCamera:GetDownVec()local totalRadius = target.Physics and target.Physics:GetRadius() or 0.5 + tornado.Physics:GetRadius() + 0.5local targetPos = target:GetPosition() + (TheCamera:GetDownVec() * totalRadius)tornado.Transform:SetPosition(getspawnlocation(staff, target):Get())tornado.components.knownlocations:RememberLocation("target", targetPos)

This could be used if I replace tornado with Abigail or butterfly, but how would I set the amount it spawns in when used? And is there a way to make it so it spawns in a shape around the player?

Edited by PrinceKawaii

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