Author Topic: Why is this conversation conditional script not working?  (Read 409 times)

Legacy_Androrc

  • Full Member
  • ***
  • Posts: 188
  • Karma: +0/-0
Why is this conversation conditional script not working?
« on: August 18, 2011, 08:56:31 pm »


               This is the script:

int StartingConditional()
{
    object oPC = GetPCSpeaker();
//    object oNPC = GetLastSpeaker();

    int nPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oPC);
//    int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oNPC);
    int nNPCClericLevel = 5;

    if (nNPCClericLevel > nPCClericLevel)
    {
        return TRUE;
    }

    return FALSE;
}

I talk to the NPC with my Wizard level 1 PC, but the conversation option doesn't appear...
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #1 on: August 18, 2011, 09:05:05 pm »


               

Androrc wrote...

This is the script:

int StartingConditional()
{
    object oPC = GetPCSpeaker();
//    object oNPC = GetLastSpeaker();

    int nPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oPC);
//    int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oNPC);
    int nNPCClericLevel = 5;

    if (nNPCClericLevel > nPCClericLevel)
    {
        return TRUE;
    }

    return FALSE;
}

I talk to the NPC with my Wizard level 1 PC, but the conversation option doesn't appear...


               
               

               
            

Legacy_Morbane

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #2 on: August 18, 2011, 09:05:25 pm »


               i think it is because the script wants oPC to be a cleric not a wizard.

Edit: ninja'd
               
               

               


                     Modifié par Morbane, 18 août 2011 - 08:05 .
                     
                  


            

Legacy_Androrc

  • Full Member
  • ***
  • Posts: 188
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #3 on: August 18, 2011, 09:11:02 pm »


               Yes, that is the point... The PC should have a Cleric level lower than 5, and it has 0 levels in Cleric, so shouldn't it work?

Or does GetLevelByclass() not return 0 when you have no levels in that class, but something different, like invalid?
               
               

               
            

Legacy_Morbane

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #4 on: August 18, 2011, 09:25:01 pm »


               In the Lexicon 1.69

Parameters
nclassType

The class to check for using class_TYPE_* constants.

oCreature

The object to check for the class. (Default: OBJECT_SELF)



Description
Returns an integer that describes the level of oCreature in the class described by class_TYPE_*. Integers from 1 to 20 indicate levels in the class. A value of 0 indicates the absence of a level in the class. For example, a placeable chair object has no classes, so for any requests 0 will be returned.




Version
1.22
               
               

               


                     Modifié par Morbane, 18 août 2011 - 08:27 .
                     
                  


            

Legacy_Morbane

  • Jr. Member
  • **
  • Posts: 79
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #5 on: August 18, 2011, 09:26:14 pm »


               the thing is is that 0 might not register in your code - you will have to account for that with more conditionals - i think
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #6 on: August 18, 2011, 09:31:47 pm »


               

Androrc wrote...

Yes, that is the point... The PC should have a Cleric level lower than 5, and it has 0 levels in Cleric, so shouldn't it work?


Ahh. That part wasn't too clear. A couple things to check: Make sure you put this script in the TextAppears tab and not the Actions taken. I've done that more than a few times. There should be other optional nodes for the NPC to say if the above is not true. Try switching the order around. For the life of me I can never remember if the default is supposed to go on the top of the NPCs optional lines or below the ones that have conditionals. It's been awhile since I've made any conversations.

Also make sure this line:

int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oNPC);

is changed to:

int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, OBJECT_SELF);
               
               

               


                     Modifié par GhostOfGod, 18 août 2011 - 08:34 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #7 on: August 18, 2011, 09:41:09 pm »


               I Do not see a problem with the script,  As long as it is compiled.  
Is this script placed in an Npc node or the PC responce node?

@Ghost:  That line is commented out so will not be the problem.
               
               

               
            

Legacy_Androrc

  • Full Member
  • ***
  • Posts: 188
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #8 on: August 18, 2011, 10:06:21 pm »


               Thanks for the help! '<img'>

It's working now, and the advice to check if it was actually in the Actions Taken tab made me realize that, while the script was correctly in the Text Appears tab, an older version of the script (which I already knew to be non-working) was selected rather than the version I posted here.

Also, I didn't know I could use OBJECT_SELF to reference the speaking NPC, and now I was able to improve the script so that I don't need one specifically for each amount of Cleric levels a NPC has.

This is the latest (and functional) script:

int StartingConditional()
{
    object oPC = GetPCSpeaker();

    int nPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oPC);
    int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, OBJECT_SELF);

    if (nNPCClericLevel > nPCClericLevel)
    {
        return TRUE;
    }

    return FALSE;
}
               
               

               


                     Modifié par Androrc, 18 août 2011 - 09:06 .
                     
                  


            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Why is this conversation conditional script not working?
« Reply #9 on: August 18, 2011, 10:12:54 pm »


               One last inprovement.    Get ride of the if statment.   Your expresion in the if statment already evaluates to what you want to return.  So just return it.

int StartingConditional()
{
    object oPC = GetPCSpeaker();

    int nPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oPC);
    int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, OBJECT_SELF);

    return nNPCClericLevel > nPCClericLevel ;
}