赞 | 0 |
VIP | 10 |
好人卡 | 3 |
积分 | 1 |
经验 | 3584 |
最后登录 | 2015-10-25 |
在线时间 | 134 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 50
- 在线时间
- 134 小时
- 注册时间
- 2009-3-29
- 帖子
- 470
|
话说我已经有点获得不难烦了,我都受够了,看来看去都不明白,真够烦的了。
#==============================================================================
# 读取rmvx备注栏 by 沉影不器
# -----------------------------------------------------------------------------
# 使用方法(例):
# 在vx数据库比如1号物品的备注栏里写: 耐久度 = 10
# 读取时使用: p $data_items[1].read_note('耐久度')
# 几点注意:
# ① 支持汉字,英文忽略大小写
# ② 等号右边遵循ruby语法格式,例如:
# test1 = 1 #=> 1
# test2 = "a" #=> "a"
# test3 = true #=> true
# test4 = [1,2,3] #=> [1,2,3]
# test5 = {"orz"=>1} #=> {"orz"=>1}
# ③ 等号忽略空格,以下均正确:
# test = nil; test= nil; test =nil; test=nil
我真不知道他到底在说什么...
求解:- #==============================================================================
- # 读取rmvx备注栏 by 沉影不器
- # -----------------------------------------------------------------------------
- # 使用方法(例):
- # 在vx数据库比如1号物品的备注栏里写: 耐久度 = 10
- # 读取时使用: p $data_items[1].read_note('耐久度')
- # 几点注意:
- # ① 支持汉字,英文忽略大小写
- # ② 等号右边遵循ruby语法格式,例如:
- # test1 = 1 #=> 1
- # test2 = "a" #=> "a"
- # test3 = true #=> true
- # test4 = [1,2,3] #=> [1,2,3]
- # test5 = {"orz"=>1} #=> {"orz"=>1}
- # ③ 等号忽略空格,以下均正确:
- # test = nil; test= nil; test =nil; test=nil
- #==============================================================================
- module RPG
- #=============================================================================
- # ■ BaseItem
- #=============================================================================
- class BaseItem
- #-------------------------------------------------------------------------
- # ○ 读取rmvx备注栏指定字段
- # section : 字段名
- # mismatch : 未匹配时的返回值
- #-------------------------------------------------------------------------
- def read_note(section, mismatch = nil)
- self.note.each_line do |line|
- ## 不希望忽略大小写,则删掉下一行最后一个i
- eval("#{line}; return #{section}") if line =~ /^\s*#{section}\s*=/i
- end
- return mismatch
- end
- end
- ReadNote = BaseItem.new.method :read_note unless const_defined? :ReadNote
- #=============================================================================
- # ■ Enemy
- #=============================================================================
- class Enemy
- def read_note(section, mismatch = nil)
- ReadNote.call(section, mismatch)
- end
- end
- #=============================================================================
- # ■ State
- #=============================================================================
- class State
- def read_note(section, mismatch = nil)
- ReadNote.call(section, mismatch)
- end
- end
- end
复制代码- #==============================================================================
- # 装备耐久度 by 沉影不器
- #------------------------------------------------------------------------------
- # ① 自定义各个装备耐久度上限
- # ② 允许显示"无法破坏"的装备,允许忽略耐久度的装备(如:戒指等装饰类)
- # ③ 物理攻击消耗武器耐久度,被打消耗防具耐久度
- # 攻击越高,对方防具减耐久度的机率越大,防御越高,对方武器减耐久度的机率越大
- # ④ 装备耐久度降为 0 时装备即损坏,该装备能力消失,提供修复耐久度的功能
- # ⑤ 修复装备时耐久度上限也会下降,提供同时修复耐久度和上限的功能
- # ⑥ 装备卖出价格随耐久度打折
- #==============================================================================
- module Game_Equip
- ## 耐久度上限(指所有装备耐久度上限不可超过的值)
- MaxDur = 999
- # 忽略耐久度的防具类型(0:盾 1:头盔 2:衣服 3:装饰 4:武器)
- # 非忽略耐久度 且未定义耐久度,则被认为"无法破坏"
- NoDur = [3]
- # 降低耐久度的基本机率最小值和最大值(大于0小于1)
- Dur_BaseDec = [0.25, 0.75]
- # 修复装备时耐久度上限减少量
- MaxDur_Dec = 1
- # 装备耐久度剩余多少比值(0到1)时提示
- Show_If_Lower = 0.1
- # 损坏时装备显示颜色
- BrokenColor = Color.new(255,0,0)
- # 耐久度占总价格比值(0到1)
- Dur_Price = 0.7
- #--------------------------------------------------------------------------
- # ● 物品(装备)重生
- # item: 物品
- #--------------------------------------------------------------------------
- def self.reini(item)
- return if item.nil?
- result = item.clone
- case result
- when RPG::Weapon
- result.inidur
- result.base_id = item.id
- result.id = $data_weapons.size
- $data_weapons << result
- when RPG::Armor
- result.inidur
- result.base_id = result.id
- result.id = $data_armors.size
- $data_armors << result
- end
- return result
- end
- #--------------------------------------------------------------------------
- # ● 物品(装备)重生
- # item_id: 物品id
- # type: 类型
- #--------------------------------------------------------------------------
- def self.reini_id(item_id, type)
- ## 排除装备id为零的情况
- return 0 if item_id == 0
- case type
- when 0
- item = $base_weapons[item_id]
- when 1
- item = $base_armors[item_id]
- end
- return self.reini(item).id
- end
- end
- module RPG
- class BaseItem
- #------------------------------------------------------------------------
- # 是否被破坏
- #------------------------------------------------------------------------
- def broken?
- return false
- end
- end
- end
- module RPG
- class Weapon < BaseItem
- include Game_Equip
- #------------------------------------------------------------------------
- # 附加属性
- #------------------------------------------------------------------------
- attr_accessor :base_id
- attr_reader :maxdur
- attr_reader :dur
- attr_reader :indesctructible
- #------------------------------------------------------------------------
- # 是否无耐久度
- #------------------------------------------------------------------------
- def nodur
- return NoDur.include? 4
- end
- #------------------------------------------------------------------------
- # 是否被破坏
- #------------------------------------------------------------------------
- def broken?
- return false if dur.nil?
- return true if dur.zero?
- end
- #------------------------------------------------------------------------
- # 是否需修复
- #------------------------------------------------------------------------
- def need_repair?(hyper)
- return false if dur.nil?
- return false if hyper.nil?
- max = hyper ? read_note('dur').to_i : maxdur
- return true if max > dur
- return false
- end
- #------------------------------------------------------------------------
- # 耐久度初始化
- #------------------------------------------------------------------------
- def inidur
- d = read_note('dur').to_i
- if d.zero?
- @indesctructible = true
- else
- @indesctructible = false
- @maxdur = @dur = [d, MaxDur].min
- end
- end
- #------------------------------------------------------------------------
- # 耐久度损耗
- #------------------------------------------------------------------------
- def decdur(n = 1)
- return if @dur.nil?
- n = [n, maxdur].min
- @dur -= n unless nodur or indesctructible or dur < n
- end
- #------------------------------------------------------------------------
- # 耐久度修复
- #------------------------------------------------------------------------
- def repair
- return false if dur.nil?
- if dur < maxdur and maxdur > 0
- @maxdur -= MaxDur_Dec if @maxdur - @dur > MaxDur_Dec
- @dur = @maxdur
- return true
- else
- return false
- end
- end
- #------------------------------------------------------------------------
- # 耐久度全修复
- #------------------------------------------------------------------------
- def hyper_repair
- return false if dur.nil?
- max = read_note('dur').to_i
- if dur < max and max > 0
- @dur = @maxdur = max
- return true
- else
- return false
- end
- end
- #------------------------------------------------------------------------
- # 攻击力
- #------------------------------------------------------------------------
- def atk
- return @atk if dur.nil?
- return dur > 0 ? @atk : 0
- end
- #------------------------------------------------------------------------
- # 防御力
- #------------------------------------------------------------------------
- def def
- return @def if dur.nil?
- return dur > 0 ? @def : 0
- end
- #------------------------------------------------------------------------
- # 魔力
- #------------------------------------------------------------------------
- def spi
- return @spi if dur.nil?
- return dur > 0 ? @spi : 0
- end
- #------------------------------------------------------------------------
- # 敏捷
- #------------------------------------------------------------------------
- def agi
- return @agi if dur.nil?
- return dur > 0 ? @agi : 0
- end
- end
- end
- module RPG
- class Armor < BaseItem
- include Game_Equip
- #------------------------------------------------------------------------
- # 附加属性
- #------------------------------------------------------------------------
- attr_accessor :base_id
- attr_reader :maxdur
- attr_reader :dur
- attr_reader :indesctructible
- #------------------------------------------------------------------------
- # 是否无耐久度
- #------------------------------------------------------------------------
- def nodur
- return NoDur.include? kind
- end
- #------------------------------------------------------------------------
- # 是否被破坏
- #------------------------------------------------------------------------
- def broken?
- return false if dur.nil?
- return true if dur.zero?
- end
- #------------------------------------------------------------------------
- # 是否需修复
- #------------------------------------------------------------------------
- def need_repair?(hyper)
- return false if dur.nil?
- return false if hyper.nil?
- max = hyper ? read_note('dur').to_i : maxdur
- return true if max > dur
- return false
- end
- #------------------------------------------------------------------------
- # 耐久度初始化
- #------------------------------------------------------------------------
- def inidur
- d = read_note('dur').to_i
- if d.zero?
- @indesctructible = true
- else
- @indesctructible = false
- @maxdur = @dur = [d, MaxDur].min
- end
- end
- #------------------------------------------------------------------------
- # 耐久度损耗
- #------------------------------------------------------------------------
- def decdur(n = 1)
- return if @dur.nil?
- n = [n, maxdur].min
- @dur -= n unless nodur or indesctructible or dur < n
- end
- #------------------------------------------------------------------------
- # 耐久度修复
- #------------------------------------------------------------------------
- def repair
- return false if dur.nil?
- if dur < maxdur and maxdur > 0
- @maxdur -= MaxDur_Dec if @maxdur - @dur > MaxDur_Dec
- @dur = @maxdur
- return true
- else
- return false
- end
- end
- #------------------------------------------------------------------------
- # 耐久度全修复
- #------------------------------------------------------------------------
- def hyper_repair
- return false if dur.nil?
- max = read_note('dur').to_i
- if dur < max and max > 0
- @dur = @maxdur = max
- return true
- else
- return false
- end
- end
- #------------------------------------------------------------------------
- # 攻击力
- #------------------------------------------------------------------------
- def atk
- return @atk if dur.nil?
- return dur > 0 ? @atk : 0
- end
- #------------------------------------------------------------------------
- # 防御力
- #------------------------------------------------------------------------
- def def
- return @def if dur.nil?
- return dur > 0 ? @def : 0
- end
- #------------------------------------------------------------------------
- # 魔力
- #------------------------------------------------------------------------
- def spi
- return @spi if dur.nil?
- return dur > 0 ? @spi : 0
- end
- #------------------------------------------------------------------------
- # 敏捷
- #------------------------------------------------------------------------
- def agi
- return @agi if dur.nil?
- return dur > 0 ? @agi : 0
- end
- #------------------------------------------------------------------------
- # 闪避率
- #------------------------------------------------------------------------
- def eva
- return @eva if dur.nil?
- return dur > 0 ? @eva : 0
- end
- end
- end
- #==============================================================================
- # ■ Game_Battler
- #==============================================================================
- class Game_Battler
- #--------------------------------------------------------------------------
- # ● 判断是否防御
- #--------------------------------------------------------------------------
- def guarding?
- return @action.guard?
- end
- #--------------------------------------------------------------------------
- # ● 反映伤害
- # user : 特技以及物品的使用者
- # 调用前先设置 @hp_damage、@mp_damage、@absorbed。
- #--------------------------------------------------------------------------
- def execute_damage(user)
- if @hp_damage > 0 # 伤害为正数
- remove_states_shock # 受到攻击解除的状态
- end
- self.hp -= @hp_damage
- self.mp -= @mp_damage
- if @absorbed # 吸收的情况
- user.hp += @hp_damage
- user.mp += @mp_damage
- end
- end
- #--------------------------------------------------------------------------
- # ● 应用普通攻击效果
- # attacker : 攻击者
- #--------------------------------------------------------------------------
- def attack_effect(attacker)
- clear_action_results
- unless attack_effective?(attacker)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(attacker) # 判断命中
- @missed = true
- return
- end
- if rand(100) < calc_eva(attacker) # 判断回避
- @evaded = true
- return
- end
- make_attack_damage_value(attacker) # 计算伤害
- execute_damage(attacker) # 反映伤害
- if @hp_damage == 0 # 判断物理攻击无效
- return
- end
- ## 处理耐久度
- set_dur(attacker, self)
- apply_state_changes(attacker) # 状态变化
- end
- #--------------------------------------------------------------------------
- # ● 应用特技效果
- # user : 特技使用者
- # skill : 特技
- #--------------------------------------------------------------------------
- def skill_effect(user, skill)
- clear_action_results
- unless skill_effective?(user, skill)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(user, skill) # 判断命中
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, skill) # 判断回避
- @evaded = true
- return
- end
- make_obj_damage_value(user, skill) # 计算伤害
- make_obj_absorb_effect(user, skill) # 计算吸收效果
- execute_damage(user) # 反映伤害
- if skill.physical_attack and @hp_damage == 0 # 判断物理攻击无效
- return
- end
- ## 处理耐久度
- set_dur(user, self, skill)
- apply_state_changes(skill) # 状态变化
- end
- #--------------------------------------------------------------------------
- # ● 应用物品效果
- # user : 物品使用者
- # item : 物品
- #--------------------------------------------------------------------------
- def item_effect(user, item)
- clear_action_results
- unless item_effective?(user, item)
- @skipped = true
- return
- end
- if rand(100) >= calc_hit(user, item) # 判断命中
- @missed = true
- return
- end
- if rand(100) < calc_eva(user, item) # 判断回避
- @evaded = true
- return
- end
- hp_recovery = calc_hp_recovery(user, item) # 计算 HP 回复量
- mp_recovery = calc_mp_recovery(user, item) # 计算 MP 回复量
- make_obj_damage_value(user, item) # 计算伤害
- @hp_damage -= hp_recovery # 减去 HP 回复量
- @mp_damage -= mp_recovery # 减去 MP 回复量
- make_obj_absorb_effect(user, item) # 计算吸收效果
- execute_damage(user) # 反映伤害
- item_growth_effect(user, item) # 应用成长效果
- if item.physical_attack and @hp_damage == 0 # 判断物理攻击无效
- return
- end
- ## 处理耐久度
- set_dur(user, self, item)
- apply_state_changes(item) # 状态变化
- end
- #--------------------------------------------------------------------------
- # ● 处理耐久度
- #--------------------------------------------------------------------------
- def set_dur(attacker, defender, obj = nil)
- ## 补血时返回
- return if @hp_damage < 0
- atk_f = obj.nil? ? 1.0 : obj.atk_f / 100.0
- w = defender.def / 999.0 * atk_f
- a = attacker.atk / 999.0 * atk_f
- w = [[w, Game_Equip::Dur_BaseDec[0]].max, Game_Equip::Dur_BaseDec[1]].min
- a = [[a, Game_Equip::Dur_BaseDec[0]].max, Game_Equip::Dur_BaseDec[1]].min
- if attacker.actor? and 0.8 > rand
- weapons = attacker.weapons.compact
- return if weapons.empty?
- weapons[rand weapons.size].decdur
- end
- if defender.actor? and 0.8 > rand
- armors = defender.armors.compact
- return if armors.empty?
- armors[rand armors.size].decdur
- end
- end
- end
- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 设置
- # actor_id : 角色 ID
- #--------------------------------------------------------------------------
- def setup(actor_id)
- actor = $data_actors[actor_id]
- @actor_id = actor_id
- @name = actor.name
- @character_name = actor.character_name
- @character_index = actor.character_index
- @face_name = actor.face_name
- @face_index = actor.face_index
- @class_id = actor.class_id
- @weapon_id = actor.weapon_id
- @armor1_id = actor.armor1_id
- @armor2_id = actor.armor2_id
- @armor3_id = actor.armor3_id
- @armor4_id = actor.armor4_id
- @level = actor.initial_level
- @exp_list = Array.new(101)
- make_exp_list
- @exp = @exp_list[@level]
- @skills = []
- for i in self.class.learnings
- learn_skill(i.skill_id) if i.level <= @level
- end
- clear_extra_values
- recover_all
- ## 生成新装备id
- reset_equip_id
- end
- #--------------------------------------------------------------------------
- # ● 装备重设
- #--------------------------------------------------------------------------
- def reset_equip_id
- @weapon_id = Game_Equip.reini_id(@weapon_id, 0)
- @armor1_id = Game_Equip.reini_id(@armor1_id, two_hands_legal? ? 0 : 1)
- @armor2_id = Game_Equip.reini_id(@armor2_id, 1)
- @armor3_id = Game_Equip.reini_id(@armor3_id, 1)
- @armor4_id = Game_Equip.reini_id(@armor4_id, 1)
- end
- #--------------------------------------------------------------------------
- # ● 判断是否可以装备
- # item : 物品
- # base : 是否读取母版数据
- #--------------------------------------------------------------------------
- def equippable?(item, base = true)
- id = base ? item.base_id : item.id
- if item.is_a?(RPG::Weapon)
- return self.class.weapon_set.include?(id)
- elsif item.is_a?(RPG::Armor)
- return false if two_swords_style and item.kind == 0
- return self.class.armor_set.include?(id)
- end
- return false
- end
- end
- #==============================================================================
- # ■ Game_Party
- #==============================================================================
- class Game_Party < Game_Unit
- #--------------------------------------------------------------------------
- # ● 判断持有的物品
- # item : 物品
- # include_equip : 包括装备品
- #--------------------------------------------------------------------------
- def has_item_by_base_id?(item, include_equip = false)
- for i in items
- return true if i.base_id == item.id
- end
- if include_equip
- for actor in members
- for e in actor.equips
- return true if e.base_id == item.id
- end
- end
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 获得物品
- # item : 物品
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_reini(item, n, include_equip = false)
- if n < 0
- lose_item(item, -n, include_equip = false)
- else
- case item
- when RPG::Item
- number = item_number(item)
- @items[item.id] = [[number + n, 0].max, 99].min
- when RPG::Weapon
- for i in 0...n
- w = Game_Equip.reini(item)
- @weapons[w.id] = 1
- end
- when RPG::Armor
- for i in 0...n
- a = Game_Equip.reini(item)
- @armors[a.id] = 1
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 减少物品 (减少)
- # item : 物品
- # n : 个数
- # include_equip : 包括装备品
- #--------------------------------------------------------------------------
- def lose_reini(item, n, include_equip = false)
- number = item_number(item)
- case item
- when RPG::Item
- @items[item.id] = [[number - n, 0].max, 99].min
- when RPG::Weapon
- @weapons[item.id] = [[number - n, 0].max, 99].min
- when RPG::Armor
- @armors[item.id] = [[number - n, 0].max, 99].min
- end
- n -= number
- if include_equip and n > 0
- for actor in members
- while n > 0 and actor.equips.include?(item)
- actor.discard_equip(item)
- n -= 1
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 获得物品
- # item_id : 物品id
- # type : 类型(0物品, 1武器, 2防具)
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_reini_byid(item_id, type, n, include_equip = false)
- case type
- when 0
- item = $data_items[item_id]
- when 1
- item = $base_weapons[item_id]
- when 2
- item = $base_armors[item_id]
- end
- gain_reini(item, n, include_equip)
- end
- end
- #==============================================================================
- # ■ Game_Troop
- #==============================================================================
- class Game_Troop < Game_Unit
- #--------------------------------------------------------------------------
- # ● 敌人角色名称后的文字表
- #--------------------------------------------------------------------------
- LETTER_TABLE = [ 'A','B','C','D','E','F','G','H','I','J',
- 'K','L','M','N','O','P','Q','R','S','T',
- 'U','V','W','X','Y','Z']
- #--------------------------------------------------------------------------
- # ● 生成掉落物品队列
- #--------------------------------------------------------------------------
- def make_drop_items
- drop_items = []
- for enemy in dead_members
- for di in [enemy.drop_item1, enemy.drop_item2]
- next if di.kind == 0
- next if rand(di.denominator) != 0
- if di.kind == 1
- drop_items.push($data_items[di.item_id])
- elsif di.kind == 2
- drop_items.push($base_weapons[di.weapon_id])
- elsif di.kind == 3
- drop_items.push($base_armors[di.weapon_id])
- end
- end
- end
- return drop_items
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● 计算操作的值
- # operation : 操作 (0:增加 1:减少)
- # operand_type : 运算域类型 (0:常量 1:变量)
- # operand : 运算域 (数值为变量 ID)
- #--------------------------------------------------------------------------
- def operate_value(operation, operand_type, operand)
- if operand_type == 0
- value = operand
- else
- value = $game_variables[operand]
- end
- if operation == 1
- value = -value
- end
- return value
- end
- #--------------------------------------------------------------------------
- # ● 条件分歧
- #--------------------------------------------------------------------------
- def command_111
- result = false
- case @params[0]
- when 0 # 开关
- result = ($game_switches[@params[1]] == (@params[2] == 0))
- when 1 # 变量
- value1 = $game_variables[@params[1]]
- if @params[2] == 0
- value2 = @params[3]
- else
- value2 = $game_variables[@params[3]]
- end
- case @params[4]
- when 0 # 相等
- result = (value1 == value2)
- when 1 # 大于等于
- result = (value1 >= value2)
- when 2 # 小于等于
- result = (value1 <= value2)
- when 3 # 大于
- result = (value1 > value2)
- when 4 # 小于
- result = (value1 < value2)
- when 5 # 不等于
- result = (value1 != value2)
- end
- when 2 # 自我开关
- if @original_event_id > 0
- key = [@map_id, @original_event_id, @params[1]]
- if @params[2] == 0
- result = ($game_self_switches[key] == true)
- else
- result = ($game_self_switches[key] != true)
- end
- end
- when 3 # 计时器
- if $game_system.timer_working
- sec = $game_system.timer / Graphics.frame_rate
- if @params[2] == 0
- result = (sec >= @params[1])
- else
- result = (sec <= @params[1])
- end
- end
- when 4 # 角色
- actor = $game_actors[@params[1]]
- if actor != nil
- case @params[2]
- when 0 # 是同伴
- result = ($game_party.members.include?(actor))
- when 1 # 姓名
- result = (actor.name == @params[3])
- when 2 # 特技
- result = (actor.skill_learn?($data_skills[@params[3]]))
- when 3 # 武器
- ## 判断是否符合母版id
- actor.weapons.each do |weapon|
- if weapon.base_id == @params[3]
- result = true
- break
- end
- end
- when 4 # 防具
- ## 判断是否符合母版id
- actor.armors.each do |armor|
- if armor.base_id == @params[3]
- result = true
- break
- end
- end
- when 5 # 状态
- result = (actor.state?(@params[3]))
- end
- end
- when 5 # 敌方角色
- enemy = $game_troop.members[@params[1]]
- if enemy != nil
- case @params[2]
- when 0 # 出现
- result = (enemy.exist?)
- when 1 # 状态
- result = (enemy.state?(@params[3]))
- end
- end
- when 6 # 角色
- character = get_character(@params[1])
- if character != nil
- result = (character.direction == @params[2])
- end
- when 7 # 金钱
- if @params[2] == 0
- result = ($game_party.gold >= @params[1])
- else
- result = ($game_party.gold <= @params[1])
- end
- when 8 # 物品
- result = $game_party.has_item?($data_items[@params[1]])
- when 9 # 武器
- result = $game_party.has_item_by_base_id?($base_weapons[@params[1]], @params[2])
- when 10 # 防具
- result = $game_party.has_item_by_base_id?($base_armors[@params[1]], @params[2])
- when 11 # 按钮
- result = Input.press?(@params[1])
- when 12 # 脚本
- result = eval(@params[1])
- when 13 # 交通工具
- result = ($game_player.vehicle_type == @params[1])
- end
- @branch[@indent] = result # 将判断结果放置在缓存中
- if @branch[@indent] == true
- @branch.delete(@indent)
- return true
- end
- return command_skip
- end
-
-
- #--------------------------------------------------------------------------
- # ● 计算装备操作的值
- # operand_type : 运算域类型 (0:常量 1:变量)
- # operand : 运算域 (数值为变量 ID)
- #--------------------------------------------------------------------------
- def opera_equip_value(operation, operand_type, operand)
- if operand_type == 0
- value = operand
- else
- value = $game_variables[operand]
- end
- return value
- end
- #--------------------------------------------------------------------------
- # ● 增减武器
- #--------------------------------------------------------------------------
- def command_127
- value = operate_value(@params[1], @params[2], @params[3])
- if @params[1] == 0
- $game_party.gain_reini($base_weapons[@params[0]], value.abs, @params[4])
- else
- $game_party.lose_reini($base_weapons[@params[0]], value.abs, @params[4])
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 增减防具
- #--------------------------------------------------------------------------
- def command_128
- value = operate_value(@params[1], @params[2], @params[3])
- if @params[1] == 0
- $game_party.gain_reini($base_armors[@params[0]], value.abs, @params[4])
- else
- $game_party.lose_reini($base_armors[@params[0]], value.abs, @params[4])
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 更改装备
- #--------------------------------------------------------------------------
- def command_319
- actor = $game_actors[@params[0]]
- if actor != nil
- actor.change_equip_by_id(@params[1], @params[2])
- end
- return true
- end
- #--------------------------------------------------------------------------
- # ● 增减武器---------
- #--------------------------------------------------------------------------
- def get_weapon(id, n, *gift)
- $game_party.gain_reini($base_weapons[id], n, false)
- end
- #--------------------------------------------------------------------------
- # ● 增减防具---------
- #--------------------------------------------------------------------------
- def get_armor(id, n, *gift)
- $game_party.gain_reini($base_armors[id], n, false)
- end
- end
- #==============================================================================
- # ■ Window_Base
- #==============================================================================
- class Window_Base < Window
- def draw_item_name(item, x, y, enabled = true)
- if item != nil
- draw_icon(item.icon_index, x, y, enabled)
- self.contents.font.color = item.broken? ? Game_Equip::BrokenColor : normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(x + 24, y, 172, WLH, item.name)
- end
- end
- end
- #==============================================================================
- # ■ Window_ShopBuy
- #==============================================================================
- class Window_ShopBuy < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- for goods_item in @shop_goods
- case goods_item[0]
- when 0
- item = $data_items[goods_item[1]]
- when 1
- item = $base_weapons[goods_item[1]]
- when 2
- item = $base_armors[goods_item[1]]
- end
- if item != nil
- @data.push(item)
- end
- end
- @item_max = @data.size
- create_contents
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- #==============================================================================
- # ■ Window_ShopStatus
- #==============================================================================
- class Window_ShopStatus < Window_Base
- #--------------------------------------------------------------------------
- # ● 描绘角色现在装备的能力值变化
- # actor : 角色
- # x : 描画目标 X 坐标
- # y : 描画目标 Y 坐标
- #--------------------------------------------------------------------------
- def draw_actor_parameter_change(actor, x, y)
- return if @item.is_a?(RPG::Item)
- enabled = actor.equippable?(@item, false)
- self.contents.font.color = normal_color
- self.contents.font.color.alpha = enabled ? 255 : 128
- self.contents.draw_text(x, y, 200, WLH, actor.name)
- if @item.is_a?(RPG::Weapon)
- item1 = weaker_weapon(actor)
- elsif actor.two_swords_style and @item.kind == 0
- item1 = nil
- else
- item1 = actor.equips[1 + @item.kind]
- end
- if enabled
- if @item.is_a?(RPG::Weapon)
- atk1 = item1 == nil ? 0 : item1.atk
- atk2 = @item == nil ? 0 : @item.atk
- change = atk2 - atk1
- else
- def1 = item1 == nil ? 0 : item1.def
- def2 = @item == nil ? 0 : @item.def
- change = def2 - def1
- end
- self.contents.draw_text(x, y, 200, WLH, sprintf("%+d", change), 2)
- end
- draw_item_name(item1, x, y + WLH, enabled)
- end
- end
- #==============================================================================
- # ■ Window_ScrRepair
- #==============================================================================
- class Window_ScrRepair < Window_Item
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽
- # height : 窗口的高
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height, hyper_repair)
- super(x, y, width, height)
- @column_max = 1
- self.index = 0
- @hyper_repair = hyper_repair
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 列表中包含的物品
- # item : 物品
- #--------------------------------------------------------------------------
- def include?(item)
- return true if item == nil
- return true if item.is_a? RPG::Weapon and item.need_repair?(@hyper_repair)
- return true if item.is_a? RPG::Armor and item.need_repair?(@hyper_repair)
- return false
- end
- #--------------------------------------------------------------------------
- # ● 是否可以使用物品
- # item : 物品
- #--------------------------------------------------------------------------
- def enable?(item)
- return true
- end
- end
- #==============================================================================
- # ■ Window_DestRepair #equip add clear items
- #==============================================================================
- class Window_DestRepair < Window_Base
- #--------------------------------------------------------------------------
- # ● 定义实例变量
- #--------------------------------------------------------------------------
- attr_reader :equips
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽
- # height : 窗口的高
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- clear
- end
- #--------------------------------------------------------------------------
- # ● 添加物品
- #--------------------------------------------------------------------------
- def add(item)
- return if item.nil?
- $game_party.lose_item(item, 1)
- @equips << item
- @index += 1
- draw_item(item)
- end
- #--------------------------------------------------------------------------
- # ● 清除物品
- #--------------------------------------------------------------------------
- def clear
- @equips = []
- @index = 0
- self.contents.clear
- self.contents.font.color = system_color
- self.contents.draw_text(0,0,self.contents.width-16,WLH,"请放入需修复的装备:")
- end
- #--------------------------------------------------------------------------
- # ● 归还物品
- #--------------------------------------------------------------------------
- def revert
- $game_party.gain_item(@equip, 1)
- @equips.each{|i| $game_party.gain_item(i, 1)}
- clear
- end
- #--------------------------------------------------------------------------
- # ● 描绘项目
- #--------------------------------------------------------------------------
- def draw_item(item)
- rect = Rect.new(4,WLH*@index,self.contents.width-8, WLH)
- ##rect.y += WLH if @index >0
- if item != nil
- draw_item_name(item, rect.x, rect.y)
- self.contents.draw_text(rect, sprintf(":%2d", 1), 2)
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新帮助文本
- #--------------------------------------------------------------------------
- def update_help
- @help_window.set_text(item == nil ? "" : item.description)
- end
- end
- #==============================================================================
- # ■ Scene_File
- #==============================================================================
- class Scene_File < Scene_Base
- #--------------------------------------------------------------------------
- # ● 写入存档数据
- # file : 写入文件用对象 (已经打开)
- #--------------------------------------------------------------------------
- def write_save_data(file)
- characters = []
- for actor in $game_party.members
- characters.push([actor.character_name, actor.character_index])
- end
- $game_system.save_count += 1
- $game_system.version_id = $data_system.version_id
- @last_bgm = RPG::BGM::last
- @last_bgs = RPG::BGS::last
- Marshal.dump(characters, file)
- Marshal.dump(Graphics.frame_count, file)
- Marshal.dump(@last_bgm, file)
- Marshal.dump(@last_bgs, file)
- Marshal.dump($game_system, file)
- Marshal.dump($game_message, file)
- Marshal.dump($game_switches, file)
- Marshal.dump($game_variables, file)
- Marshal.dump($game_self_switches, file)
- Marshal.dump($game_actors, file)
- Marshal.dump($game_party, file)
- Marshal.dump($game_troop, file)
- Marshal.dump($game_map, file)
- Marshal.dump($game_player, file)
- Marshal.dump($data_weapons, file)
- Marshal.dump($data_armors, file)
- end
- #--------------------------------------------------------------------------
- # ● 读取存档数据
- # file : 读取文件用对象 (已经打开)
- #--------------------------------------------------------------------------
- def read_save_data(file)
- characters = Marshal.load(file)
- Graphics.frame_count = Marshal.load(file)
- @last_bgm = Marshal.load(file)
- @last_bgs = Marshal.load(file)
- $game_system = Marshal.load(file)
- $game_message = Marshal.load(file)
- $game_switches = Marshal.load(file)
- $game_variables = Marshal.load(file)
- $game_self_switches = Marshal.load(file)
- $game_actors = Marshal.load(file)
- $game_party = Marshal.load(file)
- $game_troop = Marshal.load(file)
- $game_map = Marshal.load(file)
- $game_player = Marshal.load(file)
- $data_weapons = Marshal.load(file)
- $data_armors = Marshal.load(file)
- if $game_system.version_id != $data_system.version_id
- $game_map.setup($game_map.map_id)
- $game_player.center($game_player.x, $game_player.y)
- end
- end
- end
- #==============================================================================
- # ■ Scene_Shop
- #==============================================================================
- class Scene_Shop < Scene_Base
- #--------------------------------------------------------------------------
- # ● 确定输入个数
- #--------------------------------------------------------------------------
- def decide_number_input
- Sound.play_shop
- @number_window.active = false
- @number_window.visible = false
- case @command_window.index
- when 0 # 购买
- $game_party.lose_gold(@number_window.number * @item.price)
- $game_party.gain_reini(@item, @number_window.number)
- @gold_window.refresh
- @buy_window.refresh
- @status_window.refresh
- @buy_window.active = true
- @buy_window.visible = true
- when 1 # 卖出
- price = @item.price * Game_Equip::Dur_Price * @item.dur / @item.maxdur
- $game_party.gain_gold(@number_window.number * (price.round / 2))
- $game_party.lose_reini(@item, @number_window.number)
- @gold_window.refresh
- @sell_window.refresh
- @status_window.refresh
- @sell_window.active = true
- @sell_window.visible = true
- @status_window.visible = false
- end
- end
- end
- #==============================================================================
- # ■ Scene_Title
- #==============================================================================
- class Scene_Title < Scene_Base
- #--------------------------------------------------------------------------
- # ● 载入数据库
- #--------------------------------------------------------------------------
- def load_database
- $data_actors = load_data("Data/Actors.rvdata")
- $data_classes = load_data("Data/Classes.rvdata")
- $data_skills = load_data("Data/Skills.rvdata")
- $data_items = load_data("Data/Items.rvdata")
- $base_weapons = load_data("Data/Weapons.rvdata")
- $base_armors = load_data("Data/Armors.rvdata")
- $data_enemies = load_data("Data/Enemies.rvdata")
- $data_troops = load_data("Data/Troops.rvdata")
- $data_states = load_data("Data/States.rvdata")
- $data_animations = load_data("Data/Animations.rvdata")
- $data_common_events = load_data("Data/CommonEvents.rvdata")
- $data_system = load_data("Data/System.rvdata")
- $data_areas = load_data("Data/Areas.rvdata")
- $data_weapons = [nil]
- $data_armors = [nil]
- end
- #--------------------------------------------------------------------------
- # ● 载入战斗测试用的数据库
- #--------------------------------------------------------------------------
- def load_bt_database
- $data_actors = load_data("Data/BT_Actors.rvdata")
- $data_classes = load_data("Data/BT_Classes.rvdata")
- $data_skills = load_data("Data/BT_Skills.rvdata")
- $data_items = load_data("Data/BT_Items.rvdata")
- $data_weapons = load_data("Data/BT_Weapons.rvdata")
- $data_armors = load_data("Data/BT_Armors.rvdata")
- $data_enemies = load_data("Data/BT_Enemies.rvdata")
- $data_troops = load_data("Data/BT_Troops.rvdata")
- $data_states = load_data("Data/BT_States.rvdata")
- $data_animations = load_data("Data/BT_Animations.rvdata")
- $data_common_events = load_data("Data/BT_CommonEvents.rvdata")
- $data_system = load_data("Data/BT_System.rvdata")
- $base_weapons = $data_weapons
- $base_armors = $data_armors
- end
- end
- #==============================================================================
- # ■ Scene_Repair
- #==============================================================================
- class Scene_Repair < Scene_Base
- include Game_Equip
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # menu_index : 指令光标初期位置
- #--------------------------------------------------------------------------
- def initialize(hyper_repair = false)
- @hyper_repair = hyper_repair
- end
- #--------------------------------------------------------------------------
- # ● 开始处理
- #--------------------------------------------------------------------------
- def start
- super
- create_menu_background
- create_command_window
- @help_window = Window_Help.new
- @help_window.visible = true
- @scrhelp_window = Window_Help.new
- @gold_window = Window_Gold.new(96+16, 56)
- @gold_window.opacity = 0
- @scr_window = Window_ScrRepair.new(0,112,272,304,@hyper_repair)
- @scr_window.active = true
- @scr_window.help_window = @scrhelp_window
- @dest_window = Window_DestRepair.new(272,56,272,304+56)
- @result_window = Window_Base.new(56,56,384,80)
- @result_window.active = false
- @result_window.visible = false
- end
- #--------------------------------------------------------------------------
- # ● 结束处理
- #--------------------------------------------------------------------------
- def terminate
- super
- dispose_menu_background
- dispose_command_window
- @help_window.dispose
- @scrhelp_window.dispose
- @gold_window.dispose
- @scr_window.dispose
- @dest_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 更新画面
- #--------------------------------------------------------------------------
- def update
- super
- update_menu_background
- if @command_window.active
- @scr_window.contents_opacity = 128
- @command_window.contents_opacity = 255
- update_command_selection
- elsif @scr_window.active
- @scr_window.contents_opacity = 255
- @command_window.contents_opacity = 128
- update_item_selection
- elsif @result_window.active
- update_result_window
- end
- @command_window.update
- @gold_window.update
- @scr_window.update
- @dest_window.update
- @help_window.update
- @scrhelp_window.update
- end
- #--------------------------------------------------------------------------
- # ● 生成指令窗口
- #--------------------------------------------------------------------------
- def create_command_window
- s1 = "修复"
- s2 = "退出"
- @command_window = Window_Command.new(272, [s1, s2], 4, 0, 8)
- @command_window.y = 56
- @command_window.active = false
- @command_window.contents_opacity = 128
- end
- #--------------------------------------------------------------------------
- # ● 释放指令窗口
- #--------------------------------------------------------------------------
- def dispose_command_window
- @command_window.dispose
- end
- #--------------------------------------------------------------------------
- # ● 是否满足修复装备条件?
- #--------------------------------------------------------------------------
- def repairable?(equips)
- return false if equips.empty?
- price = 0
- equips.each{|e| price += e.price*Game_Equip::Dur_Price*e.dur/e.maxdur}
- return false if $game_party.gold < 2*price.round
- ## 扣钱
- $game_party.lose_gold(@hyper_repair ? 3*price.round : 2*price.round)
- ## 修复
- equips.each{|e| @hyper_repair ? e.hyper_repair : e.repair}
- return true
- end
- #--------------------------------------------------------------------------
- # ● 显示结果(包括处理金钱物品)
- #--------------------------------------------------------------------------
- def show_result
- @result_window.active = true
- @result_window.visible = true
- if @dest_window.equips.empty?
- @result_window.contents.clear
- @result_window.contents.draw_text(0,0,352,24,"请放入装备!", 1)
- return
- end
- if repairable?(@dest_window.equips)
- @result_window.contents.clear
- @result_window.contents.draw_text(0,0,352,24,"指定装备已被修复!", 1)
- @dest_window.revert
- Sound.play_shop
- else
- @result_window.contents.clear
- @result_window.contents.draw_text(0,0,352,24,"金钱不足,无法修复!", 1)
- @dest_window.revert
- Sound.play_actor_collapse
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新帮助文本
- #--------------------------------------------------------------------------
- def update_help(text)
- @help_window.set_text(text)
- end
- #--------------------------------------------------------------------------
- # ● 更新指令窗口
- #--------------------------------------------------------------------------
- def update_command_selection
- case @command_window.index
- when 0
- update_help("确定键开始修复装备")
- when 1
- update_help("退出修复界面")
- end
- if Input.trigger?(Input::B)
- ## 重来
- Sound.play_cancel
- @scr_window.active = true
- @command_window.active = false
- elsif Input.trigger?(Input::C)
- case @command_window.index
- when 0 # 升级
- Sound.play_decision
- @command_window.active = false
- @scr_window.active = false
- ######### 显示升级结果,归还物品
- show_result
- when 1 # 退出
- Sound.play_decision
- @dest_window.revert
- $scene = Scene_Map.new
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新选择物品
- #--------------------------------------------------------------------------
- def update_item_selection
- if Input.trigger?(Input::B)
- Sound.play_cancel
- @command_window.active = true
- @scr_window.active = false
- ###@help_window.set_text("")
- return
- end
- if Input.trigger?(Input::C)
- @item = @scr_window.item
- number = $game_party.item_number(@item)
- if @item == nil or number == 0
- Sound.play_buzzer
- else
- Sound.play_shop
- @dest_window.add(@scr_window.item)
- @scr_window.refresh
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 更新结果窗体
- #--------------------------------------------------------------------------
- def update_result_window
- if Input.trigger?(Input::B) or Input.trigger?(Input::C)
- Sound.play_decision
- @scr_window.refresh
- @scr_window.active = true
- @result_window.active = false
- @result_window.visible = false
- end
- end
- end
复制代码 |
|