Jump to content

How to make NPC appear, speak to PC, & walk off?


NykkiJo

Recommended Posts

I am so close to producing my first mod. Every other issue was worked out within a few hours. I have been been stuck on this issue for 2 days now, and I'm a little frustrated. Any advice for me?

 

My Goal:

1-An Argonian is in the house, currently disabled.

2-The Player sleeps in the house, the Argonian is enabled, and the Player is awakened.

3-The Argonian starts conversation with the Player. They talk.

4-The Player ends conversation.

5-The Argonian walks away, uses a strong camo/invisibility spell, leaves the house, and disappears.

 

What Happens:

1 & 2 happen perfectly.

3-The Argonian stares blankly. If I do not talk to her, she disappears after ~3 seconds.

If I talk to her, the conversation progresses as I desire.

4&5-When I end conversation, she waits ~3 seconds before disappearing. No spell or anything. Just *poof*!

 

My references are MS02 (Where Spirits Have Lease/ "Anvil House Quest") and Lucien Lachance's introduction of the Dark Brotherhood. In a previous version of the script, the Argonian started conversation fine but had no scripting beyond that. Another version had the Argonian enabling, immediately using the invisibility spell, staring at PC blankly, and waiting ~3 seconds before disappearing.

 

Relevant Quest Script Fragment:

 

 

scriptName NvDQuestScript

short NvDdoOnce
short NvDdoOnce1
short DeathCountdown
short AnseiAmbush


begin menumode


; Ansei wakes you up and threatens you!
if ( GetStage NvD01 >= 40 ) && ( AnseiAmbush == 0 )
if ( IsPCSleeping == 1 && player.getincell NvDKittyKittyHouse == 1 )
NvDLizREF.Enable
WakeUpPC
NvDLizREF.EvaluatePackage
set AnseiAmbush to 1
endif
endif

end


Argonian's Object Script

 

 

scriptname NvD01AnseiScript

; QUESTS:
; NvD01 Quest Script


short forceGreet
short greetPC
short temp
short Wait
float Timer1
float Timer2
short NoMoreEnable


begin gamemode

if greetPC == 0 && gettalkedtopc == 0
if getdistance player < 1000
NvDLizRef.StartConversation player, Greeting
set greetPC to 1

If Wait == 0
set Timer1 to ( Timer1 + GetSecondsPassed )
endif

if Timer1 > 1
set Wait to 1
set Timer1 to 0
endif

if Wait == 1
set Timer2 to ( Timer2 + GetSecondsPassed )
endif

if Timer2 > 2
if NoMoreEnable == 0
AddSpell DarkLachanceFade
set Wait to 2
set Timer2 to 0
set NoMoreEnable to 1
endif
endif

endif
endif
endif


end

 

 

Argonian has no AI packages besides a 24/7 wander at the moment.

 

 

I have another NPC, a Breton, who starts a conversation with the Player, successfully using this script. Her AI packages pertain only to wandering, eating, and sleeping.

 

 

scriptname NvD01ClawScript

; QUESTS:
; NvD01 Quest Script

short forceGreet
short greetPC
short temp

begin gamemode

if greetPC == 0 && gettalkedtopc == 0
if getdistance player < 1000
set greetPC to 1
startconversation player
endif
endif



end

 

 

The GREETING for both the Argonian & Breton are using have the GetIsID and GetTalkedToPC == 0.

Link to comment
Share on other sites

I see some potential problems here:

 

You're sending orders (evaluate package) to the actor in the same frame you've enabled him. This could lead to unexpected results, as actors may not respond to AI commands in that frame.

 

Another problem may be StartConversation, which doesn't always work (the actor sometimes ignore it).

You need to call it continuously (because he won't ignore it forever) until the conversation actually begins.

You could add this in the argonian script to check when conversation begins:

Begin MenuMode 1009
  If (NvDLizREF == GetActiveMenuRef 1009)
    ;Player is talking with NvDLizREF. Do stuff...
  EndIf
End

"if getdistance player < 1000" may be another problem: if the player is not near the actor, this condition could be false and the rest of the code is never triggered.

 

About the cast animation, if you're using AddSpell to add an ability with the invisibility effect, then no animation will happens (this is not casting a spell, but adding an ability).

You should use Cast with a spell instead, but spells have a limited duration, so you need to make the spell add the above ability with a magic effect script.

Link to comment
Share on other sites

Thank you for your help, forli. I didn't realize NPCs liked to ignore some commands. After running a few tests, the mod is working more or less as I'd like it.

 

I'm not using the script extender, so it looks like I can't use the GetActiveMenuRef, but I got it to work regardless.

 

The Argonian's evaluatepackage is now the result script of the quest stage that marks the end of the conversation. She follows it much better that way.

 

Also, the Argonian is standing right up against the PC's spawn point after waking up, so that should be less than 1000".

 

Final Argonian Script:

 

 

scriptname NvD01AnseiScript

; QUESTS:
; NvD01 Quest Script


short forceGreet
short greetPC
short temp
short Wait
float Timer1
float Timer2
short NoMoreEnable


begin gamemode

if gettalkedtopc == 0
if getdistance player < 1000
NvDLizRef.StartConversation player, Greeting
endif
endif

If Wait == 0
set Timer1 to ( Timer1 + GetSecondsPassed )
endif

if Timer1 > 4
set Wait to 1
set Timer1 to 0
endif

if Wait == 1
set Timer2 to ( Timer2 + GetSecondsPassed )
endif

if Timer2 > 5
if NoMoreEnable == 0
AddSpell DarkLachanceFade
set Wait to 2
set Timer2 to 0
set NoMoreEnable to 1
endif
endif
endif

end

 

 

I would like to tweak a few things and edit my writing again. After that, I think I will be able to share my mod with the community as "Kitty-Kitty House"!

Link to comment
Share on other sites

Little optimization suggestion by forli:

 

 

Begin Gamemode
 
   If GetTalkedToPc == 0
      If getdistance player < 1000
         NvDLizRef.StartConversation player, Greeting
      EndIf
   EndIf
 
   If Wait == 0
      set Timer1 to ( Timer1 + GetSecondsPassed )
      If Timer1 > 4    ;This should only run if "Wait == 0", right?
         set Wait to 1     ;No need to reset the timer, as you don't need it anymore.
      EndIf
   ElseIf Wait == 1
      set Timer2 to ( Timer2 + GetSecondsPassed )
      If Timer2 > 5    ;And this should only run if "Wait == 1"
         If NoMoreEnable == 0    
            AddSpell DarkLachanceFade
            set Wait to 2
            set NoMoreEnable to 1
         Endif
      Endif
   Endif
 
End

 

 

Here, the script is very little and the gain is minimal, but if you plan to write bigger scripts, they may impact performance, so the optimization become necessary.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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