Shrine of Kynareth

Oblivion. 10% Playing, 90% Modding.

Scripting Oddities in Oblivion

August 2, 2020 Modding Guides

I intend to use this page to document oddities I come across while trying to mod Oblivion. As a base I use the Elder Scrolls CS Wiki and will only write down behavior that isn't written there or directly contradicts what is written there.

For now, things are in no particular order. I just wanted to get it out, before it's lying around another 3 months unfinished.


Removing items with RemoveMeIR from the player leaves *something* behind.
Lets say you remove your apples from your inventory with RemoveMeIR. If you look at the inventory, there are no apples. But if you check it with GetItemCount, it will still return 1 apple, which you can remove with RemoveItem, after which GetItemCount correctly returns 0.
I have not yet tested if it also happens with containers.


ResetInterior does not work like in wiki described.
The wiki says: Marks the cell as expired so that the next time the game is saved or the player enters the cell, it will be cleaned up as if several days have passed.
This isn't true. It will fully reset that cell, removing anything that you dropped on the floor, which usually does not happen if a cell resets by waiting several days. Therefore it is a good function for arena like cells (in fact, arena is the only place where it is used), but a bad function for player homes.


SetDescription has an optional third argument to set the perk texts you get when reaching level 25/50/75/100. Using the command without the third argument will still set all 5 texts, the normal skill description as well as all 4 perk texts.
I have not found a way to set only the normal skill description without also setting the mastery level texts.


The OnSoulTrap event handler can cause crashes when using a soulgem that was stolen / possibly that has other extra info attached, making it pretty much unusable.

Edit: The new fork of OBSE, xOBSE, has fixed this bug. There is a possibility that this event handler has more bugs that are not yet fixed.


OnScriptedSkillUp behaves weirdly. If you set your major skill levelups inside the OnScriptedSkillUp event handler, it will ignore the game setting for skill ups needed. If you're setting that value to 100, as a lot of level mods do to be able to display progress in %, any amount over 9 will still trigger levelup.

Using exactly the same code inside an OnSkillUp event handler works as expected. One workaround I used was starting a quest that would run and do the desired changes, then stop itself again.

Additionally, getting a perk with a scripted skill up (for example by using AdvSkill) will not give the usual perk message with skill icon and text, but construct a normal message box.

GetFirstRef -> includeInactiveRefs

GetFirstRef/GetNextRef's third argument includeInactiveRefs doesn't work. It will never find references that have been picked up.


The wiki page says: Notes: Changes are saved in the savegame.

This didn't seem true in a quick test. After reloading the game, the plants were back to their previous state. I didn't test further, as in any case, it wasn't reliable enough for me.


The wiki says: This command does not currently work correctly on the player.

Update3D does seem work on the player, for the most part, with a few caveats:
It can only be used when the player is in third person mode.
It crashes the game when used on the player while he is mounted.

Both conditions can be checked before using it. Additionally, it is possible to force the camera into third person more before using this command.


ConScribe's function DeleteLinesFromLog leaves an empty line in the log whenever it is used (I think it was at the end of the log). Reading the whole log into an array, stripping all empty lines and then rebuilding it from time to time (if you delete lines from it regularly, that is) might be a good idea.

String Variables with %

Perhaps it's obvious to others, unfortunately wasn't to me: If you have a string variable containing %, it needs to be entered as %%, to print out as %. If you use that string variable to build another string variable, you need to double up on that. Say:
let textPart := "I have a 100%%%% chance to mess that up"
let textFull : "%z, and I don't like it" textPart
There even is a nice function for that, sv_Percentify, but of course I didn't find that until after I wondered for an hour why one of my scripts crashed.


Thanks to Kat for finding this one out: This function only works when used in the result script of a dialogue. If the player has any items equipped with EquipItem 1 (the no unequip flag is set) it will crash the game.

2020-11-27: Added GoToJail, edited OnSoulTrap


Welcome to my little place where I talk about playing Oblivion, and about modding Oblivion, and about making mods for Oblivion and about ...