[script link recovery] XS - Interactive Icon

Archeia

Level 99 Demi-fiend
Developer
Joined
Mar 1, 2012
Messages
15,141
Reaction score
15,473
First Language
Filipino
Primarily Uses
RMMZ
Code:
#==============================================================================
#   XaiL System - Core
#   Author: Nicke
#   Created: 07/01/2012
#   Edited: 08/10/2013
#   Version: 2.1f
#==============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# Core script for XaiL System.
# Caution! This needs to be located before any other XS scripts.
#
# *** Only for RPG Maker VX Ace. ***
#==============================================================================
($imported ||= {})["XAIL-XS-CORE"] = true

module Colors
  #--------------------------------------------------------------------------#
  # * Colors
  #--------------------------------------------------------------------------#
  White = Color.new(255,255,255)
  LightRed = Color.new(255,150,150)
  LightGreen = Color.new(150,255,150)
  LightBlue = Color.new(150,150,255)
  DarkYellow = Color.new(225,225,20)
  Alpha = Color.new(0,0,0,128)
  AlphaMenu = 100
end
module XAIL
  module CORE
  #--------------------------------------------------------------------------#
  # * Settings
  #--------------------------------------------------------------------------#
  # Graphics.resize_screen(width, height )
  Graphics.resize_screen(544,416)
 
  # FONT DEFAULTS:
  Font.default_name = ["VL Gothic"]
  Font.default_size = 20
  Font.default_bold = false
  Font.default_italic = false
  Font.default_shadow = true
  Font.default_outline = true
  Font.default_color = Colors::White
  Font.default_out_color = Colors::Alpha
 
  # USE_TONE = true/false:
  # Window tone for all windows ingame. Default: true.
  USE_TONE = false
 
  # SAVE
  SAVE_MAX = 20       # Default 16.
  SAVE_FILE_VIS = 4   # Default 4.
 
  # JAPANESE = true/false
  JAPANESE = false
 
  end
end
# *** Don't edit below unless you know what you are doing. ***
#==============================================================================#
# ** Game_System
#==============================================================================#
class Game_System
 
  # // Method to determine japanese game.
  def japanese? ; return XAIL::CORE::JAPANESE ; end
 
end
#==============================================================================#
# ** String
#==============================================================================#
class String
 
  def to_class(parent = Kernel)
   # // Method to convert string to class.
   chain = self.split "::"
   klass = parent.const_get chain.shift
   return chain.size < 1 ? (klass.is_a?(Class) ? klass : nil) : chain.join("::").to_class(klass)
   rescue
   nil
  end
 
  def cap_words
   # // Method to capitalize every word.
   self.split(' ').map {|w| w.capitalize }.join(' ')
  end
 
  def slice_char(char)
   # // Method to slice char.
   self.split(char).map {|w| w.sub(char, " ") }.join(" ")
  end

end
#==============================================================================#
# ** Vocab
#==============================================================================#
class << Vocab
 
  def xparam(id)
   # // Method to return xparam name.
   case id
   when 0 ; "Hit Chance"
   when 1 ; "Evasion"
   when 2 ; "Critical Chance"
   when 3 ; "Critical Evasion"
   when 4 ; "Magic Evasion"
   when 5 ; "Magic Reflection"
   when 6 ; "Counter Attack"
   when 7 ; "HP Regeneration"
   when 8 ; "MP Regeneration"
   when 9 ; "TP Regeneration"
   end
  end
 
end
#==============================================================================
# ** Sound
#==============================================================================
class << Sound
 
  def play(name, volume, pitch, type = :se)
   # // Method to play a sound. If specified name isn't valid throw an error.
   case type
   when :se   ; RPG::SE.new(name, volume, pitch).play rescue valid?(name)
   when :me   ; RPG::ME.new(name, volume, pitch).play rescue valid?(name)
   when :bgm  ; RPG::BGM.new(name, volume, pitch).play rescue valid?(name)
   when :bgs  ; RPG::BGS.new(name, volume, pitch).play rescue valid?(name)
   end
  end
 
  def valid?(name)
   # // Method to raise error if specified sound name is invalid.
   msgbox("Error. Unable to find sound file: " + name)
   exit
  end
 
end
#==============================================================================
# ** DataManager
#==============================================================================
class << DataManager

  def savefile_max
   # // Method override, save file max.
   return XAIL::CORE::SAVE_MAX
  end
 
end
#==============================================================================
# ** SceneManager
#==============================================================================
class << SceneManager
 
  def call_ext(scene_class, args = nil)
   # // Method to call a scene with arguments.
   @stack.push(@scene)
   @scene = scene_class.new(args)
  end
 
end
#==============================================================================
# ** Scene_File
#==============================================================================
class Scene_File < Scene_MenuBase
 
  def visible_max
   # // Method override, visible_max for save files.
   return XAIL::CORE::SAVE_FILE_VIS
  end
 
end
#==============================================================================
# ** Window_Base
#------------------------------------------------------------------------------
# Importing font fix that will remove weird characters.
# Adding new methods such as new gauge, actor param, font text, icon drawing,
# big icon drawing and a line with a shadow.
#==============================================================================
class Window_Base < Window
 
  # // Importing Custom font fix. (Credit Lone Wolf).
  alias :process_normal_character_vxa :process_normal_character
  def process_normal_character(c, pos)
   return unless c >= ' '
   process_normal_character_vxa(c, pos)
  end unless method_defined? :process_normal_character
 
  def draw_text_ex_no_reset(x, y, text)
   # // Method to draw ex text without resetting the font.
   text = convert_escape_characters(text)
   pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
   process_character(text.slice!(0, 1), text, pos) until text.empty?
  end
 
  alias xail_core_winbase_upt_tone update_tone
  def update_tone(*args, &block)
   # // Method to change tone of the window.
   return unless XAIL::CORE::USE_TONE
   xail_core_winbase_upt_tone(*args, &block)
  end
 
  def draw_gauge_ex(x, y, width, height, rate, color1, color2)
   # // Method to draw a gauge.
   fill_w = (width * rate).to_i
   gauge_y = y + line_height - 8
   contents.fill_rect(x, gauge_y, width + 1, height + 1, Color.new(255,255,255,64))
   contents.fill_rect(x, gauge_y, width, height, Color.new(0,0,0,100))
   contents.gradient_fill_rect(x, gauge_y, fill_w, height, color1, color2)
  end
 
  def draw_actor_param_gauge(actor, x, y, width, param_id, font, size, bar_color1, bar_color2, txt_color1, txt_color2)
   # // Method to draw actor parameters with a gauge.
   case param_id
   when 2 ; param_rate = actor.param(2) / actor.param_max(2).to_f
   when 3 ; param_rate = actor.param(3) / actor.param_max(3).to_f
   when 4 ; param_rate = actor.param(4) / actor.param_max(4).to_f
   when 5 ; param_rate = actor.param(5) / actor.param_max(5).to_f
   when 6 ; param_rate = actor.param(6) / actor.param_max(6).to_f
   when 7 ; param_rate = actor.param(7) / actor.param_max(7).to_f
   end
   contents.font.name = font
   contents.font.size = size
   contents.font.bold = true
   contents.font.shadow = false
   draw_gauge_ex(x, y - 14, width, 20, param_rate, bar_color1, bar_color2)
   contents.font.color = txt_color1
   draw_text(x + 10, y, 120, line_height, Vocab::param(param_id))
   contents.font.color = txt_color2
   draw_text(x + width - 38, y, 36, line_height, actor.param(param_id), 2)
   reset_font_settings
  end
 
  def draw_actor_xparam_gauge(actor, x, y, width, xparam_id, font, size, bar_color1, bar_color2, txt_color1, txt_color2)
   # // Method to draw actor xparameters with a gauge.
   case xparam_id
   when 0
     xparam_rate = actor.xparam(0) / 100.to_f
     xparam_name = Vocab.xparam(0)
   when 1
     xparam_rate = actor.xparam(1) / 100.to_f
     xparam_name = Vocab.xparam(1)
   when 2
     xparam_rate = actor.xparam(2) / 100.to_f
     xparam_name = Vocab.xparam(2)
   when 3
     xparam_rate = actor.xparam(3) / 100.to_f
     xparam_name = Vocab.xparam(3)
   when 4
     xparam_rate = actor.xparam(4) / 100.to_f
     xparam_name = Vocab.xparam(4)
   when 5
     xparam_rate = actor.xparam(5) / 100.to_f
     xparam_name = Vocab.xparam(5)
   when 6
     xparam_rate = actor.xparam(6) / 100.to_f
     xparam_name = Vocab.xparam(6)
   when 7
     xparam_rate = actor.xparam(7) / 100.to_f
     xparam_name = Vocab.xparam(7)
   when 8
     xparam_rate = actor.xparam(8) / 100.to_f
     xparam_name = Vocab.xparam(8)
   when 9
     xparam_rate = actor.xparam(9) / 100.to_f
     xparam_name = Vocab.xparam(9)
   end
   contents.font.name = font
   contents.font.size = size
   contents.font.bold = true
   contents.font.shadow = false
   draw_gauge_ex(x, y - 14, width, 20, xparam_rate, bar_color1, bar_color2)
   contents.font.color = txt_color1
   draw_text(x + 10, y, 120, line_height, xparam_name)
   contents.font.color = txt_color2
   draw_text(x + width - 38, y, 36, line_height, "#{actor.xparam(xparam_id)}%", 2)
   reset_font_settings
  end
 
  def draw_line_ex(x, y, color, shadow)
   # // Method to draw a horizontal line with a shadow.
   line_y = y + line_height / 2 - 1
   contents.fill_rect(x, line_y, contents_width, 2, color)
   line_y += 1
   contents.fill_rect(x, line_y, contents_width, 2, shadow)
  end
 
  def draw_box(x, y, width, height, color, shadow)
   # // Method to draw a box with shadow.
   contents.fill_rect(x, y, width, height, color)
   x += 1
   y += 1
   contents.fill_rect(x, y, width, height, shadow)
  end
 
  def draw_vertical_line_ex(x, y, color, shadow)
   # // Method to draw a vertical line with a shadow.
   line_x = x + line_height / 2 - 1
   contents.fill_rect(line_x, y, 2, contents_height, color)
   line_x += 1
   contents.fill_rect(line_x, y, 2, contents_height, shadow)
  end
 
  def draw_icons(icons, alignment, x = 0, y = 0, offset_icon = [])
   # // Method to draw icons in a horizonal or vertical alignment.
   icons.each {|icon|
     next if icon.nil?
     # // If included in offset do extra spacing.
     offset_icon.each {|offset|
       if icon == offset
         y += line_height * 1 if alignment == :vertical
         x += line_height * 1 if alignment == :horizontal
       end
     }
     draw_icon(icon.nil? ? nil : icon, x.nil? ? 0 : x, y.nil? ? 0 : y) rescue nil
     y += line_height if alignment == :vertical
     x += line_height if alignment == :horizontal
   }
  end
 
  def draw_big_icon(icon, x, y, width, height, opacity = 255)
   # // Method to draw a big icon.
   bitmap = Cache.system("Iconset")
   rect = Rect.new(icon % 16 * 24, icon / 16 * 24, 24, 24)
   rect2 = Rect.new(x, y, width, height)
   contents.stretch_blt(rect2, bitmap, rect, opacity)
  end
 
  def draw_font_text(text, x, y, width, alignment, font, size, color, bold = true, shadow = true)
   # // Method to draw font text.
   contents.font.name = font
   contents.font.size = size
   contents.font.color = color
   contents.font.bold = bold
   contents.font.shadow = shadow
   contents.font.out_color = Color.new(0,0,0,255)
   draw_text(x, y, width, calc_line_height(text), text, alignment)
   reset_font_settings
  end
 
  def draw_font_text_ex(text, x, y, font, size, color, bold = true, shadow = true)
   # // Method to draw font text ex.
   contents.font.name = font
   contents.font.size = size
   contents.font.color = color
   contents.font.bold = bold
   contents.font.shadow = shadow
   contents.font.out_color = Color.new(0,0,0,255)
   text = convert_escape_characters(text)
   pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
   process_character(text.slice!(0, 1), text, pos) until text.empty?
   reset_font_settings
  end
 
end
#==============================================================================#
# ** Window_Selectable
#------------------------------------------------------------------------------
#  Adding support for pageleft and pageright for window selectable.
#==============================================================================#
class Window_Selectable < Window_Base
 
  def cursor_pageright ; end
  def cursor_pageleft ; end

  alias xail_core_winselect_process_cursor_move process_cursor_move
  def process_cursor_move(*args, &block)
   # // Method to process cursor movement.
   xail_core_winselect_process_cursor_move(*args, &block)
   cursor_pageright if !handle?(:pageright) && Input.trigger?(:RIGHT)
   cursor_pageright if !handle?(:pageleft) && Input.trigger?(:LEFT)
  end
 
  alias xail_core_winselect_process_handling process_handling
  def process_handling(*args, &block)
   # // Method to process handling.
   xail_core_winselect_process_handling(*args, &block)
   return process_pageright if handle?(:pageright) && Input.trigger?(:RIGHT)
   return process_pageleft if handle?(:pageleft) && Input.trigger?(:LEFT)
  end
   
  def process_pageright
   # // Method to process page right.
   Sound.play_cursor
   Input.update
   deactivate
   call_handler(:pageright)
  end
 
  def process_pageleft
   # // Method to process page left.
   Sound.play_cursor
   Input.update
   deactivate
   call_handler(:pageleft)
  end
 
end
#==============================================================================#
# ** Window_Icon
#------------------------------------------------------------------------------
#  New Window :: Window_Icon - A window for drawing icon(s).
#==============================================================================#
class Window_Icon < Window_Base
 
  attr_accessor :enabled
  attr_accessor :alignment
 
  def initialize(x, y, window_width, hsize)
   # // Method to initialize the icon window.
   super(0, 0, window_width, window_height(hsize))
   @icons = []
   @index = 0
   @enabled = true
   @alignment = 0
   refresh
  end
 
  def window_height(hsize)
   # // Method to return the height.
   fitting_height(hsize)
  end
 
  def refresh
   # // Method to refresh the icon window.
   contents.clear
  end
 
  def draw_cmd_icons(icons, index)
   # // Draw all of the icons.
   return if !@enabled
   count = 0
   for i in icons
     align = 0
     x = 110
     next if i[index].nil?
     case @alignment
     when 1, 2 ; align = -110
     end
     draw_icon(i[index], x + align, 24 * count)
     count += 1
     break if (24 * count > height - 24)
   end
  end
 
end
#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
# Adding check item method to return a item based on the type.
#==============================================================================
class Game_Party < Game_Unit
 
  def check_item?(item, type)
   # // Method to return a item based on the type.
   case type
   when :items    ; $data_items[item]
   when :weapons  ; $data_weapons[item]
   when :armors   ; $data_armors[item]
   when :gold     ; item
   when :exp      ; item
   end
  end

end
#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
# Adding methods to check for comments on events.
#==============================================================================
class Game_Event < Game_Character
 
  def comment?(comment)
   # // Method to check if comment is included in event.
   unless empty? or @list.nil?
     for evt in @list
       if evt.code == 108 or evt.code == 408
         if evt.parameters[0].include?(comment)
           return true
         end
       end
     end
   end
   return false
  end
 
  def comment_int?(comment)
   # // Method to check for a integer in event.
   unless empty? or @list.nil?
     for evt in @list
       if evt.code == 108 or evt.code == 408
         if evt.parameters[0] =~ /<#{comment}:[ ]?(\d*)>?/
           return ($1.to_i > 0 ? $1.to_i : 0)
         end
       end
     end
   end
  end
 
  def comment_string?(comment)
   # // Method to check for a string in event.
   unless empty? or @list.nil?
     for evt in @list
       if evt.code == 108 or evt.code == 408
         if evt.parameters[0] =~ /<#{comment}:[ ]?(\w*)>?/
           return $1.to_s
         end
       end
     end
   end
  end


end # END OF FILE

#=*==========================================================================*=#
# ** END OF FILE
#=*==========================================================================*=#

Code:
#==============================================================================
#   XaiL System - Interactive Icons
#   Author: Nicke
#   Created: 29/11/2012
#   Edited: 29/01/2013
#   Version: 1.0c
#==============================================================================
# Instructions
# -----------------------------------------------------------------------------
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ? Materials but above ? Main. Remember to save.
#
# Interactive Icons. Setup a icon on a event by doing the following comment
# inside a event page:
# <CHARACTER_ICON: n>
#
# Example:
# <CHARACTER_ICON: 25> # Set the event to use icon 25. (25 is the icon_index).
#
# Script can be enabled/disabled using a switch and you can also change the
# animation below in the settings.
#
# *** Only for RPG Maker VX Ace. ***
#==============================================================================
($imported ||= {})["XAIL-INT-ICONS"] = true

module XAIL
  module INT_ICONS
  #--------------------------------------------------------------------------#
  # * Settings
  #--------------------------------------------------------------------------#
   # Set the initial default values for every icon sprite.
   # ICON_SPRITE = [ox, oy, z]
   ICON_SPRITE = [12, 34, 200]
   
   # Switch to enable/disable the script.
   # SWITCH = switch_id
   SWITCH = 1
   
   # Control the icon animation here.
   # ANIMATION = [enabled, speed, delay]
   ANIMATION = [true, 7, 60]

  end
end
# *** Don't edit below unless you know what you are doing. ***
#==============================================================================#
# ** Error Handler
#==============================================================================#
  unless $imported["XAIL-XS-CORE"]
   # // Error handler when XS - Core is not installed.
   msg = "The script %s requires the latest version of XS - Core in order to function properly."
   name = "XS - Interactive Icons"
   msgbox(sprintf(msg, name))
   exit
  end
#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character < Sprite_Base

  alias xail_int_icons_spr_char_init initialize
  def initialize(viewport, character = nil)
   # // Method to initialize sprite character.
   # // Define animation delay variable.
   @anim_speed = XAIL::INT_ICONS::ANIMATION[1]
   @anim_delay = XAIL::INT_ICONS::ANIMATION[2]
   @icon_index = 0
   xail_int_icons_spr_char_init(viewport, character)
  end
 
  def draw_character_icon(icon_index)
   # // Method to draw character icon.
   # // First dispose icon if it exists then create a new instance of it.
   dispose_icon
   @icon_sprite = ::Sprite.new(viewport)
   @icon_sprite.bitmap = Cache.system("Iconset")
   @icon_sprite.src_rect = rect = Rect.new(icon_index % 16 * 24, icon_index / 16 * 24, 24, 24)
   @icon_sprite.ox = XAIL::INT_ICONS::ICON_SPRITE[0]
   @icon_sprite.oy = XAIL::INT_ICONS::ICON_SPRITE[1]
   @icon_sprite.z = XAIL::INT_ICONS::ICON_SPRITE[2]
   @icon_sprite.bitmap.blt(@icon_sprite.x, @icon_sprite.y, @icon_sprite.bitmap, @icon_sprite.src_rect, 255)
   update_icon
  end
 
  def icon?
   # // Check if character icon is available and no transparency used.
   @character.icon and !@character.transparent
  end

  alias xail_int_icons_spr_char_upd update
  def update(*args, &block)
   # // Method to update sprite character.
   # // Update routine for the character icons and animation part.
   xail_int_icons_spr_char_upd(*args, &block)
   # // Check if icon should be displayed.
   if $game_switches[XAIL::INT_ICONS::SWITCH]
     # // Update icon sprite.
     update_icon
     # // Do animation based on speed and delay.
     update_icon_animation if XAIL::INT_ICONS::ANIMATION[0]
   else
     dispose_icon
   end
  end
 
  def update_icon
   # // Method to update character icon.
   return dispose_icon unless icon?
   if icon?
     # // Dispose and return if character opacity is equal to 0.
     return dispose_icon if @character.opacity == 0
     # // Draw the character icon based on the icon index.
     draw_character_icon(@character.icon_index) unless @icon_sprite
     # // Dispose icon and redraw it if icon index is changed.
     if @icon_index != @character.icon_index
       @icon_index = @character.icon_index
       dispose_icon
       draw_character_icon(@character.icon_index) unless @icon_sprite
     end
     # // Define icon sprite variables.
     @icon_sprite.x = x
     @icon_sprite.y = y - @icon_sprite.height
     @icon_sprite.z = z + 1
   end
  end
 
  def update_icon_animation
   # // Method to do icon animation. (fading)
   # // Do delay animation.
   if @anim_delay >= 0
     @anim_delay -= 1
   else
     # // Else do animation for icon and reset delay.
     if icon?
       @icon_sprite.opacity -= @anim_speed
       if @icon_sprite.opacity == 0 or @icon_sprite.opacity == 255
         @anim_speed *= -1
         @anim_delay = XAIL::INT_ICONS::ANIMATION[2]
       end
     end
   end
  end
 
  alias xail_int_icons_spr_chr_dispose dispose
  def dispose
   # // Method to dispose sprite chracter.
   # // Dispose the icon.
   dispose_icon
   xail_int_icons_spr_chr_dispose
  end

  def dispose_icon
   # // Method to dispose character icon.
   # // Dispose the icon unless it is nil, set the variable to nil afterwards.
   @icon_sprite.dispose unless @icon_sprite.nil?
   @icon_sprite = nil
  end
   
end
#==============================================================================
# ** Game_CharacterBase
#==============================================================================
class Game_CharacterBase
 
  attr_accessor :icon, :icon_index

  alias xail_int_icons_gm_char_init_public_members init_public_members
  def init_public_members(*args, &block)
   # // Method to init public members.
   xail_int_icons_gm_char_init_public_members(*args, &block)
   @icon = false
   @icon_index = 0
  end
 
end
#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event < Game_Character
 
  alias xail_int_icons_gm_evt_setup_page_settings setup_page_settings
  def setup_page_settings(*args, &block)
   # // Method to setup page settings for the event.
   xail_int_icons_gm_evt_setup_page_settings(*args, &block)
   # // Check comment if it includes character icon index.
   icon = comment_int?("CHARACTER_ICON")
   # // If results is a integer create icon.
   if icon.is_a?(Integer) and !icon.nil?
     @icon = true
     @icon_index = icon
   end
  end
 
  alias xail_int_icons_gm_evt_clear_page_settings clear_page_settings
  def clear_page_settings(*args, &block)
   # // Method to clear page settings for the event.
   xail_int_icons_gm_evt_clear_page_settings(*args, &block)
   @icon, @icon_index = false, 0
  end
   
end # END OF FILE

#=*==========================================================================*=#
# ** END OF FILE
#=*==========================================================================*=#
 

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,868
Messages
1,017,066
Members
137,576
Latest member
SadaSoda
Top