Advertisement
Guest User

Teleportacja

a guest
Jan 19th, 2016
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 9.33 KB | None | 0 0
  1. #==============================================================================
  2. # ** Scene_Teleport
  3. #------------------------------------------------------------------------------
  4. #  Teleportacja.
  5. #==============================================================================
  6.  
  7. class Scene_Teleport
  8.   #--------------------------------------------------------------------------
  9.   # * Main Processing
  10.   #--------------------------------------------------------------------------
  11.   def main
  12.     #Teleportacja
  13.     $game_map.setup($data_system.start_map_id=2)  
  14.     $game_player.moveto($data_system.start_x=5, $data_system.start_y=5)  
  15.     # Make sprite set
  16.     @spriteset = Spriteset_Map.new
  17.     # Make message window
  18.     @message_window = Window_Message.new
  19.     # Transition run
  20.     Graphics.transition
  21.     # Main loop
  22.     loop do
  23.       # Update game screen
  24.       Graphics.update
  25.       # Update input information
  26.       Input.update
  27.       # Frame update
  28.       update
  29.       # Abort loop if screen is changed
  30.       if $scene != self
  31.         break
  32.       end
  33.     end
  34.     # Prepare for transition
  35.     Graphics.freeze
  36.     # Dispose of sprite set
  37.     @spriteset.dispose
  38.     # Dispose of message window
  39.     @message_window.dispose
  40.     # If switching to title screen
  41.     if $scene.is_a?(Scene_Title)
  42.       # Fade out screen
  43.       Graphics.transition
  44.       Graphics.freeze
  45.     end
  46.   end
  47.   #--------------------------------------------------------------------------
  48.   # * Frame Update
  49.   #--------------------------------------------------------------------------
  50.   def update
  51.     # Loop
  52.     loop do
  53.       # Update map, interpreter, and player order
  54.       # (this update order is important for when conditions are fulfilled
  55.       # to run any event, and the player isn't provided the opportunity to
  56.       # move in an instant)
  57.       $game_map.update
  58.       $game_system.map_interpreter.update
  59.       $game_player.update
  60.       # Update system (timer), screen
  61.       $game_system.update
  62.       $game_screen.update
  63.       # Abort loop if player isn't place moving
  64.       unless $game_temp.player_transferring
  65.         break
  66.       end
  67.       # Run place move
  68.       transfer_player
  69.       # Abort loop if transition processing
  70.       if $game_temp.transition_processing
  71.         break
  72.       end
  73.     end
  74.     # Update sprite set
  75.     @spriteset.update
  76.     # Update message window
  77.     @message_window.update
  78.     # If game over
  79.     if $game_temp.gameover
  80.       # Switch to game over screen
  81.       $scene = Scene_Gameover.new
  82.       return
  83.     end
  84.     # If returning to title screen
  85.     if $game_temp.to_title
  86.       # Change to title screen
  87.       $scene = Scene_Title.new
  88.       return
  89.     end
  90.     # If transition processing
  91.     if $game_temp.transition_processing
  92.       # Clear transition processing flag
  93.       $game_temp.transition_processing = false
  94.       # Execute transition
  95.       if $game_temp.transition_name == ""
  96.         Graphics.transition(20)
  97.       else
  98.         Graphics.transition(40, "Graphics/Transitions/" +
  99.           $game_temp.transition_name)
  100.       end
  101.     end
  102.     # If showing message window
  103.     if $game_temp.message_window_showing
  104.       return
  105.     end
  106.     # If encounter list isn't empty, and encounter count is 0
  107.     if $game_player.encounter_count == 0 and $game_map.encounter_list != []
  108.       # If event is running or encounter is not forbidden
  109.       unless $game_system.map_interpreter.running? or
  110.              $game_system.encounter_disabled
  111.         # Confirm troop
  112.         n = rand($game_map.encounter_list.size)
  113.         troop_id = $game_map.encounter_list[n]
  114.         # If troop is valid
  115.         if $data_troops[troop_id] != nil
  116.           # Set battle calling flag
  117.           $game_temp.battle_calling = true
  118.           $game_temp.battle_troop_id = troop_id
  119.           $game_temp.battle_can_escape = true
  120.           $game_temp.battle_can_lose = false
  121.           $game_temp.battle_proc = nil
  122.         end
  123.       end
  124.     end
  125.     # If B button was pressed
  126.     if Input.trigger?(Input::B)
  127.       # If event is running, or menu is not forbidden
  128.       unless $game_system.map_interpreter.running? or
  129.              $game_system.menu_disabled
  130.         # Set menu calling flag or beep flag
  131.         $game_temp.menu_calling = true
  132.         $game_temp.menu_beep = true
  133.       end
  134.     end
  135.     # If debug mode is ON and F9 key was pressed
  136.     if $DEBUG and Input.press?(Input::F9)
  137.       # Set debug calling flag
  138.       $game_temp.debug_calling = true
  139.     end
  140.     # If player is not moving
  141.     unless $game_player.moving?
  142.       # Run calling of each screen
  143.       if $game_temp.battle_calling
  144.         call_battle
  145.       elsif $game_temp.shop_calling
  146.         call_shop
  147.       elsif $game_temp.name_calling
  148.         call_name
  149.       elsif $game_temp.menu_calling
  150.         call_menu
  151.       elsif $game_temp.save_calling
  152.         call_save
  153.       elsif $game_temp.debug_calling
  154.         call_debug
  155.       end
  156.     end
  157.   end
  158.   #--------------------------------------------------------------------------
  159.   # * Battle Call
  160.   #--------------------------------------------------------------------------
  161.   def call_battle
  162.     # Clear battle calling flag
  163.     $game_temp.battle_calling = false
  164.     # Clear menu calling flag
  165.     $game_temp.menu_calling = false
  166.     $game_temp.menu_beep = false
  167.     # Make encounter count
  168.     $game_player.make_encounter_count
  169.     # Memorize map BGM and stop BGM
  170.     $game_temp.map_bgm = $game_system.playing_bgm
  171.     $game_system.bgm_stop
  172.     # Play battle start SE
  173.     $game_system.se_play($data_system.battle_start_se)
  174.     # Play battle BGM
  175.     $game_system.bgm_play($game_system.battle_bgm)
  176.     # Straighten player position
  177.     $game_player.straighten
  178.     # Switch to battle screen
  179.     $scene = Scene_Battle.new
  180.   end
  181.   #--------------------------------------------------------------------------
  182.   # * Shop Call
  183.   #--------------------------------------------------------------------------
  184.   def call_shop
  185.     # Clear shop call flag
  186.     $game_temp.shop_calling = false
  187.     # Straighten player position
  188.     $game_player.straighten
  189.     # Switch to shop screen
  190.     $scene = Scene_Shop.new
  191.   end
  192.   #--------------------------------------------------------------------------
  193.   # * Name Input Call
  194.   #--------------------------------------------------------------------------
  195.   def call_name
  196.     # Clear name input call flag
  197.     $game_temp.name_calling = false
  198.     # Straighten player position
  199.     $game_player.straighten
  200.     # Switch to name input screen
  201.     $scene = Scene_Name.new
  202.   end
  203.   #--------------------------------------------------------------------------
  204.   # * Menu Call
  205.   #--------------------------------------------------------------------------
  206.   def call_menu
  207.     # Clear menu call flag
  208.     $game_temp.menu_calling = false
  209.     # If menu beep flag is set
  210.     if $game_temp.menu_beep
  211.       # Play decision SE
  212.       $game_system.se_play($data_system.decision_se)
  213.       # Clear menu beep flag
  214.       $game_temp.menu_beep = false
  215.     end
  216.     # Straighten player position
  217.     $game_player.straighten
  218.     # Switch to menu screen
  219.     $scene = Scene_Menu.new
  220.   end
  221.   #--------------------------------------------------------------------------
  222.   # * Save Call
  223.   #--------------------------------------------------------------------------
  224.   def call_save
  225.     # Straighten player position
  226.     $game_player.straighten
  227.     # Switch to save screen
  228.     $scene = Scene_Save.new
  229.   end
  230.   #--------------------------------------------------------------------------
  231.   # * Debug Call
  232.   #--------------------------------------------------------------------------
  233.   def call_debug
  234.     # Clear debug call flag
  235.     $game_temp.debug_calling = false
  236.     # Play decision SE
  237.     $game_system.se_play($data_system.decision_se)
  238.     # Straighten player position
  239.     $game_player.straighten
  240.     # Switch to debug screen
  241.     $scene = Scene_Debug.new
  242.   end
  243.   #--------------------------------------------------------------------------
  244.   # * Player Place Move
  245.   #--------------------------------------------------------------------------
  246.   def transfer_player
  247.     # Clear player place move call flag
  248.     $game_temp.player_transferring = false
  249.     # If move destination is different than current map
  250.     if $game_map.map_id != $game_temp.player_new_map_id
  251.       # Set up a new map
  252.       $game_map.setup($game_temp.player_new_map_id)
  253.     end
  254.     # Set up player position
  255.     $game_player.moveto($game_temp.player_new_x, $game_temp.player_new_y)
  256.     # Set player direction
  257.     case $game_temp.player_new_direction
  258.     when 2  # down
  259.       $game_player.turn_down
  260.     when 4  # left
  261.       $game_player.turn_left
  262.     when 6  # right
  263.       $game_player.turn_right
  264.     when 8  # up
  265.       $game_player.turn_up
  266.     end
  267.     # Straighten player position
  268.     $game_player.straighten
  269.     # Update map (run parallel process event)
  270.     $game_map.update
  271.     # Remake sprite set
  272.     @spriteset.dispose
  273.     @spriteset = Spriteset_Map.new
  274.     # If processing transition
  275.     if $game_temp.transition_processing
  276.       # Clear transition processing flag
  277.       $game_temp.transition_processing = false
  278.       # Execute transition
  279.       Graphics.transition(20)
  280.     end
  281.     # Run automatic change for BGM and BGS set on the map
  282.     $game_map.autoplay
  283.     # Frame reset
  284.     Graphics.frame_reset
  285.     # Update input information
  286.     Input.update
  287.   end
  288. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement