Author Topic: On dm message if no DM send message back  (Read 326 times)

Legacy_Guest_NWN Dragon-Blade_*

  • Jr. Member
  • **
  • Posts: 92
  • Karma: +0/-0
On dm message if no DM send message back
« on: March 20, 2011, 08:33:54 pm »


               Would I script this by an On pc chat event? I'm trying to get it so if there is a player and they send a message through DM channel and there is no DMs it sends them back a message saying there are no DM's online and with a color code so its  noticeable?

EX: '<cÿ  > 'There are currently no Dungeon Masters Online'


Thanks,

-GM_Dragon, Of Celyon
               
               

               
            

Legacy_Kingdom_Of_Hearts

  • Full Member
  • ***
  • Posts: 142
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #1 on: September 20, 2012, 08:39:45 pm »


               Bump. Can someone reply to this, but I'm also looking for send message back aswell what you sent. That way you aren't blindly shooting messages and can look back to see what you sent to the DM channel.
               
               

               
            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #2 on: September 20, 2012, 10:00:32 pm »


               You could try the following, but a few things:
1. I've not compiled this as I'm at work and unable to do so.
2. I am not 100% certain that GetFirstPC() and GetNextPC() will return DM Possessed creatures. In fact...I think it will not. But if the DM is possessing a creature, he's probably busy anyway and may not have time to respond.
3. According to the SpeakString() function in the Lexicon, SILENT_SHOUT is the DM channel, so I'm going off the assumption TALKVOLUME_SILENT_SHOUT will return anything spoken on the DM Channel.
4. This will need some testing to verify it works to return whether or not a DM is online.


int GetDMIsOnline()
{
  object oDM = GetFirstPC()
  while(GetIsObjectValid(oDM)) {
    if (GetIsDM(oDM) || GetIsDMPossessed(oDM)) return TRUE;
    oDM = GetNextPC();
  }

  return FALSE;
}

void main()
{
  object oPC = GetPCChatSpeaker();
  int iChatType = GetPCChatVolume();
  if (iChatType == TALKVOLUME_SILENT_SHOUT)  {
    SendMessageToPC(oPC, "DM Channel Text: "+GetPCChatMessage());
    if ( !GetDMIsOnline()) SendMessageToPC(oPC, "There are currently no Dungeon Masters online");
  }
}

               
               

               


                     Modifié par Thayan, 20 septembre 2012 - 09:09 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #3 on: September 25, 2012, 04:09:31 am »


               To handle this you need to solve the following:
(1) Have a way of knowing whether at least 1 DM is logged in
(2) Capture a message sent to the DM channel

My solution to (1) would involve incrementing a DM count in the OnClientEnter event if a DM is logging in and decrementing the count in the OnClientLeave event if a DM is leaving. DM count would be stored as a local integer on the module.
My solution to (2) would use the OnPlayerChat event to intecept chat text sent via the DM channel.

Scripts for (1)
Your OnClientEnter event script includes the following:
void main()
{
    object oPC          = GetEnteringObject();// The entering object which includes PCs logging in

    if(!GetIsObjectValid(oPC)){return;}     // Catch exceptions 
    object oMod         = GetModule();

    if(GetIsDM(oPC))
    {
        int nDMCount    = GetLocalInt(oMod, "DMS_LOGGEDIN")+1;
        SetLocalInt(oMod, "DMS_LOGGEDIN", nDMCount);
    }
}

The OnClientLeave event script includes the following:
void main()
{
    object oPC          = GetExitingObject(); // The exiting object which includes PCs logging out
    if(!GetIsObjectValid(oPC)){return;}     // Catch exceptions 
    object oMod         = GetModule();

    if(GetIsDM(oPC))
    {
        int nDMCount    = GetLocalInt(oMod, "DMS_LOGGEDIN")-1;
        if(nDMCount<0)
                 nDMCount = 0;
        SetLocalInt(oMod, "DMS_LOGGEDIN", nDMCount);
    }


Script for (2)
Your OnPlayerChatEvent event script includes the following: 
void main()
{
    object oPC      = GetPCChatSpeaker();
    if(!GetIsObjectValid(oPC)){return;}     // Catch exceptions
    int nVolume     = GetPCChatVolume();
    object oMod    = GetModule();
    int nDMCount    = GetLocalInt(oMod, "DMS_LOGGEDIN"); 

    if(    nVolume == TALKVOLUME_SILENT_SHOUT
       && !nDMCount
      )
    {
        SendMessageToPC(oPC, "No DMs are currently logged in to receive your message.");
    }
}
               
               

               


                     Modifié par henesua, 25 septembre 2012 - 03:16 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #4 on: September 25, 2012, 04:37:54 am »


               By the way with regards to DM Possessed creatures not showing up as DMs or PCs, that is correct. But I developed the following solution for it which is placed inside the OnPlayerChat event:

void TrackDMPossession(object oDM, object oCreature)
{
    SetLocalObject(oDM,"POSSESSED_CREATURE", oCreature);
    DeleteLocalObject(GetLocalObject(oCreature, "DM_POSSESSOR"),"POSSESSED_CREATURE");
    SetLocalObject(oCreature, "DM_POSSESSOR", oDM);
}

void main()
{
    object oPC      = GetPCChatSpeaker();
    if(!GetIsObjectValid(oPC)){return;}     // Catch exceptions

    int bDMPossessed= GetIsDMPossessed(oPC);
    object oMaster  = GetMaster(oPC);
    if(bDMPossessed)
    {
        TrackDMPossession(oMaster, oPC);
    }

    // all of your typical chat event code goes here
   // followed by teh DM Eavesdrop code below
        string sDMMsg; // this would be filled with info to send to the DM about what the PC is saying
        object oEavesdrop  = GetFirstPC();
        while(GetIsObjectValid(oEavesdrop))
        {
            if(GetIsDM(oEavesdrop))
            {
                SendMessageToPC(oEavesdrop, sDMMsg);
                SendMessageToPC(GetLocalObject(oEavesdrop,"POSSESSED_CREATURE"), sDMMsg);
            }

            oEavesdrop = GetNextPC();
        } 
}

As you can see in TrackDMPossession I placed a pair of pointers on both the DM object and the Creature Possessed. Interestingly, the DM's player object is different than the creature object which the DM possesses which is why this is required. Thankfully the master of the possessed creature is the DM player object.
               
               

               
            

Legacy_BelowTheBelt

  • Hero Member
  • *****
  • Posts: 699
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #5 on: September 26, 2012, 08:09:51 pm »


               These are excellent suggestions. I'd just offer one more. FunkySwerve's SimTools uses something like this functionality such that DMs logged in as players have access to the DM commands and can receive messages via the DM channel.

Probably worth a look to see how he's done it.

One of the key pieces involves inputting each DM's CD key info into a function so that it can be compared against that when a DM command is used or to see if it needs to route a DM message to any of the players logged on.

Slightly off-topic, but an interesting benefit of this method is that, with a little tweaking, you could create stratified levels of DMs with different levels of authority to execute commands/wands/widgets (e.g. a senior DM could ban a player, but an associate DM using that command wouldn't be able to because the function would return that the DM is not of sufficient rank).

In any event, that package includes a check and processing of DM tells to DMs-as-players. You could probably pretty easily include a response if the DM check comes up negative.

Requires Moneo and Leto.
               
               

               


                     Modifié par BelowTheBelt, 26 septembre 2012 - 07:11 .
                     
                  


            

Legacy_Thayan

  • Sr. Member
  • ****
  • Posts: 435
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #6 on: September 27, 2012, 08:51:31 pm »


               That's a neat workaround that henusa provided to get DM possessed creatures. Only caveat is that they need to have said something as that creature at least once - but it's definitely better than never getting the DM Possessed creature at all.

SimTools uses GetFirst/NextPC() function when sending messages to players validated as DMs.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #7 on: September 28, 2012, 02:12:43 am »


               I do think that  henusa  full system also includes a DM possesed HB set in states.2da that  makes that caveat only active for only the first 6 seconds.
               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
On dm message if no DM send message back
« Reply #8 on: September 28, 2012, 02:43:09 am »


               What Lightfoot said is true for Arnheim. I made changes to the statescripts.2da so that DM Possessed creatures get picked up in their heartbeat. I didn't include that bit here, because I didn't want to confuse the issue or hijack the thread any further. But you're right its probably more helpful to show others what I've done. See the link above for the dm possessed heartbeat script.