Author Topic: OBJECT_SELF Weirdness - can anyone confirm?  (Read 607 times)

Legacy_Grymlorde

  • Sr. Member
  • ****
  • Posts: 362
  • Karma: +0/-0
OBJECT_SELF Weirdness - can anyone confirm?
« on: April 08, 2016, 04:36:58 pm »


               

Background


My current project involves a lot of work on henchman and NPC conversations, including developing reaction and loyalty sub-systems.


 


Observation


The various XP2 henchman scripts make liberal use of OBJECT_SELF as the default source object of henchman. Many of these scripts execute from the PC's Action Taken tab of the conversation.


 


My Thoughts


In this recent experience of developing the reaction and loyalty sub-systems, it appears that when a script on either of the PC's convo tabs calls OBJECT_SELF, it always points to the most recent NPC Speaker. My theory is that the conversation is executing on the NPC object, since the conversation always starts on the NPC tab.


 


Questions


  1. How is it that the engine knows that OBJECT_SELF is the henchman and not the NPC when the script is executed on the PC's convo?

  2.    
  3. Is it because the convo is started from the NPC?

  4.    
  5. Is this true in the Text Appears tab of the PC's convo as well?

  6.    
  7. What if another henchman butts in, does OBJECT_SELF point to the intruding henchman now?

  8.    
  9. If so, at what point does it point back to the original henchman, if ever?

 


Can any of you expert scripters explain to this novice what may be painfully obvious to you but not to myself?


 


Thanks!


 


 



               
               

               
            

Legacy_Proleric

  • Hero Member
  • *****
  • Posts: 1750
  • Karma: +0/-0
OBJECT_SELF Weirdness - can anyone confirm?
« Reply #1 on: April 08, 2016, 10:44:52 pm »


               I'm not sure if I fully understand question 1, but here goes...


When a PC converses with an object (NPC, henchman or placeable), OBJECT_SELF always refers to that object in every script in that conversation. Period.


When the PC clicks on a creature, it fires the OnConversation script on the creature, which, by default, tells the creature to BeginConversation. Conversations started by scripts use ActionStartConversation to the same effect. In all cases, OBJECT_SELF is the object running the script.


In a multi-NPC conversation, the tag on each line has no bearing on OBJECT_SELF. For example, if a script starts a conversation between the PC and Alice, line 1 is spoken by Betty and line 2 by Cathy, Alice is OBJECT_SELF in all scripts, even though she never says anything.


A script can action the PC to talk to self. In that case, by the same logic, OBJECT_SELF is the PC, regardless of any NPCs who may speak lines in the conversation.
               
               

               
            

Legacy_Grymlorde

  • Sr. Member
  • ****
  • Posts: 362
  • Karma: +0/-0
OBJECT_SELF Weirdness - can anyone confirm?
« Reply #2 on: April 09, 2016, 06:37:07 am »


               

Thanks Proleric. That clears up a lot of confusion I had and confirms many of my suspicions.