Author Topic: My first time writing scripts. Need Help.  (Read 374 times)

Legacy_red dragon of baldur's

  • Newbie
  • *
  • Posts: 2
  • Karma: +0/-0
My first time writing scripts. Need Help.
« on: October 09, 2015, 12:33:45 am »


               

This is my first time writing scripts and triggers.


 


What I want is to have the PC enter a trigger area which then begins a conversation between the PC and five other NPC's. This conversation will end and an area transition will then take place. My problem is that I have no idea how to write such a script. I would appreciate it if someone was to write me a working script so I can see what is needed. If not could I have an explanation as to how I would write this script?



               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
My first time writing scripts. Need Help.
« Reply #1 on: October 09, 2015, 02:48:56 am »


               

You do have a copy of the lexicon don't you? You should also bookmark the lexicon site. Even if someone is kind enough to provide you with the script(s) you want, you will find these useful in the future.


 


TR



               
               

               
            

Legacy_Who said that I

  • Hero Member
  • *****
  • Posts: 931
  • Karma: +0/-0
My first time writing scripts. Need Help.
« Reply #2 on: October 09, 2015, 05:51:29 am »


               


This is my first time writing scripts and triggers.


 


What I want is to have the PC enter a trigger area which then begins a conversation between the PC and five other NPC's. This conversation will end and an area transition will then take place. My problem is that I have no idea how to write such a script. I would appreciate it if someone was to write me a working script so I can see what is needed. If not could I have an explanation as to how I would write this script?




 


Well what also helps a lot with writing scripts is to use the lilac script generator, makes things waaaay easier for you to get things done '<img'> 


 


http://neverwinterva...cript-generator


               
               

               
            

Legacy_Tarot Redhand

  • Hero Member
  • *****
  • Posts: 4165
  • Karma: +0/-0
My first time writing scripts. Need Help.
« Reply #3 on: October 09, 2015, 02:25:58 pm »


               

Dang, must getting rusty in my old age. I completely forgot about lilac soul's script generator (could be because I only tend to use it as a quick reminder how certain things should be done).


 


TR



               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
My first time writing scripts. Need Help.
« Reply #4 on: October 09, 2015, 05:14:14 pm »


               

The thing to consider about nwscript is that it is all event driven.


 


Anything that happens in nwn happens because something initiated it.


 


For your scenario - a trigger will fire a script when the onEntered or onExit event is fired.


So to start - you would right click on the trigger and click edit on the appropriate event.


 


A blank or existing script will load.


 


 
object oPC = GetEnteringObject(); // GetExitingObject() if you are in an exit event
 
AssignCommand(oPC,ActionStartConversation("conversation_file"));
 
 

 


So - this is a conversation between 5 people - so this is slightly difficult to do entirely by scripting so what you need to do is open the area that the conversation will happen in.


Then open the conversation editor


Make sure that the appropriate lines of conversation are selected, and you should be able to use one of the dropdowns to select the tag of the speaker for that specific line.


I think the only effect this has in conversation is changing camera focus and portrait for the speaker.


So construct your conversation and do the assignment for who says what in the conversation editor.


 


 


The last bit - teleporting to a new area:


Once again - this needs to be fired when an event triggers it.


In this case - its onConversationEnd (I think - for some reason I don't see it documented on the lexicon)


If there is no onConversationEnd event in the conversation file itself, then you will need to make the last node in the conversation do the teleport and make the conversation un-cancellable (to prevent people pressing esc to get out of it)


 


 


object oPC = GetPCSpeaker();
 
object oWp = GetWayPointByTag("my_Destination_wp");
DelayCommand(0.25,AssignCommand(oPC,JumpToObject(oWp)));
 

 


 


You will notice that the event that triggers the script changes the way we capture our player object.


If it is a conversation - GetPCSpeaker()


If it is the module onChat event : GetLastPCSpeaker();


If it is a trigger - GetEntering/ExitingObject   (can get players and npcs)


If it is a module Client Enter : GetEnteringObject 


Area Enter : GetEntering


Area Exit : GetExiting (does not fire on player disconnects unless you have nwnx and the appropriate plugins)