Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Closed TopicStart new topic
> Absolute Defense, BOF 5 style
Kread-EX
post Mar 18 2010, 09:08 AM
Post #1


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




Absolute Defense

Version: 1.0
Author: Kread-EX

Introduction

You never know what you can find when plugging an old hard drive you don't use since 5 years. And what did I find ? Oooh... this script.
This takes us back to the dawn of RMXP - a time when only DynaEmu's was the only existing English version !
In other words, this is one of my very first scripts. Well, let's go back on topic:

Absolute Defense is a technique used in the game Breath of Fire V (Ps2).
It allows to nullify damage inflicted by the user under a set value.
Technically, you must spam your best attacks in order to wound the big tank who use this.

Script

[Show/Hide] Spoiled for your browsing pleasure.
CODE
#==============================================================================
# Absolute_Defense v1.0
#------------------------------------------------------------------------------
# Author: Kread-EX
#==============================================================================

# INTRODUCTION
# Absolute Defense is a technique used in the game Breath of Fire V (Ps2).
# It allows to nullify damage inflicted by the user under a set value.
# Technically, you must spam your best attacks in order to wound the big tank who use this.

# IMPORTANT NOTE
# Absolute Defense protect only from HP damage. Not from eventual SP damage or status ailments.

# HOW TO USE
# Just copy this and paste above Main.
# Then follow the configuration steps.

# COMPATIBILITY
# 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).
# I suggest to NOT make 2 enemies in the same group using Absolute Degense
# Actors can't use this because this would unbalance the game.
# Work with the DBS and turn-based CBS. You shouldn't use this with ATB or RTAB. Maybe CTB, but I'm not sure.
# Will clash with custom damage displays.

#==============================================================================
# Configuration part
#==============================================================================
module KreadCFG

# Ids of enemies using Absolute Defense
ENEMIES_IDS = [1,5]

# Value of the Absolute Defense. The order MUST match the order inside the ENEMIES_ID
ABSOLUTE_VALUES = [80,650]

# Number of turns before the Absolute Defense is recharged. Then again, the order must match ENEMIES_ID
REFRESH_RATE = [1,3]

# ID of the animation used when the defense is active (leave to 0 for no animation)
FULL_ANIM_ID = 0

# ID of the animation used when the defense breaks (leave to 0 for no animation)
BREAK_ANIM_ID = 0

end

#==============================================================================
# Game_Enemy
#==============================================================================
class Game_Enemy < Game_Battler
  #--------------------------------------------------------------------------
  # Public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :absolute_defense_break
  attr_accessor :absolute_defense_value
  attr_accessor :absolute_defense_refresh_rate
  #--------------------------------------------------------------------------
  # Object initialization
  #--------------------------------------------------------------------------
  alias orig_enemy_init initialize
  def initialize(troop_id, member_index)
    orig_enemy_init(troop_id, member_index)
    unless KreadCFG::ENEMIES_IDS.include?(self.id)
      @absolute_defense_break = false
      @absolute_defense_value = 0
      @absolute_defense_refresh_rate = 0
      return
    end
   #Les variables d'instances prennent les valeurs des constantes.
   index = KreadCFG::ENEMIES_IDS.index(self.id)
   @absolute_defense_break = false
   @absolute_defense_value = KreadCFG::ABSOLUTE_VALUES[index]
   @absolute_defense_refresh_rate = KreadCFG::REFRESH_RATE[index]
end
end

#==============================================================================
# Game_Battler
#==============================================================================
class Game_Battler
  #--------------------------------------------------------------------------
  # Apply normal attack effect
  #--------------------------------------------------------------------------
  alias krx_absdef_attack_effect attack_effect
  def attack_effect(attacker)
    if self.class == Game_Actor or self.absolute_defense_value == 0
      return krx_absdef_attack_effect(attacker)
    end
    last_hp = self.hp
    result = krx_absdef_attack_effect(attacker)
    if self.damage.is_a?(Numeric) and self.damage >= self.absolute_defense_value and self.damage > 0
      last_damage = self.damage
      self.damage = [self.damage - self.absolute_defense_value, 0].max
      self.absolute_defense_break = true
      self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max
      self.hp = last_hp - self.damage
    elsif self.damage.is_a?(Numeric) and self.damage > 0
      self.absolute_defense_value -= self.damage
      self.hp = last_hp
      self.damage = '-' + self.absolute_defense_value.to_s
    end
    return result
  end
  #--------------------------------------------------------------------------
  # Apply skill effect
  #--------------------------------------------------------------------------
  alias krx_absdef_skill_effect skill_effect
  def skill_effect(user,skill)
    if self.class == Game_Actor or self.absolute_defense_value == 0
      return krx_absdef_skill_effect(user,skill)
    end
    last_hp = self.hp
    result = krx_absdef_skill_effect(user,skill)
    if self.damage.class == Numeric and self.damage >= self.absolute_defense_value and
      self.damage > 0
      last_damage = self.damage
      self.damage = [self.damage - self.absolute_defense_value, 0].max
      self.absolute_defense_break = true
      self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max
      self.hp = last_hp - self.damage
    elsif self.damage.class == Numeric and self.damage > 0
      self.absolute_defense_value -= self.damage
      self.damage = '-' + self.absolute_defense_value.to_s
    end
    return result
  end
  #--------------------------------------------------------------------------
  # Apply item effect
  #--------------------------------------------------------------------------
  alias krx_absdef_item_effect item_effect
  def item_effect(user,item)
    if self.class == Game_Actor or self.absolute_defense_value == 0
      return krx_absdef_item_effect(user,item)
    end
    last_hp = self.hp
    result = krx_absdef_item_effect(user,item)
    if self.damage.class == Numeric and self.damage >= self.absolute_defense_value and
      self.damage > 0
      last_damage = self.damage
      self.damage = [self.damage - self.absolute_defense_value, 0].max
      self.absolute_defense_break = true
      self.absolute_defense_value = [self.absolute_defense_value - last_damage, 0].max
      self.hp = last_hp - self.damage
    elsif self.damage.class == Numeric and self.damage > 0
      self.absolute_defense_value -= self.damage
      self.damage = '-' + self.absolute_defense_value.to_s
    end
    return result
  end
end

#==============================================================================
# Game_Battler
#==============================================================================
class Sprite_Battler
  #--------------------------------------------------------------------------
  # Display damage
  #--------------------------------------------------------------------------
  def damage(value, critical)
   dispose_damage
   if value.is_a?(Numeric)
     damage_string = value.abs.to_s
   else
     damage_string = value.to_s
   end
   bitmap = Bitmap.new(160, 48)
   bitmap.font.name = 'Arial Black'
   bitmap.font.size = 32
   bitmap.font.color.set(0, 0, 0)
   bitmap.draw_text(-1, 12-1, 160, 36, damage_string, 1)
   bitmap.draw_text(+1, 12-1, 160, 36, damage_string, 1)
   bitmap.draw_text(-1, 12+1, 160, 36, damage_string, 1)
   bitmap.draw_text(+1, 12+1, 160, 36, damage_string, 1)
   if value.is_a?(Numeric) and value < 0
     bitmap.font.color.set(176, 255, 144)
   elsif value.is_a?(String) and value.include?('-') and @battler.absolute_defense_value > 0 and not @battler.absolute_defense_break
     @battler.animation_id = KreadCFG::FULL_ANIM_ID
     bitmap.font.color.set(230, 230, 75)
   elsif @battler.class == Game_Enemy and @battler.absolute_defense_break
     @battler.animation_id = KreadCFG::BREAK_ANIM_ID
     @battler.absolute_defense_break = false
     bitmap.font.color.set(255, 255, 255)
   else
     @battler_animation_id = 0
     bitmap.font.color.set(255, 255, 255)
   end
   bitmap.draw_text(0, 12, 160, 36, damage_string, 1)
   if critical
     bitmap.font.size = 20
     bitmap.font.color.set(0, 0, 0)
     bitmap.draw_text(-1, -1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(+1, -1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(-1, +1, 160, 20, "CRITICAL", 1)
     bitmap.draw_text(+1, +1, 160, 20, "CRITICAL", 1)
     bitmap.font.color.set(255, 255, 255)
     bitmap.draw_text(0, 0, 160, 20, "CRITICAL", 1)
   end
   @_damage_sprite = ::Sprite.new(self.viewport)
   @_damage_sprite.bitmap = bitmap
   @_damage_sprite.ox = 80
   @_damage_sprite.oy = 20
   @_damage_sprite.x = self.x
   @_damage_sprite.y = self.y - self.oy / 2
   @_damage_sprite.z = 3000
   @_damage_duration = 40
end
end

#==============================================================================
# Scene_Battle
#==============================================================================
class Scene_Battle
  #--------------------------------------------------------------------------
  # Alias the phase 1
  #--------------------------------------------------------------------------
  alias krx_absdef_start_phase1 start_phase1
  def start_phase1
    @ad_count = {}
    $game_troop.enemies.each do |enemy|
      @ad_count[enemy.index] = enemy.absolute_defense_refresh_rate
    end
    krx_absdef_start_phase1
  end
  #--------------------------------------------------------------------------
  # Alias the step 6 of phase 4
  #--------------------------------------------------------------------------
  alias krx_absdef_update_step6 update_phase4_step6
  def update_phase4_step6
    if @active_battler.is_a?(Game_Enemy) and @active_battler.movable?
      @ad_count[@active_battler.index] -= 1
      if @ad_count[@active_battler.index] == 0
        @ad_count[@active_battler.index] = @active_battler.absolute_defense_refresh_rate
        r_index = KreadCFG::ENEMIES_IDS.index(@active_battler.id)
        @active_battler.absolute_defense_value = KreadCFG::ABSOLUTE_VALUES[r_index]
      end
    end
    krx_absdef_update_step6
  end
end


Compatibility

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).
I suggest to NOT make 2 enemies in the same group using Absolute Degense
Actors can't use this because this would unbalance the game.
Work with the DBS and turn-based CBS. You shouldn't use this with ATB or RTAB. Maybe CTB, but I'm not sure.
Will clash with custom damage displays.

Installation

Just copy this and paste above Main.
Then follow the configuration steps.

Terms and Conditions

Use this as you see fit, as long as you credit me. Even for a commercial project, I do not care.
Redistribute the script however you like, but please keep the script header.

Additional info

If you want to use this with a CBS other than ATB or RTAB, you can ask and I will adapt it.
Same goes with custom damage displays.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Bigace
post Oct 24 2010, 01:49 PM
Post #2


The King of Spades
Group Icon

Group: Revolutionary
Posts: 400
Type: Developer
RM Skill: Intermediate




Hey Kread-EX, I need help adopting your script with Enu's Sidebattle system, because both scripts Sprite_Battler's clash and this error appears after I attack:

CODE
Script '*Sideview 1' line 210: ArgumentError occurred.

Wrong number of arguments(3 for 2)


Here's the battle system: Enu Sideview Battle System




__________________________



Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

QUOTE ('Exiled One')
"If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others."
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Oct 25 2010, 04:43 AM
Post #3


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




...wow. Somebody actually wants to use this thing? I'm really surprised.

Anyway, I'll see what the problem is. Give me a day or two - Tankentai is a living nightmare to work with.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Bigace
post Oct 25 2010, 01:22 PM
Post #4


The King of Spades
Group Icon

Group: Revolutionary
Posts: 400
Type: Developer
RM Skill: Intermediate




QUOTE (Kread-EX @ Oct 25 2010, 08:43 AM) *
...wow. Somebody actually wants to use this thing? I'm really surprised.

Anyway, I'll see what the problem is. Give me a day or two - Tankentai is a living nightmare to work with.


Lol, I was searching the database for scripts and found this niffty add-on. When I look, it was kind of strange that no one posted in this. Whether people like this script or not is a mystery, but once you can get it compatible, this would be a great addition to some boss fights.

Also true, Tankentai XP is really wierd sometimes.


__________________________



Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

QUOTE ('Exiled One')
"If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others."
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Oct 26 2010, 06:05 AM
Post #5


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




So, you'll have to replace the damage method in my script by this one:
Clicky
CODE
def damage(value, critical, sp_damage = nil)
    dispose_damage(0...@_damage_durations.size)
    @_damage_sprites = []
    if value.is_a?(Numeric)
      damage_string = value.abs.to_s
    else
      damage_string = value.to_s
    end
    @damage_size = 1 if !MULTI_POP
    @damage_size = damage_string.size if MULTI_POP
    for i in 0...@damage_size
      letter = damage_string[i..i] if MULTI_POP
      letter = damage_string if !MULTI_POP
      bitmap = Bitmap.new(160, 48)
      bitmap.font.name = DAMAGE_FONT
      bitmap.font.size = DMG_F_SIZE
      bitmap.font.color.set(0, 0, 0)
      bitmap.draw_text(-1, 12-1,160, 36, letter, 1)
      bitmap.draw_text(+1, 12-1,160, 36, letter, 1)
      bitmap.draw_text(-1, 12+1,160, 36, letter, 1)
      bitmap.draw_text(+1, 12+1,160, 36, letter, 1)
      if value.is_a?(Numeric) and value < 0
        bitmap.font.color.set(HP_REC_COLOR[0],HP_REC_COLOR[1],HP_REC_COLOR[2]) if !sp_damage
        bitmap.font.color.set(SP_REC_COLOR[0],SP_REC_COLOR[1],SP_REC_COLOR[2]) if sp_damage
      elsif value.is_a?(String) and value.include?('-') and @battler.absolute_defense_value > 0 and not
      @battler.absolute_defense_break
        @battler.animation_id = KreadCFG::FULL_ANIM_ID unless KreadCFG::FULL_ANIM_ID == 0
        bitmap.font.color.set(230, 230, 75)
      elsif @battler.is_a?(Game_Enemy) and @battler.absolute_defense_break
         @battler.absolute_defense_break = false
         bitmap.font.color.set(255, 255, 255)
      else
        bitmap.font.color.set(HP_DMG_COLOR[0],HP_DMG_COLOR[1],HP_DMG_COLOR[2]) if !sp_damage
        bitmap.font.color.set(SP_DMG_COLOR[0],SP_DMG_COLOR[1],SP_DMG_COLOR[2]) if sp_damage
        bitmap.font.color.set(CRT_DMG_COLOR[0],CRT_DMG_COLOR[1],CRT_DMG_COLOR[2]) if critical
      end
      bitmap.draw_text(0, 12,160, 36, letter, 1)
      if critical and CRITIC_TEXT and i == 0
        x_pop = (MULTI_POP ? (damage_string.size - 1) * (DMG_SPACE / 2) : 0)
        bitmap.font.size = ((DMG_F_SIZE * 2) / 3).to_i
        bitmap.font.color.set(0, 0, 0)
        bitmap.draw_text(-1 + x_pop, -1, 160, 20, POP_CRI, 1)
        bitmap.draw_text(+1 + x_pop, -1, 160, 20, POP_CRI, 1)
        bitmap.draw_text(-1 + x_pop, +1, 160, 20, POP_CRI, 1)
        bitmap.draw_text(+1 + x_pop, +1, 160, 20, POP_CRI, 1)
        bitmap.font.color.set(CRT_TXT_COLOR[0],CRT_TXT_COLOR[1],CRT_TXT_COLOR[2]) if critical
        bitmap.draw_text(0 + x_pop, 0, 160, 20, POP_CRI, 1)
      end
      if critical and CRITIC_FLASH
        $game_screen.start_flash(Color.new(255, 255, 255, 255),10)
      end
      @_damage_sprites[i] = ::Sprite.new(self.viewport)
      @_damage_sprites[i].bitmap = bitmap
      @_damage_sprites[i].ox = 80
      @_damage_sprites[i].oy = 20
      @_damage_sprites[i].x = self.x + i * DMG_SPACE
      @_damage_sprites[i].y = self.y - self.oy / 2
      @_damage_sprites[i].z = DMG_DURATION + 3000 + i * 2
    end
  end

I had to remove the break animation because it's really incompatible - it would require to make an animation stack system. Otherwise, it works.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
Bigace
post Oct 26 2010, 08:30 AM
Post #6


The King of Spades
Group Icon

Group: Revolutionary
Posts: 400
Type: Developer
RM Skill: Intermediate




thanks for the update your a life saver.


__________________________



Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.

QUOTE ('Exiled One')
"If you are one of the very few teenagers that know what real rap is and don't blindly listen to the hate statements (rap is crap), then put this in your sig. I say this in the name of Common, Mos Def, Lupe Fiasco, 2Pac, Nas, Talib Kweli, Eminem, and many others."
Go to the top of the page
 
+Quote Post
   
chipino
post Dec 21 2010, 07:23 AM
Post #7



Group Icon

Group: Member
Posts: 3
Type: None
RM Skill: Undisclosed




How do I do the value part sorry nooby question.

This post has been edited by chipino: Dec 21 2010, 07:39 AM
Go to the top of the page
 
+Quote Post
   
Kread-EX
post Dec 21 2010, 11:35 AM
Post #8


(=___=)/
Group Icon

Group: +Gold Member
Posts: 4,136
Type: Scripter
RM Skill: Undisclosed




You just put the amount of HP damage you want to be nullified, and in the same order as for the IDs.


__________________________
FRACTURE - a SMT inspired game (demo) made by Rhyme, Karsuman and me. Weep and ragequit.

My blog.

Click here for my e-peen


Go to the top of the page
 
+Quote Post
   
chipino
post Dec 21 2010, 05:45 PM
Post #9



Group Icon

Group: Member
Posts: 3
Type: None
RM Skill: Undisclosed




thanks awsome script btw.
Go to the top of the page
 
+Quote Post
   
Nguyễn Anh Ngu...
post Jan 13 2011, 12:58 AM
Post #10



Group Icon

Group: Member
Posts: 1
Type: None
RM Skill: Undisclosed




Thank you very much biggrin.gif .
It very useful for my project tongue.gif .
Go to the top of the page
 
+Quote Post
   

Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 21st May 2013 - 02:47 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker