Author Topic: Help with comparative reputation, please!  (Read 621 times)

Legacy_LunarBlade

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Help with comparative reputation, please!
« on: December 20, 2010, 06:11:41 am »


               Hello, everyone. I need to ask for some help with this idea I had, since I'm pretty much not the bestestest with scripting.

I've made a 'test' for the player to take. Each answer increases the reputation with one of seven factions by +1 or +2. At the end, I want them to be told what the highest faction was and have their 'subrace' to change to the name of the faction with which they have the best reputation. In case of a tie they will get to choose one or the other. 
... Help! 
I have only gotten this far, and I get the feeling that I'm over simplifying this...

"void main(){
// These are the seven factions that need to be compared.  
object oPC = GetPCSpeaker();
   object oPride = GetObjectByTag("linu_pride");
   object oFury = GetObjectByTag("linu_fury");
   object oGlut = GetObjectByTag("linu_glut");
   object oGreed = GetObjectByTag("linu_greed");
   object oSloth = GetObjectByTag("linu_Sloth");
   object oEnvy = GetObjectByTag("linu_envy"); 
  object oLust = GetObjectByTag("linu_lust");

   GetReputation(   oPride,   oPC   )

// I was thinking I'd run an 'if then' for each to check if they are the highest, but then I got stuck. 

if
oPride>oFury,oGlut,oGreed,oSloth,oEnvy,oLust ;
   then
}"


I admit I don't even know how to make the script boxes here...

Please assist!
Thanks. '^_^'
LunarBlade.
               
               

               


                     Modifié par LunarBlade, 20 décembre 2010 - 06:13 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #1 on: December 20, 2010, 06:02:13 pm »


               I will give it a go. Instead of actually setting some rep how bout just figure out which they should be friendliest toward then tell em?

               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #2 on: December 20, 2010, 06:15:19 pm »


               To determine which subrace type they would best correspond with have the answers to your questions set locals on the PC such as greed +1. Thereby you can bring up the numbers concurrent with their answers. Understand? IE:

Question:
    You love money or people?
Answers:
    People.(in the action taken set the variable "lust" on the PC to SetLocalInt(oPC, "lust", GetLocalInt(oPC, "lust")+1)'<img'>
    Money.(in the action taken set the variable "greed" on the PC to SetLocalInt(oPC, "greed", GetLocalInt(oPC, "greed")+1)'<img'>

Using that method you can simply come up with an int that would determine the outcome.

Using something similar to the following for each type you can determine by setting an int if a certain faction should be considered for the PC.

int PRIDE = GetLocalInt(oPC, "greed");
int FURY = GetLocalInt(oPC, "lust");

if(PRIDE >= FURY && PRIDE >= GLUT && PRIDE >= GREED && PRIDE >= SLOTH && PRIDE >= ENVY && PRIDE >= LUST)
{
   SetLocalInt(oPC, "PRIDE", 1);
}
if(FURY >= PRIDE && FURY >= GLUT && FURY >= GREED && FURY >= SLOTH && FURY >= ENVY && FURY >= LUST)
 {
    SetLocalInt(oPC, "FURY", 1);
 }

The capitalized words PRIDE and such are references to integers. Using that method we determine if each is greater than or equal to the others. If we run a call like that for each then we wind up with only a few ints set on the PC, then those could be used to determine which convo nodes should be displayed to the PC.
               
               

               


                     Modifié par Baragg, 20 décembre 2010 - 06:25 .
                     
                  


            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #3 on: December 20, 2010, 06:18:37 pm »


               I have not seen If/Then statements for a long time. NWN uses If/Else. I could be wrong tho, I have been before.
               
               

               
            

Legacy_LunarBlade

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #4 on: December 20, 2010, 07:52:32 pm »


               Thank you very much, Baragg! I think this just might work for me.

How would I then make the NPC in a conversation announce the 'winning' subrace? How would I go about 'calling' the winner? would that just be as simple as calling the local int that we had just set on the oPC?



I'll give it a try! Thanks!

LunarBlade.
               
               

               
            

Legacy_Baragg

  • Sr. Member
  • ****
  • Posts: 496
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #5 on: December 20, 2010, 11:46:46 pm »


               As to announcing the winning fac, you could adjust the setting call to something like this:

if(PRIDE >= FURY && PRIDE >= GLUT && PRIDE >= GREED && PRIDE >= SLOTH && PRIDE >= ENVY && PRIDE >= LUST)
{
SetLocalInt(oPC, "PRIDE", 1);
SetLocalString(oPC, "FACTION", "Subrace/Faction Name for the Pride Faction");
}
if(FURY >= PRIDE && FURY >= GLUT && FURY >= GREED && FURY >= SLOTH && FURY >= ENVY && FURY >= LUST)
{
   SetLocalInt(oPC, "FURY", 1);
   SetLocalString(oPC, "FACTION", "Subrace/Faction Name for the FuryFaction");
}

Then you can pull that off and use it in a convo node, I have not used custom tokens much so someone else would be better qualified to cover that. Or you could just have the NPC speak it.
               
               

               


                     Modifié par Baragg, 21 décembre 2010 - 12:22 .
                     
                  


            

Legacy_LunarBlade

  • Newbie
  • *
  • Posts: 6
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #6 on: December 21, 2010, 01:09:52 am »


               You are just a fountain of knowledge...! Thanks!

If I may ask another question, though... How would you recommend I deal with any ties? I don't know how to do that... Would the game crash if two factions are tied?
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
Help with comparative reputation, please!
« Reply #7 on: December 21, 2010, 03:14:54 am »


               Hopefully this will show you a way of doing what you want.

#include "x0_i0_stringlib"
void main()
{
 object oSinner = GetPCSpeaker();
 string sFactionTags ="linu_pride,linu_fury,linu_glut,linu_greed,linu_Sloth,linu_envy,linu_lust";
 string sFactionNames ="Pride,Fury,Glut,Greed,Sloth,Envy,Lust";
 string sFTag,sWinnerName;
 int nCount, nSinRank, nWinnersRank;
 int nNumberOfDeadlySins = GetNumberTokens(sFactionTags,",");
 for(nCount=0;nCount < nNumberOfDeadlySins; nCount++)
 {
   sFTag = GetTokenByPosition( sFactionTags,",",nCount);
   nSinRank = GetReputation(GetObjectByTag(sFTag),oSinner);
   if (nSinRank == nWinnersRank) sWinnerName += " and "+GetTokenByPosition( sFactionNames,",",nCount);
   if(nSinRank > nWinnersRank)
   {
     nWinnersRank = nSinRank;
     sWinnerName = GetTokenByPosition( sFactionNames,",",nCount);
   }
 }//EndFor
 if ( FindSubString(sWinnerName," and ") == -1)
   SendMessageToPC(oSinner,"Your Greatest weakenss is " + sWinnerName);
 else
   SendMessageToPC(oSinner,"You weakness is great " + sWinnerName+
   " Threaten to comsume you");
 SendMessageToPC(oSinner, "OOC: Faction rep is: "+ IntToString(nWinnersRank));
}


               
               

               


                     Modifié par Lightfoot8, 21 décembre 2010 - 03:15 .