Aller au contenu

Photo

GetControlledCharacter() or GetPCSpeaker() ?


  • Veuillez vous connecter pour répondre
6 réponses à ce sujet

#1
Morbane

Morbane
  • Members
  • 1 883 messages
 I would like to enable a certain circumstance eg if a companion triggers a conversation; then that companion becomes oPC and the scripts inside that conversation only effect the companion; in this case a script that is potentially a trap.

so would this be the proper way? :

object oSpeaker = GetPCSpeaker();
object oPC = GetControlledCharacter(oSpeaker);

I have used GCC() for triggers but not so often in conversations for this type of "who is talking" instance.

#2
kevL

kevL
  • Members
  • 4 078 messages
What sort of trigger are ya using? offhand, I'd say GetPCSpeaker( ) would identify a companion, if a companion is the controlled conversationalist ..

needs test tho,

#3
Morbane

Morbane
  • Members
  • 1 883 messages
I guess I mis-stated my usage - the conv is indeed started by a trigger.

To be honest, I think I already solved this issue but I was looking for any possible alternatives that I may have overlooked.

#4
bealzebub

bealzebub
  • Members
  • 352 messages
so... what was the solution? What about oPC = GetLastSpeaker?

#5
Morbane

Morbane
  • Members
  • 1 883 messages
I have to do some testing to be positive - I have rewired some ga_ scripts and have to build in a test into the scenario...

#6
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
The easiest way would be to use the tag of the companion, if in SP only.  As far as I know, GetPCSpeaker() only works if the script is called from a conversation.  IF you use GetPCSpeaker() in an OnEnter event of a trigger, it won't return anything.
 


If you are in MP, I believe that GetFirstEnteringPC() may be effective, but that may only work for OnClientEnter scripts. If GetFirstEnteringPC() does not work for triggers, then I would do this:

object oEnter = GetEnteringObject();
object oPC;

if (!GetIsPC(oEnter))
      {return;}

else
     {oPC=oEnter;}


This way, oPC becomes the first PC to enter the trigger. 

Now, if you want to make sure that the original owned character doesn't trigger the trigger then use:

if ((!GetIsPC(oEnter))||
    (GetIsOwnedCharacter(oEnter))
      {return;}


This will make sure the script only runs for non-pc owned characters, so that only companions would fire it.  Keep in mind, in an MP environment, it would not fire for the owned characters of your companions, so if in MP environment, if you only wanted the main PC to not trigger it, I think you would do this, not entirely sure and definitely not tested. 

if ((!GetIsPC(oEnter))||
    (GetFirstPC() == oEnter))
      {return;}

You can try these.  I've never scripted to your particular scenario before, but these seem like they should work. 

Modifié par M. Rieder, 27 avril 2012 - 02:52 .


#7
Morbane

Morbane
  • Members
  • 1 883 messages
Well I would like to reserve the choice of either the main PC or a companion - the reason being : the guinea pig factor : make the companion "taste the potion" or something similar...

So... in the instances I am trying to code for are trigger activated events and/or conversations designed to affect the controlled character. Not exclude any particular trigger enterer.