#============================================================================
#宠物系统 By Iselia雪
#数据库中可以捕捉的敌人格式这样写 敌人,捕捉后的职业
#捕捉特技的属性下面设定。
#敌人捕捉的几率和这个属性抵抗力反比,和使用者速度+敏捷与目标速度+敏捷比值成正比。
#具体设置参考范例~
#整合了chaochao的人物仓库(新建的宠物$game_party.actors.include?不认?!)
#不过这个难不住我ORZ……^__________^
#捕捉后敌人的行走图和战斗图名字相同,没有行走图则为空。
#============================================================================
$捕捉 = "抓宠物啦"
module RPG
class Skill
def catch?
return @element_set.include?($data_system.elements.index($捕捉))
end
end
end
module RPG
class Enemy
def name
return @name.split(/,/)[0]
end
def mold
return @name.split(/,/)[1]
end
end
end
class Game_Enemy < Game_Battler
def mold
return $data_enemies[@enemy_id].mold
end
def element_ranks
return $data_enemies[@enemy_id].element_ranks
end
def make_pet
pet = $data_actors[mold.to_i]
pet.battler_name = self.battler_name
pet.battler_hue = self.battler_hue
begin
RPG::Cache.character(self.battler_name,self.battler_hue)
pet.character_name = self.battler_name
pet.character_hue = self.battler_hue
rescue Errno::ENOENT
end
pet.name = self.name
$data_actors[$data_actors.size] = pet
pet2 = Game_Actor.new($data_actors.size - 1)
$game_actors.push(pet2)
$data_actors.delete_at($data_actors.size)
p $data_actors[$data_actors.size]
if $game_party.actors.size == 4
$game_party.add_actor($game_actors.size-1,2)
else
$game_party.add_actor($game_actors.size-1)
end
$scene.status_window.refresh
end
end
class Game_Actors
def push(val)
if @data.size < 999
@data.push(val)
end
end
def size
return @data.size
end
def [](actor_id)
if actor_id > 999
return nil
end
if @data[actor_id] == nil
@data[actor_id] = Game_Actor.new(actor_id)
end
return @data[actor_id]
end
end
class Game_Battler
alias skill_effect_iselia :skill_effect
def skill_effect(user,skill)
if skill.element_set.include?($data_system.elements.index($捕捉))
catch(user)
return true
end
skill_effect_iselia(user,skill)
end
#捕捉
def catch(user)
percent = (user.agi + user.dex) / (self.agi + self.dex) * percent_base
if self.can_catch and rand(100) < percent+90
self.hidden = true
self.current_action.kind = 3
make_pet
end
end
#可否捕捉
def can_catch
return self.is_a?(Game_Enemy) && self.mold != nil
end
#宠物资料
def percent_base
return 0 if self.is_a?(Game_Actor)
return [100,80,60,40,20,10,5][self.element_ranks[$data_system.elements.index($捕捉)]]
end
end
class Scene_Battle
attr_accessor :status_window
def make_skill_action_result
# 获取特技
@skill = $data_skills[@active_battler.current_action.skill_id]
# 如果不是强制行动
unless @active_battler.current_action.forcing
# 因为 SP 耗尽而无法使用的情况下
unless @active_battler.skill_can_use?(@skill.id)
# 清除强制行动对像的战斗者
$game_temp.forcing_battler = nil
# 移至步骤 1
@phase4_step = 1
return
end
end
# 消耗 SP
@active_battler.sp -= @skill.sp_cost
# 刷新状态窗口
@status_window.refresh
# 在帮助窗口显示特技名
@help_window.set_text(@skill.name, 1)
# 设置动画 ID
@animation1_id = @skill.animation1_id
@animation2_id = @skill.animation2_id
# 设置公共事件 ID
@common_event_id = @skill.common_event_id
# 设置对像侧战斗者
set_target_battlers(@skill.scope)
if @skill.catch?
@active_battler.animation_id = @animation1_id
($data_animations[@animation1_id].frame_max + 8).times do
Graphics.update
@spriteset.update
end
@target_battlers.each do |v|
v.animation_id = @animation2_id
end
($data_animations[@animation2_id].frame_max + 8).times do
Graphics.update
@spriteset.update
end
end
# 应用特技效果
for target in @target_battlers
target.skill_effect(@active_battler, @skill)
end
if @skill.catch?
@phase4_step = 5
end
end
end
dsu_plus_rewardpost_czw作者: 恶魔王者 时间: 2011-5-2 18:07
我也不知道呀