Begin A1_DAT_SRT_ExoSort

Short iCB
Short tCB
Short lCB

If ( MenuMode == 1 )
	Return
EndIf

Set lCB to 0

If ( OnActivate == 1 )
  
  Set lCB to 1
  Set tCB to 0

EndIf

; The following are the Bloodmoon ingredients.
; If you're using this without Bloodmoon (but with Tribunal), commend out
; the following code blocks (but leaving in the 'If' and 'Set' statements
; which related to the 'lCB' variable.

If ( lCB == 1 )

; There are two forms of Belladonna (ripened and unripened).
; They're exactly the same, apart from the name.
  Set iCB to ( Player->GetItemCount, "ingred_belladonna_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_belladonna_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_belladonna_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_belladonna_02" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_belladonna_02", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_belladonna_02", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_bear_pelt" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_bear_pelt", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_bear_pelt", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_eyeball" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_eyeball", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_eyeball", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_gravetar_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_gravetar_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_gravetar_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_wolf_pelt" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_wolf_pelt", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_wolf_pelt", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_holly_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_holly_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_holly_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_horker_tusk_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_horker_tusk_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_horker_tusk_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_boar_leather" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_boar_leather", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_boar_leather", 1
      EndWhile
  EndIf

; There was an icon for this, but there doesn't seem to be any ingredients.
;
;  Set iCB to ( Player->GetItemCount, "ingred_alit_hide_01" )
;  Set tCB to tCB + iCB
;  If ( iCB > 0 )
;    While ( iCB > 0 )
;   	    Set iCB to ( iCB - 1 )
;   	    Player->RemoveItem, "ingred_alit_hide_01", 1
;        "A1_DAT_SRT_SortBagpot_B_seeds"->AddItem, "ingred_alit_hide_01", 1
;      EndWhile
; EndIf

  Set lCB to 2

EndIf

If ( lCB == 2 )

  Set iCB to ( Player->GetItemCount, "ingred_raw_Stalhrim_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_raw_Stalhrim_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_raw_Stalhrim_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_snowbear_pelt_unique" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_snowbear_pelt_unique", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_snowbear_pelt_unique", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_snowwolf_pelt_unique" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_snowwolf_pelt_unique", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_snowwolf_pelt_unique", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_wolfsbane_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_wolfsbane_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_wolfsbane_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_heartwood_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_heartwood_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_heartwood_01", 1
      EndWhile
  EndIf

  Set lCB to 3

EndIf

; The rest of the ingredients are Tribunal ingredients.

If ( lCB == 3 )

  Set iCB to ( Player->GetItemCount, "ingred_adamantium_ore_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_adamantium_ore_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_adamantium_ore_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_scrib_cabbage_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_scrib_cabbage_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_scrib_cabbage_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "ingred_durzog_meat_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "ingred_durzog_meat_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "ingred_durzog_meat_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_golden_sedge_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_golden_sedge_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_golden_sedge_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_horn_lily_bulb_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_horn_lily_bulb_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_horn_lily_bulb_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_meadow_rye_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_meadow_rye_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_meadow_rye_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_nirthfly_stalks_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_nirthfly_stalks_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_nirthfly_stalks_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_noble_sedge_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_noble_sedge_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_noble_sedge_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_lloramor_spines_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_lloramor_spines_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_lloramor_spines_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_sweetpulp_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_sweetpulp_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_sweetpulp_01", 1
      EndWhile
  EndIf

  Set iCB to ( Player->GetItemCount, "Ingred_timsa-come-by_01" )
  Set tCB to tCB + iCB
  If ( iCB > 0 )
    While ( iCB > 0 )
   	    Set iCB to ( iCB - 1 )
   	    Player->RemoveItem, "Ingred_timsa-come-by_01", 1
        "A1_DAT_SRT_SortBag"->AddItem, "Ingred_timsa-come-by_01", 1
      EndWhile
  EndIf

; The End is nigh!
  Set lCB to 100

EndIf

If ( lCB == 100 )
 
    If ( tCB > 0 ) 
      PlaySound "Item Misc Up"
      MessageBox "Removed %g 'Solstheim' and 'Mournhold' ingredients.", tCB
    Else
      PlaySound "Menu Click"
      MessageBox "You aren't carrying any 'Solstheim' or 'Mournhold' ingredients."
    EndIf

EndIf

End