Aller au contenu

Photo

if (GetIsPC(oObject)) is not the same as if(GetFirstPC()==oObject)


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

#1
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
if(GetIsPC(oObject))

will return true if oObject is currently controlled by the PC.

if (oObject ==GetFirstPC())

will only return true if oObject is the actual player character.

#2
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
I think that if you used GetFirstPC(FALSE), then they would be the same. \\


I also believe that if(GetIsOwnedByPlaer(oObject)) would be the same as

if(oObject == GetFirstPC())

Just some refleciton on funcitons after some wierd behavior in scripts.

#3
painofdungeoneternal

painofdungeoneternal
  • Members
  • 1 799 messages
GetFirstPC() is part of a loop, it should not be used otherwise except for debug messages in single player. It should be followed by GetNextPC() and there are almost always some more accurate alternative to use instead.

Here is some info on how to reference objects depending on situation. The correct answer actually varies depending on what initiated the provided script.

GetControlledCharacter(oPC); // this is the actual character now controlled, so if you pass in oPC and its the players real character and he is controlling the familar, this will return the familar.

GetOwnedCharacter(oPC) // this does the opposite, pass in the familiar and it returns the original character in control

GetIsOwnedByPlayer(oPC) // this returns true if the object is the player, or something he controls like a familar

GetIsPC(oPC) // returns true if the player is possessing at the moment

GetIsDM(oPC) // returns true if a DM and not possessing something

GetIsDMPossessed(oPC) // returns true if possessed by a DM, use with previous function

GetMaster(oPC) // get the master of a given familar

GetAssociate(oPC) // with parameters gets familars or the like, etc. uses ASSOCIATE_TYPE_*

GetHenchman(oPC) // gets the henchman

GetFactionLeader( oPC ) // gets the leader, or the object set to be leader of the party

Modifié par painofdungeoneternal, 20 avril 2011 - 03:19 .


#4
_Knightmare_

_Knightmare_
  • Members
  • 643 messages
For single player games GetFirstPC() can be used as a "shortcut."

GetFirstPC() or GetFirstPC(TRUE) will return the players originally created character (the one they made when they first started the module).

GetFirstPC(FALSE) will return their currently controlled character (for example SoZ type party with multiple PC in the party). This will return the originally created PC if they happen to be controlling it at the time.

Personally I use:

object oMasterPC = GetFirstPC(TRUE);
object oPC = GetFirstPC(FALSE);

oMasterPC is where I save/get all variables that are to be stored. That way I know exactly which PC I am always dealing with (and therefor where to save or find variables). oPC is there for things like sending messages to the player or having something interact with the player's currently controlled character.

#5
M. Rieder

M. Rieder
  • Members
  • 2 530 messages
Thanks for the info pain. I had always wondered about differences between single and multiplayer scripting. It is also good to know the implications of using different functions, especially for a novice like me.

Just to clarify,

GetOwnedCharacter(oPC) will only return true if oPC is the actual Player and not a controlled familiar or companion, right?