Author Topic: Body Decay Time  (Read 606 times)

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Body Decay Time
« on: October 07, 2012, 08:10:20 pm »


               In the single player module I'm building I have all enemies set to leave bodies on death instead of loot bags. If they bodies aren't looted, I'm assuming the body stays there forever, despite the 60 second decay timer I've set.

The encounters I am using do not respawn, so bodies won't continually stack.

Will the bodies that are left behind cause issues eventually in a single player environment, or do they get unloaded when switching areas?
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Body Decay Time
« Reply #1 on: October 07, 2012, 09:14:32 pm »


               I wouldn't worry about this in a single player environment.
               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Body Decay Time
« Reply #2 on: October 24, 2012, 11:17:17 pm »


               Does anyone know how I could go about cleaning up corpses after a minute? It's very easy to do with loot bags and remains, but I can't seem to make it work the same for a monster corpse.

I've tried setting a delayed DestroyObject(OBJECT_SELF) on the death script, and while this works, it leaves a "glow" on the ground where the monster died. This only happens when the monster had an inventory, so I assume it has something to do with having an uncleaned inventory when destroyed.

I have also tried a loop to remove any items from the inventory of the corpse before DestroyObject, but it either A) Deletes the item from the PC inventory after the delay, or 'B)' Still leaves the "glow" on the ground.

Any ideas?
               
               

               
            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
Body Decay Time
« Reply #3 on: October 25, 2012, 12:49:56 am »


               If I'm not mistaken, the flag in the creature properties window "leave lootable corpse" works a lot like a remains bag. Essentially, as long as a single item remains in the creature's inventory it will remain a selectable container. Once no items are in the containers AND it's been closed, the standard decay timer begins to count down and the body becomes unselectable. There are ways to make the body persist even after the container is empty, but it sounds like you want a clean-up.

Basically, I'd try removing all items (in-game) from the lootable corpse container and walking away, since I'm pretty sure it will decay like a remains bag. I'm not positive though, so you'll want to check it. Maybe use a shorter time for testing. As long as the creature is "destroyable" (which should be set by default, I believe) it should fade once its loot is gone. (Note: The standard henchman scripts make the henchman non-destroyable to prevent fading, so any similar scripts that have "SetIsDestroyable" might change this behavior.)
               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Body Decay Time
« Reply #4 on: October 25, 2012, 01:44:26 am »


               You are correct. I suppose I should clarify what I'm looking for.

I'm looking for a way to clean up a body whether or not it has been looted. The body decays like normal if it's looted, but I also want it to disappear after so long if it is ignored.

I'm now working with monsters that re-spawn every 30 minutes, so I don't want un-looted bodies to start stacking up if a player decides to farm a specific area more than once and not pick anything up.
               
               

               
            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
Body Decay Time
« Reply #5 on: October 25, 2012, 02:19:03 am »


               Hm... in that case, what I might try is to have a script/function that, after a certain delay from the creature's death, destroys all the items left in the container by looping through its inventory (thus avoiding destroying things the player took.) The problems I can see possibly arising is that:

1 - I'm not sure if the container used after death is the creature or a new container, and thus don't know how to call it.
2 - I'm not sure if the timer will expire properly unless the player remains in the area the creature died, and using a global int/float on the module for the timer (and later destroying the creature after returning to the area based on the timer) would mean a lot of variables being stored (one for each creature that died).

It's an interesting problem... I might have to try out a few things myself.
               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Body Decay Time
« Reply #6 on: October 25, 2012, 02:42:24 am »


               I've actually tried recently. The problem is, if you loop through an inventory and set items to destroy on a timer, they will delete themselves in the PC's inventory if they have been looted.

The problem with delays is what you are delaying is going to happen regardless, so it will either delete itself in the corpse, or in the inventory. I'm trying to find a way to make a function 'wait' and then only destroy what is actually in the corpse, but I'm having a hard time figuring it out.
               
               

               
            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
Body Decay Time
« Reply #7 on: October 25, 2012, 03:31:50 am »


               You can make a function, maybe call it "ClearInventory", and put it in an include or the death script you need it for. Then call the function on the death script like:

DelayCommand(300.0, ClearInventory());

If you delay the function call, then it SHOULD only loop through items in the container when that timer expires, not every item upon death.
               
               

               
            

Legacy_Zejan the Wonder Monkey

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +0/-0
Body Decay Time
« Reply #8 on: October 25, 2012, 05:40:58 am »


               I dunno if this will help, but...

This is code I wrote for a situation where there are a bunch of corpses around to represent a battle between a knight and his retainers, and a group of undead.  Smashing an altar nearby causes all the undead corpses to vanish.  This was done via SignalEvent, but I think it could be modified to suit a delay...

[nwscript]

#include "x0_i0_corpses"
void ClearOutCorpse(object oTarget)
{
 object oItem = GetFirstItemInInventory(oTarget);
 while(GetIsObjectValid(oItem) == TRUE)
   {
    if (GetObjectType(oItem) == OBJECT_TYPE_ITEM)
      {
       DestroyObject(oItem, 0.1);
      }
    oItem = GetNextItemInInventory(oTarget);
   }
 DestroyObject(oTarget, 0.0);
}
void main()
{
 int nEvent = GetUserDefinedEventNumber();
 switch(nEvent)
    {
     case 666:
     {
      int nIdx;
      object oTarget;
      //Hose the sparks...
      object oEffect = GetNearestObjectByTag("MagicSparksRed");
      DestroyObject(oEffect, 0.0);
      //And the Skeleton Priest...
      oTarget = GetObjectByTag("SkeletonPriest");
      SetObjectIsDestroyable(oTarget, TRUE, FALSE, FALSE);
      ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oTarget);
      DelayCommand(2.0, DestroyObject(oTarget, 3.0));
      //And his guards...
      for(nIdx = 1; nIdx <= 7; nIdx++)
         {
          oTarget = GetObjectByTag("Skeleton_"+IntToString(nIdx));
          SetObjectIsDestroyable(oTarget, TRUE, FALSE, FALSE);
          ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect(VFX_IMP_FLAME_M), oTarget);
          DelayCommand(2.0, DestroyObject(oTarget, 3.0));
         }
      //Clear out and destroy all skeleton-related corpse objects in the area.
      for(nIdx = 1; nIdx <= 8; nIdx++)
         {
          object oCorpse = GetNearestObjectByTag("SkeletonLoot", OBJECT_SELF, nIdx);
          ClearOutCorpse(oCorpse);
         }
     }
     break;
    break;
   }
}

[/nwscript]

In testing, I took a scroll that can be found on the skeleton priest's corpse, then I smashed the altar.  My character still had the scroll and everything else vanished.  Perhaps this will be of use.
               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Body Decay Time
« Reply #9 on: October 25, 2012, 06:33:56 am »


               Well I tried making an include with the function, and then put a delay on its use but there is still a "glow" highlight left on the ground.

This is what the corpse cleaning function looks like, pretty standard

void CleanCorpse()
{
      object oItem = GetFirstItemInInventory(OBJECT_SELF);

      while(GetIsObjectValid(oItem))
        {
        DestroyObject(oItem);
        oItem = GetNextItemInInventory(OBJECT_SELF);
        }

      DestroyObject(OBJECT_SELF);
}

Destroys all items, then the object itself. Not sure what's causing the highlight 'glow' or how to remove it.
               
               

               


                     Modifié par EzRemake, 25 octobre 2012 - 05:35 .
                     
                  


            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
Body Decay Time
« Reply #10 on: October 25, 2012, 02:44:48 pm »


               Interesting... is the highlight glow, as you put it, just a highlight or is it a selectable container? I'm assuming the latter, since the former can be solved by pressing TAB in-game. If it's a container, does it eventually fade if you open it in-game and then close it?
               
               

               
            

Legacy_EzRemake

  • Full Member
  • ***
  • Posts: 220
  • Karma: +0/-0
Body Decay Time
« Reply #11 on: October 25, 2012, 06:37:47 pm »


               The highlight is not selectable, and has no name and can't be clicked. It simply shows up when holding TAB in the location where a monster with an un-looted corpse died.

If a corpse fades that has no items on it, the glow doesn't remain, but, if there are items on the corpse, and they don't get looted, the glow remains.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Body Decay Time
« Reply #12 on: October 25, 2012, 07:21:27 pm »


               Isn't that related to destroying the corpse? I ran into the problem recently when I tried to use NESS's corpse system with bioware's built in system a the same time.

Ultimately I think you need to decide whether to roll a custom corpse system, or simply use bioware's corpse system as is.
               
               

               
            

Legacy_Zejan the Wonder Monkey

  • Jr. Member
  • **
  • Posts: 61
  • Karma: +0/-0
Body Decay Time
« Reply #13 on: October 26, 2012, 02:28:01 am »


               

EzRemake wrote...

Well I tried making an include with the function, and then put a delay on its use but there is still a "glow" highlight left on the ground.

This is what the corpse cleaning function looks like, pretty standard

void CleanCorpse()
{
      object oItem = GetFirstItemInInventory(OBJECT_SELF);

      while(GetIsObjectValid(oItem))
        {
        DestroyObject(oItem);
        oItem = GetNextItemInInventory(OBJECT_SELF);
        }

      DestroyObject(OBJECT_SELF);
}

Destroys all items, then the object itself. Not sure what's causing the highlight 'glow' or how to remove it.


I dunno, there has to be something weird going on here...

Try deliberately adding the float value to the Destroy command instead of letting it assume the default and see if that works.   Also, is the corpse object detroyable?
               
               

               
            

Legacy_jackkel dragon

  • Full Member
  • ***
  • Posts: 178
  • Karma: +0/-0
Body Decay Time
« Reply #14 on: October 26, 2012, 03:10:20 am »


               

Zejan the Wonder Monkey wrote...
Also, is the corpse object detroyable?


I believe I mentioned something to this effect in one of my posts, but this is a good point. If you're not sure if something it set to destroyable, use the "SetIsDestroyable()" command with the desired parameters to make sure it fades/doesn't fade as you intend.