| 赞 | 1 |
| VIP | |
| 好人卡 | |
| 积分 | 1 |
| 经验 | |
| 最后登录 | 2017-10-21 |
| 在线时间 | 1617 小时 |
炎
- 梦石
- 0
- 星屑
- 98
- 在线时间
- 1617 小时
- 注册时间
- 2013-8-15
- 回帖
- 4322
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有账号?注册会员
×
本帖最后由 永燃的狂炎 于 2014-10-8 09:39 编辑
[box=DarkRed]●狂炎@[/box]
@VIPArcher 结账结帖
[box=DarkRed]●狂炎的推测[/box]
自从用了换装脚本就会报错
[box=DarkRed]●狂炎报错的脚本[/box]
获取道具总数
- #--------------------------------------------------------------------------
- # ● 自动显示得失物品提示
- #--------------------------------------------------------------------------
- module Taroxd end
- module Taroxd::GainMessage
- #--------------------------------------------------------------------------
- # ● 常数设置
- #--------------------------------------------------------------------------
- SWITCH = 0 # 开关打开时功能开启。可以填入 0 表示始终打开。
- GAIN = '获得'
- LOSE = '失去'
- ITEM_FORMAT = '%s了 %s * %d' # 获得/失去了 某物品 * N
- GOLD_FORMAT = '%s了 %d %s' # 获得/失去了 N 金钱单位
- BACKGROUND = 1 # 窗口背景(0/1/2)
- POSITION = 1 # 显示位置(0/1/2)
- GAIN_GOLD_SE = 'Shop' # 获得金钱音效(不需要的话可以直接删去该行)
- LOSE_GOLD_SE = 'Blow2' # 失去金钱音效(不需要的话可以直接删去该行)
- GAIN_ITEM_SE = 'Item1' # 获得物品音效(不需要的话可以直接删去该行)
- LOSE_ITEM_SE = LOSE_GOLD_SE # 失去物品音效(不需要的话可以直接删去该行)
- #--------------------------------------------------------------------------
- module_function
- #--------------------------------------------------------------------------
- # ● 功能是否启用
- #--------------------------------------------------------------------------
- def enabled?
- SWITCH.zero? || $game_switches[SWITCH]
- end
- #--------------------------------------------------------------------------
- # ● 准备
- #--------------------------------------------------------------------------
- def prepare(value, item)
- @item = item
- @value = value
- $game_message.background = BACKGROUND
- $game_message.position = POSITION
- play_se
- end
- #--------------------------------------------------------------------------
- # ● 获取提示的消息
- #--------------------------------------------------------------------------
- def message
- prefix = @value > 0 ? GAIN : LOSE
- if @item
- sprintf(ITEM_FORMAT, prefix, @item.name, @value.abs)
- else
- sprintf(GOLD_FORMAT, prefix, @value.abs, Vocab.currency_unit)
- end
- end
- #--------------------------------------------------------------------------
- # ● 播放音效
- #--------------------------------------------------------------------------
- def play_se
- const = :"#{@value > 0 ? 'GAIN' : 'LOSE'}_#{@item ? 'ITEM' : 'GOLD'}_SE"
- se = const_defined?(const) && const_get(const)
- Audio.se_play('Audio/SE/' + se) if se
- end
- end
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● 获取道具总数(包括装备)
- #--------------------------------------------------------------------------
- def item_number_with_equip(item)
- members.inject(item_number(item)) do |number, actor|
- number + actor.equips.count(item)
- end
- end
- end
- class Game_Interpreter
- alias taroxd_gain_message_command_125 command_125
- alias taroxd_gain_message_command_126 command_126
- alias taroxd_gain_message_command_127 command_127
- alias taroxd_gain_message_command_128 command_128
- #--------------------------------------------------------------------------
- # ● 显示提示窗口
- #--------------------------------------------------------------------------
- def show_gain_message(value, item = nil)
- return if !Taroxd::GainMessage.enabled? || value.zero?
- Taroxd::GainMessage.prepare value, item
- wait_for_message
- $game_message.add Taroxd::GainMessage.message
- wait_for_message
- end
- #--------------------------------------------------------------------------
- # ● 增减持有金钱
- #--------------------------------------------------------------------------
- def command_125
- last_gold = $game_party.gold
- taroxd_gain_message_command_125
- show_gain_message($game_party.gold - last_gold)
- end
- #--------------------------------------------------------------------------
- # ● 增减物品
- #--------------------------------------------------------------------------
- def command_126
- item = $data_items[@params[0]]
- last_num = $game_party.item_number(item)
- taroxd_gain_message_command_126
- show_gain_message($game_party.item_number(item) - last_num, item)
- end
- #--------------------------------------------------------------------------
- # ● 增减武器
- #--------------------------------------------------------------------------
- def command_127
- item = $data_weapons[@params[0]]
- last_num = $game_party.item_number_with_equip(item)
- taroxd_gain_message_command_127
- value = $game_party.item_number_with_equip(item) - last_num
- show_gain_message(value, item)
- end
- #--------------------------------------------------------------------------
- # ● 增减护甲
- #--------------------------------------------------------------------------
- def command_128
- item = $data_armors[@params[0]]
- last_num = $game_party.item_number_with_equip(item)
- taroxd_gain_message_command_128
- value = $game_party.item_number_with_equip(item) - last_num
- show_gain_message(value, item)
- end
- end
复制代码
[box=DarkRed]●狂炎使用的脚本[/box]
半身像对话框- #encoding:utf-8
- #==============================================================================
- # ■ 半身像对话框 by LBQ
- #------------------------------------------------------------------------------
- # 一个简单的半身像对话框罢了= =
- #------------------------------------------------------------------------------
- # ■ 用法一览
- # 1:如何将半身像应用到游戏中?
- # ——如果想要把一个脸图替换成半身像,则需要找到这个脸图的编号,比如说拉尔
- # 夫,就是Actor1的编号0,之后去在Graphics/Busts这个文件夹里面拷贝一个
- # 叫做Actor1_0的图像,这个图像会被当做半身像替换原有图像。
- #==============================================================================
- # 2013.8.25 => 修复存档不能Bug (感谢小刀
- #==============================================================================
- $imported ||= {}
- $imported[:LBQ_Bust]=true
- module LBQ
- module Bust
- FOLDER="Busts"
- SUB1=[/【/, ""]
- SUB2=[/】/, ""]
- TEXT_FOR_NEXT="[next]"
- TEXT_FOR_END ="[end]"
- INDENT=255 #半身像的缩进
- end
- end
- module Cache
- def self.busts(filename)
- load_bitmap("Graphics/#{LBQ::Bust::FOLDER}/", filename)
- end
- end
复制代码
对话显示姓名- =begin
- ===============================================================================
- 对话显示姓名 By喵呜喵5
- ===============================================================================
- 【说明】
- 通过在对话中加入
- \name[姓名]
- 可以在对话中显示姓名
- =end
- $m5script ||= {};raise("需要喵呜喵5基础脚本的支持") unless $m5script[:M5Base]
- $m5script[:M5Name20141004] = 20141004;M5script.version(20140916)
- module M5Name20141004
- #==============================================================================
- # 设定部分
- #==============================================================================
- FONT = "黑体"
-
- # 姓名所使用的字体
-
- SIZE = 20
-
- # 姓名字体的大小
-
- COLOR = Color.new(0,0,0,255)
-
- # 姓名的颜色,四个数值分别是R、G、B以及透明度
-
- SET = [false,false,false,true]
-
- # 中括号中以逗号分隔开的单词分别设置姓名是否加粗、斜体、有阴影、加边框
- # 需要的话填写true,不需要的话填写false
-
- OUT_COLOR = Color.new(-255, -255, -255, 0)
-
- # 姓名边框的颜色,四个数值分别是R、G、B以及透明度
-
- ALIGN = 0
-
- # 姓名的对齐方式,0,1,2分别是居左、居中、居右
-
- NAME_X = - 10
-
- # 姓名的X坐标,数值越大姓名位置越靠近屏幕右侧
-
- NAME_Y = 2
-
- # 姓名的Y坐标,数值越大姓名位置越靠近屏幕底部
-
- DISTANCE = 1
-
- # 对话与姓名的间距,数字越大间距越大
-
- BACK_Y = 0
-
- # 姓名背景的Y坐标,数值越大姓名位置越靠近屏幕底部
-
- BACK_HEIGHT = 5
-
- # 姓名背景的高度,数字越大高度越大
- COLOR1 = Color.new(255, 255, 255, 200)
-
- # 姓名的背景框左边的颜色,四个数值分别是R、G、B以及透明度
-
- COLOR2 = Color.new(255, 255, 255, 0)
-
- # 姓名的背景框右边的颜色,四个数值分别是R、G、B以及透明度
- # 不需要背景的话,两个颜色的透明度都填0就好了
-
- #==============================================================================
- # 设定结束
- #==============================================================================
- end
- class Window_Message
- alias m5_20141004_convert_escape_characters convert_escape_characters
- def convert_escape_characters *arg
- @m5_name = nil
- result = m5_20141004_convert_escape_characters *arg
- result.gsub!(/\eNAME\[(.+)\]/i) { @m5_name = $1; "" }
- result
- end
- alias m5_20141004_draw_face draw_face
- def draw_face *arg
- if @m5_name
- temp_font = contents.font.m5_return_all_setting
- contents.font.name = M5Name20141004::FONT
- contents.font.size = M5Name20141004::SIZE
- contents.font.color = M5Name20141004::COLOR
- contents.font.out_color = M5Name20141004::OUT_COLOR
-
- contents.font.bold = M5Name20141004::SET[0]
- contents.font.italic = M5Name20141004::SET[1]
- contents.font.shadow = M5Name20141004::SET[2]
- contents.font.outline = M5Name20141004::SET[3]
-
- name_height = text_size(@m5_name).height
- m5_20141004_draw_back(name_height)
- draw_text([new_line_x + M5Name20141004::NAME_X,0].max,
- M5Name20141004::NAME_Y,self.width - new_line_x,
- name_height +[M5Name20141004::NAME_Y,0].max,@m5_name,
- M5Name20141004::ALIGN)
- contents.font.m5_set_all_setting(temp_font)
- @m5_name = name_height
- end
- m5_20141004_draw_face *arg
- end
- def m5_20141004_draw_back(height)
- rect = Rect.new(0, M5Name20141004::BACK_Y, self.width,
- height + M5Name20141004::BACK_HEIGHT)
- contents.gradient_fill_rect(rect,
- M5Name20141004::COLOR1, M5Name20141004::COLOR2)
- end
- alias m5_20141004_new_page new_page
- def new_page(text, pos)
- m5_20141004_new_page(text, pos)
- if @m5_name
- pos[:y] += @m5_name + M5Name20141004::DISTANCE
- end
- end
- end
复制代码
RMVA加点系统正常向-v1.03- #encoding:utf-8
- #=============================================================================
- #-----------RMVA加点系统正常向-v1.03---By:救世小树--------转载请注明出处-------
- #=============================================================================
- module Point_Tree
-
- POINT_KIND = 6 #设定加点种类
- LEVEL_UP_POINT = 3 #每升一级自由属性点增加数
- RESET_ITEM = 20 #洗点水编号
-
- STR_POINT = ["体力","精神","力量","魔力","韧性","灵活","???"]
-
- #分别对应增加 [MHP,MMP,物攻,物防,魔攻,魔防,敏捷,幸运]
- POINT_ADD_PARAM = [[12 , 0, 0, 0, 0, 0, 0, 0], #体力
- [0 , 12, 0, 0, 0, 0, 0, 0], #精神
- [0 , 0, 5, 0, 0, 0, 0, 0], #力量
- [0 , 0, 0, 0, 5, 0, 0, 0], #魔力
- [0 , 0, 0, 3, 0, 2, 0, 1], #韧性
- [0 , 0, 0, 0, 0, 0, 3, 0], #灵活
-
- [0,0,0,0,0,0,0,0]]
- #可以按上面的格式添加下去,不过要改POINT_KIND,STR_ALL,不然加了也白加
-
- #分别对应增加 [物理命中,物理闪避,必杀,必杀闪避,魔法闪避,魔法反射,物理反击,HP再生,Mp再生,Tp再生]
- POINT_ADD_XPARAM = [[0 , 0, 0, 0, 0, 0, 0, 6, 0, 0],
- [0 , 0, 0, 0, 0, 0, 0, 0, 6, 0],
- [6 , 6, 0, 0, 0, 0, 0, 0, 0, 0],
- [0 , 0, 6, 0, 0, 0, 0, 0, 0, 0],
- [0 , 0, 0, 0, 0, 0, 0, 4, 4, 0],
- [0 , 6, 0, 6, 6, 0, 0, 0, 0, 0],
-
- [0,0,0,0,0,0,0,0,0,0]]
- #这里的单位是万分之一数值也就是0.01%,我随便填了下【别嫌小,够大了,有心情你可以算算看平衡性】
-
- #各种名称
-
- ADDPOINT = "加点" #菜单中选项
- POINT_NAME = "属性点" #未分配点数
-
- XARAM_NAME = ["物理命中","物理闪避","必杀","必杀闪避","魔法闪避","魔法反射","物理反击","HP再生","Mp再生","Tp再生"]
-
- def temp_all
- r = 0
- for i in 0 .. POINT_KIND-1
- r+=$temp_point[i]
- end
- return r
- end
-
- def reset(actor_id)
- for i in 1..6
- $game_actors[actor_id].point[0] += $game_actors[actor_id].point[i]
- $game_actors[actor_id].point[i] =0
- end
- end
-
- end
- $temp_point = []
- for i in 0 .. Point_Tree::POINT_KIND-1
- $temp_point.push(0)
- end
- class Game_Actor < Game_Battler
- include Point_Tree
- attr_accessor :point
-
- alias setup_tre setup
- def setup(actor_id)
- @point = []
- for i in 0 .. POINT_KIND
- @point.push(0)
- end
- setup_tre(actor_id)
- end
-
-
-
-
- alias level_up_tre level_up
- def level_up
- level_up_tre
- @hp += mhp
- @mp += mmp
- @point[0] += LEVEL_UP_POINT
- end
-
-
- def point_plus(param_id)
- r=0
- for i in 1 .. POINT_KIND
- r+=@point[i]*POINT_ADD_PARAM[i-1][param_id]
- end
- return r
- end
- alias point_base_param param
-
- def param(param_id)
- value = param_base(param_id) + param_plus(param_id) + point_plus(param_id)
- value *= param_rate(param_id) * param_buff_rate(param_id)
- [[value, param_max(param_id)].min, param_min(param_id)].max.to_i
- end
- def xparam(xparam_id,extra_add = 0)
- xp = super(xparam_id)
- for i in 0 .. POINT_KIND-1
- xp+=(@point[i+1]*POINT_ADD_XPARAM[i][xparam_id]/10000.0)
- end
- return xp
- end
- def item_apply(user, item)
- super(user, item)
- if item.id == RESET_ITEM and item.is_a?(RPG::Item)
- reset(@actor_id)
- self.hp = [self.hp,self.mhp].min
- self.mp = [self.mp,self.mmp].min
- end
- end
-
- end
- class Window_Point_Command < Window_Command
-
- include Point_Tree
- #--------------------------------------------------------------------------
- # ● 初始化指令选择位置(类方法)
- #--------------------------------------------------------------------------
- def self.init_command_position
- @@last_command_symbol = nil
- end
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(actor)
- @status_window = nil
- @actor = actor
- super(0,0)
- select_last
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- def status_window=(status_window)
- return if @status_window == status_window
- @status_window = status_window
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return 160
- end
- #--------------------------------------------------------------------------
- # ● 获取显示行数
- #--------------------------------------------------------------------------
- def visible_line_number
- item_max
- end
- def get_actor_point(index)
- s = @actor.point[index+1].to_s
- return "("+s+")+"+$temp_point[index].to_s
- end
- #--------------------------------------------------------------------------
- # ● 生成指令列表
- #--------------------------------------------------------------------------
- def make_command_list
- for i in 0 .. POINT_KIND-1
- add_command(STR_POINT[i] + get_actor_point(i) , :point_add ,add_enabled)
- end
- add_command("确认", :point_ok)
- add_command("取消", :point_cancle)
- end
- #--------------------------------------------------------------------------
- # ● 按下确定键时的处理
- #--------------------------------------------------------------------------
- def process_ok
- @@last_command_symbol = current_symbol
- super
- end
- #--------------------------------------------------------------------------
- # ● 返回最后一个选项的位置
- #--------------------------------------------------------------------------
- def select_last
- select_symbol(@@last_command_symbol)
- end
-
- def add_enabled
- temp_all < @actor.point[0]
- end
- def update_help
- @help_window.set_text(self.index+1) if @help_window
- @status_window.index = self.index if @status_window
- end
- end
- #帮助窗口
- class Window_Point_Help < Window_Base
- include Point_Tree
- def initialize(x,y,w,h)
- super(x, y, w, h)
-
-
- end
- def set_text(id)
- contents.clear
- if id <= POINT_KIND
- text = "\\}提升一点该属性"
- elsif id == POINT_KIND+1
- text = "\\}确认此次加点分配"
- elsif id == POINT_KIND+2
- text = "\\}取消此次加点分配"
- end
- draw_text_ex(8, 8, text)
- end
- end
- #角色状态窗口
- class Window_Point_Actor < Window_Base
- include Point_Tree
-
-
- def initialize(actor)
- super(160, 0, Graphics.width - 160, Graphics.height)
- @actor = actor
- @index = 0
- refresh
- end
- def actor=(actor)
- return if @actor == actor
- @actor = actor
- refresh
- end
- def index=(index)
- return if @index == index
- @index = index
- refresh
- end
- def line_height
- return 24
- end
- def refresh
- contents.clear
- contents.font.size = 24
- draw_actor_name(@actor, 100, 0)
- draw_actor_class(@actor, 240, 0)
- draw_actor_face(@actor, 2, 0)
- contents.font.size = 20
- draw_actor_level(@actor, 102, 24)
- draw_actor_point(100,48)
- contents.font.size = 16
- draw_actor_param_point(8,16 * 6)
- draw_actor_xparam_point(8,16 * 14)
- end
- def draw_actor_point(x,y)
- draw_text(x,y,200,line_height," 未分配"+POINT_NAME + ":" + @actor.point[0].to_s)
- draw_text(x,y+line_height,200,line_height,"此次分配"+POINT_NAME + ":" + temp_all.to_s)
- end
- def draw_actor_param_point(x,y)
- 8.times {|i| draw_actor_param_to_s(x,y,i)}
- end
- def draw_actor_xparam_point(x,y)
- 10.times {|i| draw_actor_xparam_to_s(x,y,i)}
- end
-
- def draw_actor_param_to_s(x,y,param_id)
- a=0
- for i in 0 .. POINT_KIND-1
- a+=$temp_point[i]*POINT_ADD_PARAM[i][param_id]
- end
- s1 = Vocab::param(param_id)
- s2 = @actor.param(param_id).to_s
- s3 = (@actor.param(param_id)+a).to_s
- if @index < POINT_KIND
- if POINT_ADD_PARAM[@index][param_id]==0
- s4 = ""
- else
- s4 = "+" + POINT_ADD_PARAM[@index][param_id].to_s
- end
- else
- s4 = ""
- end
-
- change_color(system_color)
- draw_text(x,y+16*param_id,100,line_height,s1)
- change_color(normal_color)
- s2+= " →"
- draw_text(x+82,y+16*param_id,120,line_height,s2,2)
- change_color(system_color)
- draw_text(x+150,y+16*param_id,100,line_height,s3,2)
- change_color(normal_color)
- contents.font.size = 14
- draw_text(x+266,y+16*param_id,100,line_height,s4)
- contents.font.size = 16
- end
- def draw_actor_xparam_to_s(x,y,xparam_id)
- a=0.00
- for i in 0 .. POINT_KIND-1
- a+=($temp_point[i]*POINT_ADD_XPARAM[i][xparam_id]/10000.0)
- end
- s1 = XARAM_NAME[xparam_id]
- s2 = sprintf("%02.2f%%",@actor.xparam(xparam_id)*100)
- s3 = sprintf("%02.2f%%",(@actor.xparam(xparam_id) + a)*100)
- if @index < POINT_KIND
- if POINT_ADD_XPARAM[@index][xparam_id]==0
- s4=""
- else
- s4 = sprintf("+%02.2f%%",POINT_ADD_XPARAM[@index][xparam_id]/100.0)
- end
- else
- s4 = ""
- end
-
- change_color(system_color)
- draw_text(x,y+16*xparam_id,100,line_height,s1)
- change_color(normal_color)
- s2+= " →"
- draw_text(x+82,y+16*xparam_id,120,line_height,s2,2)
- change_color(system_color)
- draw_text(x+150,y+16*xparam_id,100,line_height,s3,2)
- change_color(normal_color)
- contents.font.size = 14
- draw_text(x+266,y+16*xparam_id,100,line_height,s4)
- contents.font.size = 16
-
-
- end
- end
- class Scene_Point < Scene_Base
- include Point_Tree
- def start
- super
- create_background
- @actor = $game_party.menu_actor
- create_command_window
- create_status_window
- create_help_window
- @command_window.activate
- end
- def terminate
- super
- dispose_background
- end
- def create_background
- @background_sprite = Sprite.new
- @background_sprite.bitmap = SceneManager.background_bitmap
- @background_sprite.color.set(16, 16, 16, 128)
- end
- def dispose_background
- @background_sprite.dispose
- end
-
- def create_command_window
- @command_window = Window_Point_Command.new(@actor)
- @command_window.set_handler(:cancel, method(:return_scene))
- @command_window.set_handler(:pagedown, method(:next_actor))
- @command_window.set_handler(:pageup, method(:prev_actor))
- @command_window.set_handler(:point_add, method(:add_point))
- @command_window.set_handler(:point_ok, method(:add_ok))
- @command_window.set_handler(:point_cancle,method(:add_cancle))
-
- end
- def return_scene
- add_cancle
- SceneManager.return
- end
- def create_status_window
- @status_window = Window_Point_Actor.new(@actor)
- @command_window.status_window = @status_window
- end
- def create_help_window
- @help_window = Window_Point_Help.new(0,@command_window.height,160,Graphics.height-@command_window.height)
- #(0, 216, 160, 200)
- @help_window.viewport = @viewport
- @command_window.help_window = @help_window
- end
-
- def add_point
- if temp_all >= @actor.point[0]
- @command_window.activate
- return
- end
- $temp_point[@command_window.index] += 1
- @status_window.refresh
- @command_window.refresh
- @command_window.activate
- end
-
- def add_ok
- for i in 0 .. POINT_KIND-1
- @actor.point[i+1] += $temp_point[i]
- end
- @actor.point[0]-= temp_all
- add_cancle
- end
-
- def add_cancle
- for i in 0 .. POINT_KIND-1
- $temp_point[i]=0
- end
- @status_window.refresh
- @command_window.refresh
- @command_window.activate
- end
-
-
- def next_actor
- @actor = $game_party.menu_actor_next
- on_actor_change
- end
- #--------------------------------------------------------------------------
- # ● 切换到上一个角色
- #--------------------------------------------------------------------------
- def prev_actor
- @actor = $game_party.menu_actor_prev
- on_actor_change
- end
- #--------------------------------------------------------------------------
- # ● 切换角色
- #--------------------------------------------------------------------------
- def on_actor_change
- add_cancle
- @status_window.actor = @actor
- @command_window.actor = @actor
- @command_window.activate
- end
-
- end
- class Window_MenuCommand < Window_Command
- alias add_original_commands_old add_original_commands
- def add_original_commands
- add_original_commands_old
- add_command(Point_Tree::ADDPOINT, :addpoint)
- end
- end
- class Scene_Menu < Scene_MenuBase
- alias create_command_window_old create_command_window
- def create_command_window
- create_command_window_old
- @command_window.set_handler(:addpoint,method(:add_point))
- end
- def add_point
- @status_window.select_last
- @status_window.activate
- @status_window.set_handler(:ok, method(:on_ok))
- @status_window.set_handler(:cancel, method(:on_personal_cancel))
- end
- def on_ok
- SceneManager.call(Scene_Point)
- Window_Point_Command::init_command_position
- end
- end
- class Scene_ItemBase < Scene_MenuBase
- def item_usable?
- if item.id == Point_Tree::RESET_ITEM and item.is_a?(RPG::Item)
- return true
- end
- user.usable?(item) && item_effects_valid?
- end
- end
- class Window_Status < Window_Selectable
- include Point_Tree
- alias draw_parameters_old draw_parameters
- def draw_parameters(x, y)
- draw_parameters_old(x,y)
- draw_point(x,y)
- end
- def draw_point(x,y)
- for i in 0..5
- change_color(system_color)
-
-
- draw_text(x+100, y+ line_height * i, 80, line_height, STR_POINT[i])
- change_color(normal_color)
- draw_text(x+180, y+ line_height * i, 36, line_height,@actor.point[i+1].to_s, 2)
- end
- end
-
- end
- class Window_Base < Window
- def draw_actor_param(actor, x, y, param_id)
- change_color(system_color)
- draw_text(x-30, y, 80, line_height, Vocab::param(param_id))
- change_color(normal_color)
- draw_text(x+ 50, y, 36, line_height, actor.param(param_id), 2)
- end
- end
复制代码
简易式存档界面- =begin
- ===============================================================================
- 简易式存档界面 By喵呜喵5
- ===============================================================================
- 【说明】
-
- 给存档数目只有一个的游戏使用的简易式存档界面
-
- 在事件中使用脚本“load”可以快速读档(适用于使用事件作为标题菜单的情况)
-
- =end
- module M5SimpleSave
- #==============================================================================
- # 设定部分
- #==============================================================================
-
- SAVE_NAME = "SAVE"
- #存档的文件名
-
- SAVE_OPTION = "保存记录"
- #存档按钮的提示文字
-
- CANCLE_OPTION = "回到游戏"
- #取消按钮的提示文字
-
- SAVING_HINT = "保存中"
- #存档时的提示文字
-
- SAVE_HINT = "记录已保存"
- #存档完成时的提示文字
-
- SAVE_SE = "Save"
- #存档完成时播放的音效
-
- LOAD_SE = "Load"
- #读档完成时播放的音效
-
- LOAD_ERROR = "没有发现可以使用的存档"
- #读档失败时的提示文字
-
- LOAD_ERROR_SE = "Buzzer1"
- #读档失败时播放的音效
-
- #==============================================================================
- # 设定结束
- #==============================================================================
- end
- class Window_Hint < Window_Base
- def initialize(x = 0,y = 90,height = 80)
- super(x,y,Graphics.width, height)
- end
- def write_text(text)
- contents.clear
- draw_text(0,0,Graphics.width,fitting_height(1),text,1)
- end
- def line_height
- Font.default_size
- end
- end
- class Window_SimpleSave < Window_Command
- def initialize
- super(0, 0)
- update_placement
- self.openness = 0
- open
- end
- def window_width
- 160
- end
- def update_placement
- self.x = (Graphics.width - width) / 2
- self.y = (Graphics.height - height) / 2
- end
- def make_command_list
- add_command(M5SimpleSave::SAVE_OPTION, :save)
- add_command(M5SimpleSave::CANCLE_OPTION, :cancel)
- end
- def alignment
- return 1
- end
- end
- class Scene_SimpleSave < Scene_MenuBase
- def start
- super
- create_command_window
- end
- def pre_terminate
- super
- close_command_window
- end
- def create_command_window
- @command_window = Window_SimpleSave.new
- @command_window.set_handler(:save, method(:command_save))
- @command_window.set_handler(:cancel, method(:return_scene))
- end
- def close_command_window
- @command_window.close
- update until @command_window.close?
- end
- def command_save
- DataManager.save_game(1)
- hint = Window_Hint.new
- Graphics.wait(10)
- 5.times {|i| hint.write_text(M5SimpleSave::SAVING_HINT+"."*(i+1)); Graphics.wait(20)}
- Graphics.wait(40)
- Audio.se_play("Audio/SE/"+M5SimpleSave::SAVE_SE)
- hint.write_text(M5SimpleSave::SAVE_HINT)
- Graphics.wait(10)
- loop do
- Input.update
- break if Input.trigger?(:C)
- end
- hint.dispose
- return_scene
- end
- end
- class << DataManager
- def make_filename(index)
- M5SimpleSave::SAVE_NAME
- end
- def savefile_max
- 1
- end
- def save_file_exists?
- !Dir.glob(M5SimpleSave::SAVE_NAME).empty?
- end
- end
- class Scene_File
- def visible_max
- 1
- end
- end
- class Game_Interpreter
- def load
- if FileTest.exist?(M5SimpleSave::SAVE_NAME)
- load_success
- else
- load_error
- end
- end
- def save
- SceneManager.call(Scene_SimpleSave)
- end
- def load_success
- Audio.se_play("Audio/SE/"+M5SimpleSave::LOAD_SE)
- DataManager.load_game(1)
- RPG::BGM.fade(1000)
- RPG::BGS.fade(1000)
- RPG::ME.fade(1000)
- Graphics.fadeout(1000 * Graphics.frame_rate / 1000)
- RPG::BGM.stop
- RPG::BGS.stop
- RPG::ME.stop
- $game_system.on_after_load
- SceneManager.goto(Scene_Map)
- end
- def load_error
- Audio.se_play("Audio/SE/"+M5SimpleSave::LOAD_ERROR_SE)
- hint = Window_Hint.new(0,Graphics.height/2 - 40)
- hint.write_text(M5SimpleSave::LOAD_ERROR)
- Graphics.wait(10)
- loop do
- Input.update
- break if Input.trigger?(:C)
- end
- hint.dispose
- end
- end
- Scene_Save = Scene_SimpleSave
复制代码
Symbol- #encoding:utf-8
- #==============================================================================
- # ■ Symbol
- #------------------------------------------------------------------------------
- # 。
- #==============================================================================
- $apicache = {}
- class Symbol
- #--------------------------------------------------------------------------
- # ● 轉為Win32API
- #--------------------------------------------------------------------------
- def to_api
- $apicache[self] = Win32API.new(*self.to_s.split("|")) unless $apicache.include? self
- return $apicache[self]
- end
- #--------------------------------------------------------------------------
- # ● 轉為Win32API並呼叫
- #--------------------------------------------------------------------------
- def apicall(*args)
- self.to_api.call(*args)
- end
- end
复制代码
MainWindow- #encoding:utf-8
- # 纯脚本不使用DLL就读取窗口消息
- # By 晴兰 form 66RPG
- # 功能擴充 By AAM@_@
- #==============================================================================
- # ■ MainWindow
- #------------------------------------------------------------------------------
- # 。
- #==============================================================================
- module MainWindow
- #--------------------------------------------------------------------------
- # ● 部分Windows消息定义
- #--------------------------------------------------------------------------
- WM_CREATE = 0x0001
- WM_DESTROY = 0x0002
- WM_MOVE = 0x0003
- WM_SIZE = 0x0005
-
- WM_ACTIVATE = 0x0006
- WM_ACTIVATEAPP = 0x001C
- WM_GETTEXT = 0x000D
- WM_GETTEXTLENGTH = 0x000E
- WM_PAINT = 0x000F
- WM_CLOSE = 0x0010
- WM_QUERYENDSESSION = 0x0011
- WM_QUIT = 0x0012
-
- WM_KEYDOWN = 0x0100
- WM_KEYUP = 0x0101
- WM_CHAR = 0x0102
- WM_SYSKEYDOWN = 0x0104
- WM_SYSKEYUP = 0x0105
- WM_SYSCHAR = 0x0106
- WM_COMMAND = 0x0111
- WM_SYSCOMMAND = 0x0112
- WM_TIMER = 0x0113
- WM_MOUSEMOVE = 0x0200
- WM_LBUTTONDOWN = 0x0201
- WM_LBUTTONUP = 0x0202
- WM_LBUTTONDBLCLK = 0x0203
- WM_RBUTTONDOWN = 0x0204
- WM_RBUTTONUP = 0x0205
- WM_RBUTTONDBLCLK = 0x0206
- WM_MBUTTONDOWN = 0x0207
- WM_MBUTTONUP = 0x0208
- WM_MBUTTONDBLCLK = 0x0209
- WM_MOUSEWHEEL = 0x020A
-
- RM_F1MENU_OPEN = 0x0112
- RM_F1MENU_CLOSE = 0x0125
- #--------------------------------------------------------------------------
- # ● 其他常量定义
- #--------------------------------------------------------------------------
- WA_INACTIVE = 0
- WA_ACTIVE = 1
- WA_CLICKACTIVE = 2
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- @@ShowCursor = :"user32|ShowCursor|i|l".to_api
- @@handle = false # 禁用默认窗口过程
- @@procs = {}
- @@child_procs = {}
- @@child_callback = {}
- @@child_def_procs = {}
- #--------------------------------------------------------------------------
- # ● 窗口过程函数 ※ 该名字切勿更改
- #--------------------------------------------------------------------------
- def self.wnd_proc(hwnd,msg,wparam,lparam)
- # 消息分歧
- case msg
- when WM_CREATE
- when WM_MOVE
- when WM_ACTIVATEAPP
- if wparam == WA_INACTIVE
- #SNSER.chn_pause_all
- Input.lock_all_key
- @@ShowCursor.call(1)
- else
- #SNSER.chn_resume_all
- Input.unlock_all_key
- @@ShowCursor.call(0)
- end
- when WM_LBUTTONDOWN
- Input.key_down(Input::M_L)
- when WM_LBUTTONUP
- Input.key_up(Input::M_L)
- when WM_LBUTTONDBLCLK
- Input.set_dbclick(Input::M_L)
- when WM_RBUTTONDOWN
- Input.key_down(Input::M_R)
- when WM_RBUTTONUP
- Input.key_up(Input::M_R)
- when WM_RBUTTONDBLCLK
- Input.set_dbclick(Input::M_R)
- when WM_MBUTTONDOWN
- Input.key_down(Input::M_M)
- when WM_MBUTTONUP
- Input.key_up(Input::M_M)
- when WM_MBUTTONDBLCLK
- Input.set_dbclick(Input::M_M)
- when WM_MOUSEWHEEL
- Input.set_mouse_wheel(wparam)
- when WM_MOUSEMOVE
- Input.set_mouse_pos(lparam)
- when WM_KEYDOWN
- Input.key_down(wparam)
- when WM_KEYUP
- Input.key_up(wparam)
- when WM_SYSKEYDOWN
- Input.key_down(wparam)
- when WM_SYSKEYUP
- Input.key_up(wparam)
- when WM_SIZE
- when RM_F1MENU_OPEN
- @@ShowCursor.call(1)
- when RM_F1MENU_CLOSE
- @@ShowCursor.call(0)
- else
- end
- # 調用其他外插的視窗訊息
- if !@@procs.empty?
- @@procs.each_value do |i|
- begin
- i.call(hwnd,msg,wparam,lparam)
- rescue
- end
- end
- end
- # 调用默认窗口过程
- self.use_rm_proc(hwnd,msg,wparam,lparam)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.add_proc(symbol, method)
- @@procs[symbol] = method
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.remove_proc(symbol)
- @@procs.delete(symbol)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.use_rm_proc(hwnd, msg, wp, lp)
- return :"user32|CallWindowProc|iiiii|i".apicall(@@oHandle, hwnd, msg, wp, lp) if !@@handle
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.disable_rm_proc
- @@handle = true
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.enable_rm_proc
- @@handle = false
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.child_def_proc(symbol, hwnd, msg, wp, lp)
- return :"user32|CallWindowProc|iiiii|i".apicall(@@child_def_procs[hwnd], hwnd, msg, wp, lp)
- end
- #--------------------------------------------------------------------------
- # ● ??? ※ 该名字切勿更改
- #--------------------------------------------------------------------------
- def self.child_wnd_proc(symbol, hwnd, msg, wparam, lparam)
- begin
- @@child_procs[symbol].call(hwnd,msg,wparam,lparam)
- rescue
- end
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.disableChildWndProc(hwnd)
- :"user32|SetWindowLong|iii|i".apicall(hwnd, -4, @@child_def_procs[hwnd])
- @@child_def_procs.delete(hwnd)
- :"msvcrt|free|i|i".apicall(@@child_callback[hwnd])
- @@child_callback.delete(hwnd)
- @@child_procs.delete(hwnd)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.enableChildWndProc(hwnd, proc)
- @@child_procs[hwnd] = proc
-
- @malloc = :"msvcrt|malloc|i|i"
- @memcpy = :"msvcrt|memcpy|ipi|v"
-
- sprintf = self.findProc("msvcrt", "sprintf")
- rgsseval = self.findProc("RGSS300", "RGSSGetInt")
- oHandle = :"user32|GetWindowLong|ll|l".apicall(hwnd, -4)
- buf = @malloc.apicall(1024)
- fmt = @malloc.apicall(2048)
- sprintfvar = @malloc.apicall(8)
- rgssevalvar= @malloc.apicall(8)
- oldvar = @malloc.apicall(8)
- fmtvar = @malloc.apicall(8)
- bufvar = @malloc.apicall(8)
- defvar = @malloc.apicall(8)
-
- @@child_def_procs[hwnd] = oHandle
-
- :"msvcrt|strcpy|pp|p".apicall(fmt, "MainWindow.child_wnd_proc(#{hwnd},%d,%d,%d,%d)")
-
- @memcpy.apicall(sprintfvar, [sprintf].pack("i"), 4)
- @memcpy.apicall(rgssevalvar,[rgsseval].pack("i"), 4)
- @memcpy.apicall(oldvar, [@@oHandle].pack("i"), 4)
- @memcpy.apicall(fmtvar, [fmt].pack("i"), 4)
- @memcpy.apicall(bufvar, [buf].pack("i"), 4)
- @memcpy.apicall(defvar, [oHandle].pack("i"), 4)
-
- code = [0x55,0x89,0xe5,0xff,0x75,0x14,
- 0xff,0x75,0x10,0xff,0x75,0x0c,
- 0xff,0x75,0x08,0xff,0x35].pack('C*')
- code << [fmtvar].pack('l') << [0xff, 0x35].pack('C*')
- code << [bufvar].pack('l') << [0xff, 0x15].pack('C*')
- code << [sprintfvar].pack("l")
- code << [0xff, 0x15].pack('C*')
- code << [rgssevalvar].pack("l")
- code << [0x83,0xc4,0x18].pack('C*')
- code << [0xc9,0xc2,0x10,0x00].pack('C*')
- #0xD1, 0xE8
- shellcode = @malloc.apicall(2048)
- @memcpy.apicall(shellcode, code, code.size)
- :"user32|SetWindowLong|iii|i".apicall(hwnd, -4, shellcode)
- @@child_callback[hwnd] = shellcode
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def self.enable
- MainWindow.instance_eval do
- # 清空 enable 方法(避免重複呼叫)
- def self.enable
- end
- # 取得 HWND
- @msg = "\0" * 24
- @hwnd = 0
- while @hwnd == 0
- :"user32|GetMessage|piii|v".apicall(@msg, 0, 0, 0)
- @kmsg = @msg
- :"user32|TranslateMessage|p|v".apicall(@kmsg)
- :"user32|DispatchMessage|p|v".apicall(@kmsg)
- @hwnd = @msg.unpack("i*")[0]
- end
- @hdc = :"user32|GetDC|i|i".apicall(@hwnd)
- # 方法:取得HWND
- def self.hwnd
- return @hwnd
- end
- # 方法:取得HDC
- def self.hdc
- return @hdc
- end
- # 方法:取得HWNDProc
- def self.findProc(l, n)
- lib = :"kernel32|LoadLibrary|p|i".apicall(l)
- ret = :"kernel32|GetProcAddress|ip|l".apicall(lib, n)
- :"kernel32|FreeLibrary|l|v".apicall(lib)
- return ret
- end
- # 方法:Hook HWNDProc
- def self.enableWndProc
- # 清空 enableWndProc 方法(避免重複呼叫)
- MainWindow.instance_eval do
- def self.enableWndProc
- end
- end
- @malloc = :"msvcrt|malloc|i|i"
- @memcpy = :"msvcrt|memcpy|ipi|v"
-
- sprintf = self.findProc("msvcrt", "sprintf")
- rgsseval = self.findProc("RGSS300", "RGSSGetInt")
- @@oHandle = :"user32|GetWindowLong|ll|l".apicall(@hwnd, -4)
- buf = @malloc.apicall(1024)
- fmt = @malloc.apicall(2048)
- sprintfvar = @malloc.apicall(8)
- rgssevalvar= @malloc.apicall(8)
- oldvar = @malloc.apicall(8)
- fmtvar = @malloc.apicall(8)
- bufvar = @malloc.apicall(8)
- defvar = @malloc.apicall(8)
-
- :"msvcrt|strcpy|pp|p".apicall(fmt, "MainWindow.wnd_proc(%d,%d,%d,%d)")
-
- @memcpy.apicall(sprintfvar, [sprintf].pack("i"), 4)
- @memcpy.apicall(rgssevalvar,[rgsseval].pack("i"), 4)
- @memcpy.apicall(oldvar, [@@oHandle].pack("i"), 4)
- @memcpy.apicall(fmtvar, [fmt].pack("i"), 4)
- @memcpy.apicall(bufvar, [buf].pack("i"), 4)
- @memcpy.apicall(defvar, [self.findProc("user32", "DefWindowProcA")].pack("i"), 4)
-
- @code = [0x55,0x89,0xe5,0xff,0x75,0x14,
- 0xff,0x75,0x10,0xff,0x75,0x0c,
- 0xff,0x75,0x08,0xff,0x35].pack('C*')
- @code << [fmtvar].pack('l') << [0xff, 0x35].pack('C*')
- @code << [bufvar].pack('l') << [0xff, 0x15].pack('C*')
- @code << [sprintfvar].pack("l")
- @code << [0xff, 0x15].pack('C*')
- @code << [rgssevalvar].pack("l")
- @code << [0x83,0xc4,0x18].pack('C*')
- @code << [0xc9,0xc2,0x10,0x00].pack('C*')
- #0xD1, 0xE8
- @shellcode = @malloc.apicall(2048)
- @memcpy.apicall(@shellcode, @code, @code.size)
- :"user32|SetWindowLong|iii|i".apicall(@hwnd, -4, @shellcode)
- end
- end
- end
- end
- MainWindow.enable
- MainWindow.enableWndProc
复制代码
String- #encoding:utf-8
- #==============================================================================
- # ■ String
- #------------------------------------------------------------------------------
- # 字符串类。可处理任意长度的字节串。 (追加编码转换的定义)
- #==============================================================================
- class String
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- CP_ACP = 0
- CP_UTF8 = 65001
- CP_UTF16 = 1200
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def u2s
- m2w = :"kernel32|MultiByteToWideChar|ilpipi|i".to_api
- w2m = :"kernel32|WideCharToMultiByte|ilpipipp|i".to_api
-
- len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
- buf = "\0" * (len*2)
- m2w.call(CP_UTF8, 0, self, -1, buf, buf.size/2)
-
- len = w2m.call(CP_ACP, 0, buf, -1, nil, 0, nil, nil)
- ret = "\0" * len
- w2m.call(CP_ACP, 0, buf, -1, ret, ret.size, nil, nil)
-
- return ret
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def s2u
- m2w = :"kernel32|MultiByteToWideChar|ilpipi|i".to_api
- w2m = :"kernel32|WideCharToMultiByte|ilpipipp|i".to_api
-
- len = m2w.call(CP_ACP, 0, self, -1, nil, 0);
- buf = "\0" * (len*2)
- m2w.call(CP_ACP, 0, self, -1, buf, buf.size/2);
-
- len = w2m.call(CP_UTF8, 0, buf, -1, nil, 0, nil, nil);
- ret = "\0" * len
- w2m.call(CP_UTF8, 0, buf, -1, ret, ret.size, nil, nil);
-
- return ret
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def u2w
- m2w = :"kernel32|MultiByteToWideChar|ilpipi|i".to_api
-
- len = m2w.call(CP_UTF8, 0, self, -1, nil, 0)
- buf = "\0" * (len*2)
- m2w.call(CP_UTF8, 0, self, -1, buf, len)
-
- return buf
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def w2u
- w2m = :"kernel32|WideCharToMultiByte|ilpipipp|i".to_api
-
- len = w2m.call(CP_UTF8, 0, self, -1, nil, 0, nil, nil)
- buf = "\0" * len
- w2m.call(CP_UTF8, 0, self, -1, buf, len, nil, nil)
-
- return buf
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def s2u!
- self[0, length] = s2u
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def u2s!
- self[0, length] = u2s
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def u2w!
- self[0, length] = u2u16
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def w2u!
- self[0, length] = u162u
- end
- end
复制代码
TextBox- #==============================================================================
- # ■ TextBox By AAM@_@
- #------------------------------------------------------------------------------
- # 输入框的类。
- #==============================================================================
- class TextBox
- #--------------------------------------------------------------------------
- # ● 设置API
- #--------------------------------------------------------------------------
- @@CreateWindow = :"user32|CreateWindowEx|lpplllllllll|l".to_api
- @@ShowWindow = :"user32|ShowWindow|ll|l".to_api
- @@DestroyWindow = :"user32|DestroyWindow|l|l".to_api
- @@SetWindowPos = :"user32|SetWindowPos|lllllll|l".to_api
- @@GetWindowRect = :"user32|GetWindowRect|ll|l".to_api
- @@GetWindowText = :"user32|GetWindowText|lpl|l".to_api
- @@GetWindowTextLength = :"user32|GetWindowTextLength|l|l".to_api
- @@SetWindowText = :"user32|SetWindowText|lp|l".to_api
- @@UpdateWindow = :"user32|UpdateWindow|l|i".to_api
- @@SetFocus = :"user32|SetFocus|l|l".to_api
- @@SendMessage = :"user32|SendMessage|llll|l".to_api
- @@SendMessage_Pos = :"user32|SendMessage|llpp|l".to_api
- @@CreateFont = :"gdi32|CreateFont|lllllllllllllp|l".to_api
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_accessor :focus
- attr_reader :font_name
- attr_reader :font_size
- attr_reader :password
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def default_font_name
- return Font.default_name if Font.default_name.is_a?(String)
- for i in Font.default_name
- return i if Font.exist?(i)
- end
- return ""
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def font_name=(f)
- @font_name = f
- update_font
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def font_size=(s)
- @font_size = s * 0.9
- update_font
- # Fix window height
- rect = "\0" * 16
- @@GetWindowRect.call(@window, rect)
- rect = rect.unpack("l*")
- @@SetWindowPos.call(@window, 0, rect[0], rect[1], @width, @font_size, 0)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def update_font
- hFont = @@CreateFont.call(@font_size,@font_size/2,0,0,0,0,0,0,0,0,0,0,0,@font_name.u2s)
- @@SendMessage.call(@window, 0x30, hFont, 0) # WM_SETFONT
- end
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(text = "", limit = 8, password = false, width = 160, direct_show = false, font_name = default_font_name, font_size = Font.default_size)
- @password = password
- @width = width
- @direct_show = direct_show
- @font_name = font_name
- @font_size = font_size * 0.9
- c = 0x40000000
- c |= 0x00000020 if password # ES_PASSWORD
- @window = @@CreateWindow.call(0, 'EDIT', text.u2s, c, 0, 0, @width, @font_size, MainWindow.hwnd, 0, 0, 0)
- if @direct_show
- mc = :"user32|GetWindowLong|ll|l".apicall(MainWindow.hwnd, -16) # GWL_STYLE
- mc |= 0x02000000 # WS_CLIPCHILDREN
- :"user32|SetWindowLong|lll|l".apicall(MainWindow.hwnd, -16, mc) # GWL_STYLE
- end
- @@ShowWindow.call(@window, 5) if @direct_show
- @@SendMessage.call(@window, 0xC5, limit, 0) # WM_SETLIMITTEXT
- update_font
- MainWindow.enableChildWndProc(@window, method(:wnd_proc))
- @enter_pressed = false
- @focus = true
- @disposed = false
- end
- #--------------------------------------------------------------------------
- # ● 窗口过程函数
- #--------------------------------------------------------------------------
- def wnd_proc(hwnd, msg, wp, lp)
- if hwnd == @window and msg == MainWindow::WM_CHAR and wp == 0x0D # Enter
- @enter_pressed = true
- end
- MainWindow.child_def_proc(@window, hwnd, msg, wp, lp)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- @disposed = true
- MainWindow.disableChildWndProc(@window)
- @@DestroyWindow.call(@window)
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- return if !@focus or @disposed
- if @direct_show
- @@UpdateWindow.call(@window)
- else
- @@SendMessage.call(@window, 0xB1, sel_spos, sel_epos)
- end
- @@SetFocus.call(@window)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def set_pos(x, y)
- @@SetWindowPos.call(@window, 0, x, y, @width, @font_size, 0)
- end
- #--------------------------------------------------------------------------
- # ● 获取内容
- #--------------------------------------------------------------------------
- def text
- return if @disposed
- l = @@GetWindowTextLength.call(@window) + 1
- str = "\0" * l
- @@GetWindowText.call(@window, str, l)
- return str.s2u.strip!
- end
- #--------------------------------------------------------------------------
- # ● 更改内容
- #--------------------------------------------------------------------------
- def text=(str)
- return if @disposed
- @@SetWindowText.call(@window, str.u2s)
- self.sel_pos = str.u2s.size - 1
- str
- end
- #--------------------------------------------------------------------------
- # ● 获取起始光标位置
- #--------------------------------------------------------------------------
- def sel_spos
- return if @disposed
- #return @@SendMessage.call(@window, 0xB0, 0, 0) & 0xFFFF
- spos = "\0" * 4
- @@SendMessage_Pos.call(@window, 0xB0, spos, 0)
- return spos.unpack("l")[0]
- end
- #--------------------------------------------------------------------------
- # ● 获取結束光标位置
- #--------------------------------------------------------------------------
- def sel_epos
- return if @disposed
- #return @@SendMessage.call(@window, 0xB0, 0, 0) >> 16
- epos = "\0" * 4
- @@SendMessage_Pos.call(@window, 0xB0, 0, epos)
- return epos.unpack("l")[0]
- end
- #--------------------------------------------------------------------------
- # ● 设置光标位置
- #--------------------------------------------------------------------------
- def sel_spos=(i)
- return if @disposed
- @@SendMessage.call(@window, 0xB1, i, sel_epos)
- end
- #--------------------------------------------------------------------------
- # ● 设置光标位置
- #--------------------------------------------------------------------------
- def sel_epos=(i)
- return if @disposed
- @@SendMessage.call(@window, 0xB1, sel_spos, i)
- end
- #--------------------------------------------------------------------------
- # ● 设置光标位置
- #--------------------------------------------------------------------------
- def sel_pos=(i)
- return if @disposed
- @@SendMessage.call(@window, 0xB1, i, i)
- end
- #--------------------------------------------------------------------------
- # ● 获取字數限制
- #--------------------------------------------------------------------------
- def limit
- return if @disposed
- return @@SendMessage.call(@window, 0xD5, 0, 0)
- end
- #--------------------------------------------------------------------------
- # ● 设置字數限制
- #--------------------------------------------------------------------------
- def limit=(i)
- return if @disposed
- @@SendMessage.call(@window, 0xC5, i, 0)
- end
- #--------------------------------------------------------------------------
- # ● 是否按下回车键(0x0D => Enter, 0x1B => ESC)
- #--------------------------------------------------------------------------
- def press_enter?
- return !(@enter_pressed = false) if @enter_pressed
- return false
- end
- end
复制代码
Window_Help- #==============================================================================
- # ■ Window_Help
- #------------------------------------------------------------------------------
- # スキルやアイテムの説明、アクターのステータスなどを表示するウィンドウです。
- #==============================================================================
- class Window_Help < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(line_number = 2, width = Graphics.width)
- super(0, 0, width, fitting_height(line_number))
- end
- end
复制代码
Window_TextBox- #encoding:utf-8
- #==============================================================================
- # ■ Window_TextBox By AAM@_@
- #------------------------------------------------------------------------------
- # 显示输入框用的窗口。
- #==============================================================================
- class Window_TextBox < Window_Base
- #--------------------------------------------------------------------------
- # ● 设置缓存的类
- #--------------------------------------------------------------------------
- TextBoxMem = Struct.new(:text, :sel_spos, :sel_epos)
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :textbox
- attr_reader :sel_pos
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(x, y, width = 160, password = false)
- super(x, y, width, window_height)
- @handler = nil
- @textbox = TextBox.new("", 8, password, width - standard_padding * 2)
- @textbox.set_pos(self.x + standard_padding, self.y + standard_padding)
- @tbmem = TextBoxMem.new
- @curcor = Sprite.new
- @curcor.bitmap = Bitmap.new(2, line_height)
- @curcor.bitmap.fill_rect(@curcor.bitmap.rect, system_color)
- @curcor.visible = false
- @curcor.x = self.x + standard_padding
- @curcor.y = self.y + standard_padding
- @curcor.z = self.z + 1
- @selection_color = system_color.clone
- @selection_color.alpha = 128
- refresh
- activate
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的高度
- #--------------------------------------------------------------------------
- def window_height
- fitting_height(1)
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def x=(x)
- super
- @textbox.set_pos(self.x + standard_padding, self.y + standard_padding)
- update_cursor_pos
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def y=(y)
- super
- @textbox.set_pos(self.x + standard_padding, self.y + standard_padding)
- @curcor.y = y + standard_padding
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def z=(z)
- super
- @curcor.z = z + 1
- end
- #--------------------------------------------------------------------------
- # ●
- #--------------------------------------------------------------------------
- def viewport=(viewport)
- super
- @curcor.viewport = viewport
- end
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def update
- super
- if !@textbox.focus
- @curcor.visible = false
- return
- end
- @textbox.update
- refresh if @textbox.sel_spos != @tbmem.sel_spos or @textbox.sel_epos != @tbmem.sel_epos or @textbox.text != @tbmem.text
- update_cursor
- process_handling
- end
- #--------------------------------------------------------------------------
- # ● 刷新游標
- #--------------------------------------------------------------------------
- def update_cursor
- @curcor.visible = !@curcor.visible if Graphics.frame_count % 30 == 0
- end
- #--------------------------------------------------------------------------
- # ● 刷新游標位置
- #--------------------------------------------------------------------------
- def update_cursor_pos
- if @tbmem.sel_spos == @textbox.sel_spos
- @sel_pos = @textbox.sel_epos
- else
- @sel_pos = @textbox.sel_spos
- end
- t = @textbox.text[0, @sel_pos]
- s = contents.text_size(t).width
- @curcor.x = x + standard_padding + s
- end
- #--------------------------------------------------------------------------
- # ● 選取繪製
- #--------------------------------------------------------------------------
- def fill_selection(spos, epos)
- return if spos == epos
- rect = contents.rect.clone
- t = @textbox.text[0, spos]
- rect.x = contents.text_size(t).width
- t = @textbox.text[spos, epos - spos]
- rect.width = contents.text_size(t).width
- contents.fill_rect(rect, @selection_color)
- end
- #--------------------------------------------------------------------------
- # ● 释放
- #--------------------------------------------------------------------------
- def dispose
- @textbox.dispose
- @curcor.bitmap.dispose
- @curcor.dispose
- super
- end
- #--------------------------------------------------------------------------
- # ● 内容刷新
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- fill_selection(@textbox.sel_spos, @textbox.sel_epos)
- change_color(normal_color)
- txt = @textbox.password ? ("*" * @textbox.text.size) : @textbox.text
- draw_text(contents.rect, txt)
- update_cursor_pos
- @tbmem.sel_spos = @textbox.sel_spos
- @tbmem.sel_epos = @textbox.sel_epos
- @tbmem.text = @textbox.text
- end
- #--------------------------------------------------------------------------
- # ● 设置动作对应的处理方法
- #--------------------------------------------------------------------------
- def set_ok_handler(method)
- @handler = method
- end
- #--------------------------------------------------------------------------
- # ● 调用处理方法
- #--------------------------------------------------------------------------
- def call_handler(symbol)
- @handler[symbol].call if handle?(symbol)
- end
- #--------------------------------------------------------------------------
- # ● “确定”和“取消”的处理
- #--------------------------------------------------------------------------
- def process_handling
- return unless open? && active
- return process_ok if ok_enabled? && @textbox.press_enter?
- end
- #--------------------------------------------------------------------------
- # ● 获取确定处理的有效状态
- #--------------------------------------------------------------------------
- def ok_enabled?
- return !@handler.nil?
- end
- #--------------------------------------------------------------------------
- # ● 按下确定键时的处理
- #--------------------------------------------------------------------------
- def process_ok
- Sound.play_ok
- Input.update
- deactivate
- call_ok_handler
- end
- #--------------------------------------------------------------------------
- # ● 调用“确定”的处理方法
- #--------------------------------------------------------------------------
- def call_ok_handler
- @handler.call if ok_enabled?
- end
- end
复制代码
Scene_Name- #encoding:utf-8
- #==============================================================================
- # ■ Scene_Name
- #------------------------------------------------------------------------------
- # 名字输入画面
- #==============================================================================
- class Scene_Name < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 准备
- #--------------------------------------------------------------------------
- def prepare(actor_id, max_char)
- @actor_id = actor_id
- @max_char = max_char
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- @actor = $game_actors[@actor_id]
- @text_input_help = Window_Help.new(1, 480)
- @text_input_help.x = (Graphics.width - 480) / 2
- @text_input_help.y = (Graphics.height - @text_input_help.height * 2) / 2
- @text_input_help.set_text("命名")
- @text_input = Window_TextBox.new(@text_input_help.x, @text_input_help.y + @text_input_help.height, 480)
- @text_input.set_ok_handler(method(:on_input_ok))
- @text_input.textbox.limit = @max_char
- @text_input.textbox.text = @actor.name
- @text_input.textbox.sel_pos = @actor.name.size
- end
- #--------------------------------------------------------------------------
- # ● 输入“确定”
- #--------------------------------------------------------------------------
- def on_input_ok
- @actor.name = @text_input.textbox.text
- return_scene
- end
- end
复制代码
WhiteCabbageBase- # 白菜组基础脚本 WhiteCabbageBase)v1.02 (2013/11/16)
- #
- module APIs
- def self.new(ts); Win32API.new(*ts.split('|')) end
- #-------------------------------------------------
- ClipCursor = new 'user32|ClipCursor|p|l'
- FindWindowEx = new 'user32|FindWindowEx|llpp|i'
- GetAsyncKeyState = new 'user32|GetAsyncKeyState|i|i'
- GetCursorPos = new 'user32|GetCursorPos|p|i'
- GetKeyState = new 'user32|GetKeyState|i|i'
- GetPrvPflString = new 'kernel32|GetPrivateProfileString|pppplp|l'
- GetSysMtr = new 'user32|GetSystemMetrics|i|i'
- JoyGetPosEx = new 'winmm|joyGetPosEx|lp|l'
- KeybdEvent = new 'user32|keybd_event|iill|v'
- MultiByteToWideChar = new 'kernel32|MultiByteToWideChar|ilpipi|i'
- WideCharToMultiByte = new 'kernel32|WideCharToMultiByte|ilpipipp|i'
- RtlMoveMemory_pi = new 'kernel32|RtlMoveMemory|pii|i'
- RtlMoveMemory_ip = new 'kernel32|RtlMoveMemory|ipi|i'
- ScreenToClient = new 'user32|ScreenToClient|ip|i'
- SetCursorPos = new 'user32|SetCursorPos|ii|l'
- SetFocus = new 'user32|SetFocus|l|l'
- SetKeyBoardState = new 'user32|SetKeyboardState|i|i'
- SetWindowPos = new 'user32|SetWindowPos|liiiiip|i'
- ShellExecuteA = new 'shell32|ShellExecuteA|pppppi|i'
- ShowCursor = new 'user32|ShowCursor|i|l'
- #-----------------------------------------------
- HWnd = FindWindowEx.call(0, 0, 'RGSS Player', 0)
- end
- # §
- # Base Class~~~~~~~~~~~~~~~~~~~~~~~~~~
- class NilClass
- def +(v) return v end
- def -(v) return -v end
- def *(v) return 0 end
- def /(v) return 0 end
- end
- class Numeric
- def fpart; self - self.to_i end #获取小数部分
- def rfpart; 1 - fpart end # 1 - 小数部分
- def max(v); self > v ? self : v end # 取最大值
- def min(v); self < v ? self : v end # 取最小值
- def tide(r); self * (rand-0.5)*2 * r end #进行权值波动 ± v * (-r ~ r)
- def digits(ary=10) # 获取对应进制下的数字位数 2/8/10/16 进制
- dig = 0; num = self.abs.to_i; if ary == 10; until num == 0; dig += 1
- num /= ary; end; else ary = case ary; when 2;1; when 8;3; when 16;4 end
- until num == 0; dig += 1; num = num >> ary end; end; return dig
- end
- end
- class Array
- def iswap(a, b)
- t_ = self[a]
- self[a] = self[b]
- self[b] = t_
- end
- end
- class Hash
- def iswap(a, b)
- t_ = self[a]
- self[a] = self[b]
- self[b] = t_
- end
- def key_sort(rev = false)
- a = []; h = {}
- self.each {|k, v| a.push([v, k])}
- a.sort!
- rev ? a.reverse_each {|vk| h[vk[1]] = vk[0]} :
- a.each {|vk| h[vk[1]] = vk[0]}
- return h
- end
- end
- # ~~~~~~~~~~~~~~~~~~~~~
- # =====================
- class Font
- def marshal_dump; end
- def marshal_load(*args); end
- end
- # =====================
- class Bitmap
- include APIs
- #Bitmap marshal. by 柳之一(rpg.blue)
- # --------------------------------------
- def _dump(limit)
- data = bit_4 * width * height
- RtlMoveMemory_pi.call(data, address, data.length)
- [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
- end
- def self._load(str)
- w, h, zdata = str.unpack("LLa*"); buf = new(w, h)
- RtlMoveMemory_ip.call(buf.address, Zlib::Inflate.inflate(zdata), w*h*4)
- return buf
- end
- def address
- buf = bit_4
- ad = object_id * 2 + 16
- RtlMoveMemory_pi.call(buf, ad, 4)
- ad = buf.unpack("L")[0] + 8
- RtlMoveMemory_pi.call(buf, ad, 4)
- ad = buf.unpack("L")[0] + 16
- RtlMoveMemory_pi.call(buf, ad, 4)
- buf.unpack("L")[0]
- end
- def bit_4
- 'ccav'
- end
- # --------------------------------------
- # 绘制直线
- def blt_wu_line(x1, y1, x2, y2, r,g,b,a=255) # 抗锯齿
- dx = x2 - x1
- dy = y2 - y1
- if dx.abs < dy.abs
- t_ = x1; x1 = y1; y1 = t_
- t_ = x2; x2 = y2; y2 = t_
- t_ = dx; dx = dy; dy = t_
- end
- if x2 < x1
- t_ = x1; x1 = x2; x2 = t_
- t_ = y1; y1 = y2; y2 = t_
- end
- set_pixel(x1, y1, Color.new(r,g,b,a))
- set_pixel(x2, y2, Color.new(r,g,b,a))
- gradient = dy.fdiv(dx)
- intery = y1 + gradient
- for x in (x1 + 1)..(x2 - 1)
- y1 = intery.to_i
- y2 = intery.ceil
- set_pixel(x, y1, Color.new(r,g,b, intery.rfpart * a))
- set_pixel(x, y2, Color.new(r,g,b, intery.fpart * a)) if y1 != y2
- intery = intery + gradient
- end
- end
- def blt_line(x0, y0, x1, y1, r,g,b,a=255) # 不抗锯
- c = Color.new(r,g,b,a)
- steep = (y1 - y0).abs > (x1 - x0).abs
- if steep
- t_ = x0; x0 = y0; y0 = t_
- t_ = x1; x1 = y1; y1 = t_
- end
- if x0 > x1
- t_ = x0; x0 = x1; x1 = t_
- t_ = y0; y0 = y1; y1 = t_
- end
- deltax = x1 - x0
- deltay = (y1 - y0).abs
- error = deltax / 2
- y = y0
- ystep = y0 < y1 ? 1 : -1
- for x in x0..x1
- steep ? set_pixel(y,x,c) : set_pixel(x,y,c)
- error = error - deltay
- if error < 0
- y = y + ystep
- error = error + deltax
- end
- end
- end
- # 描边 -----------------------------
- def blt_border(w = 1, d = 0, color = Color.new(255, 255, 255))
- fill_rect(d, d, width - d*2, w, color)
- fill_rect(d, height - d - w, width - d*2, w, color)
- fill_rect(d, d, w, height - d*2 - w, color)
- fill_rect(width - d - w, d*2, w, height - d*2 - w, color)
- return self
- end
- def clear_4angle_dot
- clear_rect(0, 0, 1, 1)
- clear_rect(width - 1, 0, 1, 1)
- clear_rect(0, height - 1, 1, 1)
- clear_rect(width - 1, height - 1, 1, 1)
- return self
- end
- # 纵向中心渐变
- def vert_center_gradual(c2)
- c1 = Color.new
- self.gradient_fill_rect(0, 0, width, height/2, c1, c2, true)
- self.gradient_fill_rect(0, height/2, width, height/2, c2, c1, true)
- return self
- end
- end
- # =======================
- class Sprite
- def center_screen_xy
- self.x = Graphics.width / 2
- self.y = Graphics.height / 2
- end
- def center_origin
- self.ox = (width + 1) / 2
- self.oy = (height + 1) / 2
- end
- def set_origin_tone
- self.tone = $game_map.screen.tone.inverse
- end
- def zoom(v) # 缩放精灵
- self.zoom_x = v
- self.zoom_y = v
- end
- end
- # =====================
- class Table
- def fill(value) # 填充Table
- if ysize == 1
- xsize.times {|i| self[i] = value}
- elsif zsize == 1
- ysize.times {|j| xsize.times {|i| self[i,j] = value}}
- else
- zsize.times {|k| ysize.times {|j| xsize.times {|i| self[i,j,k] = value}}}
- end
- return self
- end
- def amend(value)
- if ysize == 1
- xsize.times {|i| self[i] += value}
- elsif zsize == 1
- ysize.times {|j| xsize.times {|i|self[i,j] += value}}
- else
- zsize.times {|k| ysize.times {|j| xsize.times {|i| self[i,j,k] += value}}}
- end
- return self
- end
- #
- def self.new_by(array) #利用数组中的16进制信息创建一个Table
- xsize = array[0].digits(16) - 1
- ysize = array.size
- table = Table.new(xsize, ysize)
- ysize.times {|y|
- bit = array[y]
- xsize.times {|x|
- table[xsize - x - 1, y] = (bit >> x*4) & 0xf
- }
- }
- return table
- end
- end
- # =====================
- class Tone
- def inverse
- Tone.new(-red, -green, -blue)
- end
- end
- # =====================
- class << SceneManager
- def goto(scene_class, *args)
- @scene = scene_class.new(*args)
- end
- def call(scene_class, *args)
- @stack.push(@scene)
- @scene = scene_class.new(*args)
- end
- end
- #
- class << Input
- include APIs
- def key_press?(key)
- 0 != GetAsyncKeyState.call(key)
- end
- def key_on?(key)
- 1 == GetKeyState.call(key) & 1
- end
- def key_repeat?(key) # 该方法最好每帧只调用一次
- GetAsyncKeyState.call(key) & 1 == 1
- end
- #
- def press_shift?
- key_press?(0xA0) || key_press?(0xA1)
- end
- def press_ctrl?
- key_press?(0xA2) || key_press?(0xA3)
- end
- def press_alt?
- key_press?(0xA4) || key_press?(0xA5)
- end
- def refresh_all_keys
- 255.times {|i| key_press?(i)}
- end
- end
- # ============================
- class Window_Base
- def draw_escape_text_al(text, x = 0, y = 0) #绘制文字自动换行
- reset_font_settings
- pos = {:x => x, :y => y, :new_x => x, :height => calc_line_height(text)}
- text = convert_escape_characters(text)
- process_characters_al(text.slice!(0, 1), text, pos) until text.empty?
- end
- def process_characters_al(c, text, pos)
- case c
- when "\r", "\n"; return
- when "\f"; process_new_page(text, pos)
- when "\e"; process_escape_character(obtain_escape_code(text), text, pos)
- else process_character_al(c, pos)
- end
- end
- def process_character_al(c, pos) #处理自动换行
- tw = text_size(c).width
- process_new_line(c, pos) if pos[:x] + tw > contents.width - pos[:new_x]
- draw_text(pos[:x], pos[:y], tw * 2, pos[:height], c)
- pos[:x] += tw
- end
- end
复制代码
Scene_Menu- class Scene_Menu
- alias cp_20140811 command_personal
- def command_personal
- $game_party.members.size == 1 ? on_personal_ok : cp_20140811
- end
- end
复制代码
截图存档- #==============================================================================
- # [PS0]截图存档
- # Window_SaveFile_Plus
- #------------------------------------------------------------------------------
- # 一种带有截图的存档,同时可以自定义存档数量。
- #==============================================================================
- # [核心脚本]
- # - 快速储存Bitmap的Marshal By 柳之一
- #------------------------------------------------------------------------------
- # [更新记录]
- # - 2012.02.16 By 各种压力的猫君
- # * 修正地图边缘时截图不完整的错误
- # - 2012.01.28 By 各种压力的猫君
- # * 去掉效率较差的双线性缩放算法;
- # * 新增存档管理功能(F5键,复制/移动/删除存档)
- # - 2011.12.27 By 各种压力的猫君
- # * 补上截图阴影;
- # * 新增“不缩放”截图(推荐使用,尤其是大分辨率);
- # * 修正选择不存在的存档时存档列表窗口卡死以及奇怪的SE;
- # * 新增“存档中”提示窗口、覆盖存档提示、删除存档功能(Z键,对应键盘D)
- # - 2011.12.26 By 各种压力的猫君
- # * 功能齐全的测试版
- # - 2011.12.16 By 各种压力的猫君
- # * 移植至RGSS3,遵循PS0协议;
- # * 丰富自定义选项,整合双线性插值算法精简版
- # - 2008.05.26 By 沉影不器
- # * 蓝本(VX新截图存档)
- #------------------------------------------------------------------------------
- # [使用方法]
- # - 删除原Scene_File、Window_SaveFile 并将本脚本插入到原Scene_File位置。
- # - 或者直接将本脚本插入到MAIN以上,并确保本脚本位于上述两个脚本以下。
- #==============================================================================
- $_PS0 = {} if $_PS0 == nil
- $_PS0["Window_SaveFile_Plus"] = 20120216
- #==============================================================================
- # [PS0] 通用配置模块
- #==============================================================================
- module PS0
- module Window_SaveFile_Plus
- # 最大存档数(范围正整数)
- MAX_SAVE = 18
- # 存档目录(默认值 "Saves/";根目录 "")
- SAVE_DIR = "Saves/"
- # 无存档时显示的文字
- NO_DATA = "无存档"
- # 保存时显示的信息
- SAVE_NOW = "存档中..."
- # 复制存档时的帮助文字
- HELP_COPY = "要复制到哪个位置?"
- # 移动存档时的帮助文字
- HELP_MOVE = "要移动到哪个位置?"
- # 是否显示存档中窗口(true:显示;false:不显示)
- # - 分辨率较大时建议显示
- SHOW_SAVE_NOW = false
- # 截图缩放使用的插值算法
- # - "NN" 最邻近(速度最快,质量最差,RM默认算法)
- # - "NZ" 不缩放(速度快,质量好,以主角为中心切边,非全屏)
- Zoom_Type = "NZ"
- # 双线性插值能获得更好的截图缩放质量,但所需时间较最邻近插值更长。
- # 缩略图尺寸(范围整数,单位像素)
- # - VA默认分辨率(544×416)推荐使用340×260
- # - VA最大分辨率(640×480)推荐使用425×325
- # - 本脚本兼容分辨率解放,窗口大小将自动计算。
- # 请自行计算截图分辨率,注意要确保宽高比一致,
- # 若使用“不缩放”模式则可以不保持一致。
- Thumbnail_Width = 340 # 宽度
- Thumbnail_Height = 260 # 高度
- # 缩略图位置微调(范围整数,单位像素)
- Thumbnail_ox = -2 # 横向
- Thumbnail_oy = -2-32 # 纵向
- # 各窗口切换时的渐变帧数
- TRANS_DURATION = 5
- end
- end
- #==============================================================================
- # [核心脚本] 快速储存Bitmap的Marshal By 柳之一
- #==============================================================================
- class Font
- def marshal_dump
- end
- def marshal_load(obj)
- end
- end
- class Bitmap
- RtlMoveMemory_pi = Win32API.new('kernel32', 'RtlMoveMemory', 'pii', 'i')
- RtlMoveMemory_ip = Win32API.new('kernel32', 'RtlMoveMemory', 'ipi', 'i')
- def _dump(limit)
- data = "rgba" * width * height
- RtlMoveMemory_pi.call(data, address, data.length)
- [width, height, Zlib::Deflate.deflate(data)].pack("LLa*")
- end
- def self._load(str)
- w, h, zdata = str.unpack("LLa*")
- b = self.new(w, h)
- RtlMoveMemory_ip.call(b.address, Zlib::Inflate.inflate(zdata), w * h * 4)
- return b
- end
- def address
- buffer, ad = "rgba", object_id * 2 + 16
- RtlMoveMemory_pi.call(buffer, ad, 4)
- ad = buffer.unpack("L")[0] + 8
- RtlMoveMemory_pi.call(buffer, ad, 4)
- ad = buffer.unpack("L")[0] + 16
- RtlMoveMemory_pi.call(buffer, ad, 4)
- return buffer.unpack("L")[0]
- end
- end
- #==============================================================================
- # ■ Game_Temp
- #==============================================================================
- class Game_Temp
- attr_accessor :save_bitmap
- attr_accessor :save_snapshoot
- alias new_initialize initialize
- def initialize
- new_initialize
- @save_bitmap = Bitmap.new(1, 1)
- @save_snapshoot = Bitmap.new(1, 1)
- end
- end
- #==============================================================================
- # ■ SceneManager
- #==============================================================================
- module SceneManager
- def self.snapshot_for_save
- $game_temp.save_bitmap = Graphics.snap_to_bitmap
- unless FileTest.exist?(PS0::Window_SaveFile_Plus::SAVE_DIR)
- Dir.mkdir(PS0::Window_SaveFile_Plus::SAVE_DIR)
- end
- end
- end
- #==============================================================================
- # ■ Scene_Map
- #==============================================================================
- class Scene_Map < Scene_Base
- alias save_terminate terminate
- def terminate
- SceneManager.snapshot_for_save
- save_terminate
- end
- end
- #==============================================================================
- # ■ DataManager
- #==============================================================================
- module DataManager
- def self.save_file_exists?
- !Dir.glob(PS0::Window_SaveFile_Plus::SAVE_DIR + 'Save*.rvdata2').empty?
- end
- def self.make_filename(index)
- sprintf(PS0::Window_SaveFile_Plus::SAVE_DIR + "Save%02d.rvdata2", index + 1)
- end
- #--------------------------------------------------------------------------
- # ● セーブヘッダの作成
- #--------------------------------------------------------------------------
- def self.make_save_header
- d_rect = Rect.new(0, 0, PS0::Window_SaveFile_Plus::Thumbnail_Width,
- PS0::Window_SaveFile_Plus::Thumbnail_Height)
- case PS0::Window_SaveFile_Plus::Zoom_Type
- when "NN"
- s_rect = $game_temp.save_bitmap.rect
- $game_temp.save_snapshoot = Bitmap.new(d_rect.width, d_rect.height)
- $game_temp.save_snapshoot.stretch_blt(d_rect, $game_temp.save_bitmap, s_rect)
- when "NZ"
- x = [$game_player.screen_x - d_rect.width/2, 0].max
- x = [x, Graphics.width - d_rect.width].min
- y = [$game_player.screen_y - d_rect.height/2, 0].max
- y = [y, Graphics.height - d_rect.height].min
- s_rect = Rect.new(x, y, d_rect.width, d_rect.height)
- $game_temp.save_snapshoot = Bitmap.new(d_rect.width, d_rect.height)
- $game_temp.save_snapshoot.blt(0, 0, $game_temp.save_bitmap, s_rect)
- end
- header = {}
- header[:characters] = $game_party.characters_for_savefile
- header[:playtime_s] = $game_system.playtime_s
- header[:snapshoot] = $game_temp.save_snapshoot
- header
- end
- #--------------------------------------------------------------------------
- # ● セーブの実行
- #--------------------------------------------------------------------------
- def self.save_game(index)
- saving_window = Window_Saving.new
- Graphics.update
- begin
- save_game_without_rescue(index)
- rescue
- delete_save_file(index)
- false
- end
- saving_window.dispose
- return true
- end
- end
- #==============================================================================
- # ■ Window_Yes_Or_No
- #------------------------------------------------------------------------------
- # 提供“是”、“否”两个选项的窗口(替换、删除存档用)
- #==============================================================================
- class Window_Yes_Or_No < Window_HorzCommand
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize(yes, no)
- @yes = yes
- @no = no
- super(130, 0)
- self.visible = false
- self.active = false
- @index = 0
- end
- #--------------------------------------------------------------------------
- # ● 桁数の取得
- #--------------------------------------------------------------------------
- def col_max
- return 2
- end
- #--------------------------------------------------------------------------
- # ● コマンドリストの作成
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(@yes, :yes)
- add_command(@no, :cancel)
- end
- #--------------------------------------------------------------------------
- # ● 決定ボタンが押されたときの処理
- #--------------------------------------------------------------------------
- def process_ok
- Input.update
- call_ok_handler
- end
- #--------------------------------------------------------------------------
- # ● 按下取消键时的处理
- #--------------------------------------------------------------------------
- def process_cancel
- Input.update
- call_cancel_handler
- end
- #--------------------------------------------------------------------------
- # ● 启用窗口
- #--------------------------------------------------------------------------
- def activate
- temp = self.y + self.height - Graphics.height
- if temp > 0
- self.y -= (temp + 12)
- end
- self.active = true
- self
- end
- end
- #==============================================================================
- # ■ Window_Saving
- #------------------------------------------------------------------------------
- # 显示保存信息的窗口
- #==============================================================================
- class Window_Saving < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- w = PS0::Window_SaveFile_Plus::SAVE_NOW.length * 16 + 32
- x = (Graphics.width - w)/2
- y = (Graphics.height - fitting_height(1))/2
- super(x, y, w, fitting_height(1))
- self.visible = PS0::Window_SaveFile_Plus::SHOW_SAVE_NOW
- draw_text_ex(4, 0, PS0::Window_SaveFile_Plus::SAVE_NOW)
- end
- end
- #==============================================================================
- # ■ Window_SaveManagerCommand
- #------------------------------------------------------------------------------
- # 存档管理窗口
- #==============================================================================
- class Window_SaveManagerCommand < Window_Command
- #--------------------------------------------------------------------------
- # ● 初始化对象
- #--------------------------------------------------------------------------
- def initialize(*args)
- @copy, @move, @delete, @cancel = args[0..3]
- super(130, 0)
- self.visible = false
- self.active = false
- @index = 0
- end
- #--------------------------------------------------------------------------
- # ● 获取窗口的宽度
- #--------------------------------------------------------------------------
- def window_width
- return 100
- end
- #--------------------------------------------------------------------------
- # ● 获取项目数
- #--------------------------------------------------------------------------
- def item_max
- return 4
- end
- #--------------------------------------------------------------------------
- # ● 生成指令列表
- #--------------------------------------------------------------------------
- def make_command_list
- add_command(@copy, :copy )
- add_command(@move, :move )
- add_command(@delete, :delete)
- add_command(@cancel, :cancel)
- end
- #--------------------------------------------------------------------------
- # ● 按下确定键时的处理
- #--------------------------------------------------------------------------
- def process_ok
- Input.update
- call_ok_handler
- end
- #--------------------------------------------------------------------------
- # ● 启用窗口
- #--------------------------------------------------------------------------
- def activate
- temp = self.y + self.height - Graphics.height
- if temp > 0
- self.y -= (temp + 12)
- end
- self.active = true
- self
- end
- end
- #==============================================================================
- # ■ Window_FileCommand
- #------------------------------------------------------------------------------
- # 截图存档左侧的选择窗口。
- #==============================================================================
- class Window_FileCommand < Window_Command
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- end
- #--------------------------------------------------------------------------
- # ● ウィンドウ幅の取得
- #--------------------------------------------------------------------------
- def window_height
- return Graphics.height-fitting_height(1)
- end
- #--------------------------------------------------------------------------
- # ● 表示行数の取得
- #--------------------------------------------------------------------------
- def visible_line_number
- item_max
- end
- #--------------------------------------------------------------------------
- # ● コマンドリストの作成
- #--------------------------------------------------------------------------
- def make_command_list
- add_main_commands
- end
- #--------------------------------------------------------------------------
- # ● 主要コマンドをリストに追加
- #--------------------------------------------------------------------------
- def add_main_commands
- for i in 1..PS0::Window_SaveFile_Plus::MAX_SAVE
- if i < 10
- text = Vocab::File + " 0" + i.to_s
- else
- text = Vocab::File + " " + i.to_s
- end
- add_command(text, :file)
- end
- end
- #--------------------------------------------------------------------------
- # ● 決定ボタンが押されたときの処理
- #--------------------------------------------------------------------------
- def process_ok
- end
- end
- #==============================================================================
- # ■ Window_SaveFile
- #------------------------------------------------------------------------------
- # セーブ画面およびロード画面で表示する、セーブファイルのウィンドウです。
- #==============================================================================
- class Window_SaveFile < Window_Base
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化
- # index : セーブファイルのインデックス
- #--------------------------------------------------------------------------
- def initialize(index)
- super(160, 0, Graphics.width-160, Graphics.height-fitting_height(1))
- @file_index = index
- @selected = true
- refresh
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- change_color(normal_color)
- w = (self.width-PS0::Window_SaveFile_Plus::Thumbnail_Width-16)/2
- h = (self.height-PS0::Window_SaveFile_Plus::Thumbnail_Height-16)/2
- width = w + PS0::Window_SaveFile_Plus::Thumbnail_ox
- height = h + PS0::Window_SaveFile_Plus::Thumbnail_oy
- draw_shadow(width+5, height+5)
- draw_text((self.width-32-PS0::Window_SaveFile_Plus::NO_DATA.length*16)/2,
- self.height/2-32, PS0::Window_SaveFile_Plus::NO_DATA.length*32,
- line_height, PS0::Window_SaveFile_Plus::NO_DATA)
- draw_party_characters(32, Graphics.height-fitting_height(1)-32)
- draw_playtime(-10, contents.height - line_height-10, contents.width - 4, 2)
- draw_snapshoot(width, height)
- end
- #--------------------------------------------------------------------------
- # ● パーティキャラの描画
- #--------------------------------------------------------------------------
- def draw_party_characters(x, y)
- header = DataManager.load_header(@file_index)
- return unless header
- header[:characters].each_with_index do |data, i|
- draw_character(data[0], data[1], x + i * 48, y)
- end
- end
- #--------------------------------------------------------------------------
- # ● プレイ時間の描画
- #--------------------------------------------------------------------------
- def draw_playtime(x, y, width, align)
- header = DataManager.load_header(@file_index)
- return unless header
- draw_text(x, y, width, line_height, header[:playtime_s], 2)
- end
- #--------------------------------------------------------------------------
- # ● 绘制截图
- #--------------------------------------------------------------------------
- def draw_snapshoot(x, y)
- header = DataManager.load_header(@file_index)
- return unless header
- bitmap = header[:snapshoot]
- contents.blt(x, y, bitmap, bitmap.rect)
- bitmap.dispose
- end
- #--------------------------------------------------------------------------
- # ● 绘制阴影
- #--------------------------------------------------------------------------
- def draw_shadow(x, y)
- header = DataManager.load_header(@file_index)
- return unless header
- contents.fill_rect(x, y, PS0::Window_SaveFile_Plus::Thumbnail_Width,
- PS0::Window_SaveFile_Plus::Thumbnail_Height, Color.new(0, 0, 0))
- contents.blur
- end
- end
- #==============================================================================
- # ■ Scene_File
- #------------------------------------------------------------------------------
- # セーブ画面とロード画面の共通処理を行うクラスです。
- #==============================================================================
- class Scene_File < Scene_MenuBase
- #--------------------------------------------------------------------------
- # ● 開始処理
- #--------------------------------------------------------------------------
- def start
- super
- create_help_window
- create_savefile_viewport
- create_command_window
- create_savefile_window
- create_manager_window
- create_replace_window
- create_delete_window
- end
- #--------------------------------------------------------------------------
- # ● 終了処理
- #--------------------------------------------------------------------------
- def terminate
- super
- @savefile_viewport.dispose
- @savefile_window.dispose
- @command_window.dispose
- @window_manager.dispose
- @window_replace.dispose
- @window_delete.dispose
- end
- #--------------------------------------------------------------------------
- # ● フレーム更新
- #--------------------------------------------------------------------------
- def update
- super
- update_savefile_selection
- end
- #--------------------------------------------------------------------------
- # ● 创建替换窗口
- #--------------------------------------------------------------------------
- def create_replace_window
- @window_replace = Window_Yes_Or_No.new("替换", "取消")
- @window_replace.set_handler(:yes, method(:do_replace))
- @window_replace.set_handler(:cancel, method(:do_cancel))
- end
- #--------------------------------------------------------------------------
- # ● 创建删除窗口
- #--------------------------------------------------------------------------
- def create_delete_window
- @window_delete = Window_Yes_Or_No.new("删除", "取消")
- @window_delete.set_handler(:yes, method(:do_delete))
- @window_delete.set_handler(:cancel, method(:do_return_manager))
- @window_delete.x += 40
- end
- #--------------------------------------------------------------------------
- # ● 创建管理窗口
- #--------------------------------------------------------------------------
- def create_manager_window
- @window_manager = Window_SaveManagerCommand.new("复制", "移动", "删除", "取消")
- @window_manager.set_handler(:copy , method(:on_copy?))
- @window_manager.set_handler(:move , method(:on_move?))
- @window_manager.set_handler(:delete, method(:on_delete?))
- @window_manager.set_handler(:cancel, method(:do_cancel))
- end
- #--------------------------------------------------------------------------
- # ● ヘルプウィンドウの作成
- #--------------------------------------------------------------------------
- def create_help_window
- @help_window = Window_Help.new(1)
- @help_window.set_text(help_window_text)
- end
- #--------------------------------------------------------------------------
- # ● ヘルプウィンドウのテキストを取得
- #--------------------------------------------------------------------------
- def help_window_text
- return ""
- end
- #--------------------------------------------------------------------------
- # ● セーブファイルビューポートの作成
- #--------------------------------------------------------------------------
- def create_savefile_viewport
- @savefile_viewport = Viewport.new
- @savefile_viewport.rect.y = @help_window.height
- @savefile_viewport.rect.height -= @help_window.height
- end
- #--------------------------------------------------------------------------
- # ● セーブファイルウィンドウの作成
- #--------------------------------------------------------------------------
- def create_savefile_window
- @savefile_window = Window_SaveFile.new(@index)
- @savefile_window.viewport = @savefile_viewport
- end
- #--------------------------------------------------------------------------
- # ● 生成存档列表窗口
- #--------------------------------------------------------------------------
- def create_command_window
- @command_window = Window_FileCommand.new
- @command_window.index = first_savefile_index
- @index = @command_window.index
- @command_window.viewport = @savefile_viewport
- @command_window.set_handler(:file, method(:on_savefile_ok))
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル選択の更新
- #--------------------------------------------------------------------------
- def update_savefile_selection
- if @source_index != nil
- if Input.trigger?(:C)
- if @index == @source_index
- Sound.play_buzzer
- elsif FileTest.exist?(DataManager.make_filename(@index))
- Graphics.freeze
- @command_window.deactivate
- @window_replace.y = 72 + @index * 24
- @window_replace.activate
- @window_replace.visible = true
- @window_replace.refresh
- Sound.play_ok
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- else
- return on_copy_ok
- end
- elsif Input.trigger?(:B)
- return do_return_manager
- end
- else
- if Input.trigger?(:C)
- if self.is_a?(Scene_Save) and FileTest.exist?(DataManager.make_filename(@index))
- Graphics.freeze
- @command_window.deactivate
- @window_replace.y = 72 + @index * 24
- @window_replace.activate
- @window_replace.visible = true
- @window_replace.refresh
- Sound.play_ok
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- else
- return on_savefile_ok
- end
- elsif Input.trigger?(:B)
- return on_savefile_cancel
- elsif Input.trigger?(:F5)
- unless @window_manager.active == true or
- @window_delete.active == true or
- @window_replace.active == true
- return on_manager?
- end
- end
- end
- @need_refresh = true if @index != @command_window.index
- if @need_refresh
- Graphics.freeze
- @index = @command_window.index
- @savefile_window.dispose
- create_savefile_window
- @need_refresh = false
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- end
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[決定]
- #--------------------------------------------------------------------------
- def on_savefile_ok
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[キャンセル]
- #--------------------------------------------------------------------------
- def on_savefile_cancel
- Sound.play_cancel
- return_scene
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[決定]
- #--------------------------------------------------------------------------
- def on_copy_ok
- Graphics.freeze
- source_name = DataManager.make_filename(@source_index)
- new_name = DataManager.make_filename(@index)
- case @source_type
- when "copy"
- # 复制存档文件(API)
- Win32API.new('kernel32',"CopyFileA",'ppl','').call(source_name,new_name,0)
- when "move"
- # 重命名存档
- File.rename(source_name, new_name)
- end
- # 返回
- @help_window.set_text(help_window_text)
- @source_index = nil
- do_return_savelist
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[复制]
- #--------------------------------------------------------------------------
- def on_copy?
- Graphics.freeze
- @help_window.set_text(PS0::Window_SaveFile_Plus::HELP_COPY)
- @source_index = @index
- @source_type = "copy"
- do_return_savelist
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[移动]
- #--------------------------------------------------------------------------
- def on_move?
- Graphics.freeze
- @help_window.set_text(PS0::Window_SaveFile_Plus::HELP_MOVE)
- @source_index = @index
- @source_type = "move"
- do_return_savelist
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[管理]
- #--------------------------------------------------------------------------
- def on_manager?
- if FileTest.exist?(DataManager.make_filename(@index))
- Graphics.freeze
- @command_window.deactivate
- @window_manager.y = 72 + @index * 24
- @window_manager.activate
- @window_manager.visible = true
- @window_manager.refresh
- Sound.play_ok
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- else
- Sound.play_buzzer
- end
- end
- #--------------------------------------------------------------------------
- # ● セーブファイル[删除]
- #--------------------------------------------------------------------------
- def on_delete?
- Graphics.freeze
- @window_manager.deactivate
- @command_window.deactivate
- @window_delete.y = 72 + 72 + @index * 24
- @window_delete.activate
- @window_delete.visible = true
- @window_delete.refresh
- Sound.play_ok
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- end
- #--------------------------------------------------------------------------
- # ● 删除
- #--------------------------------------------------------------------------
- def do_delete
- Graphics.freeze
- File.delete(DataManager.make_filename(@index))
- @window_delete.index = 0
- @window_manager.index = 0
- @window_delete.visible = false
- @window_manager.visible = false
- @window_delete.deactivate
- @window_manager.deactivate
- @command_window.activate
- @need_refresh = true
- Sound.play_save
- if DataManager.save_file_exists?
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- else
- return_scene
- end
- end
- #--------------------------------------------------------------------------
- # ● 替换
- #--------------------------------------------------------------------------
- def do_replace
- Graphics.freeze
- if @source_index != nil
- return on_copy_ok
- else
- return on_savefile_ok
- end
- @window_replace.visible = false
- @window_replace.deactivate
- @need_refresh = true
- end
- #--------------------------------------------------------------------------
- # ● 取消
- #--------------------------------------------------------------------------
- def do_cancel
- Graphics.freeze
- Sound.play_cancel
- @window_delete.index = 0
- @window_replace.index = 0
- @window_manager.index = 0
- @window_delete.visible = false
- @window_replace.visible = false
- @window_manager.visible = false
- @window_delete.deactivate
- @window_replace.deactivate
- @window_manager.deactivate
- @command_window.activate
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- end
- #--------------------------------------------------------------------------
- # ● 返回管理菜单
- #--------------------------------------------------------------------------
- def do_return_manager
- Graphics.freeze
- @help_window.set_text(help_window_text)
- @command_window.index = @source_index unless @source_index == nil
- @source_index = nil
- @source_type = nil
- @command_window.deactivate
- @window_delete.index = 0
- @window_replace.index = 0
- @window_delete.visible = false
- @window_replace.visible = false
- @window_delete.deactivate
- @window_replace.deactivate
- @window_manager.y = 72 + @index * 24
- @window_manager.activate
- @window_manager.visible = true
- @window_manager.refresh
- Sound.play_cancel
- Graphics.transition(PS0::Window_SaveFile_Plus::TRANS_DURATION)
- end
- #--------------------------------------------------------------------------
- # ● 返回文件列表(复制、移动 用)
- #--------------------------------------------------------------------------
- def do_return_savelist
- @window_manager.visible = false
- @window_manager.deactivate
- @command_window.activate
- @need_refresh = true
- Sound.play_ok
- end
- end
- #==============================================================================
- # [PS0] End of Script
- #==============================================================================
复制代码
Window_ChoiceList
- class Window_ChoiceList
- def max_choice_width
- $game_message.choices.collect {|s| pro_ex(s) }.max
- end
- def pro_ex(str)
- s = convert_escape_characters(str)
- pos = {:x => 0, :y => -Graphics.height, :new_x => 0, :height => calc_line_height(s)}
- process_character(s.slice!(0, 1), s, pos) until s.empty?
- pos[:x]
- end
- end
复制代码
VXAce-RGSS3-26 8方向移動- #==============================================================================
- # ■ VXAce-RGSS3-26 8方向移動 [Ver.1.0.0] by Claimh
- #------------------------------------------------------------------------------
- # 8方向の移動が可能となります。
- # 斜め移動ができない時に縦or横に移動できる場合は縦or横に移動するようになります。
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● 方向ボタン入力による移動処理
- #--------------------------------------------------------------------------
- def move_by_input
- return if !movable? || $game_map.interpreter.running?
- if [1, 3, 7, 9].include?(Input.dir8)
- case Input.dir8
- when 1; move_diagonal(4, 2)
- when 3; move_diagonal(6, 2)
- when 7; move_diagonal(4, 8)
- when 9; move_diagonal(6, 8)
- end
- return if @move_succeed
- end
- move_straight(Input.dir4) if Input.dir4 > 0
- end
- end
- class Game_CharacterBase
- #--------------------------------------------------------------------------
- # ● 斜めに移動
- # horz : 横方向(4 or 6)
- # vert : 縦方向(2 or 8)
- #--------------------------------------------------------------------------
- alias move_diagonal_8dir move_diagonal
- def move_diagonal(horz, vert)
- if !passable?(@x, @y, horz) and !passable?(@x, @y, vert)
- @move_succeed = false
- return
- end
- return move_straight(horz) if passable?(@x, @y, horz) and !passable?(@x, @y, vert)
- return move_straight(vert) if !passable?(@x, @y, horz) and passable?(@x, @y, vert)
- move_diagonal_8dir(horz, vert)
- end
- end
复制代码
战斗结束后回复- =begin
- ===============================================================================
- 战斗结束后回复 By喵呜喵5
- ===============================================================================
- 【说明】
- 战斗后回复一定量的HP、MP
- 回复的数值可以参考数据库的伤害公式来写,支持以下字符:
- v[n] n号变量的数值
- hp 当前HP
- mp 当前mp
- tp 当前HP
- level 当前等级
- mhp 最大HP Maximum Hit Point
- mmp 最大MP Maximum Magic Point
- atk 物理攻击 ATtacK power
- def 物理防御 DEFense power
- mat 魔法攻击 Magic ATtack power
- mdf 魔法防御 Magic DeFense power
- agi 敏 捷 值 AGIlity
- luk 幸 运 值 LUcK
- hit 成功几率 HIT rate
- eva 闪避几率 EVAsion rate
- cri 必杀几率 CRItical rate
- cev 闪避必杀几率 Critical EVasion rate
- mev 闪避魔法几率 Magic EVasion rate
- mrf 反射魔法几率 Magic ReFlection rate
- cnt 反击几率 CouNTer attack rate
- hrg HP再生速度 Hp ReGeneration rate
- mrg MP再生速度 Mp ReGeneration rate
- trg TP再生速度 Tp ReGeneration rate
- tgr 受到攻击的几率 TarGet Rate
- grd 防御效果比率 GuaRD effect rate
- rec 恢复效果比率 RECovery effect rate
- pha 药理知识 PHArmacology
- mcr MP消费率 Mp Cost Rate
- tcr TP消耗率 Tp Charge Rate
- pdr 物理伤害加成 Physical Damage Rate
- mdr 魔法伤害加成 Magical Damage Rate
- fdr 地形伤害加成 Floor Damage Rate
- exr 经验获得加成 EXperience Rate
- 同样支持包括$game_switches在内其他所有的全局变量
- 如果计算公式包含多行代码或者多个判定条件,请使用“;”号分隔
- (不懂脚本的话无需理解上面两句话的意思)
- =end
- module M5_BattleRecover
- #==============================================================================
- # 设定部分
- #==============================================================================
- HP = "mhp*0.5 + v[1]"
- #这里设置HP的回复量,请不要删除引号
- MP = "mmp*0.5 + v[1]"
- #这里设置MP的回复量,请不要删除引号
- ALWAYS = true
- #设置为true的话,即使战斗没有胜利也可以恢复
- #==============================================================================
- # 设定结束
- #==============================================================================
- #==============================================================================
- # 脚本部分
- #==============================================================================
- end
- class << BattleManager
- alias m5_20131027_battle_end battle_end
- def battle_end(result)
- m5_20131027_battle_end(result)
- if (result == 0) or M5_BattleRecover::ALWAYS
- $game_party.m5_recovery
- end
- end
- end
- class Game_Battler < Game_BattlerBase
- def m5_recovery
- v = $game_variables
- self.hp += eval(M5_BattleRecover::HP).round
- self.mp += eval(M5_BattleRecover::MP).round
- end
- end
- class Game_Unit
- def m5_recovery
- members.each {|member| member.m5_recovery }
- end
- end
- #==============================================================================
- # 脚本结束
- #==============================================================================
复制代码
地图名显示美化- =begin
- ===============================================================================
- 地图名显示美化 By喵呜喵5
- ===============================================================================
- 【说明】
- 修改了默认的地图名显示方式
- 地图名的显示支持基本的转义字符,因此可以做出类似:
- 地图名:“\i[4]这里是\n[1]的家”
- 显示效果:【图标4】这里是艾里克的家
- 这样的效果
- 使用脚本需要将地图名的背景命名为“mapname”放在Graphics\System下
- =end
- $m5script = {} if $m5script.nil?
- $m5script["M5MapName"] = true
- module M5MapName
- #==============================================================================
- # 设定部分
- #==============================================================================
- DEAFUT = 3
- #在这里设置地图名的显示模式
- #1:不显示地图名,2:长时间显示地图名,3:一段时间显示地图名
- TIME = 120
- #这里设置地图名显示模式为一段时间时,地图名停留的时间
- OPTION = 1
- #在这里设置控制地图名的变量ID
- #当变量的值分别为1、2、3时地图名显示模式将切换到对应的模式
- FADE = 40
- #这里设置地图名进入的时间
- FONT = ["黑体"]
- #地图名所使用的字体
- SIZE = 20
- #地图名字体的大小
- COLOR = Color.new(0,0,0, 210)
- #地图名的颜色,四个数值分别是R、G、B以及透明度
- BOLD = false
- #地图名是否加粗
- ITALIC = false
- #地图名是否斜体
- SHADOW = false
- #地图名是否有阴影
- OUT = false
- #地图名是否加边框
- OUT_COLOR = Color.new(255, 255, 255, 100)
- #地图名边框的颜色,四个数值分别是R、G、B以及透明度
- X = 87
- #这里调整地图名的X坐标
- Y = 12
- #这里调整地图名的Y坐标
- #==============================================================================
- # 设定结束
- #==============================================================================
- end
- class Window_MapName
- def self.show_start
- @@map_name_showing = true
- end
- def self.show_end
- @@map_name_showing = false
- end
- def initialize
- super(Graphics.width, M5MapName::Y, Graphics.width,Graphics.height)
- self.opacity = self.contents_opacity = 0
- creat_map_background
- @state = :S1
- update_mode
- @showing = true
- update_haveshow? if !@@map_name_showing
- end
- def creat_map_background
- @background = Sprite.new
- @background.bitmap = Cache.system("Mapname")
- @background.opacity = 0
- @background.z = self.z - 1
- end
- def update_haveshow?
- case @mode
- when 2
- get_content
- @background.opacity = self.contents_opacity = 255
- self.x = M5MapName::X
- else
- @background.opacity = self.contents_opacity = 0
- end
- @showing = false
- end
- def update
- super
- update_mode
- if @showing
- update_open if need_update?
- update_disappear if @mode == 1
- end
- end
- def need_update?
- @mode != 1 && $game_map.display_name != ""
- end
- def update_mode
- mode = $game_variables[M5MapName::OPTION].to_i
- mode = mode.between?(1,3)? mode : M5MapName::DEAFUT
- if @mode != mode
- @mode = mode
- @showing = true
- @state = :S1
- end
- end
- def update_disappear
- @background.opacity -= (255/M5MapName::FADE)*2
- self.contents_opacity -= (255/M5MapName::FADE)*2
- if @background.opacity <= 0
- @showing = false
- self.x = Graphics.width
- end
- end
- def get_content
- contents.clear
- contents.font.name = M5MapName::FONT
- contents.font.size = M5MapName::SIZE
- contents.font.bold = M5MapName::BOLD
- contents.font.italic = M5MapName::ITALIC
- contents.font.outline = M5MapName::OUT
- contents.font.shadow = M5MapName::SHADOW
- contents.font.color = M5MapName::COLOR
- contents.font.out_color = M5MapName::OUT_COLOR
- draw_text_ex(0,0, $game_map.display_name)
- end
- def update_open
- case @state
- when :S1
- get_content
- @background.opacity += 255/M5MapName::FADE
- @state = :S2 if @background.opacity > 170
- when :S2
- @background.opacity += 255/M5MapName::FADE
- self.contents_opacity += 255/M5MapName::FADE
- self.x = [self.x - Graphics.width/M5MapName::FADE,M5MapName::X].max
- if self.x == M5MapName::X and @background.opacity == 255 and \
- self.contents_opacity == 255
- case @mode
- when 2
- @showing = false
- when 3
- @times = M5MapName::TIME
- @state = :S3
- end
- end
- when :S3
- @times -= 1
- @state = :S4 if @times < 0
- when :S4
- @background.opacity -= (255/M5MapName::FADE)/2
- self.contents_opacity -= 255/M5MapName::FADE
- self.x = [self.x + Graphics.width/M5MapName::FADE , Graphics.width].min
- @state = :S5 if self.x == Graphics.width
- when :S5
- @background.opacity -= 255/M5MapName::FADE
- if @background.opacity <= 0
- @state = :S1
- @showing = false
- end
- end
- end
- def close
- @showing = false
- self.contents_opacity = @background.opacity = 0
- self
- end
- def open
- @state = :S1
- self.x = Graphics.width
- Window_MapName::show_start
- @showing = true
- self
- end
- def dispose
- super
- @background.dispose
- end
- end
- class Scene_Map
- alias m5_20131130_update_scene update_scene
- def update_scene
- m5_20131130_update_scene
- Window_MapName::show_end if scene_changing?
- end
- end
- class << DataManager
- alias m5_20131130_setup_new_game setup_new_game
- def setup_new_game
- m5_20131130_setup_new_game
- Window_MapName::show_start
- end
- alias m5_20131130_load_game load_game
- def load_game(index)
- Window_MapName::show_start
- m5_20131130_load_game(index)
- end
- end
复制代码
战斗回合数显示- =begin
- ===============================================================================
- 战斗回合数显示 By喵呜喵5
- ===============================================================================
- 【说明】
- 在战斗界面显示当前的回合数
- =end
- $m5script = {} if $m5script.nil?
- $m5script["M5Round"] = true
- module M5Round
- #==============================================================================
- # 设定部分
- #==============================================================================
- X = 450
- #设置窗口的X坐标
- Y = 269
- #设置窗口的Y坐标
- BACK = "Battle"
- #设置窗口的背景图片,不需要则填入 "" 。背景图片素材放到 Graphics\System 目录下
- BACK_X = 416
- #设置背景图片的X坐标
- BACK_Y = 266
- #设置背景图片的Y坐标
- #==============================================================================
- # 脚本部分
- #==============================================================================
- end
- class Window_Round_Picture < Window_Base
- def initialize(filename,x=0,y=0)
- super(x, y, Graphics.width, Graphics.height)
- self.opacity = 0
- self.arrows_visible = false
- load_picture(filename)
- self.z -= 10
- end
- def standard_padding
- return 0
- end
- def load_picture(filename)
- bitmap = Cache.system(filename)
- rect = Rect.new(0,0,bitmap.width, bitmap.height)
- contents.blt(0, 0, bitmap, rect)
- bitmap.dispose
- end
- end
- class Window_Round < Window_Base
- def initialize
- super(M5Round::X, M5Round::Y, Graphics.width,Graphics.height)
- self.opacity = 0
- creat_background
- end
- def standard_padding
- return 0
- end
- def creat_background
- @background = Window_Round_Picture.new(M5Round::BACK,\
- M5Round::BACK_X,M5Round::BACK_Y) if M5Round::BACK
- end
- def set_text(text)
- if text != @text
- @text = text
- refresh
- end
- end
- def dispose
- super
- @background.dispose if @background
- end
- def clear
- set_text("")
- end
- def refresh
- contents.clear
- draw_text( 0, 0, Graphics.width, contents.font.size, @text,0)
- end
- end
- class Scene_Battle < Scene_Base
- alias m5_20130121_create_all_windows create_all_windows
- def create_all_windows
- m5_20130121_create_all_windows
- creat_round_window
- end
- def creat_round_window
- @round_window = Window_Round.new
- @round_window.set_text(round_text)
- end
- def round_text
- "第" + ($game_troop.turn_count + 1).to_s + "回合"
- end
- alias m5_20130121_turn_end turn_end
- def turn_end
- m5_20130121_turn_end
- @round_window.set_text(round_text)
- end
- end
复制代码
升级时满血满蓝- #--------------------------------------------------------------------------
- # ● 升级时满血满蓝 require Taroxd基础设置
- #--------------------------------------------------------------------------
- Game_Actor.send(:def_after, :level_up, :recover_all)
复制代码
Taroxd基础设置
无限图层显示系统 Unlimited Layers Display System
NamePop
薄雾年代记标题脚本- #encoding:utf-8
- #==============================================================================
- # ■ 薄雾年代记标题脚本
- #------------------------------------------------------------------------------
- # 薄雾年代记的标题脚本
- #==============================================================================
- #==============================================================================
- # 介绍:
- # 这个不完全是薄雾的标题脚本,但是是那个的普适版,作者:LBQ,请自由使用,转载
- #==============================================================================
- # 设置模块
- module LBQ
- module MC_Title
- #logo还有选项的淡入速度,数字越大淡出淡入越快
- FADE_SPEED=4
- #黑暗层的淡入淡出速度,数字越大淡出淡入越快。第一项是进入场景,第二项是退出
- MASK_FADE=[5,3]
- #背景滑动速度,默认是[2,1],即为每两帧横向滑动一个单位。
- SHIFT_SPEED=[2,1]
- #图像设置
- GRAPHICS=['Choice','spark','logo','background']
- #生成一个新的闪光点的间隔时间
- TIME_SPARK=0
- #分辨率设定
- RESOLUTION=[544,416]
- #储存文件的文件夹名称,位于Graphics文件夹下面
- FOLDER="MC_Title"
- #离开界面的时候的BGM淡出速度,单位毫秒
- BGM_FADE=1600
- #3个层的Z坐标设定。
- Z_SETTINGS=[1,2,3]
- #闪光的生命周期。(半衰期,总共生命周期)←装X的设定
- LIFE_CYCLE=[300,500]
- end
- end
- #Cache加强
- module Cache
- include LBQ::MC_Title
- #--------------------------------------------------------------------------
- # ● 标题
- #--------------------------------------------------------------------------
- def self.mc_title(filename)
- load_bitmap("Graphics/#{FOLDER}/", filename)
- end
- end
- #==============================================================================
- # ■ LBQ Spark
- #------------------------------------------------------------------------------
- # 闪光的精灵类
- #==============================================================================
- class Sprite_lbqSpark < Sprite_Base
- include LBQ::MC_Title
- def initialize(viewport=nil)
- @timer=0
- super(viewport)
- self.bitmap=Cache.mc_title(GRAPHICS[1])
- @opacity_speed=10
- @zoom_change=0
- set_rand_stats
- end
- def update
- super
- @timer+=1
- calc_speed
- self.x += @x_speed
- self.y += @y_speed
- if @timer<=LIFE_CYCLE[0]
- self.opacity += @opacity_speed
- else
- self.opacity -= @opacity_speed*2
- end
- self.angle += @angle_speed
- self.zoom_x += @zoom_change
- self.zoom_y += @zoom_change
- self.visible=false if @timer>=LIFE_CYCLE[1]
- end
- def calc_speed
- end
- def set_rand_stats
- @x_speed=(rand(4)-2)*0.8
- @y_speed=(rand(4)-2)*0.8
- @x_speed+=rand(2)-1 if @x_speed==0
- @y_speed+=rand(2)-1 if @y_speed==0
- @opacity_speed=2
- @angle_speed=rand(3)-3
- self.opacity = 1
- self.angle = rand(360)
- rand_num=rand(9)
- case rand_num
- when 0
- self.x,self.y=0,0
- when 1
- self.x,self.y=RESOLUTION[0],RESOLUTION[1]
- when 2
- self.x,self.y=RESOLUTION[0],0
- when 3
- self.x,self.y=0,RESOLUTION[1]
- when 4
- self.x,self.y=RESOLUTION[0]/2,0
- when 5
- self.x,self.y=RESOLUTION[0]/2,RESOLUTION[1]
- when 6
- self.x,self.y=0,208
- when 7
- self.x,self.y=RESOLUTION[0],RESOLUTION[1]/2
- when 8
- self.x,self.y=RESOLUTION[0]/2 ,RESOLUTION[1]/2
- end
- self.zoom_x=(rand(100) + 100) / 100.0
- self.zoom_y = self.zoom_x
- self.blend_type=1
- end
- def get_rand_pos
- pos=[]
- case rand(4)
- when 0
- pos[0]=0
- when 1
- pos[0]=200
- when 2
- pos[0]=300
- when 3
- pos[0]=500
- when 4
- pos[0]=100
- end
- case rand(4)
- when 0
- pos[1]=0
- when 1
- pos[1]=200
- when 2
- pos[1]=300
- when 3
- pos[1]=500
- when 4
- pos[1]=100
- end
- return pos
- end
- end
- #==============================================================================
- # ■ MC Choice
- #------------------------------------------------------------------------------
- # 可爱的选项~
- #==============================================================================
- # 选项用精灵类
- class Sprite_MCchoice < Sprite_Base
- include LBQ::MC_Title
- #设置
- MAX_INDEX=3
- MIN_INDEX=1
- #初始化
- def initialize(viewport=nil)
- super(viewport)
- #光标Index
- if DataManager.save_file_exists?
- @index=2
- else
- @index=1
- end
- #动态阶段
- @stage=1
- end
- #更新方法
- def update
- #super
- super
- #基础的动态设定
- case @stage
- when 1
- #更新选项
- update_cursor
- #再次强化不透明度
- self.opacity=0
- #之后转成第二步
- @stage+=1
- when 2
- #变得透明
- self.opacity+=FADE_SPEED
- #如果已经变完了
- if self.opacity>=255
- #进入第三步
- @stage+=1
- end
- when 3
- #好的,于是咱来进行光标更新
- if Input.trigger?(:UP)
- Sound.play_cursor
- if @index==MIN_INDEX
- @index=MAX_INDEX
- else
- @index-=1
- end
- #输入完毕之后再更新
- update_cursor
- elsif Input.trigger?(:DOWN)
- Sound.play_cursor
- if @index==MAX_INDEX
- #强化条件
- @index=MIN_INDEX
- else
- @index+=1
- end
- #输入完毕之后再更新
- update_cursor
- end
- end
- end
- #index外置接口
- def index
- @index
- end
- #更新光标
- def update_cursor
- #设置当前bitmap名字
- bitmap_name="#{GRAPHICS[0]}#{@index}"
- self.bitmap=Cache.mc_title(bitmap_name)
- end
- #设置当前index
- def set_index(index)
- @index=index
- end
- end
- #==============================================================================
- # ■ Scene_Title
- #------------------------------------------------------------------------------
- # 标题类
- #==============================================================================
- # Scene类
- class Scene_Title < Scene_Base
- include LBQ::MC_Title
- def start
- super
- @timer=0
- #抄袭原版的=-=
- SceneManager.clear
- Graphics.freeze
- #创建显示端口
- create_viewports
- #创建背景
- create_background
- #创建精灵类
- create_sprites
- #播放标题音乐
- play_title_music
- #动态阶段
- @stage=0
- end
- #创建各种显示端口
- def create_viewports
- #背景
- #RESOLUTION[0],RESOLUTION[1]
- @bg_vp=Viewport.new(0,0,RESOLUTION[0],RESOLUTION[1])
- #选项
- @choice_vp=Viewport.new(0,0,RESOLUTION[0],RESOLUTION[1])
- @choice_vp.z=Z_SETTINGS[0]
- @mask_vp=Viewport.new(0,0,RESOLUTION[0],RESOLUTION[1])
- @mask_vp.z=Z_SETTINGS[2]
- end
- #创建背景
- def create_background
- #滚动的背景
- @bg_sprite=Plane.new(@bg_vp)
- #设置背景图像
- @bg_sprite.bitmap=Cache.mc_title(GRAPHICS[3])
- end
- #更新
- def update
- super
- #计时器+
- @timer+=1
- #滚动
- @bg_sprite.ox+=SHIFT_SPEED[1] if @timer%SHIFT_SPEED[0]==0
- case @stage
- when 0
- @mask_sprite.opacity-=MASK_FADE[0]
- if @mask_sprite.opacity<=0
- @stage=1
- end
- when 1
- #淡入阶段
- @logo_sprite.opacity+=FADE_SPEED
- if @logo_sprite.opacity>=255
- @stage=2
- end
- #更新选项
- @choice_sprite.update
- when 2
- @choice_sprite.update
- #如果确定了
- if Input.trigger?(:C)
- Sound.play_ok
- case @choice_sprite.index
- when 1
- @stage=3
- when 2
- @stage=4
- when 3
- @stage=5
- end
- end
- when 3
- Audio.bgm_fade(BGM_FADE)
- @mask_sprite.opacity+=MASK_FADE[1]
- if @mask_sprite.opacity>=255
- command_new_game
- end
- when 4
- command_continue
- when 5
- Audio.bgm_fade(BGM_FADE)
- @mask_sprite.opacity+=MASK_FADE[1]
- if @mask_sprite.opacity>=255
- exit
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 指令“继续游戏”
- #--------------------------------------------------------------------------
- def command_continue
- SceneManager.call(Scene_Load)
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- SceneManager.snapshot_for_background
- @logo_sprite.dispose
- @choice_sprite.dispose
- @bg_sprite.dispose
- @bg_vp.dispose
- @choice_vp.dispose
- end
- #--------------------------------------------------------------------------
- # ● 指令“开始游戏”
- #--------------------------------------------------------------------------
- def command_new_game
- DataManager.setup_new_game
- $game_map.autoplay
- SceneManager.goto(Scene_Map)
- end
- def create_sprites
- @logo_sprite=Sprite_Base.new(@choice_vp)
- @logo_sprite.bitmap=Cache.mc_title(GRAPHICS[2])
- @logo_sprite.opacity=0
- @choice_sprite=Sprite_Base.new(@choice_vp)
- @choice_sprite=Sprite_MCchoice.new(@choice_vp)
- @choice_sprite.opacity=0
- @mask_sprite=Sprite.new(@mask_vp)
- @mask_sprite.bitmap=Bitmap.new(RESOLUTION[0],RESOLUTION[1])
- @mask_sprite.bitmap.fill_rect(0,0,RESOLUTION[0],RESOLUTION[1],Color.new(0,0,0))
- end
- def play_title_music
- $data_system.title_bgm.play
- RPG::BGS.stop
- RPG::ME.stop
- end
- end
复制代码
标题菜单补丁- #LBQ标题菜单补丁——修复了进入第一个地图没有淡入的问题
- class Scene_Title
- #--------------------------------------------------------------------------
- # ● 指令“开始游戏”
- #--------------------------------------------------------------------------
- alias lbq_bugfix_title_newgame command_new_game
- def command_new_game
- fadeout_all
- lbq_bugfix_title_newgame
- end
- end
复制代码
Yanfly Engine Ace - System Options v1.00- #==============================================================================
- #
- # ▼ Yanfly Engine Ace - System Options v1.00
- # -- Last Updated: 2012.01.01
- # -- Level: Normal
- # -- Requires: n/a
- #
- #==============================================================================
- $imported = {} if $imported.nil?
- $imported["YEA-SystemOptions"] = true
- #==============================================================================
- # ▼ Updates
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # 2012.01.01 - Started Script and Finished.
- #
- #==============================================================================
- # ▼ Introduction
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This script replaces the "Game End" option in the Main Menu with a "System"
- # menu where the player can adjust various settings in the game. Of them, the
- # player can change the window colour, the volume for BGM, BGS, SFX, set
- # automatic dashing, message text to display instantly, and speed up battles by
- # hiding battle animations.
- #
- #==============================================================================
- # ▼ Instructions
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # To install this script, open up your script editor and copy/paste this script
- # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
- #
- # -----------------------------------------------------------------------------
- # Script Calls - These commands are used with script calls.
- # -----------------------------------------------------------------------------
- # $game_system.volume_change(:bgm, x)
- # $game_system.volume_change(:bgs, x)
- # $game_system.volume_change(:sfx, x)
- # Unlike the previous Yanfly Engines, this version does not bind volume to a
- # variable. Use the script call to change the bgm, bgs, or sfx sound rate by
- # x increment. Use a negative value to lower the volume.
- #
- # $game_system.set_autodash(true)
- # $game_system.set_autodash(false)
- # Turns autodash on (true) or off (false).
- #
- # $game_system.set_instantmsg(true)
- # $game_system.set_instantmsg(false)
- # Turns instant messages on (true) or off (false).
- #
- # $game_system.set_animations(true)
- # $game_system.set_animations(false)
- # Turns battle animations on (true) or off (false).
- #
- #==============================================================================
- # ▼ Compatibility
- # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
- # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
- # it will run with RPG Maker VX without adjusting.
- #
- #==============================================================================
- module YEA
- module SYSTEM
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # - General Setting -
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # These are the general settings that govern the System settings. This will
- # change the "Game End" vocab, and disable or enable autodash, instant
- # messages, or animations by default.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- COMMAND_NAME = "系统" # Command name used to replace Game End.
- DEFAULT_AUTODASH = true # Enable automatic dashing by default?
- DEFAULT_INSTANTMSG = false # Enable instant message text by default?
- DEFAULT_ANIMATIONS = true # Enable battle animations by default?
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # - Command Settings -
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # These settings adjust the commands shown in the command list. Add, remove
- # or rearrange the commands as you see fit. Here's a list of which commands
- # do what:
- #
- # -------------------------------------------------------------------------
- # :command Description
- # -------------------------------------------------------------------------
- # :blank Inserts an empty blank space.
- #
- # :window_red Changes the red tone for all windows.
- # :window_grn Changes the green tone for all windows.
- # :window_blu Changes the blue tone for all windows.
- #
- # :volume_bgm Changes the BGM volume used.
- # :volume_bgs Changes the BGS volume used.
- # :volume_sfx Changes the SFX volume used.
- #
- # :autodash Sets the player to automatically dash.
- # :instantmsg Sets message text to appear instantly.
- # :animations Enables battle animations or disables them.
- #
- # :to_title Returns to the title screen.
- # :shutdown Shuts down the game.
- #
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- COMMANDS =[
- :window_red, # Changes the red tone for all windows.
- :window_grn, # Changes the green tone for all windows.
- :window_blu, # Changes the blue tone for all windows.
- :volume_bgm, # Changes the BGM volume used.
- :volume_bgs, # Changes the BGS volume used.
- :volume_sfx, # Changes the SFX volume used.
- :blank,
- :autodash, # Sets the player to automatically dash.
- :instantmsg, # Sets message text to appear instantly.
- :animations, # Enables battle animations or disables them.
- # :switch_1, # Custom Switch 1. Adjust settings below.
- # :switch_2, # Custom Switch 2. Adjust settings below.
- # :variable_1, # Custom Variable 1. Adjust settings below.
- # :variable_2, # Custom Variable 2. Adjust settings below.
- :blank,
- :to_title, # Returns to the title screen.
- :shutdown, # Shuts down the game.
- ] # Do not remove this.
- #--------------------------------------------------------------------------
- # - Custom Switches -
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # If you want your game to have system options other than just the ones
- # listed above, you can insert custom switches here to produce such an
- # effect. Adjust the settings here as you see fit.
- #--------------------------------------------------------------------------
- CUSTOM_SWITCHES ={
- # -------------------------------------------------------------------------
- # :switch => [Switch, Name, Off Text, On Text,
- # Help Window Description
- # ], # Do not remove this.
- # -------------------------------------------------------------------------
- :switch_1 => [ 1, "Custom Switch 1", "OFF", "ON",
- "Help description used for custom switch 1."
- ],
- # -------------------------------------------------------------------------
- :switch_2 => [ 2, "Custom Switch 2", "OFF", "ON",
- "Help description used for custom switch 2."
- ],
- # -------------------------------------------------------------------------
- } # Do not remove this.
- #--------------------------------------------------------------------------
- # - Custom Variables -
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # If you want your game to have system options other than just the ones
- # listed above, you can insert custom variables here to produce such an
- # effect. Adjust the settings here as you see fit.
- #--------------------------------------------------------------------------
- CUSTOM_VARIABLES ={
- # -------------------------------------------------------------------------
- # :variable => [Switch, Name, Colour1, Colour2, Min, Max,
- # Help Window Description
- # ], # Do not remove this.
- # -------------------------------------------------------------------------
- :variable_1 => [ 1, "Custom Variable 1", 9, 1, -100, 100,
- "Help description used for custom variable 1."
- ],
- # -------------------------------------------------------------------------
- :variable_2 => [ 2, "Custom Variable 2", 10, 2, -10, 10,
- "Help description used for custom variable 2."
- ],
- # -------------------------------------------------------------------------
- } # Do not remove this.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # - Vocab Settings -
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- # This hash adjusts the vocab used for both the commands and the help
- # description that appears above the command window. Note that for the
- # command help descriptions, you may use text codes. Use \n to linebreak.
- #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
- COMMAND_VOCAB ={
- # -------------------------------------------------------------------------
- # :command => [Command Name, Option1, Option2
- # Help Window Description,
- # ], # Do not remove this.
- # -------------------------------------------------------------------------
- :blank => ["", "None", "None",
- ""
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :window_red => ["窗口红色", "None", "None",
- "改变红色色调的Window。\n" +
- "按住SHIFT键,用10来改变增量。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :window_grn => ["窗口绿色", "None", "None",
- "改变绿色色调的Window。\n" +
- "按住SHIFT键,用10来改变增量。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :window_blu => ["窗口蓝色", "None", "None",
- "改变蓝色色调的Window。\n" +
- "按住SHIFT键,用10来改变增量。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :volume_bgm => ["背景音乐量", 12, 4, # Options 1 & 2 are Gauge Colours.
- "更改用于背景音乐的音量。\n" +
- "按住SHIFT键,用10来改变增量。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :volume_bgs => ["背景声音量", 13, 5, # Options 1 & 2 are Gauge Colours.
- "改变用于背景声音的音量。\n" +
- "按住SHIFT键,用10来改变增量。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :volume_sfx => ["音效的声量", 14, 6, # Options 1 & 2 are Gauge Colours.
- "改变用于音效的音量。\n" +
- "按住SHIFT键,用10来改变增量。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :autodash => ["主角移动速度", "走", "跑",
- "自动跑不必用运行按钮。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :instantmsg => ["显示文字速度", "普通", "快速",
- "设置消息文字出现一个接一个或瞬间。"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :animations => ["战斗速度", "隐藏", "展现",
- "在战斗中,加快战斗隐藏的动画?"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :to_title => ["返回标题页面", "None", "None",
- "返回标题页面"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- :shutdown => ["退出游戏", "None", "None",
- "退出此游戏"
- ], # Do not remove this.
- # -------------------------------------------------------------------------
- } # Do not remove this.
- end # SYSTEM
- end # YEA
- #==============================================================================
- # ▼ Editting anything past this point may potentially result in causing
- # computer damage, incontinence, explosion of user's head, coma, death, and/or
- # halitosis so edit at your own risk.
- #==============================================================================
- #==============================================================================
- # ■ Vocab
- #==============================================================================
- module Vocab
- #--------------------------------------------------------------------------
- # overwrite method: self.game_end
- #--------------------------------------------------------------------------
- def self.game_end
- return YEA::SYSTEM::COMMAND_NAME
- end
- end # Vocab
- #==============================================================================
- # ■ RPG::BGM
- #==============================================================================
- class RPG::BGM < RPG::AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play(pos = 0)
- if @name.empty?
- Audio.bgm_stop
- @@last = RPG::BGM.new
- else
- volume = @volume
- volume *= $game_system.volume(:bgm) * 0.01 unless $game_system.nil?
- Audio.bgm_play('Audio/BGM/' + @name, volume, @pitch, pos)
- @@last = self.clone
- end
- end
- end # RPG::BGM
- #==============================================================================
- # ■ RPG::ME
- #==============================================================================
- class RPG::ME < RPG::AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play
- if @name.empty?
- Audio.me_stop
- else
- volume = @volume
- volume *= $game_system.volume(:bgm) * 0.01 unless $game_system.nil?
- Audio.me_play('Audio/ME/' + @name, volume, @pitch)
- end
- end
- end # RPG::ME
- #==============================================================================
- # ■ RPG::BGS
- #==============================================================================
- class RPG::BGS < RPG::AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play(pos = 0)
- if @name.empty?
- Audio.bgs_stop
- @@last = RPG::BGS.new
- else
- volume = @volume
- volume *= $game_system.volume(:bgs) * 0.01 unless $game_system.nil?
- Audio.bgs_play('Audio/BGS/' + @name, volume, @pitch, pos)
- @@last = self.clone
- end
- end
- end # RPG::BGS
- #==============================================================================
- # ■ RPG::SE
- #==============================================================================
- class RPG::SE < RPG::AudioFile
- #--------------------------------------------------------------------------
- # overwrite method: play
- #--------------------------------------------------------------------------
- def play
- unless @name.empty?
- volume = @volume
- volume *= $game_system.volume(:sfx) * 0.01 unless $game_system.nil?
- Audio.se_play('Audio/SE/' + @name, volume, @pitch)
- end
- end
- end # RPG::SE
- #==============================================================================
- # ■ Game_System
- #==============================================================================
- class Game_System
- #--------------------------------------------------------------------------
- # alias method: initialize
- #--------------------------------------------------------------------------
- alias game_system_initialize_so initialize
- def initialize
- game_system_initialize_so
- init_volume_control
- init_autodash
- init_instantmsg
- init_animations
- end
- #--------------------------------------------------------------------------
- # new method: init_volume_control
- #--------------------------------------------------------------------------
- def init_volume_control
- @volume = {}
- @volume[:bgm] = 100
- @volume[:bgs] = 100
- @volume[:sfx] = 100
- end
- #--------------------------------------------------------------------------
- # new method: volume
- #--------------------------------------------------------------------------
- def volume(type)
- init_volume_control if @volume.nil?
- return [[@volume[type], 0].max, 100].min
- end
- #--------------------------------------------------------------------------
- # new method: volume_change
- #--------------------------------------------------------------------------
- def volume_change(type, increment)
- init_volume_control if @volume.nil?
- @volume[type] += increment
- @volume[type] = [[@volume[type], 0].max, 100].min
- end
- #--------------------------------------------------------------------------
- # new method: init_autodash
- #--------------------------------------------------------------------------
- def init_autodash
- @autodash = YEA::SYSTEM::DEFAULT_AUTODASH
- end
- #--------------------------------------------------------------------------
- # new method: autodash?
- #--------------------------------------------------------------------------
- def autodash?
- init_autodash if @autodash.nil?
- return @autodash
- end
- #--------------------------------------------------------------------------
- # new method: set_autodash
- #--------------------------------------------------------------------------
- def set_autodash(value)
- @autodash = value
- end
- #--------------------------------------------------------------------------
- # new method: init_instantmsg
- #--------------------------------------------------------------------------
- def init_instantmsg
- @instantmsg = YEA::SYSTEM::DEFAULT_INSTANTMSG
- end
- #--------------------------------------------------------------------------
- # new method: instantmsg?
- #--------------------------------------------------------------------------
- def instantmsg?
- init_instantmsg if @instantmsg.nil?
- return @instantmsg
- end
- #--------------------------------------------------------------------------
- # new method: set_instantmsg
- #--------------------------------------------------------------------------
- def set_instantmsg(value)
- @instantmsg = value
- end
- #--------------------------------------------------------------------------
- # new method: init_animations
- #--------------------------------------------------------------------------
- def init_animations
- @animations = YEA::SYSTEM::DEFAULT_ANIMATIONS
- end
- #--------------------------------------------------------------------------
- # new method: animations?
- #--------------------------------------------------------------------------
- def animations?
- init_animations if @animations.nil?
- return @animations
- end
- #--------------------------------------------------------------------------
- # new method: set_animations
- #--------------------------------------------------------------------------
- def set_animations(value)
- @animations = value
- end
- end # Game_System
- #==============================================================================
- # ■ Game_Player
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # alias method: dash?
- #--------------------------------------------------------------------------
- alias game_player_dash_so dash?
- def dash?
- if $game_system.autodash?
- return false if @move_route_forcing
- return false if $game_map.disable_dash?
- return false if vehicle
- return !Input.press?(:A)
- else
- return game_player_dash_so
- end
- end
- end # Game_Player
- #==============================================================================
- # ■ Scene_Battle
- #==============================================================================
- class Scene_Battle < Scene_Base
- #--------------------------------------------------------------------------
- # alias method: show_fast?
- #--------------------------------------------------------------------------
- alias scene_battle_show_fast_so show_fast?
- def show_fast?
- return true unless $game_system.animations?
- return scene_battle_show_fast_so
- end
- #--------------------------------------------------------------------------
- # alias method: show_normal_animation
- #--------------------------------------------------------------------------
- alias scene_battle_show_normal_animation_so show_normal_animation
- def show_normal_animation(targets, animation_id, mirror = false)
- return unless $game_system.animations?
- scene_battle_show_normal_animation_so(targets, animation_id, mirror)
- end
- end # Scene_Battle
- #==============================================================================
- # ■ Window_Message
- #==============================================================================
- class Window_Message < Window_Base
- #--------------------------------------------------------------------------
- # alias method: clear_flags
- #--------------------------------------------------------------------------
- alias window_message_clear_flags_so clear_flags
- def clear_flags
- window_message_clear_flags_so
- @show_fast = true if $game_system.instantmsg?
- end
- end # Window_Message
- #==============================================================================
- # ■ Window_SystemOptions
- #==============================================================================
- class Window_SystemOptions < Window_Command
- #--------------------------------------------------------------------------
- # initialize
- #--------------------------------------------------------------------------
- def initialize(help_window)
- @help_window = help_window
- super(0, @help_window.height)
- refresh
- end
- #--------------------------------------------------------------------------
- # window_width
- #--------------------------------------------------------------------------
- def window_width; return Graphics.width; end
- #--------------------------------------------------------------------------
- # window_height
- #--------------------------------------------------------------------------
- def window_height; return Graphics.height - @help_window.height; end
- #--------------------------------------------------------------------------
- # update_help
- #--------------------------------------------------------------------------
- def update_help
- if current_symbol == :custom_switch || current_symbol == :custom_variable
- text = @help_descriptions[current_ext]
- else
- text = @help_descriptions[current_symbol]
- end
- text = "" if text.nil?
- @help_window.set_text(text)
- end
- #--------------------------------------------------------------------------
- # ok_enabled?
- #--------------------------------------------------------------------------
- def ok_enabled?
- return true if [:to_title, :shutdown].include?(current_symbol)
- return false
- end
- #--------------------------------------------------------------------------
- # make_command_list
- #--------------------------------------------------------------------------
- def make_command_list
- @help_descriptions = {}
- for command in YEA::SYSTEM::COMMANDS
- case command
- when :blank
- add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
- @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
- when :window_red, :window_grn, :window_blu
- add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
- @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
- when :volume_bgm, :volume_bgs, :volume_sfx
- add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
- @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
- when :autodash, :instantmsg, :animations
- add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
- @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
- when :to_title, :shutdown
- add_command(YEA::SYSTEM::COMMAND_VOCAB[command][0], command)
- @help_descriptions[command] = YEA::SYSTEM::COMMAND_VOCAB[command][3]
- else
- process_custom_switch(command)
- process_custom_variable(command)
- end
- end
- end
- #--------------------------------------------------------------------------
- # process_custom_switch
- #--------------------------------------------------------------------------
- def process_custom_switch(command)
- return unless YEA::SYSTEM::CUSTOM_SWITCHES.include?(command)
- name = YEA::SYSTEM::CUSTOM_SWITCHES[command][1]
- add_command(name, :custom_switch, true, command)
- @help_descriptions[command] = YEA::SYSTEM::CUSTOM_SWITCHES[command][4]
- end
- #--------------------------------------------------------------------------
- # process_custom_variable
- #--------------------------------------------------------------------------
- def process_custom_variable(command)
- return unless YEA::SYSTEM::CUSTOM_VARIABLES.include?(command)
- name = YEA::SYSTEM::CUSTOM_VARIABLES[command][1]
- add_command(name, :custom_variable, true, command)
- @help_descriptions[command] = YEA::SYSTEM::CUSTOM_VARIABLES[command][6]
- end
- #--------------------------------------------------------------------------
- # draw_item
- #--------------------------------------------------------------------------
- def draw_item(index)
- reset_font_settings
- rect = item_rect(index)
- contents.clear_rect(rect)
- case @list[index][:symbol]
- when :window_red, :window_grn, :window_blu
- draw_window_tone(rect, index, @list[index][:symbol])
- when :volume_bgm, :volume_bgs, :volume_sfx
- draw_volume(rect, index, @list[index][:symbol])
- when :autodash, :instantmsg, :animations
- draw_toggle(rect, index, @list[index][:symbol])
- when :to_title, :shutdown
- draw_text(item_rect_for_text(index), command_name(index), 1)
- when :custom_switch
- draw_custom_switch(rect, index, @list[index][:ext])
- when :custom_variable
- draw_custom_variable(rect, index, @list[index][:ext])
- end
- end
- #--------------------------------------------------------------------------
- # draw_window_tone
- #--------------------------------------------------------------------------
- def draw_window_tone(rect, index, symbol)
- name = @list[index][:name]
- draw_text(0, rect.y, contents.width/2, line_height, name, 1)
- #---
- dx = contents.width / 2
- tone = $game_system.window_tone
- case symbol
- when :window_red
- rate = (tone.red + 255.0) / 510.0
- colour1 = Color.new(128, 0, 0)
- colour2 = Color.new(255, 0, 0)
- value = tone.red.to_i
- when :window_grn
- rate = (tone.green + 255.0) / 510.0
- colour1 = Color.new(0, 128, 0)
- colour2 = Color.new(0, 255, 0)
- value = tone.green.to_i
- when :window_blu
- rate = (tone.blue + 255.0) / 510.0
- colour1 = Color.new(0, 0, 128)
- colour2 = Color.new(0, 0, 255)
- value = tone.blue.to_i
- end
- draw_gauge(dx, rect.y, contents.width - dx - 48, rate, colour1, colour2)
- draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
- end
- #--------------------------------------------------------------------------
- # draw_volume
- #--------------------------------------------------------------------------
- def draw_volume(rect, index, symbol)
- name = @list[index][:name]
- draw_text(0, rect.y, contents.width/2, line_height, name, 1)
- #---
- dx = contents.width / 2
- case symbol
- when :volume_bgm
- rate = $game_system.volume(:bgm)
- when :volume_bgs
- rate = $game_system.volume(:bgs)
- when :volume_sfx
- rate = $game_system.volume(:sfx)
- end
- colour1 = text_color(YEA::SYSTEM::COMMAND_VOCAB[symbol][1])
- colour2 = text_color(YEA::SYSTEM::COMMAND_VOCAB[symbol][2])
- value = sprintf("%d%%", rate)
- rate *= 0.01
- draw_gauge(dx, rect.y, contents.width - dx - 48, rate, colour1, colour2)
- draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
- end
- #--------------------------------------------------------------------------
- # draw_toggle
- #--------------------------------------------------------------------------
- def draw_toggle(rect, index, symbol)
- name = @list[index][:name]
- draw_text(0, rect.y, contents.width/2, line_height, name, 1)
- #---
- dx = contents.width / 2
- case symbol
- when :autodash
- enabled = $game_system.autodash?
- when :instantmsg
- enabled = $game_system.instantmsg?
- when :animations
- enabled = $game_system.animations?
- end
- dx = contents.width/2
- change_color(normal_color, !enabled)
- option1 = YEA::SYSTEM::COMMAND_VOCAB[symbol][1]
- draw_text(dx, rect.y, contents.width/4, line_height, option1, 1)
- dx += contents.width/4
- change_color(normal_color, enabled)
- option2 = YEA::SYSTEM::COMMAND_VOCAB[symbol][2]
- draw_text(dx, rect.y, contents.width/4, line_height, option2, 1)
- end
- #--------------------------------------------------------------------------
- # cursor_right
- #--------------------------------------------------------------------------
- def draw_custom_switch(rect, index, ext)
- name = @list[index][:name]
- draw_text(0, rect.y, contents.width/2, line_height, name, 1)
- #---
- dx = contents.width / 2
- enabled = $game_switches[YEA::SYSTEM::CUSTOM_SWITCHES[ext][0]]
- dx = contents.width/2
- change_color(normal_color, !enabled)
- option1 = YEA::SYSTEM::CUSTOM_SWITCHES[ext][2]
- draw_text(dx, rect.y, contents.width/4, line_height, option1, 1)
- dx += contents.width/4
- change_color(normal_color, enabled)
- option2 = YEA::SYSTEM::CUSTOM_SWITCHES[ext][3]
- draw_text(dx, rect.y, contents.width/4, line_height, option2, 1)
- end
- #--------------------------------------------------------------------------
- # draw_custom_variable
- #--------------------------------------------------------------------------
- def draw_custom_variable(rect, index, ext)
- name = @list[index][:name]
- draw_text(0, rect.y, contents.width/2, line_height, name, 1)
- #---
- dx = contents.width / 2
- value = $game_variables[YEA::SYSTEM::CUSTOM_VARIABLES[ext][0]]
- colour1 = text_color(YEA::SYSTEM::CUSTOM_VARIABLES[ext][2])
- colour2 = text_color(YEA::SYSTEM::CUSTOM_VARIABLES[ext][3])
- minimum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][4]
- maximum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][5]
- rate = (value - minimum).to_f / [(maximum - minimum).to_f, 0.01].max
- dx = contents.width/2
- draw_gauge(dx, rect.y, contents.width - dx - 48, rate, colour1, colour2)
- draw_text(dx, rect.y, contents.width - dx - 48, line_height, value, 2)
- end
- #--------------------------------------------------------------------------
- # cursor_right
- #--------------------------------------------------------------------------
- def cursor_right(wrap = false)
- cursor_change(:right)
- super(wrap)
- end
- #--------------------------------------------------------------------------
- # cursor_left
- #--------------------------------------------------------------------------
- def cursor_left(wrap = false)
- cursor_change(:left)
- super(wrap)
- end
- #--------------------------------------------------------------------------
- # cursor_change
- #--------------------------------------------------------------------------
- def cursor_change(direction)
- case current_symbol
- when :window_red, :window_blu, :window_grn
- change_window_tone(direction)
- when :volume_bgm, :volume_bgs, :volume_sfx
- change_volume(direction)
- when :autodash, :instantmsg, :animations
- change_toggle(direction)
- when :custom_switch
- change_custom_switch(direction)
- when :custom_variable
- change_custom_variables(direction)
- end
- end
- #--------------------------------------------------------------------------
- # change_window_tone
- #--------------------------------------------------------------------------
- def change_window_tone(direction)
- Sound.play_cursor
- value = direction == :left ? -1 : 1
- value *= 10 if Input.press?(:A)
- tone = $game_system.window_tone.clone
- case current_symbol
- when :window_red; tone.red += value
- when :window_grn; tone.green += value
- when :window_blu; tone.blue += value
- end
- $game_system.window_tone = tone
- draw_item(index)
- end
- #--------------------------------------------------------------------------
- # change_window_tone
- #--------------------------------------------------------------------------
- def change_volume(direction)
- Sound.play_cursor
- value = direction == :left ? -1 : 1
- value *= 10 if Input.press?(:A)
- case current_symbol
- when :volume_bgm
- $game_system.volume_change(:bgm, value)
- RPG::BGM::last.play
- when :volume_bgs
- $game_system.volume_change(:bgs, value)
- RPG::BGS::last.play
- when :volume_sfx
- $game_system.volume_change(:sfx, value)
- end
- draw_item(index)
- end
- #--------------------------------------------------------------------------
- # change_toggle
- #--------------------------------------------------------------------------
- def change_toggle(direction)
- value = direction == :left ? false : true
- case current_symbol
- when :autodash
- current_case = $game_system.autodash?
- $game_system.set_autodash(value)
- when :instantmsg
- current_case = $game_system.instantmsg?
- $game_system.set_instantmsg(value)
- when :animations
- current_case = $game_system.animations?
- $game_system.set_animations(value)
- end
- Sound.play_cursor if value != current_case
- draw_item(index)
- end
- #--------------------------------------------------------------------------
- # change_custom_switch
- #--------------------------------------------------------------------------
- def change_custom_switch(direction)
- value = direction == :left ? false : true
- ext = current_ext
- current_case = $game_switches[YEA::SYSTEM::CUSTOM_SWITCHES[ext][0]]
- $game_switches[YEA::SYSTEM::CUSTOM_SWITCHES[ext][0]] = value
- Sound.play_cursor if value != current_case
- draw_item(index)
- end
- #--------------------------------------------------------------------------
- # change_custom_variables
- #--------------------------------------------------------------------------
- def change_custom_variables(direction)
- Sound.play_cursor
- value = direction == :left ? -1 : 1
- value *= 10 if Input.press?(:A)
- ext = current_ext
- var = YEA::SYSTEM::CUSTOM_VARIABLES[ext][0]
- minimum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][4]
- maximum = YEA::SYSTEM::CUSTOM_VARIABLES[ext][5]
- $game_variables[var] += value
- $game_variables[var] = [[$game_variables[var], minimum].max, maximum].min
- draw_item(index)
- end
- end # Window_SystemOptions
- #==============================================================================
- # ■ Scene_Menu
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # overwrite method: command_game_end
- #--------------------------------------------------------------------------
- def command_game_end
- SceneManager.call(Scene_System)
- end
- end # Scene_Menu
- #==============================================================================
- # ■ Scene_System
- #==============================================================================
- class Scene_System < Scene_MenuBase
- #--------------------------------------------------------------------------
- # start
- #--------------------------------------------------------------------------
- def start
- super
- create_help_window
- create_command_window
- end
- #--------------------------------------------------------------------------
- # create_command_window
- #--------------------------------------------------------------------------
- def create_command_window
- @command_window = Window_SystemOptions.new(@help_window)
- @command_window.set_handler(:cancel, method(:return_scene))
- @command_window.set_handler(:to_title, method(:command_to_title))
- @command_window.set_handler(:shutdown, method(:command_shutdown))
- end
- #--------------------------------------------------------------------------
- # command_to_title
- #--------------------------------------------------------------------------
- def command_to_title
- fadeout_all
- SceneManager.goto(Scene_Title)
- end
- #--------------------------------------------------------------------------
- # command_shutdown
- #--------------------------------------------------------------------------
- def command_shutdown
- fadeout_all
- SceneManager.exit
- end
- end # Scene_System
- #==============================================================================
- #
- # ▼ End of File
- #
- #==============================================================================
复制代码
Taroxd基础设置
- #--------------------------------------------------------------------------
- # ● require Taroxd基础设置
- #--------------------------------------------------------------------------
- class Game_System
- #--------------------------------------------------------------------------
- # ● 是否关闭显示消息
- #--------------------------------------------------------------------------
- attr_accessor :gain_message_disabled
- def_after(:initialize) { @gain_message_disabled = false }
- end
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● 打开显示消息
- #--------------------------------------------------------------------------
- def gain_message_on
- $game_system.gain_message_disabled = false
- end
- #--------------------------------------------------------------------------
- # ● 关闭显示消息
- #--------------------------------------------------------------------------
- def gain_message_off
- $game_system.gain_message_disabled = true
- end
- #--------------------------------------------------------------------------
- # ● 显示提示窗口
- #--------------------------------------------------------------------------
- def show_gain_message(item, value)
- return if $game_system.gain_message_disabled || value == 0
- message =
- if item
- "#{value > 0 ? '获得' : '失去'}了 #{item.name} * #{value}"
- else
- "#{value > 0 ? '获得' : '失去'}了 #{value} #{Vocab.currency_unit}"
- end
- wait_for_message
- $game_message.add(message)
- wait_for_message
- end
- #--------------------------------------------------------------------------
- # ● 增减持有金钱
- #--------------------------------------------------------------------------
- def_after :command_125 do
- value = operate_value(@params[0], @params[1], @params[2])
- show_gain_message(nil, value)
- end
- #--------------------------------------------------------------------------
- # ● 增减物品
- #--------------------------------------------------------------------------
- def_after :command_126 do
- value = operate_value(@params[1], @params[2], @params[3])
- show_gain_message($data_items[@params[0]], value)
- end
- #--------------------------------------------------------------------------
- # ● 增减武器
- #--------------------------------------------------------------------------
- def_after :command_127 do
- value = operate_value(@params[1], @params[2], @params[3])
- show_gain_message($data_weapons[@params[0]], value)
- end
- #--------------------------------------------------------------------------
- # ● 增减护甲
- #--------------------------------------------------------------------------
- def_after :command_128 do
- value = operate_value(@params[1], @params[2], @params[3])
- show_gain_message($data_armors[@params[0]], value)
- end
- end
复制代码
Syvkal's Menu Bars VXAce- #==============================================================================
- # ** Syvkal's Menu Bars VXAce
- #------------------------------------------------------------------------------
- # by Syvkal
- # Version 1.2
- # 19-03-12
- #------------------------------------------------------------------------------
- # * Original available at:
- # www.rpgmakervxace.net & forums.rpgmakerweb.com
- # Please do not redistribute this script
- #------------------------------------------------------------------------------
- # * Terms of Use
- # Available for use in commercial games provided that I get a free copy :P
- # Email me: syvkal@hotmail.co.uk
- # Please do not redistribute this script
- #==============================================================================
- #
- # - INTRODUCTION -
- #
- # This system implements a series of Plug 'N' Play Menu Bars/Gauges
- # The Bars (and some of the colour schemes) were inspired CogWheel,
- # but all coding was done by me
- #
- #------------------------------------------------------------------------------
- #
- # - USAGE -
- #
- # This system will work as soon as you put it in the Script Editor
- # You can edit the script from the Configuration System
- #
- # --- Custom Gauges -----------------------------------
- #
- # I have designed the script so you can easily (with minimal scripting
- # knowledge) add you own custom gauges for any attribute you want
- #
- # To draw a gauge use:
- # draw_syvkal_gauge(x, y, width, rate, color1, color2, slant)
- #
- # rate : Percentage of your custom attribute max (full at 1.0)
- # color1 : left side gradient color
- # color2 : right side gradient color
- # style : gauge draw style (explained in the Configuration System)
- #
- # --- Auto Generate Color ---------------------------
- #
- # Additionally, I have added an extra function to make it easy to
- # create your own colours that change as the gauge decreases
- #
- # To generate a custom colour use:
- # auto_color(color1, color2, r)
- #
- # r : Percentage of your custom attribute max (full at 1.0)
- # color1 : Colour you want for when the gauge is full
- # color2 : Colour you want for when the gauge is nearly empty
- #
- # This generates a SINGLE colour that changes with the gauge
- # Each gauge requires two colours so it has a gradient
- #
- # --- Ring Bars -------------------------------------
- #
- # Ring Bars have been removed for now, I didn't like how they looked
- # Testing has shown RGSS3 is more capable of the kind of ring bars I
- # wanted to make, but I want to perfect them first
- #
- #==============================================================================
- #===================================================#
- # ** M I N O R C O N F I G U R A T I O N ** #
- #===================================================#
- #--------------------------------------------------------------------------
- # * Parameter Gauge Max
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Minor addition allowing you to choose a max for the parameter gauges
- # Best set just above your actor's highest stat (to allow for buffs)
- # Excludes HP, MP, TP
- # (This does not affect your actor's stats, but simply makes the gauges
- # fill up quicker and look more appealing)
- #--------------------------------------------------------------------------
- P_MAX = 400 # Parameter Gauge Max
- #-------------------------------------------------------------------------#
- # ** Full Configuration system further down ** #
- #-------------------------------------------------------------------------#
- #==============================================================================
- # ** Window_Base
- #------------------------------------------------------------------------------
- # Replaces various 'Draw' functions to add each gauge.
- #==============================================================================
- class Window_Base < Window
- #===================================================#
- # ** C O N F I G U R A T I O N S Y S T E M ** #
- #===================================================#
- #--------------------------------------------------------------------------
- # * Gauge Draw Styles
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Use different bracket types to 'draw' the style of each bar
- # Available bracket types:
- # ( ) < > | / \
- # Simply mix and match for achieve your desired effect
- #
- # To use the default rectangular gauges, use | or simply leave blank
- # eg. '| |' or ''
- # Any invalid symbol will result in the default | as well
- #
- # - - W A R N I N G - -
- #
- # When using the following bracket:
- # \
- # Ensure it is followed a space (eg. '| \ ') or itself (eg. '| \\')
- # If the rest of the text below turns purple, you've done it wrong
- #--------------------------------------------------------------------------
- HPSTYLE = '| |' # Style of the HP Gauge
- MPSTYLE = '| |' # Style of the MP Gauge
- TPSTYLE = '/ /' # Style of the TP Gauge
- PARSTYLE = '( )' # Style of the Parameter Gauges
- #--------------------------------------------------------------------------
- # * Additional Gauge Preferences
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Simple adjustments to aesthetics
- # Advised to use SLANTDSIZE if you have used / or \ in multiple bars
- #--------------------------------------------------------------------------
- THICKCURVED = false # Slightly thicken curved bars?
- SLANTDSIZE = true # Shorten slanted bars?
- #--------------------------------------------------------------------------
- # * Gauge Border Colors
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Control the colours of the gauge borders
- #--------------------------------------------------------------------------
- COLOR1 = Color.new(0, 0, 0, 192) # Outer Border
- COLOR2 = Color.new(255, 255, 192, 192) # Inner Border
- #--------------------------------------------------------------------------
- # * Empty Cauge Filler Colors
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Control the colours of the empty gauge filler
- #--------------------------------------------------------------------------
- COLOR3 = Color.new(0, 0, 0, 12) # Half of Inner Shading
- COLOR4 = Color.new(64, 0, 0, 92) # Half of Inner Shading
- #--------------------------------------------------------------------------
- # * Paramater Gauge Colors
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Control the colours of various parameters such as ATK, DEF, etc.
- # (HP, MP, TP are in the 'Complex Configuration' section)
- #--------------------------------------------------------------------------
- def param_gauge_color1(param_id)
- case param_id
- when 2
- text_color(20) # ATK Gauge Color1
- when 3
- text_color(14) # DEF Gauge Color1
- when 4
- text_color(30) # MAT Gauge Color1
- when 5
- text_color(13) # MDF Gauge Color1
- when 6
- text_color(28) # AGI Gauge Color1
- when 7
- text_color(19) # LUK Gauge Color1
- end
- end
- def param_gauge_color2(param_id)
- case param_id
- when 2
- text_color(21) # ATK Gauge Color1
- when 3
- text_color(6) # DEF Gauge Color1
- when 4
- text_color(31) # MAT Gauge Color1
- when 5
- text_color(5) # MDF Gauge Color1
- when 6
- text_color(29) # AGI Gauge Color1
- when 7
- text_color(7) # LUK Gauge Color1
- end
- end
- #===================================================#
- # ** C O M P L E X C O N F I G U R A T I O N ** #
- #===================================================#
- #--------------------------------------------------------------------------
- # * HP Gauge Colors
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Control the colours of the HP gauge
- # (Edit only if you know what you're doing)
- #--------------------------------------------------------------------------
- def hp_gauge_color1 # HP Guage Color1
- return Color.new(80 - 24 * @rate, 80 * @rate, 14 * @rate, 192)
- end
- def hp_gauge_color2 # HP Guage Color2
- return Color.new(240 - 72 * @rate, 240 * @rate, 62 * @rate, 192)
- end
- #--------------------------------------------------------------------------
- # * MP Gauge Colors
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Control the colours of the MP gauge
- # (Edit only if you know what you're doing)
- #--------------------------------------------------------------------------
- def mp_gauge_color1 # MP Guage Color1
- return Color.new(14 * @rate, 80 - 24 * @rate, 80 * @rate, 192)
- end
- def mp_gauge_color2 # MP Guage Color2
- return Color.new(62 * @rate, 240 - 72 * @rate, 240 * @rate, 192)
- end
- #--------------------------------------------------------------------------
- # * TP Gauge Colors
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Control the colours of the TP gauge
- # (Edit only if you know what you're doing)
- #--------------------------------------------------------------------------
- def tp_gauge_color1 # TP Gauge Color1
- return auto_color(Color.new(192,0,0,192), Color.new(255,110,0,192))
- end
- def tp_gauge_color2 # TP Gauge Color2
- return auto_color(Color.new(255,165,0,192), Color.new(255,220,0,192))
- end
- #===================================================#
- # ** E N D C O N F I G U R A T I O N ** #
- #===================================================#
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :rate # Rate for Colour calculations
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias draw_actor_param_original draw_actor_param
- alias initialize_original initialize
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- @rate = 1.0
- initialize_original(x, y, width, height)
- end
- #--------------------------------------------------------------------------
- # * Draw HP
- #--------------------------------------------------------------------------
- def draw_actor_hp(actor, x, y, width = 124)
- @rate = [actor.hp_rate, 1.0].min
- draw_syvkal_gauge(x, y, width, @rate, hp_gauge_color1, hp_gauge_color2, HPSTYLE)
- change_color(system_color)
- draw_text(x, y, 30, line_height, Vocab::hp_a)
- draw_current_and_max_values(x, y, width, actor.hp, actor.mhp,
- hp_color(actor), normal_color)
- end
- #--------------------------------------------------------------------------
- # * Draw MP
- #--------------------------------------------------------------------------
- def draw_actor_mp(actor, x, y, width = 124)
- @rate = [actor.mp_rate, 1.0].min
- draw_syvkal_gauge(x, y, width, @rate, mp_gauge_color1, mp_gauge_color2, MPSTYLE)
- change_color(system_color)
- draw_text(x, y, 30, line_height, Vocab::mp_a)
- draw_current_and_max_values(x, y, width, actor.mp, actor.mmp,
- mp_color(actor), normal_color)
- end
- #--------------------------------------------------------------------------
- # * Draw TP
- #--------------------------------------------------------------------------
- def draw_actor_tp(actor, x, y, width = 124)
- @rate = [actor.tp_rate, 1.0].min
- draw_syvkal_gauge(x, y, width, @rate, tp_gauge_color1, tp_gauge_color2, TPSTYLE)
- change_color(system_color)
- draw_text(x, y, 30, line_height, Vocab::tp_a)
- change_color(tp_color(actor))
- draw_text(x + width - 42, y, 42, line_height, actor.tp.to_i, 2)
- end
- #--------------------------------------------------------------------------
- # * Draw Parameters
- # actor : actor
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # type : Type of parameters (0-3)
- #--------------------------------------------------------------------------
- def draw_actor_param(actor, x, y, param_id, width = 80)
- draw_syvkal_gauge(x, y, width, actor.params_rate(param_id), param_gauge_color1(param_id), param_gauge_color2(param_id), PARSTYLE)
- draw_actor_param_original(actor, x, y, param_id)
- end
- #--------------------------------------------------------------------------
- # * Auto Generate Color
- # color1 : initial color
- # color2 : ending color
- # r : rate (full at 1.0) 1 -> color1, 0 -> color2
- #--------------------------------------------------------------------------
- def auto_color(color1, color2, r = @rate)
- a_color = Color.new
- a_color.red = (1-r)*color2.red + r*color1.red
- a_color.green = (1-r)*color2.green + r*color1.green
- a_color.blue = (1-r)*color2.blue + r*color1.blue
- a_color.alpha = (1-r)*color2.alpha + r*color1.alpha
- return a_color
- end
- #--------------------------------------------------------------------------
- # * Draw Syvkal Style Gauge
- # rate : Rate (full at 1.0)
- # color1 : Left side color
- # color2 : Right side color
- # style : gauge draw style
- #--------------------------------------------------------------------------
- def draw_syvkal_gauge(x, y, width, rate, color1, color2, style = '')
- fill_w = (width * rate).to_i
- gauge_y = y + line_height - 8
- h = 6
- style.slice!(/\s*/); style = style.split(/\s*/)
- if style.empty? or (style[0] == '|' && style[1] == '|')
- contents.fill_rect(x-2, gauge_y-2, width+4, 10, COLOR1)
- contents.fill_rect(x-1, gauge_y-1, width+2, 8, COLOR2)
- contents.gradient_fill_rect(x, gauge_y, width, 6, COLOR3, COLOR4)
- contents.gradient_fill_rect(x, gauge_y, fill_w, 6, color1, color2)
- else
- adj1 = style_adj_string(style[0]); adj2 = style_adj_string(style[1], true)
- h += 4
- for i in 0...h
- a1 = eval(adj1[0]); a2 = eval(adj2[0])
- a3 = adj1[2]; a4 = adj2[4].nil? ? adj2[2] : adj2[4]
- contents.fill_rect(x-a3 +a1, gauge_y-2 + i, width+(a3+a4) - a1 - a2, 1, COLOR1)
- end
- h -= 2
- for i in 0...h
- a1 = eval(adj1[0]); a2 = eval(adj2[0])
- a3 = adj1[1]; a4 = adj2[3].nil? ? adj2[1] : adj2[3]
- contents.fill_rect(x-a3 +a1, gauge_y-1 + i, width+(a3+a4) - a1 - a2, 1, COLOR2)
- end
- h -= 2
- for i in 0...h
- a1 = eval(adj1[0]); a2 = eval(adj2[0])
- contents.gradient_fill_rect(x +a1, gauge_y +i, width - a1 - a2, 1, COLOR3, COLOR4)
- end
- for i in 0...h
- a1 = eval(adj1[0]); a2 = eval(adj2[0])
- contents.gradient_fill_rect(x +a1, gauge_y +i, fill_w - a1 - a2, 1, color1, color2)
- end
- end
- end
- #--------------------------------------------------------------------------
- # * Get Style Specific Adjustment Array
- # sym : edge style '(', ')', '<', '>', '|', '/' or '\'
- # edge : end of the gauge?
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Returns an array containing the following:
- # * a formular string to be evaluated
- # * adjustments to x and width values for Outer and Inner Borders
- #--------------------------------------------------------------------------
- def style_adj_string(sym, edge = false)
- case sym
- when '/'
- SLANTDSIZE ? [(edge ? 'i+2' : '(h+1) - i'), 3, 5] :
- [(edge ? 'i' : '(h-1) - i'), 3, 5]
- when '\\'
- SLANTDSIZE ? [(edge ? '(h+1) - i' : 'i+2'), 3, 5] :
- [(edge ? '(h-1) - i' : 'i'), 3, 5]
- when '<'
- [(edge ? '(h/2)-((h/2) - i).abs' : '((h/2) - i).abs'), 2, 3]
- when '>'
- [(edge ? '((h/2) - i).abs' : '(h/2)-((h/2) - i).abs'), 2, 3]
- when '('
- [(edge ? '((h/2) * Math.sin(i * 1.0 * Math::PI / (h-1))).round.to_i' :
- '(h-6) - ((h/2) * Math.sin(i * 1.0 * Math::PI / (h-1))).round.to_i'),
- THICKCURVED ? 3 : 2, THICKCURVED ? 5 : 4, 3, 5]
- when ')'
- [(edge ? '(h-3) - ((h/2) * Math.sin(i * 1.0 * Math::PI / (h-1))).round.to_i' :
- '((h/2) * Math.sin(i * 1.0 * Math::PI / (h-1))).round.to_i'),
- 3, 5, THICKCURVED ? 3 : 2, THICKCURVED ? 5 : 4]
- else # eg. | or invalid sym
- ['0', 1, 2]
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Gauge
- #--------------------------------------------------------------------------
- def draw_gauge(x, y, width, rate, color1, color2, style = '')
- r = [rate, 1.0].min
- draw_syvkal_gauge(x, y, width, r, color1, color2, style)
- end
- end
- #==============================================================================
- # ** Game_BattlerBase
- #------------------------------------------------------------------------------
- # Added specialised 'params_rate' function.
- #==============================================================================
- class Game_BattlerBase
- #--------------------------------------------------------------------------
- # * Get Percentage of Paramaters
- #--------------------------------------------------------------------------
- def params_rate(param_id)
- return [param(param_id).to_f / P_MAX, 1.0].min
- end
- end
- #==============================================================================
- # ** Script Import
- #==============================================================================
- $imported = {} if $imported == nil
- $imported["Syvkal's Menu Bars"] = true
复制代码
获取道具总数
- #--------------------------------------------------------------------------
- # ● 自动显示得失物品提示
- #--------------------------------------------------------------------------
- module Taroxd end
- module Taroxd::GainMessage
- #--------------------------------------------------------------------------
- # ● 常数设置
- #--------------------------------------------------------------------------
- SWITCH = 0 # 开关打开时功能开启。可以填入 0 表示始终打开。
- GAIN = '获得'
- LOSE = '失去'
- ITEM_FORMAT = '%s了 %s * %d' # 获得/失去了 某物品 * N
- GOLD_FORMAT = '%s了 %d %s' # 获得/失去了 N 金钱单位
- BACKGROUND = 1 # 窗口背景(0/1/2)
- POSITION = 1 # 显示位置(0/1/2)
- GAIN_GOLD_SE = 'Shop' # 获得金钱音效(不需要的话可以直接删去该行)
- LOSE_GOLD_SE = 'Blow2' # 失去金钱音效(不需要的话可以直接删去该行)
- GAIN_ITEM_SE = 'Item1' # 获得物品音效(不需要的话可以直接删去该行)
- LOSE_ITEM_SE = LOSE_GOLD_SE # 失去物品音效(不需要的话可以直接删去该行)
- #--------------------------------------------------------------------------
- module_function
- #--------------------------------------------------------------------------
- # ● 功能是否启用
- #--------------------------------------------------------------------------
- def enabled?
- SWITCH.zero? || $game_switches[SWITCH]
- end
- #--------------------------------------------------------------------------
- # ● 准备
- #--------------------------------------------------------------------------
- def prepare(value, item)
- @item = item
- @value = value
- $game_message.background = BACKGROUND
- $game_message.position = POSITION
- play_se
- end
- #--------------------------------------------------------------------------
- # ● 获取提示的消息
- #--------------------------------------------------------------------------
- def message
- prefix = @value > 0 ? GAIN : LOSE
- if @item
- sprintf(ITEM_FORMAT, prefix, @item.name, @value.abs)
- else
- sprintf(GOLD_FORMAT, prefix, @value.abs, Vocab.currency_unit)
- end
- end
- #--------------------------------------------------------------------------
- # ● 播放音效
- #--------------------------------------------------------------------------
- def play_se
- const = :"#{@value > 0 ? 'GAIN' : 'LOSE'}_#{@item ? 'ITEM' : 'GOLD'}_SE"
- se = const_defined?(const) && const_get(const)
- Audio.se_play('Audio/SE/' + se) if se
- end
- end
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● 获取道具总数(包括装备)
- #--------------------------------------------------------------------------
- def item_number_with_equip(item)
- members.inject(item_number(item)) do |number, actor|
- number + actor.equips.count(item)
- end
- end
- end
- class Game_Interpreter
- alias taroxd_gain_message_command_125 command_125
- alias taroxd_gain_message_command_126 command_126
- alias taroxd_gain_message_command_127 command_127
- alias taroxd_gain_message_command_128 command_128
- #--------------------------------------------------------------------------
- # ● 显示提示窗口
- #--------------------------------------------------------------------------
- def show_gain_message(value, item = nil)
- return if !Taroxd::GainMessage.enabled? || value.zero?
- Taroxd::GainMessage.prepare value, item
- wait_for_message
- $game_message.add Taroxd::GainMessage.message
- wait_for_message
- end
- #--------------------------------------------------------------------------
- # ● 增减持有金钱
- #--------------------------------------------------------------------------
- def command_125
- last_gold = $game_party.gold
- taroxd_gain_message_command_125
- show_gain_message($game_party.gold - last_gold)
- end
- #--------------------------------------------------------------------------
- # ● 增减物品
- #--------------------------------------------------------------------------
- def command_126
- item = $data_items[@params[0]]
- last_num = $game_party.item_number(item)
- taroxd_gain_message_command_126
- show_gain_message($game_party.item_number(item) - last_num, item)
- end
- #--------------------------------------------------------------------------
- # ● 增减武器
- #--------------------------------------------------------------------------
- def command_127
- item = $data_weapons[@params[0]]
- last_num = $game_party.item_number_with_equip(item)
- taroxd_gain_message_command_127
- value = $game_party.item_number_with_equip(item) - last_num
- show_gain_message(value, item)
- end
- #--------------------------------------------------------------------------
- # ● 增减护甲
- #--------------------------------------------------------------------------
- def command_128
- item = $data_armors[@params[0]]
- last_num = $game_party.item_number_with_equip(item)
- taroxd_gain_message_command_128
- value = $game_party.item_number_with_equip(item) - last_num
- show_gain_message(value, item)
- end
- end
复制代码
Ring Menu- #==============================================================================
- # **
- #------------------------------------------------------------------------------
- # by Syvkal
- # Version 1.2
- # 03-04-12
- #------------------------------------------------------------------------------
- # * Original available at:
- # www.rpgmakervxace.net & forums.rpgmakerweb.com
- # Please do not redistribute this script
- #------------------------------------------------------------------------------
- # * Terms of Use
- # Available for use in commercial games provided that I get a free copy :P
- # Email me: syvkal@hotmail.co.uk
- # Please do not redistribute this script
- #==============================================================================
- #
- # - INTRODUCTION -
- #
- # This system implements a Plug 'N' Play Ring Menu
- # Movement based off XRXS, Dubealex & Hypershadow180's original XP Ring Menu,
- # which was devised through some simple, but clever trigonometry
- #
- #------------------------------------------------------------------------------
- #
- # - USAGE -
- #
- # Any additional scenes that are added to the menu require an icon
- # Place them in the pictures folder, they are advised to be 48x48 pixels
- #
- # The name of the icons must be of the form:
- # [Command Name] Icon
- #
- # For example 'Items Icon.png' or 'Equipment Icon.png'
- #
- # If you are unsure what it needs to be called, wait for the error message,
- # then call it the name of the file it can not find
- #
- #------------------------------------------------------------------------------
- #
- # - COMPATIBILITY -
- #
- # Additional scenes should be automatically added assuming thier creators
- # utilise the 'add_original_commands' feature in Window_MenuCommand
- #
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # This script redefines the following methods:
- # * create_status_window (Scene_Menu)
- # * on_formation_ok (Scene_Menu)
- # * on_formation_cancel (Scene_Menu)
- # * draw_character (Window_Base)
- #
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- #
- # This script Aliases the following methods:
- # * add_save_command (Window_MenuCommand)
- # * start (Scene_Menu)
- # * create_command_window (Scene_Menu)
- # * command_personal (Scene_Menu)
- # * command_formation (Scene_Menu)
- # * on_personal_cancel (Scene_Menu)
- #
- #==============================================================================
- #===================================================#
- # ** C O N F I G U R A T I O N S Y S T E M ** #
- #===================================================#
- #--------------------------------------------------------------------------
- # * Startup Frames
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Amount of frames for the Startup Animation
- #--------------------------------------------------------------------------
- STARTUP_FRAMES = 20
- #--------------------------------------------------------------------------
- # * Movement Frames
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Amount of frames for Movement Animation
- #--------------------------------------------------------------------------
- MOVING_FRAMES = 15
- #--------------------------------------------------------------------------
- # * Menu Ring Radius
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Radius of the Menu Ring
- #--------------------------------------------------------------------------
- RING_R = 75
- #--------------------------------------------------------------------------
- # * Show Disabled Options
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Set to false to exclude disabled options for the menu
- #--------------------------------------------------------------------------
- DISABLED_SHOW = false
- #--------------------------------------------------------------------------
- # * Disabled Icon
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # The icon displayed over disabled options
- # (only used when DISABLED_SHOW = true)
- #--------------------------------------------------------------------------
- ICON_DISABLE = Cache::picture('DisableIcon')
- #--------------------------------------------------------------------------
- # * Skip Single Actor Select
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Set to true to skip the actor selection if there's only one party member
- #--------------------------------------------------------------------------
- ACTOR_SKIP = true
- #--------------------------------------------------------------------------
- # * Load Command Vocab
- # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- # Text displayed for the loading option
- #--------------------------------------------------------------------------
- Vocab::Load = "Load"
- #===================================================#
- # ** E N D C O N F I G U R A T I O N ** #
- #===================================================#
- #==============================================================================
- # ** Ring_Menu Module
- #------------------------------------------------------------------------------
- # Module designed to rewrite methods defined in the desired Superclass.
- #==============================================================================
- module Ring_Menu
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(*args)
- super(*args)
- @cx = contents.width / 2; @cy = contents.height / 2
- self.opacity = 0
- @startup = STARTUP_FRAMES
- @icons = []
- @mode = :start
- @steps = @startup
- end
- #--------------------------------------------------------------------------
- # * Update Cursor
- #--------------------------------------------------------------------------
- def update_cursor
- end
- #--------------------------------------------------------------------------
- # * Determines if is moving
- #--------------------------------------------------------------------------
- def animation?
- return @mode != :wait
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Down
- #--------------------------------------------------------------------------
- def cursor_down(wrap)
- cursor_right(wrap)
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Up
- #--------------------------------------------------------------------------
- def cursor_up(wrap)
- cursor_left(wrap)
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Right
- #--------------------------------------------------------------------------
- def cursor_right(wrap)
- unless animation?
- select((index + 1) % item_max)
- @mode = :mover
- @steps = MOVING_FRAMES
- Sound.play_cursor
- end
- end
- #--------------------------------------------------------------------------
- # * Move Cursor Left
- #--------------------------------------------------------------------------
- def cursor_left(wrap)
- unless animation?
- select((index - 1 + item_max) % item_max)
- @mode = :movel
- @steps = MOVING_FRAMES
- Sound.play_cursor
- end
- end
- #--------------------------------------------------------------------------
- # * Frame Update
- #--------------------------------------------------------------------------
- def update
- super
- refresh if animation?
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- self.contents.clear
- case @mode
- when :start
- refresh_start
- when :wait
- refresh_wait
- when :mover
- refresh_move(1)
- when :movel
- refresh_move(0)
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh Start Period
- #--------------------------------------------------------------------------
- def refresh_start
- d1 = 2.0 * Math::PI / item_max
- d2 = 1.0 * Math::PI / @startup
- r = RING_R - 1.0 * RING_R * @steps / @startup
- for i in 0...item_max
- d = d1 * i + d2 * @steps
- x = @cx + ( r * Math.sin( d ) ).to_i
- y = @cy - ( r * Math.cos( d ) ).to_i
- draw_item(x, y, i)
- end
- @steps -= 1
- if @steps < 0
- @mode = :wait
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh Wait Period
- #--------------------------------------------------------------------------
- def refresh_wait
- d = 2.0 * Math::PI / item_max
- for i in 0...item_max
- j = i - index
- x = @cx + ( RING_R * Math.sin( d * j) ).to_i
- y = @cy - ( RING_R * Math.cos( d * j) ).to_i
- draw_item(x, y, i)
- end
- end
- #--------------------------------------------------------------------------
- # * Refresh Movement Period
- #--------------------------------------------------------------------------
- def refresh_move( mode )
- d1 = 2.0 * Math::PI / item_max
- d2 = d1 / MOVING_FRAMES
- d2 *= -1 unless mode != 0
- for i in 0...item_max
- j = i - index
- d = d1 * j + d2 * @steps
- x = @cx + ( RING_R * Math.sin( d ) ).to_i
- y = @cy - ( RING_R * Math.cos( d ) ).to_i
- draw_item(x, y, i)
- end
- @steps -= 1
- if @steps < 0
- @mode = :wait
- end
- end
- end
- #==============================================================================
- # ** Window_MenuCommand
- #------------------------------------------------------------------------------
- # Converted into a Ring Menu.
- #==============================================================================
- class Window_MenuCommand < Window_Command
- #--------------------------------------------------------------------------
- # * Includes The Ring_Menu Module
- #--------------------------------------------------------------------------
- include Ring_Menu
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias add_save_command_ring_menu_original add_save_command
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0)
- unless DISABLED_SHOW
- @list.delete_if {|i| !i[:enabled]}
- end
- for i in 0...item_max
- @icons.push(Cache::picture(command_name(i) + ' Icon'))
- end
- if @@last_command_symbol != nil
- index = @list.index(@@last_command_symbol)
- @mode = :wait
- end
- select_last
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- super
- rect = Rect.new(0, 196, self.contents.width, line_height)
- draw_text(rect, command_name(index), 1)
- end
- #--------------------------------------------------------------------------
- # * Get Window Width
- #--------------------------------------------------------------------------
- def window_width
- return 544
- end
- #--------------------------------------------------------------------------
- # * Get Window Height
- #--------------------------------------------------------------------------
- def window_height
- return 416
- end
- #--------------------------------------------------------------------------
- # * Add Load to Command List
- #--------------------------------------------------------------------------
- def add_save_command
- add_save_command_ring_menu_original
- add_command(Vocab::Load, :load)
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # i : item number
- #--------------------------------------------------------------------------
- def draw_item(x, y, i)
- rect = Rect.new(0, 0, @icons[i].width, @icons[i].height)
- if i == index
- self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect )
- unless command_enabled?(index)
- self.contents.blt(x - rect.width/2, y - rect.height/2, ICON_DISABLE, rect )
- end
- else
- self.contents.blt(x - rect.width/2, y - rect.height/2, @icons[i], rect, 128 )
- end
- end
- end
- #==============================================================================
- # ** Window_RingStatus
- #------------------------------------------------------------------------------
- # Ring Menu for selection of Party Members
- #==============================================================================
- class Window_RingStatus < Window_Selectable
- #--------------------------------------------------------------------------
- # * Includes The Ring_Menu Module
- #--------------------------------------------------------------------------
- include Ring_Menu
- #--------------------------------------------------------------------------
- # * Public Instance Variables
- #--------------------------------------------------------------------------
- attr_accessor :pending_index # Pending position (for formation)
- attr_accessor :pending # Pending
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize
- super(0, 0, 544, 416)
- self.hide
- @mode = :wait
- @pending_index = -1
- @pending = false
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- super
- rect = Rect.new(0, 196, self.contents.width, line_height)
- draw_text(rect, $game_party.members[index].name, 1)
- end
- #--------------------------------------------------------------------------
- # * Get Number of Items
- #--------------------------------------------------------------------------
- def item_max
- $game_party.members.size
- end
- #--------------------------------------------------------------------------
- # * Refresh Movement Period
- #--------------------------------------------------------------------------
- def refresh_move( mode )
- unless pending_index >= 0
- super
- else
- d = 2.0 * Math::PI / item_max
- for i in 0...item_max
- j = i - pending_index
- x = @cx + ( RING_R * Math.sin( d * j) ).to_i
- y = @cy - ( RING_R * Math.cos( d * j) ).to_i
- draw_item(x, y, i)
- end
- @mode = :wait
- end
- end
- #--------------------------------------------------------------------------
- # * Draw Item
- # x : draw spot x-coordinate
- # y : draw spot y-coordinate
- # index : item number
- #--------------------------------------------------------------------------
- def draw_item(x, y, i)
- if i == index && !(@pending && @pending_index < 0)
- draw_character($game_party.members[i].character_name,
- $game_party.members[i].character_index , x, y, true, true)
- else
- draw_character($game_party.members[i].character_name,
- $game_party.members[i].character_index , x, y, false, true)
- end
- end
- #--------------------------------------------------------------------------
- # * Processing When OK Button Is Pressed
- #--------------------------------------------------------------------------
- def process_ok
- super
- $game_party.menu_actor = $game_party.members[index] unless pending
- end
- #--------------------------------------------------------------------------
- # * Restore Previous Selection Position
- #--------------------------------------------------------------------------
- def select_last
- select($game_party.members.index($game_party.menu_actor) || 0)
- refresh
- end
- end
- #==============================================================================
- # ** Scene_Menu
- #==============================================================================
- class Scene_Menu < Scene_MenuBase
- #--------------------------------------------------------------------------
- # * Alias Listings
- #--------------------------------------------------------------------------
- alias start_ring_original start
- alias create_command_window_ring_menu_original create_command_window
- alias command_personal_ring_original command_personal
- alias command_formation_ring_original command_formation
- alias on_personal_cancel_ring_original on_personal_cancel
- #--------------------------------------------------------------------------
- # * Start Processing
- #--------------------------------------------------------------------------
- def start
- start_ring_original
- create_location_window
- end
- #--------------------------------------------------------------------------
- # * Create Location Window
- #--------------------------------------------------------------------------
- def create_location_window
- @location_window = Window_location.new(0, 0)
- end
- #--------------------------------------------------------------------------
- # * Create Command Window
- #--------------------------------------------------------------------------
- def create_command_window
- create_command_window_ring_menu_original
- @command_window.set_handler(:load, method(:command_load))
- end
- #--------------------------------------------------------------------------
- # * Create Status Window
- #--------------------------------------------------------------------------
- def create_status_window
- @status_window = Window_RingStatus.new
- end
- #--------------------------------------------------------------------------
- # * [Skill], [Equipment] and [Status] Commands
- #--------------------------------------------------------------------------
- def command_personal
- if $game_party.members.size < 2 && ACTOR_SKIP
- on_personal_ok
- else
- @command_window.hide
- @status_window.show
- command_personal_ring_original
- end
- end
- #--------------------------------------------------------------------------
- # * [Formation] Command
- #--------------------------------------------------------------------------
- def command_formation
- @status_window.pending = true
- @command_window.hide
- command_formation_ring_original
- @status_window.index = 0
- @status_window.refresh
- @status_window.show
- end
- #--------------------------------------------------------------------------
- # * [Load] Command
- #--------------------------------------------------------------------------
- def command_load
- SceneManager.call(Scene_Load)
- end
- #--------------------------------------------------------------------------
- # * [Cancel] Personal Command
- #--------------------------------------------------------------------------
- def on_personal_cancel
- @status_window.hide
- on_personal_cancel_ring_original
- @status_window.deactivate
- @command_window.show
- end
- #--------------------------------------------------------------------------
- # * Formation [OK]
- #--------------------------------------------------------------------------
- def on_formation_ok
- if @status_window.pending_index >= 0
- $game_party.swap_order(@status_window.index,
- @status_window.pending_index)
- @status_window.index = @status_window.pending_index
- @status_window.pending_index = -1
- else
- @status_window.pending_index = @status_window.index
- end
- @status_window.refresh
- @status_window.activate
- end
- #--------------------------------------------------------------------------
- # * Formation [Cancel]
- #--------------------------------------------------------------------------
- def on_formation_cancel
- if @status_window.pending_index >= 0
- @status_window.index = @status_window.pending_index
- @status_window.pending_index = -1
- @status_window.activate
- @status_window.refresh
- else
- @status_window.pending = false
- @status_window.hide
- @status_window.select_last
- @status_window.deactivate
- @command_window.show
- @command_window.activate
- end
- end
- end
- #==============================================================================
- # ** Window_Base
- #------------------------------------------------------------------------------
- # Edited to allow disabled character icons and y centring
- #==============================================================================
- class Window_Base < Window
- #--------------------------------------------------------------------------
- # * Draw Character Graphic
- #--------------------------------------------------------------------------
- def draw_character(character_name, character_index, x, y, enabled = true, centred = false)
- return if character_name == nil
- bitmap = Cache.character(character_name)
- sign = character_name[/^[\!\$]./]
- if sign && sign.include?('$')
- cw = bitmap.width / 3
- ch = bitmap.height / 4
- else
- cw = bitmap.width / 12
- ch = bitmap.height / 8
- end
- n = character_index
- src_rect = Rect.new((n%4*3+1)*cw, (n/4*4)*ch, cw, ch)
- self.contents.blt(x - cw / 2, centred ? y - ch/2 : y - ch, bitmap, src_rect,
- enabled ? 255 : 128)
- end
- end
- #==============================================================================
- # ** Window_Location
- #------------------------------------------------------------------------------
- # This class shows the current map name.
- #==============================================================================
- class Window_location < Window_Base
- #--------------------------------------------------------------------------
- # * Object Initialization
- #--------------------------------------------------------------------------
- def initialize(x, y)
- super(x, y, 160, (line_height*2) + 32)
- refresh
- end
- #--------------------------------------------------------------------------
- # * Refresh
- #--------------------------------------------------------------------------
- def refresh
- contents.clear
- @map = load_data(sprintf("Data/Map%03d.rvdata2", $game_map.map_id))
- change_color(system_color)
- draw_text(4, 0, 128, line_height, "所在地 :")
- change_color(normal_color)
- draw_text(0, line_height, 128, line_height, @map.display_name, 1)
- end
- end
复制代码
深水游泳池- =begin
- ===============================================================================
- 深水游泳池 By喵呜喵5
- ===============================================================================
- 【说明】
- 通过本脚本可以定义流体属性图块遮挡玩家行走图的大小及被遮挡部分的透明度
- =end
- module M5Pool
- #==============================================================================
- # 设定部分
- #==============================================================================
- HEI = 20
- #这里设置遮挡部分的大小
- OPA = 20
- #这里设置被遮挡部分的透明度
- #==============================================================================
- # 设定结束
- #==============================================================================
- end
- #==============================================================================
- # 脚本部分
- #==============================================================================
- class Game_CharacterBase
- attr_reader :bush_opacity
- def update_bush_depth
- if normal_priority? && !object_character? && bush? && !jumping?
- if !moving?
- @bush_depth = M5Pool::HEI
- @bush_opacity = M5Pool::OPA
- end
- else
- @bush_depth = 0
- end
- end
- end
- class Sprite_Character < Sprite_Base
- alias m5_update_other update_other
- def update_other
- m5_update_other
- self.bush_opacity = @character.bush_opacity if @character.bush_opacity
- end
- end
复制代码
装备变更行走图- =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
复制代码
|
|