Jump to content

teleporting and then resurrecting NPC - scriping help needed


Elleh

Recommended Posts

Accidentally hit Ctrl-W instead of Shift-W when typing and it closed my browser window and wiped out everything I had typed -.-

 

Trying... again.

 

Make follower, give start items in CK, make form list & add the start items to it -- this will be your "master" form list.

Use something like this on the follower reference

 

 

 

 

Scriptname SomeScript extends ReferenceAlias
;use ReferenceAlias if applying to follower reference in a dummy quest, else use Actor if applying directly to the follower

FormList Property MasterList auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If (MasterList.HasForm(akBaseItem) == false)
        MasterList.AddForm(akBaseItem)
    EndIf
EndEvent

 

This will add any and every item given to the follower to the master list. You could build a second form list and keep track of exactly what is on the follower at any given time, but for your purpose that is not necessary.

 

When the follower dies you want their items to be transfered to a hidden container for safekeeping, but before you do that you want to find out what items are equipped so that they can be re-equipped later. Mixing in your existing teleport and such, the script then becomes something like...

 

 

Scriptname SomeScript extends ReferenceAlias
;use ReferenceAlias if applying to follower reference in a dummy quest, else use Actor if applying directly to the follower

FormList Property MasterList auto
FormList Property EquippedList auto 

ObjectReference Property HoldingCellMarker auto
ObjectReference Property HoldingCellChest auto
Activator Property banishFX auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
    If (MasterList.HasForm(akBaseItem) == false)
        MasterList.AddForm(akBaseItem)
    EndIf
EndEvent

Event OnDying(Actor Somebody)
    Utility.Wait(4.0)
    Self.PlaceAtMe(BanishFX)
    MoveTo(HoldingCellMarker)

    int MasterSize = MasterList.GetSize()
    int index = 0
    While index < MasterSize
        Form Entry = MasterList.GetAt(index)
        If (Self.GetItemCount(Entry) == 0)
            ;DO NOTHING
        ElseIf (Self.GetItemCount(Entry) == 0) && (Self.IsEquipped(Entry) == True)
            EquippedList.AddForm(Entry)
        EndIf
        index += 1
    EndWhile

    Utility.Wait(4.0)

    Self.RemoveAllItems(HoldingCellChest, True, True)
    Utility.Wait(2.0)
    Self.Resurrect()
End Event

 

 

 

 

I see no need to wait till the summons to re-add & re-equip their gear so that can take place on the same script as well just add in a wait to be safe. Thus it becomes...

 

 

 

Scriptname SomeScript extends ReferenceAlias
;use ReferenceAlias if applying to follower reference in a dummy quest, else use Actor if applying directly to the follower

FormList Property MasterList auto
FormList Property EquippedList auto

ObjectReference Property HoldingCellMarker auto
ObjectReference Property HoldingCellChest auto
Activator Property banishFX auto

Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer)
If (MasterList.HasForm(akBaseItem) == false)
MasterList.AddForm(akBaseItem)
EndIf
EndEvent

Event OnDying(Actor Somebody)
    ;move follower dead body to holding cell
    Utility.Wait(4.0)
    Self.PlaceAtMe(BanishFX)
    MoveTo(HoldingCellMarker)

    ;empty existing EquippedList
    EquippedList.Revert()

    ;get new equipped items list
    int MasterSize = MasterList.GetSize()
    int index = 0
    While index < MasterSize
        Form Entry = MasterList.GetAt(index)
        If (Self.GetItemCount(Entry) == 0)
            ;DO NOTHING
        ElseIf (Self.GetItemCount(Entry) == 0) && (Self.IsEquipped(Entry) == True)
            EquippedList.AddForm(Entry)
        EndIf
        index += 1
    EndWhile

    Utility.Wait(4.0)

    ;move all items to container for safe-keeping
    Self.RemoveAllItems(HoldingCellChest, True, True)
    Utility.Wait(2.0)

    ;resurrect follower
    Self.Resurrect()
    Utility.Wait(2.0)

    ;remove all items again so that no original items re-appear and there be duplicates etc...
    ;but this time the items get banished forever
    Self.RemoveAllItems()
    Utility.Wait(2.0)
    
    ;add the correct items back to the follower
    HoldingCellChest.RemoveAllItems(Self, True, True)

    ;re-equip the equipped items
    Int EquipSize = EquippedList.GetSize()
    Int Index2 = 0
    While Index2 < EquipSize
        Form Entry2 = EquippedList.GetAt(Index2)
        Self.EquipItem(Entry2)
        Index2 += 1
    EndWhile
End Event

 

 

 

 

Now all you need do on your magic effect is summon the follower. It should all work in theory. Please note that I've not tested compilation or function.

 

EDIT: While washing dishes of all things, I realized that the equipped form list needs to be cleared out between each death/summons. Last and final script block edited to include that.

 

EDIT 2: Corrected the typos that Elleh pointed out in the post below...

Edited by IsharaMeradin
Link to comment
Share on other sites

Oh my gawd. :O ! You're great. Yeah that...... that would have taken me some time to figure out, if at all. I'm just going to crawl back in my corner here and play with my photoshops......

 

Seriously though, thank you for your time. I'm getting ready to see if I can get this to work. And understand exactly what is going on here. Be back in a while....

Link to comment
Share on other sites

It works. It works BEAUTIFULLY. Thank you so so much Ishara! I think I'm just going to happily flail about for a few minutes. \(^_^)/


No items are duplicating, none are going missing. Hunting Bow is still there - and *does* duplicate - but I don't think there's anything to be done about that here. I think some other mods take care of that, and if my guy plays nice with those I will be happyhappy. If not - as long as I have USP installed - I can just keep grabbing the darn thing out of his inventory and throwing it at unsuspecting wildlife. Without the unofficial patch, 'tho it'd be an issue -- he would eventually have so many in his inventory he could be over encumbered. :blink: Why Beth? Why?


Anywho. There are a few more things I want to try out before I am through, but I need to play around before I come crawling back for more help. Well..... hopefully I won’t need to at all but.... you know.


Thanks again, guys! Thanks so much!

Edited by Elleh
Link to comment
Share on other sites

I see the typo now on the re-equip section at the bottom of the script. I'm glad it worked and that it works for you. As for the hunting bow, I've no clue. That may be protected some how. Perhaps there is some other script that forces the follower to have such a bow if they do not have it for some reason.

Link to comment
Share on other sites

I found it. ._. It's in the Dialog Follower Quest. "Follower Hunting Bow" and "Follower Iron Arrow" are in the Inventory for the Follower Alias. I'm piggy-backing off of the Dialog Follower Quest, so this would affect my custom follower as well. Now I'm wondering what the repercussions might be if I remove them....

 

Oh well. Imma try it anyway!

Link to comment
Share on other sites

I think if you remove the bow from the follower alias inventory, then unless the follower had a bow to begin with they wouldn't use one till you gave them a bow.

 

That might actually make better sense, honestly. Those followers that are archers by default SHOULD (read that as "would be better if they did") have a bow in their normal inventory.

Link to comment
Share on other sites

Hey, while this thread is still getting some attention -

 

Anyone have any ideas on how I might approach a spell cool-down?

 

What I want to do is this:

When he dies, I want him to be unable to be summoned again for a set amount of time. Like 24 game-hours or something. I'm trying to balance him, and make his death a big deal.... functional - but annoying enough that keeping him alive is an actual concern. Not having access to his muscle or inventory for 24 hours seems like a pretty good incentive. :P (With a huge spell cost and long casting time on top of that.)

 

Can I get the summoning script to somehow check and say "Hey! That Death event happened 14 game hours ago! I can't be used for another 10 hours!"? Or maybe there's another approach that's all together different? Admittedly, I haven't looked into this much at all yet. But a point in the right direction might help speed me along.

 

And Ishara - yeeeeeah, that would make a lot more sense. I'm going to play the game without the bow for a while, just to see if it causes any actual prolems. Probably wouldn't be a great idea if this mod were ever released for public consumption (which I'm starting to think about. It's pretty niche, but hey..... I can't be the only conjurer around that wants a more functional summon!), but it'd be kind of a huge pain in the butt to rebuild the follower quest(s) from scratch.....

Link to comment
Share on other sites

This is going to sound strange... Look up the dairy resources mod for Hearthfire. The cow milking script is set to be timed, to only allow you to milk the cow after X amount of game time has passed. Rather than using a game time update cycle, it calculates how much time has passed and gives a message that it isn't time or allows it to happen depending upon how much time has passed.

 

That may be more of what you are wanting rather than trying to use a game time update cycle which can get thrown off by waiting, sleeping, fast travel etc...

 

 

Oh EDIT...

 

Regarding the bow & the followers, maybe a script could be added to the follower alias which checks for the follower to equal the dremora. If the follower is the dremora then the bow is removed. Otherwise the bow stays. But given how 90% of the people get peeved at the follower always resorting to the hunting bow rather than that enchanted ebony bow, removing it completely from the follower alias is probably acceptable.

Edited by IsharaMeradin
Link to comment
Share on other sites

ARGH. So close. X3 I know I am doing it wrong, but I can't figure out what to do that would be correct. Or if there is even a correct way of doing what I need.

 

So I checked out that cow milking script (lol), and yeah - it pretty much does what I want!

 

Problem is this: I need this to work in my MagicEffect script, but I don't know how to get the MagicEffect script to know the actor that it has summoned is dying. I feel like it can be done, but I don't know how.

 

(Left out the Summon function in this example. Long function is long.)

 

 

Scriptname SummonDremoraThrallScript extends activemagiceffect  
{Summons Dremora Thrall in front of player.}

Actor Property DremoraThrallRef Auto
Float Property DaysToWait Auto
String Property FailureMessage auto
Float Property DayOfDeath auto Hidden

Int DremoraIsDead = 0

Auto State ReadyToSummon
	Event OnEffectStart(Actor akTarget, Actor akCaster)
		Summon(akCaster, DremoraThrallRef)
	EndEvent
EndState

Event OnDying(Actor akKiller) ;I DO NOT KNOW WHAT TO DO HERE.
	DremoraIsDead = 1
	GoToState("WaitingToRecover")
EndEvent

State WaitingToRecover
	Event OnBeginState()
		DayOfDeath = utility.getCurrentGameTime()
	EndEvent

	Event OnEffectStart(Actor akTarget, Actor akCaster)
		If (DayOfDeath + DaysToWait) <=Utility.GetCurrentGameTime() && !(DremoraIsDead == 1)
			GoToState("ReadyToSummon")
		Else
			debug.Notification(FailureMessage)
		EndIf
	EndEvent
EndState

Function Summon        
        ;blahblah stuff goes here
EndFunction

 

 

 

It compiled correctly, but.....

I know that "OnDying" event is not right. But I don't know what to do with it. Can this be done? Or should I just try a different approach? Or have I just totally missed the boat all together?

Link to comment
Share on other sites

  • Recently Browsing   0 members

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