paladin84 Posted October 11, 2023 Share Posted October 11, 2023 (edited) In a mod I am trying to destroy an item belongs to somebody in a party inside a dialog with a party member (basically the idea is to "upgrade the item"). The current code in a d file looks like this: TakePartyItem("NWAMULI1") DestroyItem("NWAMULI1") GiveItemCreate("NWAMULI2",Player1,0,0,0) It works properly if an item belongs to somebody but the party member who main character initiates dialog with (eg if PLAYER1 starts the dialog with PLAYER2 and the item belongs to PLAYER2). In this case, the item is moved to the inventory of PLAYER2 if it was equipped by PLAYER2, but not destroyed. What is the proper code to destroy the party item in any case. I tried it with BG2EE, not sure how it would work with oBG... Edited October 11, 2023 by paladin84 Quote Link to comment
jmerry Posted October 11, 2023 Share Posted October 11, 2023 Ah, but you're not destroying an item - you're replacing it. Try the TakeItemReplace() or TransformItem() actions. Probably the latter, as the former will give the new item even if the old item isn't present. (TransformItem is an EE-only action) Quote Link to comment
paladin84 Posted October 11, 2023 Author Share Posted October 11, 2023 TransformItem() should work perfectly (based on its description), thank you. The problem is that the mod works now (and should work) for oBG. Is there a way to do the same for oBG? And I still need an ability to destroy a party item properly in a dialog with party member (for other items). Quote Link to comment
jmerry Posted October 12, 2023 Share Posted October 12, 2023 About all I can think of on the non-EE front is more complex scripting. Gate the conversation that changes the item with a HasItem(****,LastTalkedToBy) condition, so you know the right person has it before you do anything. (And, of course, provide alternate dialogue so the player knows to talk to the NPC with the right person.) Quote Link to comment
paladin84 Posted October 12, 2023 Author Share Posted October 12, 2023 I think I found an answer by myself. If I do like this (looks horrible I know), item seems to destroyed no matter who in party has it: DestroyItem("NWAMULI1") TakePartyItem("NWAMULI1") DestroyItem("NWAMULI1") GiveItemCreate("NWAMULI2",Player1,0,0,0) Is such behaviour documented somewhere? Based of what I read at https://gibberlings3.github.io/iesdp/scripting/actions/index.htm simple TakePartyItem() and DestroyItem() should work... Quote Link to comment
jastey Posted October 13, 2023 Share Posted October 13, 2023 For a character outside of the party, the sequence TakePartyItem() DestroyItem() works usually. Also as a sequence done via ActionOverride - the sequence will be executed one after the other if the character it refers to does not change, i.e. ~ActionOverride("scriptname",TakePartyItem()) ActionOverride("scriptname",DestroyItem()) ActionOverride("scriptname",GiveItemCreate("NWAMULI2",Player1,0,0,0))~ should execute uninterrupted [caution with ActionOverride() as it can lead to all sorts of other problems in scripts, especially cutscenes]. For NPCs executing TakePartyItem() DestroyItem() I also experienced the problem that the taken item was not destroyed after the dialogue ended. In my case, this was usually the case when actions that were meant to be executed by a non-joinable character were transferred to an NPC due to an added interjection (i.e., I_C_T for a mod added NPC that transfers the transactions to that NPC). I then got bug reports that e.g. Breagar snatched an item that was meant to be taken by Thalantyr or similar. For me, I solved these cases by adding a definite ActionOverride() to the actions, so the transactions would stay with the non-joinable quest character. To me that was also a good solution, because the "TakePartyItem()" could lead to an (other) item pushed to the ground if the NPC/PC doing the action has a full inventory, which is usually a great PITA for players who should not have to check for ground piles after interactions with quest characters. - I am not sure this is an option for you. I have to admit I didn't really get your first post regarding Player1 talking to Player2. If nothing helps, you could spawn an invisible cre that takes and destroys the item. But in principle, the sequence TakePartyItem() DestroyItem() should work. Disclaimer: I'm not an expert in how the engine processes transactions, with some being processed instantly and others later etc. I am only writing out of experience. Quote Link to comment
paladin84 Posted October 13, 2023 Author Share Posted October 13, 2023 1 hour ago, jastey said: - I am not sure this is an option for you. I have to admit I didn't really get your first post regarding Player1 talking to Player2. If nothing helps, you could spawn an invisible cre that takes and destroys the item. In my case Player1 (main hero) starts dialog (PID) with a joined NPC (eg Player2) and then item that is located somewhere in any player's inventory should be destoryed during this dialog. I guess, I can use an invisible creature or a script attached to this NPC that destroy an item under a certain condition. All of these methods (and the one suggested by @jmerry) look like an "overkill" for just "destroying a party item in a dialog"... Thank you anyway for an idea. Quote Link to comment
jastey Posted October 13, 2023 Share Posted October 13, 2023 How does the full transaction look like? Did you test for empty / full inventory? Unfortunately, I found the "TakePartyItem() DestroyItem()"combo to be frickle if done by party members, too. I fear if you want to make sure it works in all cases, using some script / invisible cre will be the way to go. - In a script, you could check who has the item and let it be destroyed without having to take it first. One could also say that if adding another DestroyItem() works for you, then go with it. But like I said, if the inventory is full, this item transaction always bears the risk of the item in slot 1 being dropped to the ground. Since the whole transaction is done silently without the player being aware of the technicalities (and without giving a warning in the text box), I prefer to go the save way in my mods. - That's just IE engine for you. Quote Link to comment
Jarno Mikkola Posted October 13, 2023 Share Posted October 13, 2023 2 hours ago, jastey said: ~ActionOverride("scriptname",TakePartyItem()) ActionOverride("scriptname",DestroyItem()) ActionOverride("scriptname",GiveItemCreate("NWAMULI2",Player1,0,0,0))~ Yeah, this is the best solution. And for reference scriptname is the death variable of the invisible creature that takes the item and destroys it.. and the command can come from anyone, which is usually a participant in the dialog, or the dialog itself, depending on how you look at it. @jastey, should't that also have the create creature in the same dialog command, and also it's destroying ... I remeber this so well, I have no idea. Quote Link to comment
jastey Posted October 13, 2023 Share Posted October 13, 2023 1 minute ago, Jarno Mikkola said: the create creature in the same dialog command, and also it's destroying This refers to when using an invisible helper creature, do not forget to destroy it when it's done, because the engine can only handle x instances of it in an area. (I guess this is not as relevant any more for the EEs. still it's better to clean up afterwards.) And it definitely still applies to invisible creatures that uses clear fog of war, because the engine can only handle 8 of them in one area, with 6 being the full party). @Jarno Mikkola like I pointed out, using ActionOverride should make the transactions more stable but it doesn't help with items falling to the ground out of full NPC/PC inventories, so "best solution" is a relative term. Quote Link to comment
Jarno Mikkola Posted October 13, 2023 Share Posted October 13, 2023 (edited) 19 minutes ago, jastey said: like I pointed out, using ActionOverride should make the transactions more stable but it doesn't help with items falling to the ground out of full NPC/PC inventories, so "best solution" is a relative term. The only item that can fall to the ground is the Player1 given item, .. well or any item in their inventory that's not bolted down as it's replaced with the given item.. and as you are ordering an invisible creature to do the actions, the taken item goes with them, and will no longer be anywhere after they are ordered to do- ActionOverride("scriptname",Destroy(Self)) .. hopefully within the same command line as the other above. As should the creating it also... Something like: CreateCreatureObjectOffset("scriptname",Myself,0) Aka, the whole lenght of the thing would be: DO ~ CreateCreatureObjectOffset("scriptname",Myself,0) ActionOverride("scriptname",TakePartyItem()) ActionOverride("scriptname",DestroyItem()) ActionOverride("scriptname",GiveItemCreate("itemname",Player1,0,0,0)) ActionOverride("scriptname",Destroy(Self)) ~ END ... Edited October 13, 2023 by Jarno Mikkola Quote Link to comment
jastey Posted October 13, 2023 Share Posted October 13, 2023 ok, if you were referring to an invisible creature doing the actions then yes, that is the best solution. I jumped at the ActionOverride()s. Quote Link to comment
paladin84 Posted October 13, 2023 Author Share Posted October 13, 2023 Oh, seems the easier way to do everything properly is to use this utility creature (at least everything still can be done from d file without changing much of the current code). Thanks everyone, I will redo the code to work like this eventually. Quote Link to comment
Recommended Posts
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.