Project1
标题:
被动技能脚本的使用说明谁告下
[打印本页]
作者:
气味123
时间:
2010-9-1 00:20
标题:
被动技能脚本的使用说明谁告下
#--------------------------------------------------------------------------
# □ RPG::Skill
#--------------------------------------------------------------------------
module RPG
class Skill
#--------------------------------------------------------------------------
# ● 特技类型 (0 : 攻击, 1 : 回复, 2 : 支援, 3 : 被动)
#--------------------------------------------------------------------------
def type
if @occasion == 3
return 3
elsif @power == 0 and @atk_f == 0
return 2
elsif @power < 0
return 1
else
return 0
end
end
#--------------------------------------------------------------------------
# ● 被动技判定
#--------------------------------------------------------------------------
def innate?
return (type == 3)
end
#--------------------------------------------------------------------------
# ● 获得被动特技类型
# skill : 特技
#--------------------------------------------------------------------------
def innate_type
# 不是被动特技的情况下
if not innate?
return -1
end
case @scope
when 0
# 属性防御类特技
if @element_set != []
return 1
# 状态防御类特技
elsif @minus_state_set != [] or @plus_state_set != []
return 2
# 数值加成类特技
else
return 0
end
when 1
return 3
end
end
#--------------------------------------------------------------------------
# ● 判断增加或减少
# index : 判断项目
#--------------------------------------------------------------------------
def sign(index)
unless innate?
return 0
end
if index >= 0
return (@sp_cost & (2 ** index) == 2 ** index) ? -1 : 1
else
case innate_type
when 0
return 0
when 1
return @minus_state_set.include?(-index) ? -0.5 : 1
when 2
return (@sp_cost & 1024 == 1024) ? true : false
end
end
end
#--------------------------------------------------------------------------
# ● 最大 HP 上升量
#--------------------------------------------------------------------------
def maxhp_plus
return (innate? and innate_type <= 2) ? @hit * sign(6) : 0
end
#--------------------------------------------------------------------------
# ● 最大 SP 上升量
#--------------------------------------------------------------------------
def maxsp_plus
return (innate? and innate_type <= 2) ? @variance * sign(9) : 0
end
#--------------------------------------------------------------------------
# ● 力量上升量
#--------------------------------------------------------------------------
def str_plus
return (innate? and innate_type <= 2) ? @str_f * sign(2) : 0
end
#--------------------------------------------------------------------------
# ● 灵巧上升量
#--------------------------------------------------------------------------
def dex_plus
return (innate? and innate_type <= 2) ? @dex_f * sign(3): 0
end
#--------------------------------------------------------------------------
# ● 速度上升量
#--------------------------------------------------------------------------
def agi_plus
return (innate? and innate_type <= 2) ? @agi_f * sign(4) : 0
end
#--------------------------------------------------------------------------
# ● 魔力上升量
#--------------------------------------------------------------------------
def int_plus
return (innate? and innate_type <= 2) ? @int_f * sign(5) : 0
end
#--------------------------------------------------------------------------
# ● 攻击力上升量
#--------------------------------------------------------------------------
def atk_plus
return (innate? and innate_type <= 2) ? @atk_f * sign(0) : 0
end
#--------------------------------------------------------------------------
# ● 防御力上升量
#--------------------------------------------------------------------------
def pdef_plus
return (innate? and innate_type <= 2) ? @pdef_f * sign(7) : 0
end
#--------------------------------------------------------------------------
# ● 魔防力上升量
#--------------------------------------------------------------------------
def mdef_plus
return (innate? and innate_type <= 2) ? @mdef_f * sign(8) : 0
end
#--------------------------------------------------------------------------
# ● 回避修正上升量
#--------------------------------------------------------------------------
def eva_plus
return (innate? and innate_type <= 2) ? @eva_f * sign(1) : 0
end
#--------------------------------------------------------------------------
# ● 属性防御上升量
# element_id : 属性ID
#--------------------------------------------------------------------------
def element_plus(element_id)
unless innate? and innate_type == 1
return 0
else
if @element_set.include?(element_id)
return Integer(@power * sign(-element_id))
else
return 0
end
end
end
#--------------------------------------------------------------------------
# ● 状态防御上升量
# state_id : 状态ID
#--------------------------------------------------------------------------
def state_plus(state_id)
unless innate? and innate_type == 2 and not sign(-1)
return 0
else
if @plus_state_set.include?(state_id)
return @power
elsif @minus_state_set.include?(state_id)
return -@power
else
return 0
end
end
end
#--------------------------------------------------------------------------
# ● 状态防御集合
#--------------------------------------------------------------------------
def guard_state_set
return (innate? and innate_type == 2 and sign(-1)) ? @minus_state_set : []
end
#--------------------------------------------------------------------------
# ● 自动状态集合
#--------------------------------------------------------------------------
def auto_states
return (innate? and innate_type == 2 and sign(-1)) ? @plus_state_set : []
end
end
end
#==============================================================================
# ■ Game_Actor (分割定义 2)
#------------------------------------------------------------------------------
# 处理角色的类。本类在 Game_Actors 类 ($game_actors)
# 的内部使用、Game_Party 类请参考 ($game_party) 。
#==============================================================================
class Game_Actor
#--------------------------------------------------------------------------
# ● 定义实例变量
#--------------------------------------------------------------------------
attr_reader :innate_skills # 被动特技
alias sailcat_setup setup
alias sailcat_learn_skill learn_skill
alias sailcat_forget_skill forget_skill
alias sailcat_base_maxhp base_maxhp
alias sailcat_base_maxsp base_maxsp
alias sailcat_base_str base_str
alias sailcat_base_dex base_dex
alias sailcat_base_agi base_agi
alias sailcat_base_int base_int
alias sailcat_base_atk base_atk
alias sailcat_base_pdef base_pdef
alias sailcat_base_mdef base_mdef
alias sailcat_base_eva base_eva
alias sailcat_element_rate element_rate
alias sailcat_state_guard? state_guard?
alias sailcat_hit hit
#--------------------------------------------------------------------------
# ● 设置
# actor_id : 角色 ID
#--------------------------------------------------------------------------
def setup(actor_id)
@innate_skills = []
sailcat_setup(actor_id)
end
#--------------------------------------------------------------------------
# ● 领悟特技
# skill_id : 特技 ID
#--------------------------------------------------------------------------
def learn_skill(skill_id)
sailcat_learn_skill(skill_id)
unless @innate_skills.include?(skill_id)
@innate_skills.push(skill_id)
@innate_skills.sort!
update_skill_state(nil, $data_skills[skill_id])
end
end
#--------------------------------------------------------------------------
# ● 遗忘特技
# skill_id : 特技 ID
#--------------------------------------------------------------------------
def forget_skill(skill_id)
sailcat_forget_skill(skill_id)
@innate_skills.delete(skill_id)
update_skill_state($data_skills[skill_id], nil)
end
#--------------------------------------------------------------------------
# ● 更新被动特技的自动状态
# old_skill : 去除的特技
# new_skill : 设定的特技
#--------------------------------------------------------------------------
def update_skill_state(old_skill, new_skill)
if old_skill != nil and old_skill.auto_states != []
for state in old_skill.auto_states
remove_state(state, true)
end
end
if new_skill != nil and new_skill.auto_states != []
for state in new_skill.auto_states
add_state(state, true)
end
end
end
#--------------------------------------------------------------------------
# ● 获取基本 MaxHP
#--------------------------------------------------------------------------
def base_maxhp
m = n = sailcat_base_maxhp
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.maxhp_plus : 0) / 100
end
return n
end
#--------------------------------------------------------------------------
# ● 获取基本 MaxSP
#--------------------------------------------------------------------------
def base_maxsp
m = n = sailcat_base_maxsp
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.maxsp_plus : 0) / 100
end
return n
end
#--------------------------------------------------------------------------
# ● 获取基本力量
#--------------------------------------------------------------------------
def base_str
m = n = sailcat_base_str
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.str_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本灵巧
#--------------------------------------------------------------------------
def base_dex
m = n = sailcat_base_dex
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.dex_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本速度
#--------------------------------------------------------------------------
def base_agi
m = n = sailcat_base_agi
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.agi_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本魔力
#--------------------------------------------------------------------------
def base_int
m = n = sailcat_base_int
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.int_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本攻击力
#--------------------------------------------------------------------------
def base_atk
m = n = sailcat_base_atk
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.atk_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本物理防御
#--------------------------------------------------------------------------
def base_pdef
m = n = sailcat_base_pdef
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.pdef_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本魔法防御
#--------------------------------------------------------------------------
def base_mdef
m = n = sailcat_base_mdef
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += m * (skill != nil ? skill.mdef_plus : 0) / 100
end
return [n, 999].min
end
#--------------------------------------------------------------------------
# ● 获取基本回避修正
#--------------------------------------------------------------------------
def base_eva
n = sailcat_base_eva
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n += skill != nil ? skill.eva_plus : 0
end
return [n, 100].min
end
#--------------------------------------------------------------------------
# ● 获取命中率
#--------------------------------------------------------------------------
def hit
n = sailcat_hit
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n = (skill != nil and skill.sign(12) == -1) ? 100 : n
end
return n
end
#--------------------------------------------------------------------------
# ● 判定防御状态
# state_id : 状态 ID
#--------------------------------------------------------------------------
def state_guard?(state_id)
n = sailcat_state_guard?(state_id)
for skill_id in @innate_skills
skill = $data_skills[skill_id]
n |= skill.guard_state_set.include?(state_id) if skill != nil
end
return n
end
#--------------------------------------------------------------------------
# ● 取得属性修正值
# element_id : 属性 ID
#--------------------------------------------------------------------------
def element_rate(element_id)
result = sailcat_element_rate(element_id)
for skill_id in @innate_skills
skill = $data_skills[skill_id]
if skill != nil
result -= skill.element_plus(element_id)
result = [[result, 300].min, -200].max
end
end
return result
end
#--------------------------------------------------------------------------
# ● 取得状态修正值
# state_id : 状态 ID
#--------------------------------------------------------------------------
def state_rate(state_id)
table = [0,100,80,60,40,20,0]
result = table[self.state_ranks[state_id]]
for skill_id in @innate_skills
skill = $data_skills[skill_id]
if skill != nil
result -= skill.state_plus(state_id)
result = [[result, 100].min, 0].max
end
end
return result
end
end
class Game_Battler
#--------------------------------------------------------------------------
# ● 状态变化 (+) 的适用
# plus_state_set : 状态变化 (+)
#--------------------------------------------------------------------------
def states_plus(plus_state_set)
# 清除有效标志
effective = false
# 循环 (附加状态)
for i in plus_state_set
# 无法防御本状态的情况下
unless self.state_guard?(i)
# 这个状态如果不是 full 的话就设置有效标志
effective |= self.state_full?(i) == false
# 状态为 [不能抵抗] 的情况下
if $data_states[i].nonresistance
# 设置状态变化标志
@state_changed = true
# 附加状态
add_state(i)
# 这个状态不是 full 的情况下
elsif self.state_full?(i) == false
# 将状态的有效度变换为概率、与随机数比较
if rand(100) < self.state_rate(i)
# 设置状态变化标志
@state_changed = true
# 附加状态
add_state(i)
end
end
end
end
# 过程结束
return effective
end
end
class Game_Enemy
#--------------------------------------------------------------------------
# ● 获取状态修正值
# state_id : 状态 ID
#--------------------------------------------------------------------------
def state_rate(state_id)
return [0,100,80,60,40,20,0][self.state_ranks[state_id]]
end
end
复制代码
怎么使用啊
作者:
qaz4633063
时间:
2010-9-1 01:01
提示:
作者被禁止或删除 内容自动屏蔽
作者:
气味123
时间:
2010-9-1 12:20
我要力量+魔力-怎么弄
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1