赞 | 170 |
VIP | 6 |
好人卡 | 208 |
积分 | 230 |
经验 | 137153 |
最后登录 | 2024-11-18 |
在线时间 | 8639 小时 |
Lv5.捕梦者
- 梦石
- 0
- 星屑
- 22978
- 在线时间
- 8639 小时
- 注册时间
- 2011-12-31
- 帖子
- 3367
|
本帖最后由 tseyik 于 2013-9-12 00:13 编辑
用區域可簡單設定
輸入脚本
設定方法如圖
交差点的圖塊設定為☆
十字橋要用事件和開関才能解决
- #==============================================================================
- # ■區域通行設定 for RGSS3 Ver1.00-β6
- # □作成者 kure
- #===============================================================================
- module KURE
- module RegionPass
- #初期設定
- Z_Region = []
-
- #交差点區域
- CROSS_Region = [63,59]
-
- #透明化區域
- #指定しない場合は0を設定
- TRANSPARENT_Region = 0
-
-
- #プライオリティ設定タイプ
- #(0 → キャラクターより下=90 キャラクターと同じ = 100 キャラクターより上 = 110)
- #(1 → キャラクターより下=0 キャラクターと同じ = 100 キャラクターより上 = 200)
- PRIORITY_TYPE = 1
- #Z座標設定
- Z_Region[60] = 400
- Z_Region[62] = 300
- end
- end
-
- #==============================================================================
- # ■ Game_Map
- #==============================================================================
- class Game_Map
- #--------------------------------------------------------------------------
- # ● 指定座標に存在するイベント(すり抜け以外)の配列取得
- #--------------------------------------------------------------------------
- def events_xy_ex(x, y, obj, z)
- @events.values.select {|event| event.pos_nt?(x, y) && event.normal_priority? && event.same_height2?(obj,z)}
- end
- #--------------------------------------------------------------------------
- # ● 指定座標に同じ高さのプレイヤーの存在するか取得
- #--------------------------------------------------------------------------
- def player_xy_ex(x, y, z)
- if $game_player.x == x && $game_player.y == y && $game_player.screen_z == z
- return true
- end
- return false
- end
- end
- #==============================================================================
- # ■ Game_Event
- #==============================================================================
- class Game_Event < Game_Character
- #--------------------------------------------------------------------------
- # ● オブジェクト初期化(エイリアス再定義)
- # event : RPG::Event
- #--------------------------------------------------------------------------
- alias k_before_initialize initialize
- def initialize(map_id, event)
- k_before_initialize(map_id, event)
- real_first_z
- end
- #--------------------------------------------------------------------------
- # ● リフレッシュ(エイリアス再定義)
- #--------------------------------------------------------------------------
- alias k_before_refresh refresh
- def refresh
- k_before_refresh
- real_first_z
- end
- #--------------------------------------------------------------------------
- # ● 初期 Z 座標の取得(追加定義)
- #--------------------------------------------------------------------------
- def real_first_z
- unless @event.name
- @first_z_pos = 90 + @priority_type * 10 if KURE::RegionPass::PRIORITY_TYPE == 0
- @first_z_pos = @priority_type * 100 if KURE::RegionPass::PRIORITY_TYPE == 1
- end
- @event.name.match(/<Z座標\s?(\d+)\s?>/)
- @first_z_pos = 90 + @priority_type * 10 if KURE::RegionPass::PRIORITY_TYPE == 0
- @first_z_pos = @priority_type * 100 if KURE::RegionPass::PRIORITY_TYPE == 1
- return unless $1
- @first_z_pos = $1.to_i
- end
- #--------------------------------------------------------------------------
- # ● 接触イベントの起動判定(再定義)
- #--------------------------------------------------------------------------
- def check_event_trigger_touch(x, y)
- return if $game_map.interpreter.running?
- if @trigger == 2 && $game_player.pos?(x, y)
- start if !jumping? && normal_priority? && same_height?
- end
- end
- #--------------------------------------------------------------------------
- # ● プレイヤーとの衝突判定(フォロワーを含む)(再定義)
- #--------------------------------------------------------------------------
- def collide_with_player_characters?(x, y)
- same_height? && normal_priority? && $game_player.collide?(x, y)
- end
- #--------------------------------------------------------------------------
- # ● 同じ高さかどうか(プレイヤー用)
- #--------------------------------------------------------------------------
- def same_height?
- return true if self.region_id == 0
- return true if $game_player.region_id == 0
- #Z座標±10の範囲内は同じ高さと判定する
- case KURE::RegionPass::PRIORITY_TYPE
- when 0
- return true if self.screen_z - 11 < $game_player.screen_z && self.screen_z + 11 > $game_player.screen_z
- when 1
- return true if self.screen_z - 101 < $game_player.screen_z && self.screen_z + 101 > $game_player.screen_z
- end
- return false
- end
- #--------------------------------------------------------------------------
- # ● 同じ高さかどうか(イベント用)
- #--------------------------------------------------------------------------
- def same_height2?(obj, z)
- return true if self.region_id == 0
- return true if obj.region_id == 0
- #Z座標±10の範囲内は同じ高さと判定する
- return true if self.screen_z - 11 < z && self.screen_z + 11 > z
- return false
- end
- end
- #==============================================================================
- # ■ Game_Player
- #==============================================================================
- class Game_Player < Game_Character
- #--------------------------------------------------------------------------
- # ● マップイベントの起動(再定義)
- # triggers : トリガーの配列
- # normal : プライオリティ[通常キャラと同じ]かそれ以外か
- #--------------------------------------------------------------------------
- def start_map_event(x, y, triggers, normal)
- $game_map.events_xy(x, y).each do |event|
- if event.trigger_in?(triggers) && event.normal_priority? == normal && event.same_height?
- event.start
- end
- end
- end
- end
- #==============================================================================
- # ■ Game_CharacterBase
- #==============================================================================
- class Game_CharacterBase
- attr_accessor :keep_region # 區域ID保存
- attr_accessor :region_z_pos # Z座標保存
- attr_accessor :first_z_pos # 初期Z座標保存
- attr_accessor :keep_trans # 透明化設定保存
- #--------------------------------------------------------------------------
- # ● 通行可能判定(再定義)
- # d : 方向(2,4,6,8)
- #--------------------------------------------------------------------------
- def passable?(x, y, d)
- x2 = $game_map.round_x_with_direction(x, d)
- y2 = $game_map.round_y_with_direction(y, d)
- return false unless $game_map.valid?(x2, y2)
- return true if @through || debug_through?
- #區域追加設定
- pass = region_passable?(x, y, x2, y2)
- return true if pass == 1
- return false if pass == 2
-
- return false unless map_passable?(x, y, d)
- return false unless map_passable?(x2, y2, reverse_dir(d))
- return false if collide_with_characters?(x2, y2)
-
- return true
- end
- #--------------------------------------------------------------------------
- # ● 画面 Z 座標の取得(再定義)
- #--------------------------------------------------------------------------
- def screen_z
- return @region_z_pos if @region_z_pos
- return @first_z_pos if @first_z_pos
- return @priority_type * 100
- end
- #--------------------------------------------------------------------------
- # ● 初期 Z 座標の取得(追加定義)
- #--------------------------------------------------------------------------
- def real_first_z
- @first_z_pos = nil
- end
- #--------------------------------------------------------------------------
- # ● Z 座標の更新(追加定義)
- #--------------------------------------------------------------------------
- def refresh_z
- id = $game_map.region_id(@x, @y)
-
- if @keep_trans
- if id != KURE::RegionPass::TRANSPARENT_Region
- @transparent = false
- @keep_trans = false
- end
- else
- if id == KURE::RegionPass::TRANSPARENT_Region && id != 0
- @transparent = true
- @keep_trans = true
- end
- end
-
- unless KURE::RegionPass::CROSS_Region.include?(id)
- @region_z_pos = nil
- if KURE::RegionPass::Z_Region[id]
- @region_z_pos = KURE::RegionPass::Z_Region[id]
- @first_z_pos = nil
- end
- end
- end
- #--------------------------------------------------------------------------
- # ● 歩数増加(エイリアス再定義)
- #--------------------------------------------------------------------------
- alias k_before_increase_steps increase_steps
- def increase_steps
- refresh_z
- k_before_increase_steps
- end
- #--------------------------------------------------------------------------
- # ● ジャンプ時の更新(エイリアス再定義)
- #--------------------------------------------------------------------------
- alias k_before_update_jump update_jump
- def update_jump
- k_before_update_jump
- if @jump_count == 0
- refresh_z
- end
- end
- #--------------------------------------------------------------------------
- # ● 區域通行設定(再定義)
- #--------------------------------------------------------------------------
- def region_passable?(x, y, x2, y2)
- #立体交差區域を取得
- cross = KURE::RegionPass::CROSS_Region
- #現在地と移動先の區域IDを取得
- point1 = $game_map.region_id(x, y)
- point2 = $game_map.region_id(x2, y2)
-
- #立体交差區域で無ければ區域IDを取得
- unless cross.include?(point1)
- @keep_region = point1
- end
-
- #立体交差區域と関係移動ないは判定しない
- unless cross.include?(point1)
- unless cross.include?(point2)
- return 0
- end
- end
-
- #移動先に同じ高さのイベントがあれば通行できない
- if $game_map.events_xy_ex(x2, y2, self, self.screen_z) != []
- return 2
- end
-
- #移動先が同じ高さのプレイヤーでも移動できない
- return 0 if $game_map.player_xy_ex(x2, y2, self.screen_z)
-
- #移動先の侵入可能設定
- if point2 != 0
- return 0 if point1 == 0
- return 1 if cross.include?(point2)
- return 1 if point2 == @keep_region
- return 2
- end
-
- return 0
- end
- end
- #==============================================================================
- # ■ Game_Interpreter
- #==============================================================================
- class Game_Interpreter
- #--------------------------------------------------------------------------
- # ● 區域ID取得
- #--------------------------------------------------------------------------
- def get_region_id
- x = $game_player.x
- y = $game_player.y
- return $game_map.region_id(x, y)
- end
- end
复制代码 ��� |
|