Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Problem with Sketch Script

Muse

Member

I'm using Prexus' Sketch script in my game and, for some reason, whenever I use an attacking item against the enemy, this message pops up:

Script 'Sketch' line 157:NoMethodError occured.
undefined method 'scope' for 1:Fixnum

The script is:

Code:
#------------------
# Sketch
# by Prexus
# Mimics the ability Sketch by Relm in Final Fantasy 6
# Randomly selects one of the monster's abilities and uses it
# http://rm-dev.org/
#------------------

class Scene_Battle
  
  # Set the ID of the Sketch skill here:
  $SKETCH_ID = 81
  
  # Do not edit any of the following:
  def make_skill_action_result
    # Get skill
    @skill = $data_skills[@active_battler.current_action.skill_id]
    if @skill.id == $SKETCH_ID
      set_target_battlers(@skill)
      for target in @target_battlers
        enemy = $data_enemies[target.id]
        skills = []
        for i in 0...enemy.actions.size
          if enemy.actions[i].kind = 1
            if enemy.actions[i].condition_level <= @active_battler.level
              skills.push($data_skills[enemy.actions[i].skill_id])
            end
          end
        end
        if skills.size != 0
          # Randomly picks an enemy's skill
          @skill = skills[rand(skills.size)-1]
        else
          # Clear battler being forced into action
          $game_temp.forcing_battler = nil
          # Shift to step 1
          @phase4_step = 1
          return
        end
      end
    end
    # If not a forcing action
    unless @active_battler.current_action.forcing
      # If unable to use due to SP running out
      unless @active_battler.skill_can_use?(@skill.id)
        # Clear battler being forced into action
        $game_temp.forcing_battler = nil
        # Shift to step 1
        @phase4_step = 1
        return
      end
    end
    # Use up SP
    if skills != nil
      skills = []
      skills = nil
      @target_battlers = []
      sketch = true
    else
      @active_battler.sp -= @skill.sp_cost
      sketch = false
    end
    # Refresh status window
    @status_window.refresh
    # Show skill name on help window
    @help_window.set_text(@skill.name, 1)
    # Set animation ID
    @animation1_id = @skill.animation1_id
    @animation2_id = @skill.animation2_id
    # Set command event ID
    @common_event_id = @skill.common_event_id
    # Set target battlers
    set_target_battlers(@skill, sketch)
    # Apply skill effect
    for target in @target_battlers
      target.skill_effect(@active_battler, @skill)
    end
  end
  
  alias stb set_target_battlers
  def set_target_battlers(skill, sketch = false)
    if sketch
      if @active_battler.is_a?(Game_Enemy)
        case skill.scope
        when 1
          index = rand($game_party.actors.size)-1
          @target_battlers.push($game_party.smooth_target_actor(index))
        when 2
          for actor in $game_party.actors
            if actor.exist?
              @target_battlers.push(actor)
            end
          end
        when 3
          index = rand($game_troop.enemies.size)-1
          @target_battlers.push($game_troop.smooth_target_enemy(index))
        when 4
          for enemy in $game_troop.enemies
            if enemy.exist?
              @target_battlers.push(enemy)
            end
          end
        when 5
          index = rand($game_troop.enemies.size)-1
          enemy = $game_troop.enemies[index]
          if enemy != nil and enemy.hp0?
            @target_battlers.push(enemy)
          end
        when 6
          for enemy in $game_troop.enemies
            if enemy != nil and enemy.hp0?
              @target_battlers.push(enemy)
            end
          end
        when 7
          @target_battlers.push(@active_battler)
        end
      end
      if @active_battler.is_a?(Game_Actor)
        case skill.scope
        when 1
          index = rand($game_troop.enemies.size)-1
          @target_battlers.push($game_troop.smooth_target_enemy(index))
        when 2
          for enemy in $game_troop.enemies
            if enemy.exist?
              @target_battlers.push(enemy)
            end
          end
        when 3
          index = rand($game_party.actors.size)-1
          @target_battlers.push($game_party.smooth_target_actor(index))
        when 4
          for actor in $game_party.actors
            if actor.exist?
              @target_battlers.push(actor)
            end
          end
        when 5
          index = rand($game_party.actors.size)-1
          actor = $game_party.actors[index]
          if actor != nil and actor.hp0?
            @target_battlers.push(actor)
          end
        when 6
          for actor in $game_party.actors
            if actor != nil and actor.hp0?
              @target_battlers.push(actor)
            end
          end
        when 7
          @target_battlers.push(@active_battler)
        end
      end
      return
    end
    stb(skill.scope)
  end
end

class Game_Actor < Game_Battler
  #--------------------------------------------------------------------------
  # * Determine if Skill can be Used
  #     skill_id : skill ID
  #--------------------------------------------------------------------------
  def skill_can_use?(skill_id)
    #if not skill_learn?(skill_id)
    #  return false
    #end
    return super
  end
end

If anyone can help me with this, I'll owe you big time. Thank you! ^^
 
def skill_can_use?(skill_id)
#if not skill_learn?(skill_id)
# return false
#end
return super
end
end

At the bottom, Try takign off the #, It is putting it as a comment when it looks like it needs to be done...

Edit - Stupid me, Figured out my Error on 87, So I deleted that part of my post
 

Muse

Member

Thanks for the help! I didn't even notice that! However, it's still doing the same thing. It still says that there's an error on line 157. Here's the line:

Code:
    stb(skill.scope)
 
I believe since it's saying 'scope' is not defined, As well seeing as it's a skill, I think you might have to make the skill in the database, I'm not too familiar with scripting, I know little bits, Wish I could be more help
 

Muse

Member

I changed lines 157-159 to this:

Code:
    print skill
    print skill.scope
    stb(skill.scope)

I gave me the same exact error when I used the items. =\

Code:
Script 'Sketch' line 157:NoMethodError occured.
undefined method 'scope' for 1:Fixnum

I also checked the skill in the database and I have it set as 'One Enemy.' The funny thing is that it's not the skill that I use to bring up these errors. It's items. Using different sorts of items just changes the number behind the 'Fixnum' part of the error. (Status Healing = 0, Attacking =1, Healing = 3, etc.)
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top