Defend against projectiles in BABS?

Started by Boba Fett Link, January 17, 2012, 07:02:36 pm

Previous topic - Next topic

Boba Fett Link

Is there a way to make the player defend against projectiles in BABS?
This post will self-destruct in 30 seconds.

KK20

I want to say yes, but not without edits of course. It would also be nice to know what types of projectiles you are talking about. For example, under what types of scenarios can the projectile be blocked?

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Boba Fett Link

I know I'll have to edit the script to make it work, but I need to know where. And I wanted you to be able to block all projectiles at any time. I'm pretty sure that you can block arrows with a shield if you wanted to.
This post will self-destruct in 30 seconds.

KK20

January 18, 2012, 04:46:11 pm #3 Last Edit: January 18, 2012, 07:33:31 pm by KK20
My guess is it has to do something with Map_Remote. Particularily, 'def execute'.
Original Method: ShowHide
  #----------------------------------------------------------------------------
 # execute
 #  Executes the projectile's effect.
 #----------------------------------------------------------------------------
 def execute(target = @target)
   # if skill
   if BlizzABS::REMSkills.include?(@type)
     # execute skill
     target.skill_effect(@creator, @battler_copy, $data_skills[@id])
     # check special skill effects
     $BlizzABS.check_special_skills(@creator, [target], $data_skills[@id])
   # if item
   elsif BlizzABS::REMItems.include?(@type)
     # execute item
     target.item_effect(@creator, @battler_copy, $data_items[@id])
   else
     # execute attack
     target.attack_effect(@creator, @battler_copy)
     # if shot item
     if @type == BlizzABS::REMShotItem
       # store damage
       dmg = target.battler.damage
       # execute item
       target.item_effect(@creator, @battler_copy, $data_items[@id])
       # if damage is a number and any damage done
       if target.battler.damage.is_a?(Numeric) &&
         (target.battler.hpdamage > 0 || target.battler.spdamage > 0)
         # add attack damage if attack damage was a number
         target.battler.damage += dmg if dmg.is_a?(Numeric)
       # if no damage done with item
       elsif target.battler.hpdamage == 0 && target.battler.spdamage == 0
         # set back to attack damage
         target.battler.damage = dmg
       end
     end
   end
   # clear damage displays
   target.battler.damage, target.battler.damage_pop = nil, false
   # add to already hit targets
   @hit.push(target)
   # sets flag for self-termination if necessary
   @terminate = true unless BlizzABS::REMPersistent.include?(@type)
 end
I don't work a whole lot with BABS anymore, but I (and anyone else who has better knowledge of it) can take a crack at it.


EDIT: Okay, I think I figured it out. It was just a matter of flipping two lines around.
In Part 2 of BABS, CTRL + F for "class Processor". Scroll down to 'def update' and replace with this:
Spoiler: ShowHide
    #--------------------------------------------------------------------------
    # update
    #  Updates Blizz-ABS processes.
    #--------------------------------------------------------------------------
    def update
      # update player battle input
      @controls.update
      # update each projectile and trap
      $BlizzABS.cache.remotes.each {|remote| remote.update}
      # update summons
      update_summons
      # stop if scene is not Scene_Map
      return if !$scene.is_a?(Scene_Map)
      # update killed events
      update_killed
      # remove expired events from the map
      event_removal
      # remove expired summons from the map
      summon_removal
      # check special status effects
      check_special_states
    end
To the people who want to know the reason: I made the game print out whether I was defending or not against a normal attack under 'def attack_effect'. It worked fine with normal attacks (Sword-type), but it kept saying that I was not defending against projectiles (Bow-type). The game is processing projectiles (class Map_Remote instances) before it is getting the player's key input. Thus, I swapped the two around.

Didn't do any thorough testing.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Boba Fett Link

This post will self-destruct in 30 seconds.

Magus

Does that really work?  *Sigh* Although, I prefer a separate type of defend called: Magic Defend and it eats away your SP.
LEVEL ME DOWN. THE ANTI-BLIZZ GROUP IS AMONG YOU... Do it for the chick below...She watches..<br />

Boba Fett Link

So I've noticed that this fix allows you to defend against projectile attacks, but not projectile skills. Is there a way to fix that?

Sorry about the bump...
This post will self-destruct in 30 seconds.

KK20

I've already noticed that pressing the defend key does absolutely nothing to any skill effect. I think it's because of this line in Part 3:
# reset own battler's action
@battler.current_action.kind = @battler.current_action.basic = 0
when I think it should look like this (based off of attack_effect)
# reset own battler's action
@battler.current_action.kind = 0
@battler.current_action.basic = (@ai.act.defend? ? 1 : 0)


Now if you want Full Defend to block all damage from Projectile-based skills only, that's going to need an edit.

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Boba Fett Link

Yeah, I just hadn't tried it with any other skill.

Now defending blocks half the damage, as if normal defending is on (I have Full Defend on).
This post will self-destruct in 30 seconds.

KK20

To defend against any kind of skill:
Spoiler: ShowHide
class Map_Battler < Game_Character
  #----------------------------------------------------------------------------
  # skill_effect
  #  character - the character that holds skill use (can be projectile)
  #  _battler  - the skill using battler
  #  skill     - the skill
  #  Executes skill use upon a map character.
  #----------------------------------------------------------------------------
  def skill_effect(character, _battler, skill)
    # stop skill if no battler assigned
    return false if @battler == nil
    # stop skill if pressing CTRL in debug mode
    return false if $DEBUG && @ai.group != 0 && Input.press?(Input::CTRL)
    # damage sprite character
    dmgchar = (@body == nil ? self : @body)
    # if full defending
    if BlizzABS::Config::FULL_DEFEND && @ai.act.defend?
      # set attacked counter
      self.attacked = $BlizzABS.pixel
      # request damage sprite
      $BlizzABS.util.request_damage_sprite(dmgchar, BlizzABS::Cache::TXTDefend)
      # not executed
      return false
    end

    # if defending set action data
    if @ai.act.defend? && @battler.last_action[0] == "defend"
      @battler.last_action[1] = true
    end
    # reset own battler's action
    @battler.current_action.kind = 0
    @battler.current_action.basic = (@ai.act.defend? ? 1 : 0)
    # reset hpdamage and spdamage
    @battler.hpdamage, @battler.spdamage = 0, 0
    # get slip damage state
    slip_dmg = (@battler.slip_damage? ? true : false)
    # get result
    result = @battler.skill_effect(_battler, skill)
    # if effect processing was executed
    if result || self.damage_display?
      # apply basic effects
      action_effect(skill)
      # apply knockback
      self.attacked *= BlizzABS::Skills.knockback(skill.id)
      # face attacker
      turn_toward(character) if BlizzABS::Config::KNOCKBACK_MODE == 2
      # apply action effect if any actual damage done
      alignment_effect(character.ai.group) if self.damage_done?
      # request damage sprite
      $BlizzABS.util.request_damage_sprite(@body == nil ? self : @body)
      # set last hit by
      if @battler.hpdamage > 0 || @battler.spdamage > 0
        @battler.last_hit_by = _battler
      end
      # reset hpdamage and spdamage
      @battler.hpdamage, @battler.spdamage = 0, 0
      # attack was executed
      result = true
      # set attacker and target data
      @battler.last_attackers.push(_battler)
      _battler.last_targets.push(@battler)
      # if skill set action data
      _battler.last_action[1] = true if _battler.last_action[0] == "skill"
      # check slip damage state
      if skill.plus_state_set.any? {|s| $data_states[s].slip_damage}
        @battler.last_slip_attackers.push(_battler)
      end
    end
    # send data to obeserver if attacked by actor
    $BlizzABS.AI.observe(_battler, @battler.damage) if _battler.is_a?(Game_Actor)
    # delete own charge data if executed
    @charge = nil if result
    # return result
    return result
  end
end

To defend against ONLY a projectile-based skill (SHOOT and HOMING):
Spoiler: ShowHide
class Map_Projectile < Map_Remote
  #----------------------------------------------------------------------------
  # execute
  #  Executes the projectile's effect.
  # Modified to allow defend against skill-based projectiles
  #----------------------------------------------------------------------------
  def execute(target = @target)
    # if skill and full defense
    if BlizzABS::REMSkills.include?(@type) and
    BlizzABS::Config::FULL_DEFEND && target.ai.act.defend?
      # execute skill, but call full defend
      target.skill_effect(@creator, @battler_copy, $data_skills[@id], true)
      # clear damage displays
      target.battler.damage, target.battler.damage_pop = nil, false
      # add to already hit targets
      @hit.push(target)
      # sets flag for self-termination if necessary
      @terminate = true unless BlizzABS::REMPersistent.include?(@type)
      # Stop processing
      return
    end
    super(target)
   
  end
end
#===============================================================================
#===============================================================================
class Map_Battler < Game_Character
  #----------------------------------------------------------------------------
  # skill_effect
  #  character - the character that holds skill use (can be projectile)
  #  _battler  - the skill using battler
  #  skill     - the skill
  #  Executes skill use upon a map character.
  #----------------------------------------------------------------------------
  def skill_effect(character, _battler, skill, projectile_defend = false)
    # stop skill if no battler assigned
    return false if @battler == nil
    # stop skill if pressing CTRL in debug mode
    return false if $DEBUG && @ai.group != 0 && Input.press?(Input::CTRL)
    # damage sprite character
    dmgchar = (@body == nil ? self : @body)
    # if full defending
    if projectile_defend && BlizzABS::Config::FULL_DEFEND && @ai.act.defend?
      # set attacked counter
      self.attacked = $BlizzABS.pixel
      # request damage sprite
      $BlizzABS.util.request_damage_sprite(dmgchar, BlizzABS::Cache::TXTDefend)
      # not executed
      return false
    end

    # if defending set action data
    if @ai.act.defend? && @battler.last_action[0] == "defend"
      @battler.last_action[1] = true
    end
    # reset own battler's action
    @battler.current_action.kind = 0
    @battler.current_action.basic = (@ai.act.defend? ? 1 : 0)
    # reset hpdamage and spdamage
    @battler.hpdamage, @battler.spdamage = 0, 0
    # get slip damage state
    slip_dmg = (@battler.slip_damage? ? true : false)
    # get result
    result = @battler.skill_effect(_battler, skill)
    # if effect processing was executed
    if result || self.damage_display?
      # apply basic effects
      action_effect(skill)
      # apply knockback
      self.attacked *= BlizzABS::Skills.knockback(skill.id)
      # face attacker
      turn_toward(character) if BlizzABS::Config::KNOCKBACK_MODE == 2
      # apply action effect if any actual damage done
      alignment_effect(character.ai.group) if self.damage_done?
      # request damage sprite
      $BlizzABS.util.request_damage_sprite(@body == nil ? self : @body)
      # set last hit by
      if @battler.hpdamage > 0 || @battler.spdamage > 0
        @battler.last_hit_by = _battler
      end
      # reset hpdamage and spdamage
      @battler.hpdamage, @battler.spdamage = 0, 0
      # attack was executed
      result = true
      # set attacker and target data
      @battler.last_attackers.push(_battler)
      _battler.last_targets.push(@battler)
      # if skill set action data
      _battler.last_action[1] = true if _battler.last_action[0] == "skill"
      # check slip damage state
      if skill.plus_state_set.any? {|s| $data_states[s].slip_damage}
        @battler.last_slip_attackers.push(_battler)
      end
    end
    # send data to obeserver if attacked by actor
    $BlizzABS.AI.observe(_battler, @battler.damage) if _battler.is_a?(Game_Actor)
    # delete own charge data if executed
    @charge = nil if result
    # return result
    return result
  end
end

To defend against ANY type of remote skill (but not skills like SHOCKWAVE, DIRECT, or BEAM):
Spoiler: ShowHide
class Map_Remote < Map_Battler
  #----------------------------------------------------------------------------
  # execute
  #  Executes the projectile's effect.
  #----------------------------------------------------------------------------
  def execute(target = @target)
    # if skill
    if BlizzABS::REMSkills.include?(@type)
      # execute skill
      target.skill_effect(@creator, @battler_copy, $data_skills[@id], true)
      # check special skill effects
      $BlizzABS.check_special_skills(@creator, [target], $data_skills[@id])
    # if item
    elsif BlizzABS::REMItems.include?(@type)
      # execute item
      target.item_effect(@creator, @battler_copy, $data_items[@id])
    else
      # execute attack
      target.attack_effect(@creator, @battler_copy)
      # if shot item
      if @type == BlizzABS::REMShotItem
        # store damage
        dmg = target.battler.damage
        # execute item
        target.item_effect(@creator, @battler_copy, $data_items[@id])
        # if damage is a number and any damage done
        if target.battler.damage.is_a?(Numeric) &&
          (target.battler.hpdamage > 0 || target.battler.spdamage > 0)
          # add attack damage if attack damage was a number
          target.battler.damage += dmg if dmg.is_a?(Numeric)
        # if no damage done with item
        elsif target.battler.hpdamage == 0 && target.battler.spdamage == 0
          # set back to attack damage
          target.battler.damage = dmg
        end
      end
    end
    # clear damage displays
    target.battler.damage, target.battler.damage_pop = nil, false
    # add to already hit targets
    @hit.push(target)
    # sets flag for self-termination if necessary
    @terminate = true unless BlizzABS::REMPersistent.include?(@type)
  end
end
#===============================================================================
#===============================================================================
class Map_Battler < Game_Character
  #----------------------------------------------------------------------------
  # skill_effect
  #  character - the character that holds skill use (can be projectile)
  #  _battler  - the skill using battler
  #  skill     - the skill
  #  Executes skill use upon a map character.
  #----------------------------------------------------------------------------
  def skill_effect(character, _battler, skill, projectile_defend = false)
    # stop skill if no battler assigned
    return false if @battler == nil
    # stop skill if pressing CTRL in debug mode
    return false if $DEBUG && @ai.group != 0 && Input.press?(Input::CTRL)
    # damage sprite character
    dmgchar = (@body == nil ? self : @body)
    # if full defending
    if projectile_defend && BlizzABS::Config::FULL_DEFEND && @ai.act.defend?
      # set attacked counter
      self.attacked = $BlizzABS.pixel
      # request damage sprite
      $BlizzABS.util.request_damage_sprite(dmgchar, BlizzABS::Cache::TXTDefend)
      # not executed
      return false
    end

    # if defending set action data
    if @ai.act.defend? && @battler.last_action[0] == "defend"
      @battler.last_action[1] = true
    end
    # reset own battler's action
    @battler.current_action.kind = 0
    @battler.current_action.basic = (@ai.act.defend? ? 1 : 0)
    # reset hpdamage and spdamage
    @battler.hpdamage, @battler.spdamage = 0, 0
    # get slip damage state
    slip_dmg = (@battler.slip_damage? ? true : false)
    # get result
    result = @battler.skill_effect(_battler, skill)
    # if effect processing was executed
    if result || self.damage_display?
      # apply basic effects
      action_effect(skill)
      # apply knockback
      self.attacked *= BlizzABS::Skills.knockback(skill.id)
      # face attacker
      turn_toward(character) if BlizzABS::Config::KNOCKBACK_MODE == 2
      # apply action effect if any actual damage done
      alignment_effect(character.ai.group) if self.damage_done?
      # request damage sprite
      $BlizzABS.util.request_damage_sprite(@body == nil ? self : @body)
      # set last hit by
      if @battler.hpdamage > 0 || @battler.spdamage > 0
        @battler.last_hit_by = _battler
      end
      # reset hpdamage and spdamage
      @battler.hpdamage, @battler.spdamage = 0, 0
      # attack was executed
      result = true
      # set attacker and target data
      @battler.last_attackers.push(_battler)
      _battler.last_targets.push(@battler)
      # if skill set action data
      _battler.last_action[1] = true if _battler.last_action[0] == "skill"
      # check slip damage state
      if skill.plus_state_set.any? {|s| $data_states[s].slip_damage}
        @battler.last_slip_attackers.push(_battler)
      end
    end
    # send data to obeserver if attacked by actor
    $BlizzABS.AI.observe(_battler, @battler.damage) if _battler.is_a?(Game_Actor)
    # delete own charge data if executed
    @charge = nil if result
    # return result
    return result
  end
end


Choose the one that you want and paste it below BABS. Sorry this took so long--I guess I forgot again  :<_<:

Other Projects
RPG Maker XP Ace  Upgrade RMXP to RMVXA performance!
XPA Tilemap  Tilemap rewrite with many features, including custom resolution!

Nintendo Switch Friend Code: 8310-1917-5318
Discord: KK20 Tyler#8901

Join the CP Discord Server!

Boba Fett Link

This post will self-destruct in 30 seconds.