Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #____________________________________________________________________________#
- # ProAchievements System
- # V1.0
- #
- # Free for commercial and non-commercial use.
- #___________________________________________________________________________#
- #[Usage]-------------------------------------------------------------------#
- # This script allows you to make achievements! This allows the player #
- # to look for the achievements to feel rewareded.
- #--------------------------------------------------------------------------#
- #[Configuration]-----------------------------------------------------------#
- #
- #--------------------------------------------------------------------------#
- $Gold_Achievement_Icon=125
- $Silver_Achievement_Icon=126
- $Bronze_Achievement_Icon=127
- $Gold_Achievement_Value=15
- $Silver_Achievement_Value=5
- $Bronze_Achievement_Value=1
- $Get_Sound_Effect="Audio/SE/Bell3"
- #[Variables]-------------------------------------------------------------#
- #
- #$Max_Achievements=50
- #------------------------------------------------------------------------#
- $ProPoints=0
- $Max_Achievements=4
- $Ach_ID = Array.new($Max_Achievements)
- $ach_id=0
- $Ach_Title=Array.new($Max_Achievements)
- $Ach_Purpose=Array.new($Max_Achievements)
- $Ach_Star=Array.new($Max_Achievements)
- $Ach_Earned=Array.new($Max_Achievements)
- #[Module DataManager]---------------------------------------------------#
- #
- #-----------------------------------------------------------------------#
- module DataManager
- class << self
- alias :old_make_save_contents :make_save_contents
- alias :old_extract_save_contents :extract_save_contents
- end
- def self.make_save_contents
- contents = old_save_contents
- contents[:ach_title] = $Ach_Title
- contents[:ach_purpose] = $Ach_Purpose
- contents[:ach_star] = $Ach_Star
- contents[:ach_earned] = $Ach_Earned
- contents
- end
- def self.extract_save_contents(contents)
- old_extract_save_contents(contents)
- $Ach_Title = contents[:ach_title]
- $Ach_Purpose = contents[:quest_desc]
- $Ach_Star = contents[:quest_sender]
- $Ach_Earned = contents[:ach_earned]
- end
- end
- #[Achievements Window]--------------------------------------------------#
- #
- #-----------------------------------------------------------------------#
- class Window_Achievements < Window_Base
- def initialize
- super(16, 16, Graphics.width-32, Graphics.height-32)
- refresh
- end
- def refresh
- contents.clear
- change_color(system_color)
- if $Ach_Title[$ach_id]!=nil
- contents.fill_rect(160, line_height, contents.width-160, line_height*3, darker)
- draw_text(160, 0, contents.width, line_height, $Ach_Title[$ach_id])
- draw_text(160, line_height*5, contents.width, line_height, "Value:")
- change_color(normal_color)
- #draw_text(160, line_height, contents.width, line_height, $Ach_Purpose[$ach_id])
- draw_icon($Gold_Achievement_Icon, 160, line_height*4) if $Ach_Star[$ach_id]==2
- draw_icon($Silver_Achievement_Icon, 160, line_height*4) if $Ach_Star[$ach_id]==1
- draw_icon($Bronze_Achievement_Icon, 160, line_height*4) if $Ach_Star[$ach_id]==0
- draw_text(160+24, line_height*4, contents.width, line_height, "Gold") if $Ach_Star[$ach_id]==2
- draw_text(160+24, line_height*4, contents.width, line_height, "Silver") if $Ach_Star[$ach_id]==1
- draw_text(160+24, line_height*4, contents.width, line_height, "Bronze") if $Ach_Star[$ach_id]==0
- draw_text(160, line_height*6, contents.width, line_height, $Gold_Achievement_Value) if $Ach_Star[$ach_id]==2
- draw_text(160, line_height*6, contents.width, line_height, $Silver_Achievement_Value) if $Ach_Star[$ach_id]==1
- draw_text(160, line_height*6, contents.width, line_height, $Bronze_Achievement_Value) if $Ach_Star[$ach_id]==0
- draw_text(160, line_height*7, contents.width, line_height, "Achievement is not yet earned.") if $Ach_Earned[$ach_id]!=1
- draw_text(160, line_height*7, contents.width, line_height, "Achievement is earned.") if $Ach_Earned[$ach_id]==1
- draw_text(160, line_height*13, contents.width, line_height, "Total Points:")
- draw_text(160, line_height*14, contents.width, line_height, $ProPoints)
- text=sprintf("%s", $Ach_Purpose[$ach_id])
- ypos = line_height
- change_color(normal_color)
- text.split(/\n/).each do |t|
- draw_text(160, ypos, contents.width, line_height, t)
- ypos += line_height
- end
- end
- end
- def darker
- color=Color.new(0, 0, 0, 75)
- color
- end
- def update
- super
- refresh
- end
- end
- #[Achievements Selection List]------------------------------------------#
- #
- #-----------------------------------------------------------------------#
- class Achievement_List < Window_Command
- def initialize
- super(16, 16)
- self.opacity=0
- end
- def make_command_list
- $i=0
- while $i<$Max_Achievements
- add_command($Ach_Title[$i], :see) if $Ach_Title[$i] != nil
- add_command("Ach-Not Set", :no_set) if $Ach_Title[$i]==nil
- $i+=1
- end
- end
- def update
- super
- $ach_id=index
- end
- end
- #[Achievements Scene]---------------------------------------------------#
- #
- #-----------------------------------------------------------------------#
- class Scene_Achievements < Scene_Base
- def start
- super
- make_stuff
- end
- def make_stuff
- @win=Window_Achievements.new
- @cmd=Achievement_List.new
- @cmd.height=@win.height
- @cmd.set_handler(:cancel, method(:return_scene))
- end
- end
- #[Menu Edit]------------------------------------------------------------#
- #
- #-----------------------------------------------------------------------#
- class Window_MenuCommand < Window_Command
- alias old_add_original_commands add_original_commands
- def add_original_commands
- old_add_original_commands
- add_command("Achievements", :achievements)
- end
- end
- class Scene_Menu < Scene_MenuBase
- alias old_create_command_window create_command_window
- def create_command_window
- old_create_command_window
- @command_window.set_handler(:achievements, method(:achievements))
- end
- def achievements
- SceneManager.call(Scene_Achievements)
- end
- end
- #[Map Popup]------------------------------------------------------------#
- #
- #-----------------------------------------------------------------------#
- class Map_Popup < Window_Base
- def initialize
- super(Graphics.width-160, 0, 160, line_height*3)
- $timer=0
- self.hide
- refresh
- end
- def refresh
- contents.clear
- draw_text(0, 0, contents.width, line_height, "Achievement Earned!")
- draw_text(0, line_height, contents.width, line_height, $Ach_Title[$ach_id])
- end
- def update
- super
- if $Show_Ach_Win==1
- self.show
- if $timer==0
- Audio.se_play($Get_Sound_Effect, 100, 0)
- end
- $timer+=1
- if $timer==120
- $Show_Ach_Win=0
- self.hide
- $timer=0
- end
- end
- refresh
- end
- end
- class Scene_Map < Scene_Base
- alias old_create_all_windows create_all_windows
- def create_all_windows
- old_create_all_windows
- @Ach_Popup = Map_Popup.new
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement