Jump to content

Need help with simple script


Recommended Posts

Begin OnDeath



MoveTo MercTrashcanMarker00


End




That's the script, attached to an NPC. When the NPC dies, it moves to the marker on death. But when I use coc to the marker location, the body is not there. If I resurrect it, it appears. Though If I kill it again, it doesn't spawn right at the marker, it just stays at the same spot. That's not my problem at the moment though.


If I am already at the marker location, then kill the npc in a different location, the body moves to the marker and I can see it spawn, just as I wanted.


The NPC is not set to respawn. So why can't I see the body when I move to the marker location after the NPCs death?


I do use some cleanup mods to help with lag. Maybe one of those is hiding the body when it goes to a new location?

Link to comment
Share on other sites

i think moveto doesnt work in dead npcs

so perhaps you have to ressurect it and send it there and kill it again there(i dont know what exacty you want to accomplish)

 

SCN AAAmoscript

; Applied to npc

Short Dead
short deadtwice

Begin OnDeath

Set Dead to 1


End


Begin GameMode
if deadtwice == 0
If GetDistance Player > 2000
If Dead == 1
Resurrect


Set Dead to 0

MoveTo MercTrashcanMarker00
;kill conditions
;kill code
set deadtwice to 1

EndIf
EndIf


End

 

Link to comment
Share on other sites

The dead body does at least somewhat respond to MoveTo, as the body is transferred to MercTrashcanMarker00. But I guess it may be invisible, or else it gets sent to some type of purgatory. If it's only invisible, that might be fine for me.

 

What I'm trying to do is send a dead NPC spawned with PlaceAtMe to a cell, which I will use Resetinterior on. I read ResetInterior will delete NPCs, thereby eliminating save game bloat from PlaceAtMe spawned NPCs.

 

I'm not sure if I can have the NPC resurrect, since I want to delay 3 days to when it will move to the marker. And I'm not sure if delay functions (or "variable" is it?... I'm new to scripting) work on dead NPCs either, as I've tried adding it in, but after 3 days the body won't move to the marker. I need the body to remain for 3 days so that the player will have time to loot the body.

 

I did test what would happen with MoveTo on a living NPC, and it did successfully move to the marker. I might be able to work with your suggestion, but it'd be a bit of a compromise I think.

Link to comment
Share on other sites

I think if I just resurrect and kill them after they've reached the marker (while dead) that'll work. It's just the delay timer now that I can't get working, and I don't think it will with a dead NPC. Maybe with a scripted token or something it will.

Edited by unknownhero2827
Link to comment
Share on other sites

the delay timer work with dead npcs

this works with a normal npc(without place at me)

 

SCN AAAmoscript

; Applied to npc

Short Dead
short deadtwice
short doonce

float CurrentDay
ref deadactor

Begin OnDeath

Set Dead to 1
set deadactor to getself
set CurrentDay to GameDaysPassed
;deadactor.MoveTo MercTrashcanMarker00 ;test


End


Begin GameMode
if doonce == 0
set CurrentDay to GameDaysPassed
set deadactor to getself
set doonce to 1
endif

if GameDaysPassed >= CurrentDay + 2 ;two days just for sure
if deadtwice == 0

If Dead == 1




deadactor.disable
deadactor.MoveTo MercTrashcanMarker00
deadactor.enable
deadactor.Resurrect

;kill conditions
;kill code

set deadtwice to 1
kill

EndIf
;else
;deadactor.evp ;this doesnt seem to help
EndIf
endif


End

 

Link to comment
Share on other sites

Your "cleanup mods" may very well be getting rid of the body. One way to test this is to make your NPC a "Quest" item (there's a box you can select for this when editing the NPC). Quest items are not "cleaned up" when a cell resets.

Link to comment
Share on other sites

@kastano, That worked. I just have to do a few tweaks. Thank you very much for taking the time to write all that script. Well appreciated.

 

@The_Vyper, Sorry for posting twice. I wasn't sure whether to post in mod talk or troobleshooting, I think troobleshooting is where I want to be. My NPC is a quest item. Does that mean it can never be deleted, even If I use resetinterior?

 

Edit: My question has been answered on another topic. Thanks again for your replies.

Edited by unknownhero2827
Link to comment
Share on other sites

  • Recently Browsing   0 members

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