扫描二维码关注官方公众号
返回列表
+ 发新帖
查看: 98|回复: 0

[转载发布] 装备变更行走图 Ace 版 附属脚本—— 染色与涂装

[复制链接]
累计送礼:
0 个
累计收礼:
1 个
  • TA的每日心情
    开心
    3 天前
  • 签到天数: 191 天

    连续签到: 3 天

    [LV.7]常住居民III

    2594

    主题

    772

    回帖

    2万

    积分

    管理员

    Rank: 9Rank: 9Rank: 9

    VIP
    7
    卡币
    17427
    OK点
    16
    推广点
    0
    同能卷
    50
    积分
    20823

    灌水之王

    发表于 3 天前 | 显示全部楼层 |阅读模式
    RUBY 代码
    1. #==============================================================================#
    2. #  ** 染色与涂装系统 —— 装备变更行走图 Ace 版 附属脚本
    3. #------------------------------------------------------------------------------#
    4. #  作者:MrRuigi
    5. #  功能:
    6. #    · 在物品备注中定义染料和涂装,通过菜单对已装备的武器/防具进行染色/涂装
    7. #    · 染色采用色相旋转(hue_change),仅改变非透明像素的色调,保持透明背景
    8. #    · 涂装采用正片叠底(Multiply)混合,平铺小图案,仅作用于装备非透明区域
    9. #    · 装备外观变化会实时反映在玩家行走图中
    10. #    · 无可用物品时自动返回上一级,避免卡操作感
    11. #==============================================================================#
    12. #==============================================================================#
    13. # ■ 配置模块
    14. #==============================================================================#
    15. module FalDyePaint
    16.   # 菜单中显示的选项名称
    17.   COMMAND_NAME = "染色/涂装"
    18.   # 操作音效
    19.   DYE_SE      = "Heal6"      # 染色成功
    20.   PAINT_SE    = "Item3"      # 涂装成功
    21.   CANCEL_SE   = "Cancel2"    # 取消操作
    22.   ERROR_SE    = "Buzzer1"    # 错误提示
    23.   # 默认颜色(无染色时视为白色,不影响色调)
    24.   DEFAULT_COLOR = Color.new(255, 255, 255)
    25.   # 预览窗口尺寸
    26.   PREVIEW_WIDTH  = 100
    27.   PREVIEW_HEIGHT = 100
    28.   # 染色模式:true = 色相旋转(推荐),false = 像素颜色混合(旧版效果)
    29.   USE_HUE_CHANGE = true
    30.   # 像素混合模式下的染色强度 (0-255),仅在 USE_HUE_CHANGE = false 时生效
    31.   DYE_OPACITY = 160
    32.   # 涂装图片存放文件夹(相对于 Graphics 目录)
    33.   PAINTING_DIR = "Painting"
    34. end
    35. #==============================================================================#
    36. # ■ 装备变更行走图相关配置
    37. #==============================================================================#
    38. module EquipDisplay
    39.   # 各个朝向对应的显示优先级,靠后的显示在最前
    40.   Priority = {
    41.     0 => [:body, :armor, :helmet, :weapon, :shield], # 下
    42.     1 => [:weapon, :body, :armor, :helmet, :shield], # 左
    43.     2 => [:shield, :body, :armor, :helmet, :weapon], # 右
    44.     3 => [:body, :weapon, :shield, :armor, :helmet]  # 上
    45.   }
    46. end
    47. #==============================================================================#
    48. # ■ RPG::EquipItem (扩展)
    49. #==============================================================================#
    50. classRPG::EquipItem < RPG::BaseItem
    51.   # 获取此装备当前的染色颜色(从系统数据中读取)
    52.   def dye_color
    53.     $game_system.dye_data(self)rescuenil
    54.   end
    55.   # 获取此装备当前的涂装图案文件名
    56.   def paint_pattern
    57.     $game_system.paint_data(self)rescuenil
    58.   end
    59.   # 获取行走图装备备注中的图片名
    60.   def display_equip_part
    61.     @note =~ //
    62.     return $1
    63.   end
    64. end
    65. #==============================================================================#
    66. # ■ RPG::Item (扩展)
    67. #==============================================================================#
    68. classRPG::Item < RPG::UsableItem
    69.   # 判断是否为染料物品,并返回解析出的颜色(Color 对象)
    70.   def dye_color
    71.     @note =~ //i
    72.     returnnilunless $1 && $2 && $3
    73.     Color.new($1.to_i, $2.to_i, $3.to_i)
    74.   end
    75.   # 判断是否为涂装物品,并返回图案文件名
    76.   def paint_pattern
    77.     @note =~ //i
    78.     return $1
    79.   end
    80.   # 是否为可用的外观物品(染料或涂装)
    81.   def appearance_item?
    82.     dye_color || paint_pattern
    83.   end
    84. end
    85. #==============================================================================#
    86. # ■ Game_System (扩展)
    87. #==============================================================================#
    88. class Game_System
    89.   # 初始化染色/涂装数据容器
    90.   alias dye_paint_initialize initialize
    91.   def initialize
    92.     dye_paint_initialize
    93.     @dye_data   = {}   # 格式: { equip_id => Color }
    94.     @paint_data = {}   # 格式: { equip_id => "pattern_name" }
    95.   end
    96.   # 获取装备的染色颜色
    97.   def dye_data(equip)
    98.     @dye_data[equip_id(equip)] || FalDyePaint::DEFAULT_COLOR
    99.   end
    100.   # 设置装备的染色颜色
    101.   def set_dye_data(equip, color)
    102.     @dye_data[equip_id(equip)] = color
    103.   end
    104.   # 获取装备的涂装图案
    105.   def paint_data(equip)
    106.     @paint_data[equip_id(equip)]
    107.   end
    108.   # 设置装备的涂装图案
    109.   def set_paint_data(equip, pattern)
    110.     @paint_data[equip_id(equip)] = pattern
    111.   end
    112.   # 清除装备的染色数据
    113.   def clear_dye_data(equip)
    114.     @dye_data.delete(equip_id(equip))
    115.   end
    116.   # 清除装备的涂装数据
    117.   def clear_paint_data(equip)
    118.     @paint_data.delete(equip_id(equip))
    119.   end
    120.   private
    121.   # 生成装备的唯一标识符(类别 + ID)
    122.   def equip_id(equip)
    123.     "#{equip.class.name}_#{equip.id}"
    124.   end
    125. end
    126. #==============================================================================#
    127. # ■ Game_Actor (扩展)
    128. #==============================================================================#
    129. class Game_Actor
    130.   attr_accessor :equip_changed
    131.   alias dye_paint_change_equip change_equip
    132.   def change_equip(slot_id, item)
    133.     dye_paint_change_equip(slot_id, item)
    134.     @equip_changed = true
    135.   end
    136. end
    137. #==============================================================================#
    138. # ■ Window_DyePaintHelp (自定义帮助窗口)
    139. #==============================================================================#
    140. class Window_DyePaintHelp < Window_Help
    141.   def initialize(line_number = 2)
    142.     super(line_number)
    143.   end
    144.   def set_actor(actor)
    145.     set_text(actor ? "#{actor.name} 的装备" : "")
    146.   end
    147.   def set_equip(equip)
    148.     text = equip ? equip.name : ""
    149.     if equip
    150.       dye = $game_system.dye_data(equip)
    151.       pattern = $game_system.paint_data(equip)
    152.       extra = []
    153.       extra  0
    154.   end
    155.   definclude?(item)
    156.     case@mode
    157.     when:dye
    158.       item.is_a?(RPG::Item) && item.dye_color != nil
    159.     when:paint
    160.       item.is_a?(RPG::Item) && item.paint_pattern != nil
    161.     else
    162.       false
    163.     end
    164.   end
    165.   def enable?(item)
    166.     $game_party.item_number(item) > 0
    167.   end
    168.   def update_help
    169.     @help_window.set_item(item)if@help_window
    170.   end
    171. end
    172. #==============================================================================#
    173. # ■ Window_DyePaintPreview (预览窗口)
    174. #==============================================================================#
    175. class Window_DyePaintPreview < Window_Base
    176.   def initialize(x, y)
    177.     super(x, y, FalDyePaint::PREVIEW_WIDTH + 32, FalDyePaint::PREVIEW_HEIGHT + 32)
    178.     @equip = nil
    179.     @dye_color = nil
    180.     @paint_pattern = nil
    181.     refresh
    182.   end
    183.   def set_preview(equip, dye_color = nil, paint_pattern = nil)
    184.     returnif@equip == equip && @dye_color == dye_color && @paint_pattern == paint_pattern
    185.     @equip = equip
    186.     @dye_color = dye_color
    187.     @paint_pattern = paint_pattern
    188.     refresh
    189.   end
    190.   def clear
    191.     @equip = nil
    192.     @dye_color = nil
    193.     @paint_pattern = nil
    194.     refresh
    195.   end
    196.   def refresh
    197.     contents.clear
    198.     returnunless@equip
    199.     draw_icon(@equip.icon_index, 0, 0)
    200.     if@dye_color
    201.       rect = Rect.new(24, 0, 24, 24)
    202.       contents.fill_rect(rect, @dye_color)
    203.     end
    204.     if@paint_pattern
    205.       contents.font.size = 16
    206.       contents.draw_text(48, 0, contents_width - 48, 24, @paint_pattern)
    207.     end
    208.     contents.font.size = Font.default_size
    209.     contents.draw_text(0, 30, contents_width, 24, "当前效果", 1)
    210.   end
    211. end
    212. #==============================================================================#
    213. # ■ Scene_DyePaint (染色/涂装主场景)
    214. #==============================================================================#
    215. class Scene_DyePaint < Scene_MenuBase
    216.   def start
    217.     super
    218.     create_help_window
    219.     create_command_window
    220.     create_actor_window
    221.     create_equip_window
    222.     create_item_window
    223.     create_preview_window
    224.     @help_window.height = 72
    225.     @command_window.activate
    226.     @mode = :dye
    227.   end
    228.   def create_help_window
    229.     @help_window = Window_DyePaintHelp.new
    230.     @help_window.viewport = @viewport
    231.   end
    232.   def create_command_window
    233.     @command_window = Window_DyePaintCommand.new
    234.     @command_window.viewport = @viewport
    235.     @command_window.y = @help_window.height
    236.     @command_window.set_handler(:dye,   method(:command_dye))
    237.     @command_window.set_handler(:paint, method(:command_paint))
    238.     @command_window.set_handler(:cancel, method(:return_scene))
    239.   end
    240.   def create_actor_window
    241.     y = @command_window.y + @command_window.height
    242.     @actor_window = Window_DyePaintActor.new(0, y)
    243.     @actor_window.viewport = @viewport
    244.     @actor_window.help_window = @help_window
    245.     @actor_window.set_handler(:ok,     method(:on_actor_ok))
    246.     @actor_window.set_handler(:cancel, method(:on_actor_cancel))
    247.     @actor_window.deactivate
    248.   end
    249.   def create_equip_window
    250.     x = @actor_window.width
    251.     y = @actor_window.y
    252.     @equip_window = Window_DyePaintEquip.new(x, y)
    253.     @equip_window.viewport = @viewport
    254.     @equip_window.help_window = @help_window
    255.     @equip_window.set_handler(:ok,     method(:on_equip_ok))
    256.     @equip_window.set_handler(:cancel, method(:on_equip_cancel))
    257.   end
    258.   def create_item_window
    259.     x = @actor_window.width + @equip_window.width
    260.     y = @actor_window.y
    261.     w = Graphics.width - x
    262.     h = Graphics.height - y
    263.     @item_window = Window_DyePaintItem.new(x, y, w, h)
    264.     @item_window.viewport = @viewport
    265.     @item_window.help_window = @help_window
    266.     @item_window.set_handler(:ok,     method(:on_item_ok))
    267.     @item_window.set_handler(:cancel, method(:on_item_cancel))
    268.     @item_window.mode = :dye
    269.   end
    270.   def create_preview_window
    271.     x = Graphics.width - FalDyePaint::PREVIEW_WIDTH - 32
    272.     y = @command_window.y
    273.     @preview_window = Window_DyePaintPreview.new(x, y)
    274.     @preview_window.viewport = @viewport
    275.   end
    276.   #--------------------------------------------------------------------------
    277.   # * 命令处理
    278.   #--------------------------------------------------------------------------
    279.   def command_dye
    280.     @mode = :dye
    281.     @command_window.deactivate
    282.     @actor_window.activate
    283.     @item_window.mode = :dye
    284.     @item_window.refresh
    285.     update_preview
    286.   end
    287.   def command_paint
    288.     @mode = :paint
    289.     @command_window.deactivate
    290.     @actor_window.activate
    291.     @item_window.mode = :paint
    292.     @item_window.refresh
    293.     update_preview
    294.   end
    295.   #--------------------------------------------------------------------------
    296.   # * 角色窗口处理
    297.   #--------------------------------------------------------------------------
    298.   def on_actor_ok
    299.     @equip_window.actor = @actor_window.actor
    300.     @actor_window.deactivate
    301.     if@equip_window.item_max > 0
    302.       @equip_window.activate
    303.     else
    304.       Sound.play_buzzer
    305.       @actor_window.activate
    306.     end
    307.     update_preview
    308.   end
    309.   def on_actor_cancel
    310.     @actor_window.deactivate
    311.     @command_window.activate
    312.     @preview_window.clear
    313.   end
    314.   #--------------------------------------------------------------------------
    315.   # * 装备窗口处理
    316.   #--------------------------------------------------------------------------
    317.   def on_equip_ok
    318.     @item_window.refresh
    319.     if@item_window.item_max == 0
    320.       Sound.play_buzzer
    321.       @help_window.set_text("没有可用的#{@mode == :dye ? '染料' : '涂装'}物品")
    322.       @equip_window.deactivate
    323.       @actor_window.activate
    324.       @preview_window.clear
    325.       return
    326.     end
    327.     @equip_window.deactivate
    328.     @item_window.activate
    329.     update_preview
    330.   end
    331.   def on_equip_cancel
    332.     @equip_window.deactivate
    333.     @actor_window.activate
    334.     @preview_window.clear
    335.     @item_window.unselect
    336.   end
    337.   #--------------------------------------------------------------------------
    338.   # * 物品窗口处理
    339.   #--------------------------------------------------------------------------
    340.   def on_item_ok
    341.     item = @item_window.item
    342.     equip = @equip_window.equip
    343.     if item.nil?
    344.       on_item_cancel
    345.       return
    346.     end
    347.     if(@mode == :dye && item.dye_color) || (@mode == :paint && item.paint_pattern)
    348.       apply_appearance(equip, item)
    349.     else
    350.       Sound.play_buzzer
    351.     end
    352.   end
    353.   def on_item_cancel
    354.     @item_window.deactivate
    355.     @equip_window.activate
    356.     @preview_window.set_preview(@equip_window.equip,
    357.                                 $game_system.dye_data(@equip_window.equip),
    358.                                 $game_system.paint_data(@equip_window.equip))
    359.   end
    360.   #--------------------------------------------------------------------------
    361.   # * 应用染色/涂装
    362.   #--------------------------------------------------------------------------
    363.   def apply_appearance(equip, item)
    364.     if@mode == :dye
    365.       color = item.dye_color
    366.       $game_system.set_dye_data(equip, color)
    367.       RPG::SE.new(FalDyePaint::DYE_SE, 80).play
    368.     else
    369.       pattern = item.paint_pattern
    370.       $game_system.set_paint_data(equip, pattern)
    371.       RPG::SE.new(FalDyePaint::PAINT_SE, 80).play
    372.     end
    373.     $game_party.lose_item(item, 1)
    374.     @item_window.refresh
    375.     @equip_window.refresh
    376.     update_preview
    377.     @item_window.deactivate
    378.     @equip_window.activate
    379.     @equip_window.select(@equip_window.index)
    380.     $game_player.refresh
    381.   end
    382.   #--------------------------------------------------------------------------
    383.   # * 更新预览窗口
    384.   #--------------------------------------------------------------------------
    385.   def update_preview
    386.     equip = @equip_window.equip
    387.     if equip
    388.       dye = $game_system.dye_data(equip)
    389.       paint = $game_system.paint_data(equip)
    390.       @preview_window.set_preview(equip, dye, paint)
    391.     else
    392.       @preview_window.clear
    393.     end
    394.   end
    395.   #--------------------------------------------------------------------------
    396.   # * 帧更新
    397.   #--------------------------------------------------------------------------
    398.   def update
    399.     super
    400.     if@item_window.active && @item_window.item
    401.       item = @item_window.item
    402.       equip = @equip_window.equip
    403.       if equip
    404.         if@mode == :dye && item.dye_color
    405.           @preview_window.set_preview(equip, item.dye_color,
    406.                                       $game_system.paint_data(equip))
    407.         elsif@mode == :paint && item.paint_pattern
    408.           @preview_window.set_preview(equip,
    409.                                       $game_system.dye_data(equip),
    410.                                       item.paint_pattern)
    411.         else
    412.           @preview_window.set_preview(equip,
    413.                                       $game_system.dye_data(equip),
    414.                                       $game_system.paint_data(equip))
    415.         end
    416.       end
    417.     end
    418.   end
    419. end
    420. #==============================================================================#
    421. # ■ Window_MenuCommand (在菜单中添加命令)
    422. #==============================================================================#
    423. class Window_MenuCommand < Window_Command
    424.   alias dye_paint_add_original_commands add_original_commands
    425.   def add_original_commands
    426.     dye_paint_add_original_commands
    427.     add_command(FalDyePaint::COMMAND_NAME, :dyepaint, true)
    428.   end
    429. end
    430. #==============================================================================#
    431. # ■ Scene_Menu (增加菜单选项)
    432. #==============================================================================#
    433. class Scene_Menu < Scene_MenuBase
    434.   alias dye_paint_create_command_window create_command_window
    435.   def create_command_window
    436.     dye_paint_create_command_window
    437.     @command_window.set_handler(:dyepaint, method(:command_dyepaint))
    438.   end
    439.   def command_dyepaint
    440.     SceneManager.call(Scene_DyePaint)
    441.   end
    442. end
    443. #==============================================================================#
    444. # ■ Sprite_Player (装备变更行走图 + 染色/涂装叠加)
    445. #==============================================================================#
    446. class Sprite_Player < Sprite_Character
    447.   EquipDisplayPriority = EquipDisplay::Priority
    448.   def graphic_changed?
    449.     super || equip_changed?
    450.   end
    451.   def equip_changed?
    452.     @character.actor && @character.actor.equip_changed
    453.   end
    454.   def set_character_bitmap
    455.     super
    456.     setup_bitmap_display_equips
    457.   end
    458.   def setup_bitmap_display_equips
    459.     w = @cw * 3
    460.     h = @ch * 4
    461.     i = @character.character_index
    462.     orig_bitmap = Bitmap.new(w, h)
    463.     orig_bitmap.blt(0, 0, self.bitmap, Rect.new(i%4*w, i/4*h, w, h))
    464.     self.bitmap = Bitmap.new(w, h)
    465.     bitmap_draw_equips(orig_bitmap)if@character.actor
    466.     orig_bitmap.dispose
    467.   end
    468.   def bitmap_draw_equips(orig_bitmap)
    469.     @character.actor.equip_changed = false
    470.     temp_equip_bitmaps = []
    471.     @character.actor.equips.each_with_indexdo |equip, index|
    472.       img_name = equip ? equip.display_equip_part : nil
    473.       if img_name
    474.         base_bmp = equip_bitmap(img_name, index == 1 && equip.is_a?(RPG::Weapon))
    475.         if base_bmp
    476.           colored_bmp = apply_dye_and_paint(base_bmp, equip)
    477.           temp_equip_bitmaps.push(colored_bmp)
    478.         else
    479.           temp_equip_bitmaps.push(nil)
    480.         end
    481.       else
    482.         temp_equip_bitmaps.push(nil)
    483.       end
    484.     end
    485.     btmp_rect = Rect.new(0, 0, @cw*3, @ch)
    486.     4.timesdo |i|
    487.       btmp_rect.y = @ch * i
    488.       EquipDisplayPriority[i].eachdo |part|
    489.         btmp = equip_part_bitmap(part, temp_equip_bitmaps, orig_bitmap)
    490.         self.bitmap.blt(0, btmp_rect.y, btmp, btmp_rect)if btmp
    491.       end
    492.     end
    493.     temp_equip_bitmaps.each{|b| b.disposeif b}
    494.   end
    495.   #--------------------------------------------------------------------------
    496.   # * 应用染色和涂装(染色:色相旋转;涂装:正片叠底 + 平铺)
    497.   #--------------------------------------------------------------------------
    498.   def apply_dye_and_paint(src_bitmap, equip)
    499.     return src_bitmap unless equip
    500.     new_bmp = Bitmap.new(src_bitmap.width, src_bitmap.height)
    501.     # ----- 染色处理(色相旋转)-----
    502.     dye_color = equip.dye_color
    503.     if dye_color && dye_color != FalDyePaint::DEFAULT_COLOR
    504.       ifFalDyePaint::USE_HUE_CHANGE
    505.         hue = rgb_to_hue(dye_color.red, dye_color.green, dye_color.blue)
    506.         new_bmp.blt(0, 0, src_bitmap, src_bitmap.rect)
    507.         new_bmp.hue_change(hue)
    508.       else
    509.         new_bmp.blt(0, 0, src_bitmap, src_bitmap.rect)
    510.         (0...new_bmp.width).eachdo |x|
    511.           (0...new_bmp.height).eachdo |y|
    512.             color = new_bmp.get_pixel(x, y)
    513.             nextif color.alpha == 0
    514.             r = (color.red   * (255 - FalDyePaint::DYE_OPACITY) + dye_color.red   * FalDyePaint::DYE_OPACITY) / 255
    515.             g = (color.green * (255 - FalDyePaint::DYE_OPACITY) + dye_color.green * FalDyePaint::DYE_OPACITY) / 255
    516.             b = (color.blue  * (255 - FalDyePaint::DYE_OPACITY) + dye_color.blue  * FalDyePaint::DYE_OPACITY) / 255
    517.             new_bmp.set_pixel(x, y, Color.new(r, g, b, color.alpha))
    518.           end
    519.         end
    520.       end
    521.     else
    522.       new_bmp.blt(0, 0, src_bitmap, src_bitmap.rect)
    523.     end
    524.     # ----- 涂装处理(正片叠底 + 平铺,仅作用于非透明区域)-----
    525.     paint_pattern = equip.paint_pattern
    526.     if paint_pattern
    527.       paint_file = "Graphics/#{FalDyePaint::PAINTING_DIR}/#{paint_pattern}.png"
    528.       ifFile.exist?(paint_file)
    529.         paint_bmp = Bitmap.new(paint_file)
    530.         # 创建平铺图层
    531.         tile_bmp = Bitmap.new(new_bmp.width, new_bmp.height)
    532.         tile_x = (new_bmp.width.to_f / paint_bmp.width).ceil
    533.         tile_y = (new_bmp.height.to_f / paint_bmp.height).ceil
    534.         tile_y.timesdo |y|
    535.           tile_x.timesdo |x|
    536.             tile_bmp.blt(x * paint_bmp.width, y * paint_bmp.height,
    537.                          paint_bmp, paint_bmp.rect)
    538.           end
    539.         end
    540.         # 逐像素正片叠底
    541.         (0...new_bmp.width).eachdo |x|
    542.           (0...new_bmp.height).eachdo |y|
    543.             src_color = src_bitmap.get_pixel(x, y)
    544.             nextif src_color.alpha == 0          # 透明区域不处理
    545.             paint_color = tile_bmp.get_pixel(x, y)
    546.             nextif paint_color.alpha == 0        # 涂装透明像素跳过
    547.             base_color = new_bmp.get_pixel(x, y)
    548.             # 正片叠底公式: Result = (Base * Overlay) / 255
    549.             r = (base_color.red * paint_color.red) / 255
    550.             g = (base_color.green * paint_color.green) / 255
    551.             b = (base_color.blue * paint_color.blue) / 255
    552.             # 处理涂装的透明度(Alpha 混合)
    553.             if paint_color.alpha < 255
    554.               alpha_factor = paint_color.alpha / 255.0
    555.               r = (base_color.red * (1 - alpha_factor) + r * alpha_factor).to_i
    556.               g = (base_color.green * (1 - alpha_factor) + g * alpha_factor).to_i
    557.               b = (base_color.blue * (1 - alpha_factor) + b * alpha_factor).to_i
    558.             end
    559.             new_bmp.set_pixel(x, y, Color.new(r, g, b, base_color.alpha))
    560.           end
    561.         end
    562.         tile_bmp.dispose
    563.         paint_bmp.dispose
    564.       end
    565.     end
    566.     new_bmp
    567.   end
    568.   #--------------------------------------------------------------------------
    569.   # * RGB 转色相 (0~360)
    570.   #--------------------------------------------------------------------------
    571.   def rgb_to_hue(r, g, b)
    572.     r /= 255.0
    573.     g /= 255.0
    574.     b /= 255.0
    575.     max = [r, g, b].max
    576.     min = [r, g, b].min
    577.     delta = max - min
    578.     hue = 0.0
    579.     if delta != 0
    580.       case max
    581.       when r
    582.         hue = 60.0 * ((g - b) / delta % 6)
    583.       when g
    584.         hue = 60.0 * ((b - r) / delta + 2)
    585.       when b
    586.         hue = 60.0 * ((r - g) / delta + 4)
    587.       end
    588.     end
    589.     hue = 0if hue < 0
    590.     hue.to_i
    591.   end
    592.   def equip_part_bitmap(part, temp_equip_bitmaps, orig_bitmap)
    593.     case part
    594.     when:body;     orig_bitmap
    595.     when:weapon;   temp_equip_bitmaps[0]
    596.     when:shield;   temp_equip_bitmaps[1]
    597.     when:armor;    temp_equip_bitmaps[2]
    598.     when:helmet;   temp_equip_bitmaps[3]
    599.     end
    600.   end
    601.   def equip_bitmap(img_name, dual_weapon)
    602.     if img_name
    603.       img_file = "Graphics/DisplayEquips/#{img_name}"
    604.       if dual_weapon
    605.         img_dual = img_file + "_dual.png"
    606.         File.exist?(img_dual) ? Bitmap.new(img_dual) : nil
    607.       else
    608.         Bitmap.new(img_file + ".png")rescuenil
    609.       end
    610.     else
    611.       nil
    612.     end
    613.   end
    614.   def update_src_rect
    615.     pattern = @character.pattern < 3 ? @character.pattern : 1
    616.     sx = pattern * @cw
    617.     sy = (@character.direction - 2) / 2 * @ch
    618.     self.src_rect.set(sx, sy, @cw, @ch)
    619.   end
    620.   def dispose
    621.     bitmap.disposeif bitmap
    622.     super
    623.   end
    624. end
    625. #==============================================================================#
    626. # ■ Spriteset_Map (覆盖角色精灵创建)
    627. #==============================================================================#
    628. class Spriteset_Map
    629.   def create_characters
    630.     @character_sprites = []
    631.     $game_map.events.values.eachdo |event|
    632.       @character_sprites.push(Sprite_Character.new(@viewport1, event))
    633.     end
    634.     $game_map.vehicles.eachdo |vehicle|
    635.       @character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
    636.     end
    637.     $game_player.followers.reverse_eachdo |follower|
    638.       @character_sprites.push(Sprite_Player.new(@viewport1, follower))
    639.     end
    640.     @character_sprites.push(Sprite_Player.new(@viewport1, $game_player))
    641.     @map_id = $game_map.map_id
    642.   end
    643. end
    复制代码






    注意:由于未知问题,不适用URGE,会导致无报错闪退




                本帖来自P1论坛作者Ruigi,因Project1站服务器在国外有时候访问缓慢不方便作者交流学习,经联系P1站长fux2同意署名转载一起分享游戏制作经验,共同为国内独立游戏作者共同创造良好交流环境,原文地址:https://rpg.blue/forum.php?mod=viewthread&tid=498805  若有侵权,发帖作者可联系底部站长QQ在线咨询功能删除,谢谢。

    本帖子中包含更多资源

    您需要 登录 才可以下载或查看,没有账号?立即注册

    x
    天天去同能,天天有童年!
    回复 送礼论坛版权

    使用道具 举报

    文明发言,和谐互动
    文明发言,和谐互动
    高级模式
    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    关闭

    幸运抽奖

    社区每日抽奖来袭,快来试试你是欧皇还是非酋~

    立即查看

    聊天机器人
    Loading...

    QQ|Archiver|手机版|小黑屋|同能RPG制作大师 ( 沪ICP备12027754号-3 )

    GMT+8, 2026-4-12 00:16 , Processed in 0.089564 second(s), 52 queries .

    Powered by Discuz! X3.4

    Copyright © 2001-2020, Tencent Cloud.

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