Last active
July 22, 2018 03:59
-
-
Save LaughingLeader/d481391927900acbbab76945c787f40a to your computer and use it in GitHub Desktop.
An ItemScript for DOS2 that generates a certain amount of items within an item, using a status as a timer.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INIT | |
ITEM:__Me | |
EXTERN STATUS:%TimerStatus = BURNING | |
EXTERN ITEMTEMPLATE:%ItemToCreate = CON_Potion_A_Health_944e4b8c-1736-4ff6-8fa6-d7ceda9941da | |
EXTERN INT:%MaxAmount = 1 | |
INT:%CurrentAmount = 0 | |
INT:%Opened = 0 | |
EVENTS | |
EVENT Events_Init | |
ON | |
OnInit() | |
ACTIONS | |
SetTag(__Me, "TME_ItemCreator") | |
EVENT Events_CreateItem | |
VARS | |
ITEM:_Item | |
ON | |
OnItemStatusRemoved(__Me, %TimerStatus) | |
ACTIONS | |
SpawnItem(%ItemToCreate, __Me, _Item) | |
ItemToInventory(_Item, __Me) | |
SetTag(_Item, "TME_ItemCreatorItem") | |
SetVar(_Item, "TME_ParentInventory", __Me) | |
Add(%CurrentAmount, 1) | |
SetPriority("StartGrowing", 99999) | |
StatusText(__Me, "Added item") | |
EVENT Events_OnOpened | |
VARS | |
ITEM:_Item | |
ON | |
OnItemOpened(__Me) | |
ACTIONS | |
Set(%Opened, 1) | |
EVENT Events_OnClosed | |
VARS | |
ITEM:_Item | |
ON | |
OnItemClosed(__Me) | |
ACTIONS | |
Set(%Opened, 0) | |
EVENT Events_OnItemTaken | |
VARS | |
ITEM:_Owner | |
ITEM:_Item | |
ON | |
OnItemEvent(_Item, "TME_Events_CharacterRemovedItemFromItemCreator") // Story script event | |
ACTIONS | |
IF "c1&c2&c3" | |
IsTagged(_Item, "TME_ItemCreatorItem") | |
GetVar(_Owner, _Item, "TME_ParentInventory") | |
IsEqual(_Owner, __Me) | |
THEN | |
SetVar(_Item, "TME_ParentInventory", ITEM:null) | |
ClearTag(_Item, "TME_ItemCreatorItem") | |
IF "c1" | |
IsGreaterThen(%CurrentAmount, 0) | |
THEN | |
Subtract(%CurrentAmount, 1) | |
ENDIF | |
StatusText(__Me, "Subtracted from current amount") | |
ENDIF | |
BEHAVIOUR | |
REACTION StartGrowing, 99999 | |
USAGE ALL | |
ACTIONS | |
IF "!c1&c2" | |
ItemHasStatus(__Me, %TimerStatus) | |
IsLessThen(%CurrentAmount, %MaxAmount) | |
THEN | |
ItemApplyStatus(__Me, %TimerStatus, 1, 1) | |
StatusText(__Me, "Applied status") | |
SetPriority("StartGrowing", -1) | |
ELSE | |
//StatusText(__Me, "Skipping generation") | |
Sleep(10) | |
ENDIF |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment