Project1

标题: [rpgmakervx.net]影子效果~~请人翻译讲解 [打印本页]

作者: king    时间: 2008-12-1 18:31
标题: [rpgmakervx.net]影子效果~~请人翻译讲解
rpgmakervx.net
在上面看中了几个脚本,请人翻译讲解一下~~~{/wx}

Sprite Shadows/Sprite Sun VX
http://www.rpgmakervx.net/index.php?showtopic=5623

影子效果



How to Use
Place these scripts above main, with the Spriteset Map script above the other two. Instructions are included inside.

The 'anglemin' and the 'anglemax' values are set in degrees, in a counterclockwise manner. For example, if i want to make a shadow source that casts shadows only in a right angle, id add to the event

anglemin 0
anglemax 90

Here is a picture for reference

Also, for Sprite Shadow, when adding optional values for 'distancemax' and 'self_opacity' you have to specify 'anglemin' and 'anglemax' before them, otherwise it won't work. Here is how it should be:

anglemin 'value'
anglemax 'value'
distancemax 'value'
self_opacity 'value'

Scripts

  1. #==============================================================================
  2. # ** Spriteset_Map
  3. #------------------------------------------------------------------------------
  4. # This class edits problems cause by Sprite_Shadow and Sprite_Sun
  5. #==============================================================================

  6. class Spriteset_Map
  7. #--------------------------------------------------------------------------
  8. # * Alias Listings
  9. #--------------------------------------------------------------------------
  10. alias create_viewports_original create_viewports
  11. alias dispose_viewports_original dispose_viewports
  12. alias update_viewports_original update_viewports
  13. alias update_tilemap_original update_tilemap
  14. alias dispose_tilemap_original dispose_tilemap
  15. alias create_tilemap_original create_tilemap
  16. #--------------------------------------------------------------------------
  17. # * Create Viewport
  18. #--------------------------------------------------------------------------
  19. def create_viewports
  20. create_viewports_original
  21. @viewport0 = Viewport.new(0, 0, 544, 416)
  22. @viewport0.z = 1
  23. @viewport1.z = 20
  24. end
  25. #--------------------------------------------------------------------------
  26. # * Create Tilemap
  27. #--------------------------------------------------------------------------
  28. def create_tilemap
  29. create_tilemap_original
  30. @tilemap0 = Tilemap.new(@viewport0)
  31. @tilemap0.bitmaps[0] = Cache.system("TileA1")
  32. @tilemap0.bitmaps[1] = Cache.system("TileA2")
  33. @tilemap0.bitmaps[4] = Cache.system("TileA5")
  34. @tilemap = Tilemap.new(@viewport1)
  35. @tilemap.bitmaps[2] = Cache.system("TileA3")
  36. @tilemap.bitmaps[3] = Cache.system("TileA4")
  37. @tilemap.bitmaps[5] = Cache.system("TileB")
  38. @tilemap.bitmaps[6] = Cache.system("TileC")
  39. @tilemap.bitmaps[7] = Cache.system("TileD")
  40. @tilemap.bitmaps[8] = Cache.system("TileE")
  41. @tilemaps = [@tilemap, @tilemap0]
  42. @tilemaps.each {|x| x.map_data = $game_map.data}
  43. @tilemaps.each {|x| x.passages = $game_map.passages}
  44. end
  45. #--------------------------------------------------------------------------
  46. # * Dispose of Tilemap
  47. #--------------------------------------------------------------------------
  48. def dispose_tilemap
  49. dispose_tilemap_original
  50. @tilemap0.dispose
  51. end
  52. #--------------------------------------------------------------------------
  53. # * Dispose of Viewport
  54. #--------------------------------------------------------------------------
  55. def dispose_viewports
  56. @viewport0.dispose
  57. dispose_viewports_original
  58. end
  59. #--------------------------------------------------------------------------
  60. # * Update Tilemap
  61. #--------------------------------------------------------------------------
  62. def update_tilemap
  63. update_tilemap_original
  64. @tilemap0.ox = $game_map.display_x / 8
  65. @tilemap0.oy = $game_map.display_y / 8
  66. @tilemap0.update
  67. end
  68. #--------------------------------------------------------------------------
  69. # * Update Viewport
  70. #--------------------------------------------------------------------------
  71. def update_viewports
  72. update_viewports_original
  73. @viewport0.tone = $game_map.screen.tone
  74. @viewport0.ox = $game_map.screen.shake
  75. @viewport0.update
  76. end
  77. end
复制代码

  1. #==============================================================================
  2. # ** Sprite Sun
  3. #------------------------------------------------------------------------------
  4. #    Based on Sprite Shadow
  5. #    modified by Rataime
  6. #    New Edits by DerVVulfman
  7. #    Modified for VX by Syvkal
  8. #    Fixes by Painhurt
  9. #    October 14, 2008
  10. #------------------------------------------------------------------------------
  11. #
  12. # Introduction:
  13. #
  14. #  This system allows you and all 'prepared' events to generate shadows while
  15. #  on the field map. The player can move around while a programmed 'sun' will
  16. #  display a shadow.   Likewise,  events with a special comment  within their
  17. #  event list can also generate shadows.
  18. #
  19. #------------------------------------------------------------------------------
  20. #
  21. # Instructions:
  22. #
  23. #  -- The Sun
  24. #     To create a sun effect, you'll need to create a map event that's to be
  25. #     used 'as' the sun itself.   Under most circumstances,  this will be an
  26. #     event without a characterset graphic. You don't want to 'SEE' the sun,
  27. #     do you?
  28. #
  29. #     To make one of these events a 'sun,  you'll need to insert a couple of
  30. #     things into that event's  "List of Event Commands".   These things are
  31. #     nothing more than comments.  
  32. #
  33. #     The first comment  to add is "begin Sun" (without quotes).  It informs
  34. #     the system that this map  has a sun effect in use.   The remaining two
  35. #     values  are optional  and have  default values  in  the  configuration
  36. #     section  (only just added  into the script).   They too  are added  as
  37. #     comments.
  38. #
  39. #     self_angle  'number'  --- How much of an angle each shadow will have.
  40. #     self_opacity 'number' --- How dark the shadow will be.
  41. #
  42. #     After that, your characters can now move about and generate shadows.
  43. #
  44. #  -- Other Events
  45. #     Events do not know that they can generate shadows.   To let them gene-
  46. #     rate a shadow,  all you need to do is add a special comment into their
  47. #     "List of Event Commands".   This comment needed  is merely  the phrase
  48. #     'begin Shadow' (again, without quotes).
  49. #
  50. #
  51. #------------------------------------------------------------------------------
  52. #
  53. # Revisions to note:
  54. #
  55. #  1) Added formatted headers and comments throughout the script.
  56. #  2) Encapsulated a comment/parameter code in an XPML module.
  57. #  3) Set the sun shadow array into an instance value to lower resource costs.
  58. #  4) Compatability with Near Fantastica's Squad Movement systems.
  59. #  5) Compatability with Ccoa's Caterpillar system.
  60. #  6) Compatability with Trickster's Caterpillar system.
  61. #  7) Added default shadow settings into the configuration section.
  62. #
  63. #==============================================================================



  64.    #========================================================================
  65.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  66.    #========================================================================
  67.     # Caterpillar Systems
  68.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  69.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  70.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  71.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  72.    
  73.     # Sun Specific Systems
  74.     SUN_WARN                    = true    # Checks for older sun systems
  75.     SUN_ANGLE                   = 45      # Angle for sun-generated shadow
  76.     SUN_OPACITY                 = 128     # Darkness setting for sun shadow

  77.    
  78.    #========================================================================
  79.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  80.    #========================================================================
  81.   
  82.   

  83. #==============================================================================
  84. # ** Game_Temp
  85. #------------------------------------------------------------------------------
  86. #  This class handles temporary data that is not included with save data.
  87. #  Refer to "$game_temp" for the instance of this class.
  88. #==============================================================================

  89. class Game_Temp
  90.   #--------------------------------------------------------------------------
  91.   # * Public Instance Variables
  92.   #--------------------------------------------------------------------------
  93.   attr_accessor :sun_spriteset            # holds spritesets for 'sun' shadows
  94. end



  95. #==============================================================================
  96. # ** Game_Party
  97. #------------------------------------------------------------------------------
  98. #  This class handles the party. It includes information on amount of gold
  99. #  and items. Refer to "$game_party" for the instance of this class.
  100. #==============================================================================

  101. class Game_Party
  102.   #--------------------------------------------------------------------------
  103.   # * Public Instance Variables
  104.   #--------------------------------------------------------------------------
  105.   attr_reader :characters
  106. end



  107. #==============================================================================
  108. # ** Sprite_Sun
  109. #------------------------------------------------------------------------------
  110. #  This sprite is used to position character shadows relative to map position.
  111. #  It observes the Game_Character class and automatically changes sprite
  112. #  conditions.
  113. #==============================================================================

  114. class Sprite_Sun < Sprite_Base
  115.   #--------------------------------------------------------------------------
  116.   # * Public Instance Variables
  117.   #--------------------------------------------------------------------------
  118.   attr_accessor :character         
  119.   #--------------------------------------------------------------------------
  120.   # * Object Initialization
  121.   #     viewport  : viewport
  122.   #     character : character (Game_Character)
  123.   #     id        : id
  124.   #--------------------------------------------------------------------------
  125.   def initialize(viewport, character = nil, id=0)
  126.     super(viewport)
  127.     @character = character
  128.     params=$game_temp.sun_spriteset.sun[id]
  129.     self_angle    = SUN_ANGLE
  130.     self_opacity  = SUN_OPACITY
  131.     self_angle    = params[0]   if params.size > 0
  132.     self_opacity  = params[1]   if params.size > 1
  133.     @self_angle   = self_angle
  134.     @self_opacity = self_opacity
  135.     update
  136.   end
  137.   #--------------------------------------------------------------------------
  138.   # * Frame Update
  139.   #--------------------------------------------------------------------------  
  140.   def update
  141.     super
  142.     # If tile ID, file name, or hue are different from current ones
  143.     if @tile_id != @character.tile_id or
  144.        @character_name != @character.character_name or
  145.        @character_index != @character.character_index
  146.       @tile_id = @character.tile_id
  147.       @character_name = @character.character_name
  148.       @character_index = @character.character_index
  149.       if @tile_id > 0
  150.         sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
  151.         sy = @tile_id % 256 / 8 % 16 * 32;
  152.         set_number = @tile_id / 256
  153.         self.bitmap = Cache.system("TileB") if set_number == 0
  154.         self.bitmap = Cache.system("TileC") if set_number == 1
  155.         self.bitmap = Cache.system("TileD") if set_number == 2
  156.         self.bitmap = Cache.system("TileE") if set_number == 3
  157.         self.src_rect.set(sx, sy, 32, 32)
  158.         self.ox = 16
  159.         self.oy = 32
  160.       else
  161.         self.bitmap = Cache.character(@character_name)
  162.         sign = @character_name[/^[\!\$]./]
  163.         if sign != nil and sign.include?('$')
  164.           @cw = bitmap.width / 3
  165.           @ch = bitmap.height / 4
  166.         else
  167.           @cw = bitmap.width / 12
  168.           @ch = bitmap.height / 8
  169.         end
  170.         self.ox = @cw / 2
  171.         self.oy = @ch
  172.       end
  173.     end
  174.     # Set visible situation
  175.     self.visible = (not @character.transparent)
  176.     # If graphic is character
  177.     if @tile_id == 0
  178.       index = @character.character_index
  179.       pattern = @character.pattern < 3 ? @character.pattern : 1
  180.       # Set rectangular transfer
  181.       sx = (index % 4 * 3 + pattern) * @cw
  182.       @direct = @character.direction
  183.       if self.angle > 90 or angle < -90
  184.         sy = ( 4 - 2) / 2 * @ch                   if @direct == 6
  185.         sy = ( 6 - 2) / 2 * @ch                   if @direct == 4
  186.         sy = (@character.direction - 2) / 2 * @ch if @direct != 4 and @direct != 6
  187.       else
  188.         sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  189.       end
  190.       self.src_rect.set(sx, sy, @cw, @ch)
  191.     end
  192.     # Set sprite coordinates
  193.     self.x = @character.screen_x
  194.     self.y = @character.screen_y-5
  195.     self.z = @character.screen_z- 1
  196.     # Set opacity level, blend method, and bush depth
  197.     self.opacity = @self_opacity
  198.     self.blend_type = @character.blend_type
  199.     self.bush_depth = @character.bush_depth
  200.     # Animation
  201.     if @character.animation_id != 0
  202.       animation = $data_animations[@character.animation_id]
  203.       animation(animation, true)
  204.       @character.animation_id = 0
  205.     end
  206.     self.angle = @self_angle.to_i - 90
  207.     self.color = Color.new(0, 0, 0)
  208.   end
  209. end



  210. #==============================================================================
  211. # ** Sprite_Character
  212. #------------------------------------------------------------------------------
  213. #  This sprite is used to display the character.It observes the Game_Character
  214. #  class and automatically changes sprite conditions.
  215. #==============================================================================

  216. class Sprite_Character < Sprite_Base
  217.   #--------------------------------------------------------------------------
  218.   # * Alias Listings
  219.   #--------------------------------------------------------------------------  
  220.   alias sun_initialize initialize
  221.   alias sun_update update
  222.   #--------------------------------------------------------------------------
  223.   # * Object Initialization
  224.   #     viewport  : viewport
  225.   #     character : character (Game_Character)
  226.   #--------------------------------------------------------------------------
  227.   def initialize(viewport, character = nil)
  228.     @viewport0 = Viewport.new(0, 0, 544, 416)
  229.     @viewport0.z = 1
  230.     @character = character
  231.     super(viewport)
  232.     @sunlist=[]
  233.     if character.is_a?(Game_Event) and $game_temp.sun_spriteset.sun != []
  234.       params = XPML.XPML_read("Shadow", @character.id, 2)
  235.       if params != nil
  236.         for i in 0...$game_temp.sun_spriteset.sun.size
  237.           @sunlist.push(Sprite_Sun.new(@viewport0, @character, i))
  238.         end
  239.       end
  240.     end
  241.     if character.is_a?(Game_Player) and $game_temp.sun_spriteset.sun != []
  242.       for i in 0...$game_temp.sun_spriteset.sun.size
  243.         @sunlist.push(Sprite_Sun.new(@viewport0, $game_player, i))
  244.       end
  245.       #===================================================
  246.       # * Compatibility with Caterpillar Functions
  247.       #===================================================
  248.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  249.         for member in $game_party.characters
  250.           for i in 0...$game_temp.sun_spriteset.sun.size
  251.             @sunlist.push(Sprite_Sun.new(@viewport0, member, i))
  252.           end
  253.         end
  254.       end
  255.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  256.         for member in $game_allies.values
  257.           for i in 0...$game_temp.sun_spriteset.sun.size
  258.             @sunlist.push(Sprite_Sun.new(@viewport0, member, i))
  259.           end
  260.         end
  261.       end
  262.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  263.         for member in $game_train.actors
  264.           for i in 0...$game_temp.sun_spriteset.sun.size
  265.             @sunlist.push(Sprite_Sun.new(@viewport0, member, i))
  266.           end
  267.         end
  268.       end
  269.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  270.         for member in $game_party.followers
  271.           for i in 0...$game_temp.sun_spriteset.sun.size
  272.             @sunlist.push(Sprite_Sun.new(@viewport0, member, i))
  273.           end
  274.         end
  275.       end
  276.       #===================================================
  277.       # ** End of the compatibility
  278.       #===================================================      
  279.     end
  280.     # Perform the original call
  281.     sun_initialize(viewport, @character)
  282.   end
  283.   #--------------------------------------------------------------------------
  284.   # * Frame Update
  285.   #--------------------------------------------------------------------------  
  286.   def update
  287.     sun_update
  288.     if @sunlist != []
  289.       for i in [email protected]
  290.         @sunlist[i].update
  291.       end
  292.     end
  293.   end  
  294. end



  295. #==============================================================================
  296. # ** Game_Event
  297. #------------------------------------------------------------------------------
  298. #  This class deals with events. It handles functions including event page
  299. #  switching via condition determinants, and running parallel process events.
  300. #  It's used within the Game_Map class.
  301. #==============================================================================

  302. class Game_Event < Game_Character
  303.   #--------------------------------------------------------------------------
  304.   # * Public Instance Variables
  305.   #--------------------------------------------------------------------------
  306.   attr_accessor :id
  307. end



  308. #==============================================================================
  309. # ** Spriteset_Map
  310. #------------------------------------------------------------------------------
  311. #  This class brings together map screen sprites, tilemaps, etc.
  312. #  It's used within the Scene_Map class.
  313. #==============================================================================

  314. class Spriteset_Map
  315.   #--------------------------------------------------------------------------
  316.   # * Public Instance Variables
  317.   #--------------------------------------------------------------------------  
  318.   attr_accessor :sun
  319.   #--------------------------------------------------------------------------
  320.   # * Alias Listings
  321.   #--------------------------------------------------------------------------  
  322.   alias sun_initialize initialize
  323.   #--------------------------------------------------------------------------
  324.   # * Object Initialization
  325.   #--------------------------------------------------------------------------   
  326.   def initialize
  327.     @sun = []
  328.     $game_temp.sun_spriteset = self
  329.     warn = false
  330.     for k in $game_map.events.keys.sort
  331.       if ($game_map.events[k].list != nil and
  332.           $game_map.events[k].list[0].code == 108 and
  333.           ($game_map.events[k].list[0].parameters == ["sun"] or
  334.           $game_map.events[k].list[0].parameters == ["o"]))
  335.         warn = true
  336.       end
  337.       params = XPML.XPML_read("Sun", k, 2)
  338.       $game_temp.sun_spriteset.sun.push(params) if params != nil
  339.     end
  340.     if warn == true and SUN_WARN
  341.       p "Warning : At least one event on this map uses an obsolete way to add a sun effect"
  342.     end
  343.     # Perform the original call
  344.     sun_initialize
  345.   end  
  346. end


  347. #==============================================================================
  348. # ** module XPML
  349. #------------------------------------------------------------------------------
  350. #  This module handles the reading and passing of 'comment' parameters
  351. #
  352. #  The main XPML method is used to check and read event comments.
  353. #  * It returns 'nil' if the markup 'check' text isn't even present.
  354. #  * It returns [] if no parameters are passed
  355. #  * It returns a parameter list with "int" converted as int.
  356. #       eg :
  357. #       begin first
  358. #       begin second
  359. #       param1 1
  360. #       param2 two
  361. #       begin third
  362. #       anything 3
  363. #
  364. #   p XPML_read("first", event_id) -> []
  365. #   p XPML_read("second", event_id) -> [1,"two"]
  366. #   p XPML_read("third", event_id) -> [3]
  367. #   p XPML_read("forth", event_id) -> nil
  368. #===================================================

  369. module XPML
  370.   module_function
  371.   #--------------------------------------------------------------------------
  372.   # * XPML_read
  373.   #     markup           : text in event comment to check
  374.   #     event_id         : event ID
  375.   #     max_param_number : maximum number of parameter/comments to load
  376.   #--------------------------------------------------------------------------  
  377.   def XPML_read(markup, event_id, max_param_number = 0)
  378.     parameter_list = nil
  379.     event = $game_map.events[event_id]
  380.     return if event.list == nil
  381.       for i in 0...event.list.size
  382.         if event.list[i].code == 108 and
  383.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  384.           parameter_list = [] if parameter_list == nil
  385.           for j in i + 1...event.list.size
  386.             if event.list[j].code == 108
  387.               parts = event.list[j].parameters[0].split
  388.               if parts.size != 1 and parts[0].downcase != "begin"
  389.                 if parts[1].to_i != 0 or parts[1] == "0"
  390.                   parameter_list.push(parts[1].to_i)
  391.                 else
  392.                   parameter_list.push(parts[1])
  393.                 end
  394.               else
  395.                 return parameter_list
  396.               end
  397.             else
  398.               return parameter_list
  399.             end
  400.             if max_param_number != 0 and j == i + max_param_number
  401.               return parameter_list
  402.             end
  403.           end
  404.         end
  405.       end
  406.     return parameter_list
  407.   end
  408. end
复制代码


[LINE]1,#dddddd[/LINE]版务信息:本贴由楼主自主结贴~
作者: king    时间: 2008-12-1 18:31
  1. #==============================================================================
  2. # ** Sprite Shadow (Sprite_Ombre )
  3. #------------------------------------------------------------------------------
  4. #    Based on Genzai Kawakami's shadows
  5. #    dynamisme & features by Rataime
  6. #    extra features Boushy
  7. #    New Edits by DerVVulfman
  8. #    Modified for VX by Syvkal
  9. #    Fixes by Painhurt
  10. #    October 14, 2008
  11. #
  12. #------------------------------------------------------------------------------
  13. #
  14. # Introduction:
  15. #
  16. #  This system allows you and all 'prepared' events to generate shadows while
  17. #  on the field map.   The player can move around  a 'light source' event and
  18. #  display a shadow.   Likewise,  events with a special comment  within their
  19. #  event list can also generate shadows.
  20. #
  21. #------------------------------------------------------------------------------
  22. #
  23. # Instructions:
  24. #
  25. #  -- The Light Source
  26. #     To create a light source, you need to create a map event that is to be
  27. #     used 'as' the light source.   Most of the time,  these could be events
  28. #     that sport 'torch' or 'lantern' charactersets.  Just examples
  29. #
  30. #     To make one of these events a light source,  you need  to insert a few
  31. #     things into that event's  "List of Event Commands".   These things are
  32. #     nothing more than comments.  
  33. #
  34. #     The first comment to add is "begin Shadow Source" (without quotes). It
  35. #     informs the system  that this event is a light source.   The remaining
  36. #     three values are optional and have default values in the configuration
  37. #     section  (only just added  into the script).   They too  are added  as
  38. #     comments.
  39. #
  40. #     anglemin 'number'     --- Starting position of a lightsource's arc.
  41. #     anglemax 'number'     --- Ending position of a lightsource's arc.
  42. #     distancemax 'number'  --- How far away from the 'source' you can go
  43. #     self_opacity 'number' --- How dark the shadow will grow.
  44. #
  45. #     After that, your characters can now move about and generate shadows.
  46. #
  47. #  -- Other Events
  48. #     Events do not know that they can generate shadows.   To let them gene-
  49. #     rate a shadow,  all you need to do is add a special comment into their
  50. #     "List of Event Commands".   This comment needed  is merely  the phrase
  51. #     'begin Shadow' (again, without quotes).
  52. #
  53. #
  54. #  -- Blocking Shadows
  55. #     To prevent shadows  from passing through  solid objects such as doors,
  56. #     walls, cabinets or other forms of furniture,  you will want to apply a
  57. #     priority flag of '1' or higher on these items.  Normally, walls in the
  58. #     default database do not have a priority flag as they merely block  the
  59. #     player from passing through.
  60. #   
  61. #
  62. #------------------------------------------------------------------------------
  63. #
  64. # Revisions to note:
  65. #
  66. #  1) Added formatted headers and comments throughout the script.
  67. #  2) Encapsulated a comment/parameter code in an XPML module.
  68. #  3) Set the shadow array into an instance value to lower resource costs.
  69. #  4) Compatability with Near Fantastica's Squad Movement systems.
  70. #  5) Compatability with Ccoa's Caterpillar system.
  71. #  6) Compatability with Trickster's Caterpillar system.
  72. #  7) Added default shadow settings into the configuration section.
  73. #
  74. #==============================================================================



  75.    #========================================================================
  76.    #  **  C  O  N  F  I  G  U  R  A  T  I  O  N      S  Y  S  T  E  M  **  #
  77.    #========================================================================
  78.     # Caterpillar Systems
  79.     CATERPILLAR_COMPATIBLE      = true    # Toggle for Fukuyama's original  
  80.     SQUAD_MOVE_COMPATIBLE       = false   # Toggle for Near Fantastica's SBABS
  81.     CCOA_CATER_COMPATIBLE       = false   # Toggle for Ccoa's Caterpillar
  82.     TRICKSTER_CATER_COMPATIBLE  = false   # Toggle for Trickster's Caterpillar
  83.    
  84.     # Shadow Specific Systems
  85.     SHADOW_WARN                 = true    # Checks for older shadow system
  86.     SHADOW_MIN                  = 0       # Start setting of shadow arc *
  87.     SHADOW_MAX                  = 0       # Ending setting of shadow arc *
  88.     SHADOW_OPACITY              = 150     # Darkness level of shadow
  89.     SHADOW_DISTANCE             = 350     # Maximum range in pixels

  90.     # * SHADOW ARC:  Set in degrees,  this controls whether a light source
  91.     #                can 'force' shadows in certain directions.  Useful if
  92.     #                a light source is hanging on a wall so it cannot make
  93.     #                a shadow THROUGH a wall.
  94.     #
  95.     #                It may take some practice  to set  the desired angles
  96.     #                as it recognizes 90°  being the  top most part  of an
  97.     #                arc,  180° being the leftmost side and so on...  pro-
  98.     #                ceeding in a counter-clockwise motion.
  99.    
  100.    #========================================================================
  101.    #  ****   E N D   O F   C O N F I G U R A T I O N   S Y S T E M   ****  #
  102.    #========================================================================
  103.   
  104.   

  105. #==============================================================================
  106. # ** Game_Temp
  107. #------------------------------------------------------------------------------
  108. #  This class handles temporary data that is not included with save data.
  109. #  Refer to "$game_temp" for the instance of this class.
  110. #==============================================================================

  111. class Game_Temp
  112.   #--------------------------------------------------------------------------
  113.   # * Public Instance Variables
  114.   #--------------------------------------------------------------------------
  115.   attr_accessor :shadow_spriteset         # holds shadow spritesets
  116. end



  117. #==============================================================================
  118. # ** Game_Party
  119. #------------------------------------------------------------------------------
  120. #  This class handles the party. It includes information on amount of gold
  121. #  and items. Refer to "$game_party" for the instance of this class.
  122. #==============================================================================

  123. class Game_Party
  124.   #--------------------------------------------------------------------------
  125.   # * Public Instance Variables
  126.   #--------------------------------------------------------------------------
  127.   attr_reader :characters
  128. end



  129. #==============================================================================
  130. # ** Sprite_Shadow
  131. #------------------------------------------------------------------------------
  132. #  This sprite is used to display the character's shadow.  It observes the
  133. #  Game_Character class and automatically changes sprite conditions.
  134. #==============================================================================
  135. class Sprite_Shadow < Sprite_Base
  136.   #--------------------------------------------------------------------------
  137.   # * Public Instance Variables
  138.   #--------------------------------------------------------------------------
  139.   attr_accessor :character
  140.   #--------------------------------------------------------------------------
  141.   # * Object Initialization
  142.   #     viewport  : viewport
  143.   #     character : character (Game_Character)
  144.   #     id        : id
  145.   #--------------------------------------------------------------------------
  146.   def initialize(viewport, character = nil, id = 0)
  147.     super(viewport)
  148.     params  = $game_temp.shadow_spriteset.shadows[id]
  149.     @source = params[0]
  150.     # Default settings
  151.     @anglemin     = SHADOW_MIN
  152.     @anglemax     = SHADOW_MAX
  153.     @self_opacity = SHADOW_OPACITY
  154.     @distancemax  = SHADOW_DISTANCE
  155.     # Settings changed by parameters
  156.     @anglemin     = params[1]   if params.size > 1
  157.     @anglemax     = params[2]   if params.size > 2
  158.     @distancemax  = params[3]   if params.size > 3
  159.     @self_opacity = params[4]   if params.size > 4
  160.     @character = character
  161.     update
  162.   end
  163.   #--------------------------------------------------------------------------
  164.   # * Frame Update
  165.   #--------------------------------------------------------------------------
  166.   def update
  167.     # If shadow not in range of light source
  168.     if !in_range?(@character, @source, @distancemax)
  169.       self.opacity = 0
  170.       return
  171.     end
  172.     super
  173.     # If tile ID, file name, or hue are different from current ones
  174.     if @tile_id != @character.tile_id or
  175.        @character_name != @character.character_name or
  176.        @character_index != @character.character_index
  177.       @tile_id = @character.tile_id
  178.       @character_name = @character.character_name
  179.       @character_index = @character.character_index
  180.       if @tile_id > 0
  181.         sx = (@tile_id / 128 % 2 * 8 + @tile_id % 8) * 32;
  182.         sy = @tile_id % 256 / 8 % 16 * 32;
  183.         set_number = @tile_id / 256
  184.         self.bitmap = Cache.system("TileB") if set_number == 0
  185.         self.bitmap = Cache.system("TileC") if set_number == 1
  186.         self.bitmap = Cache.system("TileD") if set_number == 2
  187.         self.bitmap = Cache.system("TileE") if set_number == 3
  188.         self.src_rect.set(sx, sy, 32, 32)
  189.         self.ox = 16
  190.         self.oy = 32
  191.       else
  192.         self.bitmap = Cache.character(@character_name)
  193.         sign = @character_name[/^[\!\$]./]
  194.         if sign != nil and sign.include?('$')
  195.           @cw = bitmap.width / 3
  196.           @ch = bitmap.height / 4
  197.         else
  198.           @cw = bitmap.width / 12
  199.           @ch = bitmap.height / 8
  200.         end
  201.         self.ox = @cw / 2
  202.         self.oy = @ch
  203.       end
  204.     end
  205.     # Set visible situation
  206.     self.visible = (not @character.transparent)
  207.     # If graphic is character
  208.     if @tile_id == 0
  209.       index = @character.character_index
  210.       pattern = @character.pattern < 3 ? @character.pattern : 1
  211.       # Set rectangular transfer
  212.       sx = (index % 4 * 3 + pattern) * @cw
  213.       sy = (index / 4 * 4 + (@character.direction - 2) / 2) * @ch
  214.       if self.angle > 90 or angle < -90
  215.         sy = ( 4 - 2) / 2 * @ch   if @character.direction == 6
  216.         sy = ( 6 - 2) / 2 * @ch   if @character.direction == 4
  217.         sy = ( 8 - 2) / 2 * @ch   if @character.direction == 2
  218.         sy = ( 2 - 2) / 2 * @ch   if @character.direction == 8
  219.       end
  220.       self.src_rect.set(sx, sy, @cw, @ch)
  221.     end
  222.     # Set sprite coordinates   
  223.     self.x = @character.screen_x
  224.     self.y = @character.screen_y-5
  225.     self.z = 10#@character.screen_z-1
  226.     # Set blend method and bush depth
  227.     self.blend_type = @character.blend_type
  228.     self.bush_depth = @character.bush_depth
  229.     # Animation
  230.     if @character.animation_id != 0
  231.       animation = $data_animations[@character.animation_id]
  232.       animation(animation, true)
  233.       @character.animation_id = 0
  234.     end
  235.     @deltax       = @source.screen_x - self.x
  236.     @deltay       = @source.screen_y - self.y
  237.     self.color    = Color.new(0, 0, 0)
  238.     @distance     = ((@deltax ** 2) + (@deltay ** 2))
  239.     # Set opacity level based on light source distance
  240.     self.opacity  = @self_opacity * 13000 /
  241.                       ((@distance * 370 / @distancemax) + 6000)
  242.     self.angle    = 57.3 * Math.atan2(@deltax, @deltay )
  243.     @angle_trigo  = self.angle+90
  244.     if @angle_trigo < 0
  245.         @angle_trigo = 360 + @angle_trigo
  246.      end
  247.     if @anglemin != 0 or @anglemax != 0
  248.        if (@angle_trigo < @anglemin or @angle_trigo > @anglemax) and
  249.           @anglemin < @anglemax
  250.          self.opacity = 0
  251.          return
  252.        end
  253.        if (@angle_trigo < @anglemin and @angle_trigo > @anglemax) and
  254.           @anglemin > @anglemax
  255.          self.opacity=0
  256.          return
  257.        end   
  258.      end
  259.   end
  260.   #--------------------------------------------------------------------------
  261.   # * In Range?  (From Near's Anti Lag Script, edited)
  262.   #     element     : element
  263.   #     object      : object
  264.   #     range       : range in tiles
  265.   #--------------------------------------------------------------------------  
  266.   def in_range?(element, object, range)
  267.     x = (element.screen_x - object.screen_x) * (element.screen_x - object.screen_x)
  268.     y = (element.screen_y - object.screen_y) * (element.screen_y - object.screen_y)
  269.     r = x + y
  270.     if r <= (range * range)
  271.        return true
  272.     else
  273.       return false
  274.     end
  275.   end
  276. end



  277. #==============================================================================
  278. # ** Sprite_Character
  279. #------------------------------------------------------------------------------
  280. #  This sprite is used to display the character.It observes the Game_Character
  281. #  class and automatically changes sprite conditions.
  282. #==============================================================================

  283. class Sprite_Character < Sprite_Base
  284.   #--------------------------------------------------------------------------
  285.   # * Alias Listings
  286.   #--------------------------------------------------------------------------
  287.   alias shadow_initialize initialize
  288.   alias shadow_update update  
  289.   #--------------------------------------------------------------------------
  290.   # * Object Initialization
  291.   #     viewport  : viewport
  292.   #     character : character (Game_Character)
  293.   #--------------------------------------------------------------------------
  294.   def initialize(viewport, character = nil)
  295.     @viewport0 = Viewport.new(0, 0, 544, 416)
  296.     @viewport0.z = 1
  297.     @character = character
  298.     super(viewport)
  299.     @ombrelist = Array.new
  300.     @ombrelist = []
  301.     if character.is_a?(Game_Event) and $game_temp.shadow_spriteset.shadows != []
  302.       params = XPML.XPML_read("Shadow", @character.id, 5)
  303.       if params != nil
  304.         for i in 0...$game_temp.shadow_spriteset.shadows.size
  305.           @ombrelist.push(Sprite_Shadow.new(@viewport0, @character,i))
  306.         end
  307.       end
  308.     end
  309.     if character.is_a?(Game_Player) and $game_temp.shadow_spriteset.shadows != []
  310.       for i in 0...$game_temp.shadow_spriteset.shadows.size
  311.         @ombrelist.push(Sprite_Shadow.new(@viewport0, $game_player,i))
  312.       end
  313.       #===================================================
  314.       # * Compatibility with Caterpillar Functions
  315.       #===================================================
  316.       if CATERPILLAR_COMPATIBLE and $game_party.characters != nil
  317.         for member in $game_party.characters
  318.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  319.             @ombrelist.push(Sprite_Shadow.new(@viewport0, member, i))
  320.           end
  321.         end
  322.       end
  323.       if SQUAD_MOVE_COMPATIBLE and $game_allies.values != nil
  324.         for member in $game_allies.values
  325.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  326.             @ombrelist.push(Sprite_Shadow.new(@viewport0, member, i))
  327.           end
  328.         end
  329.       end
  330.       if CCOA_CATER_COMPATIBLE and $game_train.actors != nil
  331.         for member in $game_train.actors
  332.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  333.             @ombrelist.push(Sprite_Shadow.new(@viewport0, member, i))
  334.           end
  335.         end
  336.       end
  337.       if TRICKSTER_CATER_COMPATIBLE and $game_party.followers != nil
  338.         for member in $game_party.followers
  339.           for i in 0...$game_temp.shadow_spriteset.shadows.size
  340.             @ombrelist.push(Sprite_Shadow.new(@viewport0, member, i))
  341.           end
  342.         end
  343.       end
  344.       #===================================================
  345.       # ** End of the compatibility
  346.       #===================================================      
  347.     end
  348.     # Perform the original call
  349.     shadow_initialize(viewport, @character)
  350.   end
  351.   #--------------------------------------------------------------------------
  352.   # * Frame Update
  353.   #--------------------------------------------------------------------------
  354.   def update
  355.     shadow_update
  356.     if @ombrelist != []
  357.       for i in [email protected]
  358.         @ombrelist[i].update

  359.       end
  360.     end
  361.   end  
  362. end



  363. #==============================================================================
  364. # ** Game_Event
  365. #------------------------------------------------------------------------------
  366. #  This class deals with events. It handles functions including event page
  367. #  switching via condition determinants, and running parallel process events.
  368. #  It's used within the Game_Map class.
  369. #==============================================================================

  370. class Game_Event < Game_Character
  371.   #--------------------------------------------------------------------------
  372.   # * Public Instance Variables
  373.   #--------------------------------------------------------------------------
  374.   attr_accessor :id
  375. end



  376. #==============================================================================
  377. # ** Spriteset_Map
  378. #------------------------------------------------------------------------------
  379. #  This class brings together map screen sprites, tilemaps, etc.
  380. #  It's used within the Scene_Map class.
  381. #==============================================================================

  382. class Spriteset_Map
  383.   #--------------------------------------------------------------------------
  384.   # * Public Instance Variables
  385.   #--------------------------------------------------------------------------  
  386.   attr_accessor :shadows
  387.   #--------------------------------------------------------------------------
  388.   # * Alias Listings
  389.   #--------------------------------------------------------------------------  
  390.   alias shadow_initialize initialize
  391.   #--------------------------------------------------------------------------
  392.   # * Object Initialization
  393.   #--------------------------------------------------------------------------  
  394.   def initialize
  395.     $game_temp.shadow_spriteset = self
  396.     @shadows = []
  397.     warn = false
  398.     for k in $game_map.events.keys.sort
  399.       if ($game_map.events[k].list != nil and
  400.             $game_map.events[k].list[0].code == 108 and
  401.             ($game_map.events[k].list[0].parameters == ["s"] or
  402.             $game_map.events[k].list[0].parameters == ["o"]))
  403.         warn = true        
  404.       end
  405.       params = XPML.XPML_read("Shadow Source", k, 5)
  406.       if params != nil
  407.         $game_temp.shadow_spriteset.shadows.push([$game_map.events[k]] + params)
  408.       end
  409.     end
  410.     if warn == true and SHADOW_WARN
  411.       p "Warning : At least one event on this map uses an obsolete way to add shadows"
  412.     end
  413.     # Perform the original call
  414.     shadow_initialize
  415.   end  
  416. end



  417. #==============================================================================
  418. # ** module XPML
  419. #------------------------------------------------------------------------------
  420. #  This module handles the reading and passing of 'comment' parameters
  421. #
  422. #  The main XPML method is used to check and read event comments.
  423. #  * It returns 'nil' if the markup 'check' text isn't even present.
  424. #  * It returns [] if no parameters are passed
  425. #  * It returns a parameter list with "int" converted as int.
  426. #       eg :
  427. #       begin first
  428. #       begin second
  429. #       param1 1
  430. #       param2 two
  431. #       begin third
  432. #       anything 3
  433. #
  434. #   p XPML_read("first", event_id) -> []
  435. #   p XPML_read("second", event_id) -> [1,"two"]
  436. #   p XPML_read("third", event_id) -> [3]
  437. #   p XPML_read("forth", event_id) -> nil
  438. #===================================================

  439. module XPML
  440.   module_function
  441.   #--------------------------------------------------------------------------
  442.   # * XPML_read
  443.   #     markup           : text in event comment to check
  444.   #     event_id         : event ID
  445.   #     max_param_number : maximum number of parameter/comments to load
  446.   #--------------------------------------------------------------------------  
  447.   def XPML_read(markup, event_id, max_param_number = 0)
  448.     parameter_list = nil
  449.     event = $game_map.events[event_id]
  450.     return if event.list == nil
  451.       for i in 0...event.list.size
  452.         if event.list[i].code == 108 and
  453.           event.list[i].parameters[0].downcase == "begin " + markup.downcase
  454.           parameter_list = [] if parameter_list == nil
  455.           for j in i + 1...event.list.size
  456.             if event.list[j].code == 108
  457.               parts = event.list[j].parameters[0].split
  458.               if parts.size != 1 and parts[0].downcase != "begin"
  459.                 if parts[1].to_i != 0 or parts[1] == "0"
  460.                   parameter_list.push(parts[1].to_i)
  461.                 else
  462.                   parameter_list.push(parts[1])
  463.                 end
  464.               else
  465.                 return parameter_list
  466.               end
  467.             else
  468.               return parameter_list
  469.             end
  470.             if max_param_number != 0 and j == i + max_param_number
  471.               return parameter_list
  472.             end
  473.           end
  474.         end
  475.       end
  476.     return parameter_list
  477.   end
  478. end
复制代码


地图人物显示信息
http://www.rpgmakervx.net/index.php?showtopic=2453

状态窗口,血条描绘比较神奇,是版弧度的~~
http://www.rpgmakervx.net/index.php?showtopic=3151

作者: 偶尔杀人越货    时间: 2008-12-1 20:17
都是不错的脚本,感兴趣,我正考虑翻译其中的一两个
作者: king    时间: 2008-12-1 20:30
以下引用偶尔杀人越货于2008-12-1 12:17:39的发言:

都是不错的脚本,感兴趣,我正考虑翻译其中的一两个

真的~~~翻译影子吧~~{/qiang}
不枉费我把它的3个脚本贴出来……{/cy}
作者: 纯子    时间: 2008-12-1 21:02
oh my god 效果惊人啊{/fd}{/fd}
作者: 疯鸡瘫圣老贱    时间: 2008-12-2 05:45
提示: 作者被禁止或删除 内容自动屏蔽
作者: 沉影不器    时间: 2008-12-2 05:48
提示: 作者被禁止或删除 内容自动屏蔽
作者: 雪流星    时间: 2008-12-2 18:24
以下引用沉影不器于2008-12-1 21:48:20的发言:
很奇特的影子效果啊...看起来系统开销应该不小.
是否支持多光源?比如玩实况时开启灯光能看到4个影子

看截圖應該支持多光源
左邊的火爐和右邊的蠟燭
甚至還能設定不同光源的遠近和強度影響
.....所以一定會佔用很多資源吧
作者: 偶尔杀人越货    时间: 2008-12-3 01:15
光源多了影子会混乱也说不定,不过这个脚本仍然不错,影子的叠加是很复杂的事情
作者: 越前リョーマ    时间: 2008-12-3 01:38
那个影子的效果实在太赞了。{/qiang}
作者: 光的圆周率    时间: 2008-12-6 02:50
地图人物显示信息
很早以前就汉化了

状态窗口,血条描绘比较神奇,是版弧度的~~


看过了 完全不知道怎么调用,总是没反应 就抛弃了 并且圆弧都很有锯齿

影子效果的话其实不用翻译 直接调用就可以了个人觉得CYBQ的那个效果也不错
作者: ONEWateR    时间: 2008-12-7 10:28
全都是宝……{/se}

外国达人 {/qiang}
作者: 精灵使者    时间: 2008-12-9 17:55
精灵准备完美翻译加范例工程,这效果真是太棒了。
作者: 殲滅天使·玲    时间: 2008-12-10 05:51
我多嘴了.谢谢精灵......{/gg}
作者: 精灵使者    时间: 2008-12-10 09:51
翻译已经全部完工……无奈复制文本老出问题。说明和注释都完美汉化,等明天放范例工程 [LINE]1,#dddddd[/LINE]系统信息:本贴由楼主认可为正确答案,66RPG感谢您的热情解答~
作者: 过眼云烟    时间: 2010-8-10 13:02
话说真希望能有xp的:lol




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