I'm looking to script the following interaction elegantly. I have some parts of it correct, but there are other elements that need to be adjusted. This script regards meeting certain NPCs for the first time.
1. NPC "sees" player character. (OnUserDefined, flagged from default OnPerception script)
2. NPC says one-liner set as local variable. (ex. greeting)
3. NPC walks over to PC until it reaches a certain distance.
4. NPC starts conversation.
Everything seems to work fine, except the one-liner is delayed until just before the conversation starts, and the NPC walks to a default conversation distance that I don't know how to change.
I should also mention that the script fired also activates cut scene mode, so the player can't escape the conversation and break plot until the conversation is completed.
Thank you for any assistance you can give from your experience.
James
<script>void main()
{
int nEvent = GetUserDefinedEventNumber();
string oneLine = GetLocalString(OBJECT_SELF, "oneLine");
if (nEvent == 1002) // OnPerceive event
{
object oPC = GetLastPerceived();
if(GetIsPC(oPC) && GetLocalInt(oPC, "Dlg_Init_" + GetTag(OBJECT_SELF)) == FALSE && !IsInConversation(OBJECT_SELF))
{
AssignCommand(OBJECT_SELF, ActionSpeakString(oneLine));
SetCutsceneMode(oPC, TRUE, FALSE);
ClearAllActions();
AssignCommand(oPC, ClearAllActions());
ActionStartConversation("", oPC);
}
}
}</script>
Modifié par Kelther, 04 janvier 2011 - 05:46 .