Project1

标题: 谁知道这个脚本怎么用啊 [打印本页]

作者: dongdongok    时间: 2008-7-17 07:57
标题: 谁知道这个脚本怎么用啊
  1. #================================
  2. # ■ Dynamic Maps
  3. #================================
  4. #  By: Near Fantastica
  5. #   Date: 05.09.05
  6. #   Version: 1
  7. #================================

  8. module Map
  9. #--------------------------------------------------------------
  10. @map_data = {}
  11. #--------------------------------------------------------------------------  
  12. def Map.set_map(map, map_id)
  13.    @map_data[map_id] = map
  14. end
  15. #--------------------------------------------------------------------------  
  16. def Map.data(map_id)
  17.    return @map_data[map_id]
  18. end
  19. end

  20. class Map_Data
  21. #--------------------------------------------------------------
  22. attr_accessor :map_id
  23. attr_accessor :map
  24. attr_accessor :tileset_name
  25. attr_accessor :autotile_names
  26. attr_accessor :panorama_name
  27. attr_accessor :panorama_hue
  28. attr_accessor :fog_name
  29. attr_accessor :fog_hue
  30. attr_accessor :fog_opacity
  31. attr_accessor :fog_blend_type
  32. attr_accessor :fog_zoom
  33. attr_accessor :fog_sx
  34. attr_accessor :fog_sy
  35. attr_accessor :battleback_name
  36. attr_accessor :passages
  37. attr_accessor :priorities
  38. attr_accessor :terrain_tags
  39. attr_accessor :display_x
  40. attr_accessor :display_y
  41. attr_accessor :need_refresh
  42. attr_accessor :events
  43. attr_accessor :common_events
  44. attr_accessor :fog_ox
  45. attr_accessor :fog_oy
  46. attr_accessor :fog_tone
  47. attr_accessor :fog_tone_target
  48. attr_accessor :fog_tone_duration
  49. attr_accessor :fog_opacity_duration
  50. attr_accessor :fog_opacity_target
  51. attr_accessor :scroll_direction
  52. attr_accessor :scroll_rest
  53. attr_accessor :scroll_speed
  54. attr_accessor :fow_on
  55. attr_accessor :fow_grid
  56. attr_accessor :fow_range
  57. #-------------------------------------------------------------
  58. def initialize
  59.    @map_id = 0
  60.    @map = 0
  61.    @tileset_name = 0
  62.    @autotile_names = 0
  63.    @panorama_name = 0
  64.    @panorama_hue = 0
  65.    @fog_name = 0
  66.    @fog_hue = 0
  67.    @fog_opacity = 0
  68.    @fog_blend_type = 0
  69.    @fog_zoom = 0
  70.    @fog_sx = 0
  71.    @fog_sy = 0
  72.    @battleback_name = 0
  73.    @passages = 0
  74.    @priorities = 0
  75.    @terrain_tags = 0
  76.    @display_x = 0
  77.    @display_y = 0
  78.    @need_refresh = 0
  79.    @events = 0
  80.    @common_events = 0
  81.    @fog_ox = 0
  82.    @fog_oy = 0
  83.    @fog_tone = 0
  84.    @fog_tone_target = 0
  85.    @fog_tone_duration = 0
  86.    @fog_opacity_duration = 0
  87.    @fog_opacity_target = 0
  88.    @scroll_direction = 0
  89.    @scroll_rest = 0
  90.    @scroll_speed = 0
  91.    @fow_on = 0 # FOW   
  92.    @fow_grid = 0 # FOW  
  93.    @fow_range = 0 # FOW   
  94. end
  95. end

  96. class Game_Map
  97.   

  98.   
  99.   
  100. #--------------------------------------------------------------
  101. def setup(map_id)
  102.    save_map(@map_id)
  103.    if Map.data(map_id) == nil
  104.      setup_map(map_id)
  105.    else
  106.      load_map(map_id)
  107.    end
  108. end
  109. #--------------------------------------------------------------
  110. def setup_map(map_id)
  111.    @map_id = map_id
  112.    @map = load_data(sprintf("Data/Map%03d.rxdata", @map_id))
  113.    tileset = $data_tilesets[@map.tileset_id]
  114.    @tileset_name = tileset.tileset_name
  115.    @autotile_names = tileset.autotile_names
  116.    @panorama_name = tileset.panorama_name
  117.    @panorama_hue = tileset.panorama_hue
  118.    @fog_name = tileset.fog_name
  119.    @fog_hue = tileset.fog_hue
  120.    @fog_opacity = tileset.fog_opacity
  121.    @fog_blend_type = tileset.fog_blend_type
  122.    @fog_zoom = tileset.fog_zoom
  123.    @fog_sx = tileset.fog_sx
  124.    @fog_sy = tileset.fog_sy
  125.    @battleback_name = tileset.battleback_name
  126.    @passages = tileset.passages
  127.    @priorities = tileset.priorities
  128.    @terrain_tags = tileset.terrain_tags
  129.    @display_x = 0
  130.    @display_y = 0
  131.    @need_refresh = false
  132.    @events = {}
  133.    for i in @map.events.keys
  134.      @events[i] = Game_Event.new(@map_id, @map.events[i])
  135.    end
  136.    @common_events = {}
  137.    for i in 1...$data_common_events.size
  138.      @common_events[i] = Game_CommonEvent.new(i)
  139.    end
  140.    @fog_ox = 0
  141.    @fog_oy = 0
  142.    @fog_tone = Tone.new(0, 0, 0, 0)
  143.    @fog_tone_target = Tone.new(0, 0, 0, 0)
  144.    @fog_tone_duration = 0
  145.    @fog_opacity_duration = 0
  146.    @fog_opacity_target = 0
  147.    @scroll_direction = 2
  148.    @scroll_rest = 0
  149.    @scroll_speed = 4
  150. end
  151. #-----------------------------------------------------------
  152. def load_map(map_id)
  153.    map_data = Map.data(map_id)
  154.    @map_id = map_data.map_id
  155.    @map = map_data.map
  156.    @tileset_name = map_data.tileset_name
  157.    @autotile_names = map_data.autotile_names
  158.    @panorama_name = map_data.panorama_name
  159.    @panorama_hue =  map_data.panorama_hue
  160.    @fog_name = map_data.fog_name
  161.    @fog_hue = map_data.fog_hue
  162.    @fog_opacity = map_data.fog_opacity
  163.    @fog_blend_type = map_data.fog_blend_type
  164.    @fog_zoom = map_data.fog_zoom
  165.    @fog_sx = map_data.fog_sx
  166.    @fog_sy = map_data.fog_sy
  167.    @battleback_name = map_data.battleback_name
  168.    @passages = map_data.passages
  169.    @priorities = map_data.priorities
  170.    @terrain_tags = map_data.terrain_tags
  171.    @display_x = map_data.display_x
  172.    @display_y = map_data.display_y
  173.    @need_refresh = map_data.need_refresh
  174.    @events = map_data.events
  175.    @common_events = map_data.common_events
  176.    @fog_ox = map_data.fog_ox
  177.    @fog_oy = map_data.fog_oy
  178.    @fog_tone = map_data.fog_tone
  179.    @fog_tone_target = map_data.fog_tone_target
  180.    @fog_tone_duration = map_data.fog_tone_duration
  181.    @fog_opacity_duration = map_data.fog_opacity_duration
  182.    @fog_opacity_target = map_data.fog_opacity_target
  183.    @scroll_direction = map_data.scroll_direction
  184.    @scroll_rest = map_data.scroll_rest
  185.    @scroll_speed = map_data.scroll_speed
  186.    @fow_on = map_data.fow_on # FOW     
  187.    @fow_grid = map_data.fow_grid # FOW
  188.    @fow_range = map_data.fow_range # FOW
  189. end
  190. #--------------------------------------------------------------
  191. def save_map(map_id)
  192.    return if map_id == 0
  193.    map_data = Map_Data.new
  194.    map_data.map_id = map_id
  195.    map_data.map = @map
  196.    map_data.tileset_name = @tileset_name
  197.    map_data.autotile_names = @autotile_names
  198.    map_data.panorama_name = @panorama_name
  199.    map_data.panorama_hue = @panorama_hue
  200.    map_data.fog_name = @fog_name
  201.    map_data.fog_hue = @fog_hue
  202.    map_data.fog_opacity = @fog_opacity
  203.    map_data.fog_blend_type = @fog_blend_type
  204.    map_data.fog_zoom = @fog_zoom
  205.    map_data.fog_sx = @fog_sx
  206.    map_data.fog_sy = @fog_sy
  207.    map_data.battleback_name = @battleback_name
  208.    map_data.passages = @passages
  209.    map_data.priorities = @priorities
  210.    map_data.terrain_tags =  @terrain_tags
  211.    map_data.display_x = @display_x
  212.    map_data.display_y = @display_y
  213.    map_data.need_refresh = @need_refresh
  214.    map_data.events = @events
  215.    map_data.common_events = @common_events
  216.    map_data.fog_ox = @fog_ox
  217.    map_data.fog_oy = @fog_oy
  218.    map_data.fog_tone = @fog_tone
  219.    map_data.fog_tone_target = @fog_tone_target
  220.    map_data.fog_tone_duration =  @fog_tone_duration
  221.    map_data.fog_opacity_duration = @fog_opacity_duration
  222.    map_data.fog_opacity_target = @fog_opacity_target
  223.    map_data.scroll_direction = @scroll_direction
  224.    map_data.scroll_rest = @scroll_rest
  225.    map_data.scroll_speed = @scroll_speed
  226.    map_data.fow_on = @fow_on # FOW      
  227.    map_data.fow_grid = @fow_grid # FOW
  228.    map_data.fow_range = @fow_range # FOW
  229.    Map.set_map(map_data, map_id)
  230. end
  231. end

  232. =begin
  233.   ============
  234.    Fog of War - version 1.0 (2005-10-26)
  235.   ============
  236.    by Wachunga
  237.    
  238.   0.8 - original release
  239.   0.85
  240.     - added colour parameter to map names
  241.     - fixed bug where map grids overlapped
  242.   0.9
  243.     - switched over to a tilemap (from a sprite)
  244.     - now more compatible with minimap scripts (but they'll have to take
  245.     extra tilemap into account)
  246.   1.0
  247.     - switched over to an autotile instead of using a custom tileset
  248.       * edges looks nicer, but gradual fading had to be removed
  249.       * colour parameter no longer possible (set by autotile)
  250.     - move event (including jumping and speed changes) bug fixed
  251.     - teleportation bug fixed
  252.     - some optimization
  253.     - made compatible with Cogwheel's Pixel Movement script
  254.     (see http://www.rmxp.net/forums/index.php?showtopic=24716 for details)
  255.    
  256.   Note:
  257.   There's no need to add the autotile via the database. Just place the file in
  258.   the autotile folder, import it, and change the FOW_AT_NAME constant to
  259.   the appropriate filename. To change the colour of the fog of war, create a
  260.   new autotile.
  261.   
  262.   To indicate a map is to have fog of war (i.e. its tiles are dark until
  263.   the player gets within visual range), include <FoW> in its name.  You may
  264.   also optionally specify a range between 0 and 3. This may also be
  265.   included in the map name, as in this example:
  266.   "your-map-name <FoW><2>" (range is 2)
  267.   
  268.   The ranges work as follows:
  269.   
  270.   range = 0 reveals just the square on which the player stands
  271.   
  272.   range = 1 is the same as range 0 plus four adjacent tiles
  273.   i.e.   @
  274.         @P@
  275.          @
  276.   
  277.   range = 2 is the same as range 1 plus eight additional tiles
  278.    i.e.  @
  279.         @@@
  280.        @@P@@
  281.         @@@
  282.          @
  283.          
  284.   range = 3 (default) is the same as range 2 plus twelve additional tiles
  285.    i.e.  @
  286.         @@@
  287.        @@@@@
  288.       @@@P@@@
  289.        @@@@@
  290.         @@@      
  291.          @
  292. =end

  293. #-------------------------------------------------------------------------------

  294.   FOW = 0b00
  295.   REVEALED = 0b01
  296.   # tiles with no surrounding fog are flagged "SKIP" for efficiency
  297.   SKIP = 0b10

  298.   FOW_AT_NAME = "fow_default"
  299.   
  300. #-------------------------------------------------------------------------------  
  301.   
  302. class Game_Map
  303.   
  304.   attr_reader :fow_on
  305.   attr_reader :fow_grid
  306.   attr_reader :fow_range

  307.   alias dm_setup setup_map
  308.   def setup_map(map_id)
  309.     dm_setup(map_id)
  310.     # set defaults
  311.     @fow_on = false
  312.     @fow_grid = nil   
  313.     @fow_range = 3
  314.     # get any tags from the map name
  315.     tags = $game_map.map_name.delete(' ').scan(/<[A-Za-z0-9_.,]+>/)
  316.     if not tags.empty? and tags[0].upcase == '<FOW>'
  317.       tags.shift # remove FOW tag
  318.       @fow_on = true
  319.       if @fow_grid == nil # only if not already defined
  320.           @fow_grid = Array.new(@map.width, FOW)
  321.           for i in [email protected]
  322.             @fow_grid[i] = Array.new(@map.height, FOW)
  323.           end
  324.       end
  325.       # check if range specified, else default to 3
  326.       if not tags.empty?
  327.         x = tags[0].delete("<>").to_i
  328.         @fow_range = x if x >= 0 and x < 4
  329.       end
  330.     end
  331.   end
  332.   
  333. =begin  
  334.   Updates the underlying grid which keeps track of which tiles have been
  335.   "discovered" (i.e. no fog of war) based on where player has already explored.
  336. =end
  337.   def update_fow_grid
  338.     px = $game_player.x
  339.     py = $game_player.y

  340.     @fow_grid[px][py] |= REVEALED
  341.     # reveal more, depending on range
  342.     if @fow_range > 0
  343.       if px > 0
  344.         @fow_grid[px-1][py] |= REVEALED
  345.       end
  346.       if py < @map.height-1
  347.         @fow_grid[px][py+1] |= REVEALED
  348.       end
  349.       if py > 0
  350.         @fow_grid[px][py-1] |= REVEALED
  351.       end
  352.       if px < @map.width-1
  353.         @fow_grid[px+1][py] |= REVEALED
  354.       end
  355.      
  356.       if @fow_range > 1
  357.         if px > 0
  358.           if py > 0
  359.             @fow_grid[px-1][py-1] |= REVEALED
  360.           end
  361.           if py < @map.height-1
  362.             @fow_grid[px-1][py+1] |= REVEALED   
  363.           end            
  364.           if px > 1      
  365.             @fow_grid[px-2][py] |= REVEALED
  366.           end
  367.         end
  368.         if px < @map.width-1
  369.           if py > 0
  370.             @fow_grid[px+1][py-1] |= REVEALED
  371.           end
  372.           if py < @map.height-1
  373.             @fow_grid[px+1][py+1] |= REVEALED
  374.           end
  375.         end
  376.         if px < @map.width-2
  377.           @fow_grid[px+2][py] |= REVEALED
  378.         end           
  379.         if py > 1
  380.           @fow_grid[px][py-2] |= REVEALED      
  381.         end
  382.         if py < @map.height-2
  383.           @fow_grid[px][py+2] |= REVEALED
  384.         end        

  385.         if @fow_range > 2
  386.           if px > 0
  387.             if py > 1
  388.               @fow_grid[px-1][py-2] |= REVEALED
  389.             end
  390.             if py < @map.height-2
  391.               @fow_grid[px-1][py+2] |= REVEALED   
  392.             end               
  393.             if px > 1
  394.               if py > 0
  395.                 @fow_grid[px-2][py-1] |= REVEALED
  396.               end
  397.               if py < @map.height-1
  398.                 @fow_grid[px-2][py+1] |= REVEALED  
  399.               end              
  400.               if px > 2
  401.                 @fow_grid[px-3][py] |= REVEALED               
  402.               end
  403.             end
  404.           end
  405.           if px < @map.width-1
  406.             if py > 1
  407.               @fow_grid[px+1][py-2] |= REVEALED
  408.             end
  409.             if py < @map.height-2
  410.               @fow_grid[px+1][py+2] |= REVEALED
  411.             end
  412.             if px < @map.width-2
  413.               if py > 0
  414.                 @fow_grid[px+2][py-1] |= REVEALED
  415.               end
  416.               if py < @map.height-1
  417.                 @fow_grid[px+2][py+1] |= REVEALED               
  418.               end              
  419.               if px < @map.width-3
  420.                 @fow_grid[px+3][py] |= REVEALED   
  421.               end               
  422.             end
  423.           end         
  424.           if py > 2
  425.             @fow_grid[px][py-3] |= REVEALED      
  426.           end         
  427.           if py < @map.height-3
  428.             @fow_grid[px][py+3] |= REVEALED
  429.           end         
  430.         end
  431.       end
  432.     end
  433.   end  
  434.   
  435.   def map_name
  436.     return load_data("Data/MapInfos.rxdata")[@map_id].name
  437.   end  
  438.       
  439. end      

  440. #-------------------------------------------------------------------------------

  441. class Spriteset_Map
  442.   
  443.   def initialize
  444.     @viewport1 = Viewport.new(0, 0, 640, 480)
  445.     @viewport2 = Viewport.new(0, 0, 640, 480)
  446.     @viewport3 = Viewport.new(0, 0, 640, 480)
  447.     @viewport2.z = 200
  448.     @viewport3.z = 5000
  449.     @tilemap = Tilemap.new(@viewport1)
  450.     @tilemap.tileset = RPG::Cache.tileset($game_map.tileset_name)
  451.     for i in 0..6
  452.       autotile_name = $game_map.autotile_names[i]
  453.       @tilemap.autotiles[i] = RPG::Cache.autotile(autotile_name)
  454.     end
  455.     @tilemap.map_data = $game_map.data
  456.     @tilemap.priorities = $game_map.priorities
  457.     @panorama = Plane.new(@viewport1)
  458.     @panorama.z = -1000
  459.     @fog = Plane.new(@viewport1)
  460.     @fog.z = 3000
  461.     @character_sprites = []
  462.     for i in $game_map.events.keys.sort
  463.       sprite = Sprite_Character.new(@viewport1, $game_map.events[i])
  464.       @character_sprites.push(sprite)
  465.     end
  466.     @character_sprites.push(Sprite_Character.new(@viewport1, $game_player))
  467.     @weather = RPG::Weather.new(@viewport1)
  468.     @picture_sprites = []
  469.     for i in 1..50
  470.       @picture_sprites.push(Sprite_Picture.new(@viewport2,
  471.         $game_screen.pictures[i]))
  472.     end
  473.     @timer_sprite = Sprite_Timer.new

  474.     # add fog of war tilemap...
  475.     if $game_map.fow_on
  476.       for m in 0...$game_map.width
  477.         for n in 0...$game_map.height
  478.           # reset SKIP flag
  479.           $game_map.fow_grid[m][n] &= ~SKIP
  480.         end
  481.       end
  482.       @fow_tilemap = Tilemap.new(@viewport1)
  483.       @fow_tilemap.autotiles[0] = RPG::Cache.autotile(FOW_AT_NAME)
  484.       @fow_autotiles = Hash.new(0)
  485.       j = 48 # starting autotile index
  486.       for i in Autotile_Keys
  487.         @fow_autotiles[i] = j
  488.         j += 1
  489.       end
  490.       # add duplicates
  491.       for i in Duplicate_Keys.keys
  492.         @fow_autotiles[i] = @fow_autotiles[Duplicate_Keys[i]]
  493.       end
  494.       data = Table.new($game_map.width, $game_map.height, 3)
  495.       # set everything to fog
  496.       for x in 0...$game_map.width
  497.         for y in 0...$game_map.height
  498.           data[x,y,2] = 48 # fog
  499.         end
  500.       end
  501.       @fow_tilemap.map_data = data
  502.       priorities = Table.new(96)
  503.       # set to highest priority to ensure everything is covered
  504.       for i in 48...96
  505.         priorities[i] = 5
  506.       end
  507.       @fow_tilemap.priorities = priorities
  508.       $game_map.update_fow_grid
  509.       update_fow_tilemap # reveal any explored tiles
  510.     end
  511.     update   
  512.   end
  513.   
  514. =begin
  515.   Updates the fog of war tilemap based on the map's underlying grid.
  516.   
  517.   This method is called by Game_Player.update whenever the player moves.
  518. =end
  519.   def update_fow_tilemap
  520.     checked = Array.new($game_map.width,0)
  521.     for k in 0...$game_map.width
  522.       checked[k] = Array.new($game_map.height,0)
  523.     end
  524.     for x in (($game_map.display_x/128)-1).round .. (($game_map.display_x/128)+21).round
  525.       for y in (($game_map.display_y/128)-1).round .. (($game_map.display_y/128)+16).round
  526.         # check boundaries
  527.         if x > $game_map.width - 1 or x < 0 then next end
  528.         if y > $game_map.height - 1 or y < 0 then next end   
  529.         if $game_map.fow_grid[x][y] == REVEALED # (but not SKIP)
  530.           others = false
  531.           @fow_tilemap.map_data[x,y,2] = 0 if @fow_tilemap.map_data[x,y,2] != 0
  532.           for i in x-1 .. x+1
  533.             for j in y-1 .. y+1
  534.               # check new boundaries
  535.               if i > $game_map.width - 1 or i < 0 then next end
  536.               if j > $game_map.height - 1 or j < 0 then next end
  537.               if $game_map.fow_grid[i][j] == FOW
  538.                 others = true # can't flag as SKIP because there's nearby fog
  539.                 if checked[i][j] == 0
  540.                   checked[i][j] = 1
  541.                   # only fill if not already revealed
  542.                   if @fow_tilemap.map_data[i,j,2] != 0
  543.                     # calculate adjacent fog
  544.                     adj = ''
  545.                     if (i == 0)
  546.                       adj << '147'
  547.                     else
  548.                       if (j == 0) then adj << '1'
  549.                       else
  550.                         if ($game_map.fow_grid[i-1][j-1] == FOW) then adj << '1' end
  551.                       end
  552.                       if ($game_map.fow_grid[i-1][j] == FOW) then adj << '4' end
  553.                       if (j == $game_map.height-1) then adj << '7'
  554.                       else
  555.                         if ($game_map.fow_grid[i-1][j+1] == FOW) then adj << '7' end
  556.                       end
  557.                     end
  558.                     if (i == $game_map.width-1)
  559.                       adj << '369'
  560.                     else
  561.                       if (j == 0) then adj << '3'
  562.                       else
  563.                         if ($game_map.fow_grid[i+1][j-1] == FOW) then adj << '3' end
  564.                       end
  565.                       if ($game_map.fow_grid[i+1][j] == FOW) then adj << '6' end
  566.                       if (j == $game_map.height-1) then adj << '9'
  567.                       else
  568.                         if ($game_map.fow_grid[i+1][j+1] == FOW) then adj << '9' end
  569.                       end
  570.                     end
  571.                     if (j == 0)
  572.                       adj << '2'
  573.                     else
  574.                       if ($game_map.fow_grid[i][j-1] == FOW) then adj << '2' end
  575.                     end
  576.                     if (j == $game_map.height-1)
  577.                       adj << '8'
  578.                     else
  579.                       if ($game_map.fow_grid[i][j+1] == FOW) then adj << '8' end
  580.                     end
  581.                     # if no adjacent fog, set it as 0
  582.                     if (adj == '') then adj = '0' end
  583.                     # convert to an array, sort, and then back to a string
  584.                     adj = adj.split(//).sort.join
  585.                     @fow_tilemap.map_data[i,j,2] = eval '@fow_autotiles[adj.to_i]'
  586.                   end
  587.                 end
  588.               end
  589.             end
  590.           end
  591.           if not others
  592.             # no adjacent fog found, so flag tile to prevent processing again
  593.             $game_map.fow_grid[x][y] |= SKIP
  594.           end
  595.         end
  596.       end
  597.     end   
  598.   end

  599.   alias old_dispose dispose
  600.   def dispose
  601.     if $game_map.fow_on == true
  602.     end
  603.     old_dispose
  604.   end

  605.   alias old_update update
  606.   def update
  607.     if $game_map.fow_on == true
  608.       @fow_tilemap.ox = $game_map.display_x / 4   
  609.       @fow_tilemap.oy = $game_map.display_y / 4   
  610.       @fow_tilemap.update   
  611.     end
  612.     old_update
  613.   end
  614. end

  615. #-------------------------------------------------------------------------------

  616. class Game_Player

  617.   def initialize
  618.     super
  619.     @last_x = @x
  620.     @last_y = @y
  621.   end  

  622.   def update_jump
  623.     super
  624.     # only update when about to land, not revealing anything jumped over
  625.     if $game_map.fow_on and @jump_count == 0
  626.       $game_map.update_fow_grid
  627.       $scene.spriteset.update_fow_tilemap
  628.     end
  629.   end
  630.   
  631.   def update_move
  632.     super
  633.     if $game_map.fow_on and (@x != @last_x or @y != @last_y)
  634.         unless jumping?
  635.           $game_map.update_fow_grid         
  636.           $scene.spriteset.update_fow_tilemap
  637.         end
  638.     end  
  639.     @last_x = @x
  640.     @last_y = @y     
  641.   end

  642. end

  643. #-------------------------------------------------------------------------------

  644. class Scene_Map
  645.   attr_reader :spriteset
  646. end

  647. =begin
  648.         Autotile in column 2:
  649.    
  650. row\col| 1  2  3  4  5  6  7  8
  651.      ---------------------------
  652.      1 | 48 49 50 51 52 53 54 55
  653.      2 | 56 57 58 59 60 61 62 63
  654.      3 | 64 65 66 67 68 69 70 71
  655.      4 | 72 73 74 75 76 77 78 79
  656.      5 | 80 81 82 83 84 85 86 87
  657.      6 | 88 89 90 91 92 93 94 95
  658.      
  659.      The function to return the index of a single tile within an autotile
  660.      (given by at_index) is (at_index-1)*48 + col-1 + (row-1)*8
  661.      (where row, col, and at_index are again NOT zero-indexed)
  662. =end

  663. =begin
  664.     The following array lists systematic keys which are based on adjacent
  665.     walls (where 'W' is the wall itself):
  666.     1 2 3
  667.     4 W 6
  668.     7 8 9
  669.     e.g. 268 is the key that will be used to refer to the autotile
  670.     which has adjacent walls north, east, and south.  For the Castle Prison
  671.     tileset (autotile #1), this is 67.
  672.    
  673.     (It's a bit unwieldy, but it works.)
  674. =end

  675.   Autotile_Keys = [
  676.   12346789,
  677.   2346789,
  678.   1246789,
  679.   246789,
  680.   1234678,
  681.   234678,
  682.   124678,
  683.   24678,
  684.   
  685.   1234689,
  686.   234689,
  687.   124689,
  688.   24689,
  689.   123468,
  690.   23468,
  691.   12468,
  692.   2468,
  693.   
  694.   23689,
  695.   2689,
  696.   2368,
  697.   268,
  698.   46789,
  699.   4678,
  700.   4689,
  701.   468,
  702.   
  703.   12478,
  704.   1248,
  705.   2478,
  706.   248,
  707.   12346,
  708.   2346,
  709.   1246,
  710.   246,
  711.   
  712.   28,
  713.   46,
  714.   689,
  715.   68,
  716.   478,
  717.   48,
  718.   124,
  719.   24,
  720.   
  721.   236,
  722.   26,
  723.   8,
  724.   6,
  725.   2,
  726.   4,
  727.   0 ]
  728.    
  729.   # many autotiles handle multiple situations
  730.   # this hash keeps track of which keys are identical
  731.   # to ones already defined above
  732.   Duplicate_Keys = {
  733.   123689 => 23689,
  734.   236789 => 23689,
  735.   1236789 => 23689,
  736.   34689 => 4689,
  737.   14689 => 4689,
  738.   134689 => 4689,
  739.   14678 => 4678,
  740.   34678 => 4678,
  741.   134678 => 4678,
  742.   146789 => 46789,
  743.   346789 => 46789,
  744.   1346789 => 46789,
  745.   23467 => 2346,
  746.   23469 => 2346,
  747.   234679 => 2346,
  748.   123467 => 12346,
  749.   123469 => 12346,
  750.   1234679 => 12346,
  751.   12467 => 1246,
  752.   12469 => 1246,
  753.   124679 => 1246,
  754.   124789 => 12478,
  755.   123478 => 12478,
  756.   1234789 => 12478,
  757.   146 => 46,
  758.   346 => 46,
  759.   467 => 46,
  760.   469 => 46,
  761.   1346 => 46,
  762.   1467 => 46,
  763.   1469 => 46,
  764.   3467 => 46,
  765.   3469 => 46,
  766.   4679 => 46,
  767.   13467 => 46,
  768.   13469 => 46,
  769.   14679 => 46,
  770.   34679 => 46,
  771.   134679 => 46,
  772.   128 => 28,
  773.   238 => 28,
  774.   278 => 28,
  775.   289 => 28,
  776.   1238 => 28,
  777.   1278 => 28,
  778.   1289 => 28,
  779.   2378 => 28,
  780.   2389 => 28,
  781.   2789 => 28,
  782.   12378 => 28,
  783.   12389 => 28,
  784.   12789 => 28,
  785.   23789 => 28,
  786.   123789 => 28,
  787.   
  788.   1247 => 124,
  789.   2369 => 236,
  790.   147 => 4,
  791.   247 => 24,
  792.   14 => 4,
  793.   47 => 4,
  794.   1478 => 478,
  795.   3478 => 478,
  796.   4789 => 478,
  797.   134789 => 478,
  798.   14789 => 478,  
  799.   13478 => 478,
  800.   34789 => 478,
  801.   1234 => 124,
  802.   1247 => 124,
  803.   1249 => 124,
  804.   12347 => 124,
  805.   12349 => 124,
  806.   12479 => 124,
  807.   123479 => 124,
  808.   1236 => 236,
  809.   2367 => 236,
  810.   2369 => 236,
  811.   12367 => 236,
  812.   12369 => 236,
  813.   23679 => 236,
  814.   123679 => 236,
  815.   12368 => 2368,
  816.   23678 => 2368,  
  817.   123678 => 2368,
  818.   12348 => 1248,
  819.   12489 => 1248,
  820.   123489 => 1248,
  821.   1689 => 689,
  822.   3689 => 689,
  823.   6789 => 689,
  824.   13689 => 689,
  825.   16789 => 689,
  826.   36789 => 689,
  827.   136789 => 689,
  828.   12689 => 2689,
  829.   26789 => 2689,  
  830.   126789 => 2689,
  831.   23478 => 2478,
  832.   24789 => 2478,
  833.   234789 => 2478,

  834.   12 => 2,
  835.   23 => 2,
  836.   27 => 2,
  837.   29 => 2,  
  838.   123 => 2,
  839.   127 => 2,
  840.   129 => 2,
  841.   237 => 2,
  842.   239 => 2,
  843.   279 => 2,
  844.   1237 => 2,
  845.   1239 => 2,  
  846.   1279 => 2,
  847.   2379 => 2,
  848.   12379 => 2,

  849.   
  850.   14 => 4,
  851.   47 => 4,
  852.   34 => 4,
  853.   49 => 4,  
  854.   147 => 4,
  855.   134 => 4,
  856.   347 => 4,
  857.   349 => 4,  
  858.   149 => 4,
  859.   479 => 4,
  860.   1347 => 4,
  861.   1479 => 4,   
  862.   1349 => 4,
  863.   3479 => 4,
  864.   13479 => 4,   

  865.   16 => 6,
  866.   36 => 6,
  867.   67 => 6,
  868.   69 => 6,
  869.   136 => 6,
  870.   167 => 6,
  871.   169 => 6,
  872.   367 => 6,
  873.   369 => 6,
  874.   679 => 6,
  875.   1369 => 6,  
  876.   3679 => 6,  
  877.   1367 => 6,
  878.   1679 => 6,
  879.   13679 => 6,  
  880.   
  881.   78 => 8,
  882.   89 => 8,
  883.   18 => 8,
  884.   38 => 8,
  885.   138 => 8,
  886.   789 => 8,
  887.   178 => 8,
  888.   189 => 8,
  889.   378 => 8,
  890.   389 => 8,
  891.   1789 => 8,  
  892.   3789 => 8,
  893.   1378 => 8,
  894.   1389 => 8,
  895.   13789 => 8,
  896.   
  897.   1468 => 468,
  898.   3468 => 468,
  899.   13468 => 468,
  900.   
  901.   2467 => 246,
  902.   2469 => 246,
  903.   24679 => 246,
  904.   
  905.   2348 => 248,
  906.   2489 => 248,
  907.   23489 => 248,
  908.   
  909.   1268 => 268,
  910.   2678 => 268,
  911.   12678 => 268,
  912.   
  913.   148 => 48,
  914.   348 => 48,
  915.   489 => 48,
  916.   1348 => 48,
  917.   1489 => 48,
  918.   3489 => 48,
  919.   13489 => 48,
  920.   
  921.   168 => 68,
  922.   368 => 68,
  923.   678 => 68,
  924.   1368 => 68,
  925.   1678 => 68,
  926.   3678 => 68,
  927.   13678 => 68,
  928.   
  929.   234 => 24,
  930.   247 => 24,
  931.   249 => 24,
  932.   2347 => 24,
  933.   2349 => 24,
  934.   2479 => 24,
  935.   23479 => 24,
  936.   
  937.   126 => 26,
  938.   267 => 26,
  939.   269 => 26,
  940.   1267 => 26,
  941.   1269 => 26,
  942.   2679 => 26,
  943.   12679 => 26,  
  944.   }
复制代码
[LINE]1,#dddddd[/LINE]此贴于 2008-7-22 7:29:01 被版主darkten提醒,请楼主看到后对本贴做出回应。 [LINE]1,#dddddd[/LINE]版务信息:版主帮忙结贴~
作者: yuscvscv    时间: 2008-7-17 10:12
提示: 作者被禁止或删除 内容自动屏蔽
作者: 轮回者    时间: 2008-7-17 18:30
这似乎是国外的脚本吧,问下原始地址在哪?
作者: dongdongok    时间: 2008-7-17 20:35
  我没原始地址,这个也是在这里找到的,那时是为了要个全地图都是黑的,只有走到的地方显示出地图,然后就有人发出这个脚本拉,可不知道怎么用啊?
作者: 荆芥    时间: 2008-7-17 20:41
这不是有注释么~
不过是全英文。。。。。。。
=begin
  ============
   Fog of War - version 1.0 (2005-10-26)
  ============
   by Wachunga
   
  0.8 - original release
  0.85
    - added colour parameter to map names
    - fixed bug where map grids overlapped
  0.9
    - switched over to a tilemap (from a sprite)
    - now more compatible with minimap scripts (but they'll have to take
    extra tilemap into account)
  1.0
    - switched over to an autotile instead of using a custom tileset
      * edges looks nicer, but gradual fading had to be removed
      * colour parameter no longer possible (set by autotile)
    - move event (including jumping and speed changes) bug fixed
    - teleportation bug fixed
    - some optimization
    - made compatible with Cogwheel's Pixel Movement script
    (see http://www.rmxp.net/forums/index.php?showtopic=24716 for details)

   
  Note:
  There's no need to add the autotile via the database. Just place the file in
  the autotile folder, import it, and change the FOW_AT_NAME constant to
  the appropriate filename. To change the colour of the fog of war, create a
  new autotile.
  
  To indicate a map is to have fog of war (i.e. its tiles are dark until
  the player gets within visual range), include <FoW> in its name.  You may
  also optionally specify a range between 0 and 3. This may also be
  included in the map name, as in this example:
  "your-map-name <FoW><2>" (range is 2)
  
  The ranges work as follows:
  
  range = 0 reveals just the square on which the player stands
  
  range = 1 is the same as range 0 plus four adjacent tiles
  i.e.   @
        @P@
         @
  
  range = 2 is the same as range 1 plus eight additional tiles
   i.e.  @
        @@@
       @@P@@
        @@@
         @
         
  range = 3 (default) is the same as range 2 plus twelve additional tiles
   i.e.  @
        @@@
       @@@@@
      @@@P@@@
       @@@@@
        @@@      
         @
=end
[LINE]1,#dddddd[/LINE]系统信息:本贴由本区版主认可为正确答案,66RPG感谢您的热情解答~
作者: dongdongok    时间: 2008-7-19 21:48
这注解也看不懂,不知道怎么弄的. [LINE]1,#dddddd[/LINE]版主对此帖的评论:『恶补英文,或者使用翻译器就看得懂了...』,积分『-0』。这些被扣积分的一半会用于对本帖正确答案的悬赏。




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