Save-Point

Full Version: Save-Point
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Board Message
Sorry, you do not have permission to access this resource.
Save-Point - I need some help "combining" two scripts[XP]

Save-Point

Full Version: I need some help "combining" two scripts[XP]
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Now that I have had time to work on the database section of my project a bit I noticed something I did not before. Here is the situation:

I am using the KGC_StateIcon script which shows an icon for status effects in the menu as well as in the battle. (Instead of the text). I am also using the Advanced Equip Window by RPG Advocat which among other things shows Auto State and State Defense from equipment. However, since that is not part of the standard it is not affected by the StateIcon script and thus still shows the words.
There are no compatibility issues, they work perfectly fine together it's just that it's a bit funny looking. Besides, if you have -let's say the ribbon from Final Fantasy VII which makes you immune to all status changes, there will be many words listed and eventually to many for the window.
So in short what I would like would be to show the Icons for the status in the Equip menu as well. (And maybe starting a second row if the first is full. Again: in case one Item causes many things.) Whether or not that can be achieved by linking the scripts together somehow or by just editing the Equip script and setting up the icons there again I don't know.
I tried to do this myself but quickly came to the realisation that while I would be able to show a specific icon in specific place with some trial and error, I had no idea how to show it only under certain conditions. I also thought about setting up all possible icons in gray and 'colorizing' aka 'activating' them if the condition is met but with the same problem.

At first I didn't wanna ask because I thought it would be nit-picky, but it really does look stupid and I think other people might have use for this as well. So...
Hopefully this isn't to hard to do. Laughing + Tongue sticking out


Here are the scripts of which I speak. Hopefully it shouldn't be necessary to add my whole script file for this.

Code:
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
#_/◆ ステートアイコン表示 - KGC_StateIcon ◆
#_/◇ Last update : 2009/09/13 ◇
#_/----------------------------------------------------------------------------
#_/  ステートをアイコンで表示します。
#_/============================================================================
#_/ ≪基本設定強化[Base Reinforce]≫より上
#_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/

#==============================================================================
# ★ カスタマイズ項目 ★
#==============================================================================

module KGC
module StateIcon
  # ◆ アイコンファイル名
  ICONS = []

  # ここから下に
  #   ICONS [State ID] = "Dateiname"
  # という書式で指定。
  # ファイル名は Graphics/Icons 内のもの。
  # 表示するステートが無い場合は ICONS[0] を表示。
  ICONS[3] = "001-Weapon01"

  ICONS[0] = ""  # [正常] 時のアイコン ("" ならアイコンなし)

  #  position correction icon # [x, y]
  #  ≪Active Count Battle≫ 等を併用すると位置が微妙なため。
  OFFSET_MENU   = [0, 0]  # menu (non-combat)
  OFFSET_BATTLE = [0, 3]  # combat
end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

$imported = {} if $imported == nil
$imported["StateIcon"] = true

#==============================================================================
# ■ RPG::State
#==============================================================================

class RPG::State
  #--------------------------------------------------------------------------
  # ○ アイコンファイル名
  #--------------------------------------------------------------------------
  def icon_name
return KGC::StateIcon::ICONS[id]
  end
end

#★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★☆★

#==============================================================================
# ■ Window_Base
#==============================================================================

class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● ステートの描画
  # actor : アクター
  # x : 描画先 X 座標
  # y : 描画先 Y 座標
  # width : 描画先の幅
  #--------------------------------------------------------------------------
  def draw_actor_state(actor, x, y, width = 120)
icons = make_battler_state_icon_list(actor, width / 24)
dx = x
dy = y
if $game_temp.in_battle
  dx += KGC::StateIcon::OFFSET_BATTLE[0]
  dy += KGC::StateIcon::OFFSET_BATTLE[1]
else
  dx += KGC::StateIcon::OFFSET_MENU[0]
  dy += KGC::StateIcon::OFFSET_MENU[1]
end
icons.each { |i|
  icon = RPG::Cache.icon(i)
  self.contents.blt(dx, dy, icon, icon.rect)
  dx += 24
}
  end
  #--------------------------------------------------------------------------
  # ○ ステートアイコンリスト作成
  # actor : アクター
  # limit : 最大数
  #--------------------------------------------------------------------------
  def make_battler_state_icon_list(actor, limit)
result = []
actor.states.each { |i|
  state = $data_states[i]
  next if state.rating == 0

  icon = state.icon_name
  if icon != nil
    result << icon
    break if result.size == limit
  end
}
result << KGC::StateIcon::ICONS[0] if result.empty?
return result
  end
end
Code:
#==============================================================================
# ** Advanced Equip Window V1.0
# AdvancedEquipWindow.rb von RPG Advocat (28.07.2008)
#------------------------------------------------------------------------------
# http://www.rpg-studio.de/scriptdb/node/13
# http://www.rpg-studio.de/forum/index.php?page=Thread&threadID=31209
# http://www.phylomortis.com/resource/script/scr012.html
# http://www.phylomortis.com
#==============================================================================

class Scene_Equip
  # --------------------------------
  def refresh
@item_window1.visible = (@right_window.index == 0)
@item_window2.visible = (@right_window.index == 1)
@item_window3.visible = (@right_window.index == 2)
@item_window4.visible = (@right_window.index == 3)
@item_window5.visible = (@right_window.index == 4)
item1 = @right_window.item
case @right_window.index
when 0
  @item_window = @item_window1
  newmode = 0
when 1
  @item_window = @item_window2
  newmode = 1
when 2
  @item_window = @item_window3
  newmode = 1
when 3
  @item_window = @item_window4
  newmode = 1
when 4
  @item_window = @item_window5
  newmode = 1
end
if newmode != @left_window.mode
  @left_window.mode = newmode
  @left_window.refresh
end
if @right_window.active
  @left_window.set_new_parameters(nil, nil, nil, nil, nil, nil, nil, nil,
  "", "")
end
if @item_window.active
  item2 = @item_window.item
  last_hp = @actor.hp
  last_sp = @actor.sp
  old_atk = @actor.atk
  old_pdef = @actor.pdef
  old_mdef = @actor.mdef
  old_str = @actor.str
  old_dex = @actor.dex
  old_agi = @actor.agi
  old_int = @actor.int
  old_eva = @actor.eva
  @actor.equip(@right_window.index, item2 == nil ? 0 : item2.id)
  new_atk = @actor.atk
  new_pdef = @actor.pdef
  new_mdef = @actor.mdef
  new_str = @actor.str
  new_dex = @actor.dex
  new_agi = @actor.agi
  new_int = @actor.int
  new_eva = @actor.eva
  @left_window.changes = [0, 0, 0, 0, 0, 0, 0, 0]
  if new_atk > old_atk
    @left_window.changes[0] = 1
  end
  if new_atk < old_atk
    @left_window.changes[0] = -1
  end
  if new_pdef > old_pdef
    @left_window.changes[1] = 1
  end
  if new_pdef < old_pdef
    @left_window.changes[1] = -1
  end
  if new_mdef > old_mdef
    @left_window.changes[2] = 1
  end
  if new_mdef < old_mdef
    @left_window.changes[2] = -1
  end
   if new_str > old_str
    @left_window.changes[3] = 1
  end
  if new_str < old_str
    @left_window.changes[3] = -1
  end
    if new_dex > old_dex
    @left_window.changes[4] = 1
  end
  if new_dex < old_dex
    @left_window.changes[4] = -1
  end
  if new_agi > old_agi
    @left_window.changes[5] = 1
  end
  if new_agi < old_agi
    @left_window.changes[5] = -1
  end
  if new_int > old_int
    @left_window.changes[6] = 1
  end
  if new_int < old_int
    @left_window.changes[6] = -1
  end
  if new_eva > old_eva
    @left_window.changes[7] = 1
  end
  if new_eva < old_eva
    @left_window.changes[7] = -1
  end
  elem_text = make_elem_text(item2)
  stat_text = make_stat_text(item2)
  @actor.equip(@right_window.index, item1 == nil ? 0 : item1.id)
  @actor.hp = last_hp
  @actor.sp = last_sp
  @left_window.set_new_parameters(new_atk, new_pdef, new_mdef, new_str,
  new_dex, new_agi, new_int, new_eva, elem_text, stat_text)
end
  end
  # --------------------------------
  def make_elem_text(item)
text = ""
flag = false
if item.is_a?(RPG::Weapon)
  for i in item.element_set
    if flag
      text += ", "
    end
    text += $data_system.elements[i]
    flag = true
  end
end
if item.is_a?(RPG::Armor)
  for i in item.guard_element_set
    if flag
      text += ", "
    end
    text += $data_system.elements[i]
    flag = true
  end
end
return text
  end
  # --------------------------------
  def make_stat_text(item)
text = ""
flag = false
if item.is_a?(RPG::Weapon)
  for i in item.plus_state_set
    if flag
      text += ", "
    end
    text += $data_states[i].name
    flag = true
  end
end
if item.is_a?(RPG::Armor)
  for i in item.guard_state_set
    if flag
      text += ", "
    end
    text += $data_states[i].name
    flag = true
  end
end
return text
  end
end

class Window_EquipLeft < Window_Base
  # --------------------------------
  attr_accessor :mode
  attr_accessor :changes
  # --------------------------------
  def initialize(actor)
super(0, 64, 272, 416)
self.contents = Bitmap.new(width - 32, height - 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
self.z += 100
@actor = actor
@mode = 0
@changes = [0, 0, 0, 0, 0, 0, 0, 0]
@elem_text = ""
@stat_text = ""
refresh
  end
  # --------------------------------
  def refresh
self.contents.clear
draw_actor_name(@actor, 4, 0)
draw_actor_level(@actor, 180, 0)
draw_actor_parameter(@actor, 4, 32, 0)
draw_actor_parameter(@actor, 4, 64, 1)
draw_actor_parameter(@actor, 4, 96, 2)
draw_actor_parameter(@actor, 4, 128, 3)

draw_actor_parameter(@actor, 4, 160, 4)
draw_actor_parameter(@actor, 4, 192, 5)
draw_actor_parameter(@actor, 4, 224, 6)
if @mode == 0
  self.contents.draw_text(4, 256, 200, 32, "Element:")
  self.contents.draw_text(4, 320, 200, 32, "Status Effekt:")
end
if @mode == 1
  self.contents.draw_text(4, 256, 200, 32, "Element Abwehr:")
  self.contents.draw_text(4, 320, 200, 32, "Status Abwehr:")
end
self.contents.draw_text(12, 288, 220, 32, @elem_text)
self.contents.draw_text(12, 352, 220, 32, @stat_text)
if @new_atk != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 32, 40, 32, "→", 1)
  if @changes[0] == 0
    self.contents.font.color = normal_color
  elsif @changes[0] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 32, 36, 32, @new_atk.to_s, 2)
end
if @new_pdef != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 64, 40, 32, "→", 1)
  if @changes[1] == 0
    self.contents.font.color = normal_color
  elsif @changes[1] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 64, 36, 32, @new_pdef.to_s, 2)
end
if @new_mdef != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 96, 40, 32, "→", 1)
  if @changes[2] == 0
    self.contents.font.color = normal_color
  elsif @changes[2] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 96, 36, 32, @new_mdef.to_s, 2)
end
if @new_str != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 128, 40, 32, "→", 1)
  if @changes[3] == 0
    self.contents.font.color = normal_color
  elsif @changes[3] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 128, 36, 32, @new_str.to_s, 2)
end
if @new_dex != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 160, 40, 32, "→", 1)
  if @changes[4] == 0
    self.contents.font.color = normal_color
  elsif @changes[4] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 160, 36, 32, @new_dex.to_s, 2)
end
  if @new_agi != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 192, 40, 32, "→", 1)
  if @changes[5] == 0
    self.contents.font.color = normal_color
  elsif @changes[5] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 192, 36, 32, @new_agi.to_s, 2)
end
  if @new_int != nil
  self.contents.font.color = system_color
  self.contents.draw_text(160, 224, 40, 32, "→", 1)
  if @changes[6] == 0
    self.contents.font.color = normal_color
  elsif @changes[6] == -1
    self.contents.font.color = down_color
  else
    self.contents.font.color = up_color
  end
  self.contents.draw_text(200, 224, 36, 32, @new_int.to_s, 2)
end
  end
# --------------------------------
def set_new_parameters(new_atk, new_pdef, new_mdef, new_str, new_dex,
new_agi, new_int, new_eva, elem_text, stat_text)
flag = false
if new_atk != @new_atk || new_pdef != @new_pdef || new_mdef != @new_mdef
  flag = true
end
if new_str != @new_str || new_dex != @new_dex || new_agi != @new_agi
  flag = true
end
if new_eva != @new_eva || elem_text != @elem_text || stat_text != @stat_text
  flag = true
end
  @new_atk = new_atk
  @new_pdef = new_pdef
  @new_mdef = new_mdef
  @new_str = new_str
  @new_dex = new_dex
  @new_agi = new_agi
  @new_int = new_int
  @new_eva = new_eva
  @elem_text = elem_text
  @stat_text = stat_text
  if flag
    refresh
  end
  end
end


class Window_EquipItem < Window_Selectable
  # --------------------------------
  def initialize(actor, equip_type)
super(272, 256, 368, 224)
@actor = actor
@equip_type = equip_type
@column_max = 1
refresh
self.active = false
self.index = -1
  end
  # --------------------------------
  def item
return @data[self.index]
  end
  # --------------------------------
  def refresh
if self.contents != nil
  self.contents.dispose
  self.contents = nil
end
@data = []
if @equip_type == 0
  weapon_set = $data_classes[@actor.class_id].weapon_set
  for i in 1...$data_weapons.size
    if $game_party.weapon_number(i) > 0 and weapon_set.include?(i)
      @data.push($data_weapons[i])
    end
  end
end
if @equip_type != 0
  armor_set = $data_classes[@actor.class_id].armor_set
  for i in 1...$data_armors.size
    if $game_party.armor_number(i) > 0 and armor_set.include?(i)
      if $data_armors[i].kind == @equip_type-1
        @data.push($data_armors[i])
      end
    end
  end
end
@data.push(nil)
@item_max = @data.size
self.contents = Bitmap.new(width - 32, row_max * 32)
self.contents.font.name = "Arial"
self.contents.font.size = 24
for i in 0...@item_max-1
  draw_item(i)
end
s = @data.size-1
self.contents.draw_text(4, s*32, 100, 32, "[Ablegen]")
  end
  # --------------------------------
  def draw_item(index)
item = @data[index]
x = 4
y = index * 32
case item
when RPG::Weapon
  number = $game_party.weapon_number(item.id)
when RPG::Armor
  number = $game_party.armor_number(item.id)
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 288, y, 16, 32, ":", 1)
self.contents.draw_text(x + 304, y, 24, 32, number.to_s, 2)
  end
  # --------------------------------
  def update_help
@help_window.set_text(self.item == nil ? "" : self.item.description)
  end
end

class Window_Base < Window
  # --------------------------------
  def up_color
return Color.new(74, 210, 74)
  end
  # --------------------------------
  def down_color
return Color.new(170, 170, 170)
  end
end
I tried something, but if there are too many icons, they won't go to a second line, but alternate every 60 frames.
There are two versions. A basic for the status, and another to show also icons instead of elements names.
Paste the script below the two others.

Only status :
script

Status + Elements (you have to populate the array ELEMENTS_ICONS, it's the same thing as KGC's ICON array) :

script
O_O
That answer came amazingly fast, I did not expect that XD
And you found a working solution for the 'to many icons' problem (that I actually like even better and did not think about XD) AND even included the elements as well which I completely forgot about XD
Thank you a lot, it works wonderfull =D

I did encounter the cannot convert nil into string bug at first when I tried to select some equipment but soon realized that it was only triggered if I would chose a piece that defended you from a state that had no icon (for what ever reason) which of course can easy to work around.
So, yeah...what is there left to say besides thank you? A lot? XD
(I'm always amazed what those who understand scripting and understand it well can do XD)