Author Topic: Convo not starting after OnRest  (Read 1342 times)

Legacy_Grymlorde

  • Sr. Member
  • ****
  • Posts: 362
  • Karma: +0/-0
Convo not starting after OnRest
« on: June 09, 2016, 01:32:02 am »


               

I'm trying to have a henchman initiate a romance dialog with to the PC after resting is successful. However, the henchman does nothing. I've double-checked the henchman's tag and created a non-random event trigger to test the convo and interjection 1 fires. This script fires interjection #100 (invalid #) which is how BioWare does it to initiate a romance dialog. Here's the module OnRest script:




//::///////////////////////////////////////////////
//:: Name: x2_onrest
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    The generic wandering monster system
*/
//:://////////////////////////////////////////////
//:: Created By: Georg Zoeller
//:: Created On: June 9/03
//:://////////////////////////////////////////////
//:: Modified By: Deva Winblood
//:: Modified Date: January 28th, 2008
//:://////////////////////////////////////////////
/*  Modified by The Grymlorde
    Copied wandering monster system from X2_ONREST
*///////////////////////////////////////////////////////////////////////////////


#include "x2_inc_restsys"
#include "x2_inc_switches"
#include "x3_inc_horse"
#include "x2_inc_banter"


void main()
{
    object oPC = GetLastPCRested();


//-------------- Start Mount Section ----------------------
    object oMount;


    if (!GetLocalInt(GetModule(),"X3_MOUNT_NO_REST_DISMOUNT"))
    { // make sure not mounted
        /*  Deva, Jan 17, 2008
            Do not allow a mounted PC to rest
        */
        if (HorseGetIsMounted(oPC))
        { // cannot mount
            if (GetLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT"))
            { // cancel message already played
                DeleteLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT");
            } // cancel message already played
            else
            { // play cancel message
                FloatingTextStrRefOnCreature(112006,oPC,FALSE);
                SetLocalInt(oPC,"X3_REST_CANCEL_MESSAGE_SENT",TRUE); // sentinel
                // value to prevent message played a 2nd time on canceled rest
            } // play cancel message
            AssignCommand(oPC,ClearAllActions(TRUE));
            return;
        } // cannot mount
    } // make sure not mounted


    if (!GetLocalInt(GetModule(),"X3_MOUNT_NO_REST_DESPAWN"))
    { // if there is a paladin mount despawn it
        oMount=HorseGetPaladinMount(oPC);
        if (!GetIsObjectValid(oMount)) oMount=GetLocalObject(oPC,"oX3PaladinMount");
        if (GetIsObjectValid(oMount))
        { // paladin mount exists
            if (oMount==oPC||!GetIsObjectValid(GetMaster(oMount))) AssignCommand(oPC,HorseUnsummonPaladinMount());
            else { AssignCommand(GetMaster(oMount),HorseUnsummonPaladinMount()); }
        } // paladin mount exists
    } // if there is a paladin mount despawn it


//------------------- End Mount Section -----------------------


    if (GetModuleSwitchValue(MODULE_SWITCH_USE_XP2_RESTSYSTEM) == TRUE)
    {
        /*  Georg, August 11, 2003
            Added this code to allow the designer to specify a variable on the module
            Instead of using a OnAreaEnter script. Nice new toolset feature!
            Basically, the first time a player rests, the area is scanned for the
            encounter table string and will set it up.
        */
        object oArea = GetArea (oPC);


        string sTable = GetLocalString(oArea,"X2_WM_ENCOUNTERTABLE") ;
        if (sTable != "" )
        {
            int nDoors = GetLocalInt(oArea,"X2_WM_AREA_USEDOORS");
            int nDC = GetLocalInt(oArea,"X2_WM_AREA_LISTENCHECK");
            WMSetAreaTable(oArea,sTable,nDoors,nDC);


            //remove string to indicate we are set up
            DeleteLocalString(oArea,"X2_WM_ENCOUNTERTABLE");
        }


        if (GetLastRestEventType()==REST_EVENTTYPE_REST_STARTED)
        {
            if (!WMStartPlayerRest(oPC))
            {
                // The resting system has objections against resting here and now
                // Probably because there is an ambush already in progress
                FloatingTextStrRefOnCreature(84142  ,oPC);
                AssignCommand(oPC,ClearAllActions());
            }
            if (WMCheckForWanderingMonster(oPC))
            {
                //This script MUST be run or the player won't be able to rest again ...
                ExecuteScript("x2_restsys_ambus",oPC);
            }
        }
        else if (GetLastRestEventType()==REST_EVENTTYPE_REST_CANCELLED)
        {
         // No longer used but left in for the community
         // WMFinishPlayerRest(oPC,TRUE); // removes sleep effect, etc
        }
        else if (GetLastRestEventType()==REST_EVENTTYPE_REST_FINISHED)
        {
            // No longer used but left in for the community
            //WMFinishPlayerRest(oPC); // removes sleep effect, etc
            object oVal = GetNearestObjectByTag("Hen_Valentina");
            if (GetMaster(oVal) == oPC);
            {
                AssignCommand(oVal, SetHasInterjection(oPC, TRUE, 100));
                // * must fake an interjection here, an invalid numbered one
                // * so it jumps down to the romance dialog
                AssignCommand(oVal, ActionStartConversation(oPC));
            }
        }
    }
    //---- Rest for 1 hour ------------
    //Get current time
    int nHour = GetTimeHour();
    int nMinute = GetTimeMinute();
    int nSecond = GetTimeSecond();
    int nMillisecond = GetTimeMillisecond();
    //Advance the hour by 1
    nHour += 0;
    nMinute += 30; // This function runs twice
    // Set the new time
    SetTime(nHour, nMinute, nSecond, nMillisecond);
}

Any suggestions on how to initiate the romance dialog on a successful rest?



 



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Convo not starting after OnRest
« Reply #1 on: June 09, 2016, 01:57:27 am »


               

I suspect you are not finding Valentina because you are using the module as the object to get the nearest object by tag from.  The script is running as the module.  Try passing in oPC as the second argument to GetNearestObjectByTag there.



               
               

               
            

Legacy_Grymlorde

  • Sr. Member
  • ****
  • Posts: 362
  • Karma: +0/-0
Convo not starting after OnRest
« Reply #2 on: June 09, 2016, 02:57:59 am »


               

Yep, that's the problem. I changed GetNearestObjectByTag to GetObjectByTag and everything works fine now.


 


Thanks for the help, Meaglyn!



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Convo not starting after OnRest
« Reply #3 on: June 09, 2016, 02:49:30 pm »


               

Sure, glad to be of help.


 


I liked GetNearest better in case the hench was not in the same area. Probably does not matter in practice, though...



               
               

               
            

Legacy_KMdS!

  • Sr. Member
  • ****
  • Posts: 364
  • Karma: +0/-0
Convo not starting after OnRest
« Reply #4 on: June 09, 2016, 04:14:33 pm »


               

The only difference between the getnearestobject  and getobject would be the amount of processing performed because nearest only checks in the area the caller is located, but I'm sure you know that meaglyn, just wanted to be sure the OP did.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
Convo not starting after OnRest
« Reply #5 on: June 09, 2016, 05:18:11 pm »


               

Well, GetObjectByTag will do less processing because it's just a lookup in a hashtable. My point was GetObjectByTag will return Valentina in the off chance that she is a henchperson but is not in the same area, in which case it's probably not worth trying to start the conversation.  What I meant by not mattering in practice is that it's probably an unlikely situation to hit...