GetMaster
GetMaster(object)
Determine who controls a creature.
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.
Note: Ultimately returns the party leader if used in a loop as below. Fine for singleplayer, problematic for multiplayer.
Known bugs
This function always returns OBJECT_INVALID when used in creature OnSpawn event. To get correct results, use this function with slight delay or in signal event.
Version
1.32
Example
{
//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: |
author: Charles Feduke, editor: Lilac Soul, additional contributor(s): Jochem van 't Hull, Lilac Soul