Jump to content
The Indie Stone Forums
MrCakehat

Spawning an object through using/firing a weapon?

Recommended Posts

Hey all, I am wondering how I would go about spawning an object, say for example a box or a barrel or whatever, when the player fires a specific weapon?

What I'm thinking of is just messing around with something the player can equip, which will "Auto-create" something else, maybe a box, or another weapon or something, when the equipped weapon is fired, how would I go about starting to do something like that?

Share this post


Link to post
Share on other sites

It depends on what "spawning" means to you.

 

If you want a new item in the inventory after the weapon is fired then you could use the "OnWeaponHitCharacter" event and "AddItem" to spawn stuff in the player's inventory when he hits something. If you want it to happen when he uses the weapon the event "OnWeaponSwing" would be your friend.

 

For more events check out the event reference on pz-mods.net.

 

If you want to spawn a world object ... then well you should look at some of the carpentry code :)

Share this post


Link to post
Share on other sites

Ah thank you that helps a lot, I'll have a good look at the references, see what I can do.

And yeah I was thinking of a world object, something that would appear where the player is standing

Share this post


Link to post
Share on other sites

I just updated my tutorial and included a small part on how to use events.

 

There should be a method to drop items directly on the ground (what's used when cutting down a tree for example) but I'm not sure which one it is right now. I'll see if I can find out later :)

 

P.S.: May I make a guess? Will your mod spawn empty shells on the ground when shooting a pistol? :)

Share this post


Link to post
Share on other sites

Thanks for that, It's a bit better to understand

haha yeah something like that, and also the objects, or shells or whatever would also have a life time and be removed. I was just going to use this as a practice mod for myself, then expand it use it on an idea I've got

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...