Script Help Needed - Lockpicking and Broken Picks

Post » Tue May 17, 2011 6:16 am

Ok, here's the deal: Obivion XP awards points for lockpicking. Open an easy lock and you get 30 points, pick a very hard lock and you get 75. That works just fine. However, there is a part of the script that is supposed to take broken lockpicks into account and that doesn't work at all.

So, my question is: when does Misc Stat 9 (which keeps track of broken lockpicks) get updated? There is a quest running with a script attached that keeps track of this stuff. I'm finding that the Misc Stat 9 is not being updated during this script. I've tried using MenuMode and GetActiveMenuMode and that doesn't help.

Here's the basic idea:

On gameload record the number of broken lockpicks in a variable. (if I update the variable only when a lock is picked - see code below)
Upon opening a lock, check the Misc Stat 9 and figure out how many lockpicks have been broken. However I always get zero for the number of broken lockpicks.
Update the script variable with the new number of broken picks.

Below is the actual script. See my comments next to a couple of statements.
Spoiler
;lockpicking - tracking broken lockpickslet numberOfBrokenPicks := getPCMiscStat 9 - numberOfBrokenPicksOldlet numberOfBrokenPicksOld := getPCMiscStat 9                 ---- At one point I commented this out and put the assignment in the if statement, below.  When I had it further down in the script, I also added the initialization when the game is loaded.;if (ObXPMain.debugMode)	;scribe "Broken Lockpicks: %.0f, Old value: %.0f|OblivonXP" numberOfBrokenPicks numberOfBrokenPicksOld;endiflet tempLong := arrayMiscXP[1]if ( getPCMiscStat 8 > tempLong ) && ( numberOfBrokenPicks <= ObXPSettings.lockpicksBrokenMax )	let gainedXP :=  ( 1 + ObXPMain.playerLevel * ObXPSettings.multXPLevel ) * ( getPCMiscStat 8 - tempLong ) * ObXPSettings.multXPLockpick * lockPickDifficulty	if ( gainedXP )                ** this block updates the running total of experience points and displays a message on-screen - it works fine	endif	;let numberOfBrokenPicksOld := getPCMiscStat 9                  ---- I tried this instead of the assignment outside of the if statement - it didn't work either.endif


ObXPSettings.lockpicksBrokenMax is normally set to 5, so if you break 5 or more lockpicks, you're not supposed to get any points. However the numberOfBrokenPicks is always zero, no matter what.

Later in the script there's a MenuMode block for some other processing. I tried adding if (GetActiveMenuMode == 1014) or if (MenuMode 1014 == 1) and setting variables in there, but that didn't help.

So does anybody know how I might accomplish this? I know Misc Stat 9 is getting updated, but I can't figure out what the timing is so I can query it in this scipt.

Thanks for any help!
User avatar
Kortniie Dumont
 
Posts: 3428
Joined: Wed Jan 10, 2007 7:50 pm

Post » Tue May 17, 2011 10:41 am

Why not use the number of lockpicks the player has instead? That does mean you'll have to update it often but if it gets around the problem it'd be worth it.
User avatar
Catharine Krupinski
 
Posts: 3377
Joined: Sun Aug 12, 2007 3:39 pm

Post » Tue May 17, 2011 5:02 am

I'd be paranoid and put parentheses into
let numberOfBrokenPicks := getPCMiscStat 9 - numberOfBrokenPicksOld

just in case the subtraction is done first! That would probably kill the script and just not do the points work.
User avatar
Matt Bee
 
Posts: 3441
Joined: Tue Jul 10, 2007 5:32 am

Post » Tue May 17, 2011 3:24 am

The problem might be that the tracing of the broken lockpicks is being done too fast, since it's running outside the block that checks if a lock has actually been picked or not. With the result that if a lock is not picked by the time another check is done, numberOfBrokenPicksOld will still have the same value as getPCMiscStat 9 and numberOfBrokenPicks will result in being set to 0 (getPCMiscStat 9 - numberOfBrokenPicksOld).

let numberOfBrokenPicks := (getPCMiscStat 9) - numberOfBrokenPicksSinceLastLocklet tempLong := arrayMiscXP[1]if ( getPCMiscStat 8 > tempLong ) && ( numberOfBrokenPicks <= ObXPSettings.lockpicksBrokenMax )	let gainedXP :=  ( 1 + ObXPMain.playerLevel * ObXPSettings.multXPLevel ) * ( getPCMiscStat 8 - tempLong ) * ObXPSettings.multXPLockpick * lockPickDifficulty	if ( gainedXP )                ** this block updates the running total of experience points and displays a message on-screen - it works fine	endif	let numberOfBrokenPicksSinceLastLock := numberOfBrokenPicksendif


This should fix the problem, though it adds a new one. The broken lockpicks will keep adding up and the player will never gain XP for picking a lock again if he breaks too many. So you'll need to run a tiny bit of code that checks if the player is exiting the lockpicking minigame without actually picking the lock and then let numberOfBrokenPicksSinceLastLock := numberOfBrokenPicks. Or something along those lines.

Anyway, hope I gave you some ideas.
User avatar
suzan
 
Posts: 3329
Joined: Mon Jul 17, 2006 5:32 pm

Post » Tue May 17, 2011 11:30 am

I decided to run a quick test in game.

The code you have should work fine as the lockpick minigame is in menumode so the code doesn't run until you're done. But I did notice that getPCMiscStat 9 does not get updated if you use "Auto Attempt" on the lock. It only updates when you manually do it. I suggest using The Greatness' suggestion to check the number of lockpicks the player has instead.
User avatar
leni
 
Posts: 3461
Joined: Tue Jul 17, 2007 3:58 pm

Post » Tue May 17, 2011 10:03 am

Ah, interesting ideas, guys, thanks. I was using auto attempt to test this since that's the easiest way to break a ton of lockpicks :) I love the idea of simply checking for the number of lockpicks - talking about approaching something from a completely different angle! And as LogicDragon says, that might be the best way to do it too. I thought it was a timing thing or something happening in the menus, but I think the stat did eventually get updated, but not in time for my purposes.

Ok, back to work. Thanks again for the help!
User avatar
Portions
 
Posts: 3499
Joined: Thu Jun 14, 2007 1:47 am

Post » Tue May 17, 2011 4:48 am

Got it working! Probably as LogicDragon suggested - misc stat 9 isn't updated if you use auto attempt, or if it is updated, the timing is odd, so it's not practical to use in a script. Used The Greatness' suggestion and now you don't get any points if you break too many lockpicks - muwahahaha! Now I'm probably going to get a bunch of complaints about not getting points for lockpicking :sigh:

Thanks again, guys.
User avatar
Breanna Van Dijk
 
Posts: 3384
Joined: Mon Mar 12, 2007 2:18 pm


Return to IV - Oblivion