赞 | 1 |
VIP | 0 |
好人卡 | 0 |
积分 | 7 |
经验 | 0 |
最后登录 | 2023-12-14 |
在线时间 | 77 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 669
- 在线时间
- 77 小时
- 注册时间
- 2022-7-29
- 帖子
- 42
|
3楼
楼主 |
发表于 2022-10-4 13:30:25
|
只看该作者
换装脚本
- =begin
- 装备变更行走图 Ace 版 v1.0
-
- ( XP 版作者:亿万星辰 )
-
- 素材请使用 png 格式的去底图片
-
- 装备样式行走图放在 Graphics\DisplayEquips 文件夹内
- 装备的备注里填写 <display 图片名>,装备上以后在行走图上绘制对应的装备样式
-
- 可以双持的装备还需要另一个左手持武器的图片
- 在原图片的图片名后加“_dual”显示左手拿这个武器的效果
- 如果没有这个图片则不显示
-
- =end
- #-
- class Sprite_Player < Sprite_Character
-
- EquipDisplayPriority = {
- #各个朝向对应的显示优先级,靠后的显示在最前 人物朝向
- 0 => [:body, :armor, :helmet, :weapon, :shield], #下
- 1 => [:weapon, :body, :armor, :helmet, :shield], #左
- 2 => [:shield, :body, :armor, :helmet, :weapon], #右
- 3 => [:body, :weapon, :shield, :armor, :helmet] #上
- }
- def graphic_changed?
- super || equip_changed?
- end
- def equip_changed?
- @character.actor && @character.actor.equip_changed
- end
- #
- def set_character_bitmap
- super
- setup_bitmap_display_equips
- end
- #
- def setup_bitmap_display_equips
- w = @cw * 3
- h = @ch * 4
- i = @character.character_index
- # 创建临时位图
- orig_bitmap = Bitmap.new(w, h)
- orig_bitmap.blt( 0, 0, self.bitmap, Rect.new(i%4*w, i/4*h, w, h) )
- self.bitmap = Bitmap.new(w, h)
- # 绘制装备
- bitmap_draw_equips(orig_bitmap) if @character.actor
- #~ if @character == $game_player
- #~ $sprite = Sprite.new
- #~ $sprite.bitmap = bitmap
- #~ end
- orig_bitmap.dispose
- end
-
- #
- def bitmap_draw_equips(orig_bitmap)
- @character.actor.equip_changed = false
- # 创建装备临时位图
- temp_equip_bitmaps = []
- @character.actor.equips.each_with_index {|equip, index|
- img_name = equip ? equip.display_equip_part : nil
- temp_equip_bitmaps.push(
- equip_bitmap(img_name, index == 1 && equip.class == RPG::Weapon)
- )
- }
- dual_wield = @character.actor.dual_wield?
- # 逐层绘制装备
- btmp_rect = Rect.new(0, 0, @cw*3, @ch)
- 4.times {|i|
- btmp_rect.y = @ch * i
- EquipDisplayPriority[i].each {|part|
- btmp = equip_part_bitmap(part, temp_equip_bitmaps, orig_bitmap)
- bitmap.blt( 0, btmp_rect.y, btmp, btmp_rect ) if btmp
- }
- }
- # 释放临时位图
- temp_equip_bitmaps.each {|bitmap| bitmap.dispose if bitmap}
- end
- #
- def equip_part_bitmap( part, temp_equip_bitmaps, orig_bitmap )
- case part
- when :body; orig_bitmap
- when :weapon; temp_equip_bitmaps[0]
- when :shield; temp_equip_bitmaps[1]
- when :armor; temp_equip_bitmaps[2]
- when :helmet; temp_equip_bitmaps[3]
- end
- end
- def equip_bitmap(img_name, dual_weapon)
- if img_name
- img_file = "Graphics/DisplayEquips/#{img_name}"
- if dual_weapon
- img_dual = img_file + "_dual.png"
- File.exist?(img_dual) ? Bitmap.new(img_dual) : nil
- else
- Bitmap.new(img_file)
- end
- else
- nil
- end
- end
- #
- def update_src_rect
- pattern = @character.pattern < 3 ? @character.pattern : 1
- sx = pattern * @cw
- sy = (@character.direction - 2) / 2 * @ch
- self.src_rect.set(sx, sy, @cw, @ch)
- end
- #
-
- def dispose
- bitmap.dispose
- super
- end
- end
- module RPG
- class Weapon
- def display_equip_part
- @note =~ /<display.(\S+)>/
- return $1
- end
- end
- class Armor
- def display_equip_part
- @note =~ /<display.(\S+)>/
- return $1
- end
- end
- end
- #-
- class Game_Actor
- attr_accessor\
- :equip_changed
- alias_method :display_equip_change_equip, :change_equip
- def change_equip(slot_id, item)
- display_equip_change_equip(slot_id, item)
- @equip_changed = true
- end
- end
- class Game_Character
- end
- #-
- class Spriteset_Map
- def create_characters # 覆盖
- @character_sprites = []
- $game_map.events.values.each do |event|
- @character_sprites.push(Sprite_Character.new(@viewport1, event))
- end
- $game_map.vehicles.each do |vehicle|
- @character_sprites.push(Sprite_Character.new(@viewport1, vehicle))
- end
- $game_player.followers.reverse_each do |follower|
- @character_sprites.push(Sprite_Player.new(@viewport1, follower))
- end
- @character_sprites.push(Sprite_Player.new(@viewport1, $game_player))
- @map_id = $game_map.map_id
- end
- end
复制代码 |
|