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 .