Difference between revisions of "How to script conversation between two or more NPCs"

m
no edit summary
imported>Maturin
 
imported>Garin
m
 
(4 intermediate revisions by 3 users not shown)
Line 1: Line 1:
__TOC__
A basic scripted conversation between two NPCs is fairly simple to set up. Getting three or more NPCs to talk to each other, particularly if you want them to do something besides stand still, is more complicated. We'll cover all of these possibilities, starting with the simplest.
A basic scripted conversation between two NPCs is fairly simple to set up. Getting three or more NPCs to talk to each other, particularly if you want them to do something besides stand still, is more complicated. We'll cover all of these possibilities, starting with the simplest.


 
==Creating a basic scripted conversation between two NPCs==
'''Creating a basic scripted conversation between two NPCs.'''


There are two simple ways to get NPCs to talk to each other:
There are two simple ways to get NPCs to talk to each other:
Line 9: Line 11:


* Use [[StartConversation]] to trigger the conversation. This can be useful if you want to start the conversation with a custom topic (i.e. something besides HELLO).
* Use [[StartConversation]] to trigger the conversation. This can be useful if you want to start the conversation with a custom topic (i.e. something besides HELLO).


In order to force the NPCs to have a particular conversation, you need to set up the dialogue infos that they will use so that they link together into a complete conversation. The basic principles are as follows:
In order to force the NPCs to have a particular conversation, you need to set up the dialogue infos that they will use so that they link together into a complete conversation. The basic principles are as follows:
Line 35: Line 36:
* Repeat this process for the rest of the conversation. The final info in the conversation should have its "Link To" field left blank, and have "Goodbye" checked to indicate that it serves as the end of the conversation (otherwise the game will automatically tack on a random GOODBYE).
* Repeat this process for the rest of the conversation. The final info in the conversation should have its "Link To" field left blank, and have "Goodbye" checked to indicate that it serves as the end of the conversation (otherwise the game will automatically tack on a random GOODBYE).


 
==Creating a speech by a single NPC==
 
'''Creating a speech by a single NPC'''


Setting up a "speech" by an NPC (where he is the only one talking) is actually a variant of the process given above. You can either use StartConversation to tell him to talk to himself (e.g. BurdRef.Startconversation BurdRef), or set up the conversation so that all the infos are "Next Speaker: Self" (e.g. you have a second NPC present, but he never speaks).
Setting up a "speech" by an NPC (where he is the only one talking) is actually a variant of the process given above. You can either use StartConversation to tell him to talk to himself (e.g. BurdRef.Startconversation BurdRef), or set up the conversation so that all the infos are "Next Speaker: Self" (e.g. you have a second NPC present, but he never speaks).


 
==Creating a conversation between multiple NPCs==
'''Creating a conversation between multiple NPCs'''


Getting more than two NPCs to talk to each other, or getting NPCs to talk and move at the same time, requires abandoning the game's conversation generator completely, and handling everything by script. The key commands here are [[Say]] and [[SayTo]], in combination with script timers which track when it is time for the next NPC to speak. All the NPC conversations in the character creation sequence were handled in this way.
Getting more than two NPCs to talk to each other, or getting NPCs to talk and move at the same time, requires abandoning the game's conversation generator completely, and handling everything by script. The key commands here are [[Say]] and [[SayTo]], in combination with script timers which track when it is time for the next NPC to speak. All the NPC conversations in the character creation sequence were handled in this way.
Line 49: Line 47:


  begin gamemode
  begin gamemode
; count down timer
  ; count down timer
if convTimer > 0
  if convTimer > 0
set convTimer to convTimer - [[getSecondsPassed]]
    set convTimer to convTimer - [[getSecondsPassed]]
endif
  endif
  end
  end


Line 70: Line 68:
  begin gamemode
  begin gamemode
   
   
; talk when it is time
  ; talk when it is time
if CharacterGen.speaker == 3 && CharacterGen.convTimer <= 0
  if CharacterGen.speaker == 3 && CharacterGen.convTimer <= 0
set target to CharacterGen.target
    set target to CharacterGen.target
   
   
if target == 0
    if target == 0
set CharacterGen.convTimer to Say CharGenMain 1
        set CharacterGen.convTimer to Say CharGenMain 1
elseif target == 1
    elseif target == 1
set CharacterGen.convTimer to SayTo BaurusRef, CharGenMain 1
        set CharacterGen.convTimer to SayTo BaurusRef, CharGenMain 1
elseif target == 2
    elseif target == 2
set CharacterGen.convTimer to SayTo RenoteRef, CharGenMain 1
        set CharacterGen.convTimer to SayTo RenoteRef, CharGenMain 1
elseif target == 3
    elseif target == 3
set CharacterGen.convTimer to SayTo GlenroyRef, CharGenMain 1
        set CharacterGen.convTimer to SayTo GlenroyRef, CharGenMain 1
elseif target == 4
    elseif target == 4
set CharacterGen.convTimer to SayTo UrielSeptimRef, CharGenMain 1
        set CharacterGen.convTimer to SayTo UrielSeptimRef, CharGenMain 1
elseif target == 5
    elseif target == 5
set CharacterGen.convTimer to SayTo player, CharGenMain 1
        set CharacterGen.convTimer to SayTo player, CharGenMain 1
endif
    endif
   
   
endif
  endif
  end
  end


Line 97: Line 95:
  set characterGen.target to 2 ; Renote
  set characterGen.target to 2 ; Renote


See the CharacterGen quest, CharGenMain topic for an extensive example.


See the CharacterGen quest, CharGenMain topic for an extensive example.
==See Also==
*[[Three Way Conversation Tutorial]]






[[Category:Solutions]]
[[Category:Advanced_Modding_Techniques]]
Anonymous user