设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 1557|回复: 2
打印 上一主题 下一主题

[已经解决] 守护别人的技能

 关闭 [复制链接]

Lv3.寻梦者

梦石
1
星屑
3918
在线时间
592 小时
注册时间
2007-8-14
帖子
182
跳转到指定楼层
1
发表于 2011-8-21 22:21:32 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
想做一个技能,效果就是保护一名队友,这一回合该队友的伤害全部由此技能使用者承受。

是不是又要用到脚本啊?拜托各位了

ps.有段时间没来这了,如果格式什么的有哪里做错了请指正。
赞美灵魂……

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1071 小时
注册时间
2011-5-12
帖子
2317

贵宾

2
发表于 2011-8-22 06:09:20 | 只看该作者
用法:在数据库-里的状态页新建个状态备注加入protect,设定一个技能附加这个状态就行了~
  1. #                         Protect Skill v 1.2.3
  2. #                           by Kal
  3. #
  4. #                         ===== How to use =====
  5. #
  6. # Make a state that has the magic word in it's note box. When that state
  7. # is inflicted on an ally, the person who inflicted the state (by casting
  8. # a spell that adds the state, for example) will receive all the damage
  9. # that is done to the ally.
  10. #
  11. #                  ===== What battle system is this for? =====
  12. #         
  13. # The script was designed for the default battle system but it's also works
  14. # with Tankentai (and ATB). However, there is no animation support for
  15. # Tankentai at the moment (i.e. protector jumping in front of protectee) and
  16. # the damage numbers need to be fixed.
  17. #
  18. #                         ===== Version history =====
  19. #
  20. # 1.0 - Finished script
  21. #
  22. # 1.1   - Added message text configuration in the config module.
  23. #       - Status effect will be removed immediately after the protector dies
  24. #       - Fixed a bug where a dead protector would still protect under certain
  25. #         circumstances.
  26. #       - Fixed a bug where the protect message got drawn when it shouldn't.
  27. #
  28. # 1.2   - Added ability to increase/decrease the amount of damage a protector
  29. #         takes when protecting.
  30. #
  31. # 1.2.1 - Fixed using items on protector bug with Tankentai + ATB.
  32. #
  33. # 1.2.2 - Fixed a bug where you could not cast the state again after a battle.
  34. #
  35. # 1.2.3 - Fixed a bug with Tankentai + ATB where the protect state would not
  36. #         be removed when the protector died.

  37. module ProtectConfig
  38.   MAGIC_WORD           = "Protect"
  39.   # Add this word in the "Note" box for any status in order to enable protect
  40.   # for that status.
  41.   PROTECT_PHYSICAL     = true
  42.   PROTECT_SKILLS       = true
  43.   # Set these to true/false to enable/disable protection from physical damage
  44.   # and protection from skills damage.
  45.   PROTECT_LIMIT        = 2
  46.   # This is the number of allies one character can protect at the same time.
  47.   DAMAGE_EFFECT        = 100
  48.   # This is a percentage of damage the protector will take when protecting
  49.   # an ally. For example, if this value is set to 50, the protector will take
  50.   # half damage when protecting an ally.
  51.   MP_DAMAGE_EFFECT     = false
  52.   # Should DAMAGE_EFFECT apply to MP damage?
  53.   MESSAGE = lambda do |context|
  54.     eval "protector.name + ' protected ' + target.name + '!'", context
  55.     # Edit this line to change the message that is displayed when an actor
  56.     # protects an ally. protector.name is the protector's name and
  57.     # target.name is the protected ally's name. Any text you want to add
  58.     # needs to be in single quote strings, as above.
  59.     # Note: not working for Tankentai at the moment.
  60.   end
  61. end

  62. class RPG::State
  63.   attr_accessor :skill_user
  64.   
  65.   def protect?
  66.     set_protect if @protect.nil?
  67.     @protect
  68.   end
  69.   
  70.   def set_protect
  71.     if @note.downcase =~ /#{ProtectConfig::MAGIC_WORD.downcase}/
  72.       @protect = true
  73.     else
  74.       @protect = false
  75.     end
  76.   end
  77. end

  78. class Scene_Battle
  79.   unless $@
  80.     alias :kal_old_display_action_effects :display_action_effects
  81.     alias :kal_old_process_action :process_action
  82.   end

  83.   # NOTE: not being called at all with Tankentai and ATB. Fix?
  84.   def display_action_effects(target, obj = nil)
  85.     # If this is a physical attack (obj == nil) and PROTECT_PHYSICAL is false
  86.     if !ProtectConfig::PROTECT_PHYSICAL and obj.nil?
  87.       kal_old_display_action_effects(target, obj) # call original method and return
  88.       return
  89.     # If this is a skills attack and PROTECT_SKILLS is false
  90.     elsif !ProtectConfig::PROTECT_SKILLS and obj
  91.       kal_old_display_action_effects(target, obj) # call original method and return
  92.       return
  93.     end
  94.    
  95.     if target.protect?
  96.       protector = target.states.find { |state| state.protect? }.skill_user
  97.       protector.display_protect = true unless protector.dead?
  98.       if protector != @active_battler and protector.display_protect
  99.         protector.display_protect = false if protector.dead?
  100.         text = ProtectConfig::MESSAGE.call(binding)
  101.         @message_window.add_instant_text(text)
  102.         wait(30)
  103.         kal_old_display_action_effects(protector)
  104.         return
  105.       end
  106.     end
  107.    
  108.     kal_old_display_action_effects(target, obj)
  109.   end

  110.   # Check if any protector is dead after an action has been processed.
  111.   # If dead remove the state.
  112.   def process_action
  113.     kal_old_process_action
  114.     $game_party.members.each do |member|
  115.       member.states.each do |state|
  116.         if state.protect?
  117.           if state.skill_user.dead?
  118.             state.skill_user.protected_allies = 0
  119.             member.remove_state(state.id)
  120.             @status_window.refresh
  121.           end
  122.         end
  123.       end
  124.     end
  125.   end
  126. end

  127. class Game_Battler
  128.   attr_accessor :protected_allies, :display_protect, :protecting
  129.   
  130.   unless $@
  131.     alias :kal_old_initialize :initialize
  132.     alias :kal_old_make_attack_damage_value :make_attack_damage_value
  133.     alias :kal_old_add_state :add_state
  134.     alias :kal_old_skill_effect :skill_effect
  135.     alias :kal_old_make_obj_damage_value :make_obj_damage_value
  136.   end
  137.   
  138.   def initialize
  139.     @protected_allies = 0
  140.     @display_protect = true
  141.     @protecting = false
  142.     kal_old_initialize
  143.   end
  144.   
  145.   def make_attack_damage_value(attacker, effect = nil)
  146.     kal_old_make_attack_damage_value(attacker)
  147.     if ProtectConfig::PROTECT_PHYSICAL
  148.       states.each do |state|
  149.         if state.protect? and !state.skill_user.dead?
  150.           @hp_damage = 0
  151.           state.skill_user.protecting = true
  152.           state.skill_user.attack_effect(attacker)
  153.         end
  154.       end
  155.       if @protecting
  156.         @hp_damage *= (ProtectConfig::DAMAGE_EFFECT / 100)
  157.         @protecting = false
  158.       end
  159.     end
  160.   end
  161.   

  162.   def make_obj_damage_value(user, obj)
  163.     kal_old_make_obj_damage_value(user, obj)
  164.     if ProtectConfig::PROTECT_SKILLS and !$game_party.members.include?(user)
  165.       states.each do |state|
  166.         if state.protect? and !state.skill_user.dead?
  167.           @hp_damage = 0
  168.           @mp_damage = 0
  169.           state.skill_user.protecting = true
  170.           state.skill_user.skill_effect(user, obj)
  171.         end
  172.       end
  173.       if @protecting
  174.         @hp_damage *= (ProtectConfig::DAMAGE_EFFECT / 100)
  175.         @mp_damage *= (ProtectConfig::DAMAGE_EFFECT / 100) if ProtectConfig::MP_DAMAGE_EFFECT
  176.         @protecting = false
  177.       end
  178.     end
  179.   end

  180.   def add_state(state_id)
  181.     state = $data_states[state_id]
  182.     if state.protect?
  183.       state.skill_user = @skill_user
  184.       @skill_user.protected_allies += 1
  185.     end
  186.     kal_old_add_state(state_id)
  187.   end
  188.   
  189.   def skill_effect(user, skill)
  190.     @skill_user = user
  191.     kal_old_skill_effect(user, skill)
  192.   end
  193.   
  194.   def protect?
  195.     states.any? {|state| state.protect?}
  196.   end
  197. end

  198. class Game_Actor
  199.   alias :kal_old_state_resist? :state_resist? unless $@

  200.   def state_resist?(state_id)
  201.     # Prevent castng protect on self
  202.     if @skill_user == self and $data_states[state_id].protect?
  203.       return true
  204.     #  Prevent casting protect on a char that is already protected
  205.     elsif protect? and $data_states[state_id].protect?
  206.       return true
  207.     # Prevent casting protect if the protect limit is reached
  208.     elsif @skill_user.protected_allies >= ProtectConfig::PROTECT_LIMIT
  209.       return true
  210.     end
  211.     kal_old_state_resist?(state_id)
  212.   end
  213. end

  214. class Game_Party
  215.   alias :kal_old_remove_states_battle :remove_states_battle unless $@
  216.   
  217.   def remove_states_battle
  218.     kal_old_remove_states_battle
  219.     members.each do |actor|
  220.       actor.protected_allies = 0
  221.     end
  222.   end
  223. end
复制代码
找我请找芙蕾娅
顺带一提,完全看得懂我头像请捡起你自己的节操哟(自重
回复

使用道具 举报

Lv3.寻梦者

梦石
1
星屑
3918
在线时间
592 小时
注册时间
2007-8-14
帖子
182
3
 楼主| 发表于 2011-8-22 20:28:24 | 只看该作者
月夜神音 发表于 2011-8-22 06:09
用法:在数据库-里的状态页新建个状态备注加入protect,设定一个技能附加这个状态就行了~ ...

成功了~~万岁~~感谢帮助~~
赞美灵魂……
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2025-1-10 11:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表