Suddenly broken script

Post » Sat Dec 05, 2009 8:41 pm

Okay, here's the deal, two parter, should be easy but I can't seem to make sense of this. The point of the script was to equip the repairhammer to launch it's UI once you clicked the activator, boost your armorer skill by 25, and then when you finish doing repairs the bonus is removed and old stat returned. I mostly had it figured out, but the two hitches are this:
1) It was invariably adding up to 100 either because it was resolving 75+ for some reason (it's a new character with 8 skill) or it was repeating the original line of player.SetAV Armorer + 25 behind an else statement. Now that I added the runonce bit to prevent a loop, the script says it can no longer save and the problem is line 17, the bonus line. But it was fine before.
2) The line I commented is the method to restore the original value. Without the comment it was automatically restoring the value back to what it was, is there any way to make that part only run once the repair screen is shut down?

scn AAWscript ScriptBegin onactivateshort originalskillshort runonceset runonce to 0set originalskill to player.GetAV Armorerplayer.equipitem repairhammerif (originalskill > 75 && runonce == 0 ) 		player.setAV Armorer 100		set runonce to 1	else		player.setAV Armorer originalskill + 25		set runonce to 1endif;player.setAV Armorer originalskillend

And of course if there is any easier way to do this that I'm not realizing I'd love you for it.
User avatar
Ludivine Dupuy
 
Posts: 3418
Joined: Tue Mar 27, 2007 6:51 pm

Post » Sun Dec 06, 2009 2:10 am

The GetAV and SetAV functions are generally to be used with great care.
The definitions of the functions you used alone are making it obvious how easily such a usage can fail.

GetAV returns the "current" value of the skill, while SetAV, according to the documentation, sets the "base" value.
So if there's any effect on your Armorer skill, using "set value to player.GetAV Armorer" and "player.SetAV Armorer value" in succession, as your script does when this line isn't commented out, will lead to your Armorer skill rising beyond its original value.

I'd first advise using the ModAV approaches rather and next also using the additional ones form OBSE and not the regular ones, which are again modifying the "base" skills.
Read up on those ...AV functions over at the CS Wiki, http://cs.elderscrolls.com/index.php/. There's a lot of stumbling stones with these to be aware of.

OBSE's ModAV2 for example is acting like a "fortify skill" spell and should be much safer in this regards.
User avatar
Natasha Biss
 
Posts: 3491
Joined: Mon Jul 10, 2006 8:47 am

Post » Sun Dec 06, 2009 8:24 am

I specifically want to avoid using ModAV or ModAV2, as I want the actual value and skill level to go up by 25 temporarily. That way it effectively has you go from Journeyman to Expert, etc. Isn't there something like ActorBaseValue for the unmodded total?
User avatar
Anna Beattie
 
Posts: 3512
Joined: Sat Nov 11, 2006 4:59 am

Post » Sun Dec 06, 2009 2:22 am

scn AAWscript Script

Begin onactivate

short originalskill
short runonce

set runonce to 0
set originalskill to player.GetAV Armorer

player.equipitem repairhammer

if (originalskill > 75 && runonce == 0 )
player.setAV Armorer 100
set runonce to 1
else
player.setAV Armorer originalskill + 25
set runonce to 1
endif

player.setAV Armorer originalskill - 25
;This should return it to normal, or if it doesn't, I'm stumped

end
User avatar
Laura Elizabeth
 
Posts: 3454
Joined: Wed Oct 11, 2006 7:34 pm

Post » Sat Dec 05, 2009 8:01 pm

It still won't parse the script returning an error of "expected end of line at 17", which is the player.setAV Armorer originalskill + 25 line. If it's not behind an else statement it'll resolve, but won't if it is.

Like I needed more evidence Gamebryo has the single worst scripting ever. =| Really wish they'd use accepted script practices or actual code integration. I can build an entire website and forum out of PHP without thinking twice, but THIS has issues with anything that would qualify as well put together. Yes, I'm bitter you can't even do things like ($var + 1) for easier math usage.

And of course as I wrote that in the quick reply "Your secure key is no longer valid." Why am I surprised, they can't even cookie the website correctly. ><
User avatar
oliver klosoff
 
Posts: 3436
Joined: Sun Nov 25, 2007 1:02 am

Post » Sun Dec 06, 2009 9:43 am

That's likely because the blank serves as an argument seperator in function calls. The function doesn't take more than 2 parameters, so "Armorer" + "originalskill" + "+" + "25" is too much. Usually this can be dealt with by using brackets: "player.setAV Armorer (originalskill + 25)", but in case it doesn't you'll need a temporary variable in a line before this one for the second parameter to be "originalskill + 25" in value.

And for the records, I still don't think this will work, because you're still technically getting and setting different stats. Getting "current" value (base + modifiers), setting "base" value (modifiers will then be added onto this to get the real value). In my eyes this is not going to work with those 2 functions.
User avatar
Jack Moves
 
Posts: 3367
Joined: Wed Jun 27, 2007 7:51 am


Return to IV - Oblivion