Lives System v1.0

17 de junho de 2013

Lives System é um script para o RPG Maker XP que adiciona um sistema de vidas num game ou projeto deste maker.

O script foi desenvolvido por Constance, e pode ser pego logo abaixo:

#==============================================================================
# ** Lives System
#------------------------------------------------------------------------------
# Constance
# Version: 1.0
# 8.9.06
#==============================================================================

#------------------------------------------------------------------------------
# * SDK Log Script
#------------------------------------------------------------------------------
SDK.log('Lives System', 'Constance', 1.0, '8.9.06')

#------------------------------------------------------------------------------
# * Begin SDK Enable Test
#------------------------------------------------------------------------------
if SDK.state('Lives System') == true

#==============================================================================
# ** Game Party
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor  :lives
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias con_livessystem_gameactor_init initialize 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    # Orginal Initialization Method
    con_livessystem_gameactor_init
    # Default Lives
    @lives = 3
  end
  #--------------------------------------------------------------------------
  # * Add Lives
  #--------------------------------------------------------------------------
  def add_lives(n)
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Sets n value
    $game_party.lives += n
  end
  #--------------------------------------------------------------------------
  # * Remove Lives
  #--------------------------------------------------------------------------
  def remove_lives(n)
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Sets n value
    $game_party.lives -= n
  end
end

#==============================================================================
# ** Window Lives
#==============================================================================

class Window_Lives < Window_Base
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    super(0, 416, 250, 64)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.opacity = 160
    refresh
  end
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    self.contents.clear
    cx = contents.text_size($game_party.lives.to_s).width
    self.contents.font.color = normal_color
    self.contents.draw_text(4, 0, 120-cx-2, 32, 'You have: ', 2)
    self.contents.draw_text(114-cx, 0, 120-cx-2, 32, "#{$game_party.lives}" + ' lives left.', 2)
    # Checks If Lives is set to 1
    case $game_party.lives
    when 0
    self.contents.clear
      self.contents.draw_text(4, 0, 120-cx-2, 32, 'You have: ', 2)
      self.contents.draw_text(114-cx, 0, 120-cx-2, 32, "no" + ' lives left.', 2)
    when 1
    self.contents.clear
      self.contents.draw_text(4, 0, 120-cx-2, 32, 'You have: ', 2)
      self.contents.draw_text(94-cx, 0, 120-cx-2, 32, "#{$game_party.lives}" + ' life left.', 2)
    end
  end
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  #def update

  #end
end

#==============================================================================
# ** Interpreter (part 7)
#==============================================================================

class Interpreter
  #--------------------------------------------------------------------------
  # * Game Over
  #--------------------------------------------------------------------------
  def command_353
    # Play cancel SE
    $game_system.se_play($data_system.cancel_se)
    # Set Local Variable Value
    $game_party.lives -= 1
  end
end

#==============================================================================
# ** Scene Map
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listings
  #--------------------------------------------------------------------------
  alias con_livessystem_scenemap_main main
  alias con_livessystem_scenemap_update update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Set Wait Count
    @wait_count = 15
    # Set Phase for Trigger
    @phase = 2
    # Set Window Lives
    @window_lives = Window_Lives.new
    # Call Original Method
    con_livessystem_scenemap_main
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Updates Window Lives
    @window_lives.update
    # Refresh Window Lives
    @window_lives.refresh
    # Call Original Method
    con_livessystem_scenemap_update
    # Check Wait Count for 0 Lives and Call Gameover Flag
    case $game_party.lives
    when 0
      # Decrease Wait Count
      @wait_count -= 1
      # If Wait Count is 8
      if @wait_count <= 8
      # Prepare for transition
      Graphics.freeze
        # If Wait Count is 0
        if @wait_count <= 0
          # Set game over flag
          $game_temp.gameover = true
          # Return true
          return true
        end
      end
    end
  end
end

#--------------------------------------------------------------------------
# * End SDK Enable Test
#--------------------------------------------------------------------------
end

Observação: se você gostou deste post ou ele lhe foi útil de alguma forma, por favor considere apoiar financeiramente a Gaming Room. Fico feliz só de ajudar, mas a contribuição do visitante é muito importante para que este site continua existindo e para que eu possa continuar provendo este tipo de conteúdo e melhorar cada vez mais. Clique aqui e saiba como. Obrigado!

Deixe um comentário

Inscreva-se na nossa newsletter!