设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
Project1 查看内容

利用数据库更改物品名颜色

2005-10-19 00:00| 发布者: 柳柳| 查看: 9200| 评论: 0|原作者: 66RPG

摘要:    作者 柳柳(本站站长)  版本与更新  2005年8月更新  相关网址    范例工程 不提供 脚本功能 可以在数据库中设置各种武器、防具、物品、特技名字的显示
 

 作者

柳柳(本站站长)

 版本与更新

 2005年8月更新

 相关网址

 

 范例工程

不提供



脚本功能

可以在数据库中设置各种武器、防具、物品、特技名字的显示颜色。

使用方法

复制全部脚本内容,在Main脚本之前按insert,插入此脚本全部内容。

 使用时,对于不想为白色表示的物品,在数据库的物品描述中最后添加@6,@4一类的即可。数字为颜色编号,和对话框中的一样。比如在某物品描述如下:

最高级的剑。战士可以装备。@3

则此物品的物品名显示为3号颜色,也就是绿色(@3这种东西不会在游戏中显示出来,放心)
 

脚本冲突可能:一些系统类的东西,其实可能性不是很大,不过如果碰到改了坐标的脚本就比较讨厌。解决的核心方法是将原来描述颜色为normal_color的地方改为item.name_color_66RPG或skill.name_color_66RPG

相关截图


 

 脚本内容

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================
#
# 脚本功能:给不同物品显示不同颜色,类似暗黑破坏神,比如套装为绿色,超级为金色
#           可以更改的种类包括物品、防具、特技、武器。
#
# 使用方法:对于不想为白色表示的物品,在描述中最后添加@6,@4一类的即可。
#           数字为颜色编号,和对话框中的一样。
# ——————————————————————————————————————
module RPG
  class Skill
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def name_color_66RPG
      name_color = @description.split(/@/)[1]
      return name_color != nil ? name_color.to_i : 0
    end
  end
  class Weapon
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def name_color_66RPG
      name_color = @description.split(/@/)[1]
      return name_color != nil ? name_color.to_i : 0
    end
  end
  class Item
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def name_color_66RPG
      name_color = @description.split(/@/)[1]
      return name_color != nil ? name_color.to_i : 0
    end
  end
  class Armor
    def description
      description = @description.split(/@/)[0]
      return description != nil ? description : ''
    end
    def name_color_66RPG
      name_color = @description.split(/@/)[1]
      return name != nil ? name_color.to_i : 0
    end
  end
end

# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_Base < Window
  #--------------------------------------------------------------------------
  # ● 描绘物品名
  #     item : 物品
  #     x    : 描画目标 X 坐标
  #     y    : 描画目标 Y 坐标
  #--------------------------------------------------------------------------
  def draw_item_name(item, x, y)
    if item == nil
      return
    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 = text_color(item.name_color_66RPG)
    self.contents.draw_text(x + 28, y, 212, 32, item.name.to_s)
  end
end

# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_Item
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    if item.is_a?(RPG::Item) and
       $game_party.item_can_use?(item.id)
      self.contents.font.color = text_color(item.name_color_66RPG)
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == disabled_color ? 128 : 255
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
end

# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_EquipItem < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 项目的描绘
  #     index : 项目符号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 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 = text_color(item.name_color_66RPG)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
end

# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_ShopBuy < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 描绘羡慕
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    # 获取物品所持数
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    # 价格在所持金以下、并且所持数不是 99 的情况下为普通颜色
    # 除此之外的情况设置为无效文字色
    if item.price <= $game_party.gold and number < 99
      self.contents.font.color = text_color(item.name_color_66RPG)
    else
      self.contents.font.color = disabled_color
    end
    x = 4
    y = index * 32
    rect = Rect.new(x, y, self.width - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == disabled_color ? 128 : 255
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  end
end

# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_ShopSell < Window_Selectable
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目标号
  #--------------------------------------------------------------------------
  def draw_item(index)
    item = @data[index]
    case item
    when RPG::Item
      number = $game_party.item_number(item.id)
    when RPG::Weapon
      number = $game_party.weapon_number(item.id)
    when RPG::Armor
      number = $game_party.armor_number(item.id)
    end
    # 可以卖掉的显示为普通颜色、除此之外设置成无效文字颜色
    if item.price > 0
      self.contents.font.color = text_color(item.name_color_66RPG)
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(item.icon_name)
    opacity = self.contents.font.color == disabled_color ? 128 : 255
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
    self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
    self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  end
end
 
# ——————————————————————————————————————
# 本脚本原创自www.66rpg.com,转载请保留此信息
# ——————————————————————————————————————
class Window_Skill
  #--------------------------------------------------------------------------
  # ● 描绘项目
  #     index : 项目编号
  #--------------------------------------------------------------------------
  def draw_item(index)
    skill = @data[index]
    if @actor.skill_can_use?(skill.id)
      self.contents.font.color = text_color(skill.name_color_66RPG)
    else
      self.contents.font.color = disabled_color
    end
    x = 4 + index % 2 * (288 + 32)
    y = index / 2 * 32
    rect = Rect.new(x, y, self.width / @column_max - 32, 32)
    self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
    bitmap = RPG::Cache.icon(skill.icon_name)
    opacity = self.contents.font.color == disabled_color ? 128 : 255
    self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
    self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
    self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  end
end

#==============================================================================
# 本脚本来自www.66RPG.com,使用和转载请保留此信息
#==============================================================================


 

脚本使用的通用说明

约定:本脚本来源于网络,任何人不得随意将本脚本应用于商业用途,如需转载,必须保留所有版权信息,如果是国内作者,最好征求作者同意——否则发生任何后果,66RPG不予负责。使用此脚本表示您默认接受上述约定。

说明:不同脚本之间、尤其是不同作者脚本之间会有冲突,本站会对已知脚本冲突进行简单说明。测试新脚本请下载本站提供的测试文件或者新建工程测试。脚本不要贪多,否则可能会互相冲突对您的游戏造成未知的影响。如果脚本内或者本站内提供了解释,请务必完全看完解释后再使用,如有问题,请到论坛讨论。

3

鲜花

刚表态过的朋友 (3 人)

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-3-29 08:56

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

返回顶部