嗯嗯 基本算搞定啦 有个小问题想请教下大虾 你逝2里神装 圣装之类的装备前缀是怎么做的 我不怎么想要那个暗黑类的前缀词 ‘‘──独行于2012-5-26 10:15补充以下内容 还有从包箱里获得的随机属性装备如何能获得提示 ’’ ‘‘──独行于2012-5-26 10:16补充以下内容 嗯 还有怎样能将随机装备摆到商店里进行交易 ’’ ‘‘──独行于2012-5-26 10:22补充以下内容 我的扣扣 1005080435 大虾加我吧 我也想做个类似于逝2的游戏 ’’ ‘‘──独行于2012-5-28 09:11补充以下内容: 可以回答下我问题吗 不懂的话就算啦吧 ’’ |
本帖最后由 protosssonny 于 2012-5-21 22:17 编辑 这个脚本系统是我研究得最透彻的脚本系统之一。 首先,回答你的问题。GiftMax这里写成rand()什么的是无法达到随机属性数量的目的的,因为这是“module”,在开始游戏的瞬间就已经预读完毕,假设rand(11)值随机到5,那么就永远是5了,不可能是其他数了!你要最大属性数量为11的话,直接GiftMax=11。既然已经设置为11,可是为什么装备属性的数量一直上不去? 最重要的地方点,看处理极品爆率的定义:def reini_chance(item, chance),按下面的脚本提示更改:
当生成一个属性后,极品爆率除以2,即50;再生成一个属性后,极品爆率在除以2,即25:……以此类推。所以你的极品概率到4个属性就几乎没什么可能性了。改成1.1后,100除以1.1也有90多,90多再除以1.1也还有90多,概率降低得比较慢,这样就容易看到多属性的装备了! 注意,这里只是改了战斗胜利后获得极品装备属性条数的条件,手动指定装备条数的方法是不会因此改变的。手动设定6至10条属性的装备,只需要在事件脚本中写:
在事件脚本中写:
再次,这套脚本系统BUG超多!如果使用本套脚本系统,比如使用事件法判断某武器、防具是否装备在身,某武器某防具的数量是否等于某个数、增加减少某装备;商店处理卖某物品等事件都会出错!虽然我已经把这些BUG完全修复了,但是都是只针对我的游戏《逝2》的修复,因此难以大众化匹配常规的游戏。所以,如果你不会脚本,那么请慎重使用。 |
#============================================================================== # 复杂装备系统之随机属性 by 沉影不器 #------------------------------------------------------------------------------ # 说明: 让装备类似暗黑那样附加随机属性,目前有17种属性元素可供组合,允许按 # 能力百分比加成. # # 附加属性的名称允许多个(按能力从小大到排列),用英文逗号隔开,自动按 # 附加能力大小选择词缀 # # 极品爆率不影响物品掉落机率,而是指掉落的物品带附加属性的机率 # # 获得随机属性装备的方法: # 事件脚本中输入 get_weapon(母版武器id, 数量, 附加属性1, 附加属性2...) # 或者直接指定附加属性数 get_weapon(母版武器id, 数量, 附加属性数) # 将随机生成指定附加属性数的装备 # 获得防具方法是 get_armor() 参数含义同上 # # 获得普通装备的方法: # 事件脚本中输入 get_weapon(母版武器id, 数量) # 获得防具方法是 get_armor() 参数含义同上 #============================================================================== # 参数设定 #============================================================================== module Game_Equip ## 最大附加属性数 GiftMax = 1 + rand(11 - 0 + 1) ## 附加属性影响价格基数 GiftPrice = 10 ## 极品爆率最低值和最高值(0到100) Equip_Chance = [95, 100] ## 附加属性各参数: ## name 添加到装备前的修饰词 ## max 该属性最大值 ## weight 权重(最大值的权重,用于计算价值,用于计算颜色也行) ## percent 是否按百分比计算 Gift = Struct.new(:name, :max, :weight, :percent) Gifts = [ # 攻击 Gift.new("锐利,伤害,霸道", 50, 25, false), Gift.new("残忍,残酷,凶残", 50, 40, true), # 防御 Gift.new("厚重,守卫,守护", 50, 10, false), Gift.new("结实,防卫,防护", 50, 20, true), # 精神 Gift.new("光荣", 50, 15, false), Gift.new("祝福", 50, 25, true), # 敏捷 Gift.new("敏捷", 50, 20, false), Gift.new("灵巧", 50, 30, true), # hp Gift.new("落英", 80, 20, false), Gift.new("武士", 15, 20, true), # mp Gift.new("神灵", 80, 15, false), Gift.new("圣者", 15, 15, true), # 命中 Gift.new("精确", 10, 10,false), # 闪避 Gift.new("幻影", 10, 10, false), # 暴击 Gift.new("暴击", 10, 10, false), # 经验 Gift.new("贪婪", 20, 10, true), # 极品爆率 ###(待定) Gift.new("幸运", 50, 10, false) ] end #============================================================================== # ■ Game_Equip 自定义装备模块 #============================================================================== module Game_Equip #-------------------------------------------------------------------------- # ● 物品(装备)重生 # item: 物品 # *gift: 附加属性(留空表示无属性,数字表示指定数量随机属性) #-------------------------------------------------------------------------- def self.reini(item, *gift) return if item.nil? result = item.clone gifts = *gift gifts.flatten! if gifts.is_a? Array ## 附加属性为空或指定为(0)时,直接返回母版 return self.result(result) if gifts.nil? or gifts == 0 ## 指定附加属性数量时 if gifts.is_a? Integer ## 控制数量 num = [gifts, GiftMax].min gifts = [] ## 随机生成指定数量的附加属性 rd = different_rand(Gifts.size-1, num) rd.each{|n| gifts.push Game_Gift.new(n)} end gifts = [gifts].flatten return self.result(result) if gifts.empty? ## 处理数据 result.gifts = gifts name = "" price = 0 for gift in gifts name += gift.name price += gift.weight * GiftPrice end ## 设定名称 result.name = name + '的' + result.name ## 设定价格 result.price += price.round ## 设定颜色 result.text_color = gifts.size return self.result(result) end #-------------------------------------------------------------------------- # ● 返回结果 # item: 物品 #-------------------------------------------------------------------------- def self.result(item) case item when RPG::Item when RPG::Weapon item.base_id = item.id item.id = $data_weapons.size $data_weapons << item when RPG::Armor item.base_id = item.id item.id = $data_armors.size $data_armors << item end return item end #-------------------------------------------------------------------------- # ● 物品(装备)重生 # item_id: 物品id # type: 类型 # *gift: 附加属性(留空表示无属性,数字表示指定数量随机属性) #-------------------------------------------------------------------------- def self.reini_id(item_id, type, *gift) ## 排除装备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, *gift).id end end #============================================================================== # ■ Game_Gift 装备附加能力 #============================================================================== class Game_Gift include Game_Equip #-------------------------------------------------------------------------- # ● 读取口 #-------------------------------------------------------------------------- attr_reader :type attr_reader :value attr_reader :name #-------------------------------------------------------------------------- # ● 初始化 #-------------------------------------------------------------------------- def initialize(type = nil, value = nil) get_type(type) get_value(value) get_name end #-------------------------------------------------------------------------- # ● 获取属性 #-------------------------------------------------------------------------- def get_type(type) unless type.nil? or type > Gifts.size or type < 0 @type = type else @type = rand(Gifts.size - 1) end end #-------------------------------------------------------------------------- # ● 获取品质值 #-------------------------------------------------------------------------- def get_value(value) unless value.nil? or value.abs > max @value = value else @value = linear_rand(max) + 1 end end #-------------------------------------------------------------------------- # ● 获取名称 #-------------------------------------------------------------------------- def get_name names = Gifts[@type].name.split(/,/) n = (@value.abs-1)/(max.to_f/names.size) @name = names[n.truncate] end #-------------------------------------------------------------------------- # ● 获取最大值 #-------------------------------------------------------------------------- def max return Gifts[@type].max end #-------------------------------------------------------------------------- # ● 获取权重 #-------------------------------------------------------------------------- def weight return @value > 0 ? @value / max.to_f * Gifts[@type].weight : 0 end #-------------------------------------------------------------------------- # ● 获取是否百分比 #-------------------------------------------------------------------------- def percent return Gifts[@type].percent end #-------------------------------------------------------------------------- # ● 攻击力 #-------------------------------------------------------------------------- def atk(actor_id) # 无角色信息时返回 return 0 unless actor_id # 数据类型不符时返回 return 0 if @type != 0 and @type != 1 if percent return $game_actors[actor_id].self_atk * @value / 100 else return @value end end #-------------------------------------------------------------------------- # ● 防御力 #-------------------------------------------------------------------------- def def(actor_id) # 无角色信息时返回 return 0 unless actor_id # 数据类型不符时返回 return 0 if @type != 2 and @type != 3 if percent return $game_actors[actor_id].self_def * @value / 100 else return @value end end #-------------------------------------------------------------------------- # ● 精神 #-------------------------------------------------------------------------- def spi(actor_id) # 无角色信息时返回 return 0 unless actor_id # 数据类型不符时返回 return 0 if @type != 4 and @type != 5 if percent return $game_actors[actor_id].self_spi * @value / 100 else return @value end end #-------------------------------------------------------------------------- # ● 敏捷 #-------------------------------------------------------------------------- def agi(actor_id) # 无角色信息时返回 return 0 unless actor_id # 数据类型不符时返回 return 0 if @type != 6 and @type != 7 if percent return $game_actors[actor_id].self_agi * @value / 100 else return @value end end #-------------------------------------------------------------------------- # ● maxhp #-------------------------------------------------------------------------- def maxhp(actor_id) # 无角色信息时返回 return 0 unless actor_id # 数据类型不符时返回 return 0 if @type != 8 and @type != 9 if percent return $game_actors[actor_id].self_maxhp * @value / 100 else return @value end end #-------------------------------------------------------------------------- # ● maxmp #-------------------------------------------------------------------------- def maxmp(actor_id) # 无角色信息时返回 return 0 unless actor_id # 数据类型不符时返回 return 0 if @type != 10 and @type != 11 if percent return $game_actors[actor_id].self_maxmp * @value / 100 else return @value end end #-------------------------------------------------------------------------- # ● 命中 #-------------------------------------------------------------------------- def hit # 数据类型不符时返回 return 0 if @type != 12 return @value end #-------------------------------------------------------------------------- # ● 闪避 #-------------------------------------------------------------------------- def eva # 数据类型不符时返回 return 0 if @type != 13 return @value end #-------------------------------------------------------------------------- # ● 暴击 #-------------------------------------------------------------------------- def cri # 数据类型不符时返回 return 0 if @type != 14 return @value end #-------------------------------------------------------------------------- # ● 经验(百分比) #-------------------------------------------------------------------------- def exp # 数据类型不符时返回 return 0 if @type != 15 return @value end #-------------------------------------------------------------------------- # ● 高级装备暴率(百分比) #-------------------------------------------------------------------------- def equip_chance # 数据类型不符时返回 return 0 if @type != 16 return @value end end #============================================================================== # ■ RPG::BaseItem #============================================================================== module RPG class BaseItem ## 颜色 attr_accessor :text_color end end #============================================================================== # ■ RPG::Weapon #============================================================================== module RPG class Weapon < BaseItem #------------------------------------------------------------------------ # 附加属性 #------------------------------------------------------------------------ attr_accessor :base_id attr_accessor :actor_id attr_accessor :gifts #------------------------------------------------------------------------ # 攻击力(合) #------------------------------------------------------------------------ def atk n = @atk @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.atk(actor_id) end return n end #------------------------------------------------------------------------ # 防御力(合) #------------------------------------------------------------------------ def def n = @def @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.def(actor_id) end return n end #------------------------------------------------------------------------ # 魔力(合) #------------------------------------------------------------------------ def spi n = @spi @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.spi(actor_id) end return n end #------------------------------------------------------------------------ # 敏捷(合) #------------------------------------------------------------------------ def agi n = @agi @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.agi(actor_id) end return n end #------------------------------------------------------------------------ # 最大hp(合) #------------------------------------------------------------------------ def maxhp n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.maxhp(actor_id) end return n end #------------------------------------------------------------------------ # 最大mp(合) #------------------------------------------------------------------------ def maxmp n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.maxmp(actor_id) end return n end #------------------------------------------------------------------------ # 命中率(合) #------------------------------------------------------------------------ def hit n = @hit @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.hit end return n end #------------------------------------------------------------------------ # 闪避率(合) #------------------------------------------------------------------------ def eva n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.eva end return n end #------------------------------------------------------------------------ # 暴击率(合) #------------------------------------------------------------------------ def cri n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.cri end return n end #-------------------------------------------------------------------------- # ● 经验(百分比) #-------------------------------------------------------------------------- def exp n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.exp end return n end #-------------------------------------------------------------------------- # ● 高级装备暴率(百分比) #-------------------------------------------------------------------------- def equip_chance n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.equip_chance end return n end end end #============================================================================== # ■ RPG::Armor #============================================================================== module RPG class Armor < BaseItem #------------------------------------------------------------------------ # 附加属性 #------------------------------------------------------------------------ attr_accessor :base_id attr_accessor :actor_id attr_accessor :gifts #------------------------------------------------------------------------ # 攻击力(合) #------------------------------------------------------------------------ def atk n = @atk @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.atk(actor_id) end return n end #------------------------------------------------------------------------ # 防御力(合) #------------------------------------------------------------------------ def def n = @def @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.def(actor_id) end return n end #------------------------------------------------------------------------ # 魔力(合) #------------------------------------------------------------------------ def spi n = @spi @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.spi(actor_id) end return n end #------------------------------------------------------------------------ # 敏捷(合) #------------------------------------------------------------------------ def agi n = @agi @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.agi(actor_id) end return n end #------------------------------------------------------------------------ # 最大hp(合) #------------------------------------------------------------------------ def maxhp n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.maxhp(actor_id) end return n end #------------------------------------------------------------------------ # 最大mp(合) #------------------------------------------------------------------------ def maxmp n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.maxmp(actor_id) end return n end #------------------------------------------------------------------------ # 命中率(合) #------------------------------------------------------------------------ def hit n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.hit end return n end #------------------------------------------------------------------------ # 闪避率(合) #------------------------------------------------------------------------ def eva n = @eva @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.eva end return n end #------------------------------------------------------------------------ # 暴击率(合) #------------------------------------------------------------------------ def cri n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.cri end return n end #-------------------------------------------------------------------------- # ● 经验(百分比) #-------------------------------------------------------------------------- def exp n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.exp end return n end #-------------------------------------------------------------------------- # ● 高级装备暴率(百分比) #-------------------------------------------------------------------------- def equip_chance n = 0 @gifts = [] if @gifts.nil? for g in @gifts.compact do n += g.equip_chance end return n end end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 基本 MaxHP の取得 #-------------------------------------------------------------------------- def base_maxhp n = actor.parameters[0, @level] for item in equips.compact do n += item.maxhp end return n end #-------------------------------------------------------------------------- # ● 获取基本 MaxMP #-------------------------------------------------------------------------- def base_maxmp n = actor.parameters[1, @level] for item in equips.compact do n += item.maxmp end return n end #-------------------------------------------------------------------------- # ● 获取自身 MaxHP #-------------------------------------------------------------------------- def self_maxhp return actor.parameters[0, @level] end #-------------------------------------------------------------------------- # ● 获取自身 MaxMP #-------------------------------------------------------------------------- def self_maxmp return actor.parameters[1, @level] end #-------------------------------------------------------------------------- # ● 获取自身攻击力 #-------------------------------------------------------------------------- def self_atk return actor.parameters[2, @level] end #-------------------------------------------------------------------------- # ● 获取自身防御力 #-------------------------------------------------------------------------- def self_def return actor.parameters[3, @level] end #-------------------------------------------------------------------------- # ● 获取自身精神力 #-------------------------------------------------------------------------- def self_spi return actor.parameters[4, @level] end #-------------------------------------------------------------------------- # ● 获取自身敏捷性 #-------------------------------------------------------------------------- def self_agi return actor.parameters[5, @level] end #-------------------------------------------------------------------------- # ● 获取命中率 #-------------------------------------------------------------------------- def hit n = 95 for e in equips.compact do n += e.hit end return n end #-------------------------------------------------------------------------- # ● 获取回避率 #-------------------------------------------------------------------------- def eva n = 5 for e in equips.compact do n += e.eva end return n end #-------------------------------------------------------------------------- # ● 获取会心一击概率 #-------------------------------------------------------------------------- def cri n = 4 n += 4 if actor.critical_bonus for e in equips.compact do n += e.cri end return n end #-------------------------------------------------------------------------- # ● 获取更多经验值 #-------------------------------------------------------------------------- def exp_added exp = 1 for equip in equips.compact exp += equip.exp end return exp end #-------------------------------------------------------------------------- # ● 获取高级物品暴率 #-------------------------------------------------------------------------- def equip_chance equip_chance = 0 for equip in equips.compact equip_chance += equip.equip_chance end return equip_chance end #-------------------------------------------------------------------------- # ● 获得经验值 (考虑到附加经验值) # exp : 经验值增加量 # show : 显示升级标志 #-------------------------------------------------------------------------- def gain_exp(exp, show) change_exp(@exp + exp * exp_added, show) end end #============================================================================== # ■ Game_Actor #============================================================================== class Game_Actor < Game_Battler #-------------------------------------------------------------------------- # ● 初始化对象 # actor_id : 角色 ID #-------------------------------------------------------------------------- def initialize(actor_id) super() setup(actor_id) @last_skill_id = 0 end #-------------------------------------------------------------------------- # ● 设置 # 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) return true if item == nil 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 #-------------------------------------------------------------------------- # ● 更改装备 (指定对象) # equip_type : 装备部位 (0..4) # item : 武器 or 防具 (nil 为解除装备) # test : 测试标志 (战斗测试、以及装备画面的临时装备) #-------------------------------------------------------------------------- def change_equip(equip_type, item, test = false) last_item = equips[equip_type] unless test return if $game_party.item_number(item) == 0 if item != nil $game_party.gain_item(last_item, 1) $game_party.lose_item(item, 1) last_item.actor_id = nil unless last_item.nil? end item_id = item == nil ? 0 : item.id case equip_type when 0 # 武器 @weapon_id = item_id unless two_hands_legal? # 违反双手拿取的情况下 change_equip(1, nil, test) # 解除反手的装备 end when 1 # 盾 @armor1_id = item_id unless two_hands_legal? # 违反双手拿取的情况下 change_equip(0, nil, test) # 解除反手的装备 end when 2 # 头 @armor2_id = item_id when 3 # 身体 @armor3_id = item_id when 4 # 装饰品 @armor4_id = item_id end item.actor_id = self.id unless item.nil? 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, *gift) 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, *gift) @weapons[w.id] = 1 end when RPG::Armor for i in 0...n a = Game_Equip.reini(item, *gift) @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, *gift) 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, *gift) end #-------------------------------------------------------------------------- # ● 极品爆率 #-------------------------------------------------------------------------- def equip_chance chance = Game_Equip::Equip_Chance[0] members.each {|actor| chance += actor.equip_chance} return chance 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 item = reini_chance($base_weapons[di.weapon_id], $game_party.equip_chance) drop_items.push(item) elsif di.kind == 3 item = reini_chance($base_armors[di.armor_id], $game_party.equip_chance) drop_items.push(item) end end end return drop_items end #-------------------------------------------------------------------------- # ● 处理极品爆率 #-------------------------------------------------------------------------- def reini_chance(item, chance) @item = item @chance = [chance/100.0, Game_Equip::Equip_Chance[1]/100.0].min @gifts = [] loop do if rand(0) < @chance and @gifts.size < Game_Equip::GiftMax @gifts << Game_Gift.new @chance /= 2 else return Game_Equip.reini(@item, @gifts) end end 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| next if weapon.nil? if weapon.base_id == @params[3] result = true break end end when 4 # 防具 ## 判断是否符合母版id actor.armors.each do |armor| next if armor.nil? 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, *gift) end #-------------------------------------------------------------------------- # ● 增减防具 #-------------------------------------------------------------------------- def get_armor(id, n, *gift) $game_party.gain_reini($base_armors[id], n, false, *gift) 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 = text_color(item.text_color.to_i) 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 = $data_weapons[goods_item[1]] when 2 item = $data_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 #============================================================================== # ■ 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 # 卖出 $game_party.gain_gold(@number_window.number * (@item.price / 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 |
贴下脚本吧 |
站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作
GMT+8, 2024-12-24 02:09
Powered by Discuz! X3.1
© 2001-2013 Comsenz Inc.