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.

BombScript with Errors.

Hello again, if you remember i make a request of a bomb script very months ago, I request the script to dargor, he make me te script and all OK... but i have a problem with this.

The problem is that when i make maps with more tiles that 20*15 the bomb follow the actor and that is a very ugly bug, there are a scripter that can fix the bug?. because dargor its busy (Thanks for all Dargor).. thanks

And all these bugs must be fix also.

1. The comment function of the script not work.
2. The priority of the bomb its very high in the layers.
3. The bomb can be put in an non passable tile and on the events.
4. When you use a bomb you will lose 1 unity of item:BOMB, but this not happen.

this is the original request, the script have all the request tips:

http://www.rmxp.org/forums/showthread.php?t=24762&highlight=bomb

this is the script:

Code:
#==============================================================================
# ** Bomb Engine
#------------------------------------------------------------------------------
#  Author: Dargor
#  Requested by: Mephisto
#  Version 1.0
#  15/07/2007
#==============================================================================

#==============================================================================
# ** Customization Module
#==============================================================================

module Dargor
  module Bomb_Engine
    Icon = "036-Item05"
    Animation_ID = 27
    Required_Level = 1
    Wait = 60
    Key = Input::SHIFT
    Required_Acc = 5
    Item_ID = 33
    Switch_ID = 1
    Range = 1
    Activation_Comment = 'Bomb Engine'
    Self_Switch = 'A'
    Timer = 60
    Use_Accessory = false
  end
end

#==============================================================================
# ** View Range Module
#==============================================================================
# Near Fantastica
# Version 4
# 29.11.05
#==============================================================================
module VR
  #----------------------------------------------------------------------------
  def VR.in_range?(element, object, range)
    x = (element.x - object.x) * (element.x - object.x)
    y = (element.y - object.y) * (element.y - object.y)
    r = x + y
    if r <= (range * range)
      return true
    else
      return false
    end
  end
  #----------------------------------------------------------------------------
  def VR.range(element, object)
    x = (element.x - object.x) * (element.x - object.x)
    y = (element.y - object.y) * (element.y - object.y)
    r = x + y
    r = Math.sqrt(r)
    return r.to_i
  end
end
#==============================================================================
class Interpreter
  #----------------------------------------------------------------------------
  def event
    return $game_map.events[@event_id]
  end
end

#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
#  Refer to "$game_temp" for the instance of this class.
#==============================================================================

class Game_Temp
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :bomb_x   # Bomb X axis
  attr_accessor :bomb_y   # Bomb Y axis
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias bomb_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @bomb_x = 0
    @bomb_y = 0
    # Original method
    bomb_initialize
  end
end

#==============================================================================
# ** Game_Party
#------------------------------------------------------------------------------
#  This class handles the party. It includes information on amount of gold 
#  and items. Refer to "$game_party" for the instance of this class.
#==============================================================================

class Game_Party
  #--------------------------------------------------------------------------
  # * Has item
  #--------------------------------------------------------------------------
  def has_item?(id)
    return @items.include?(id)
  end
end

#==============================================================================
# ** Game_Event
#------------------------------------------------------------------------------
#  This class deals with events. It handles functions including event page 
#  switching via condition determinants, and running parallel process events.
#  It's used within the Game_Map class.
#==============================================================================

class Game_Event
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :bomb     # Is a bomb, true/false
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias bomb_initialize initialize
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     map_id : map ID
  #     event  : event (RPG::Event)
  #--------------------------------------------------------------------------
  def initialize(map_id, event_id)
    # Original method
    bomb_initialize(map_id, event_id)
    @bomb = false
  end
end

#==============================================================================
# ** Game_Bomb
#------------------------------------------------------------------------------
#  This class is a dummy bomb class used to calculate the bomb's range.
#==============================================================================

class Game_Bomb
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :x
  attr_accessor :y
  #--------------------------------------------------------------------------
  # * Object Initialization
  #     x : X axis
  #     y : Y axis
  #--------------------------------------------------------------------------
  def initialize(x,y)
    self.x = x
    self.y = y
  end
end

#==============================================================================
# ** Scene_Map
#------------------------------------------------------------------------------
#  This class performs map screen processing.
#==============================================================================

class Scene_Map
  #--------------------------------------------------------------------------
  # * Alias Listing
  #--------------------------------------------------------------------------
  alias bomb_main main
  alias bomb_update update
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Make the bomb counters
    @bomb_count = 0
    @bomb_timer = -1
    # Make the bomb sprite
    bitmap = RPG::Cache.icon(Dargor::Bomb_Engine::Icon)
    @bomb = RPG::Sprite.new
    @bomb.bitmap = bitmap
    @bomb.z = 1
    @bomb.visible = false
    # Evaluate each bomb targets
    $game_map.events.values.each do |event|
      parameters = SDK.event_comment_input(event, 0, Dargor::Bomb_Engine::Activation_Comment)
      if parameters != nil
        event.bomb = true
      end
    end
    # Original method
    bomb_main
    # Dispose of bomb sprite
    @bomb.dispose
    @bomb.bitmap.dispose
  end
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
    # Bomb sprite update
    @bomb.update
    # Original method
    bomb_update
    # Bomb engine update
    update_bomb_engine
  end
  #--------------------------------------------------------------------------
  # * Frame Update (Bomb Engine)
  #--------------------------------------------------------------------------
  def update_bomb_engine
    return unless $game_switches[Dargor::Bomb_Engine::Switch_ID]
    if Input.trigger?(Dargor::Bomb_Engine::Key)
      # Place the bomb on map
      place_bomb
    end
    # Timer processing
    @bomb_timer -= 1 unless @bomb_timer == -1
    # Blowing up the bomb
    if @bomb_timer == 0
      $game_map.events.values.each do |event|
        next unless event.bomb
        dummy_bomb = Game_Bomb.new(@bomb.x/32,@bomb.y/32)
        if VR.in_range?(dummy_bomb,event,Dargor::Bomb_Engine::Range)
          # Activation of the Self Switch
          key = [$game_map.map_id, event.id, Dargor::Bomb_Engine::Self_Switch]
          $game_self_switches[key] = true
          $game_map.need_refresh = true
        end
      end
      # Bomb animation
      animation_id = Dargor::Bomb_Engine::Animation_ID
      @bomb.animation($data_animations[animation_id],true)
      # Delete the bomb
      @bomb.visible = false
    end
  end
  def place_bomb
    # Bomb availability tests
    return if Graphics.frame_count < @bomb_count + Dargor::Bomb_Engine::Wait
    return if $game_party.actors[0].level < Dargor::Bomb_Engine::Required_Level
    if Dargor::Bomb_Engine::Use_Accessory
      if $game_party.actors[0].armor4_id != Dargor::Bomb_Engine::Required_Acc
        return 
      end
    end
    return unless $game_party.has_item?(Dargor::Bomb_Engine::Item_ID)
    # Remove 1 bomb
    $game_party.lose_item(Dargor::Bomb_Engine::Item_ID,1)
    # Adjusting the bomb's x & y coords depending on the player's direction
    case $game_player.direction
    when 2 # Down
      x = $game_player.x
      y = $game_player.y + 1
    when 4 # Left
      x = $game_player.x - 1
      y = $game_player.y
    when 6 # Right
      x = $game_player.x + 1
      y = $game_player.y
    when 8 # Up
      x = $game_player.x
      y = $game_player.y - 1
    end
    $game_temp.bomb_x = x
    $game_temp.bomb_y = y
    @bomb.x = 4 + x * 32
    @bomb.y = 4 + y * 32
    @bomb.visible = true
    # Start timers
    @bomb_count = Graphics.frame_count
    @bomb_timer = Dargor::Bomb_Engine::Timer
  end
end

Thanks for advance, this is a great script, but the bugs destroy the beautiful of the code.
the script requires the SDK (its there are a fly XD)
 

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