最近玩一款很老的游戏“光明与黑暗”时候想到的效果。
比如使用恶魔戒指可以放火雨,使用光之剑可以发三级雷,暗之剑即死之类的东东~~~
当初设想时候思路很简单...
可是实现起来却远远比想象要难的多....
感觉这脚本有些“偷天换日”的样子呢....
复制代码
- #=========================================================================
- #可使用武器和防具 BY绿发的Eclair~~~
- #=========================================================================
- #使用方法:在数据库最后一页添加两个属性,“可使用武器”和“可使用防具”。
- #把要做成可使用武器或者防具的东东分别购上这两个属性~~~
- #然后在物品里面设定一个与想要做可使用武器或防具的东东名字相同的物品,并且设
- #定好使用的效果。就可以了。
- #得到可使用武器或防具的时候,自动获得名字相同的物品,获得物品的时候也会同时
- #得到名字一样的武器和防具了,可以使用的武器和防具不在默认的“物品”里面显示
- #看起来就象只有一个的样子~~~ *^_^*
- #战斗中,装备可使用的武器或者防具的队员可以使用能用的武器或防具,如果武器或
- #防具关联的物品为消耗品而且可以使用的仅剩下该角色的装备,装备会坏掉~~
- #另外....冲突性较高....
- #=========================================================================
- module RPG
- class Weapon
- #=========================================================================
- #是否关联物品
- #=========================================================================
- def chain
- @chain = false
- return false if !@element_set.include?($data_system.elements.index("可使用武器"))
- for i in 1...$data_items.size
- @chain |= $data_items[i].name == @name
- end
- return @chain
- end
- #==========================================================================
- #关联物品id判定
- #==========================================================================
- def chain_id
- @chain_id = 0
- return 0 if !chain
- for i in 1...$data_items.size
- @chain_id = $data_items[i].id if $data_items[i].name == @name
- end
- return @chain_id
- end
- end
- end
- module RPG
- class Armor
- #=========================================================================
- #是否关联物品
- #=========================================================================
- def chain
- @chain = false
- return false if !@guard_element_set.include?($data_system.elements.index("可使用防具"))
- for i in 1...$data_items.size
- @chain |= $data_items[i].name == @name
- end
- return @chain
- end
- #==========================================================================
- #关联物品id判定
- #==========================================================================
- def chain_id
- @chain_id = 0
- return 0 if !chain
- for i in 1...$data_items.size
- @chain_id = $data_items[i].id if $data_items[i].name == @name
- end
- return @chain_id
- end
- end
- end
- #==============================================================================
- # ■ Game_Party
- #------------------------------------------------------------------------------
- # 处理同伴的类。包含金钱以及物品的信息。本类的实例
- # 请参考 $game_party。
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # ● 获取物品的所持数
- # item_id : 物品 ID
- #--------------------------------------------------------------------------
- def item_number(item_id)
- if $game_temp.in_battle
- for i in 0...5
- if make_chain(i) == item_id and make_chain(i) != 0
- if [email protected]?(item_id)
- return 1
- else
- return [@items[item_id] + 1,99].min
- end
- end
- end
- return @items.include?(item_id) ? @items[item_id] : 0
- end
- # 如果 hash 个数数值不存在就返回 0
- return @items.include?(item_id) ? @items[item_id] : 0
- end
- #======================================================================
- #取得角色关联装备关联道具id
- #======================================================================
- def make_chain(type)
- a = 0
- case type
- when 0
- $scene.active_battler.weapon_id != 0 ? a = $data_weapons[$scene.active_battler.weapon_id].chain_id : a = 0
- when 1
- $scene.active_battler.armor1_id != 0 ? a = $data_armors[$scene.active_battler.armor1_id].chain_id : a = 0
- when 2
- $scene.active_battler.armor2_id != 0 ? a = $data_armors[$scene.active_battler.armor2_id].chain_id : a = 0
- when 3
- $scene.active_battler.armor3_id != 0 ? a = $data_armors[$scene.active_battler.armor3_id].chain_id : a = 0
- when 4
- $scene.active_battler.armor4_id != 0 ? a = $data_armors[$scene.active_battler.armor4_id].chain_id : a = 0
- end
- return a
- end
- #--------------------------------------------------------------------------
- # ● 增加物品 (减少)
- # item_id : 物品 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_item(item_id, n)
- # 更新 hash 的个数数据
- use = 0
- if item_id > 0
- if @items.include?(item_id)
- use = @items[item_id]
- else
- use = 0
- end
- @items[item_id] = [[use + n, 0].max, 99].min
- for i in 1...$data_weapons.size
- if $data_weapons[i].chain_id == item_id
- @weapons[i] = [[weapon_number(i) + n, 0].max, 99].min
- end
- end
- for j in 1...$data_armors.size
- if $data_armors[j].chain_id == item_id
- @armors[j] = [[armor_number(j) + n, 0].max, 99].min
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 增加防具 (减少)
- # armor_id : 防具 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_armor(armor_id, n)
- # 更新 hash 的个数数据
- if armor_id > 0
- @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
- if $data_armors[armor_id].chain_id != 0
- @items[$data_armors[armor_id].chain_id] = [[item_number($data_armors[armor_id].chain_id) + n, 0].max, 99].min
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 增加武器 (减少)
- # weapon_id : 武器 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_weapon(weapon_id, n)
- # 更新 hash 的个数数据
- if weapon_id > 0
- @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
- if $data_weapons[weapon_id].chain_id != 0
- @items[$data_weapons[weapon_id].chain_id] = [[item_number($data_weapons[weapon_id].chain_id) + n, 0].max, 99].min
- end
- end
- end
- end
- class Scene_Battle
- def active_battler
- return @active_battler
- end
- #--------------------------------------------------------------------------
- # ● 生成物品行动结果
- #--------------------------------------------------------------------------
- def make_item_action_result
- # 获取物品
- @item = $data_items[@active_battler.current_action.item_id]
- # 因为物品耗尽而无法使用的情况下
- unless $game_party.item_can_use?(@item.id)
- # 移至步骤 1
- @phase4_step = 1
- return
- end
- # 消耗品的情况下
- if @item.consumable
- # 使用的物品减 1
- $game_party.lose_item(@item.id, 1)
- if @active_battler.weapon_id != 0
- if $data_weapons[@active_battler.weapon_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的"+$data_system.words.weapon+"#{$data_weapons[@active_battler.weapon_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(0, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor1_id != 0
- if $data_armors[@active_battler.armor1_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor1+"#{$data_armors[@active_battler.armor1_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(1, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor2_id != 0
- if $data_armors[@active_battler.armor2_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor2+"#{$data_armors[@active_battler.armor2_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(2, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor3_id != 0
- if $data_armors[@active_battler.armor3_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor3+"#{$data_armors[@active_battler.armor3_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(3, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor4_id != 0
- if $data_armors[@active_battler.armor4_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor4+"#{$data_armors[@active_battler.armor4_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(4, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- end
- # 在帮助窗口显示物品名
- @help_window.set_text(@item.name, 1)
- # 设置动画 ID
- @animation1_id = @item.animation1_id
- @animation2_id = @item.animation2_id
- # 设置公共事件 ID
- @common_event_id = @item.common_event_id
- # 确定对像
- index = @active_battler.current_action.target_index
- target = $game_party.smooth_target_actor(index)
- # 设置对像侧战斗者
- set_target_battlers(@item.scope)
- # 应用物品效果
- for target in @target_battlers
- target.item_effect(@item)
- end
- end
- end
- #==============================================================================
- # ■ Window_Item
- #------------------------------------------------------------------------------
- # 物品画面、战斗画面、显示浏览物品的窗口。
- #==============================================================================
- class Window_Item < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # 添加报务
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- # 在战斗中以外添加武器、防具
- unless $game_temp.in_battle
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0 #and !$data_weapons[i].chain || $data_weapons[i].chain_id == 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0 #and !$data_armors[i].chain || $data_armors[i].chain_id == 0
- @data.push($data_armors[i])
- end
- end
- end
- # 如果项目数不是 0 就生成位图、重新描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- end
可爱的小范例:http://rpg.blue/upload_program/files/使用武器e.rar
最近玩一款很老的游戏“光明与黑暗”时候想到的效果。
比如使用恶魔戒指可以放火雨,使用光之剑可以发三级雷,暗之剑即死之类的东东~~~
当初设想时候思路很简单...
可是实现起来却远远比想象要难的多....
感觉这脚本有些“偷天换日”的样子呢....
复制代码
- #=========================================================================
- #可使用武器和防具 BY绿发的Eclair~~~
- #=========================================================================
- #使用方法:在数据库最后一页添加两个属性,“可使用武器”和“可使用防具”。
- #把要做成可使用武器或者防具的东东分别购上这两个属性~~~
- #然后在物品里面设定一个与想要做可使用武器或防具的东东名字相同的物品,并且设
- #定好使用的效果。就可以了。
- #得到可使用武器或防具的时候,自动获得名字相同的物品,获得物品的时候也会同时
- #得到名字一样的武器和防具了,可以使用的武器和防具不在默认的“物品”里面显示
- #看起来就象只有一个的样子~~~ *^_^*
- #战斗中,装备可使用的武器或者防具的队员可以使用能用的武器或防具,如果武器或
- #防具关联的物品为消耗品而且可以使用的仅剩下该角色的装备,装备会坏掉~~
- #另外....冲突性较高....
- #=========================================================================
- module RPG
- class Weapon
- #=========================================================================
- #是否关联物品
- #=========================================================================
- def chain
- @chain = false
- return false if !@element_set.include?($data_system.elements.index("可使用武器"))
- for i in 1...$data_items.size
- @chain |= $data_items[i].name == @name
- end
- return @chain
- end
- #==========================================================================
- #关联物品id判定
- #==========================================================================
- def chain_id
- @chain_id = 0
- return 0 if !chain
- for i in 1...$data_items.size
- @chain_id = $data_items[i].id if $data_items[i].name == @name
- end
- return @chain_id
- end
- end
- end
- module RPG
- class Armor
- #=========================================================================
- #是否关联物品
- #=========================================================================
- def chain
- @chain = false
- return false if !@guard_element_set.include?($data_system.elements.index("可使用防具"))
- for i in 1...$data_items.size
- @chain |= $data_items[i].name == @name
- end
- return @chain
- end
- #==========================================================================
- #关联物品id判定
- #==========================================================================
- def chain_id
- @chain_id = 0
- return 0 if !chain
- for i in 1...$data_items.size
- @chain_id = $data_items[i].id if $data_items[i].name == @name
- end
- return @chain_id
- end
- end
- end
- #==============================================================================
- # ■ Game_Party
- #------------------------------------------------------------------------------
- # 处理同伴的类。包含金钱以及物品的信息。本类的实例
- # 请参考 $game_party。
- #==============================================================================
- class Game_Party
- #--------------------------------------------------------------------------
- # ● 获取物品的所持数
- # item_id : 物品 ID
- #--------------------------------------------------------------------------
- def item_number(item_id)
- if $game_temp.in_battle
- for i in 0...5
- if make_chain(i) == item_id and make_chain(i) != 0
- if [email protected]?(item_id)
- return 1
- else
- return [@items[item_id] + 1,99].min
- end
- end
- end
- return @items.include?(item_id) ? @items[item_id] : 0
- end
- # 如果 hash 个数数值不存在就返回 0
- return @items.include?(item_id) ? @items[item_id] : 0
- end
- #======================================================================
- #取得角色关联装备关联道具id
- #======================================================================
- def make_chain(type)
- a = 0
- case type
- when 0
- $scene.active_battler.weapon_id != 0 ? a = $data_weapons[$scene.active_battler.weapon_id].chain_id : a = 0
- when 1
- $scene.active_battler.armor1_id != 0 ? a = $data_armors[$scene.active_battler.armor1_id].chain_id : a = 0
- when 2
- $scene.active_battler.armor2_id != 0 ? a = $data_armors[$scene.active_battler.armor2_id].chain_id : a = 0
- when 3
- $scene.active_battler.armor3_id != 0 ? a = $data_armors[$scene.active_battler.armor3_id].chain_id : a = 0
- when 4
- $scene.active_battler.armor4_id != 0 ? a = $data_armors[$scene.active_battler.armor4_id].chain_id : a = 0
- end
- return a
- end
- #--------------------------------------------------------------------------
- # ● 增加物品 (减少)
- # item_id : 物品 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_item(item_id, n)
- # 更新 hash 的个数数据
- use = 0
- if item_id > 0
- if @items.include?(item_id)
- use = @items[item_id]
- else
- use = 0
- end
- @items[item_id] = [[use + n, 0].max, 99].min
- for i in 1...$data_weapons.size
- if $data_weapons[i].chain_id == item_id
- @weapons[i] = [[weapon_number(i) + n, 0].max, 99].min
- end
- end
- for j in 1...$data_armors.size
- if $data_armors[j].chain_id == item_id
- @armors[j] = [[armor_number(j) + n, 0].max, 99].min
- end
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 增加防具 (减少)
- # armor_id : 防具 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_armor(armor_id, n)
- # 更新 hash 的个数数据
- if armor_id > 0
- @armors[armor_id] = [[armor_number(armor_id) + n, 0].max, 99].min
- if $data_armors[armor_id].chain_id != 0
- @items[$data_armors[armor_id].chain_id] = [[item_number($data_armors[armor_id].chain_id) + n, 0].max, 99].min
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 增加武器 (减少)
- # weapon_id : 武器 ID
- # n : 个数
- #--------------------------------------------------------------------------
- def gain_weapon(weapon_id, n)
- # 更新 hash 的个数数据
- if weapon_id > 0
- @weapons[weapon_id] = [[weapon_number(weapon_id) + n, 0].max, 99].min
- if $data_weapons[weapon_id].chain_id != 0
- @items[$data_weapons[weapon_id].chain_id] = [[item_number($data_weapons[weapon_id].chain_id) + n, 0].max, 99].min
- end
- end
- end
- end
- class Scene_Battle
- def active_battler
- return @active_battler
- end
- #--------------------------------------------------------------------------
- # ● 生成物品行动结果
- #--------------------------------------------------------------------------
- def make_item_action_result
- # 获取物品
- @item = $data_items[@active_battler.current_action.item_id]
- # 因为物品耗尽而无法使用的情况下
- unless $game_party.item_can_use?(@item.id)
- # 移至步骤 1
- @phase4_step = 1
- return
- end
- # 消耗品的情况下
- if @item.consumable
- # 使用的物品减 1
- $game_party.lose_item(@item.id, 1)
- if @active_battler.weapon_id != 0
- if $data_weapons[@active_battler.weapon_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的"+$data_system.words.weapon+"#{$data_weapons[@active_battler.weapon_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(0, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor1_id != 0
- if $data_armors[@active_battler.armor1_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor1+"#{$data_armors[@active_battler.armor1_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(1, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor2_id != 0
- if $data_armors[@active_battler.armor2_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor2+"#{$data_armors[@active_battler.armor2_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(2, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor3_id != 0
- if $data_armors[@active_battler.armor3_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor3+"#{$data_armors[@active_battler.armor3_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(3, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- if @active_battler.armor4_id != 0
- if $data_armors[@active_battler.armor4_id].chain_id == @item.id and $game_party.item_number(@item.id) == 1
- @help_window.set_text("#{@active_battler.name}"+"的" +$data_system.words.armor4+"#{$data_armors[@active_battler.armor4_id].name}"+"坏了....",1)
- for i in 0...40
- @spriteset.update
- Graphics.update
- end
- @active_battler.equip(4, 0)
- $game_party.lose_item(@item.id, 2)
- end
- end
- end
- # 在帮助窗口显示物品名
- @help_window.set_text(@item.name, 1)
- # 设置动画 ID
- @animation1_id = @item.animation1_id
- @animation2_id = @item.animation2_id
- # 设置公共事件 ID
- @common_event_id = @item.common_event_id
- # 确定对像
- index = @active_battler.current_action.target_index
- target = $game_party.smooth_target_actor(index)
- # 设置对像侧战斗者
- set_target_battlers(@item.scope)
- # 应用物品效果
- for target in @target_battlers
- target.item_effect(@item)
- end
- end
- end
- #==============================================================================
- # ■ Window_Item
- #------------------------------------------------------------------------------
- # 物品画面、战斗画面、显示浏览物品的窗口。
- #==============================================================================
- class Window_Item < Window_Selectable
- #--------------------------------------------------------------------------
- # ● 刷新
- #--------------------------------------------------------------------------
- def refresh
- if self.contents != nil
- self.contents.dispose
- self.contents = nil
- end
- @data = []
- # 添加报务
- for i in 1...$data_items.size
- if $game_party.item_number(i) > 0
- @data.push($data_items[i])
- end
- end
- # 在战斗中以外添加武器、防具
- unless $game_temp.in_battle
- for i in 1...$data_weapons.size
- if $game_party.weapon_number(i) > 0 #and !$data_weapons[i].chain || $data_weapons[i].chain_id == 0
- @data.push($data_weapons[i])
- end
- end
- for i in 1...$data_armors.size
- if $game_party.armor_number(i) > 0 #and !$data_armors[i].chain || $data_armors[i].chain_id == 0
- @data.push($data_armors[i])
- end
- end
- end
- # 如果项目数不是 0 就生成位图、重新描绘全部项目
- @item_max = @data.size
- if @item_max > 0
- self.contents = Bitmap.new(width - 32, row_max * 32)
- for i in 0...@item_max
- draw_item(i)
- end
- end
- end
- end
可爱的小范例:http://rpg.blue/upload_program/files/使用武器e.rar
欢迎光临 Project1 (https://rpg.blue/) | Powered by Discuz! X3.1 |