Author Topic: Conversation conditional by level  (Read 379 times)

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Conversation conditional by level
« on: April 18, 2012, 01:52:55 pm »


               Hi

I'm trying to set up a conversation where new topics become availiable as the PC gains experience, similar to your companions in KOTOR. So what I need to do is store the PC's level upon entering the game, and have the conditional be something like "pclevelvariable +1" and so on. I could use some help.

On Mod enter script:

void main()
{
object oPC = GetFirstPC();
int ilevel = GetHitDice(oPC);
}

Conversation Conditional 1

#include_file
int StartingConditional()
{
if (GetHitDice(GetPCSpeaker) == ilevel+1) return FALSE;
return TRUE;

if(GetLocalInt(GetPCSpeaker(), "DariusTalk") < 1)
return TRUE;
return FALSE;
}

I suppose I could also modify the OnLevelUp script to increment the variable. Suggestions?
               
               

               
            

Legacy__Guile

  • Hero Member
  • *****
  • Posts: 1308
  • Karma: +0/-0
Conversation conditional by level
« Reply #1 on: April 18, 2012, 04:32:29 pm »


               //This is the include script (save it under  the name below)
//NOTE: Be sure to build your module (scripts only) after saving these scripts!

//   gen_levelbyxp

int GetLevelByXP(object oPC)
{
 int nXP = GetXP(oPC);
 int i = 1;;
 if(nXP >= 780000) { i = 40; }
 else if(nXP >= 741000) { i = 39; }
 else if(nXP >= 703000) { i = 38; }
 else if(nXP >= 666000) { i = 37; }
 else if(nXP >= 630000) { i = 36; }
 else if(nXP >= 595000) { i = 35; }
 else if(nXP >= 561000) { i = 34; }
 else if(nXP >= 528000) { i = 33; }
 else if(nXP >= 496000) { i = 32; }
 else if(nXP >= 465000) { i = 31; }
 else if(nXP >= 435000) { i = 30; }
 else if(nXP >= 406000) { i = 29; }
 else if(nXP >= 378000) { i = 28; }
 else if(nXP >= 351000) { i = 27; }
 else if(nXP >= 325000) { i = 26; }
 else if(nXP >= 300000) { i = 25; }
 else if(nXP >= 276000) { i = 24; }
 else if(nXP >= 263000) { i = 23; }
 else if(nXP >= 231000) { i = 22; }
 else if(nXP >= 210000) { i = 21; }
 else if(nXP >= 190000) { i = 20; }
 else if(nXP >= 171000) { i = 19; }
 else if(nXP >= 153000) { i = 18; }
 else if(nXP >= 136000) { i = 17; }
 else if(nXP >= 120000) { i = 16; }
 else if(nXP >= 105000) { i = 15; }
 else if(nXP >= 91000)  { i = 14; }
 else if(nXP >= 78000)  { i = 13; }
 else if(nXP >= 66000)  { i = 12; }
 else if(nXP >= 55000)  { i = 11; }
 else if(nXP >= 45000)  { i = 10; }
 else if(nXP >= 36000)  { i = 9; }
 else if(nXP >= 28000)  { i = 8; }
 else if(nXP >= 21000)  { i = 7; }
 else if(nXP >= 15000)  { i = 6; }
 else if(nXP >= 10000)  { i = 5; }
 else if(nXP >= 6000)   { i = 4; }
 else if(nXP >= 3000)   { i = 3; }
 else if(nXP >= 1000)   { i = 2; }
 else { i = 1; }

 return i;
}

-----------------------

#include "gen_levelbyxp"

void main()
{
 object oPC = GetEnteringObject();
 int nLvl = GetLevelByXP(oPC);
 SetLocalInt(oPC, "ENTERING_LVL", nLvl);  //Not Persistent....
}

---------------------------------

//Starting Conditional....

#include "gen_levelbyxp"

int StartingConditional()
{
 int iReturn = FALSE;
 int iPass = TRUE;
 int iLevel = GetLocalInt(oPC, "ENTERING_LVL");
 int nAdj += 1; //Add + 1 to the level they had OnModEnter...
//If the PC's level is greater than or equal to 1 Level higher than the level they had on enter...
//(meaning they gained enough XP for a level...)
if (GetLevelByXP>= nAdj)
iPass =  FALSE;

if(GetLocalInt(GetPCSpeaker(), "DariusTalk") < 1)
iReturn = TRUE;

if(iReturn && iPass)
return TRUE;
else
return FALSE;

}


Try those and let me know how it works...  :happy:
               
               

               


                     Modifié par _Guile, 18 avril 2012 - 03:56 .
                     
                  


            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Conversation conditional by level
« Reply #2 on: April 18, 2012, 07:30:59 pm »


               Just out of curiosity, why even set the variable OnClientEnter or LevelUp. Why not just have the conditional check the level?

Example:

int StartingConditional()
{
//If player's level is greater than or = to 10 this line will show up.
if (GetHitDice(GetPCSpeaker) >= 10) return TRUE;
return FALSE;
}
               
               

               
            

Legacy_ehye_khandee

  • Hero Member
  • *****
  • Posts: 1415
  • Karma: +0/-0
Conversation conditional by level
« Reply #3 on: April 18, 2012, 07:35:51 pm »


               Just a guess, but, overkill as a style?

His code does allow for level by xp (in case the PC has earned a level and not levelled as yet) - but other than that and where the code goes, there would seem no functional difference. Arguably code in the on_level and on_enter can be useful in other scripts thereby limiting how many times this code must run for the output to be used in this and other scripts. The prior post (edited by _Guile) was totally ginormous tho, this is actually shorter.

Be well. Game on.
GM_ODA
http://playnwn.com
               
               

               


                     Modifié par ehye_khandee, 18 avril 2012 - 06:45 .
                     
                  


            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Conversation conditional by level
« Reply #4 on: April 18, 2012, 07:49:53 pm »


               I think the goal here is to provide different conversation options based on how many levels the PC has gained since starting play int he module. So the OP is not looking for a solution with absolute level, but only for how many levels the PC has gained.

The solution would be to increment an INT on the PC at every level up. If you need a persistent int use the player skin, if this is single player simply set an int.

Then your conditional script checks for how large that INT is. 0 means that PC level is equal to that at module start. 1 means 1 level gained since module start. Etc.....
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Conversation conditional by level
« Reply #5 on: April 19, 2012, 12:01:05 am »


               

henesua wrote...

I think the goal here is to provide different conversation options based on how many levels the PC has gained since starting play int he module. So the OP is not looking for a solution with absolute level, but only for how many levels the PC has gained.

The solution would be to increment an INT on the PC at every level up. If you need a persistent int use the player skin, if this is single player simply set an int.

Then your conditional script checks for how large that INT is. 0 means that PC level is equal to that at module start. 1 means 1 level gained since module start. Etc.....



 If that goal is number of level gained After starting, I see no problem with his first sugestion of just setting the variable OnClientEnter.    Something like:

If (GetLocalInt(oPC,"PC_START_LEVEL") == 0) SetLocalInt(oPC,"PC_START_LEVEL",GetHitDice(oPC));


After that your starting conditions are simple,  You just need to subtract the current Hit dice from the variable you set. your starting contition for the PC having gained only one level would look like. 


int StartingConditional()
{
  object oPC =GetPCSpeaker();
  return (GetHitDice(oPC ) - GetLocalInt( oPC,"PC_START_LEVEL") ) == 1;  
}

Just change the == and 1 to whatever condition you want to match.
               
               

               


                     Modifié par Lightfoot8, 18 avril 2012 - 11:02 .
                     
                  


            

Legacy_Snarkblat

  • Full Member
  • ***
  • Posts: 104
  • Karma: +0/-0
Conversation conditional by level
« Reply #6 on: April 19, 2012, 03:03:34 pm »


               Thank you, everyone for your help. Lightfoot, I did as you suggested - stored the variable OnEnter and incremented it OnLevelUp - and it worked like a charm.

I was dissatisfied with a lot of the ways henchman dialogue was handled in NWN, particularly HOTU, where advancing the plot was dependent upon wandering into talk triggers - which didn't always fire. Gaining experience always made more sense to me, as it gave a sense that the PC was growing as a character and their companions were coming to trust them more.

But thanks again, I'll work on this some more until I have a nice system going.