Show posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Topics - Jaiden

1
RMXP Script Database / [XP] Extra Fogs & Panorama Lock
October 22, 2019, 01:27:01 pm
Extra Fogs & Panorama Lock
Authors: Jaiden
Version: 1.0
Type: Mapping Enhancement
Key Term: Environment Add-on

Introduction

This is a script that I've used to enhance XP's mapping even further. It allows for an additional fog that is exclusive to the map ID instead of the tileset, plus an additional two fogs: one drawn as a "lightmap" to add lighting effects and one drawn as a "parallax" (like RMVXA's parallax mapping) to add additional little details to the map like vegetation, etc.

Lastly, there is an option to lock the panorama (background image) of a map so it can also be used as a ground layer, effectively giving you two more layers to work with if you know how to drive it.

I've included a demo to help solidify the concept a bit. Note that you will still need to understand how to make parallaxes and lightmaps in GIMP/Photoshop. There are lots of tutorials on this--this script just makes it much easier to apply them.

Features

  • Allows for an additional fog, which is per map instead of per tileset
  • Allows a panorama to lock so it doesn't scroll, allowing it to be used as a ground layer
  • Designated fog for parallax/detail mapping
  • Designated fog for lighting overlay

Screenshots

Nothing to show here, just try the demo if you'd like.

Demo

https://drive.google.com/open?id=1z6Xas94VmIQca1KVA1T_BbLssb_C3l4w

Script

Place this script above main just as you would any other custom script.
Spoiler: ShowHide

#==============================================================================
# Extra Fogs & Panorama Lock
# - - -
# By Jaiden (RPGmaker.net / rpgmakerweb.com)
# (Twitter: @studioalemni)
# v1.0 - September 2019
# * Allows for an additional fog, which is per map instead of per tileset
# * Allows a panorama to lock so it doesn't scroll, allowing it to be used
#  as a ground layer
#  (Thanks to Game_Guy from www.chaos-project.com for help on this)
# * Designated fog for parallax/detail mapping
# * Designated fog for lighting overlay
#
# [[Compatibility]]
# This script aliases the Spriteset_Map class. Place it above main
# like any other custom script.
# It hasn't been extensively tested, but should otherwise play nicely
# with other map scripts.
#
# [[How to Use]]
# The "fogs" folder should contains two subfolders:
# /Fogs/Lightmaps
# /Fogs/Parallax
#
# In these folders, place a file named "Map[MAPID]", such as "Map002.png"
# If the file is detected, it will be applied to the map.
#
# ***NOTE: In order to get the desired effect, these files MUST be the same size
# as the map they're applied to. If they are not, the panorama/lights will not
# match up with the tilemap / player.
#
# Lightmaps will always have subtractive blending, and "parallax" will always
# be drawn above the ground layer but below the player. This means the player
# can always walk over items in the parallax, and is best reserved for things
# like vegetation, etc.
#
#==============================================================================
module CustomFogsPanorama
  def self.fogs(map_id)
    case map_id
    #==============================================================================
    #
    # BEGIN CONFIGURATION
    #
    # When a fog is specified here, it will be drawn in addition to the
    # already existing map fog.
    #
    # Configuration values are identical to that of the editor.
    # Please follow the format exactly, and do not modify the "else"
    # or the lines below it. Mind your commas!
   
    # when MAPID then ["Name", Zoom_x (%), Zoom_y (%), Opacity (0-255), Blend (0:norm, 1:add, 2:sub), Tone.new(r,g,b), scroll x, scroll y]
      when 1 then ["003-Shade01", 100, 100, 50, 2, Tone.new(0,0,0), -1, 5]
    # when 2 then ["Fog Name", 100, 100, 255, 2, Tone.new(0,0,0), 0, 0]
   
    #
    #---- End Extra Fog Config -------------------------------------------------
    else
      [""]
    end
  end
  #--------------------------------------------------------------------------
  # * Lock Panorama
  #
  # Specify a list of map IDs that will stop the panorama from scrolling
  # Separated by commas: [ID, ID, ID]
  #
  LOCK_PANORAMA_IDS = [2]
#
# END CONFIGURATION
# (Do not modify below this line unless you know what you're doing!)
#
#==============================================================================
end


class Game_Map
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :parallax_lock
  attr_accessor :fog2_ox
  attr_accessor :fog2_oy
  #--------------------------------------------------------------------------
  # * Setup
  #    map_id : map ID
  #--------------------------------------------------------------------------
  alias jaiden_parallax_map_setup setup
  def setup(map_id)
    # Call original
    jaiden_parallax_map_setup(map_id)
    # Initialize fog variables
    @fog2_ox = 0
    @fog2_oy = 0
    # Get fog sx/sy
    @fog2 = CustomFogsPanorama.fogs(@map_id)
    @fog2_sx = @fog2[6]
    @fog2_sy = @fog2[7]
    # Check if map_id includes parallax
    if CustomFogsPanorama::LOCK_PANORAMA_IDS.include?(@map_id)
      @parallax_lock = true
    else
      @parallax_lock = false
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias jaiden_second_fog_update update
  def update
    # Call original / aliases
    jaiden_second_fog_update
    # Manage fog scrolling
    if @fog2[0] != ""
      @fog2_ox -= @fog2_sx / 8.0
      @fog2_oy -= @fog2_sy / 8.0
    end
  end
end

class Spriteset_Map
  #--------------------------------------------------------------------------
  # * Initialize
  #--------------------------------------------------------------------------
  alias jaiden_lights_initialize_spritemap initialize
  def initialize
    # Call original
    jaiden_lights_initialize_spritemap
    # Reassign fog plane if a custom one is assigned
    second_fog = CustomFogsPanorama.fogs($game_map.map_id)
    if second_fog[0] != ""
      @fog2 = Plane.new(@viewport1)
      @fog2.bitmap = RPG::Cache.fog(second_fog[0], 0)
      @fog2.zoom_x = second_fog[1] / 100.0
      @fog2.zoom_y = second_fog[2] / 100.0
      @fog2.opacity = second_fog[3]
      @fog2.blend_type = second_fog[4]
      @fog2.tone = second_fog[5]
      @fog2.z = 3500
    end
    # Create parallax (unlike panorama, this overlays the map and should always = map size)
    if FileTest.exist?("Graphics/Fogs/Parallax/Map#{$game_map.map_id}.png")
      @parallax = Plane.new(@viewport1)
      @parallax.bitmap = RPG::Cache.fog("/Parallax/Map#{$game_map.map_id}", 0)
      @parallax.blend_type = 0 # Normal blending
      @parallax.opacity = 255
      @parallax.ox = $game_map.display_x / 4
      @parallax.oy = $game_map.display_y / 4
    end
    # Create lightmap (above everything else)
    if FileTest.exist?("Graphics/Fogs/Lightmaps/Map#{$game_map.map_id}.png")
      @lightmap = Plane.new(@viewport1)
      @lightmap.z = 4000 
      @lightmap.bitmap = RPG::Cache.fog("/Lightmaps/Map#{$game_map.map_id}", 0)
      @lightmap.blend_type = 2 # Subtractive blending
      @lightmap.opacity = 255
      @lightmap.ox = $game_map.display_x / 4
      @lightmap.oy = $game_map.display_y / 4
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  alias jaiden_lights_dispose_spritemap dispose
  def dispose
    @fog2.dispose if @fog2
    @parallax.dispose if @parallax
    @lightmap.dispose if @lightmap
    # Call original
    jaiden_lights_dispose_spritemap
  end 
  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  alias jaiden_lights_spriteset_update update
  def update
    # Update second fog
    if @fog2
      @fog2.ox = $game_map.display_x / 4 + $game_map.fog2_ox
      @fog2.oy = $game_map.display_y / 4 + $game_map.fog2_oy
    end
    # Update parallax
    if @parallax
      @parallax.ox = $game_map.display_x / 4
      @parallax.oy = $game_map.display_y / 4
    end
    # Update lightmap
    if @lightmap
      @lightmap.ox = $game_map.display_x / 4
      @lightmap.oy = $game_map.display_y / 4
    end
    # Call original / aliased methods
    jaiden_lights_spriteset_update
    # Check for locked parallax
    if $game_map.parallax_lock
      @panorama.ox = $game_map.display_x / 4
      @panorama.oy = $game_map.display_y / 4
    else
      @panorama.ox = $game_map.display_x / 8
      @panorama.oy = $game_map.display_y / 8
    end
  end
end


Instructions

Please see the script for instructions, or check out the demo.

Compatibility

This script aliases the Spriteset_Map class. Place it above main like any other custom script.
It hasn't been extensively tested, but should otherwise play nicely with other map scripts.

Credits and Thanks

  • Game_Guy (for helping with the parallax lock)

Author's Notes

Feel free to let me know if there are any bugs. Commercial use is OK, but I would really appreciate it if you credited me (and showed me what kind of awesome game you're making with it!)

I made this script specifically for use in my game Legends of Astravia. Consider supporting it if you were happy with this script!
2
RMXP Script Database / [XP] Audio Extras
February 05, 2019, 12:15:26 pm
Audio Extras
Authors: Jaiden
Version: 1.2
Type: Game System Utility
Key Term: Misc Add-on




Introduction

This script contains a few extra audio functions, and thanks to RPG Maker XP Ace, includes a feature that was only available via RGSS3.

Note that you must have RPG Maker XP Ace installed in order to use the "Pause/Resume BGM" feature of this script.
You can get it here: https://forum.chaos-project.com/index.php/topic,12899.0.html

Otherwise, only the master volume and map volume change features will be available.




Features

  • Ability to pause and resume BGM at the position it was paused [RGSS3/XPA ONLY]

  • Master volume controls for BGM, BGS, and SE

  • Automatic BGM/BGS volume decrease when entering "houses" or any other marked map




Screenshots

Not relevant to the script.


Demo

None at this time.


Script
Spoiler: ShowHide

#==============================================================================
# Audio Extras [+Additional Features with XPA]
# Author: Jaiden
# Version 1.2 - Feb 6th, 2019
#   - Changed the script so it would work in either vanilla RMXP or XPA.
# Version 1.1 - Feb 5th, 2019
#   - Fixed a typo in the directions
#   - Shortened the "change_bgm/bgs/se_volume" methods to "change_bgm/bgs/se_vol"
#     so they would be friendlier with script calls.
# Version 1.0 - Feb 4th, 2019
#   - Initial release
# ---------------------------------------------------------------------------
# This script includes a few small audio features, as well as a special
# functionality to pause and resume an audio track if paired with
# RPG Maker XP Ace.
#
# Features:
# -> Ability to pause and resume an audio track at any point [RGSS3/XPA ONLY]
# -> Decreasing the volume of BGM/BGS when entering / exiting buildings
# -> Master volume for decreasing and increasing all tracks throughout the game
#
# [[NOTE]]
# The pause/resume audio feature is only available through an audio method
# from RGSS3 (RPG Maker XP ACE). Because of this, that feature will only
# work if you are running the RPG Maker XP Ace.
#
# For more information on RPG Maker XP ACE, visit this thread:
# https://forum.chaos-project.com/index.php?topic=12899.0
#
# This script is not intended for use in RPG Maker VX or VXA.
#
# ---------------------------------------------------------------------------
# ** Instructions:
# ---------------------------------------------------------------------------
# [XPA ONLY]
# -> To "Pause" the BGM at the current position, use the following script call:
#
#    AudioExtras.save_bgm
#
# [XPA ONLY]
# -> To "Resume" a saved BGM track, use the following script call:
#
#    AudioExtras.resume_bgm
#
# Note that this function does not support MIDI; they will always resume from the beginning.
# ---------------------------------------------------------------------------
#
# -> To mark a map as "Indoors" and automatically decrease the volume,
#
#    Use the following tag in your maps: [ind]
#
# For example, a map named "[ind]Inside House" will have its volume
# lowered when you enter it. Note that the "[ind]" is automatically removed
# from the map name to avoid conflict with map name display scripts.
#
# Note that when the player moves from the next map without an [ind] tag,
# the volume will increase back to the original level.
#
# -> To disable changing the volume level even when a map is marked [ind],
#
#   Set a switch with the same ID set in the configuration below.
#
# This is useful for cutscenes where you change the audio track, but don't want
# the volume to increase or decrease further when the player changes maps.
#
# ---------------------------------------------------------------------------
# ** Additional Features:
# ---------------------------------------------------------------------------
# This script also gives access to a master volume control, which can be
# used to control the overall game volume, such as via events or a menu.
#
# -> The follow values are responsible for the master volume:
#
#    AudioExtras.bgm_volume
#    AudioExtras.bgs_volume
#    AudioExtras.se_volume
#
# -> You can set the master volume to any value (0 to 100):
#
#    AudioExtras.bgm_volume = VALUE
#    AudioExtras.bgs_volume = VALUE
#    AudioExtras.se_volume = VALUE
#
# -> Conversely, if you would like to INCREMENT/DECREMENT the value (-100 to 100):
#
#    AudioExtras.change_bgm_vol = VALUE
#    AudioExtras.change_bgs_vol = VALUE
#    AudioExtras.change_se_vol = VALUE
#
# This is useful when creating volume controls in-game where you want
# to change the master volume by a set amount.
#
# For example to set the BGM volume to 80%, you would use:
#
#   AudioExtras.bgm_volume = 80
#
# But if you wanted to DECREASE the SE volume by 20%, you would use:
#
#   AudioExtras.change_se = -20
#
#==============================================================================
  module AudioExtras
  # ======================== # BEGIN CONFIGURATION # ========================= 
 
    # Switch ID to disable decreasing the game volume when entering a house
    DISABLE_BGM_CHANGE = 14
 
    # Level (as a percentage) to decrease the volume when going indoors.
    # The default value is 20%
    LEVEL_DECREASE = 20
 
  #
  # = Please do not edit below this line unless you know what you are doing. =
  #
  # ======================== # END CONFIGURATION # ===========================
    # Skip these methods if running RGSS1
    unless defined?(Hangup)
      def self.save_bgm
        # Save the currently playing BGM 
        $game_system.bgm_save if !$game_system.playing_bgm.nil?
      end
     
      def self.resume_bgm
        # Resume the saved BGM
        $game_system.bgm_resume
      end
    end
    # End Skip
 
    def self.bgm_volume
      $game_system.bgm_master_vol
    end
 
    def self.bgs_volume
      $game_system.bgs_master_vol
    end
 
    def self.se_volume
      $game_system.se_master_vol
    end
 
    def self.bgm_volume=(value)
      # Set the master BGM volume
      $game_system.bgm_master_vol = [[value, 0].max, 100].min
      # Set new BGM if playing
      if $game_system.playing_bgm != nil
        $game_system.bgm_play($game_system.playing_bgm)
      end 
    end
   
    def self.bgs_volume=(value)
      # Set the master BGS volume
      $game_system.bgs_master_vol = [[value, 0].max, 100].min
      # Set new BGS if playing
      if $game_system.playing_bgs != nil
        $game_system.bgs_play($game_system.playing_bgs)
      end 
    end
 
    def self.se_volume=(value)
      # Set the master SE volume
      $game_system.se_master_vol = [[value, 0].max, 100].min
    end
 
    def self.change_bgm_vol=(value)
      # Increment / Decrement the BGM volume
      $game_system.bgm_master_vol = $game_system.bgm_master_vol + value
      # Ensure the value isn't higher than 100 or lower than 0
      $game_system.bgm_master_vol = [[$game_system.bgm_master_vol, 0].max, 100].min
      # Set new BGM if playing
      if $game_system.playing_bgm != nil
        $game_system.bgm_play($game_system.playing_bgm)
      end     
    end
 
    def self.change_bgs_vol=(value)
      # Increment / Decrement the BGM volume
      $game_system.bgs_master_vol = $game_system.bgs_master_vol + value
      # Ensure the value isn't higher than 100 or lower than 0
      $game_system.bgs_master_vol = [[$game_system.bgs_master_vol, 0].max, 100].min
      # Set new BGS if playing
      if $game_system.playing_bgs != nil
        $game_system.bgs_play($game_system.playing_bgs)
      end 
    end
 
    def self.change_se_vol=(value)
      # Increment / Decrement the BGM volume
      $game_system.se_master_vol = $game_system.se_master_vol + value
      # Ensure the value isn't higher than 100 or lower than 0
      $game_system.se_master_vol = [[$game_system.se_master_vol, 0].max, 100].min
    end
  end
 
 
  #==============================================================================
  # ** Game_System
  #------------------------------------------------------------------------------
  #  This class handles data surrounding the system. Backround music, etc.
  #  is managed here as well. Refer to "$game_system" for the instance of
  #  this class.
  #==============================================================================
  class Game_System
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :bgm_master_vol  # store bgm volume
    attr_accessor :bgs_master_vol  # store sfx volume
    attr_accessor :se_master_vol   # store se volume
    attr_accessor :saved_bgm_vol   # Saves the BGM volume
    attr_accessor :saved_bgs_vol   # Saves the BGS volume
    #--------------------------------------------------------------------------
    # * Object Initialization
    #--------------------------------------------------------------------------
    alias system_options_jaiden_initialize initialize
    def initialize
      system_options_jaiden_initialize
      # Initialize volume settings
      @bgm_master_vol = 100
      @bgs_master_vol = 100
      @se_master_vol = 100
      @saved_bgm_vol = nil
      @saved_bgs_vol = nil
    end
    #==========================================================================
    # The following methods for playing music and sounds have been REWRITTEN
    #--------------------------------------------------------------------------
    # * Play Background Music
    #--------------------------------------------------------------------------
    def bgm_play(bgm)
      @playing_bgm = bgm
      if bgm != nil and bgm.name != ""
        Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume * @bgm_master_vol / 100, bgm.pitch)
      else
        Audio.bgm_stop
      end
      Graphics.frame_reset
    end
    #--------------------------------------------------------------------------
    # * Play Background Sound
    #--------------------------------------------------------------------------
    def bgs_play(bgs)
      @playing_bgs = bgs
      if bgs != nil and bgs.name != ""
        Audio.bgs_play("Audio/BGS/" + bgs.name, bgs.volume * @bgs_master_vol / 100, bgs.pitch)
      else
        Audio.bgs_stop
      end
      Graphics.frame_reset
    end
    #--------------------------------------------------------------------------
    # * Play Music Effect
    #--------------------------------------------------------------------------
    def me_play(me)
      if me != nil and me.name != ""
        Audio.me_play("Audio/ME/" + me.name, me.volume * @se_master_vol / 100, me.pitch)
      else
        Audio.me_stop
      end
      Graphics.frame_reset
    end
    #--------------------------------------------------------------------------
    # * Play Sound Effect
    #     se : sound effect to be played
    #--------------------------------------------------------------------------
    def se_play(se)
      if se != nil and se.name != ""
        Audio.se_play("Audio/SE/" + se.name, se.volume * @se_master_vol / 100, se.pitch)
      end
    end
    # Skip these methods if running RGSS1
    unless defined?(Hangup)
      #--------------------------------------------------------------------------
      # * Memorize BGM
      #--------------------------------------------------------------------------
      def bgm_save
        @memorized_bgm = @playing_bgm
        @position = Audio.bgm_pos
      end
      #--------------------------------------------------------------------------
      # * Resume memorized bgm
      #--------------------------------------------------------------------------
      def bgm_resume
        bgm = @memorized_bgm
        return if @position.nil? || bgm.nil? || bgm.name == ""
        Audio.bgm_play("Audio/BGM/" + bgm.name, bgm.volume * @bgm_master_vol / 100, bgm.pitch, @position)
      end
    end
    # End Skip
  end
 
 
  #==============================================================================
  # ** Game_Map
  #==============================================================================
  class Game_Map
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_reader    :is_house # Determines if the map is a house
    attr_accessor  :name     # Map name
    #--------------------------------------------------------------------------
    # * Initialize
    #--------------------------------------------------------------------------
    alias jaiden_house_initialize initialize
    def initialize
      jaiden_house_initialize
      @name = ""
    end
    #--------------------------------------------------------------------------
    # * Setup
    #     map_id : map ID
    #--------------------------------------------------------------------------
    alias jaiden_house_setup setup
    def setup(map_id)   
      jaiden_house_setup(map_id)
      # Store the map name
      @name = get_name(map_id)
      # Determine if it's a house, strip the name if it is.=
      @is_house = !self.name.scan(/\[ind\]/i).first.nil?
      self.name.gsub!(/\[ind\]/i, '')
    end
    #--------------------------------------------------------------------------
    # * Get name
    # Get the map name
    #-------------------------------------------------------------------------- 
    def get_name(id = @map_id)
      map_info = load_data("Data/MapInfos.rxdata")
      return map_info[id].name
    end
    #--------------------------------------------------------------------------
    # * Automatically Change Background Music and Backround Sound < needs to move to scene_map
    #--------------------------------------------------------------------------
    def setup_house_bgm
      # If the map is indoors
      if @is_house
        # And we didn't already reduce the volume
        if $game_system.saved_bgm_vol.nil?
          # Save the current volume
          $game_system.saved_bgm_vol = $game_system.bgm_master_vol
          # Decrease the volume
          AudioExtras.change_bgm_vol = -AudioExtras::LEVEL_DECREASE
        end
        if $game_system.saved_bgs_vol.nil?
          # Save the current volume
          $game_system.saved_bgs_vol = $game_system.bgs_master_vol
          # Decrease the volume
          AudioExtras.change_bgs_vol = -AudioExtras::LEVEL_DECREASE
        end
      # If the map is not outdoors
      elsif
        # And there is a saved volume
        unless $game_system.saved_bgm_vol.nil?
          # Set the master volume to the saved volume
          AudioExtras.bgm_volume = $game_system.saved_bgm_vol
          # Clear the saved volume
          $game_system.saved_bgm_vol = nil
        end
        unless $game_system.saved_bgs_vol.nil?
          # Set the master volume to the saved volume
          AudioExtras.bgs_volume = $game_system.saved_bgs_vol
          # Clear the saved volume
          $game_system.saved_bgs_vol = nil
        end
      end
    end
  end
  #==============================================================================
  # ** Scene_Map
  #==============================================================================
  class Scene_Map
    alias jaiden_house_transfer transfer_player
    def transfer_player
      jaiden_house_transfer
      # Check if BGM changing is disabled
      unless $game_switches[AudioExtras::DISABLE_BGM_CHANGE]
        $game_map.setup_house_bgm
      end
    end
  end




Instructions

Install this script above main as you would any other script.

If you create an options menu that controls the master volume, make sure this script is ABOVE that menu.

See the script for directions on how to use this script. Note that the pause and resume function will not work with MIDI (it can be used, but the MIDI will always start from the beginning).


Compatibility

This script makes modifications to the Game_System class, including re-writing the "bgm/bgs/se_play" methods. Use with caution with any other audio scripts.

As noted above, this script has a feature that will only be accessible if used with RPG Maker XP Ace. This is highly recommended.



Credits and Thanks

  • KK20, as always, for helping me make it not-garbage.





Author's Notes
I created this script for my game, Legends of Astravia, but I figured anyone else using XPA would love to have access to these functions.

I may create an options menu that goes along with this at a later time! Let me know if you run into any bugs.
3
RMXP Script Database / [XP] "Inspect" Event Animation
October 01, 2018, 11:14:56 pm
"Inspect" Event Animation
Authors: Jaiden, KK20
Version: 2.0
Type: Event Feature
Key Term: Environment Add-on



Introduction

Do you want to indicate that an event can be interacted with using a nifty animation? This is the script for you! Similar to how most games have some sort of a "press to interact" indicator, this script displays an animation when the player is facing events you've marked for "inspection".


Features


  • Easy to select which event / event page to display on

  • Animation displayed is customizable

  • Should be reasonably compatible with most scripts




Screenshots

Gif example using a custom animation:
Spoiler: ShowHide



Demo

(N/A)


Script

Spoiler: ShowHide

#==============================================================================
# Inspect Event
# by Jaiden, KK20 (mostly KK20)
# v2.0 March 2019
# - Added the capability to configure the inspect direction
# - KK20 fixed all that logic 'cuz it was bad
# v1.0 September 2018
# - Initial release
#==============================================================================
# Checks if an event is flagged for "inspection" and displays an
# animation above the player indicating it can be interacted with.
# -----
# This script aliases methods in the following classes:
# * Game_Character
# * Game_Event
# * Game_Map
# * Sprite_Character
# It may not be compatible with other scripts that have heavily
# modified these classes
#==============================================================================
# HOW TO USE THIS SCRIPT
# -----
# Create a comment with the text \inspect_event in the page of
# an event that you want to have display an animaton over the player when
# they are facing it. Then, set the animation ID below.
#
# [Multiple Directions]
# You can also set specific directions that will trigger the animation.
# Assuming the player is 0, imagine the directions like this:
#    8
# 4  0  6
#    2
#
# For example, \inspect_event[4,6] will only display the animation when
# the player is facing the event from the left and right.
# Use \inspect_event[0] to only display when the player is on top of the event.
#
# Specifying no direction will show the animation when the player faces
# the event from any direction.
#==============================================================================
module InspectEvent
  #--------------------------------------------------------------------------
  # Animation ID
  #--------------------------------------------------------------------------
  # Set this value to the ID in your animation database that you want
  # to display to indicate that an event can be inspected
  EVENT_ANIMATION_ID = 120
  #--------------------------------------------------------------------------
end
#==============================================================================
# END CONFIGURATION / DOCUMENTATION
#==============================================================================

#==============================================================================
# ** Game_Character
#==============================================================================
class Game_Character
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  # inspect_event - flags an event for interation
  # inspect_dir_flags - Array of directions for inspection
  #   0 = Center (animation displays when player is on the event)
  #   4 = Left
  #   8 = Above
  #   6 = Right
  #   2 = Below
  # animation_loop_id - id for a looped animation
  #--------------------------------------------------------------------------
  attr_accessor    :inspect_event
  attr_accessor    :inspect_dir_flags
  attr_accessor    :animation_loop_id
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  alias inspect_event_initialize initialize
  def initialize
    inspect_event_initialize
    # Flag to determine if an event can be inspected
    @inspect_event = false
    # Array of directions
    @inspect_dir_flags = []
    # ID for looped animations
    @animation_loop_id = 0
  end
end

#==============================================================================
# ** Game_Event
#==============================================================================
class Game_Event
  alias inspect_event_refresh refresh
  def refresh
    prev_page = @page
    # Call original
    inspect_event_refresh
    return if prev_page == @page
    # Initialize flags
    @inspect_event = false
    # Initialize direction array
    @inspect_dir_flags = []
    # Check each list item for a comment
    return if @list.nil?
    @list.each do |cmd|
      # Check if it's a comment
      if cmd.code == 108
        # Set comment
        comment = cmd.parameters[0]
        comment_check = comment.scan(/^\\inspect_event/).flatten[0]
        # Check if the comment contains the string "\inspect_event"
        if comment_check == "\\inspect_event"
          # Flag it
          @inspect_event = true
          # Set directional array
          @inspect_dir_flags = comment.scan(/(\d)+/).flatten
          # Convert to ints
          @inspect_dir_flags.map!{|c| c.to_i}
          break
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Check if player is adjacent to and facing an event
  # directions = an array containing the different directions to register
  # the animation by returning true:
  #    8
  # 4  0  6
  #    2
  #--------------------------------------------------------------------------
  def player_facing?(directions = @inspect_dir_flags)
    # Exit if we're not checking directions
    return false if directions.nil?
    # Initialize variable
    check = false
    # Test each direction
    case $game_player.direction
    when 2 # Facing down
      if directions.include?(8) || directions == [] # Player is above event
        check = (self.y == $game_player.y + 1 && self.x == $game_player.x)
      else
        check = false
      end
    when 4 # Facing left
      if directions.include?(6) || directions == [] # Player is right of event
        check = (self.x == $game_player.x - 1 && self.y == $game_player.y)
      else
        check = false
      end
    when 6 # Facing right
      if directions.include?(4) || directions == [] # Player is left of event
        check = (self.x == $game_player.x + 1 && self.y == $game_player.y)
      else
        check = false
      end
    when 8 # Facing up
      if directions.include?(2) || directions == [] # Player is below event
        check = (self.y == $game_player.y - 1 && self.x == $game_player.x)
      else
        check = false
      end
    end
    # Check for 0 (player on event)
    if directions.include?(0)
      check = (self.y == $game_player.y && self.x == $game_player.x)
    end
    return check
  end
end
#==============================================================================
# ** Game_Map
#==============================================================================
class Game_Map
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias inspect_event_map_update update
  def update
    # Call original
    inspect_event_map_update
    # Call animation method
    inspect_event_anim
  end
  #--------------------------------------------------------------------------
  # * Inspect Event Animation
  #--------------------------------------------------------------------------
  def inspect_event_anim
    if $game_player.moving?
      $game_player.animation_loop_id = 0
      return
    end
   
    @events.values.each do |event|
      next unless event.inspect_event
      next if (event.x - $game_player.x).abs + (event.y - $game_player.y).abs > 1
      if event.player_facing?
        $game_player.animation_loop_id = InspectEvent::EVENT_ANIMATION_ID
        return
      end
    end
    $game_player.animation_loop_id = 0

  end
end

#==============================================================================
# ** Sprite_Character
#==============================================================================
class Sprite_Character
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  alias inspect_event_character_update update
  def update
    # Call original
    inspect_event_character_update
    # Set loop animation (not if message windows are showing)
    if $game_temp.message_window_showing == true
      loop_animation(nil)
    elsif @character.animation_loop_id != 0
      anim = $data_animations[@character.animation_loop_id]
      loop_animation(anim)
    else
      loop_animation(nil)
    end
  end
end



Instructions

Instructions are in the script, but it is as simple as putting a comment with "\inspect_event" in the event page you want the animation to display on. Note that the default animation used, "EM Exclamation" plays a sound every time it is looped. I suggest creating a new, silent animation and setting its ID in the configuration.


Compatibility

This script aliases the Game_Map, Game_Event, Game_Character and Sprite_Character classes. This will not be compatible with any scripts that heavily re-write those classes.


Credits and Thanks


  • KK20 for helping with 90% of this

  • Everyone else in the Discord server for helping out and/or dealing with my ramblings




Author's Notes

This is my first script. I figured I'd make a contribution back to Chaos Project since this community has been so helpful in my game's development. Hopefully this script treats someone else just as well!

Credit for this script isn't required, but greatly appreciated, with the exception of redistribution. If you post this script elsewhere, please link back to this original post.
4
Script Troubleshooting / [RMXP] Battlebacks
November 14, 2017, 08:05:56 pm
All set on this now, but I'll leave it for future reference so someone else doesn't do what I did.

RPG Maker XP default battlebacks are not 640x480. If you use them with a transparent window, you won't notice the transparency! Took me hours to figure that one out, derp.




5
Script Troubleshooting / Understanding Aliases
November 08, 2017, 01:56:38 pm
I've done some reading on aliases and understand (somewhat) how they work, but there is still something I don't understand:

When looking at an alias method, I've noticed the method appears within the alias, but I'm not sure I correctly understand it's function in relation to its placement, as I've seen it both ways. For example:

alias superduper_update_target update_target
def update_target
   #some code
   #goes here
   superduper_update_target
end


vs

alias superduper_update_target update_target
def update_target
   superduper_update_target
   #some code
   #goes here
end


Does this determine where in the original "update_target" method the code is placed? In this case, the first method places the new code above the original method, and the second method places the new code below the original method, or is it visa versa?

Thanks guys.





6
Projects / Games / Legends of Astravia
November 06, 2017, 01:42:43 pm

Dive into Astravia, a world torn by magic and brimming with bold quests,
engaging battles, and compelling secrets.





Legends of Astravia
is a story-driven role-playing game built on engaging battles and fulfilling exploration.
It takes its inspiration from Japanese-style RPGs like Golden Sun, Chrono Trigger, and Grandia.

The game starts off in Mordin, bordered by swamps and forests on the western edge of Astravia.
You play as Oliver, discovered unconscious by a mysterious magic user--known in the world of Astravia as mysticians--named Azel.

He considers you a suspect behind the breach of a local magic sanctuary,
but offers you the opportunity to prove yourself innocent as you journey there together,
taking care to avoid the ruthless knights that stalk the woods...






Engaging, character-driven storyline that will keep you attached until the end.

Entirely custom "Action Time Battle" system--with a completely unique twist.

Plenty of monsters, but no random encounters! You choose your own battles.

8-direction pixel movement that makes moving and exploring feel great.

Multiple party members with individual combat styles, stories, and secrets.

Various dungeons, caves, and towns to explore with unique puzzles and characters.

Many side-quests with special rewards.

Crafting / enchantment system for weapons, equipment, and items.







Spoiler: ShowHide


















Centuries ago, before calm villages and thriving cities,
we were fated to perish at the brink of an inevitable apocalypse.

The ground quaked with terror as the day of reckoning
manifested--the air burned with the sick certainty of death...

...and we begged to the Gods that our world would not be taken from us.

It was then that two figures appeared, casting their shadows across the horizon
and blotting out the sun. In awe of their presence, the ground went still
and the fires went silent--order returning to Astravia once more.

Hailed as legends from those who survived the Cataclysm, the First Shadow
was generous and powerful, but the Second Shadow was neither.
The two performed miracles said to be as dangerous as the
Cataclysm itself, digging seas with the wave of their hands,
shaping mountains with their shouts, and growing forests with only a whisper.

Perhaps their greatest feat, however, was their ability to
take the form of whatever they pleased.

And when the two Shadows grew tired of admiration,
they took the forms of mortals and vanished into myth.

The remnants of their power...the
Essence of their divinity, is all that remains to us.





Currently, there is no download available. Stay tuned for v3.0!




FULL GAME CREDITS
You can also follow me on Twitter or join the official Discord server for updates and occasional easter eggs and progress images I don't post anywhere else.

Want to contact me privately? You can PM here, but I may not see it. Feel free to message me on Discord (Jaiden#5195), or email me directly.
7
Script Requests / Sprite Opacity "Glow"
November 04, 2017, 05:48:35 pm
I am having a hard time understanding how to properly use the sprite class. Long story short, I am using sprites on the title screen instead of a command window to display selections. I'd like to have a custom cursor that fades in and out (like the window cursor), but using a custom bitmap instead of a rectangle.

How would I make a sprite fade in and out? I understand this would use the "update" method, I considered using a for loop like so:
#Assuming @com is the sprite bitmap for the "selection" sprite...
for i in 1...17
if @com.opacity > 0
@com.opacity = 255 - i * 15
elsif @com.opacity < 255
@com.opacity = 0 + i * 15
end
end


But I assumed this is just...bad logic. Thoughts?
8
Script Troubleshooting / [Resolved] Blank Error
November 02, 2017, 11:13:35 am
So I have found sometimes I get a blank error message when editing scripts. I assume it means "you messed up so bad even the engine doesn't know what's wrong":


But I'm curious if there is actually an explanation? It generally makes troubleshooting a bear unless I've paid attention to the changes I've made. Is it related to the stack?
I noticed I've seen it appear with events most often, but this current case is related to gaining EXP at the end of battle, and I believe it may be a recursion issue.

Also, the problem script, if someone would like to help. I am trying to figure out how EXP is calculated with this battle script, it seems to be completely wrong--my actor is gaining way more exp than the enemy provides--so I was trying to fix it, rather unsuccessfully:

The phase 5 calls "gain_exp" after battle like so:
exp = gain_exp


And gain_exp
Spoiler: ShowHide
  def gain_exp
    exp = exp_gained
    for i in 0...$game_party.actors.size
      actor = $game_party.actors[i]
      if actor.cant_get_exp? == false
        last_level = actor.level
        actor.exp += exp
        if actor.level > last_level
          @status_window.level_up(i)
        end
      end
    end
    return exp
  end
  #--------------------------------------------------------------------------
  def exp_gained
    # For each enemy in the troop
    for enemy in $game_troop.enemies
      # Add their exp to the pool
      exp += enemy.exp
      # Old line: exp = exp.nil? ? enemy.exp : exp + enemy.exp
    end
    if EXP_SHARE
      actor_number = 0
      for actor in $game_party.actors
        actor_number += 1 unless actor.cant_get_exp?
      end
      exp = exp / [actor_number, 1].max
      #exp = exp / [actor_number, 1].max
    end
    return exp
  end

9
I am getting an error with ForeverZer0's Blacksmith script (the fixed version by KK20):
http://forum.chaos-project.com/index.php/topic,6171.0.html
(I didn't want to necropost, and I'm not sure if it's the script as much as it's a conflict)

It's giving me the following error:


In the following method:
Spoiler: ShowHide
  def self.materials?(type, id)
    # Get the required materials for the item
    materials = case type
    when 0 then [self.weapon_forges(id), self.weapon_gold(id)]
    when 1 then [self.armor_forges(id), self.armor_gold(id)]
    when 2 then [self.item_forges(id), self.item_gold(id)]
    end
    materials[0] = [] if materials[0] == nil
    # Check gold, skipping item check if there is not enough.
    if $game_party.gold >= materials[1][0]
      # Iterate all required materials, making sure enough are in inventory.
      materials[0].each {|item|
        # Branch by the type of the item.
        result = case item[0]
        when 0 then ($game_party.weapon_number(item[1]) >= item[2])
        when 1 then ($game_party.armor_number(item[1]) >= item[2])
        when 2 then ($game_party.item_number(item[1]) >= item[2])
        end
        # End iteration and return false immidiately if missing required item.
        return false unless result
      }
      return true
    end
    return false
  end


Here is my config:
Spoiler: ShowHide
module Blacksmith
 
#===============================================================================
#                          BEGIN CONFIGURATION
#===============================================================================

  FORGE_SE = ['006-System06', 80, 100]
  # SE played when an item is forged. ['FILENAME', VOLUME, PITCH]
  EXTRACT_SE = ['020-Teleport03', 80, 100]
  # SE played when an item extraction is performed. ['FILENAME', VOLUME, PITCH]
  ENCHANT_SE = ['020-Teleport03', 80, 100]
  # SE played when an item enchantment is performed. ['FILENAME', VOLUME, PITCH]
 
  USE_ENCHANTMENTS = true
  # Set to true to enable the "Enchant" feature of the system.
 
  NO_ENCHANT_WEAPONS = []
  NO_ENCHANT_ARMORS = []
  # Include IDs of any equipment that cannot be enchanted in the respective
  # arrays, seperating by commas. Ignore these if not using enchant feature.
 
  # Define the colors used for the text in the Blacksmith shop.
  PLUS_COLOR = Color.new(128, 255, 128)
  MINUS_COLOR = Color.new(255, 128, 128)
 
  MAP_BACK = true
  # Set to true if you would like slightly opaque windows with the map showing
  # through.
 
  #-----------------------------------------------------------------------------
  # FORGE DATABASE
  #-----------------------------------------------------------------------------
  # Define the materials used for each weapon/armor/item that can be forged and
  # extracted. They configuration is slightly different than what it was in the
  # first version of the script. You can seperately define materials that are
  # given during extraction if you like, or ignore it and it will simply return
  # the same materials it takes to forge them. It works like this:
  #
  # STEP 1:
  #   Create a new "case" in the appropriate method below for the type of item
  #   you are trying to define. There are three of them, one each for weapons,
  #   armors, and items. Just use this syntax:
  #       
  #          when DATABASE_ID then []
  #
  # STEP 2:
  #   Now you can begin to add materials to forge the item. Each material has
  #   an number which defines what type of item is is. Here is the "key":
  #
  #       0 = Weapon
  #       1 = Armor
  #       2 = Item
  #
  #   To define a material for an item, you simply create a three element array
  #   using this format:
  #                       [ITEM_TYPE, DATABASE_ID, QUANTITY]
  #
  #   ...and add it the appropriate empty array in the case statement you made
  #   in Step 1. You can add as many different items as you please to forge an
  #   weapon/armor/item, simply seperate the material arrays with commas. See
  #   below for a few examples.
  #-----------------------------------------------------------------------------
  def self.weapon_forges(id)
    return case id
    when 1 then [[2, 33, 3]]            # Bronze Sword
    end
  end
 
  def self.armor_forges(id)
    return case id
    when 1 then [[2, 33, 5]]
    end
  end
 
  def self.item_forges(id)
    return case id
    when 2 then [[2, 33, 5]]
    end
  end
 
  #-----------------------------------------------------------------------------
  # EXTRACT DATABASE
  #-----------------------------------------------------------------------------
  # Here you can define the items received when a specific item is extracted.
  # It can be setup the same as way as above. Items left undefined will return
  # the same items that are required to forge it. You can define an item with an
  # empty array to have it return no items, though it can still return gold.
  #-----------------------------------------------------------------------------
  def self.weapon_extractions(id)
    return case id
    when 1 then [[2, 33, 1], [2, 42, 1]]
    else
      self.weapon_forges(id)
    end
     
  end
 
  def self.armor_extractions(id)
    return case id
    when 1 then [[2, 34, 2], [0, 1, 1]]
    else
      self.armor_forges(id)
    end
  end
 
  def self.item_extractions(id)
    return case id
    when 1 then []                     # Potion
    when 2 then [[2, 1, 2]]            # High Potion
    when 3 then [[2, 2, 2], [2, 1, 2]] # Full Potion
    when 4 then []                     # Perfume
    when 5 then [[2, 4, 2]]            # High Perfume
    when 6 then [[2, 4, 2], [2, 5, 2]] # Full Perfume
    else
      self.item_forges(id)
    end
  end
 
  #-----------------------------------------------------------------------------
  # GOLD DATABASE
  #-----------------------------------------------------------------------------
  # Here you can define the amount of gold that is required to forge an item,
  # and the amount that is given if extracted. There are three methods, one each
  # for weapons, armors, and items. Simply follow this pattern for each
  # category:
  #
  #     when DATABASE_ID then [FORGE_PRICE, EXTRACT_GOLD,]
  #-----------------------------------------------------------------------------
  def self.weapon_gold(id)
    return case id
    when 1 then [200, 50]
    when 2 then [450, 225]
    else
      [0, 0]
    end
  end
 
  def self.armor_gold(id)
    return case id
    when 1 then []
    when 2 then []
    when 3 then []
    when 4 then []
    when 5 then []
    else
      [0, 0]
    end
  end
 
  def self.item_gold(id)
    return case id
    when 1 then [100, 0]
    else
      [0, 0]
    end
  end
 
  #-----------------------------------------------------------------------------
  # ENCHANT DATABASE
  #-----------------------------------------------------------------------------
 
  #-----------------------------------------------------------------------------
  # Here you can define what items will alter stats when used to enchant with.
  # You need to create a two element array, and add it to the respective array
  # below that corresponds with the desired item.
  #
  # ex.
  #     when ITEM_ID then [[KEYWORD, VALUE], [KEYWORD, VALUE]]
  #
  #     KEYWORD: See below for a list of possible keywords. Stat changes that
  #              can affect only weapons will have no effect on armors, and
  #              vice-versa.
  #     VALUE : The amount by which to change the stat. Negative values will
  #             lower the stat.
  #-----------------------------------------------------------------------------
  # KEYWORDS:
  #
  #   'ATK' (Weapon Only)           'DEX'               'PDEF'
  #   'EVA' (Armor Only)            'AGI'               'MDEF'
  #   'STR'                         'INT'   
  #
  #   ** Keywords have to be written EXACTLY as they appear.
  #   ex: when 40 then [['STR', 15], ['ATK', 5]] # Behemoth Juice
  #-----------------------------------------------------------------------------
  def self.enchant_stats(item_id)
    return case item_id
    when 1 then []
    #Enter stats here
    end
  end
 
  #-----------------------------------------------------------------------------
  # Define state altering enchantments.
  #
  # ex.
  #     when ITEM_ID then [[VALUE, STATE_ID], [VALUE, STATE_ID]]
  #
  #     VALUE: One of three different values to represent states efficiency.
  #              -1 = Minus state (Does nothing on armors)
  #               0 = Neutral
  #               1 = Plus state
  #     STATE_ID: The ID in the database of the state.
  #-----------------------------------------------------------------------------
  def self.enchant_states(item_id)
    return case item_id
    when 1 then []
    #when 38 then [[1, 2], [1, 4], [1, 6]] # Chaos Orb
    end
  end
 
  #-----------------------------------------------------------------------------
  # Define element altering enchantments.
  #
  # ex.
  #     when ITEM_ID then [[VALUE, ELEMENT_ID], [VALUE, ELEMENT_ID]]
  #
  #     VALUE: One of two different values to represent element efficiency.
  #              true  = Uses element
  #              false = Doesn't use element (Negates element if present)
  #     ELEMENT_ID: The ID in the database of the element.
  #-----------------------------------------------------------------------------
  def self.enchant_elements(item_id)
    return case item_id
    when 1 then []
    #when 36 then [[true, 3], [false, 5]] # Amethyst
    #when 37 then [[true, 1]]             # Ruby ;)
    end
  end 
 
  #-----------------------------------------------------------------------------
  # Define the amount of gold it takes to enchant a weapon or armor with the
  # item.
  #-----------------------------------------------------------------------------
  def self.enchant_gold(item_id)
    return case item_id
    when 1 then []
    #when 36 then 1500
    else
      0
    end
  end
 
#===============================================================================
#                              END CONFIGURATION
#===============================================================================
 


I tried troubleshooting with puts and I found that "materials[0][1]" is nil but I'm not sure why. materials[0] and materials[1] are both normal values. I have a feeling it's a script conflict, as I've got quite a few in my game now.

Thanks!
10
Script Troubleshooting / Ruby Question
October 28, 2017, 05:39:25 pm
I am having a hard time figuring out what a method with an "=" is. I'm sure it's really basic Ruby stuff, but what is the difference between these two methods? Rather, what does it mean to attach "=()" at the end of a method?

#--------------------------------------------------------------------------
  # * Get Top Row
  #--------------------------------------------------------------------------
  def top_row
    # Divide y-coordinate of window contents transfer origin by 1 row
    # height of 32
    return self.oy / 32
  end

#--------------------------------------------------------------------------
  # * Set Top Row
  #     row : row shown on top
  #--------------------------------------------------------------------------
  def top_row=(row)
    # If row is less than 0, change it to 0
    if row < 0
      row = 0
    end
    # If row exceeds row_max - 1, change it to row_max - 1
    if row > row_max - 1
      row = row_max - 1
    end
    # Multiply 1 row height by 32 for y-coordinate of window contents
    # transfer origin
    self.oy = row * 32
  end
11
Troubleshooting / Help / Combat System Basics
October 27, 2017, 09:30:47 pm
I'm at it again, another silly question.

Is there any documentation on the RMXP battle system phases? I can gather some things from reading the comments in the base RPG Maker scripts, but I am going to be making some edits to a sideview battle system and was looking for more detailed documentation or tutorials if possible.

12
I'm hoping someone can help me with writing a script. I'm not really looking for free code as much as I'm looking for assistance figuring out how to implement something, so I can learn how to code better.

Right now I have a custom status menu with a standard help window. The user can select and scroll through the list of stats to see a description of what each one does (Though it's kind of broken, see below).

I now want to create a window that displays the actors current status effects (states) and populates information to the help window about each state. I understand I'll need a custom array that associates each state with a description, as RPG Maker XP does not provide state descriptions by default. I am using Blizz's states as icons scripts, if that helps.

I actually already have the framework for the window (I know how to create the window, make it active/inactive, set the index, the screenshot below is all in-game with the exception of the white text/icons), but I'm not entirely sure what the best way to draw each state and its associated icon on the list and assure it is properly selected and populated into the help window.

Here is a screenshot example:
Spoiler: ShowHide


Bonus question:
For some reason, my stats window isn't working properly. The first item on the list is selected properly, but nothing happens when I scroll (the index doesn't change?). Is it because I need to explicitly set the "commands"? In this case, I would happy to accept help, but I feel like I really need to figure it out on my own.

Here is the code:
class Window_Stats < Window_Selectable

include CMS_Config

  #--------------------------------------------------------------------------
  # * Object Initialization
  #     actor : actor
  #--------------------------------------------------------------------------
  def initialize(actor)
super(0, 0, 152, 246)
self.contents = Bitmap.new(width - 32, height - 32)
@item_max = 8
@column_max = 1
@actor = actor
self.z += 10
self.active = false
self.index = -1
refresh
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
 
  def refresh
self.contents.clear
for i in 0...7
draw_actor_parameter(@actor, 0, i*32, i)
end
update_cursor_rect
  end

  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    super
      #update cursor rectangle
  update_cursor_rect
  end

    # Update cursor rectangle
      def update_cursor_rect
if @index < 0
self.cursor_rect.empty
else
# Get current row
row = @index / @column_max
# If current row is before top row
if row < self.top_row
# Scroll so that current row becomes top row
self.top_row = row
end
# If current row is more to back than back row
if row > self.top_row + (self.page_row_max - 1)
# Scroll so that current row becomes back row
self.top_row = row - (self.page_row_max - 1)
end
# Calculate cursor width
cursor_width = self.width / @column_max - 16
# Calculate cursor coordinates
x = 4
y = @index * 32
# Update cursor rectangle
self.cursor_rect.set(x, y, cursor_width, 32)
end
end

 
  #--------------------------------------------------------------------------
  # * Help Text Update
  #--------------------------------------------------------------------------

  def update_help
@help_window.set_text(self.index < 0 ? "" : STAT_DESCRIPTIONS[@index], 0)
  end
 
  #--------------------------------------------------------------------------
  # * Draw Parameters
  #     actor : actor
  #     x     : draw spot x-coordinate
  #     y     : draw spot y-coordinate
  #     type  : parameter type (0-6)
  #--------------------------------------------------------------------------
  def draw_actor_parameter(actor, x, y, type)
    case type
    when 0
      parameter_name = $data_system.words.atk
      parameter_value = actor.atk
    when 1
      parameter_name = $data_system.words.pdef
      parameter_value = actor.pdef
    when 2
      parameter_name = $data_system.words.mdef
      parameter_value = actor.mdef
    when 3
      parameter_name = $data_system.words.str
      parameter_value = actor.str
    when 4
      parameter_name = $data_system.words.dex
      parameter_value = actor.dex
    when 5
      parameter_name = $data_system.words.agi
      parameter_value = actor.agi
    when 6
      parameter_name = $data_system.words.int
      parameter_value = actor.int
    end
    self.contents.font.color = system_color
    self.contents.draw_text(x, y, 80, 32, parameter_name)
    self.contents.font.color = normal_color
    self.contents.draw_text(x + 80, y, 36, 32, parameter_value.to_s, 2)
  end

end


Thanks everyone!
13
Script Troubleshooting / NoMethodError Help
October 23, 2017, 04:19:10 pm
I'm running into a little trouble with a NoMethodError and I'm just looking for a little help to get me into the right direction.

I am using a custom menu script made by "albertfish", it's quite old. I am using it as a framework to write my own custom menu.

I am currently using RPG Maker XP with the RPG Maker VX Ace engine, as defined here: http://forum.chaos-project.com/index.php/topic,12899.msg173956.html#msg173956

This error:
Spoiler: ShowHide


Appears when my actors receive items.

The specific line is here:
if $recent_items[i].id == $data_items[item_id].id && $recent_items[i].is_a?(RPG::Item)


The problem I'm having is with a custom "Game_Party" class. It is telling me the method "id" is not defined, but I'm pretty certain it is a built-in RGSS method. I'm not sure if the problem is due to me using the RPG Maker VX engine and that there is a syntax change, or it is a script conflict issue.

This is the particular area that it is flagging:
Spoiler: ShowHide
#--------------------------------------------------------------------------
  # * Gain Recent Items
  #     item_id  : item ID
  #--------------------------------------------------------------------------
  def gain_recent_item(item_id)
    for i in 0...$recent_items.size
      if $recent_items[i].id == $data_items[item_id].id && $recent_items[i].is_a?(RPG::Item)
        $recent_items.delete_at(i)
      end
    end
    $recent_items.push($data_items[item_id])
    if $recent_items.size > 40
      $recent_items.delete_at(0)
    end
  end


This script is pretty big I've uploaded the whole thing to pastebin:
https://pastebin.com/WEGdtdrK

Any sort of hints or advice would be helpful!


14
Troubleshooting / Help / Basic RGSS Window Questions
October 23, 2017, 12:09:45 pm
Hi guys,

I am pretty new to this forum, but I've been using RPG Maker for a while. I am currently working with RPG Maker XP ("Ace" version). Hopefully I am asking this in the right spot.

I am working on modifying the menu system in my game and I was wondering if there was a good resource that had basic explanations of the basic methods or if someone could give a quick explanation. I don't really need a full RGSS guide--I've got a pretty good handle on things--but I'm curious on the process of drawing a window to make sure I get things right.

I understand the classes "Window_" handle how a window is drawn and "Scene_" actually draws the windows.

I just need a little help with the basic methods and when to use them. I understand "initialize" initializes the object, but I am a little confused with "refresh" and "update" and the difference between the two.

I suppose the TL:DR of my question: Is there a quick explanation on the "refresh" and "update" methods and when to use them when drawing menu windows?

Or, if anyone knows of a nice tutorial focused on creating/editing menu systems specifically, that would also be helpful. I have had a hard time finding one.

Thanks!