Author Topic: RE: SpeakOneLinerConversation(); - Interesting Finding  (Read 393 times)

Legacy_Pstemarie

  • Hero Member
  • *****
  • Posts: 4368
  • Karma: +0/-0
RE: SpeakOneLinerConversation(); - Interesting Finding
« on: December 06, 2014, 02:36:17 am »


               

Anyone that has played SoU or HotU is familiar with the one-liner interjections and comments made by henchmen when the PC passes through a trigger. While playing around with a custom ambient AI I stumbled across a way to use the SpeakOneLinerConversation(); function without the trigger.


 


This is snippet of code is from the UserDefined event for my blacksmith. 


 


if(nUser == EVENT_HEARTBEAT ) //HEARTBEAT

{

       int nRandom = d10();

       SetLocalInt(OBJECT_SELF,"X0_CURRENT_ONE_LINER",nRandom);

       SpeakOneLinerConversation();

}

 

The conversation is setup with 10 "owner" lines with the starting conditional script set to x0_d2_hen_line1 - x0_d2_hen_line10 (where the end digits correspond to the number of the line in the conversation file). My conversation has 10 lines - hence the d10() call - but you could have as many as you want. Bioware provided starting conditional scripts for up to 52 lines. 

 

The one-liners work identical to the henchman interjections and one-liners, but without need for the PC to activate them via the trigger. It also eliminates the need for a lot of scripts and a large include file that, as I've seen in so many other ambient NPC systems, houses a ton of SpeakString(); calls.

 

It never fails to amaze me how much stuff is embedded into the game - it just takes a lot of effort to weed it out sometimes.

 

One other tidbit

 

Some years back I did system for a variable controlled AI that expanded upon the method used in HotU which allowed you to set behavior states using variables on the creature template which were called from the OnSpawn script. Well, it turns out all that work was never needed. 

 

This snippet is from the OnUserDefined event for my Blacksmith:

 


 else if (nUser == EVENT_USER_DEFINED_PRESPAWN)

 {

        SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);

 }

 

As fate would have it, you can set any NW_FLAG constant via the PRESPAWN or POSTSPAWN events. All you need is to define the variable X2_USERDEFINED_ONSPAWN_EVENTS on the creature template (viable values are 1, 2, or 3). Yes, I've tested every single flag and they ALL work.