Portable corpses, one little problem

Post » Thu Jun 21, 2012 9:34 am

Ok so I made it so you can pick up dead bodies and place them in your inventory into a nice little body bag. I am using a large sack which shipped with the game for the body bag, which is normally a static container. The problem is, it doesn't have physics so when I drop the dead body sack, it is floating at the position I dropped it instead of dropping to the floor. I don't know how to add physics to it, and I assume if I did, I would have to do stuff to the nif. I figured I would just use a script to place the object on the ground, or move it to the ground each frame until it's there. Here is my code.

Scriptname DeadBodySackScript extends ObjectReference PlayerVampireQuestScript Property PlayerVampireQuest  Auto ;this doesn't work yet because I don't know how to identify the object itselfEvent OnInit() ; This event will run once, when the script is initializedRegisterForUpdate(0.01)GotoState ("polling")EndEventState pollingEvent OnUpdate()    if ;my object is at z height 0   Debug.Notification("Got what we needed, so stop polling!")   UnregisterForUpdate()   GotoState ("active") ; Switch to a state that doesn't use OnUpdate()  else  ;move my object down a little  endifEndEventEndStateState active; Do nothing in hereEndState;this stuff works greatEvent OnActivate(ObjectReference akActionRef)PlayerVampireQuest.DeadBodyVictim.enable()PlayerVampireQuest.DeadBodyVictim.MoveTo(Game.GetPlayer(),0,0,afZoffset = 60)Disable()EndEvent

I guess it would be ok to just dump the body in front of the player instead of dropping the sack too. It might be cooler though dropping the sack, since that is what you see in the inventory. Or if it's easy to add basic physics to the sack I'm up for that too.
User avatar
Luis Longoria
 
Posts: 3323
Joined: Fri Sep 07, 2007 1:21 am

Post » Thu Jun 21, 2012 5:34 am

i dont think we have the tools to export properly working physics into nif files (not that i know of).

i did manage to create a moveable container by using an existing moveable static mesh and assigning it to be used as a container (actually its the other way around i created a container object using the havok enabled nif). one example of this kind of object in the vanilla game is the free standing spit pot.

i would look through the existing havok enabled nifs to see if any of them match the kind of container look you are going for and then create a container using that nif. otherwise, you may be able to swap meshes in nifskope using a custom mesh or extract one from the vanilla game and switch it out, leaving all of the havok physics behavior intact

maybe JustinOther can chime in as he would probably know better. i think his bag of holding is just this exact kind of thing
User avatar
SWagg KId
 
Posts: 3488
Joined: Sat Nov 17, 2007 8:26 am

Post » Thu Jun 21, 2012 5:44 pm

For Bag of Holding, there's a switcharoo since the container can't be placed in one's inventory. With activation blocked, you can script the corpse to disable and give the player a proxy, then script the proxy to disable OnContainerChanged if !akNewContainer right after the corpse is enabled and moved to it. The corpse should then havok and fall to the ground as though it were being dropped.

If ever it floats when 'dropped', try http://www.creationkit.com/ApplyHavokImpulse_-_ObjectReference.
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Thu Jun 21, 2012 3:33 am

Ok so within my Object Reference Script, how do I identify the object?
User avatar
ZzZz
 
Posts: 3396
Joined: Sat Jul 08, 2006 9:56 pm

Post » Thu Jun 21, 2012 4:38 pm

If you were to use JustinOther's method, you wouldn't use that script at all, since bodies are havok enabled. If I were to do it, I would create a perk with an "Activate" perk entry point similar to the cannibalism ability from the Namira quest.

I would add a choice to "pick up" the body. There would be a perk fragment script involving AddItem to akActor, Disable akTargetRef, and then saving akTargetRef to some object reference property in a quest. The last part is because I don't trust scripted inventory objects to keep their variables...

The dummy item added to akActor would have an OnContainerChanged like JustinOther describes. When the item is dropped, it will pull the object reference from the quest, and then use MoveTo on the body to place it in front of the player.
User avatar
Chantel Hopkin
 
Posts: 3533
Joined: Sun Dec 03, 2006 9:41 am

Post » Thu Jun 21, 2012 4:01 am

If you were to use JustinOther's method, you wouldn't use that script at all, since bodies are havok enabled. If I were to do it, I would create a perk with an "Activate" perk entry point similar to the cannibalism ability from the Namira quest.

I would add a choice to "pick up" the body. There would be a perk fragment script involving AddItem to akActor, Disable akTargetRef, and then saving akTargetRef to some object reference property in a quest. The last part is because I don't trust scripted inventory objects to keep their variables...

The dummy item added to akActor would have an OnContainerChanged like JustinOther describes. When the item is dropped, it will pull the object reference from the quest, and then use MoveTo on the body to place it in front of the player.
I got it working. Basically ditched the sack using the OnContainerChanged function. Thanks everyone!
User avatar
Fam Mughal
 
Posts: 3468
Joined: Sat May 26, 2007 3:18 am


Return to V - Skyrim