赞 | 2 |
VIP | 0 |
好人卡 | 1 |
积分 | 5 |
经验 | 5802 |
最后登录 | 2018-7-28 |
在线时间 | 97 小时 |
Lv2.观梦者
- 梦石
- 0
- 星屑
- 480
- 在线时间
- 97 小时
- 注册时间
- 2016-4-5
- 帖子
- 123
|
3楼
楼主 |
发表于 2016-4-30 08:32:23
|
只看该作者
Vortur 发表于 2016-4-30 05:40
是【装备耐久度】脚本吗?
#==============================================================================
# 装备耐久度
# by 沉影不器
#==============================================================================
#主要更改:
#
# ① 角色的每件装备都是原数据库的克隆品,使每件装备都有唯一id
# ② 角色物品窗口中所有装备单独一格
# ③ 更改了商店中对装备的买卖方式,跳过输入数量,只能一件一件买卖
# ④ 战斗中,打人消耗武器耐久度(非物理攻击的技能不消耗),被打消耗防具耐久度,有一定机率
# ⑤ 装备耐久度降为 0 时即是装备损坏,装备能力消失,可修复
# ⑥ 损坏的装备将在地图上显示
# ⑦ 装备卖出价格随耐久度打折
#------------------------------------------------------------------------------
#使用说明
#
# ① 武器耐久度在[数据库-武器]一栏的武器名称后输入,格式为"武器名,耐久度最大值"
# 例如"铜剑,12"表示铜剑最大耐久度为12
# 防具设定同上
# ② 脚本第31行设定原数据库武器最大id
# 例如:默认数据库里最后一个武器是密斯利尔杖,id是32
# ③ 脚本第32行设定原数据库防具最大id,同上
# ●注意! 以上两个常量为必设,须根据您自己的数据库更改,否则出错
# ④ 脚本第33行设定最大耐久度
# 脚本第34行设定修复装备时的音效
# ⑤ 角色初期装备最好没有重复id的装备,比如默认数据库中几个人物都用了铜盾(id:1)
# 这将使几个人物的该铜盾共享一个耐久度
# ⑥ 使用$scene = Scene_Dur_Equip.new调出修复装备画面
#==============================================================================
module DUR
DATA_WEAPON_SIZE = 32 # 原数据库武器最大id
DATA_ARMOR_SIZE = 32 # 原数据库防具最大id
DUR_SET_MAX = 999 # 最大耐久度
REP_SE = "055-Right01" # 修复装备时的音效文件名
end
#==============================================================================
class Game_Actor < Game_Battler
#--------------------------------------------------------------------------
def base_str
n = $data_actors[@actor_id].parameters[2, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += (weapon != nil and weapon.dur > 0) ? weapon.str_plus : 0
n += (armor1 != nil and armor1.dur > 0) ? armor1.str_plus : 0
n += (armor2 != nil and armor2.dur > 0) ? armor2.str_plus : 0
n += (armor3 != nil and armor3.dur > 0) ? armor3.str_plus : 0
n += (armor4 != nil and armor4.dur > 0) ? armor4.str_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
def base_dex
n = $data_actors[@actor_id].parameters[3, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += (weapon != nil and weapon.dur > 0) ? weapon.dex_plus : 0
n += (armor1 != nil and armor1.dur > 0) ? armor1.dex_plus : 0
n += (armor2 != nil and armor2.dur > 0) ? armor2.dex_plus : 0
n += (armor3 != nil and armor3.dur > 0) ? armor3.dex_plus : 0
n += (armor4 != nil and armor4.dur > 0) ? armor4.dex_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
def base_agi
n = $data_actors[@actor_id].parameters[4, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += (weapon != nil and weapon.dur > 0) ? weapon.agi_plus : 0
n += (armor1 != nil and armor1.dur > 0) ? armor1.agi_plus : 0
n += (armor2 != nil and armor2.dur > 0) ? armor2.agi_plus : 0
n += (armor3 != nil and armor3.dur > 0) ? armor3.agi_plus : 0
n += (armor4 != nil and armor4.dur > 0) ? armor4.agi_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
def base_int
n = $data_actors[@actor_id].parameters[5, @level]
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
n += (weapon != nil and weapon.dur > 0) ? weapon.int_plus : 0
n += (armor1 != nil and armor1.dur > 0) ? armor1.int_plus : 0
n += (armor2 != nil and armor2.dur > 0) ? armor2.int_plus : 0
n += (armor3 != nil and armor3.dur > 0) ? armor3.int_plus : 0
n += (armor4 != nil and armor4.dur > 0) ? armor4.int_plus : 0
return [[n, 1].max, 999].min
end
#--------------------------------------------------------------------------
def base_atk
weapon = $data_weapons[@weapon_id]
return (weapon != nil and weapon.dur > 0) ? weapon.atk : 0
end
#--------------------------------------------------------------------------
def base_pdef
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
pdef1 = (weapon != nil and weapon.dur > 0) ? weapon.pdef : 0
pdef2 = (armor1 != nil and armor1.dur > 0) ? armor1.pdef : 0
pdef3 = (armor2 != nil and armor2.dur > 0) ? armor2.pdef : 0
pdef4 = (armor3 != nil and armor3.dur > 0) ? armor3.pdef : 0
pdef5 = (armor4 != nil and armor4.dur > 0) ? armor4.pdef : 0
return pdef1 + pdef2 + pdef3 + pdef4 + pdef5
end
#--------------------------------------------------------------------------
def base_mdef
weapon = $data_weapons[@weapon_id]
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
mdef1 = (weapon != nil and weapon.dur > 0) ? weapon.mdef : 0
mdef2 = (armor1 != nil and armor1.dur > 0) ? armor1.mdef : 0
mdef3 = (armor2 != nil and armor2.dur > 0) ? armor2.mdef : 0
mdef4 = (armor3 != nil and armor3.dur > 0) ? armor3.mdef : 0
mdef5 = (armor4 != nil and armor4.dur > 0) ? armor4.mdef : 0
return mdef1 + mdef2 + mdef3 + mdef4 + mdef5
end
#--------------------------------------------------------------------------
def base_eva
armor1 = $data_armors[@armor1_id]
armor2 = $data_armors[@armor2_id]
armor3 = $data_armors[@armor3_id]
armor4 = $data_armors[@armor4_id]
eva1 = (armor1 != nil and armor1.dur > 0) ? armor1.eva : 0
eva2 = (armor2 != nil and armor2.dur > 0) ? armor2.eva : 0
eva3 = (armor3 != nil and armor3.dur > 0) ? armor3.eva : 0
eva4 = (armor4 != nil and armor4.dur > 0) ? armor4.eva : 0
return eva1 + eva2 + eva3 + eva4
end
end
#==============================================================================
class Game_Party
#--------------------------------------------------------------------------
attr_accessor :weapons
attr_accessor :armors
#--------------------------------------------------------------------------
def weapon_number(weapon_id)
return @weapons.include?(weapon_id) ? @weapons[weapon_id] : 0
end
#--------------------------------------------------------------------------
# 以下修改于<<武器攻击力波动>>(灼眼的夏娜)
def gain_weapon(weapon_id, n)
if weapon_id > 0
if n > 0 # 增加武器的情况
n = 1
# 装备栏中使用的武器不处理~
if $scene.is_a?(Scene_Equip)
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
else
new_weapon = $data_weapons[weapon_id].clone
new_weapon.dur_set = $data_weapons[weapon_id].dur_set
new_weapon.dur = $data_weapons[weapon_id].dur_set
new_weapon.id = $data_weapons.size
#数据库扩容
$data_weapons.push(new_weapon)
# 职业可装备武器数组更新~
for i in 1...$data_classes.size
if $data_classes.weapon_set.include?(weapon_id)
$data_classes.weapon_set.push(new_weapon.id)
end
end
# 增加武器~
@weapons[new_weapon.id] = [[weapon_number(new_weapon.id) + n, 0].max, 99].min
end
else # n < 0 减少武器的情况(未定的情况: n = 0)
n = -1
# 装备栏中卸下的武器不处理~
if $scene.is_a?(Scene_Equip)
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
else
lose_name = $data_weapons[weapon_id].name
dur_min = DUR::DUR_SET_MAX
for i in DUR::DATA_WEAPON_SIZE+1...$data_weapons.size
# 重新确定weapon_id,必定在原武器数据库之外
# 减少同名武器中耐久度最低的
if $data_weapons.name == lose_name and $data_weapons.dur < dur_min
weapon_id = i
end
end
# 已不存在的不做操作
if weapon_number(weapon_id) <= 0
return
end
# 减少武器
@weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
# 删除行囊拥有的武器id,后id补进
@weapons.delete(weapon_id)
weapon_keys = @weapons.keys.sort!
for i in weapon_keys
if i > weapon_id
@weapons[i-1] = @weapons
@weapons.delete(i)
end
end
# 更改角色使用中的武器id
for i in [email protected]
if @actors.weapon_id != nil and @actors.weapon_id > weapon_id
@actors.weapon_id -= 1
end
end
if weapon_id > DUR::DATA_WEAPON_SIZE
# 删除数据库武器id,后补进
for i in weapon_id+1...$data_weapons.size
$data_weapons.id -= 1
end
$data_weapons.delete_at(weapon_id)
# 职业可装备武器数组更新
for i in 1...$data_classes.size
if $data_classes.weapon_set.include?(weapon_id)
$data_classes.weapon_set.delete(weapon_id)
end
for j in $data_classes.weapon_set
if j > weapon_id
$data_classes.weapon_set.delete(j)
j -= 1
$data_classes.weapon_set.push(j)
end
end
end
end
end
end
end
end
#--------------------------------------------------------------------------
def gain_armor(armor_id, n)
if armor_id > 0
if n > 0 # 增加防具的情况
n = 1
# 装备栏中使用的防具不处理~
if $scene.is_a?(Scene_Equip)
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
else
new_armor = $data_armors[armor_id].clone
new_armor.dur_set = $data_armors[armor_id].dur_set
new_armor.dur = $data_armors[armor_id].dur_set
new_armor.id = $data_armors.size
#数据库扩容
$data_armors.push(new_armor)
# 职业可装备防具数组更新~
for i in 1...$data_classes.size
if $data_classes.armor_set.include?(armor_id)
$data_classes.armor_set.push(new_armor.id)
end
end
# 增加防具
@armors[new_armor.id] = [[armor_number(new_armor.id) + n, 0].max, 99].min
end
else # n < 0 减少防具的情况(未定的情况: n = 0)
n = -1
# 装备栏中卸下的防具不处理
if $scene.is_a?(Scene_Equip)
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
else
lose_name = $data_armors[armor_id].name
dur_min = DUR::DUR_SET_MAX
for i in DUR::DATA_ARMOR_SIZE+1...$data_armors.size
# 重新确定armor_id,必定在原防具数据库之外
# 减少同名防具中耐久度最低的
if $data_armors.name == lose_name and $data_armors.dur < dur_min
armor_id = i
end
end
# 已不存在的不做操作
if armor_number(armor_id) <= 0
return
end
# 减少防具
@armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
# 删除行囊拥有的防具id,后id补进
@weapons.delete(armor_id)
armor_keys = @armors.keys.sort!
for i in armor_keys
if i > armor_id
@armors[i-1] = @armors
@armors.delete(i)
end
end
# 更改角色使用中的防具id
for i in [email protected]
if @actors.armor1_id != nil and @actors.armor1_id > armor_id
@actors.armor1_id -= 1
end
if @actors.armor2_id != nil and @actors.armor2_id > armor_id
@actors.armor2_id -= 1
end
if @actors.armor3_id != nil and @actors.armor3_id > armor_id
@actors.armor3_id -= 1
end
if @actors.armor4_id != nil and @actors.armor4_id > armor_id
@actors.armor4_id -= 1
end
end
if armor_id > DUR::DATA_ARMOR_SIZE
# 删除数据库防具id,后补进
for i in armor_id+1...$data_armors.size
$data_armors.id -= 1
end
$data_armors.delete_at(armor_id)
# 职业可装备防具数组更新
for i in 1...$data_classes.size
if $data_classes.armor_set.include?(armor_id)
$data_classes.armor_set.delete(armor_id)
end
for j in $data_classes.armor_set
if j > armor_id
$data_classes.armor_set.delete(j)
j -= 1
$data_classes.armor_set.push(j)
end
end
end
end
end
end
end
end
end
# ===========================================================================
class Window_Item < Window_Selectable
#--------------------------------------------------------------------------
def update_help
description = ""
if self.item != nil
description = self.item.description
if !self.item.is_a? RPG::Item
dur_set = item.dur_set
dur = item.dur
description = description + " 耐久度: #{dur}/#{dur_set}"
end
end
@help_window.set_text(description)
end
end
# ===========================================================================
class Window_EquipItem < Window_Selectable
#--------------------------------------------------------------------------
def update_help
description = ""
if self.item != nil
description = self.item.description
dur_set = item.dur_set
dur = item.dur
description = description + " 耐久度: #{dur}/#{dur_set}"
end
@help_window.set_text(description)
end
end
# ===========================================================================
class Window_EquipRight < Window_Selectable
#--------------------------------------------------------------------------
def update_help
description = ""
if self.item != nil
description = self.item.description
dur_set = item.dur_set
dur = item.dur
description = description + " 耐久度: #{dur}/#{dur_set}"
end
@help_window.set_text(description)
end
end
#==============================================================================
class Window_ShopBuy < Window_Selectable
#--------------------------------------------------------------------------
def update_help
description = ""
if self.item != nil
description = self.item.description
if !self.item.is_a? RPG::Item
dur_set = item.dur_set
dur = item.dur
description = description + " 耐久度: #{dur}/#{dur_set}"
end
end
@help_window.set_text(description)
end
end
#==============================================================================
class Window_ShopSell < Window_Selectable
#--------------------------------------------------------------------------
def update_help
description = ""
if self.item != nil
description = self.item.description
if !self.item.is_a? RPG::Item
dur_set = item.dur_set
dur = item.dur
description = description + " 耐久度: #{dur}/#{dur_set}"
end
end
@help_window.set_text(description)
end
end
#==============================================================================
class Scene_Title
#--------------------------------------------------------------------------
alias main_add_dur main
def main
main_add_dur
# 战斗测试的情况下
if $BTEST
battle_test
return
end
$data_weapons = load_data("Data/Weapons.rxdata")
$data_armors = load_data("Data/Armors.rxdata")
# 初始化耐久度
for i in 1...$data_weapons.size
$data_weapons.dur = $data_weapons.dur_set
end
for i in 1...$data_armors.size
$data_armors.dur = $data_armors.dur_set
end
end
end
#==============================================================================
class Scene_Shop
#--------------------------------------------------------------------------
def update_buy
@status_window.item = @buy_window.item
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
# 窗口状态转向初期模式
@command_window.active = true
@dummy_window.visible = true
@buy_window.active = false
@buy_window.visible = false
@status_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @buy_window.item
if @item == nil or @item.price > $game_party.gold
$game_system.se_play($data_system.buzzer_se)
return
end
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
if number == 99
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
max = @item.price == 0 ? 99 : $game_party.gold / @item.price
max = [max, 99 - number].min
if @item.is_a? RPG::Item # 除物品外直接买进1件
@buy_window.active = false
@buy_window.visible = false
@number_window.set(@item, max, @item.price)
@number_window.active = true
@number_window.visible = true
else
update_number
end
end
end
#--------------------------------------------------------------------------
def update_sell
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@command_window.active = true
@dummy_window.visible = true
@sell_window.active = false
@sell_window.visible = false
@status_window.item = nil
@help_window.set_text("")
return
end
if Input.trigger?(Input::C)
@item = @sell_window.item
@status_window.item = @item
if @item == nil or @item.price == 0
$game_system.se_play($data_system.buzzer_se)
return
end
$game_system.se_play($data_system.decision_se)
case @item
when RPG::Item
number = $game_party.item_number(@item.id)
when RPG::Weapon
number = $game_party.weapon_number(@item.id)
when RPG::Armor
number = $game_party.armor_number(@item.id)
end
max = number
if @item.is_a? RPG::Item # 除物品外直接卖出1件
@sell_window.active = false
@sell_window.visible = false
@number_window.set(@item, max, @item.price / 2)
@number_window.active = true
@number_window.visible = true
@status_window.visible = true
else
update_number
end
end
end
#--------------------------------------------------------------------------
def update_number
# 按下 B 键的情况下
if Input.trigger?(Input::B)
$game_system.se_play($data_system.cancel_se)
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 购买
@buy_window.active = true
@buy_window.visible = true
when 1 # 卖出
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
$game_system.se_play($data_system.shop_se)
@number_window.active = false
@number_window.visible = false
case @command_window.index
when 0 # 购买
$game_party.lose_gold(@number_window.number * @item.price)
case @item
when RPG::Item
$game_party.gain_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.gain_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.gain_armor(@item.id, @number_window.number)
end
@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 * rep_cost(@item) / 2)
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, @number_window.number)
when RPG::Armor
$game_party.lose_armor(@item.id, @number_window.number)
end
@gold_window.refresh
@sell_window.refresh
@status_window.refresh
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
end
end
#==============================================================================
class Game_Battler
#--------------------------------------------------------------------------
def attack_effect(attacker)
self.critical = false
hit_result = (rand(100) < attacker.hit)
if hit_result == true
atk = [attacker.atk - self.pdef / 2, 0].max
self.damage = atk * (20 + attacker.str) / 20
self.damage *= elements_correct(attacker.element_set)
self.damage /= 100
if self.damage > 0
if rand(100) < 4 * attacker.dex / self.agi
self.damage *= 2
self.critical = true
end
if self.guarding?
self.damage /= 2
end
end
if self.damage.abs > 0
amp = [self.damage.abs * 15 / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
eva = 8 * self.agi / attacker.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
end
if hit_result == true
remove_states_shock
self.hp -= self.damage
@state_changed = false
states_plus(attacker.plus_state_set)
states_minus(attacker.minus_state_set)
else
self.damage = "Miss"
self.critical = false
end
# 耐久度判断
if hit_result == true
if self.is_a?(Game_Actor) # 如果挨打的是角色,减防具耐久度
armor_kind = 1 + rand(4)
case armor_kind
when 1
if self.armor1_id != nil and self.armor1_id > 0
if rand(2) == 0 and $data_armors[self.armor1_id].dur > 0
$data_armors[self.armor1_id].dur -= 1
end
end
when 2
if self.armor2_id != nil and self.armor2_id > 0
if rand(2) == 0 and $data_armors[self.armor2_id].dur > 0
$data_armors[self.armor2_id].dur -= 1
end
end
when 3
if self.armor3_id != nil and self.armor3_id > 0
if rand(2) == 0 and $data_armors[self.armor3_id].dur > 0
$data_armors[self.armor3_id].dur -= 1
end
end
when 4
if self.armor4_id != nil and self.armor4_id > 0
if rand(2) == 0 and $data_armors[self.armor4_id].dur > 0
$data_armors[self.armor4_id].dur -= 1
end
end
end
else # 角色打人,减武器耐久度
if attacker.weapon_id != nil and attacker.weapon_id > 0
if rand(8) == 0 and $data_weapons[attacker.weapon_id].dur > 0
$data_weapons[attacker.weapon_id].dur -= 1
end
end
end
end
# 过程结束
return true
end
#--------------------------------------------------------------------------
def skill_effect(user, skill)
self.critical = false
if ((skill.scope == 3 or skill.scope == 4) and self.hp == 0) or
((skill.scope == 5 or skill.scope == 6) and self.hp >= 1)
return false
end
effective = false
effective |= skill.common_event_id > 0
hit = skill.hit
if skill.atk_f > 0
hit *= user.hit / 100
end
hit_result = (rand(100) < hit)
effective |= hit < 100
if hit_result == true
power = skill.power + user.atk * skill.atk_f / 100
if power > 0
power -= self.pdef * skill.pdef_f / 200
power -= self.mdef * skill.mdef_f / 200
power = [power, 0].max
end
rate = 20
rate += (user.str * skill.str_f / 100)
rate += (user.dex * skill.dex_f / 100)
rate += (user.agi * skill.agi_f / 100)
rate += (user.int * skill.int_f / 100)
self.damage = power * rate / 20
self.damage *= elements_correct(skill.element_set)
self.damage /= 100
if self.damage > 0
if self.guarding?
self.damage /= 2
end
end
if skill.variance > 0 and self.damage.abs > 0
amp = [self.damage.abs * skill.variance / 100, 1].max
self.damage += rand(amp+1) + rand(amp+1) - amp
end
eva = 8 * self.agi / user.dex + self.eva
hit = self.damage < 0 ? 100 : 100 - eva * skill.eva_f / 100
hit = self.cant_evade? ? 100 : hit
hit_result = (rand(100) < hit)
effective |= hit < 100
end
if hit_result == true
if skill.power != 0 and skill.atk_f > 0
remove_states_shock
effective = true
end
last_hp = self.hp
self.hp -= self.damage
effective |= self.hp != last_hp
@state_changed = false
effective |= states_plus(skill.plus_state_set)
effective |= states_minus(skill.minus_state_set)
if skill.power == 0
self.damage = ""
unless @state_changed
self.damage = "Miss"
end
end
else
self.damage = "Miss"
end
unless $game_temp.in_battle
self.damage = nil
end
# 耐久度判断
if hit_result == true
if self.is_a?(Game_Actor) # 如果挨打的是角色,减防具耐久度
armor_kind = 1 + rand(4)
case armor_kind
when 1
if self.armor1_id != nil and self.armor1_id > 0
if rand(2) == 0 and $data_armors[self.armor1_id].dur > 0
$data_armors[self.armor1_id].dur -= 1
end
end
when 2
if self.armor2_id != nil and self.armor2_id > 0
if rand(2) == 0 and $data_armors[self.armor2_id].dur > 0
$data_armors[self.armor2_id].dur -= 1
end
end
when 3
if self.armor3_id != nil and self.armor3_id > 0
if rand(2) == 0 and $data_armors[self.armor3_id].dur > 0
$data_armors[self.armor3_id].dur -= 1
end
end
when 4
if self.armor4_id != nil and self.armor4_id > 0
if rand(2) == 0 and $data_armors[self.armor4_id].dur > 0
$data_armors[self.armor4_id].dur -= 1
end
end
end
else # 角色打人,减武器耐久度
if user.weapon_id != nil and user.weapon_id > 0
if rand(8) == 0 and $data_weapons[user.weapon_id].dur > 0
if skill.atk_f == 0 # 非物理技能不损武器耐久度
$data_weapons[user.weapon_id].dur -= 1
end
end
end
end
end
# 过程结束
return effective
end
end
#==============================================================================
class Window_Dur < Window_Base
#--------------------------------------------------------------------------
def initialize
super(0,0,320,480)
self.opacity = 0
self.contents = Bitmap.new(width - 32, height - 32)
@text_dur_old = [0]
@text_dur = []
refresh
end
#--------------------------------------------------------------------------
def draw_text_dur(index,y)
text = @text_dur[index]
tx = 0
ty = index * 24 + y
self.contents.font.color = normal_color
self.contents.draw_text(tx, ty, 320-32, 24, text)
end
#--------------------------------------------------------------------------
def refresh
# 节省内存
if @text_dur_old == @text_dur
return
end
@text_dur.clear
# 取得空耐久度的装备名
for i in $game_party.actors
if $data_weapons[i.weapon_id] != nil and $data_weapons[i.weapon_id].dur == 0
@text_dur.push(i.name + "-" + $data_weapons[i.weapon_id].name)
end
if $data_armors[i.armor1_id] != nil and $data_armors[i.armor1_id].dur == 0
@text_dur.push(i.name + "-" + $data_armors[i.armor1_id].name)
end
if $data_armors[i.armor2_id] != nil and $data_armors[i.armor2_id].dur == 0
@text_dur.push(i.name + "-" + $data_armors[i.armor2_id].name)
end
if $data_armors[i.armor3_id] != nil and $data_armors[i.armor3_id].dur == 0
@text_dur.push(i.name + "-" + $data_armors[i.armor3_id].name)
end
if $data_armors[i.armor4_id] != nil and $data_armors[i.armor4_id].dur == 0
@text_dur.push(i.name + "-" + $data_armors[i.armor4_id].name)
end
end
@text_dur_old = @text_dur
y = 448 - @text_dur.size * 24
self.contents.clear
self.contents.font.size = 14
if @text_dur != []
self.contents.font.color = Color.new(255, 0, 0) # 红色显示
self.contents.draw_text(0, y - 24, 320 - 32, 24, "装备损坏:")
end
for i in 0... @text_dur.size
draw_text_dur(i,y)
end
self.contents.font.size = Font.default_size
end
end |
|