Jump to content

Destroying items taken via script


Skye

Recommended Posts

Is there an easier way to destroy items taken from player inventory via script than calling DestroyItem() for every single instance?

The problem I have is the following: Let's say I want an NPC to accept a stack of items, for instance 10 sunstone gems. Doing that is simple enough by using TakePartyItemNum("MISC18",10). The issue here is that every single gem is taken individually and ends up occupying its own inventory slot (which is a problem in and of itself but whatever), meaning that if I call DestroyItem("MISC18") immediately after, it will only destroy one gemstone and the other 9 will still be occupying the slots. Is there a way to avoid having to call DestroyItem() ten times in a row?

I know that one option would be to create an invisible creature, have it take the items and destroy itself, but I was just wandering if there's a better way.

Link to comment

I don't know... but presumably the area script could take the items... which then, won't have them left anywhere.

Which is why the smiths and others like Thalantyr & Cespenar all have their own special small areas in the game.

Edited by Jarno Mikkola
Link to comment

Hrm, I haven't actually tried that. I've never seen any of the smiths do that either. As far as I know, they all take and destroy your items via conversation actions.

I'll take it under consideration. It would certainly make my dialog files cleaner, although maintenance becomes a bit more of a chore with split files.

Link to comment

Firing the actions from an area script does seem to work well enough. I did encounter one issue, however. When I use the trigger NumItemsPartyGT() from an area script, it doesn't seem to be able to detect items from bags, whereas the same trigger has no issue when used in a conversation. Since there's obviously a delay between ending a conversation and triggering the area script, I need this check to work if I want to avoid shenanigans from players.

Any ideas?

Link to comment

Use the dialog to detect the items and then gives a go to have the option to give the items to the NPC, that then fires an area scripts action via a

THEN

SetGlobal(customthing,GLOBAL,1)

END

..with ends in a closure of the action, say like:

IF

Global(customthing,GLOBAL,1)

THEN

RESPONSE #100

//Takealltheitems

SetGlobal(customthing,GLOBAL,2)

END

Extended to the top to the area script. It fires about 15 times a second, so the dialog exit should distract the player enough for them not to be able to remove the items before they are gone.

Link to comment

Yeah, that's exactly what I did. And the first thing I tried after testing it was if I could pause the game and drop the items before the script fires and I had no trouble doing so. The disconnect between the two events isn't really something I'm comfortable with. It should be just fine in practice, but the perfectionist in me is struggling really hard with introducing an obvious exploit into the mod. Also the fact that the same triggers from the area script and the dialog file work differently is entirely mind-boggling to me.

It's always one step forward, two steps back...

Link to comment

Join the conversation

You are posting as a guest. 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.

×
×
  • Create New...