Jump to content

trying to Randomize Harvestable plant loot


Recommended Posts

hey normally I don't usually do this but I'm already super close to getting this to work. in short I have a static object I'm trying to set up so when you activate it it gives you a random item out of a loot-table without pausing dialog boxes. just quick click and in your inventory.

 

the closest I've gotten is experimenting with the Sleeping Tree and TreeSap, because its close to what I'm looking for in terms of click and go, but I can't seem to randomize the loot that gets deposited in your inventory, i thought if I set the new property to LeveledItem and selected the leveledloot it would just show up.

 

if you can give me some advice on how to fix this I'd be grateful, I have no experience with writing script so I don't know how to go about this the right way

 

if theirs a premade script already in place that would be wonderful

Link to comment
Share on other sites

ScriptNameLatada

Formlist property YourFormListHere Auto
Form property YourRandomItemHere Auto

Actor TargetActor

Form Function GetAnItem(FormList YourFormListHere)
	Int MaxIndex = YourFormListHere.GetSize() - 1
	Int Index = Utility.RandomInt(0,MaxIndex)
	Return YourFormListHere.GetAt(index)
EndFunction
 
EVENT OnEffectStart(Actor Target, Actor Caster)
	YourRandomItemHere = GetAnItem(YourFormListHere)
	Target.AddItem(YourRandomItemHere,1) ;;The Number here is how many you want added to your inventory.
EndEvent

Allright, the above code is designed to be used in a spell, but you should be able to modify it to run on an activate event instead. It uses 2 properties (one of which you'll reference the formlist, and the other which the script uses to give you the item) and 1 formlist (which contains all the possible items you want it to have a chance of giving you, item type does not really matter). The script will randomly select 1 item from the formlist and give it to the target that triggered the event.

 

Hopefully that gets you to where you need to be.

Link to comment
Share on other sites

  • Recently Browsing   0 members

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