菜鸟版绿色装备耐久系统
之所以叫"绿色"是因为我没用到热门地盘description... 这年头XP数据库地皮紧张, 能不用它就不用了XD支持 持有复数同类型装备,支持装备丢包裹也能保存耐久,支持每个人的装备都独立耐久
设置:价格的前两位是 耐久度, 价格的后4位是价格 千万数着来别设置错, 你说这样装备贬值了?为了不通货膨胀, 市面流通的货币还是能少则少吧
耐久设置为99 就是无限耐久
然后做N件同名字的装备,N为允许所持同类型装备的数量, 注意所持有是包括全员装备上的也算
超过的话,再次获得会直接消失 ,商店超过数量就不让你买了
冲突 ,不太清楚 应该或许可能也许说不定大概maybe 可以和那些用到description的一起用{:4_86:}
不好意思,之前的有BUG, 粗心造成的, 已经更新脚本和范例(2018,4,6), 经几次测试确认没问题了......
RUBY 代码
# 菜鸟版耐久度系统by 灯笼菜刀酱
#
# 设置:价格的前两位是 耐久度, 价格的后4位是价格 千万数着来别设置错 =v= ....
#耐久设置为99 就是无限耐久
#
# 然后做N件同名字的装备,N为允许所持同类型装备的数量,超过的话,再次获得会
# 直接消失@_@,商店超过数量就不让你买了
#
# 获取武器的方法: $game_party.入手("铁剑") 记得双引号别丢
# 获取防具的方法: $game_party.入手("帽子",1)
# 丢弃武器的方法: $game_party.丢弃("铁剑")
# 丢弃防具的方法: $game_party.丢弃("帽子",1)
# 持有XX武器数量: $game_party.持有("铁剑")
# 持有XX防具数量: $game_party.持有("帽子",1)
# 全身修理: $game_party.actors[队伍位数].全修
#============================================
module XOXO
WEAPON_MAX = 10#允许同类型武器所持最大数(根据你做的武器数量设置,用于商店可买的上限)
ARMOR_MAX = 10#允许同类型装备所持最大数(根据你做的防具数量设置,用于商店可买的上限)
NORMAL_ATTACK = 1#普通攻击消耗武器耐久
SKILL_ATTACK = 2#技能攻击消耗武器耐久
NORMAL_DAMAGE = 1#普通挨打消耗防具耐久
SKILL_DAMAGE = 1#技能挨打消耗防具耐久
end
#============================================
module RPG
class Weapon
def durable
return@price % 100
end
def price
return@price / 100
end
end
class Armor
def durable
return@price % 100
end
def price
return@price / 100
end
end
end
class Game_Actor < Game_Battler
attr_accessor :durable
alias xoxo_setup setup
def setup(actor_id)
xoxo_setup(actor_id)
actor = $data_actors
@durable = []
a = actor.weapon_id == 0 ? 0 : $data_weapons.durable
@durable.push(a)
a = actor.armor1_id == 0 ? 0 : $data_armors.durable
@durable.push(a)
a = actor.armor2_id == 0 ? 0 : $data_armors.durable
@durable.push(a)
a = actor.armor3_id == 0 ? 0 : $data_armors.durable
@durable.push(a)
a = actor.armor4_id == 0 ? 0 : $data_armors.durable
@durable.push(a)
end
def armorid
a = []
a.push(@armor1_id)
a.push(@armor2_id)
a.push(@armor3_id)
a.push(@armor4_id)
return a
end
def equip(t, id)
case t
when0
if id == 0or$game_party.weapon_number(id) > 0
$game_party.gain_weapon(@weapon_id,@durable)
@weapon_id = id
@durable = $game_party.weapon_number(id)
$game_party.lose_weapon(id,@durable)
end
else
f = self.armorid
if id == 0or$game_party.armor_number(id) > 0
update_auto_state($data_armors], $data_armors)
$game_party.gain_armor(f, @durable)
f = id
@durable = $game_party.armor_number(id)
$game_party.lose_armor(id, @durable)
end
@armor1_id = f
@armor2_id = f
@armor3_id = f
@armor4_id = f
end
end
def 损坏
f = self.armorid
if@durable0
next
elsif q.include?(i)
next
else
f.push(i)
end
end
end
a = f
if a != niland a != 0
$game_party.gain_weapon(a,$data_weapons.durable)
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
def 丢弃(name,t=0)
case t
when0
for i in@weapons.keys
if$data_weapons.name == name
$game_party.lose_weapon(i, $game_party.weapon_number(i))
break
end
end
else
for i in@armors.keys
if$data_armors.name == name
$game_party.lose_armor(i, $game_party.armor_number(i))
break
end
end
end
end
def 持有(name,t=0)
a = 0
case t
when0
for i in@weapons.keys
if$game_party.weapon_number(i) > 0and$data_weapons.name == name
a += 1
end
end
for j in1...$data_actors.size
if$game_actors.weapon_id !=0and$data_weapons[$game_actors.weapon_id] != 0
a += 1if$data_weapons[$game_actors.weapon_id].name == name
end
end
else
for i in@armors.keys
if$game_party.armor_number(i)>0and$data_armors.name == name
a += 1
end
end
for j in1...$data_actors.size
for k in0..3
if$game_actors.armorid != 0and$data_armors[$game_actors.armorid] != 0
a += 1if$data_armors[$game_actors.armorid].name == name
end
end
end
end
return a
end
end
class Window_EquipRight < Window_Selectable
def refresh
self.contents.clear
@data = []
@data.push($data_weapons[@actor.weapon_id])
@data.push($data_armors[@actor.armor1_id])
@data.push($data_armors[@actor.armor2_id])
@data.push($data_armors[@actor.armor3_id])
@data.push($data_armors[@actor.armor4_id])
@item_max = @data.size
self.contents.font.color = system_color
self.contents.draw_text(4, 32 * 0, 92, 32, $data_system.words.weapon)
self.contents.draw_text(4, 32 * 1, 92, 32, $data_system.words.armor1)
self.contents.draw_text(4, 32 * 2, 92, 32, $data_system.words.armor2)
self.contents.draw_text(4, 32 * 3, 92, 32, $data_system.words.armor3)
self.contents.draw_text(5, 32 * 4, 92, 32, $data_system.words.armor4)
draw_item_name(@data, 92, 32 * 0)
draw_item_name(@data, 92, 32 * 1)
draw_item_name(@data, 92, 32 * 2)
draw_item_name(@data, 92, 32 * 3)
draw_item_name(@data, 92, 32 * 4)
for i in0..3
if@actor.armorid != 0
number = @actor.durable
self.contents.draw_text(230,32 + 32*i, 48, 32,"耐久")
if$data_armors[@actor.armorid].durable == 99
self.contents.draw_text(240,32 + 32*i,96,32,"--/--",2)
else
self.contents.draw_text(240,32 + 32*i, 96, 32,number.to_s + "/" + $data_armors[@actor.armorid].durable.to_s, 2)
end
end
end
if@actor.weapon_id != 0
number = @actor.durable
self.contents.draw_text(230,0, 48, 32,"耐久")
if$data_weapons[@actor.weapon_id].durable == 99
self.contents.draw_text(240,0,96,32,"--/--",2)
else
self.contents.draw_text(240, 0, 96, 32,number.to_s + "/" + $data_weapons[@actor.weapon_id].durable.to_s, 2)
end
end
end
end
class Window_EquipItem < Window_Selectable
def draw_item(index)
item = @data
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
whenRPG::Weapon
number = $game_party.weapon_number(item.id)
a = $data_weapons.durable
whenRPG::Armor
number = $game_party.armor_number(item.id)
a = $data_armors.durable
end
bitmap = RPG::Cache.icon(item.icon_name)
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24))
self.contents.font.color = normal_color
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 146, y, 48, 32, "耐久", 2)
if a == 99
self.contents.draw_text(x + 160, y, 96, 32, "--/--", 2)
else
self.contents.draw_text(x + 160, y, 96, 32, number.to_s + "/" + a.to_s, 2)
end
end
end
class Game_Battler
alias xoxo_attack_effect attack_effect
def attack_effect(attacker)
xoxo_attack_effect(attacker)
if attacker.is_a?(Game_Actor)
ifself.damage != "MISS"
attacker.durable -= XOXO::NORMAL_ATTACKif attacker.durable != 99
attacker.损坏
end
end
ifself.is_a?(Game_Actor)
ifself.damage != "MISS"
for i in1..4
self.durable -= XOXO::NORMAL_DAMAGEifself.durable != 99
end
self.损坏
end
end
end
alias xoxo_skill_effect skill_effect
def skill_effect(user, skill)
xoxo_skill_effect(user, skill)
if user.is_a?(Game_Actor)
ifself.damage != "MISS"
user.durable -= XOXO::SKILL_ATTACKif user.durable != 99
user.损坏
end
end
ifself.is_a?(Game_Actor)
ifself.damage != "MISS"
for i in1..4
self.durable -= XOXO::SKILL_DAMAGEifself.durable != 99
end
self.损坏
end
end
end
end
class Window_ShopNumber < Window_Base
def set(item, max, price)
if item.is_a?(RPG::Item)
@no = true
else
@no = false
end
@item = item
@max = max
@price = price
@number = 1
refresh
end
def update
super
ifself.active
if@no
if Input.repeat?(Input::RIGHT)and@number < @max
$game_system.se_play($data_system.cursor_se)
@number += 1
refresh
end
if Input.repeat?(Input::LEFT)and@number > 1
$game_system.se_play($data_system.cursor_se)
@number -= 1
refresh
end
if Input.repeat?(Input::UP)and@number < @max
$game_system.se_play($data_system.cursor_se)
@number = [@number + 10, @max].min
refresh
end
if Input.repeat?(Input::DOWN)and@number > 1
$game_system.se_play($data_system.cursor_se)
@number = [@number - 10, 1].max
refresh
end
else
if Input.dir4 != 0
$game_system.se_play($data_system.decision_se)
end
end
end
end
end
class Scene_Shop
def update_number
# 按下 B 键的情况下
if Input.trigger?(Input::B)
# 演奏取消 SE
$game_system.se_play($data_system.cancel_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case@command_window.index
when0# 购买
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when1# 卖出
# 窗口状态转向卖出模式
@sell_window.active = true
@sell_window.visible = true
@status_window.visible = false
end
return
end
# 按下 C 键的情况下
if Input.trigger?(Input::C)
# 演奏商店 SE
$game_system.se_play($data_system.shop_se)
# 设置个数输入窗口为不活动·非可视状态
@number_window.active = false
@number_window.visible = false
# 命令窗口光标位置分支
case@command_window.index
when0# 购买
# 购买处理
$game_party.lose_gold(@number_window.number * @item.price)
case@item
whenRPG::Item
$game_party.gain_item(@item.id, @number_window.number)
whenRPG::Weapon
$game_party.入手(@item.name)
whenRPG::Armor
$game_party.入手(@item.name,1)
end
# 刷新各窗口
@gold_window.refresh
@buy_window.refresh
@status_window.refresh
# 窗口状态转向购买模式
@buy_window.active = true
@buy_window.visible = true
when1# 卖出
# 卖出处理
$game_party.gain_gold(@number_window.number * (@item.price / 2))
case@item
whenRPG::Item
$game_party.lose_item(@item.id, @number_window.number)
whenRPG::Weapon
$game_party.lose_weapon(@item.id, $game_party.weapon_number(@item.id))
whenRPG::Armor
$game_party.lose_armor(@item.id, $game_party.armor_number(@item.id))
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 Window_ShopBuy < Window_Selectable
def draw_item(index)
item = @data
# 获取物品所持数
case item
whenRPG::Item
number = $game_party.item_number(item.id)
max = 99
whenRPG::Weapon
number = $game_party.持有(item.name)
max = XOXO::WEAPON_MAX
whenRPG::Armor
number = $game_party.持有(item.name,1)
max = XOXO::ARMOR_MAX
end
# 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
# 除此之外的情况设置为无效文字色
if item.price
页:
[1]