查看: 2203|回复: 4

[已经解决] 如何让事件不能被通过就算开了Through On

[复制链接]
梦石
8
星屑
2872
在线时间
476 小时
注册时间
2010-9-11
回帖
480
发表于 2017-7-10 23:26:30 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
我在地图上放了区域然后用脚本禁止角色通行(开了Through On也不行)
Mori2.png

问题来了 地图上有可破坏事件 需要玩家自己去破坏才可以通过(ARPG)
a.png

另外我的RMVA是英文的我不知道Through On中文叫什么.. 不明白的话我再解释
Paku
梦石
0
星屑
6375
在线时间
1473 小时
注册时间
2015-7-25
回帖
609

极短25参与开拓者

发表于 2017-7-11 10:54:23 | 显示全部楼层
事件名字上写<不可穿透>

[pre lang="ruby"]class Game_Event < Game_Character
  def setup_page_settings
    @tile_id          = @page.graphic.tile_id
    @character_name   = @page.graphic.character_name
    @character_index  = @page.graphic.character_index
    if @original_direction != @page.graphic.direction
      @direction          = @page.graphic.direction
      @original_direction = @direction
      @prelock_direction  = 0
    end
    if @original_pattern != @page.graphic.pattern
      @pattern            = @page.graphic.pattern
      @original_pattern   = @pattern
    end
    @move_type          = @page.move_type
    @move_speed         = @page.move_speed
    @move_frequency     = @page.move_frequency
    @move_route         = @page.move_route
    @move_route_index   = 0
    @move_route_forcing = false
    @walk_anime         = @page.walk_anime
    @step_anime         = @page.step_anime
    @direction_fix      = @page.direction_fix
    if @event.name.include?("<不可穿透>")
      @through = false
    else
      @through            = @page.through
    end
    @priority_type      = @page.priority_type
    @trigger            = @page.trigger
    @list               = @page.list
    @interpreter = @trigger == 4 ? Game_Interpreter.new : nil
  end
end[/pre]

评分

参与人数 1星屑 +10 收起 理由
phunmung5173 + 10

查看全部评分

笨肉包的游戏讨论群932812135 (实时更新) 喜欢的话欢迎加入~
目前的坑
??? #像素风OC游戏 准备中 短篇-约5小时
花城梦之心 #像素风OC游戏 系统开发+素材绘制中
【不可思议的迷宫】幽灵契约外传:歌莉娅 v0.4 游戏文件已更新
同时更新中~ (沉迷摸鱼中~更新速度较慢请见谅w)
这是属于笨肉包一个人的旅行~(这只肉包又在摸鱼!
旅途的最终目标~ ???(保密~
回复

使用道具 举报

梦石
8
星屑
2872
在线时间
476 小时
注册时间
2010-9-11
回帖
480
 楼主| 发表于 2017-7-11 18:50:03 | 显示全部楼层
魔法丶小肉包 发表于 2017-7-11 10:54
事件名字上写

class Game_Event < Game_Character

谢谢帮忙,但是行不通呢。

虽然不知道有没有关联
忘记说明的是:

这里用了一些可能会影响到的脚本

[pre lang="ruby"]#==============================================================================
#
# ▼ Yanfly Engine Ace - Move Restrict Region v1.03
# -- Last Updated: 2012.01.03
# -- Level: Normal
# -- Requires: n/a
#
#==============================================================================

$imported = {} if $imported.nil?
$imported["YEA-MoveRestrictRegion"] = true

#==============================================================================
# ▼ Updates
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# 2012.23.08 - Added Feature: <all restrict: x>
# 2012.01.03 - Added Feature: <all restrict: x>
# 2011.12.26 - Bug Fixed: Player Restricted Regions.
# 2011.12.15 - Started Script and Finished.
#
#==============================================================================
# ▼ Introduction
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# Not everybody wants NPC's to travel all over the place. With this script, you
# can set NPC's to be unable to move pass tiles marked by a specified Region.
# Simply draw out the area you want to enclose NPC's in on and they'll be
# unable to move past it unless they have Through on. Likewise, there are
# regions that you can prevent the player from moving onto, too!
#
#==============================================================================
# ▼ Instructions
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# To install this script, open up your script editor and copy/paste this script
# to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
#
# -----------------------------------------------------------------------------
# Map Notetags - These notetags go in the map notebox in a map's properties.
# -----------------------------------------------------------------------------
# <all restrict: x>
# <all restrict: x, x>
# Players and NPC's on the map will be unable to move past region x even if
# they have the "through" flag set. The only thing that can go past is if the
# player is using the debug through flag. Draw out the area you want to close
# the player and NPC's in with the regions and both will be unable to move onto
# any of those tiles marked by region x. If you want to have more regions
# restrict NPC's, insert multiples of this tag.
#
# <npc restrict: x>
# <npc restrict: x, x>
# NPC's on that map will be unable to move past regions x unless they have a
# "Through" flag on. Draw out the area you want to close NPC's in with the
# regions and the NPC's will be unable to move onto any of those tiles marked
# by region x. If you want to have more regions restrict NPC's, insert
# multiples of this tag.
#
# <player restrict: x>
# <player restrict: x, x>
# Players will not be able to move on tiles marked by region x unless the
# player has a "Through" flag on. Draw out the area you want to close the
# player in with the regions and the player will be unable to move past any of
# those tiles marked by region x. If you want to have more regions restrict the
# player, insert multiples of this tag.
#
#==============================================================================
# ▼ Compatibility
# =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
# This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
# it will run with RPG Maker VX without adjusting.
#
#==============================================================================

module YEA
  module MOVE_RESTRICT
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Default Completely Restricted Regions -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # If you want there to always be a region ID that will forbid both the
    # player and NPC's from passing through, insert that region ID into the
    # array below. This effect will completely block out both players and NPC's
    # even if they have the "through" flag. However, it does not block the
    # debug_through flag for players.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_ALL = [61]
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Default Player Restricted Regions -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # If you want there to always be a region ID that will forbid the player
    # from passing through, insert that region ID into the array below.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_PLAYER = [62]
   
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # - Default NPC Restricted Regions -
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    # If you want there to always be a region ID that will forbid NPC's from
    # passing through, insert that region ID into the array below.
    #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
    DEFAULT_NPC = [63]
   
  end # MOVE_RESTRICT
end # YEA

#==============================================================================
# ▼ Editting anything past this point may potentially result in causing
# computer damage, incontinence, explosion of user's head, coma, death, and/or
# halitosis so edit at your own risk.
#==============================================================================

module YEA
  module REGEXP
  module MAP
   
    ALL_RESTRICT =
      /<(?:ALL_RESTRICT|all restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    NPC_RESTRICT =
      /<(?:NPC_RESTRICT|npc restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
    PLAYER_RESTRICT =
      /<(?:PLAYER_RESTRICT|player restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
   
  end # MAP
  end # REGEXP
end # YEA

#==============================================================================
# ■ RPG::Map
#==============================================================================

class RPG::Map
  
  #--------------------------------------------------------------------------
  # public instance variables
  #--------------------------------------------------------------------------
  attr_accessor :all_restrict_regions
  attr_accessor :npc_restrict_regions
  attr_accessor :player_restrict_regions
  
  #--------------------------------------------------------------------------
  # common cache: load_notetags_mrr
  #--------------------------------------------------------------------------
  def load_notetags_mrr
    @all_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_ALL.clone
    @npc_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_NPC.clone
    @player_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_PLAYER.clone
    #---
    self.note.split(/[\r\n]+/).each { |line|
      case line
      #---
      when YEA::REGEXP::MAP::ALL_RESTRICT
        $1.scan(/\d+/).each { |num|
        @all_restrict_regions.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::MAP::NPC_RESTRICT
        $1.scan(/\d+/).each { |num|
        @npc_restrict_regions.push(num.to_i) if num.to_i > 0 }
      when YEA::REGEXP::MAP::PLAYER_RESTRICT
        $1.scan(/\d+/).each { |num|
        @player_restrict_regions.push(num.to_i) if num.to_i > 0 }
      #---
      end
    } # self.note.split
    #---
  end
  
end # RPG::Map

#==============================================================================
# ■ Game_Map
#==============================================================================

class Game_Map
  
  #--------------------------------------------------------------------------
  # alias method: setup
  #--------------------------------------------------------------------------
  alias game_map_setup_mrr setup
  def setup(map_id)
    game_map_setup_mrr(map_id)
    @map.load_notetags_mrr
  end
  
  #--------------------------------------------------------------------------
  # new method: all_restrict_regions
  #--------------------------------------------------------------------------
  def all_restrict_regions
    return @map.all_restrict_regions
  end
  
  #--------------------------------------------------------------------------
  # new method: npc_restrict_regions
  #--------------------------------------------------------------------------
  def npc_restrict_regions
    return @map.npc_restrict_regions
  end
  
  #--------------------------------------------------------------------------
  # new method: player_restrict_regions
  #--------------------------------------------------------------------------
  def player_restrict_regions
    return @map.player_restrict_regions
  end
  
end # Game_Map

#==============================================================================
# ■ Game_CharacterBase
#==============================================================================

class Game_CharacterBase
  
  #--------------------------------------------------------------------------
  # alias method: passable?
  #--------------------------------------------------------------------------
  alias game_characterbase_passable_mrr passable?
  def passable?(x, y, d)
    return false if npc_region_forbid?(x, y, d)
    return false if player_region_forbid?(x, y, d)
    return game_characterbase_passable_mrr(x, y, d)
  end
  
  #--------------------------------------------------------------------------
  # new method: npc_forbid?
  #--------------------------------------------------------------------------
  def npc_region_forbid?(x, y, d)
    return false unless self.is_a?(Game_Event)
    region = 0
    case d
    when 1; region = $game_map.region_id(x-1, y+1)
    when 2; region = $game_map.region_id(x+0, y+1)
    when 3; region = $game_map.region_id(x+1, y+1)
    when 4; region = $game_map.region_id(x-1, y+0)
    when 5; region = $game_map.region_id(x+0, y+0)
    when 6; region = $game_map.region_id(x+1, y+0)
    when 7; region = $game_map.region_id(x-1, y-1)
    when 8; region = $game_map.region_id(x+0, y-1)
    when 9; region = $game_map.region_id(x+1, y-1)
    end
    return true if $game_map.all_restrict_regions.include?(region)
    return false if @through
    return $game_map.npc_restrict_regions.include?(region)
  end
  
  #--------------------------------------------------------------------------
  # new method: player_region_forbid?
  #--------------------------------------------------------------------------
  def player_region_forbid?(x, y, d)
    return false unless self.is_a?(Game_Player)
    return false if debug_through?
    region = 0
    case d
    when 1; region = $game_map.region_id(x-1, y+1)
    when 2; region = $game_map.region_id(x+0, y+1)
    when 3; region = $game_map.region_id(x+1, y+1)
    when 4; region = $game_map.region_id(x-1, y+0)
    when 5; region = $game_map.region_id(x+0, y+0)
    when 6; region = $game_map.region_id(x+1, y+0)
    when 7; region = $game_map.region_id(x-1, y-1)
    when 8; region = $game_map.region_id(x+0, y-1)
    when 9; region = $game_map.region_id(x+1, y-1)
    end
    return true if $game_map.all_restrict_regions.include?(region)
    return false if @through
    return $game_map.player_restrict_regions.include?(region)
  end
  
end # Game_CharacterBase

#==============================================================================
#
# ▼ End of File
#
#==============================================================================[/pre]

[pre lang="ruby"]#==============================================================================
# ** Game_CharacterBase
#------------------------------------------------------------------------------
#  This base class handles characters. It retains basic information, such as
# coordinates and graphics, shared by all characters.
#==============================================================================

class Game_CharacterBase
  alias regpass? passable?
  #--------------------------------------------------------------------------
  # * Determine if Passable
  #     d : Direction (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 if $game_map.region_id(x2, y2) == 2 && !debug_through?
    regpass?(x,y,d)
  end
end[/pre]

另外用了Falcao 的ARPG系统 所以事件本身已经有名字
a.png
Paku
回复

使用道具 举报

梦石
0
星屑
6375
在线时间
1473 小时
注册时间
2015-7-25
回帖
609

极短25参与开拓者

发表于 2017-7-11 20:04:24 | 显示全部楼层
修改了一下,放在这个arpg系统的下方,事件已经有名字了也没关系,只要加上<不可穿透>
比如:<enemy: 33><不可穿透>
[pre lang="ruby"]class Game_Event < Game_Character
  def setup_page_settings
    create_token_arrays
    @tile_id          = @page.graphic.tile_id
    @character_name   = @page.graphic.character_name
    @character_index  = @page.graphic.character_index
    if @original_direction != @page.graphic.direction
      @direction          = @page.graphic.direction
      @original_direction = @direction
      @prelock_direction  = 0
    end
    if @original_pattern != @page.graphic.pattern
      @pattern            = @page.graphic.pattern
      @original_pattern   = @pattern
    end
    @move_type          = @page.move_type
    @move_speed         = @page.move_speed
    @move_frequency     = @page.move_frequency
    @move_route         = @page.move_route
    @move_route_index   = 0
    @move_route_forcing = false
    @walk_anime         = @page.walk_anime
    @step_anime         = @page.step_anime
    @direction_fix      = @page.direction_fix
    if @event.name.include?("<不可穿透>")
      @through = false
    else
      @through            = @page.through
    end
    @priority_type      = @page.priority_type
    @trigger            = @page.trigger
    @list               = @page.list
    @interpreter = @trigger == 4 ? Game_Interpreter.new : nil
    wtag = string_data("<start_with_weapon: ")
    @token_weapon = wtag.split(",").map { |s| s.to_i } if wtag != nil
    atag = string_data("<start_with_armor: ")
    @token_armor = atag.split(",").map { |s| s.to_i } if atag != nil
    itag = string_data("<start_with_item: ")
    @token_item = itag.split(",").map { |s| s.to_i } if itag != nil
    stag = string_data("<start_with_skill: ")
    @token_skill = stag.split(",").map { |s| s.to_i } if stag != nil
    @hook_pull = string_data("<hook_pull: ") == "true"
    @hook_grab = string_data("<hook_grab: ") == "true"
    @boom_grab = string_data("<boom_grab: ") == "true"
    @boom_start = string_data("<boomed_start: ") == "true"
    @direction_fix = false if @hook_grab
    if has_token? || @hook_pull || @hook_grab || @boom_grab || @boom_start
      $game_map.events_withtags.push(self) unless
      $game_map.events_withtags.include?(self)
    end
    @parallel_mode = @trigger == 3 || @trigger == 4 || @ignore_antilag
  end
end
class Game_Character < Game_CharacterBase
  def process_move_command(command)
    params = command.parameters
    case command.code
    when ROUTE_END;               process_route_end
    when ROUTE_MOVE_DOWN;         move_straight(2)
    when ROUTE_MOVE_LEFT;         move_straight(4)
    when ROUTE_MOVE_RIGHT;        move_straight(6)
    when ROUTE_MOVE_UP;           move_straight(8)
    when ROUTE_MOVE_LOWER_L;      move_diagonal(4, 2)
    when ROUTE_MOVE_LOWER_R;      move_diagonal(6, 2)
    when ROUTE_MOVE_UPPER_L;      move_diagonal(4, 8)
    when ROUTE_MOVE_UPPER_R;      move_diagonal(6, 8)
    when ROUTE_MOVE_RANDOM;       move_random
    when ROUTE_MOVE_TOWARD;       move_toward_player
    when ROUTE_MOVE_AWAY;         move_away_from_player
    when ROUTE_MOVE_FORWARD;      move_forward
    when ROUTE_MOVE_BACKWARD;     move_backward
    when ROUTE_JUMP;              jump(params[0], params[1])
    when ROUTE_WAIT;              @wait_count = params[0] - 1
    when ROUTE_TURN_DOWN;         set_direction(2)
    when ROUTE_TURN_LEFT;         set_direction(4)
    when ROUTE_TURN_RIGHT;        set_direction(6)
    when ROUTE_TURN_UP;           set_direction(8)
    when ROUTE_TURN_90D_R;        turn_right_90
    when ROUTE_TURN_90D_L;        turn_left_90
    when ROUTE_TURN_180D;         turn_180
    when ROUTE_TURN_90D_R_L;      turn_right_or_left_90
    when ROUTE_TURN_RANDOM;       turn_random
    when ROUTE_TURN_TOWARD;       turn_toward_player
    when ROUTE_TURN_AWAY;         turn_away_from_player
    when ROUTE_SWITCH_ON;         $game_switches[params[0]] = true
    when ROUTE_SWITCH_OFF;        $game_switches[params[0]] = false
    when ROUTE_CHANGE_SPEED;      @move_speed = params[0]
    when ROUTE_CHANGE_FREQ;       @move_frequency = params[0]
    when ROUTE_WALK_ANIME_ON;     @walk_anime = true
    when ROUTE_WALK_ANIME_OFF;    @walk_anime = false
    when ROUTE_STEP_ANIME_ON;     @step_anime = true
    when ROUTE_STEP_ANIME_OFF;    @step_anime = false
    when ROUTE_DIR_FIX_ON;        @direction_fix = true
    when ROUTE_DIR_FIX_OFF;       @direction_fix = false
    when ROUTE_THROUGH_ON;        @event.name.include?("<不可穿透>")? @through = false : @through = true
    when ROUTE_THROUGH_OFF;       @through = false
    when ROUTE_TRANSPARENT_ON;    @transparent = true
    when ROUTE_TRANSPARENT_OFF;   @transparent = false
    when ROUTE_CHANGE_GRAPHIC;    set_graphic(params[0], params[1])
    when ROUTE_CHANGE_OPACITY;    @opacity = params[0]
    when ROUTE_CHANGE_BLENDING;   @blend_type = params[0]
    when ROUTE_PLAY_SE;           params[0].play
    when ROUTE_SCRIPT;            eval(params[0])
    end
  end
end[/pre]

点评

我每天能回家碰电脑也就那2~3小时了 速度真快真是帮大忙了~ 话说我几年没来提问了 记得以前有个认可答案的规定 版规找不到  发表于 2017-7-11 21:04

评分

参与人数 1星屑 +250 收起 理由
RaidenInfinity + 250 认可答案

查看全部评分

笨肉包的游戏讨论群932812135 (实时更新) 喜欢的话欢迎加入~
目前的坑
??? #像素风OC游戏 准备中 短篇-约5小时
花城梦之心 #像素风OC游戏 系统开发+素材绘制中
【不可思议的迷宫】幽灵契约外传:歌莉娅 v0.4 游戏文件已更新
同时更新中~ (沉迷摸鱼中~更新速度较慢请见谅w)
这是属于笨肉包一个人的旅行~(这只肉包又在摸鱼!
旅途的最终目标~ ???(保密~
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部