Jump to content

[LE] simple dead body cleanup script help plz


masternoxx

Recommended Posts

So I am doing my mod and I am getting tired to keep adding WIdeadBodyCleanupScript to all the actors missing it and to set all the properties each time. (There are a lot of actors missing this script). What I would like to do is make 2 scripts, one that cleans up the body in 2 days (for normal NPC's), and one 10 days, for followers.

Well I don't want to break the game. When setting WIdeadBodyCleanupScript, there are two properties deathcontainer, and WI, which need to be set. Well do these need to be set even? I would prefer to just delete the body, therefore destroying the inventory, and be done with it.

I was just change the days, comment out the deathcontainer and WI parts, should that work okay? Thanks

 

 

here is the

---------------WIdeadBodyCleanupScript--------------------

 

Scriptname WIDeadBodyCleanupScript extends Actor

;**** This should ONLY BE USED ON UNIQUE ACTORS!!! ****

;This script cleans up dead actors, enables a container (ie grave/crypt) and moves all their inventory, after it Loads/unloads after a certain period of time.
;If you need to temporarily stop someone from being cleaned up, put them in the WINoBodyCleanupFaction faction.

;please do not modify this script without talking to jduvall

WIFunctionsScript Property WI Auto
{Pointer to WIFunctionsScript attached to WI quest. You MUST set this or things will be broken.}

float Property DaysBeforeCleanUp = 0.5 Auto
{Default = 0.5: What's the minimum amount of time (in days) that the body should stick around before being cleaned up. (Clean up happens during while loop.)}

ObjectReference Property DeathContainer Auto
{Container to move all the items the actor has in his inventory when cleaned up.}

actor SelfRef ;used to keep me persistent so I get UnLoad events while I exist

state Dead
;do nothing
Event OnDeath(Actor akKiller)
EndEvent

EndState


Event OnDeath(Actor akKiller)

GoToState("Dead")

if DeathContainer

bool cleanedUp = false

while cleanedUp == false
; debug.trace("WIDeadBodyCleanupScript" + self + "OnDeath() In While Loop, will try cleaning up after waiting " + DaysBeforeCleanUp)

utility.waitGameTime(DaysBeforeCleanUp * 24)

cleanedUp = checkForCleanup()

endWhile

else
; debug.trace("WIDeadBodyCleanupScript" + self + " WARNING: NO DeathContainer!", 2)

endif

EndEvent


bool function checkForCleanup()

if IsInFaction(WI.WINoBodyCleanupFaction)
; debug.trace("WIDeadBodyCleanupScript" + self + "In Faction WINoBodyCleanupFaction so NOT cleaning up body.", 1)
;do nothing
return true ;bail out of while loop

Elseif Is3DLoaded() == False
; debug.trace("WIDeadBodyCleanupScript" + self + "Cleaning up body.")
cleanUpBody()
return true
Else
; debug.trace("WIDeadBodyCleanupScript" + self + "Not cleaning up body, because my 3D is loaded.")
EndIf

return false

endfunction

function cleanUpBody()
; debug.trace("WIDeadBodyCleanupScript" + self + "cleanUpBody() moving to WIDeadBodyCleanupCellMarker in WIDeadBodyCleanupCell and Calling RemoveAllItems() to DeathContainer, and enabling it:" + DeathContainer)

;Disable()
;*** It has been decided it's safer to move them to a holding cell, for quests that might be filling allowing for dead actors but not allowing checking for disabled actors

MoveTo(WI.WIDeadBodyCleanupCellMarker)

DeathContainer.SetActorOwner(GetActorBase())
DeathContainer.Enable()
RemoveAllItems(DeathContainer)

EndFunction

Link to comment
Share on other sites

I'm suspecting that you're trying to add these to leveled actors/actors that are not unique. Yet the script states in big bold letters that it should be used only for unique actors. For vanilla at least, this is why you'll find this only on actors flagged as unique(and they are all named NPCs). Things like bandits, dragons, wolves, etc, things where there is more than one reference are cleaned up by an internal system.

Link to comment
Share on other sites

No actually I am using it on unique NPC's. I am replacing most essential npc flags with protected, and so those NPC's need cleanup now. On top of that many unique NPC's are just missing the flag. The USLEEP has added the cleanup script to hundreds of these NPC's. Or their dead bodies stay around forever.

I'm doing my mod to my preference which is all NPCs can die.

 

The way its done in the USLEEP is they use WIdeadBodyCleanupScript and set all the properties every time, so I will continue to do that because I'm worried if they dont have a "deathContainer" or "WI" (whatever that is) it will break the game.

Perhaps if you try to set the script on a plot actor in the CK and then set the properties you will see why it is annoying after a while. i dont care about their items want to just destroy them and clean up the NPC's body after a couple days.

But then at the end of the script there theres also a part about moving the body to some cell as well, that could be a problem also.

Link to comment
Share on other sites

I like learning experiences! But to be honest, I don't see the problem ...

 

function cleanUpBody()
;     debug.trace("WIDeadBodyCleanupScript" + self + "cleanUpBody() moving to WIDeadBodyCleanupCellMarker in WIDeadBodyCleanupCell and Calling RemoveAllItems() to DeathContainer, and enabling it:" + DeathContainer)
    
    Disable()
    ;*** It has been decided it's safer to move them to a holding cell, for quests that might be filling allowing for dead actors but not allowing checking for disabled actors
    
    MoveTo(WI.WIDeadBodyCleanupCellMarker)
        
    DeathContainer.SetActorOwner(GetActorBase())
    DeathContainer.Enable()
    RemoveAllItems(DeathContainer)
    
EndFunction

 



(I am assuming you are editing some vanilla NPCs?) Just removing that mark in front of Disable() will stop the actor's items form being preserved, but for the aforementioned reason I don't see why you would ever want to. This would cause a host of vanilla quest alias errors and potential game crashes. Same goes for making literally EVERY NPC kill able ... If you ask me this just isn't a good modding choice. I would stick to only doing this with custom Actors where you can easily manipulate your own quest, and stay out of vanilla content. This way your mod is easily compatible with other mods.

I mean .. deathcontainer is the container the items get moved into, if you aren't gonna use it then there really is no point in setting it. WIFunctionsScript Property WI Auto I have never seen anything like this before, but from my understanding its probably a custom property that can be set to literally anything ... Apparently its for some kind of quest that is apart of the whole system.

The script kind of already mentions this stuff, I am guessing the script author left instructions or more scripts? If not, then I don't think anyone can help you but him.

Also, if all that is bothering you is setting the properties each time, then all I can say is "patients" I guess ... I spend most my hours trouble shooting and correcting, in fact, all I did today with my mod is re modify some script systems, thats it. ... Make sure everything functions with one actor, then take the time to do it with all of your actors, then just be done with it ..

Edited by smashballsx88
Link to comment
Share on other sites

  • 1 year later...

I only just seen this. And it's a good source.

 

Wouldn't MarkForDelete also remove any running scripts still active on the dead bodies, as well as any attached forms? To lighten the load of the game, as well as the save game bloat effect from collecting all the dead bodies.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...