tamtastic Posted February 28, 2021 Share Posted February 28, 2021 Hello Nexus Modding Community, I could use some help. I have a script that targets a human corpse, checks that it is dead, add items to it(skull, human flesh, bone meal, iron ore and bloody rags) and then disintegrates the body. It all works great. What I am having trouble with is: 1) giving ownership of the newly added items to the dead npc (akTarget). I want these items to show up in their inventor with the red hand, and to be marked as stolen when looted by our PC's. I included a snippet below. Scriptname dw02ISeeTheLight extends activemagiceffect {Using modified Magelight to target a deadbody.} import utility MiscObject Property BoneHumanSkullFull auto Event OnEffectStart(Actor akTarget, Actor akCaster) bool bIsDead = akTarget.IsDead() IF bIsDead == TRUE akTarget.AddItem(BoneHumanSkullFull,1,true) ;<<<<< Works BoneHumanSkullFull.SetActorOwner(akTarget().GetActorBase()) ;<<<<< Not correct. I tried many variations. EndIf EndEvent 2) Making the casting this spell a crime if observed. Thank you in advance for any help or suggestions. Link to comment Share on other sites More sharing options...
maxarturo Posted February 28, 2021 Share Posted February 28, 2021 Your script does not have the ID of the added item, so it can't set ownership, it should look something like this: ObjecReference MyObj = akTarget.AddItem(BoneHumanSkullFull,1,true) MyObj .SetActorOwner(akTarget().GetActorBase()) Link to comment Share on other sites More sharing options...
tamtastic Posted February 28, 2021 Author Share Posted February 28, 2021 Thank you maxarturo. I added per your recommendation: ;akTarget.AddItem(BoneHumanSkullFull,1,true) ObjectReference MyObj = akTarget.AddItem(BoneHumanSkullFull,1,true) ;<<<< compiles fine MyObj.SetActorOwner(akTarget().GetActorBase()) <<<does not compile, throws errors: ;(127,23): akTarget is not a function or does not exist, then ;(127,34): none is not a known user-defined type I also tried MyObj.SetActorOwner(akTarget.GetActorBase()); <<<compiles, but does not change ownership I added the debug: debug.notification("MyObj = " + MyObj.GetActorOwner() + " " + MyObj) ;<<<<<< This returns: "MyObj None None" Any thoughts would be appreciated. Thank you. Link to comment Share on other sites More sharing options...
ReDragon2013 Posted March 1, 2021 Share Posted March 1, 2021 (edited) hmm.. try next, maybe it works. dw02ISeeTheLight Scriptname dw02ISeeTheLight extends ActiveMagicEffect {Using modified Magelight to target a deadbody.} ; https://forums.nexusmods.com/index.php?/topic/9709908-set-target-actor-as-owner-of-items-added-to-their-corpse/ MiscObject PROPERTY BoneHumanSkullFull auto ; this is the baseobject of skull ; -- EVENT -- EVENT OnEffectStart(Actor akTarget, Actor akCaster) IF akTarget.IsDead() ELSE RETURN ; - STOP - target is still alive ENDIF ;--------------------- myF_Action( akTarget ) ENDEVENT ; -- FUNCTION -- ;---------------------------------- FUNCTION myF_Action(Actor akTarget) ;---------------------------------- ; (1) place a new skull object nearby, https://www.creationkit.com/index.php?title=PlaceAtMe_-_ObjectReference objectReference oRef = akTarget.PlaceAtMe(BoneHumanSkullFull as Form, 1, False, TRUE) ; non-persistent and disabled ; (2) make the ownership, https://www.creationkit.com/index.php?title=SetActorOwner_-_ObjectReference ;;; oRef.SetActorOwner( akTarget().GetActorBase() ) ; edited caused by later postings oRef.SetActorOwner( akTarget.GetActorBase() ) oRef.EnableNoWait() Debug.Trace(" *** TEST *** object = " +oRef+ ", owned by " + oRef.GetActorOwner()) ; look at papyrus.0.log (inside My Games\Skyrim\Logs\Script) ; (3) now move the skull into NPC inventory akTarget.AddItem(oRef as Form) ENDFUNCTION Edited March 1, 2021 by ReDragon2013 Link to comment Share on other sites More sharing options...
lofgren Posted March 1, 2021 Share Posted March 1, 2021 Unfortunately, items picked off of corpses are not counted as stolen ever as far as I can tell, which is why I had to move the items into a hidden container for my Contraband mod. Link to comment Share on other sites More sharing options...
tamtastic Posted March 1, 2021 Author Share Posted March 1, 2021 Thank you ReDragon2013. I really appreciate how well commented your code is. Unfortunately, I am getting the same set of error messages from the line: oRef.SetActorOwner( akTarget().GetActorBase() )(32,24): akTarget is not a function or does not exist(32,35): none is not a known user-defined type lofgren, I appreciate your suggestion of moving items into a hidden container and sharing of your experience. I will investigate this. Thank you. Link to comment Share on other sites More sharing options...
dylbill Posted March 1, 2021 Share Posted March 1, 2021 You can get rid of the parentheses. It should be oRef.SetActorOwner(akTarget.GetActorBase()). Link to comment Share on other sites More sharing options...
tamtastic Posted March 2, 2021 Author Share Posted March 2, 2021 (edited) Thank you maxarturo, RedDragon2013, lofgren and dylbill. You all helped me to figure this out. RedDragron2013 's code with dylbill's edit works. While the item does not show up with the red hand on the corpse, as soon as the PC loots it it is marked as stolen. Wonderful! Scriptname dw02ISeeTheLight extends ActiveMagicEffect {Using modified Magelight to target a deadbody.} ; https://forums.nexusmods.com/index.php?/topic/9709908-set-target-actor-as-owner-of-items-added-to-their-corpse/ MiscObject PROPERTY BoneHumanSkullFull auto ; this is the baseobject of skull ; -- EVENT -- EVENT OnEffectStart(Actor akTarget, Actor akCaster) IF akTarget.IsDead() ELSE RETURN ; - STOP - target is still alive ENDIF ;--------------------- myF_Action( akTarget ) ENDEVENT ; -- FUNCTION -- ;---------------------------------- FUNCTION myF_Action(Actor akTarget) ;---------------------------------- ; (1) place a new skull object nearby, https://www.creationkit.com/index.php?title=PlaceAtMe_-_ObjectReference objectReference oRef = akTarget.PlaceAtMe(BoneHumanSkullFull as Form, 1, False, TRUE) ; non-persistent and disabled ; (2) make the ownership, https://www.creationkit.com/index.php?title=SetActorOwner_-_ObjectReference oRef.SetActorOwner( akTarget.GetActorBase() ) oRef.EnableNoWait() Debug.Trace(" *** TEST *** object = " +oRef+ ", owned by " + oRef.GetActorOwner()) ; look at papyrus.0.log (inside My Games\Skyrim\Logs\Script) ; (3) now move the skull into NPC inventory akTarget.AddItem(oRef as Form) ENDFUNCTION Thank you again! Edited March 3, 2021 by tamtastic Link to comment Share on other sites More sharing options...
maxarturo Posted March 2, 2021 Share Posted March 2, 2021 (edited) I've been quite busy lately with work and with the current vast update of my latest mod which is eating all my free time, that's why i didn't respond earlier, but i see you manage to resolve the issue with the help of others modders. ** I replied to your post just right before hitting the bed (while i was literally sleeping on my feet), and i just copy/paste your lines without checking them to see the "akTarget()", which was a stupid amateur mistake from my part. Sorry... Have a happy modding. Edited March 2, 2021 by maxarturo Link to comment Share on other sites More sharing options...
tamtastic Posted November 27, 2021 Author Share Posted November 27, 2021 I finally published my mod. https://www.nexusmods.com/skyrimspecialedition/mods/58248?tab=description Thank you again for all your help. Link to comment Share on other sites More sharing options...
Recommended Posts