# 菜鸟版耐久度系统 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
wt1.PNG (16.07 KB, 下载次数: 11)
1696993583 发表于 2018-4-6 17:58
你把铜剑和铁剑的价格都设置为 100010 就会发生很神奇的一幕...
另外就是耐久无法设置为个位数...设置 ...
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-0] = 0 @durable[i] = 0 end end @armor1_id = f[0] @armor2_id = f[1] @armor3_id = f[2] @armor4_id = f[3] end
wt4.PNG (15.31 KB, 下载次数: 9)
简直了
1696993583 发表于 2018-4-6 21:32
不过... 你到底有没有修改一下价格再测试脚本啊!反正目前BUG好多啊!基本上砍一刀就出BUG. ...
灯笼菜刀王 发表于 2018-4-6 22:22
这些就是我之前说的"无数 里麻烦 " , 这个是写脚本的时候没考虑周全出现的
原因是:敌人没有定 ...
夜狠简单 发表于 2018-4-6 22:32
既然已知异常,怎么不试试用rescue修饰符解决掉了。半残品多可惜
1696993583 发表于 2018-4-6 21:32
不过... 你到底有没有修改一下价格再测试脚本啊!反正目前BUG好多啊!基本上砍一刀就出BUG. ...
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
y967 发表于 2018-4-7 11:58
不错,只是有两个问题,1,价格不能超过9999了?2,商店买的时候只能一个一个买了... ...
192.32 KB, 下载次数: 50
1696993583 发表于 2018-4-7 14:15
我就不想说什么了...问题都在这里面.
灯笼菜刀王 发表于 2018-4-7 14:33
那是当然的,你不按我设置的来
# 获取武器的方法: $game_party.入手("铁剑") 记得双引号别丢
灯笼菜刀王 发表于 2018-4-7 14:33
那是当然的,你不按我设置的来
# 获取武器的方法: $game_party.入手("铁剑") 记得双引号别丢
商店界面弹出.PNG (63.8 KB, 下载次数: 18)
是我的游戏有问题吗.PNG (13 KB, 下载次数: 15)
数据没错吧.PNG (98.04 KB, 下载次数: 13)
到底是哪里出问题了啊!.PNG (39.51 KB, 下载次数: 16)
是我的游戏有问题吗.PNG (13 KB, 下载次数: 14)
1696993583 发表于 2018-4-7 15:31
我的天呐... 到底是我的游戏有问题还是你的脚本有问题啊?
....PNG (20.37 KB, 下载次数: 10)
1696993583 发表于 2018-4-7 16:02
比如说我们有32种武器还有32钟装备.每一种最大上限10个.就要打32x10+32x10=640个勾
然后有12个职业.还要再 ...
灯笼菜刀王 发表于 2018-4-7 16:11
数量是随你设置的, 只要你能保证游戏里不会出现相同的装备, 1件一个也是可以的(如果设置1个,获得第二个就 ...
捕获.PNG (71.5 KB, 下载次数: 12)
1696993583 发表于 2018-4-7 17:58
所以具体是修改哪些地方啊...我不敢乱改
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |