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.

[VX] Portals [old script]

Portals
Version: 1.1
Author: AmIMeYet
Release Date: 13/02/09


Warning: This is an old script. It includes many bugs!
(I might update it later on)


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


Script -- Use Demo instead! (it includes required images)
Code:
#==============================================================================#

#==============►  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)

#           [url=http://www.rmxp.org/forums/viewtopic.php?f=7&t=60928]viewtopic.php?f=7&t=60928[/url]

#

#§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
Code:
#==============================================================================#

#==============►  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)

#           [url=http://www.rmxp.org/forums/viewtopic.php?f=7&t=60928]viewtopic.php?f=7&t=60928[/url]

#

#§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
  • 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
  • #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
portals_sh1.png


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
 
Hello AmIMeYet, long time no see :biggrin

I'm downloading the demo, but I'm still confused what this script capable of... I mean for what kind of situation this script used?
:crazy:

Maybe you could tell bit more the backgrounds you intended for?
 
lahandi":152d43uc said:
Hello AmIMeYet, long time no see :biggrin

I'm downloading the demo, but I'm still confused what this script capable of... I mean for what kind of situation this script used?
:crazy:

Maybe you could tell bit more the backgrounds you intended for?

This was based off the game portal.
I really like this a lot just wish it was for xp, any chances of that.
 
lahandi":13af41hi said:
I'm downloading the demo, but I'm still confused what this script capable of... I mean for what kind of situation this script used?
Maybe you could tell bit more the backgrounds you intended for?
Well, this script is best to be used to make portal-fan-games.. (people can even use my graphics if they want, and if they credit me for it), but any game that want's to be able to shoot portals could use this..

And I know; I'ts far from perfect, but I'm working on a version with a fix (for landing in the middle of the wall if you shoot and exit portal up, and the portal you enter to the left or right), and a way to change the bullet speed. I'm also looking in to teleporting events; but that's really hard..

catkitten":13af41hi said:
I really like this a lot just wish it was for xp, any chances of that.
I'm afraid not because I don't have XP on my laptop.. (it's Vista)
I might be able to use the XP version on my brothers PC, but I can't make any promises..
I don't know if the methods I use in this VX version could be used in XP anyway.. but I'm really wanting to try it.
 
Gimnis":33o1ngwq said:
woow, this is awesome!
is there any chance you will convert this to RMXP?
Nope.. I don't have access to RMXP, so I coulnd't test it or anything..
Plus, I'm busy enough as it is :P

WARNING: this script is very old!
I will still offer (some) support for this, but I must say that this is extremely buggy.
Some parts are also coded quite poorly, I might add. (This I know from my new experience with my new project, EventScripter).

I might however update this script in the future.. .. .. .. (so maybe not)
 

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