Jump to content

Removing items from a creature in a Die() trigger - impossible?


pro5

Recommended Posts

I've tried numerous ways, but nothing seems to work:

 

1) Applying effect opcodes 112 / 123

IF
 Die()
THEN
 RESPONSE #100
  ApplySpellRES("P5DRIW1",Myself)   // P5DRIW1 applies opcodes 112 + 123 with resource field = wanted item resref (F_DRIWP1)
  AddexperienceParty(6)	// This is just to make sure the script block actually gets executed (it does)	
END

Doesn't work, the item is not removed. Works fine if used without Die() - for example, with a HotKey() trigger.

 

2) DestroyItem

IF
 Die()
THEN
 RESPONSE #100
  DestroyItem("F_DRIWP1")
  AddexperienceParty(6)	// This is just to make sure the script block actually gets executed (it does)
END

Doesn't work, the item is not removed. Works fine if used without Die() - for example, with a HotKey() trigger.

 

3) TakeItemReplace

 

IF
 Die()
THEN
 RESPONSE #100
  TakeItemReplace("MISC75","F_DRIWP1",Myself)
  AddexperienceParty(6)	// This is just to make sure the script block actually gets executed (it does)
END

Doesn't work, the item is not removed. Works fine if used without Die() - for example, with a HotKey() trigger.

 

Out of desperation, I even tried DestroyAllEquipment() and DropItem() - those don't work with Die() either! CreateItem() + DropInventory() on the other hand do work, so it's not like inventory is untouchable at this point as the creature is about to die. Adding Wait() or SmallWait() after any of the actions does not seem to help.

Link to comment

Many actions cannot be executed by dead actors. Most of the spell actions have a *Dead() version that is identical to the normal version, except it can be executed by dead actors, e.g., ReallyForceSpellDeadRES().

 

I missed ReallyForceSpellDeadRES when searching IESDP, thanks. But unfortunately it doesn't seem to work either...

Link to comment

it does work, even vanilla bg2 uses it around 100 times (ok, mostly the id variant).

 

It doesn't specifically for my needs - to remove items. This doesn't work, unless I'm missing something:

IF
 Die()
THEN
 RESPONSE #100
  ReallyForceSpellDeadRES("P5DRIW1",Myself)   // P5DRIW1 applies opcodes 112 + 123 with resource field = wanted item resref (F_DRIWP1)
  AddexperienceParty(6)	// This is just to make sure the script block actually gets executed (it does)	
END

The item is not removed. Again, this works fine if used without Die() - for example, with a HotKey() trigger.

Link to comment
Why the item needs to be removed when the creature is dead ? Just asking, cause there could be other better ways to go about this.
IIRC it doesn't work because items drop from the inventory upon death, i.e. no longer count as equipped, unless they're flagged as non-movable.

I'm trying to prevent a certain item from dropping, replacing it with another item. I'd rather not make it undroppable because the NPC is joinable and the item is his in-party weapon. However, this item is also restricted to be usable only by the NPC (or, rather, it has some limitations which make it less useful for a PC) and if the player chooses to attack and kill the NPC instead of recruiting him, they won't be able to use it. I want the NPC to drop a different version of that item without some usability restrictions in that scenario.

Link to comment
I'm trying to prevent a certain item from dropping, replacing it with another item. I'd rather not make it undroppable because the NPC is joinable and the item is his in-party weapon. However, this item is also restricted to be usable only by the NPC
Check ToBEx, it allows such item restriction on engine level, and iirc BGEE has this feature built in as well.
Link to comment

I'd rather not make it undroppable because the NPC is joinable and the item is his in-party weapon. However, this item is also restricted to be usable only by the NPC (or, rather, it has some limitations which make it less useful for a PC) and if the player chooses to attack and kill the NPC instead of recruiting him, they won't be able to use it. I want the NPC to drop a different version of that item without some usability restrictions in that scenario.

Why not equip that different version by default and replace it by the restricted version if the character actually joins the party?

Link to comment

Thanks all for responses, the answer to original question is clearly yes, it's impossible. I just wanted to make sure I'm not messing up somewhere. I'll figure out something to do what I need, although it won't be as pretty and easy as it could be with Die().

 

Why not equip that different version by default and replace it by the restricted version if the character actually joins the party?

 

I'll probably end up doing something similar to this suggestion, it'll just be a bit more workaround work than I hoped for. BG engine offers very limited possibilities for scripting equippable items management, and whichever way you try to do it, something seems to be off or outright doesn't work. :sigh:

Link to comment

Just a thought, but I'm of a very firm opinion that trying to pull off a smart trick within an NPC mod is generally a bad idea and a waste of modder's time.

 

As mentioned above, use ToBEx or BGEE to restrict an item to a particular character, there's even a setting to allow free moving of an item in their inventory, but never taking outside of it.

 

Also you might be able to drop a new item upon death via ~GiveItemCreate() DropInventory()~, I think I've tested it once.

Link to comment

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...