Author Topic: LocalInt Problem  (Read 570 times)

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
LocalInt Problem
« on: July 13, 2014, 02:55:41 pm »


               I,m having a problem storing a localInt.

I'll try to be brief. On a custom mod acquire, I set a localInt on PC with at 1.
As the PC acquires other items and does other task the Int is increased by 1. I have an NPC named Script Boy I use to test scripts, set Locals, ect. during testing.
Example of increase script.
void main()
{
object oPC = GetFirstPC();
object oBook = GetItemPossessedBy(oPC,"ManifestVolume98");
int nNum = GetLocalInt(oBook,"Manifest") +1 ;
if(GetIsObjectValid(oBook))
{
AddJournalQuestEntry("JtManifest",4,oPC,TRUE,TRUE,TRUE);
SetLocalInt(oBook,"Manifest",nNum);
ExecuteScript("ex_chk_manifest",oPC);
GiveXPToCreature(oPC,5000);
}
else
{
GiveXPToCreature(oPC,2000);
}
}
The int was originaly set on the PC. I changed it to oBook after reading a thread that said variables are not stored on PC when they exit the game. I still get the same result.

In play eveything works fine. Every task or item acquired increases the int. This is checked by convo with Script Boy.
The problem arrisies when I save and exit the game. When I load the saved game.
Script Boy tells me that the int is set to 1.
He also tells me that the int on the PC for another NPC convo is set at 14(which is what it should be).
The Exectute script is a seperate script that checks the state of the LocalInt, so that when a certain number is reached the quest ends.

Sorry. I know it's a bit wordy.
Ed
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
LocalInt Problem
« Reply #1 on: July 13, 2014, 07:21:46 pm »


               

Are you exporting/saving the character after the update to the int? The variables won't stay with the items that the character possesses unless you are saving that character to the vault with that item and it's most recent variables. As long as the character is getting exported at some point before the server reset it should be working.



               
               

               
            

Legacy_zero-feeling

  • Sr. Member
  • ****
  • Posts: 287
  • Karma: +0/-0
LocalInt Problem
« Reply #2 on: July 13, 2014, 08:46:19 pm »


               

if this is for a quest?


if it is i use PQJ (Persistent Quest Journal).


it works awesome, one script as an include that goes at the top of the secondary scripts.


heres a link to my dropbox where it's available to download all the time.


i added the editor that was made for it as a DM tool.


 


https://www.dropbox....with_editor.zip


 


give it a try, so easy to use.



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
LocalInt Problem
« Reply #3 on: July 14, 2014, 01:28:07 am »


               

Ghost of God,


No this is not an export/save. This Quest is big, I would guess about 3-6 hrs. This is just a single player, save,exit, and load saved game. This problem seems to be just with this variable,("Manifest"). It was originaly set on the PC. What I don't understand is why it is failing when all the other variables I set on the PC, and increase work. I have months of building in this part of the mod, and would rather not scrap it for a different system. Should I try a different name for the variable ?


 


Thank you for taking the time to help,


Ed



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
LocalInt Problem
« Reply #4 on: July 14, 2014, 02:42:21 am »


               

Is the book an item that you would have scripted replacement for if it could not be found on the PC?  Is the book ever copied?



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
LocalInt Problem
« Reply #5 on: July 14, 2014, 04:03:40 am »


               WhiZard,
No, and no. The book is only in one place. I acquire it in each test. It has a unique tag and ref.
I have sinse changed the script back to putting the LocalInt on the PC, as putting it on the book made no difference. From what I can tell, it dosen't matter what I set it on. The problem must be something else.
Ed
               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
LocalInt Problem
« Reply #6 on: July 14, 2014, 04:29:36 am »


               

Well. I don't know what caused this but the only way to solve that I can see is to debug each step thoroughly.


 


Make a script which will print you into combat log the actual variable value. Call this script via console after each step in the whole quest or what is that. Find exact spot where it does break.


 


Sorry if you already did this.



               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
LocalInt Problem
« Reply #7 on: July 14, 2014, 05:26:50 am »


               

My guess is you have typed the tag incorrectly into the script (check capitalization as this is case-sensitive).



               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
LocalInt Problem
« Reply #8 on: July 14, 2014, 09:16:33 am »


               

umm.  in single player, variables do not get saved to players items, when they export the character.  Unless the item is in a bag. 


 


Now if the player never leaves the game, In single player games, both the character himself and items will work to keep the data.   If there is some reason for the character to export the character in single player,  your best bet is the data base. 


 


Believe it or not,  not saving vars to items in single player exports is a good thing.    



               
               

               
            

Legacy_MagicalMaster

  • Hero Member
  • *****
  • Posts: 2712
  • Karma: +0/-0
LocalInt Problem
« Reply #9 on: July 14, 2014, 05:30:21 pm »


               

Can you show the script boy code that's printing off the 1?



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
LocalInt Problem
« Reply #10 on: July 16, 2014, 01:17:35 am »


               

MagicMaster,

You certainly may.


PC NODE - I would like to see what number a variable is set at.

  NPC NODE - Which one ?

    PC Node - SirAlConvo. Action Taken "at_cus_108_01"

      NPC -Node - The variable is set at, <CUSTOM108>.

    PC Node - Manifest. Action Taken "at_cus_108_02"

      NPC Node - The variable is set at, <CUSTOM108>.


"at_cus_108_01"

void main()

{

object oPC = GetFirstPC();

int nNum = GetLocalInt(oPC,"SirAlConvo");

string sNum = IntToString(nNum);

string sFu = "Something is F****d Up !";// Cleaned up the language


if(GetLocalInt(oPC,"SirAlConvo") >= 1)

{

SetCustomToken(108,sNum);

}

else

{

SetCustomToken(108,sFu);

}

}


"at_cus_108_02"

void main()

{

object oPC = GetFirstPC();

object oBook = GetItemPossessedBy(oPC,"ManifestVolume98");

int nNum = GetLocalInt(oPC,"Manifest");

string sNum = IntToString(nNum);

string sFu = "Something is F****d Up !";// Potty mouth


if(GetLocalInt(oPC,"Manifest") >= 1)

{

SetCustomToken(108,sNum);

}

else

{

SetCustomToken(108,sFu);

}

}


Sorry it took so long to reply. Fired up the Computer, sat back and waited for the processes to load. Next I knew it was 1:00 am. I could get alot more building done if I didn't have to work for a living.


At first I thought it was the Custom Token, but I have a script on a safe convo that uses 3 tokens to generate the numbers turned on the dial. Every time you loop through the same dialouge, the Token generates 3 new numbers.


Also I can go through the above convo several times and the answers are correct. In fact, if I run through the entire quest, the execute script will tell me that the quest has finished. That tells me it's not a tag problem. The problem only occures when I save the game, exit the game, and load the saved game.


I must have done something horribly wrong,

Ed



               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
LocalInt Problem
« Reply #11 on: July 16, 2014, 01:30:00 am »


               

Sorry the last 2 PC nodes are attached to the 1st NPC node.


  Ed


               
               

               
            

Legacy_Ed Venture

  • Full Member
  • ***
  • Posts: 200
  • Karma: +0/-0
LocalInt Problem
« Reply #12 on: July 17, 2014, 03:17:37 am »


               AHA !
Found the problem. Here's what Stupid learned today.
The Mod event OnAcquireItem, fires when you load a saved game. Silly me I thought it only fired when you put an item in your inventory. Wrong !
Lets have a look.
This is the Mod OnAcquire,

//ON MOD ACQUIRE ITEM "mod_acq_item_ed"
void main()
{

object oItem;
oItem = GetModuleItemAcquired();
object oPC = GetItemPossessor(oItem);
object oBook = GetItemPossessedBy(oPC,"ManifestVolume98");
string sScript = "ex_chk_manifest";
int nInt = GetLocalInt(oPC,"Manifest");
int nNum = nInt +1 ;

if(GetIsObjectValid(oItem))// Is the object valid
{
if(GetIsPC(oPC))
{
if(GetTag(oItem) == "RoyalCor")// Tag of the item
{
AddJournalQuestEntry("JtLighthouse",1,oPC);
}
if(GetTag(oItem) == "RoyalGoldBars")
{
AddJournalQuestEntry("JtLighthouse",4,oPC);
}
if(GetTag(oItem) == "ManifestVolume98")
{
AddJournalQuestEntry("JtManifest",1,oPC);
SetLocalInt(oPC,"Manifest",1); // sets original int to 1
}
if(GetTag(oItem) == "SmTuna")
{
object oCat = GetObjectByTag("HungryKitty");
AssignCommand(oCat,ActionMoveToObject(oPC,TRUE,0.1f));
SetLocalInt(oCat,"Meow",1);
}
if(GetIsObjectValid(oBook))//Items in Manifest Destiny Quest
{
if(GetTag(oItem) == "PayrollBox")
{
AddJournalQuestEntry("JtManifest",10,oPC,TRUE,TRUE,TRUE);
SetLocalInt(oPC,"Manifest",nNum); //2
GiveXPToCreature(oPC,2000);
GiveGoldToCreature(oPC,392);
ExecuteScript("ex_chk_manifest",oPC);
}
if(GetTag(oItem) == "SirDalBlade")
{
SetLocalInt(oPC,"Manifest",nNum); //3
AddJournalQuestEntry("JtManifest",17,oPC,TRUE,TRUE,TRUE);
ExecuteScript("ex_chk_manifest",oPC);
}
// Add addisional quest Items here
}
//Add addisional Items here
}
}
}

The test,
PC enters Mod.
PC acquires oBook.
PC speaks to Script Boy - Variable is set at 1
PC does a quest task
Script Boy says variable is set at two.
It is at this point, if I save, exit, and load save that the variable would be set back to 1
Instead PC drops oBook
Save,Exit,Load
Script Boy says the variable is still set at 2.

On Load the script runs and finds the first variable and sets it.
My head hurts.

Ed
               
               

               
            

Legacy_WhiZard

  • Hero Member
  • *****
  • Posts: 2149
  • Karma: +0/-0
LocalInt Problem
« Reply #13 on: July 17, 2014, 04:07:44 pm »


               

So if you dropped the book and then picked it up you would reset the quest status? Looks like you need a do once check.



               
               

               
            

Legacy_meaglyn

  • Hero Member
  • *****
  • Posts: 1451
  • Karma: +0/-0
LocalInt Problem
« Reply #14 on: July 17, 2014, 04:31:49 pm »


               


So if you dropped the book and then picked it up you would reset the quest status? Looks like you need a do once check.




 


Or check that the quest is in the state you expect (effectively the same thing, but already there in the journal).



if (GetTag(oItem) == "RoyalCor"  && GetLocalInt(oPC,  "NW_JOURNAL_ENTRYJtLighthouse") == 0) {
...

I'm asusming since this is getting set to entry 1 that 0 is the right state to be in to do this.