Project1

标题: 如何制作一个防御结界 [打印本页]

作者: tsukiyin    时间: 2010-7-26 01:54
提示: 作者被禁止或删除 内容自动屏蔽
作者: tsukiyin    时间: 2010-7-26 17:47
提示: 作者被禁止或删除 内容自动屏蔽
作者: moy    时间: 2010-7-26 17:54
用状态法,检测到某状态以后被攻击就扣1点某变量值.到零就状态消失,应该可以.
状态法在6R搜应该能搜到.
作者: tsukiyin    时间: 2010-7-26 18:10
提示: 作者被禁止或删除 内容自动屏蔽
作者: 无心孤云    时间: 2010-7-26 18:19
传说中有种东西可以用来记录。那种东西叫变量。。。楼主看看新手教程吧
作者: tsukiyin    时间: 2010-7-26 20:45
提示: 作者被禁止或删除 内容自动屏蔽
作者: SOU    时间: 2010-7-27 00:18
就是说,在事件里制作条件分歧
当 某某角色 有 防御结界 状态时
防御次数+1
当某某角色 防御次数 = XX时
状态解除
计数归零
作者: 无心孤云    时间: 2010-7-27 00:21
为何我让楼主看教程楼主就是不信呢。。
作者: 九夜神尊    时间: 2010-7-27 01:48
只能说楼主是一个绝对的伸手党
作者: 逸豫    时间: 2010-7-27 11:49
乃们表打击人家嘛!
于是说怎么判定敌人做了攻击?不用脚本貌似没有办法吧……
(用两个变量记录HP之类不算= =|||)
不去思考就认为别人是SSD实在太讨厌了……
在Game_Battler 3的attack_effect方法的最底下(94~95行左右)添加
  1.     if self.is_a?(Game_Actor) && hit_result
  2.       $game_variables[self.id+20] += 1
  3.     end
复制代码
这样的话20+角色id号变量即为角色被攻击次数
作者: zhangbanxian    时间: 2010-7-27 13:54
  1. #==============================================================================
  2. # Absolute_Defense v1.0
  3. #--
  4. # Author: Kread-EX
  5. #==============================================================================
  6. # INTRODUCTION
  7. # Absolute Defense is a technique used in the game Breath of Fire V (Ps2).
  8. # It allows to nullify damage inflicted by the user under a set value.
  9. # Technically, you must spam your best attacks in order to wound the big tank who use this.
  10. # IMPORTANT NOTE
  11. # Absolute Defense protect only from HP damage. Not from eventual SP damage or status ailments.
  12. # HOW TO USE
  13. # Just copy this and paste above Main.
  14. # Then follow the configuration steps.
  15. # COMPATIBILITY
  16. # Very low compatibility with any script which modify Game_Battler, Sprite_Battler or Scene_Battle (this was one of my very first script, be indulgent).
  17. # I suggest to NOT make 2 enemies in the same group using Absolute Degense
  18. # Actors can't use this because this would unbalance the game.
  19. # Work with the DBS and turn-based CBS. You shouldn't use this with ATB or RTAB. Maybe CTB, but I'm not sure.
  20. # Will clash with custom damage displays.
  21. #==============================================================================
  22. # Configuration part
  23. #==============================================================================
  24. module KreadCFG
  25. # Ids of enemies using Absolute Defense
  26. ENEMIES_IDS = [1,5]
  27. # Value of the Absolute Defense. The order MUST match the order inside the ENEMIES_ID
  28. ABSOLUTE_VALUES = [80,650]
  29. # Number of turns before the Absolute Defense is recharged. Then again, the order must match ENEMIES_ID
  30. REFRESH_RATE = [1,3]
  31. # ID of the animation used when the defense is active (leave to 0 for no animation)
  32. FULL_ANIM_ID = 0
  33. # ID of the animation used when the defense breaks (leave to 0 for no animation)
  34. BREAK_ANIM_ID = 0
  35. end
  36. #==============================================================================
  37. # Game_Enemy
  38. #==============================================================================
  39. class Game_Enemy < Game_Battler
  40.   #------------------------------------
  41.   # Public instance variables
  42.   #------------------------------------
  43.   attr_accessor :absolute_defense_break
  44.   attr_accessor :absolute_defense_value
  45.   attr_accessor :absolute_defense_refresh_rate
  46.   #------------------------------------
  47.   # Object initialization
  48.   #------------------------------------
  49.   alias orig_enemy_init initialize
  50.   def initialize(troop_id, member_index)
  51.     orig_enemy_init(troop_id, member_index)
  52.     unless KreadCFG::ENEMIES_IDS.include?(self.id)
  53.       @absolute_defense_break = false
  54.       @absolute_defense_value = 0
  55.       @absolute_defense_refresh_rate = 0
  56.       return
  57.     end
  58.    #Les variables d'instances prennent les valeurs des constantes.
  59.    index = KreadCFG::ENEMIES_IDS.index(self.id)
  60.    @absolute_defense_break = false
  61.    @absolute_defense_value = KreadCFG::ABSOLUTE_VALUES[index]
  62.    @absolute_defense_refresh_rate = KreadCFG::REFRESH_RATE[index]
  63. end
  64. end
  65. #==============================================================================
  66. # Game_Battler
  67. #==============================================================================
  68. class Game_Battler
  69.   #------------------------------------
  70.   # Apply normal attack effect
  71.   #------------------------------------
  72.   alias krx_absdef_attack_effect attack_effect
  73.   def attack_effect(attacker)
  74.     if self.class == Game_Actor or self.absolute_defense_value == 0
  75.       return krx_absdef_attack_effect(attacker)
  76.     end
  77.     last_hp = self.hp
  78.     result = krx_absdef_attack_effect(attacker)
  79.     if self.damage.is_a?(Numeric) and self.damage >= self.absolute_defense_value and self.damage > 0
  80.       last_damage = self.damage
  81.       self.damage = [self.damage - self.absolute_defense_value, 0].max
  82.       self.absolute_defense_break = true
  83.       self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max
  84.       self.hp = last_hp - self.damage
  85.     elsif self.damage.is_a?(Numeric) and self.damage > 0
  86.       self.absolute_defense_value -= self.damage
  87.       self.hp = last_hp
  88.       self.damage = '-' + self.absolute_defense_value.to_s
  89.     end
  90.     return result
  91.   end
  92.   #------------------------------------
  93.   # Apply skill effect
  94.   #------------------------------------
  95.   alias krx_absdef_skill_effect skill_effect
  96.   def skill_effect(user,skill)
  97.     if self.class == Game_Actor or self.absolute_defense_value == 0
  98.       return krx_absdef_skill_effect(user,skill)
  99.     end
  100.     last_hp = self.hp
  101.     result = krx_absdef_skill_effect(user,skill)
  102.     if self.damage.class == Numeric and self.damage >= self.absolute_defense_value and
  103.       self.damage > 0
  104.       last_damage = self.damage
  105.       self.damage = [self.damage - self.absolute_defense_value, 0].max
  106.       self.absolute_defense_break = true
  107.       self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max
  108.       self.hp = last_hp - self.damage
  109.     elsif self.damage.class == Numeric and self.damage > 0
  110.       self.absolute_defense_value -= self.damage
  111.       self.damage = '-' + self.absolute_defense_value.to_s
  112.     end
  113.     return result
  114.   end
  115.   #------------------------------------
  116.   # Apply item effect
  117.   #------------------------------------
  118.   alias krx_absdef_item_effect item_effect
  119.   def item_effect(user,item)
  120.     if self.class == Game_Actor or self.absolute_defense_value == 0
  121.       return krx_absdef_item_effect(user,item)
  122.     end
  123.     last_hp = self.hp
  124.     result = krx_absdef_item_effect(user,item)
  125.     if self.damage.class == Numeric and self.damage >= self.absolute_defense_value and
  126.       self.damage > 0
  127.       last_damage = self.damage
  128.       self.damage = [self.damage - self.absolute_defense_value, 0].max
  129.       self.absolute_defense_break = true
  130.       self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max
  131.       self.hp = last_hp - self.damage
  132.     elsif self.damage.class == Numeric and self.damage > 0
  133.       self.absolute_defense_value -= self.damage
  134.       self.damage = '-' + self.absolute_defense_value.to_s
  135.     end
  136.     return result
  137.   end
  138. end
  139. #==============================================================================
  140. # Game_Battler
  141. #==============================================================================
  142. class Sprite_Battler
  143.   #------------------------------------
  144.   # Display damage
  145.   #------------------------------------
  146.   def damage(value, critical)
  147.    dispose_damage
  148.    if value.is_a?(Numeric)
  149.      damage_string = value.abs.to_s
  150.    else
  151.      damage_string = value.to_s
  152.    end
  153.    bitmap = Bitmap.new(160, 48)
  154.    bitmap.font.name = 'Arial Black'
  155.    bitmap.font.size = 32
  156.    bitmap.font.color.set(0, 0, 0)
  157.    bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
  158.    bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
  159.    bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
  160.    bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
  161.    if value.is_a?(Numeric) and value < 0
  162.      bitmap.font.color.set(176, 255, 144)
  163.    elsif value.is_a?(String) and value.include?('-') and @battler.absolute_defense_value > 0 and not @battler.absolute_defense_break
  164.      @battler.animation_id = KreadCFG::FULL_ANIM_ID
  165.      bitmap.font.color.set(230, 230, 75)
  166.    elsif @battler.class == Game_Enemy and @battler.absolute_defense_break
  167.      @battler.animation_id = KreadCFG::BREAK_ANIM_ID
  168.      @battler.absolute_defense_break = false
  169.      bitmap.font.color.set(255, 255, 255)
  170.    else
  171.      @battler_animation_id = 0
  172.      bitmap.font.color.set(255, 255, 255)
  173.    end
  174.    bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
  175.    if critical
  176.      bitmap.font.size = 20
  177.      bitmap.font.color.set(0, 0, 0)
  178.      bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
  179.      bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
  180.      bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
  181.      bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
  182.      bitmap.font.color.set(255, 255, 255)
  183.      bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
  184.    end
  185.    @_damage_sprite = ::Sprite.new(self.viewport)
  186.    @_damage_sprite.bitmap = bitmap
  187.    @_damage_sprite.ox = 80
  188.    @_damage_sprite.oy = 20
  189.    @_damage_sprite.x = self.x
  190.    @_damage_sprite.y = self.y - self.oy / 2
  191.    @_damage_sprite.z = 3000
  192.    @_damage_duration = 40
  193. end
  194. end
  195. #==============================================================================
  196. # Scene_Battle
  197. #==============================================================================
  198. class Scene_Battle
  199.   #------------------------------------
  200.   # Alias the phase 1
  201.   #------------------------------------
  202.   alias krx_absdef_start_phase1 start_phase1
  203.   def start_phase1
  204.     @ad_count = {}
  205.     $game_troop.enemies.each do |enemy|
  206.       @ad_count[enemy.index] = enemy.absolute_defense_refresh_rate
  207.     end
  208.     krx_absdef_start_phase1
  209.   end
  210.   #------------------------------------
  211.   # Alias the step 6 of phase 4
  212.   #------------------------------------
  213.   alias krx_absdef_update_step6 update_phase4_step6
  214.   def update_phase4_step6
  215.     if @active_battler.is_a?(Game_Enemy) and @active_battler.movable?
  216.       @ad_count[@active_battler.index] -= 1
  217.       if @ad_count[@active_battler.index] == 0
  218.         @ad_count[@active_battler.index] = @active_battler.absolute_defense_refresh_rate
  219.         r_index = KreadCFG::ENEMIES_IDS.index(@active_battler.id)
  220.         @active_battler.absolute_defense_value = KreadCFG::ABSOLUTE_VALUES[r_index]
  221.       end
  222.     end
  223.     krx_absdef_update_step6
  224.   end
  225. end
复制代码

作者: tsukiyin    时间: 2010-7-27 15:45
提示: 作者被禁止或删除 内容自动屏蔽




欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1