Jump to content

Teleport To Random Dungeon Spell


Kolagon

Recommended Posts

I'd like for someone to make a spell that teleports you to a random forte, cave, ayleid ruin, etc, vanilla only, no DLCs. Basically, I like adventuring, but it's a bit of a hassle needing to find those places, oh sure I could use console code, but it would be more fun if you don't expect which dungeon you'll end up at via spell.

Edited by Kolagon
Link to comment
Share on other sites

Maybe something like this would work (not tested, just an idea). A quest script:

 

 

 

scriptname YourPrefixQuestScript

array_var TeleportTargetList
short ListReady ; <-- set to 0 to rebuild the list on next save load

begin _MenuMode 1044 ; I think it was 1044 the main menu

    if ( GetGameRestarted )
        seteventhandler "PostLoadGame" YourPrefixPostLoadGameHandler
    endif

end

 

 

 

The OBSE event handler (user-created function script, of type object script, yet not attached to anything):

 

 

 

scriptname YourPrefixPostLoadGameHandler

short Success

begin _Function { Success }

    if eval !( Success ) || ( YourPrefixQuest.ListReady )
        return
    endif

    let YourPrefixQuest.ListReady := 1

    if eval ( ( ar_Size YourPrefixQuest.TeleportTargetList ) > -1 )
        ; the ar_Erase should erase the whole array according to documentation?
        ar_Erase YourPrefixQuest.TeleportTargetList
    else
        let YourPrefixQuest.TeleportTargetList := ar_Construct "Array"
    endif

    ; appending the elements
    ar_Append YourPrefixQuest.TeleportTargetList SomeTeleportMarkerRef
    ar_Append YourPrefixQuest.TeleportTargetList OtherTeleportMarkerRef
    ....
    ar_Append YourPrefixQuest.TeleportTargetList FinalTeleportMarkerRef

end

 

 

 

The spell script which would select a random marker from the list:

 

 

 

scriptname YourPrefixSpellScript

short i

begin _ScriptEffectFinish

    ; the one below should pick a random integer from [0, <size-of-list> - 1]
    ; also, the call to "Floor" might be unnecessary when/if Oblivion
    ; discards the part 'after the dot' in the float
    let i := Floor ( Rand 0 ( ar_Size YourQuestPrefix.TeleportTargetList ) )
    PlayerRef.MoveTo YourQuestPrefix.TeleportTargetList[i]

end

 


It is obviously not the best possible solution, and I have not tested if it compiles (it should, as far as I know), but to give you some sort of an idea of what it could maybe look like. Another option is to use a group of if-elseif-elseif-...-else-endif statements only in the spell itself, although that one already sounds a bit too heavy (as in, too much writing).

 

Hopefully that helps a bit. If you have any questions, feel free to ask. I will try to answer when I have the time. :thumbsup:

 

Edit: Also, if someone has a better idea on how to do it, just post it. The simpler, the better (and less prone to errors). :smile:

 

Edit 2: I wanted to put them in spoilers, not quotes. :facepalm: Fixed that.

Edited by Contrathetix
Link to comment
Share on other sites

  • 7 years later...
On 4/4/2017 at 11:04 AM, Surilindur said:

Maybe something like this would work (not tested, just an idea). A quest script:

 

 

  Reveal hidden contents

 

scriptname YourPrefixQuestScript

array_var TeleportTargetList
short ListReady ; <-- set to 0 to rebuild the list on next save load

begin _MenuMode 1044 ; I think it was 1044 the main menu

    if ( GetGameRestarted )
        seteventhandler "PostLoadGame" YourPrefixPostLoadGameHandler
    endif

end

 

 

 

The OBSE event handler (user-created function script, of type object script, yet not attached to anything):

 

 

  Reveal hidden contents

 

scriptname YourPrefixPostLoadGameHandler

short Success

begin _Function { Success }

    if eval !( Success ) || ( YourPrefixQuest.ListReady )
        return
    endif

    let YourPrefixQuest.ListReady := 1

    if eval ( ( ar_Size YourPrefixQuest.TeleportTargetList ) > -1 )
        ; the ar_Erase should erase the whole array according to documentation?
        ar_Erase YourPrefixQuest.TeleportTargetList
    else
        let YourPrefixQuest.TeleportTargetList := ar_Construct "Array"
    endif

    ; appending the elements
    ar_Append YourPrefixQuest.TeleportTargetList SomeTeleportMarkerRef
    ar_Append YourPrefixQuest.TeleportTargetList OtherTeleportMarkerRef
    ....
    ar_Append YourPrefixQuest.TeleportTargetList FinalTeleportMarkerRef

end

 

 

 

The spell script which would select a random marker from the list:

 

 

  Reveal hidden contents

 

scriptname YourPrefixSpellScript

short i

begin _ScriptEffectFinish

    ; the one below should pick a random integer from [0, <size-of-list> - 1]
    ; also, the call to "Floor" might be unnecessary when/if Oblivion
    ; discards the part 'after the dot' in the float
    let i := Floor ( Rand 0 ( ar_Size YourQuestPrefix.TeleportTargetList ) )
    PlayerRef.MoveTo YourQuestPrefix.TeleportTargetList[i]

end

 

 

It is obviously not the best possible solution, and I have not tested if it compiles (it should, as far as I know), but to give you some sort of an idea of what it could maybe look like. Another option is to use a group of if-elseif-elseif-...-else-endif statements only in the spell itself, although that one already sounds a bit too heavy (as in, too much writing).

 

Hopefully that helps a bit. If you have any questions, feel free to ask. I will try to answer when I have the time. 👍

 

Edit: Also, if someone has a better idea on how to do it, just post it. The simpler, the better (and less prone to errors). 😄

 

Edit 2: I wanted to put them in spoilers, not quotes. :facepalm: Fixed that.

GAH! I'm so sorry, I didn't know anyone replied to this old request of mine.  As for the idea, it can work as long as it teleports me to a dungeon's entrance so I can explore it, clear it, return to entrance, use the item or spell, and just keep doing it. I just love dungeon exploration, getting treasure, fighting mobs, etc.

Link to comment
Share on other sites

No problem! I guess the teleport marker would need to be the entrance one, then, or some other way to get the door marker would have to be used. Also, after looking at the scripts I posted years ago, I doubt they will work since the menu mode block uses 'main menu' and I think quests are not even running at that point. 😅

Link to comment
Share on other sites

13 hours ago, Surilindur said:

No problem! I guess the teleport marker would need to be the entrance one, then, or some other way to get the door marker would have to be used. Also, after looking at the scripts I posted years ago, I doubt they will work since the menu mode block uses 'main menu' and I think quests are not even running at that point. 😅

Considering its been seven years, you may have gotten better at your scripting?

Link to comment
Share on other sites

On 9/8/2024 at 2:44 AM, Kolagon said:

GAH! I'm so sorry, I didn't know anyone replied to this old request of mine.  As for the idea, it can work as long as it teleports me to a dungeon's entrance so I can explore it, clear it, return to entrance, use the item or spell, and just keep doing it. I just love dungeon exploration, getting treasure, fighting mobs, etc.

You should like Repeatable Oblivion quests then since i notably added a treasure hunt.

Edited by Oblivionaddicted
Link to comment
Share on other sites

  • Recently Browsing   0 members

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