RPG Maker Forums

I FINALLY figured out what the cause of this little bug in my game, it is caused


with a small addon script for my XAS features.


The script allows you to see what weapon is equipped when you swing it,(if you have a dagger equipped, when you hit A, it will swing  the dagger icon outwards.)


The problem. When other Actors Unequip a weapon, or Equip a weapon, the main character actor is effected as well, say for example if actor 3 equips a boomerang, then suddenly actor 1 has that boomerang icon equipped instead of his current dagger, and to top it off, the shield icon is replaced with a seperate icon as well.


I think it is because this script may only be valid for 1 player at a time, I'm going to need it to be multiple actors that are not effected from picking new weapons and stuff.


here's the script

#==============================================================================
# ■ XAS Icon Graphic Add-on 1.0.0
#==============================================================================
# original : Khas Arcthunder's SASIV
#==============================================================================
# modified by etude87
#==============================================================================
module Etude87_XAS
  #-------------------------------------------------------------------------------
  # □ action_id => {dir=>[angles],...}
  # ※ action_id -1 is a shield
  #-------------------------------------------------------------------------------
  Use_Weapon_Draw = {
  -1 => {2=>[   0,   0,   0,   0],4=>[   0,   0,   0,   0],6=>[   0,   0,   0,   0],8=>[   0,   0,   0,   0]},
   1 => {2=>[  80, 110, 140, 170],4=>[ 320,  10,  40,  70],6=>[-320, -10, -40, -70],8=>[ 290, 320, 350,  20]},
   2 => {2=>[ 170, 140, 110,  80],4=>[  70,  40,  10, 320],6=>[ -70, -40, -10,-320],8=>[  20, 350, 320, 290]},
   3 => {2=>[  80, 110, 140, 170],4=>[ 320,  10,  40,  70],6=>[-320, -10, -40, -70],8=>[ 290, 320, 350,  20]},
  16 => {2=>[  80, 110, 140, 170],4=>[ 320,  10,  40,  70],6=>[-320, -10, -40, -70],8=>[ 290, 320, 350,  20]},
  17 => {2=>[ 170, 140, 110,  80],4=>[  70,  40,  10, 320],6=>[ -70, -40, -10,-320],8=>[  20, 350, 320, 290]},
  18 => {2=>[ 170, 140, 110,  80],4=>[  70,  40,  10, 320],6=>[ -70, -40, -10,-320],8=>[  20, 350, 320, 290]},
  }
  #-------------------------------------------------------------------------------
  # □ dir 6
  #-------------------------------------------------------------------------------
  Use_Mirror = true
  #-------------------------------------------------------------------------------
  # □ action_id => {dir=>[offset],...}
  #-------------------------------------------------------------------------------
  Default_Correction = {2=>[-8,-10],4=>[0,-10],6=>[0,-4],8=>[4,-10]}
  #-------------------------------------------------------------------------------
  # □ action_id => {dir=>[offset],...}
  # ※ action_id -1 is a shield
  #-------------------------------------------------------------------------------
  Custom_Correction = {-1 => {2=>[2,-10],4=>[0,-10],6=>[0,-4],8=>[22,-14]},
  }
  #-------------------------------------------------------------------------------
  # □ {dir=>z pos,...}
  #-------------------------------------------------------------------------------
  Z_Values = {2=>120,4=>120,6=>120,8=>50}
  #-------------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Scene_Map < Scene_Base
  attr_accessor :spriteset
end
#==============================================================================
#==============================================================================
class Spriteset_Map
  alias sas_update update
  alias sas_initialize initialize
  alias sas_dispose dispose
  #-------------------------------------------------------------------------------
  def initialize
    @trash = []
    sas_initialize
    @weapon_graphic = Sprite.new(@viewport1)
    @weapon_graphic.ox = 22
    @weapon_graphic.oy = 22
    @attacking = false
    @attack_timer = 0
    @angles = {}
    @correction = Etude87_XAS::Default_Correction
    @z_values = Etude87_XAS::Z_Values
    @action_id = 0
    refresh_weapon
    refresh_shield
  end
  #-------------------------------------------------------------------------------
  def refresh_weapon
    @weapon_bitmap.dispose unless @weapon_bitmap.nil?
    @weapon_bitmap = nil
    return if $game_party.members.empty?
    index = ($game_party.members[0].weapons[0].icon_index rescue nil)
    unless index == nil
      temp = Cache.system("Iconset")
      @weapon_bitmap = Bitmap.new(24,24)
      @weapon_bitmap.blt(0,0,temp,Rect.new(index%16*24,index/16*24,24,24))
      temp.dispose
      temp = nil
    end
  end
  #-------------------------------------------------------------------------------
  def refresh_shield
    @shield_bitmap.dispose unless @shield_bitmap.nil?
    @shield_bitmap = nil
    return if $game_party.members.empty?
    index = ($game_party.members[0].armors[0].icon_index rescue nil)
    unless index == nil
      temp = Cache.system("Iconset")
      @shield_bitmap = Bitmap.new(24,24)
      @shield_bitmap.blt(0,0,temp,Rect.new(index%16*24,index/16*24,24,24))
      temp.dispose
      temp = nil
    end
  end
  #-------------------------------------------------------------------------------
  def dispose
    sas_dispose
    @weapon_graphic.bitmap = nil
    unless @weapon_bitmap.nil?
      @weapon_bitmap.dispose
      @weapon_bitmap = nil
    end
    unless @shield_bitmap.nil?
      @shield_bitmap.dispose
      @shield_bitmap = nil
    end
    @weapon_graphic.dispose
    @weapon_graphic = nil
  end
  #-------------------------------------------------------------------------------
  def update
    sas_update
    update_weapon_graphic if @attacking
  end
  #-------------------------------------------------------------------------------
  def set_correction
    if Etude87_XAS::Custom_Correction.include?(@action_id)
      @correction = Etude87_XAS::Custom_Correction[@action_id]
    else
      @correction = Etude87_XAS::Default_Correction
    end
  end
  #-------------------------------------------------------------------------------
  def update_weapon_graphic
    set_correction
    @weapon_graphic.x = $game_player.screen_x + @correction[$game_player.direction][0]
    @weapon_graphic.y = $game_player.screen_y + @correction[$game_player.direction][1]
    if Etude87_XAS::Use_Mirror
      if $game_player.direction == 6
        @weapon_graphic.mirror = true
        @weapon_graphic.ox = 2
      else
        @weapon_graphic.mirror = false
        @weapon_graphic.ox = 22
      end
    end
    @angles = Etude87_XAS::Use_Weapon_Draw[@action_id]
    if @action_id == -1
      @weapon_graphic.y += 6 unless @weapon_graphic.mirror
      @weapon_graphic.angle = @angles[$game_player.direction][0]
      @weapon_graphic.z = @z_values[$game_player.direction]
    else
      @weapon_graphic.y -= 6 if @weapon_graphic.mirror
      case @attack_timer
      when 12
        @weapon_graphic.angle = @angles[$game_player.direction][0]
        @weapon_graphic.z = @z_values[$game_player.direction]
      when 9
        @weapon_graphic.angle = @angles[$game_player.direction][1]
        @weapon_graphic.z = @z_values[$game_player.direction]
      when 6
        @weapon_graphic.angle = @angles[$game_player.direction][2]
        @weapon_graphic.z = @z_values[$game_player.direction]
      when 3
        @weapon_graphic.angle = @angles[$game_player.direction][3]
        @weapon_graphic.z = @z_values[$game_player.direction]
      when 0
        @attacking = false
        @weapon_graphic.bitmap = nil
        @action_id = 0
      end
      @attack_timer -= 1
    end
    @weapon_graphic.update
  end
  #-------------------------------------------------------------------------------
  def weapon_animation(action_id)
    return if @weapon_bitmap.nil?
    @weapon_graphic.bitmap = @weapon_bitmap
    @attacking = true
    @attack_timer = 12
    @action_id = action_id
  end
  #-------------------------------------------------------------------------------
  def shield_animation(attacking)
    return if @shield_bitmap.nil?
    return if @action_id > 0
    return if @attacking == attacking
    @attacking = attacking
    if @attacking
      @weapon_graphic.bitmap = @shield_bitmap
      @action_id = -1
    else
      @weapon_graphic.bitmap = nil
      @weapon_graphic.update
      @action_id = 0
    end
  end
  #-------------------------------------------------------------------------------
end
#===============================================================================
#===============================================================================
module XAS_ACTION
  #--------------------------------------------------------------------------
  alias etude87_xas_shoot shoot
  def shoot(action_id = 0)
    etude87_xas_shoot(action_id)
    SceneManager.scene.spriteset.weapon_animation(action_id) if Etude87_XAS::Use_Weapon_Draw.include?(action_id)
  end
  #--------------------------------------------------------------------------
end
#==============================================================================
#==============================================================================
class Game_Player < Game_Character
  #--------------------------------------------------------------------------
  alias etude87_xas_update_shield_button update_shield_button
  def update_shield_button
    etude87_xas_update_shield_button
    SceneManager.scene.spriteset.shield_animation(self.battler.shield) if SceneManager.scene.spriteset.is_a?(Spriteset_Map)
  end
  #--------------------------------------------------------------------------
end


I appreciate any help!


Thank you!

[/SPOILER]

Latest Threads

Latest Profile Posts

Don't forget, aspiring writers: Personality isn't what your characters do, it is WHY they do it.
Hello! I would like to know if there are any pluggings or any way to customize how battles look?
I was thinking that when you start the battle for it to appear the eyes of your characters and opponents sorta like Ace Attorney.
Sadly I don't know how that would be possible so I would be needing help! If you can help me in any way I would really apreciate it!
The biggest debate we need to complete on which is better, Waffles or Pancakes?
rux
How is it going? :D
Day 9 of giveaways! 8 prizes today :D

Forum statistics

Threads
106,051
Messages
1,018,549
Members
137,837
Latest member
Dabi
Top