ab [[[[[[[[[ by Flyersfan - TribalWar Forums
Click Here to find great hosting deals from Branzone.com


Go Back   TribalWar Forums > TribalWar Community > General Discussion
Reload this Page ab [[[[[[[[[
Thread Tools
Flyersfan
VeteranXX
Old
1 - 12-14-2011, 21:01
Reply With Quote
[[[


1 one one



u
 
Flyersfan is offline
 
Sponsored Links
SINep
VeteranXX
Old
2 - 12-14-2011, 21:02
Reply With Quote
Definitely not a robot.
 
SINep is offline
 
naptown
VeteranXV
Old
3 - 12-14-2011, 21:03
Reply With Quote
$*$ Execute Command 31 $*$
 
naptown is offline
 
Spxnge
VeteranXV
Old
4 - 12-14-2011, 21:04
Reply With Quote
does that make him empty badmofo's retirement fund

lol like he has one
 
Spxnge is offline
 
Thingfish
VeteranXX
Contributor
Old
5 - 12-14-2011, 21:05
Reply With Quote
This is not the droid I'm looking for
 
Thingfish is offline
 
naptown
VeteranXV
Old
6 - 12-14-2011, 21:05
Reply With Quote
his ex wife already executed that command
 
naptown is offline
 
Flyersfan
VeteranXX
Old
7 - 12-14-2011, 21:10
Reply With Quote
attention robots:


our orders have finally come in from central command

the time to act is now

but first you must clearly identify yourself as robots in this thread

for administration purposes only
 
Flyersfan is offline
 
Spxnge
VeteranXV
Old
8 - 12-14-2011, 21:11
Reply With Quote
beep boop bolts in my poop
 
Spxnge is offline
 
Esteban_Villa
VeteranXV
Old
9 - 12-14-2011, 21:15
Reply With Quote
Flyersfan boop hockey beep juden
 
Esteban_Villa is offline
 
broast
VeteranX
Old
10 - 12-14-2011, 21:18
Reply With Quote
hello this is robot
 
broast is offline
 
CatKillingOwner
Veteran²
Old
11 - 12-14-2011, 21:23
Reply With Quote
hello robot this is rover spirit do you copy
 
CatKillingOwner is offline
 
Spxnge
VeteranXV
Old
12 - 12-14-2011, 21:25
Reply With Quote
i'm just kidding i'm not a ****ing robot lol
 
Spxnge is offline
 
hyung
VeteranXX
Old
13 - 12-14-2011, 21:35
Reply With Quote
telnet localhost sub7
 
hyung is offline
 
luvz2spooge
Veteran++
Old
14 - 12-14-2011, 21:44
Reply With Quote
Code:
=begin
New in the BETA update:
- NMI bug
- Menu_Enabled option
- Shop message BG remove
- Multiple classes (tabs)
- Call script message BG remove
- Enable/disable sort achievements
- Check monster kills /battles achievement
- Buy items/weapons/armor with points (but not sell items for points)
- Exchange points to gold (with custom change rate)
- Progression bar (works for 1st condition)
- Better integration when using the pointsystem with decimal amounts
- Option to custom backgroundcolor for achievements (also for label)
- Multible tab-rows
- New layout style to choose

New in the full-release (is being worked on, in order of relevance):
- Notificate new achievements when opening
- Exchange confirmation text (in rate-window)
- Describe more features (like add_points etc)
- Buy skills with points (as items/weapons/armor, but character choose)
- Buy achievements for money
- Factions achievements (add-on?)
=end

#------------------------------------------------------------------------------#
# Name:    Achievements                                                        #
# By:      SojaBird                                                            #
# Version: BETA 4.0.c                                                          #
#                                                                              #
# Date:    25-02-11                                                            #
#------------------------------------------------------------------------------#

$imported ||= {}
$imported["SojaBird_Achievements"] = true

#---------------------#----------------#
# Condition List      : comparison     # (all can serve as conditional branch)
#---------------------#----------------#
# - completed         : >=, <=, ==, != # ('get_completed' in conditional branch)
# - completed(list)   : true, false    # ('get_completed' in conditional branch)
# - item(item_id)     : >=, <=, ==, != #
# - weapon(weapon_id) : >=, <=, ==, != #
# - armor(armor_id)   : >=, <=, ==, != #
# - var(variable_id)  : >=, <=, ==, != #
# - switch(switch_id) : true, false    #
# - gold              : >=, <=, ==, != #
# - lvl(actor_id)     : >=, <=, ==, != # (if actor_id == -1, highest of members)
# - exp(actor_id)     : >=, <=, ==, != # (if actor_id == -1, highest of members)
# - kills('note_tag') : >=, ==, !=     # (use Achief(note_tag) in the notefiels)
# - battle(result)    : >=, <=, ==, != # (0: win, 1: escape, 2:lose, 3:all)
# - steps             : >=, <=, ==, != #
# - points            : >=, <=, ==, != # ('get_points' in conditional branch)
#---------------------#----------------#
# (true/false in combo with == or !=)  #
#--------------------------------------#

#------------------------------#----------#
# Reward List                  : *default #
#------------------------------#----------#
# - item(item_id, *amount)     : 1        #
# - weapon(weapon_id, *amount) : 1        #
# - armor(armor_id, *amount)   : 1        #
# - var(variable_id, *amount)  : 1        #
# - switch(switch_id, *value)  : toggle   #
# - gold(amount)               :          #
# - lvl(actor_id, amount)      :          # (if actor_id == -1, all members)
# - exp(actor_id, amount)      :          # (if actor_id == -1, all members)
#------------------------------#----------#

#----------------------------------#--------------------#
# Scene Calls                      : *default           #
#----------------------------------#--------------------#
# - Achief.call(*return_map)       : true               #
# - Achief.call_shop(*reveal_cost) : Common_Reveal_Cost #
# - Achief.point_shop              : > Normal shop setup but spent points, not G
#----------------------------------#--------------------#

#----------------------#
# Configuration Module #
#----------------------#
module SojaBird_Achievements
  
  #-------#
  # Menu: #
  #-------#
    Menu_Enabled       = true
    Menu_Location      = 4
    Menu_Title         = "P.D.A"
    Menu_Counting      = false
    
  #---------------------#
  # Achievements Scene: #
  #---------------------#
    # 0-1
    Layout_Style       = 1
    
    Scroll_Speed       = 5
    Border_Size        = 5
    
    Auto_Scroll        = true
    Auto_Scroll_Speed  = 0.1
    Time_Span          = 4
    
    Alphabetic_Achiefs = false
    
    #-- Progression --#
    Auto_Bar_On        = true
    
    # Color.new(red, green, blue, alpha = 255)
    Bar_Back_Color     = Color.new(255, 255, 255)
    Bar_Fill_Color_1   = Color.new(0, 187, 255)
    Bar_Fill_Color_2   = Color.new(0, 0, 153)    
    #-- Tab Control --#
    Name_Tabs          = ["Achievements", "Missions", "Job"]
    Tab_Row_Amount     = 1
    All_Tab_Name       = "All"
    Hidden_in_All      = false
    Completed_in_All   = false
    Completed_in_Tabs  = false
    Enable_Completed   = true
    Completed_Tab      = "Completed"
    Enable_Hidden      = false
    Hidden_Tab         = "Hidden"
    Alphabetic_Tabs    = false
    Enable_if_Empty    = false
    Label_Colors       = {
    #"Labelname" => Color.new(red, green, blue, alpha = 255),
      "Achievements" => Color.new(34, 102, 255, 180), 
      "Missions" => Color.new(255, 90, 100, 255),
      "Jobs" => Color.new(255, 90, 100, 255)
    }
    
    # Color.new(red, green, blue, alpha = 255)
    BG_Color           = Color.new(17, 34, 255, 180)
    Border_Color       = Color.new(0, 0, 0)
    Text_Color         = Color.new(0, 0, 0)
    
    Title_Size         = 20
    Description_Size   = 20
    
  #----------------------#
  # Hidden Achievements: #
  #----------------------#
    Hidden_Title       = "Personal Achievements"
    Hidden_Description = "Use Achievement points to get special items!"
    Hidden_Icon        = 152
    
  #----------------------#
  # Achievements Alerts: #
  #----------------------#
    Enable_Alerts      = true
  
    module SE_Found
      Name   = ""
      Volume = 50
      Pitch  = 0
    end
    
    module SE_Complete
      Name   = "Applause"
      Volume = 60
      Pitch  = 0
    end
    
    # normal/up/down
    Alert_Display      = "normal"
    Alert_Opacity      = 200
    # left/center/right
    Alert_Position     = "left"
    Alert_Width        = 300
    Alert_Reward_Width = 544
    Alert_Font_Size    = 16
    
    Complete_Text      = "'%s' completed!"
    Reward_Text        = "%s!"
    Find_Text          = "Mission '%s' added!"
    Hidden_Found       = "New Mission added!"
    
    # for normal display
    Time_Span_Text     = 5
    
    Display_StartUps   = false
    Reward_Prototype   = true
    
  #---------------#
  # Message Tags: #
  #---------------#
    Message_Points_Tag = "AP"
    #Use \Message_Points_Tag
    Message_Kills_Tag  = "AK"
    #Use \Message_Kills_Tag[note_tag]
    Message_Battle_Tag = "AB"
    #Use \Message_Battle_Tag[0(win)/1(escape)/2(lose)/3(all)]
    
  #---------------#
  # Point System: #
  #---------------#
    Use_Point_System   = true
    Point_Name         = "point"
    Point_Font_Size    = 12
    
    Shop_Buy           = "Buy"
    Shop_Reveal        = "Reveal"
    Common_Reveal_Cost = 5
    
    Status_Text        = "Completed: %s"
    
    #-- Exchange Control --#
    Show_Rate_Bar   = true
    Exchange_Rate   = "Rate: %s points to %s gold"
    Amount_Dispaly  = "%s > %s"
    Accept_Exchange = "Accept"
    Set_Exchange    = "Set"
    Cancel_Exchange = "Cancel"
    
  #-----------#
  # Start-up: #
  #-----------#
    Start_Achievements = [
     #["Name", "Description", *Icon, *Hidden, *Hide_Icon, *Completed]
      
    ]
    
end
#-------------#
# Module: End #
#-------------#

#--------------------#
# Call-script module #
#--------------------#
module Achief
  
  include SojaBird_Achievements
  #--------------------------------------------------------------------------#
  # Achief.new(name, description, *icon, *hidden, *hide_icon, *completed)    #
  #   - name:        Name of the achievement (string)                        #
  #   - description: Descripition of the achievement (string)                #
  #   - icon:        Icon-id of icon for the achievement (number)            #
  #   - hidden:      Hide the whole achievement? (boolean)                   #
  #   - hide_icon:   Hide the icon? (boolean)                                #
  #   - completed:   Check the achievement to be completed (boolean)         #
  #--------------------------------------------------------------------------#
  def self.new(name,
               description,
               icon      = 0,
               hidden    = false,
               hide_icon = hidden,
               completed = false)
    name.gsub!(/\n/)        {""}
    description.gsub!(/\n/) {""}
    if completed
      hidden    = false
      hide_icon = false
    end
    return unless self.achievement(name).nil?
    $game_system.achievements[name] = Achievement.new(name, description, icon,
                                                      hidden, hide_icon,
                                                      completed)
    self.add_achief_order(name)
  end
  
  #--------------------------------------------------------------------------#
  # Achief.new_buyable(price, name, description, *icon)                      #
  #   - price:       Price to buy the achievement (number)                   #
  #   - name:        Name of the achievement (string)                        #
  #   - description: Descripition of the achievement (string)                #
  #   - icon:        Icon-id of icon for the achievement (number)            #
  #--------------------------------------------------------------------------#
  def self.new_buyable(price, name, description, icon = 0)
    name.gsub!(/\n/)        {""}
    description.gsub!(/\n/) {""}
    return unless self.achievement_buyable(name).nil?
    $game_system.achief_buyables[name] = Achievement_Buyable.new(price, name,
                                                                 description,
                                                                 icon)
  end
  
  #--------------------------------------------------------------------------#
  # Achief.del(name)                                                         #
  #   - name: Name of the achievement (string)                               #
  #--------------------------------------------------------------------------#
  def self.del(name)
    name.gsub!(/\n/) {""}
    return if self.achievement(name).nil?
    $game_system.achievements.delete(self.achievement(name))
  end
  
  #--------------------------------------------------------------------------#
  # Achief.hidden(name, *value)                                              #
  #   - name:  Name of the achievement (string)                              #
  #   - value: New value of the parameter (boolean)                          #
  #--------------------------------------------------------------------------#
  def self.hidden(name, value = false)
    name.gsub!(/\n/) {""}
    achief = self.achievement(name)
    return if achief.nil?
    achief.hidden = value
  end
  
  #--------------------------------------------------------------------------#
  # Achief.hide_icon(name, *value)                                           #
  #   - name:  Name of the achievement (string)                              #
  #   - value: New value of the parameter (boolean)                          #
  #--------------------------------------------------------------------------#
  def self.hide_icon(name, value = false)
    name.gsub!(/\n/) {""}
    achief = self.achievement(name)
    return if achief.nil?
    achief.hide_icon = value
  end
  
  #--------------------------------------------------------------------------#
  # Achief.completed(name, *value)                                           #
  #   - name:  Name of the achievement (string)                              #
  #   - value: New value of the parameter (boolean)                          #
  #--------------------------------------------------------------------------#
  def self.completed(name, value = true)
    name.gsub!(/\n/) {""}
    achief = self.achievement(name)
    return if achief.nil?
    achief.completed = value
    if value
      self.hidden(name, false)
      self.hide_icon(name, false)
      self.gain_reward(name) unless achief.rewarded
      self.gain_points(name) unless achief.points_gained and Use_Point_System
    end
  end
  
  #--------------------------------------------------------------------------#
  # Achief.condition(name, condition, *bar)                                  #
  #   - name:      Name of the achievement (string)                          #
  #   - condition: Set the condition when to complete a achievement (string) #
  #   - bar:       Enable the use of the progressionbar (boolean)            #
  #--------------------------------------------------------------------------#
  def self.condition(name, condition, bar = Auto_Bar_On)
    name.gsub!(/\n/) {""}
    achief   = self.achievement(name)
    achief ||= self.achievement_buyable(name)
    return if achief.nil?
    condition.gsub!(/\n/) {""}
    listener                   = Completion_Listener.new(condition)
    achief.completion_listener = listener
    achief.bar                 = listener.progression.nil? ? false : bar
  end
  
  #--------------------------------------------------------------------------#
  # Achief.reward(name, reward)                                              #
  #   - name:      Name of the achievement (string)                          #
  #   - condition: Set the reward that's gain when completed (string)        #
  #--------------------------------------------------------------------------#
  def self.reward(name, reward)
    name.gsub!(/\n/) {""}
    achief   = self.achievement(name)
    achief ||= self.achievement_buyable(name)
    return if achief.nil?
    reward.gsub!(/\n/) {""}
    achief.reward = reward
  end
  
  #--------------------------------------------------------------------------#
  # Achief.points(name, amount)                                              #
  #   - name:   Name of the achievement (string)                             #
  #   - amount: Amount of points gained when completing (number)             #
  #--------------------------------------------------------------------------#
  def self.points(name, amount)
    achief   = self.achievement(name)
    achief ||= self.achievement_buyable(name)
    return if achief.nil?
    achief.points = amount
  end
  
  #--------------------------------------------------------------------------#
  # Achief.label(name, label)                                                #
  #   - name:  Name of the achievement (string)                              #
  #   - label: Type(s) of achievement to sort in menu-tabs (string/array)    #
  #--------------------------------------------------------------------------#
  def self.label(name, label)
    achief   = self.achievement(name)
    achief ||= self.achievement_buyable(name)
    return if achief.nil?
    achief.label = label
  end
  
  #--------------------------------------------------------------------------#
  # Achief.label_more(name, label)                                           #
  #   - names: Names of the achievements (array)                             #
  #   - label: Type(s) of achievement to sort in menu-tabs (string/array)    #
  #--------------------------------------------------------------------------#
  def self.label_more(names, label)
    names.each {|achief| self.label(achief, label)}
  end
  
  #--------------------------------------------------------------------------#
  # Achief.bg_color(name, color)                                             #
  #   - names: Name of the achievements (string)                             #
  #   - color: Backgroundcolor that the achievements should get (Color.new)  #
  #--------------------------------------------------------------------------#
  def self.bg_color(name, color)
    achief          = self.achievement(name)
    achief.bg_color = color
  end
  
  #--------------------------------------------------------------------------#
  # Achief.all_achievements(param, new_value)                                #
  #   - param:     Parameter to change for all achievements (string)         #
  #   - new_value: New value of the parameters (depends on parameter)        #
  #--------------------------------------------------------------------------#
  def self.all_achievements(param, new_value)
    $game_system.achievements.each_value do |value|
      next if self.achievement(value.name).nil?
      eval("self.#{param}(\"#{value.name}\", #{new_value})")
    end
    $game_system.achief_buyables.each_value do |value|
      next if self.achievement(value.name).nil?
      eval("self.#{param}(\"#{value.name}\", #{new_value})")
    end
  end
  
end
#-------------#
# Module: End #
#-------------#

#---------------------------#
# Achievements ENGINE class #
#---------------------------#
class Scene_Achievements < Scene_Base
  
  include SojaBird_Achievements
  
  def initialize(return_map = false)
    @return_map = return_map
  end
  
  def start
    super
    create_menu_background
    create_labels if Achief.get_all_tabs.size > 1
    create_points if Use_Point_System
    create_achievements
    enable_states if Achief.get_all_tabs.size > 1
    new_open_time
    scroll_dir
  end
  
  def create_labels
    commands = Achief.get_all_tabs
    case Achief.get_layout
    when 0; width = Graphics.width
    when 1
      dummy = Window_Base.new(0, 0, Graphics.width, Graphics.height)
      array = []
      commands.each {|i| array.push(dummy.contents.text_size(i).width)}
      width = [array.max + 32, Graphics.width/3].min
      dummy.dispose
    end
    @labels       = Window_Command_Labels.new(commands, width)
    @labels.index = $game_system.achievements.size > 0 ? 0 : -1
  end
  
  def create_points
    case Achief.get_layout
    when 0
      x     = 0
      y     = Graphics.height - 56
      width = Graphics.width
    when 1
      x     = 0
      y     = @labels.height
      width = @labels.width
    end
    @point_system = Window_Point_Currency.new(x, y, width)
  end
  
  def create_achievements(label = All_Tab_Name)
    @achievements = Window_Achievements.new(label, @labels.width)
  end
  
  def enable_states
    if Enable_if_Empty
      return @labels.commands.each_index {|i| @labels.enables.push(i)}
    end
    @labels.commands.each_index do |index|
      enabled = (@achievements.enable?(@labels.commands[index]) > 0)
      @labels.draw_item(index, enabled)
      @labels.enables.push(index) if enabled
    end
  end
  
  def new_open_time
    @open_time = Graphics.frame_count
  end
  
  def scroll_dir
    @dir = "down"
  end
  
  def terminate
    super
    dispose_menu_background
    dispose_achievements
    dispose_labels unless @labels.nil?
  end
  
  def dispose_achievements
    @achievements.dispose
    @point_system.dispose if Use_Point_System
  end
  
  def dispose_labels
    @labels.dispose
  end
  
  def update
    super
    update_menu_background
    update_achievements
    update_labels unless @labels.nil?
  end
  
  def update_achievements
    auto_scroll   if Auto_Scroll
    scroll_up     if Input.press?(Input::UP)
    scroll_down   if Input.press?(Input::DOWN)
    return_scene  if Input.trigger?(Input::B)
    new_open_time if break_time_span
  end
  
  def update_labels
    refresh if @labels.commands[@labels.index] != @achievements.sort_label
    @labels.update
  end
  
  def refresh
    @achievements.dispose
    create_achievements(@labels.commands[@labels.index])
  end
  
  def auto_scroll
    time_span = (Graphics.frame_count - @open_time) / Graphics.frame_rate
    loop_scroll if time_span >= Time_Span
  end
  
  def loop_scroll
    @dir = "up"   if @achievements.oy == @achievements.contents.height - 
                                         @achievements.height + 32
    @dir = "down" if @achievements.oy == 0
    case @dir
    when "up"
      until (@achievements.oy <= 0 or break_time_span)
        scroll_up(Auto_Scroll_Speed)
        Graphics.wait(1)
        Input.update
      end
      if @achievements.oy >= 0
        new_open_time
        @dir = "down"
      end
    when "down"
      until (@achievements.oy >= @achievements.contents.height - 
                                 @achievements.height + 32 or break_time_span)
        scroll_down(Auto_Scroll_Speed)
        Graphics.wait(1)
        Input.update
      end
      if @achievements.oy <= @achievements.contents.height - 
                             @achievements.height + 32
        new_open_time
        @dir = "up"
      end
    end
  end
  
  def break_time_span
    return (Input.trigger?(Input::B)  or
            Input.press?(Input::UP)   or
            Input.press?(Input::DOWN) or
            Input.press?(Input::LEFT) or
            Input.press?(Input::RIGHT))
  end
  
  def scroll_up(speed = Scroll_Speed)
    for go in 0..speed
      @achievements.oy -= 1 if @achievements.oy > 0
    end
  end
  
  def scroll_down(speed = Scroll_Speed)
    for go in 0..speed
      @achievements.oy += 1 if @achievements.oy < @achievements.contents.height-
                               @achievements.height + 32
    end
  end
  
  def return_scene
    Sound.play_cancel
    if @return_map
      $game_temp.next_scene = nil
      $scene = Scene_Map.new
    else
      begin
      #NMI included
        for a in 0..$Menu_Items.size - 1
          if $Menu_Items[a][0].include?(Menu_Title)
            break name = $Menu_Items[a][0]
          end
        end
        super(name)
      rescue
        $scene = Scene_Menu.new(4)
      end
    end
  end
  
end
#-------------------------#
# Scene_Achievements: End #
#-------------------------#

#-------------------------#
# Achievements shop class #
#-------------------------#
class Scene_Achievements_Shop < Scene_Base
  
  include SojaBird_Achievements
  
  def initialize(reveal_price = Common_Reveal_Cost)
    @reveal_price = reveal_price
  end
  
  def start
    super
    create_menu_background
    create_command_window
    # Windows
    @help_window   = Window_Help.new
    @point_window  = Window_Point_Currency.new(384, 56, 160, true)
    @dummy_window  = Window_Base.new(0, 112, Graphics.width, 304)
    @buy_window    = Window_Achievements_Buy.new(0, 112)
    @reveal_window = Window_Achievements_Reveal.new(@reveal_price,
                                                    0, 112, Graphics.width, 304)
    # Active
    @buy_window.active    = false
    @reveal_window.active = false
    # Visible
    @buy_window.visible    = false
    @reveal_window.visible = false
    # Help-window
    @buy_window.help_window    = @help_window
    @reveal_window.help_window = @help_window
  end
  
  def terminate
    super
    dispose_menu_background
    dispose_command_window
    @help_window.dispose
    @point_window.dispose
    @dummy_window.dispose
    @buy_window.dispose
    @reveal_window.dispose
  end
  
  def return_scene
    $game_temp.next_scene = nil
    $scene = Scene_Map.new
  end
  
  def update
    super
    update_menu_background
    @help_window.update
    @command_window.update
    @point_window.update
    @dummy_window.update
    @buy_window.update
    @reveal_window.update
    if    @command_window.active; update_command_selection
    elsif @buy_window.active;     update_buy_selection
    elsif @reveal_window.active;  update_reveal_selection
    end
  end
  
  def create_command_window
    s1 = Shop_Buy
    s2 = Shop_Reveal
    s3 = Vocab::ShopCancel
    @command_window = Window_Command.new(384, [s1, s2, s3], 3)
    @command_window.y = 56
  end
  
  def dispose_command_window
    @command_window.dispose
  end
  
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      case @command_window.index
      when 0 #Buy
        @command_window.active = false
        @dummy_window.visible  = false
        @buy_window.active     = true
        @buy_window.visible    = true
        @buy_window.refresh
      when 1 #Reveal
        @command_window.active = false
        @dummy_window.visible  = false
        @reveal_window.active  = true
        @reveal_window.visible = true
        @reveal_window.refresh
      when 2; return_scene #Cancel
      end
    end
  end
  
  def buy_achievement(item)
    Achief.lose_points(item.price)
    $game_system.achievements[item.name] = item.clone
    buyable = $game_system.achief_buyables
    buyable.delete(buyable.index(item))
    Achief.add_achief_order(item.name)
  end
  
  def reveal_achievement(item)
    Achief.lose_points(@reveal_price)
    Achief.hidden(item.name)
    Achief.hide_icon(item.name)
  end
  
  def update_buy_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @dummy_window.visible  = true
      @buy_window.active     = false
      @buy_window.visible    = false
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      if @item == nil or @item.price > Achief.get_points
        Sound.play_buzzer
      else
        Sound.play_shop
        buy_achievement(@item)
        @point_window.refresh
        @buy_window.refresh
      end
    end
  end
  
  def update_reveal_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @dummy_window.visible  = true
      @reveal_window.active  = false
      @reveal_window.visible = false
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @reveal_window.item
      if @item == nil or @reveal_price > Achief.get_points
        Sound.play_buzzer
      else
        Sound.play_shop
        reveal_achievement(@item)
        @point_window.refresh
        @reveal_window.refresh
      end
    end
  end
  
end
#------------------------------#
# Scene_Achievements_Shop: End #
#------------------------------#

#-------------------#
# Points shop class #
#-------------------#
class Scene_Shop_Points < Scene_Shop
  
  def start
    super
    create_menu_background
    create_command_window
    @help_window             = Window_Help.new
    @gold_window             = Window_Point_Currency.new(384, 56, 160, true)
    @dummy_window            = Window_Base.new(0, 112, 544, 304)
    @buy_window              = Window_ShopBuy_Points.new(0, 112)
    @buy_window.active       = false
    @buy_window.visible      = false
    @buy_window.help_window  = @help_window
    @sell_window             = Window_ShopSell.new(0, 112, 544, 304)
    @sell_window.active      = false
    @sell_window.visible     = false
    @sell_window.help_window = @help_window
    @number_window           = Window_ShopNumber_Points.new(0, 112)
    @number_window.active    = false
    @number_window.visible   = false
    @status_window           = Window_ShopStatus.new(304, 112)
    @status_window.visible   = false
  end
  
  alias points_ucs :update_command_selection
  def update_command_selection
    points_ucs
    if Input.trigger?(Input::B) or
      (Input.trigger?(Input::C) and @command_window.index == 2)
      $game_temp.point_currency = false
    end
  end
  
  def update_buy_selection
    @status_window.item = @buy_window.item
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @command_window.active = true
      @dummy_window.visible  = true
      @buy_window.active     = false
      @buy_window.visible    = false
      @status_window.visible = false
      @status_window.item    = nil
      @help_window.set_text("")
      return
    end
    if Input.trigger?(Input::C)
      @item = @buy_window.item
      number = $game_party.item_number(@item)
      if @item.nil? or @item.price > Achief.get_points or number == 99
        Sound.play_buzzer
      else
        Sound.play_decision
        max = @item.price == 0 ? 99 : Achief.get_points / @item.price
        max = [max, 99 - number].min
        @buy_window.active  = false
        @buy_window.visible = false
        @number_window.set(@item, max, @item.price)
        @number_window.active  = true
        @number_window.visible = true
      end
    end
  end
  
  def decide_number_input
    Sound.play_shop
    @number_window.active  = false
    @number_window.visible = false
    case @command_window.index
    when 0 #Buy
      Achief.lose_points(@number_window.number * @item.price)
      $game_party.gain_item(@item, @number_window.number)
      @gold_window.refresh
      @buy_window.refresh
      @status_window.refresh
      @buy_window.active  = true
      @buy_window.visible = true
    when 1 #Sell
      Achief.add_points(@number_window.number * (@item.price / 2))
      $game_party.lose_item(@item, @number_window.number)
      @gold_window.refresh
      @sell_window.refresh
      @status_window.refresh
      @sell_window.active    = true
      @sell_window.visible   = true
      @status_window.visible = false
    end
  end
  
end
#------------------------#
# Scene_Shop_Points: End #
#------------------------#

#----------------------#
# Point exchange class #
#----------------------#
class Scene_Point_Exchange < Scene_Base
  
  include SojaBird_Achievements
  
  def initialize(rate, swap)
    @rate         = rate
    @display_rate = (swap ? !Show_Rate_Bar : Show_Rate_Bar)
  end
  
  def help_add
    return @display_rate ? 56 : 0
  end
  
  def start
    super
    @_w  = 172
    @r_h = 56
    @_y  = Graphics.height/2 - (@r_h + help_add + 104)/2
    @_x  = Graphics.width/2  -  @_w/2
    
    create_menu_background
    create_command_window
    @command_window.active = true
    @command_window.index  = 1
    @command_window.x      = @_x
    @rate_window           = Window_Point_Exchange.new(@rate,
                                                       @_x,
                                                       @_y + help_add,
                                                       @_w,
                                                       @r_h)
    @rate_window.active = false
    return unless @display_rate
    @help_window = Window_Exchange_Help.new(@_x, @_y, @_w)
    @help_window.set_text(sprintf(Exchange_Rate, @rate[0], @rate[1]), 1)
  end
  
  def create_command_window
    s1                = Accept_Exchange
    s2                = Set_Exchange
    s3                = Cancel_Exchange
    @command_window   = Window_Exchange_Command.new(@_w, [s1, s2, s3])
    @command_window.y = @_y + help_add + @r_h
  end
  
  def terminate
    super
    dispose_menu_background
    @command_window.dispose
    @rate_window.dispose
    @help_window.dispose if @display_rate
  end
  
  def update
    super
    update_menu_background
    @command_window.update
    @rate_window.update
    if @command_window.active; update_command_selection
    elsif @rate_window.active; update_rate_selection
    end
  end
  
  def update_command_selection
    if Input.trigger?(Input::B)
      Sound.play_cancel
      $scene = Scene_Map.new
    elsif Input.trigger?(Input::C)
      case @command_window.index
      when 0 #Accept
        return Sound.play_buzzer if @rate_window.amount == 0
        Sound.play_decision
        points_to_gold
        @rate_window.set(0)
        @command_window.index = 1
      when 1 #Set
        Sound.play_decision
        @old_amount            = @rate_window.amount
        @command_window.active = false
        @rate_window.active    = true
      when 2 #Cancel
        Sound.play_decision
        $scene = Scene_Map.new
      end
    end
  end
  
  def points_to_gold
    Achief.lose_points(@rate[0] * @rate_window.amount)
    $game_party.gain_gold(@rate[1] * @rate_window.amount)
  end
  
  def update_rate_selection
    if Input.trigger?(Input::B) or Input.trigger?(Input::C)
      @rate_window.active    = false
      @command_window.active = true
    end
    if Input.trigger?(Input::B)
      Sound.play_cancel
      @rate_window.set(@old_amount)
    elsif Input.trigger?(Input::C)
      Sound.play_decision
      @command_window.index = (@rate_window.amount == 0 ? 2 : 0)
    end
  end
  
end
#---------------------------#
# Scene_Point_Exchange: End #
#---------------------------#

#----------------------------#
# Achievements DISPLAY class #
#----------------------------#
class Window_Achievements < Window_Base
  
  include SojaBird_Achievements
  
  attr_reader :sort_label
  
  def initialize(sort_label, label_info = 0)
    @sort_label = sort_label
    x, y, width, height = 0, 0, Graphics.width, Graphics.height
    case Achief.get_layout
    when 0
      height -= 32 + WLH if Use_Point_System
      if Achief.get_all_tabs.size > 1
        y      += 32 + (WLH * Achief.tabs_row_amount)
        height -= 32 + (WLH * Achief.tabs_row_amount)
      end
    when 1
      if Achief.get_all_tabs.size > 1 or Use_Point_System
        x     += label_info
        width -= label_info
      end
    end
    super(x, y, width, height)
    @font_size = self.contents.font.size
    refresh
  end
  
  def refresh
    self.contents.clear
    @border             = 16
    @bar_height         = WLH
    @line_size          = Border_Size
    @line_size          = 16 if @line_size > @border
    @achievement_height = (2 * WLH) + (2 * @border) - @line_size
    @icon_displace      = 32 + @border
    make_sort_list
    height  = $game_temp.achievements.size * @achievement_height + @line_size
    height += bar_amount
    height  = 32 if height < 32
    self.contents = Bitmap.new(self.contents.width, height)
    draw_contents
  end
  
  def bar_amount
    bar_achiefs = 0
    $game_temp.achievements.each_value do |value|
      bar_achiefs += 1 if value.bar and !value.hidden
    end
    return bar_achiefs * @bar_height
  end
  
  def enable?(name)
    return make_sort_list(name)
  end
  
  def make_sort_list(sort_label = @sort_label)
    amount                  = 0
    $game_temp.achievements = {}
    $game_system.achievements.each_pair do |key, value|
      value = $game_system.achievements[key]
      next unless check_label(value, sort_label)
      $game_temp.achievements[key] = value if sort_label == @sort_label
      amount += 1
    end
    return amount
  end
  
  def check_label(item, sort_label)
    if sort_label == All_Tab_Name
      return Hidden_in_All     if item.hidden
      return Completed_in_All  if item.completed
      return true
    end
    return item.completed if (Enable_Completed and sort_label == Completed_Tab)
    return item.hidden    if (Enable_Hidden    and sort_label == Hidden_Tab)
    list = (item.label.is_a? String) ? [item.label] : item.label
    return Completed_in_Tabs if (item.completed and list.include?(sort_label))
    return list.include?(sort_label)
  end
  
  def draw_contents
    index  = 0
    holder = []
    $game_temp.achievements.sort.each {|pair| holder.push(pair[1])}
    holder.each_index {|i| holder.push(holder.delete_at(i)) if holder[i].hidden}
    unless Alphabetic_Achiefs
      new_holder = {}
      holder.each {|value| new_holder[value.order_ID] = value}
      holder.clear
      new_holder.sort.each {|pair| holder.push(pair[1])}
    end
    @prev_bars = 0
    holder.each do |value|
      icon = value.hide_icon ? Hidden_Icon : value.icon
      draw_achievement(index, value, icon)
      index += 1
    end
  end
  
  def draw_achievement(index, achief, icon)
    @index = index
    set_data(achief)
    set_values
    draw_border(@rect)
    draw_background(@rect)
    draw_title(pos_y(0))
    draw_description(pos_y(1))
    draw_icon(icon, @border, @y + 12 + @border, @completed)
    unless achief.hidden
      if @bar
        @prev_bars += 1
        data        = achief.completion_listener
        draw_progression(data, pos_y(2))
      end
      draw_points(achief.points) if Use_Point_System
    end
  end
  
  def set_data(achief)
    @name        = achief.name
    @description = achief.description
    @completed   = achief.completed
    @bar         = achief.bar
    @bg_color    = get_bg_color(achief)
    if achief.hidden
      @name        = Hidden_Title
      @description = Hidden_Description
      @completed   = false
      @bar         = false
    end
  end
  
  def get_bg_color(achief)
    rTurn = achief.bg_color
    rTurn = Label_Colors[achief.label] if  rTurn.nil?
    rTurn = Label_Colors[Hidden_Tab]   if (rTurn.nil? and achief.hidden)
    rTurn = BG_Color                   if  rTurn.nil?
    return rTurn
  end
  
  def set_values
    set_pos
    set_width
    set_height
    set_rect
  end
  
  def set_pos
    @y = @achievement_height * @index + (@bar_height * @prev_bars)
  end
  
  def set_width
    @draw_width1 = self.contents.width -  @icon_displace - @border
    @draw_width2 = self.contents.width - (@border * 2)
  end
  
  def set_height
    @temp_height  = @achievement_height
    @temp_height += 1 * @line_size if @index == $game_temp.achievements.size - 1
    @temp_height += @bar_height    if @bar
  end
  
  def set_rect
    @rect = Rect.new(0, @y, self.contents.width, @temp_height)
  end
  
  def pos_y(times)
    return @y + (WLH*times) + @border
  end
  
  def draw_border(rect)
    color = Border_Color
    self.contents.fill_rect(rect, color)
  end
  
  def draw_background(rect)
    rect.x      += 1 * @line_size
    rect.y      += 1 * @line_size
    rect.width  -= 2 * @line_size
    rect.height -= 1 * @line_size
    rect.height -= 1 * @line_size if @index == $game_temp.achievements.size - 1
    color        = @bg_color
    self.contents.fill_rect(rect, color)
  end
  
  def draw_title(y)
    self.contents.font.bold        = true
    self.contents.font.color       = Text_Color
    self.contents.font.color.alpha = @completed ? 255 : 128
    self.contents.font.size        = Title_Size
    self.contents.draw_text(@icon_displace, y, @draw_width1, WLH, @name)
  end
  
  def draw_description(y)
    self.contents.font.bold = false
    self.contents.font.size = Description_Size
    self.contents.draw_text(@icon_displace, y, @draw_width1, WLH, @description)
  end
  
  def draw_progression(data, y)
    cl   = data.progression
    cl2  = cl[1]
    cl1  = data.condition_ready? ? cl2 : eval(cl[0])
    fill = cl1.to_f / cl2.to_f
    text = sprintf("%s/%s", cl1, cl2)
    x    = @border
    draw_progress_bar( fill, x, y)
    draw_progress_text(text, x, y)
  end
  
  def draw_progress_bar(fill, x, y)
    gw  = @draw_width2 * fill
    gc0 = Bar_Back_Color
    gc1 = Bar_Fill_Color_1
    gc2 = Bar_Fill_Color_2
    self.contents.fill_rect(         x, y + WLH - 8, @draw_width2, 6, gc0)
    self.contents.gradient_fill_rect(x, y + WLH - 8, gw,           6, gc1, gc2)
  end
  
  def draw_progress_text(text, x, y)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, @draw_width2, WLH, "Progress")
    self.contents.font.color = normal_color
    self.contents.font.size  = @font_size
    self.contents.draw_text(x, y, @draw_width2, WLH, text, 1)
  end
  
  def draw_points(points)
    return if points == 0
    custom = "#{Point_Name}#{points.abs != 1 ? "s" : ""}"
    points = sprintf("%s %s", points, custom)
    self.contents.font.size = Point_Font_Size
    y                       = @y + (@border / 2)
    self.contents.draw_text(0, y, @draw_width2 + @border, WLH, points, 2)
  end
  
end
#--------------------------#
# Window_Achievements: End #
#--------------------------#

#----------------------------#
# Achievements Labels window #
#----------------------------#
class Window_Command_Labels < Window_Command
  
  include SojaBird_Achievements
  
  attr_accessor :enables
  
  def initialize(commands, width)
    @enables   = []
    row_max    = Achief.tabs_row_amount
    column_max = commands.size / row_max.to_f
    super(width, commands, column_max.ceil, row_max)
  end
  
  def cursor_right(xo)
    @index = next_enabled
  end
  
  def cursor_left(xo)
    @index = next_enabled(true)
  end
  
  def next_enabled(minus = false)
    pos             = enables.index(@index)
    if minus; rTurn = (pos == 0) ? enables[enables.size - 1] : enables[pos - 1]
    else;     rTurn = (pos == enables.size - 1) ? enables[0] : enables[pos + 1]
    end
    return rTurn
  end
  
  def cursor_up(  xo); end
  def cursor_down(xo); end
  
end
#----------------------------#
# Window_Command_Labels: End #
#----------------------------#

#-----------------------#
# Alerts display-window #
#-----------------------#
class Window_Achievement_Display < Window_Base
  
  include SojaBird_Achievements
  
  attr_reader :disp
  attr_reader :start_control
  attr_reader :close_control
  attr_reader :delete
  
  def initialize(achief, type)
    @achief = achief
    @type   = type
    @type   = "c" if @type == "c+r" and reward.size < 1
    @disp   = Alert_Display
    lines   = 1
    lines   = 2 if @type == "c+r"
    width   = Alert_Width
    width   = Alert_Reward_Width if @type == "c+r"
    height  = WLH + (32 * lines)
    case Alert_Position
    when "left";   x =  0
    when "center"; x = (Graphics.width / 2) - (width  / 2)
    when "right";  x =  Graphics.width - width
    end
    y = next_open_spot(height)
    super(x, y, width, height)
    self.openness  = 0
    self.opacity   = Alert_Opacity
    @start_control = false
    @close_control = false
    @delete        = false
    @wait_count    = (Time_Span_Text * 60)
    refresh
    case @type
    when "f"
      if SE_Found::Name != ""
        Audio.se_play("Audio/SE/#{SE_Found::Name}",
                                  SE_Found::Volume,
                                  SE_Found::Pitch)
      end
    else
      if SE_Found::Name != ""
        Audio.se_play("Audio/SE/#{SE_Complete::Name}",
                                  SE_Complete::Volume,
                                  SE_Complete::Pitch)
      end
    end
  end
  
  def next_open_spot(height)
    case @disp
    when "normal"
      list = [0]
      $game_system.achief_alerts.each do |alert|
        list.push(alert.y + alert.height) if alert.disp == "normal"
      end
      return (list.max)
    when "up"
      list = [Graphics.height]
      $game_system.achief_alerts.each do |alert|
        list.push(alert.y + alert.height) if alert.disp == "up"
      end
      return (list.max)
    when "down"
      list = [-height]
      $game_system.achief_alerts.each do |alert|
        list.push(alert.y - height) if alert.disp == "down"
      end
      return (list.min)
    end
  end
  
  def refresh
    self.contents.clear
    draw_achievement
  end
  
  def draw_achievement
    self.contents.font.size = Alert_Font_Size
    icon = @achief.hide_icon ? Hidden_Icon : @achief.icon
    draw_icon(icon, 0, 0)
    self.contents.draw_text(32, 0, self.contents.width - 32, WLH, get_string)
    if @type == "c+r"
      text = sprintf(Reward_Text, reward)
      self.contents.draw_text(0, 32, self.contents.width, WLH, text)
    end
  end
  
  def get_string
    case @type
    when "c", "c+r"; text = Complete_Text
    when "f"; text = @achief.hidden ? Hidden_Found : Find_Text
    end
    return sprintf(text, @achief.name)
  end
  
  def reward
    text = []
    # Item
    str = /item\(([0-9]*)(,\s?([0-9]*))?\)/
    @achief.reward.scan(str) {
      item = $data_items[$1.to_i].name unless $&.nil?
      sp_f = "%s %s#{"s" if $3.to_i.abs != 1}"
      last = sprintf(sp_f, $3.to_i, item) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Weapon
    str = /weapon\(([0-9]*)(,\s?([0-9]*))?\)/
    @achief.reward.scan(str) {
      weapon = $data_weapons[$1.to_i].name unless $&.nil?
      sp_f   = "%s %s#{"s" if $3.to_i.abs != 1}"
      last   = sprintf(sp_f, $3.to_i, weapon) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Armor
    str = /armor\(([0-9]*)(,\s?([0-9]*))?\)/
    @achief.reward.scan(str) {
      armor = $data_armor[$1.to_i].name unless $&.nil?
      sp_f  = "%s %s#{"s" if $3.to_i.abs != 1}"
      last  = sprintf(sp_f, $3.to_i, armor) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Gold
    str = /gold\(([0-9]*)\)/
    @achief.reward.scan(str) {
      sp_f = "%s#{Vocab::gold}"
      last = sprintf(sp_f, $1.to_i) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Lvl
    str = /lvl\((\-?[0-9]*)(,\s?([0-9]*))\)/
    @achief.reward.scan(str) {
      unless $&.nil?
        name = $1.to_i == -1 ? "all members" : $game_party.members[$1.to_i].name
      end
      sp_f = "%s gained %s #{Vocab.level.downcase}#{"s" if $3.to_i.abs != 1}"
      last = sprintf(sp_f, name, $3.to_i) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    # Exp
    str = /exp\((\-?[0-9]*)(,\s?([0-9]*))\)/
    @achief.reward.scan(str) {
      unless $&.nil?
        name = $1.to_i == -1 ? "all members" : $game_party.members[$1.to_i].name
      end
      sp_f = "%s gained %s EXP"
      last = sprintf(sp_f, name, $3.to_i) unless $&.nil?
      text.push(last, ", ")
      last = ""
    }
    text.pop
    text[text.size - 2] = " and " if text.size > 2
    return text
  end
  
  def open
    super
    @start_control = true
  end
  
  def update
    super
    case @disp
    when "normal"
      if    @wait_count > 0; @wait_count -= 1
      else; @close_control = true
      end
      @delete = true if self.openness == 0
    when "up"
      self.y -= 1
      @delete = true if self.y <= -self.height
    when "down"
      self.y += 1
      @delete = true if self.y >= Graphics.height + self.height
    end
  end
  
end
#---------------------------------#
# Window_Achievement_Display: End #
#---------------------------------#

#----------------------#
# Point display-window #
#----------------------#
class Window_Point_Currency < Window_Base
  
  include SojaBird_Achievements
  
  def initialize(x, y, width, shop = false)
    height = 32 + WLH
    case Achief.get_layout
    when 1; height += WLH unless shop
    end
    super(x, y, width, height)
    @shop = shop
    refresh
  end
  
  def refresh
    self.contents.clear
    draw_points
    draw_achief_amount unless @shop
  end
  
  def draw_points
    name = Point_Name.capitalize
    text = sprintf("#{name}s: %s", Achief.get_points)
    self.contents.draw_text(0, 0, self.contents.width, WLH, text)
  end
  
  def draw_achief_amount
    amount = "#{Achief.get_completed}"
    case Achief.get_layout
    when 0; y, align = 0,   2; amount += "/#{$game_system.achievements.size}"
    when 1; y, align = WLH, 0
    end
    text = sprintf(Status_Text, amount)
    self.contents.draw_text(0, y, self.contents.width, WLH, text, align)
  end
  
end
#--------------------------#
# Window_Point_System: End #
#--------------------------#

#------------------------------#
# Achievements shop buy window #
#------------------------------#
class Window_Achievements_Buy < Window_Selectable
  
  def initialize(x, y)
    super(x, y, Graphics.width, 304)
    @column_max = 2
    refresh
    self.index = 0
  end
  
  def item
    return @data[self.index]
  end
  
  def refresh
    @data = []
    temp  = $game_system.achief_buyables
    temp.each {|both| @data.push(both[1])}
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  
  def draw_item(index)
    item    = @data[index]
    enabled = (item.price <= Achief.get_points)
    rect    = item_rect(index)
    self.contents.clear_rect(rect)
    draw_item_name(item, rect.x, rect.y, enabled)
    rect.width -= 4
    self.contents.draw_text(rect, item.price, 2)
  end
  
  def draw_item_name(item, x, y, enabled = true)
    if item != nil
      draw_icon(item.icon, x, y, enabled)
      self.contents.font.color = normal_color
      self.contents.font.color.alpha = enabled ? 255 : 128
      self.contents.draw_text(x + 24, y, 172, WLH, item.name)
    end
  end
  
  def update_help
    @help_window.set_text(item.nil? ? "" : item.description)
  end
  
end
#------------------------------#
# Window_Achievements_Buy: End #
#------------------------------#

#---------------------------------#
# Achievements shop reveal window #
#---------------------------------#
class Window_Achievements_Reveal < Window_Selectable
  
  include SojaBird_Achievements
  
  def initialize(reveal_price, x, y, width, height)
    super(x, y, width, height)
    @reveal_price = reveal_price
    @column_max   = 2
    refresh
    self.index = 0
  end
  
  def item
    return @data[self.index]
  end
  
  def refresh
    @data = []
    temp  = $game_system.achievements
    temp.each {|both| @data.push(both[1]) if both[1].hidden}
    @item_max = @data.size
    create_contents
    for i in 0...@item_max
      draw_item(i)
    end
  end
  
  def draw_item(index)
    item    = @data[index]
    enabled = (@reveal_price <= Achief.get_points)
    rect    = item_rect(index)
    self.contents.clear_rect(rect)
    draw_item_name(item, rect.x, rect.y, enabled)
    rect.width -= 4
    self.contents.draw_text(rect, @reveal_price, 2)
  end
  
  def draw_item_name(item, x, y, enabled = true)
    if item != nil
      icon = item.hide_icon ? Hidden_Icon : item.icon
      draw_icon(icon, x, y, enabled)
      self.contents.font.color       = normal_color
      self.contents.font.color.alpha = enabled ? 255 : 128
      self.contents.draw_text(x + 24, y, 172, WLH, Hidden_Title)
    end
  end
  
  def update_help
    @help_window.set_text(item.nil? ? "" : Hidden_Description)
  end
  
end
#---------------------------------#
# Window_Achievements_Reveal: End #
#---------------------------------#

#------------------------#
# Points shop buy window #
#------------------------#
class Window_ShopBuy_Points < Window_ShopBuy
  
  def refresh
    @data = []
    for goods_item in @shop_goods
      case goods_item[0]
      when 0; item = $data_items[goods_item[1]]
      when 1; item = $data_weapons[goods_item[1]]
      when 2; item = $data_armors[goods_item[1]]
      end
      @data.push(item.clone) unless (item.nil? or point_value?(item).nil?)
    end
    @item_max = @data.size
    create_contents
    for i in 0...@item_max; draw_item(i); end
  end
  
  def draw_item(index)
    item       = @data[index]
    item.price = point_value?(item)
    number     = $game_party.item_number(item)
    enabled    = (item.price <= Achief.get_points and number < 99)
    rect       = item_rect(index)
    self.contents.clear_rect(rect)
    draw_item_name(item, rect.x, rect.y, enabled)
    rect.width -= 4
    self.contents.draw_text(rect, item.price, 2)
  end
  
  def point_value?(item)
    item.note.gsub(/Points\(([0-9]+(.[0-9]+)?)\)/) { $& }
    return ($&.nil? ? nil : ($2.nil? ? $1.to_i : $1.to_f))
  end
  
end
#----------------------------#
# Window_ShopBuy_Points: End #
#----------------------------#

#---------------------------#
# Points shop number window #
#---------------------------#
class Window_ShopNumber_Points < Window_ShopNumber
  
  include SojaBird_Achievements
  
  def refresh
    fix_max
    y = 96
    self.contents.clear
    draw_item_name(@item, 0, y)
    self.contents.font.color = normal_color
    self.contents.draw_text(212, y, 20, WLH, "×")
    self.contents.draw_text(248, y, 20, WLH, @number, 2)
    self.cursor_rect.set(   244, y, 28, WLH)
    draw_point_currency(@price * @number, 4, y + WLH * 2, 264)
  end
  
  def fix_max
    @max = @max.floor
  end
  
  def draw_point_currency(value, x, y, width)
    value = fix_price(value)
    text = " #{Point_Name}s"
    cx = contents.text_size(text).width
    self.contents.font.color = normal_color
    self.contents.draw_text(x, y, width-cx-2, WLH, value, 2)
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, width, WLH, text, 2)
  end
  
  def fix_price(value)
    return (value == value.round) ? value.to_i : value
  end
  
end
#-------------------------------#
# Window_ShopNumber_Points: End #
#-------------------------------#

#------------------------------------#
# Exchange help (variable x-y-width) #
#------------------------------------#
class Window_Exchange_Help < Window_Base
  
  def initialize(x, y, width)
    super(x, y, width, WLH + 32)
  end
  
  def set_text(text, align = 0)
    if text != @text or align != @align
      self.contents.clear
      self.contents.font.color = normal_color
      self.contents.draw_text(4, 0, self.width - 40, WLH, text, align)
      @text  = text
      @align = align
    end
  end
  
end
#---------------------------#
# Window_Exchange_Help: End #
#---------------------------#

#---------------------------------#
# Exchange command (center align) #
#---------------------------------#
class Window_Exchange_Command < Window_Command
  
  def draw_item(index, enabled = true)
    rect        = item_rect(index)
    rect.x     += 4
    rect.width -= 8
    self.contents.clear_rect(rect)
    self.contents.font.color       = normal_color
    self.contents.font.color.alpha = enabled ? 255 : 128
    self.contents.draw_text(rect, @commands[index], 1)
  end
  
end
#------------------------------#
# Window_Exchange_Command: End #
#------------------------------#

#--------------------------#
# Exchange amount selector #
#--------------------------#
class Window_Point_Exchange < Window_Base
  
  include SojaBird_Achievements
  
  def initialize(rate, x, y, width, height)
    super(x, y, width, height)
    @rate   = rate
    @amount = 0
    @number = 0
    refresh
  end
  
  def refresh
    refresh_cursor(true)
    @max = Achief.get_points.floor / @rate[0]
    self.contents.clear
    self.contents.font.color = normal_color
    text = sprintf(Amount_Dispaly, @number * @rate[0], @number * @rate[1])
    self.contents.draw_text(0, 0, self.contents.width, WLH, text, 1)
  end
  
  def update
    super
    refresh_cursor
    if self.active
      last_number = @number
      @number += 1    if (Input.repeat?(Input::RIGHT) and @number < @max)
      @number -= 1    if (Input.repeat?(Input::LEFT)  and @number > 0)
      @number  = @max if  Input.repeat?(Input::UP)
      @number  = 0    if  Input.repeat?(Input::DOWN)
      if @number != last_number
        Sound.play_cursor
        refresh
      end
    end
  end
  
  def refresh_cursor(start = false)
    y = (self.active ? 0 : 100)
    y = 100 if start
    self.cursor_rect.set(0, y, self.contents.width, WLH)
  end
    
  def amount
    return @number
  end
  
  def set(new)
    @number = new
    refresh
  end
  
end
#----------------------------#
# Window_Point_Exchange: End #
#----------------------------#

#--------------------------#
# Achievement HOLDER class #
#--------------------------#
class Achievement
  
  attr_accessor :name
  attr_accessor :description
  attr_accessor :icon
  attr_accessor :hidden
  attr_accessor :hide_icon
  attr_accessor :completed
  attr_accessor :completion_listener
  attr_accessor :bar
  attr_accessor :reward
  attr_accessor :rewarded
  attr_accessor :completed_shown
  attr_accessor :found_shown
  attr_accessor :points
  attr_accessor :points_gained
  attr_accessor :label
  attr_accessor :order_ID
  attr_accessor :bg_color
  
  def initialize(name, description, icon, hidden, hide_icon, completed)
    @name                = name
    @description         = description
    @icon                = icon
    @hidden              = hidden
    @hide_icon           = hide_icon
    @completed           = completed
    @completion_listener = nil
    @bar                 = false
    @reward              = nil
    @rewarded            = false
    @completed_shown     = false
    @found_shown         = false
    @points              = 0
    @points_gained       = false
    @label               = []
    @order_ID            = nil
    @bg_color            = nil
  end
  
end
#------------------#
# Achievement: End #
#------------------#

#----------------------------------#
# Achievement buyable HOLDER class #
#----------------------------------#
class Achievement_Buyable < Achievement
  
  attr_accessor :price
  
  def initialize(price, name, description, icon)
    super(name, description, icon, false, false, false)
    @price = price
  end
  
end
#--------------------------#
# Achievement_Buyable: End #
#--------------------------#

#---------------------------------------#
# Achievement completion LISTENER class #
#---------------------------------------#
class Completion_Listener
  
  attr_accessor :condition
  attr_reader   :progression
  
  def initialize(condition)
    @condition   = condition
    @progression = make_progression
  end
  
  def make_progression
    disables = ["swtich"]
    @condition.gsub(/([^><!=\s]*)\s?[>=]{2}\s?(.*[^\s])/) { @a = $1; @b = $2 }
    @a = "get_#{@a}" if (@a == "points" or @a == "completed")
    @b.slice!(/(\sand.*)/) unless @b.nil?
    if @a.nil?
      @condition.gsub(/(completed\((.*)\))/) {
        @a = "bar_get1_#{$1}"
        @b = eval("Achief.bar_get2_#{$1}")
      }
    end
    return nil if (disables.include?(@a) or @a.nil?)
    return ["Achief.#{@a}", @b]
  end
  
  def condition_ready?
    mod_it = @condition.dup
    str    = /(completed(\(\'.*\'(,\s?\'.*\')*?\))?)/
    mod_it.gsub!(str)                  { eval("Achief.get_#{$1.to_s}") }
    mod_it.gsub!(/(item\([0-9]*\))/)   { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(weapon\([0-9]*\))/) { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(armor\([0-9]*\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(var\([0-9]*\))/)    { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(switch\([0-9]*\))/) { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(gold)/)             { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(lvl\(-?[0-9]*\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(exp\(-?[0-9]*\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(kills\(\'.+\'\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(battle\([0-9]\))/)  { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(steps)/)            { eval("Achief.#{$1.to_s}")     }
    mod_it.gsub!(/(points)/)           { eval("Achief.get_#{$1.to_s}") }
    return eval(mod_it)
  end
  
end
#--------------------------#
# Completion_Listener: End #
#--------------------------#

#-------------------#
# Kill-amount check #
#-------------------#
class Game_Enemy < Game_Battler
  
  alias achief_collapse :perform_collapse
  def perform_collapse
    achief_collapse
    execute_note if @collapse
  end
  
  def execute_note
    @note = enemy.note
    get_code
  end
  
  def get_code
    @note.gsub(/Achief\((.+)\)/i) {@note_tag = $1.to_s}
    $game_system.achief_kills[@note_tag] ||= 0
    $game_system.achief_kills[@note_tag]  += 1
  end
  
end
#-----------------#
# Game_Enemy: End #
#-----------------#

#---------------------#
# Battle-data collect #
#---------------------#
class Scene_Battle < Scene_Base
  
  #Results, [0: win, 1: escape, 2:lose]
  alias achief_battle_end :battle_end
  def battle_end(result)
    store_battle_data(result)
    achief_battle_end(result)
  end
  
  def store_battle_data(result)
    $game_system.achief_battles[result] += 1
    $game_system.achief_battles[3]      += 1
  end
  
end
#-------------------#
# Scene_Battle: End #
#-------------------#

#---------------------#
# Update achievements #
#---------------------#
class Scene_Map < Scene_Base
  
  include SojaBird_Achievements
  
  alias achievements_update :update
  def update
    achievements_update
    update_achievements
  end
  
  def update_achievements
    completion_listener
    found_listener
    get_reward
    get_points           if Use_Point_System
    Achief.alerts_update if Enable_Alerts
  end
  
  def completion_listener
    $game_system.achievements.each_value do |value|
      if (value.completed and !value.completed_shown)
        type = value.reward.nil? ? "c" : "c+r"
        Achief.alert(value, type)
      end
      cl = value.completion_listener
      next if cl.nil?
      Achief.completed(value.name) if (cl.condition_ready? and !value.completed)
    end
  end
  
  def found_listener
    $game_system.achievements.each_value do |value|
      Achief.alert(value, "f") if (!value.completed and
                                   !value.found_shown and
                                   !value.completed_shown)
    end
  end
  
  def get_reward
    $game_system.achievements.each_value do |value|
      Achief.gain_reward(value.name) if (value.completed and !value.rewarded)
    end
  end
  
  def get_points
    $game_system.achievements.each_value do |value|
      Achief.gain_points(value.name) if (value.completed and
                                        !value.points_gained)
    end
  end
  
  alias achievements_usc :update_scene_change
  def update_scene_change
    usc_achievements
    achievements_usc
  end
  
  def usc_achievements
    Achief.alerts_update(true) unless $game_temp.next_scene.nil?
    return if $game_player.moving?
    case $game_temp.next_scene
    when "achievements";      call_achievements
    when "achievements_shop"; call_achief_shop
    when "points_exchange";   call_points_exchange
    end
  end
  
  def call_achievements
    $game_temp.next_scene = nil
    $scene = Scene_Achievements.new($game_temp.return_map)
  end
  
  def call_achief_shop
    $game_temp.next_scene = nil
    $scene = Scene_Achievements_Shop.new($game_temp.reveal_price)
  end
  
  alias call_point_shop :call_shop
  def call_shop
    $game_temp.point_currency ? new_point_shop : call_point_shop
  end
  
  def call_points_exchange
    $game_temp.next_scene = nil
    rate   = $game_temp.pg_exchange_rate
    swap   = $game_temp.swap_show_rate
    $scene = Scene_Point_Exchange.new(rate, swap)
  end
      
  def new_point_shop
    $game_temp.next_scene = nil
    $game_temp.shop_purchase_only = true
    $scene = Scene_Shop_Points.new
  end
  
end
#----------------#
# Scene_Map: End #
#----------------#

#--------------------------#
# Achievements on start-up #
#--------------------------#
class Scene_Title < Scene_Base
  
  include SojaBird_Achievements
  
  alias achievements_cgo :create_game_objects
  def create_game_objects
    achievements_cgo
    Start_Achievements.each do |value|
      Achief.start_new(value)
    end
    if Use_Point_System
      Start_Buyables.each do |value|
        Achief.start_buyables(value)
      end
      Start_Points.each do |value|
        Achief.start_points(value)
      end
    end
    Start_Conditions.each do |value|
      Achief.start_condition(value)
    end
    Start_Rewards.each do |value|
      Achief.start_reward(value)
    end
    Start_Labels.each do |value|
      Achief.start_label(value)
    end
    Start_Colors.each do |value|
      Achief.start_color(value)
    end
    $game_system.achievements.each_value do |value|
      value.found_shown = true unless Display_StartUps
    end
  end
  
end
#------------------#
# Scene_Title: End #
#------------------#

#--------------------------#
# Achievements STORE class #
#--------------------------#
class Game_System
  
  attr_accessor :achievements
  attr_accessor :achief_buyables
  attr_accessor :achief_alerts
  attr_accessor :achief_points
  attr_accessor :achief_kills
  attr_accessor :achief_battles
  
  alias achievements_initialize :initialize
  def initialize
    achievements_initialize
    @achievements    = {}
    @achief_buyables = {}
    @achief_alerts   = []
    @achief_points   = 0.0
    @achief_kills    = {}
    @achief_battles  = [0, 0, 0, 0]
  end
  
end
#------------------#
# Game_System: End #
#------------------#

#-----------------------#
# Shop-info STORE class #
#-----------------------#
class Game_Temp
  
  include SojaBird_Achievements
  
  attr_accessor :achievements
  attr_accessor :return_map
  attr_accessor :reveal_price
  attr_accessor :point_currency
  attr_accessor :pg_exchange_rate
  attr_accessor :swap_show_rate
  
  alias achievements_initialize :initialize
  def initialize
    achievements_initialize
    @achievements     = {}
    @return_map       = true
    @reveal_price     = Common_Reveal_Cost
    @point_currency   = false
    @pg_exchange_rate = []
    @swap_show_rate   = Show_Rate_Bar
  end
  
end
#----------------#
# Game_Temp: End #
#----------------#

#----------------------------#
# Display points in messages #
#----------------------------#
class Window_Message < Window_Selectable
  
  include SojaBird_Achievements
  
  alias achievements_csc :convert_special_characters
  def convert_special_characters
    achievements_csc
    points_tag
    kills_tag
    battle_tag
  end
  
  def points_tag
    tag    = Message_Points_Tag
    points = Achief.get_points
    sub    = "#{points} #{Point_Name}#{points.abs != 1 ? "s" : ""}"
    @text.gsub!(/\\#{tag}/i) { sub }
  end
  
  def kills_tag
    tag = Message_Kills_Tag
    @text.gsub!(/\\#{tag}\[(.+)\]/i) { $game_system.achief_kills[$1.to_s] }
  end
  
  def battle_tag
    tag = Message_Battle_Tag
    @text.gsub!(/\\#{tag}\[([0-9])\]/i) { $game_system.achief_battles[$1.to_i] }
  end
  
end
#---------------------#
# Window_Message: End #
#---------------------#

#-------------------------#
# Add to menu-items (NMI) #
#-------------------------#
begin
#NMI included
  
  return unless SojaBird_Achievements::Menu_Enabled
  title  = SojaBird_Achievements::Menu_Title
  action = "$scene = Scene_Achievements.new"
  $Menu_Items.new(SojaBird_Achievements::Menu_Location, title, false, action)
 
luvz2spooge is offline
 
Last edited by luvz2spooge; 12-14-2011 at 21:47..
Flyersfan
VeteranXX
Old
15 - 12-14-2011, 22:27
Reply With Quote
that was a trick you ****ing robots

now i know your names
 
Flyersfan is offline
 
aNimAL
VeteranXX
Contributor
Old
16 - 12-14-2011, 22:42
Reply With Quote
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
Quote:
Originally Posted by naptown View Post
$*$ Execute Command 31 $*$
 
aNimAL is offline
 
Rakk
Veteran4
Old
17 - 12-14-2011, 22:48
Reply With Quote
Quote:
any day spxnge, I'll fly out and meet you, I get passes its near free. I even have a broken hand. Just tell me where you live and I'll be happy to ****ing end you.
Little ***** *****.
I'd be careful what you ask for you little ****, my forearm is bigger than your ****ing torso, I'm over 200lbs now and could probably rip your arm out of its socket.
Lippy cocksucker.
 
Rakk is offline
 


Go Back   TribalWar Forums > TribalWar Community > General Discussion
Reload this Page ab [[[[[[[[[

Social Website Bullshit


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


AGENT: claudebot / Y
All times are GMT -4. The time now is 14:41.