Jump to content

[Story Manager Question] Taking control of an NPC through a Quest using story manager


Recommended Posts

Alright so I've been working on a spell where the player "possesses" another npc and the camera and player controls are switched to that NPC through the story manager. It is broken down into 3 scripts:

 

**akTarget and akCaster were added to a Script Event Quest, then a Story Manager Node thingy-ma-bob was added to "Listen" for the Keyword to be sent. However when I start the game, I notice the Image Space Modifier activates on my Character as soon as it loads, which means the scripts are activating without waiting for the keyword.

 

Both aliases had the "optional" condition checked but their scripts still activate prematurely.

 

The Magic Effect (Fire and Forget):

 

 

Scriptname DAEPossessScript extends activemagiceffect  
{Script for the Possession ability of the Daedric Princess.}
Keyword Property STARTPOSSESSION Auto
GlobalVariable Property ISDAEDRAPOSSESED Auto
GlobalVariable Property ISDAEDRAGHOST Auto
Spell Property FamiliarVisuals Auto
ImageSpaceModifier Property EtherealIMOD Auto
ReferenceAlias Property Alias_akTarget Auto
ReferenceAlias Property Alias_akCaster Auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
	akTarget = Alias_akTarget.GetActorReference()
	akCaster = Alias_akCaster.GetActorReference()
	STARTPOSSESSION.SendStoryEvent(akref1=akCaster,akref2=akTarget)
EndEvent


Event OnEffectFinish(Actor akTarget, Actor akCaster)
	akTarget = Alias_akTarget.GetActorReference()
	akCaster = Alias_akCaster.GetActorReference()
	if(ISDAEDRAGHOST.GetValueInt()==0&&ISDAEDRAPOSSESED.GetValueInt()==0)
		akCaster.SetAlpha(1,true)
		utility.wait(1)
		akcaster.SetGhost(False)
		akcaster.RemoveSpell(FamiliarVisuals)
		akcaster.DispelAllSpells()
		EtherealIMOD.Remove()
		ISDAEDRAGHOST.SetValueInt(0)
	endif
EndEvent

 

 

The akTarget Alias' attached Script

 

GlobalVariable Property ISDAEDRAPOSSESED Auto
ReferenceAlias Property Alias_akTarget Auto
{Alias to the akTarget of the spell}

Event OnInit()
	Actor akTarget=Alias_akTarget.GetActorReference()
	Game.SetCameraTarget(Alias_akTarget.GetActorReference())
	akTarget.SetPlayerControls(True)
	akTarget.EnableAI(True)
	ISDAEDRAPOSSESED.SetValueInt(1)
EndEvent

 

 

The akCaster Alias' attached Script

 

 

Scriptname DAEPOSSCRIPTCASTER extends ReferenceAlias  
{The Caster Side of the effects for the Daedra Possesion Spell}
Actor Property PlayerRef Auto
ReferenceAlias Property Alias_akCaster Auto
GlobalVariable Property ISDAEDRAPOSSESED Auto
GlobalVariable Property ISDAEDRAGHOST Auto
ImageSpaceModifier Property EtherealIMOD Auto
Spell Property FamiliarVisuals Auto

Event OnInit()
	Actor akCaster = Alias_akCaster.GetActorReference()
	EtherealIMOD.ApplyCrossFade(3.0)
	akCaster.SetAlpha(0.1, true)
	utility.wait(2)
	akCaster.SetAlpha(0, true)
	utility.wait(1)
	akCaster.SetGhost(True)
	akCaster.SetAlpha(0.5, true)
	akCaster.AddSpell(FamiliarVisuals, false)
	ISDAEDRAGHOST.SetValueInt(1)
	akCaster.SetPlayerControls(False)
	EtherealIMOD.Remove()

	if(ISDAEDRAPOSSESED.GetValueInt())
		akCaster.SetAlpha(1,true)
		utility.wait(1)
		akCaster.SetGhost(False)
		akCaster.RemoveSpell(FamiliarVisuals)
		akCaster.DispelAllSpells()
		akCaster.SetPlayerControls(True)
		akCaster.EnableAI(true)
		Game.SetCameraTarget(akCaster)
		EtherealIMOD.Remove()
		ISDAEDRAGHOST.SetValueInt(0)
		ISDAEDRAPOSSESED.SetValueInt(0)
	endif
EndEvent

 

 

Link to comment
Share on other sites

Aliases run the init events as soon as the quest starts, regardless of whether there is anything in them.

 

Edit: Sorry, I misunderstood. So the quest is starting before the keyword is sent. Sounds like maybe you didn't filter your story event for your keyword? Should be GetEventData keyword getid yourkeyword == 1

Edited by lofgren
Link to comment
Share on other sites

Post a screenshot of the aliases.

 

How did you get them to stop initializing at the start of the game?

 

The aliases:

 

 

ce34644a55e087680033b223596e80eb.png

 

 

 

akCaster Alias Properties

 

 

dcdfe7c93e25f971706c1cff9c3487a1.png

 

 

 

akTarget Alias Properties

 

 

a963fb7ff902cc1bafefdd8ee386c120.png

 

 

 

I changed the code for the Aliases for Event OnInit() to Event OnStoryScript(Keyword akKeyword, Location akLocation, ObjectReference akRef1, ObjectReference akRef2, \

int aiValue1, int aiValue2)
The code for the Magic Effect:

Scriptname DAEPossessScript extends activemagiceffect  
{Script for the Possession ability of the Daedric Princess.}
Keyword Property STARTPOSSESSION Auto
GlobalVariable Property ISDAEDRAPOSSESED Auto
GlobalVariable Property ISDAEDRAGHOST Auto
Spell Property FamiliarVisuals Auto
ImageSpaceModifier Property EtherealIMOD Auto
ReferenceAlias Property Alias_akTarget Auto
ReferenceAlias Property Alias_akCaster Auto
Event OnEffectStart(Actor akTarget, Actor akCaster)
	STARTPOSSESSION.SendStoryEvent(akref1=akCaster,akref2=akTarget)
EndEvent


Event OnEffectFinish(Actor akTarget, Actor akCaster)
	akTarget = Alias_akTarget.GetActorReference()
	akCaster = Alias_akCaster.GetActorReference()
	if(ISDAEDRAGHOST.GetValueInt()==0&&ISDAEDRAPOSSESED.GetValueInt()==0)
		akCaster.SetAlpha(1,true)
		utility.wait(1)
		akcaster.SetGhost(False)
		akcaster.RemoveSpell(FamiliarVisuals)
		akcaster.DispelAllSpells()
		EtherealIMOD.Remove()
		ISDAEDRAGHOST.SetValueInt(0)
	endif
EndEvent

 

 

 

The Script for The akCaster Alias

 

 

Scriptname DAEPOSSCRIPTCASTER extends ReferenceAlias  
{The Caster Side of the effects for the Daedra Possesion Spell}
Actor Property PlayerRef Auto
ReferenceAlias Property Alias_akCaster Auto
GlobalVariable Property ISDAEDRAPOSSESED Auto
GlobalVariable Property ISDAEDRAGHOST Auto
ImageSpaceModifier Property EtherealIMOD Auto
Spell Property FamiliarVisuals Auto
Keyword Property STARTPOSSESSION Auto

Event OnStoryScript(Keyword akKeyword, Location akLocation, ObjectReference akRef1, ObjectReference akRef2, \
  int aiValue1, int aiValue2)
	Actor akCaster = Alias_akCaster.GetActorReference()
	akRef1 = akCaster
	EtherealIMOD.ApplyCrossFade(3.0)
	akCaster.SetAlpha(0.1, true)
	utility.wait(2)
	akCaster.SetAlpha(0, true)
	utility.wait(1)
	akCaster.SetGhost(True)
	akCaster.SetAlpha(0.5, true)
	akCaster.AddSpell(FamiliarVisuals, false)
	ISDAEDRAGHOST.SetValueInt(1)
	akCaster.SetPlayerControls(False)
	EtherealIMOD.Remove()

	if(ISDAEDRAPOSSESED.GetValueInt())
		akCaster.SetAlpha(1,true)
		utility.wait(1)
		akCaster.SetGhost(False)
		akCaster.RemoveSpell(FamiliarVisuals)
		akCaster.DispelAllSpells()
		akCaster.SetPlayerControls(True)
		akCaster.EnableAI(true)
		Game.SetCameraTarget(akCaster)
		EtherealIMOD.Remove()
		ISDAEDRAGHOST.SetValueInt(0)
		ISDAEDRAPOSSESED.SetValueInt(0)
	endif
EndEvent

 

 

 

The Script attached to the akTarget Alias:

 

 

Scriptname DAEPOSALIASTARGSCRIPT extends ReferenceAlias  
{Script Effects for the Possession Spell}  
GlobalVariable Property ISDAEDRAPOSSESED Auto
ReferenceAlias Property Alias_akTarget Auto
{Alias to the akTarget of the spell}

Event OnStoryScript(Keyword akKeyword, Location akLocation, ObjectReference akRef1, ObjectReference akRef2, \
  int aiValue1, int aiValue2)
	Actor akTarget=Alias_akTarget.GetActorReference()
	akRef2 = akTarget
	Game.SetCameraTarget(Alias_akTarget.GetActorReference())
	akTarget.SetPlayerControls(True)
	akTarget.EnableAI(True)
	ISDAEDRAPOSSESED.SetValueInt(1)
EndEvent

 

 

 

Story Manager Setup:

 

 

f62d5ac7979488d8b731524dd7ec126c.png

 

 

 

When I hit an actor with the spell, nothing happens. I checked to see if the quest was running in the console and it wasn't. Hrmm.

Edited by Govilku
Link to comment
Share on other sites

  • Recently Browsing   0 members

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