赞 | 5 |
VIP | 620 |
好人卡 | 38 |
积分 | 69 |
经验 | 125468 |
最后登录 | 2015-7-27 |
在线时间 | 1666 小时 |
Lv4.逐梦者
- 梦石
- 0
- 星屑
- 6865
- 在线时间
- 1666 小时
- 注册时间
- 2008-10-29
- 帖子
- 6710
|
装备附带技能其实是个很简单的东西
原理就和防具带的自动状态一样
只要你找对地方稍做修改即可实现
下面是我改的
既然原理和自动状态一样
那我们就先找到刷新自动状态的这个方法
#--------------------------------------------------------------------------
# ● 更新自动状态
#--------------------------------------------------------------------------
def update_auto_state(old_armor, new_armor)
if old_armor != nil and old_armor.auto_state_id != 0
remove_state(old_armor.auto_state_id, true)
end
if new_armor != nil and new_armor.auto_state_id != 0
add_state(new_armor.auto_state_id, true)
end
if old_armor != nil and old_armor.skill_id != 0
forget_skill(old_armor.skill_id)
end
if new_armor != nil and new_armor.skill_id != 0
learn_skill(new_armor.skill_id)
end
end
这个方法里默认只有2个if句子.我帖的这个方法里后面2个if句子是我加进去的
这个方法刷新的只是防具的.但是默认武器是没有自动状态的
所以我新def了一个武器的
#--------------------------------------------------------------------------
# ● 变更武器刷新技能
#--------------------------------------------------------------------------
def update_weapon_skill(old_weapon, new_weapon)
if old_weapon != nil and old_weapon.skill_id != 0
forget_skill(old_weapon.skill_id)
end
if new_weapon != nil and new_weapon.skill_id != 0
learn_skill(new_weapon.skill_id)
end
end
然后是.不管是在装备场景里更换装备还是用事件更换装备
都会用到这个更换装备的方法.把新定义的武器的部分加到换武器的那里
#--------------------------------------------------------------------------
# ● 变更装备
#--------------------------------------------------------------------------
def equip(equip_type, id)
case equip_type
when 0 # 武器
if id == 0 or $game_party.weapon_number(id) > 0
update_weapon_skill($data_weapons[@weapon_id], $data_weapons[id])
$game_party.gain_weapon(@weapon_id, 1)
@weapon_id = id
$game_party.lose_weapon(id, 1)
end
when 1 # 盾
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor1_id], $data_armors[id])
$game_party.gain_armor(@armor1_id, 1)
@armor1_id = id
$game_party.lose_armor(id, 1)
end
when 2 # 头
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor2_id], $data_armors[id])
$game_party.gain_armor(@armor2_id, 1)
@armor2_id = id
$game_party.lose_armor(id, 1)
end
when 3 # 身体
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor3_id], $data_armors[id])
$game_party.gain_armor(@armor3_id, 1)
@armor3_id = id
$game_party.lose_armor(id, 1)
end
when 4 # 装饰品
if id == 0 or $game_party.armor_number(id) > 0
update_auto_state($data_armors[@armor4_id], $data_armors[id])
$game_party.gain_armor(@armor4_id, 1)
@armor4_id = id
$game_party.lose_armor(id, 1)
end
end
end
上面这个方法和默认的相比.我就只增加了一行
然后是在角色初始化的时候也要刷新一下武器的
#--------------------------------------------------------------------------
# ● 设置
#--------------------------------------------------------------------------
alias hzhj_actor_setup setup
def setup(actor_id)
hzhj_actor_setup(actor_id)
update_weapon_skill(nil, $data_weapons[@weapon_id])
end
最后是对武器和防具追加技能ID的设置
module RPG
class Weapon
def name
new_name = @name.split(/@/)[0]
new_name = new_name == nil ? "" : new_name
return new_name
end
def skill_id
skillid = @name.split(/@/)[1]
skillid = skillid == nil ? 0 : skillid.to_i.abs
return skillid
end
end
class Armor
def name
new_name = @name.split(/@/)[0]
new_name = new_name == nil ? "" : new_name
return new_name
end
def skill_id
skillid = @name.split(/@/)[1]
skillid = skillid == nil ? 0 : skillid.to_i.abs
return skillid
end
end
end
完整脚本如下.设置方法为在武器或者防具的名字后面加 @ID
比如 铜剑@80 铜盾@70- #==============================================================================
- # ■ Game_Actor
- #==============================================================================
- class Game_Actor < Game_Battler
- #--------------------------------------------------------------------------
- # ● 更新自动状态
- #--------------------------------------------------------------------------
- def update_auto_state(old_armor, new_armor)
- if old_armor != nil and old_armor.auto_state_id != 0
- remove_state(old_armor.auto_state_id, true)
- end
- if new_armor != nil and new_armor.auto_state_id != 0
- add_state(new_armor.auto_state_id, true)
- end
- if old_armor != nil and old_armor.skill_id != 0
- forget_skill(old_armor.skill_id)
- end
- if new_armor != nil and new_armor.skill_id != 0
- learn_skill(new_armor.skill_id)
- end
- end
- #--------------------------------------------------------------------------
- # ● 变更武器刷新技能
- #--------------------------------------------------------------------------
- def update_weapon_skill(old_weapon, new_weapon)
- if old_weapon != nil and old_weapon.skill_id != 0
- forget_skill(old_weapon.skill_id)
- end
- if new_weapon != nil and new_weapon.skill_id != 0
- learn_skill(new_weapon.skill_id)
- end
- end
- #--------------------------------------------------------------------------
- # ● 变更装备
- #--------------------------------------------------------------------------
- def equip(equip_type, id)
- case equip_type
- when 0 # 武器
- if id == 0 or $game_party.weapon_number(id) > 0
- update_weapon_skill($data_weapons[@weapon_id], $data_weapons[id])
- $game_party.gain_weapon(@weapon_id, 1)
- @weapon_id = id
- $game_party.lose_weapon(id, 1)
- end
- when 1 # 盾
- if id == 0 or $game_party.armor_number(id) > 0
- update_auto_state($data_armors[@armor1_id], $data_armors[id])
- $game_party.gain_armor(@armor1_id, 1)
- @armor1_id = id
- $game_party.lose_armor(id, 1)
- end
- when 2 # 头
- if id == 0 or $game_party.armor_number(id) > 0
- update_auto_state($data_armors[@armor2_id], $data_armors[id])
- $game_party.gain_armor(@armor2_id, 1)
- @armor2_id = id
- $game_party.lose_armor(id, 1)
- end
- when 3 # 身体
- if id == 0 or $game_party.armor_number(id) > 0
- update_auto_state($data_armors[@armor3_id], $data_armors[id])
- $game_party.gain_armor(@armor3_id, 1)
- @armor3_id = id
- $game_party.lose_armor(id, 1)
- end
- when 4 # 装饰品
- if id == 0 or $game_party.armor_number(id) > 0
- update_auto_state($data_armors[@armor4_id], $data_armors[id])
- $game_party.gain_armor(@armor4_id, 1)
- @armor4_id = id
- $game_party.lose_armor(id, 1)
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 设置
- #--------------------------------------------------------------------------
- alias hzhj_actor_setup setup
- def setup(actor_id)
- hzhj_actor_setup(actor_id)
- update_weapon_skill(nil, $data_weapons[@weapon_id])
- end
- end
- module RPG
- class Weapon
- def name
- new_name = @name.split(/@/)[0]
- new_name = new_name == nil ? "" : new_name
- return new_name
- end
- def skill_id
- skillid = @name.split(/@/)[1]
- skillid = skillid == nil ? 0 : skillid.to_i.abs
- return skillid
- end
- end
- class Armor
- def name
- new_name = @name.split(/@/)[0]
- new_name = new_name == nil ? "" : new_name
- return new_name
- end
- def skill_id
- skillid = @name.split(/@/)[1]
- skillid = skillid == nil ? 0 : skillid.to_i.abs
- return skillid
- end
- end
- end
复制代码 而你需要做的就是
把新加的句子加到你的装备扩展脚本里去
如果那个脚本里出现以上的方法.就把我新写的句子加过去就是了
如果那个脚本里没有出现以上的方法.那就把整个方法复制过去
这就是所谓的融合了...
最后的 module RPG 模块里的东西稍改一下就可以了
这个冲突性比较大.
用脚本变更装备要用那个 equip 方法 |
|