FANDOM


Created by Taz.

Using "RC_Core.rcm"
; testingrc1 1.26
; Date/Time: 2:43:36 AM on 9/10/2010
; By Naddaz on TAZCO
;will call achievement functions from attack script.
;funcion achievement Lion tamer

;-------------------------------------
;achievements so far. In order of added to script list.
;Achievments are in there own function that will be called from scripts that are accosiaded with the achievnemet.
;-------------------------------------
;Was Lion Tamer IS Krystalics Slayer
;Mining Maniac
 ;Herb Horder
 ;Master Alchemist
;Larvae balance
 
 
 
 Function LionMain() 
 ;Requires 125 kills of Krystalics.

;achievement name Krystalics Slayer
player = Actor()
target = contextactor() 
PName$ = Name(Player)
PHuman = ActorIsHuman(Player)

If (PHuman = 0) ;if player is not human end script.
Return
EndIf
;make achievements test
;May have to make a text file for each achievement
;Make achievements file if not made yet.
  YounglionA% = OpenFile(+ PName + " Krystalics Slayer.txt") ;using to check if file exestits below. 

;OutPut(Player, "----- Debug ----- young lion acheve ran", 255, 21, 132)

;only run this if file is not there otherwize close opend file above and continue with script.
      If (YounglionA = 0)  ;if YounglionA = to 0 make file.
      
             ;Check if player has completed achievement before making a new one.
            ;if player has ach name in there text file do not make a new achevment file.
             PAName$ = + PName + "Achievements.txt"  ;write to player ahc file so this ach is complete.
             PA$ = Openfile(PAName) ;(P)layer (A)chievement

                Repeat
                    DoEvents(12)
                    ;SeekFile(PA, FileSize(PAName))
                    AchCheck$ = ReadLine(PA) 
                    EndFile$ = Eof(PA)
                    AName$ = "Krystalics Slayer" ;must be changed to achievement name
                   ; OutPut(Player, "----- DeBug ----- Checking line " + AchCheck, 32, 23, 43)
                     
                        If (AchCheck = AName) ; if line in file, end script since player has avh already
                        ;OutPut(Player, "----- DeBug ----- ach complete", 32, 23, 43)
                        DoEvents(50) ; keep number low.
                        EndFile = 1 ;end repeat and end script
                        CloseFile(PA) ;close PA open file above
                        CloseFile(AchCheck) ; Close achcheck
                        Return ;end script
                        EndIf
                       CloseFile(AchCheck) ;close file.
                   
                Until (EndFile = 1)
                CloseFile(PA) ;close file
              
                 
                
          OutPut(Player, "You have started Krystalics Slayer Achievement.", 230, 145, 23)
          YLKeyFile$ = WriteFile(+ PName + " Krystalics Slayer.txt") ;write file           
          CloseFile(YLKeyFile) ;close write file
          CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
         DoEvents(200)
         YLstart$ = 0 ;set new file to 0
         YounglionA1$ = OpenFile(+ PName + " Krystalics Slayer.txt")
         ;SeekFile(YLionFile, FileSize(YLionA)) 
         WriteLine(YounglionA1, YLstart) ;set new file line 1 to 0
         DoEvents(100) ;wait 1 mil sec then close files 
         CloseFile(YounglionA1) ;close file.
         
       EndIf 
   CloseFile(YounglionA) ;close file
  
   
 ;Read file to get kill amount
DoEvents(100)
     YLionA$ = + PName + " Krystalics Slayer.txt" ;file name to be opened
     YLionFile$ = OpenFile(YLionA) 
     ;SeekFile(YLionFile, FileSize(YLionA))
     YLionCheck$ = ReadLine(YLionFile) ;read number if ther is one to add to amount.
     TestNumber$ = YLionCheck$
   CloseFile(YLionFile) ;close achievements file that is made         

Doevents(100)
DeleteFile(+ PName + " Krystalics Slayer.txt") ;delete file so new amount can be entered.

   ;YounglionA2$ = OpenFile(+ PName + " YounglionA.txt") ;using to check if file exestits below. 
   killamount% = 1 ;kill amount is 1 
   YounglionAWrite% = TestNumber$ ;need to change $ to %
   YounglionAWriteNum% = YounglionAWrite% + Killamount% ;change from strings to numbers
   YounglionA% = OpenFile(+ PName + " Krystalics Slayer.txt") ;using to check if file exestits below. 
  
            YLKeyFile$ = WriteFile(+ PName + " Krystalics Slayer.txt")  ;make new file           
           CloseFile(YLKeyFile) ;close file
           CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
     ;-------------------------------------------------------------------------------------
     ;check if Achievement is met.
     ;Lion taimer 125 kills
     AchNeed% = 125
     
      If (YounglionAWriteNum >= AchNeed)
     PlaySound(Player, 56, 0)
     ScreenFlash(Player, 255, 255, 255, 255, 7000, 285) ;flash Achievement that player recived.
     DoEvents(100)
     DeleteFile(+ PName + " Krystalics Slayer.txt") ;delete file so new amount can be entered.     
     OutPut(Player, "Achievments have been updated. You have recived your reward.", 255, 255, 0) ;tell player that achievment has been updated.
     ;Write to player Achievement that this achievement is complete.
        PAName$ = + Pname + "Achievements.txt"  ;write to player ahc file so this ach is complete.
        PA$ = Openfile(+ Pname + "Achievements.txt") ;(P)layer (A)chievement
        AName$ = "Krystalics Slayer" ;must be changed to achievement name
        SeekFile(PA, FileSize(PAName))
        WriteLine(PA, AName) ;set new file line 1 to 0
        CloseFile(PA)
        ;----------------------------------
        ;Give reward to player for achievenmet.
        ;Reward is 5 stat points., for completeing this achievenmet.
        ;-----------------------------------
        StatPoints% = Attribute(Player, "Stats") + 5
        
         SetMaxAttribute(Player, "Stats", StatPoints)
        SetAttribute(Player, "Stats", StatPoints)
                
               
         Return
 
      ;OutPut(Player, "----- Debug ----- 5 kills Achieved", 245, 123, 213)
     EndIf
      
      ;-------------------------------------------------------------------------------------
   
                
          DoEvents(100)
         YLstart$ = YounglionAWriteNum
         YLionA$ = + PName + " Krystalics Slayer.txt"
         YLionFile$ = OpenFile(YLionA)
         ;SeekFile(YLionFile, FileSize(YLionA))
         WriteLine(YLionFile, YLstart) ;write 0 to file 
         CloseFile(YLionFile) 

               ;  OutPut(Player, "Amount of kills is " + YounglionAWriteNum, 234, 23, 33)               
End Function
;End Lion tamer achievemnet
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------



;Start Mining maniac achievemts
;Requires 400 ore collected for achievement
Function MManiacMain() 

;achievement name Mining Maniac
player = Actor()
target = contextactor() 
PName$ = Name(Player)
PHuman = ActorIsHuman(Player)

If (PHuman = 0) ;if player is not human end script.
Return
EndIf
;make achievements test
;May have to make a text file for each achievement
;Make achievements file if not made yet.
  YounglionA% = OpenFile(+ PName + " Mining Maniac.txt") ;using to check if file exestits below. 

;OutPut(Player, "----- Debug ----- young lion acheve ran", 255, 21, 132)

;only run this if file is not there otherwize close opend file above and continue with script.
      If (YounglionA = 0)  ;if YounglionA = to 0 make file.
      
             ;Check if player has completed achievement before making a new one.
            ;if player has ach name in there text file do not make a new achevment file.
             PAName$ = + PName + "Achievements.txt"  ;write to player ahc file so this ach is complete.
             PA$ = Openfile(PAName) ;(P)layer (A)chievement
                Repeat
                    DoEvents(12)
                    ;SeekFile(PA, FileSize(PAName))
                    AchCheck$ = ReadLine(PA) 
                    EndFile$ = Eof(PA)
                    AName$ = "Mining Maniac" ;must be changed to achievement name
                   ; OutPut(Player, "----- DeBug ----- Checking line " + AchCheck, 32, 23, 43)
                     
                        If (AchCheck = AName) ; if line in file, end script since player has avh already
                        ;OutPut(Player, "----- DeBug ----- ach complete", 32, 23, 43)
                        DoEvents(50) ; keep number low.
                        EndFile = 1 ;end repeat and end script
                        CloseFile(PA) ;close PA open file above
                        CloseFile(AchCheck) ; Close achcheck
                        Return ;end script
                        EndIf
                       CloseFile(AchCheck) ;close file.
                   
                Until (EndFile = 1)
                CloseFile(PA) ;close file
              
                 
                
          OutPut(Player, "You have started Mining Maniac Achievement.", 230, 145, 23)
          YLKeyFile$ = WriteFile(+ PName + " Mining Maniac.txt") ;write file           
          CloseFile(YLKeyFile) ;close write file
          CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
         DoEvents(200)
         YLstart$ = 0 ;set new file to 0
         YounglionA1$ = OpenFile(+ PName + " Mining Maniac.txt")
         ;SeekFile(YLionFile, FileSize(YLionA)) 
         WriteLine(YounglionA1, YLstart) ;set new file line 1 to 0
         DoEvents(100) ;wait 1 mil sec then close files 
         CloseFile(YounglionA1) ;close file.
         
       EndIf 
   CloseFile(YounglionA) ;close file
  
   
 ;Read file to get kill amount
DoEvents(100)
     YLionA$ = + PName + " Mining Maniac.txt" ;file name to be opened
     YLionFile$ = OpenFile(YLionA) 
     ;SeekFile(YLionFile, FileSize(YLionA))
     YLionCheck$ = ReadLine(YLionFile) ;read number if ther is one to add to amount.
     TestNumber$ = YLionCheck$
   CloseFile(YLionFile) ;close achievements file that is made         

Doevents(100)
DeleteFile(+ PName + " Mining Maniac.txt") ;delete file so new amount can be entered.

   ;YounglionA2$ = OpenFile(+ PName + " YounglionA.txt") ;using to check if file exestits below. 
   killamount% = 1 ;kill amount is 1 
   YounglionAWrite% = TestNumber$ ;need to change $ to %
   YounglionAWriteNum% = YounglionAWrite% + Killamount% ;change from strings to numbers
   YounglionA% = OpenFile(+ PName + " Mining Maniac.txt") ;using to check if file exestits below. 
  
            YLKeyFile$ = WriteFile(+ PName + " Mining Maniac.txt")  ;make new file           
           CloseFile(YLKeyFile) ;close file
           CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
     ;-------------------------------------------------------------------------------------
     ;check if Achievement is met.
     ;Mining Maniac 400 ores collected.
     AchNeed% = 400    
     If (YounglionAWriteNum >= AchNeed)
     PlaySound(Player, 56, 0)
     ScreenFlash(Player, 255, 255, 255, 255, 7000, 288) ;flash Achievement that player recived.
     DoEvents(100)
     DeleteFile(+ PName + " Mining Maniac.txt") ;delete file so new amount can be entered.
        OutPut(Player, "Achievments have been updated. You have recived your reward.", 255, 255, 0) ;tell player that achievment has been updated.
     ;Write to player Achievement that this achievement is complete.
        PAName$ = + Pname + "Achievements.txt"  ;write to player ahc file so this ach is complete.
        PA$ = Openfile(+ Pname + "Achievements.txt") ;(P)layer (A)chievement
        AName$ = "Mining Maniac" ;must be changed to achievement name
        SeekFile(PA, FileSize(PAName))
        WriteLine(PA, AName) ;set new file line 1 to 0
        CloseFile(PA)
        ;----------------------------------
        ;Give reward to player for achievenmet.
        ;Reward 3 mining levels
        ;-----------------------------------
        MinLevel% = Attribute(Player, "Mining") + 3 ;reward amount.
        SetMaxAttribute(Player, "Mining", MinLevel) ;set mining level for reward.
        SetAttribute(Player, "Mining", MinLevel) ;set mining level for reward.
        
         
         
         
         Return
 
      ;OutPut(Player, "----- Debug ----- 5 kills Achieved", 245, 123, 213)
     EndIf
      
      ;-------------------------------------------------------------------------------------
   
                
          DoEvents(100)
         YLstart$ = YounglionAWriteNum
         YLionA$ = + PName + " Mining Maniac.txt"
         YLionFile$ = OpenFile(YLionA)
         ;SeekFile(YLionFile, FileSize(YLionA))
         WriteLine(YLionFile, YLstart) ;write 0 to file 
         CloseFile(YLionFile) 

               ;  OutPut(Player, "Amount of kills is " + YounglionAWriteNum, 234, 23, 33)                
End Function
;End Mining Maniac Achievement
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
 
 
 ;Herb Horder Achievement
;Requires 400 herbs collected.
Function HerbHord()

;Using same layout templete for faster achevenmet adding.

;achievement name Mining Maniac
player = Actor()
target = contextactor() 
PName$ = Name(Player)
PHuman = ActorIsHuman(Player)

If (PHuman = 0) ;if player is not human end script.
Return
EndIf
;make achievements test
;May have to make a text file for each achievement
;Make achievements file if not made yet.
  YounglionA% = OpenFile(+ PName + " Herb Horder.txt") ;using to check if file exestits below. 

;OutPut(Player, "----- Debug ----- young lion acheve ran", 255, 21, 132)

;only run this if file is not there otherwize close opend file above and continue with script.
      If (YounglionA = 0)  ;if YounglionA = to 0 make file.
      
             ;Check if player has completed achievement before making a new one.
            ;if player has ach name in there text file do not make a new achevment file.
             PAName$ = + PName + "Achievements.txt"  ;write to player ahc file so this ach is complete.
             PA$ = Openfile(PAName) ;(P)layer (A)chievement
                Repeat
                    DoEvents(12)
                    ;SeekFile(PA, FileSize(PAName))
                    AchCheck$ = ReadLine(PA) 
                    EndFile$ = Eof(PA)
                    AName$ = "Herb Horder" ;must be changed to achievement name
                   ; OutPut(Player, "----- DeBug ----- Checking line " + AchCheck, 32, 23, 43)
                     
                        If (AchCheck = AName) ; if line in file, end script since player has avh already
                        ;OutPut(Player, "----- DeBug ----- ach complete", 32, 23, 43)
                        DoEvents(50) ; keep number low.
                        EndFile = 1 ;end repeat and end script
                        CloseFile(PA) ;close PA open file above
                        CloseFile(AchCheck) ; Close achcheck
                        Return ;end script
                        EndIf
                       CloseFile(AchCheck) ;close file.
                   
                Until (EndFile = 1)
                CloseFile(PA) ;close file
              
                 
                
          OutPut(Player, "You have started Herb Horder Achievement.", 230, 145, 23)
          YLKeyFile$ = WriteFile(+ PName + " Herb Horder.txt") ;write file           
          CloseFile(YLKeyFile) ;close write file
          CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
         DoEvents(200)
         YLstart$ = 0 ;set new file to 0
         YounglionA1$ = OpenFile(+ PName + " Herb Horder.txt")
         ;SeekFile(YLionFile, FileSize(YLionA)) 
         WriteLine(YounglionA1, YLstart) ;set new file line 1 to 0
         DoEvents(100) ;wait 1 mil sec then close files 
         CloseFile(YounglionA1) ;close file.
         
       EndIf 
   CloseFile(YounglionA) ;close file
  
   
 ;Read file to get kill amount
DoEvents(100)
     YLionA$ = + PName + " Herb Horder.txt" ;file name to be opened
     YLionFile$ = OpenFile(YLionA) 
     ;SeekFile(YLionFile, FileSize(YLionA))
     YLionCheck$ = ReadLine(YLionFile) ;read number if ther is one to add to amount.
     TestNumber$ = YLionCheck$
   CloseFile(YLionFile) ;close achievements file that is made         

Doevents(100)
DeleteFile(+ PName + " Herb Horder.txt") ;delete file so new amount can be entered.

   ;YounglionA2$ = OpenFile(+ PName + " YounglionA.txt") ;using to check if file exestits below. 
   killamount% = 1 ;kill amount is 1 
   YounglionAWrite% = TestNumber$ ;need to change $ to %
   YounglionAWriteNum% = YounglionAWrite% + Killamount% ;change from strings to numbers
   YounglionA% = OpenFile(+ PName + " Herb Horder.txt") ;using to check if file exestits below. 
  
            YLKeyFile$ = WriteFile(+ PName + " Herb Horder.txt")  ;make new file           
           CloseFile(YLKeyFile) ;close file
           CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
     ;-------------------------------------------------------------------------------------
     ;check if Achievement is met.
     ;Herb Horder 400 Herbs collected.
     AchNeed% = 400     
     If (YounglionAWriteNum >= AchNeed)
     PlaySound(Player, 56, 0)
     ScreenFlash(Player, 255, 255, 255, 255, 7000, 284) ;flash Achievement that player recived.
     DoEvents(100)
     DeleteFile(+ PName + " Herb Horder.txt") ;delete file so new amount can be entered.
        OutPut(Player, "Achievments have been updated. You have recived your reward.", 255, 255, 0) ;tell player that achievment has been updated.
     ;Write to player Achievement that this achievement is complete.
        PAName$ = + Pname + "Achievements.txt"  ;write to player ahc file so this ach is complete.
        PA$ = Openfile(+ Pname + "Achievements.txt") ;(P)layer (A)chievement
        AName$ = "Herb Horder" ;must be changed to achievement name
        SeekFile(PA, FileSize(PAName))
        WriteLine(PA, AName) ;set new file line 1 to 0
        CloseFile(PA)
        ;----------------------------------
        ;Give reward to player for achievenmet.
        ;Reward 3 Herbing levels
        ;-----------------------------------
        HerbLevel% = MaxAttribute(Player, "Herbing") + 3 ;reward amount.
        SetMaxAttribute(Player, "Herbing", HerbLevel) ;set mining level for reward.
        SetAttribute(Player, "Herbing", HerbLevel) ;set mining level for reward.
             
         Return
 
      ;OutPut(Player, "----- Debug ----- 5 kills Achieved", 245, 123, 213)
     EndIf
      
      ;-------------------------------------------------------------------------------------
   
                
          DoEvents(100)
         YLstart$ = YounglionAWriteNum
         YLionA$ = + PName + " Herb Horder.txt"
         YLionFile$ = OpenFile(YLionA)
         ;SeekFile(YLionFile, FileSize(YLionA))
         WriteLine(YLionFile, YLstart) ;write 0 to file 
         CloseFile(YLionFile) 

               ;  OutPut(Player, "Amount of kills is " + YounglionAWriteNum, 234, 23, 33)






;End Herb Horder
End Function


;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
                          
 
 Function AlchMaster()
 ;Alchemy Master achievenmet
;Templete from above for faster coding.

;achievement name Master Alchemist
player = Actor()
target = contextactor() 
PName$ = Name(Player)
PHuman = ActorIsHuman(Player)

PotionAmount% = Parameter(1) ;amount of potions made taken from alchmey that can be added to file.


If (PHuman = 0) ;if player is not human end script.
Return
EndIf
;make achievements test
;May have to make a text file for each achievement
;Make achievements file if not made yet.
  YounglionA% = OpenFile(+ PName + " Master Alchemist.txt") ;using to check if file exestits below. 

;OutPut(Player, "----- Debug ----- young lion acheve ran", 255, 21, 132)

;only run this if file is not there otherwize close opend file above and continue with script.
      If (YounglionA = 0)  ;if YounglionA = to 0 make file.
      
             ;Check if player has completed achievement before making a new one.
            ;if player has ach name in there text file do not make a new achevment file.
             PAName$ = + PName + "Achievements.txt"  ;write to player ahc file so this ach is complete.
             PA$ = Openfile(PAName) ;(P)layer (A)chievement
                Repeat
                    DoEvents(12)
                    ;SeekFile(PA, FileSize(PAName))
                    AchCheck$ = ReadLine(PA) 
                    EndFile$ = Eof(PA)
                    AName$ = "Master Alchemist" ;must be changed to achievement name
                   ; OutPut(Player, "----- DeBug ----- Checking line " + AchCheck, 32, 23, 43)
                     
                        If (AchCheck = AName) ; if line in file, end script since player has avh already
                        ;OutPut(Player, "----- DeBug ----- ach complete", 32, 23, 43)
                        DoEvents(50) ; keep number low.
                        EndFile = 1 ;end repeat and end script
                        CloseFile(PA) ;close PA open file above
                        CloseFile(AchCheck) ; Close achcheck
                        Return ;end script
                        EndIf
                       CloseFile(AchCheck) ;close file.
                   
                Until (EndFile = 1)
                CloseFile(PA) ;close file
              
                 
                
          OutPut(Player, "You have started Master Alchemist Achievement.", 230, 145, 23)
          YLKeyFile$ = WriteFile(+ PName + " Master Alchemist.txt") ;write file           
          CloseFile(YLKeyFile) ;close write file
          CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
         DoEvents(200)
         YLstart$ = 0 ;set new file to 0
         YounglionA1$ = OpenFile(+ PName + " Master Alchemist.txt")
         ;SeekFile(YLionFile, FileSize(YLionA)) 
         WriteLine(YounglionA1, YLstart) ;set new file line 1 to 0
         DoEvents(100) ;wait 1 mil sec then close files 
         CloseFile(YounglionA1) ;close file.
         
       EndIf 
   CloseFile(YounglionA) ;close file
  
   
 ;Read file to get kill amount
DoEvents(100)
     YLionA$ = + PName + " Master Alchemist.txt" ;file name to be opened
     YLionFile$ = OpenFile(YLionA) 
     ;SeekFile(YLionFile, FileSize(YLionA))
     YLionCheck$ = ReadLine(YLionFile) ;read number if ther is one to add to amount.
     TestNumber$ = YLionCheck$
   CloseFile(YLionFile) ;close achievements file that is made         

Doevents(100)
DeleteFile(+ PName + " Master Alchemist.txt") ;delete file so new amount can be entered.

   ;YounglionA2$ = OpenFile(+ PName + " YounglionA.txt") ;using to check if file exestits below. 
   killamount% = PotionAmount ;parameter from alchemy script
   YounglionAWrite% = TestNumber$ ;need to change $ to %
   YounglionAWriteNum% = YounglionAWrite% + Killamount% ;change from strings to numbers
   YounglionA% = OpenFile(+ PName + " Master Alchemist.txt") ;using to check if file exestits below. 
  
            YLKeyFile$ = WriteFile(+ PName + " Master Alchemist.txt")  ;make new file           
           CloseFile(YLKeyFile) ;close file
           CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
     ;-------------------------------------------------------------------------------------
     ;check if Achievement is met.
     ;Master Alchemist 250 potion made.
     AchNeed% = 250   
     If (YounglionAWriteNum >= AchNeed)
     PlaySound(Player, 56, 0)
     ScreenFlash(Player, 255, 255, 255, 255, 7000, 287) ;flash Achievement that player recived.
     DoEvents(100)
     DeleteFile(+ PName + " Master Alchemist.txt") ;delete file so new amount can be entered.
        OutPut(Player, "Achievments have been updated. You have recived your reward.", 255, 255, 0) ;tell player that achievment has been updated.
     ;Write to player Achievement that this achievement is complete.
        PAName$ = + Pname + "Achievements.txt"  ;write to player ahc file so this ach is complete.
        PA$ = Openfile(+ Pname + "Achievements.txt") ;(P)layer (A)chievement
        AName$ = "Master Alchemist" ;must be changed to achievement name
        SeekFile(PA, FileSize(PAName))
        WriteLine(PA, AName) ;set new file line 1 to 0
        CloseFile(PA)
        ;----------------------------------
        ;Give reward to player for achievenmet.
        ;Reward 2 alchemy levels
        ;-----------------------------------
        AlchLevel% = AbilityLevel(Player, "Alchemy") + 2 ;reward amount.
        SetAbilityLevel(Player, "Alchemy", AlchLevel) ;set Alchemy level for reward.
       
    
         Return
 
      ;OutPut(Player, "----- Debug ----- 5 kills Achieved", 245, 123, 213)
     EndIf
      
      ;-------------------------------------------------------------------------------------
   
                
          DoEvents(100)
         YLstart$ = YounglionAWriteNum
         YLionA$ = + PName + " Master Alchemist.txt"
         YLionFile$ = OpenFile(YLionA)
         ;SeekFile(YLionFile, FileSize(YLionA))
         WriteLine(YLionFile, YLstart) ;write 0 to file 
         CloseFile(YLionFile) 

               ;  OutPut(Player, "Amount of kills is " + YounglionAWriteNum, 234, 23, 33)




End Function


;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;Start Tree Chopper Achievenmet,           
Function TreeChop()
 
 
 ;Tree Chopper achievenmet
;Templete from above for faster coding.

;achievement name Tree Chopper
player = Actor()
target = contextactor() 
PName$ = Name(Player)
PHuman = ActorIsHuman(Player)


If (PHuman = 0) ;if player is not human end script.
Return
EndIf
;make achievements test
;May have to make a text file for each achievement
;Make achievements file if not made yet.
  YounglionA% = OpenFile(+ PName + " Tree Chopper.txt") ;using to check if file exestits below. 
    
 
 ;OutPut(Player, "----- Debug ----- young lion acheve ran", 255, 21, 132)

;only run this if file is not there otherwize close opend file above and continue with script.
      If (YounglionA = 0)  ;if YounglionA = to 0 make file.
      
             ;Check if player has completed achievement before making a new one.
            ;if player has ach name in there text file do not make a new achevment file.
             PAName$ = + PName + "Achievements.txt"  ;write to player ahc file so this ach is complete.
             PA$ = Openfile(PAName) ;(P)layer (A)chievement
                Repeat
                    DoEvents(12)
                    ;SeekFile(PA, FileSize(PAName))
                    AchCheck$ = ReadLine(PA) 
                    EndFile$ = Eof(PA)
                    AName$ = "Tree Chopper" ;must be changed to achievement name
                   ; OutPut(Player, "----- DeBug ----- Checking line " + AchCheck, 32, 23, 43)
                     
                        If (AchCheck = AName) ; if line in file, end script since player has avh already
                        ;OutPut(Player, "----- DeBug ----- ach complete", 32, 23, 43)
                        DoEvents(50) ; keep number low.
                        EndFile = 1 ;end repeat and end script
                        CloseFile(PA) ;close PA open file above
                        CloseFile(AchCheck) ; Close achcheck
                        Return ;end script
                        EndIf
                       CloseFile(AchCheck) ;close file.
                   
                Until (EndFile = 1)
                CloseFile(PA) ;close file
              
                 
                
          OutPut(Player, "You have started Tree Chopper Achievement.", 230, 145, 23)
          YLKeyFile$ = WriteFile(+ PName + " Tree Chopper.txt") ;write file           
          CloseFile(YLKeyFile) ;close write file
          CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
         DoEvents(200)
         YLstart$ = 0 ;set new file to 0
         YounglionA1$ = OpenFile(+ PName + " Tree Chopper.txt")
         ;SeekFile(YLionFile, FileSize(YLionA)) 
         WriteLine(YounglionA1, YLstart) ;set new file line 1 to 0
         DoEvents(100) ;wait 1 mil sec then close files 
         CloseFile(YounglionA1) ;close file.
         
       EndIf 
   CloseFile(YounglionA) ;close file
  
   
 ;Read file to get kill amount
DoEvents(100)
     YLionA$ = + PName + " Tree Chopper.txt" ;file name to be opened
     YLionFile$ = OpenFile(YLionA) 
     ;SeekFile(YLionFile, FileSize(YLionA))
     YLionCheck$ = ReadLine(YLionFile) ;read number if ther is one to add to amount.
     TestNumber$ = YLionCheck$
   CloseFile(YLionFile) ;close achievements file that is made         

Doevents(100)
DeleteFile(+ PName + " Tree Chopper.txt") ;delete file so new amount can be entered.

   ;YounglionA2$ = OpenFile(+ PName + " YounglionA.txt") ;using to check if file exestits below. 
   killamount% = 1 ;parameter from alchemy script
   YounglionAWrite% = TestNumber$ ;need to change $ to %
   YounglionAWriteNum% = YounglionAWrite% + Killamount% ;change from strings to numbers
   YounglionA% = OpenFile(+ PName + " Tree Chopper.txt") ;using to check if file exestits below. 
  
            YLKeyFile$ = WriteFile(+ PName + " Tree Chopper.txt")  ;make new file           
           CloseFile(YLKeyFile) ;close file
           CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
     ;-------------------------------------------------------------------------------------
     ;check if Achievement is met.
     ;Tree Chopper 400 logs collected.
     AchNeed% = 400   
     If (YounglionAWriteNum >= AchNeed)
     PlaySound(Player, 56, 0)
     ScreenFlash(Player, 255, 255, 255, 255, 7000, 289) ;flash Achievement that player recived.
     DoEvents(100)
     DeleteFile(+ PName + " Tree Chopper.txt") ;delete file so new amount can be entered.
        OutPut(Player, "Achievments have been updated. You have recived your reward.", 255, 255, 0) ;tell player that achievment has been updated.
     ;Write to player Achievement that this achievement is complete.
        PAName$ = + Pname + "Achievements.txt"  ;write to player ahc file so this ach is complete.
        PA$ = Openfile(+ Pname + "Achievements.txt") ;(P)layer (A)chievement
        AName$ = "Tree Chopper" ;must be changed to achievement name
        SeekFile(PA, FileSize(PAName))
        WriteLine(PA, AName) ;set new file line 1 to 0
        CloseFile(PA)
        ;----------------------------------
        ;Give reward to player for achievenmet.
        ;Reward 2 alchemy levels
        ;-----------------------------------
        WCLevel% = MaxAttribute(Player, "WoodCutting") + 2 ;reward amount.
        SetAbilityLevel(Player, "WoodCutting", WCLevel) ;set Alchemy level for reward.
       
    
         Return
 
      ;OutPut(Player, "----- Debug ----- 5 kills Achieved", 245, 123, 213)
     EndIf
      
      ;-------------------------------------------------------------------------------------
   
                
          DoEvents(100)
         YLstart$ = YounglionAWriteNum
         YLionA$ = + PName + " Tree Chopper.txt"
         YLionFile$ = OpenFile(YLionA)
         ;SeekFile(YLionFile, FileSize(YLionA))
         WriteLine(YLionFile, YLstart) ;write 0 to file 
         CloseFile(YLionFile) 

               ;  OutPut(Player, "Amount of kills is " + YounglionAWriteNum, 234, 23, 33)







End Function
;End Tree Chopper

;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
;-------------------------------------------------------------------------------------
           
            
 ;Larvae balance           
Function LarvaeMain() 
;Requires 125 kills of Larvae.

;achievement name Larvae balance
player = Actor()
target = contextactor() 
PName$ = Name(Player)
PHuman = ActorIsHuman(Player)

If (PHuman = 0) ;if player is not human end script.
Return
EndIf
;make achievements test
;May have to make a text file for each achievement
;Make achievements file if not made yet.
  YounglionA% = OpenFile(+ PName + " Larvae balance.txt") ;using to check if file exestits below. 

;OutPut(Player, "----- Debug ----- Larvae balance acheve ran", 255, 21, 132)

;only run this if file is not there otherwize close opend file above and continue with script.
      If (YounglionA = 0)  ;if YounglionA = to 0 make file.
      
             ;Check if player has completed achievement before making a new one.
            ;if player has ach name in there text file do not make a new achevment file.
             PAName$ = + PName + "Achievements.txt"  ;write to player ahc file so this ach is complete.
             PA$ = Openfile(PAName) ;(P)layer (A)chievement

                Repeat
                    DoEvents(12)
                    ;SeekFile(PA, FileSize(PAName))
                    AchCheck$ = ReadLine(PA) 
                    EndFile$ = Eof(PA)
                    AName$ = "Larvae balance" ;must be changed to achievement name
                   ; OutPut(Player, "----- DeBug ----- Checking line " + AchCheck, 32, 23, 43)
                     
                        If (AchCheck = AName) ; if line in file, end script since player has avh already
                        ;OutPut(Player, "----- DeBug ----- ach complete", 32, 23, 43)
                        DoEvents(50) ; keep number low.
                        EndFile = 1 ;end repeat and end script
                        CloseFile(PA) ;close PA open file above
                        CloseFile(AchCheck) ; Close achcheck
                        Return ;end script
                        EndIf
                       CloseFile(AchCheck) ;close file.
                   
                Until (EndFile = 1)
                CloseFile(PA) ;close file
              
                 
                
          OutPut(Player, "You have started Larvae balance Achievement.", 230, 145, 23)
          YLKeyFile$ = WriteFile(+ PName + " Larvae balance.txt") ;write file           
          CloseFile(YLKeyFile) ;close write file
          CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
         DoEvents(200)
         YLstart$ = 0 ;set new file to 0
         YounglionA1$ = OpenFile(+ PName + " Larvae balance.txt")
         ;SeekFile(YLionFile, FileSize(YLionA)) 
         WriteLine(YounglionA1, YLstart) ;set new file line 1 to 0
         DoEvents(100) ;wait 1 mil sec then close files 
         CloseFile(YounglionA1) ;close file.
         
       EndIf 
   CloseFile(YounglionA) ;close file
  
   
 ;Read file to get kill amount
DoEvents(100)
     YLionA$ = + PName + " Larvae balance.txt" ;file name to be opened
     YLionFile$ = OpenFile(YLionA) 
     ;SeekFile(YLionFile, FileSize(YLionA))
     YLionCheck$ = ReadLine(YLionFile) ;read number if ther is one to add to amount.
     TestNumber$ = YLionCheck$
   CloseFile(YLionFile) ;close achievements file that is made         

Doevents(100)
DeleteFile(+ PName + " Larvae balance.txt") ;delete file so new amount can be entered.

   ;YounglionA2$ = OpenFile(+ PName + " YounglionA.txt") ;using to check if file exestits below. 
   killamount% = 1 ;kill amount is 1 
   YounglionAWrite% = TestNumber$ ;need to change $ to %
   YounglionAWriteNum% = YounglionAWrite% + Killamount% ;change from strings to numbers
   YounglionA% = OpenFile(+ PName + " Larvae balance.txt") ;using to check if file exestits below. 
  
            YLKeyFile$ = WriteFile(+ PName + " Larvae balance.txt")  ;make new file           
           CloseFile(YLKeyFile) ;close file
           CloseFile(YounglionA) ;close file       
               ;no need to stop script just wait a few mil seconds then continue
               ;Write 0 to file
     ;-------------------------------------------------------------------------------------
     ;check if Achievement is met.
     ;Larvae balance 125 kills
     AchNeed% = 125
     
      If (YounglionAWriteNum >= AchNeed)
     PlaySound(Player, 56, 0)
     ScreenFlash(Player, 255, 255, 255, 255, 7000, 753) ;flash Achievement that player recived.
     DoEvents(100)
     DeleteFile(+ PName + " Larvae balance.txt") ;delete file so new amount can be entered.
     OutPut(Player, "Achievments have been updated. You have recived your reward.", 255, 255, 0) ;tell player that achievment has been updated.
     ;Write to player Achievement that this achievement is complete.
        PAName$ = + Pname + "Achievements.txt"  ;write to player ahc file so this ach is complete.
        PA$ = Openfile(+ Pname + "Achievements.txt") ;(P)layer (A)chievement
        AName$ = "Larvae balance" ;must be changed to achievement name
        SeekFile(PA, FileSize(PAName))
        WriteLine(PA, AName) ;set new file line 1 to 0
        CloseFile(PA)
        ;----------------------------------
        ;Give reward to player for achievenmet.
        ;Reward is 5 stat points., for completeing this achievenmet.
        ;-----------------------------------
        StatPoints% = Attribute(Player, "Stats") + 5
        
         SetMaxAttribute(Player, "Stats", StatPoints)
        SetAttribute(Player, "Stats", StatPoints)
                
               
         Return
 
      ;OutPut(Player, "----- Debug ----- 5 kills Achieved", 245, 123, 213)
     EndIf
      
      ;-------------------------------------------------------------------------------------
   
                
          DoEvents(100)
         YLstart$ = YounglionAWriteNum
         YLionA$ = + PName + " Larvae balance.txt"
         YLionFile$ = OpenFile(YLionA)
         ;SeekFile(YLionFile, FileSize(YLionA))
         WriteLine(YLionFile, YLstart) ;write 0 to file 
         CloseFile(YLionFile) 

               ;  OutPut(Player, "Amount of kills is " + YounglionAWriteNum, 234, 23, 33)               
End Function
;End Larvae balance achievemnet
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------
;-----------------------------------------------------------------------------------------------