-------------------------------------------------------------------
Tutorial for script that updates your leveled items
You probably know about level scalling used in entire game. And you probably know about common problem which comes with leveled rewards from quests - once you receive one particular version of the item, including low-leveled ones, then it remains the same forever, what can be quite annoying when your character reaches 30-th level or higher and you still possess that stupid 10-th level version of the sword. If you wish to make level scalling less annoying - no matter for what purpose you might need it, for your own pleasure, or maybe also for other users of your mod - then you should consider creating a script which updates specific leveled items every time your character reaches enough high level. And this is what I am going to show in this tutorial.
The idea of the script itself is simple - it runs all the time, checking if you are possessing a specified item with too high level, and if yes, then replaces it with better version. For example, if you type to check does you are possessing a steel longsword while having level 16 or higher, the script will notify if those two conditions are true and will perform the desired result. For the purpose of this tutorial, I have created a custom script of updating the Blackwater Blade from quest "Unexpected Voyage". You can take a look on him at the bottom of this article and see for your own.
First of all, we need to check the player's level. For this purpose, we need to type this:
if ( LVL != player.getlevel ) set LVL to player.getlevel endif
This part will run whenever the "LVL" variable is not equal to the player's level, what means you have reached another level. It is not essential for your script and I am using it to simplify the progress, so you will not need to type every time "player.getlevel", but just "LVL". With this part, our script will look this way so far:
scn aaaTestScriptUpdater short LVL Begin GameMode if ( LVL != player.getlevel ) set LVL to player.getlevel endif
Now it is a time to create first part of script which checks does the player is possessing specified item with too high level. Since it has been reported that riding a horse when such script runs might create problems, we will add at the beginning the condition which blocks the script while player is on the horse. Also, to prevent situations when player is currectly holding the item in his hand or wearing it and the script suddenly unequips the item from him, we will add the condition which checks does the player is currectly using the specified item. So, we need to type this:
if ( player.IsRidingHorse == 0 ) if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) if ( player.getequipped IDofLowLevelItem == 1 )
Obviously, in "IDofLowLevelItem" we need to type the ID name of item that should be replaced with better version, and in "NumberOfLevelWhenPlayerShouldn'tHaveThisItem" we need to type the number of minimum level, when this item becomes too low-level for player and must be replaced with better one.
Okay, so we have our first conditions in our script. Now we need to type the lines which takes the low-level item away from player and gives the better version instead. The most simple version may look this way:
if ( player.IsRidingHorse == 0 ) if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) if ( player.getequipped IDofLowLevelItem == 1 ) player.unequipitem IDofLowLevelItem player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 player.equipitem IDofBetterItem else player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 endif
As you may guess, "IDofBetterItemOrLeveledList" means ID name of specific better item if there is only one such item, or of the leveled list if there are many of those better versions. "IDofBetterItem" means ONLY a specific better item.
This part of script does following: first, it unequips the item and takes him away, then it adds the better item or the leveled list to the player, and finally it equips this better item on the player. You must remember that if there are many of those better versions, then you need to type every single one for the part when script must equip it on the player - it will not guess which one should be equipped, and if player is not currectly possessing the version typed for "equipitem" function, then player will just remain with not holded/weared item.
That was the most simple version. For this one, it will just do what it should and you will be notified with this by "XXX removed" and "XXX added" messages. If you would like to remove them, there are two ways to perform that, and you can learn about both of them by checking Message Spam article.
Okay, it is time to check what we have made so far:
scn aaaTestScriptUpdater short LVL Begin GameMode if ( LVL != player.getlevel ) set LVL to player.getlevel endif if ( player.IsRidingHorse == 0 ) if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) if ( player.getequipped IDofLowLevelItem == 1 ) player.unequipitem IDofLowLevelItem player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 player.equipitem IDofBetterItem else player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 endif endif
Now if you wish to add more versions to replace, then just copy/paste the part after "if ( player.IsRidingHorse == 0 )", and do not forget about replacing "if" with "elseif". To complete the script, finish it with enough "endif" and one "END":
scn aaaTestScriptUpdater short LVL Begin GameMode if ( LVL != player.getlevel ) set LVL to player.getlevel endif if ( player.IsRidingHorse == 0 ) if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) if ( player.getequipped IDofLowLevelItem == 1 ) player.unequipitem IDofLowLevelItem player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 player.equipitem IDofBetterItem else player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 endif endif elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) (...) endif endif End
And at this point, your script should be correct. There is only one thing to do - you must add it to the quest in order to make it working. Set type of your script as "Quest" at the top of the script menu, and then open quest menu by button with "Q". Add new quest by clicking RMB on the list and checking "New". Then click this quest and in "Script" part choose your script from the list. You did it! Now save your mod and you are free to go.
There is one more feature to add, if you wish. Such updating script can be a bit problematic for the game and can make it working slower if there are many such scripts working in the background. To avoid such problem, you should do following: add also "short NotPerform" below "short LVL", add "set NotPerform to 0" below "set LVL to player.getlevel", add "&& NotPerform == 0" next to "if ( player.IsRidingHorse" and at the end of the script, after last replaced item, add instead of next one:
else set NotPerform to 1
In this case, your script will look this way:
scn aaaTestScriptUpdater short LVL short NotPerform Begin GameMode if ( LVL != player.getlevel ) set LVL to player.getlevel set NotPerform to 0 endif if ( player.IsRidingHorse == 0 && NotPerform == 0 ) if ( player.getitemcount IDofLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) if ( player.getequipped IDofLowLevelItem == 1 ) player.unequipitem IDofLowLevelItem player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 player.equipitem IDofBetterItem else player.removeitem IDofLowLevelItem 1 player.additem IDofBetterItemOrLeveledList 1 endif endif elseif ( player.getitemcount IDofAnotherLowLevelItem > 0 && LVL >= NumberOfLevelWhenPlayerShouldn'tHaveThisItem ) (...) else set NotPerform to 1 endif endif End
Remember that in this version, this script will replace your item ONLY if you are currently possessing it while gaining a new level, because we have forced the script to block itself after completing his task and to not run again unless you have reached another level. To avoid this, you should also add this script to the item:
scn aaaTestScriptUpdaterItem Begin OnAdd Player set IDofTheQuest.NotPerform to 0 End
"IDofTheQuest" is a ID name of the quest you have just created. This script will cause game to make quest script running whenever you add the item to your inventory.
And this is all. Below you will find my example of complete script, to be absolutely sure that you have understood everything correctly.
















Back to top






Sign In
Create Account


