I was/am having an issue where if a creature is slain, w/ Lootable Corpse set TRUE, and the PC does this to loot the corpse (for whatever reason) - open loot, close loot, then open loot & pillage
The corpse was not decaying, w/ Decay set TRUE. This is a problem if, uh, a PC drops his sword and the creature dies on top of it! (basically you'd have to write a script to force the corpse to decay, to get the sword back).
So was trying to check the corpse's Inventory to see when it gets emptied, then DestroyObject(oCorpse) on a pseudo-heartbeat ... but my debug kept telling me that the Inventory was empty and therefore the corpse kept disappearing, before any looting was done.
so I ran some extra debug and found this out:
OnDeath w/LootableCorpse (hardcoded) - the engine creates an invisible object with name "Remains" and tag "BodyBag" <-- this is what needs to be checked for Inventory.
notes
- the BodyBag section of creature properties is from NwN1 ... no workie in NwN2, not effectively. (suggest, leave on Default)
- the corpse retains the same tag it had while alive and is a Valid_Object in the game, until it decays. Clicking on that object should then 'access' the invisible Remains/BodyBag-object with its Inventory.
- the .Sef to remove is "fx_lootbag" ...
QUESTION: What is NwN2SpecialEffect "fx_lootbag" really applied to???!
cheers,
here's the code; i hope someone finds it amusing ..
----
// gotto run this before PC has a chance to grab anything out of Inventory:
void kL_SetRemainsAsPossessor(object oItem)
{
object oPossessor = GetItemPossessor(oItem);
// this goes away when Tholly decays
SetLocalObject(OBJECT_SELF, "kL_oPossessor_thol", oPossessor);
string sPossessor = GetName(oPossessor);
SendMessageToPC(GetFirstPC(FALSE), ". . . Set Remains - oPossessor : " + sPossessor);
}
// kL, let's make sure Tholly's corpse disappears after it's looted
// - have been running into a problem where sometimes it does not decay
// properly, and if it happens to be on top of a disarmed weapon (or
// the Fire Giant King's corpse, which has to be looted before PC can
// leave the Fire Giant's canyon) this could be anything from a P.O.
// to game-breaking.
// notes: Tholly has a big corpse, cannot loot or pick up anything underneath it;
// the corpse does not decay sometimes, esp. when her inventory is opened and
// then closed & then opened again & looted ...
// - usually she decays fine; this is a safety.
void kL_DecayTholly(int bDoneOnce = FALSE, int bDoneTwice = FALSE, object oPossessor = OBJECT_SELF)
{
object oPC = GetFirstPC(FALSE); // debug only.
object oThol = OBJECT_SELF;
// object oThol = GetObjectByTag("3031_tholapsyx");
string sCalledBy = GetName(oThol); // debug only.
SendMessageToPC(oPC, ". running ( kL_DecayTholly ) from " + sCalledBy);
if (!GetIsObjectValid(oThol)) return;
else SendMessageToPC(oPC, ". . Tholly is Valid");
object oItem;
if (!bDoneOnce)
{
// has to be called from a creature, placeable, etc.
oItem = GetFirstItemInInventory(oThol);
string sItem = GetName(oItem);
SendMessageToPC(oPC, ". . . First Fire - item : " + sItem);
// this needs to fire *after* Tholly's inventory items have been
// transferred to "Remains" (tag: BodyBag), but *before* PC has
// a chance to loot oItem ... hence the short Delay:
DelayCommand(0.1f, kL_SetRemainsAsPossessor(oItem));
}
else
{
if (!bDoneTwice)
{
bDoneTwice = TRUE;
oPossessor = GetLocalObject(oThol, "kL_oPossessor_thol");
}
string sPossessor = GetName(oPossessor);
SendMessageToPC(oPC, ". . . First Fire done - oPossessor : " + sPossessor);
oItem = GetFirstItemInInventory(oPossessor);
// if Tholly's remains have been looted, destroy the corpse/Remains:
if (!GetIsObjectValid(oItem))
{
SendMessageToPC(oPC, ". . . no Item in Inventory, DESTROY Tholly");
// but I hate these empty lootbags lying around:
// none of these work!!!! The .Sef is probably applied to a Location ...
// can't see any way to remove those.
// RemoveSEFFromObject(oThol, "fx_lootbag");
// RemoveSEFFromObject(oPossessor, "fx_lootbag");
// RemoveSEFFromObject(GetArea(oThol), "fx_lootbag");
SetIsDestroyable(TRUE, FALSE, FALSE);
DestroyObject(oThol, 2.0f, FALSE);
return;
}
}
SendMessageToPC(oPC, ". . corpse & inventory Valid, re-fire");
DelayCommand(12.0f, kL_DecayTholly(TRUE, bDoneTwice, oPossessor));
}
// OnDeath script ( w/ etc ):
void main()
{
// [ onDeath stuff removed ]
// kL, let's make sure Tholly's corpse disappears after it's looted
// nota bene, this can be called from Tholly's corpse, since it depends
// on her corpse existing to have relevance (once it's gone who cares)!
kL_DecayTholly();
}----
Any ideas on how to get rid of the glowing, pale blue loot-VFX ?
Modifié par kevL, 16 janvier 2012 - 12:26 .





Retour en haut







