#==============================================================================
# GAMBIT ARCADE LIVES
#------------------------------------------------------------------------------
# WRITTEN BY: Gambit
#------------------------------------------------------------------------------
# VERSION: 1.00
#------------------------------------------------------------------------------
# CHANGELOG:
# v 1.00 - May 24, 2014 > Initial release
#------------------------------------------------------------------------------
# DESCRIPTION AND FEATURES:
# This script creates a simple arcade-like lives system represented either by
# icons or text.
#
# Features:
# - Lives can be represented by icons or text
# - Game over when no lives are left
# - HalfLives option allows for icons to represent two lives each and for a
# faded icon to represent a single life
# - Adjustable position of lives window on the map scene
#------------------------------------------------------------------------------
# REQUIRES:
# - None
#------------------------------------------------------------------------------
# INSTRUCTIONS AND SETUP:
# Place this script below Materials and above Main Process.
# -------------------------------------------------------------
# Use the following event script calls:
# To check the number of lives:
# lives
#
# To modify the number of lives:
# lives(number)
# Examples:
# lives(2) this will INCREASE the number of lives by 2
# lives(-1) this will DECREASE the number of lives by 1
#
# To set the total number of lives:
# set_lives(number)
# Example:
# set_lives(5) this will set the number of lives to 5
# -------------------------------------------------------------
# Alternatively, use the methods below to access lives even outside events:
# $game_party.lives to check the number of lives
# $game_party.lives(number) to modify lives by number
# $game_party.lives(number, true) to set the total lives to number
# -------------------------------------------------------------
# Setup for this script is below. Please read explanations in comments.
#------------------------------------------------------------------------------
# Terms of Use:
# - Credit if used
# - Free for use in non-commercial projects
# - Please do not repost elsewhere, convert, or translate this script without
# permission.
# - If seeking to use in commercial projects (projects that are generating money
# in any way, including advertisements), please contact me via PM at:
# http://www.rpgmakervxace.net/user/14194-gambit/
# - When using third-party scripts, the terms and conditions of those scripts
# also apply. Please be aware of them prior to using.
# - Not for use in any project involving any form of nudity, commercial or not
#==============================================================================
module Gambit
module ArcadeLives
# Icon to use for lives. To use text instead, use Icons = false.
Icons = 3
# Only needed if Icons are being used. This will make each icon count as two
# lives. An icon will fade when the first life is lost and then disappear
# when the second life is lost.
HalfLives = false
# Only needed if Icons = false. Text to display in front of number of lives.
Text = 'Lives: '
# X and Y position of the lives window.
X = 0
Y = 0
# Starting number of lives.
StartingLives = 3
end
end
###############################################################################
###############################################################################
###############################################################################
###############################################################################
### END OF SETTING UP ###### ONLY EDIT BELOW IF YOU KNOW WHAT YOU ARE DOING ###
###############################################################################
###############################################################################
###############################################################################
###############################################################################
($imported ||={})["GambitArcadeLives"] = true
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# This class handles parties. Information such as gold and items is included.
# Instances of this class are referenced by $game_party.
#==============================================================================
class Game_Party < Game_Unit
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
alias gam_arcadelives_initialize initialize
def initialize
gam_arcadelives_initialize
@lives = Gambit::ArcadeLives::StartingLives
end
#--------------------------------------------------------------------------
# * Change Party Lives
#--------------------------------------------------------------------------
def lives(change = false, set = false)
return @lives unless change
set ? @lives = change : @lives += change
SceneManager.scene.refresh_lives_window if SceneManager.scene_is? Scene_Map
SceneManager.goto(Scene_Gameover) if @lives < 1
end
end
#==============================================================================
# ** Game_Interpreter
#------------------------------------------------------------------------------
# An interpreter for executing event commands. This class is used within the
# Game_Map, Game_Troop, and Game_Event classes.
#==============================================================================
class Game_Interpreter
#--------------------------------------------------------------------------
# * Change Lives
#--------------------------------------------------------------------------
def lives(change = false)
$game_party.lives(change)
end
#--------------------------------------------------------------------------
# * Set Lives
#--------------------------------------------------------------------------
def set_lives(lives)
$game_party.lives(lives, true)
end
end
#==============================================================================
# ** Window_Lives
#------------------------------------------------------------------------------
# This window displays the party's remaining lives.
#==============================================================================
class Window_Lives < Window_Base
include Gambit::ArcadeLives
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(X, Y, Graphics.width, fitting_height(1))
self.opacity = 1
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
contents.clear
if Icons && HalfLives
hearts = $game_party.lives / 2
hearts.times {|i| draw_icon(Icons, i * 24, 0) }
draw_icon(Icons, hearts * 24, 0, false) if $game_party.lives % 2 > 0
elsif Icons
$game_party.lives.times {|i| draw_icon(Icons, i * 24, 0) }
else
draw_text(0, 0, contents_width, line_height, Text +
$game_party.lives.to_s)
end
end
end
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
# This class performs the map screen processing.
#==============================================================================
class Scene_Map < Scene_Base
#--------------------------------------------------------------------------
# * Create All Windows
#--------------------------------------------------------------------------
alias gam_arcadelives_create_all_windows create_all_windows
def create_all_windows
gam_arcadelives_create_all_windows
create_lives_window
end
#--------------------------------------------------------------------------
# * Create Lives Window
#--------------------------------------------------------------------------
def create_lives_window
@lives_window = Window_Lives.new
end
#--------------------------------------------------------------------------
# * Refresh Lives Window
#--------------------------------------------------------------------------
def refresh_lives_window
@lives_window.refresh
end
end