Aller au contenu

Photo

DM NPC control & onExit event


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

#1
Yester

Yester
  • Members
  • 4 messages
Greetings,
I'm trying to make script using onExit event, but I found a problem I can't manage by myself.
The problem is, that in the case of taking control on NPC by DM, the DM avatar is calling Area onExit event. What's more - leaving NPC alone does not call onEnter script.
I have easy solution of the problem in my mind, but the real problem is how to recognize the event onExit with was called by taking control on NPC. Is there any way to do this?
Thanks for help, and sorry for my "English".
Yester

PS. Is there any reverse function of GetMaster()? I mean - the function with can found NPC possesed by given DM.

#2
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Not sure if this is the one you are looking for.



// Returns TRUE if the creature oCreature is currently possessed by a DM character.

// Returns FALSE otherwise.

// Note: GetIsDMPossessed() will return FALSE if oCreature is the DM character.

// To determine if oCreature is a DM character use GetIsDM()

int GetIsDMPossessed(object oCreature)



#3
Yester

Yester
  • Members
  • 4 messages
Thanks for answer,

I know about this function, but using this function i can only find a NPC controlled by DM, looping through all NPC around.

It's kind of ugly solution...

The question is how to find NPC controlled by DM without looping trough all creatures in module.

Hm... Maybe there is a script called when DM is entering into creature? I couldn't find anything like that, but if You know about this kind of script I will be grateful ;-)

#4
Yester

Yester
  • Members
  • 4 messages
Ok,
For now i use this ugly solution, but if sombody have idea to do this better - please write a note here.

IMHO ugly solution (but still solution):
In onExit script conditional:
if(!GetIsDM(oPC) || !GetIsObjectValid(oGetIsInside(oPC, lArea)))

And function oGetIsInside:
object oGetIsInside(object oMaster, location lMarker){
    int nWO = 1;
    object oCreature = GetNearestCreatureToLocation(CREATURE_TYPE_IS_ALIVE, TRUE, lMarker, nWO);
    while(GetIsObjectValid(oCreature)){
        if(GetMaster(oCreature)==oMaster){
            return oCreature;
        }else{
            nWO++;
            oCreature = GetNearestCreatureToLocation(CREATURE_TYPE_IS_ALIVE, TRUE, lMarker, nWO);
        }
    }
    return OBJECT_INVALID;
}

Thanks for help, and please write if You have any better ideas.

--
Yester

#5
Shadooow

Shadooow
  • Members
  • 4 468 messages

The problem is, that in the case of taking control on NPC by DM, the DM avatar is calling Area onExit event.


You mean, that if DM use posses creature, that NPC will fire OnExit event in that moment?

if so, just simple check

if(GetIsDMPossessed(oPC)) return;

should do the trick I think

#6
Yester

Yester
  • Members
  • 4 messages
Nope

The think is, that onExit in this moment is called by DM avatar, so GetIsDMPossessed(oPC) will return false.

Maybe my solution isn't great, but it works. The question is how to find creature possessed by DM if we have only DM avatar object ;-)

Or.. Maybe there is another option to find out if onExit is executed by DM, with is currently getting control over creature.



Anyway - thanks for answer ;)

#7
Shadooow

Shadooow
  • Members
  • 4 468 messages
I bet then exiting DM avatar is not PC...