Why is this conversation conditional script not working?
#1
Posté 18 août 2011 - 07:56
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...
#2
Posté 18 août 2011 - 08:05
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...
#3
Posté 18 août 2011 - 08:05
Edit: ninja'd
Modifié par Morbane, 18 août 2011 - 08:05 .
#4
Posté 18 août 2011 - 08:11
Or does GetLevelByclass() not return 0 when you have no levels in that class, but something different, like invalid?
#5
Posté 18 août 2011 - 08:25
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 .
#6
Posté 18 août 2011 - 08:26
#7
Posté 18 août 2011 - 08:31
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 .
#8
Posté 18 août 2011 - 08:41
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.
#9
Posté 18 août 2011 - 09:06
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 .
#10
Posté 18 août 2011 - 09:12
int StartingConditional()
{
object oPC = GetPCSpeaker();
int nPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, oPC);
int nNPCClericLevel = GetLevelByclass(class_TYPE_CLERIC, OBJECT_SELF);
return nNPCClericLevel > nPCClericLevel ;
}





Retour en haut






