Well, I want to make use of the new Feature of the Support Forum, and ask for a little guide for this script that I was making today.
Then I splitted the script in the parts, but it's a little large, so I'll Include a demo for this uses.
First, I created some methods for personal uses, I only copy from the MACL and Re-edited to fit with my requests.
The Only problem that I cant solve, if the Event.Name, so I was wondering if there is another way to get the name, and another bad ways in the methods
events_name_has_string?
event_with_name
The Second part is the Comment Function, It Looks fine, but I want, in the future, put more kinds of Destructions Engines (Arrows and that), a tip to get ride of this part?
And the Last Part it's the engine itself, I get some problems with the Animation Display, so I used one of Tricksters Scripts (Display Animations) but it is old, so i was searching another form to display the animation at bomb x,y spot, (The animation isn't displayed because I delete the bomb event at the same time, but I use a Counter to determine when, so i have the problem there)..
Well, that's all, I used other scripts to get this (Like EventSpawner, SDK and some macl methods).
Because there are too may scripts, I make a demo, so you can view how it works, and give a complete diagnostic of this code.
http://www.4shared.com/file/90807698/e4 ... ect18.html
That's all, thanks for giveme your help, tips, and whatever you say
Then I splitted the script in the parts, but it's a little large, so I'll Include a demo for this uses.
First, I created some methods for personal uses, I only copy from the MACL and Re-edited to fit with my requests.
The Only problem that I cant solve, if the Event.Name, so I was wondering if there is another way to get the name, and another bad ways in the methods
events_name_has_string?
event_with_name
Code:
#==============================================================================
# ** Game_Map
#==============================================================================
Â
class Game_Map
 #-------------------------------------------------------------------------
 # * Name    : delete_event_at
 #  Info    : Delete event at [x,y] position
 #  Author   : MephistoX
 #  Call Info : Two Arguments Integer X, Y - Event coordinates to delete
 #-------------------------------------------------------------------------
 def delete_event_at(x, y)
  # If exist an event at [x,y] position, store the event_id
  event_id = event?(x, y) ? event_at(x, y).id : nil
  # Delete event with id = id
  delete_event(event_id)
 end
 #-------------------------------------------------------------------------
 # * Name    : Events names have string?
 #  Info    : If any event on map include string
 #  Author   : MephistoX
 #  Call Info : One Argument, String to check
 #-------------------------------------------------------------------------
 def events_name_has_string?(string)
  # Pass through all Map Events
  @events.each_value do |event|
   # If any map events names include the string
   return true if event.name.include?(string)
  end
  return false
 end
 #-------------------------------------------------------------------------
 # * Name    : Event With Name
 #  Info    : Return Event ID with Defined Name
 #  Author   : MephistoX
 #  Call Info : One Argument, Name to Check(String)
 #-------------------------------------------------------------------------
 def event_with_name(name)
  # Pass through all Map Events
  @events.each_value do |event|
   return event.id if event.name.include?(name)
  end
  return nil Â
 end
 #-------------------------------------------------------------------------
 # * Name    : Event With Name
 #  Info    : Return Event ID with Defined Name and Delete It!
 #  Author   : MephistoX
 #  Call Info : One Argument, Name of the Event to delete
 #-------------------------------------------------------------------------
 def event_with_name!(name)
  delete_event(event_with_name(name))
 end
end
Â
Â
#==============================================================================
# ** Game_Event
#==============================================================================
Â
class Game_Event < Game_Character
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader :name
 #--------------------------------------------------------------------------
 # * Alias Listing
 #--------------------------------------------------------------------------
 alias_method :meph_furni_gvent_init, :initialize
 #--------------------------------------------------------------------------
 # * Object Initialization
 #--------------------------------------------------------------------------
 def initialize(*args)
  # Original Initialize
  meph_furni_gvent_init(*args)
  # Set Event Name
  @name = @event.name
 end
end
The Second part is the Comment Function, It Looks fine, but I want, in the future, put more kinds of Destructions Engines (Arrows and that), a tip to get ride of this part?
Code:
#==============================================================================
# ** Game_Event
#==============================================================================
Â
class Game_Event
 #--------------------------------------------------------------------------
 # * Public Instance Variables
 #--------------------------------------------------------------------------
 attr_reader :destroyable
 #--------------------------------------------------------------------------
 # * Alias Listing
 #--------------------------------------------------------------------------
 alias_method :meph_dyne_bombs_gvent_refresh, :refresh
 #--------------------------------------------------------------------------
 # * Refresh
 #--------------------------------------------------------------------------
 def refresh
  # Original Refresh
  meph_dyne_bombs_gvent_refresh
  # Clear Destroyable Flag
  @destroyable = false
  # Return if Erased
  return if @erased || @list.nil?
  # Pass through event commands
  for ec in @list
   # Skip if not comment
   next unless ec.code == 108
   # If Comment Inlclude Destroyable
   if ec.parameters[0].include?(Bombs::Destroyable_Comment)
    @destroyable = true
    break
   end
  end
 end
end
And the Last Part it's the engine itself, I get some problems with the Animation Display, so I used one of Tricksters Scripts (Display Animations) but it is old, so i was searching another form to display the animation at bomb x,y spot, (The animation isn't displayed because I delete the bomb event at the same time, but I use a Counter to determine when, so i have the problem there)..
Code:
module Bombs
Bomb_Item_ID = 1
Bomb_Graphic = 'MP_001-Bomb01'
Bomb_Name = 'Bomb_Event'
Bomb_Counter = 60
Bomb_Range = 1
Destroyable_Comment = 'Destroyable'
Bomb_Animation = 99
Bombable_Maps = [1]
#--------------------------------------------------------------------------
# * Put Bomb
#--------------------------------------------------------------------------
def self.put_bomb
unless self.can_put_bomb?
# Play buzzer SE
$game_system.se_play($data_system.buzzer_se)
return
end
# Play Equip SE
$game_system.se_play($data_system.equip_se)
# Create Bomb Event
Event_Spawner::Events.bomb_event
# Lose Bomb Item from Inventory
$game_party.lose_item(Bomb_Item_ID, 1)
end
#--------------------------------------------------------------------------
# * Can Put Bomb? : Determine If it's possible put the bomb in the map
#--------------------------------------------------------------------------
def self.can_put_bomb?
# Return False if in the Current Map Can put Bombs
return false unless Bombable_Maps.include?($game_map.map_id)
# Return False if Party doesn't have Bombs
return false if $game_party.item_number(Bomb_Item_ID) == 0
# Return False if There is a Bomb at the moment of Check
return false if $game_map.events_name_has_string?(Bomb_Name)
# Return True/Flase If the Tile in-front of Player is Pasable
return (gp = $game_player).passable?(gp.x, gp.y, gp.direction)
end
#--------------------------------------------------------------------------
# * Bomb Detonation : Begin Bomb Detonation Engine
#--------------------------------------------------------------------------
def self.bomb_detonation
# Set Bomb Event ID
bomb = (gm = $game_map).events[gm.event_with_name(Bomb_Name)]
# Show Animation where is the Bomb
$animations.push(Animation.new('tile', bomb.x, bomb.y, Bomb_Animation))
# Pass Through Events in the Map
$game_map.events.each_value do |event|
# Check if Events in Bomb Range are Destroyables
if VR.in_range?(bomb, event, Bomb_Range) && event.destroyable
# Erase the Events
event.erase
end
# Remove Bomb from Events List
$game_map.event_with_name!(Bomb_Name)
end
end
end
#==============================================================================
# ** Scene_Map
#==============================================================================
Â
class Scene_Map
 #--------------------------------------------------------------------------
 # * Alias Listings
 #--------------------------------------------------------------------------
 alias_method :meph_dyne_bombs_scmap_main,   :main
 alias_method :meph_dyne_bombs_scmap_update,  :update
 #--------------------------------------------------------------------------
 # * Main Processing
 #--------------------------------------------------------------------------
 def main
  @bomb_counter = Bombs::Bomb_Counter
  meph_dyne_bombs_scmap_main
 end
 #--------------------------------------------------------------------------
 # * Frame Update
 #--------------------------------------------------------------------------
 def update
  # Original Update
  meph_dyne_bombs_scmap_update
  # If Z Button was pressed
  if Input.trigger?(Input::Z)
   # Put Bomb
   Bombs.put_bomb
  end
  # Begin the Chronometer if There is a bomb in the map (Checked by Name)
  @bomb_counter -= 1 if $game_map.events_name_has_string?(Bombs::Bomb_Name)
  # If Bomb Counter is 0
  if @bomb_counter == 0
   # Detone Bomb
   Bombs.bomb_detonation
   # Reset the Bomb Counter to Original Counter
   @bomb_counter = Bombs::Bomb_Counter
  end
 end
end
Well, that's all, I used other scripts to get this (Like EventSpawner, SDK and some macl methods).
Because there are too may scripts, I make a demo, so you can view how it works, and give a complete diagnostic of this code.
http://www.4shared.com/file/90807698/e4 ... ect18.html
That's all, thanks for giveme your help, tips, and whatever you say