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.

warp spell

Script Request Template
This is a request for a new script, an edit or debug of an existing script.

Script Title: Warp spell script
Give your script a name, or list the exact name & link to existing script
RMXP or RMVX:rmxp
select either the VX or XP topic icon. No other topic icons are acceptable here.
Detailed Description:I want a script that I can insert into a skill which will call up a menu, the menu will list the names of each towns you have visited (which I will add to a list with an autorun event), then an item can be selected and the party teleports to that town. I'd also like the syntax to add and remove towns, and temorarily disable and re-enable the script so it gives another message like 'you can't use this now' when disabled. Basically I just want a script to make an old-school warp spell.

I plan to insert an autorun event in each town that will set a variable (x,y) that will always be where the party warps when they select that particular town from the large menu that appears. I'm going to have 12+ towns, so the menu that comes up needs to be large. As long as I have the call script syntax to add/remove towns and dis/enable the skill from working, I deal with the details of that through events. An example of this would be in basically any old school rpg, like Lufia 1/2, I think BOF1-2, etc.

Be VERY specific about how you want the script to work with the rest of your game.
Think about other parts of the game that will be affected. If you want a functionality
you have seen in a commercial game, describe it in detail. Assume the scripter taking your request has not played that game. Use references to commercial games as references only.
Screen shots: N/A
a picture is worth a hundred words (at least).
Other Scripts I am using (in order):
Okay I'm not sure that this script would interact with other scripts but here they are, from the top.
Bonus Features (semi-custom made, just allows a Bonus Features selection from the start menu)
Multislot add on, multislot modules, multislot actors, multislotwindows, multislot others.
level_up(a simple script that shows the stats/skills gained at level up)
realistic_shop( allows you to add items to your cart before finalizing the purchase/change rates of items, etc)
individualbattlecommands(basically a script to allow me to change 'skills' to whatever, which I believe is based on the actor slot, not the class in this case.
ItemConsumingSkills(Just a script that links several skills to require items be present in the inventory before the skill is used, then the skill uses some of those items when cast, etc.)
EndMeAfterBattle(Just a quick little script someone wrote up for me to end the ME after battle because I have a particularly long victory ME)
Crafting(A crafting script)
Recipe List(a sub menu to above, which lists out the recipes needed)
path finding
party changer(by Dargor, still haven't implemented this yet, waiting for a syntax guide first)
AMS
Main.

So yeah, that is all of them, but as I said, I really doubt they will interact with this particular script. I'm also not using SDK and cannot because using it screws with several of my scripts, unfortunately. =\
 

Atoa

Member

Code:
#==============================================================================

# ◆ KGC_Teleport ◆

#==============================================================================

<span style="color:#000080; font-style:italic;">=begin

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">First you must add the "TELEPORT_ID" element (it can be configurated in the module KGC) to the teleport skill.

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">to add an new location to the teleport list, you must make an Script Call via events and add:

<span style="color:#000080; font-style:italic;">add_teleport("name", id, x, y, direction)

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">Onde:

<span style="color:#000080; font-style:italic;">- nome: The name of the map where you will teleport. This name don't need to be exactly the map name on the databas

<span style="color:#000080; font-style:italic;">    To make two teleport points in the same map, you must add different names.

<span style="color:#000080; font-style:italic;">    E.g.: "Maker City - North" and "Maker City - South"

<span style="color:#000080; font-style:italic;">- id: ID of the map

<span style="color:#000080; font-style:italic;">- x: coord X

<span style="color:#000080; font-style:italic;">- y: coord Y 

<span style="color:#000080; font-style:italic;">- direção: direction that the charater will be looking after the telepor

<span style="color:#000080; font-style:italic;">  must be equal 2, 4, 6 ou 8

<span style="color:#000080; font-style:italic;">  2 = looks down

<span style="color:#000080; font-style:italic;">  4 = looks left

<span style="color:#000080; font-style:italic;">  6 = looks right

<span style="color:#000080; font-style:italic;">  8 = looks up

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">To desactivate the teleport, you must turn ON the switch with the ID equal "NO_TELEPORT_SWITCH"

<span style="color:#000080; font-style:italic;"> 

<span style="color:#000080; font-style:italic;">=end

 

module KGC

  # Teleport Sound

  TELEPORT_SE = RPG::AudioFile.new("018-Teleport01", 80)

  # Switch ID to negate teleport

  NO_TELEPORT_SWITCH = 1

  # Element ID for Teleport Skill

  TELEPORT_ID = 20

end

 

 

#--------------------------------------------------------------------------

def add_teleport(name, id, x, y, dir = 2)

  for dest in $game_system.teleport_dest

    return if dest == nil || dest[0] == name

  end

  $game_system.teleport_dest.push([name, id, x, y, dir])

end

#--------------------------------------------------------------------------

def add_teleport_now_place

  place = [$game_map.map_name,

    $game_map.map_id,

    $game_player.x,

    $game_player.y,

    $game_player.direction]

  for dest in $game_system.teleport_dest

    return if dest == nil || dest[0] == place[0]

  end

  $game_system.teleport_dest.push(place)

end

#--------------------------------------------------------------------------

def delete_teleport(name)

  for dest in $game_system.teleport_dest

    next if dest == nil

    if dest[0] == name

      $game_system.teleport_dest.delete(dest)

      break

    end

  end

end

 

#==============================================================================

# â–  Game_Temp

#==============================================================================

class Game_Temp

  #--------------------------------------------------------------------------

  attr_accessor :teleport_calling         

  attr_accessor :teleport_item            

  attr_accessor :teleport_user            

  attr_accessor :teleport_cost_sp         

  #--------------------------------------------------------------------------

  alias initialize_KGC_Teleport initialize

  def initialize

    initialize_KGC_Teleport

    @teleport_item, @teleport_user = nil, nil

    @teleport_cost_sp, @teleport_calling = 0, false

  end

end

 

#==============================================================================

# â–  Game_System

#==============================================================================

class Game_System

  #--------------------------------------------------------------------------

  attr_accessor :teleport_dest           

  attr_accessor :teleport_permit          

  #--------------------------------------------------------------------------

  alias initialize_KGC_Teleport initialize

  def initialize

    initialize_KGC_Teleport

    @teleport_dest, @teleport_permit = [], true

  end

end

 

#==============================================================================

# â–  Game_Map

#==============================================================================

class Game_Map

  #--------------------------------------------------------------------------

  def map_name

    mapinfo = load_data("Data/MapInfos.rxdata")

    return mapinfo[@map_id].name

  end

end

 

 

#==============================================================================

# â–  Window_Teleport

#==============================================================================

class Window_Teleport < Window_Selectable

  #--------------------------------------------------------------------------

  def initialize

    super(80, 80, 480, 320)

    @column_max = 2

    refresh

    self.back_opacity = 160

    self.visible = false

    self.index = 0

  end

  #--------------------------------------------------------------------------

  def dest

    return @data[self.index]

  end

  #--------------------------------------------------------------------------

  def refresh

    if self.contents != nil

      self.contents.dispose

      self.contents = nil

    end

    @data = []

    for dest in $game_system.teleport_dest

      next if dest == nil

      @data.push(dest)

    end

    @item_max = @data.size

    if @item_max > 0

      self.contents = Bitmap.new(width - 32, row_max * 32)

      for i in 0...@item_max

        draw_item(i)

      end

    end

  end

  #--------------------------------------------------------------------------

  def draw_item(index)

    dest = @data[index]

    x = 4 + index % 2 * 224

    y = index / 2 * 32

    self.contents.draw_text(x, y, 224, 32, dest[0], 0)

  end

  #--------------------------------------------------------------------------

  def update_cursor_rect

    if @index < 0

      self.cursor_rect.empty

      return

    end

    row = @index / @column_max

    if row < self.top_row

      self.top_row = row

    end

    if row > self.top_row + (self.page_row_max - 1)

      self.top_row = row - (self.page_row_max - 1)

    end

    cursor_width = (self.width - 32) / @column_max

    x = @index % @column_max * cursor_width

    y = @index / @column_max * 32 - self.oy

    self.cursor_rect.set(x, y, cursor_width, 32)

  end

end

 

 

#==============================================================================

# â–  Scene_Map

#==============================================================================

class Scene_Map

  #--------------------------------------------------------------------------

  alias main_KGC_Teleport main

  def main

    @teleport_window = Window_Teleport.new

    main_KGC_Teleport

    @teleport_window.dispose

  end

  #--------------------------------------------------------------------------

  alias update_KGC_Teleport update

  def update

    update_KGC_Teleport

    unless $game_player.moving?

      if $game_temp.teleport_calling

        call_teleport

      end

    end

  end

  #--------------------------------------------------------------------------

  def call_teleport

    $game_temp.teleport_calling = false

    if $game_switches[KGC::NO_TELEPORT_SWITCH] == true

      $game_system.se_play($data_system.buzzer_se)

      @message_waiting = true

      $game_temp.message_proc = Proc.new { @message_waiting = false }

      $game_temp.message_text = "You can't teleport now."       

    else

    teleport_flag = false

    @teleport_window.refresh

    @teleport_window.opacity = 0

    @teleport_window.visible = true

    @teleport_window.active = true

    loop do

      @teleport_window.opacity += 16 if @teleport_window.opacity < 255

      @teleport_window.update

      Graphics.update

      Input.update

      if Input.trigger?(Input::B)

        $game_system.se_play($data_system.cancel_se)

        if $game_temp.teleport_item != nil

          item = $game_temp.teleport_item

          $game_party.gain_item(item.id, 1) if item.consumable 

          $game_temp.teleport_item = nil

        elsif $game_temp.teleport_user != nil

          $game_temp.teleport_user.sp += $game_temp.teleport_cost_sp

          $game_temp.teleport_user = nil

          $game_temp.teleport_cost_sp = 0

        end

        Graphics.freeze

        break

      end

      if Input.trigger?(Input::C)

        dest = @teleport_window.dest

        if dest == nil

          $game_system.se_play($data_system.buzzer_se)

          next

        end

        $game_temp.player_new_map_id = dest[1]

        $game_temp.player_new_x = dest[2]

        $game_temp.player_new_y = dest[3]

        $game_temp.player_new_direction = dest[4]

        teleport_flag = true

        break

      end

    end

    @teleport_window.visible = false

    @teleport_window.active = false

    if teleport_flag

      $game_temp.player_transferring = true

      $game_temp.transition_processing = true

      Graphics.freeze

      if KGC::TELEPORT_SE.is_a?(RPG::AudioFile)

        $game_system.se_play(KGC::TELEPORT_SE)

      elsif KGC::TELEPORT_SE.is_a?(String)

        Audio.se_play("Audio/SE/" + KGC::TELEPORT_SE)

      end

      transfer_player

    else

      Graphics.transition

    end

    end

  end

end

 

#==============================================================================

# â–  Scene_Item

#==============================================================================

class Scene_Item

  #--------------------------------------------------------------------------

  alias update_item_KGC_Teleport update_item

  def update_item

    if Input.trigger?(Input::C)

      @item = @item_window.item

      if @item != nil && @item.is_a?(RPG::Item) &&

          @item.element_set.include?(KGC::TELEPORT_ID)

        if $game_system.teleport_permit && @item.is_a?(RPG::Item) &&

            $game_party.item_can_use?(@item.id)

          $game_system.se_play(@item.menu_se)

          $game_party.lose_item(@item.id, 1) if @item.consumable

          $game_temp.teleport_item = @item

          $game_temp.teleport_calling = true

          $scene = Scene_Map.new

        else

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        return

      end

    end

    update_item_KGC_Teleport

  end

end

 

#==============================================================================

# â–  Scene_Skill

#==============================================================================

class Scene_Skill

  #--------------------------------------------------------------------------

  alias update_skill_KGC_Teleport update_skill

  def update_skill

    if Input.trigger?(Input::C)

      @skill = @skill_window.skill

      if @skill != nil && @skill.element_set.include?(KGC::TELEPORT_ID)

        if @skill != nil && @actor.skill_can_use?(@skill.id) &&

            $game_system.teleport_permit

          $game_system.se_play(@skill.menu_se)

          @actor.sp -= @skill.sp_cost

          $game_temp.teleport_user = @actor

          $game_temp.teleport_cost_sp = @skill.sp_cost

          $game_temp.teleport_calling = true

          $scene = Scene_Map.new

        else

          $game_system.se_play($data_system.buzzer_se)

          return

        end

        return

      end

    end

    update_skill_KGC_Teleport

  end

end
 

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