Help - Search - Members - Calendar
Full Version: Remove all equipment on death
The Black Wyrm's Lair - Forums > Mod development resources & discussion > Modder's Workshop
aigleborgne
Hello smile.gif

I want to remove all equipment from my creature when it dies.
There are 2 solutions:
- Set all items to undropable
- Use a script

The last one doesn't work :

IF
Die()
THEN
RESPONSE #100
DestroyAllEquipment()
ReallyForceSpellDead(Myself,RED_HOLY_MIGHT)
END

Any idea?
Vlasák
As for script solution try to read my Non-lethal compat tutorial - http://www.blackwyrmlair.net/Tutorials/nonlethal.php . It contains some ideas that can be usable for your needs.

According my testing Die() is quite reliable so there should not be the problem. Have you tried run your script with True() trigger or some checking of debug global to find out whether actions in this block really work?

Maybe you could try nest your actions inside ActionOverride...
aigleborgne
Thanks for answer
The trigger "Die" works fine, since my 2nd action is executed. But all items are droped to the ground, so nothing is destroyed.

Of course, I could use undropable items, but it would be simplier with a script action.
devSin
In Baldur's Gate II, you could use DestroyAllEquipment() or the (misspelled) DestroyAllDestructableEquipment(), but I don't think they work in Baldur's Gate or TotSC (you shouldn't even be able to compile it, so I'm not sure if you're talking BG1).

Marking the items undroppable in the creature file really should be the easiest solution (assuming that Baldur's Gate respects the creature item flags). This would be tougher if you just wanted it for one instance of a generic creature, in which case you'd need to patch the items or make a new creature.

Lastly, if you know the inventory, you can just try a bunch of DestroyItem() calls, one for each item.
jastey
You could use the area script, with something like

IF
Dead("creatureDV")
THEN
"ActionOverride("creatureDV", DestroyAllEquipment())

That could work.
aigleborgne
It's a mod for BG2-Tutu / BGT, so it should work

Using undropable flag isn't easy, because I use a patching method for most of creatures in BG1, based on many external files.
I would need to add a flag just for 6 creatures.

I will test the Jastey solution and keep you informed smile.gif
CamDawg
The creature will drop all of its equipment on death, so the script won't fire until after it's already dropped everything. Undroppable flags are pretty easy; below are examples to flag a single item or all items on a creature.

CODE
// for a specific item, replace itemname with resref
COPY_EXISTING foo.cre~ ~override~
 READ_LONG  0x2bc "itm_off" ELSE 0
 READ_LONG  0x2c0 "itm_num" ELSE 0
 FOR (index = 0; index < item_num; index = index + 1) BEGIN
   READ_ASCII ("%itm_off%" + (0x14 * "%index%")) "item"
   PATCH_IF ("%item%" STRING_COMPARE_CASE "itemname" = 0) BEGIN
     READ_BYTE   ("%itm_off%" + 0x10 + (0x14 * "%index%")) "flags"
     WRITE_BYTE  ("%itm_off%" + 0x10 + (0x14 * "%index%")) ("%flags%" BOR   0b00001000) // adds undroppable flag
   END
 END
 BUT_ONLY_IF_IT_CHANGES

// for all items
COPY_EXISTING foo.cre~ ~override~
 READ_LONG  0x2bc "itm_off" ELSE 0
 READ_LONG  0x2c0 "itm_num" ELSE 0
 FOR (index = 0; index < item_num; index = index + 1) BEGIN
   READ_BYTE   ("%itm_off%" + 0x10 + (0x14 * "%index%")) "flags"
   WRITE_BYTE  ("%itm_off%" + 0x10 + (0x14 * "%index%")) ("%flags%" BOR   0b00001000) // adds undroppable flag
 END
 BUT_ONLY_IF_IT_CHANGES
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2024 Invision Power Services, Inc.