Jump to content

Scripting advice requested


disterra

Recommended Posts

To anyone that's having problems similar to mine below, notice that my fix was to change the offending part of the script from all variables to some arithmetic. See my edits.

 

I've been teaching myself coding with mixed success, and have attempted to create my own mod, again with mixed success. This mod is intended to increase the player's magicka permanently each level based on their intelligence and race/sign. I can get it to work upon leveling up once per gaming session. However it refuses to do so a second time and I am forced to save/reload to correct the lapse.

 

My question is: how do I correct my script to make the mod run more than once per session?

 

Here's my script:

(AetherLevel is a short global variable)

(below this section of code is another with a startscript)

 

begin (script)
float Int
float Fint
short level
short plev

set Int to ( player->GetIntelligence )
set plev to ( player->GetLevel )

if ( plev == 1 )
set AetherLevel to 1
endif

set level to AetherLevel

if ( plev == level )
return
endif

;Now we mod the character's magicka. The current ratio of int->magicka is the same as the end->health.

if ( plev > level )

;Here is where intelligence variable is modified based on race/astological sign.
;Feel free to add functions for custom classes/races/astrological signs. Preferably as an additional elseif.

if ( player->GetRace, "High Elf" == 1 )
	set Int to ( Int * 2.5 )
elseif ( player->GetRace, "Breton" == 1 )
	set Int to ( Int * 1.5 )
endif
if ( player->GetSpellEffects, "fay ability" == 1 )
	set Int to ( Int * 1.5 )
elseif ( player->GetSpellEffects, "elfborn ability" == 1 )
	set Int to ( Int * 2.5 )
elseif ( player->GetSpellEffects, "wombburn" == 1 )
	set Int to ( Int * 3 )
endif

;Here's where the magicka is actually modified.

set Fint to ( Int / 10 )
player->ModMagicka, Fint
set AetherGlobalValue to ( AetherGlobalValue + Fint )
set AetherLevel to plev
endif

end (script)

 

And here's the startscript I have to modify the player's magicka upon reloading a save file:

(AetherGlobalValue is a floating global variable)

 

begin (startscript)
float Paint

set Paint to AetherGlobalValue
player->ModMagicka, Paint
Stopscript, (startscript)

end (startscript)

 

EDIT:

 

Well I feel derp. I figured out the most glaring issue, and have stumbled upon another to fix later, but here's the big hangup:

 

Line 45 as it was in the OP:

 

        set AetherLevel to plev

 

Which still confuses me how it was the problem, but here's my solution:

 

        set AetherLevel to ( AetherLevel + 1 )

 

The script will now run multiple times per session. I had a save with enough points to level twice in sequence, which worked perfectly most of the time. The only problem I discovered was when the Dark Brotherhood assassin attacks, it fails to execute properly. My new goal is to somehow correct this.

 

EDIT2:

 

I've somewhat corrected the Dark Brotherhood assassin problem. It required me to edit the DBattackScript so that before each "WakeUpPC" I placed a "startscript, (script)" command. Still doesn't work perfectly, but it's better than before.

Edited by disterra
Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...