幻想森林

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1485|回复: 2

[RMXP] 怎么显示物品级别颜色,比方普通是白色 套装是绿色等?

[复制链接]

2

主题

3

帖子

28

积分

②入门

积分
28
发表于 2010-1-28 09:50:42 | 显示全部楼层 |阅读模式
怎么做出来的?最好详细些谢谢。
回复

使用道具 举报

0

主题

42

帖子

347

积分

④见习

积分
347
发表于 2010-1-28 12:13:07 | 显示全部楼层
  1. #==============================================================================
  2. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息 by 柳柳
  3. #==============================================================================
  4. module RPG
  5.   class Skill
  6.     def name
  7.       name = @name.split(/@/)[0]
  8.       return name != nil ? name : ''
  9.     end
  10.     def name_color
  11.       name_color = @name.split(/@/)[1]
  12.       return name_color != nil ? name_color.to_i : 0
  13.     end
  14.   end
  15.   class Weapon
  16.     def name
  17.       name = @name.split(/@/)[0]
  18.       return name != nil ? name : ''
  19.     end
  20.     def name_color
  21.       name_color = @name.split(/@/)[1]
  22.       return name_color != nil ? name_color.to_i : 0
  23.     end
  24.   end
  25.   class Item
  26.     def name
  27.       name = @name.split(/@/)[0]
  28.       return name != nil ? name : ''
  29.     end
  30.     def name_color
  31.       name_color = @name.split(/@/)[1]
  32.       return name_color != nil ? name_color.to_i : 0
  33.     end
  34.   end
  35.   class Armor
  36.     def name
  37.       name = @name.split(/@/)[0]
  38.       return name != nil ? name : ''
  39.     end
  40.     def name_color
  41.       name_color = @name.split(/@/)[1]
  42.       return name != nil ? name_color.to_i : 0
  43.     end
  44.   end
  45. end
  46. #============================================================================
  47. # ——————————————————————————————————————
  48. # 本脚本原创自[url]www.66rpg.com[/url],转载请保留此信息
  49. # ——————————————————————————————————————
  50. class Window_Base < Window
  51.   #--------------------------------------------------------------------------
  52.   # ● 描绘物品名
  53.   #     item : 物品
  54.   #     x    : 描画目标 X 坐标
  55.   #     y    : 描画目标 Y 坐标
  56.   #--------------------------------------------------------------------------
  57.   def draw_item_name(item, x, y)
  58.     if item == nil
  59.       return
  60.     end
  61.     bitmap = RPG::Cache.icon(item.icon_name)
  62.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  63.     self.contents.font.color = text_color(item.name_color)
  64.     self.contents.draw_text(x + 28, y, 212, 32, item.name.to_s)
  65.   end
  66. end
  67. # ——————————————————————————————————————
  68. # 本脚本原创自[url]www.66rpg.com[/url],转载请保留此信息
  69. # ——————————————————————————————————————
  70. class Window_Item
  71.   #--------------------------------------------------------------------------
  72.   # ● 描绘项目
  73.   #     index : 项目编号
  74.   #--------------------------------------------------------------------------
  75.   def draw_item(index)
  76.     item = @data[index]
  77.     case item
  78.     when RPG::Item
  79.       number = $game_party.item_number(item.id)
  80.     when RPG::Weapon
  81.       number = $game_party.weapon_number(item.id)
  82.     when RPG::Armor
  83.       number = $game_party.armor_number(item.id)
  84.     end
  85.     if item.is_a?(RPG::Item) and
  86.        $game_party.item_can_use?(item.id)
  87.       self.contents.font.color = text_color(item.name_color)
  88.     else
  89.       self.contents.font.color = text_color(item.name_color)
  90.     end
  91.     x = 4 + index % 2 * (288 + 32)
  92.     y = index / 2 * 32
  93.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  94.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  95.     bitmap = RPG::Cache.icon(item.icon_name)
  96.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  97.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  98.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  99.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  100.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  101.   end
  102. end
  103. # ——————————————————————————————————————
  104. # 本脚本原创自[url]www.66rpg.com[/url],转载请保留此信息
  105. # ——————————————————————————————————————
  106. class Window_EquipItem < Window_Selectable
  107.   #--------------------------------------------------------------------------
  108.   # ● 项目的描绘
  109.   #     index : 项目符号
  110.   #--------------------------------------------------------------------------
  111.   def draw_item(index)
  112.     item = @data[index]
  113.     x = 4 + index % 2 * (288 + 32)
  114.     y = index / 2 * 32
  115.     case item
  116.     when RPG::Weapon
  117.       number = $game_party.weapon_number(item.id)
  118.     when RPG::Armor
  119.       number = $game_party.armor_number(item.id)
  120.     end
  121.     bitmap = RPG::Cache.icon(item.icon_name)
  122.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
  123.     self.contents.font.color = text_color(item.name_color)
  124.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  125.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  126.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  127.   end
  128. end
  129. # ——————————————————————————————————————
  130. # 本脚本原创自[url]www.66rpg.com[/url],转载请保留此信息
  131. # ——————————————————————————————————————
  132. class Window_ShopBuy < Window_Selectable
  133.   #--------------------------------------------------------------------------
  134.   # ● 描绘羡慕
  135.   #     index : 项目编号
  136.   #--------------------------------------------------------------------------
  137.   def draw_item(index)
  138.     item = @data[index]
  139.     # 获取物品所持数
  140.     case item
  141.     when RPG::Item
  142.       number = $game_party.item_number(item.id)
  143.     when RPG::Weapon
  144.       number = $game_party.weapon_number(item.id)
  145.     when RPG::Armor
  146.       number = $game_party.armor_number(item.id)
  147.     end
  148.     # 价格在所持金以下、并且所持数不是 99 的情况下为普通颜色
  149.     # 除此之外的情况设置为无效文字色
  150.     if item.price <= $game_party.gold and number < 99
  151.       self.contents.font.color = text_color(item.name_color)
  152.     else
  153.       self.contents.font.color = text_color(item.name_color)
  154.     end
  155.     x = 4
  156.     y = index * 32
  157.     rect = Rect.new(x, y, self.width - 32, 32)
  158.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  159.     bitmap = RPG::Cache.icon(item.icon_name)
  160.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  161.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  162.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  163.     self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
  164.   end
  165. end
  166. # ——————————————————————————————————————
  167. # 本脚本原创自[url]www.66rpg.com[/url],转载请保留此信息
  168. # ——————————————————————————————————————
  169. class Window_ShopSell < Window_Selectable
  170.   #--------------------------------------------------------------------------
  171.   # ● 描绘项目
  172.   #     index : 项目标号
  173.   #--------------------------------------------------------------------------
  174.   def draw_item(index)
  175.     item = @data[index]
  176.     case item
  177.     when RPG::Item
  178.       number = $game_party.item_number(item.id)
  179.     when RPG::Weapon
  180.       number = $game_party.weapon_number(item.id)
  181.     when RPG::Armor
  182.       number = $game_party.armor_number(item.id)
  183.     end
  184.     # 可以卖掉的显示为普通颜色、除此之外设置成无效文字颜色
  185.     if item.price > 0
  186.       self.contents.font.color = text_color(item.name_color)
  187.     else
  188.       self.contents.font.color = text_color(item.name_color)
  189.     end
  190.     x = 4 + index % 2 * (288 + 32)
  191.     y = index / 2 * 32
  192.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  193.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  194.     bitmap = RPG::Cache.icon(item.icon_name)
  195.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  196.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  197.     self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
  198.     self.contents.draw_text(x + 240, y, 16, 32, ":", 1)
  199.     self.contents.draw_text(x + 256, y, 24, 32, number.to_s, 2)
  200.   end
  201. end
  202.   
  203. # ——————————————————————————————————————
  204. # 本脚本原创自[url]www.66rpg.com[/url],转载请保留此信息
  205. # ——————————————————————————————————————
  206. class Window_Skill
  207.   #--------------------------------------------------------------------------
  208.   # ● 描绘项目
  209.   #     index : 项目编号
  210.   #--------------------------------------------------------------------------
  211.   def draw_item(index)
  212.     skill = @data[index]
  213.     if @actor.skill_can_use?(skill.id)
  214.       self.contents.font.color = text_color(skill.name_color)
  215.     else
  216.       self.contents.font.color = text_color(skill.name_color)
  217.     end
  218.     x = 4 + index % 2 * (288 + 32)
  219.     y = index / 2 * 32
  220.     rect = Rect.new(x, y, self.width / @column_max - 32, 32)
  221.     self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
  222.     bitmap = RPG::Cache.icon(skill.icon_name)
  223.     opacity = self.contents.font.color == disabled_color ? 128 : 255
  224.     self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
  225.     self.contents.draw_text(x + 28, y, 204, 32, skill.name, 0)
  226.     self.contents.draw_text(x + 232, y, 48, 32, skill.sp_cost.to_s, 2)
  227.   end
  228. end
  229. #==============================================================================
  230. # 本脚本来自[url]www.66RPG.com[/url],使用和转载请保留此信息
  231. #==============================================================================
复制代码
使用:例如 铜剑@2 在名称后面加@数字
回复 支持 反对

使用道具 举报

2

主题

3

帖子

28

积分

②入门

积分
28
 楼主| 发表于 2010-1-28 16:02:46 | 显示全部楼层
灰常感谢啊。这里面那些是重要参数。麻烦了
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|幻想森林

GMT+8, 2024-5-16 02:19 , Processed in 0.020545 second(s), 20 queries .

Powered by Discuz! X3.4

© 2001-2017 Comsenz Inc.

快速回复 返回顶部 返回列表