Author Topic: DM Spy  (Read 413 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« on: July 04, 2012, 04:01:28 pm »


               I've got a particular tough nut to crack and am wondering if others have cracked it.

My module's OnChat event has a player loop at the end (GetFirstPC --- GetNextPC) which is intended to cycle through all DMs and DMPossessed. But... it turns out DMPossessed creatures are not caught in a player loop.

Since I use this loop to keep the DM up to date on what PCs are chatting, DMs miss out on things when possessing NPCs. I have looked at SendMessageToAllDMs as an alternative BUT it does not function the same way as SendMessageToPC and results in spam for the DMs with no means to fine tune it.

I had an idea of creating my own DM list that woud be managed in the module's Enter and Exit events, but I'm unclear if this will even work. If I have the DM's Player Object, will this also point to them when they Possess an NPC?

Alternatively... is it possible to find the object the DM is possessing when  you have the DM object?
               
               

               
            

Legacy_ShadowM

  • Hero Member
  • *****
  • Posts: 1373
  • Karma: +0/-0
DM Spy
« Reply #1 on: July 04, 2012, 04:41:36 pm »


               You have some of the script for us to look at?
               
               

               
            

Legacy_Rubies

  • Hero Member
  • *****
  • Posts: 508
  • Karma: +0/-0
DM Spy
« Reply #2 on: July 04, 2012, 05:24:50 pm »


               

Alternatively... is it possible to find the object the DM is possessing when  you have the DM object?


...Might sound stupid, but you could try ObjectToString and store it somewhere?

EDIT: Nevermind I'm completely dumb. '<img'>
               
               

               


                     Modifié par Rubies, 04 juillet 2012 - 04:32 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
DM Spy
« Reply #3 on: July 04, 2012, 05:41:35 pm »


               <shaking a finger at the lady...>

Well, you're dumber than I like... in the original sense of the word (don't post near enough :-)
Remember, the only *dumb* question is one without a voice.

<...hoping she doesn't bite>
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« Reply #4 on: July 04, 2012, 06:08:28 pm »


               Here's a way to test the situation I described (looping through PCs and not catching the DMs in possession):
  • put this code in the module's onchat:
     string sDMMsg = GetPCChatMessage();
     object oDM  = GetFirstPC();
     while(GetIsObjectValid(oDM)) 
     {
            if(  GetIsDM(oDM) || GetIsDMPossessed(oDM) )
                    SendMessageToPC(oDM, sDMMsg);

            oDM = GetNextPC(); 
    }
  • Log in as a DM and possess a creature.
  • Log in as a PC as well. Say something.
  • The DM is not sent the message.
I am trying something else:

Area Enter Script (this would be the module enter area so you capture all new players):
//::///////////////////////////////////////////////
//:: area_enter
//:://////////////////////////////////////////////
/*

*/
//:://////////////////////////////////////////////
//:: Created: The Magus (2012 july 4)
//:://////////////////////////////////////////////

void main()
{
   object oEnter  = GetEnteringObject();
   if (GetIsPC(oEnter))
   {
       object oMod     = GetModule();
       int nPCCount    = GetLocalInt(oMod, "PC_COUNT")+1;
       int nPCIndex    = GetLocalInt(oEnter, "PC_INDEX_MOD");
       if(     nPCIndex
           &&  oEnter==GetLocalObject(oMod, "PC_OBJECT"+IntToString(nPCIndex))
         )
           nPCCount=0;

       if(nPCCount)
       {
           SetLocalObject(oMod, "PC_OBJECT"+IntToString(nPCCount), oEnter);
           SetLocalInt(oMod, "PC_COUNT", nPCCount);
       }
   }
}

Chat Script:
//::///////////////////////////////////////////////
//:: mod_chat
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created: The Magus (2012 july 4)
//:://////////////////////////////////////////////

void main()
{
    object oSpeaker = GetPCChatSpeaker();
    string sSpkrName= GetName(oSpeaker);
    string sMessage = GetPCChatMessage();
    object oMod     = GetModule();
    int nPCCount    = GetLocalInt(oMod, "PC_COUNT");
    int nIt         = 1;
    object oPC, oAss;

    while(nIt<=nPCCount)
    {
        oPC = GetLocalObject(oMod, "PC_OBJECT"+IntToString(nIt));
        if(GetIsObjectValid(oPC))
        {
            SendMessageToPC(oPC, sSpkrName+": "+sMessage);
            if(GetIsDM(oPC))
            {
                oAss = GetAssociate(ASSOCIATE_TYPE_NONE, oPC);
                SendMessageToPC(oAss, "[Ass None] "+sSpkrName+": "+sMessage);
                oAss = GetAssociate(ASSOCIATE_TYPE_DOMINATED, oPC);
                SendMessageToPC(oAss, "[Ass Dom] "+sSpkrName+": "+sMessage);
            }
        }
        else
        {
            SendMessageToPC(oSpeaker, "PC"+IntToString(nIt)+" is invalid.");
        }
        nIt++;
    }
}

i am using this to test a way to capture the DM possessing a creature. So far I have found that the DM is still valid in my pseudo array, but this object is not the same as the Object Possessed by the DM. Thats what I need to find.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« Reply #5 on: July 04, 2012, 06:37:05 pm »


               Ok i did a serious test.
here's my chat event. it loops through all associate types that I know of and does 10 each. Not one of them sends a message to the DMPossessed creature. I think this means that DM Possession does not make the creature an associate of the DM.

However a DMPossessed creature DOES send spoken text to the chat event, and is identified as the PCSpeaker. This means that I should be able to put a possessed creature pointer on the DM Object when the DM Possessed creature speaks. And thereafter be able to telegraph messages to a DMPossessed creature when looping through DMs.

//::///////////////////////////////////////////////
//:: mod_chat
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created: The Magus (2012 july 4)
//:://////////////////////////////////////////////

void main()
{
   object oSpeaker = GetPCChatSpeaker();
   string sSpkrName= GetName(oSpeaker);
   string sMessage = GetPCChatMessage();
   object oMod     = GetModule();
   int nPCCount    = GetLocalInt(oMod, "PC_COUNT");
   int nIt         = 1;
   int nAss, nAssIt;
   object oPC, oAss;

   while(nIt<=nPCCount)
   {
       oPC = GetLocalObject(oMod, "PC_OBJECT"+IntToString(nIt));
       if(GetIsObjectValid(oPC))
       {
           SendMessageToPC(oPC, sSpkrName+": "+sMessage);
           if(GetIsDM(oPC))
           {
               nAss    = 0;
               while(nAss<6)
               {
                   string sAss = IntToString(nAss);
                   nAssIt  = 0;
                   while(nAssIt<10)
                   {
                       SendMessageToAllDMs("AssType("+sAss+") #"+IntToString(nAssIt));
                       oAss = GetAssociate(nAss, oPC, nAssIt++);
                       SendMessageToPC(oAss, "["+"AssType("+sAss+") #"+IntToString(nAssIt)+"] "+sSpkrName+": "+sMessage);
                   }
                   ++nAss;
               }
           }
       }
       else
       {
           SendMessageToPC(oSpeaker, "PC"+IntToString(nIt)+" is invalid.");
       }
       nIt++;
   }
}
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« Reply #6 on: July 04, 2012, 07:05:25 pm »


               Ok... it works

//::///////////////////////////////////////////////
//:: mod_chat
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created: The Magus (2012 july 4)
//:://////////////////////////////////////////////

void main()
{
   object oSpeaker = GetPCChatSpeaker();
   if(GetIsDMPossessed(oSpeaker))
   {
       object oDM  = GetMaster(oSpeaker);
       SetLocalObject(oDM, "POSSESSED_CREATURE", oSpeaker);
       SendMessageToPC(oSpeaker, GetName(oDM)+" is your master.");
   }
   string sSpkrName= GetName(oSpeaker);
   string sMessage = GetPCChatMessage();
   object oMod     = GetModule();
   int nPCCount    = GetLocalInt(oMod, "PC_COUNT");
   int nIt         = 1;
   int nAss, nAssIt;
   object oPC, oAss;

   while(nIt<=nPCCount)
   {
       oPC = GetLocalObject(oMod, "PC_OBJECT"+IntToString(nIt));
       if(GetIsObjectValid(oPC))
       {
           SendMessageToPC(oPC, sSpkrName+": "+sMessage);
           if(GetIsDM(oPC))
           {
               oAss    = GetLocalObject(oPC, "POSSESSED_CREATURE");
               SendMessageToPC(oAss, sSpkrName+": "+sMessage);
           }
       }
       else
       {
           SendMessageToPC(oSpeaker, "PC"+IntToString(nIt)+" is invalid.");
       }
       nIt++;
   }
}

Next up I'll try the same thing with the normal PC loop.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« Reply #7 on: July 04, 2012, 07:24:04 pm »


               and it works in the PC loop too.

So... the problem was that the DMPossessed creature is not the DM object, and the DM object is not the DMPossessed and a DMPossessed creature is not a "PC".

But the DM object still exists and so you can use a pointer to the creature that the dm is possessing

Now all I have to do is find the best way to establish that pointer.
I suppose I can do it in a PC Loop in Module Heartbeat, and the Module Chat Event


Sorry to have just had a conversation with myself. I think now I'll go make some ice cream with my kids to celebrate.
               
               

               


                     Modifié par henesua, 04 juillet 2012 - 06:25 .
                     
                  


            

Legacy_Rolo Kipp

  • Hero Member
  • *****
  • Posts: 4349
  • Karma: +0/-0
DM Spy
« Reply #8 on: July 04, 2012, 07:29:54 pm »


               <sipping hazelnut flavored...>

Not that I'm dissing the thread, 'cuz I'm not, but that's the best idea I've seen today :-)

Edit: Specifically, I am quite happy you worked this out in an archivable, searchable place for when *I* need it later. That's also why I advocate Builder's logs/journals :-)

<...komodo dragon roast>
               
               

               


                     Modifié par Rolo Kipp, 04 juillet 2012 - 06:31 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« Reply #9 on: July 04, 2012, 07:36:58 pm »


               Now I need to reverse the process, and figure out how to ID a DM object Possessing a creature. GetAssociate doesn't work. But I did not try using GetIsDMPossessed... hmmmmm. I wonder if it works both ways.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
DM Spy
« Reply #10 on: July 04, 2012, 11:43:02 pm »


               Just a thought, I was going to try and test out earlier and ran out of time in trying to test it.  

The basic Question that I had in my mind for the tests are:  
Does the DM have a faction?
If the DM has a faction. Are all DM's in the same faction.
Would a loop Through Get all Faction members for the DM's faction, If it exsists, return the possosed NPC? along with all other DM?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
DM Spy
« Reply #11 on: July 05, 2012, 06:18:01 am »


               I never did look into the faction Idea I posted above,  My gut feeling says it will be a bust. 

I have found another solution though.  It however have up to a 6 second dead air time for the DM, so it is not a perfect solution.   It is still better then no solution at all. 

system

OnClientEnter

 if the player is a DM:
set a Local Object on the module with the PC's player name as the lable that points to the DM's object. This is needed so that the possesed creature can find the object for the DM that is possessing it.

set a Local String on the DM that is the PC's players name.   This the needed  for when the DM is possessing another creature, because the GetPCPlayerName function will return a blank string when the DM is possessing something else.  

code example: 

   object oPC = GetEnteringObject();
   string sPCPName = GetPCPlayerName(oPC);
  
   SetLocalObject(OBJECT_SELF,sPCPName,oPC);
   SetLocalString(oPC,"PlayerName",sPCPName); 


HB For DM Possessed creature.

First you will have to set it up so that the creature possessed will have a HB event. you do this by editing the states.2da.   I am sure you can figure it out from there.   

While the creature is possesed by the DM. You can get the account name of the DM possessing the creature  using the GetPCPlayerName function.   You can use the players account name to look up the local placed on the module  in the client enter script to get the object for the DM possessing the creature.  This allows us to Set  this creature as on Object on the DM's object.   I see no reason to check if the creature is possessed or not, If it wasn't this script would not be running on it.   I also see no reason to check if the local is already set of not,  It would take just as long to check as it would to just go ahead an set it again. 

script example: 

void main()
{
   object oPossessed = OBJECT_SELF;
   object oDM = GetLocalObject(GetModule(),GetPCPlayerName(oPossessed));
   SetLocalObject(oDM,"LAST_POSSESSED",oPossessed);
}
 

PC Chat Script

Within the Get First/Next PC loop,  If the PC is a DM and has no account name:  change the object to the LAST_POSSESED local.  

 code example:

If ( GetIsDM(oPC) && GetPCPlayerName(oPC) =="") oPC = GetLocalObject(oPC,"LAST_POSSESSED");


Hope that helps,
L8
               
               

               


                     Modifié par Lightfoot8, 05 juillet 2012 - 05:18 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
DM Spy
« Reply #12 on: July 05, 2012, 06:36:39 am »


               That is helpful, Lightfoot. Well put together. The advantage of your system is that after six seconds the pointer from the DM object to the DMPossessed Creature is established.

Before I saw this I simply used all the typical event scripts (equip/unequip/acquire/unacquire/activate/chat) and in each one check if the active creature object is a DM Possessed and then create the pointer. It is theoretically possible for a DMPossessed creature not to trip any of those events, but unlikely for the purposes of turning DM Spy on for the DMPossessed.

If my way of doing it still poses a problem on our next session I'll switch out my code for yours.