RMRK is retiring.
Registration is disabled. The site will remain online, but eventually become a read-only archive. More information.

RMRK.net has nothing to do with Blockchains, Cryptocurrency or NFTs. We have been around since the early 2000s, but there is a new group using the RMRK name that deals with those things. We have nothing to do with them.
NFTs are a scam, and if somebody is trying to persuade you to buy or invest in crypto/blockchain/NFT content, please turn them down and save your money. See this video for more information.
Need help with fishing script error

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 87
I am using Rpg Maker XP Ver 1.02a
I am trying to use this fishing script in my game
According to the instruction I have edited Scene_Map to this
Code: [Select]
#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make sprite set
    @spriteset = Spriteset_Map.new
    # Make message window
    @message_window = Window_Message.new
    # Transition run
    Graphics.transition
    # Main loop
    loop do
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      # Frame update
      update
      # Abort loop if screen is changed
      if $scene != self
        break
      end
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose of sprite set
    @spriteset.dispose
    # Dispose of message window
    @message_window.dispose
    # If switching to title screen
    if $scene.is_a?(Scene_Title)
      # Fade out screen
      Graphics.transition
      Graphics.freeze
    end
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Loop
    loop do
      # Update map, interpreter, and player order
      # (this update order is important for when conditions are fulfilled
      # to run any event, and the player isn't provided the opportunity to
      # move in an instant)
      $game_map.update
      $game_system.map_interpreter.update
      $game_player.update
      # Update system (timer), screen
      $game_system.update
      $game_screen.update
      # Abort loop if player isn't place moving
      unless $game_temp.player_transferring
        break
      end
      # Run place move
      transfer_player
      # Abort loop if transition processing
      if $game_temp.transition_processing
        break
      end
    end
    # Update sprite set
    @spriteset.update
    # Update message window
    @message_window.update
    # If game over
    if $game_temp.gameover
      # Switch to game over screen
      $scene = Scene_Gameover.new
      return
    end
    # If returning to title screen
    if $game_temp.to_title
      # Change to title screen
      $scene = Scene_Title.new
      return
    end
    # If transition processing
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      if $game_temp.transition_name == ""
        Graphics.transition(20)
      else
        Graphics.transition(40, "Graphics/Transitions/" +
          $game_temp.transition_name)
      end
    end
    # If showing message window
    if $game_temp.message_window_showing
      return
    end
    # If encounter list isn't empty, and encounter count is 0
    if $game_player.encounter_count == 0 and $game_map.encounter_list != []
      # If event is running or encounter is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.encounter_disabled
        # Confirm troop
        n = rand($game_map.encounter_list.size)
        troop_id = $game_map.encounter_list[n]
        # If troop is valid
        if $data_troops[troop_id] != nil
          # Set battle calling flag
          $game_temp.battle_calling = true
          $game_temp.battle_troop_id = troop_id
          $game_temp.battle_can_escape = true
          $game_temp.battle_can_lose = false
          $game_temp.battle_proc = nil
        end
      end
    end
    # If B button was pressed
    if Input.trigger?(Input::B)
      # If event is running, or menu is not forbidden
      unless $game_system.map_interpreter.running? or
             $game_system.menu_disabled
        # Set menu calling flag or beep flag
        $game_temp.menu_calling = true
        $game_temp.menu_beep = true
      end
    end
   
    #----------------------------Added For Fishing---------------------------#
   
    if Input.trigger?(Input::A)
      call_fishing                       
    end
   
    #-------------------------Add-For Fishing-Ends------------------------#
   
    # If debug mode is ON and F9 key was pressed
    if $DEBUG and Input.press?(Input::F9)
      # Set debug calling flag
      $game_temp.debug_calling = true
    end
    # If player is not moving
    unless $game_player.moving?
      # Run calling of each screen
      if $game_temp.battle_calling
        call_battle
      elsif $game_temp.shop_calling
        call_shop
      elsif $game_temp.name_calling
        call_name
      elsif $game_temp.menu_calling
        call_menu
      elsif $game_temp.save_calling
        call_save
      elsif $game_temp.debug_calling
        call_debug
      end
    end
  end
  #--------------------------------------------------------------------------
  #     Added For Fishing
  #--------------------------------------------------------------------------
  def call_fishing
    character = $game_player
    case character.direction
    when 2
      lookingx = character.x
      lookingy = character.y + 1
   when 4
      lookingx = character.x - 1
      lookingy = character.y
    when 6
      lookingx = character.x + 1
      lookingy = character.y
    when 8
      lookingx = character.x
      lookingy = character.y - 1
    end
    for i in 0..$game_party.actors.size
      actor = $game_party.actors[i].id
      if $data_weapons[$game_actors[actor].weapon_id] != nil
        if $data_armors[$game_actors[actor].armor1_id] != nil
          if $data_armors[$game_actors[actor].armor2_id] != nil
            if $data_armors[$game_actors[actor].armor3_id] != nil
              poleused = $data_weapons[$game_actors[actor].weapon_id]
              baitused = $data_armors[$game_actors[actor].armor1_id]
              lineused = $data_armors[$game_actors[actor].armor2_id]
              reelused = $data_armors[$game_actors[actor].armor3_id]
              if poleused.element_set.include?(17)
                if baitused.guard_element_set.include?(18)
                  if lineused.guard_element_set.include?(19)
                    if reelused.guard_element_set.include?(20)
                      if $game_map.terrain_tag(lookingx,lookingy) != 0
                        $waterlevel = $game_map.terrain_tag(lookingx,lookingy)
                        @event_counter = 0
                        for h in 1..999
                          if $game_map.events[h].id > @event_counter
                            @event_counter = $game_map.events[h].id
                          end
                        end
                        for h in 1..@event_counter
                          if  $game_map.events[h] != nil
                            if $game_map.events[h].x == lookingx and $game_map.events[h].y == lookingy
                              case $game_map.events[h].opacity
                              when 1
                                $waterlevel = 1
                              when 2
                                $waterlevel = 2
                              when 3
                                $waterlevel = 3
                              when 4
                                $waterlevel = 4
                              when 5
                                $waterlevel = 5
                              when 6
                                $waterlevel = 6
                              when 7
                                $waterlevel = 7
                              end
                            end
                          end
                        end
                        $fisherman = actor
                        $scene = Scene_Fishing.new
                        break
                      end
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
  #--------------------------------------------------------------------------
  #     Added For Fishing Ends
  #--------------------------------------------------------------------------
  #--------------------------------------------------------------------------
  # * Battle Call
  #--------------------------------------------------------------------------
  def call_battle
    # Clear battle calling flag
    $game_temp.battle_calling = false
    # Clear menu calling flag
    $game_temp.menu_calling = false
    $game_temp.menu_beep = false
    # Make encounter count
    $game_player.make_encounter_count
    # Memorize map BGM and stop BGM
    $game_temp.map_bgm = $game_system.playing_bgm
    $game_system.bgm_stop
    # Play battle start SE
    $game_system.se_play($data_system.battle_start_se)
    # Play battle BGM
    $game_system.bgm_play($game_system.battle_bgm)
    # Straighten player position
    $game_player.straighten
    # Switch to battle screen
    $scene = Scene_Battle.new
  end
  #--------------------------------------------------------------------------
  # * Shop Call
  #--------------------------------------------------------------------------
  def call_shop
    # Clear shop call flag
    $game_temp.shop_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to shop screen
    $scene = Scene_Shop.new
  end
  #--------------------------------------------------------------------------
  # * Name Input Call
  #--------------------------------------------------------------------------
  def call_name
    # Clear name input call flag
    $game_temp.name_calling = false
    # Straighten player position
    $game_player.straighten
    # Switch to name input screen
    $scene = Scene_Name.new
  end
  #--------------------------------------------------------------------------
  # * Menu Call
  #--------------------------------------------------------------------------
  def call_menu
    # Clear menu call flag
    $game_temp.menu_calling = false
    # If menu beep flag is set
    if $game_temp.menu_beep
      # Play decision SE
      $game_system.se_play($data_system.decision_se)
      # Clear menu beep flag
      $game_temp.menu_beep = false
    end
    # Straighten player position
    $game_player.straighten
    # Switch to menu screen
    $scene = Scene_Menu.new
  end
  #--------------------------------------------------------------------------
  # * Save Call
  #--------------------------------------------------------------------------
  def call_save
    # Straighten player position
    $game_player.straighten
    # Switch to save screen
    $scene = Scene_Save.new
  end
  #--------------------------------------------------------------------------
  # * Debug Call
  #--------------------------------------------------------------------------
  def call_debug
    # Clear debug call flag
    $game_temp.debug_calling = false
    # Play decision SE
    $game_system.se_play($data_system.decision_se)
    # Straighten player position
    $game_player.straighten
    # Switch to debug screen
    $scene = Scene_Debug.new
  end
  #--------------------------------------------------------------------------
  # * Player Place Move
  #--------------------------------------------------------------------------
  def transfer_player
    # Clear player place move call flag
    $game_temp.player_transferring = false
    # If move destination is different than current map
    if $game_map.map_id != $game_temp.player_new_map_id
      # Set up a new map
      $game_map.setup($game_temp.player_new_map_id)
    end
    # Set up player position
    $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
    # Set player direction
    case $game_temp.player_new_direction
    when 2  # down
      $game_player.turn_down
    when 4  # left
      $game_player.turn_left
    when 6  # right
      $game_player.turn_right
    when 8  # up
      $game_player.turn_up
    end
    # Straighten player position
    $game_player.straighten
    # Update map (run parallel process event)
    $game_map.update
    # Remake sprite set
    @spriteset.dispose
    @spriteset = Spriteset_Map.new
    # If processing transition
    if $game_temp.transition_processing
      # Clear transition processing flag
      $game_temp.transition_processing = false
      # Execute transition
      Graphics.transition(20)
    end
    # Run automatic change for BGM and BGS set on the map
    $game_map.autoplay
    # Frame reset
    Graphics.frame_reset
    # Update input information
    Input.update
  end
end

And this is the actual Fishing script by Tiberius_XXVII
Code: [Select]
#     This is the fishing script itself...
#
#     Instructions:
#
# 1. Add four elements in system, 17: Pole, 18: Lure, 19: Line, and 20: Reel.
# 2. Add some weapons to be fishing poles and give them the element "Pole."
# 3. Set the strength of the new weapons to any number. Higher number means stronger pole.
# 4. Add some shields to be lure and give them the element "Lure."
# 5. Set the evasion of the lures to something 100 or less. Lower number means better lure.
# 6. Add some helmets to be lines and give them the element "Line."
# 7. Set the evasion of the new lines to 100 or less. Higher numbers mean better line.
# 8. Add some armors to be reels and give them the element "Reel."
# 9. Set the evasion of these reels to something 5 or less. Higher numbers mean better reels. You can
#     also give the reels strength, this also increases the speed a fisher reels in.
# 10. Make item 33 bait.
# 11. Add some items and call them fish, then set their accuracy to 100 or below.
#       Lower number for accuracy means weaker fish.
# 12. Go to lines 105-146, and change the values there.
# 13. Import a picture to be used as a background and call it "FishingBackground.jpg"
# 14. Import an icon that looks like a ripple or bobber and call it "081-Ripple.png"
# 15. Make sure classes can use fishing poles, lures, lines, and reels!
# 16. Edit the tilesets and set the water in their terrain to a number 1-7.
#       Higher numbers mean more difficult fish in the water.
# 17. To give a piece of water a different level than the default of that tile, make an event on it and set
#       its graphic's opacity to 1-7, these numbers correspond to the difficulty set in step 12.
# 18. To fish, press Shift when you have bait, a pole, a lure, line, a reel and water in front of you.

#==============================================================================
#     Scene_Fishing
#------------------------------------------------------------------------------
#       The Fishing Scene
#==============================================================================

class Scene_Fishing
  #--------------------------------------------------------------------------
  #   The set up of the scene
  #--------------------------------------------------------------------------
  def initialize
    $distance = 0 #Sets the distance of your bobber to 0.
  end
#--------------------------------------------------------------------------
  def main
    @fishing_window = Window_Fishing.new
    @fishing_window.x = 0
    @fishing_window.y = 64
    @help_window = Window_Help.new
    $hooked = false #You don't have a fish on your hook yet.
    @wait_count = 0 #It's not waiting for anything.
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
  end
 
  #--------------------------------------------------------------------------
  #   The fishing part
  #--------------------------------------------------------------------------
  def update
    if @wait_count == 0 #If you're not waiting...
      $showfish = false
      if $game_party.item_number(33) > 0 #Makes sure you have bait.
        if Input.trigger?(Input::B) #If you press Esc then it plays a sound and quits.
          $game_system.se_play($data_system.cancel_se)
          @fishing_window.dispose
          @help_window.dispose
          $scene = Scene_Map.new
          return
        end
        if $distance <= 0 #If the distance between you and you're bobber is 0 or less.
          $distance = 0 #Than make sure distance is only 0, no less.
          if $hooked == true #If a fish was hooked, then catch it and wait a little.
            $hooked = false
            @help_window.set_text("You caught a " + $data_items[$fish].name + "!", 1)
            $showfish = true
            $game_party.gain_item($fish, 1)
            $game_system.me_play($data_system.battle_end_me)
            $game_actors[$fisherman].exp=($game_actors[$fisherman].exp + $data_items[$fish].hit)
            @fishing_window.refresh
            @wait_count = 100
          end
          if @wait_count == 0
            @help_window.set_text("Use the action key to cast!", 1) #Set the help window text to that.
            if Input.trigger?(Input::C) #If you press Spacebar...
              @help_window.set_text("You just cast your line...", 1) #It sets the help window text,
              Audio.se_play("Audio/SE/021-Dive01") #Plays a sound,
              $distance = $data_armors[$game_actors[$fisherman].armor2_id].eva * 18#Sets's distance
                                                                                                  #between you and your bobber.
            end
          end
        end
        if Input.trigger?(Input::C) #If you press Spacebar and a fish is hooked
          if $hooked == true
            actor = $game_actors[$fisherman]
            $distance = $distance - rand(Math.sqrt(actor.str *
            $data_armors[$game_actors[$fisherman].armor3_id].eva) * 2) #It sets distance to less based
                                                                                                      #on strength.
          end
        end
        if $distance > 0 #If distance is more than 0 and nothing is hooked then it reels in
          if $hooked == false
            $distance = $distance - $data_armors[$game_actors[$fisherman].armor3_id].eva
            if rand($distance) > 100 #And decides to hook something based on bait and distance.
              bait = $game_actors[$fisherman].armor1_id
              if rand($data_armors[bait].eva * 10) == 0
                $hooked = true
                case $waterlevel
                when 1
                  fishinwater =
                  [51, 51, 51, 51, 51, 52]
                when 2
                  fishinwater =
                  [52, 52, 53]
                when 3
                  fishinwater =
                  [53, 53, 54, 54]
                when 4
                  fishinwater =
                  [55, 55, 55, 56]
                when 5
                  fishinwater =
                  [56, 57, 58, 59]
                when 6
                  fishinwater =
                  [59, 59, 60, 60]
               when 7
                  fishinwater =
                  [61, 62]
                end
                $fish = fishinwater[rand(fishinwater.size)] #Decides which fish to hook.
                @help_window.set_text("You hooked something! Use the action key!", 1) #Says you got one
                $game_system.se_play($data_system.battle_start_se) #Plays a sound
                @wait_count = 50 #And waits.
              end
            end
          end
        end
        if $hooked == true #If something is hooked, the fish will try to pull away based on it's strength.
          $distance = $distance + rand(Math.sqrt($data_items[$fish].hit) * 2)
          if rand(80) == 0 #About 1 out of 80 times it will sound like the fish is splashing
            Audio.se_play("Audio/SE/022-Dive02")
          end
        end
        if $distance > $data_armors[$game_actors[$fisherman].armor2_id].eva * 20 #If the fish gets far
                                                          #away, it releases the fish, sets text, plays a sound, and waits.
          @help_window.set_text("The fish got away!", 1)
          if rand(5) == 0
            $game_party.lose_item(60, 1)
            @help_window.set_text("The fish got away with the bait!", 1)
          end
          $game_system.me_play($data_system.gameover_me)
          @wait_count = 50
          $hooked = false
        end
        @fishing_window.refresh #Updates the windows.
        @help_window.update
      else
        @help_window.set_text("You're out of bait.", 1)
        if Input.trigger?(Input::C) #If you press Spacebar then it quits.
          @fishing_window.dispose
          @help_window.dispose
          $scene = Scene_Map.new
          return
        end
      end
    else
      @wait_count =  @wait_count - 1 #Sets the wait count to less.
    end
  end
end

#==============================================================================
#   Window_Fishing
#==============================================================================
 
class Window_Fishing < Window_Base
  def initialize
    super(0, 0, 640, 416)
    self.contents = Bitmap.new(width - 32, height - 32)
    self.contents.font.name = $defaultfonttype
    self.contents.font.size = $defaultfontsize
    self.contents.clear
    refresh
  end
  def refresh
    self.contents.clear #Clears the picture
    bitmap = RPG::Cache.picture("FishingBackground.jpg") #And redraws it.
    self.contents.blt(0, 0, bitmap, Rect.new(0, 0, bitmap.width, bitmap.height))
    actor = $game_actors[$fisherman] #Chooses the actor to draw.
    draw_fisher(actor, 150, 320) #Draws character one at the point (150, 320).
    if $distance != 0 #If the bobber is out then it draws a ripple/bobber.
      bitmap = RPG::Cache.icon("081-Ripple.png")
      self.contents.blt(($distance / 5) + 160, 300, bitmap, Rect.new(0, 0, 24, 24))
    end
    if $showfish == true
      bitmap = RPG::Cache.icon($data_items[$fish].icon_name)
      self.contents.blt(165, 280, bitmap, Rect.new(0, 0, 24, 24))
    end
  end
  def draw_fisher(actor, x, y)
    bitmap = RPG::Cache.character(actor.character_name, actor.character_hue)
    cw = bitmap.width / 4
    ch = bitmap.height / 4
    src_rect = Rect.new(0, ch * 2, cw, ch)
    self.contents.blt(x - cw / 2, y - ch, bitmap, src_rect)
  end
end

I keep getting this error


Can anyone help me with this?
Thanks.