Author Topic: A question about variables: solved.  (Read 574 times)

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
A question about variables: solved.
« on: March 22, 2013, 09:46:54 am »


               First off, the variable I refer to is integer. I'm experimenting with a new relationship system I've developed, where the PC has a set relationship with all relevant NPCS. This relationship is a vaule of 1-30. Each relationship variable is the tag of the NPC with a RS on the end. For example, one of my NPC's tag is "npc_elf_father" so the variable would be called "npc_elf_fatherRS". The way the Father talks to the PC would then depend on what relationship value the PC has with the Father. There are 3 relationship types, Loveful, Netural and Hateful. The relationship is Loveful if the variable is between 30-21. The relationship is Netural, then the variable is between 20-11. If the relationship is hateful then the variable is between 11-1. Now, depending on how the PC talks to them, or other things such as not completing a quest or generally screwing up, then the value is either pushed up or pushed back. For example, if the PC was rude to the Father, 1 point may be taken from the variable.

I then found a problem, what if, in situations where the variable would be increase by 5 and this would push it ABOVE 30 (which is the max)... how could I find my way around it. I decided to test the current value of the variable to see if its above 25, in which case, instead of adding 5 to it, I'd just set it to 30 to stop it from going over. 

Wasn't sure how to put it in a frame, so I put the code in a quote.

void main()
{    int nValue;
    // The PC //   
object oPC = GetPCSpeaker();
    // If the local integer is more than 25. //   
if ( GetLocalInt(oPC, "npc_elf_fatherRS") > 25 ) 
  {     
// Set local integer. //       
SetLocalInt(oPC, "npc_elf_father", 30);   
}    else 
  {     
  // Set local integer. //     
  nValue = GetLocalInt(oPC, "npc_elf_father") + 5;       
SetLocalInt(oPC, "npc_elf_father", nValue);}


But now I run into my next pitfall, which I probably should have found out first... As I stated, some of things the father could say is dependant on what type of relationship the PC shares with him. However, these values are intergers not strings. Therefore, my question: Is it possible to test for a value inbetween 2 values? For example, to test for a loveful relationship, a value between 30-21. If this is not possible, could I work around it somehow? 
               
               

               


                     Modifié par simomate2, 22 mars 2013 - 10:45 .
                     
                  


            

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
A question about variables: solved.
« Reply #1 on: March 22, 2013, 10:00:44 am »


               I may have figured it out. Basically, to test for a loveful relationship it would test for a value greater then 20. To test for a hateful relationship, it would test for a value less then 11. Now for the most complicated one, the netural relationship... it would test for a value less then 21 but also for a value greater then 10.
               
               

               
            

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
A question about variables: solved.
« Reply #2 on: March 22, 2013, 10:14:31 am »


               Uh, new question.

I'm trying to convert the script to set the variable, or test for one in the pc skin,

#include "x3_inc_skin"
void main()
{
// Find the PC //
object oPC = GetPCSpeaker();
//The Variable being set //
nValue = GetSkinInt(oPC, "npc_elf_father") + 1;
SetSkinInt(oPC, "npc_elf_father", nValue);
}


However, I get a compile error. How can I add to a value already set in skin?
               
               

               
            

Legacy_acomputerdood

  • Sr. Member
  • ****
  • Posts: 378
  • Karma: +0/-0
A question about variables: solved.
« Reply #3 on: March 22, 2013, 04:00:04 pm »


               you're not declaring nValue.

or is this just an excerpt of the real code?
               
               

               


                     Modifié par acomputerdood, 22 mars 2013 - 04:00 .
                     
                  


            

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
A question about variables: solved.
« Reply #4 on: March 22, 2013, 10:45:36 pm »


               Yes that was it ^ I left that bit out.
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
A question about variables: solved.
« Reply #5 on: March 23, 2013, 02:47:57 pm »


               So you really going with a rather time honored tradition, whether you realize it or not.  So if you have a 20+ somebody really got under your skin.
               
               

               
            

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
A question about variables: solved.
« Reply #6 on: March 23, 2013, 09:54:47 pm »


               If you have under 11 you pissed someone off '<img'>

Generally the relationship begins at 15 which is neutral except for some cases. Oh, about this being a tradition, I'm not suprised if this was done before. I wasn't aiming to do something unique, I was simply aiming to benefit my module. Mostly, I just want to increase the roleplay ability. If the player is an **** then NPC's should treat him like one. 
               
               

               


                     Modifié par simomate2, 23 mars 2013 - 09:57 .
                     
                  


            

Legacy_AzurDraak

  • Jr. Member
  • **
  • Posts: 84
  • Karma: +0/-0
A question about variables: solved.
« Reply #7 on: March 24, 2013, 12:48:16 pm »


               I was wondering about the disappearing "RS" suffix.
Is this a typo in your post, or is it also in your script?
               
               

               
            

Legacy_ffbj

  • Hero Member
  • *****
  • Posts: 1097
  • Karma: +0/-0
A question about variables: solved.
« Reply #8 on: March 24, 2013, 11:33:14 pm »


               simonate:  I was just referencing the old song "I've got you under my skin I've got you deep in the heart of me." Since the variable is set on the persons skin.  That's all.  No it's a cool idea.
               
               

               
            

Legacy_simomate2

  • Full Member
  • ***
  • Posts: 133
  • Karma: +0/-0
A question about variables: solved.
« Reply #9 on: March 25, 2013, 06:05:32 am »


               

AzurDraak wrote...

I was wondering about the disappearing "RS" suffix.
Is this a typo in your post, or is it also in your script?


It WAS in my script when I first made this topic but I fixed it shortly after.