Advertisement
LiTTleDRAgo

[RGSS/2/3] Automatic Door

Jul 2nd, 2012
466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.90 KB | None | 0 0
  1. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  2. # [Xp/Vx-VxA] Automatic Door
  3. # Version: 2.00
  4. # Author : LiTTleDRAgo
  5. #:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
  6. #==============================================================================
  7. # ■ Game_Event
  8. #------------------------------------------------------------------------------
  9. #  イベントを扱うクラスです。条件判定によるイベントページ切り替えや、並列処理
  10. # イベント実行などの機能を持っており、Game_Map クラスの内部で使用されます。
  11. #==============================================================================
  12. class Game_Event < Game_Character
  13.  
  14.   VX = defined?(Window_ActorCommand)
  15.   VXA = defined?(Window_BattleActor)
  16.   DOOR_SOUND = ["Audio.se_play('Audio/SE/Open1', 90, 100)", # Opened Door
  17.                 "Audio.se_play('Audio/SE/Close1', 90, 100)"] # Closed Door
  18.   #--------------------------------------------------------------------------
  19.   # ● フレーム更新
  20.   #--------------------------------------------------------------------------
  21.   alias :drg145_upd :update unless method_defined?(:drg145_upd)
  22.   def update
  23.     drg145_upd
  24.     update_autodoor
  25.   end
  26.   #--------------------------------------------------------------------------
  27.   # ● ドアの全て
  28.   #--------------------------------------------------------------------------  
  29.   def update_autodoor
  30.     interpreter = VX ? $game_map.interpreter.running? :
  31.                   $game_system.map_interpreter.running?
  32.     if @event.name =~ /Door/i && @page.through && !interpreter
  33.       distance,type = ($game_player.real_x-@real_x).abs+
  34.                       ($game_player.real_y-@real_y).abs, 1
  35.       number = VXA ? [0.5,1.0,1.5] : VX ? [216,232,248] : [128,132,148]
  36.       distance = [distance-32,0].max if !VXA
  37.       case distance
  38.       when 0...number[0]
  39.         return if @direction == 8
  40.         door_se(type * 2) if @direction == 2
  41.         turn_up
  42.         @wait_count = 6
  43.       when number[0]...number[1]
  44.         return if @direction == 6
  45.         if @direction > 6 && @wait_count > 0
  46.           @wait_count -= 1
  47.         elsif @direction == 8
  48.           turn_right
  49.           @wait_count = 6
  50.         else
  51.           door_se(type * 2) if @direction == 2
  52.           turn_right
  53.           @wait_count = 6
  54.         end
  55.       when number[1]...number[2] #
  56.         return if @direction == 4
  57.         if @direction > 4 && @wait_count > 0
  58.           @wait_count -= 1
  59.         elsif @direction == 8
  60.           turn_right
  61.           @wait_count = 6
  62.         elsif @direction == 6
  63.           turn_left
  64.           @wait_count = 6
  65.         else
  66.           door_se(type * 2) if @direction == 2
  67.           turn_left
  68.           @wait_count = 6
  69.         end
  70.       else
  71.         return if @direction == 2
  72.         if @direction > 2 and @wait_count > 0
  73.           @wait_count -= 1
  74.         elsif @direction == 8
  75.           turn_right
  76.           @wait_count = 6
  77.         elsif @direction == 6
  78.           turn_left
  79.           @wait_count = 6
  80.         elsif @direction == 4
  81.           door_se(type * 2 + 1)
  82.           turn_down
  83.         end
  84.       end
  85.     end
  86.   end
  87.   #--------------------------------------------------------------------------
  88.   # ● セト ヂレクシオン
  89.   #--------------------------------------------------------------------------
  90.   if VXA
  91.     def turn_up()   set_direction(8) end
  92.     def turn_right()set_direction(6) end
  93.     def turn_left() set_direction(4) end
  94.     def turn_down() set_direction(2) end
  95.   end
  96.   #--------------------------------------------------------------------------
  97.   # ● ドアの SE 設定
  98.   #--------------------------------------------------------------------------
  99.   def door_se(type)
  100.     case type
  101.     when 2 then eval(DOOR_SOUND[0]) rescue nil
  102.     when 3 then eval(DOOR_SOUND[1]) rescue nil
  103.     end
  104.   end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement