赞 | 406 |
VIP | 0 |
好人卡 | 11 |
积分 | 390 |
经验 | 242285 |
最后登录 | 2024-11-26 |
在线时间 | 5719 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 39021
- 在线时间
- 5719 小时
- 注册时间
- 2006-11-10
- 帖子
- 6619
|
加入我们,或者,欢迎回来。
您需要 登录 才可以下载或查看,没有帐号?注册会员
x
本帖最后由 灯笼菜刀王 于 2018-4-7 16:30 编辑
之所以叫"绿色"是因为我没用到热门地盘description... 这年头XP数据库地皮紧张, 能不用它就不用了XD
支持 持有复数同类型装备,支持装备丢包裹也能保存耐久,支持每个人的装备都独立耐久
设置:价格的前两位是 耐久度, 价格的后4位是价格 千万数着来别设置错, 你说这样装备贬值了? 为了不通货膨胀, 市面流通的货币还是能少则少吧
耐久设置为99 就是无限耐久
然后做N件同名字的装备,N为允许所持同类型装备的数量, 注意所持有是包括全员装备上的也算
超过的话,再次获得会直接消失 ,商店超过数量就不让你买了
冲突 ,不太清楚 应该或许可能也许说不定大概maybe 可以和那些用到description的一起用{:4_86:}
不好意思,之前的有BUG, 粗心造成的, 已经更新脚本和范例(2018,4,6), 经几次测试确认没问题了......
# 菜鸟版耐久度系统 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[actor_id] @durable = [] a = actor.weapon_id == 0 ? 0 : $data_weapons[actor.weapon_id].durable @durable.push(a) a = actor.armor1_id == 0 ? 0 : $data_armors[actor.armor1_id].durable @durable.push(a) a = actor.armor2_id == 0 ? 0 : $data_armors[actor.armor2_id].durable @durable.push(a) a = actor.armor3_id == 0 ? 0 : $data_armors[actor.armor3_id].durable @durable.push(a) a = actor.armor4_id == 0 ? 0 : $data_armors[actor.armor4_id].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 when 0 if id == 0 or $game_party.weapon_number(id) > 0 $game_party.gain_weapon(@weapon_id,@durable[0]) @weapon_id = id @durable[0] = $game_party.weapon_number(id) $game_party.lose_weapon(id,@durable[0]) end else f = self.armorid if id == 0 or $game_party.armor_number(id) > 0 update_auto_state($data_armors[f[t-1]], $data_armors[id]) $game_party.gain_armor(f[t-1], @durable[t]) f[t-1] = id @durable[t] = $game_party.armor_number(id) $game_party.lose_armor(id, @durable[t]) end @armor1_id = f[0] @armor2_id = f[1] @armor3_id = f[2] @armor4_id = f[3] end end def 损坏 f = self.armorid if @durable[0] <= 0 @weapon_id = 0 @durable[0] = 0 end for i in 1..4 if @durable[i] <= 0 f[i-1] = 0 @durable[i] = 0 end end @armor1_id = f[0] @armor2_id = f[1] @armor3_id = f[2] @armor4_id = f[3] end def 全修 @durable[0] = $data_weapons[@weapon_id].durable if @weapon_id != 0 for i in 1..4 @durable[i] = $data_weapons[self.armorid[i-1]].durable if self.armorid[i-1] != 0 end end end class Game_Party def 入手(name,t=0) f = [] q = [] case t when 1 for j in 1...$data_actors.size for k in 0..3 q.push($game_actors[j].armorid[k]) end end for i in 1...$data_armors.size if $data_armors[i].name == name if $game_party.armor_number(i) > 0 next elsif q.include?(i) next else f.push(i) end end end a = f[rand(f.size - 1)] if a != nil and a != 0 $game_party.gain_armor(a,$data_armors[a].durable) else $game_system.se_play($data_system.buzzer_se) end else for j in 1...$data_actors.size q.push($game_actors[j].weapon_id) end for i in 1...$data_weapons.size if $data_weapons[i].name == name if $game_party.weapon_number(i) > 0 next elsif q.include?(i) next else f.push(i) end end end a = f[rand(f.size - 1)] if a != nil and a != 0 $game_party.gain_weapon(a,$data_weapons[a].durable) else $game_system.se_play($data_system.buzzer_se) end end end def 丢弃(name,t=0) case t when 0 for i in @weapons.keys if $data_weapons[i].name == name $game_party.lose_weapon(i, $game_party.weapon_number(i)) break end end else for i in @armors.keys if $data_armors[i].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 when 0 for i in @weapons.keys if $game_party.weapon_number(i) > 0 and $data_weapons[i].name == name a += 1 end end for j in 1...$data_actors.size if $game_actors[j].weapon_id !=0 and $data_weapons[$game_actors[j].weapon_id] != 0 a += 1 if $data_weapons[$game_actors[j].weapon_id].name == name end end else for i in @armors.keys if $game_party.armor_number(i)>0 and $data_armors[i].name == name a += 1 end end for j in 1...$data_actors.size for k in 0..3 if $game_actors[j].armorid[k] != 0 and $data_armors[$game_actors[j].armorid[k]] != 0 a += 1 if $data_armors[$game_actors[j].armorid[k]].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[0], 92, 32 * 0) draw_item_name(@data[1], 92, 32 * 1) draw_item_name(@data[2], 92, 32 * 2) draw_item_name(@data[3], 92, 32 * 3) draw_item_name(@data[4], 92, 32 * 4) for i in 0..3 if @actor.armorid[i] != 0 number = @actor.durable[i+1] self.contents.draw_text(230,32 + 32*i, 48, 32,"耐久") if $data_armors[@actor.armorid[i]].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[i]].durable.to_s, 2) end end end if @actor.weapon_id != 0 number = @actor.durable[0] 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[index] x = 4 + index % 2 * (288 + 32) y = index / 2 * 32 case item when RPG::Weapon number = $game_party.weapon_number(item.id) a = $data_weapons[item.id].durable when RPG::Armor number = $game_party.armor_number(item.id) a = $data_armors[item.id].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) if self.damage != "MISS" attacker.durable[0] -= XOXO::NORMAL_ATTACK if attacker.durable[0] != 99 attacker.损坏 end end if self.is_a?(Game_Actor) if self.damage != "MISS" for i in 1..4 self.durable[i] -= XOXO::NORMAL_DAMAGE if self.durable[i] != 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) if self.damage != "MISS" user.durable[0] -= XOXO::SKILL_ATTACK if user.durable[0] != 99 user.损坏 end end if self.is_a?(Game_Actor) if self.damage != "MISS" for i in 1..4 self.durable[i] -= XOXO::SKILL_DAMAGE if self.durable[i] != 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 if self.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 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) # 演奏商店 SE $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.入手(@item.name) when RPG::Armor $game_party.入手(@item.name,1) 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 * (@item.price / 2)) case @item when RPG::Item $game_party.lose_item(@item.id, @number_window.number) when RPG::Weapon $game_party.lose_weapon(@item.id, $game_party.weapon_number(@item.id)) when RPG::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[index] # 获取物品所持数 case item when RPG::Item number = $game_party.item_number(item.id) max = 99 when RPG::Weapon number = $game_party.持有(item.name) max = XOXO::WEAPON_MAX when RPG::Armor number = $game_party.持有(item.name,1) max = XOXO::ARMOR_MAX end # 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色 # 除此之外的情况设置为无效文字色 if item.price <= $game_party.gold and number < max self.contents.font.color = normal_color else self.contents.font.color = disabled_color end x = 4 y = index * 32 rect = Rect.new(x, y, self.width - 32, 32) self.contents.fill_rect(rect, Color.new(0, 0, 0, 0)) bitmap = RPG::Cache.icon(item.icon_name) opacity = self.contents.font.color == normal_color ? 255 : 128 self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity) self.contents.draw_text(x + 28, y, 212, 32, item.name, 0) self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2) end end
# 菜鸟版耐久度系统 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[actor_id]
@durable = []
a = actor.weapon_id == 0 ? 0 : $data_weapons[actor.weapon_id].durable
@durable.push(a)
a = actor.armor1_id == 0 ? 0 : $data_armors[actor.armor1_id].durable
@durable.push(a)
a = actor.armor2_id == 0 ? 0 : $data_armors[actor.armor2_id].durable
@durable.push(a)
a = actor.armor3_id == 0 ? 0 : $data_armors[actor.armor3_id].durable
@durable.push(a)
a = actor.armor4_id == 0 ? 0 : $data_armors[actor.armor4_id].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
when 0
if id == 0 or $game_party.weapon_number(id) > 0
$game_party.gain_weapon(@weapon_id,@durable[0])
@weapon_id = id
@durable[0] = $game_party.weapon_number(id)
$game_party.lose_weapon(id,@durable[0])
end
else
f = self.armorid
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[f[t-1]], $data_armors[id])
$game_party.gain_armor(f[t-1], @durable[t])
f[t-1] = id
@durable[t] = $game_party.armor_number(id)
$game_party.lose_armor(id, @durable[t])
end
@armor1_id = f[0]
@armor2_id = f[1]
@armor3_id = f[2]
@armor4_id = f[3]
end
end
def 损坏
f = self.armorid
if @durable[0] <= 0
@weapon_id = 0
@durable[0] = 0
end
for i in 1..4
if @durable[i] <= 0
f[i-1] = 0
@durable[i] = 0
end
end
@armor1_id = f[0]
@armor2_id = f[1]
@armor3_id = f[2]
@armor4_id = f[3]
end
def 全修
@durable[0] = $data_weapons[@weapon_id].durable if @weapon_id != 0
for i in 1..4
@durable[i] = $data_weapons[self.armorid[i-1]].durable if self.armorid[i-1] != 0
end
end
end
class Game_Party
def 入手(name,t=0)
f = []
q = []
case t
when 1
for j in 1...$data_actors.size
for k in 0..3
q.push($game_actors[j].armorid[k])
end
end
for i in 1...$data_armors.size
if $data_armors[i].name == name
if $game_party.armor_number(i) > 0
next
elsif q.include?(i)
next
else
f.push(i)
end
end
end
a = f[rand(f.size - 1)]
if a != nil and a != 0
$game_party.gain_armor(a,$data_armors[a].durable)
else
$game_system.se_play($data_system.buzzer_se)
end
else
for j in 1...$data_actors.size
q.push($game_actors[j].weapon_id)
end
for i in 1...$data_weapons.size
if $data_weapons[i].name == name
if $game_party.weapon_number(i) > 0
next
elsif q.include?(i)
next
else
f.push(i)
end
end
end
a = f[rand(f.size - 1)]
if a != nil and a != 0
$game_party.gain_weapon(a,$data_weapons[a].durable)
else
$game_system.se_play($data_system.buzzer_se)
end
end
end
def 丢弃(name,t=0)
case t
when 0
for i in @weapons.keys
if $data_weapons[i].name == name
$game_party.lose_weapon(i, $game_party.weapon_number(i))
break
end
end
else
for i in @armors.keys
if $data_armors[i].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
when 0
for i in @weapons.keys
if $game_party.weapon_number(i) > 0 and $data_weapons[i].name == name
a += 1
end
end
for j in 1...$data_actors.size
if $game_actors[j].weapon_id !=0 and $data_weapons[$game_actors[j].weapon_id] != 0
a += 1 if $data_weapons[$game_actors[j].weapon_id].name == name
end
end
else
for i in @armors.keys
if $game_party.armor_number(i)>0 and $data_armors[i].name == name
a += 1
end
end
for j in 1...$data_actors.size
for k in 0..3
if $game_actors[j].armorid[k] != 0 and $data_armors[$game_actors[j].armorid[k]] != 0
a += 1 if $data_armors[$game_actors[j].armorid[k]].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[0], 92, 32 * 0)
draw_item_name(@data[1], 92, 32 * 1)
draw_item_name(@data[2], 92, 32 * 2)
draw_item_name(@data[3], 92, 32 * 3)
draw_item_name(@data[4], 92, 32 * 4)
for i in 0..3
if @actor.armorid[i] != 0
number = @actor.durable[i+1]
self.contents.draw_text(230,32 + 32*i, 48, 32,"耐久")
if $data_armors[@actor.armorid[i]].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[i]].durable.to_s, 2)
end
end
end
if @actor.weapon_id != 0
number = @actor.durable[0]
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[index]
x = 4 + index % 2 * (288 + 32)
y = index / 2 * 32
case item
when RPG::Weapon
number = $game_party.weapon_number(item.id)
a = $data_weapons[item.id].durable
when RPG::Armor
number = $game_party.armor_number(item.id)
a = $data_armors[item.id].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)
if self.damage != "MISS"
attacker.durable[0] -= XOXO::NORMAL_ATTACK if attacker.durable[0] != 99
attacker.损坏
end
end
if self.is_a?(Game_Actor)
if self.damage != "MISS"
for i in 1..4
self.durable[i] -= XOXO::NORMAL_DAMAGE if self.durable[i] != 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)
if self.damage != "MISS"
user.durable[0] -= XOXO::SKILL_ATTACK if user.durable[0] != 99
user.损坏
end
end
if self.is_a?(Game_Actor)
if self.damage != "MISS"
for i in 1..4
self.durable[i] -= XOXO::SKILL_DAMAGE if self.durable[i] != 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
if self.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
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)
# 演奏商店 SE
$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.入手(@item.name)
when RPG::Armor
$game_party.入手(@item.name,1)
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 * (@item.price / 2))
case @item
when RPG::Item
$game_party.lose_item(@item.id, @number_window.number)
when RPG::Weapon
$game_party.lose_weapon(@item.id, $game_party.weapon_number(@item.id))
when RPG::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[index]
# 获取物品所持数
case item
when RPG::Item
number = $game_party.item_number(item.id)
max = 99
when RPG::Weapon
number = $game_party.持有(item.name)
max = XOXO::WEAPON_MAX
when RPG::Armor
number = $game_party.持有(item.name,1)
max = XOXO::ARMOR_MAX
end
# 价格在所持金以下、并且所持数不是 99 的情况下为普通文字颜色
# 除此之外的情况设置为无效文字色
if item.price <= $game_party.gold and number < max
self.contents.font.color = normal_color
else
self.contents.font.color = disabled_color
end
x = 4
y = index * 32
rect = Rect.new(x, y, self.width - 32, 32)
self.contents.fill_rect(rect, Color.new(0, 0, 0, 0))
bitmap = RPG::Cache.icon(item.icon_name)
opacity = self.contents.font.color == normal_color ? 255 : 128
self.contents.blt(x, y + 4, bitmap, Rect.new(0, 0, 24, 24), opacity)
self.contents.draw_text(x + 28, y, 212, 32, item.name, 0)
self.contents.draw_text(x + 240, y, 88, 32, item.price.to_s, 2)
end
end
范例一只
Project2.rar
(383.03 KB, 下载次数: 146)
|
评分
-
查看全部评分
|