GetMaster(object)

Determine who controls a creature.

object GetMaster(
    object oAssociate = OBJECT_SELF
);

Parameters

oAssociate

Creature to get the master of. (Default: OBJECT_SELF)


Description

Returns the master PC of the specified creature (familiar) or the DM for DM controlled creatures.



Remarks

Returns OBJECT_INVALID if oAssociate doesn't have a master.

This can be used in a loop to find the PC who ultimately controls the associate (for instance, if there are multiple henchmen, or if the henchman has summoned a creature). In the code example below, for instance, the PC is granted XP OnDeath of a creature, even if the NPC was killed by an associate of the PC, or an associate of that associate, etc. etc.


Version

1.32

Example

void main()
{
//The actual killer
object oKiller=GetLastKiller();

//Loop through until we find one that doesn't have a master

while (GetIsObjectValid(GetMaster(oKiller)))
   {
   oKiller=GetMaster(oKiller);
   }

//we're now at the top of the hierarchy. Let's check if it
//is a PC
if (!GetIsPC(oKiller)) return;

//Give XP
GiveXPToCreature(oKiller, 500);
}

See Also

functions: GetAssociate | GetAssociateState | GetIsDM | GetIsDMPossessed | GetIsPC | SetAssociateState | SetFormerMaster
categories: Get Data from Creature Functions | Henchmen/Familiars/Summoned Functions


 author: Charles Feduke, editor: Lilac Soul, additional contributor(s): Jochem van 't Hull, Lilac Soul