FANDOM


Created by Taz.

Using "RC_Core.rcm"


;updated april 5 2010 adding extra potion chance, added alchemy levels need to make potions, health and mana potions will not need alchemy level rquirements.
;Note May want to change the alch lvl check, could use an else
;and have the script finish the until for the repeat in stead of using return.
;there should be no problems with it this way, just seems more efficent the menched way.

;NOTE  The progress bar will depend on what the player enters to make.
;updated skill xp to delimiter july 16 2012

Function Main()
	Player = Actor()
	Target = ContextActor()
    
     ;find alchemy lab and see if its in range to use it.
    LabName$ = "Alchemy Lab"
    Foundlab% = FindActor(LabName, 2) ;type 2 look through npcs
    
      
       IsClose3# = ActorDistance(Foundlab, Player)
      
       IsClose% = IsClose3

        If (Foundlab = 0)
            OutPut(Player, "Alchemy Lab not found!!")
        EndIf
     
         If (IsClose > 10)
            OutPUt(Player, "You need to find a Alchemy Lab to make potions.")
            Return
        EndIf
     
     Repeat
 	
 	alchemylvl% = AbilityLevel(Player, "Alchemy")	
 	chatbox% = OpenDialog(Player, Target, "Alchemy", 495)
     DialogOutPut(Player, ChatBox, "")  ;space filler to push next line down one.
   	DialogOutPut(Player, chatbox, "What type of potion ", 145, 45, 89) 
    DialogOutPut(Player, chatbox, "would you like to make?", 145, 45, 89)
	alchemyoption% = DialogInPut(Player, chatbox, "Health Potion,Mana Potion,Strength Potion,Agility Potion,Toughness Potion,Defence Potion,Dodge Potion,More,None")
    
     
     ;-----------------------
    ;Extra potion chance
    ;-----------------------
    If (Alchemylvl <= 10)
    ExtraPotion% = Rand(1, 70) ;alchemy level 10 and under. Set this number to the chance the player has to get extra potion.
    Else
     ExtraPotion% = Rand(1, 40) ;alchemy level 11 and over. Set this number to the chance the player has to get extra potion.
  
     EndIf
     
     If (Extrapotion = 1)
        If (Alchemylvl <= 5)
              GiveExtrapot% = Rand(1, 2)
             ; OutPut(Player, "You have made " + GiveExtrapot + " extra potions, thanks to your alchemy chance.", 255, 0, 234)
        Elseif (Alchemylvl >= 15)
              GiveExtrapot% = Rand(3, 5)
              ;OutPut(Player, "Since you are level 15 or over you have made " + GiveExtrapot + " potions. Thanks to your alchemy chance of course.", 255, 0, 234)
        EndIf
     EndIf   
      ;-----------------------
     ;Extra Alchemy XP
     ;------------------------
     ExtrachanceXp% = Rand(1, 5) * alchemylvl * GiveExtrapot ;give extra alchemy xp for the extra pots givin.
 
     ;---------------------------------------
	;End extra potion chance
    ;----------------------------------------
    
     
 If (alchemyoption = 1) ;make health potion
 	
 		 ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 3
             AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 15 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount
        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        
         
      If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial 
       If (HasItem(Actor(), "Chamomile", AlchCost)) ; check if the player has needed herbs
  
        
          PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Health Potion") ; casting bar
         Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
  
 			;stop to do the progress bar count down
 			Repeat
 			Ticks% = Ticks - 1				;take 1 tick per half a sec
 			DoEvents(500)
 			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
 			Until(Ticks = 0)
 				;Continue with alchemy
 				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
 				GiveItem(Player, "Chamomile", - AlchCost) ;take herbs
 		
 				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Health Potion", 145, 45, 89) ;tell player they made a potion
 				GiveItem(Player, "Health Potion", AlchExtra) ;give potion
 				DoEvents(2500) ; wait 2.5 sec 
 				CloseDialog(Player, chatbox) ;close chatbox
 				DeleteProgressBar(Player, PBar)
   ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

     
 				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                 DoEvents(1000)
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Chamomile", 255, 0, 0) ;tell the player they dont have enough herbs
		DoEvents(2000)
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck
	Else ; player has no empty vials
	OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
	CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
	
ElseIf (alchemyoption = 2) ;make mana potion

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Cinque foil
             AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 25 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount 

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        
 
    If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	If (HasItem(Actor(), "Cinque foil", AlchCost))

		If (HasItem(Actor(), "Chamomile", AlchAmount)) ; check if the player has needed herbs

			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Mana Potion") ; casting bar
  			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Chamomile", - AlchAmount) ;take herbs
				GiveItem(Player, "Cinque foil", - AlchCost)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Mana Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Mana Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

                ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount)
                DoEvents(1000)
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Chamomile", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Cinque foil", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check

ElseIf (alchemyoption = 3) ;make strength potion

        ;------------------------------
        ;Strength potion level requiered 5 or Higher.
        ;--------------------------------
        If (alchemylvl < 5)
            OutPut(Player, "You need an alchemy level of 5 or higher to make a strength potion.", 255, 0, 0)
            DoEvents(1100)
            CloseDialog(Player, chatbox) ;close chatbox
            return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------

	  ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Cinque foil and Plant Goop since both are 2
            
              AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 35 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount
        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
          If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

       If (HasItem(Actor(), "Cinque foil", AlchCost))

		If (HasItem(Actor(), "Plant Goop", AlchCost)) ; check if the player has needed herbs
                
       
 
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Strength Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchExtra) ;take empty vial
				GiveItem(Player, "Plant Goop", - AlchCost) ;take herbs
				GiveItem(Player, "Cinque foil", - AlchCost)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Strength Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Strength Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;--------------------------------------------------------------------------------------------------------------------  

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount)  
                DoEvents(1000)
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Plant Goop", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Cinque foil", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check

ElseIf (alchemyoption = 4) ;make agility potion
  ;------------------------------
        ;agility potion level requiered 5 or Higher.
        ;--------------------------------     
        QuestName$ = "Try some alchemy"
        QuestResults$ = QuestStatus(Player, QuestName)
        QuestStatusText$ = "Make 1 Agility Potion"
        
         If (QuestResults = QuestStatusText)
            alchemylvl% = 7
        Endif
 
 
         If (alchemylvl < 7)
            OutPut(Player, "You need an alchemy level of 7 or higher to make a agility potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------
       
         ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 3 ;Plant Goop * 3
            
              AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 45 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount   

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        
        If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

        If (HasItem(Actor(), "Chamomile", AlchAmount))

		 If (HasItem(Actor(), "Plant Goop", AlchCost)) ; check if the player has needed herb

			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Agility Potion") ; casting bar
  			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Plant Goop", - AlchCost) ;take herbs
				GiveItem(Player, "Chamomile", - AlchAmount)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Agility Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Agility Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount)
                DoEvents(1000)
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Plant Goop", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Chamomile", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
ElseIf (alchemyoption = 5) ;make toughness potion

      ;------------------------------
        ;Strength potion level requiered 9 or Higher.
        ;--------------------------------
        If (alchemylvl < 9)
            OutPut(Player, "You need an alchemy level of 9 or higher to make a toughness potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Mushroom * 2
            
              AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 55 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount
     
         ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
    If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	  If (HasItem(Actor(), "Mushroom", AlchCost))

		If (HasItem(Actor(), "Plant Goop", AlchAmount)) ; check if the player has needed herbs
			If (HasItem(Actor(), "Leafs", AlchAmount))
            
             
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making 1 Toughness Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Plant Goop", - AlchAmount) ;take herbs
				GiveItem(Player, "Mushroom", - AlchCost)
				GiveItem(Player, "Leafs", - AlchAmount)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Toughness Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Toughness Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;--------------------------------------------------------------------------------------------------------------------  

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount)
                   DoEvents(1000)
			Else   ;   another herb check
			OutPut(Player, "You do not have any Leafs!", 255, 0, 0)
			CloseDialog(Player, chatbox)
			Return
			EndIf
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Plant Goop", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Mushrooms", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
ElseIf (alchemyoption = 6) ;make defence potion

        ;------------------------------
        ;defence potion level requiered 12 or Higher.
        ;--------------------------------
        If (alchemylvl < 12)
            OutPut(Player, "You need an alchemy level of 12 or higher to make a defence potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------

	
         ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Leafs * 2
             AlchCost1% = AlchAmount * 3 ;Mushroom * 3
             AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 65 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount
        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
   If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

      If (HasItem(Actor(), "Leafs", AlchCost))

          If (HasItem(Actor(), "Mushroom", AlchCost1)) ; check if the player has needed herbs

            
 
 
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Defence Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Mushroom", - AlchCost1) ;take Mushroom herbs
				GiveItem(Player, "Leafs", - AlchCost) ;Take Leafs herbs

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Defence Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Defence Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount)
                   DoEvents(1000)
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Mushrooms", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Leafs", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
    
     
 ElseIf (alchemyoption = 7) ; make dodge potion
 
         ;------------------------------
        ;Dodge potion level requiered 15 or Higher.
        ;--------------------------------
        If (alchemylvl < 15)
            OutPut(Player, "You need an alchemy level of 15 or higher to make a Dodge potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------

	
        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Local Weed and Plant Goop * 2 since they are both costing 2
       
              AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 76 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount      

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
    If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	  If (HasItem(Actor(), "Local Weed", AlchCost))

		If (HasItem(Actor(), "Plant Goop", AlchCost)) ; check if the player has needed herbs

            
 
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Dodge Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Plant Goop", - AlchCost) ;take herbs cost 2
				GiveItem(Player, "Local Weed", - AlchCost) ;cost 2

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Dodge Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Dodge Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

                ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                       DoEvents(1000)
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Plant Goop", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Local Weed", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check

   ElseIf (alchemyoption = 9)
    CloseDialog(Player, chatbox) ;close chatbox
    Closealch = 6
    DoEvents(100)
        
 
 
 ElseIf (alchemyoption = 8) ; more option
 		DoEvents(500)
         CloseDialog(Player, ChatBox)
        ChatBox = OpenDialog(Player, ContextActor(), "Alchemy", 173)
        DialogOutPut(Player, ChatBox, "")  ;space filler to push next line down one.
	alchemymoreoption = DialogInPut(Player, chatbox, "Ranging Potion,Melee Potion,Magic Potion,Prayer Potion,Dexterity Potion,None")

	If (alchemymoreoption = 1) ;make ranging potion
    
         ;------------------------------
        ;ranging potion level requiered 18 or Higher.
        ;--------------------------------
        If (alchemylvl < 18)
            OutPut(Player, "You need an alchemy level of 18 or higher to make a Ranging potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------
     
         ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Local Weed
       
              AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 95 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount      

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
   If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	If (HasItem(Actor(), "Local Weed", AlchCost))

		If (HasItem(Actor(), "Bean Jerkey", AlchAmount)) ; check if the player has needed herbs
			If (HasItem(Actor(), "Mushroom", AlchAmount))
            
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Ranging Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Bean Jerkey", - AlchAmount) ;take herbs
				GiveItem(Player, "Mushroom", - AlchAmount)
				GiveItem(Player, "Local Weed", - AlchCost)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Ranging Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Ranging Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                       DoEvents(1000)
			Else   ;   another herb check
			OutPut(Player, "You do not have any Mushrooms!", 255, 0, 0)
			CloseDialog(Player, chatbox)
			Return
			EndIf
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Bug Jerkey", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Local Weed", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
ElseIf (alchemymoreoption = 2)  ;make melee potion
        ;------------------------------
        ;melee potion level requiered 21 or Higher.
        ;--------------------------------
        If (alchemylvl < 21)
            OutPut(Player, "You need an alchemy level of 21 or higher to make a Melee potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------
     
          ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Hyosc
             AlchCost1% = AlchAmount * 3 ;Chamomile
       
              AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 110 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount      

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
  If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	If (HasItem(Actor(), "Hyosc", AlchCost))

		If (HasItem(Actor(), "Chamomile", AlchCost1)) ; check if the player has needed herbs
			If (HasItem(Actor(), "Leafs", AlchAmount))
            
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Melee Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Chamomile", - AlchCost1) ;take herbs
				GiveItem(Player, "Leafs", - AlchAmount)
				GiveItem(Player, "Hyosc", - AlchCost)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Melee Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Melee Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

			    ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                           DoEvents(1000)
			Else   ;   another herb check
			OutPut(Player, "You do not have any Leafs!", 255, 0, 0)
			CloseDialog(Player, chatbox)
			Return
			EndIf
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Chamomile", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Hyosc", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
ElseIf (alchemymoreoption = 3) ;make magic potion
         ;------------------------------
        ;magic potion level requiered 24 or Higher.
        ;--------------------------------
        If (alchemylvl < 24)
            OutPut(Player, "You need an alchemy level of 24 or higher to make a magic potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------
    
 
         ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Hyosc, Chamomile and Cinque foil using the same one since the all cost 2
                 
             AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 120 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount      

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
  If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	If (HasItem(Actor(), "Hyosc", AlchCost))

		If (HasItem(Actor(), "Cinque foil", AlchCost)) ; check if the player has needed herbs
			If (HasItem(Actor(), "Chamomile", AlchCost))
            
             
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Magic Potion") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Chamomile", - AlchCost) ;take herbs
				GiveItem(Player, "Cinque Foil", - AlchCost)
				GiveItem(Player, "Hyosc", - AlchCost)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Magic Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Magic Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;--------------------------------------------------------------------------------------------------------------------  

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                       DoEvents(1000)
			Else   ;   another herb check
			OutPut(Player, "You do not have any Chamomile!", 255, 0, 0)
			CloseDialog(Player, chatbox)
			Return
			EndIf
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Cinque foil", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Hyosc", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
	EndIf ;end empty vial check
ElseIf (alchemymoreoption = 4) ;make Prayer potion
        ;------------------------------
        ;Prayer potion level requiered 25 or Higher.
        ;--------------------------------
        If (alchemylvl < 25)
            OutPut(Player, "You need an alchemy level of 25 or higher to make a Prayer Potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------
            
         ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 ;Black Pansy and Local Weed using the same one since the all cost 2
                 
             AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 135 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount      

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
  If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	If (HasItem(Actor(), "Black Pansy", AlchCost))

		If (HasItem(Actor(), "Local Weed", AlchCost)) ; check if the player has needed herbs
			If (HasItem(Actor(), "Black Orchid", AlchAmount))
            
 			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Prayer Potions") ; casting bar
   			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Black Orchid", - AlchAmount) ;take herbs
				GiveItem(Player, "Local Weed", - AlchCost)
				GiveItem(Player, "Black Pansy", - AlchCost)

				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Prayer Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Prayer Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                       DoEvents(1000)
			Else   ;   another herb check
			OutPut(Player, "You do not have any Black Orchid!", 255, 0, 0)
			CloseDialog(Player, chatbox)
			Return
			EndIf
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Local Weed", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Black Pansy", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
   EndIf
 ElseIf (alchemymoreoption = 5) ;make dexterity potion
 	
         ;------------------------------
        ;dexterity potion level requiered 28 or Higher.
        ;--------------------------------
        If (alchemylvl < 28)
            OutPut(Player, "You need an alchemy level of 28 or higher to make a dexterity potion.", 255, 0, 0)
            DoEvents(1100)
           CloseDialog(Player, chatbox) ;close chatbox
           return
        EndIf    
        ;-------------------------------
        ;end alchemy required level
        ;-------------------------------
        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
        ;allow player to pick an amount to make.
			 AlchAmount% = Input(Player, "How many would you like to make?", "Total", 2) ;get player to add amount to buy
             AlchCost% = AlchAmount * 2 
             AlchExtra% = AlchAmount + GiveExtrapot ;set to give item for extra pot chance.
     
             AlchXp% = AlchAmount * 175 + ExtrachanceXp ; Amount of xp based on extra potion + amount that player inputs X xp amount      

        ;_____________________________________________________________________________
         ;-----------------------------------------------------------------------------
  If (HasItem(Actor(), "Empty Vial", AlchAmount)) ; check if player has an empty vial

	If (HasItem(Actor(), "Black Pansy", AlchCost))

		If (HasItem(Actor(), "Hyosc", AlchCost)) ; check if the player has needed herbs
			If (HasItem(Actor(), "Black Orchid", AlchCost))
				If (HasItem(Actor(), "Bean Jerkey", AlchAmount))
                
                 
			PBar% = CreateProgressBar(Player, 55, 5, 255, 0.40, 0.82, 0.2, 0.04, 30, 30, "Making Dexterity Potion") ; casting bar
  			Ticks% = 30 ;amount of ticks also change the max and valve number in the PBar above.
			;stop to do the progress bar count down

			Repeat
			Ticks% = Ticks - 1				;take 1 tick per half a sec
			DoEvents(500)
			UpdateProgressBar(Player, PBar, Ticks)   ;update progress bar
			Until(Ticks = 0)

				;Continue with alchemy
				GiveItem(Player, "Empty Vial", - AlchAmount) ;take empty vial
				GiveItem(Player, "Black Orchid", - AlchCost) ;take herbs
				GiveItem(Player, "Been Jerkey", - AlchAmount)
				GiveItem(Player, "Black Pansy", - AlchCost)
	
				DialogOutPut(Player, chatbox, "You have made " + AlchExtra + " Dexterity Potion", 145, 45, 89) ;tell player they made a potion
				GiveItem(Player, "Dexterity Potion", AlchExtra) ;give potion
				DoEvents(2500) ; wait 2.5 sec 
				CloseDialog(Player, chatbox) ;close chatbox
				DeleteProgressBar(Player, PBar)
  ;--------------------------------------------------------------------------------------------------------------------		
            ;Send to levelup if Alchemy level should be given.            
                  ;get Alchemy xp, add new xp and ccheck if player has a Alchemy level              
                    MeleeXp% = Split(ActorGlobal(Player, 2), 1, "|")
                    RangingXp% = Split(ActorGlobal(Player, 2), 2, "|")
                    MagicXp% = Split(ActorGlobal(Player, 2), 3, "|")
                    AlchemyXp% = Split(ActorGlobal(Player, 2), 4, "|")
                    CraftingXp% = Split(ActorGlobal(Player, 2), 5, "|")
                    HerbingXp% = Split(ActorGlobal(Player, 2), 6, "|")
                    MiningXp% = Split(ActorGlobal(Player, 2), 7, "|")
                    PrayerXp% = Split(ActorGlobal(Player, 2), 8, "|")
                    SmeltingXp% = Split(ActorGlobal(Player, 2), 9, "|")
                    WoodCuttingXp% = Split(ActorGlobal(Player, 2), 10, "|")
                    DodgeXp% = Split(ActorGlobal(Player, 2), 11, "|")
                    DexXp% = Split(ActorGlobal(Player, 2), 12, "|")
                    ;extra skills for easy adding later.
                    NewSkillXp1% = Split(ActorGlobal(Player, 2), 13, "|")
                    NewSkillXp2% = Split(ActorGlobal(Player, 2), 14, "|")
                    NewskillXp3% = Split(ActorGlobal(Player, 2), 15, "|")
                    NewskillXp4% = Split(ActorGlobal(Player, 2), 16, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 17, "|")
                    NewskillXp5% = Split(ActorGlobal(Player, 2), 18, "|")        
                
                    AlchemyXpToGive% = AlchemyXp + AlchXp ;get amount of xp
				
 
             
              If (AlchemyXpToGive >= Alchlvl * 750) ;if player has amount of xp need to level send them to level up

                ThreadExecute("LevelUp", "Main", Player, Target, 9)	;parameter for Alchemy = 9 
                  AlchemyXpToGive% = 0 ;set xp back to 0
              EndIf
              
      SkillXPToStore$ = MeleeXp + "|" + RangingXp + "|" + MagicXp + "|" + AlchemyXpToGive + "|" +  CraftingXp + "|" + HerbingXp + "|" + MiningXp + "|" + PrayerXp + "|" + SmeltingXp + "|" + WoodCuttingXp + "|" + DodgeXp + "|" + DexXp + "|" + NewSkillXp1 + "|" + NewSkillXp2 + "|" + NewSkillXp3 + "|" + NewSkillXp4 + "|" + NewSkillXp5 + "|" + NewSkillXp6
  
      SetActorGlobal(Player, 2, SkillXPToStore) ;set dilimiter to actor global 2 with new Alchemy xp amount
 ;-------------------------------------------------------------------------------------------------------------------- 

				ThreadExecute("In-game Achievements", "AlchMaster", Player, 0, AlchAmount) ;send to Alchemy Master Achievement
                       DoEvents(1000)
				Else
				OutPut(Player, "You do not have any Bean Jerkey", 255, 0, 0)
				CloseDialog(Player, chatbox)
				Return
				EndIf
			Else   ;   another herb check
			OutPut(Player, "You do not have any Black Orchid!", 255, 0, 0)
			CloseDialog(Player, chatbox)
			Return
			EndIf
		Else ;player does not have enough herbs or has none
		OutPut(Player, "You do not have enough Hyosc", 255, 0, 0) ;tell the player they dont have enough herbs
		CloseDialog(Player, chatbox) ; close chatbox
		Return
		EndIf ; end herbcheck

	Else ; has none of the second herb check
	OutPut(Player, "You do not have enough Black Pansy", 255, 0, 0) ;tell the player they dont have enough herbs
	CloseDialog(Player, chatbox) ; close chatbox
	Return
	EndIf ; end herbcheck

   Else ; player has no empty vials
   OutPut(Player, "You do not have any Empty Vials", 255, 0, 0) ;tell player they have no empty vials
   CloseDialog(Player, chatbox) ;close chatbox
	Return
   EndIf
    
    
 
 ElseIf (alchemymoreoption = 6)
 CloseDialog(Player, chatbox) ;close chatbox
 Closealch = 6
 DoEvents(100)
 EndIf ;end empty vial check
 
 
 EndIf
     If (ExtraPotion = 1)
        If (Closealch < 5) ;if this is less then 6 then player is making pots
            If (Alchemylvl <= 5)
                OutPut(Player, "You have made " + GiveExtrapot + " extra potions, thanks to your alchemy chance.", 255, 0, 234)
            Elseif (Alchemylvl >= 15)
                OutPut(Player, "Since you are level 15 or over you have made " + GiveExtrapot + " potions. Thanks to your alchemy chance of course.", 255, 0, 234)
            EndIf
        EndIf    
    EndIf    
 Until (Closealch = 6)
 
    
 End Function