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.
Portals [Now V1.1!]

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 85
Portals
Version: 1.1
Author: AmIMeYet
Release Date: 13/02/09

    Introduction
    It's finally here.. a portalgun for RPG Maker VX!
   
    Features
   
  • Easy to use settings!
  • Works both ways!
  • Red an Blue portal
  • Erase function
  • Advanced function.. (running a script on error; etc.)
  New in V1.1:
  • added BULLET_SPEED
  • fixed player from gettings stuck in wall

    DEMO
    V1.1: (LATEST)
    Mediafire

    V1.0:
    Mediafire
    Mirror 1

    Script -- Use Demo instead! (it includes required images)
   
Spoiler for Portalgun v1.1:
Code: [Select]
#==============================================================================#
#==============?  Name:     Portals                             ?==============#
#==============?  Author:   AmIMeYet                            ?==============#
#==============?  Version:  1.1                                 ?==============#
#==============?  Release:  13/02/09 (dd/mm/yy)                 ?==============#
#==============?  Website:  amimeyet.890m.com / amimeyet.nl.tp  ?==============#
#==============================================================================#
##§Description:::::
#   This script adds a portal-gun/shooter to RPG Maker VX
#
#§Instructions::::
#   All you need to do is look at the first lines of 'module Amimeyet_portals';
#   Look for ###BASIC SETTINGS###.. that's where you want to edit..
#   Look at the comments there to find out what to do.
#
#   These are the settings:
#       SHOOT_B, SHOOT_R, REMOVE, CHECK, GUN_ID, START_SHOOTABLE, RANGE,
#                BULLET_SPEED
#   The default values are:
#       Input::X, Input::Z, Input::Y, 1, 31, true, 20, 6

#§New in v1.1:::::
#   ?added BULLET_SPEED
#   ?fixed player from gettings stuck in wall
#
#§Bugs::::::::::::
#   ?There may be no event ID missing in your map
#           (Example: 9 events.. but no event 3)
#     So say you create three events on a map.. and then delete the second,
#     instead of a portal erasing.. you erase the third event.
#     counteract this by cutting (Ctrl+X) and pasting (Ctrl+V) the last event,
#     (in this case the third), so that it gets an ID of '2'.
#
#§Special thanks::
#   SephirothSpawn,
#           for his map data decrypter (a MUST HAVE to do this sort of thing)
#           http://www.hbgames.org/forums/viewtopic.php?f=7&t=60928
#
#§Disclaimer::::::
#   ?If you use this script on your game, you must credit me.
#   ?If you want to put this script on a website or forum,
#         you must ask me for permission.
#   ?You are free to use any graphics found in this demo, but,
#       you MUST ABSOLUTELY credit me.
#   ?Portal is a registered trademark of Valve Corporation
#
#§Advanced usage::
#   Advanced settings:
#    ?Take a look at ###ADVANCED SETTINGS###
#   Functions:
#    ?Amimeyet_portals::erase(type) - "blue","red" - Erase the specified portals
#    ?Amimeyet_portals::teleport(type) - "blue","red" - Teleport to oposite portal
#       "blue" teleports player to red
#       "red" teleports player to blue
#    ?Amimeyet_portals::shoot(type) - "blue","red" - Launch specified portal
#   Aliases:
#    ?Game_System:initialize || Also added attr_accessor :shoot_enabled
#    ?Scene_Map:update
#    ?Scene_Map:start
#==============================================================================#

#==============================================================================#
#======================== module Amimeyet_portals =============================#
#========= Includes all settings and functions of the portals script ==========#
#==============================================================================#
module Amimeyet_portals
  ###BASIC SETTINGS###
  SHOOT_B = Input::X      #What button to press, to shoot the blue portal
  SHOOT_R = Input::Z      #What button to press, to shoot the red portal
  REMOVE = Input::Y       #What button to press, to remove both portals
 
  CHECK   = 1             #Type of the 'can shoot' check
                            #1 = Equipped weapon with id of GUN_ID
                            #2 = Use the START_SHOOTABLE value
                            #3 = I'll set it later using
                                      #$game_system.shoot_enabled = true
                                     
  GUN_ID  = 31            #The ID of the portalgun weapon.
                            #Only works if CHECK = 1
                           
  START_SHOOTABLE = true  #Can you shoot at the beginning?
 
  RANGE = 20              #Number of tiles you can shoot
  BULLET_SPEED = 6        #The speed of the bullet
                            #1 = x8 slower
                            #2 = x4 slower
                            #3 = x2 slower
                            #4 = normal
                            #5 = x2 faster
                            #6 = x4 faster
   
  ###ADVANCED SETTINGS###
 
  #These are little pieces of code to execute at the specific error..
  #This can be anything from a message window ('p'), to s $scene change..
  #Its pure RUBY, and my script eval()'s it...
 
  #The piece of code to run when the user tries to shoot, but it is disabled..
  DISABLED_SHOOT = "#do nothing.. it's a comment"
  #The piece of code to run when the erase function is called,
  #   but no type is supplied
  NO_ERASE_TYPE = "#do nothing.. it's a comment"
 
  DB_ALLOW_MULT_PORTALS = false #Set to true to stop portals from auto-deleting
  DB_ALLOW_REMOVE = true        #If true, the erase button can be pressed
 
  ###END OF SETTINGS###             
                                   
  @prev_blue_id = []
  @prev_red_id = []
                                   
  def self.erase(type = "none")
   if DB_ALLOW_REMOVE
    if type == "blue"
      if @prev_blue_id.length > 0
        for i in 0...@prev_blue_id.length
          $game_map.events[@blue_id].erase
        end
      end       
    elsif type == "red"
      if @prev_red_id.length > 0
        for i in 0...@prev_red_id.length
          $game_map.events[@red_id].erase
        end
      end
    else
      #What to do when no erasy type is supplied:
      eval(NO_ERASE_TYPE)
    end
    $scene = Scene_Map.new #Refresh
   end
 end
 
 def self.teleport(type)
    direction = $game_player.direction
    for i in 0...30
      Graphics.update
    end
    if type == "blue"
      if $game_map.events.has_key?(@red_id)
      x = $game_map.events[@red_id].x
      y = $game_map.events[@red_id].y
      if $game_map.events[@red_id].direction == 8 #if the portal is looking up
        y += 1 #get it out of the wall/block
      end
      $game_player.moveto(x, y)
      end
    elsif type == "red"
      if $game_map.events.has_key?(@blue_id)
      x = $game_map.events[@blue_id].x
      y = $game_map.events[@blue_id].y
      if $game_map.events[@blue_id].direction == 8 #if the portal is looking up
        y += 1 #get it out of the wall/block
      end
      $game_player.moveto(x, y)
      end
    end
  end
  def self.shoot(type)
#dir
    case $game_player.direction
     when 8 #up
       pdir = 8
       x = $game_player.x
       y = $game_player.y - 1
       dir = RPG::MoveCommand.new(19)
     when 6 #right
       pdir = 6
       x = $game_player.x + 1
       y = $game_player.y
       dir = RPG::MoveCommand.new(18)
     when 4 #down
       pdir = 4
       x = $game_player.x - 1
       y = $game_player.y
       dir = RPG::MoveCommand.new(17)
     when 2 #left
       pdir = 2
       x = $game_player.x
       y = $game_player.y + 1
       dir = RPG::MoveCommand.new(16)
     end   
#move
    if $game_map.passable?(x, y)
    mv1 = RPG::MoveCommand.new(12)
    mv2 = RPG::MoveCommand.new(0)
    move_r = RPG::MoveRoute.new()
    move_r.repeat = false
    move_r.skippable = true
    move_r.wait = true
    move_r.list = [dir]
    for i in 0...RANGE
      move_r.list.push(mv1)
    end
    move_r.list.push(mv2)
    move = RPG::EventCommand.new(205, 0, [0, move_r])
    end
#touch
    t1 = RPG::MoveCommand.new(37)
    if pdir == 8 and  #up
      if $game_map.passable?(x, y)
      t2 = RPG::MoveCommand.new(12) #move 1 tile further
      else
      t2 = RPG::MoveCommand.new(15, [0]) #wait 0 frames
      end
    else
      if $game_map.passable?(x, y)
      t2 = RPG::MoveCommand.new(15, [0]) #wait 0 frames
      else
      t2 = RPG::MoveCommand.new(13, [0]) #move 1 tile back
      end
    end
    t3 = RPG::MoveCommand.new(38)
    t4 = RPG::MoveCommand.new(35)
    t5 = RPG::MoveCommand.new(34)
    case type
        when "blue"
    t6 = RPG::MoveCommand.new(41, ["!portals", 0]) #BP opening sequence
    t8 = RPG::MoveCommand.new(41, ["!portals", 1])
    t9 = RPG::MoveCommand.new(41, ["!portals", 2])
        when "red"
    t6 = RPG::MoveCommand.new(41, ["!portals", 4]) #RP opening sequence
    t8 = RPG::MoveCommand.new(41, ["!portals", 5])
    t9 = RPG::MoveCommand.new(41, ["!portals", 6])
    end
    t7 = RPG::MoveCommand.new(15, [10])
    t10 = RPG::MoveCommand.new(0)
    touch_r = RPG::MoveRoute.new()
    touch_r.repeat = false
    touch_r.skippable = false
    touch_r.wait = true #13
    if $game_map.passable?(x, y)
    touch_r.list = [dir, t1, t2, t3, t4, t5, t6, t7, t8, t7, t9, t7, t10]
    else
    touch_r.list = [dir, t1, t2, t3, t4, t5, t6, t7, t8, t7, t9, t7, t10]
    end
    touch = RPG::EventCommand.new(205, 0, [0, touch_r])
#tp
    case type
      when "blue"
    tp = RPG::EventCommand.new(355, 0, ["Amimeyet_portals::teleport(\"blue\")"])
      when "red"
    tp = RPG::EventCommand.new(355, 0, ["Amimeyet_portals::teleport(\"red\")"])
    end
#turn
    turn_r = RPG::MoveRoute.new()
    turn_r.repeat = false
    turn_r.skippable = false
    turn_r.wait = true
    turn_r.list = [dir]
    turn = RPG::EventCommand.new(205, 0, [0, turn_r])
#switch
    switch = RPG::EventCommand.new(123, 0, ["A", 0])
#pend
    pend = RPG::EventCommand.new(0, 0, [])
#cond
    cond = RPG::Event::Page::Condition.new
    cond.self_switch_valid = true
    cond.self_switch_ch = "A"
#img
    img = RPG::Event::Page::Graphic.new #Set the bullet image
    if $game_map.passable?(x, y)
    img.tile_id = 0
    img.character_name = "!Flame"
    img.character_index = 6
    img.direction = 2
    img.pattern = 1
    else
    img.character_index = 0
    img.direction = 2
    img.pattern = 0
    end
   
#img2
    img2 = RPG::Event::Page::Graphic.new #Set the open portal image.. Deprecated
    img2.tile_id = 0
    img2.character_name = "!portals"
    case type
      when "blue"
    img2.character_index = 2
      when "red"
    img2.character_index = 6
    end
    img2.direction = pdir
    img2.pattern = 1
#page 1
    p1 = RPG::Event::Page.new
    p1.trigger = 4
    p1.priority_type = 1
    if $game_map.passable?(x, y)
    p1.list = [move, touch, switch, pend]
    else
    p1.list = [touch, switch, pend]
    end
    p1.graphic = img
    p1.move_speed = BULLET_SPEED #Set the speed to more than the default..
#page 2
    p2 = RPG::Event::Page.new
    p2.condition = cond
    p2.trigger = 1
    p2.priority_type = 1
    p2.graphic = img2
    p2.walk_anime = true
    p2.step_anime = false
    p2.list = [tp, pend]
    p2.direction_fix = true
#bullet
    bullet = RPG::Event.new(x,y)
    bullet.id = $game_map.events.size + 1
    bullet.pages = [p1, p2]
    case type
      when "blue"
    bullet.name = "blue portal"
    #It's important to erase the previous portal, before overwriting it below
    self.erase("blue") if !DB_ALLOW_MULT_PORTALS
    @blue_id = bullet.id
    @prev_blue_id[@prev_blue_id.length + 1] = @blue_id
      when "red"
    bullet.name = "red portal"
    #It's important to erase the previous portal, before overwriting it below
    self.erase("red") if !DB_ALLOW_MULT_PORTALS
    @red_id = bullet.id
    @prev_red_id[@prev_red_id.length + 1] = @red_id
    end
    if type == "red" || "blue"
    event = Game_Event.new($game_map.map_id, bullet)
    $game_map.events[$game_map.events.size + 1] = event
    end
    $scene = Scene_Map.new #Refresh
  end
end

#==============================================================================#
#=========================== class Game_System ================================#
#========= Aliassed [initialize], added attr_accessor :shoot_enabled ==========#
#==============================================================================#
class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :shoot_enabled   # Can you shoot?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias amimeyet_shoot_enabled_initialize initialize
  def initialize
    # Run Original Method
    amimeyet_shoot_enabled_initialize
    # can shoot if the check type is 2
    @shoot_enabled = true if Amimeyet_portals::CHECK == 2
  end
end

#==============================================================================#
#============================ class Scene_Map =================================#
#======================= Aliassed [start, update]==============================#
#==============================================================================#
class Scene_Map < Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias amimeyet_shoot_key_update update
  alias amimeyet_shoot_start start
  def update
    amimeyet_shoot_key_update
   
    if $game_system.shoot_enabled
      Amimeyet_portals::shoot("blue") if Input.trigger? (Amimeyet_portals::SHOOT_B)
      Amimeyet_portals::shoot("red") if Input.trigger? (Amimeyet_portals::SHOOT_R)
      if Input.trigger? (Amimeyet_portals::REMOVE)
        Amimeyet_portals::erase("blue")
        Amimeyet_portals::erase("red")
      end
    else
      #What to do when shooting is disabled:
      eval(Amimeyet_portals::DISABLED_SHOOT)
    end
  end
  def start
    amimeyet_shoot_start
    if Amimeyet_portals::CHECK == 1
      for item in $game_party.members[0].equips
        if item.id == Amimeyet_portals::GUN_ID
          $game_system.shoot_enabled = true
          break
        end
      end
    end
  end
end
Spoiler for Portalgun v1.0:
Code: [Select]
#==============================================================================#
#==============?  Name:     Portals                             ?==============#
#==============?  Author:   AmIMeYet                            ?==============#
#==============?  Version:  1.0                                 ?==============#
#==============?  Release:  13/02/09 (dd/mm/yy)                 ?==============#
#==============?  Website:  amimeyet.890m.com / amimeyet.nl.tp  ?==============#
#==============================================================================#
##§Description:::::
#   This script adds a portal-gun/shooter to RPG Maker VX
#
#§Instructions::::
#   All you need to do is look at the first lines of 'module Amimeyet_portals';
#   Look for ###BASIC SETTINGS###.. that's where you want to edit..
#   Look at the comments there to find out what to do.
#
#   These are the settings:
#       SHOOT_B, SHOOT_R, REMOVE, CHECK, GUN_ID, START_SHOOTABLE, RANGE
#   The default values are:
#       Input::X, Input::Z, Input::Y, 1, 31, true, 20

#§Bugs::::::::::::
#   ?There may be no event ID missing in your map
#           (Example: 9 events.. but no event 3)
#     So say you create three events on a map.. and then delete the second,
#     instead of a portal erasing.. you erase the third event.
#     counteract this by cutting (Ctrl+X) and pasting (Ctrl+V) the last event,
#     (in this case the third), so that it gets an ID of '2'.
#
#§Special thanks::
#   SephirothSpawn,
#           for his map data decrypter (a MUST HAVE to do this sort of thing)
#           http://www.hbgames.org/forums/viewtopic.php?f=7&t=60928
#
#§Disclaimer::::::
#   ?If you use this script on your game, you must credit me.
#   ?If you want to put this script on a website or forum,
#         you must ask me for permission.
#   ?You are free to use any graphics found in this demo, but,
#       you MUST ABSOLUTELY credit me.
#   ?Portal is a registered trademark of Valve Corporation
#
#§Advanced usage::
#   Advanced settings:
#    ?Take a look at ###ADVANCED SETTINGS###
#   Functions:
#    ?Amimeyet_portals::erase(type) - "blue","red" - Erase the specified portals
#    ?Amimeyet_portals::teleport(type) - "blue","red" - Teleport to oposite portal
#       "blue" teleports player to red
#       "red" teleports player to blue
#    ?Amimeyet_portals::shoot(type) - "blue","red" - Launch specified portal
#   Aliases:
#    ?Game_System:initialize || Also added attr_accessor :shoot_enabled
#    ?Scene_Map:update
#    ?Scene_Map:start
#==============================================================================#

#==============================================================================#
#======================== module Amimeyet_portals =============================#
#========= Includes all settings and functions of the portals script ==========#
#==============================================================================#
module Amimeyet_portals
  ###BASIC SETTINGS###
  SHOOT_B = Input::X      #What button to press, to shoot the blue portal
  SHOOT_R = Input::Z      #What button to press, to shoot the red portal
  REMOVE = Input::Y       #What button to press, to remove both portals
 
  CHECK   = 1             #Type of the 'can shoot' check
                            #1 = Equipped weapon with id of GUN_ID
                            #2 = Use the START_SHOOTABLE value
                            #3 = I'll set it later using
                                      #$game_system.shoot_enabled = true
                                     
  GUN_ID  = 31            #The ID of the portalgun weapon.
                            #Only works if CHECK = 1
                           
  START_SHOOTABLE = true  #Can you shoot at the beginning?
 
  RANGE = 20              #Number of tiles you can shoot
   
  ###ADVANCED SETTINGS###
 
  #These are little pieces of code to execute at the specific error..
  #This can be anything from a message window ('p'), to s $scene change..
  #Its pure RUBY, and my script eval()'s it...
 
  #The piece of code to run when the user tries to shoot, but it is disabled..
  DISABLED_SHOOT = "#do nothing.. it's a comment"
  #The piece of code to run when the erase function is called,
  #   but no type is supplied
  NO_ERASE_TYPE = "#do nothing.. it's a comment"
 
  DB_ALLOW_MULT_PORTALS = false #Set to true to stop portals from auto-deleting
  DB_ALLOW_REMOVE = true        #If true, the erase button can be pressed
 
  ###END OF SETTINGS###             
                                   
  @prev_blue_id = []
  @prev_red_id = []
                                   
  def self.erase(type = "none")
   if DB_ALLOW_REMOVE
    if type == "blue"
      if @prev_blue_id.length > 0
        for i in 0...@prev_blue_id.length
          $game_map.events[@blue_id].erase
        end
      end       
    elsif type == "red"
      if @prev_red_id.length > 0
        for i in 0...@prev_red_id.length
          $game_map.events[@red_id].erase
        end
      end
    else
      #What to do when no erasy type is supplied:
      eval(NO_ERASE_TYPE)
    end
    $scene = Scene_Map.new
   end
 end
 
 def self.teleport(type)
    direction = $game_player.direction
    for i in 0...30
      Graphics.update
    end
    if type == "blue"
      if $game_map.events.has_key?(@red_id)
      x = $game_map.events[@red_id].x
      y = $game_map.events[@red_id].y
      $game_player.moveto(x, y)
      end
    elsif type == "red"
      if $game_map.events.has_key?(@blue_id)
      x = $game_map.events[@blue_id].x
      y = $game_map.events[@blue_id].y
      $game_player.moveto(x, y)
      end
    end
  end
  def self.shoot(type)
#dir
    case $game_player.direction
     when 8 #up
       pdir = 8
       x = $game_player.x
       y = $game_player.y - 1
       dir = RPG::MoveCommand.new(19)
     when 6 #right
       pdir = 6
       x = $game_player.x + 1
       y = $game_player.y
       dir = RPG::MoveCommand.new(18)
     when 4 #down
       pdir = 4
       x = $game_player.x - 1
       y = $game_player.y
       dir = RPG::MoveCommand.new(17)
     when 2 #left
       pdir = 2
       x = $game_player.x
       y = $game_player.y + 1
       dir = RPG::MoveCommand.new(16)
     end   
#move
    if $game_map.passable?(x, y)
    mv1 = RPG::MoveCommand.new(12)
    mv2 = RPG::MoveCommand.new(0)
    move_r = RPG::MoveRoute.new()
    move_r.repeat = false
    move_r.skippable = true
    move_r.wait = true
    move_r.list = [dir]
    for i in 0...RANGE
      move_r.list.push(mv1)
    end
    move_r.list.push(mv2)
    move = RPG::EventCommand.new(205, 0, [0, move_r])
    end
#touch
    t1 = RPG::MoveCommand.new(37)
    if pdir == 8 and  #up
      if $game_map.passable?(x, y)
      t2 = RPG::MoveCommand.new(12) #move 1 tile further
      else
      t2 = RPG::MoveCommand.new(15, [0]) #wait 0 frames
      end
    else
      if $game_map.passable?(x, y)
      t2 = RPG::MoveCommand.new(15, [0]) #wait 0 frames
      else
      t2 = RPG::MoveCommand.new(13, [0]) #move 1 tile back
      end
    end
    t3 = RPG::MoveCommand.new(38)
    t4 = RPG::MoveCommand.new(35)
    t5 = RPG::MoveCommand.new(34)
    case type
        when "blue"
    t6 = RPG::MoveCommand.new(41, ["!portals", 0]) #BP opening sequence
    t8 = RPG::MoveCommand.new(41, ["!portals", 1])
    t9 = RPG::MoveCommand.new(41, ["!portals", 2])
        when "red"
    t6 = RPG::MoveCommand.new(41, ["!portals", 4]) #RP opening sequence
    t8 = RPG::MoveCommand.new(41, ["!portals", 5])
    t9 = RPG::MoveCommand.new(41, ["!portals", 6])
    end
    t7 = RPG::MoveCommand.new(15, [10])
    t10 = RPG::MoveCommand.new(0)
    touch_r = RPG::MoveRoute.new()
    touch_r.repeat = false
    touch_r.skippable = false
    touch_r.wait = true #13
    if $game_map.passable?(x, y)
    touch_r.list = [dir, t1, t2, t3, t4, t5, t6, t7, t8, t7, t9, t7, t10]
    else
    touch_r.list = [dir, t1, t2, t3, t4, t5, t6, t7, t8, t7, t9, t7, t10]
    end
    touch = RPG::EventCommand.new(205, 0, [0, touch_r])
#tp
    case type
      when "blue"
    tp = RPG::EventCommand.new(355, 0, ["Amimeyet_portals::teleport(\"blue\")"])
      when "red"
    tp = RPG::EventCommand.new(355, 0, ["Amimeyet_portals::teleport(\"red\")"])
    end
#turn
    turn_r = RPG::MoveRoute.new()
    turn_r.repeat = false
    turn_r.skippable = false
    turn_r.wait = true
    turn_r.list = [dir]
    turn = RPG::EventCommand.new(205, 0, [0, turn_r])
#switch
    switch = RPG::EventCommand.new(123, 0, ["A", 0])
#pend
    pend = RPG::EventCommand.new(0, 0, [])
#cond
    cond = RPG::Event::Page::Condition.new
    cond.self_switch_valid = true
    cond.self_switch_ch = "A"
#img
    img = RPG::Event::Page::Graphic.new #Set the bullet image
    if $game_map.passable?(x, y)
    img.tile_id = 0
    img.character_name = "!Flame"
    img.character_index = 6
    img.direction = 2
    img.pattern = 1
    else
    img.character_index = 0
    img.direction = 2
    img.pattern = 0
    end
   
#img2
    img2 = RPG::Event::Page::Graphic.new #Set the open portal image.. Deprecated
    img2.tile_id = 0
    img2.character_name = "!portals"
    case type
      when "blue"
    img2.character_index = 2
      when "red"
    img2.character_index = 6
    end
    img2.direction = pdir
    img2.pattern = 1
#page 1
    p1 = RPG::Event::Page.new
    p1.trigger = 4
    p1.priority_type = 1
    if $game_map.passable?(x, y)
    p1.list = [move, touch, switch, pend]
    else
    p1.list = [touch, switch, pend]
    end
    p1.graphic = img
#page 2
    p2 = RPG::Event::Page.new
    p2.condition = cond
    p2.trigger = 1
    p2.priority_type = 1
    p2.graphic = img2
    p2.walk_anime = true
    p2.step_anime = false
    p2.list = [tp, pend]
    p2.direction_fix = true
#bullet
    bullet = RPG::Event.new(x,y)
    bullet.id = $game_map.events.size + 1
    bullet.pages = [p1, p2]
    case type
      when "blue"
    bullet.name = "blue portal"
    #It's important to erase the previous portal, before overwriting it below
    self.erase("blue") if !DB_ALLOW_MULT_PORTALS
    @blue_id = bullet.id
    @prev_blue_id[@prev_blue_id.length + 1] = @blue_id
      when "red"
    bullet.name = "red portal"
    #It's important to erase the previous portal, before overwriting it below
    self.erase("red") if !DB_ALLOW_MULT_PORTALS
    @red_id = bullet.id
    @prev_red_id[@prev_red_id.length + 1] = @red_id
    end
    if type == "red" || "blue"
    event = Game_Event.new($game_map.map_id, bullet)
    $game_map.events[$game_map.events.size + 1] = event
    end
    $scene = Scene_Map.new
  end
end

#==============================================================================#
#=========================== class Game_System ================================#
#========= Aliassed [initialize], added attr_accessor :shoot_enabled ==========#
#==============================================================================#
class Game_System
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Public Instance Variables
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  attr_accessor :shoot_enabled   # Can you shoot?
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Object Initialization
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias amimeyet_shoot_enabled_initialize initialize
  def initialize
    # Run Original Method
    amimeyet_shoot_enabled_initialize
    # can shoot if the check type is 2
    @shoot_enabled = true if Amimeyet_portals::CHECK == 2
  end
end

#==============================================================================#
#============================ class Scene_Map =================================#
#======================= Aliassed [start, update]==============================#
#==============================================================================#
class Scene_Map < Scene_Base
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  # * Frame Update
  #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  alias amimeyet_shoot_key_update update
  alias amimeyet_shoot_start start
  def update
    amimeyet_shoot_key_update
   
    if $game_system.shoot_enabled
      Amimeyet_portals::shoot("blue") if Input.trigger? (Amimeyet_portals::SHOOT_B)
      Amimeyet_portals::shoot("red") if Input.trigger? (Amimeyet_portals::SHOOT_R)
      if Input.trigger? (Amimeyet_portals::REMOVE)
        Amimeyet_portals::erase("blue")
        Amimeyet_portals::erase("red")
      end
    else
      #What to do when shooting is disabled:
      eval(Amimeyet_portals::DISABLED_SHOOT)
    end
  end
  def start
    amimeyet_shoot_start
    if Amimeyet_portals::CHECK == 1
      for item in $game_party.members[0].equips
        if item.id == Amimeyet_portals::GUN_ID
          $game_system.shoot_enabled = true
          break
        end
      end
    end
  end
end
       Though it requires so many images, I really reccomend the demo!
   
    Customization
   
Spoiler for Available options::
  • SHOOT_B = Input::X      #What button to press, to shoot the blue portal
  • SHOOT_R = Input::Z      #What button to press, to shoot the red portal
  • REMOVE = Input::Y       #What button to press, to remove both portals
  • CHECK   = 1             #Type of the 'can shoot' check

                            #1 = Equipped weapon with id of GUN_ID
                            #2 = Use the START_SHOOTABLE value
                            #3 = I'll set it later using
                                      #$game_system.shoot_enabled = true
                                     
 
  • GUN_ID  = 31            #The ID of the portalgun weapon.

                            #Only works if CHECK = 1                         
 
  • START_SHOOTABLE = true  #Can you shoot at the beginning?
  • RANGE = 20              #Number of tiles you can shoot
  • BULLET_SPEED = 6        #The speed of the bullet

                            #1 = x8 slower
                            #2 = x4 slower
                            #3 = x2 slower
                            #4 = normal
                            #5 = x2 faster
                            #6 = x4 faster
[/list]
Spoiler for Advanced settings::
    #These are little pieces of code to execute at the specific error..
      #This can be anything from a message window ('p'), to s $scene change..
      #Its pure RUBY, and my script eval()'s it...
     
      #The piece of code to run when the user tries to shoot, but it is disabled..
     
  • DISABLED_SHOOT = "#do nothing.. it's a comment"

  #The piece of code to run when the erase function is called,
  #   but no type is supplied
 
  • NO_ERASE_TYPE = "#do nothing.. it's a comment"
  • DB_ALLOW_MULT_PORTALS = false #Set to true to stop portals from auto-deleting
  • DB_ALLOW_REMOVE = true        #If true, the erase button can be pressed

    Compatibility
    Maximum.
    All methods except for my own module have been aliased; so nothing is overwritten
   
    Screenshot
   
     
    Installation
    Copy the script and place it above 'main'; the default place where you install scripts.
    Next, copy all the images from the 'Graphics' folder to your game, and edit them to your liking
    Also, there are a few methods my script uses to check if it can shoot portals, and the default is set to GUN_ID.
    So, if you don't change this.. the portal gun won't shoot.. so please make sure you configure this.
   
    FAQ/Bugs
  • There may be no event ID missing in your map
     (Example: 9 events.. but no event 3)
    So say you create three events on a map.. and then delete the second, instead of a portal erasing.. you erase the third event.
    Counteract this by cutting (Ctrl+X) and pasting (Ctrl+V) the last event, (in this case the third), so that it gets the ID of the missing one (in this case 2).
    Know another bug? Contact me here, or via mail.
   
    Terms and Conditions
    If you use this script on your game, you must credit me.
    If you want to put this script on a website or forum, you must ask me for permission.
    You are free to use any graphics found in this demo, but you MUST ABSOLUTELY credit me.
    Portal is a registered trademark of Valve Corporation
    If you run into any issues, or have a question, please contact me, using the forum or using mail.
   
    Special thanks
« Last Edit: February 16, 2009, 09:11:06 AM by AmIMeYet »

Portals - in VX!
Spoiler for Do require's in VX::
Code: [Select]
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
Spoiler for Invert Dash enabling::
Code: [Select]
#=============================================================================#
# # # ANTI DASH HACK    # # #
# # #   By AmIMeYet # # #
# # #    please credit me   # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
return false if @move_route_forcing
return false if in_vehicle?
return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
 end
This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Most Mature Member2010 Favourite Staff Member
This looks really cool. Great work!

**
Rep: +0/-0Level 85
This looks really cool. Great work!

Thanks!

Also:

Version 1.1 is out!

Portals - in VX!
Spoiler for Do require's in VX::
Code: [Select]
$LOAD_PATH << Dir.getwd #You only need to call this once
Kernel.require("includable.rb") #replace includable.rb with the name of the file you want to load
Spoiler for Invert Dash enabling::
Code: [Select]
#=============================================================================#
# # # ANTI DASH HACK    # # #
# # #   By AmIMeYet # # #
# # #    please credit me   # # #
#=============================================================================#
class Game_Player < Game_Character
  def dash?
return false if @move_route_forcing
return false if in_vehicle?
return true if Input.press?(Input::A) and $game_map.disable_dash?
  end
 end
This snippet basically inverts the dashing.. allowing you to dash only when 'disable dashing' is checked.
This way, normal maps disable dashing, but the ones you set to disable actually allow dashing..

It should be placed where you normally place the scripts ('above main', in the materials section of the scripts window)..