Aller au contenu

Photo

Fyi & question: dropped items on a Lootable corpse ( resolved )


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
kevL

kevL
  • Members
  • 4 074 messages
jeez i had to run through hoops to figure this out:
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 .


#2
kevL

kevL
  • Members
  • 4 074 messages
hey, i did it!! (i'm so happy)

it was really simple, after M.R. started asking questions about bodybags: Destroy the empty BodyBag (as well as the corpse), doh.

#3
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Hey, here's something that also may be interesting and relevant. Didn't think to post it before. The way to make creatures not drop loot for sure is to set the local int "X2_L_NOTREASURE" to 1. That keeps them from dropping loot every time in my experience.

#4
kevL

kevL
  • Members
  • 4 074 messages
ya, tks Matt

but no treasure is not an option ;)


I mean, i guess a fella could spawn treasure in a chest or even on the ground. What i'm getting really seems to be an engine issue; i think I can recreate it on standard drops. On a decayable corpse w/ more than 1 treasure : Open Loot. Take one treasure. Close Loot window via [X].

Don't move and click corpse - the action queue shows a brief action, but does nothing. Then click & Open loot 2nd time. Loot all!


corpse/bodybag/VFX won't decay on my end :\\

After more testing I'll probably put kL_DecayCorpse() into my Override's default OnDeath script, nw_c2_default7. It is same as above but with

// destroy the BodyBag:
AssignCommand(oPossessor, SetIsDestroyable(TRUE, FALSE, FALSE));
DestroyObject(oPossessor, 1.0f, FALSE);

// destroy the Corpse:
SetIsDestroyable(TRUE, FALSE, FALSE);
DestroyObject(OBJECT_SELF, 2.0f, FALSE);


in the obvious place. ( i really was resigned to empty baggies lying 'round, till we looked further into BodyBag! :)