Jump to content

Trying to modify a perk mod


Ewendoun

Recommended Posts

Happy new year evryone !

Apologies about my poor english.

Lately I am trying to modify a mod found on the nexus, just in order to create a loop or reiterate some properties of the script. The mod can be found on nexus, but I am absolutely unable to remember where exactly, even trying to search it on the site.

Anyway, the use I want to make of the modified mod is a bit between selfish and private use and learning some scripting skills. Apologies once again if the question I am about to ask appears a kind of silly ones.

 

So:

Here is the original script, basically it allows to choose two perks per level, using a trick to levelup once again when levelup time is reached (when the player gets a level more):

scn aaExtraPerksScript

int plevel
int lastlevel
int doOnce
int levelup
int justperked
int prelevel
float timer
float secondtimer
int xpdiff
int preXP
int postxp

Begin GameMode

	if doOnce != 2
		set lastlevel to player.getlevel
		set doOnce to 2
	endif
	
	set plevel to player.getlevel
	
	if plevel != lastlevel  && justperked != 2
		set levelup to 2
		set timer to 10
		set prelevel to plevel
		set preXP to player.getav XP
	endif
	
	if levelup == 2
		set timer to timer - getsecondspassed
		if timer <= 0
			player.addperk aaSkillDrop
			player.advlevel
			set secondtimer to 10
			set levelup to 0
			set justperked to 2
		endif
	endif
	
	if justperked == 2
		set secondtimer to secondtimer - getsecondspassed
		if secondtimer <= 0
			player.setlevel prelevel
				if player.hasperk SwiftLearner == 0
					set postxp to player.getav xp
					set xpdiff to (prexp - postXP)
					player.rewardxp xpdiff
				Endif
			set justperked to 0
			player.removeperk aaSkillDrop
		endif
	endif
			set lastlevel to player.getlevel
End
	  
	

The fact is I try to be greedy and allow a third picking of perk, not twice but three times, or even more. So with my lack of knowledge in coding/scripting, I tried two things: duplicate once or more the code to obtain the result, as following:

 

scn aaExtraPerksScript

int plevel
int lastlevel
int doOnce
int bdoOnce
int levelup
int justperked
int prelevel
float timer
float secondtimer
float thirdtimer
float fourthtimer
int xpdiff
int preXP
int postxp

Begin GameMode

	if doOnce != 2
		set lastlevel to player.getlevel
		set doOnce to 2
	endif
	
	set plevel to player.getlevel
	
	if plevel != lastlevel  && justperked != 2
		set levelup to 2
		set timer to 10
		set prelevel to plevel
		set preXP to player.getav XP
	endif
	
	if levelup == 2
		set timer to timer - getsecondspassed
		if timer <= 0
			player.addperk aaSkillDrop
			player.advlevel
			set secondtimer to 10
			set levelup to 0
			set justperked to 2
		endif
	endif
	
	if justperked == 2
		set secondtimer to secondtimer - getsecondspassed
		if secondtimer <= 0
			player.setlevel prelevel
				if player.hasperk SwiftLearner == 0
					set postxp to player.getav xp
					set xpdiff to (prexp - postXP)
					player.rewardxp xpdiff
				Endif
			set justperked to 0
			player.removeperk aaSkillDrop
		endif
	endif
 
	If bdoOnce !=2	
	 	set lastlevel to player.getlevel
	    set bdoOnce to 2
	endif

	set plevel to player.getlevel

	if plevel != lastlevel  && justperked != 2
		set levelup to 2
		set thirdtimer to 10
		set prelevel to plevel
		set preXP to player.getav XP
	endif
	
	if levelup == 2
		set thirdtimer to thirdtimer - getsecondspassed
		if thirdtimer <= 0
			player.addperk aaSkillDrop
			player.advlevel
			set fourthtimer to 10
			set levelup to 0
			set justperked to 2
		endif
	endif
	
	if justperked == 2
		set fourthtimer to fourthtimer - getsecondspassed
		if fourthtimer <= 0
			player.setlevel prelevel
				if player.hasperk SwiftLearner == 0
					set postxp to player.getav xp
					set xpdiff to (prexp - postXP)
					player.rewardxp xpdiff
				Endif
			set justperked to 0
			player.removeperk aaSkillDrop
		endif
	endif

 set lastlevel to player.getlevel
End

It seems to work, but two problems occur: the player in game when tested can only choose oonce normal levelup is done, once the three perks consecutively, but when leveling up once again, keep going on with only two perks to choose. Anyone knows why ?
And another problem, maybe due to the lenght of the script, is that it absolutely fails to work when I try to iterate this kind of trick more than three times (using for example a fifth and a sixth timer following this handling).

Something I would like to try but cannot avoid yet a game crash/freeze is using a loop with a "goto/label" iteration, to repeat the process a definite number of times, but I wasn't able yet to insert a condition to exit the loop, due to my lack of knowledge.
Any solution about this ?

 

Thanks a lot.

 

Ewendoun

Link to comment
Share on other sites

  • Recently Browsing   0 members

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