Project1

标题: 如何让事件不能被通过就算开了Through On [打印本页]

作者: phunmung5173    时间: 2017-7-10 23:26
标题: 如何让事件不能被通过就算开了Through On
我在地图上放了区域然后用脚本禁止角色通行(开了Through On也不行)


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


另外我的RMVA是英文的我不知道Through On中文叫什么.. 不明白的话我再解释
作者: 魔法丶小肉包    时间: 2017-7-11 10:54
事件名字上写<不可穿透>

RUBY 代码复制
  1. class Game_Event < Game_Character
  2.   def setup_page_settings
  3.     @tile_id          = @page.graphic.tile_id
  4.     @character_name   = @page.graphic.character_name
  5.     @character_index  = @page.graphic.character_index
  6.     if @original_direction != @page.graphic.direction
  7.       @direction          = @page.graphic.direction
  8.       @original_direction = @direction
  9.       @prelock_direction  = 0
  10.     end
  11.     if @original_pattern != @page.graphic.pattern
  12.       @pattern            = @page.graphic.pattern
  13.       @original_pattern   = @pattern
  14.     end
  15.     @move_type          = @page.move_type
  16.     @move_speed         = @page.move_speed
  17.     @move_frequency     = @page.move_frequency
  18.     @move_route         = @page.move_route
  19.     @move_route_index   = 0
  20.     @move_route_forcing = false
  21.     @walk_anime         = @page.walk_anime
  22.     @step_anime         = @page.step_anime
  23.     @direction_fix      = @page.direction_fix
  24.     if @event.name.include?("<不可穿透>")
  25.       @through = false
  26.     else
  27.       @through            = @page.through
  28.     end
  29.     @priority_type      = @page.priority_type
  30.     @trigger            = @page.trigger
  31.     @list               = @page.list
  32.     @interpreter = @trigger == 4 ? Game_Interpreter.new : nil
  33.   end
  34. end

作者: phunmung5173    时间: 2017-7-11 18:50
魔法丶小肉包 发表于 2017-7-11 10:54
事件名字上写

class Game_Event < Game_Character

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

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

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

RUBY 代码复制
  1. #==============================================================================
  2. #
  3. # ▼ Yanfly Engine Ace - Move Restrict Region v1.03
  4. # -- Last Updated: 2012.01.03
  5. # -- Level: Normal
  6. # -- Requires: n/a
  7. #
  8. #==============================================================================
  9.  
  10. $imported = {} if $imported.nil?
  11. $imported["YEA-MoveRestrictRegion"] = true
  12.  
  13. #==============================================================================
  14. # ▼ Updates
  15. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  16. # 2012.23.08 - Added Feature: <all restrict: x>
  17. # 2012.01.03 - Added Feature: <all restrict: x>
  18. # 2011.12.26 - Bug Fixed: Player Restricted Regions.
  19. # 2011.12.15 - Started Script and Finished.
  20. #
  21. #==============================================================================
  22. # ▼ Introduction
  23. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  24. # Not everybody wants NPC's to travel all over the place. With this script, you
  25. # can set NPC's to be unable to move pass tiles marked by a specified Region.
  26. # Simply draw out the area you want to enclose NPC's in on and they'll be
  27. # unable to move past it unless they have Through on. Likewise, there are
  28. # regions that you can prevent the player from moving onto, too!
  29. #
  30. #==============================================================================
  31. # ▼ Instructions
  32. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  33. # To install this script, open up your script editor and copy/paste this script
  34. # to an open slot below ▼ Materials/素材 but above ▼ Main. Remember to save.
  35. #
  36. # -----------------------------------------------------------------------------
  37. # Map Notetags - These notetags go in the map notebox in a map's properties.
  38. # -----------------------------------------------------------------------------
  39. # <all restrict: x>
  40. # <all restrict: x, x>
  41. # Players and NPC's on the map will be unable to move past region x even if
  42. # they have the "through" flag set. The only thing that can go past is if the
  43. # player is using the debug through flag. Draw out the area you want to close
  44. # the player and NPC's in with the regions and both will be unable to move onto
  45. # any of those tiles marked by region x. If you want to have more regions
  46. # restrict NPC's, insert multiples of this tag.
  47. #
  48. # <npc restrict: x>
  49. # <npc restrict: x, x>
  50. # NPC's on that map will be unable to move past regions x unless they have a
  51. # "Through" flag on. Draw out the area you want to close NPC's in with the
  52. # regions and the NPC's will be unable to move onto any of those tiles marked
  53. # by region x. If you want to have more regions restrict NPC's, insert
  54. # multiples of this tag.
  55. #
  56. # <player restrict: x>
  57. # <player restrict: x, x>
  58. # Players will not be able to move on tiles marked by region x unless the
  59. # player has a "Through" flag on. Draw out the area you want to close the
  60. # player in with the regions and the player will be unable to move past any of
  61. # those tiles marked by region x. If you want to have more regions restrict the
  62. # player, insert multiples of this tag.
  63. #
  64. #==============================================================================
  65. # ▼ Compatibility
  66. # =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
  67. # This script is made strictly for RPG Maker VX Ace. It is highly unlikely that
  68. # it will run with RPG Maker VX without adjusting.
  69. #
  70. #==============================================================================
  71.  
  72. module YEA
  73.   module MOVE_RESTRICT
  74.  
  75.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  76.     # - Default Completely Restricted Regions -
  77.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  78.     # If you want there to always be a region ID that will forbid both the
  79.     # player and NPC's from passing through, insert that region ID into the
  80.     # array below. This effect will completely block out both players and NPC's
  81.     # even if they have the "through" flag. However, it does not block the
  82.     # debug_through flag for players.
  83.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  84.     DEFAULT_ALL = [61]
  85.  
  86.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  87.     # - Default Player Restricted Regions -
  88.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  89.     # If you want there to always be a region ID that will forbid the player
  90.     # from passing through, insert that region ID into the array below.
  91.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  92.     DEFAULT_PLAYER = [62]
  93.  
  94.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  95.     # - Default NPC Restricted Regions -
  96.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  97.     # If you want there to always be a region ID that will forbid NPC's from
  98.     # passing through, insert that region ID into the array below.
  99.     #=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  100.     DEFAULT_NPC = [63]
  101.  
  102.   end # MOVE_RESTRICT
  103. end # YEA
  104.  
  105. #==============================================================================
  106. # ▼ Editting anything past this point may potentially result in causing
  107. # computer damage, incontinence, explosion of user's head, coma, death, and/or
  108. # halitosis so edit at your own risk.
  109. #==============================================================================
  110.  
  111. module YEA
  112.   module REGEXP
  113.   module MAP
  114.  
  115.     ALL_RESTRICT =
  116.       /<(?:ALL_RESTRICT|all restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  117.     NPC_RESTRICT =
  118.       /<(?:NPC_RESTRICT|npc restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  119.     PLAYER_RESTRICT =
  120.       /<(?:PLAYER_RESTRICT|player restrict):[ ]*(\d+(?:\s*,\s*\d+)*)>/i
  121.  
  122.   end # MAP
  123.   end # REGEXP
  124. end # YEA
  125.  
  126. #==============================================================================
  127. # ■ RPG::Map
  128. #==============================================================================
  129.  
  130. class RPG::Map
  131.  
  132.   #--------------------------------------------------------------------------
  133.   # public instance variables
  134.   #--------------------------------------------------------------------------
  135.   attr_accessor :all_restrict_regions
  136.   attr_accessor :npc_restrict_regions
  137.   attr_accessor :player_restrict_regions
  138.  
  139.   #--------------------------------------------------------------------------
  140.   # common cache: load_notetags_mrr
  141.   #--------------------------------------------------------------------------
  142.   def load_notetags_mrr
  143.     @all_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_ALL.clone
  144.     @npc_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_NPC.clone
  145.     @player_restrict_regions = YEA::MOVE_RESTRICT::DEFAULT_PLAYER.clone
  146.     #---
  147.     self.note.split(/[\r\n]+/).each { |line|
  148.       case line
  149.       #---
  150.       when YEA::REGEXP::MAP::ALL_RESTRICT
  151.         $1.scan(/\d+/).each { |num|
  152.         @all_restrict_regions.push(num.to_i) if num.to_i > 0 }
  153.       when YEA::REGEXP::MAP::NPC_RESTRICT
  154.         $1.scan(/\d+/).each { |num|
  155.         @npc_restrict_regions.push(num.to_i) if num.to_i > 0 }
  156.       when YEA::REGEXP::MAP::PLAYER_RESTRICT
  157.         $1.scan(/\d+/).each { |num|
  158.         @player_restrict_regions.push(num.to_i) if num.to_i > 0 }
  159.       #---
  160.       end
  161.     } # self.note.split
  162.     #---
  163.   end
  164.  
  165. end # RPG::Map
  166.  
  167. #==============================================================================
  168. # ■ Game_Map
  169. #==============================================================================
  170.  
  171. class Game_Map
  172.  
  173.   #--------------------------------------------------------------------------
  174.   # alias method: setup
  175.   #--------------------------------------------------------------------------
  176.   alias game_map_setup_mrr setup
  177.   def setup(map_id)
  178.     game_map_setup_mrr(map_id)
  179.     @map.load_notetags_mrr
  180.   end
  181.  
  182.   #--------------------------------------------------------------------------
  183.   # new method: all_restrict_regions
  184.   #--------------------------------------------------------------------------
  185.   def all_restrict_regions
  186.     return @map.all_restrict_regions
  187.   end
  188.  
  189.   #--------------------------------------------------------------------------
  190.   # new method: npc_restrict_regions
  191.   #--------------------------------------------------------------------------
  192.   def npc_restrict_regions
  193.     return @map.npc_restrict_regions
  194.   end
  195.  
  196.   #--------------------------------------------------------------------------
  197.   # new method: player_restrict_regions
  198.   #--------------------------------------------------------------------------
  199.   def player_restrict_regions
  200.     return @map.player_restrict_regions
  201.   end
  202.  
  203. end # Game_Map
  204.  
  205. #==============================================================================
  206. # ■ Game_CharacterBase
  207. #==============================================================================
  208.  
  209. class Game_CharacterBase
  210.  
  211.   #--------------------------------------------------------------------------
  212.   # alias method: passable?
  213.   #--------------------------------------------------------------------------
  214.   alias game_characterbase_passable_mrr passable?
  215.   def passable?(x, y, d)
  216.     return false if npc_region_forbid?(x, y, d)
  217.     return false if player_region_forbid?(x, y, d)
  218.     return game_characterbase_passable_mrr(x, y, d)
  219.   end
  220.  
  221.   #--------------------------------------------------------------------------
  222.   # new method: npc_forbid?
  223.   #--------------------------------------------------------------------------
  224.   def npc_region_forbid?(x, y, d)
  225.     return false unless self.is_a?(Game_Event)
  226.     region = 0
  227.     case d
  228.     when 1; region = $game_map.region_id(x-1, y+1)
  229.     when 2; region = $game_map.region_id(x+0, y+1)
  230.     when 3; region = $game_map.region_id(x+1, y+1)
  231.     when 4; region = $game_map.region_id(x-1, y+0)
  232.     when 5; region = $game_map.region_id(x+0, y+0)
  233.     when 6; region = $game_map.region_id(x+1, y+0)
  234.     when 7; region = $game_map.region_id(x-1, y-1)
  235.     when 8; region = $game_map.region_id(x+0, y-1)
  236.     when 9; region = $game_map.region_id(x+1, y-1)
  237.     end
  238.     return true if $game_map.all_restrict_regions.include?(region)
  239.     return false if @through
  240.     return $game_map.npc_restrict_regions.include?(region)
  241.   end
  242.  
  243.   #--------------------------------------------------------------------------
  244.   # new method: player_region_forbid?
  245.   #--------------------------------------------------------------------------
  246.   def player_region_forbid?(x, y, d)
  247.     return false unless self.is_a?(Game_Player)
  248.     return false if debug_through?
  249.     region = 0
  250.     case d
  251.     when 1; region = $game_map.region_id(x-1, y+1)
  252.     when 2; region = $game_map.region_id(x+0, y+1)
  253.     when 3; region = $game_map.region_id(x+1, y+1)
  254.     when 4; region = $game_map.region_id(x-1, y+0)
  255.     when 5; region = $game_map.region_id(x+0, y+0)
  256.     when 6; region = $game_map.region_id(x+1, y+0)
  257.     when 7; region = $game_map.region_id(x-1, y-1)
  258.     when 8; region = $game_map.region_id(x+0, y-1)
  259.     when 9; region = $game_map.region_id(x+1, y-1)
  260.     end
  261.     return true if $game_map.all_restrict_regions.include?(region)
  262.     return false if @through
  263.     return $game_map.player_restrict_regions.include?(region)
  264.   end
  265.  
  266. end # Game_CharacterBase
  267.  
  268. #==============================================================================
  269. #
  270. # ▼ End of File
  271. #
  272. #==============================================================================


RUBY 代码复制
  1. #==============================================================================
  2. # ** Game_CharacterBase
  3. #------------------------------------------------------------------------------
  4. #  This base class handles characters. It retains basic information, such as
  5. # coordinates and graphics, shared by all characters.
  6. #==============================================================================
  7.  
  8. class Game_CharacterBase
  9.   alias regpass? passable?
  10.   #--------------------------------------------------------------------------
  11.   # * Determine if Passable
  12.   #     d : Direction (2,4,6,8)
  13.   #--------------------------------------------------------------------------
  14.   def passable?(x, y, d)
  15.     x2 = $game_map.round_x_with_direction(x, d)
  16.     y2 = $game_map.round_y_with_direction(y, d)
  17.     return false if $game_map.region_id(x2, y2) == 2 && !debug_through?
  18.     regpass?(x,y,d)
  19.   end
  20. end


另外用了Falcao 的ARPG系统 所以事件本身已经有名字


作者: 魔法丶小肉包    时间: 2017-7-11 20:04
修改了一下,放在这个arpg系统的下方,事件已经有名字了也没关系,只要加上<不可穿透>
比如:<enemy: 33><不可穿透>
RUBY 代码复制
  1. class Game_Event < Game_Character
  2.   def setup_page_settings
  3.     create_token_arrays
  4.     @tile_id          = @page.graphic.tile_id
  5.     @character_name   = @page.graphic.character_name
  6.     @character_index  = @page.graphic.character_index
  7.     if @original_direction != @page.graphic.direction
  8.       @direction          = @page.graphic.direction
  9.       @original_direction = @direction
  10.       @prelock_direction  = 0
  11.     end
  12.     if @original_pattern != @page.graphic.pattern
  13.       @pattern            = @page.graphic.pattern
  14.       @original_pattern   = @pattern
  15.     end
  16.     @move_type          = @page.move_type
  17.     @move_speed         = @page.move_speed
  18.     @move_frequency     = @page.move_frequency
  19.     @move_route         = @page.move_route
  20.     @move_route_index   = 0
  21.     @move_route_forcing = false
  22.     @walk_anime         = @page.walk_anime
  23.     @step_anime         = @page.step_anime
  24.     @direction_fix      = @page.direction_fix
  25.     if @event.name.include?("<不可穿透>")
  26.       @through = false
  27.     else
  28.       @through            = @page.through
  29.     end
  30.     @priority_type      = @page.priority_type
  31.     @trigger            = @page.trigger
  32.     @list               = @page.list
  33.     @interpreter = @trigger == 4 ? Game_Interpreter.new : nil
  34.     wtag = string_data("<start_with_weapon: ")
  35.     @token_weapon = wtag.split(",").map { |s| s.to_i } if wtag != nil
  36.     atag = string_data("<start_with_armor: ")
  37.     @token_armor = atag.split(",").map { |s| s.to_i } if atag != nil
  38.     itag = string_data("<start_with_item: ")
  39.     @token_item = itag.split(",").map { |s| s.to_i } if itag != nil
  40.     stag = string_data("<start_with_skill: ")
  41.     @token_skill = stag.split(",").map { |s| s.to_i } if stag != nil
  42.     @hook_pull = string_data("<hook_pull: ") == "true"
  43.     @hook_grab = string_data("<hook_grab: ") == "true"
  44.     @boom_grab = string_data("<boom_grab: ") == "true"
  45.     @boom_start = string_data("<boomed_start: ") == "true"
  46.     @direction_fix = false if @hook_grab
  47.     if has_token? || @hook_pull || @hook_grab || @boom_grab || @boom_start
  48.       $game_map.events_withtags.push(self) unless
  49.       $game_map.events_withtags.include?(self)
  50.     end
  51.     @parallel_mode = @trigger == 3 || @trigger == 4 || @ignore_antilag
  52.   end
  53. end
  54. class Game_Character < Game_CharacterBase
  55.   def process_move_command(command)
  56.     params = command.parameters
  57.     case command.code
  58.     when ROUTE_END;               process_route_end
  59.     when ROUTE_MOVE_DOWN;         move_straight(2)
  60.     when ROUTE_MOVE_LEFT;         move_straight(4)
  61.     when ROUTE_MOVE_RIGHT;        move_straight(6)
  62.     when ROUTE_MOVE_UP;           move_straight(8)
  63.     when ROUTE_MOVE_LOWER_L;      move_diagonal(4, 2)
  64.     when ROUTE_MOVE_LOWER_R;      move_diagonal(6, 2)
  65.     when ROUTE_MOVE_UPPER_L;      move_diagonal(4, 8)
  66.     when ROUTE_MOVE_UPPER_R;      move_diagonal(6, 8)
  67.     when ROUTE_MOVE_RANDOM;       move_random
  68.     when ROUTE_MOVE_TOWARD;       move_toward_player
  69.     when ROUTE_MOVE_AWAY;         move_away_from_player
  70.     when ROUTE_MOVE_FORWARD;      move_forward
  71.     when ROUTE_MOVE_BACKWARD;     move_backward
  72.     when ROUTE_JUMP;              jump(params[0], params[1])
  73.     when ROUTE_WAIT;              @wait_count = params[0] - 1
  74.     when ROUTE_TURN_DOWN;         set_direction(2)
  75.     when ROUTE_TURN_LEFT;         set_direction(4)
  76.     when ROUTE_TURN_RIGHT;        set_direction(6)
  77.     when ROUTE_TURN_UP;           set_direction(8)
  78.     when ROUTE_TURN_90D_R;        turn_right_90
  79.     when ROUTE_TURN_90D_L;        turn_left_90
  80.     when ROUTE_TURN_180D;         turn_180
  81.     when ROUTE_TURN_90D_R_L;      turn_right_or_left_90
  82.     when ROUTE_TURN_RANDOM;       turn_random
  83.     when ROUTE_TURN_TOWARD;       turn_toward_player
  84.     when ROUTE_TURN_AWAY;         turn_away_from_player
  85.     when ROUTE_SWITCH_ON;         $game_switches[params[0]] = true
  86.     when ROUTE_SWITCH_OFF;        $game_switches[params[0]] = false
  87.     when ROUTE_CHANGE_SPEED;      @move_speed = params[0]
  88.     when ROUTE_CHANGE_FREQ;       @move_frequency = params[0]
  89.     when ROUTE_WALK_ANIME_ON;     @walk_anime = true
  90.     when ROUTE_WALK_ANIME_OFF;    @walk_anime = false
  91.     when ROUTE_STEP_ANIME_ON;     @step_anime = true
  92.     when ROUTE_STEP_ANIME_OFF;    @step_anime = false
  93.     when ROUTE_DIR_FIX_ON;        @direction_fix = true
  94.     when ROUTE_DIR_FIX_OFF;       @direction_fix = false
  95.     when ROUTE_THROUGH_ON;        @event.name.include?("<不可穿透>")? @through = false : @through = true
  96.     when ROUTE_THROUGH_OFF;       @through = false
  97.     when ROUTE_TRANSPARENT_ON;    @transparent = true
  98.     when ROUTE_TRANSPARENT_OFF;   @transparent = false
  99.     when ROUTE_CHANGE_GRAPHIC;    set_graphic(params[0], params[1])
  100.     when ROUTE_CHANGE_OPACITY;    @opacity = params[0]
  101.     when ROUTE_CHANGE_BLENDING;   @blend_type = params[0]
  102.     when ROUTE_PLAY_SE;           params[0].play
  103.     when ROUTE_SCRIPT;            eval(params[0])
  104.     end
  105.   end
  106. end





欢迎光临 Project1 (https://rpg.blue/) Powered by Discuz! X3.1