赞 | 2 |
VIP | 73 |
好人卡 | 13 |
积分 | 2 |
经验 | 1598378 |
最后登录 | 2014-9-24 |
在线时间 | 2399 小时 |
Lv1.梦旅人
- 梦石
- 0
- 星屑
- 239
- 在线时间
- 2399 小时
- 注册时间
- 2008-4-11
- 帖子
- 12326
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
沉影的复杂装备系列的《打孔镶嵌》篇
脚本的332行处
## 绑定角色id
last_item.actor_id = nil
return if item.nil?
item.actor_id = self.id### if item.actor_id.nil?
end
end
nil解除装备时会弹窗。
所以用这个脚本的朋友会无法解除装备,如果装备那处是空的,则不能再装备其它
以下是部分脚本
- #==============================================================================
- # 复杂装备系统(2)打孔镶嵌 by 沉影不器
- #==============================================================================
- module Game_Equip
-
- ## 装备升级参数
- ## 能力升级基数(倍数)
- BaseAbility = 0.2
- ## 每级价格提高基数(倍数)
- BasePrice = 0.3
- ## 是否保证成功
- UpGrade_Absoluteness = false
- ## 每级成功率基数(百分比倍数,用于逐级下降)
- BaseSucceed = 80
- ## 最大等级
- MaxLevel = 10
- ## 需金钱基数(与本身价格的倍数)
- GoldNeed = 0.8
- ## 需物品id => 数量
- ItemsNeed = {21=>1, 22=>2}
-
-
-
- ## 打孔价格
- SocketPrice = 1000
- SocketItems = {21=>1}
-
- #--------------------------------------------------------------------------
- # ● 装备重生
- # equip: 装备
- #--------------------------------------------------------------------------
- def self.reini(equip, sockets_num = 0)
- return if equip.nil?
- result = Marshal.load(Marshal.dump(equip))
- result.base_id = equip.id
- ######result.sockets = []
- sockets_num.times{result.sockets_add}
- case result
- when RPG::Weapon
- result.id = $data_weapons.size
- $data_weapons.push result
- when RPG::Armor
- result.id = $data_armors.size
- $data_armors.push result
- end
- return result
- end
- end
- module RPG
- class BaseItem
- def initialize
- @id = 0
- @name = ""
- @icon_index = 0
- @description = ""
- @note = ""
- @base_id = 0
- end
- attr_accessor :id
- attr_accessor :name
- attr_accessor :icon_index
- attr_accessor :description
- attr_accessor :note
- attr_accessor :base_id
- end
- end
- module RPG
- class Item < UsableItem
- def gem?
- return read_note('gem').to_i > 0
- end
- def socket_gem?
- return read_note('gem').to_i == 1
- end
- end
- end
- module RPG
- class Weapon < BaseItem
- ## 母版id
- attr_accessor :base_id
- ## 角色id
- attr_reader :actor_id
- ## 孔集合(Array)
- attr_accessor :sockets
-
- def sockets_max
- return read_note('sockets').to_i
- end
-
- def sockets_num
- return 0 if @sockets.nil?
- return @sockets.size
- end
-
- def sockets_add
- @sockets = [] unless @sockets
- if sockets_num < sockets_max
- @sockets.push 0
- @name += "[O]"
- end
- end
-
- def sockets_use(item_id)
- return false unless @sockets
- for i in [email protected]
- if @sockets[i] == 0
- @sockets[i] = item_id
- @name.sub!(/\[O\]/) {"[#{$data_items[item_id].name}]"}
- return true
- end
- end
- return false
- end
-
- def actor_id=(id)
- @actor_id = id
- ## 处理能力变化
- parameter_change
- end
-
- def parameter_change
- @atk = $data_weapons[@base_id].atk
- @def = $data_weapons[@base_id].def
- @spi = $data_weapons[@base_id].spi
- @agi = $data_weapons[@base_id].agi
- @hp_max = 0
- @mp_max = 0
- return unless @sockets
- for id in @sockets
- next if id == 0
- next if actor_id.nil?
- g = Game_Gem.new(id)
- a = $game_actors[actor_id.to_i]
- @atk += g.atk
- @def += g.def
- @spi += g.spi
- @agi += g.agi
- @hp_max += g.hp_max + a.base_maxhp * g.hp_rate / 100
- @mp_max += g.mp_max + a.base_maxmp * g.mp_rate / 100
- end
- end
-
- def hp_max
- return @hp_max.to_i
- end
-
- def mp_max
- return @mp_max.to_i
- end
-
- end
- end
- module RPG
- class Armor < BaseItem
- ## 母版id
- attr_accessor :base_id
- ## 角色id
- attr_reader :actor_id
- ## 孔集合(Array)
- attr_accessor :sockets
- def sockets_max
- return read_note('sockets').to_i
- end
-
- def sockets_num
- return 0 if @sockets.nil?
- return @sockets.size
- end
-
- def sockets_add
- @sockets = [] unless @sockets
- if sockets_num < sockets_max
- @sockets.push 0
- @name += "[O]"
- end
- end
-
- def sockets_use(item_id)
- return false unless @sockets
- for i in [email protected]
- if @sockets[i] == 0
- @sockets[i] = item_id
- @name.sub!(/\[O\]/) {"[#{$data_items[item_id].name}]"}
- return true
- end
- end
- return false
- end
-
- def actor_id=(id)
- @actor_id = id
- ## 处理能力变化
- parameter_change
- end
-
- def parameter_change
- @atk = $data_armors[@base_id].atk
- @def = $data_armors[@base_id].def
- @spi = $data_armors[@base_id].spi
- @agi = $data_armors[@base_id].agi
- @hp_max = 0
- @mp_max = 0
- return unless @sockets
- for id in @sockets
- next if id == 0
- next if actor_id.nil?
- g = Game_Gem.new(id)
- a = $game_actors[actor_id.to_i]
- @atk += g.atk
- @def += g.def
- @spi += g.spi
- @agi += g.agi
- @hp_max += g.hp_max + a.base_maxhp * g.hp_rate / 100
- @mp_max += g.mp_max + a.base_maxmp * g.mp_rate / 100
- end
- end
-
- def hp_max
- return @hp_max.to_i
- end
-
- def mp_max
- return @mp_max.to_i
- end
-
- end
- end
- #==============================================================================
- # ■ Game_Gem
- #==============================================================================
- class Game_Gem
- attr_reader :hp_rate
- attr_reader :mp_rate
- attr_reader :hp_max
- attr_reader :mp_max
- attr_reader :atk
- attr_reader :def
- attr_reader :spi
- attr_reader :agi
- #--------------------------------------------------------------------------
- # ● 初始化
- #--------------------------------------------------------------------------
- def initialize(item_id)
- item = $data_items[item_id]
- @hp_rate = item.hp_recovery_rate
- @mp_rate = item.mp_recovery_rate
- @hp_max = item.hp_recovery
- @mp_max = item.mp_recovery
- @atk = 0
- @def = 0
- @spi = 0
- @agi = 0
- n = item.parameter_points
- case item.parameter_type
- when 1 #HP上限
- @hp_max += n
- when 2 #MP上限
- @mp_max += n
- when 3 #攻击力
- @atk = n
- when 4 #防御力
- @def = n
- when 5 #精神
- @spi = n
- when 6 #敏捷
- @agi = 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.hp_max end
- return n
- end
- #--------------------------------------------------------------------------
- # ● 获取基本 MaxHP
- #--------------------------------------------------------------------------
- def base_maxmp
- n = actor.parameters[1, @level]
- for item in equips.compact do n += item.mp_max end
- return n
- 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)
- 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
- ## 绑定角色id
- last_item.actor_id = nil
- return if item.nil?
- item.actor_id = self.id### if item.actor_id.nil?
- 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
- if @weapon_id != 0
- item = Game_Equip.reini($base_weapons[@weapon_id])
- unless item.nil?
- $data_weapons.push item
- @weapon_id = item.id
- end
- end
- if @armor1_id != 0
- if two_swords_style####two_hands_legal?
- item = Game_Equip.reini($base_weapons[@armor1_id])
- unless item.nil?
- $data_weapons.push item
- @armor1_id = item.id
- end
- else
- item = Game_Equip.reini($base_armors[@armor1_id])
- unless item.nil?
- $data_armors.push item
- @armor1_id = item.id
- end
- end
- end
- if @armor2_id != 0
- item = $base_armors[@armor2_id]
- unless item.nil?
- item = Game_Equip.reini(item)
- $data_armors.push item
- @armor2_id = item.id
- end
- end
- if @armor3_id != 0
- item = $base_armors[@armor3_id]
- unless item.nil?
- item = Game_Equip.reini(item)
- $data_armors.push item
- @armor3_id = item.id
- end
- end
- if @armor4_id != 0
- item = $base_armors[@armor4_id]
- unless item.nil?
- item = Game_Equip.reini(item)
- $data_armors.push item
- @armor4_id = item.id
- end
- end
- 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
- #--------------------------------------------------------------------------
- # ● 判断持有的物品(依据base_id)
- # 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(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(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
- 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.armor_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_item($base_weapons[@params[0]], value.abs, @params[4])
- else
- $game_party.lose_reini_item($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_item($base_armors[@params[0]], value.abs, @params[4])
- else
- $game_party.lose_reini_item($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
- end
- #==============================================================================
- # ■ Window_ShopBuy
- #==============================================================================
- class Window_ShopBuy < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- @data = []
- for goods_item in @shop_goods
- case goods_item[0]
- when 0
- item = $base_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_ScrEquip
- #==============================================================================
- class Window_ScrEquip < Window_Selectable
- attr_accessor :equip_only
- #--------------------------------------------------------------------------
- # ● 初始化对象
- # x : 窗口的 X 坐标
- # y : 窗口的 Y 坐标
- # width : 窗口的宽
- # height : 窗口的高
- #--------------------------------------------------------------------------
- def initialize(x, y, width, height)
- super(x, y, width, height)
- @column_max = 1
- @equip_only = true
- refresh
- end
- #--------------------------------------------------------------------------
- # ● 取得物品
- #--------------------------------------------------------------------------
- def item
- return @data[self.index]
- end
- #--------------------------------------------------------------------------
- # ● 显示是否可以使用物品
- # item : 物品
- #--------------------------------------------------------------------------
- def enable?(item)
- return true
复制代码 |
|