Jump to content

Get follower reference (EFF, UFO,AFT compatible)


Vykroft

Recommended Posts

Posted

I'm trying to link a follower to certain magic effect casted on the player. And I'm having problem with the Follower reference when you are using a custom follower mod, I know that with "DialogueFollower" quest I can obtain the ref, but with EFF, UFO or any other follower mod that method doesn't work, and I don't want to have an incompatibility.

So, I need to find out how to search or scan a current cell for followers and then use them in a script. This is what I was using, the caster was getting the effect, but not the follower.

ReferenceAlias Property FollowerAlias Auto

event OnEffectStart ( Actor akFollower, Actor akCaster )
  akCaster.myCasterFunction("my effect on the caster")
  FollowerAlias.GetActorRef().myFollowerFunction ("my effect on the follower")
EndEvent

Any idea?

Posted

 

Cell c = PlayerRef.getParentCell()
int i = (c.GetNumRefs(62)) as Int
while i
  i -= 1
  Actor a = c.GetNthRef(i, 62) as Actor
  if a && a.isPlayerTeamMate()
    ; "--> Do what you want with the Actor a, it is a follower"
  endIf
endWhile
Posted

Thank for the code, here are the compile output.

getParentCell is not a function or does not exist
GetNumRefs is not a function or does not exist
cannot cast a none to a int, types are incompatible
GetNthRef is not a function or does not exist
cannot cast a none to a actor, types are incompatible
Posted

 

Thank for the code, here are the compile output.

getParentCell is not a function or does not exist
GetNumRefs is not a function or does not exist
cannot cast a none to a int, types are incompatible
GetNthRef is not a function or does not exist
cannot cast a none to a actor, types are incompatible

 

You are missing the SKSE sources.

Download the 7zip file of SKSE, unzip it, and put all the files (overwriting) where your Scripts are.

Posted

arf I have them, but I compile my script directly with Notepadd ++ outside CK because I can't inside the editor. So I need to set notepad in order to work with skse...

Posted

Download my NP++ config files (in my signature), it includes everything to compile also from MO outside CK.

Posted

Ok done it, I reinstalled all my SKSE files, and your config files too, but I still have one of the problems.

 getParentCell is not a function or does not exist

weird... and specially considering that I already use that function in the same script and never gave me any problem.

Posted

Is "PlayerRef" defined as: Actor Properrty PlayerRef Auto ???

Posted

Nup as ReferenceAlias Property PlayerRef Auto... sorry, change it and is compiling. Time to test if is working now.
 
Ok no, is not working, this is the complete code:

Actor Property PlayerRef Auto
ObjectReference Property markPlayer Auto  
ObjectReference Property myMarker Auto
Cell Property mycell Auto
 
event OnEffectStart ( Actor akTarget, Actor akCaster )
 
    if (akCaster.GetParentCell() != mycell)
        markPlayer.MoveTo (akCaster)
        akCaster.MoveTo (myMarker)
 
        Cell c = PlayerRef.GetParentCell()
        int i = (c.GetNumRefs(62)) as Int
        while i
            i -= 1
            Actor a = c.GetNthRef(i, 62) as Actor
            if a && a.isPlayerTeamMate()
                Debug.Notification("Hello I will do something")
            endIf
        endWhile

    Endif
EndEvent

It compile without errors, but the code is not working

Posted

Ok, I tried everything, I even reinstalled the script folder and SKSE again, but with no luck. The code compile, but it doesn't work at all...

Posted

Put a debug.notification("I am here") at the begin of the magic effect.

Just to check if the magic effect is applied.

If it is then check your papyrus to see if there is any error in the code.

If it is not, then check when the magic effect has to be applied.

Posted

ok I fixed it, I made a simple mistake. This was the order of all the instruction:

 

1-Check if current cell is not destination cell

2-Hook the cell with an Xmarker

3-Teleport the player to the new cell

4-(Your code) See if you have any follower in the current cell (of course not, the player has just been teleported)

Actor Property PlayerRef Auto
ObjectReference Property markPlayer Auto  
ObjectReference Property myMarker Auto
Cell Property mycell Auto
 
event OnEffectStart ( Actor akTarget, Actor akCaster )
 
    if (akCaster.GetParentCell() != mycell)
        markPlayer.MoveTo (akCaster)
        akCaster.MoveTo (myMarker)
 
        Cell c = PlayerRef.GetParentCell()
        int i = (c.GetNumRefs(62)) as Int
        while i
            i -= 1
            Actor a = c.GetNthRef(i, 62) as Actor
            if a && a.isPlayerTeamMate()
                Debug.Notification("Hello I will do something")
            endIf
        endWhile

    Endif
EndEvent

And I changed to this:

 

1-Check if current cell is not destination cell

2-(Your code) See if you have any follower in the current cell 

3-Hook the cell with an Xmarker

4-Teleport the player to the new cell

5-Teleport the rest of the crew

ObjectReference Property markPlayer Auto  
ObjectReference Property myMarker Auto
Cell Property mycell Auto
 
event OnEffectStart ( Actor akTarget, Actor akCaster )
 
    if (akCaster.GetParentCell() != mycell)
        Cell c = akCaster.GetParentCell()
        markPlayer.MoveTo (akCaster)
        akCaster.MoveTo (myMarker)
 
        int i = (c.GetNumRefs(62)) as Int
        while i
            i -= 1
            Actor a = c.GetNthRef(i, 62) as Actor
            if a && a.isPlayerTeamMate()
                ;teleport the followers with me
            endIf
        endWhile

    Endif
EndEvent

And I deleted "Actor Property PlayerRef Auto" because I'm using the caster location (the caster is the player and is with his/her followers)

 

The only problem, is that sometimes Sofia (from Sofia standalone mod) teleport with me, even she is not in my party and is also located in the same cell by the time the player cast the spell, but that is a minor problem (I'll see how can I avoid that in the future), the most important thing is that your code works, and I tested with vanilla and with EFF.

 

Thank you again gentleman.

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

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