Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Bizarre issue with Lanzer counter script.
#1
Recently I ran into a really weird problem regarding a modified version of Lanzer's counter attack script:


Code:
#==========================================================================

# ** UL Counter Attack
#==========================================================================
# Uncle Lanzer
# Version 1
# 21.09.10
#==========================================================================
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#   
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------

#################
#               #  
# CONFIGURATION #
#               #
#################
# IT`S PRETTY SIMPLE........ JUST KILL THE BATMAN! <-- FORGET THAT -.-U
# MAKE A "(YOUR COUNTER NAME)" STATE
# UL_COUNTER_STATES = { A => [ B,C]}
# A = THE COUNTER STATE
# B = RATE OF SUCCESS
# C = STRENGHT OF COUNTER ( % OF A NORMAL ATTACK)
Scene_Battle::UL_Counter_States = { 33 => [25,100], 68 => [50, 100], 69 => [75, 100]} #ADD MORE BY THE SAME SYNTAX


# MESSAGGE WHEN COUNTER
Scene_Battle::UL_Counter_Messages = ['Counter']

# CHECKING SCRIPT
if !@ul_counterattack_disabled

# START
    class Game_Battler
        
      alias lanzer_counter_battler_atkeff attack_effect
      def attack_effect(attacker)
        lanzer_counter_battler_atkeff(attacker)
        if $scene.is_a?(Scene_Battle) && $scene.active_battler == attacker
          $scene.ul_atkcounter_test(self)
        end
      end
      
      alias counter_skill_attacks skill_effect
      def skill_effect(attacker, skill)
        counter_skill_attacks(attacker, skill)
        if $scene.is_a?(Scene_Battle) && $scene.active_battler == attacker and skill.power > 0
          $scene.ul_atkcounter_test(self)
        end
      end
      
    end

class Scene_Battle
  attr_accessor :active_battler
 
  def ul_atkcounter_test(battler)
    # The actor is applied with a state that prevents movement. Stop counter.
    return unless battler.movable?
    
    ul_temp = UL_Counter_States.keys
    for i in 0...ul_temp.size
      if battler.state?(ul_temp[i])
        if UL_Counter_States[ul_temp[i]][0] > rand(99)
          @ul_counter = UL_Counter_States[ul_temp[i]][1]
          @ul_countertarget = battler
          return
        end
      end
    end
  end
 
  alias lanzer_counter_battle_up4s5 update_phase4_step5
  def update_phase4_step5
    lanzer_counter_battle_up4s5
    if @ul_countertarget != nil
      @phase4_step = 1337  # LEET
      @ul_atkcounter = 28
    end
  end
 
  def ul_counter_update
    if @ul_countertarget.dead? or @ul_atkcounter == 0 or !@ul_countertarget.movable?
      @ul_atkcounter = nil
      @ul_counter = nil
      @ul_countertarget = nil
      @phase4_step = 6
      return
    end
    @ul_atkcounter -= 1
    if @ul_atkcounter == 10
      @ul_countertarget.animation_id = @ul_countertarget.animation1_id
      @active_battler.animation_id = @ul_countertarget.animation2_id
      ul_temp = rand(UL_Counter_Messages.size)
      ul_temp = UL_Counter_Messages[ul_temp].clone
      ul_temp.gsub!(/\\[Mm]/) { @ul_countertarget.name }
      @help_window.set_text(ul_temp, 1)
      @active_battler.attack_effect(@ul_countertarget)
      if !@active_battler.damage.is_a?(String)
        @active_battler.hp += @active_battler.damage
        @active_battler.damage = @active_battler.damage * @ul_counter / 100
        @active_battler.hp -= @active_battler.damage
        @status_window.refresh
      end
      @active_battler.damage_pop = true
    end
  end
 
  alias lanzer_counter_battle_update update
  def update
    if @ul_atkcounter != nil
      ul_counter_update
    end
    lanzer_counter_battle_update
  end
end

#--------------------------------------------------------------------------#
end


When you try to use a healing skill from the main menu, the game makes it look like you can't complete with "wrong!" buzzer. But when you exit the menu and re-enter, the characters are healed. It seems like a refresh issue, methinks.

If you are wondering, I'm using Blizard's Stormtronics Custom Menu System plus a dozen or so scripts.

BUT!!

I tested it in a new project and the problem's still here. Ergo, it must be this script and this script alone that's causing the error.
Reply
#2
Oh... how I hate sloppy code (but like the 'Dark Knight' quote in the script ^_^). Well, it was kinda clean... but one should add comments and keep with a more traditional 'indent' system.

Code:
#==========================================================================
# ** UL Counter Attack
#==========================================================================
# Uncle Lanzer
# Version 1
# 21.09.10
#==========================================================================
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#  
#  This work is protected by the following license:
# #----------------------------------------------------------------------------
# #  
# #  Creative Commons - Attribution-NonCommercial-ShareAlike 3.0 Unported
# #  ( http://creativecommons.org/licenses/by-nc-sa/3.0/ )
# #  
# #  You are free:
# #  
# #  to Share - to copy, distribute and transmit the work
# #  to Remix - to adapt the work
# #  
# #  Under the following conditions:
# #  
# #  Attribution. You must attribute the work in the manner specified by the
# #  author or licensor (but not in any way that suggests that they endorse you
# #  or your use of the work).
# #  
# #  Noncommercial. You may not use this work for commercial purposes.
# #  
# #  Share alike. If you alter, transform, or build upon this work, you may
# #  distribute the resulting work only under the same or similar license to
# #  this one.
# #  
# #  - For any reuse or distribution, you must make clear to others the license
# #    terms of this work. The best way to do this is with a link to this web
# #    page.
# #  
# #  - Any of the above conditions can be waived if you get permission from the
# #    copyright holder.
# #  
# #  - Nothing in this license impairs or restricts the author's moral rights.
# #  
# #----------------------------------------------------------------------------

#################
#               #  
# CONFIGURATION #
#               #
#################
# IT`S PRETTY SIMPLE........ JUST KILL THE BATMAN! <-- FORGET THAT -.-U
# MAKE A "(YOUR COUNTER NAME)" STATE
# UL_COUNTER_STATES = { A => [ B,C]}
# A = THE COUNTER STATE
# B = RATE OF SUCCESS
# C = STRENGHT OF COUNTER ( % OF A NORMAL ATTACK)

Scene_Battle::UL_Counter_States = { 33 => [25,100],
                                    68 => [50, 100],
                                    69 => [75, 100]
                                  } #ADD MORE BY THE SAME SYNTAX


# MESSAGGE WHEN COUNTER
Scene_Battle::UL_Counter_Messages = ['Counter']



#==============================================================================
# ** Perform script only if not disabled
#==============================================================================
if !@ul_counterattack_disabled

  #============================================================================
  # ** Game_Battler
  #----------------------------------------------------------------------------
  #  This class deals with battlers. It's used as a superclass for the
  #  Game_Actor and Game_Enemy classes.
  #============================================================================
  
  class Game_Battler
    #------------------------------------------------------------------------
    # * Alias Listings
    #------------------------------------------------------------------------
    alias lanzer_counter_battler_atkeff attack_effect
    alias counter_skill_attacks skill_effect
    #------------------------------------------------------------------------
    # * Applying Normal Attack Effects
    #     attacker : battler
    #------------------------------------------------------------------------    
    def attack_effect(attacker)
      # Perform the original call and get the returned 'did it work?' value
      effective = lanzer_counter_battler_atkeff(attacker)
      # Perform the battlesystem test
      if $scene.is_a?(Scene_Battle) && $scene.active_battler == attacker
        $scene.ul_atkcounter_test(self)
      end
      # Return effective
      return effective
    end
    #------------------------------------------------------------------------
    # * Apply Skill Effects
    #     user  : the one using skills (battler)
    #     skill : skill
    #------------------------------------------------------------------------      
    def skill_effect(attacker, skill)
      # Perform the original call and get the returned 'did it work?' value
      effective = counter_skill_attacks(attacker, skill)
      # Perform the battlesystem test
      if $scene.is_a?(Scene_Battle) &&
        $scene.active_battler == attacker and skill.power > 0
        $scene.ul_atkcounter_test(self)
      end
      # Return effective
      return effective
    end
  end
  

  #============================================================================
  # ** Scene_Battle (part 1)
  #----------------------------------------------------------------------------
  #  This class performs battle screen processing.
  #============================================================================
  
  class Scene_Battle
    #--------------------------------------------------------------------------
    # * Public Instance Variables
    #--------------------------------------------------------------------------
    attr_accessor :active_battler         # active battler
    #--------------------------------------------------------------------------
    # * Alias Listings
    #--------------------------------------------------------------------------
    alias lanzer_counter_battle_up4s5 update_phase4_step5
    alias lanzer_counter_battle_update update
    #--------------------------------------------------------------------------
    # * Uncle Lanzar's counter test
    #     battler : battler
    #--------------------------------------------------------------------------
    def ul_atkcounter_test(battler)
      # The actor is applied with a state that prevents movement. Stop counter.
      return unless battler.movable?
      ul_temp = UL_Counter_States.keys
      for i in 0...ul_temp.size
        if battler.state?(ul_temp[i])
          if UL_Counter_States[ul_temp[i]][0] > rand(99)
            @ul_counter = UL_Counter_States[ul_temp[i]][1]
            @ul_countertarget = battler
            return
          end
        end
      end
    end
    #--------------------------------------------------------------------------
    # * Frame Update (main phase step 5 : damage display)
    #--------------------------------------------------------------------------
    def update_phase4_step5
      lanzer_counter_battle_up4s5
      if @ul_countertarget != nil
        @phase4_step = 1337  # LEET
        @ul_atkcounter = 28
      end
    end
   #--------------------------------------------------------------------------
    # * Uncle Lanzar's update
    #     battler : battler
    #--------------------------------------------------------------------------
    def ul_counter_update
      if @ul_countertarget.dead? or
          @ul_atkcounter == 0 or
          !@ul_countertarget.movable?
        @ul_atkcounter    = nil
        @ul_counter       = nil
        @ul_countertarget = nil
        @phase4_step      = 6
        return
      end
      @ul_atkcounter -= 1
      if @ul_atkcounter == 10
        @ul_countertarget.animation_id  = @ul_countertarget.animation1_id
        @active_battler.animation_id    = @ul_countertarget.animation2_id
        ul_temp     = rand(UL_Counter_Messages.size)
        ul_temp     = UL_Counter_Messages[ul_temp].clone
        ul_temp.gsub!(/\\[Mm]/) { @ul_countertarget.name }
        @help_window.set_text(ul_temp, 1)
        @active_battler.attack_effect(@ul_countertarget)
        if !@active_battler.damage.is_a?(String)
          @active_battler.hp += @active_battler.damage
          @active_battler.damage = @active_battler.damage * @ul_counter / 100
          @active_battler.hp -= @active_battler.damage
          @status_window.refresh
        end
        @active_battler.damage_pop = true
      end
    end
    #--------------------------------------------------------------------------
    # * Frame Update
    #--------------------------------------------------------------------------
    def update
      if @ul_atkcounter != nil
        ul_counter_update
      end
      lanzer_counter_battle_update
    end
  end
end

Technically, he forgot that both the 'attack_effect' and 'skill_effect' methods return a true/false value after they are run... to determine if the actions were effective. As he left that little bit out, the system thought the skills were not effective and thus *BRRRZZZZZZZ!!!!* ... even though the members were healed. You may not have noticed that the SPs weren't being used up either.
Up is down, left is right and sideways is straight ahead. - Cord "Circle of Iron", 1978 (written by Bruce Lee and James Coburn... really...)
[Image: QrnbKlx.jpg]

Reply
#3
A thousand thanks, DerVVulfman! I just tested the new script and now it works as intended.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
   Script compatibility help Lord Vectra 3 649 07-25-2021, 11:42 PM
Last Post: DerVVulfman
   Adding face script on Cogwheel's RTAB Battle Status rekkatsu 15 5,318 08-25-2020, 03:09 AM
Last Post: DerVVulfman
   "Wait" in the script Whisper 13 6,494 04-28-2020, 04:06 PM
Last Post: Whisper
   Skill Cooldown script Fenriswolf 11 6,699 12-10-2019, 11:10 AM
Last Post: Fenriswolf
   Need help with my menu - Current issue is item grid layout LilyFrog 41 17,510 09-24-2018, 02:03 AM
Last Post: LilyFrog
   Help iwth script (RGSS Player crash) Whisper 3 4,170 06-17-2017, 05:03 PM
Last Post: Whisper
   Help modifying a script Keeroh 7 5,720 06-11-2017, 04:43 PM
Last Post: DerVVulfman
Question  Mog Menu script: help me stop the crazy picture movement during transitions Zachariad 4 5,630 05-31-2017, 05:10 AM
Last Post: Zachariad
   Actor names in Quest Script jreagan406 5 4,768 03-07-2017, 08:06 AM
Last Post: JayRay
   Moonpearl script Animated Battlers help!! x(( Starmage 11 8,714 05-21-2016, 05:34 AM
Last Post: Starmage



Users browsing this thread: