Chaos Project

RPG Maker => RPG Maker Scripts => Script Troubleshooting => Topic started by: Wraith89 on May 02, 2020, 08:55:59 pm

Title: [Resolved][RMXP]Script Incompatibility Issue (Hima's Reflector & Absorb HP/SP)
Post by: Wraith89 on May 02, 2020, 08:55:59 pm
Hello. I have tried using Hima's Elemental Reflector (found here (https://forum.chaos-project.com/index.php/topic,4469.0.html)), but I found it incompatible with Blizzard's Tons of Addons' "Absorb HP/SP Skill" section. I am using one that is slightly modified thanks to KK20 for MP Shield damage calculations.

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
# Absorb HP/SP Skill by Blizzard
# Version: 2.0b
# Type: Enhanced Skill
# Date: 8.5.2006
# Date v1.7b: 14.11.2006
# Date v1.72b: 20.10.2007
# Date v1.8b: 20.3.2008
# Date v2.0b: 13.7.2008
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=
#
# new in v1.7b:
#   - overworked code, fixed bugs and glitches, added "undead SP"
#
# new in v1.72b:
#   - slightly improved code and slight system change
#
# new in v1.8b:
#   - fixed a bug with SP absorbing that would kill an enemy instead of taking
#     all remaining SP
#
# new in v2.0b:
#   - enhanced compatibility with Full Reflection System and Blizz-ABS
#
#   Just include all the skill IDs that are supposed to steal HP/SP. You can
#   also define undead enemies who will (due to common belief...) revert the HP
#   absorb effect. Also you may add any IDs of enemies who use the same undead
#   effect, but on SP. Just add the IDs into UNDEAD_SP. Note that you can make
#   enemies who only are "undead" for HP stealing, SP stealing or even both.
#
# Note:
#   If you let a skill steal both HP and SP, only HP will be stolen.
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# START Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

SKILL_IDS_HP = [24,42,116,275,293,575,613,621,622,623,629,682,734] # add any Skill IDs and separate them with commas
SKILL_IDS_SP = [63,117] # add any Skill IDs and separate them with commas
UNDEAD_IDS = [] # add IDS and separate them with commas
UNDEAD_SP = [] # add IDS and separate them with commas

#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
# END Configuration
#::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

#==============================================================================
# Game_Battler
#==============================================================================
class Game_Battler
 
  alias skill_effect_hpsp_absorb_later skill_effect
  def skill_effect(user, skill)
    last_hp = self.hp
    last_sr = self.sr if $crls && self.is_a?(Game_Actor)
    result = skill_effect_hpsp_absorb_later(user, skill)
    if $game_system.ABSORB_HP_SP && self.damage.is_a?(Numeric)
      if SKILL_IDS_SP.include?(skill.id)
        self.sr = last_sr if $crls && self.is_a?(Game_Actor)
        if user != self
          if self.is_a?(Game_Enemy) && UNDEAD_SP.include?(self.id)
            self.damage = -self.damage
          end
          if self.sp >= self.damage
            self.sp -= self.damage
          else
            self.damage, self.sp = self.sp, 0
          end
        else
          self.damage = 0
        end
      elsif SKILL_IDS_HP.include?(skill.id)
        lost_hp = last_hp - self.hp
        self.sr = last_sr if $crls && self.is_a?(Game_Actor)
        if user != self
          if self.is_a?(Game_Enemy) && UNDEAD_IDS.include?(self.id)
            self.damage = -self.damage
          end
          self.damage = lost_hp
        else
          self.damage = 0
        end
      end
    end
    return result
  end
 
end

#==============================================================================
# Scene_Battle
#==============================================================================

class Scene_Battle

  alias update_phase4_step5_hpsp_absorb_later update_phase4_step5
  def update_phase4_step5(battler = nil)
    if $game_system.ABSORB_HP_SP
      @status_window.refresh
      @help_window.visible, damages = false, 0
      @target_battlers.each {|target|
          if target.damage != nil
            target.damage_pop = true
            damages += target.damage if target.damage.is_a?(Numeric)
          end}
      if check_absorb(@active_battler, @active_battler.current_action.skill_id,
          damages)
        @status_window.refresh
      end
      @skill, @phase4_step = nil, 6
    elsif battler == nil
      update_phase4_step5_hpsp_absorb_later
    else
      update_phase4_step5_hpsp_absorb_later(battler)
    end
  end
 
  def check_absorb(user, id, damage)
    if (SKILL_IDS_HP | SKILL_IDS_SP).include?(id)
      if SKILL_IDS_HP.include?(id)
        user.hp += damage
      elsif SKILL_IDS_SP.include?(id)
        user.sp += damage
      end
      user.damage, user.damage_pop = -damage, true
      return true
    end
    return false
  end
   
end


The issue is it reports back a "NoMethodError" for undefined method "type_of_skill" for Nil:Class (around line 148ish) within Hima's Reflector script. Moving the reflector script above Blizzard's Tons of Addons 3 makes the reflector "work" with the blocking part but not the actual damaging from reflection. After testing things on a blank project I concluded enabling the Absorb HP/SP script causes problems, even on a fresh version of Blizzard's script.

Any assistance would be greatly appreciated.

Title: Re: [RMXP]Script Incompatibility Issue (Hima's Reflector & Absorb HP/SP)
Post by: KK20 on May 02, 2020, 10:42:23 pm
In the Absorb script, you can comment out the line
@skill, @phase4_step = nil, 6
The issue was that @skill was being set to nil before the reflection happened. Not sure *why* @skill was set to nil in the first place because I didn't see anything bad happen after removal.
Title: Re: [RMXP]Script Incompatibility Issue (Hima's Reflector & Absorb HP/SP)
Post by: Wraith89 on May 03, 2020, 01:18:11 am
Thank you very much! That solved everything. That was actually the default setting in Tons, but I think within Tons there are still some parts that may be somewhat buggy, even within a fresh new project, and not just compatibility issues.