Jump to content

Help With Vampire Follower Feeding Script


achintyagk

Recommended Posts

I made a vampire follower earlier. She behaves exactly like a normal vampire NPC usually does in that she uses the vampire drain spell to drain her victims of their blood. But I want her to literally drink blood from her victims. Could someone please help me make a script which scans for dead humanoid NPCs nearby, checks if the Follower NPC is in combat and if she isn't, uses the bedroll vampire feeding animation on the dead NPCs while simultaneously adding some HP to the follower?
Link to comment
Share on other sites

I have checked this out, and have made a function to track dead actors, but it requires SKSE and probably slow too.

Actor property PlayerRef auto
Actor[] DeadActors ; We need an array to place all those dead actors, if any, inside.
Keyword property ActorTypeNPC auto ; Ignore all actors that do not have this keyword.

Event OnInit()
DeadActors = new Actor[10] ; You dont 'need' this event. Can initialize the array another way if you want.
                           ; Also the amount of actors can be as many as you want, up to 128.

EndEvent

Function ArraySetDeadActor()

; Array stuff ================
Int i = 0
;=============================

; Cell stuff =================
Cell kCell = PlayerRef.GetParentCell()
Int iCellIndex = 0
Int iCell = kCell.GetNumRefs(43) ; NPCs
; ============================

While iCellIndex < iCell
    ObjectReference kDeadActors = kCell.GetNthRef(iCellIndex, 43)
    if (kDeadActors as Actor).isDead() && kDeadActors.HasKeyword(ActorTypeNPC)
        DeadActors[i] = kDeadActors as Actor
        i += 1
    endif
    iCellIndex += 1
EndWhile 

EndFunction

This will add any dead actors to an array, and with that array you can do stuff to those NPCs by calling functions on it. It's easy to check if your follower is in combat, via isInCombat(), HOWEVER, the game wasn't properly programmed to tell the difference between the player and the follower in some cases, and this might be one of them where it will return false if YOU are not in combat.

 

The thing with the vampire.. I couldn't come up with something that would work without a package.

 

 

 

Link to comment
Share on other sites

I have to say I'm sorry, for I don't know to set all of that up for you, and it would take me a lot of time and thought to do, which I don't have. I always test functions with a quest stage.

 

For feeding..hmm maybe:

 

 

Function FollowerFeed(Actor akFollowerRef,Float afValue)
; afValue is the amount you wish to restore health, as a float.

    akFollowerRef.PlayIdle(VampireFeedingBedRollRight_Loose)
    akFollowerRef.RestoreActorValue("Health", afValue)
    
EndFunction
Link to comment
Share on other sites

Hello Terra Nova, you can slightly improve the performance of you script in this way

 

Actor property PlayerRef auto
Actor[] DeadActors = new Actor[10] ; We need an array to place all those dead actors, if any, inside.
Keyword property ActorTypeNPC auto ; Ignore all actors that do not have this keyword.

Function ArraySetDeadActor()
 ; Array stuff ================
 Int i = 0
 ;=============================

 ; Cell stuff =================
 Cell kCell = PlayerRef.GetParentCell()
 Int iCell = kCell.GetNumRefs(62) ; Real NPCs
 ; ============================

 While iCell
   iCell -= 1
   Actor kDeadActor = kCell.GetNthRef(iCellIndex, 62) as Actor
   if kDeadActor.isDead() && kDeadActors.HasKeyword(ActorTypeNPC) ; The keywork is OK only if you need to filter out creatures.
     DeadActors[i] = kDeadActors
     i += 1
   endif
 EndWhile 
EndFunction

I hope this helps.

 

Why it has better performance?

* The number of items got from SKSE is restricted to only actors

* The cycle has better performance because the check condition is lighter

* Less castings

* The init to init the array can be done directly at global variable instanciation level, without requiring an init function

Link to comment
Share on other sites

  • Recently Browsing   0 members

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