Jump to content

Force Greeting


shadowform

Recommended Posts

Hey everyone,

 

Can anyone please explain to me how to get my NPC to 'Force Greet' me? (So I dont have to activate them first)

 

Im trying to figure it out but its getting the better of me.

 

Thanks in advance,

 

Shadowform

Link to comment
Share on other sites

  • Below I have copied my force greeting script that attaches to the NPC . The script starts with a 'StartScript' command in the dialog paprus fragment box. However, I cant get it to save let alone work. Can you see what is wrong with it? It is hard to find morrowind CS support these days haha thanks.

  • begin AAAASCQForceGreetingCLOSE

    short once

    if ( Menumode == 1 )

    return

    endif

    if ( once == 0 )

    if ( GetDistance, Player <= 512 )

    forcegreeting

    set once to 1

    endif

    endif

    end

Edited by shadowform
Link to comment
Share on other sites

There is nothing wrong with your script's syntax that I can see, so I don't understand why it does not compile for you.

 

You imply that it is running from the dialogue results box of the greeting (what you refer to as the 'dialogue papyrus fragment box'). Is this true? Any code in dialogue results is not compiled when the dialogue entry (greeting) is saved, but it may crash in-game if the engine cannot parse it. There are important difference between adding code to dialogue results in Morrowind and adding a papyrus fragment to a dialogue entry in Skyrim (I assume you are coming from there).

 

*The script does not have a name

*There is no 'Begin' and 'End'

*We cannot declare variables (although we can write and read variables that are declared in a so-called local script attached to the NPC).

 

[study examples from the official dialogue to see how this is done.]

 

Regardless of what you are doing now, what you need to do it attach your script to a local object. The NPC is the logical and best choice. Your script should run perfectly as is. However, if there is a reason you do not want to attach the script to the NPC (perhaps it is an original NPC and you want to avoid any possible mod conflicts), create an activator in the same cell as the NPC and attach the script to it. For it to work, you will need to add 'fixes' so the engine will know on what object reference to run the script:

 

If ( "NPC_ID"->GetDistance, Player <= 512 )

"NPC_ID"->forcegreeting

Link to comment
Share on other sites

Hi thanks for your great replies. I dont have much experience with modding skyrim. I spent a lot of time with morrowind and oblivion and just trying to get my feet wet again. I wonder if my script is having issues compiling due to the fact that the NPC with the script attached is disabled at the start of game? She is enabled via "NPC->Enable" in the dialog results box. I tried using a "ChangedCell" variable in the attached script and that still didnt have any real effect.

 

Thanks,

 

Shadowform

Link to comment
Share on other sites

It is not important if you mod Skyrim. I made an assumption about what preconceptions you might have based on your comment about papyrus script fragments. Also, I miss read "The script starts with a 'StartScript' command in the dialog paprus fragment box" - that's all on me. So let's start again with you giving definitive answers to straight forward questions.

 

Was the disabled NPC placed in the world by you (is it a new, unique NPC) or by Bethesda?

How is the NPC initially disabled?

Is the script you posted attached to the NPC in question?

Does the script compile in the editor (construction set)?

Is this script started in dialogue results of a different NPC using StartScript?

Is there a journal (quest) entry associated with the enabling of this NPC?

Are the two NPCs in the same cell?

Link to comment
Share on other sites

Answers:

 

Was the disabled NPC placed in the world by you (is it a new, unique NPC) or by Bethesda? Unique NPC

How is the NPC initially disabled? The 'StartUp Script'

Is the script you posted attached to the NPC in question? Yes

Does the script compile in the editor (construction set)? Yes

Is this script started in dialogue results of a different NPC using StartScript? Yes

Is there a journal (quest) entry associated with the enabling of this NPC? Not directly. But the journal is updated using the same results box.

Are the two NPCs in the same cell? Not at the moment. Originally they were but I wondered if this may have been an issue so I moved the NPC's to separate cells.

Thanks for your help.

Shadowform

Edited by shadowform
Link to comment
Share on other sites

Do not use 'StartScript' on a local script (a script attached to an object). In Morrowind, local scripts run automatically and continuously when their cell is loaded. 'StartScript' is used to initiate global scripts (scripts not attached to ojects and therefore do not exist in the world). Calling 'StartScript' from dialogue results of an NPC creates what we call a 'targeted global script' since it runs on the calling NPC. In this instance, the script was checking the distance between the calling NPC and the player and prompting a forced greeting. Even though your local script attached to the intended NPC and the new instance of it created by 'StartScript' have the same code, they run independently of each other and this unto itself should not create a problem. Still, get rid of 'StartScript'.

 

Life is easier with unique NPCs created and placed in the world by the player. Journal entries are excellent ways of triggering action. It sounds like there is a journal update at the same time as the NPC is to be enabled (in the same dialogue results box). This is what I would suggest:

 

Have the script attached to the NPC you want to force greet the player disable and enable itself, (you do not need to do so with the StartUp script). This approach is a little cleaner. The script might look like this:

Begin AAAASCQForceGreetingCLOSE
 
short doOnce 
 
if ( doOnce >= 3 )
    return
endif
 
if ( menumode == 1 )
    return
endif
 
if ( doOnce == 0 )
    set doOnce to 1
    Disable
elseif ( doOnce == 1 )
    if ( ( GetJournalIndex "YourScriptID" ) == xx ) ; xx is the index of the journal entry to enable NPC
        set doOnce to 2
        Enable
    endif
elseif ( doOnce == 2 )
    if ( ( GetDistance player ) <= 512 )
        set doOnce to 3
        Forcegreeting
    endif
endif
 
End

This script disables the NPC the first game cycle (frame) that its cell loads. It will not be observed by the player.

 

The only thing you need to do from dialogue results of the NPC that 'enables' the other NPC is to add the journal entry that the other NPC's script checks to enable it - no 'StartScript' and no 'Enable'.

 

You might want to filter the forced greeting to check for the local variable 'doOnce' to have a value of 3 (set by the NPC's script). Then in dialogue results, 'set doOnce to 4'. This will prevent the NPC from using that greeting a second time, and the value of doOnce will still cause the local script to return quickly.

Link to comment
Share on other sites

Wow! Excellent. That was exactly what I was looking for. Thanks for your help. Its much appreciated

Link to comment
Share on other sites

  • Recently Browsing   0 members

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