begin _vdm_kegstand_xyz
short temp
short inventory
short state
short button
short daysleft
short currentday
short doOnce
short Counter
if ( doOnce == 0 )
set currentday to dayspassed
set doonce to 1
set daysleft to 1
endif
if ( getdisabled == 1 )
set Counter to ( Counter - 1 )
IF ( Counter == 0 )
setdelete 1
ENDIF
RETURN
ENDIF
IF ( state == 0 )
IF ( currentday != dayspassed )
set temp to ( dayspassed - currentday )
set currentday to dayspassed
IF ( daysleft >= 1 )
set daysleft to ( daysleft - temp )
IF ( daysleft <= 0 )
set daysleft to 0
set inventory to 10
ENDIF
ENDIF
set temp to 0
ENDIF
IF ( OnActivate == 1 )
IF ( Inventory > 0 )
set state to 1
ELSE
set state to 4
ENDIF
activate
ENDIF
RETURN
ELSEIF ( state == 1 )
messagebox "The kegstand contains %g bottles of xyz.", inventory, "Fill a bottle", "Fill as many bottles as possible", "Drain the kegstand", "Cancel"
set state to 2
ENDIF
IF ( state == 2 )
set button to getbuttonpressed
IF ( button == -1 )
RETURN
ELSE
set state to 0
ENDIF
IF ( button == 0 )
IF ( player->GetItemCount "misc_com_bottle_01" > 0 )
player->RemoveItem "misc_com_bottle_01" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_02" > 0 )
player->RemoveItem "misc_com_bottle_02" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_04" > 0 )
player->RemoveItem "misc_com_bottle_04" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_05" > 0 )
player->RemoveItem "misc_com_bottle_05" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_06" > 0 )
player->RemoveItem "misc_com_bottle_06" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_08" > 0 )
player->RemoveItem "misc_com_bottle_08" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_09" > 0 )
player->RemoveItem "misc_com_bottle_09" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_10" > 0 )
player->RemoveItem "misc_com_bottle_10" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_11" > 0 )
player->RemoveItem "misc_com_bottle_11" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_13" > 0 )
player->RemoveItem "misc_com_bottle_13" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_14" > 0 )
player->RemoveItem "misc_com_bottle_14" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_15" > 0 )
player->RemoveItem "misc_com_bottle_15" 1
ELSE
messagebox "You need an empty bottle."
RETURN
ENDIF
player->additem _vdm_xyz_01 1
messagebox "You fill one of your empty bottles."
set inventory to ( inventory - 1 )
IF ( inventory == 0 )
set state to 999
ENDIF
ELSEIF ( button == 1 )
set temp to player->GetItemCount "misc_com_bottle_01" + player->GetItemCount "misc_com_bottle_02" + player->GetItemCount "misc_com_bottle_03"
set temp to temp + player->GetItemCount "misc_com_bottle_04" + player->GetItemCount "misc_com_bottle_05" + player->GetItemCount "misc_com_bottle_06"
set temp to temp + player->GetItemCount "misc_com_bottle_07" + player->GetItemCount "misc_com_bottle_08" + player->GetItemCount "misc_com_bottle_09"
set temp to temp + player->GetItemCount "misc_com_bottle_10" + player->GetItemCount "misc_com_bottle_11" + player->GetItemCount "misc_com_bottle_12"
set temp to temp + player->GetItemCount "misc_com_bottle_13" + player->GetItemCount "misc_com_bottle_14" + player->GetItemCount "misc_com_bottle_15"
IF ( temp == 0 )
messagebox "You don't have any empty bottles."
RETURN
ELSEIF ( temp < inventory )
set Counter to temp
ELSE
set Counter to inventory
set temp to inventory
ENDIF
set inventory to ( inventory - Counter )
WHILE ( Counter > 0 )
IF ( player->GetItemCount "misc_com_bottle_01" > 0 )
player->RemoveItem "misc_com_bottle_01" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_02" > 0 )
player->RemoveItem "misc_com_bottle_02" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_04" > 0 )
player->RemoveItem "misc_com_bottle_04" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_05" > 0 )
player->RemoveItem "misc_com_bottle_05" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_06" > 0 )
player->RemoveItem "misc_com_bottle_06" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_08" > 0 )
player->RemoveItem "misc_com_bottle_08" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_09" > 0 )
player->RemoveItem "misc_com_bottle_09" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_10" > 0 )
player->RemoveItem "misc_com_bottle_10" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_11" > 0 )
player->RemoveItem "misc_com_bottle_11" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_13" > 0 )
player->RemoveItem "misc_com_bottle_13" 1
ELSEIF ( player->GetItemCount "misc_com_bottle_14" > 0 )
player->RemoveItem "misc_com_bottle_14" 1
ELSE
player->RemoveItem "misc_com_bottle_15" 1
ENDIF
player->additem _vdm_xyz_01 1
set Counter to ( Counter - 1 )
ENDWHILE
IF ( inventory > 1 )
messagebox "You managed to fill %g empty bottles. There are still %g servings of xyz left in the kegstand.", temp, inventory
ELSEIF ( inventory = 1 )
messagebox "You managed to fill %g empty bottles. There is still 1 serving of xyz left in the kegstand.", temp
ELSE
messagebox "You managed to fill %g empty bottles before the keg went dry.", temp
set state to 999
ENDIF
ELSEIF ( button == 2 )
messagebox "The kegstand still contains %g bottles of xyz. Are you sure you want to do that?", inventory, "Yes. Empty it.", "Cancel"
set state to 3
ENDIF; button 3 does zilch, so nothing needed here.
RETURN
ENDIF
IF ( state == 3 )
set button to getbuttonpressed
IF ( button == 1 )
set state to 0
ELSEIF( button == 0 )
set inventory to 0
set state to 999
ENDIF
RETURN
ELSEIF ( state == 4 )
messagebox "The kegstand contains fermenting xyz. What do you want to do?" "Empty it.", "Check it."
set state to 5
RETURN
ENDIF
IF ( state == 5 )
set button to getbuttonpressed
IF ( button == -1 )
return
ELSEIF ( button == 0 )
messagebox "You completely drain the kegstand and clean it out."
set state to 999
ELSE
IF ( daysleft > 1 )
messagebox "The fermenting is going well. You should have the finished xyz in %g days.", daysleft
ELSE
messagebox "The fermenting is going well. You should have the finished xyz tomorrow."
ENDIF
set state to 0
ENDIF
ENDIF
IF ( state == 999 )
placeatme "_vdm_kegstand_empty" 1,0,0
set state to 0
set Counter to 10
disable
ENDIF
end