Project1
标题:
守护别人的技能
[打印本页]
作者:
cryhades
时间:
2011-8-21 22:21
标题:
守护别人的技能
想做一个技能,效果就是保护一名队友,这一回合该队友的伤害全部由此技能使用者承受。
是不是又要用到脚本啊?拜托各位了
ps.有段时间没来这了,如果格式什么的有哪里做错了请指正。 dsu_plus_rewardpost_czw
作者:
月夜神音
时间:
2011-8-22 06:09
用法:在数据库-里的状态页新建个状态备注加入protect,设定一个技能附加这个状态就行了~
# Protect Skill v 1.2.3
# by Kal
#
# ===== How to use =====
#
# Make a state that has the magic word in it's note box. When that state
# is inflicted on an ally, the person who inflicted the state (by casting
# a spell that adds the state, for example) will receive all the damage
# that is done to the ally.
#
# ===== What battle system is this for? =====
#
# The script was designed for the default battle system but it's also works
# with Tankentai (and ATB). However, there is no animation support for
# Tankentai at the moment (i.e. protector jumping in front of protectee) and
# the damage numbers need to be fixed.
#
# ===== Version history =====
#
# 1.0 - Finished script
#
# 1.1 - Added message text configuration in the config module.
# - Status effect will be removed immediately after the protector dies
# - Fixed a bug where a dead protector would still protect under certain
# circumstances.
# - Fixed a bug where the protect message got drawn when it shouldn't.
#
# 1.2 - Added ability to increase/decrease the amount of damage a protector
# takes when protecting.
#
# 1.2.1 - Fixed using items on protector bug with Tankentai + ATB.
#
# 1.2.2 - Fixed a bug where you could not cast the state again after a battle.
#
# 1.2.3 - Fixed a bug with Tankentai + ATB where the protect state would not
# be removed when the protector died.
module ProtectConfig
MAGIC_WORD = "Protect"
# Add this word in the "Note" box for any status in order to enable protect
# for that status.
PROTECT_PHYSICAL = true
PROTECT_SKILLS = true
# Set these to true/false to enable/disable protection from physical damage
# and protection from skills damage.
PROTECT_LIMIT = 2
# This is the number of allies one character can protect at the same time.
DAMAGE_EFFECT = 100
# This is a percentage of damage the protector will take when protecting
# an ally. For example, if this value is set to 50, the protector will take
# half damage when protecting an ally.
MP_DAMAGE_EFFECT = false
# Should DAMAGE_EFFECT apply to MP damage?
MESSAGE = lambda do |context|
eval "protector.name + ' protected ' + target.name + '!'", context
# Edit this line to change the message that is displayed when an actor
# protects an ally. protector.name is the protector's name and
# target.name is the protected ally's name. Any text you want to add
# needs to be in single quote strings, as above.
# Note: not working for Tankentai at the moment.
end
end
class RPG::State
attr_accessor :skill_user
def protect?
set_protect if @protect.nil?
@protect
end
def set_protect
if @note.downcase =~ /#{ProtectConfig::MAGIC_WORD.downcase}/
@protect = true
else
@protect = false
end
end
end
class Scene_Battle
unless $@
alias :kal_old_display_action_effects :display_action_effects
alias :kal_old_process_action :process_action
end
# NOTE: not being called at all with Tankentai and ATB. Fix?
def display_action_effects(target, obj = nil)
# If this is a physical attack (obj == nil) and PROTECT_PHYSICAL is false
if !ProtectConfig::PROTECT_PHYSICAL and obj.nil?
kal_old_display_action_effects(target, obj) # call original method and return
return
# If this is a skills attack and PROTECT_SKILLS is false
elsif !ProtectConfig::PROTECT_SKILLS and obj
kal_old_display_action_effects(target, obj) # call original method and return
return
end
if target.protect?
protector = target.states.find { |state| state.protect? }.skill_user
protector.display_protect = true unless protector.dead?
if protector != @active_battler and protector.display_protect
protector.display_protect = false if protector.dead?
text = ProtectConfig::MESSAGE.call(binding)
@message_window.add_instant_text(text)
wait(30)
kal_old_display_action_effects(protector)
return
end
end
kal_old_display_action_effects(target, obj)
end
# Check if any protector is dead after an action has been processed.
# If dead remove the state.
def process_action
kal_old_process_action
$game_party.members.each do |member|
member.states.each do |state|
if state.protect?
if state.skill_user.dead?
state.skill_user.protected_allies = 0
member.remove_state(state.id)
@status_window.refresh
end
end
end
end
end
end
class Game_Battler
attr_accessor :protected_allies, :display_protect, :protecting
unless $@
alias :kal_old_initialize :initialize
alias :kal_old_make_attack_damage_value :make_attack_damage_value
alias :kal_old_add_state :add_state
alias :kal_old_skill_effect :skill_effect
alias :kal_old_make_obj_damage_value :make_obj_damage_value
end
def initialize
@protected_allies = 0
@display_protect = true
@protecting = false
kal_old_initialize
end
def make_attack_damage_value(attacker, effect = nil)
kal_old_make_attack_damage_value(attacker)
if ProtectConfig::PROTECT_PHYSICAL
states.each do |state|
if state.protect? and !state.skill_user.dead?
@hp_damage = 0
state.skill_user.protecting = true
state.skill_user.attack_effect(attacker)
end
end
if @protecting
@hp_damage *= (ProtectConfig::DAMAGE_EFFECT / 100)
@protecting = false
end
end
end
def make_obj_damage_value(user, obj)
kal_old_make_obj_damage_value(user, obj)
if ProtectConfig::PROTECT_SKILLS and !$game_party.members.include?(user)
states.each do |state|
if state.protect? and !state.skill_user.dead?
@hp_damage = 0
@mp_damage = 0
state.skill_user.protecting = true
state.skill_user.skill_effect(user, obj)
end
end
if @protecting
@hp_damage *= (ProtectConfig::DAMAGE_EFFECT / 100)
@mp_damage *= (ProtectConfig::DAMAGE_EFFECT / 100) if ProtectConfig::MP_DAMAGE_EFFECT
@protecting = false
end
end
end
def add_state(state_id)
state = $data_states[state_id]
if state.protect?
state.skill_user = @skill_user
@skill_user.protected_allies += 1
end
kal_old_add_state(state_id)
end
def skill_effect(user, skill)
@skill_user = user
kal_old_skill_effect(user, skill)
end
def protect?
states.any? {|state| state.protect?}
end
end
class Game_Actor
alias :kal_old_state_resist? :state_resist? unless $@
def state_resist?(state_id)
# Prevent castng protect on self
if @skill_user == self and $data_states[state_id].protect?
return true
# Prevent casting protect on a char that is already protected
elsif protect? and $data_states[state_id].protect?
return true
# Prevent casting protect if the protect limit is reached
elsif @skill_user.protected_allies >= ProtectConfig::PROTECT_LIMIT
return true
end
kal_old_state_resist?(state_id)
end
end
class Game_Party
alias :kal_old_remove_states_battle :remove_states_battle unless $@
def remove_states_battle
kal_old_remove_states_battle
members.each do |actor|
actor.protected_allies = 0
end
end
end
复制代码
作者:
cryhades
时间:
2011-8-22 20:28
月夜神音 发表于 2011-8-22 06:09
用法:在数据库-里的状态页新建个状态备注加入protect,设定一个技能附加这个状态就行了~ ...
成功了~~万岁~~感谢帮助~~
欢迎光临 Project1 (https://rpg.blue/)
Powered by Discuz! X3.1