#装备附加HP SP #使用方法 给装备名后用“,”追加数值 #例如: 铜剑,500,200 那个这个武器会增加500点HP和200点SP #顺序不可改变 如果只需要加 HP 不需要再追加 SP 例如 铜剑,500 只会增加500HP #如果只需要增加SP 那么HP留0即可 例如 铜剑,0, 200 只增加200点SP module RPG class Weapon def name return @name.split(/,/)[0] end def hp return @name.split(/,/)[1] == nil ? 0 : @name.split(/,/)[1].to_i end def sp return @name.split(/,/)[2] == nil ? 0 : @name.split(/,/)[2].to_i end end class Armor def name return @name.split(/,/)[0] end def hp return @name.split(/,/)[1] == nil ? 0 : @name.split(/,/)[1].to_i end def sp return @name.split(/,/)[2] == nil ? 0 : @name.split(/,/)[2].to_i end end end class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 获取基本 MaxHP #-------------------------------------------------------------------------- def base_maxhp n = $data_actors[@actor_id].parameters[0, @level] n += $data_weapons[@weapon_id].hp if $data_weapons[@weapon_id] != nil n += $data_armors[@armor1_id].hp if $data_armors[@armor1_id] != nil n += $data_armors[@armor2_id].hp if $data_armors[@armor2_id] != nil n += $data_armors[@armor3_id].hp if $data_armors[@armor3_id] != nil n += $data_armors[@armor4_id].hp if $data_armors[@armor4_id] != nil return n end #-------------------------------------------------------------------------- # ● 获取基本 MaxSP #-------------------------------------------------------------------------- def base_maxsp n = $data_actors[@actor_id].parameters[1, @level] n += $data_weapons[@weapon_id].sp if $data_weapons[@weapon_id] != nil n += $data_armors[@armor1_id].sp if $data_armors[@armor1_id] != nil n += $data_armors[@armor2_id].sp if $data_armors[@armor2_id] != nil n += $data_armors[@armor3_id].sp if $data_armors[@armor3_id] != nil n += $data_armors[@armor4_id].sp if $data_armors[@armor4_id] != nil return n end alias equip_hp_sp_old_dl equip def equip(equip_type, id) equip_hp_sp_old_dl(equip_type, id) @hp = maxhp if @hp > maxhp @sp = maxsp if @sp > maxsp end end
#============================================================================== # ■ System #------------------------------------------------------------------------------ # 我的系统。 #============================================================================== module System #============================================================================ # ■ Window_Help #---------------------------------------------------------------------------- # 特技及物品的说明、角色的状态显示的窗口。 #============================================================================ class Window_Help < Window_Base #------------------------------------------------------------------------ # ● 初始化对像 #------------------------------------------------------------------------ def initialize super(0, 0, 640, 64) self.windowskin = nil self.visible = false self.z = 1500 end #------------------------------------------------------------------------ # ● 设置文本 # text : 窗口显示的字符串 # align : 对齐方式 (0..左对齐、1..中间对齐、2..右对齐) #------------------------------------------------------------------------ def set_text(text, align = 0) # 如果文本和对齐方式的至少一方与上次的不同 if text != @text or align != @align # 属于文字的情况下 if text.is_a?(String) # 再描绘文本 self.contents = Bitmap.new(self.width - 32, self.height - 32) if self.contents.nil? self.contents.clear self.contents.font.color = normal_color self.contents.draw_text(4, 0, self.width - 40, 32, text, align) self.visible = true @text = text @align = align @actor = nil return end end Picture.dispose(@back) Picture.dispose(@edge) # 没有资料的情况下返回 return if text.nil? # 描绘资料 case text when RPG::Weapon set_equip_text(text) when RPG::Armor set_equip_text(text) when RPG::Item set_item_text(text) when RPG::Skill set_skill_text(text) end end #------------------------------------------------------------------------ # ● 更新帮助窗口 #------------------------------------------------------------------------ def non_auto_update(data) @data = data case @data when RPG::Item set_item_text(@data) when RPG::Weapon set_equip_text(@data) when RPG::Armor set_equip_text(@data) when RPG::Skill set_skill_text(@data) end end #------------------------------------------------------------------------ # ● 获得内容的宽 #------------------------------------------------------------------------ def get_width(str) return self.contents.text_size(str.to_s).width end #------------------------------------------------------------------------ # ● 描绘装备资料 #------------------------------------------------------------------------ def set_equip_text(equip) self.contents = Bitmap.new(320, 380) self.contents.clear self.contents.font.name = ["黑体","方正像素16","宋体"] self.contents.font.color = normal_color Picture.dispose(@back) Picture.dispose(@edge) x = y = 0 # 图标描绘 bitmap = RPG::Cache.new("Graphics/Goods/#{equip.icon_name}") #<----待设置 self.contents.blt(0, 0, bitmap, bitmap.rect) # 名字描绘 self.contents.font.color = Color.new(255, 255, 128, 255) self.contents.font.size = 20 self.contents.draw_text(120, 0, get_width(equip.name), 20, equip.name) # 说明描绘 x = 0 y += 1 description = equip.description.clone while ((text = description.slice!(/./m)) != nil) self.contents.font.color = normal_color self.contents.font.size = 15 # 描绘文字 self.contents.draw_text(x + 120, y * 15 + 5, 15, 15, text) # x 为要描绘文字的加法运算 x += self.contents.text_size(text).width if x == 13 * 15 x = 0 y += 1 end end # 装备条件 x = 0 y += 1 text = "【装备条件】等级#{equip.level}" self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) # 装备角色 case equip when RPG::Weapon x = 0 y += 1 text = "【装备角色】" for i in 0...equip.element_set.size if equip.element_set[i] > 10 and equip.element_set[i] < 23 text += $data_system.elements[equip.element_set[i]] end end self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) when RPG::Armor x = 0 y += 1 text = "【装备角色】男" #<---------------------待设置 self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) end # 等级五行 x = 0 y += 1 text = "等级 #{equip.level} 五行 #{equip.f_element}" self.contents.font.color = Color.new(248,252,0) self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) case equip # 命中伤害 when RPG::Weapon x = 0 y += 1 text = " 伤害 +#{equip.atk}" self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) # 敏捷防御 when RPG::Armor #<---------------------待设置 # 帽子 if equip.guard_element_set.include?(6) # 魔法 +10 防御 +10 txt = "魔法 +#{equip.mp} " unless equip.sp.zero? # 项链 elsif equip.guard_element_set.include?(7) # 灵力 +10 txt = "灵力 +#{equip.int_plus} " unless equip.int_plus.zero? # 衣服 elsif equip.guard_element_set.include?(8) # 体质 +10 防御 +10 txt = "体质 +#{equip.mdef} " unless equip.mdef.zero? # 腰带 elsif equip.guard_element_set.include?(9) # 气血 +10 防御 +10 txt = "气血 +#{equip.hp} " unless equip.hp.zero? # 鞋子 elsif equip.guard_element_set.include?(10)# 敏捷 +10 防御 +10 txt = "速度 +#{equip.agi_plus} " unless equip.agi_plus.zero? end x = 0 y += 1 txt = txt.to_s + "防御 +#{equip.pdef}" unless equip.pdef.zero? self.contents.draw_text(120, y * 15 + 5, get_width(txt), 15, txt) end # 魔法防御描绘 unless equip.mdef.zero? or equip.guard_element_set.include?(8) x = 0 y += 1 text = "体质 +" + equip.mdef.to_s self.contents.font.color = Color.new(0,255,0) self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) end # 魔力描绘 unless equip.int_plus.zero? or equip.guard_element_set.include?(7) x = 0 y += 1 text = "魔力 +" + equip.int_plus.to_s self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) end # 力量描绘 unless equip.str_plus.zero? x = 0 y += 1 text = "力量 +" + equip.str_plus.to_s self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) end # 灵巧描绘 unless equip.dex_plus.zero? x = 0 y += 1 text = "耐力 +"+ equip.dex_plus.to_s self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) end # 速度描绘 unless equip.agi_plus.zero? or equip.guard_element_set.include?(10) x = 0 y += 1 text = "速度 +"+ equip.agi_plus.to_s self.contents.draw_text(120, y * 15 + 5, get_width(text), 15, text) end # 特技 # 特效 # 设置窗口大小 self.width = 347 self.height = (y + 1) * 15 + 37 @back,@edge = System.draw_skin(self.x+5, self.y+10, self.z, self.width-10, self.height-20, normal_color, Color.new(17,17,17,180)) end #-------------------------------------------------------------------------- # ● 设置可见标记 #-------------------------------------------------------------------------- def visibles=(value) x,y = Mouse.get_mouse_pos self.x,self.y = x - self.width / 2,y + 20 self.x = 0 if self.x < 0 self.y = 0 if self.y < 0 if self.y + self.height > 470 self.y = y - 20 - self.height end if self.x + self.width > 640 self.x = 640 - self.width end if self.y + self.height > 480 self.y = 480 - self.height end self.visible = value if Picture.exist?(@back) @back.visible = @edge.visible = self.visible @back.x,@back.y = self.x + 6,self.y + 11 @edge.x,@edge.y = self.x + 5,self.y + 10 end end #-------------------------------------------------------------------------- # ● 释放 #-------------------------------------------------------------------------- def dispose super Picture.dispose(@back) Picture.dispose(@edge) end ############################################# #-------------------------------------------------------------------------- # ● 物品帮助窗口 #-------------------------------------------------------------------------- def set_item_text(item) # 取得描述 description = item.description.clone # 取得属性、附加状态、解除状态之副本 element_set = item.element_set.clone plus_state_set = item.plus_state_set.clone minus_state_set = item.minus_state_set.clone # 初始化数据设定 x = 0 y = 0 h = 0 name_size = 18 # 名字文字大小 size = 14 # 描述文字大小 word = 12 # 每行的描述文字数 move = 120 # 全体描述偏移幅度 # 基本文字设定(1) phrase = {} phrase["scope"] = "范围:" phrase["price"] = "价格:" phrase["recover_hp_rate"] = "HP 回复率:" phrase["recover_hp"] = "HP 回复量:" phrase["recover_sp_rate"] = "SP 回复率:" phrase["recover_sp"] = "SP 回复量:" phrase["elements"] = "属性:" phrase["plus"] = "附加" phrase["minus"] = "解除" phrase["states"] = "状态" # 基本文字设定(2) scope ={} scope[0] = "特殊物品" scope[1] = "特殊物品" scope[2] = "敌单体" scope[3] = "敌全体" scope[4] = "己方单体" scope[5] = "己方全体" scope[6] = "己方昏死单体" scope[7] = "己方昏死全体" scope[8] = "使用者" # 基本文字设定(3) parameter_type = {} parameter_type[1] = "MaxHP" parameter_type[2] = "MaxSP" parameter_type[3] = $data_system.words.str parameter_type[4] = $data_system.words.dex parameter_type[5] = $data_system.words.agi parameter_type[6] = $data_system.words.int ##################################################################### # 依显示内容确定自身高 h = (description.size / 3 / word) h += 1 if (description.size / 3 % word)> 0 now_h = h h += 3 # 空行,效果范围,价格 h += 1 unless item.recover_hp_rate.zero? h += 1 unless item.recover_hp.zero? h += 1 unless item.recover_sp_rate.zero? h += 1 unless item.recover_sp.zero? h += 1 unless item.parameter_type.zero? h += 1 unless element_set[0].nil? h += 1 unless element_set[4].nil? h += (1 + plus_state_set.size) unless plus_state_set.empty? h += (1 + minus_state_set.size) unless minus_state_set.empty? # 图片显示高度 h = 6 + now_h if (h - now_h) < 6 # 换算高度 self.height = h * size + name_size + 32 ##################################################################### # 生成背景 self.contents = Bitmap.new(self.width =347, self.height - 32) self.contents.clear @back,@edge = System.draw_skin(self.x+5, self.y+10, self.z, self.width-10, self.height-20, normal_color, Color.new(17,17,17,180)) # 名字描绘 text = item.name # 当没有资料的时候 if text.nil? or $help_visible == false self.visible = false return else self.visible = true end self.contents.font.color = Color.new(255, 255, 128, 255) self.contents.font.size = 20 self.contents.draw_text(x + move, 0, text.size * 7, name_size, text, 0) # 说明描绘 x = 0 y += 1 while ((text = description.slice!(/./m)) != nil) self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x * size + move, y * size + 5, size, size, text, 0) x += 1 if x == word x = 0 y += 1 end end # 图标描绘 bitmap = RPG::Cache.new("Graphics/Goods/#{item.icon_name}") unless item.icon_name.nil? self.contents.blt(0, 0, bitmap, bitmap.rect) end #-------------------------------------------------------------------------- # ● 技能帮助窗口 #-------------------------------------------------------------------------- def set_skill_text(skill, icon = false) # 取得描述 description = skill.description.clone # 取得属性、附加状态、解除状态之副本 element_set = skill.element_set.clone plus_state_set = skill.plus_state_set.clone minus_state_set = skill.minus_state_set.clone # 初始化设定 x = 0 y = 0 h = 0 name_size = 18 # 名字文字大小 size = 14 # 描述文字大小 word = 12 # 每行的描述文字数 move = 80 # 全体描述偏移幅度 icon_move = element_set.include?(25)? 45: 0 word = element_set.include?(25)? 10: 12 # 基本文字设定(1) phrase = {} phrase["scope"] = "范围:" phrase["power"] = "威力:" phrase["cost_sp"] = "消耗SP:" phrase["hit_rate"] = "命中率:" phrase["elements"] = "攻击属性" phrase["plus"] = "附加" phrase["minus"] = "解除" phrase["states"] = "状态" # 基本文字设定(2) scope = {} scope[0] = "特殊技能" scope[1] = "敌单体" scope[2] = "敌全体" scope[3] = "我方单体" scope[4] = "我方全体" scope[5] = "我方昏死(单体)" scope[6] = "我方昏死(全体)" scope[7] = "自身" ##################################################################### #由描叙确定高 h = description.size / 3 / word h += 1 if (description.size % 3 / word) > 0 h += 4 # 空行,效果范围,消费SP,命中率 unless element_set.include?(25) h += 1 unless skill.power.zero? h += 1 unless element_set.empty? h += 1 unless element_set[4].nil? h += plus_state_set.size h += minus_state_set.size end # 换算高度 self.height = h * size + name_size + 32 ##################################################################### self.contents = Bitmap.new(self.width - 32, self.height - 32) self.contents.clear # 名字描绘 text = skill.name # 当没有资料的时候 if text.nil? or $help_visible == false self.visible = false return else self.visible = true end self.contents.font.color = Color.new(255, 255, 128, 255) self.contents.font.size = name_size self.contents.draw_text(icon_move, 0, text.size * 7, name_size, text, 0) # 说明描述 x = 0 y += element_set.include?(25)? 1.5 : 1 text = description while ((text = description.slice!(/./m)) != nil) self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x * size + icon_move, y * size + 5, size, size, text, 0) x += 1 if x == word # 每行10个字 x = 0 y += 1 end end # 技能包含25号属性的情况下 if element_set.include?(25) # 图标描绘 bitmap = RPG::Cache.icon(skill.icon_name) unless skill.icon_name.nil? self.contents.blt(0, 0, bitmap, bitmap.rect) self.height = y * size + 5 + name_size + 32 return end # 攻击范围 text = phrase["scope"] + scope[skill.scope] x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) # 威力描述 unless skill.power.zero? power = skill.power > 0 ? skill.power : -1 * skill.power text = phrase["power"] + power.to_s x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) end # 消耗SP描述 text = phrase["cost_sp"] + skill.sp_cost.to_s x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) # 命中率描述 text = phrase["hit_rate"] + skill.hit.to_s + "%" x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) # 攻击属性 if element_set.size > 0 text = phrase["elements"] for i in 0...element_set.size if i < 4 text += $data_system.elements[element_set[i]] else break end end x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) end if element_set.size >= 5 text = "" for i in 4...element_set.size text += $data_system.elements[element_set[i]] end x = (phrase["elements"].size) * 3 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) end # 状态附加 unless plus_state_set.empty? text = phrase["plus"] x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) plus_state_set.each do |plus_state| y += 1 text = $data_states[plus_state].name self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) end end # 状态解除 unless minus_state_set.empty? text = phrase["minus"] x = 0 y += 1 self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) minus_state_set.each do |minus_state| y += 1 text = $data_states[minus_state].name self.contents.font.color = normal_color self.contents.font.size = size self.contents.draw_text(x, y * size + 5, text.size * 6, size, text, 0) end end end #-------------------------------------------------------------------------- # ● 设置角色 # actor : 要显示状态之角色 #-------------------------------------------------------------------------- def set_actor(actor) self.contents = Bitmap.new(self.width - 32, self.height - 32) if self.contents.nil? if actor != @actor self.contents.clear draw_actor_name(actor, 4, 0) draw_actor_state(actor, 140, 0) draw_actor_hp(actor, 284, 0) draw_actor_sp(actor, 460, 0) @actor = actor @text = nil self.visible = true end end #-------------------------------------------------------------------------- # ● 设置敌人 # enemy : 要显示名字和状态的敌人 #-------------------------------------------------------------------------- def set_enemy(enemy) self.contents = Bitmap.new(self.width - 32, self.height - 32) if self.contents.nil? text = enemy.name.sub(/\\[Ff]\[([0-9]+)\]/) {""} state_text = make_battler_state_text(enemy, 112, false) if state_text != "" text += " " + state_text end set_text(text, 1) self.visible = true end =begin #-------------------------------------------------------------------------- # ● 校正帮助窗口位置 #-------------------------------------------------------------------------- def set_pos(x, y, width, oy, index, column_max) #光标坐标 cursor_width = width / column_max - 32 xx = index % column_max * (cursor_width + 32) yy = index / column_max * 32 - oy self.x = xx + x + 150 self.y = yy + y + 30 if self.x + self.width > 640 self.x = 640 - self.width end if self.y + self.height > 480 self.y = 480 - self.height end end =end #-------------------------------------------------------------------------- # ● 校正帮助窗口位置 #-------------------------------------------------------------------------- def set_pos2(x, y) #光标坐标 self.x = x self.y = y if self.x + self.width > 640 self.x = 640 - self.width end if self.y + self.height > 480 self.y = 480 - self.height end end end end
1.jpg (10.6 KB, 下载次数: 13)
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |