Trouble with VX-Ace tutorial self-effect script

I am sorry if this is in the wrong place, but the last thread I turned up when looking for answers to this issue was in this part of the forums and dated 2013.
Very new to the program, and extremely fearful of ruby, but I'm trying!

The self-effect script from the tutorial 3.5 (https://www.rpgmakerweb.com/support/products/tutorials) gives me the error
fd52iZm.png


I consulted doctor google, and was directed to a thread here with a few possible causes and fixes, including a very thoughtful post with a revised script. The cause is that it bugs out if there is any note attached to a skill other than one for the script (if the thread is correct, I don't know enough to be able to tell myself). I did a little test battling and it seems to point in that direction.

When "Attack" is used by anything (enemy or player) it bugs immediately, when I tried a move where self-effect is used, the animation played out and it didn't freeze up until the enemy tried 'Attack'.

I've tried: the original script from the tutorial, the revised one in the thread linked below, and a fix the user mobychan recommended: adding the line "next if scan.nil?" above the problem line.

Any ideas? I'd hate to have learned as much as I have to just throw my arms up and quit over something this silly, I'd really like to get this working. Sorry if I've missed something painfully obvious, misplaced this post, or done some other dumb thing. Thanks


Thread I referenced so much:
https://forums.rpgmakerweb.com/index.php?threads/newbie-needs-help-with-tutorial-3-5.2957/

EDIT: i should probly put the script in, huh.
Code:
#===============================================================================
# Skill Self Effects
# By Jet10985 (Jet)
# Requested by Touchfuzzy
#===============================================================================
# This script will allow you to specify a skill's effects tot arget the user
# instead of the target, on skills that don't already effect the user.
# This script has: 0 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Battler: item_effect_apply
#===============================================================================
=begin
To specify the effects, use this notetag in the skill's notebox:

<self effect: 1>
or
<self effect: 1, 2, 3> to specify more than 1 effect
--------------------------------------------------------------------------------
Use of this script could be as the following.

You make a "Berserk Strike" skill, which does 200% damage to an enemy.
You make the 2nd effect "Defense Down 50%" and want it applied to the user.
You'd use this notetag: <self effect: 2>
=end

class RPG::Skill
 
  def self_effects
    if @self_effects.nil?
      @self_effects = []
      self.note.each_line {|a|
        scan = a.scan(/<self[ ]*effect[ ]*\:[ ]*(\d+(?:[ ]*,[ ]*\d+)*)>/i)
        scan[0][0].scan(/\d+/).each {|b|
          @self_effects.push(@effects[b.to_i - 1]) if b.to_i >= 1
        }
      }
    end
    @self_effects
  end
end

class Game_Battler
 
  alias jet3745_item_effect_apply item_effect_apply
  def item_effect_apply(user, item, effect, reffed = false)
    if item.is_a?(RPG::Skill) && item.self_effects.include?(effect) && !reffed
      user.item_effect_apply(user, item, effect, true)
      return
    end
    jet3745_item_effect_apply(user, item, effect)
  end
end
please ignore tutorial 3.5

The script contains an error and for access reasons, the correct script was never uploaded there (it is in the forum somewhere).
And no one really bothers anymore because the community has found a much easier way to handle the same thing: direct use of damage formula coding.
You'll find links to topics about that in the forum (for example if you follow the link to the starting point in my signature)
Thanks, appreciate the answer/help!
That regex in the script is painful to watch. 😀
You can replace that method with this one:
Spoiler
Code:
  def self_effects
    if @self_effects.nil?
      @self_effects = []
      if @note =~ /<self effect: (\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each {|eff| @self_effects << @effects[eff.to_i - 1] }
      end
    end
    return @self_effects
  end
This should fix the NoMethod error you get.

Using the damage formula is fine too, but typing everything into that tiny formula box can and will get annoying soon enough. 😛
That regex in the script is painful to watch. 😀
You can replace that method with this one:
Spoiler
Code:
  def self_effects
    if @self_effects.nil?
      @self_effects = []
      if @note =~ /<self effect: (\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each {|eff| @self_effects << @effects[eff.to_i - 1] }
      end
    end
    return @self_effects
  end
This should fix the NoMethod error you get.

Using the damage formula is fine too, but typing everything into that tiny formula box can and will get annoying soon enough. 😛

I am not entirely sure where i ought to plug this in, but I will toy around with it. thank you!
EDIT: well that seemed to do it!
EDIT 2: by do it i mean it fixed the crashes but no self effects are taking place either! well damn.
in the script there is a class self effects My bad it is Class RPG::Skill
below that is def self effects
What sixth provided replaced the def section.
Be sure not to overwrite the end statement for closing off the class.

I tested this myself and there are no errors.
I just fixed the regex, so it won't give you the error you got before.
Whatever thing the script should do otherwise stayed the same, so it should work the same.
The other method gets the same data as before (minus the crash issue), so if it doesn't work after replacing that method with mine, it couldn't work even before that.
Make sure to leave a space after the : sign in your note-tags, otherwise it won't work (too lazy to add that into the regex I used 😛).

Replace the entire method in the original script with the same name as the method I wrote above.
So, from the def self_effects line to the end line which closes that method.
in the script there is a class self effects
below that is def self effects
What sixth provided replaced the def section.
Be sure not to overwrite the end statement for closing off the class.

I tested this myself and there are no errors.
could you tell me which lines to replace so i know what to look for in the future?
i see "Class Rpg::skill" with and where it looks like it "def self_effects" under it, am i in the right neighborhood? originally i tried replacing lines 28 to 36 with that fix

Again my apologies for being so woefully ignorant with code, but I'm trying and appreciate the help!

EDIT: just saw your last reply sixth, thanks! i'll poke around until i find the correct 'end' and hope for the best.
Well, many helpful replies and a fix later, I'm no closer to getting the desired effects (right out of the tutorial, no less) so I suppose this isn't for me.

Noted the space in the note tag and replaced lines 27 - 36 with the fix, for the record. F

Feeling really dumb.
This is how the script should look after the fix:
Spoiler
Code:
#===============================================================================
# Skill Self Effects
# By Jet10985 (Jet)
# Requested by Touchfuzzy
#===============================================================================
# This script will allow you to specify a skill's effects tot arget the user
# instead of the target, on skills that don't already effect the user.
# This script has: 0 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Battler: item_effect_apply
#===============================================================================
=begin
To specify the effects, use this notetag in the skill's notebox:

<self effect: 1>
or
<self effect: 1, 2, 3> to specify more than 1 effect
--------------------------------------------------------------------------------
Use of this script could be as the following.

You make a "Berserk Strike" skill, which does 200% damage to an enemy.
You make the 2nd effect "Defense Down 50%" and want it applied to the user.
You'd use this notetag: <self effect: 2>
=end

class RPG::Skill
 
  def self_effects
    if @self_effects.nil?
      @self_effects = []
      if @note =~ /<self effect: (\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each {|eff| @self_effects << @effects[eff.to_i - 1] }
      end
    end
    return @self_effects
  end

end

class Game_Battler
 
  alias jet3745_item_effect_apply item_effect_apply
  def item_effect_apply(user, item, effect, reffed = false)
    if item.is_a?(RPG::Skill) && item.self_effects.include?(effect) && !reffed
      user.item_effect_apply(user, item, effect, true)
      return
    end
    jet3745_item_effect_apply(user, item, effect)
  end
 
end
This is how the script should look after the fix:
Spoiler
Code:
#===============================================================================
# Skill Self Effects
# By Jet10985 (Jet)
# Requested by Touchfuzzy
#===============================================================================
# This script will allow you to specify a skill's effects tot arget the user
# instead of the target, on skills that don't already effect the user.
# This script has: 0 customization options.
#===============================================================================
# Overwritten Methods:
# None
#-------------------------------------------------------------------------------
# Aliased methods:
# Game_Battler: item_effect_apply
#===============================================================================
=begin
To specify the effects, use this notetag in the skill's notebox:

<self effect: 1>
or
<self effect: 1, 2, 3> to specify more than 1 effect
--------------------------------------------------------------------------------
Use of this script could be as the following.

You make a "Berserk Strike" skill, which does 200% damage to an enemy.
You make the 2nd effect "Defense Down 50%" and want it applied to the user.
You'd use this notetag: <self effect: 2>
=end

class RPG::Skill
 
  def self_effects
    if @self_effects.nil?
      @self_effects = []
      if @note =~ /<self effect: (\d+(?:\s*,\s*\d+)*)>/i
        $1.scan(/\d+/).each {|eff| @self_effects << @effects[eff.to_i - 1] }
      end
    end
    return @self_effects
  end

end

class Game_Battler
 
  alias jet3745_item_effect_apply item_effect_apply
  def item_effect_apply(user, item, effect, reffed = false)
    if item.is_a?(RPG::Skill) && item.self_effects.include?(effect) && !reffed
      user.item_effect_apply(user, item, effect, true)
      return
    end
    jet3745_item_effect_apply(user, item, effect)
  end
 
end
sorry you had to spoonfeed the whole damn thing to me, i REALLY tried to wrap my head around it, but i haven't messed with code in a few years, and it sure wasn't ruby. not familiar with the terms and whatnot anymore.

Thank you very, very, very much.

Original thread: https://forums.rpgmakerweb.com/threads/trouble-with-vx-ace-tutorial-self-effect-script.81174/