Jump to content

Activate Objects from Another Actor


Recommended Posts

I'm experimenting with a mod that allows the player to control other NPCs, primarily for use with followers. However, I'm struggling to find a way so that I can activate things while the player is controlling a NPC. If anyone can give me some advice on how to go about this, it would be appreciated.

 

Here is the code I have so far. It is attached to a fire and forget - target actor spell.

Scriptname _P_PuppetScript extends activemagiceffect  
 
Idle Property IdleStop_Loose  Auto  
FormList Property ActivateList  Auto  
int Property ReadyKey Auto
int Property ActivateKey Auto
 
Actor Target
 
Event OnEffectStart(Actor akTarget, Actor akCaster)
   Actor Player = Game.GetPlayer()
   if(Player == Game.GetPlayer())
      Target = akTarget
      RegisterForKey(ReadyKey)
      RegisterForKey(ActivateKey)
      Game.ForceThirdPerson()
      ;Game.DisablePlayerControls(false, true, true, false, false, true, true, false)
      Game.SetCameraTarget(akTarget)
      akTarget.SetPlayerControls(true)
      Player.SetPlayerControls(false)
      akTarget.EnableAI()
      akTarget.PlayIdle(IdleStop_Loose)
   endIf
endEvent
 
Event OnEffectFinish(Actor akTarget, Actor akCaster)
   Actor Player = Game.GetPlayer()
   akTarget.SetPlayerControls(false)
   Player.SetPlayerControls(true)
   akTarget.EnableAI()
   Game.SetCameraTarget(Player)
   ;Game.EnablePlayerControls()
endEvent
 
Event OnKeyDown(Int KeyCode)
   if(KeyCode == ReadyKey)
      Dispel()
   elseif(KeyCode == ActivateKey)
      ObjectReference Nearest = Game.FindClosestReferenceOfAnyTypeInListFromRef(ActivateList, Target, 15)
      Nearest.Activate(Game.GetPlayer())
   endIf
EndEvent
Link to comment
Share on other sites

I tried something similar, I was told I should use the message box that pops up when you are a vampire and suck blood and manipulate it to do what you want. I'm not that advanced to I ended up doing something else, if you are, let me know how it goes!

I only needed 1 function so it was a lot easier to implement. I simply checked for activate key press like you but it shot a spell and the spell itself does all the work. Try shoving that ObjectReference code into a touch spell or a short distance target spell.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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