4
Fork 0
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

44 lines
1.3 KiB

Scriptname defaultAddItemScript extends Actor
{Adds an item to this reference in a Reset-safe way. Not directly usable, but extended by the defaultAddItem<TYPE>Scripts}
Form property ItemToAdd Auto Hidden
{YOU CAN'T FILL THIS PROPERTY IN THE EDITOR. Use one of the defaultAddItem<TYPE> scripts instead.}
int property count = 1 Auto
{The number of instances of the item the actor should have. Defaults to 1.}
bool property parentUnique = True Auto Hidden
{If the player already has this item, don't give the actor another one. Defaults to True.}
bool property shouldEquip = False Auto
{ACTORS ONLY: Should we equip this item?}
bool property forceEquip = False Auto
{ACTORS ONLY: Should we force this item to stay equipped?}
bool addedItem = False
;On load, add the item.
Event OnLoad()
if (!addedItem)
addedItem = True
AddItemIfNeeded()
EndIf
EndEvent
;On reset, add the item.
Event OnReset()
addedItem = True
AddItemIfNeeded()
EndEvent
Function AddItemIfNeeded()
;If (parentUnique && Player has item), don't generate.
if ((Game.GetForm(0x14) as Actor).GetItemCount(ItemToAdd) == 0 || !parentUnique)
Self.AddItem(ItemToAdd, (count - Self.GetItemCount(ItemToAdd)), True)
if (shouldEquip && (Self as Actor) != None)
Self.EquipItem(ItemToAdd, forceEquip, True)
EndIf
EndIf
EndFunction