Jump to content

[LE] Random Item from Formlist Script


Recommended Posts

 

I know very little scripting .. I'm not certain how I'd do that. :sad:

 

 

Everybody's gotta start somewhere! Do you know how to use the debug log? It's very useful for stuff like this, since various runtime errors will can be spotted even without debug statements in your script itself (e.g. unfilled variables, out-of-bounds array accesses, stuff like that) and *with* debug statements can be used to see exactly what's going on with your script, complete with accurate timestamps.

 

Some example code:

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 3
Scriptname AAA_GordonGif_TIF__02005940 Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_2
Function Fragment_2(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
int n = GordonGiftCommon.GetSize() - 1
 
Debug.Trace("AKARSIL: List Length: " + n)

n = utility.RandomInt(0, n)
 
Debug.Trace("AKARSIL: Random: " + n)
 
Form newItem = GordonGiftCommon.GetAt(n)
 
Debug.Trace("AKARSIL: Form: " + newItem.GetName())

(game.GetPlayer()).AddItem(newForm)
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

FormList Property GordonGiftCommon  Auto

(I assume your formlist actually has items in it?)

 

EDIT:

 

I should note however a simpler solution to this would be to create or use an existing LeveledItem list instead, which can be used in an AddItem call and will evaluate the leveled list at that time. This is how a lot of vanilla quest rewards are set up, for example.

 

Thanks a lot for the time and effort :) I'll slap this in first thing in the morning and return to you!

Link to comment
Share on other sites

I couldn't get much information from your example code unfortunately. :/ How would you go by making a script for adding an item via a leveledlist? I'm not having much luck with getting the formlist script to work unfortunately. I have no problem setting up the leveled list.

I did enable papyrus logging, but the logs turned out empty for some reason.

Alright I tried the leveledlist approach with a little googling around but that doesn't work either.

EDIT

;BEGIN FRAGMENT CODE - Do not edit anything between this and the end comment
;NEXT FRAGMENT INDEX 4
Scriptname AAA_GordonFavorC_TIF__02005940 Extends TopicInfo Hidden

;BEGIN FRAGMENT Fragment_3
Function Fragment_3(ObjectReference akSpeakerRef)
Actor akSpeaker = akSpeakerRef as Actor
;BEGIN CODE
Game.GetPlayer().AddItem(Alias_GordonBookReward.GetRef())

Debug.Notification("Gordon is trying to give you a book.")
;END CODE
EndFunction
;END FRAGMENT

;END FRAGMENT CODE - Do not edit anything between this and the begin comment

ReferenceAlias Property Alias_GordonBookReward Auto

 

The script was placed in the end fragment of the dialogue option and it seemingly does fire ingame. But no reward is given nor does an Added item message I wrote show up. I've filled out a custom leveled list and matched the criteria for vanilla quest rewards going by how MQ104 "Dragon Rising" handles it's quest rewards. I've tried recompiling the scripts. Nothing. New save game - Nothing.

Just doesn't seem like this wants to work.

Edited by Akarsil
Link to comment
Share on other sites

If the notification isn't appearing your fragment is not firing. What makes you think it is?

 

The code I gave you wasn't for the levelled list, it was to try and track down potential failure points and log the status of variables so's you could see what was happening. If the log files were empty but you were doing everything else correctly, that suggests the entire fragment isn't triggering as well.

Link to comment
Share on other sites

The debug notification fires, the "Debug.Notification("Gordon is trying to give you a book.")" Does actually show up, however the leveledlist script I made doesn't actually give a reward from the leveled list. Or anything at all.

I tried the leveled list method you suggested after I ran the debug example code you gave me on the old formlist script, nothing showed up in the logs strangely enough.

The new fragment I posted above is for the leveledlist solution I tried, not for the formlist one.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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