Das was man bis jetzt zu sehen und zu lesen bekommen hat, macht schon lust auf mehr :3
Falls du Hilfe mit RGSS brauchen solltest steh ich dir gern zur Verfügung (:
Freuen tu ich mich schon mal derbst über dieses Projekt :D
Druckbare Version
Das was man bis jetzt zu sehen und zu lesen bekommen hat, macht schon lust auf mehr :3
Falls du Hilfe mit RGSS brauchen solltest steh ich dir gern zur Verfügung (:
Freuen tu ich mich schon mal derbst über dieses Projekt :D
Danke für das Angebot. :) Bislang behaupte ich noch die Kontrolle über die eingefügten Scripte, aber wer weiß, wie lange noch? Und auf die Script-Möglichkeiten werde ich bei diesem Projekt nicht verzichten, sonst hätte ich ja gleich bei den ganz alten Makern bleiben können.
Bitte bitte, ich steh dir jederzeit zur Verfügung, falls du eigene Systeme haben willst, die es so nicht gibt (:
Zwei Idioten und eine Gedanke? Jawollja!
Erst vor einiger Zeit habe ich ein kleines Nebenprojekt begonnen das im Stil wie Fallout 3 / 4 gehalten sein soll. Atomare Welt, Mutanten und Guhle, Verstrahlung und so weiter. All dies soll in meinem Nebenprojekt drin sein. Ich bin jetzt schon vollkommen hin und weg von dem was ich wieder zu sehen bekommen habe. Ich freue mich derbe auf das was du da wieder mit deinen Grünen Daumen, äh Händen erschaffst und werde wie auch bei Die Reise ins All und Wolfenhain mit großen Erwartungen an das Game rann gehen. Und gerade ich bin ein großer Freund von Endzeitwelten die genau dieses Thema auffassen. Ich hoffe ich viel davon zu hören und mich in diese große Welt rein leben zu können und die Gefahren der Atomaren Welt erleben zu können, so wie es sich gehört. Freu mich schon drauf, wie gesagt. Noch viel Spaß und Glück beim Bearbeiten und erarbeiten des Games. Treuer Fan. Sarab
@ FlipelyFlip
Ich sichte gerade bestehende Systeme und gucke, inwieweit die zu meinen Absichten passen bzw. ob ich durch den bloßen Kontakt zur technischen Möglichkeit eine zusätzliche spielerische Idee entwickle.
Ah, eine Frage habe ich gleich: Kann ich ein RGSS-Script per Switch an- und ausschalten?
@ SARAB
Danke für die guten Wünsche. Solange du keine Mad-Max-Rockerkannibalen einbaust, werden sich unser beider Projekte schon noch unterscheiden. ;)
Das, mein Guter, werde ich schon lassen. ;) Aber schon lustig das wir zur fast selben Zeit die gleiche Idee hatten. Btw. ich finde den jetztigen Trailer, den ich mir jetzt nochmal ohne ruckeln angucken konnte da mein Internetstick endlich wieder richtig läuft, den finde ich einfach nur süper. Und macht auch noch viel mehr Spaß auf das kommende Game.
Kommt drauf an was das Script macht, aber grundsätzlich kann man da alles per Switches ansteuern um so Scripts an und aus zu schalten (:
@ SARAB
Der Trailer ist der Vorspann des Spiels. Ich mag keine Post-Apokalypsen, die sich um die Darstellung der Zerstörung herummogeln, also zerballere ich im Intro die Welt und der Spieler darf dann in den Resten toben.
@ FlipelyFlip
Ich möchte dieses Script (zeigt die HP-Balken der Gegner) jederzeit an- bzw. ausschalten können, je nachdem, ob der Schalter mit der ID 100 an ist.
Eigentlich dachte ich, es gehe so:Code:
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Enemy/Actor HP & SP Bars +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: El Conducter +
# Updated: January/08/08 +
# Version: 4.0 +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Update History:
# Version 1.0 - Displays enemy & actor HP & SP bars in battle.
#
# Version 2.0 - Made the enemy HP bars more centered aligned with the
# enemy. Actor bars now also show in menu screen.
#
# Version 3.0 - Module added to change bar lengths easier.
#
# Version 4.0 - System Rebuilt, new look for bars, new scrolling ability,
# more customizable features, bars on menu screen is lost,
# SDK compatible
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# What it Does:
# See enemy and actor HP/SP bars during battle.
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How it Works:
#
# This version of the script works similar to the previous versions,
# however it runs a lot differently. Rather than the invisible window
# to display the bars as in previous versions, sub-sprites are used
# instead. The same effects can be achieved this way with more efficeincy
# and less code. New fetures can be taken advantage of through this new
# system like the ability for visual filling and depletion of bars.
# Though not built directly for the SDK, this script will work with or
# without it.
#
# Lengths and settings for the bars are stored in module Bar_Config.
#
# New and altered scripts are:
#
# - module Bar_Length
# - Sprite_HP_Bar
# - Sprite_SP_Bar
# - Sprite_Battler
# - Game_Battler
# - Scene_Battle
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main. If using the SDK, paste below SDK
# and above Main.
#
# To change the bar lengths and other settings go to module Bar_Config
# and change the values there.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Comments:
# I hope my script is easy for you to use and modify. Study this script
# to learn the ways of RGSS and join the ranks of those known as 'Scripters'.
#----------------------------------------------------------------------------
#==============================================================================
# ** Module Bar_Config
#------------------------------------------------------------------------------
# Contains various configurations for bars. The lengths, colors, and speeds
# are assigned to constants that will be referenced later in the script.
#==============================================================================
module Bar_Config
# CONSTANTS
# Bar Size
LENGTH = 75
WIDTH = 8
# Bar Colors
# Full bar color
GREEN = Color.new(50, 200, 50, 255)
# Bar low color
RED = Color.new(200, 50, 50, 255)
# Colors for HP Bar
YELLOW = Color.new(200, 200, 0, 255)
ORANGE = Color.new(220, 150, 0, 255)
# Colors for SP Bar
INDIGO = Color.new(50, 50, 200, 255)
VIOLET = Color.new(120, 50, 180, 255)
# Color for bar border
BLACK = Color.new(0, 0, 0, 255)
# Bar fill & decrease speed
FASTEST = 10
FAST = Graphics.frame_rate / 2
MEDUIM = Graphics.frame_rate
SLOW = Graphics.frame_rate * 2
SLOWEST = 100
# Set this to the above desired speed
CURRENT_SPEED = FAST
# Visibility for bars. Set which bars you want visible for battle.
ACTOR_HP_USED = false
ACTOR_SP_USED = false
ENEMY_HP_USED = true
ENEMY_SP_USED = false
end
#==============================================================================
# ** Sprite_HP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the HP_Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_HP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_hp = 0
@accu_damages = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_hp = @battler.hp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_HP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_HP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + 10
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to health
length = Bar_Config::LENGTH * @battler_hp / @battler.maxhp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's health
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxhp
half = @battler.maxhp / 2
quarter = @battler.maxhp / 4
# Change bar color depending on amount HP
case @battler.hp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::YELLOW # Yellow when above half
when quarter...half
color = Bar_Config::ORANGE # Orange when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler receives damage
#--------------------------------------------------------------------------
def damage_dealing(damages)
# Don't do process if damage is a String "Miss"
unless damages.is_a?(String)
# Add new damage to accumulitive damages
@accu_damages += damages
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_damages / @counter
end
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_damages -= @rate
@battler_hp -= @rate
# Check for healing over the bar amount. If so, fix amount
if @battler_hp > @battler.maxhp
@battler_hp = @battler.maxhp
end
end
# Call method to draw bars
draw_bars
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_hp = @battler.hp
@accu_damages = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_SP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the SP Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_SP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_sp = 0
@accu_magic = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_sp = @battler.sp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, 9)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_SP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_SP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + self.bitmap.height
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to SP
length = Bar_Config::LENGTH * @battler_sp / @battler.maxsp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's SP
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxsp
half = @battler.maxsp / 2
quarter = @battler.maxsp / 4
# Change bar color depending on amount SP
case @battler.sp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::INDIGO # Indigo when above half
when quarter...half
color = Bar_Config::VIOLET # Violet when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler uses skills
#--------------------------------------------------------------------------
def skill_use(magic_used)
# Add new magic_used to accumulitive magic_used
@accu_magic += magic_used
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_magic / @counter
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_magic -= @rate
@battler_sp -= @rate
# Check for recovering SP over the bar amount. If so, fix amount
if @battler_sp > @battler.maxsp
@battler_sp = @battler.maxsp
end
end
# Call method to draw bars
draw_bars
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_sp = @battler.sp
@accu_magic = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_Battler
#==============================================================================
class Sprite_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :bar_initialize_init, :initialize
alias_method :bar_dispose_dispose, :dispose
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
# Original Initialization
bar_initialize_init(viewport, battler)
# Create bar sprites
@hp_bar = Sprite_HP_Bar.new(viewport, @battler)
@sp_bar = Sprite_SP_Bar.new(viewport, @battler)
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Original Method
bar_dispose_dispose
# Dispose Battler Bars
@hp_bar.dispose
@sp_bar.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If the HP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @hp_bar.battler == nil
@hp_bar.battler = @battler
@hp_bar.setup
end
# If the SP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @sp_bar.battler == nil
@sp_bar.battler = @battler
@sp_bar.setup
end
# If battler is changed, notify the bar sprites
if @battler != @hp_bar.battler
@hp_bar.battler = @battler
@sp_bar.battler = @battler
@hp_bar.setup
@sp_bar.setup
end
@hp_bar.update
@sp_bar.update
# If battler is nil
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# If file name or hue are different than current ones
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# Get and set bitmap
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
# Change opacity level to 0 when dead or hidden
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
# If animation ID is different than current one
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# If actor which should be displayed
if @battler.is_a?(Game_Actor) and @battler_visible
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# Blink
if @battler.blink
blink_on
else
blink_off
end
# If invisible
unless @battler_visible
# Appear
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@hp_bar.appear
@battler_visible = true
end
end
# If visible
if @battler_visible
# Escape
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# White flash
if @battler.white_flash
whiten
@battler.white_flash = false
end
# Animation
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
#@hp_bar.duration = animation.frame_max
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# Damage
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@hp_bar.damage_dealing(@battler.damage)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# Using Skill
if @battler.magic_casting
@sp_bar.skill_use(@battler.sp_used)
@battler.sp_used = nil
@battler.magic_casting = false
end
# Collapse
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@hp_bar.battler = nil
@hp_bar.collapse
@sp_bar.collapse
@battler_visible = false
end
end
# Set sprite coordinates
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :magic_casting # sp bar update flag
attr_accessor :sp_used # skill points used
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias bar_initialize_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Added variables
@magic_casting = false
@sp_used = nil
# Original method execution
bar_initialize_init
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_skill_action_result
# Get skill
@skill = $data_skills[@active_battler.current_action.skill_id]
# If not a forcing action
unless @active_battler.current_action.forcing
# If unable to use due to SP running out
unless @active_battler.skill_can_use?(@skill.id)
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
# Use up SP
@active_battler.sp -= @skill.sp_cost
# Set amount used for use with sp bar
@active_battler.sp_used = @skill.sp_cost
# Refresh status window
@status_window.refresh
# Show skill name on help window
@help_window.set_text(@skill.name, 1)
# Set animation ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# Set command event ID
@common_event_id = @skill.common_event_id
# Set target battlers
set_target_battlers(@skill.scope)
# Apply skill effect
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Set flag to update sp bar sprite
if @active_battler.sp_used != nil
@active_battler.magic_casting = true
end
# Shift to step 4
@phase4_step = 4
end
end
if $game_switches[100] = true
[hier Code]
end
Klappt aber nicht.
In der Hinsicht sind Programmiersprachen etwas fies: $game_switches[100] = true testet nicht, ob der Switch an ist, sondern setzt ihn auf true. Um auf Gleichheit zu testen, muss ein Doppel-Gleichheitszeichen benutzt werden, also:
if $game_switches[100] == true
@ Kelven
Ah, danke. Das ist wirklich eine etwas eigene Ausdrucksweise.
Ich scheine aber noch wesentlich mehr nicht zu beachten. Wenn ich das Script mit dieser if-Klammer versehe, bricht der RPG Maker XP direkt mit der Meldung eines "NoMethodError" ab. Vermutlich fehlen Vordefinitionen in einer wie auch immer gearteten Kopfzeile. Ist doch alles komplizierter als gedacht. Entweder lese ich mich da vertiefend ein oder ich handhabe auch diese Makerversion im ursprünglichen Sinne und nutze nur die Möglichkeiten, die keine echten Programmierkenntnisse verlangen. Auch in der Form bietet der XP-Maker durchaus noch seine spezifischen Vorzüge.
Vielleicht hast du die Abfrage an der falschen Stelle eingesetzt. Eine (wenig elegante) Lösung wäre vielleicht, nur das Anzeigen der Balken auszuklammern.
Code:def draw_bars
# Clear previous bars if any
self.bitmap.clear
if $game_switches[100] == true
# Use formula to get length ratio to health
length = Bar_Config::LENGTH * @battler_hp / @battler.maxhp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
end
@Kelven & realTroll:
Damit löst du lediglich die eine draw_bars-Funktionen die es gibt. Witzigerweise sind zwei verbaut (einmal HP und einmal SP), was aber nicht viel mehr aufwand ist sogesehen. Ich hätte es allgemein eher so gelöst:
Da ein Switch lediglich nur true/false haben kann als Wert (ist seine einzige Gültigkeit, nicht so wie bei Variablen, dass diese auch Strings haben können), reicht lediglich folgendes für die Abfrage:Code:#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Enemy/Actor HP & SP Bars +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: El Conducter +
# Updated: January/08/08 +
# Version: 4.0 +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Update History:
# Version 1.0 - Displays enemy & actor HP & SP bars in battle.
#
# Version 2.0 - Made the enemy HP bars more centered aligned with the
# enemy. Actor bars now also show in menu screen.
#
# Version 3.0 - Module added to change bar lengths easier.
#
# Version 4.0 - System Rebuilt, new look for bars, new scrolling ability,
# more customizable features, bars on menu screen is lost,
# SDK compatible
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# What it Does:
# See enemy and actor HP/SP bars during battle.
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How it Works:
#
# This version of the script works similar to the previous versions,
# however it runs a lot differently. Rather than the invisible window
# to display the bars as in previous versions, sub-sprites are used
# instead. The same effects can be achieved this way with more efficeincy
# and less code. New fetures can be taken advantage of through this new
# system like the ability for visual filling and depletion of bars.
# Though not built directly for the SDK, this script will work with or
# without it.
#
# Lengths and settings for the bars are stored in module Bar_Config.
#
# New and altered scripts are:
#
# - module Bar_Length
# - Sprite_HP_Bar
# - Sprite_SP_Bar
# - Sprite_Battler
# - Game_Battler
# - Scene_Battle
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main. If using the SDK, paste below SDK
# and above Main.
#
# To change the bar lengths and other settings go to module Bar_Config
# and change the values there.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Comments:
# I hope my script is easy for you to use and modify. Study this script
# to learn the ways of RGSS and join the ranks of those known as 'Scripters'.
#----------------------------------------------------------------------------
#==============================================================================
# ** Module Bar_Config
#------------------------------------------------------------------------------
# Contains various configurations for bars. The lengths, colors, and speeds
# are assigned to constants that will be referenced later in the script.
#==============================================================================
module Bar_Config
# CONSTANTS
# Bar Size
LENGTH = 75
WIDTH = 8
# Bar Colors
# Full bar color
GREEN = Color.new(50, 200, 50, 255)
# Bar low color
RED = Color.new(200, 50, 50, 255)
# Colors for HP Bar
YELLOW = Color.new(200, 200, 0, 255)
ORANGE = Color.new(220, 150, 0, 255)
# Colors for SP Bar
INDIGO = Color.new(50, 50, 200, 255)
VIOLET = Color.new(120, 50, 180, 255)
# Color for bar border
BLACK = Color.new(0, 0, 0, 255)
# Bar fill & decrease speed
FASTEST = 10
FAST = Graphics.frame_rate / 2
MEDUIM = Graphics.frame_rate
SLOW = Graphics.frame_rate * 2
SLOWEST = 100
# Set this to the above desired speed
CURRENT_SPEED = FAST
# Visibility for bars. Set which bars you want visible for battle.
ACTOR_HP_USED = false
ACTOR_SP_USED = false
ENEMY_HP_USED = true
ENEMY_SP_USED = false
end
#==============================================================================
# ** Sprite_HP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the HP_Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_HP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_hp = 0
@accu_damages = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_hp = @battler.hp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_HP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_HP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + 10
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars if $game_switches[100]
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to health
length = Bar_Config::LENGTH * @battler_hp / @battler.maxhp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's health
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxhp
half = @battler.maxhp / 2
quarter = @battler.maxhp / 4
# Change bar color depending on amount HP
case @battler.hp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::YELLOW # Yellow when above half
when quarter...half
color = Bar_Config::ORANGE # Orange when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler receives damage
#--------------------------------------------------------------------------
def damage_dealing(damages)
# Don't do process if damage is a String "Miss"
unless damages.is_a?(String)
# Add new damage to accumulitive damages
@accu_damages += damages
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_damages / @counter
end
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_damages -= @rate
@battler_hp -= @rate
# Check for healing over the bar amount. If so, fix amount
if @battler_hp > @battler.maxhp
@battler_hp = @battler.maxhp
end
end
# Call method to draw bars
draw_bars if $game_switches[100]
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_hp = @battler.hp
@accu_damages = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_SP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the SP Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_SP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_sp = 0
@accu_magic = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_sp = @battler.sp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, 9)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_SP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_SP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + self.bitmap.height
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars if $game_switches[100]
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to SP
length = Bar_Config::LENGTH * @battler_sp / @battler.maxsp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's SP
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxsp
half = @battler.maxsp / 2
quarter = @battler.maxsp / 4
# Change bar color depending on amount SP
case @battler.sp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::INDIGO # Indigo when above half
when quarter...half
color = Bar_Config::VIOLET # Violet when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler uses skills
#--------------------------------------------------------------------------
def skill_use(magic_used)
# Add new magic_used to accumulitive magic_used
@accu_magic += magic_used
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_magic / @counter
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_magic -= @rate
@battler_sp -= @rate
# Check for recovering SP over the bar amount. If so, fix amount
if @battler_sp > @battler.maxsp
@battler_sp = @battler.maxsp
end
end
# Call method to draw bars
draw_bars if $game_switches[100]
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_sp = @battler.sp
@accu_magic = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_Battler
#==============================================================================
class Sprite_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :bar_initialize_init, :initialize
alias_method :bar_dispose_dispose, :dispose
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
# Original Initialization
bar_initialize_init(viewport, battler)
# Create bar sprites
@hp_bar = Sprite_HP_Bar.new(viewport, @battler)
@sp_bar = Sprite_SP_Bar.new(viewport, @battler)
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Original Method
bar_dispose_dispose
# Dispose Battler Bars
@hp_bar.dispose
@sp_bar.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If the HP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @hp_bar.battler == nil
@hp_bar.battler = @battler
@hp_bar.setup
end
# If the SP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @sp_bar.battler == nil
@sp_bar.battler = @battler
@sp_bar.setup
end
# If battler is changed, notify the bar sprites
if @battler != @hp_bar.battler
@hp_bar.battler = @battler
@sp_bar.battler = @battler
@hp_bar.setup
@sp_bar.setup
end
@hp_bar.update
@sp_bar.update
# If battler is nil
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# If file name or hue are different than current ones
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# Get and set bitmap
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
# Change opacity level to 0 when dead or hidden
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
# If animation ID is different than current one
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# If actor which should be displayed
if @battler.is_a?(Game_Actor) and @battler_visible
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# Blink
if @battler.blink
blink_on
else
blink_off
end
# If invisible
unless @battler_visible
# Appear
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@hp_bar.appear
@battler_visible = true
end
end
# If visible
if @battler_visible
# Escape
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# White flash
if @battler.white_flash
whiten
@battler.white_flash = false
end
# Animation
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
#@hp_bar.duration = animation.frame_max
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# Damage
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@hp_bar.damage_dealing(@battler.damage)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# Using Skill
if @battler.magic_casting
@sp_bar.skill_use(@battler.sp_used)
@battler.sp_used = nil
@battler.magic_casting = false
end
# Collapse
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@hp_bar.battler = nil
@hp_bar.collapse
@sp_bar.collapse
@battler_visible = false
end
end
# Set sprite coordinates
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :magic_casting # sp bar update flag
attr_accessor :sp_used # skill points used
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias bar_initialize_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Added variables
@magic_casting = false
@sp_used = nil
# Original method execution
bar_initialize_init
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_skill_action_result
# Get skill
@skill = $data_skills[@active_battler.current_action.skill_id]
# If not a forcing action
unless @active_battler.current_action.forcing
# If unable to use due to SP running out
unless @active_battler.skill_can_use?(@skill.id)
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
# Use up SP
@active_battler.sp -= @skill.sp_cost
# Set amount used for use with sp bar
@active_battler.sp_used = @skill.sp_cost
# Refresh status window
@status_window.refresh
# Show skill name on help window
@help_window.set_text(@skill.name, 1)
# Set animation ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# Set command event ID
@common_event_id = @skill.common_event_id
# Set target battlers
set_target_battlers(@skill.scope)
# Apply skill effect
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Set flag to update sp bar sprite
if @active_battler.sp_used != nil
@active_battler.magic_casting = true
end
# Shift to step 4
@phase4_step = 4
end
end
Die Abfrage verlangt ja lediglich nur, ob das Ergebnis true ist. Es kommt nun aufs selbe raus, ob wir direkt hier true als Ergebnis erhalten, oder es zuerst mit true abgleichen (:Code:if $game_switches[100]
Für die False-Abfrage (also ob ein Switch False ist) reicht es lediglich folgendes zu machen:
Das Rufezeichen invertiert die Aussage, was bedeutet: Ist der Switch auf true gesetzt, gibt dies nun ein False zurück und der Inhalt der Abfrage wird übersprungen. Bei False wäreCode:if !$game_switches[id]
nun genau das umgekehrte der Fall und würde aus dem False ein true machen (:
Aber um kurz auf meine Änderung im Script einzugehen, also was ich geändert habe ist folgendes:
Es wird ja in der setup-Methode das draw_bars aufgerufen. Ich hab lediglich nur eine Abfrage eingefügt (draw_bars if $game_switches[100]). Diese Abfrage bedeutet soviel wie:
in kurz (:Code:if $game_switches[100]
draw_bars
end
Ist sehr zu empfehlen, wenn man mal einzelne Zeilen so verstecken will.
Bei deiner Fehlermeldung realTroll hast du wohl das gesamte Script in die Abfrage gepackt (vermute ich zumindest mal). Der Maker geht beim Playtest einmal die gesamte Scriptlist durch und schaut mal kurz durch, ob Fehler auftreten und initialisiert nur einen minimalen Anteil an den benötigten Daten (Game_System grundsätzlich) und startet danach erst die Scene_Title. Das führt dazu, dass in diesem Fehlerdurchlauf geschaut wird, ob ein End oder ähnliches vergessen wurde. Da die $game_switches noch nicht erstellt wurden, geht das System davon aus, dass hier ein Fehler in der Syntax ist und wirft deswegen den NoMethodError aus (:
Die Variable $game_switches wird nämlich erst im Scene_Title initialisiert, bzw. beim Start dessen (:
lg flipy
Danke für die Hilfe. Ganz klappt es noch nicht. In eurer Variante werden die Lebensbalken der Gegner nunmehr erst erstellt, wenn der Feind getroffen wurde, anstatt von Anfang an angezeigt zu werden.
Und vielen Dank für die Erklärung, in welcher Reihenfolge der Maker die Scripte initiiert. Dadurch hat sich ein kryptisches Mirakel in einen rationalen Umstand verwandelt.
Du schaltest den Switch erst im Kampf ein, oder? Ich hab das Script mal getestet. Wenn der Switch vor dem Kampf eingeschaltet wird, dann sieht man die Balken sofort, schaltet man den Switch aber erst im Kampf ein, dann sieht man die Balken erst nach einem Treffer. Da bin ich auf die Schnelle überfragt, wie man das Problem am besten löst.
Ich würde es so lösen:
Dadurch wird es sofort angezeigt, wenn der Switch 100 auf true gesetzt wird (:Code:#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# Enemy/Actor HP & SP Bars +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# By: El Conducter +
# Updated: January/08/08 +
# Version: 4.0 +
#++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#
# Update History:
# Version 1.0 - Displays enemy & actor HP & SP bars in battle.
#
# Version 2.0 - Made the enemy HP bars more centered aligned with the
# enemy. Actor bars now also show in menu screen.
#
# Version 3.0 - Module added to change bar lengths easier.
#
# Version 4.0 - System Rebuilt, new look for bars, new scrolling ability,
# more customizable features, bars on menu screen is lost,
# SDK compatible
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# What it Does:
# See enemy and actor HP/SP bars during battle.
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How it Works:
#
# This version of the script works similar to the previous versions,
# however it runs a lot differently. Rather than the invisible window
# to display the bars as in previous versions, sub-sprites are used
# instead. The same effects can be achieved this way with more efficeincy
# and less code. New fetures can be taken advantage of through this new
# system like the ability for visual filling and depletion of bars.
# Though not built directly for the SDK, this script will work with or
# without it.
#
# Lengths and settings for the bars are stored in module Bar_Config.
#
# New and altered scripts are:
#
# - module Bar_Length
# - Sprite_HP_Bar
# - Sprite_SP_Bar
# - Sprite_Battler
# - Game_Battler
# - Scene_Battle
#
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# How to Use This Script:
# Just copy it and paste it above Main. If using the SDK, paste below SDK
# and above Main.
#
# To change the bar lengths and other settings go to module Bar_Config
# and change the values there.
#----------------------------------------------------------------------------
#----------------------------------------------------------------------------
# Comments:
# I hope my script is easy for you to use and modify. Study this script
# to learn the ways of RGSS and join the ranks of those known as 'Scripters'.
#----------------------------------------------------------------------------
#==============================================================================
# ** Module Bar_Config
#------------------------------------------------------------------------------
# Contains various configurations for bars. The lengths, colors, and speeds
# are assigned to constants that will be referenced later in the script.
#==============================================================================
module Bar_Config
# CONSTANTS
# Bar Size
LENGTH = 75
WIDTH = 8
# Bar Colors
# Full bar color
GREEN = Color.new(50, 200, 50, 255)
# Bar low color
RED = Color.new(200, 50, 50, 255)
# Colors for HP Bar
YELLOW = Color.new(200, 200, 0, 255)
ORANGE = Color.new(220, 150, 0, 255)
# Colors for SP Bar
INDIGO = Color.new(50, 50, 200, 255)
VIOLET = Color.new(120, 50, 180, 255)
# Color for bar border
BLACK = Color.new(0, 0, 0, 255)
# Bar fill & decrease speed
FASTEST = 10
FAST = Graphics.frame_rate / 2
MEDUIM = Graphics.frame_rate
SLOW = Graphics.frame_rate * 2
SLOWEST = 100
# Set this to the above desired speed
CURRENT_SPEED = FAST
# Visibility for bars. Set which bars you want visible for battle.
ACTOR_HP_USED = false
ACTOR_SP_USED = false
ENEMY_HP_USED = true
ENEMY_SP_USED = false
end
#==============================================================================
# ** Sprite_HP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the HP_Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_HP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_hp = 0
@accu_damages = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_hp = @battler.hp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_HP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_HP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + 10
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to health
length = Bar_Config::LENGTH * @battler_hp / @battler.maxhp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's health
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxhp
half = @battler.maxhp / 2
quarter = @battler.maxhp / 4
# Change bar color depending on amount HP
case @battler.hp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::YELLOW # Yellow when above half
when quarter...half
color = Bar_Config::ORANGE # Orange when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler receives damage
#--------------------------------------------------------------------------
def damage_dealing(damages)
# Don't do process if damage is a String "Miss"
unless damages.is_a?(String)
# Add new damage to accumulitive damages
@accu_damages += damages
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_damages / @counter
end
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_damages -= @rate
@battler_hp -= @rate
# Check for healing over the bar amount. If so, fix amount
if @battler_hp > @battler.maxhp
@battler_hp = @battler.maxhp
end
end
# Call method to draw bars
draw_bars
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
self.visible = $game_switches[100] if @battler.is_a?(Game_Enemy)
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_hp = @battler.hp
@accu_damages = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_SP_Bar
#------------------------------------------------------------------------------
# This sprite is used to display the SP Bar for the battler. It inherits form
# RPG::Sprite.
#==============================================================================
class Sprite_SP_Bar < RPG::Sprite
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :battler
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler)
super(viewport)
# Assign battler and variables used in drawing bar
@battler = battler
@battler_sp = 0
@accu_magic = 0
@counter = 0
# Only call setup method if @battler is not equal to nothing
if @battler != nil
setup
end
end
#--------------------------------------------------------------------------
# * Setup: this prepares the bitmap
#--------------------------------------------------------------------------
def setup
@battler_sp = @battler.sp
self.bitmap = Bitmap.new(Bar_Config::LENGTH + 2, 9)
# Determine if bar is visible for Actor or Enemy
if @battler.is_a?(Game_Enemy)
self.visible = Bar_Config::ENEMY_SP_USED
elsif @battler.is_a?(Game_Actor)
self.visible = Bar_Config::ACTOR_SP_USED
end
# Set bar placement
self.x = @battler.screen_x
self.y = @battler.screen_y + self.bitmap.height
self.ox = self.bitmap.width / 2
self.oy = self.bitmap.height
# Call method to draw bars
draw_bars
update
end
#--------------------------------------------------------------------------
# * Method that draws the bars
#--------------------------------------------------------------------------
def draw_bars
# Clear previous bars if any
self.bitmap.clear
# Use formula to get length ratio to SP
length = Bar_Config::LENGTH * @battler_sp / @battler.maxsp
# Specify bar & border
bar_border = Rect.new(0, 0, Bar_Config::LENGTH + 2, Bar_Config::WIDTH)
bar = Rect.new(1, 1, length, Bar_Config::WIDTH - 2)
# Draw the bar with border
self.bitmap.fill_rect(bar_border, Bar_Config::BLACK)
self.bitmap.fill_rect(bar, get_color)
end
#--------------------------------------------------------------------------
# * Determine the appropriate color based on battler's SP
#--------------------------------------------------------------------------
def get_color
# Variables
full = @battler.maxsp
half = @battler.maxsp / 2
quarter = @battler.maxsp / 4
# Change bar color depending on amount SP
case @battler.sp
when full
color = Bar_Config::GREEN # Green when full
when half...full
color = Bar_Config::INDIGO # Indigo when above half
when quarter...half
color = Bar_Config::VIOLET # Violet when below half
when 0...quarter
color = Bar_Config::RED # Red when below quarter
end
# Return the appropriate color
return color
end
#--------------------------------------------------------------------------
# * Process when battler uses skills
#--------------------------------------------------------------------------
def skill_use(magic_used)
# Add new magic_used to accumulitive magic_used
@accu_magic += magic_used
# Counter will be how many times the bars will be refreshed
# for the 'fill' effect.
@counter = Bar_Config::CURRENT_SPEED
# Rate is how many points will be altered for every refresh
@rate = @accu_magic / @counter
end
#--------------------------------------------------------------------------
# * Refresh Method
#--------------------------------------------------------------------------
def refresh
# Do only while @battler is not equal to nothing
unless @battler == nil
# Do only if @counter isn't equal to 0
unless @counter == 0
# Minus variables by rate amount of rate
@accu_magic -= @rate
@battler_sp -= @rate
# Check for recovering SP over the bar amount. If so, fix amount
if @battler_sp > @battler.maxsp
@battler_sp = @battler.maxsp
end
end
# Call method to draw bars
draw_bars
end
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
unless self.bitmap == nil
self.bitmap.dispose
end
super
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# Clear if Battler is nil
if @battler.nil?
self.bitmap.clear unless self.bitmap.nil?
return
end
# If @counter is greater than zero, decrement @counter and refresh bars
if @counter > 0
# If counter is on last iteration
if @counter == 1
# Adjust variables in case of floating point number in-accuracy
@battler_sp = @battler.sp
@accu_magic = 0
end
@counter -= 1
refresh
end
end
end
#==============================================================================
# ** Sprite_Battler
#==============================================================================
class Sprite_Battler
#--------------------------------------------------------------------------
# * Alias Methods
#--------------------------------------------------------------------------
alias_method :bar_initialize_init, :initialize
alias_method :bar_dispose_dispose, :dispose
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize(viewport, battler = nil)
# Original Initialization
bar_initialize_init(viewport, battler)
# Create bar sprites
@hp_bar = Sprite_HP_Bar.new(viewport, @battler)
@sp_bar = Sprite_SP_Bar.new(viewport, @battler)
end
#--------------------------------------------------------------------------
# * Dispose
#--------------------------------------------------------------------------
def dispose
# Original Method
bar_dispose_dispose
# Dispose Battler Bars
@hp_bar.dispose
@sp_bar.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
super
# If the HP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @hp_bar.battler == nil
@hp_bar.battler = @battler
@hp_bar.setup
end
# If the SP bar sprite doesn't have a battler, assign one to it
if @battler != nil && @sp_bar.battler == nil
@sp_bar.battler = @battler
@sp_bar.setup
end
# If battler is changed, notify the bar sprites
if @battler != @hp_bar.battler
@hp_bar.battler = @battler
@sp_bar.battler = @battler
@hp_bar.setup
@sp_bar.setup
end
@hp_bar.update
@sp_bar.update
# If battler is nil
if @battler == nil
self.bitmap = nil
loop_animation(nil)
return
end
# If file name or hue are different than current ones
if @battler.battler_name != @battler_name or
@battler.battler_hue != @battler_hue
# Get and set bitmap
@battler_name = @battler.battler_name
@battler_hue = @battler.battler_hue
self.bitmap = RPG::Cache.battler(@battler_name, @battler_hue)
@width = bitmap.width
@height = bitmap.height
self.ox = @width / 2
self.oy = @height
# Change opacity level to 0 when dead or hidden
if @battler.dead? or @battler.hidden
self.opacity = 0
end
end
# If animation ID is different than current one
if @battler.damage == nil and
@battler.state_animation_id != @state_animation_id
@state_animation_id = @battler.state_animation_id
loop_animation($data_animations[@state_animation_id])
end
# If actor which should be displayed
if @battler.is_a?(Game_Actor) and @battler_visible
# Bring opacity level down a bit when not in main phase
if $game_temp.battle_main_phase
self.opacity += 3 if self.opacity < 255
else
self.opacity -= 3 if self.opacity > 207
end
end
# Blink
if @battler.blink
blink_on
else
blink_off
end
# If invisible
unless @battler_visible
# Appear
if not @battler.hidden and not @battler.dead? and
(@battler.damage == nil or @battler.damage_pop)
appear
@hp_bar.appear
@battler_visible = true
end
end
# If visible
if @battler_visible
# Escape
if @battler.hidden
$game_system.se_play($data_system.escape_se)
escape
@battler_visible = false
end
# White flash
if @battler.white_flash
whiten
@battler.white_flash = false
end
# Animation
if @battler.animation_id != 0
animation = $data_animations[@battler.animation_id]
#@hp_bar.duration = animation.frame_max
animation(animation, @battler.animation_hit)
@battler.animation_id = 0
end
# Damage
if @battler.damage_pop
damage(@battler.damage, @battler.critical)
@hp_bar.damage_dealing(@battler.damage)
@battler.damage = nil
@battler.critical = false
@battler.damage_pop = false
end
# Using Skill
if @battler.magic_casting
@sp_bar.skill_use(@battler.sp_used)
@battler.sp_used = nil
@battler.magic_casting = false
end
# Collapse
if @battler.damage == nil and @battler.dead?
if @battler.is_a?(Game_Enemy)
$game_system.se_play($data_system.enemy_collapse_se)
else
$game_system.se_play($data_system.actor_collapse_se)
end
collapse
@hp_bar.battler = nil
@hp_bar.collapse
@sp_bar.collapse
@battler_visible = false
end
end
# Set sprite coordinates
self.x = @battler.screen_x
self.y = @battler.screen_y
self.z = @battler.screen_z
end
end
#==============================================================================
# ** Game_Battler
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
# * Public Instance Variables
#--------------------------------------------------------------------------
attr_accessor :magic_casting # sp bar update flag
attr_accessor :sp_used # skill points used
#--------------------------------------------------------------------------
# * Alias
#--------------------------------------------------------------------------
alias bar_initialize_init initialize
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
# Added variables
@magic_casting = false
@sp_used = nil
# Original method execution
bar_initialize_init
end
end
#==============================================================================
# ** Scene_Battle
#==============================================================================
class Scene_Battle
#--------------------------------------------------------------------------
# * Make Skill Action Results
#--------------------------------------------------------------------------
def make_skill_action_result
# Get skill
@skill = $data_skills[@active_battler.current_action.skill_id]
# If not a forcing action
unless @active_battler.current_action.forcing
# If unable to use due to SP running out
unless @active_battler.skill_can_use?(@skill.id)
# Clear battler being forced into action
$game_temp.forcing_battler = nil
# Shift to step 1
@phase4_step = 1
return
end
end
# Use up SP
@active_battler.sp -= @skill.sp_cost
# Set amount used for use with sp bar
@active_battler.sp_used = @skill.sp_cost
# Refresh status window
@status_window.refresh
# Show skill name on help window
@help_window.set_text(@skill.name, 1)
# Set animation ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# Set command event ID
@common_event_id = @skill.common_event_id
# Set target battlers
set_target_battlers(@skill.scope)
# Apply skill effect
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
end
#--------------------------------------------------------------------------
# * Frame Update (main phase step 3 : animation for action performer)
#--------------------------------------------------------------------------
def update_phase4_step3
# Animation for action performer (if ID is 0, then white flash)
if @animation1_id == 0
@active_battler.white_flash = true
else
@active_battler.animation_id = @animation1_id
@active_battler.animation_hit = true
end
# Set flag to update sp bar sprite
if @active_battler.sp_used != nil
@active_battler.magic_casting = true
end
# Shift to step 4
@phase4_step = 4
end
end
Einzig allein, musste ich in der update-Methode von Sprite_HP_Bars eine Zeile ergänzen, welche folgende wäre:
Dadurch wird nur dann die Zeile ausgeführt, wenn der aktuelle @battler ein Gegner ist. Würde die if-Abfrage fehlen, würde es auch für Helden gelten undCode:self.visible = $game_switches[100] if @battler.is_a?(Game_Enemy)
diese würden dann auch eine Anzeigeleiste bekommen (:
@ Kelven
Nee, der Schalter fragt schon vor dem Kampf die Erfüllung einer Bedingung ab, ist also bereits aktiv. Erst dachte ich, eventuell beißt sich etwas mit einem anderen Script, aber die Nachforschung hat mir FlipelyFlip dankenswerterweise erspart.
@ FlipelyFlip
Super, es klappt. :) Und dank deiner Erklärung weiß ich sogar, weshalb. Dann kann ich mich ja jetzt in unbelasteter Leichtfertigkeit auf dynamische Lichteffekte stürzen. Die sind zum Glück nicht nur schick, sondern auch spielmechanisch attraktiv.
Ein riesigesSpiel wie Wolfenhain gerade erst beendet und schon am nächsten Meisterwerk arbeiten. Du bist echt Toll, woher nimmst du nur die Ausdauer?! Und danke, dass du dem Grafikstil treu bleibst! Viel Spaß beim Werkeln, freue mich schon auf das Ergebnis, denn der Trailer macht Lust auf mehr! Grüße ein Fanboy
@ C3lv1c3
Endzeit wird kleiner als "Wolfenhain" oder die "Allreise". Ganz so unverwüstlich bin ich dann doch nicht, als dass ich nach dem gerade fertigen Spielzeitkoloss bereits die Puste für den nächsten hätte. ;)
http://file1.npage.de/002672/73/bild..._bauweisen.png
Eine der angenehme Seiten einer in Europa angesiedelten Endzeit ist die Abkehr von überstrapazierten Bildmotiven. Freiheitsstatue zerdeppert, Wolkenkratzer mal wieder geborstene Stümpfe, dazwischen die immergleichen Funktionsbauten mit flachem Dach und ohne Gesicht. Das ist nicht per se schlimm (ich gucke ja selbst mit unverwüstlichem Beharren solche Filme), aber ein gelegentlicher Ausbruch aus der Standardrotation kann der Postapokalypse neue Eindrücke abgewinnen. Belgien wird seit der Antike besiedelt und mit Eifer bebaut, es hält also genug zum kreativen Kaputtmachen bereit. Da bin ich gerade mit Freude dabei.
Hitze, Druckwelle und Strahlung sind ein vergnügliches Trio, die ich als Einwirkungsfaktoren dem Brüsseler Umland überstülpe und daraus möglichst unterhaltsame Konstellationen entwickle. Interessant wird es auch dann, wenn die Endzeit auf die Bausubstanz des Mittelalters trifft. Wie ist sie denn so, die Postapokalypse in einer Burg? In Europa ist eben auch das Zusammentreffen von modernen Gefahren in klassischen Rollenspielkulissen möglich, woraus ein ganz eigener Charme erwachsen kann.