Author Topic: Initiate a conversation WITHOUT NPC  (Read 309 times)

Legacy_Moranin

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« on: January 19, 2011, 10:14:48 pm »


               Hello,

I was wondering how to start a conversation with a PC without having an NPC talk to that PC.
Is this at all possible? I want the PC to have a conversation upon entering the module.

Moranin
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« Reply #1 on: January 19, 2011, 10:19:19 pm »


               Something like so:

void main()
{
object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;
AssignCommand(oPC, ActionStartConversation(oPC, "conv res ref", TRUE));
}

You might have problems with a pc starting a conversation with itself in the OnClientEnter event.
If you do then put a trigger around the starting location and use it's OnEnter event.
               
               

               


                     Modifié par GhostOfGod, 19 janvier 2011 - 10:26 .
                     
                  


            

Legacy_Moranin

  • Newbie
  • *
  • Posts: 10
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« Reply #2 on: January 19, 2011, 10:33:00 pm »


               Ahh. It was that simple.. Thanks.
               
               

               
            

Legacy_Blue Totoro

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« Reply #3 on: January 23, 2011, 04:37:46 am »


               Is there a way to have this script, only start the conversation at a specific time? I'm hoping for a recurring conversation to go off every 7 days hopefully at hour 19 but at hour 0 otherwise. It needs to only go off only once per 7 days.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« Reply #4 on: January 23, 2011, 04:50:15 am »


               There are a couple different ways to do something like this. However they may both add a bit of lag to your server/mod. You could use the module heartbeat or an area or object heartbeat to constantly check for the current time. Then once it gets to the time you start the conversation.
You could also slap a recursive script on the players themselves to check for the time and then start the conversation that way.
And of course there are some things to consider. Will this conversation fire for all the players or only certain ones. And then you'd also need to make sure that the script doesn't keep firing the conversation off for all the players..just once. That can be done in the script as well.
So...yes it can be done. But it may cause some lag or resource issues.

Something like this to start the conversation with all the players:
(This would go in the moduels "OnHeartbeat" event)

void main()
{
int iDay = GetCalendarDay();
int iHour = GetTimeHour();
int iActive = GetLocalInt(GetModule(), "CONVERSATION_ACTIVE");

if (iDay == 7 && iHour == 19 && iActive != TRUE)
    {
    object oPC = GetFirstPC();
    while (GetIsObjectValid(oPC))
        {
        AssignCommand(oPC, ActionStartConversation(oPC, "conv res ref", TRUE));
        oPC = GetNextPC();
        }
    SetLocalInt(GetModule(), "CONVERSATION_ACTIVE", TRUE);
    }
else if ((iDay != 7 || iHour != 19) && iActive == TRUE)
    {
    SetLocalInt(GetModule(), "CONVERSATION_ACTIVE", FALSE);
    }
}

Hope it helps. Good luck.
               
               

               


                     Modifié par GhostOfGod, 23 janvier 2011 - 05:03 .
                     
                  


            

Legacy_Blue Totoro

  • Newbie
  • *
  • Posts: 14
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« Reply #5 on: January 23, 2011, 06:48:30 am »


               This looks like it would work, but it also looks like it fires only once: when the module is at 7 days 19 hours. Is it possible to loop this or maybe just send it back to 0 days 19 hours or something?

Edit: Also, this is a single-player module, so multiplayer issues don't need to be worried about. The only PC is the only thing that needs to have this conversation. I suppose I can slap a new script to reset the date to one of the later conversation branches and do it that way, but I can't find a date reset script.
               
               

               


                     Modifié par Blue Totoro, 23 janvier 2011 - 09:03 .
                     
                  


            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
Initiate a conversation WITHOUT NPC
« Reply #6 on: January 26, 2011, 06:44:19 pm »


               Yes what you need to do is have a object npc store the day. ie day 7 first time to db ie //store day
void main()
{
object oObjstore =GetObjectByTag("name_of_npc");
SetCampaignInt(sDBName,"last_day_spoken",GetCalendarDay(),oObjstore);
}

this would store the day in a db using nwndb, then with more code add 7 to stored day to get new day to speek again... ie:

//store day
void main()
{
object oObjstore =GetObjectByTag("name_of_npc");
string sDBName ="SPEEK_"+GetName(oObjstore)+"";

SetCampaignInt(sDBName,"last_day_spoken",GetCalendarDay(),oObjstore);

int iDayAdd =GetCampaignInt(sDBName,"last_day_spoken",oObjstore)+7 ;
SetCampaignInt(sDBName,"next_day_speek",iDayAdd,oObjstore);
}

this will store the day they spoke and then store the day to speek adjust the code above by ghost to check for next_day_speek db data and they will speek every seven days at hour 19
this should work in single or multiplayer, but I dont want to assume '<img'> 
It's the basic logic on how to do it.  and since it is a single player mod you can have the script only fired when pc interacting with pc.
               
               

               


                     Modifié par Greyfort, 26 janvier 2011 - 06:46 .