View Single Post
Old 06-13-2007, 12:52 PM   #12
stoffe
Network Caretaker
 
stoffe's Avatar
 
Status: Administrator
Join Date: Apr 2002
Posts: 5,833
Helpful! 10 year veteran! Notable contributor 
Quote:
Originally Posted by tk102
Interesting. I wonder where these two functions are used. I suppose they make it possible to store a reference to an object as a global variable.
Nice.
That would be somewhat risky since global variables are game-wide while all objects except players, roster members and what they carry are module specific. While you probably could do it I can't see where it would be useful that couldn't be handled via "real" object Locals set on an object instead.

They can be useful if you want to create tags that are unique for one specific object.... for example:

Code:
    object oTarget = GetSpellTargetObject();    
    int iOID = ObjectToInt(OBJECT_SELF);
    string sTag = "IsActive_" + IntToString(iOID);

    if (!GetLocalInt(oTarget, sTag)) {
        SetLocalInt(oTarget, sTag, TRUE);
        DelayCommand(HoursToSeconds(24), DeleteLocalInt(oTarget, sTag));
        // Do something...
    }
    else {
        SendMessageToPC(OBJECT_SELF, GetName(oTarget) + " has already been affected by this today, and is immune for the rest of the day...");
    }
That could be used to produce something like a fear aura that can only affect the victim once per day, rendering them immune in the meantime. It would set a tracking local on the victim, but one that is unique to that particular caster (using their OID as part of the variable tag), since you only want them immune to the aura of that creature, not all creatures.

Last edited by stoffe; 06-13-2007 at 01:04 PM.
stoffe is offline   you may: quote & reply,