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

Project1

 找回密码
 注册会员
搜索
12
返回列表 发新帖
楼主: tsukiyin
打印 上一主题 下一主题

[已经解决] 如何制作一个防御结界

[复制链接]

Lv1.梦旅人

梦石
0
星屑
50
在线时间
270 小时
注册时间
2010-2-4
帖子
1305
11
发表于 2010-7-27 13:54:39 | 只看该作者
  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
复制代码
好歹当年也当过大魔王过,orz
回复 支持 反对

使用道具 举报

头像被屏蔽

Lv1.梦旅人 (禁止发言)

梦石
0
星屑
50
在线时间
3 小时
注册时间
2010-6-14
帖子
65
12
 楼主| 发表于 2010-7-27 15:45:23 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

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

本版积分规则

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

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

GMT+8, 2024-12-28 15:50

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

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